@arkyn/components 3.0.1-beta.142 → 3.0.1-beta.144
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/bundle.css +1 -1
- package/dist/components/alert/alertContainer/index.d.ts +27 -43
- package/dist/components/alert/alertContainer/index.d.ts.map +1 -1
- package/dist/components/alert/alertContainer/index.js +20 -40
- package/dist/components/alert/alertContent/index.d.ts +11 -36
- package/dist/components/alert/alertContent/index.d.ts.map +1 -1
- package/dist/components/alert/alertContent/index.js +11 -31
- package/dist/components/alert/alertDescription/index.d.ts +10 -38
- package/dist/components/alert/alertDescription/index.d.ts.map +1 -1
- package/dist/components/alert/alertDescription/index.js +10 -33
- package/dist/components/alert/alertIcon/index.d.ts +14 -38
- package/dist/components/alert/alertIcon/index.d.ts.map +1 -1
- package/dist/components/alert/alertIcon/index.js +14 -32
- package/dist/components/alert/alertTitle/index.d.ts +12 -35
- package/dist/components/alert/alertTitle/index.d.ts.map +1 -1
- package/dist/components/alert/alertTitle/index.js +12 -27
- package/dist/components/audioPlayer/index.d.ts +24 -32
- package/dist/components/audioPlayer/index.d.ts.map +1 -1
- package/dist/components/audioPlayer/index.js +15 -18
- package/dist/components/audioUpload/index.d.ts +37 -48
- package/dist/components/audioUpload/index.d.ts.map +1 -1
- package/dist/components/audioUpload/index.js +23 -48
- package/dist/components/badge/index.d.ts +31 -22
- package/dist/components/badge/index.d.ts.map +1 -1
- package/dist/components/badge/index.js +14 -22
- package/dist/components/button/index.d.ts +38 -28
- package/dist/components/button/index.d.ts.map +1 -1
- package/dist/components/button/index.js +18 -28
- package/dist/components/cardTab/cardTabButton/index.d.ts +14 -52
- package/dist/components/cardTab/cardTabButton/index.d.ts.map +1 -1
- package/dist/components/cardTab/cardTabButton/index.js +12 -52
- package/dist/components/cardTab/cardTabContainer/index.d.ts +16 -58
- package/dist/components/cardTab/cardTabContainer/index.d.ts.map +1 -1
- package/dist/components/cardTab/cardTabContainer/index.js +12 -58
- package/dist/components/checkbox/index.d.ts +38 -37
- package/dist/components/checkbox/index.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +21 -37
- package/dist/components/clientOnly.d.ts +13 -66
- package/dist/components/clientOnly.d.ts.map +1 -1
- package/dist/components/clientOnly.js +11 -66
- package/dist/components/currencyInput/index.d.ts +67 -50
- package/dist/components/currencyInput/index.d.ts.map +1 -1
- package/dist/components/currencyInput/index.js +28 -50
- package/dist/components/divider/index.d.ts +12 -25
- package/dist/components/divider/index.d.ts.map +1 -1
- package/dist/components/divider/index.js +8 -25
- package/dist/components/drawer/drawerContainer/index.d.ts +16 -50
- package/dist/components/drawer/drawerContainer/index.d.ts.map +1 -1
- package/dist/components/drawer/drawerContainer/index.js +13 -50
- package/dist/components/drawer/drawerHeader/index.d.ts +9 -33
- package/dist/components/drawer/drawerHeader/index.d.ts.map +1 -1
- package/dist/components/drawer/drawerHeader/index.js +8 -33
- package/dist/components/facebookPixel/index.d.ts +47 -0
- package/dist/components/facebookPixel/index.d.ts.map +1 -1
- package/dist/components/facebookPixel/index.js +35 -0
- package/dist/components/fieldError/index.d.ts +4 -11
- package/dist/components/fieldError/index.d.ts.map +1 -1
- package/dist/components/fieldError/index.js +4 -11
- package/dist/components/fieldLabel/index.d.ts +6 -21
- package/dist/components/fieldLabel/index.d.ts.map +1 -1
- package/dist/components/fieldLabel/index.js +5 -21
- package/dist/components/fieldWrapper/index.d.ts +12 -22
- package/dist/components/fieldWrapper/index.d.ts.map +1 -1
- package/dist/components/fieldWrapper/index.js +7 -22
- package/dist/components/fileUpload/index.d.ts +36 -61
- package/dist/components/fileUpload/index.d.ts.map +1 -1
- package/dist/components/fileUpload/index.js +23 -61
- package/dist/components/googleAnalytics/index.d.ts +11 -7
- package/dist/components/googleAnalytics/index.d.ts.map +1 -1
- package/dist/components/googleAnalytics/index.js +9 -7
- package/dist/components/googleTagManager/index.d.ts +27 -21
- package/dist/components/googleTagManager/index.d.ts.map +1 -1
- package/dist/components/googleTagManager/index.js +20 -21
- package/dist/components/iconButton/index.d.ts +31 -15
- package/dist/components/iconButton/index.d.ts.map +1 -1
- package/dist/components/iconButton/index.js +12 -15
- package/dist/components/imageUpload/index.d.ts +47 -75
- package/dist/components/imageUpload/index.d.ts.map +1 -1
- package/dist/components/imageUpload/index.js +27 -75
- package/dist/components/input/index.d.ts +51 -44
- package/dist/components/input/index.d.ts.map +1 -1
- package/dist/components/input/index.js +24 -44
- package/dist/components/mapView/index.d.ts +44 -0
- package/dist/components/mapView/index.d.ts.map +1 -1
- package/dist/components/mapView/index.js +35 -0
- package/dist/components/maskedInput/index.d.ts +66 -51
- package/dist/components/maskedInput/index.d.ts.map +1 -1
- package/dist/components/maskedInput/index.js +28 -51
- package/dist/components/modal/modalContainer/index.d.ts +17 -57
- package/dist/components/modal/modalContainer/index.d.ts.map +1 -1
- package/dist/components/modal/modalContainer/index.js +15 -57
- package/dist/components/modal/modalFooter/index.d.ts +17 -50
- package/dist/components/modal/modalFooter/index.d.ts.map +1 -1
- package/dist/components/modal/modalFooter/index.js +10 -50
- package/dist/components/modal/modalHeader/index.d.ts +13 -47
- package/dist/components/modal/modalHeader/index.d.ts.map +1 -1
- package/dist/components/modal/modalHeader/index.js +12 -47
- package/dist/components/multiSelect/index.d.ts +67 -62
- package/dist/components/multiSelect/index.d.ts.map +1 -1
- package/dist/components/multiSelect/index.js +28 -62
- package/dist/components/pagination/index.d.ts +18 -9
- package/dist/components/pagination/index.d.ts.map +1 -1
- package/dist/components/pagination/index.js +18 -9
- package/dist/components/phoneInput/index.d.ts +65 -30
- package/dist/components/phoneInput/index.d.ts.map +1 -1
- package/dist/components/phoneInput/index.js +35 -30
- package/dist/components/popover/index.d.ts +34 -114
- package/dist/components/popover/index.d.ts.map +1 -1
- package/dist/components/popover/index.js +25 -114
- package/dist/components/radio/radioBox/index.d.ts +17 -65
- package/dist/components/radio/radioBox/index.d.ts.map +1 -1
- package/dist/components/radio/radioBox/index.js +14 -65
- package/dist/components/radio/radioGroup/index.d.ts +36 -67
- package/dist/components/radio/radioGroup/index.d.ts.map +1 -1
- package/dist/components/radio/radioGroup/index.js +25 -67
- package/dist/components/richText/index.d.ts +33 -47
- package/dist/components/richText/index.d.ts.map +1 -1
- package/dist/components/richText/index.js +30 -44
- package/dist/components/searchPlaces.d.ts +52 -50
- package/dist/components/searchPlaces.d.ts.map +1 -1
- package/dist/components/searchPlaces.js +23 -30
- package/dist/components/select/index.d.ts +68 -63
- package/dist/components/select/index.d.ts.map +1 -1
- package/dist/components/select/index.js +29 -63
- package/dist/components/slider/index.d.ts +20 -34
- package/dist/components/slider/index.d.ts.map +1 -1
- package/dist/components/slider/index.js +15 -33
- package/dist/components/switch/index.d.ts +42 -58
- package/dist/components/switch/index.d.ts.map +1 -1
- package/dist/components/switch/index.js +24 -58
- package/dist/components/tab/tabButton/index.d.ts +14 -52
- package/dist/components/tab/tabButton/index.d.ts.map +1 -1
- package/dist/components/tab/tabButton/index.js +12 -52
- package/dist/components/tab/tabContainer/index.d.ts +16 -58
- package/dist/components/tab/tabContainer/index.d.ts.map +1 -1
- package/dist/components/tab/tabContainer/index.js +12 -58
- package/dist/components/table/tableBody/index.d.ts +13 -47
- package/dist/components/table/tableBody/index.d.ts.map +1 -1
- package/dist/components/table/tableBody/index.js +12 -47
- package/dist/components/table/tableCaption/index.d.ts +6 -46
- package/dist/components/table/tableCaption/index.d.ts.map +1 -1
- package/dist/components/table/tableCaption/index.js +6 -46
- package/dist/components/table/tableContainer/index.d.ts +12 -41
- package/dist/components/table/tableContainer/index.d.ts.map +1 -1
- package/dist/components/table/tableContainer/index.js +12 -41
- package/dist/components/table/tableFooter/index.d.ts +5 -29
- package/dist/components/table/tableFooter/index.d.ts.map +1 -1
- package/dist/components/table/tableFooter/index.js +5 -29
- package/dist/components/table/tableHeader/index.d.ts +4 -25
- package/dist/components/table/tableHeader/index.d.ts.map +1 -1
- package/dist/components/table/tableHeader/index.js +4 -25
- package/dist/components/textarea/index.d.ts +32 -64
- package/dist/components/textarea/index.d.ts.map +1 -1
- package/dist/components/textarea/index.js +16 -64
- package/dist/components/tooltip/index.d.ts +27 -55
- package/dist/components/tooltip/index.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +16 -55
- package/dist/hooks/useAutomation.d.ts +18 -26
- package/dist/hooks/useAutomation.d.ts.map +1 -1
- package/dist/hooks/useAutomation.js +18 -26
- package/dist/hooks/useDrawer.d.ts +19 -64
- package/dist/hooks/useDrawer.d.ts.map +1 -1
- package/dist/hooks/useForm.d.ts +12 -29
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/hooks/useForm.js +12 -29
- package/dist/hooks/useHydrated.d.ts +8 -63
- package/dist/hooks/useHydrated.d.ts.map +1 -1
- package/dist/hooks/useHydrated.js +8 -63
- package/dist/hooks/useModal.d.ts +19 -59
- package/dist/hooks/useModal.d.ts.map +1 -1
- package/dist/hooks/useScopedParams.d.ts +17 -69
- package/dist/hooks/useScopedParams.d.ts.map +1 -1
- package/dist/hooks/useScopedParams.js +17 -69
- package/dist/hooks/useScrollLock.d.ts +11 -27
- package/dist/hooks/useScrollLock.d.ts.map +1 -1
- package/dist/hooks/useScrollLock.js +11 -33
- package/dist/hooks/useSearchAutomation.d.ts +16 -34
- package/dist/hooks/useSearchAutomation.d.ts.map +1 -1
- package/dist/hooks/useSearchAutomation.js +16 -34
- package/dist/hooks/useSlider.d.ts +5 -19
- package/dist/hooks/useSlider.d.ts.map +1 -1
- package/dist/hooks/useSlider.js +5 -19
- package/dist/hooks/useToast.d.ts +8 -52
- package/dist/hooks/useToast.d.ts.map +1 -1
- package/dist/hooks/useToast.js +8 -52
- package/dist/providers/drawerProvider.d.ts +15 -81
- package/dist/providers/drawerProvider.d.ts.map +1 -1
- package/dist/providers/drawerProvider.js +15 -81
- package/dist/providers/formProvider.d.ts +17 -53
- package/dist/providers/formProvider.d.ts.map +1 -1
- package/dist/providers/formProvider.js +17 -53
- package/dist/providers/modalProvider.d.ts +16 -77
- package/dist/providers/modalProvider.d.ts.map +1 -1
- package/dist/providers/modalProvider.js +16 -77
- package/dist/providers/placesProvider.d.ts +16 -11
- package/dist/providers/placesProvider.d.ts.map +1 -1
- package/dist/providers/placesProvider.js +16 -11
- package/dist/providers/toastProvider.d.ts +10 -21
- package/dist/providers/toastProvider.d.ts.map +1 -1
- package/dist/providers/toastProvider.js +10 -21
- package/dist/services/toHtml.d.ts +11 -10
- package/dist/services/toHtml.d.ts.map +1 -1
- package/dist/services/toHtml.js +11 -10
- package/dist/services/toRichTextValue.d.ts +11 -17
- package/dist/services/toRichTextValue.d.ts.map +1 -1
- package/dist/services/toRichTextValue.js +11 -17
- package/package.json +1 -1
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* useAutomation — runs UI side-effects (close modals, scroll, toast) in response to a server action payload.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
4
|
+
* Pass the raw response from a form submission. On every change the hook:
|
|
5
|
+
* 1. Closes all open modals if `closeModal` is `true`.
|
|
6
|
+
* 2. Smooth-scrolls to a named element if `cause.data.scrollTo` is set.
|
|
7
|
+
* 3. Shows a toast based on `name` (matched against `successResponses`/`badResponses`) and `message`.
|
|
8
|
+
* When `cause.fieldErrors` is present, the first field error takes priority in the toast.
|
|
9
|
+
* The message `"Unprocessable entity"` is intentionally suppressed.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
* -
|
|
14
|
-
*
|
|
15
|
-
* @param {any} formResponseData Response payload used to trigger automations.
|
|
16
|
-
* @param {boolean} [formResponseData.closeModal] Closes all modals when `true`.
|
|
17
|
-
* @param {string} [formResponseData.message] Message used in toast notifications.
|
|
18
|
-
* @param {string} [formResponseData.name] Response identifier used to classify success/error.
|
|
19
|
-
* @param {Object} [formResponseData.cause] Additional payload metadata.
|
|
20
|
-
* @param {Object} [formResponseData.cause.data] Additional response data.
|
|
21
|
-
* @param {string} [formResponseData.cause.data.scrollTo] Scroll target name for `react-scroll`.
|
|
22
|
-
* @param {Record<string, string>} [formResponseData.cause.fieldErrors] Field-level error messages.
|
|
11
|
+
* @param formResponseData - Raw server response payload.
|
|
12
|
+
* @param formResponseData.closeModal - Closes all open modals when `true`.
|
|
13
|
+
* @param formResponseData.name - Response identifier matched against success/bad response lists.
|
|
14
|
+
* @param formResponseData.message - Text shown in the toast notification.
|
|
15
|
+
* @param formResponseData.cause.data.scrollTo - Element name to scroll to via `react-scroll`.
|
|
16
|
+
* @param formResponseData.cause.fieldErrors - Field-level errors; the first value is shown in the toast.
|
|
23
17
|
*
|
|
24
18
|
* @example
|
|
25
19
|
* ```tsx
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* name: "created",
|
|
29
|
-
* message: "Saved successfully"
|
|
30
|
-
* });
|
|
20
|
+
* // After a successful create action
|
|
21
|
+
* useAutomation({ closeModal: true, name: "created", message: "Saved successfully" });
|
|
31
22
|
* ```
|
|
32
23
|
*
|
|
33
24
|
* @example
|
|
34
25
|
* ```tsx
|
|
26
|
+
* // Validation error with field-level feedback and scroll
|
|
35
27
|
* useAutomation({
|
|
36
28
|
* name: "validation_error",
|
|
37
29
|
* message: "Invalid payload",
|
|
38
30
|
* cause: {
|
|
39
31
|
* data: { scrollTo: "email" },
|
|
40
|
-
* fieldErrors: { email: "E-mail is required" }
|
|
41
|
-
* }
|
|
32
|
+
* fieldErrors: { email: "E-mail is required" },
|
|
33
|
+
* },
|
|
42
34
|
* });
|
|
43
35
|
* ```
|
|
44
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutomation.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutomation.ts"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"useAutomation.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutomation.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,iBAAS,aAAa,CAAC,gBAAgB,EAAE,GAAG,QA+B3C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -5,46 +5,38 @@ import { useToast } from "./useToast";
|
|
|
5
5
|
import { badResponses } from "../templates/badResponses";
|
|
6
6
|
import { successResponses } from "../templates/successResponses";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* useAutomation — runs UI side-effects (close modals, scroll, toast) in response to a server action payload.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
10
|
+
* Pass the raw response from a form submission. On every change the hook:
|
|
11
|
+
* 1. Closes all open modals if `closeModal` is `true`.
|
|
12
|
+
* 2. Smooth-scrolls to a named element if `cause.data.scrollTo` is set.
|
|
13
|
+
* 3. Shows a toast based on `name` (matched against `successResponses`/`badResponses`) and `message`.
|
|
14
|
+
* When `cause.fieldErrors` is present, the first field error takes priority in the toast.
|
|
15
|
+
* The message `"Unprocessable entity"` is intentionally suppressed.
|
|
14
16
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
* @param {any} formResponseData Response payload used to trigger automations.
|
|
22
|
-
* @param {boolean} [formResponseData.closeModal] Closes all modals when `true`.
|
|
23
|
-
* @param {string} [formResponseData.message] Message used in toast notifications.
|
|
24
|
-
* @param {string} [formResponseData.name] Response identifier used to classify success/error.
|
|
25
|
-
* @param {Object} [formResponseData.cause] Additional payload metadata.
|
|
26
|
-
* @param {Object} [formResponseData.cause.data] Additional response data.
|
|
27
|
-
* @param {string} [formResponseData.cause.data.scrollTo] Scroll target name for `react-scroll`.
|
|
28
|
-
* @param {Record<string, string>} [formResponseData.cause.fieldErrors] Field-level error messages.
|
|
17
|
+
* @param formResponseData - Raw server response payload.
|
|
18
|
+
* @param formResponseData.closeModal - Closes all open modals when `true`.
|
|
19
|
+
* @param formResponseData.name - Response identifier matched against success/bad response lists.
|
|
20
|
+
* @param formResponseData.message - Text shown in the toast notification.
|
|
21
|
+
* @param formResponseData.cause.data.scrollTo - Element name to scroll to via `react-scroll`.
|
|
22
|
+
* @param formResponseData.cause.fieldErrors - Field-level errors; the first value is shown in the toast.
|
|
29
23
|
*
|
|
30
24
|
* @example
|
|
31
25
|
* ```tsx
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* name: "created",
|
|
35
|
-
* message: "Saved successfully"
|
|
36
|
-
* });
|
|
26
|
+
* // After a successful create action
|
|
27
|
+
* useAutomation({ closeModal: true, name: "created", message: "Saved successfully" });
|
|
37
28
|
* ```
|
|
38
29
|
*
|
|
39
30
|
* @example
|
|
40
31
|
* ```tsx
|
|
32
|
+
* // Validation error with field-level feedback and scroll
|
|
41
33
|
* useAutomation({
|
|
42
34
|
* name: "validation_error",
|
|
43
35
|
* message: "Invalid payload",
|
|
44
36
|
* cause: {
|
|
45
37
|
* data: { scrollTo: "email" },
|
|
46
|
-
* fieldErrors: { email: "E-mail is required" }
|
|
47
|
-
* }
|
|
38
|
+
* fieldErrors: { email: "E-mail is required" },
|
|
39
|
+
* },
|
|
48
40
|
* });
|
|
49
41
|
* ```
|
|
50
42
|
*/
|
|
@@ -1,78 +1,33 @@
|
|
|
1
1
|
import { DrawerContextProps } from "../providers/drawerProvider";
|
|
2
2
|
type OpenDrawerProps<T = any> = (data?: T) => void;
|
|
3
3
|
/**
|
|
4
|
-
* useDrawer
|
|
4
|
+
* useDrawer — accesses the nearest `DrawerProvider` context.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Two call signatures:
|
|
7
|
+
* - **Without `key`** — returns the raw context object (manage any drawer by name).
|
|
8
|
+
* - **With `key`** — returns a scoped object bound to one named drawer.
|
|
7
9
|
*
|
|
8
|
-
* @
|
|
9
|
-
* @returns When called with key: Object containing drawer-specific functions:
|
|
10
|
-
* - `drawerIsOpen`: Boolean indicating if the specific drawer is open
|
|
11
|
-
* - `drawerData`: Data associated with the specific drawer
|
|
12
|
-
* - `openDrawer`: Function to open the specific drawer with optional data
|
|
13
|
-
* - `closeDrawer`: Function to close the specific drawer
|
|
10
|
+
* @param key - Drawer identifier registered in `DrawerProvider`.
|
|
14
11
|
*
|
|
15
|
-
* @
|
|
16
|
-
* ```tsx
|
|
17
|
-
* // Basic usage - access to full drawer context
|
|
18
|
-
* function DrawerManager() {
|
|
19
|
-
* const drawerContext = useDrawer();
|
|
20
|
-
*
|
|
21
|
-
* return (
|
|
22
|
-
* <div>
|
|
23
|
-
* <button onClick={() => drawerContext.openDrawer('navigation', { section: 'main' })}>
|
|
24
|
-
* Open Navigation
|
|
25
|
-
* </button>
|
|
26
|
-
* <button onClick={() => drawerContext.openDrawer('filters', { category: 'electronics' })}>
|
|
27
|
-
* Open Filters
|
|
28
|
-
* </button>
|
|
29
|
-
* </div>
|
|
30
|
-
* );
|
|
31
|
-
* }
|
|
12
|
+
* @returns Without key: full `DrawerContextProps`. With key: `{ drawerIsOpen, drawerData, openDrawer, closeDrawer }`.
|
|
32
13
|
*
|
|
33
|
-
*
|
|
34
|
-
* function NavigationDrawer() {
|
|
35
|
-
* const { drawerIsOpen, drawerData, openDrawer, closeDrawer } = useDrawer('navigation');
|
|
14
|
+
* @throws If called outside a `DrawerProvider`.
|
|
36
15
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* <button onClick={closeDrawer}>Close</button>
|
|
42
|
-
* </Drawer>
|
|
43
|
-
* );
|
|
44
|
-
* }
|
|
45
|
-
*
|
|
46
|
-
* // Usage with typed data
|
|
47
|
-
* interface FilterData {
|
|
48
|
-
* category: string;
|
|
49
|
-
* priceRange: [number, number];
|
|
50
|
-
* brands: string[];
|
|
51
|
-
* }
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* // Scoped to one drawer — the most common pattern
|
|
19
|
+
* const { drawerIsOpen, drawerData, openDrawer, closeDrawer } = useDrawer<{ section: string }>('navigation');
|
|
52
20
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
21
|
+
* openDrawer({ section: 'products' });
|
|
22
|
+
* ```
|
|
55
23
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* <p>Price: ${drawerData?.priceRange?.[0]} - ${drawerData?.priceRange?.[1]}</p>
|
|
61
|
-
* <p>Brands: {drawerData?.brands?.join(', ')}</p>
|
|
62
|
-
* </Drawer>
|
|
63
|
-
* );
|
|
64
|
-
* }
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Full context — useful when triggering multiple different drawers from one place
|
|
27
|
+
* const { openDrawer } = useDrawer();
|
|
65
28
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* return (
|
|
69
|
-
* <DrawerProvider>
|
|
70
|
-
* <NavigationDrawer />
|
|
71
|
-
* <FilterDrawer />
|
|
72
|
-
* <DrawerManager />
|
|
73
|
-
* </DrawerProvider>
|
|
74
|
-
* );
|
|
75
|
-
* }
|
|
29
|
+
* openDrawer('navigation', { section: 'main' });
|
|
30
|
+
* openDrawer('filters', { category: 'electronics' });
|
|
76
31
|
* ```
|
|
77
32
|
*/
|
|
78
33
|
declare function useDrawer<T = any>(): DrawerContextProps<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrawer.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrawer.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEhF,KAAK,eAAe,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"useDrawer.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrawer.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEhF,KAAK,eAAe,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACrD,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EACxB,GAAG,EAAE,MAAM,GACV;IACD,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,CAAC,CAAC;IACd,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AA6BF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/hooks/useForm.d.ts
CHANGED
|
@@ -1,45 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useForm
|
|
2
|
+
* useForm — reads the nearest `FormProvider` context to access field-level validation errors.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* All form inputs (`Input`, `Select`, `Checkbox`, etc.) call this hook internally,
|
|
5
|
+
* so you rarely need it directly. Use it when you want to read errors outside of
|
|
6
|
+
* an input component, or build a custom input.
|
|
7
|
+
*
|
|
8
|
+
* @returns Form context containing:
|
|
9
|
+
* - `fieldErrors` — `Record<string, string>` mapping field names to error messages.
|
|
6
10
|
*
|
|
7
11
|
* @example
|
|
8
12
|
* ```tsx
|
|
9
|
-
* //
|
|
10
|
-
* function MyComponent() {
|
|
11
|
-
* const { fieldErrors } = useForm();
|
|
12
|
-
*
|
|
13
|
-
* return (
|
|
14
|
-
* <Input
|
|
15
|
-
* name="email"
|
|
16
|
-
* errorMessage={fieldErrors?.email}
|
|
17
|
-
* />
|
|
18
|
-
* );
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* // Usage with FormProvider
|
|
13
|
+
* // Wrapping a form with FormProvider
|
|
22
14
|
* function App() {
|
|
23
|
-
* const errors = { email: "Invalid email format" };
|
|
24
|
-
*
|
|
25
15
|
* return (
|
|
26
|
-
* <FormProvider fieldErrors={
|
|
16
|
+
* <FormProvider fieldErrors={{ email: "Invalid email" }}>
|
|
27
17
|
* <MyForm />
|
|
28
18
|
* </FormProvider>
|
|
29
19
|
* );
|
|
30
20
|
* }
|
|
31
21
|
*
|
|
32
|
-
* //
|
|
33
|
-
* function
|
|
22
|
+
* // Reading errors manually
|
|
23
|
+
* function CustomField() {
|
|
34
24
|
* const { fieldErrors } = useForm();
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* return (
|
|
38
|
-
* <div>
|
|
39
|
-
* <Input name="username" />
|
|
40
|
-
* {hasError && <span>Error: {fieldErrors.username}</span>}
|
|
41
|
-
* </div>
|
|
42
|
-
* );
|
|
25
|
+
* return <span>{fieldErrors?.username}</span>;
|
|
43
26
|
* }
|
|
44
27
|
* ```
|
|
45
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,iBAAS,OAAO;;;;EAGf;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/hooks/useForm.js
CHANGED
|
@@ -1,47 +1,30 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { formContext } from "../providers/formProvider";
|
|
3
3
|
/**
|
|
4
|
-
* useForm
|
|
4
|
+
* useForm — reads the nearest `FormProvider` context to access field-level validation errors.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* All form inputs (`Input`, `Select`, `Checkbox`, etc.) call this hook internally,
|
|
7
|
+
* so you rarely need it directly. Use it when you want to read errors outside of
|
|
8
|
+
* an input component, or build a custom input.
|
|
9
|
+
*
|
|
10
|
+
* @returns Form context containing:
|
|
11
|
+
* - `fieldErrors` — `Record<string, string>` mapping field names to error messages.
|
|
8
12
|
*
|
|
9
13
|
* @example
|
|
10
14
|
* ```tsx
|
|
11
|
-
* //
|
|
12
|
-
* function MyComponent() {
|
|
13
|
-
* const { fieldErrors } = useForm();
|
|
14
|
-
*
|
|
15
|
-
* return (
|
|
16
|
-
* <Input
|
|
17
|
-
* name="email"
|
|
18
|
-
* errorMessage={fieldErrors?.email}
|
|
19
|
-
* />
|
|
20
|
-
* );
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* // Usage with FormProvider
|
|
15
|
+
* // Wrapping a form with FormProvider
|
|
24
16
|
* function App() {
|
|
25
|
-
* const errors = { email: "Invalid email format" };
|
|
26
|
-
*
|
|
27
17
|
* return (
|
|
28
|
-
* <FormProvider fieldErrors={
|
|
18
|
+
* <FormProvider fieldErrors={{ email: "Invalid email" }}>
|
|
29
19
|
* <MyForm />
|
|
30
20
|
* </FormProvider>
|
|
31
21
|
* );
|
|
32
22
|
* }
|
|
33
23
|
*
|
|
34
|
-
* //
|
|
35
|
-
* function
|
|
24
|
+
* // Reading errors manually
|
|
25
|
+
* function CustomField() {
|
|
36
26
|
* const { fieldErrors } = useForm();
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* return (
|
|
40
|
-
* <div>
|
|
41
|
-
* <Input name="username" />
|
|
42
|
-
* {hasError && <span>Error: {fieldErrors.username}</span>}
|
|
43
|
-
* </div>
|
|
44
|
-
* );
|
|
27
|
+
* return <span>{fieldErrors?.username}</span>;
|
|
45
28
|
* }
|
|
46
29
|
* ```
|
|
47
30
|
*/
|
|
@@ -1,73 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useHydrated
|
|
2
|
+
* useHydrated — returns `true` once the component has hydrated on the client, `false` during SSR.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Built on `useSyncExternalStore` so it is safe with React 18 concurrent rendering.
|
|
5
|
+
* Use this when you need to defer client-only rendering (e.g. browser APIs, `window`, `navigator`)
|
|
6
|
+
* without causing a hydration mismatch. For most cases, prefer the `ClientOnly` component.
|
|
6
7
|
*
|
|
7
|
-
* @returns
|
|
8
|
-
* - `true`: Component is hydrated on the client side
|
|
9
|
-
* - `false`: Component is being rendered on the server side or before hydration
|
|
8
|
+
* @returns `true` on the client after hydration; `false` on the server.
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
11
|
* ```tsx
|
|
13
|
-
*
|
|
14
|
-
* function ClientOnlyComponent() {
|
|
12
|
+
* function Map() {
|
|
15
13
|
* const isHydrated = useHydrated();
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* return <div>Loading...</div>;
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* return (
|
|
22
|
-
* <div>
|
|
23
|
-
* <p>This content is only rendered on the client</p>
|
|
24
|
-
* <p>Current time: {new Date().toLocaleString()}</p>
|
|
25
|
-
* </div>
|
|
26
|
-
* );
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* // Conditional rendering based on hydration state
|
|
30
|
-
* function ResponsiveComponent() {
|
|
31
|
-
* const isHydrated = useHydrated();
|
|
32
|
-
*
|
|
33
|
-
* return (
|
|
34
|
-
* <div>
|
|
35
|
-
* <h1>My App</h1>
|
|
36
|
-
* {isHydrated ? (
|
|
37
|
-
* <InteractiveWidget />
|
|
38
|
-
* ) : (
|
|
39
|
-
* <StaticPlaceholder />
|
|
40
|
-
* )}
|
|
41
|
-
* </div>
|
|
42
|
-
* );
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* // Using with client-only features
|
|
46
|
-
* function LocationComponent() {
|
|
47
|
-
* const isHydrated = useHydrated();
|
|
48
|
-
* const [location, setLocation] = useState(null);
|
|
49
|
-
*
|
|
50
|
-
* useEffect(() => {
|
|
51
|
-
* if (isHydrated && navigator.geolocation) {
|
|
52
|
-
* navigator.geolocation.getCurrentPosition((pos) => {
|
|
53
|
-
* setLocation(pos.coords);
|
|
54
|
-
* });
|
|
55
|
-
* }
|
|
56
|
-
* }, [isHydrated]);
|
|
57
|
-
*
|
|
58
|
-
* if (!isHydrated) {
|
|
59
|
-
* return <div>Preparing location services...</div>;
|
|
60
|
-
* }
|
|
61
|
-
*
|
|
62
|
-
* return (
|
|
63
|
-
* <div>
|
|
64
|
-
* {location ? (
|
|
65
|
-
* <p>Your location: {location.latitude}, {location.longitude}</p>
|
|
66
|
-
* ) : (
|
|
67
|
-
* <p>Getting your location...</p>
|
|
68
|
-
* )}
|
|
69
|
-
* </div>
|
|
70
|
-
* );
|
|
14
|
+
* if (!isHydrated) return <Skeleton />;
|
|
15
|
+
* return <MapView accessToken={token} coordinates={coords} />;
|
|
71
16
|
* }
|
|
72
17
|
* ```
|
|
73
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHydrated.d.ts","sourceRoot":"","sources":["../../src/hooks/useHydrated.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"useHydrated.d.ts","sourceRoot":"","sources":["../../src/hooks/useHydrated.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,WAAW,YAMnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -3,75 +3,20 @@ function subscribe() {
|
|
|
3
3
|
return () => { };
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* useHydrated
|
|
6
|
+
* useHydrated — returns `true` once the component has hydrated on the client, `false` during SSR.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Built on `useSyncExternalStore` so it is safe with React 18 concurrent rendering.
|
|
9
|
+
* Use this when you need to defer client-only rendering (e.g. browser APIs, `window`, `navigator`)
|
|
10
|
+
* without causing a hydration mismatch. For most cases, prefer the `ClientOnly` component.
|
|
10
11
|
*
|
|
11
|
-
* @returns
|
|
12
|
-
* - `true`: Component is hydrated on the client side
|
|
13
|
-
* - `false`: Component is being rendered on the server side or before hydration
|
|
12
|
+
* @returns `true` on the client after hydration; `false` on the server.
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
15
|
* ```tsx
|
|
17
|
-
*
|
|
18
|
-
* function ClientOnlyComponent() {
|
|
16
|
+
* function Map() {
|
|
19
17
|
* const isHydrated = useHydrated();
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* return <div>Loading...</div>;
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* return (
|
|
26
|
-
* <div>
|
|
27
|
-
* <p>This content is only rendered on the client</p>
|
|
28
|
-
* <p>Current time: {new Date().toLocaleString()}</p>
|
|
29
|
-
* </div>
|
|
30
|
-
* );
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* // Conditional rendering based on hydration state
|
|
34
|
-
* function ResponsiveComponent() {
|
|
35
|
-
* const isHydrated = useHydrated();
|
|
36
|
-
*
|
|
37
|
-
* return (
|
|
38
|
-
* <div>
|
|
39
|
-
* <h1>My App</h1>
|
|
40
|
-
* {isHydrated ? (
|
|
41
|
-
* <InteractiveWidget />
|
|
42
|
-
* ) : (
|
|
43
|
-
* <StaticPlaceholder />
|
|
44
|
-
* )}
|
|
45
|
-
* </div>
|
|
46
|
-
* );
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* // Using with client-only features
|
|
50
|
-
* function LocationComponent() {
|
|
51
|
-
* const isHydrated = useHydrated();
|
|
52
|
-
* const [location, setLocation] = useState(null);
|
|
53
|
-
*
|
|
54
|
-
* useEffect(() => {
|
|
55
|
-
* if (isHydrated && navigator.geolocation) {
|
|
56
|
-
* navigator.geolocation.getCurrentPosition((pos) => {
|
|
57
|
-
* setLocation(pos.coords);
|
|
58
|
-
* });
|
|
59
|
-
* }
|
|
60
|
-
* }, [isHydrated]);
|
|
61
|
-
*
|
|
62
|
-
* if (!isHydrated) {
|
|
63
|
-
* return <div>Preparing location services...</div>;
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* return (
|
|
67
|
-
* <div>
|
|
68
|
-
* {location ? (
|
|
69
|
-
* <p>Your location: {location.latitude}, {location.longitude}</p>
|
|
70
|
-
* ) : (
|
|
71
|
-
* <p>Getting your location...</p>
|
|
72
|
-
* )}
|
|
73
|
-
* </div>
|
|
74
|
-
* );
|
|
18
|
+
* if (!isHydrated) return <Skeleton />;
|
|
19
|
+
* return <MapView accessToken={token} coordinates={coords} />;
|
|
75
20
|
* }
|
|
76
21
|
* ```
|
|
77
22
|
*/
|
package/dist/hooks/useModal.d.ts
CHANGED
|
@@ -1,73 +1,33 @@
|
|
|
1
1
|
import { ModalContextProps } from "../providers/modalProvider";
|
|
2
2
|
type OpenModalProps<T = any> = (data?: T) => void;
|
|
3
3
|
/**
|
|
4
|
-
* useModal
|
|
4
|
+
* useModal — accesses the nearest `ModalProvider` context.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Two call signatures:
|
|
7
|
+
* - **Without `key`** — returns the raw context object (manage any modal by name).
|
|
8
|
+
* - **With `key`** — returns a scoped object bound to one named modal.
|
|
7
9
|
*
|
|
8
|
-
* @
|
|
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
|
|
10
|
+
* @param key - Modal identifier registered in `ModalProvider`.
|
|
14
11
|
*
|
|
15
|
-
* @
|
|
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
|
-
* }
|
|
12
|
+
* @returns Without key: full `ModalContextProps`. With key: `{ modalIsOpen, modalData, openModal, closeModal }`.
|
|
29
13
|
*
|
|
30
|
-
*
|
|
31
|
-
* function UserModal() {
|
|
32
|
-
* const { modalIsOpen, modalData, openModal, closeModal } = useModal('user-details');
|
|
14
|
+
* @throws If called outside a `ModalProvider`.
|
|
33
15
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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
|
-
* }
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* // Scoped to one modal — the most common pattern
|
|
19
|
+
* const { modalIsOpen, modalData, openModal, closeModal } = useModal<{ id: number }>('confirm-delete');
|
|
49
20
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
21
|
+
* openModal({ id: user.id });
|
|
22
|
+
* ```
|
|
52
23
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* </Modal>
|
|
58
|
-
* );
|
|
59
|
-
* }
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Full context — useful when triggering multiple different modals from one place
|
|
27
|
+
* const { openModal } = useModal();
|
|
60
28
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* return (
|
|
64
|
-
* <ModalProvider>
|
|
65
|
-
* <UserModal />
|
|
66
|
-
* <UserProfileModal />
|
|
67
|
-
* <ModalManager />
|
|
68
|
-
* </ModalProvider>
|
|
69
|
-
* );
|
|
70
|
-
* }
|
|
29
|
+
* openModal('confirm-delete', { id: user.id });
|
|
30
|
+
* openModal('user-details', { id: user.id });
|
|
71
31
|
* ```
|
|
72
32
|
*/
|
|
73
33
|
declare function useModal<T = any>(): ModalContextProps<T>;
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;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"}
|