@mittwald/flow-react-components 0.2.0-alpha.747 → 0.2.0-alpha.749

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 (31) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/assets/doc-properties.json +4799 -4780
  3. package/dist/js/components/src/integrations/react-hook-form/components/Form/Form.mjs +7 -2
  4. package/dist/js/components/src/integrations/react-hook-form/components/Form/Form.mjs.map +1 -1
  5. package/dist/js/components/src/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.mjs +29 -0
  6. package/dist/js/components/src/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.mjs.map +1 -0
  7. package/dist/js/components/src/integrations/react-hook-form/components/Form/{useHotkeySubmit.mjs → hooks/useHotkeySubmit.mjs} +2 -2
  8. package/dist/js/components/src/integrations/react-hook-form/components/Form/hooks/useHotkeySubmit.mjs.map +1 -0
  9. package/dist/js/components/src/integrations/react-hook-form/components/FormAction/FormResetAction.mjs +0 -8
  10. package/dist/js/components/src/integrations/react-hook-form/components/FormAction/FormResetAction.mjs.map +1 -1
  11. package/dist/js/components/src/integrations/react-hook-form/components/FormRootError/FormRootError.mjs +0 -13
  12. package/dist/js/components/src/integrations/react-hook-form/components/FormRootError/FormRootError.mjs.map +1 -1
  13. package/dist/js/components/src/integrations/react-hook-form/components/FormRootError/useMountedFormRootErrorComponent.mjs +0 -13
  14. package/dist/js/components/src/integrations/react-hook-form/components/FormRootError/useMountedFormRootErrorComponent.mjs.map +1 -1
  15. package/dist/js/react-hook-form.mjs +1 -1
  16. package/dist/types/integrations/react-hook-form/components/Form/Form.d.ts +2 -1
  17. package/dist/types/integrations/react-hook-form/components/Form/Form.d.ts.map +1 -1
  18. package/dist/types/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.d.ts +12 -0
  19. package/dist/types/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.d.ts.map +1 -0
  20. package/dist/types/integrations/react-hook-form/components/Form/{useHotkeySubmit.d.ts → hooks/useHotkeySubmit.d.ts} +2 -2
  21. package/dist/types/integrations/react-hook-form/components/Form/hooks/useHotkeySubmit.d.ts.map +1 -0
  22. package/dist/types/integrations/react-hook-form/components/Form/index.d.ts +1 -0
  23. package/dist/types/integrations/react-hook-form/components/Form/index.d.ts.map +1 -1
  24. package/dist/types/integrations/react-hook-form/components/Form/stories/Form.stories.d.ts.map +1 -1
  25. package/dist/types/integrations/react-hook-form/components/FormContextProvider/index.d.ts +0 -1
  26. package/dist/types/integrations/react-hook-form/components/FormContextProvider/index.d.ts.map +1 -1
  27. package/dist/types/integrations/react-hook-form/index.d.ts +1 -1
  28. package/dist/types/integrations/react-hook-form/index.d.ts.map +1 -1
  29. package/package.json +6 -6
  30. package/dist/js/components/src/integrations/react-hook-form/components/Form/useHotkeySubmit.mjs.map +0 -1
  31. package/dist/types/integrations/react-hook-form/components/Form/useHotkeySubmit.d.ts.map +0 -1
@@ -2,7 +2,6 @@
2
2
  /* */
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { ConfirmUnsavedChangesModal } from '../../../../components/Modal/components/ConfirmUnsavedChangesModal/ConfirmUnsavedChangesModal.mjs';
5
- import { useHotkeySubmit } from './useHotkeySubmit.mjs';
6
5
  import { FormContextProvider } from '../FormContextProvider/FormContextProvider.mjs';
7
6
  import { flags } from '../../flags.mjs';
8
7
  import 'mobx';
@@ -13,6 +12,8 @@ import { FormProvider } from 'react-hook-form';
13
12
  import { useFormRootErrorController } from '../FormRootError/useFormRootErrorController.mjs';
14
13
  import { FormRootError } from '../../lib/FormRootError.mjs';
15
14
  import { useFormSettings } from '../FormSettingsProvider/FormSettingsProvider.mjs';
15
+ import { useFormSubmitController } from './hooks/useFormSubmitController.mjs';
16
+ import { useHotkeySubmit } from './hooks/useHotkeySubmit.mjs';
16
17
 
17
18
  const DefaultFormComponent = (p) => /* @__PURE__ */ jsx("form", { ...p });
