@judo/components 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components.cjs +1 -1
- package/dist/cjs/components.cjs.map +1 -1
- package/dist/components.d.cts +2 -6
- package/dist/components.d.mts +2 -6
- package/dist/esm/components.mjs +1 -1
- package/dist/esm/components.mjs.map +1 -1
- package/package.json +7 -7
- package/src/dialog/{DialogContext.tsx → DialogProvider.tsx} +9 -57
- package/src/dialog/RangeDialog.tsx +1 -1
- package/src/dialog/hooks.tsx +59 -0
- package/src/dialog/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@judo/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/components.cjs",
|
|
6
6
|
"module": "./dist/esm/components.mjs",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"url": "https://github.com/BlackBeltTechnology/judo-web-toolbox/issues"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@judo/components-api": "^0.1.
|
|
46
|
-
"@judo/data-api-common": "^0.1.
|
|
47
|
-
"@judo/utilities": "^0.1.
|
|
45
|
+
"@judo/components-api": "^0.1.2",
|
|
46
|
+
"@judo/data-api-common": "^0.1.2",
|
|
47
|
+
"@judo/utilities": "^0.1.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@judo/theme": "^0.1.
|
|
51
|
-
"@judo/utilities": "^0.1.
|
|
50
|
+
"@judo/theme": "^0.1.1",
|
|
51
|
+
"@judo/utilities": "^0.1.1",
|
|
52
52
|
"@mdi/js": "^6.7.96",
|
|
53
53
|
"@mdi/react": "^1.6.0",
|
|
54
54
|
"@mui/icons-material": "^5.6.2",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"react": "^18.1.0",
|
|
60
60
|
"react-router-dom": "^6.3.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "d1035fe597d84bf6b73d93264486b5f11c0f11d3"
|
|
63
63
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { ConfirmationDialog } from './ConfirmationDialog';
|
|
4
4
|
import { FilterDialog } from './FilterDialog';
|
|
@@ -14,60 +14,14 @@ import type {
|
|
|
14
14
|
} from '@judo/components-api';
|
|
15
15
|
import type { Filter, FilterOption } from '@judo/components-api';
|
|
16
16
|
import type { JudoStored, QueryCustomizer } from '@judo/data-api-common';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const RangeDialogContextState = createContext<RangeDialogProviderContext>();
|
|
26
|
-
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
const FilterDialogContextState = createContext<FilterDialogProviderContext>();
|
|
29
|
-
|
|
30
|
-
const usePageDialog = () => {
|
|
31
|
-
const context = useContext(PageDialogContextState);
|
|
32
|
-
|
|
33
|
-
if (context === undefined) {
|
|
34
|
-
throw new Error('useConfirmDialog was used outside of its Provider');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return context;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const useConfirmDialog = () => {
|
|
41
|
-
const context = useContext(ConfirmDialogContextState);
|
|
42
|
-
|
|
43
|
-
if (context === undefined) {
|
|
44
|
-
throw new Error('useConfirmDialog was used outside of its Provider');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return context;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const useRangeDialog = () => {
|
|
51
|
-
const context = useContext(RangeDialogContextState);
|
|
52
|
-
|
|
53
|
-
if (context === undefined) {
|
|
54
|
-
throw new Error('useRangeDialog was used outside of its Provider');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return context;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const useFilterDialog = () => {
|
|
61
|
-
const context = useContext(FilterDialogContextState);
|
|
62
|
-
|
|
63
|
-
if (context === undefined) {
|
|
64
|
-
throw new Error('useFilterDialog was used outside of its Provider');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return context;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const DialogProvider = ({ children }: DialogProviderProps) => {
|
|
17
|
+
import {
|
|
18
|
+
ConfirmDialogContextState,
|
|
19
|
+
FilterDialogContextState,
|
|
20
|
+
PageDialogContextState,
|
|
21
|
+
RangeDialogContextState,
|
|
22
|
+
} from './hooks';
|
|
23
|
+
|
|
24
|
+
export const DialogProvider = ({ children }: DialogProviderProps) => {
|
|
71
25
|
// Page Dialog
|
|
72
26
|
const [isOpenPageDialog, setIsOpenPageDialog] = useState(false);
|
|
73
27
|
const [pageDialog, setPageDialog] = useState<ReactNode>();
|
|
@@ -202,5 +156,3 @@ const DialogProvider = ({ children }: DialogProviderProps) => {
|
|
|
202
156
|
</PageDialogContextState.Provider>
|
|
203
157
|
);
|
|
204
158
|
};
|
|
205
|
-
|
|
206
|
-
export { DialogProvider, useConfirmDialog, useRangeDialog, useFilterDialog, usePageDialog };
|
|
@@ -16,7 +16,7 @@ import type { JudoStored, QueryCustomizer } from '@judo/data-api-common';
|
|
|
16
16
|
import type { Filter, FilterOption } from '@judo/components-api';
|
|
17
17
|
import { errorHandling } from '@judo/utilities';
|
|
18
18
|
import { CustomTablePagination } from '../CustomTablePagination';
|
|
19
|
-
import { useFilterDialog } from './
|
|
19
|
+
import { useFilterDialog } from './hooks';
|
|
20
20
|
|
|
21
21
|
interface RangeDialogProps<T extends JudoStored<T>, U extends QueryCustomizer<T>> {
|
|
22
22
|
resolve: (value: any) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ConfirmDialogProviderContext,
|
|
4
|
+
FilterDialogProviderContext,
|
|
5
|
+
PageDialogProviderContext,
|
|
6
|
+
RangeDialogProviderContext,
|
|
7
|
+
} from '@judo/components-api';
|
|
8
|
+
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
export const PageDialogContextState = createContext<PageDialogProviderContext>();
|
|
11
|
+
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
export const ConfirmDialogContextState = createContext<ConfirmDialogProviderContext>();
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
export const RangeDialogContextState = createContext<RangeDialogProviderContext>();
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
export const FilterDialogContextState = createContext<FilterDialogProviderContext>();
|
|
20
|
+
|
|
21
|
+
export const useFilterDialog = () => {
|
|
22
|
+
const context = useContext(FilterDialogContextState);
|
|
23
|
+
|
|
24
|
+
if (context === undefined) {
|
|
25
|
+
throw new Error('useFilterDialog was used outside of its Provider');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return context;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const usePageDialog = () => {
|
|
32
|
+
const context = useContext(PageDialogContextState);
|
|
33
|
+
|
|
34
|
+
if (context === undefined) {
|
|
35
|
+
throw new Error('useConfirmDialog was used outside of its Provider');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return context;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const useConfirmDialog = () => {
|
|
42
|
+
const context = useContext(ConfirmDialogContextState);
|
|
43
|
+
|
|
44
|
+
if (context === undefined) {
|
|
45
|
+
throw new Error('useConfirmDialog was used outside of its Provider');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return context;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const useRangeDialog = () => {
|
|
52
|
+
const context = useContext(RangeDialogContextState);
|
|
53
|
+
|
|
54
|
+
if (context === undefined) {
|
|
55
|
+
throw new Error('useRangeDialog was used outside of its Provider');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return context;
|
|
59
|
+
};
|
package/src/dialog/index.tsx
CHANGED