mado-ui 0.2.2 → 0.3.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.
- package/css/index.css +975 -3421
- package/dist/components/button.d.ts +32 -10
- package/dist/components/details.d.ts +18 -0
- package/dist/components/drop-down.d.ts +28 -0
- package/dist/components/form/fieldset.d.ts +9 -0
- package/dist/components/form/index.d.ts +2 -1
- package/dist/components/form/input/index.d.ts +1 -1
- package/dist/components/form/submit-button.d.ts +24 -5
- package/dist/components/form/textarea.d.ts +1 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/link.d.ts +31 -8
- package/dist/components/modal.d.ts +1 -2
- package/dist/components/tooltip.d.ts +26 -0
- package/dist/components.d.ts +1 -0
- package/dist/components.esm.js +2562 -285
- package/dist/components.esm.js.map +1 -1
- package/dist/components.js +2621 -313
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.esm.js.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/icons.d.ts +1 -0
- package/dist/icons.esm.js.map +1 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.esm.js +2932 -663
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2972 -671
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils.d.ts +5 -7
- package/dist/types.d.ts +1 -0
- package/dist/utils/helpers.d.ts +7 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +15 -14
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks/';
|
package/dist/hooks.esm.js.map
CHANGED
|
@@ -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":";;;
|
|
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,GAAG,KAAK;;AAEtB,YAAA,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;AACpD,SAAC;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,SAAC;QAED,OAAO;YACN,GAAG;YACH,GAAG;YACH,SAAS;SACT;;AAKF,IAAA,MAAM,YAAY,GAAG,aAAa,CAAgC,IAAI,CAAC;IAEvE,SAAS,QAAQ,CAAC,EACjB,YAAY,GAAG,mBAAmB,EAClC,GAAG,KAAK,EACkE,EAAA;AAC1E,QAAA,OAAOA,GAAA,CAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,EAAA,GAAM,KAAK,GAAI;;AAG/E,I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a,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;;;;"}
|
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":";;;;;
|
|
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,CAAC;;iBAC/D;AACN,gBAAA,KAAK,CAAC,OAAO,GAAG,KAAK;;AAEtB,YAAA,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;AACpD,SAAC;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