@arkyn/components 3.0.1-beta.143 → 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.
Files changed (206) hide show
  1. package/dist/components/alert/alertContainer/index.d.ts +27 -43
  2. package/dist/components/alert/alertContainer/index.d.ts.map +1 -1
  3. package/dist/components/alert/alertContainer/index.js +20 -40
  4. package/dist/components/alert/alertContent/index.d.ts +11 -36
  5. package/dist/components/alert/alertContent/index.d.ts.map +1 -1
  6. package/dist/components/alert/alertContent/index.js +11 -31
  7. package/dist/components/alert/alertDescription/index.d.ts +10 -38
  8. package/dist/components/alert/alertDescription/index.d.ts.map +1 -1
  9. package/dist/components/alert/alertDescription/index.js +10 -33
  10. package/dist/components/alert/alertIcon/index.d.ts +14 -38
  11. package/dist/components/alert/alertIcon/index.d.ts.map +1 -1
  12. package/dist/components/alert/alertIcon/index.js +14 -32
  13. package/dist/components/alert/alertTitle/index.d.ts +12 -35
  14. package/dist/components/alert/alertTitle/index.d.ts.map +1 -1
  15. package/dist/components/alert/alertTitle/index.js +12 -27
  16. package/dist/components/audioPlayer/index.d.ts +24 -32
  17. package/dist/components/audioPlayer/index.d.ts.map +1 -1
  18. package/dist/components/audioPlayer/index.js +15 -18
  19. package/dist/components/audioUpload/index.d.ts +37 -48
  20. package/dist/components/audioUpload/index.d.ts.map +1 -1
  21. package/dist/components/audioUpload/index.js +23 -48
  22. package/dist/components/badge/index.d.ts +31 -22
  23. package/dist/components/badge/index.d.ts.map +1 -1
  24. package/dist/components/badge/index.js +14 -22
  25. package/dist/components/button/index.d.ts +38 -28
  26. package/dist/components/button/index.d.ts.map +1 -1
  27. package/dist/components/button/index.js +18 -28
  28. package/dist/components/cardTab/cardTabButton/index.d.ts +14 -52
  29. package/dist/components/cardTab/cardTabButton/index.d.ts.map +1 -1
  30. package/dist/components/cardTab/cardTabButton/index.js +12 -52
  31. package/dist/components/cardTab/cardTabContainer/index.d.ts +16 -58
  32. package/dist/components/cardTab/cardTabContainer/index.d.ts.map +1 -1
  33. package/dist/components/cardTab/cardTabContainer/index.js +12 -58
  34. package/dist/components/checkbox/index.d.ts +38 -37
  35. package/dist/components/checkbox/index.d.ts.map +1 -1
  36. package/dist/components/checkbox/index.js +21 -37
  37. package/dist/components/clientOnly.d.ts +13 -66
  38. package/dist/components/clientOnly.d.ts.map +1 -1
  39. package/dist/components/clientOnly.js +11 -66
  40. package/dist/components/currencyInput/index.d.ts +67 -50
  41. package/dist/components/currencyInput/index.d.ts.map +1 -1
  42. package/dist/components/currencyInput/index.js +28 -50
  43. package/dist/components/divider/index.d.ts +12 -25
  44. package/dist/components/divider/index.d.ts.map +1 -1
  45. package/dist/components/divider/index.js +8 -25
  46. package/dist/components/drawer/drawerContainer/index.d.ts +16 -50
  47. package/dist/components/drawer/drawerContainer/index.d.ts.map +1 -1
  48. package/dist/components/drawer/drawerContainer/index.js +13 -50
  49. package/dist/components/drawer/drawerHeader/index.d.ts +9 -33
  50. package/dist/components/drawer/drawerHeader/index.d.ts.map +1 -1
  51. package/dist/components/drawer/drawerHeader/index.js +8 -33
  52. package/dist/components/facebookPixel/index.d.ts +47 -0
  53. package/dist/components/facebookPixel/index.d.ts.map +1 -1
  54. package/dist/components/facebookPixel/index.js +35 -0
  55. package/dist/components/fieldError/index.d.ts +4 -11
  56. package/dist/components/fieldError/index.d.ts.map +1 -1
  57. package/dist/components/fieldError/index.js +4 -11
  58. package/dist/components/fieldLabel/index.d.ts +6 -21
  59. package/dist/components/fieldLabel/index.d.ts.map +1 -1
  60. package/dist/components/fieldLabel/index.js +5 -21
  61. package/dist/components/fieldWrapper/index.d.ts +12 -22
  62. package/dist/components/fieldWrapper/index.d.ts.map +1 -1
  63. package/dist/components/fieldWrapper/index.js +7 -22
  64. package/dist/components/fileUpload/index.d.ts +36 -61
  65. package/dist/components/fileUpload/index.d.ts.map +1 -1
  66. package/dist/components/fileUpload/index.js +23 -61
  67. package/dist/components/googleAnalytics/index.d.ts +11 -7
  68. package/dist/components/googleAnalytics/index.d.ts.map +1 -1
  69. package/dist/components/googleAnalytics/index.js +9 -7
  70. package/dist/components/googleTagManager/index.d.ts +27 -21
  71. package/dist/components/googleTagManager/index.d.ts.map +1 -1
  72. package/dist/components/googleTagManager/index.js +20 -21
  73. package/dist/components/iconButton/index.d.ts +31 -15
  74. package/dist/components/iconButton/index.d.ts.map +1 -1
  75. package/dist/components/iconButton/index.js +12 -15
  76. package/dist/components/imageUpload/index.d.ts +47 -75
  77. package/dist/components/imageUpload/index.d.ts.map +1 -1
  78. package/dist/components/imageUpload/index.js +27 -75
  79. package/dist/components/input/index.d.ts +51 -44
  80. package/dist/components/input/index.d.ts.map +1 -1
  81. package/dist/components/input/index.js +24 -44
  82. package/dist/components/mapView/index.d.ts +44 -0
  83. package/dist/components/mapView/index.d.ts.map +1 -1
  84. package/dist/components/mapView/index.js +35 -0
  85. package/dist/components/maskedInput/index.d.ts +66 -51
  86. package/dist/components/maskedInput/index.d.ts.map +1 -1
  87. package/dist/components/maskedInput/index.js +28 -51
  88. package/dist/components/modal/modalContainer/index.d.ts +17 -57
  89. package/dist/components/modal/modalContainer/index.d.ts.map +1 -1
  90. package/dist/components/modal/modalContainer/index.js +15 -57
  91. package/dist/components/modal/modalFooter/index.d.ts +17 -50
  92. package/dist/components/modal/modalFooter/index.d.ts.map +1 -1
  93. package/dist/components/modal/modalFooter/index.js +10 -50
  94. package/dist/components/modal/modalHeader/index.d.ts +13 -47
  95. package/dist/components/modal/modalHeader/index.d.ts.map +1 -1
  96. package/dist/components/modal/modalHeader/index.js +12 -47
  97. package/dist/components/multiSelect/index.d.ts +67 -62
  98. package/dist/components/multiSelect/index.d.ts.map +1 -1
  99. package/dist/components/multiSelect/index.js +28 -62
  100. package/dist/components/pagination/index.d.ts +18 -9
  101. package/dist/components/pagination/index.d.ts.map +1 -1
  102. package/dist/components/pagination/index.js +18 -9
  103. package/dist/components/phoneInput/index.d.ts +65 -30
  104. package/dist/components/phoneInput/index.d.ts.map +1 -1
  105. package/dist/components/phoneInput/index.js +35 -30
  106. package/dist/components/popover/index.d.ts +34 -114
  107. package/dist/components/popover/index.d.ts.map +1 -1
  108. package/dist/components/popover/index.js +25 -114
  109. package/dist/components/radio/radioBox/index.d.ts +17 -65
  110. package/dist/components/radio/radioBox/index.d.ts.map +1 -1
  111. package/dist/components/radio/radioBox/index.js +14 -65
  112. package/dist/components/radio/radioGroup/index.d.ts +36 -67
  113. package/dist/components/radio/radioGroup/index.d.ts.map +1 -1
  114. package/dist/components/radio/radioGroup/index.js +25 -67
  115. package/dist/components/richText/index.d.ts +33 -47
  116. package/dist/components/richText/index.d.ts.map +1 -1
  117. package/dist/components/richText/index.js +30 -44
  118. package/dist/components/searchPlaces.d.ts +52 -50
  119. package/dist/components/searchPlaces.d.ts.map +1 -1
  120. package/dist/components/searchPlaces.js +23 -30
  121. package/dist/components/select/index.d.ts +68 -63
  122. package/dist/components/select/index.d.ts.map +1 -1
  123. package/dist/components/select/index.js +29 -63
  124. package/dist/components/slider/index.d.ts +20 -34
  125. package/dist/components/slider/index.d.ts.map +1 -1
  126. package/dist/components/slider/index.js +15 -33
  127. package/dist/components/switch/index.d.ts +42 -58
  128. package/dist/components/switch/index.d.ts.map +1 -1
  129. package/dist/components/switch/index.js +24 -58
  130. package/dist/components/tab/tabButton/index.d.ts +14 -52
  131. package/dist/components/tab/tabButton/index.d.ts.map +1 -1
  132. package/dist/components/tab/tabButton/index.js +12 -52
  133. package/dist/components/tab/tabContainer/index.d.ts +16 -58
  134. package/dist/components/tab/tabContainer/index.d.ts.map +1 -1
  135. package/dist/components/tab/tabContainer/index.js +12 -58
  136. package/dist/components/table/tableBody/index.d.ts +13 -47
  137. package/dist/components/table/tableBody/index.d.ts.map +1 -1
  138. package/dist/components/table/tableBody/index.js +12 -47
  139. package/dist/components/table/tableCaption/index.d.ts +6 -46
  140. package/dist/components/table/tableCaption/index.d.ts.map +1 -1
  141. package/dist/components/table/tableCaption/index.js +6 -46
  142. package/dist/components/table/tableContainer/index.d.ts +12 -41
  143. package/dist/components/table/tableContainer/index.d.ts.map +1 -1
  144. package/dist/components/table/tableContainer/index.js +12 -41
  145. package/dist/components/table/tableFooter/index.d.ts +5 -29
  146. package/dist/components/table/tableFooter/index.d.ts.map +1 -1
  147. package/dist/components/table/tableFooter/index.js +5 -29
  148. package/dist/components/table/tableHeader/index.d.ts +4 -25
  149. package/dist/components/table/tableHeader/index.d.ts.map +1 -1
  150. package/dist/components/table/tableHeader/index.js +4 -25
  151. package/dist/components/textarea/index.d.ts +32 -64
  152. package/dist/components/textarea/index.d.ts.map +1 -1
  153. package/dist/components/textarea/index.js +16 -64
  154. package/dist/components/tooltip/index.d.ts +27 -55
  155. package/dist/components/tooltip/index.d.ts.map +1 -1
  156. package/dist/components/tooltip/index.js +16 -55
  157. package/dist/hooks/useAutomation.d.ts +18 -26
  158. package/dist/hooks/useAutomation.d.ts.map +1 -1
  159. package/dist/hooks/useAutomation.js +18 -26
  160. package/dist/hooks/useDrawer.d.ts +19 -64
  161. package/dist/hooks/useDrawer.d.ts.map +1 -1
  162. package/dist/hooks/useForm.d.ts +12 -29
  163. package/dist/hooks/useForm.d.ts.map +1 -1
  164. package/dist/hooks/useForm.js +12 -29
  165. package/dist/hooks/useHydrated.d.ts +8 -63
  166. package/dist/hooks/useHydrated.d.ts.map +1 -1
  167. package/dist/hooks/useHydrated.js +8 -63
  168. package/dist/hooks/useModal.d.ts +19 -59
  169. package/dist/hooks/useModal.d.ts.map +1 -1
  170. package/dist/hooks/useScopedParams.d.ts +17 -69
  171. package/dist/hooks/useScopedParams.d.ts.map +1 -1
  172. package/dist/hooks/useScopedParams.js +17 -69
  173. package/dist/hooks/useScrollLock.d.ts +11 -27
  174. package/dist/hooks/useScrollLock.d.ts.map +1 -1
  175. package/dist/hooks/useScrollLock.js +11 -33
  176. package/dist/hooks/useSearchAutomation.d.ts +16 -34
  177. package/dist/hooks/useSearchAutomation.d.ts.map +1 -1
  178. package/dist/hooks/useSearchAutomation.js +16 -34
  179. package/dist/hooks/useSlider.d.ts +5 -19
  180. package/dist/hooks/useSlider.d.ts.map +1 -1
  181. package/dist/hooks/useSlider.js +5 -19
  182. package/dist/hooks/useToast.d.ts +8 -52
  183. package/dist/hooks/useToast.d.ts.map +1 -1
  184. package/dist/hooks/useToast.js +8 -52
  185. package/dist/providers/drawerProvider.d.ts +15 -81
  186. package/dist/providers/drawerProvider.d.ts.map +1 -1
  187. package/dist/providers/drawerProvider.js +15 -81
  188. package/dist/providers/formProvider.d.ts +17 -53
  189. package/dist/providers/formProvider.d.ts.map +1 -1
  190. package/dist/providers/formProvider.js +17 -53
  191. package/dist/providers/modalProvider.d.ts +16 -77
  192. package/dist/providers/modalProvider.d.ts.map +1 -1
  193. package/dist/providers/modalProvider.js +16 -77
  194. package/dist/providers/placesProvider.d.ts +16 -11
  195. package/dist/providers/placesProvider.d.ts.map +1 -1
  196. package/dist/providers/placesProvider.js +16 -11
  197. package/dist/providers/toastProvider.d.ts +10 -21
  198. package/dist/providers/toastProvider.d.ts.map +1 -1
  199. package/dist/providers/toastProvider.js +10 -21
  200. package/dist/services/toHtml.d.ts +11 -10
  201. package/dist/services/toHtml.d.ts.map +1 -1
  202. package/dist/services/toHtml.js +11 -10
  203. package/dist/services/toRichTextValue.d.ts +11 -17
  204. package/dist/services/toRichTextValue.d.ts.map +1 -1
  205. package/dist/services/toRichTextValue.js +11 -17
  206. package/package.json +1 -1
