Skip to content

Commit 058754a

Browse files
committed
πŸŽ‰ Add react filters-bar module
1 parent 2bda8ac commit 058754a

5 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/dist
3+
/coverage
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@cloudwalker/react-filters-bar",
3+
"version": "0.0.0",
4+
"files": [
5+
"dist/**"
6+
],
7+
"main": "./dist/main.js",
8+
"module": "./dist/main.mjs",
9+
"types": "./dist/main.d.ts",
10+
"sideEffects": false,
11+
"author": {
12+
"name": "Luca Barone",
13+
"email": "baro.luc@gmail.com",
14+
"url": "https://github.com/cloud-walker"
15+
},
16+
"publishConfig": {
17+
"access": "public"
18+
},
19+
"devDependencies": {
20+
"react": "^18.2.0"
21+
}
22+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createContext, PropsWithChildren, useContext } from "react";
2+
3+
type FilterState = {
4+
remove: () => void;
5+
setOperator: (value: string) => void;
6+
setValue: (value: string) => void;
7+
operator: string;
8+
value: string;
9+
};
10+
11+
const FilterCtx = createContext<FilterState | null>(null);
12+
13+
export function useFilterCtx() {
14+
const ctx = useContext(FilterCtx);
15+
if (ctx == null) {
16+
throw Error("FilterCtx.Provider is missing.");
17+
}
18+
return ctx;
19+
}
20+
21+
export function FilterProvider({
22+
children,
23+
...props
24+
}: PropsWithChildren<Provider>) {
25+
return <FilterCtx.Provider value={props}>{children}</FilterCtx.Provider>;
26+
}

β€Žpackages/react-filters-bar/src/main.tsβ€Ž

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"jsx": "react-jsx",
5+
"noUncheckedIndexedAccess": true
6+
},
7+
"include": ["src"]
8+
}

0 commit comments

Comments
Β (0)