@arkyn/components 3.0.1-beta.22 → 3.0.1-beta.24
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/README.md +265 -0
- package/dist/bundle.js +1485 -859
- package/dist/bundle.umd.cjs +1 -1
- package/dist/components/audioUpload/hasFileContent/index.d.ts +13 -0
- package/dist/components/audioUpload/hasFileContent/index.d.ts.map +1 -0
- package/dist/components/audioUpload/hasFileContent/index.js +26 -0
- package/dist/components/audioUpload/index.d.ts +82 -0
- package/dist/components/audioUpload/index.d.ts.map +1 -0
- package/dist/components/audioUpload/index.js +120 -0
- package/dist/components/audioUpload/noFileContent/index.d.ts +12 -0
- package/dist/components/audioUpload/noFileContent/index.d.ts.map +1 -0
- package/dist/components/audioUpload/noFileContent/index.js +29 -0
- package/dist/components/clientOnly.d.ts +86 -0
- package/dist/components/clientOnly.d.ts.map +1 -0
- package/dist/components/clientOnly.js +86 -0
- package/dist/components/fileUpload/hasFileContent/index.d.ts +13 -0
- package/dist/components/fileUpload/hasFileContent/index.d.ts.map +1 -0
- package/dist/components/fileUpload/hasFileContent/index.js +34 -0
- package/dist/components/fileUpload/index.d.ts +94 -0
- package/dist/components/fileUpload/index.d.ts.map +1 -0
- package/dist/components/fileUpload/index.js +127 -0
- package/dist/components/fileUpload/noFileContent/index.d.ts +12 -0
- package/dist/components/fileUpload/noFileContent/index.d.ts.map +1 -0
- package/dist/components/fileUpload/noFileContent/index.js +29 -0
- package/dist/components/imageUpload/hasFileContent/index.d.ts +13 -0
- package/dist/components/imageUpload/hasFileContent/index.d.ts.map +1 -0
- package/dist/components/imageUpload/hasFileContent/index.js +24 -0
- package/dist/components/imageUpload/index.d.ts +114 -0
- package/dist/components/imageUpload/index.d.ts.map +1 -0
- package/dist/components/imageUpload/index.js +148 -0
- package/dist/components/imageUpload/noFileContent/index.d.ts +12 -0
- package/dist/components/imageUpload/noFileContent/index.d.ts.map +1 -0
- package/dist/components/imageUpload/noFileContent/index.js +29 -0
- package/dist/components/tab/tabContainer/index.d.ts +1 -1
- package/dist/components/tab/tabContainer/index.d.ts.map +1 -1
- package/dist/components/table/tableBody/index.d.ts +67 -0
- package/dist/components/table/tableBody/index.d.ts.map +1 -0
- package/dist/components/table/tableBody/index.js +69 -0
- package/dist/components/table/tableCaption/index.d.ts +62 -0
- package/dist/components/table/tableCaption/index.d.ts.map +1 -0
- package/dist/components/table/tableCaption/index.js +64 -0
- package/dist/components/table/tableContainer/index.d.ts +64 -0
- package/dist/components/table/tableContainer/index.d.ts.map +1 -0
- package/dist/components/table/tableContainer/index.js +66 -0
- package/dist/components/table/tableFooter/index.d.ts +45 -0
- package/dist/components/table/tableFooter/index.d.ts.map +1 -0
- package/dist/components/table/tableFooter/index.js +47 -0
- package/dist/components/table/tableHeader/index.d.ts +44 -0
- package/dist/components/table/tableHeader/index.d.ts.map +1 -0
- package/dist/components/table/tableHeader/index.js +46 -0
- package/dist/components/tooltip/index.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/hooks/useDrawer.d.ts +86 -0
- package/dist/hooks/useDrawer.d.ts.map +1 -0
- package/dist/hooks/useDrawer.js +20 -0
- package/dist/hooks/useHydrated.d.ts +76 -0
- package/dist/hooks/useHydrated.d.ts.map +1 -0
- package/dist/hooks/useHydrated.js +81 -0
- package/dist/hooks/useModal.d.ts +81 -0
- package/dist/hooks/useModal.d.ts.map +1 -0
- package/dist/hooks/useModal.js +20 -0
- package/dist/hooks/useToast.d.ts +70 -0
- package/dist/hooks/useToast.d.ts.map +1 -0
- package/dist/hooks/useToast.js +72 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/providers/drawerProvider.d.ts +106 -0
- package/dist/providers/drawerProvider.d.ts.map +1 -0
- package/dist/providers/drawerProvider.js +120 -0
- package/dist/providers/modalProvider.d.ts +103 -0
- package/dist/providers/modalProvider.d.ts.map +1 -0
- package/dist/providers/modalProvider.js +119 -0
- package/dist/providers/toastProvider.d.ts +48 -0
- package/dist/providers/toastProvider.d.ts.map +1 -0
- package/dist/providers/toastProvider.js +73 -0
- package/dist/style.css +1 -1
- package/package.json +21 -3
@@ -0,0 +1,81 @@
|
|
1
|
+
import { ModalContextProps } from "../providers/modalProvider";
|
2
|
+
type OpenModalProps<T = any> = (data?: T) => void;
|
3
|
+
/**
|
4
|
+
* useModal hook - provides access to modal context for managing modal state and data
|
5
|
+
*
|
6
|
+
* @param key - Optional modal identifier key. When provided, returns functions for a specific modal
|
7
|
+
*
|
8
|
+
* @returns When called without key: Complete modal context with all modal management functions
|
9
|
+
* @returns When called with key: Object containing modal-specific functions:
|
10
|
+
* - `modalIsOpen`: Boolean indicating if the specific modal is open
|
11
|
+
* - `modalData`: Data associated with the specific modal
|
12
|
+
* - `openModal`: Function to open the specific modal with optional data
|
13
|
+
* - `closeModal`: Function to close the specific modal
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* ```tsx
|
17
|
+
* // Basic usage - access to full modal context
|
18
|
+
* function ModalManager() {
|
19
|
+
* const modalContext = useModal();
|
20
|
+
*
|
21
|
+
* return (
|
22
|
+
* <div>
|
23
|
+
* <button onClick={() => modalContext.openModal('user-details', { id: 1 })}>
|
24
|
+
* Open User Modal
|
25
|
+
* </button>
|
26
|
+
* </div>
|
27
|
+
* );
|
28
|
+
* }
|
29
|
+
*
|
30
|
+
* // Usage with specific modal key
|
31
|
+
* function UserModal() {
|
32
|
+
* const { modalIsOpen, modalData, openModal, closeModal } = useModal('user-details');
|
33
|
+
*
|
34
|
+
* return (
|
35
|
+
* <Modal isOpen={modalIsOpen} onClose={closeModal}>
|
36
|
+
* <h2>User Details</h2>
|
37
|
+
* <p>User ID: {modalData?.id}</p>
|
38
|
+
* <button onClick={closeModal}>Close</button>
|
39
|
+
* </Modal>
|
40
|
+
* );
|
41
|
+
* }
|
42
|
+
*
|
43
|
+
* // Usage with typed data
|
44
|
+
* interface UserData {
|
45
|
+
* id: number;
|
46
|
+
* name: string;
|
47
|
+
* email: string;
|
48
|
+
* }
|
49
|
+
*
|
50
|
+
* function UserProfileModal() {
|
51
|
+
* const { modalIsOpen, modalData, closeModal } = useModal<UserData>('user-profile');
|
52
|
+
*
|
53
|
+
* return (
|
54
|
+
* <Modal isOpen={modalIsOpen} onClose={closeModal}>
|
55
|
+
* <h2>{modalData?.name}</h2>
|
56
|
+
* <p>Email: {modalData?.email}</p>
|
57
|
+
* </Modal>
|
58
|
+
* );
|
59
|
+
* }
|
60
|
+
*
|
61
|
+
* // Usage with ModalProvider
|
62
|
+
* function App() {
|
63
|
+
* return (
|
64
|
+
* <ModalProvider>
|
65
|
+
* <UserModal />
|
66
|
+
* <UserProfileModal />
|
67
|
+
* <ModalManager />
|
68
|
+
* </ModalProvider>
|
69
|
+
* );
|
70
|
+
* }
|
71
|
+
* ```
|
72
|
+
*/
|
73
|
+
declare function useModal<T = any>(): ModalContextProps<T>;
|
74
|
+
declare function useModal<T = any>(key: string): {
|
75
|
+
modalIsOpen: boolean;
|
76
|
+
modalData: T;
|
77
|
+
openModal: OpenModalProps<T>;
|
78
|
+
closeModal: () => void;
|
79
|
+
};
|
80
|
+
export { useModal };
|
81
|
+
//# sourceMappingURL=useModal.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useModal.d.ts","sourceRoot":"","sources":["../../src/hooks/useModal.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE7E,KAAK,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,iBAAS,QAAQ,CAAC,CAAC,GAAG,GAAG,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAAC;AACnD,iBAAS,QAAQ,CAAC,CAAC,GAAG,GAAG,EACvB,GAAG,EAAE,MAAM,GACV;IACD,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,CAAC,CAAC;IACb,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC7B,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AA6BF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { useContext } from "react";
|
2
|
+
import { modalContext } from "../providers/modalProvider";
|
3
|
+
function useModal(key) {
|
4
|
+
const contextData = useContext(modalContext);
|
5
|
+
if (Object.entries(contextData).length === 0) {
|
6
|
+
throw new Error("useModal must be used within a Provider");
|
7
|
+
}
|
8
|
+
if (key) {
|
9
|
+
const { modalData: contextModalData, modalIsOpen: contextModalIsOpen, openModal: contextOpenModal, closeModal: contextCloseModal, } = contextData;
|
10
|
+
const modalIsOpen = contextModalIsOpen(key);
|
11
|
+
const modalData = contextModalData(key);
|
12
|
+
const openModal = (data) => contextOpenModal(key, data);
|
13
|
+
const closeModal = () => contextCloseModal(key);
|
14
|
+
return { modalIsOpen, modalData, openModal, closeModal };
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
return contextData;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
export { useModal };
|
@@ -0,0 +1,70 @@
|
|
1
|
+
/**
|
2
|
+
* Custom hook to access toast functionality from ToastProvider context
|
3
|
+
*
|
4
|
+
* @returns Object containing toast methods and state
|
5
|
+
* @returns {function} showToast - Function to display toast notifications
|
6
|
+
*
|
7
|
+
* @throws {Error} Throws an error if used outside of ToastProvider
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* Basic usage:
|
11
|
+
* ```tsx
|
12
|
+
* function MyComponent() {
|
13
|
+
* const { showToast } = useToast();
|
14
|
+
*
|
15
|
+
* const handleSuccess = () => {
|
16
|
+
* showToast({
|
17
|
+
* message: 'Operation completed successfully!',
|
18
|
+
* type: 'success'
|
19
|
+
* });
|
20
|
+
* };
|
21
|
+
*
|
22
|
+
* const handleError = () => {
|
23
|
+
* showToast({
|
24
|
+
* message: 'Something went wrong!',
|
25
|
+
* type: 'danger'
|
26
|
+
* });
|
27
|
+
* };
|
28
|
+
*
|
29
|
+
* return (
|
30
|
+
* <div>
|
31
|
+
* <button onClick={handleSuccess}>Success Toast</button>
|
32
|
+
* <button onClick={handleError}>Error Toast</button>
|
33
|
+
* </div>
|
34
|
+
* );
|
35
|
+
* }
|
36
|
+
* ```
|
37
|
+
*
|
38
|
+
* @example
|
39
|
+
* Using in async operations:
|
40
|
+
* ```tsx
|
41
|
+
* function FormComponent() {
|
42
|
+
* const { showToast } = useToast();
|
43
|
+
*
|
44
|
+
* const handleSubmit = async (data) => {
|
45
|
+
* try {
|
46
|
+
* await submitForm(data);
|
47
|
+
* showToast({
|
48
|
+
* message: 'Form submitted successfully!',
|
49
|
+
* type: 'success'
|
50
|
+
* });
|
51
|
+
* } catch (error) {
|
52
|
+
* showToast({
|
53
|
+
* message: 'Failed to submit form',
|
54
|
+
* type: 'danger'
|
55
|
+
* });
|
56
|
+
* }
|
57
|
+
* };
|
58
|
+
*
|
59
|
+
* return <form onSubmit={handleSubmit}>...</form>;
|
60
|
+
* }
|
61
|
+
* ```
|
62
|
+
*/
|
63
|
+
declare function useToast(): {
|
64
|
+
showToast(toast: {
|
65
|
+
message: string;
|
66
|
+
type: "success" | "danger";
|
67
|
+
}): void;
|
68
|
+
};
|
69
|
+
export { useToast };
|
70
|
+
//# sourceMappingURL=useToast.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useToast.d.ts","sourceRoot":"","sources":["../../src/hooks/useToast.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,iBAAS,QAAQ;;;;;EAQhB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { toastContext } from "../providers/toastProvider";
|
2
|
+
import { useContext } from "react";
|
3
|
+
/**
|
4
|
+
* Custom hook to access toast functionality from ToastProvider context
|
5
|
+
*
|
6
|
+
* @returns Object containing toast methods and state
|
7
|
+
* @returns {function} showToast - Function to display toast notifications
|
8
|
+
*
|
9
|
+
* @throws {Error} Throws an error if used outside of ToastProvider
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* Basic usage:
|
13
|
+
* ```tsx
|
14
|
+
* function MyComponent() {
|
15
|
+
* const { showToast } = useToast();
|
16
|
+
*
|
17
|
+
* const handleSuccess = () => {
|
18
|
+
* showToast({
|
19
|
+
* message: 'Operation completed successfully!',
|
20
|
+
* type: 'success'
|
21
|
+
* });
|
22
|
+
* };
|
23
|
+
*
|
24
|
+
* const handleError = () => {
|
25
|
+
* showToast({
|
26
|
+
* message: 'Something went wrong!',
|
27
|
+
* type: 'danger'
|
28
|
+
* });
|
29
|
+
* };
|
30
|
+
*
|
31
|
+
* return (
|
32
|
+
* <div>
|
33
|
+
* <button onClick={handleSuccess}>Success Toast</button>
|
34
|
+
* <button onClick={handleError}>Error Toast</button>
|
35
|
+
* </div>
|
36
|
+
* );
|
37
|
+
* }
|
38
|
+
* ```
|
39
|
+
*
|
40
|
+
* @example
|
41
|
+
* Using in async operations:
|
42
|
+
* ```tsx
|
43
|
+
* function FormComponent() {
|
44
|
+
* const { showToast } = useToast();
|
45
|
+
*
|
46
|
+
* const handleSubmit = async (data) => {
|
47
|
+
* try {
|
48
|
+
* await submitForm(data);
|
49
|
+
* showToast({
|
50
|
+
* message: 'Form submitted successfully!',
|
51
|
+
* type: 'success'
|
52
|
+
* });
|
53
|
+
* } catch (error) {
|
54
|
+
* showToast({
|
55
|
+
* message: 'Failed to submit form',
|
56
|
+
* type: 'danger'
|
57
|
+
* });
|
58
|
+
* }
|
59
|
+
* };
|
60
|
+
*
|
61
|
+
* return <form onSubmit={handleSubmit}>...</form>;
|
62
|
+
* }
|
63
|
+
* ```
|
64
|
+
*/
|
65
|
+
function useToast() {
|
66
|
+
const contextData = useContext(toastContext);
|
67
|
+
if (Object.entries(contextData).length === 0) {
|
68
|
+
throw new Error("useToast must be used within a Provider");
|
69
|
+
}
|
70
|
+
return contextData;
|
71
|
+
}
|
72
|
+
export { useToast };
|
package/dist/index.d.ts
CHANGED
@@ -4,11 +4,13 @@ export { AlertDescription } from "./components/alert/alertDescription";
|
|
4
4
|
export { AlertIcon } from "./components/alert/alertIcon";
|
5
5
|
export { AlertTitle } from "./components/alert/alertTitle";
|
6
6
|
export { AudioPlayer } from "./components/audioPlayer";
|
7
|
+
export { AudioUpload } from "./components/audioUpload";
|
7
8
|
export { Badge } from "./components/badge";
|
8
9
|
export { Button } from "./components/button";
|
9
10
|
export { CardTabButton } from "./components/cardTab/cardTabButton";
|
10
11
|
export { CardTabContainer } from "./components/cardTab/cardTabContainer";
|
11
12
|
export { Checkbox } from "./components/checkbox";
|
13
|
+
export { ClientOnly } from "./components/clientOnly";
|
12
14
|
export { CurrencyInput } from "./components/currencyInput";
|
13
15
|
export { Divider } from "./components/divider";
|
14
16
|
export { DrawerContainer } from "./components/drawer/drawerContainer";
|
@@ -16,7 +18,9 @@ export { DrawerHeader } from "./components/drawer/drawerHeader";
|
|
16
18
|
export { FieldError } from "./components/fieldError";
|
17
19
|
export { FieldLabel } from "./components/fieldLabel";
|
18
20
|
export { FieldWrapper } from "./components/fieldWrapper";
|
21
|
+
export { FileUpload } from "./components/fileUpload";
|
19
22
|
export { IconButton } from "./components/iconButton";
|
23
|
+
export { ImageUpload } from "./components/imageUpload";
|
20
24
|
export { Input } from "./components/input";
|
21
25
|
export { MaskedInput } from "./components/maskedInput";
|
22
26
|
export { ModalContainer } from "./components/modal/modalContainer";
|
@@ -30,11 +34,21 @@ export { Slider } from "./components/slider";
|
|
30
34
|
export { Switch } from "./components/switch";
|
31
35
|
export { TabButton } from "./components/tab/tabButton";
|
32
36
|
export { TabContainer } from "./components/tab/tabContainer";
|
37
|
+
export { TableBody } from "./components/table/tableBody";
|
38
|
+
export { TableCaption } from "./components/table/tableCaption";
|
39
|
+
export { TableContainer } from "./components/table/tableContainer";
|
40
|
+
export { TableFooter } from "./components/table/tableFooter";
|
41
|
+
export { TableHeader } from "./components/table/tableHeader";
|
33
42
|
export { Textarea } from "./components/textarea";
|
34
43
|
export { Tooltip } from "./components/tooltip";
|
44
|
+
export { useDrawer } from "./hooks/useDrawer";
|
35
45
|
export { useForm } from "./hooks/useForm";
|
46
|
+
export { useHydrated } from "./hooks/useHydrated";
|
47
|
+
export { useModal } from "./hooks/useModal";
|
36
48
|
export { useScopedParams } from "./hooks/useScopedParams";
|
37
49
|
export { useScrollLock } from "./hooks/useScrollLock";
|
38
50
|
export { useSlider } from "./hooks/useSlider";
|
51
|
+
export { DrawerProvider } from "./providers/drawerProvider";
|
39
52
|
export { FormProvider } from "./providers/formProvider";
|
53
|
+
export { ModalProvider } from "./providers/modalProvider";
|
40
54
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAA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AAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
@@ -5,11 +5,13 @@ export { AlertDescription } from "./components/alert/alertDescription";
|
|
5
5
|
export { AlertIcon } from "./components/alert/alertIcon";
|
6
6
|
export { AlertTitle } from "./components/alert/alertTitle";
|
7
7
|
export { AudioPlayer } from "./components/audioPlayer";
|
8
|
+
export { AudioUpload } from "./components/audioUpload";
|
8
9
|
export { Badge } from "./components/badge";
|
9
10
|
export { Button } from "./components/button";
|
10
11
|
export { CardTabButton } from "./components/cardTab/cardTabButton";
|
11
12
|
export { CardTabContainer } from "./components/cardTab/cardTabContainer";
|
12
13
|
export { Checkbox } from "./components/checkbox";
|
14
|
+
export { ClientOnly } from "./components/clientOnly";
|
13
15
|
export { CurrencyInput } from "./components/currencyInput";
|
14
16
|
export { Divider } from "./components/divider";
|
15
17
|
export { DrawerContainer } from "./components/drawer/drawerContainer";
|
@@ -17,7 +19,9 @@ export { DrawerHeader } from "./components/drawer/drawerHeader";
|
|
17
19
|
export { FieldError } from "./components/fieldError";
|
18
20
|
export { FieldLabel } from "./components/fieldLabel";
|
19
21
|
export { FieldWrapper } from "./components/fieldWrapper";
|
22
|
+
export { FileUpload } from "./components/fileUpload";
|
20
23
|
export { IconButton } from "./components/iconButton";
|
24
|
+
export { ImageUpload } from "./components/imageUpload";
|
21
25
|
export { Input } from "./components/input";
|
22
26
|
export { MaskedInput } from "./components/maskedInput";
|
23
27
|
export { ModalContainer } from "./components/modal/modalContainer";
|
@@ -31,12 +35,22 @@ export { Slider } from "./components/slider";
|
|
31
35
|
export { Switch } from "./components/switch";
|
32
36
|
export { TabButton } from "./components/tab/tabButton";
|
33
37
|
export { TabContainer } from "./components/tab/tabContainer";
|
38
|
+
export { TableBody } from "./components/table/tableBody";
|
39
|
+
export { TableCaption } from "./components/table/tableCaption";
|
40
|
+
export { TableContainer } from "./components/table/tableContainer";
|
41
|
+
export { TableFooter } from "./components/table/tableFooter";
|
42
|
+
export { TableHeader } from "./components/table/tableHeader";
|
34
43
|
export { Textarea } from "./components/textarea";
|
35
44
|
export { Tooltip } from "./components/tooltip";
|
36
45
|
// hooks
|
46
|
+
export { useDrawer } from "./hooks/useDrawer";
|
37
47
|
export { useForm } from "./hooks/useForm";
|
48
|
+
export { useHydrated } from "./hooks/useHydrated";
|
49
|
+
export { useModal } from "./hooks/useModal";
|
38
50
|
export { useScopedParams } from "./hooks/useScopedParams";
|
39
51
|
export { useScrollLock } from "./hooks/useScrollLock";
|
40
52
|
export { useSlider } from "./hooks/useSlider";
|
41
53
|
// providers
|
54
|
+
export { DrawerProvider } from "./providers/drawerProvider";
|
42
55
|
export { FormProvider } from "./providers/formProvider";
|
56
|
+
export { ModalProvider } from "./providers/modalProvider";
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import { ReactNode } from "react";
|
2
|
+
type DrawerContextProps<T = any> = {
|
3
|
+
drawerIsOpen(key: string): boolean;
|
4
|
+
drawerData(key: string): T;
|
5
|
+
openDrawer(key: string, data?: T): void;
|
6
|
+
closeDrawer(key: string): void;
|
7
|
+
};
|
8
|
+
type DrawerProviderProps = {
|
9
|
+
children: ReactNode;
|
10
|
+
enableDrawerAutomation?: boolean;
|
11
|
+
};
|
12
|
+
declare const drawerContext: import("react").Context<DrawerContextProps<any>>;
|
13
|
+
/**
|
14
|
+
* DrawerProvider component - provides drawer context for managing multiple drawers state and data
|
15
|
+
*
|
16
|
+
* @param props - DrawerProvider component properties
|
17
|
+
* @param props.children - React elements that will have access to the drawer context
|
18
|
+
* @param props.enableDrawerAutomation - Optional flag to enable drawer automation features
|
19
|
+
*
|
20
|
+
* @returns DrawerProvider JSX element that wraps children with drawer context
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* ```tsx
|
24
|
+
* // Basic drawer provider setup
|
25
|
+
* function App() {
|
26
|
+
* return (
|
27
|
+
* <DrawerProvider>
|
28
|
+
* <NavigationDrawer />
|
29
|
+
* <FilterDrawer />
|
30
|
+
* <SettingsDrawer />
|
31
|
+
* <MainContent />
|
32
|
+
* </DrawerProvider>
|
33
|
+
* );
|
34
|
+
* }
|
35
|
+
*
|
36
|
+
* // Drawer provider with automation enabled
|
37
|
+
* function AppWithAutomation() {
|
38
|
+
* return (
|
39
|
+
* <DrawerProvider enableDrawerAutomation={true}>
|
40
|
+
* <Dashboard />
|
41
|
+
* <SidePanel />
|
42
|
+
* <NotificationDrawer />
|
43
|
+
* </DrawerProvider>
|
44
|
+
* );
|
45
|
+
* }
|
46
|
+
*
|
47
|
+
* // Using with multiple drawers
|
48
|
+
* function MultiDrawerApp() {
|
49
|
+
* return (
|
50
|
+
* <DrawerProvider>
|
51
|
+
* <Header />
|
52
|
+
* <NavigationDrawer key="navigation" />
|
53
|
+
* <FilterDrawer key="filters" />
|
54
|
+
* <CartDrawer key="shopping-cart" />
|
55
|
+
* <MainContent />
|
56
|
+
* </DrawerProvider>
|
57
|
+
* );
|
58
|
+
* }
|
59
|
+
*
|
60
|
+
* // Component using drawer context
|
61
|
+
* function DrawerController() {
|
62
|
+
* const { openDrawer, closeDrawer } = useDrawer();
|
63
|
+
*
|
64
|
+
* const handleOpenNavigation = () => {
|
65
|
+
* openDrawer('navigation', { section: 'main-menu' });
|
66
|
+
* };
|
67
|
+
*
|
68
|
+
* const handleOpenFilters = () => {
|
69
|
+
* openDrawer('filters', { category: 'electronics', priceRange: [0, 1000] });
|
70
|
+
* };
|
71
|
+
*
|
72
|
+
* return (
|
73
|
+
* <div>
|
74
|
+
* <button onClick={handleOpenNavigation}>
|
75
|
+
* Open Navigation
|
76
|
+
* </button>
|
77
|
+
* <button onClick={handleOpenFilters}>
|
78
|
+
* Open Filters
|
79
|
+
* </button>
|
80
|
+
* </div>
|
81
|
+
* );
|
82
|
+
* }
|
83
|
+
*
|
84
|
+
* // Drawer component consuming context
|
85
|
+
* function NavigationDrawer() {
|
86
|
+
* const { drawerIsOpen, drawerData, closeDrawer } = useDrawer('navigation');
|
87
|
+
*
|
88
|
+
* if (!drawerIsOpen) return null;
|
89
|
+
*
|
90
|
+
* return (
|
91
|
+
* <Drawer position="left" onClose={() => closeDrawer('navigation')}>
|
92
|
+
* <h2>Navigation</h2>
|
93
|
+
* <p>Current section: {drawerData?.section}</p>
|
94
|
+
* <nav>
|
95
|
+
* <a href="/home">Home</a>
|
96
|
+
* <a href="/products">Products</a>
|
97
|
+
* <a href="/about">About</a>
|
98
|
+
* </nav>
|
99
|
+
* </Drawer>
|
100
|
+
* );
|
101
|
+
* }
|
102
|
+
* ```
|
103
|
+
*/
|
104
|
+
declare function DrawerProvider(args: DrawerProviderProps): import("react/jsx-runtime").JSX.Element;
|
105
|
+
export { drawerContext, DrawerProvider, type DrawerContextProps };
|
106
|
+
//# sourceMappingURL=drawerProvider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"drawerProvider.d.ts","sourceRoot":"","sources":["../../src/providers/drawerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAY,MAAM,OAAO,CAAC;AAE3D,KAAK,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI;IACjC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IAC3B,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACxC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAOF,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,QAAA,MAAM,aAAa,kDAA0C,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AAEH,iBAAS,cAAc,CAAC,IAAI,EAAE,mBAAmB,2CAiChD;AAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,CAAC"}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { createContext, useState } from "react";
|
3
|
+
const drawerContext = createContext({});
|
4
|
+
/**
|
5
|
+
* DrawerProvider component - provides drawer context for managing multiple drawers state and data
|
6
|
+
*
|
7
|
+
* @param props - DrawerProvider component properties
|
8
|
+
* @param props.children - React elements that will have access to the drawer context
|
9
|
+
* @param props.enableDrawerAutomation - Optional flag to enable drawer automation features
|
10
|
+
*
|
11
|
+
* @returns DrawerProvider JSX element that wraps children with drawer context
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* ```tsx
|
15
|
+
* // Basic drawer provider setup
|
16
|
+
* function App() {
|
17
|
+
* return (
|
18
|
+
* <DrawerProvider>
|
19
|
+
* <NavigationDrawer />
|
20
|
+
* <FilterDrawer />
|
21
|
+
* <SettingsDrawer />
|
22
|
+
* <MainContent />
|
23
|
+
* </DrawerProvider>
|
24
|
+
* );
|
25
|
+
* }
|
26
|
+
*
|
27
|
+
* // Drawer provider with automation enabled
|
28
|
+
* function AppWithAutomation() {
|
29
|
+
* return (
|
30
|
+
* <DrawerProvider enableDrawerAutomation={true}>
|
31
|
+
* <Dashboard />
|
32
|
+
* <SidePanel />
|
33
|
+
* <NotificationDrawer />
|
34
|
+
* </DrawerProvider>
|
35
|
+
* );
|
36
|
+
* }
|
37
|
+
*
|
38
|
+
* // Using with multiple drawers
|
39
|
+
* function MultiDrawerApp() {
|
40
|
+
* return (
|
41
|
+
* <DrawerProvider>
|
42
|
+
* <Header />
|
43
|
+
* <NavigationDrawer key="navigation" />
|
44
|
+
* <FilterDrawer key="filters" />
|
45
|
+
* <CartDrawer key="shopping-cart" />
|
46
|
+
* <MainContent />
|
47
|
+
* </DrawerProvider>
|
48
|
+
* );
|
49
|
+
* }
|
50
|
+
*
|
51
|
+
* // Component using drawer context
|
52
|
+
* function DrawerController() {
|
53
|
+
* const { openDrawer, closeDrawer } = useDrawer();
|
54
|
+
*
|
55
|
+
* const handleOpenNavigation = () => {
|
56
|
+
* openDrawer('navigation', { section: 'main-menu' });
|
57
|
+
* };
|
58
|
+
*
|
59
|
+
* const handleOpenFilters = () => {
|
60
|
+
* openDrawer('filters', { category: 'electronics', priceRange: [0, 1000] });
|
61
|
+
* };
|
62
|
+
*
|
63
|
+
* return (
|
64
|
+
* <div>
|
65
|
+
* <button onClick={handleOpenNavigation}>
|
66
|
+
* Open Navigation
|
67
|
+
* </button>
|
68
|
+
* <button onClick={handleOpenFilters}>
|
69
|
+
* Open Filters
|
70
|
+
* </button>
|
71
|
+
* </div>
|
72
|
+
* );
|
73
|
+
* }
|
74
|
+
*
|
75
|
+
* // Drawer component consuming context
|
76
|
+
* function NavigationDrawer() {
|
77
|
+
* const { drawerIsOpen, drawerData, closeDrawer } = useDrawer('navigation');
|
78
|
+
*
|
79
|
+
* if (!drawerIsOpen) return null;
|
80
|
+
*
|
81
|
+
* return (
|
82
|
+
* <Drawer position="left" onClose={() => closeDrawer('navigation')}>
|
83
|
+
* <h2>Navigation</h2>
|
84
|
+
* <p>Current section: {drawerData?.section}</p>
|
85
|
+
* <nav>
|
86
|
+
* <a href="/home">Home</a>
|
87
|
+
* <a href="/products">Products</a>
|
88
|
+
* <a href="/about">About</a>
|
89
|
+
* </nav>
|
90
|
+
* </Drawer>
|
91
|
+
* );
|
92
|
+
* }
|
93
|
+
* ```
|
94
|
+
*/
|
95
|
+
function DrawerProvider(args) {
|
96
|
+
const { children = false } = args;
|
97
|
+
const [openedDrawers, setOpenedDrawers] = useState([]);
|
98
|
+
function drawerIsOpen(key) {
|
99
|
+
return !!openedDrawers.some((drawer) => drawer.key === key);
|
100
|
+
}
|
101
|
+
function drawerData(key) {
|
102
|
+
return openedDrawers.find((drawer) => drawer.key === key)?.data;
|
103
|
+
}
|
104
|
+
function openDrawer(key, data) {
|
105
|
+
const alreadyExist = drawerIsOpen(key);
|
106
|
+
if (alreadyExist) {
|
107
|
+
setOpenedDrawers((old) => {
|
108
|
+
const filtered = old.filter((drawer) => drawer.key !== key);
|
109
|
+
return [...filtered, { key, data }];
|
110
|
+
});
|
111
|
+
}
|
112
|
+
else
|
113
|
+
setOpenedDrawers([...openedDrawers, { key, data }]);
|
114
|
+
}
|
115
|
+
function closeDrawer(key) {
|
116
|
+
setOpenedDrawers(openedDrawers.filter((drawer) => drawer.key !== key));
|
117
|
+
}
|
118
|
+
return (_jsx(drawerContext.Provider, { value: { drawerIsOpen, drawerData, openDrawer, closeDrawer }, children: children }));
|
119
|
+
}
|
120
|
+
export { drawerContext, DrawerProvider };
|