@@ -1,44 +1,36 @@
1
1
  /**
2
- * Executes UI automations based on a form response payload.
2
+ * useAutomation — runs UI side-effects (close modals, scroll, toast) in response to a server action payload.
3
3
  *
4
- * Current behaviors:
5
- * - Closes all open modals when `closeModal` is `true`.
6
- * - Scrolls to a target element when `cause.data.scrollTo` is provided.
7
- * - Shows a toast according to response `name`, `message`, and `cause.fieldErrors`.
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
- * Toast rules:
10
- * - Success responses (`successResponses`) show a success toast with `message`.
11
- * - Bad responses (`badResponses`) show a danger toast.
12
- * - When `cause.fieldErrors` exists, the first field error message has priority.
13
- * - The message `"Unprocessable entity"` is intentionally ignored.
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
- * useAutomation({
27
- * closeModal: true,
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,iBAAS,aAAa,CAAC,gBAAgB,EAAE,GAAG,QA+B3C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
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
- * Executes UI automations based on a form response payload.
8
+ * useAutomation — runs UI side-effects (close modals, scroll, toast) in response to a server action payload.
9
9
  *
10
- * Current behaviors:
11
- * - Closes all open modals when `closeModal` is `true`.
12
- * - Scrolls to a target element when `cause.data.scrollTo` is provided.
13
- * - Shows a toast according to response `name`, `message`, and `cause.fieldErrors`.
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
- * Toast rules:
16
- * - Success responses (`successResponses`) show a success toast with `message`.
17
- * - Bad responses (`badResponses`) show a danger toast.
18
- * - When `cause.fieldErrors` exists, the first field error message has priority.
19
- * - The message `"Unprocessable entity"` is intentionally ignored.
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
- * useAutomation({
33
- * closeModal: true,
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 hook - provides access to drawer context for managing drawer state and data
4
+ * useDrawer accesses the nearest `DrawerProvider` context.
5
5
  *
6
- * @param key - Optional drawer identifier key. When provided, returns functions for a specific drawer
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
- * @returns When called without key: Complete drawer context with all drawer management functions
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
- * @example
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
- * // Usage with specific drawer key
34
- * function NavigationDrawer() {
35
- * const { drawerIsOpen, drawerData, openDrawer, closeDrawer } = useDrawer('navigation');
14
+ * @throws If called outside a `DrawerProvider`.
36
15
  *
37
- * return (
38
- * <Drawer isOpen={drawerIsOpen} onClose={closeDrawer} position="left">
39
- * <h2>Navigation</h2>
40
- * <p>Current section: {drawerData?.section}</p>
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
- * function FilterDrawer() {
54
- * const { drawerIsOpen, drawerData, closeDrawer } = useDrawer<FilterData>('filters');
21
+ * openDrawer({ section: 'products' });
22
+ * ```
55
23
  *
56
- * return (
57
- * <Drawer isOpen={drawerIsOpen} onClose={closeDrawer} position="right">
58
- * <h2>Filters</h2>
59
- * <p>Category: {drawerData?.category}</p>
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
- * // Usage with DrawerProvider
67
- * function App() {
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;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"}
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"}
@@ -1,45 +1,28 @@
1
1
  /**
2
- * useForm hook - provides access to form context data including field errors
2
+ * useForm reads the nearest `FormProvider` context to access field-level validation errors.
3
3
  *
4
- * @returns Form context object containing:
5
- * - `fieldErrors`: Object with field validation errors indexed by field name
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
- * // Basic usage in a component
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={errors}>
16
+ * <FormProvider fieldErrors={{ email: "Invalid email" }}>
27
17
  * <MyForm />
28
18
  * </FormProvider>
29
19
  * );
30
20
  * }
31
21
  *
32
- * // Checking for specific field errors
33
- * function FormField() {
22
+ * // Reading errors manually
23
+ * function CustomField() {
34
24
  * const { fieldErrors } = useForm();
35
- * const hasError = !!fieldErrors?.username;
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,iBAAS,OAAO;;;;EAGf;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
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"}
@@ -1,47 +1,30 @@
1
1
  import { useContext } from "react";
2
2
  import { formContext } from "../providers/formProvider";
3
3
  /**
4
- * useForm hook - provides access to form context data including field errors
4
+ * useForm reads the nearest `FormProvider` context to access field-level validation errors.
5
5
  *
6
- * @returns Form context object containing:
7
- * - `fieldErrors`: Object with field validation errors indexed by field name
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
- * // Basic usage in a component
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={errors}>
18
+ * <FormProvider fieldErrors={{ email: "Invalid email" }}>
29
19
  * <MyForm />
30
20
  * </FormProvider>
31
21
  * );
32
22
  * }
33
23
  *
34
- * // Checking for specific field errors
35
- * function FormField() {
24
+ * // Reading errors manually
25
+ * function CustomField() {
36
26
  * const { fieldErrors } = useForm();
37
- * const hasError = !!fieldErrors?.username;
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 hook - detects if the component is hydrated on the client side
2
+ * useHydrated returns `true` once the component has hydrated on the client, `false` during SSR.
3
3
  *
4
- * This hook is useful for preventing hydration mismatches when rendering different content
5
- * on server and client sides. It returns false during SSR and true after hydration.
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 Boolean indicating if the component is hydrated
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
- * // Basic usage to prevent hydration mismatches
14
- * function ClientOnlyComponent() {
12
+ * function Map() {
15
13
  * const isHydrated = useHydrated();
16
- *
17
- * if (!isHydrated) {
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,iBAAS,WAAW,YAMnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
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 hook - detects if the component is hydrated on the client side
6
+ * useHydrated returns `true` once the component has hydrated on the client, `false` during SSR.
7
7
  *
8
- * This hook is useful for preventing hydration mismatches when rendering different content
9
- * on server and client sides. It returns false during SSR and true after hydration.
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 Boolean indicating if the component is hydrated
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
- * // Basic usage to prevent hydration mismatches
18
- * function ClientOnlyComponent() {
16
+ * function Map() {
19
17
  * const isHydrated = useHydrated();
20
- *
21
- * if (!isHydrated) {
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
  */
