mado-ui 0.3.2 → 0.5.0

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 (194) hide show
  1. package/css/index.css +604 -6
  2. package/dist/components/button.d.ts +3 -23
  3. package/dist/components/details.d.ts +2 -2
  4. package/dist/components/drop-down.d.ts +6 -5
  5. package/dist/components/form/fieldset.d.ts +35 -7
  6. package/dist/components/form/index.d.ts +5 -6
  7. package/dist/components/form/input/date/index.d.ts +36 -0
  8. package/dist/components/form/input/index.d.ts +78 -12
  9. package/dist/components/form/submit-button.d.ts +1 -1
  10. package/dist/components/form/textarea.d.ts +1 -1
  11. package/dist/components/ghost.d.ts +1 -1
  12. package/dist/components/heading.d.ts +1 -1
  13. package/dist/components/iframe.d.ts +15 -0
  14. package/dist/components/index.d.ts +12 -11
  15. package/dist/components/link.d.ts +3 -14
  16. package/dist/components/modal.d.ts +1 -1
  17. package/dist/components/time.d.ts +1 -1
  18. package/dist/components/tooltip.d.ts +1 -1
  19. package/dist/components/video.d.ts +30 -0
  20. package/dist/components.esm.js +891 -129
  21. package/dist/components.esm.js.map +1 -1
  22. package/dist/components.js +892 -126
  23. package/dist/components.js.map +1 -1
  24. package/dist/hooks/create-fast-context.d.ts +1 -1
  25. package/dist/hooks/index.d.ts +4 -4
  26. package/dist/hooks/use-fieldset-context.d.ts +22 -0
  27. package/dist/hooks/use-form-context.d.ts +18 -10
  28. package/dist/hooks.esm.js +99 -5
  29. package/dist/hooks.esm.js.map +1 -1
  30. package/dist/hooks.js +100 -3
  31. package/dist/hooks.js.map +1 -1
  32. package/dist/icons/10-arrow-trianglehead-clockwise.d.ts +2 -0
  33. package/dist/icons/10-arrow-trianglehead-counterclockwise.d.ts +2 -0
  34. package/dist/icons/15-arrow-trianglehead-clockwise.d.ts +2 -0
  35. package/dist/icons/15-arrow-trianglehead-counterclockwise.d.ts +2 -0
  36. package/dist/icons/3-people.d.ts +2 -2
  37. package/dist/icons/3-rectangles-desktop-fill.d.ts +2 -2
  38. package/dist/icons/3-rectangles-desktop.d.ts +2 -2
  39. package/dist/icons/30-arrow-trianglehead-clockwise.d.ts +2 -0
  40. package/dist/icons/30-arrow-trianglehead-counterclockwise.d.ts +2 -0
  41. package/dist/icons/45-arrow-trianglehead-clockwise.d.ts +2 -0
  42. package/dist/icons/45-arrow-trianglehead-counterclockwise.d.ts +2 -0
  43. package/dist/icons/5-arrow-trianglehead-clockwise.d.ts +2 -0
  44. package/dist/icons/5-arrow-trianglehead-counterclockwise.d.ts +2 -0
  45. package/dist/icons/60-arrow-trianglehead-clockwise.d.ts +2 -0
  46. package/dist/icons/60-arrow-trianglehead-counterclockwise.d.ts +2 -0
  47. package/dist/icons/75-arrow-trianglehead-clockwise.d.ts +2 -0
  48. package/dist/icons/75-arrow-trianglehead-counterclockwise.d.ts +2 -0
  49. package/dist/icons/90-arrow-trianglehead-clockwise.d.ts +2 -0
  50. package/dist/icons/90-arrow-trianglehead-counterclockwise.d.ts +2 -0
  51. package/dist/icons/airplane.d.ts +2 -2
  52. package/dist/icons/arrow-down-backward-and-arrow-up-forward-rectangle.d.ts +2 -0
  53. package/dist/icons/arrow-triangle-2-circlepath-circle-fill.d.ts +2 -2
  54. package/dist/icons/arrow-triangle-2-circlepath-circle.d.ts +2 -2
  55. package/dist/icons/arrow-up-forward-and-arrow-down-backward-rectangle.d.ts +2 -0
  56. package/dist/icons/bag-fill.d.ts +2 -2
  57. package/dist/icons/banknote.d.ts +2 -2
  58. package/dist/icons/bell-fill.d.ts +2 -2
  59. package/dist/icons/bolt-car.d.ts +2 -2
  60. package/dist/icons/bolt-fill.d.ts +2 -2
  61. package/dist/icons/bolt-ring-closed.d.ts +2 -2
  62. package/dist/icons/bolt-trianglebadge-exclamationmark.d.ts +2 -2
  63. package/dist/icons/book-fill.d.ts +2 -2
  64. package/dist/icons/bookmark-fill.d.ts +2 -2
  65. package/dist/icons/briefcase-fill.d.ts +2 -2
  66. package/dist/icons/bubble-left-fill.d.ts +2 -2
  67. package/dist/icons/building-2-fill.d.ts +2 -2
  68. package/dist/icons/calendar.d.ts +2 -2
  69. package/dist/icons/camera-fill.d.ts +2 -2
  70. package/dist/icons/car-fill.d.ts +2 -2
  71. package/dist/icons/cart-fill.d.ts +2 -2
  72. package/dist/icons/chart-bar-doc-horizontal.d.ts +2 -2
  73. package/dist/icons/checkmark-seal.d.ts +2 -2
  74. package/dist/icons/checkmark.d.ts +2 -2
  75. package/dist/icons/chevron-compact-down.d.ts +1 -1
  76. package/dist/icons/chevron-down.d.ts +2 -2
  77. package/dist/icons/chevron-left-forwardslash-chevron-right.d.ts +2 -2
  78. package/dist/icons/chevron-left.d.ts +2 -2
  79. package/dist/icons/chevron-right.d.ts +2 -2
  80. package/dist/icons/chevron-up-chevron-down.d.ts +2 -2
  81. package/dist/icons/circle-fill.d.ts +2 -2
  82. package/dist/icons/clock-badge-checkmark.d.ts +2 -2
  83. package/dist/icons/clock-fill.d.ts +2 -2
  84. package/dist/icons/cloud-fill.d.ts +2 -2
  85. package/dist/icons/cube-fill.d.ts +2 -2
  86. package/dist/icons/curve-point-left.d.ts +2 -2
  87. package/dist/icons/dial-high.d.ts +2 -2
  88. package/dist/icons/doc-fill.d.ts +2 -2
  89. package/dist/icons/doc-on-clipboard.d.ts +2 -2
  90. package/dist/icons/doc-on-doc-fill.d.ts +2 -2
  91. package/dist/icons/doc-on-doc.d.ts +2 -2
  92. package/dist/icons/doc-text-magnifyingglass.d.ts +2 -2
  93. package/dist/icons/dollar-sign.d.ts +2 -2
  94. package/dist/icons/ellipsis-circle-fill.d.ts +2 -2
  95. package/dist/icons/ellipsis-circle.d.ts +2 -2
  96. package/dist/icons/envelope-fill.d.ts +2 -2
  97. package/dist/icons/envelope.d.ts +2 -2
  98. package/dist/icons/exclamationmark-octagon.d.ts +2 -2
  99. package/dist/icons/eye.d.ts +2 -2
  100. package/dist/icons/figure-water-fitness.d.ts +2 -2
  101. package/dist/icons/flag-fill.d.ts +2 -2
  102. package/dist/icons/flame-fill.d.ts +2 -2
  103. package/dist/icons/folder-fill.d.ts +2 -2
  104. package/dist/icons/folder.d.ts +2 -2
  105. package/dist/icons/gearshape-fill.d.ts +2 -2
  106. package/dist/icons/gearshape.d.ts +2 -2
  107. package/dist/icons/gift-fill.d.ts +2 -2
  108. package/dist/icons/globe-americas-fill.d.ts +2 -2
  109. package/dist/icons/hare-fill.d.ts +2 -2
  110. package/dist/icons/house-deskclock.d.ts +2 -2
  111. package/dist/icons/house-fill.d.ts +2 -2
  112. package/dist/icons/house.d.ts +2 -2
  113. package/dist/icons/index.d.ts +143 -104
  114. package/dist/icons/iphone-house.d.ts +2 -2
  115. package/dist/icons/light-ribbon.d.ts +2 -2
  116. package/dist/icons/lightbulb-fill.d.ts +2 -2
  117. package/dist/icons/lightbulb-led.d.ts +2 -2
  118. package/dist/icons/list-bullet-clipboard-fill.d.ts +2 -2
  119. package/dist/icons/magnifyingglass.d.ts +2 -2
  120. package/dist/icons/map-pin-ellipse.d.ts +2 -2
  121. package/dist/icons/minus-plus-batterblock.d.ts +2 -2
  122. package/dist/icons/network-shield.d.ts +2 -2
  123. package/dist/icons/network.d.ts +2 -2
  124. package/dist/icons/newspaper-fill.d.ts +2 -2
  125. package/dist/icons/number.d.ts +2 -2
  126. package/dist/icons/paperplane-fill.d.ts +2 -2
  127. package/dist/icons/pause-fill.d.ts +2 -0
  128. package/dist/icons/person-crop-square.d.ts +2 -2
  129. package/dist/icons/person-fill-questionmark.d.ts +2 -2
  130. package/dist/icons/person-fill.d.ts +2 -2
  131. package/dist/icons/person.d.ts +2 -2
  132. package/dist/icons/phone-arrow-up-right.d.ts +2 -2
  133. package/dist/icons/phone-fill.d.ts +2 -2
  134. package/dist/icons/phone.d.ts +2 -2
  135. package/dist/icons/photo-badge-arrow-down-fill.d.ts +2 -0
  136. package/dist/icons/photo-badge-arrow-down.d.ts +2 -0
  137. package/dist/icons/play-fill.d.ts +2 -0
  138. package/dist/icons/play-rectangle-fill.d.ts +2 -2
  139. package/dist/icons/plus.d.ts +2 -2
  140. package/dist/icons/qrcode.d.ts +2 -2
  141. package/dist/icons/rectangle-fill-on-arrow-down-forward-topleading-rectangle.d.ts +2 -0
  142. package/dist/icons/rectangle-fill.d.ts +2 -0
  143. package/dist/icons/rectangle-portrait-and-arrow-left-fill.d.ts +2 -2
  144. package/dist/icons/rectangle-portrait-and-arrow-left.d.ts +2 -2
  145. package/dist/icons/rectangle-triangle-up.d.ts +2 -0
  146. package/dist/icons/rectangle.d.ts +2 -0
  147. package/dist/icons/sensor.d.ts +2 -2
  148. package/dist/icons/signature.d.ts +2 -2
  149. package/dist/icons/solar-panel.d.ts +2 -2
  150. package/dist/icons/speaker-fill.d.ts +2 -0
  151. package/dist/icons/speaker-minus-fill.d.ts +2 -0
  152. package/dist/icons/speaker-minus.d.ts +2 -0
  153. package/dist/icons/speaker-plus-fill.d.ts +2 -0
  154. package/dist/icons/speaker-plus.d.ts +2 -0
  155. package/dist/icons/speaker-slash-fill.d.ts +2 -0
  156. package/dist/icons/speaker-slash.d.ts +2 -0
  157. package/dist/icons/speaker-wave-1-fill.d.ts +2 -0
  158. package/dist/icons/speaker-wave-1.d.ts +2 -0
  159. package/dist/icons/speaker-wave-2-fill.d.ts +2 -0
  160. package/dist/icons/speaker-wave-2.d.ts +2 -0
  161. package/dist/icons/speaker-wave-3-fill.d.ts +2 -0
  162. package/dist/icons/speaker-wave-3.d.ts +2 -0
  163. package/dist/icons/speaker.d.ts +2 -0
  164. package/dist/icons/square-and-arrow-down-fill.d.ts +2 -2
  165. package/dist/icons/square-and-arrow-down.d.ts +2 -2
  166. package/dist/icons/square-and-arrow-up-fill.d.ts +2 -2
  167. package/dist/icons/square-and-arrow-up.d.ts +2 -2
  168. package/dist/icons/square-and-pencil-fill.d.ts +2 -2
  169. package/dist/icons/square-and-pencil.d.ts +2 -2
  170. package/dist/icons/text-bubble.d.ts +2 -2
  171. package/dist/icons/trash-fill.d.ts +2 -2
  172. package/dist/icons/trash.d.ts +2 -2
  173. package/dist/icons/tree.d.ts +2 -2
  174. package/dist/icons/umbrella-fill.d.ts +2 -2
  175. package/dist/icons/xmark.d.ts +2 -2
  176. package/dist/icons.esm.js +162 -2
  177. package/dist/icons.esm.js.map +1 -1
  178. package/dist/icons.js +203 -3
  179. package/dist/icons.js.map +1 -1
  180. package/dist/index.esm.js +891 -129
  181. package/dist/index.esm.js.map +1 -1
  182. package/dist/index.js +892 -126
  183. package/dist/index.js.map +1 -1
  184. package/dist/types/index.d.ts +1 -2
  185. package/dist/types/utils.d.ts +20 -0
  186. package/dist/utils/get-date.d.ts +17 -0
  187. package/dist/utils/index.d.ts +8 -9
  188. package/dist/utils/string-manipulation.d.ts +38 -3
  189. package/dist/utils/tw-sort.d.ts +1 -1
  190. package/dist/utils.esm.js +112 -21
  191. package/dist/utils.esm.js.map +1 -1
  192. package/dist/utils.js +113 -20
  193. package/dist/utils.js.map +1 -1
  194. package/package.json +95 -94
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes } from 'react';
2
- export default function createFastContext<Store>(defaultInitialState: Store): {
2
+ export declare function createFastContext<Store>(defaultInitialState: Store): {
3
3
  Provider: ({ initialValue, ...props }: Pick<HTMLAttributes<HTMLElement>, "children"> & {
4
4
  initialValue?: Store;
5
5
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import createFastContext from './create-fast-context';
2
- import { defineField, Field, FieldType, FormContext, FormContextProvider, useFormContext } from './use-form-context';
3
- import { FormStatus, FormStatusProvider, useFormStatus } from './use-form-status';
4
- export { createFastContext, defineField, Field, FieldType, FormContext, FormContextProvider, useFormContext, FormStatus, FormStatusProvider, useFormStatus, };
1
+ export * from './create-fast-context';
2
+ export * from './use-fieldset-context';
3
+ export * from './use-form-context';
4
+ export * from './use-form-status';
@@ -0,0 +1,22 @@
1
+ import { Field } from './use-form-context';
2
+ export type FieldsetContextValue = {
3
+ fieldList: Field[];
4
+ decorative: boolean;
5
+ id: string;
6
+ join?: string;
7
+ name: string;
8
+ };
9
+ export type FieldsetContext = [
10
+ FieldsetContextValue | undefined,
11
+ {
12
+ registerField: (field: Field) => void;
13
+ removeField: (fieldID: string) => void;
14
+ updateField: (fieldID: string, updates: Partial<Field>) => void;
15
+ }
16
+ ];
17
+ import { ReactNode } from 'react';
18
+ export declare function FieldsetContextProvider({ children, initialValue, }: {
19
+ children?: ReactNode;
20
+ initialValue?: FieldsetContextValue;
21
+ }): import("react/jsx-runtime").JSX.Element;
22
+ export declare function useFieldsetContext(): FieldsetContext;
@@ -1,30 +1,38 @@
1
- import { ReactNode } from 'react';
2
1
  export type FieldType = 'array' | 'email' | 'file' | 'number' | 'object' | 'string' | 'tel' | 'textarea' | 'url';
3
- type ArrayObjectOrNormalField = {
2
+ export type StringField = {
4
3
  type: 'email' | 'file' | 'number' | 'string' | 'tel' | 'textarea' | 'url';
5
- } | {
6
- type: 'array';
7
- of: ArrayObjectOrNormalField;
8
- } | {
4
+ value: string;
5
+ required?: boolean;
6
+ invalid?: boolean;
7
+ };
8
+ export type ObjectField = {
9
9
  type: 'object';
10
10
  fields: Field[];
11
11
  };
12
+ export type ArrayField = {
13
+ type: 'array';
14
+ of: ArrayObjectOrNormalField;
15
+ };
16
+ type ArrayObjectOrNormalField = StringField | ArrayField | ObjectField;
12
17
  export type Field = ArrayObjectOrNormalField & {
13
18
  id: string;
14
- invalid?: boolean;
15
19
  name: string;
16
- required?: boolean;
17
- value: string;
18
20
  };
19
21
  export type FormContext = Field[];
22
+ import { ReactNode } from 'react';
20
23
  /**
21
24
  * # Define Field
22
25
  *
23
26
  * This is a helper function to define a field in a form context with type safety.
24
27
  */
25
28
  export declare function defineField(fieldDefinition: Field): Field;
29
+ export declare function isStringField(field: Field): boolean;
26
30
  export declare function FormContextProvider({ children }: {
27
31
  children?: ReactNode;
28
32
  }): import("react/jsx-runtime").JSX.Element;
29
- export declare function useFormContext(): [FormContext | undefined, ((value: FormContext | ((prevState: FormContext) => FormContext)) => void) | undefined];
33
+ export declare function useFormContext(): readonly [FormContext | undefined, {
34
+ readonly registerField: (field: Field) => void;
35
+ readonly removeField: (fieldID: string) => void;
36
+ readonly updateField: (fieldID: string, updates: Partial<Field>) => void;
37
+ }];
30
38
  export {};
package/dist/hooks.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useContext, useSyncExternalStore, useRef, Suspense } from 'react';
2
+ import { createContext, useContext, useSyncExternalStore, useRef, useCallback, useEffect, Suspense } from 'react';
3
3
 
4
4
  function createFastContext(defaultInitialState) {
5
5
  function useStoreData(initialState = defaultInitialState) {
@@ -52,12 +52,106 @@ function createFastContext(defaultInitialState) {
52
52
  function defineField(fieldDefinition) {
53
53
  return fieldDefinition;
54
54
  }
55
- const { Provider: Provider$1, useStore: useStore$1 } = createFastContext([]);
55
+ function isStringField(field) {
56
+ return Boolean(field.type !== 'object' && field.type !== 'array');
57
+ }
58
+ const { Provider: Provider$2, useStore: useStore$2 } = createFastContext([]);
56
59
  function FormContextProvider({ children }) {
57
- return jsx(Provider$1, { children: children });
60
+ return jsx(Provider$2, { children: children });
58
61
  }
59
62
  function useFormContext() {
60
- return useStore$1(store => store);
63
+ const [formContext, setFormContext] = useStore$2(store => store);
64
+ const registerField = useCallback((field) => {
65
+ setFormContext?.(prevContext => {
66
+ const otherFields = (prevContext || []).filter(otherField => otherField.id !== field.id);
67
+ return [...otherFields, field];
68
+ });
69
+ }, []);
70
+ const removeField = useCallback((fieldID) => {
71
+ setFormContext?.(prevContext => (prevContext || []).filter(field => field.id !== fieldID));
72
+ }, []);
73
+ const updateField = useCallback((fieldID, updates) => {
74
+ setFormContext?.(prevContext => {
75
+ const field = prevContext.find(({ id }) => id === fieldID);
76
+ if (!field)
77
+ throw new Error(`Field with id "${fieldID}" not found in form context.`);
78
+ const otherFields = prevContext.filter(({ id }) => id !== fieldID);
79
+ const updatedField = { ...field, ...updates };
80
+ return [...otherFields, updatedField];
81
+ });
82
+ }, []);
83
+ return [formContext, { registerField, removeField, updateField }];
84
+ }
85
+
86
+ const { Provider: Provider$1, useStore: useStore$1 } = createFastContext(undefined);
87
+ function FieldsetContextProvider({ children, initialValue, }) {
88
+ return jsx(Provider$1, { initialValue: initialValue, children: children });
89
+ }
90
+ function useFieldsetContext() {
91
+ const [fieldsetContext, setFieldsetContext] = useStore$1(store => store), [, formContextFunctions] = useFormContext();
92
+ const registerField = useCallback((field) => {
93
+ setFieldsetContext?.(prev => {
94
+ if (!prev)
95
+ return prev;
96
+ const existingFieldIndex = prev.fieldList.findIndex(existingField => existingField.id === field.id);
97
+ const newFieldList = existingFieldIndex >= 0
98
+ ? prev.fieldList.map((existingField, index) => (index === existingFieldIndex ? field : existingField))
99
+ : [...prev.fieldList, field];
100
+ return { ...prev, fieldList: newFieldList };
101
+ });
102
+ }, []);
103
+ const removeField = useCallback((fieldID) => {
104
+ setFieldsetContext?.(prev => {
105
+ if (!prev)
106
+ return prev;
107
+ return {
108
+ ...prev,
109
+ fieldList: prev.fieldList.filter(field => field.id !== fieldID),
110
+ };
111
+ });
112
+ }, []);
113
+ const updateField = useCallback((fieldID, updates) => {
114
+ setFieldsetContext?.(prev => {
115
+ if (!prev)
116
+ return prev;
117
+ return {
118
+ ...prev,
119
+ fieldList: prev.fieldList.map(field => (field.id === fieldID ? { ...field, ...updates } : field)),
120
+ };
121
+ });
122
+ }, []);
123
+ const createFormContextEntry = useCallback((fieldsetEntry) => {
124
+ if (fieldsetEntry.join) {
125
+ const joinedValue = fieldsetEntry.fieldList
126
+ .filter(field => isStringField(field) && field.value !== '')
127
+ .map(field => field.value)
128
+ .join(fieldsetEntry.join);
129
+ return defineField({
130
+ type: 'string',
131
+ id: fieldsetEntry.id,
132
+ name: fieldsetEntry.name,
133
+ value: joinedValue,
134
+ required: fieldsetEntry.fieldList.some(field => field.required),
135
+ invalid: fieldsetEntry.fieldList.some(field => field.invalid),
136
+ });
137
+ }
138
+ return defineField({
139
+ type: 'object',
140
+ id: fieldsetEntry.id,
141
+ name: fieldsetEntry.name,
142
+ fields: fieldsetEntry.fieldList,
143
+ });
144
+ }, []);
145
+ useEffect(() => {
146
+ if (!fieldsetContext || fieldsetContext.decorative)
147
+ return;
148
+ const formContextEntry = createFormContextEntry(fieldsetContext);
149
+ formContextFunctions.registerField(formContextEntry);
150
+ return () => {
151
+ formContextFunctions.removeField(fieldsetContext.id);
152
+ };
153
+ }, [fieldsetContext, formContextFunctions.registerField, formContextFunctions.removeField, createFormContextEntry]);
154
+ return [fieldsetContext, { registerField, removeField, updateField }];
61
155
  }
62
156
 
63
157
  const DEFAULT_STATUS = 'incomplete';
@@ -69,5 +163,5 @@ function useFormStatus() {
69
163
  return useStore(store => store);
70
164
  }
71
165
 
72
- export { FormContextProvider, FormStatusProvider, createFastContext, defineField, useFormContext, useFormStatus };
166
+ export { FieldsetContextProvider, FormContextProvider, FormStatusProvider, createFastContext, defineField, isStringField, useFieldsetContext, useFormContext, useFormStatus };
73
167
  //# sourceMappingURL=hooks.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.esm.js","sources":["../src/hooks/create-fast-context.tsx","../src/hooks/use-form-context.tsx","../src/hooks/use-form-status.tsx"],"sourcesContent":["// * React\nimport { HTMLAttributes, useRef, createContext, useContext, useSyncExternalStore } from 'react'\n\nexport default function createFastContext<Store>(defaultInitialState: Store) {\n\tfunction useStoreData(initialState: Store = defaultInitialState): {\n\t\tget: () => Store\n\t\tset: (value: Store | ((prevState: Store) => Store)) => void\n\t\tsubscribe: (callback: () => void) => () => void\n\t} {\n\t\tconst store = useRef(initialState),\n\t\t\tget = () => store.current,\n\t\t\tsubscribers = useRef(new Set<() => void>())\n\n\t\tconst set = (value: Store | ((prevState: Store) => Store)) => {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\tstore.current = (value as (prevState: Store) => Store)(store.current)\n\t\t\t} else {\n\t\t\t\tstore.current = value\n\t\t\t}\n\t\t\tsubscribers.current.forEach(callback => callback())\n\t\t}\n\n\t\tconst subscribe = (callback: () => void) => {\n\t\t\tsubscribers.current.add(callback)\n\t\t\treturn () => subscribers.current.delete(callback)\n\t\t}\n\n\t\treturn {\n\t\t\tget,\n\t\t\tset,\n\t\t\tsubscribe,\n\t\t}\n\t}\n\n\ttype UseStoreDataReturnType = ReturnType<typeof useStoreData>\n\n\tconst StoreContext = createContext<UseStoreDataReturnType | null>(null)\n\n\tfunction Provider({\n\t\tinitialValue = defaultInitialState,\n\t\t...props\n\t}: Pick<HTMLAttributes<HTMLElement>, 'children'> & { initialValue?: Store }) {\n\t\treturn <StoreContext.Provider value={useStoreData(initialValue)} {...props} />\n\t}\n\n\tfunction useStore<SelectorOutput>(\n\t\tselector: (store: Store) => SelectorOutput,\n\t\tinitialValue?: Store,\n\t): [SelectorOutput | undefined, ((value: Store | ((prevState: Store) => Store)) => void) | undefined] {\n\t\tconst store = useContext(StoreContext)\n\n\t\tif (!store) {\n\t\t\tconst localStoreValue = initialValue !== undefined ? initialValue : defaultInitialState\n\n\t\t\tconst selectedValue = selector(localStoreValue)\n\t\t\tconst noOpSet = () => console.warn('Attempting to set store value outside of Provider')\n\n\t\t\treturn [selectedValue, noOpSet]\n\t\t}\n\n\t\tconst state = useSyncExternalStore(\n\t\t\tstore.subscribe,\n\t\t\t() => selector(store.get()),\n\t\t\t() => selector(initialValue !== undefined ? initialValue : defaultInitialState),\n\t\t)\n\n\t\treturn [state, store.set]\n\t}\n\n\treturn {\n\t\tProvider,\n\t\tuseStore,\n\t}\n}\n","// * Types\nimport { ReactNode } from 'react'\n\nexport type FieldType = 'array' | 'email' | 'file' | 'number' | 'object' | 'string' | 'tel' | 'textarea' | 'url'\n\ntype ArrayObjectOrNormalField =\n\t| { type: 'email' | 'file' | 'number' | 'string' | 'tel' | 'textarea' | 'url' }\n\t| { type: 'array'; of: ArrayObjectOrNormalField }\n\t| { type: 'object'; fields: Field[] }\n\nexport type Field = ArrayObjectOrNormalField & {\n\tid: string\n\tinvalid?: boolean\n\tname: string\n\trequired?: boolean\n\tvalue: string\n}\n\nexport type FormContext = Field[]\n\n// * Hooks\nimport createFastContext from './create-fast-context'\n\n/**\n * # Define Field\n *\n * This is a helper function to define a field in a form context with type safety.\n */\nexport function defineField(fieldDefinition: Field) {\n\treturn fieldDefinition\n}\n\nconst { Provider, useStore } = createFastContext<FormContext>([])\n\nexport function FormContextProvider({ children }: { children?: ReactNode }) {\n\treturn <Provider>{children}</Provider>\n}\n\nexport function useFormContext() {\n\treturn useStore(store => store)\n}\n","// * Types\nimport { ReactNode, Suspense } from 'react'\n\nexport type FormStatus = 'error' | 'incomplete' | 'loading' | 'ready' | 'success' | 'readonly'\n\n// * Hooks\nimport createFastContext from './create-fast-context'\n\nconst DEFAULT_STATUS: FormStatus = 'incomplete'\n\nconst { Provider, useStore } = createFastContext<FormStatus>(DEFAULT_STATUS)\n\nexport function FormStatusProvider({\n\tchildren,\n\tinitialStatus = DEFAULT_STATUS,\n}: {\n\tchildren?: ReactNode\n\tinitialStatus?: FormStatus\n}) {\n\treturn (\n\t\t<Suspense>\n\t\t\t<Provider initialValue={initialStatus}>{children}</Provider>\n\t\t</Suspense>\n\t)\n}\n\nexport function useFormStatus() {\n\treturn useStore(store => store)\n}\n"],"names":["_jsx","Provider","useStore"],"mappings":";;;AAGc,SAAU,iBAAiB,CAAQ,mBAA0B,EAAA;IAC1E,SAAS,YAAY,CAAC,YAAA,GAAsB,mBAAmB,EAAA;QAK9D,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,EACjC,GAAG,GAAG,MAAM,KAAK,CAAC,OAAO,EACzB,WAAW,GAAG,MAAM,CAAC,IAAI,GAAG,EAAc,CAAC;AAE5C,QAAA,MAAM,GAAG,GAAG,CAAC,KAA4C,KAAI;AAC5D,YAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAChC,KAAK,CAAC,OAAO,GAAI,KAAqC,CAAC,KAAK,CAAC,OAAO,CAAC;;iBAC/D;AACN,gBAAA,KAAK,CAAC,OAAO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,EAAE,KAAK,CAAC,GAAG,CAAC;;IAG1B,OAAO;QACN,QAAQ;QACR,QAAQ;KACR;AACF;;AClDA;;;;AAIG;AACG,SAAU,WAAW,CAAC,eAAsB,EAAA;AACjD,IAAA,OAAO,eAAe;AACvB;AAEA,MAAM,YAAEC,UAAQ,YAAEC,UAAQ,EAAE,GAAG,iBAAiB,CAAc,EAAE,CAAC;AAE3D,SAAU,mBAAmB,CAAC,EAAE,QAAQ,EAA4B,EAAA;AACzE,IAAA,OAAOF,GAAA,CAACC,UAAQ,EAAA,EAAA,QAAA,EAAE,QAAQ,GAAY;AACvC;SAEgB,cAAc,GAAA;IAC7B,OAAOC,UAAQ,CAAC,KAAK,IAAI,KAAK,CAAC;AAChC;;AChCA,MAAM,cAAc,GAAe,YAAY;AAE/C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAAa,cAAc,CAAC;AAEtE,SAAU,kBAAkB,CAAC,EAClC,QAAQ,EACR,aAAa,GAAG,cAAc,GAI9B,EAAA;AACA,IAAA,QACCF,GAAA,CAAC,QAAQ,EAAA,EAAA,QAAA,EACRA,IAAC,QAAQ,EAAA,EAAC,YAAY,EAAE,aAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAY,EAAA,CAClD;AAEb;SAEgB,aAAa,GAAA;IAC5B,OAAO,QAAQ,CAAC,KAAK,IAAI,KAAK,CAAC;AAChC;;;;"}
1
+ {"version":3,"file":"hooks.esm.js","sources":["../src/hooks/create-fast-context.tsx","../src/hooks/use-form-context.tsx","../src/hooks/use-fieldset-context.tsx","../src/hooks/use-form-status.tsx"],"sourcesContent":["// * React\nimport { HTMLAttributes, useRef, createContext, useContext, useSyncExternalStore } from 'react'\n\nexport function createFastContext<Store>(defaultInitialState: Store) {\n\tfunction useStoreData(initialState: Store = defaultInitialState): {\n\t\tget: () => Store\n\t\tset: (value: Store | ((prevState: Store) => Store)) => void\n\t\tsubscribe: (callback: () => void) => () => void\n\t} {\n\t\tconst store = useRef(initialState),\n\t\t\tget = () => store.current,\n\t\t\tsubscribers = useRef(new Set<() => void>())\n\n\t\tconst set = (value: Store | ((prevState: Store) => Store)) => {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\tstore.current = (value as (prevState: Store) => Store)(store.current)\n\t\t\t} else {\n\t\t\t\tstore.current = value\n\t\t\t}\n\t\t\tsubscribers.current.forEach(callback => callback())\n\t\t}\n\n\t\tconst subscribe = (callback: () => void) => {\n\t\t\tsubscribers.current.add(callback)\n\t\t\treturn () => subscribers.current.delete(callback)\n\t\t}\n\n\t\treturn {\n\t\t\tget,\n\t\t\tset,\n\t\t\tsubscribe,\n\t\t}\n\t}\n\n\ttype UseStoreDataReturnType = ReturnType<typeof useStoreData>\n\n\tconst StoreContext = createContext<UseStoreDataReturnType | null>(null)\n\n\tfunction Provider({\n\t\tinitialValue = defaultInitialState,\n\t\t...props\n\t}: Pick<HTMLAttributes<HTMLElement>, 'children'> & { initialValue?: Store }) {\n\t\treturn <StoreContext.Provider value={useStoreData(initialValue)} {...props} />\n\t}\n\n\tfunction useStore<SelectorOutput>(\n\t\tselector: (store: Store) => SelectorOutput,\n\t\tinitialValue?: Store,\n\t): [SelectorOutput | undefined, ((value: Store | ((prevState: Store) => Store)) => void) | undefined] {\n\t\tconst store = useContext(StoreContext)\n\n\t\tif (!store) {\n\t\t\tconst localStoreValue = initialValue !== undefined ? initialValue : defaultInitialState\n\n\t\t\tconst selectedValue = selector(localStoreValue)\n\t\t\tconst noOpSet = () => console.warn('Attempting to set store value outside of Provider')\n\n\t\t\treturn [selectedValue, noOpSet]\n\t\t}\n\n\t\tconst state = useSyncExternalStore(\n\t\t\tstore.subscribe,\n\t\t\t() => selector(store.get()),\n\t\t\t() => selector(initialValue !== undefined ? initialValue : defaultInitialState),\n\t\t)\n\n\t\treturn [state, store.set]\n\t}\n\n\treturn {\n\t\tProvider,\n\t\tuseStore,\n\t}\n}\n","// * Types\nexport type FieldType = 'array' | 'email' | 'file' | 'number' | 'object' | 'string' | 'tel' | 'textarea' | 'url'\n\nexport type StringField = {\n\ttype: 'email' | 'file' | 'number' | 'string' | 'tel' | 'textarea' | 'url'\n\tvalue: string\n\trequired?: boolean\n\tinvalid?: boolean\n}\n\nexport type ObjectField = { type: 'object'; fields: Field[] }\n\nexport type ArrayField = { type: 'array'; of: ArrayObjectOrNormalField }\n\ntype ArrayObjectOrNormalField = StringField | ArrayField | ObjectField\n\nexport type Field = ArrayObjectOrNormalField & {\n\tid: string\n\tname: string\n}\n\nexport type FormContext = Field[]\n\n// * React\nimport { ReactNode, useCallback } from 'react'\n\n// * Hooks\nimport { createFastContext } from './create-fast-context'\n\n/**\n * # Define Field\n *\n * This is a helper function to define a field in a form context with type safety.\n */\nexport function defineField(fieldDefinition: Field) {\n\treturn fieldDefinition\n}\n\nexport function isStringField(field: Field) {\n\treturn Boolean(field.type !== 'object' && field.type !== 'array')\n}\n\nconst { Provider, useStore } = createFastContext<FormContext>([])\n\nexport function FormContextProvider({ children }: { children?: ReactNode }) {\n\treturn <Provider>{children}</Provider>\n}\n\nexport function useFormContext() {\n\tconst [formContext, setFormContext] = useStore(store => store)\n\n\tconst registerField = useCallback((field: Field) => {\n\t\tsetFormContext?.(prevContext => {\n\t\t\tconst otherFields = (prevContext || []).filter(otherField => otherField.id !== field.id)\n\n\t\t\treturn [...otherFields, field]\n\t\t})\n\t}, [])\n\n\tconst removeField = useCallback((fieldID: string) => {\n\t\tsetFormContext?.(prevContext => (prevContext || []).filter(field => field.id !== fieldID))\n\t}, [])\n\n\tconst updateField = useCallback((fieldID: string, updates: Partial<Field>) => {\n\t\tsetFormContext?.(prevContext => {\n\t\t\tconst field = prevContext.find(({ id }) => id === fieldID)\n\n\t\t\tif (!field) throw new Error(`Field with id \"${fieldID}\" not found in form context.`)\n\n\t\t\tconst otherFields = prevContext.filter(({ id }) => id !== fieldID)\n\n\t\t\tconst updatedField = { ...field, ...updates } as Field\n\n\t\t\treturn [...otherFields, updatedField]\n\t\t})\n\t}, [])\n\n\treturn [formContext, { registerField, removeField, updateField }] as const\n}\n","// * Types\nimport { defineField, Field, isStringField, StringField, useFormContext } from './use-form-context'\n\nexport type FieldsetContextValue = {\n\tfieldList: Field[]\n\tdecorative: boolean\n\tid: string\n\tjoin?: string\n\tname: string\n}\n\nexport type FieldsetContext = [\n\tFieldsetContextValue | undefined,\n\t{\n\t\tregisterField: (field: Field) => void\n\t\tremoveField: (fieldID: string) => void\n\t\tupdateField: (fieldID: string, updates: Partial<Field>) => void\n\t},\n]\n\n// * React\nimport { ReactNode, useCallback, useEffect } from 'react'\n\n// * Hooks\nimport { createFastContext } from './create-fast-context'\n\nconst { Provider, useStore } = createFastContext<FieldsetContextValue | undefined>(undefined)\n\nexport function FieldsetContextProvider({\n\tchildren,\n\tinitialValue,\n}: {\n\tchildren?: ReactNode\n\tinitialValue?: FieldsetContextValue\n}) {\n\treturn <Provider initialValue={initialValue}>{children}</Provider>\n}\n\nexport function useFieldsetContext(): FieldsetContext {\n\tconst [fieldsetContext, setFieldsetContext] = useStore(store => store),\n\t\t[, formContextFunctions] = useFormContext()\n\n\tconst registerField = useCallback((field: Field) => {\n\t\tsetFieldsetContext?.(prev => {\n\t\t\tif (!prev) return prev\n\n\t\t\tconst existingFieldIndex = prev.fieldList.findIndex(existingField => existingField.id === field.id)\n\n\t\t\tconst newFieldList =\n\t\t\t\texistingFieldIndex >= 0\n\t\t\t\t\t? prev.fieldList.map((existingField, index) => (index === existingFieldIndex ? field : existingField))\n\t\t\t\t\t: [...prev.fieldList, field]\n\n\t\t\treturn { ...prev, fieldList: newFieldList }\n\t\t})\n\t}, [])\n\n\tconst removeField = useCallback((fieldID: string) => {\n\t\tsetFieldsetContext?.(prev => {\n\t\t\tif (!prev) return prev\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfieldList: prev.fieldList.filter(field => field.id !== fieldID),\n\t\t\t}\n\t\t})\n\t}, [])\n\n\tconst updateField = useCallback((fieldID: string, updates: Partial<Field>) => {\n\t\tsetFieldsetContext?.(prev => {\n\t\t\tif (!prev) return prev\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfieldList: prev.fieldList.map(field => (field.id === fieldID ? ({ ...field, ...updates } as Field) : field)),\n\t\t\t}\n\t\t})\n\t}, [])\n\n\tconst createFormContextEntry = useCallback((fieldsetEntry: FieldsetContextValue): Field => {\n\t\tif (fieldsetEntry.join) {\n\t\t\tconst joinedValue = fieldsetEntry.fieldList\n\t\t\t\t.filter(field => isStringField(field) && (field as StringField).value !== '')\n\t\t\t\t.map(field => (field as StringField).value)\n\t\t\t\t.join(fieldsetEntry.join)\n\n\t\t\treturn defineField({\n\t\t\t\ttype: 'string',\n\t\t\t\tid: fieldsetEntry.id,\n\t\t\t\tname: fieldsetEntry.name,\n\t\t\t\tvalue: joinedValue,\n\t\t\t\trequired: fieldsetEntry.fieldList.some(field => (field as StringField).required),\n\t\t\t\tinvalid: fieldsetEntry.fieldList.some(field => (field as StringField).invalid),\n\t\t\t})\n\t\t}\n\n\t\treturn defineField({\n\t\t\ttype: 'object',\n\t\t\tid: fieldsetEntry.id,\n\t\t\tname: fieldsetEntry.name,\n\t\t\tfields: fieldsetEntry.fieldList,\n\t\t})\n\t}, [])\n\n\tuseEffect(() => {\n\t\tif (!fieldsetContext || fieldsetContext.decorative) return\n\n\t\tconst formContextEntry = createFormContextEntry(fieldsetContext)\n\n\t\tformContextFunctions.registerField(formContextEntry)\n\n\t\treturn () => {\n\t\t\tformContextFunctions.removeField(fieldsetContext.id)\n\t\t}\n\t}, [fieldsetContext, formContextFunctions.registerField, formContextFunctions.removeField, createFormContextEntry])\n\n\treturn [fieldsetContext, { registerField, removeField, updateField }]\n}\n","// * Types\nimport { ReactNode, Suspense } from 'react'\n\nexport type FormStatus = 'error' | 'incomplete' | 'loading' | 'ready' | 'success' | 'readonly'\n\n// * Hooks\nimport { createFastContext } from './create-fast-context'\n\nconst DEFAULT_STATUS: FormStatus = 'incomplete'\n\nconst { Provider, useStore } = createFastContext<FormStatus>(DEFAULT_STATUS)\n\nexport function FormStatusProvider({\n\tchildren,\n\tinitialStatus = DEFAULT_STATUS,\n}: {\n\tchildren?: ReactNode\n\tinitialStatus?: FormStatus\n}) {\n\treturn (\n\t\t<Suspense>\n\t\t\t<Provider initialValue={initialStatus}>{children}</Provider>\n\t\t</Suspense>\n\t)\n}\n\nexport function useFormStatus() {\n\treturn useStore(store => store)\n}\n"],"names":["_jsx","Provider","useStore"],"mappings":";;;AAGM,SAAU,iBAAiB,CAAQ,mBAA0B,EAAA;IAClE,SAAS,YAAY,CAAC,YAAA,GAAsB,mBAAmB,EAAA;QAK9D,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,EACjC,GAAG,GAAG,MAAM,KAAK,CAAC,OAAO,EACzB,WAAW,GAAG,MAAM,CAAC,IAAI,GAAG,EAAc,CAAC;AAE5C,QAAA,MAAM,GAAG,GAAG,CAAC,KAA4C,KAAI;AAC5D,YAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAChC,KAAK,CAAC,OAAO,GAAI,KAAqC,CAAC,KAAK,CAAC,OAAO,CAAC;YACtE;iBAAO;AACN,gBAAA,KAAK,CAAC,OAAO,GAAG,KAAK;YACtB;AACA,YAAA,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;AACpD,QAAA,CAAC;AAED,QAAA,MAAM,SAAS,GAAG,CAAC,QAAoB,KAAI;AAC1C,YAAA,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACjC,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;AAClD,QAAA,CAAC;QAED,OAAO;YACN,GAAG;YACH,GAAG;YACH,SAAS;SACT;IACF;AAIA,IAAA,MAAM,YAAY,GAAG,aAAa,CAAgC,IAAI,CAAC;IAEvE,SAAS,QAAQ,CAAC,EACjB,YAAY,GAAG,mBAAmB,EAClC,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,EAAA,EAAA,QAAA,EACRA,IAAC,QAAQ,EAAA,EAAC,YAAY,EAAE,aAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAY,EAAA,CAClD;AAEb;SAEgB,aAAa,GAAA;IAC5B,OAAO,QAAQ,CAAC,KAAK,IAAI,KAAK,CAAC;AAChC;;;;"}
package/dist/hooks.js CHANGED
@@ -54,12 +54,106 @@ function createFastContext(defaultInitialState) {
54
54
  function defineField(fieldDefinition) {
55
55
  return fieldDefinition;
56
56
  }
57
- const { Provider: Provider$1, useStore: useStore$1 } = createFastContext([]);
57
+ function isStringField(field) {
58
+ return Boolean(field.type !== 'object' && field.type !== 'array');
59
+ }
60
+ const { Provider: Provider$2, useStore: useStore$2 } = createFastContext([]);
58
61
  function FormContextProvider({ children }) {
59
- return jsxRuntime.jsx(Provider$1, { children: children });
62
+ return jsxRuntime.jsx(Provider$2, { children: children });
60
63
  }
61
64
  function useFormContext() {
62
- return useStore$1(store => store);
65
+ const [formContext, setFormContext] = useStore$2(store => store);
66
+ const registerField = react.useCallback((field) => {
67
+ setFormContext?.(prevContext => {
68
+ const otherFields = (prevContext || []).filter(otherField => otherField.id !== field.id);
69
+ return [...otherFields, field];
70
+ });
71
+ }, []);
72
+ const removeField = react.useCallback((fieldID) => {
73
+ setFormContext?.(prevContext => (prevContext || []).filter(field => field.id !== fieldID));
74
+ }, []);
75
+ const updateField = react.useCallback((fieldID, updates) => {
76
+ setFormContext?.(prevContext => {
77
+ const field = prevContext.find(({ id }) => id === fieldID);
78
+ if (!field)
79
+ throw new Error(`Field with id "${fieldID}" not found in form context.`);
80
+ const otherFields = prevContext.filter(({ id }) => id !== fieldID);
81
+ const updatedField = { ...field, ...updates };
82
+ return [...otherFields, updatedField];
83
+ });
84
+ }, []);
85
+ return [formContext, { registerField, removeField, updateField }];
86
+ }
87
+
88
+ const { Provider: Provider$1, useStore: useStore$1 } = createFastContext(undefined);
89
+ function FieldsetContextProvider({ children, initialValue, }) {
90
+ return jsxRuntime.jsx(Provider$1, { initialValue: initialValue, children: children });
91
+ }
92
+ function useFieldsetContext() {
93
+ const [fieldsetContext, setFieldsetContext] = useStore$1(store => store), [, formContextFunctions] = useFormContext();
94
+ const registerField = react.useCallback((field) => {
95
+ setFieldsetContext?.(prev => {
96
+ if (!prev)
97
+ return prev;
98
+ const existingFieldIndex = prev.fieldList.findIndex(existingField => existingField.id === field.id);
99
+ const newFieldList = existingFieldIndex >= 0
100
+ ? prev.fieldList.map((existingField, index) => (index === existingFieldIndex ? field : existingField))
101
+ : [...prev.fieldList, field];
102
+ return { ...prev, fieldList: newFieldList };
103
+ });
104
+ }, []);
105
+ const removeField = react.useCallback((fieldID) => {
106
+ setFieldsetContext?.(prev => {
107
+ if (!prev)
108
+ return prev;
109
+ return {
110
+ ...prev,
111
+ fieldList: prev.fieldList.filter(field => field.id !== fieldID),
112
+ };
113
+ });
114
+ }, []);
115
+ const updateField = react.useCallback((fieldID, updates) => {
116
+ setFieldsetContext?.(prev => {
117
+ if (!prev)
118
+ return prev;
119
+ return {
120
+ ...prev,
121
+ fieldList: prev.fieldList.map(field => (field.id === fieldID ? { ...field, ...updates } : field)),
122
+ };
123
+ });
124
+ }, []);
125
+ const createFormContextEntry = react.useCallback((fieldsetEntry) => {
126
+ if (fieldsetEntry.join) {
127
+ const joinedValue = fieldsetEntry.fieldList
128
+ .filter(field => isStringField(field) && field.value !== '')
129
+ .map(field => field.value)
130
+ .join(fieldsetEntry.join);
131
+ return defineField({
132
+ type: 'string',
133
+ id: fieldsetEntry.id,
134
+ name: fieldsetEntry.name,
135
+ value: joinedValue,
136
+ required: fieldsetEntry.fieldList.some(field => field.required),
137
+ invalid: fieldsetEntry.fieldList.some(field => field.invalid),
138
+ });
139
+ }
140
+ return defineField({
141
+ type: 'object',
142
+ id: fieldsetEntry.id,
143
+ name: fieldsetEntry.name,
144
+ fields: fieldsetEntry.fieldList,
145
+ });
146
+ }, []);
147
+ react.useEffect(() => {
148
+ if (!fieldsetContext || fieldsetContext.decorative)
149
+ return;
150
+ const formContextEntry = createFormContextEntry(fieldsetContext);
151
+ formContextFunctions.registerField(formContextEntry);
152
+ return () => {
153
+ formContextFunctions.removeField(fieldsetContext.id);
154
+ };
155
+ }, [fieldsetContext, formContextFunctions.registerField, formContextFunctions.removeField, createFormContextEntry]);
156
+ return [fieldsetContext, { registerField, removeField, updateField }];
63
157
  }
64
158
 
65
159
  const DEFAULT_STATUS = 'incomplete';
@@ -71,10 +165,13 @@ function useFormStatus() {
71
165
  return useStore(store => store);
72
166
  }
73
167
 
168
+ exports.FieldsetContextProvider = FieldsetContextProvider;
74
169
  exports.FormContextProvider = FormContextProvider;
75
170
  exports.FormStatusProvider = FormStatusProvider;
76
171
  exports.createFastContext = createFastContext;
77
172
  exports.defineField = defineField;
173
+ exports.isStringField = isStringField;
174
+ exports.useFieldsetContext = useFieldsetContext;
78
175
  exports.useFormContext = useFormContext;
79
176
  exports.useFormStatus = useFormStatus;
80
177
  //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../src/hooks/create-fast-context.tsx","../src/hooks/use-form-context.tsx","../src/hooks/use-form-status.tsx"],"sourcesContent":["// * React\nimport { HTMLAttributes, useRef, createContext, useContext, useSyncExternalStore } from 'react'\n\nexport default function createFastContext<Store>(defaultInitialState: Store) {\n\tfunction useStoreData(initialState: Store = defaultInitialState): {\n\t\tget: () => Store\n\t\tset: (value: Store | ((prevState: Store) => Store)) => void\n\t\tsubscribe: (callback: () => void) => () => void\n\t} {\n\t\tconst store = useRef(initialState),\n\t\t\tget = () => store.current,\n\t\t\tsubscribers = useRef(new Set<() => void>())\n\n\t\tconst set = (value: Store | ((prevState: Store) => Store)) => {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\tstore.current = (value as (prevState: Store) => Store)(store.current)\n\t\t\t} else {\n\t\t\t\tstore.current = value\n\t\t\t}\n\t\t\tsubscribers.current.forEach(callback => callback())\n\t\t}\n\n\t\tconst subscribe = (callback: () => void) => {\n\t\t\tsubscribers.current.add(callback)\n\t\t\treturn () => subscribers.current.delete(callback)\n\t\t}\n\n\t\treturn {\n\t\t\tget,\n\t\t\tset,\n\t\t\tsubscribe,\n\t\t}\n\t}\n\n\ttype UseStoreDataReturnType = ReturnType<typeof useStoreData>\n\n\tconst StoreContext = createContext<UseStoreDataReturnType | null>(null)\n\n\tfunction Provider({\n\t\tinitialValue = defaultInitialState,\n\t\t...props\n\t}: Pick<HTMLAttributes<HTMLElement>, 'children'> & { initialValue?: Store }) {\n\t\treturn <StoreContext.Provider value={useStoreData(initialValue)} {...props} />\n\t}\n\n\tfunction useStore<SelectorOutput>(\n\t\tselector: (store: Store) => SelectorOutput,\n\t\tinitialValue?: Store,\n\t): [SelectorOutput | undefined, ((value: Store | ((prevState: Store) => Store)) => void) | undefined] {\n\t\tconst store = useContext(StoreContext)\n\n\t\tif (!store) {\n\t\t\tconst localStoreValue = initialValue !== undefined ? initialValue : defaultInitialState\n\n\t\t\tconst selectedValue = selector(localStoreValue)\n\t\t\tconst noOpSet = () => console.warn('Attempting to set store value outside of Provider')\n\n\t\t\treturn [selectedValue, noOpSet]\n\t\t}\n\n\t\tconst state = useSyncExternalStore(\n\t\t\tstore.subscribe,\n\t\t\t() => selector(store.get()),\n\t\t\t() => selector(initialValue !== undefined ? initialValue : defaultInitialState),\n\t\t)\n\n\t\treturn [state, store.set]\n\t}\n\n\treturn {\n\t\tProvider,\n\t\tuseStore,\n\t}\n}\n","// * Types\nimport { ReactNode } from 'react'\n\nexport type FieldType = 'array' | 'email' | 'file' | 'number' | 'object' | 'string' | 'tel' | 'textarea' | 'url'\n\ntype ArrayObjectOrNormalField =\n\t| { type: 'email' | 'file' | 'number' | 'string' | 'tel' | 'textarea' | 'url' }\n\t| { type: 'array'; of: ArrayObjectOrNormalField }\n\t| { type: 'object'; fields: Field[] }\n\nexport type Field = ArrayObjectOrNormalField & {\n\tid: string\n\tinvalid?: boolean\n\tname: string\n\trequired?: boolean\n\tvalue: string\n}\n\nexport type FormContext = Field[]\n\n// * Hooks\nimport createFastContext from './create-fast-context'\n\n/**\n * # Define Field\n *\n * This is a helper function to define a field in a form context with type safety.\n */\nexport function defineField(fieldDefinition: Field) {\n\treturn fieldDefinition\n}\n\nconst { Provider, useStore } = createFastContext<FormContext>([])\n\nexport function FormContextProvider({ children }: { children?: ReactNode }) {\n\treturn <Provider>{children}</Provider>\n}\n\nexport function useFormContext() {\n\treturn useStore(store => store)\n}\n","// * Types\nimport { ReactNode, Suspense } from 'react'\n\nexport type FormStatus = 'error' | 'incomplete' | 'loading' | 'ready' | 'success' | 'readonly'\n\n// * Hooks\nimport createFastContext from './create-fast-context'\n\nconst DEFAULT_STATUS: FormStatus = 'incomplete'\n\nconst { Provider, useStore } = createFastContext<FormStatus>(DEFAULT_STATUS)\n\nexport function FormStatusProvider({\n\tchildren,\n\tinitialStatus = DEFAULT_STATUS,\n}: {\n\tchildren?: ReactNode\n\tinitialStatus?: FormStatus\n}) {\n\treturn (\n\t\t<Suspense>\n\t\t\t<Provider initialValue={initialStatus}>{children}</Provider>\n\t\t</Suspense>\n\t)\n}\n\nexport function useFormStatus() {\n\treturn useStore(store => store)\n}\n"],"names":["useRef","createContext","_jsx","useContext","useSyncExternalStore","Provider","useStore","Suspense"],"mappings":";;;;;AAGc,SAAU,iBAAiB,CAAQ,mBAA0B,EAAA;IAC1E,SAAS,YAAY,CAAC,YAAA,GAAsB,mBAAmB,EAAA;QAK9D,MAAM,KAAK,GAAGA,YAAM,CAAC,YAAY,CAAC,EACjC,GAAG,GAAG,MAAM,KAAK,CAAC,OAAO,EACzB,WAAW,GAAGA,YAAM,CAAC,IAAI,GAAG,EAAc,CAAC;AAE5C,QAAA,MAAM,GAAG,GAAG,CAAC,KAA4C,KAAI;AAC5D,YAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAChC,KAAK,CAAC,OAAO,GAAI,KAAqC,CAAC,KAAK,CAAC,OAAO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G,mBAAmB,CAAC,CAC/E;AAED,QAAA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;;IAG1B,OAAO;QACN,QAAQ;QACR,QAAQ;KACR;AACF;;AClDA;;;;AAIG;AACG,SAAU,WAAW,CAAC,eAAsB,EAAA;AACjD,IAAA,OAAO,eAAe;AACvB;AAEA,MAAM,YAAEC,UAAQ,YAAEC,UAAQ,EAAE,GAAG,iBAAiB,CAAc,EAAE,CAAC;AAE3D,SAAU,mBAAmB,CAAC,EAAE,QAAQ,EAA4B,EAAA;AACzE,IAAA,OAAOJ,cAAA,CAACG,UAAQ,EAAA,EAAA,QAAA,EAAE,QAAQ,GAAY;AACvC;SAEgB,cAAc,GAAA;IAC7B,OAAOC,UAAQ,CAAC,KAAK,IAAI,KAAK,CAAC;AAChC;;AChCA,MAAM,cAAc,GAAe,YAAY;AAE/C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAAa,cAAc,CAAC;AAEtE,SAAU,kBAAkB,CAAC,EAClC,QAAQ,EACR,aAAa,GAAG,cAAc,GAI9B,EAAA;AACA,IAAA,QACCJ,cAAA,CAACK,cAAQ,EAAA,EAAA,QAAA,EACRL,eAAC,QAAQ,EAAA,EAAC,YAAY,EAAE,aAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAY,EAAA,CAClD;AAEb;SAEgB,aAAa,GAAA;IAC5B,OAAO,QAAQ,CAAC,KAAK,IAAI,KAAK,CAAC;AAChC;;;;;;;;;"}
1
+ {"version":3,"file":"hooks.js","sources":["../src/hooks/create-fast-context.tsx","../src/hooks/use-form-context.tsx","../src/hooks/use-fieldset-context.tsx","../src/hooks/use-form-status.tsx"],"sourcesContent":["// * React\nimport { HTMLAttributes, useRef, createContext, useContext, useSyncExternalStore } from 'react'\n\nexport function createFastContext<Store>(defaultInitialState: Store) {\n\tfunction useStoreData(initialState: Store = defaultInitialState): {\n\t\tget: () => Store\n\t\tset: (value: Store | ((prevState: Store) => Store)) => void\n\t\tsubscribe: (callback: () => void) => () => void\n\t} {\n\t\tconst store = useRef(initialState),\n\t\t\tget = () => store.current,\n\t\t\tsubscribers = useRef(new Set<() => void>())\n\n\t\tconst set = (value: Store | ((prevState: Store) => Store)) => {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\tstore.current = (value as (prevState: Store) => Store)(store.current)\n\t\t\t} else {\n\t\t\t\tstore.current = value\n\t\t\t}\n\t\t\tsubscribers.current.forEach(callback => callback())\n\t\t}\n\n\t\tconst subscribe = (callback: () => void) => {\n\t\t\tsubscribers.current.add(callback)\n\t\t\treturn () => subscribers.current.delete(callback)\n\t\t}\n\n\t\treturn {\n\t\t\tget,\n\t\t\tset,\n\t\t\tsubscribe,\n\t\t}\n\t}\n\n\ttype UseStoreDataReturnType = ReturnType<typeof useStoreData>\n\n\tconst StoreContext = createContext<UseStoreDataReturnType | null>(null)\n\n\tfunction Provider({\n\t\tinitialValue = defaultInitialState,\n\t\t...props\n\t}: Pick<HTMLAttributes<HTMLElement>, 'children'> & { initialValue?: Store }) {\n\t\treturn <StoreContext.Provider value={useStoreData(initialValue)} {...props} />\n\t}\n\n\tfunction useStore<SelectorOutput>(\n\t\tselector: (store: Store) => SelectorOutput,\n\t\tinitialValue?: Store,\n\t): [SelectorOutput | undefined, ((value: Store | ((prevState: Store) => Store)) => void) | undefined] {\n\t\tconst store = useContext(StoreContext)\n\n\t\tif (!store) {\n\t\t\tconst localStoreValue = initialValue !== undefined ? initialValue : defaultInitialState\n\n\t\t\tconst selectedValue = selector(localStoreValue)\n\t\t\tconst noOpSet = () => console.warn('Attempting to set store value outside of Provider')\n\n\t\t\treturn [selectedValue, noOpSet]\n\t\t}\n\n\t\tconst state = useSyncExternalStore(\n\t\t\tstore.subscribe,\n\t\t\t() => selector(store.get()),\n\t\t\t() => selector(initialValue !== undefined ? initialValue : defaultInitialState),\n\t\t)\n\n\t\treturn [state, store.set]\n\t}\n\n\treturn {\n\t\tProvider,\n\t\tuseStore,\n\t}\n}\n","// * Types\nexport type FieldType = 'array' | 'email' | 'file' | 'number' | 'object' | 'string' | 'tel' | 'textarea' | 'url'\n\nexport type StringField = {\n\ttype: 'email' | 'file' | 'number' | 'string' | 'tel' | 'textarea' | 'url'\n\tvalue: string\n\trequired?: boolean\n\tinvalid?: boolean\n}\n\nexport type ObjectField = { type: 'object'; fields: Field[] }\n\nexport type ArrayField = { type: 'array'; of: ArrayObjectOrNormalField }\n\ntype ArrayObjectOrNormalField = StringField | ArrayField | ObjectField\n\nexport type Field = ArrayObjectOrNormalField & {\n\tid: string\n\tname: string\n}\n\nexport type FormContext = Field[]\n\n// * React\nimport { ReactNode, useCallback } from 'react'\n\n// * Hooks\nimport { createFastContext } from './create-fast-context'\n\n/**\n * # Define Field\n *\n * This is a helper function to define a field in a form context with type safety.\n */\nexport function defineField(fieldDefinition: Field) {\n\treturn fieldDefinition\n}\n\nexport function isStringField(field: Field) {\n\treturn Boolean(field.type !== 'object' && field.type !== 'array')\n}\n\nconst { Provider, useStore } = createFastContext<FormContext>([])\n\nexport function FormContextProvider({ children }: { children?: ReactNode }) {\n\treturn <Provider>{children}</Provider>\n}\n\nexport function useFormContext() {\n\tconst [formContext, setFormContext] = useStore(store => store)\n\n\tconst registerField = useCallback((field: Field) => {\n\t\tsetFormContext?.(prevContext => {\n\t\t\tconst otherFields = (prevContext || []).filter(otherField => otherField.id !== field.id)\n\n\t\t\treturn [...otherFields, field]\n\t\t})\n\t}, [])\n\n\tconst removeField = useCallback((fieldID: string) => {\n\t\tsetFormContext?.(prevContext => (prevContext || []).filter(field => field.id !== fieldID))\n\t}, [])\n\n\tconst updateField = useCallback((fieldID: string, updates: Partial<Field>) => {\n\t\tsetFormContext?.(prevContext => {\n\t\t\tconst field = prevContext.find(({ id }) => id === fieldID)\n\n\t\t\tif (!field) throw new Error(`Field with id \"${fieldID}\" not found in form context.`)\n\n\t\t\tconst otherFields = prevContext.filter(({ id }) => id !== fieldID)\n\n\t\t\tconst updatedField = { ...field, ...updates } as Field\n\n\t\t\treturn [...otherFields, updatedField]\n\t\t})\n\t}, [])\n\n\treturn [formContext, { registerField, removeField, updateField }] as const\n}\n","// * Types\nimport { defineField, Field, isStringField, StringField, useFormContext } from './use-form-context'\n\nexport type FieldsetContextValue = {\n\tfieldList: Field[]\n\tdecorative: boolean\n\tid: string\n\tjoin?: string\n\tname: string\n}\n\nexport type FieldsetContext = [\n\tFieldsetContextValue | undefined,\n\t{\n\t\tregisterField: (field: Field) => void\n\t\tremoveField: (fieldID: string) => void\n\t\tupdateField: (fieldID: string, updates: Partial<Field>) => void\n\t},\n]\n\n// * React\nimport { ReactNode, useCallback, useEffect } from 'react'\n\n// * Hooks\nimport { createFastContext } from './create-fast-context'\n\nconst { Provider, useStore } = createFastContext<FieldsetContextValue | undefined>(undefined)\n\nexport function FieldsetContextProvider({\n\tchildren,\n\tinitialValue,\n}: {\n\tchildren?: ReactNode\n\tinitialValue?: FieldsetContextValue\n}) {\n\treturn <Provider initialValue={initialValue}>{children}</Provider>\n}\n\nexport function useFieldsetContext(): FieldsetContext {\n\tconst [fieldsetContext, setFieldsetContext] = useStore(store => store),\n\t\t[, formContextFunctions] = useFormContext()\n\n\tconst registerField = useCallback((field: Field) => {\n\t\tsetFieldsetContext?.(prev => {\n\t\t\tif (!prev) return prev\n\n\t\t\tconst existingFieldIndex = prev.fieldList.findIndex(existingField => existingField.id === field.id)\n\n\t\t\tconst newFieldList =\n\t\t\t\texistingFieldIndex >= 0\n\t\t\t\t\t? prev.fieldList.map((existingField, index) => (index === existingFieldIndex ? field : existingField))\n\t\t\t\t\t: [...prev.fieldList, field]\n\n\t\t\treturn { ...prev, fieldList: newFieldList }\n\t\t})\n\t}, [])\n\n\tconst removeField = useCallback((fieldID: string) => {\n\t\tsetFieldsetContext?.(prev => {\n\t\t\tif (!prev) return prev\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfieldList: prev.fieldList.filter(field => field.id !== fieldID),\n\t\t\t}\n\t\t})\n\t}, [])\n\n\tconst updateField = useCallback((fieldID: string, updates: Partial<Field>) => {\n\t\tsetFieldsetContext?.(prev => {\n\t\t\tif (!prev) return prev\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfieldList: prev.fieldList.map(field => (field.id === fieldID ? ({ ...field, ...updates } as Field) : field)),\n\t\t\t}\n\t\t})\n\t}, [])\n\n\tconst createFormContextEntry = useCallback((fieldsetEntry: FieldsetContextValue): Field => {\n\t\tif (fieldsetEntry.join) {\n\t\t\tconst joinedValue = fieldsetEntry.fieldList\n\t\t\t\t.filter(field => isStringField(field) && (field as StringField).value !== '')\n\t\t\t\t.map(field => (field as StringField).value)\n\t\t\t\t.join(fieldsetEntry.join)\n\n\t\t\treturn defineField({\n\t\t\t\ttype: 'string',\n\t\t\t\tid: fieldsetEntry.id,\n\t\t\t\tname: fieldsetEntry.name,\n\t\t\t\tvalue: joinedValue,\n\t\t\t\trequired: fieldsetEntry.fieldList.some(field => (field as StringField).required),\n\t\t\t\tinvalid: fieldsetEntry.fieldList.some(field => (field as StringField).invalid),\n\t\t\t})\n\t\t}\n\n\t\treturn defineField({\n\t\t\ttype: 'object',\n\t\t\tid: fieldsetEntry.id,\n\t\t\tname: fieldsetEntry.name,\n\t\t\tfields: fieldsetEntry.fieldList,\n\t\t})\n\t}, [])\n\n\tuseEffect(() => {\n\t\tif (!fieldsetContext || fieldsetContext.decorative) return\n\n\t\tconst formContextEntry = createFormContextEntry(fieldsetContext)\n\n\t\tformContextFunctions.registerField(formContextEntry)\n\n\t\treturn () => {\n\t\t\tformContextFunctions.removeField(fieldsetContext.id)\n\t\t}\n\t}, [fieldsetContext, formContextFunctions.registerField, formContextFunctions.removeField, createFormContextEntry])\n\n\treturn [fieldsetContext, { registerField, removeField, updateField }]\n}\n","// * Types\nimport { ReactNode, Suspense } from 'react'\n\nexport type FormStatus = 'error' | 'incomplete' | 'loading' | 'ready' | 'success' | 'readonly'\n\n// * Hooks\nimport { createFastContext } from './create-fast-context'\n\nconst DEFAULT_STATUS: FormStatus = 'incomplete'\n\nconst { Provider, useStore } = createFastContext<FormStatus>(DEFAULT_STATUS)\n\nexport function FormStatusProvider({\n\tchildren,\n\tinitialStatus = DEFAULT_STATUS,\n}: {\n\tchildren?: ReactNode\n\tinitialStatus?: FormStatus\n}) {\n\treturn (\n\t\t<Suspense>\n\t\t\t<Provider initialValue={initialStatus}>{children}</Provider>\n\t\t</Suspense>\n\t)\n}\n\nexport function useFormStatus() {\n\treturn useStore(store => store)\n}\n"],"names":["useRef","createContext","_jsx","useContext","useSyncExternalStore","Provider","useStore","useCallback","useEffect","Suspense"],"mappings":";;;;;AAGM,SAAU,iBAAiB,CAAQ,mBAA0B,EAAA;IAClE,SAAS,YAAY,CAAC,YAAA,GAAsB,mBAAmB,EAAA;QAK9D,MAAM,KAAK,GAAGA,YAAM,CAAC,YAAY,CAAC,EACjC,GAAG,GAAG,MAAM,KAAK,CAAC,OAAO,EACzB,WAAW,GAAGA,YAAM,CAAC,IAAI,GAAG,EAAc,CAAC;AAE5C,QAAA,MAAM,GAAG,GAAG,CAAC,KAA4C,KAAI;AAC5D,YAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAChC,KAAK,CAAC,OAAO,GAAI,KAAqC,CAAC,KAAK,CAAC,OAAO,CAAC;YACtE;iBAAO;AACN,gBAAA,KAAK,CAAC,OAAO,GAAG,KAAK;YACtB;AACA,YAAA,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;AACpD,QAAA,CAAC;AAED,QAAA,MAAM,SAAS,GAAG,CAAC,QAAoB,KAAI;AAC1C,YAAA,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YACjC,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;AAClD,QAAA,CAAC;QAED,OAAO;YACN,GAAG;YACH,GAAG;YACH,SAAS;SACT;IACF;AAIA,IA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iB,CAAa,cAAc,CAAC;AAEtE,SAAU,kBAAkB,CAAC,EAClC,QAAQ,EACR,aAAa,GAAG,cAAc,GAI9B,EAAA;AACA,IAAA,QACCN,cAAA,CAACO,cAAQ,EAAA,EAAA,QAAA,EACRP,eAAC,QAAQ,EAAA,EAAC,YAAY,EAAE,aAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAY,EAAA,CAClD;AAEb;SAEgB,aAAa,GAAA;IAC5B,OAAO,QAAQ,CAAC,KAAK,IAAI,KAAK,CAAC;AAChC;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function TenArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function TenArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function FifteenArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function FifteenArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function ThreePeople(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ThreePeople(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function ThreeRectanglesDesktopFill(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ThreeRectanglesDesktopFill(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function ThreeRectanglesDesktop(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ThreeRectanglesDesktop(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ThirtyArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ThirtyArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function FortyFiveArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function FortyFiveArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function FiveArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function FiveArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function SixtyArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function SixtyArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function SeventyFiveArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function SeventyFiveArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function NinetyArrowTriangleheadClockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function NinetyArrowTriangleheadCounterclockwise(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function Airplane(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function Airplane(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ export declare function ArrowDownBackwardAndArrowUpForwardRectangle(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function ArrowTriangle2CirclepathCircleFill(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ArrowTriangle2CirclepathCircleFill(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function ArrowTriangle2CirclepathCircle(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function ArrowTriangle2CirclepathCircle(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ComponentPropsWithRef } from "react";
2
+ export declare function ArrowUpForwardAndArrowDownBackwardRectangle(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function BagFill(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function BagFill(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function Banknote(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function Banknote(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function BellFill(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function BellFill(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function BoltCar(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function BoltCar(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function BoltFill(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function BoltFill(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function BoltRingClosed(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function BoltRingClosed(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { SVGProps } from 'react';
2
- export default function BoltTrianglebadgeExclamationmark(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentPropsWithRef } from 'react';
2
+ export declare function BoltTrianglebadgeExclamationmark(props: Omit<ComponentPropsWithRef<'svg'>, 'viewBox'>): import("react/jsx-runtime").JSX.Element;