@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@judo/components",
3
- "version": "0.1.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.1",
46
- "@judo/data-api-common": "^0.1.1",
47
- "@judo/utilities": "^0.1.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.0",
51
- "@judo/utilities": "^0.1.0",
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": "50597933c6eea1fca6eabe8c72e45869e7ca81f6"
62
+ "gitHead": "d1035fe597d84bf6b73d93264486b5f11c0f11d3"
63
63
  }
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useState } from 'react';
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
- // @ts-ignore
19
- const PageDialogContextState = createContext<PageDialogProviderContext>();
20
-
21
- // @ts-ignore
22
- const ConfirmDialogContextState = createContext<ConfirmDialogProviderContext>();
23
-
24
- // @ts-ignore
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 './DialogContext';
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
+ };
@@ -1,5 +1,5 @@
1
1
  export * from './ConfirmationDialog';
2
- export * from './DialogContext';
2
+ export * from './DialogProvider';
3
3
  export * from './FilterDialog';
4
4
  export * from './PageDialog';
5
5
  export * from './RangeDialog';