@@ -1,73 +1,33 @@
1
1
  import { ModalContextProps } from "../providers/modalProvider";
2
2
  type OpenModalProps<T = any> = (data?: T) => void;
3
3
  /**
4
- * useModal hook - provides access to modal context for managing modal state and data
4
+ * useModal accesses the nearest `ModalProvider` context.
5
5
  *
6
- * @param key - Optional modal identifier key. When provided, returns functions for a specific modal
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
- * @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
10
+ * @param key - Modal identifier registered in `ModalProvider`.
14
11
  *
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
- * }
12
+ * @returns Without key: full `ModalContextProps`. With key: `{ modalIsOpen, modalData, openModal, closeModal }`.
29
13
  *
30
- * // Usage with specific modal key
31
- * function UserModal() {
32
- * const { modalIsOpen, modalData, openModal, closeModal } = useModal('user-details');
14
+ * @throws If called outside a `ModalProvider`.
33
15
  *
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
- * }
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
- * function UserProfileModal() {
51
- * const { modalIsOpen, modalData, closeModal } = useModal<UserData>('user-profile');
21
+ * openModal({ id: user.id });
22
+ * ```
52
23
  *
53
- * return (
54
- * <Modal isOpen={modalIsOpen} onClose={closeModal}>
55
- * <h2>{modalData?.name}</h2>
56
- * <p>Email: {modalData?.email}</p>
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
- * // Usage with ModalProvider
62
- * function App() {
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
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"}