18
19
  function Form(props) {
@@ -25,6 +26,7 @@ function Form(props) {
25
26
  ref,
26
27
  id: idProp,
27
28
  autoReset = true,
29
+ submitController: submitControllerFromProps,
28
30
  ...formProps
29
31
  } = props;
30
32
  const newFormId = useId();
@@ -33,6 +35,8 @@ function Form(props) {
33
35
  const afterSubmitCallback = useRef(void 0);
34
36
  const { isSubmitting, isValidating, isDirty } = form.formState;
35
37
  const rootErrorController = useFormRootErrorController();
38
+ const defaultSubmitController = useFormSubmitController();
39
+ const submitController = submitControllerFromProps ? submitControllerFromProps.submit.extend(defaultSubmitController) : defaultSubmitController;
36
40
  const autoResetOptions = typeof autoReset === "boolean" ? { onAfterModalClose: autoReset } : autoReset;
37
41
  const modalController = useModalController();
38
42
  modalController.useUpdateOptions({
@@ -69,12 +73,13 @@ function Form(props) {
69
73
  handleSubmitResult(submitResult);
70
74
  })(formEvent);
71
75
  };
76
+ submitController.submit.set(handleSubmit);
72
77
  const onAfterSuccessFeedback = () => {
73
78
  afterSubmitCallback.current?.();
74
79
  };
75
80
  const refWithHotkeySubmit = useHotkeySubmit({
76
81
  ref,
77
- handleSubmit
82
+ submitController
78
83
  });
79
84
  return /* @__PURE__ */ jsxs(FormProvider, { ...form, children: [
80
85
  /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"Form.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"sourcesContent":["import ConfirmUnsavedChangesModal from \"@/components/Modal/components/ConfirmUnsavedChangesModal\";\nimport { useHotkeySubmit } from \"@/integrations/react-hook-form/components/Form/useHotkeySubmit\";\nimport { FormContextProvider } from \"@/integrations/react-hook-form/components/FormContextProvider/FormContextProvider\";\nimport { flags } from \"@/integrations/react-hook-form/flags\";\nimport { useModalController } from \"@/lib/controller\";\nimport {\n type BaseSyntheticEvent,\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type Ref,\n type SubmitEventHandler,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport type {\n FieldValues,\n Path,\n SubmitHandler,\n UseFormReturn,\n} from \"react-hook-form\";\nimport { FormProvider as RhfFormContextProvider } from \"react-hook-form\";\nimport { useFormRootErrorController } from \"../FormRootError/useFormRootErrorController\";\nimport { FormRootError } from \"../../lib/FormRootError\";\nimport { useFormSettings } from \"../FormSettingsProvider/FormSettingsProvider\";\n\nexport type FormOnSubmitHandler<F extends FieldValues> = SubmitHandler<F>;\n\nexport type AfterFormSubmitCallback = (...unknownArgs: unknown[]) => unknown;\n\nexport interface FormAutoResetOptions {\n onAfterModalClose?: boolean;\n}\n\ntype FormComponentType = FC<\n PropsWithChildren<{\n id: string;\n onSubmit?: SubmitEventHandler | FormOnSubmitHandler<never>;\n ref?: Ref<HTMLFormElement>;\n }>\n>;\n\nexport interface FormProps<F extends FieldValues>\n extends Omit<ComponentProps<\"form\">, \"onSubmit\">, PropsWithChildren {\n form: UseFormReturn<F>;\n onSubmit: FormOnSubmitHandler<F>;\n formComponent?: FC<Omit<FormComponentType, \"ref\">>;\n isReadOnly?: boolean;\n autoReset?: FormAutoResetOptions | boolean;\n}\n\nconst DefaultFormComponent: FormComponentType = (p) => <form {...p} />;\n\nexport function Form<F extends FieldValues>(props: FormProps<F>) {\n const {\n form,\n children,\n onSubmit: onSubmitProp,\n formComponent = DefaultFormComponent,\n isReadOnly,\n ref,\n id: idProp,\n autoReset = true,\n ...formProps\n } = props;\n\n const newFormId = useId();\n const formId = idProp ?? newFormId;\n const FormComponent = useMemo(() => formComponent, [formId]);\n const afterSubmitCallback = useRef<AfterFormSubmitCallback>(undefined);\n const { isSubmitting, isValidating, isDirty } = form.formState;\n const rootErrorController = useFormRootErrorController();\n\n const autoResetOptions =\n typeof autoReset === \"boolean\"\n ? { onAfterModalClose: autoReset }\n : autoReset;\n\n const modalController = useModalController();\n modalController.useUpdateOptions({\n confirmOnClose:\n flags.requireCloseModalConfirmationOnUnsavedChanges && isDirty,\n onClose: () => {\n if (autoResetOptions?.onAfterModalClose) {\n form.reset();\n }\n },\n });\n\n const { submitInterceptor } = useFormSettings();\n const onSubmit = submitInterceptor\n ? (values: F) => submitInterceptor<F>(onSubmitProp, values, { form })\n : onSubmitProp;\n\n const handleSubmitResult = (result: unknown) => {\n if (typeof result === \"function\") {\n afterSubmitCallback.current = result as AfterFormSubmitCallback;\n }\n const rootError = form.getFieldState(\"root\" as Path<F>)?.error;\n if (rootError && !rootErrorController.errorComponentMounted) {\n throw new FormRootError(rootError);\n }\n };\n\n const handleSubmit = (e?: BaseSyntheticEvent | F) => {\n const formEvent =\n e && \"nativeEvent\" in e ? (e as BaseSyntheticEvent) : undefined;\n\n formEvent?.stopPropagation();\n\n if (isSubmitting || isValidating) {\n return;\n }\n\n modalController.confirmClose();\n\n return form.handleSubmit((values, event) => {\n const submitResult = onSubmit(values, event);\n if (submitResult instanceof Promise) {\n return submitResult.then(handleSubmitResult);\n }\n handleSubmitResult(submitResult);\n })(formEvent);\n };\n\n const onAfterSuccessFeedback = () => {\n afterSubmitCallback.current?.();\n };\n\n const refWithHotkeySubmit = useHotkeySubmit({\n ref,\n handleSubmit,\n });\n\n return (\n <RhfFormContextProvider {...form}>\n <FormContextProvider\n form={form as UseFormReturn}\n isReadOnly={isReadOnly}\n id={formId}\n onAfterSuccessFeedback={onAfterSuccessFeedback}\n rootErrorController={rootErrorController}\n >\n <FormComponent\n {...formProps}\n ref={refWithHotkeySubmit}\n id={formId}\n onSubmit={handleSubmit}\n >\n {children}\n </FormComponent>\n </FormContextProvider>\n <ConfirmUnsavedChangesModal />\n </RhfFormContextProvider>\n );\n}\n\nexport default Form;\n"],"names":["RhfFormContextProvider"],"mappings":";;;;;;;;;;;;;;AAoDA,MAAM,uBAA0C,CAAC,CAAA,qBAAM,GAAA,CAAC,MAAA,EAAA,EAAM,GAAG,CAAA,EAAG,CAAA;AAE7D,SAAS,KAA4B,KAAA,EAAqB;AAC/D,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA,EAAU,YAAA;AAAA,IACV,aAAA,GAAgB,oBAAA;A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A,YACE,GAAG,SAAA;AAAA,YACJ,GAAA,EAAK,mBAAA;AAAA,YACL,EAAA,EAAI,MAAA;AAAA,YACJ,QAAA,EAAU,YAAA;AAAA,YAET;AAAA;AAAA;AACH;AAAA,KACF;AAAA,wBACC,0BAAA,EAAA,EAA2B;AAAA,GAAA,EAC9B,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"Form.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"sourcesContent":["import ConfirmUnsavedChangesModal from \"@/components/Modal/components/ConfirmUnsavedChangesModal\";\nimport { FormContextProvider } from \"@/integrations/react-hook-form/components/FormContextProvider/FormContextProvider\";\nimport { flags } from \"@/integrations/react-hook-form/flags\";\nimport { useModalController } from \"@/lib/controller\";\nimport {\n type BaseSyntheticEvent,\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type Ref,\n type SubmitEventHandler,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport type {\n FieldValues,\n Path,\n SubmitHandler,\n UseFormReturn,\n} from \"react-hook-form\";\nimport { FormProvider as RhfFormContextProvider } from \"react-hook-form\";\nimport { useFormRootErrorController } from \"../FormRootError/useFormRootErrorController\";\nimport { FormRootError } from \"../../lib/FormRootError\";\nimport { useFormSettings } from \"../FormSettingsProvider/FormSettingsProvider\";\nimport {\n useFormSubmitController,\n type WithFormSubmitControllerProps,\n} from \"@/integrations/react-hook-form/components/Form/hooks/useFormSubmitController\";\nimport { useHotkeySubmit } from \"@/integrations/react-hook-form/components/Form/hooks/useHotkeySubmit\";\n\nexport type FormOnSubmitHandler<F extends FieldValues> = SubmitHandler<F>;\n\nexport type AfterFormSubmitCallback = (...unknownArgs: unknown[]) => unknown;\n\nexport interface FormAutoResetOptions {\n onAfterModalClose?: boolean;\n}\n\ntype FormComponentType = FC<\n PropsWithChildren<{\n id: string;\n onSubmit?: SubmitEventHandler | FormOnSubmitHandler<never>;\n ref?: Ref<HTMLFormElement>;\n }>\n>;\n\nexport interface FormProps<F extends FieldValues>\n extends\n Omit<ComponentProps<\"form\">, \"onSubmit\">,\n PropsWithChildren,\n WithFormSubmitControllerProps {\n form: UseFormReturn<F>;\n onSubmit: FormOnSubmitHandler<F>;\n formComponent?: FC<Omit<FormComponentType, \"ref\">>;\n isReadOnly?: boolean;\n autoReset?: FormAutoResetOptions | boolean;\n}\n\nconst DefaultFormComponent: FormComponentType = (p) => <form {...p} />;\n\nexport function Form<F extends FieldValues>(props: FormProps<F>) {\n const {\n form,\n children,\n onSubmit: onSubmitProp,\n formComponent = DefaultFormComponent,\n isReadOnly,\n ref,\n id: idProp,\n autoReset = true,\n submitController: submitControllerFromProps,\n ...formProps\n } = props;\n\n const newFormId = useId();\n const formId = idProp ?? newFormId;\n const FormComponent = useMemo(() => formComponent, [formId]);\n const afterSubmitCallback = useRef<AfterFormSubmitCallback>(undefined);\n const { isSubmitting, isValidating, isDirty } = form.formState;\n const rootErrorController = useFormRootErrorController();\n\n const defaultSubmitController = useFormSubmitController();\n const submitController = submitControllerFromProps\n ? submitControllerFromProps.submit.extend(defaultSubmitController)\n : defaultSubmitController;\n\n const autoResetOptions =\n typeof autoReset === \"boolean\"\n ? { onAfterModalClose: autoReset }\n : autoReset;\n\n const modalController = useModalController();\n modalController.useUpdateOptions({\n confirmOnClose:\n flags.requireCloseModalConfirmationOnUnsavedChanges && isDirty,\n onClose: () => {\n if (autoResetOptions?.onAfterModalClose) {\n form.reset();\n }\n },\n });\n\n const { submitInterceptor } = useFormSettings();\n const onSubmit = submitInterceptor\n ? (values: F) => submitInterceptor<F>(onSubmitProp, values, { form })\n : onSubmitProp;\n\n const handleSubmitResult = (result: unknown) => {\n if (typeof result === \"function\") {\n afterSubmitCallback.current = result as AfterFormSubmitCallback;\n }\n const rootError = form.getFieldState(\"root\" as Path<F>)?.error;\n if (rootError && !rootErrorController.errorComponentMounted) {\n throw new FormRootError(rootError);\n }\n };\n\n const handleSubmit = (e?: BaseSyntheticEvent | F) => {\n const formEvent =\n e && \"nativeEvent\" in e ? (e as BaseSyntheticEvent) : undefined;\n\n formEvent?.stopPropagation();\n\n if (isSubmitting || isValidating) {\n return;\n }\n\n modalController.confirmClose();\n\n return form.handleSubmit((values, event) => {\n const submitResult = onSubmit(values, event);\n if (submitResult instanceof Promise) {\n return submitResult.then(handleSubmitResult);\n }\n handleSubmitResult(submitResult);\n })(formEvent);\n };\n submitController.submit.set(handleSubmit);\n\n const onAfterSuccessFeedback = () => {\n afterSubmitCallback.current?.();\n };\n\n const refWithHotkeySubmit = useHotkeySubmit({\n ref,\n submitController,\n });\n\n return (\n <RhfFormContextProvider {...form}>\n <FormContextProvider\n form={form as UseFormReturn}\n isReadOnly={isReadOnly}\n id={formId}\n onAfterSuccessFeedback={onAfterSuccessFeedback}\n rootErrorController={rootErrorController}\n >\n <FormComponent\n {...formProps}\n ref={refWithHotkeySubmit}\n id={formId}\n onSubmit={handleSubmit}\n >\n {children}\n </FormComponent>\n </FormContextProvider>\n <ConfirmUnsavedChangesModal />\n </RhfFormContextProvider>\n );\n}\n\nexport default Form;\n"],"names":["RhfFormContextProvider"],"mappings":";;;;;;;;;;;;;;;AA2DA,MAAM,uBAA0C,CAAC,CAAA,qBAAM,GAAA,CAAC,MAAA,EAAA,EAAM,GAAG,CAAA,EAAG,CAAA;AAE7D,SAAS,KAA4B,KAAA,EAAqB;AAC/D,EAAA,MAAM;AAAA,IACJ,IAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA,EAAU,YAAA;AAAA,IACV,aAAA,GAAgB,oBAAA;AAAA,IAChB,UAAA;AAAA,IACA,GAAA;AAAA,IACA,EAAA,EAAI,MAAA;AAAA,IACJ,SAAA,GAAY,IAAA;AAAA,IACZ,gBAAA,EAAkB,yBAAA;AAAA,IAClB,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,YAAY,KAAA,EAAM;AACxB,EAAA,MAAM,SAAS,MAAA,IAAU,SAAA;AACzB,EAAA,MAAM,gBAAgB,OAAA,CAAQ,MAAM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AA,YACL,EAAA,EAAI,MAAA;AAAA,YACJ,QAAA,EAAU,YAAA;AAAA,YAET;AAAA;AAAA;AACH;AAAA,KACF;AAAA,wBACC,0BAAA,EAAA,EAA2B;AAAA,GAAA,EAC9B,CAAA;AAEJ;;;;"}
@@ -0,0 +1,29 @@
1
+ "use client"
2
+ /* */
3
+ import { useRef } from 'react';
4
+
5
+ const useFormSubmitController = () => {
6
+ const submitHandler = useRef(async () => {
7
+ });
8
+ const fn = async () => {
9
+ await submitHandler.current();
10
+ };
11
+ const formSubmitControllerReturn = {
12
+ submit: fn
13
+ };
14
+ fn.set = (newSubmitHandler) => {
15
+ submitHandler.current = newSubmitHandler;
16
+ };
17
+ fn.extend = (submitController) => {
18
+ const previous = submitHandler.current;
19
+ submitHandler.current = async () => {
20
+ await previous();
21
+ await submitController.submit();
22
+ };
23
+ return formSubmitControllerReturn;
24
+ };
25
+ return formSubmitControllerReturn;
26
+ };
27
+
28
+ export { useFormSubmitController };
29
+ //# sourceMappingURL=useFormSubmitController.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormSubmitController.mjs","sources":["../../../../../../../../../src/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.ts"],"sourcesContent":["import { useRef } from \"react\";\n\nexport type FormSubmitController = ReturnType<typeof useFormSubmitController>;\n\nexport interface WithFormSubmitControllerProps {\n submitController?: FormSubmitController;\n}\n\nexport const useFormSubmitController = () => {\n const submitHandler = useRef<() => Promise<void> | void>(async () => {\n /* empty */\n });\n\n const fn = async () => {\n await submitHandler.current();\n };\n\n const formSubmitControllerReturn = {\n submit: fn,\n };\n\n fn.set = (newSubmitHandler: () => Promise<void> | void) => {\n submitHandler.current = newSubmitHandler;\n };\n\n fn.extend = (submitController: FormSubmitController) => {\n const previous = submitHandler.current;\n\n submitHandler.current = async () => {\n await previous();\n await submitController.submit();\n };\n\n return formSubmitControllerReturn;\n };\n\n return formSubmitControllerReturn;\n};\n"],"names":[],"mappings":";;AAQO,MAAM,0BAA0B,MAAM;AAC3C,EAAA,MAAM,aAAA,GAAgB,OAAmC,YAAY;AAAA,EAErE,CAAC,CAAA;AAED,EAAA,MAAM,KAAK,YAAY;AACrB,IAAA,MAAM,cAAc,OAAA,EAAQ;AAAA,EAC9B,CAAA;AAEA,EAAA,MAAM,0BAAA,GAA6B;AAAA,IACjC,MAAA,EAAQ;AAAA,GACV;AAEA,EAAA,EAAA,CAAG,GAAA,GAAM,CAAC,gBAAA,KAAiD;AACzD,IAAA,aAAA,CAAc,OAAA,GAAU,gBAAA;AAAA,EAC1B,CAAA;AAEA,EAAA,EAAA,CAAG,MAAA,GAAS,CAAC,gBAAA,KAA2C;AACtD,IAAA,MAAM,WAAW,aAAA,CAAc,OAAA;AAE/B,IAAA,aAAA,CAAc,UAAU,YAAY;AAClC,MAAA,MAAM,QAAA,EAAS;AACf,MAAA,MAAM,iBAAiB,MAAA,EAAO;AAAA,IAChC,CAAA;AAEA,IAAA,OAAO,0BAAA;AAAA,EACT,CAAA;AAEA,EAAA,OAAO,0BAAA;AACT;;;;"}
@@ -5,10 +5,10 @@ import { useHotkeys } from 'react-hotkeys-hook';
5
5
  import { useMergeRefs } from 'use-callback-ref';
6
6
 
7
7
  const useHotkeySubmit = (options) => {
8
- const { ref, handleSubmit } = options;
8
+ const { ref, submitController } = options;
9
9
  return useMergeRefs([
10
10
  useObjectRef(ref),
11
- useHotkeys("mod+enter", handleSubmit, {
11
+ useHotkeys("mod+enter", submitController.submit, {
12
12
  enableOnFormTags: true,
13
13
  enableOnContentEditable: true
14
14
  })
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHotkeySubmit.mjs","sources":["../../../../../../../../../src/integrations/react-hook-form/components/Form/hooks/useHotkeySubmit.ts"],"sourcesContent":["import type { Ref } from \"react\";\nimport { useObjectRef } from \"react-aria\";\nimport { useHotkeys } from \"react-hotkeys-hook\";\nimport { useMergeRefs } from \"use-callback-ref\";\nimport type { WithFormSubmitControllerProps } from \"@/integrations/react-hook-form\";\n\ninterface Options extends Required<WithFormSubmitControllerProps> {\n ref: Ref<HTMLFormElement> | undefined;\n}\n\nexport const useHotkeySubmit = (options: Options) => {\n const { ref, submitController } = options;\n\n return useMergeRefs([\n useObjectRef(ref),\n useHotkeys<never>(\"mod+enter\", submitController.submit, {\n enableOnFormTags: true,\n enableOnContentEditable: true,\n }),\n ]);\n};\n"],"names":[],"mappings":";;;;AAUO,MAAM,eAAA,GAAkB,CAAC,OAAA,KAAqB;AACnD,EAAA,MAAM,EAAE,GAAA,EAAK,gBAAA,EAAiB,GAAI,OAAA;AAElC,EAAA,OAAO,YAAA,CAAa;AAAA,IAClB,aAAa,GAAG,CAAA;AAAA,IAChB,UAAA,CAAkB,WAAA,EAAa,gBAAA,CAAiB,MAAA,EAAQ;AAAA,MACtD,gBAAA,EAAkB,IAAA;AAAA,MAClB,uBAAA,EAAyB;AAAA,KAC1B;AAAA,GACF,CAAA;AACH;;;;"}
@@ -6,15 +6,7 @@ import 'react-aria';
6
6
  import 'react';
7
7
  import '@react-aria/live-announcer';
8
8
  import { useFormContext } from '../FormContextProvider/FormContextProvider.mjs';
9
- import 'mobx';
10
9
  import '../../../../lib/propsContext/propsContext.mjs';
11
- import 'remeda';
12
- import '@react-aria/utils';
13
- import 'dot-prop';
14
- import '../../../../lib/controller/overlay/context.mjs';
15
- import 'invariant';
16
- import '../../../../components/Action/context.mjs';
17
- import '../../../../components/Action/models/ActionStateContext.mjs';
18
10
  import { PropsContextProvider } from '../../../../lib/propsContext/components/PropsContextProvider.mjs';
19
11
 
20
12
  const FormResetAction = (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"FormResetAction.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/FormAction/FormResetAction.tsx"],"sourcesContent":["import Action, { type ActionProps } from \"@/components/Action\";\nimport { useFormContext } from \"@/integrations/react-hook-form/components/FormContextProvider\";\nimport { PropsContextProvider, type PropsContext } from \"@/lib/propsContext\";\nimport type { FC, PropsWithChildren } from \"react\";\n\ntype SupportedActionProps = Pick<ActionProps, \"showFeedback\">;\n\nexport const FormResetAction: FC<PropsWithChildren<SupportedActionProps>> = (\n props,\n) => {\n const { children, ...actionProps } = props;\n\n const { form, isReadOnly, id } = useFormContext();\n\n const propsContext: PropsContext = {\n Button: {\n isReadOnly,\n form: id,\n color: \"secondary\",\n variant: \"soft\",\n type: \"button\",\n },\n };\n\n return (\n <Action onAction={() => form.reset()} {...actionProps}>\n <PropsContextProvider\n props={propsContext}\n dependencies={[isReadOnly, id]}\n >\n {children}\n </PropsContextProvider>\n </Action>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAOO,MAAM,eAAA,GAA+D,CAC1E,KAAA,KACG;AACH,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,WAAA,EAAY,GAAI,KAAA;AAErC,EAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,EAAA,KAAO,cAAA,EAAe;AAEhD,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,MAAA,EAAQ;AAAA,MACN,UAAA;AAAA,MACA,IAAA,EAAM,EAAA;AAAA,MACN,KAAA,EAAO,WAAA;AAAA,MACP,OAAA,EAAS,MAAA;AAAA,MACT,IAAA,EAAM;AAAA;AACR,GACF;AAEA,EAAA,uBACE,GAAA,CAAC,UAAO,QAAA,EAAU,MAAM,KAAK,KAAA,EAAM,EAAI,GAAG,WAAA,EACxC,QAAA,kBAAA,GAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,YAAA;AAAA,MACP,YAAA,EAAc,CAAC,UAAA,EAAY,EAAE,CAAA;AAAA,MAE5B;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"FormResetAction.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/FormAction/FormResetAction.tsx"],"sourcesContent":["import Action, { type ActionProps } from \"@/components/Action\";\nimport { useFormContext } from \"@/integrations/react-hook-form/components/FormContextProvider\";\nimport { PropsContextProvider, type PropsContext } from \"@/lib/propsContext\";\nimport type { FC, PropsWithChildren } from \"react\";\n\ntype SupportedActionProps = Pick<ActionProps, \"showFeedback\">;\n\nexport const FormResetAction: FC<PropsWithChildren<SupportedActionProps>> = (\n props,\n) => {\n const { children, ...actionProps } = props;\n\n const { form, isReadOnly, id } = useFormContext();\n\n const propsContext: PropsContext = {\n Button: {\n isReadOnly,\n form: id,\n color: \"secondary\",\n variant: \"soft\",\n type: \"button\",\n },\n };\n\n return (\n <Action onAction={() => form.reset()} {...actionProps}>\n <PropsContextProvider\n props={propsContext}\n dependencies={[isReadOnly, id]}\n >\n {children}\n </PropsContextProvider>\n </Action>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAOO,MAAM,eAAA,GAA+D,CAC1E,KAAA,KACG;AACH,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,WAAA,EAAY,GAAI,KAAA;AAErC,EAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,EAAA,KAAO,cAAA,EAAe;AAEhD,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,MAAA,EAAQ;AAAA,MACN,UAAA;AAAA,MACA,IAAA,EAAM,EAAA;AAAA,MACN,KAAA,EAAO,WAAA;AAAA,MACP,OAAA,EAAS,MAAA;AAAA,MACT,IAAA,EAAM;AAAA;AACR,GACF;AAEA,EAAA,uBACE,GAAA,CAAC,UAAO,QAAA,EAAU,MAAM,KAAK,KAAA,EAAM,EAAI,GAAG,WAAA,EACxC,QAAA,kBAAA,GAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,YAAA;AAAA,MACP,YAAA,EAAc,CAAC,UAAA,EAAY,EAAE,CAAA;AAAA,MAE5B;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;;;;"}
@@ -2,19 +2,6 @@
2
2
  /* */
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
  import { useFormContext } from '../FormContextProvider/FormContextProvider.mjs';
5
- import '../../../../components/Action/Action.mjs';
6
- import 'react-aria';
7
- import 'react';
8
- import '@react-aria/live-announcer';
9
- import 'mobx';
10
- import '../../../../lib/propsContext/propsContext.mjs';
11
- import 'remeda';
12
- import '@react-aria/utils';
13
- import 'dot-prop';
14
- import '../../../../lib/controller/overlay/context.mjs';
15
- import 'invariant';
16
- import '../../../../components/Action/context.mjs';
17
- import '../../../../components/Action/models/ActionStateContext.mjs';
18
5
  import FieldErrorView from '../../../../views/FieldErrorView.mjs';
19
6
  import { useMountedFormRootErrorComponent } from './useMountedFormRootErrorComponent.mjs';
20
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"FormRootError.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useFormContext } from \"../FormContextProvider\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useMountedFormRootErrorComponent } from \"./useMountedFormRootErrorComponent\";\n\nexport const FormRootError: FC = () => {\n const form = useFormContext().form;\n useMountedFormRootErrorComponent();\n const error = form.formState.errors.root;\n return <FieldErrorView>{error?.message}</FieldErrorView>;\n};\n\nexport default FormRootError;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAKO,MAAM,gBAAoB,MAAM;AACrC,EAAA,MAAM,IAAA,GAAO,gBAAe,CAAE,IAAA;AAC9B,EAAA,gCAAA,EAAiC;AACjC,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,IAAA;AACpC,EAAA,uBAAO,GAAA,CAAC,cAAA,EAAA,EAAgB,QAAA,EAAA,KAAA,EAAO,OAAA,EAAQ,CAAA;AACzC;;;;"}
1
+ {"version":3,"file":"FormRootError.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useFormContext } from \"../FormContextProvider\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useMountedFormRootErrorComponent } from \"./useMountedFormRootErrorComponent\";\n\nexport const FormRootError: FC = () => {\n const form = useFormContext().form;\n useMountedFormRootErrorComponent();\n const error = form.formState.errors.root;\n return <FieldErrorView>{error?.message}</FieldErrorView>;\n};\n\nexport default FormRootError;\n"],"names":[],"mappings":";;;;;AAKO,MAAM,gBAAoB,MAAM;AACrC,EAAA,MAAM,IAAA,GAAO,gBAAe,CAAE,IAAA;AAC9B,EAAA,gCAAA,EAAiC;AACjC,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,IAAA;AACpC,EAAA,uBAAO,GAAA,CAAC,cAAA,EAAA,EAAgB,QAAA,EAAA,KAAA,EAAO,OAAA,EAAQ,CAAA;AACzC;;;;"}
@@ -2,19 +2,6 @@
2
2
  /* */
3
3
  import { useEffect } from 'react';
4
4
  import { useFormContext } from '../FormContextProvider/FormContextProvider.mjs';
5
- import '../../../../components/Action/Action.mjs';
6
- import 'react/jsx-runtime';
7
- import 'react-aria';
8
- import '@react-aria/live-announcer';
9
- import 'mobx';
10
- import '../../../../lib/propsContext/propsContext.mjs';
11
- import 'remeda';
12
- import '@react-aria/utils';
13
- import 'dot-prop';
14
- import '../../../../lib/controller/overlay/context.mjs';
15
- import 'invariant';
16
- import '../../../../components/Action/context.mjs';
17
- import '../../../../components/Action/models/ActionStateContext.mjs';
18
5
 
19
6
  const useMountedFormRootErrorComponent = () => {
20
7
  const controller = useFormContext().rootErrorController;
@@ -1 +1 @@
1
- {"version":3,"file":"useMountedFormRootErrorComponent.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/FormRootError/useMountedFormRootErrorComponent.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useFormContext } from \"../FormContextProvider\";\n\nexport const useMountedFormRootErrorComponent = () => {\n const controller = useFormContext().rootErrorController;\n\n useEffect(() => {\n controller.updateErrorComponentMounted(true);\n return () => {\n controller.updateErrorComponentMounted(false);\n };\n }, [controller]);\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGO,MAAM,mCAAmC,MAAM;AACpD,EAAA,MAAM,UAAA,GAAa,gBAAe,CAAE,mBAAA;AAEpC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,UAAA,CAAW,4BAA4B,IAAI,CAAA;AAC3C,IAAA,OAAO,MAAM;AACX,MAAA,UAAA,CAAW,4BAA4B,KAAK,CAAA;AAAA,IAC9C,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,UAAU,CAAC,CAAA;AACjB;;;;"}
1
+ {"version":3,"file":"useMountedFormRootErrorComponent.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/FormRootError/useMountedFormRootErrorComponent.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useFormContext } from \"../FormContextProvider\";\n\nexport const useMountedFormRootErrorComponent = () => {\n const controller = useFormContext().rootErrorController;\n\n useEffect(() => {\n controller.updateErrorComponentMounted(true);\n return () => {\n controller.updateErrorComponentMounted(false);\n };\n }, [controller]);\n};\n"],"names":[],"mappings":";;;AAGO,MAAM,mCAAmC,MAAM;AACpD,EAAA,MAAM,UAAA,GAAa,gBAAe,CAAE,mBAAA;AAEpC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,UAAA,CAAW,4BAA4B,IAAI,CAAA;AAC3C,IAAA,OAAO,MAAM;AACX,MAAA,UAAA,CAAW,4BAA4B,KAAK,CAAA;AAAA,IAC9C,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,UAAU,CAAC,CAAA;AACjB;;;;"}
@@ -2,12 +2,12 @@
2
2
  /* */
3
3
  export { Field, typedField } from './components/src/integrations/react-hook-form/components/Field/Field.mjs';
4
4
  export { Form } from './components/src/integrations/react-hook-form/components/Form/Form.mjs';
5
+ export { useFormSubmitController } from './components/src/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.mjs';
5
6
  export { SubmitButton } from './components/src/integrations/react-hook-form/components/SubmitButton/SubmitButton.mjs';
6
7
  export { FormSettingsProvider } from './components/src/integrations/react-hook-form/components/FormSettingsProvider/FormSettingsProvider.mjs';
7
8
  export { ResetButton } from './components/src/integrations/react-hook-form/components/ResetButton/ResetButton.mjs';
8
9
  export { FormRootError } from './components/src/integrations/react-hook-form/components/FormRootError/FormRootError.mjs';
9
10
  export { useFormContext, useOptionalFormContext } from './components/src/integrations/react-hook-form/components/FormContextProvider/FormContextProvider.mjs';
10
- export { useFormSubmitAction } from './components/src/integrations/react-hook-form/components/FormContextProvider/useFormSubmitAction.mjs';
11
11
  export { FormAction } from './components/src/integrations/react-hook-form/components/FormAction/FormAction.mjs';
12
12
  export { flags } from './components/src/integrations/react-hook-form/flags.mjs';
13
13
  //# sourceMappingURL=react-hook-form.mjs.map
@@ -1,5 +1,6 @@
1
1
  import { ComponentProps, FC, PropsWithChildren, Ref, SubmitEventHandler } from 'react';
2
2
  import { FieldValues, SubmitHandler, UseFormReturn } from 'react-hook-form';
3
+ import { WithFormSubmitControllerProps } from './hooks/useFormSubmitController';
3
4
  export type FormOnSubmitHandler<F extends FieldValues> = SubmitHandler<F>;
4
5
  export type AfterFormSubmitCallback = (...unknownArgs: unknown[]) => unknown;
5
6
  export interface FormAutoResetOptions {
@@ -10,7 +11,7 @@ type FormComponentType = FC<PropsWithChildren<{
10
11
  onSubmit?: SubmitEventHandler | FormOnSubmitHandler<never>;
11
12
  ref?: Ref<HTMLFormElement>;
12
13
  }>>;
13
- export interface FormProps<F extends FieldValues> extends Omit<ComponentProps<"form">, "onSubmit">, PropsWithChildren {
14
+ export interface FormProps<F extends FieldValues> extends Omit<ComponentProps<"form">, "onSubmit">, PropsWithChildren, WithFormSubmitControllerProps {
14
15
  form: UseFormReturn<F>;
15
16
  onSubmit: FormOnSubmitHandler<F>;
16
17
  formComponent?: FC<Omit<FormComponentType, "ref">>;
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/react-hook-form/components/Form/Form.tsx"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,cAAc,EACn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IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,2CA6G9D;AAED,eAAe,IAAI,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type FormSubmitController = ReturnType<typeof useFormSubmitController>;
2
+ export interface WithFormSubmitControllerProps {
3
+ submitController?: FormSubmitController;
4
+ }
5
+ export declare const useFormSubmitController: () => {
6
+ submit: {
7
+ (): Promise<void>;
8
+ set(newSubmitHandler: () => Promise<void> | void): void;
9
+ extend(submitController: FormSubmitController): /*elided*/ any;
10
+ };
11
+ };
12
+ //# sourceMappingURL=useFormSubmitController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormSubmitController.d.ts","sourceRoot":"","sources":["../../../../../../../src/integrations/react-hook-form/components/Form/hooks/useFormSubmitController.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,MAAM,WAAW,6BAA6B;IAC5C,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED,eAAO,MAAM,uBAAuB;;;8BAaN,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;iCAIvB,oBAAoB;;CAYpD,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Ref } from 'react';
2
- interface Options {
2
+ import { WithFormSubmitControllerProps } from '../../..';
3
+ interface Options extends Required<WithFormSubmitControllerProps> {
3
4
  ref: Ref<HTMLFormElement> | undefined;
4
- handleSubmit: () => void;
5
5
  }
6
6
  export declare const useHotkeySubmit: (options: Options) => import('react').MutableRefObject<HTMLFormElement | null>;
7
7
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHotkeySubmit.d.ts","sourceRoot":"","sources":["../../../../../../../src/integrations/react-hook-form/components/Form/hooks/useHotkeySubmit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAEpF,UAAU,OAAQ,SAAQ,QAAQ,CAAC,6BAA6B,CAAC;IAC/D,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,eAAe,GAAI,SAAS,OAAO,6DAU/C,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { default } from './Form';
2
2
  export { Form, type FormOnSubmitHandler, type FormProps } from './Form';
3
+ export { type WithFormSubmitControllerProps, useFormSubmitController, } from './hooks/useFormSubmitController';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/react-hook-form/components/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qDAAqD,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/react-hook-form/components/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qDAAqD,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxE,OAAO,EACL,KAAK,6BAA6B,EAClC,uBAAuB,GACxB,MAAM,iCAAiC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Form.stories.d.ts","sourceRoot":"","sources":["../../../../../../../src/integrations/react-hook-form/components/Form/stories/Form.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,qDAAqD,CAAC;AAE3E,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAwBvD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CA2B3B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,QAAQ,EAAE,KAAsC,CAAC;AAE9D,eAAO,MAAM,sBAAsB,EAAE,KAgCpC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,KAwBtC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,KAwB1C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAgCjC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAmC3B,CAAC"}
1
+ {"version":3,"file":"Form.stories.d.ts","sourceRoot":"","sources":["../../../../../../../src/integrations/react-hook-form/components/Form/stories/Form.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,qDAAqD,CAAC;AAE3E,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AA0BvD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CAyC3B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,QAAQ,EAAE,KAAsC,CAAC;AAE9D,eAAO,MAAM,sBAAsB,EAAE,KAgCpC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,KAwBtC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,KAwB1C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAgCjC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAmC3B,CAAC"}
@@ -1,4 +1,3 @@
1
1
  export { default } from './FormContextProvider';
2
2
  export { FormContextProvider, type FormContextProviderProps, useFormContext, useOptionalFormContext, } from './FormContextProvider';
3
- export * from './useFormSubmitAction';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/react-hook-form/components/FormContextProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mFAAmF,CAAC;AAC5G,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,cAAc,EACd,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/react-hook-form/components/FormContextProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mFAAmF,CAAC;AAC5G,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,cAAc,EACd,sBAAsB,GACvB,MAAM,uBAAuB,CAAC"}
@@ -4,7 +4,7 @@ export * from './components/SubmitButton';
4
4
  export { FormSettingsProvider, type FormSettingsProviderProps, type SubmitInterceptor, type SubmitInterceptorContext, } from './components/FormSettingsProvider';
5
5
  export * from './components/ResetButton';
6
6
  export * from './components/FormRootError';
7
- export { useFormContext, useOptionalFormContext, useFormSubmitAction, } from './components/FormContextProvider';
7
+ export { useFormContext, useOptionalFormContext, } from './components/FormContextProvider';
8
8
  export * from './components/FormAction';
9
9
  export { flags } from './flags';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/react-hook-form/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,mCAAmC,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/react-hook-form/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,mCAAmC,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "0.2.0-alpha.747",
3
+ "version": "0.2.0-alpha.749",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://mittwald.github.io/flow",
@@ -57,9 +57,9 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@internationalized/string-compiler": "^3.2.6",
60
- "@mittwald/flow-icons": "0.2.0-alpha.747",
60
+ "@mittwald/flow-icons": "0.2.0-alpha.749",
61
61
  "@mittwald/password-tools-js": "3.0.0-alpha.18",
62
- "@mittwald/react-tunnel": "0.2.0-alpha.747",
62
+ "@mittwald/react-tunnel": "0.2.0-alpha.749",
63
63
  "@mittwald/react-use-promise": "^4.2.2",
64
64
  "@react-aria/form": "^3.1.3",
65
65
  "@react-aria/live-announcer": "^3.4.4",
@@ -104,7 +104,7 @@
104
104
  "@faker-js/faker": "^10.2.0",
105
105
  "@internationalized/date": "^3.10.1",
106
106
  "@mittwald/flow-core": "",
107
- "@mittwald/flow-design-tokens": "0.2.0-alpha.747",
107
+ "@mittwald/flow-design-tokens": "0.2.0-alpha.749",
108
108
  "@mittwald/flow-icons-base": "",
109
109
  "@mittwald/react-use-promise": "^4.2.2",
110
110
  "@mittwald/remote-dom-react": "1.2.2-mittwald.10",
@@ -157,7 +157,7 @@
157
157
  },
158
158
  "peerDependencies": {
159
159
  "@internationalized/date": "^3.10.0",
160
- "@mittwald/flow-icons-pro": "0.2.0-alpha.746",
160
+ "@mittwald/flow-icons-pro": "0.2.0-alpha.748",
161
161
  "@mittwald/react-use-promise": "^4.2.2",
162
162
  "next": "*",
163
163
  "react": "^19.2.0",
@@ -178,5 +178,5 @@
178
178
  "optional": true
179
179
  }
180
180
  },
181
- "gitHead": "0df5d9b78d126b1263bc728e90dd41c2199e259b"
181
+ "gitHead": "84511f170d093509668d3ba9f60d37de50fe1077"
182
182
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"useHotkeySubmit.mjs","sources":["../../../../../../../../src/integrations/react-hook-form/components/Form/useHotkeySubmit.ts"],"sourcesContent":["import type { Ref } from \"react\";\nimport { useObjectRef } from \"react-aria\";\nimport { useHotkeys } from \"react-hotkeys-hook\";\nimport { useMergeRefs } from \"use-callback-ref\";\n\ninterface Options {\n ref: Ref<HTMLFormElement> | undefined;\n handleSubmit: () => void;\n}\n\nexport const useHotkeySubmit = (options: Options) => {\n const { ref, handleSubmit } = options;\n\n return useMergeRefs([\n useObjectRef(ref),\n useHotkeys<never>(\"mod+enter\", handleSubmit, {\n enableOnFormTags: true,\n enableOnContentEditable: true,\n }),\n ]);\n};\n"],"names":[],"mappings":";;;;AAUO,MAAM,eAAA,GAAkB,CAAC,OAAA,KAAqB;AACnD,EAAA,MAAM,EAAE,GAAA,EAAK,YAAA,EAAa,GAAI,OAAA;AAE9B,EAAA,OAAO,YAAA,CAAa;AAAA,IAClB,aAAa,GAAG,CAAA;AAAA,IAChB,UAAA,CAAkB,aAAa,YAAA,EAAc;AAAA,MAC3C,gBAAA,EAAkB,IAAA;AAAA,MAClB,uBAAA,EAAyB;AAAA,KAC1B;AAAA,GACF,CAAA;AACH;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useHotkeySubmit.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/react-hook-form/components/Form/useHotkeySubmit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAKjC,UAAU,OAAO;IACf,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;IACtC,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,GAAI,SAAS,OAAO,6DAU/C,CAAC"}