@contember/react-form 2.1.0-alpha.37 → 2.1.0-alpha.39

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 (138) hide show
  1. package/dist/development/index.cjs +30 -0
  2. package/dist/development/index.cjs.map +1 -0
  3. package/dist/development/index.js +30 -0
  4. package/dist/development/index.js.map +1 -0
  5. package/dist/development/src/components/FormCheckbox.cjs +83 -0
  6. package/dist/development/src/components/FormCheckbox.cjs.map +1 -0
  7. package/dist/development/src/components/FormCheckbox.js +67 -0
  8. package/dist/development/src/components/FormCheckbox.js.map +1 -0
  9. package/dist/development/src/components/FormError.cjs +22 -0
  10. package/dist/development/src/components/FormError.cjs.map +1 -0
  11. package/dist/development/src/components/FormError.js +22 -0
  12. package/dist/development/src/components/FormError.js.map +1 -0
  13. package/dist/development/src/components/FormFieldScope.cjs +33 -0
  14. package/dist/development/src/components/FormFieldScope.cjs.map +1 -0
  15. package/dist/development/src/components/FormFieldScope.js +33 -0
  16. package/dist/development/src/components/FormFieldScope.js.map +1 -0
  17. package/dist/development/src/components/FormFieldStateProvider.cjs +56 -0
  18. package/dist/development/src/components/FormFieldStateProvider.cjs.map +1 -0
  19. package/dist/development/src/components/FormFieldStateProvider.js +56 -0
  20. package/dist/development/src/components/FormFieldStateProvider.js.map +1 -0
  21. package/dist/development/src/components/FormHasManyRelationScope.cjs +33 -0
  22. package/dist/development/src/components/FormHasManyRelationScope.cjs.map +1 -0
  23. package/dist/development/src/components/FormHasManyRelationScope.js +33 -0
  24. package/dist/development/src/components/FormHasManyRelationScope.js.map +1 -0
  25. package/dist/development/src/components/FormHasOneRelationScope.cjs +33 -0
  26. package/dist/development/src/components/FormHasOneRelationScope.cjs.map +1 -0
  27. package/dist/development/src/components/FormHasOneRelationScope.js +33 -0
  28. package/dist/development/src/components/FormHasOneRelationScope.js.map +1 -0
  29. package/dist/development/src/components/FormInput.cjs +62 -0
  30. package/dist/development/src/components/FormInput.cjs.map +1 -0
  31. package/dist/development/src/components/FormInput.js +62 -0
  32. package/dist/development/src/components/FormInput.js.map +1 -0
  33. package/dist/development/src/components/FormLabel.cjs +34 -0
  34. package/dist/development/src/components/FormLabel.cjs.map +1 -0
  35. package/dist/development/src/components/FormLabel.js +34 -0
  36. package/dist/development/src/components/FormLabel.js.map +1 -0
  37. package/dist/development/src/components/FormRadioInput.cjs +55 -0
  38. package/dist/development/src/components/FormRadioInput.cjs.map +1 -0
  39. package/dist/development/src/components/FormRadioInput.js +55 -0
  40. package/dist/development/src/components/FormRadioInput.js.map +1 -0
  41. package/dist/development/src/contexts.cjs +13 -0
  42. package/dist/development/src/contexts.cjs.map +1 -0
  43. package/dist/development/src/contexts.js +13 -0
  44. package/dist/development/src/contexts.js.map +1 -0
  45. package/dist/development/src/hooks/useFormInputValidationHandler.cjs +80 -0
  46. package/dist/development/src/hooks/useFormInputValidationHandler.cjs.map +1 -0
  47. package/dist/development/src/hooks/useFormInputValidationHandler.js +64 -0
  48. package/dist/development/src/hooks/useFormInputValidationHandler.js.map +1 -0
  49. package/dist/development/src/internal/useFormInputHandler.cjs +122 -0
  50. package/dist/development/src/internal/useFormInputHandler.cjs.map +1 -0
  51. package/dist/development/src/internal/useFormInputHandler.js +122 -0
  52. package/dist/development/src/internal/useFormInputHandler.js.map +1 -0
  53. package/dist/production/index.cjs +30 -0
  54. package/dist/production/index.cjs.map +1 -0
  55. package/dist/production/index.js +30 -0
  56. package/dist/production/index.js.map +1 -0
  57. package/dist/production/src/components/FormCheckbox.cjs +71 -0
  58. package/dist/production/src/components/FormCheckbox.cjs.map +1 -0
  59. package/dist/production/src/components/FormCheckbox.js +55 -0
  60. package/dist/production/src/components/FormCheckbox.js.map +1 -0
  61. package/dist/production/src/components/FormError.cjs +22 -0
  62. package/dist/production/src/components/FormError.cjs.map +1 -0
  63. package/dist/production/src/components/FormError.js +22 -0
  64. package/dist/production/src/components/FormError.js.map +1 -0
  65. package/dist/production/src/components/FormFieldScope.cjs +25 -0
  66. package/dist/production/src/components/FormFieldScope.cjs.map +1 -0
  67. package/dist/production/src/components/FormFieldScope.js +25 -0
  68. package/dist/production/src/components/FormFieldScope.js.map +1 -0
  69. package/dist/production/src/components/FormFieldStateProvider.cjs +34 -0
  70. package/dist/production/src/components/FormFieldStateProvider.cjs.map +1 -0
  71. package/dist/production/src/components/FormFieldStateProvider.js +34 -0
  72. package/dist/production/src/components/FormFieldStateProvider.js.map +1 -0
  73. package/dist/production/src/components/FormHasManyRelationScope.cjs +25 -0
  74. package/dist/production/src/components/FormHasManyRelationScope.cjs.map +1 -0
  75. package/dist/production/src/components/FormHasManyRelationScope.js +25 -0
  76. package/dist/production/src/components/FormHasManyRelationScope.js.map +1 -0
  77. package/dist/production/src/components/FormHasOneRelationScope.cjs +25 -0
  78. package/dist/production/src/components/FormHasOneRelationScope.cjs.map +1 -0
  79. package/dist/production/src/components/FormHasOneRelationScope.js +25 -0
  80. package/dist/production/src/components/FormHasOneRelationScope.js.map +1 -0
  81. package/dist/production/src/components/FormInput.cjs +50 -0
  82. package/dist/production/src/components/FormInput.cjs.map +1 -0
  83. package/dist/production/src/components/FormInput.js +50 -0
  84. package/dist/production/src/components/FormInput.js.map +1 -0
  85. package/dist/production/src/components/FormLabel.cjs +26 -0
  86. package/dist/production/src/components/FormLabel.cjs.map +1 -0
  87. package/dist/production/src/components/FormLabel.js +26 -0
  88. package/dist/production/src/components/FormLabel.js.map +1 -0
  89. package/dist/production/src/components/FormRadioInput.cjs +43 -0
  90. package/dist/production/src/components/FormRadioInput.cjs.map +1 -0
  91. package/dist/production/src/components/FormRadioInput.js +43 -0
  92. package/dist/production/src/components/FormRadioInput.js.map +1 -0
  93. package/dist/production/src/contexts.cjs +13 -0
  94. package/dist/production/src/contexts.cjs.map +1 -0
  95. package/dist/production/src/contexts.js +13 -0
  96. package/dist/production/src/contexts.js.map +1 -0
  97. package/dist/production/src/hooks/useFormInputValidationHandler.cjs +80 -0
  98. package/dist/production/src/hooks/useFormInputValidationHandler.cjs.map +1 -0
  99. package/dist/production/src/hooks/useFormInputValidationHandler.js +64 -0
  100. package/dist/production/src/hooks/useFormInputValidationHandler.js.map +1 -0
  101. package/dist/production/src/internal/useFormInputHandler.cjs +122 -0
  102. package/dist/production/src/internal/useFormInputHandler.cjs.map +1 -0
  103. package/dist/production/src/internal/useFormInputHandler.js +122 -0
  104. package/dist/production/src/internal/useFormInputHandler.js.map +1 -0
  105. package/dist/types/components/FormCheckbox.d.ts +11 -0
  106. package/dist/types/components/FormCheckbox.d.ts.map +1 -0
  107. package/dist/types/components/FormError.d.ts +7 -0
  108. package/dist/types/components/FormError.d.ts.map +1 -0
  109. package/dist/types/components/FormFieldScope.d.ts +9 -0
  110. package/dist/types/components/FormFieldScope.d.ts.map +1 -0
  111. package/dist/types/components/FormFieldStateProvider.d.ts +36 -0
  112. package/dist/types/components/FormFieldStateProvider.d.ts.map +1 -0
  113. package/dist/types/components/FormHasManyRelationScope.d.ts +12 -0
  114. package/dist/types/components/FormHasManyRelationScope.d.ts.map +1 -0
  115. package/dist/types/components/FormHasOneRelationScope.d.ts +9 -0
  116. package/dist/types/components/FormHasOneRelationScope.d.ts.map +1 -0
  117. package/dist/types/components/FormInput.d.ts +13 -0
  118. package/dist/types/components/FormInput.d.ts.map +1 -0
  119. package/dist/types/components/FormLabel.d.ts +5 -0
  120. package/dist/types/components/FormLabel.d.ts.map +1 -0
  121. package/dist/types/components/FormRadioInput.d.ts +11 -0
  122. package/dist/types/components/FormRadioInput.d.ts.map +1 -0
  123. package/dist/types/components/index.d.ts +10 -0
  124. package/dist/types/components/index.d.ts.map +1 -0
  125. package/dist/types/contexts.d.ts +12 -0
  126. package/dist/types/contexts.d.ts.map +1 -0
  127. package/dist/types/hooks/index.d.ts +2 -0
  128. package/dist/types/hooks/index.d.ts.map +1 -0
  129. package/dist/types/hooks/useFormInputValidationHandler.d.ts +8 -0
  130. package/dist/types/hooks/useFormInputValidationHandler.d.ts.map +1 -0
  131. package/dist/types/index.d.ts +5 -0
  132. package/dist/types/index.d.ts.map +1 -0
  133. package/dist/types/internal/useFormInputHandler.d.ts +4 -0
  134. package/dist/types/internal/useFormInputHandler.d.ts.map +1 -0
  135. package/dist/types/tsconfig.tsbuildinfo +1 -0
  136. package/dist/types/types/index.d.ts +23 -0
  137. package/dist/types/types/index.d.ts.map +1 -0
  138. package/package.json +9 -9
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const contexts = require("../contexts.cjs");
6
+ const emptyArr = [];
7
+ const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }) => {
8
+ const generatedId = React.useId();
9
+ htmlId ?? (htmlId = generatedId);
10
+ const value = React.useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field]);
11
+ return /* @__PURE__ */ jsxRuntime.jsx(contexts.FormFieldStateContext.Provider, { value, children });
12
+ };
13
+ const FormFieldIdContext = {
14
+ /**
15
+ * @deprecated use `FormFieldStateProvider` instead
16
+ */
17
+ Provider: ({ children, value }) => {
18
+ const state = contexts.useFormFieldState();
19
+ return /* @__PURE__ */ jsxRuntime.jsx(FormFieldStateProvider, { ...state, htmlId: value, children });
20
+ }
21
+ };
22
+ const FormErrorContext = {
23
+ /**
24
+ * @deprecated use `FormFieldStateProvider` instead
25
+ */
26
+ Provider: ({ children, value }) => {
27
+ const state = contexts.useFormFieldState();
28
+ return /* @__PURE__ */ jsxRuntime.jsx(FormFieldStateProvider, { ...state, errors: value, children });
29
+ }
30
+ };
31
+ exports.FormErrorContext = FormErrorContext;
32
+ exports.FormFieldIdContext = FormFieldIdContext;
33
+ exports.FormFieldStateProvider = FormFieldStateProvider;
34
+ //# sourceMappingURL=FormFieldStateProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormFieldStateProvider.cjs","sources":["../../../../../packages/react-form/src/components/FormFieldStateProvider.tsx"],"sourcesContent":["import { ErrorAccessor } from '@contember/react-binding'\nimport { useEffect, useId, useMemo } from 'react'\nimport { FormFieldStateContext, useFormFieldState } from '../contexts'\nimport { FormFieldState } from '../types'\n\nconst emptyArr: [] = []\n\nexport type FormFieldStateProvider =\n\t& Partial<FormFieldState>\n\t& {\n\t\tchildren: React.ReactNode\n\t}\n\nexport const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }: FormFieldStateProvider) => {\n\tconst generatedId = useId()\n\thtmlId ??= generatedId\n\tconst value = useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field])\n\treturn <FormFieldStateContext.Provider value={value}>{children}</FormFieldStateContext.Provider>\n}\n\n/**\n * BC for\n * \t<FormFieldIdContext.Provider value={id}>\n * \t<FormErrorContext.Provider value={[]}>\n */\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormFieldIdContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: string }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormFieldIdContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} htmlId={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormErrorContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: ErrorAccessor.Error[] }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormErrorContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} errors={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n"],"names":["useId","useMemo","FormFieldStateContext","useFormFieldState"],"mappings":";;;;;AAKA,MAAM,WAAe,CAAA;AAQd,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,QAAQ,OAAO,QAAQ,MAAA,MAAoC;AAClJ,QAAM,cAAcA,MAAAA,MAAA;AACpB,aAAA,SAAW;AACX,QAAM,QAAQC,MAAAA,QAAQ,OAAO,EAAE,QAAQ,UAAU,QAAQ,OAAO,MAAA,IAAU,CAAC,QAAQ,UAAU,QAAQ,OAAO,KAAK,CAAC;AAClH,wCAAQC,SAAAA,sBAAsB,UAAtB,EAA+B,OAAe,UAAS;AAChE;AAWO,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC,UAAU,CAAC,EAAE,UAAU,YAA0D;AAChF,UAAM,QAAQC,SAAAA,kBAAA;AAMd,0CACE,wBAAA,EAAwB,GAAG,OAAO,QAAQ,OACzC,UACF;AAAA,EAEF;AACD;AAKO,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI/B,UAAU,CAAC,EAAE,UAAU,YAAyE;AAC/F,UAAM,QAAQA,SAAAA,kBAAA;AAMd,0CACE,wBAAA,EAAwB,GAAG,OAAO,QAAQ,OACzC,UACF;AAAA,EAEF;AACD;;;;"}
@@ -0,0 +1,34 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useId, useMemo } from "react";
3
+ import { useFormFieldState, FormFieldStateContext } from "../contexts.js";
4
+ const emptyArr = [];
5
+ const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }) => {
6
+ const generatedId = useId();
7
+ htmlId ?? (htmlId = generatedId);
8
+ const value = useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field]);
9
+ return /* @__PURE__ */ jsx(FormFieldStateContext.Provider, { value, children });
10
+ };
11
+ const FormFieldIdContext = {
12
+ /**
13
+ * @deprecated use `FormFieldStateProvider` instead
14
+ */
15
+ Provider: ({ children, value }) => {
16
+ const state = useFormFieldState();
17
+ return /* @__PURE__ */ jsx(FormFieldStateProvider, { ...state, htmlId: value, children });
18
+ }
19
+ };
20
+ const FormErrorContext = {
21
+ /**
22
+ * @deprecated use `FormFieldStateProvider` instead
23
+ */
24
+ Provider: ({ children, value }) => {
25
+ const state = useFormFieldState();
26
+ return /* @__PURE__ */ jsx(FormFieldStateProvider, { ...state, errors: value, children });
27
+ }
28
+ };
29
+ export {
30
+ FormErrorContext,
31
+ FormFieldIdContext,
32
+ FormFieldStateProvider
33
+ };
34
+ //# sourceMappingURL=FormFieldStateProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormFieldStateProvider.js","sources":["../../../../../packages/react-form/src/components/FormFieldStateProvider.tsx"],"sourcesContent":["import { ErrorAccessor } from '@contember/react-binding'\nimport { useEffect, useId, useMemo } from 'react'\nimport { FormFieldStateContext, useFormFieldState } from '../contexts'\nimport { FormFieldState } from '../types'\n\nconst emptyArr: [] = []\n\nexport type FormFieldStateProvider =\n\t& Partial<FormFieldState>\n\t& {\n\t\tchildren: React.ReactNode\n\t}\n\nexport const FormFieldStateProvider = ({ children, required = false, errors = emptyArr, dirty = false, htmlId, field }: FormFieldStateProvider) => {\n\tconst generatedId = useId()\n\thtmlId ??= generatedId\n\tconst value = useMemo(() => ({ htmlId, required, errors, dirty, field }), [htmlId, required, errors, dirty, field])\n\treturn <FormFieldStateContext.Provider value={value}>{children}</FormFieldStateContext.Provider>\n}\n\n/**\n * BC for\n * \t<FormFieldIdContext.Provider value={id}>\n * \t<FormErrorContext.Provider value={[]}>\n */\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormFieldIdContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: string }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormFieldIdContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} htmlId={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n\n/**\n * @deprecated use `FormFieldStateProvider` instead\n */\nexport const FormErrorContext = {\n\t/**\n\t * @deprecated use `FormFieldStateProvider` instead\n\t */\n\tProvider: ({ children, value }: { children: React.ReactNode; value: ErrorAccessor.Error[] }) => {\n\t\tconst state = useFormFieldState()\n\t\tif (import.meta.env.DEV) {\n\t\t\tuseEffect(() => {\n\t\t\t\tconsole.warn('FormErrorContext.Provider is deprecated, use FormFieldStateProvider instead')\n\t\t\t}, [])\n\t\t}\n\t\treturn (\n\t\t\t<FormFieldStateProvider {...state} errors={value}>\n\t\t\t\t{children}\n\t\t\t</FormFieldStateProvider>\n\t\t)\n\t},\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,WAAe,CAAA;AAQd,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,OAAO,SAAS,UAAU,QAAQ,OAAO,QAAQ,MAAA,MAAoC;AAClJ,QAAM,cAAc,MAAA;AACpB,aAAA,SAAW;AACX,QAAM,QAAQ,QAAQ,OAAO,EAAE,QAAQ,UAAU,QAAQ,OAAO,MAAA,IAAU,CAAC,QAAQ,UAAU,QAAQ,OAAO,KAAK,CAAC;AAClH,6BAAQ,sBAAsB,UAAtB,EAA+B,OAAe,UAAS;AAChE;AAWO,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA,EAIjC,UAAU,CAAC,EAAE,UAAU,YAA0D;AAChF,UAAM,QAAQ,kBAAA;AAMd,+BACE,wBAAA,EAAwB,GAAG,OAAO,QAAQ,OACzC,UACF;AAAA,EAEF;AACD;AAKO,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI/B,UAAU,CAAC,EAAE,UAAU,YAAyE;AAC/F,UAAM,QAAQ,kBAAA;AAMd,+BACE,wBAAA,EAAwB,GAAG,OAAO,QAAQ,OACzC,UACF;AAAA,EAEF;AACD;"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactBinding = require("@contember/react-binding");
5
+ const FormFieldStateProvider = require("./FormFieldStateProvider.cjs");
6
+ const React = require("react");
7
+ const FormHasManyRelationScope = ({ children, required, ...props }) => {
8
+ const entityRelation = reactBinding.useEntityList(props);
9
+ const entityName = entityRelation.getParent().name;
10
+ const marker = entityRelation.getMarker();
11
+ const fieldName = marker.parameters.field;
12
+ const fieldInfo = React.useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
13
+ return /* @__PURE__ */ jsxRuntime.jsx(
14
+ FormFieldStateProvider.FormFieldStateProvider,
15
+ {
16
+ errors: entityRelation.errors?.errors,
17
+ dirty: entityRelation.hasUnpersistedChanges,
18
+ required,
19
+ field: fieldInfo,
20
+ children
21
+ }
22
+ );
23
+ };
24
+ exports.FormHasManyRelationScope = FormHasManyRelationScope;
25
+ //# sourceMappingURL=FormHasManyRelationScope.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasManyRelationScope.cjs","sources":["../../../../../packages/react-form/src/components/FormHasManyRelationScope.tsx"],"sourcesContent":["import { HasManyRelationMarker, SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport * as React from 'react'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasManyRelationScopeProps = {\n\tfield: SugaredRelativeEntityList['field']\n\torderBy?: SugaredRelativeEntityList['orderBy']\n\tlimit?: SugaredRelativeEntityList['limit']\n\toffset?: SugaredRelativeEntityList['offset']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasManyRelationScope = ({ children, required, ...props }: FormHasManyRelationScopeProps) => {\n\tconst entityRelation = useEntityList(props)\n\tconst entityName = entityRelation.getParent()!.name\n\tconst marker = entityRelation.getMarker() as HasManyRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":["useEntityList","useMemo","jsx","FormFieldStateProvider"],"mappings":";;;;;;AAcO,MAAM,2BAA2B,CAAC,EAAE,UAAU,UAAU,GAAG,YAA2C;AAC5G,QAAM,iBAAiBA,aAAAA,cAAc,KAAK;AAC1C,QAAM,aAAa,eAAe,UAAA,EAAa;AAC/C,QAAM,SAAS,eAAe,UAAA;AAC9B,QAAM,YAAY,OAAO,WAAW;AACpC,QAAM,YAAYC,cAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AAEpF,SACCC,2BAAAA;AAAAA,IAACC,uBAAAA;AAAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,EAAA;AAGJ;;"}
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useEntityList } from "@contember/react-binding";
3
+ import { FormFieldStateProvider } from "./FormFieldStateProvider.js";
4
+ import { useMemo } from "react";
5
+ const FormHasManyRelationScope = ({ children, required, ...props }) => {
6
+ const entityRelation = useEntityList(props);
7
+ const entityName = entityRelation.getParent().name;
8
+ const marker = entityRelation.getMarker();
9
+ const fieldName = marker.parameters.field;
10
+ const fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
11
+ return /* @__PURE__ */ jsx(
12
+ FormFieldStateProvider,
13
+ {
14
+ errors: entityRelation.errors?.errors,
15
+ dirty: entityRelation.hasUnpersistedChanges,
16
+ required,
17
+ field: fieldInfo,
18
+ children
19
+ }
20
+ );
21
+ };
22
+ export {
23
+ FormHasManyRelationScope
24
+ };
25
+ //# sourceMappingURL=FormHasManyRelationScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasManyRelationScope.js","sources":["../../../../../packages/react-form/src/components/FormHasManyRelationScope.tsx"],"sourcesContent":["import { HasManyRelationMarker, SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport * as React from 'react'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasManyRelationScopeProps = {\n\tfield: SugaredRelativeEntityList['field']\n\torderBy?: SugaredRelativeEntityList['orderBy']\n\tlimit?: SugaredRelativeEntityList['limit']\n\toffset?: SugaredRelativeEntityList['offset']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasManyRelationScope = ({ children, required, ...props }: FormHasManyRelationScopeProps) => {\n\tconst entityRelation = useEntityList(props)\n\tconst entityName = entityRelation.getParent()!.name\n\tconst marker = entityRelation.getMarker() as HasManyRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":[],"mappings":";;;;AAcO,MAAM,2BAA2B,CAAC,EAAE,UAAU,UAAU,GAAG,YAA2C;AAC5G,QAAM,iBAAiB,cAAc,KAAK;AAC1C,QAAM,aAAa,eAAe,UAAA,EAAa;AAC/C,QAAM,SAAS,eAAe,UAAA;AAC9B,QAAM,YAAY,OAAO,WAAW;AACpC,QAAM,YAAY,QAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AAEpF,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,EAAA;AAGJ;"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactBinding = require("@contember/react-binding");
5
+ const FormFieldStateProvider = require("./FormFieldStateProvider.cjs");
6
+ const React = require("react");
7
+ const FormHasOneRelationScope = ({ field, children, required }) => {
8
+ const entityRelation = reactBinding.useEntity({ field });
9
+ const marker = entityRelation.getMarker();
10
+ const fieldName = marker.parameters.field;
11
+ const entityName = entityRelation.getParent().name;
12
+ const fieldInfo = React.useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
13
+ return /* @__PURE__ */ jsxRuntime.jsx(
14
+ FormFieldStateProvider.FormFieldStateProvider,
15
+ {
16
+ errors: entityRelation.errors?.errors,
17
+ dirty: entityRelation.hasUnpersistedChanges,
18
+ required,
19
+ field: fieldInfo,
20
+ children
21
+ }
22
+ );
23
+ };
24
+ exports.FormHasOneRelationScope = FormHasOneRelationScope;
25
+ //# sourceMappingURL=FormHasOneRelationScope.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasOneRelationScope.cjs","sources":["../../../../../packages/react-form/src/components/FormHasOneRelationScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { HasOneRelationMarker, SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasOneRelationScopeProps = {\n\tfield: SugaredRelativeSingleEntity['field']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasOneRelationScope = ({ field, children, required }: FormHasOneRelationScopeProps) => {\n\tconst entityRelation = useEntity({ field })\n\tconst marker = entityRelation.getMarker() as HasOneRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst entityName = entityRelation.getParent()!.name\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":["useEntity","useMemo","jsx","FormFieldStateProvider"],"mappings":";;;;;;AAWO,MAAM,0BAA0B,CAAC,EAAE,OAAO,UAAU,eAA6C;AACvG,QAAM,iBAAiBA,aAAAA,UAAU,EAAE,OAAO;AAC1C,QAAM,SAAS,eAAe,UAAA;AAC9B,QAAM,YAAY,OAAO,WAAW;AACpC,QAAM,aAAa,eAAe,UAAA,EAAa;AAC/C,QAAM,YAAYC,cAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AACpF,SACCC,2BAAAA;AAAAA,IAACC,uBAAAA;AAAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,EAAA;AAGJ;;"}
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useEntity } from "@contember/react-binding";
3
+ import { FormFieldStateProvider } from "./FormFieldStateProvider.js";
4
+ import { useMemo } from "react";
5
+ const FormHasOneRelationScope = ({ field, children, required }) => {
6
+ const entityRelation = useEntity({ field });
7
+ const marker = entityRelation.getMarker();
8
+ const fieldName = marker.parameters.field;
9
+ const entityName = entityRelation.getParent().name;
10
+ const fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName]);
11
+ return /* @__PURE__ */ jsx(
12
+ FormFieldStateProvider,
13
+ {
14
+ errors: entityRelation.errors?.errors,
15
+ dirty: entityRelation.hasUnpersistedChanges,
16
+ required,
17
+ field: fieldInfo,
18
+ children
19
+ }
20
+ );
21
+ };
22
+ export {
23
+ FormHasOneRelationScope
24
+ };
25
+ //# sourceMappingURL=FormHasOneRelationScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasOneRelationScope.js","sources":["../../../../../packages/react-form/src/components/FormHasOneRelationScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { HasOneRelationMarker, SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\nimport { FormFieldStateProvider } from './FormFieldStateProvider'\nimport { useMemo } from 'react'\n\nexport type FormHasOneRelationScopeProps = {\n\tfield: SugaredRelativeSingleEntity['field']\n\tchildren: React.ReactNode\n\trequired?: boolean\n}\n\nexport const FormHasOneRelationScope = ({ field, children, required }: FormHasOneRelationScopeProps) => {\n\tconst entityRelation = useEntity({ field })\n\tconst marker = entityRelation.getMarker() as HasOneRelationMarker\n\tconst fieldName = marker.parameters.field\n\tconst entityName = entityRelation.getParent()!.name\n\tconst fieldInfo = useMemo(() => ({ entityName, fieldName }), [entityName, fieldName])\n\treturn (\n\t\t<FormFieldStateProvider\n\t\t\terrors={entityRelation.errors?.errors}\n\t\t\tdirty={entityRelation.hasUnpersistedChanges}\n\t\t\trequired={required}\n\t\t\tfield={fieldInfo}\n\t\t>\n\t\t\t{children}\n\t\t</FormFieldStateProvider>\n\t)\n}\n"],"names":[],"mappings":";;;;AAWO,MAAM,0BAA0B,CAAC,EAAE,OAAO,UAAU,eAA6C;AACvG,QAAM,iBAAiB,UAAU,EAAE,OAAO;AAC1C,QAAM,SAAS,eAAe,UAAA;AAC9B,QAAM,YAAY,OAAO,WAAW;AACpC,QAAM,aAAa,eAAe,UAAA,EAAa;AAC/C,QAAM,YAAY,QAAQ,OAAO,EAAE,YAAY,cAAc,CAAC,YAAY,SAAS,CAAC;AACpF,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,QAAQ,eAAe,QAAQ;AAAA,MAC/B,OAAO,eAAe;AAAA,MACtB;AAAA,MACA,OAAO;AAAA,MAEN;AAAA,IAAA;AAAA,EAAA;AAGJ;"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const reactSlot = require("@radix-ui/react-slot");
6
+ const reactBinding = require("@contember/react-binding");
7
+ const utilities = require("@contember/utilities");
8
+ const useFormInputHandler = require("../internal/useFormInputHandler.cjs");
9
+ const contexts = require("../contexts.cjs");
10
+ const useFormInputValidationHandler = require("../hooks/useFormInputValidationHandler.cjs");
11
+ const reactUtils = require("@contember/react-utils");
12
+ const SlotInput = reactSlot.Slot;
13
+ const FormInput = reactBinding.Component(
14
+ ({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {
15
+ const accessor = reactBinding.useField(field);
16
+ const formState = contexts.useFormFieldState();
17
+ const id = formState?.htmlId;
18
+ const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
19
+ const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
20
+ const required = formState?.required ?? !accessor.schema.nullable;
21
+ const [state, setState] = React.useState(void 0);
22
+ const { parseValue, formatValue, defaultInputProps } = useFormInputHandler.useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn });
23
+ const accessorGetter = accessor.getAccessor;
24
+ const { ref, onFocus, onBlur } = useFormInputValidationHandler.useFormInputValidationHandler(accessor);
25
+ return /* @__PURE__ */ jsxRuntime.jsx(
26
+ SlotInput,
27
+ {
28
+ ref,
29
+ value: formatValue(accessor.value, { state, setState }),
30
+ "data-invalid": utilities.dataAttribute(hasErrors),
31
+ "data-dirty": utilities.dataAttribute(dirty),
32
+ "data-required": utilities.dataAttribute(required),
33
+ onFocus,
34
+ onBlur,
35
+ onChange: reactUtils.useReferentiallyStableCallback((e) => {
36
+ accessorGetter().updateValue(parseValue(e.target.value, { state, setState }));
37
+ }),
38
+ ...defaultInputProps,
39
+ id: id ? `${id}-input` : void 0,
40
+ required,
41
+ ...props
42
+ }
43
+ );
44
+ },
45
+ ({ field, isNonbearing, defaultValue }) => {
46
+ return /* @__PURE__ */ jsxRuntime.jsx(reactBinding.Field, { field, isNonbearing, defaultValue });
47
+ }
48
+ );
49
+ exports.FormInput = FormInput;
50
+ //# sourceMappingURL=FormInput.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormInput.cjs","sources":["../../../../../packages/react-form/src/components/FormInput.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ComponentType, useCallback, useState } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputHandler } from '../internal/useFormInputHandler'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks/useFormInputValidationHandler'\nimport { FormInputHandler } from '../types'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\n\ntype InputProps = React.JSX.IntrinsicElements['input']\nconst SlotInput = Slot as ComponentType<InputProps>\n\nexport interface FormInputProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactElement\n\tformatValue?: FormInputHandler['formatValue']\n\tparseValue?: FormInputHandler['parseValue']\n}\n\nexport const FormInput = Component<FormInputProps>(\n\t({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {\n\t\tconst accessor = useField(field)\n\n\t\tconst formState = useFormFieldState()\n\t\tconst id = formState?.htmlId\n\t\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\t\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\t\tconst required = formState?.required ?? !accessor.schema.nullable\n\n\t\tconst [state, setState] = useState<any>(undefined)\n\n\t\tconst { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn })\n\t\tconst accessorGetter = accessor.getAccessor\n\t\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\t\treturn (\n\t\t\t<SlotInput\n\t\t\t\tref={ref}\n\t\t\t\tvalue={formatValue(accessor.value, { state, setState })}\n\t\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\t\tdata-required={dataAttribute(required)}\n\t\t\t\tonFocus={onFocus}\n\t\t\t\tonBlur={onBlur}\n\t\t\t\tonChange={useReferentiallyStableCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\t\taccessorGetter().updateValue(parseValue(e.target.value, { state, setState }))\n\t\t\t\t})}\n\t\t\t\t{...defaultInputProps}\n\t\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\t\trequired={required}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t)\n\t},\n\t({ field, isNonbearing, defaultValue }) => {\n\t\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />\n\t},\n)\n"],"names":["Slot","Component","useField","useFormFieldState","useState","useFormInputHandler","useFormInputValidationHandler","jsx","dataAttribute","useReferentiallyStableCallback","Field"],"mappings":";;;;;;;;;;;AAYA,MAAM,YAAYA,UAAAA;AAWX,MAAM,YAAYC,aAAAA;AAAAA,EACxB,CAAC,EAAE,OAAO,cAAc,cAAc,aAAa,eAAe,YAAY,cAAc,GAAG,YAAY;AAC1G,UAAM,WAAWC,aAAAA,SAAS,KAAK;AAE/B,UAAM,YAAYC,SAAAA,kBAAA;AAClB,UAAM,KAAK,WAAW;AACtB,UAAM,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACvF,UAAM,QAAQ,WAAW,SAAS,SAAS;AAC3C,UAAM,WAAW,WAAW,YAAY,CAAC,SAAS,OAAO;AAEzD,UAAM,CAAC,OAAO,QAAQ,IAAIC,MAAAA,SAAc,MAAS;AAEjD,UAAM,EAAE,YAAY,aAAa,kBAAA,IAAsBC,oBAAAA,oBAAoB,UAAU,EAAE,aAAa,eAAe,YAAY,aAAA,CAAc;AAC7I,UAAM,iBAAiB,SAAS;AAChC,UAAM,EAAE,KAAK,SAAS,OAAA,IAAWC,8BAAAA,8BAA8B,QAAQ;AAEvE,WACCC,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACA;AAAA,QACA,OAAO,YAAY,SAAS,OAAO,EAAE,OAAO,UAAU;AAAA,QACtD,gBAAcC,UAAAA,cAAc,SAAS;AAAA,QACrC,cAAYA,UAAAA,cAAc,KAAK;AAAA,QAC/B,iBAAeA,UAAAA,cAAc,QAAQ;AAAA,QACrC;AAAA,QACA;AAAA,QACA,UAAUC,WAAAA,+BAAqE,CAAA,MAAK;AACnF,yBAAA,EAAiB,YAAY,WAAW,EAAE,OAAO,OAAO,EAAE,OAAO,SAAA,CAAU,CAAC;AAAA,QAC7E,CAAC;AAAA,QACA,GAAG;AAAA,QACJ,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,QACzB;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AAAA,EACA,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC1C,WAAOF,2BAAAA,IAACG,aAAAA,OAAA,EAAM,OAAc,cAA4B,aAAA,CAA4B;AAAA,EACrF;AACD;;"}
@@ -0,0 +1,50 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { Component, useField, Field } from "@contember/react-binding";
5
+ import { dataAttribute } from "@contember/utilities";
6
+ import { useFormInputHandler } from "../internal/useFormInputHandler.js";
7
+ import { useFormFieldState } from "../contexts.js";
8
+ import { useFormInputValidationHandler } from "../hooks/useFormInputValidationHandler.js";
9
+ import { useReferentiallyStableCallback } from "@contember/react-utils";
10
+ const SlotInput = Slot;
11
+ const FormInput = Component(
12
+ ({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {
13
+ const accessor = useField(field);
14
+ const formState = useFormFieldState();
15
+ const id = formState?.htmlId;
16
+ const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
17
+ const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
18
+ const required = formState?.required ?? !accessor.schema.nullable;
19
+ const [state, setState] = useState(void 0);
20
+ const { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn });
21
+ const accessorGetter = accessor.getAccessor;
22
+ const { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor);
23
+ return /* @__PURE__ */ jsx(
24
+ SlotInput,
25
+ {
26
+ ref,
27
+ value: formatValue(accessor.value, { state, setState }),
28
+ "data-invalid": dataAttribute(hasErrors),
29
+ "data-dirty": dataAttribute(dirty),
30
+ "data-required": dataAttribute(required),
31
+ onFocus,
32
+ onBlur,
33
+ onChange: useReferentiallyStableCallback((e) => {
34
+ accessorGetter().updateValue(parseValue(e.target.value, { state, setState }));
35
+ }),
36
+ ...defaultInputProps,
37
+ id: id ? `${id}-input` : void 0,
38
+ required,
39
+ ...props
40
+ }
41
+ );
42
+ },
43
+ ({ field, isNonbearing, defaultValue }) => {
44
+ return /* @__PURE__ */ jsx(Field, { field, isNonbearing, defaultValue });
45
+ }
46
+ );
47
+ export {
48
+ FormInput
49
+ };
50
+ //# sourceMappingURL=FormInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormInput.js","sources":["../../../../../packages/react-form/src/components/FormInput.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ComponentType, useCallback, useState } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputHandler } from '../internal/useFormInputHandler'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks/useFormInputValidationHandler'\nimport { FormInputHandler } from '../types'\nimport { useReferentiallyStableCallback } from '@contember/react-utils'\n\ntype InputProps = React.JSX.IntrinsicElements['input']\nconst SlotInput = Slot as ComponentType<InputProps>\n\nexport interface FormInputProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactElement\n\tformatValue?: FormInputHandler['formatValue']\n\tparseValue?: FormInputHandler['parseValue']\n}\n\nexport const FormInput = Component<FormInputProps>(\n\t({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {\n\t\tconst accessor = useField(field)\n\n\t\tconst formState = useFormFieldState()\n\t\tconst id = formState?.htmlId\n\t\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\t\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\t\tconst required = formState?.required ?? !accessor.schema.nullable\n\n\t\tconst [state, setState] = useState<any>(undefined)\n\n\t\tconst { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn })\n\t\tconst accessorGetter = accessor.getAccessor\n\t\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\t\treturn (\n\t\t\t<SlotInput\n\t\t\t\tref={ref}\n\t\t\t\tvalue={formatValue(accessor.value, { state, setState })}\n\t\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\t\tdata-required={dataAttribute(required)}\n\t\t\t\tonFocus={onFocus}\n\t\t\t\tonBlur={onBlur}\n\t\t\t\tonChange={useReferentiallyStableCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\t\taccessorGetter().updateValue(parseValue(e.target.value, { state, setState }))\n\t\t\t\t})}\n\t\t\t\t{...defaultInputProps}\n\t\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\t\trequired={required}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t)\n\t},\n\t({ field, isNonbearing, defaultValue }) => {\n\t\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />\n\t},\n)\n"],"names":[],"mappings":";;;;;;;;;AAYA,MAAM,YAAY;AAWX,MAAM,YAAY;AAAA,EACxB,CAAC,EAAE,OAAO,cAAc,cAAc,aAAa,eAAe,YAAY,cAAc,GAAG,YAAY;AAC1G,UAAM,WAAW,SAAS,KAAK;AAE/B,UAAM,YAAY,kBAAA;AAClB,UAAM,KAAK,WAAW;AACtB,UAAM,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACvF,UAAM,QAAQ,WAAW,SAAS,SAAS;AAC3C,UAAM,WAAW,WAAW,YAAY,CAAC,SAAS,OAAO;AAEzD,UAAM,CAAC,OAAO,QAAQ,IAAI,SAAc,MAAS;AAEjD,UAAM,EAAE,YAAY,aAAa,kBAAA,IAAsB,oBAAoB,UAAU,EAAE,aAAa,eAAe,YAAY,aAAA,CAAc;AAC7I,UAAM,iBAAiB,SAAS;AAChC,UAAM,EAAE,KAAK,SAAS,OAAA,IAAW,8BAA8B,QAAQ;AAEvE,WACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA;AAAA,QACA,OAAO,YAAY,SAAS,OAAO,EAAE,OAAO,UAAU;AAAA,QACtD,gBAAc,cAAc,SAAS;AAAA,QACrC,cAAY,cAAc,KAAK;AAAA,QAC/B,iBAAe,cAAc,QAAQ;AAAA,QACrC;AAAA,QACA;AAAA,QACA,UAAU,+BAAqE,CAAA,MAAK;AACnF,yBAAA,EAAiB,YAAY,WAAW,EAAE,OAAO,OAAO,EAAE,OAAO,SAAA,CAAU,CAAC;AAAA,QAC7E,CAAC;AAAA,QACA,GAAG;AAAA,QACJ,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,QACzB;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AAAA,EACA,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC1C,WAAO,oBAAC,OAAA,EAAM,OAAc,cAA4B,aAAA,CAA4B;AAAA,EACrF;AACD;"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactSlot = require("@radix-ui/react-slot");
5
+ const utilities = require("@contember/utilities");
6
+ const contexts = require("../contexts.cjs");
7
+ const reactBinding = require("@contember/react-binding");
8
+ const FormLabel = (props) => {
9
+ const formState = contexts.useFormFieldState();
10
+ if (!formState) {
11
+ throw new reactBinding.BindingError("FormError must be used inside a FormField");
12
+ }
13
+ const { errors, htmlId, dirty, required } = formState;
14
+ return /* @__PURE__ */ jsxRuntime.jsx(
15
+ reactSlot.Slot,
16
+ {
17
+ "data-invalid": utilities.dataAttribute(errors.length > 0),
18
+ "data-dirty": utilities.dataAttribute(dirty),
19
+ "data-required": utilities.dataAttribute(required),
20
+ ...htmlId ? { htmlFor: `${htmlId}-input` } : {},
21
+ ...props
22
+ }
23
+ );
24
+ };
25
+ exports.FormLabel = FormLabel;
26
+ //# sourceMappingURL=FormLabel.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormLabel.cjs","sources":["../../../../../packages/react-form/src/components/FormLabel.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormFieldState } from '../contexts'\nimport { BindingError } from '@contember/react-binding'\n\nexport const FormLabel = (props: {\n\tchildren: React.ReactElement\n}) => {\n\tconst formState = useFormFieldState()\n\tif (!formState) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\tconst { errors, htmlId, dirty, required } = formState\n\treturn (\n\t\t<Slot\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tdata-required={dataAttribute(required)}\n\t\t\t{...(htmlId ? { htmlFor: `${htmlId}-input` } : {})}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["useFormFieldState","BindingError","jsx","Slot","dataAttribute"],"mappings":";;;;;;;AAMO,MAAM,YAAY,CAAC,UAEpB;AACL,QAAM,YAAYA,SAAAA,kBAAA;AAClB,MAAI,CAAC,WAAW;AACf,UAAM,IAAIC,aAAAA,aAAa,2CAA2C;AAAA,EACnE;AACA,QAAM,EAAE,QAAQ,QAAQ,OAAO,aAAa;AAC5C,SACCC,2BAAAA;AAAAA,IAACC,UAAAA;AAAAA,IAAA;AAAA,MACA,gBAAcC,UAAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,cAAYA,UAAAA,cAAc,KAAK;AAAA,MAC/B,iBAAeA,UAAAA,cAAc,QAAQ;AAAA,MACpC,GAAI,SAAS,EAAE,SAAS,GAAG,MAAM,SAAA,IAAa,CAAA;AAAA,MAC9C,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP;;"}
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { dataAttribute } from "@contember/utilities";
4
+ import { useFormFieldState } from "../contexts.js";
5
+ import { BindingError } from "@contember/react-binding";
6
+ const FormLabel = (props) => {
7
+ const formState = useFormFieldState();
8
+ if (!formState) {
9
+ throw new BindingError("FormError must be used inside a FormField");
10
+ }
11
+ const { errors, htmlId, dirty, required } = formState;
12
+ return /* @__PURE__ */ jsx(
13
+ Slot,
14
+ {
15
+ "data-invalid": dataAttribute(errors.length > 0),
16
+ "data-dirty": dataAttribute(dirty),
17
+ "data-required": dataAttribute(required),
18
+ ...htmlId ? { htmlFor: `${htmlId}-input` } : {},
19
+ ...props
20
+ }
21
+ );
22
+ };
23
+ export {
24
+ FormLabel
25
+ };
26
+ //# sourceMappingURL=FormLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormLabel.js","sources":["../../../../../packages/react-form/src/components/FormLabel.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormFieldState } from '../contexts'\nimport { BindingError } from '@contember/react-binding'\n\nexport const FormLabel = (props: {\n\tchildren: React.ReactElement\n}) => {\n\tconst formState = useFormFieldState()\n\tif (!formState) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\tconst { errors, htmlId, dirty, required } = formState\n\treturn (\n\t\t<Slot\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tdata-required={dataAttribute(required)}\n\t\t\t{...(htmlId ? { htmlFor: `${htmlId}-input` } : {})}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,YAAY,CAAC,UAEpB;AACL,QAAM,YAAY,kBAAA;AAClB,MAAI,CAAC,WAAW;AACf,UAAM,IAAI,aAAa,2CAA2C;AAAA,EACnE;AACA,QAAM,EAAE,QAAQ,QAAQ,OAAO,aAAa;AAC5C,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,cAAY,cAAc,KAAK;AAAA,MAC/B,iBAAe,cAAc,QAAQ;AAAA,MACpC,GAAI,SAAS,EAAE,SAAS,GAAG,MAAM,SAAA,IAAa,CAAA;AAAA,MAC9C,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactBinding = require("@contember/react-binding");
5
+ const utilities = require("@contember/utilities");
6
+ const reactSlot = require("@radix-ui/react-slot");
7
+ const React = require("react");
8
+ const contexts = require("../contexts.cjs");
9
+ const useFormInputValidationHandler = require("../hooks/useFormInputValidationHandler.cjs");
10
+ const SlotInput = reactSlot.Slot;
11
+ const FormRadioInput = reactBinding.Component(({ field, value, defaultValue, isNonbearing, ...props }) => {
12
+ const accessor = reactBinding.useField(field);
13
+ const formState = contexts.useFormFieldState();
14
+ const id = formState?.htmlId;
15
+ const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
16
+ const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
17
+ const accessorGetter = accessor.getAccessor;
18
+ const { ref, onFocus, onBlur } = useFormInputValidationHandler.useFormInputValidationHandler(accessor);
19
+ const handleChange = React.useCallback((e) => {
20
+ accessorGetter().updateValue(value);
21
+ }, [accessorGetter, value]);
22
+ return /* @__PURE__ */ jsxRuntime.jsx(
23
+ SlotInput,
24
+ {
25
+ ref,
26
+ type: "radio",
27
+ value: typeof value === "string" ? value : void 0,
28
+ checked: accessor.value === value,
29
+ "data-invalid": utilities.dataAttribute(hasErrors),
30
+ "data-dirty": utilities.dataAttribute(dirty),
31
+ name: id ? id + "-input" : void 0,
32
+ id: id ? `${id}-input` : void 0,
33
+ onFocus,
34
+ onBlur,
35
+ onChange: handleChange,
36
+ ...props
37
+ }
38
+ );
39
+ }, ({ field, isNonbearing, defaultValue }) => {
40
+ return /* @__PURE__ */ jsxRuntime.jsx(reactBinding.Field, { field, isNonbearing, defaultValue });
41
+ });
42
+ exports.FormRadioInput = FormRadioInput;
43
+ //# sourceMappingURL=FormRadioInput.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormRadioInput.cjs","sources":["../../../../../packages/react-form/src/components/FormRadioInput.tsx"],"sourcesContent":["import { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { ChangeEventHandler, useCallback } from 'react'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormRadioItemProps {\n\tfield: SugaredRelativeSingleField['field']\n\tvalue: string | null | number | boolean\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactNode\n}\n\nexport const FormRadioInput = Component<FormRadioItemProps>(({ field, value, defaultValue, isNonbearing, ...props }) => {\n\tconst accessor = useField(field)\n\n\tconst formState = useFormFieldState()\n\tconst id = formState?.htmlId\n\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\tconst handleChange = useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\taccessorGetter().updateValue(value)\n\t}, [accessorGetter, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\ttype=\"radio\"\n\t\t\tvalue={typeof value === 'string' ? value : undefined}\n\t\t\tchecked={accessor.value === value}\n\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tname={id ? id + '-input' : undefined}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={handleChange}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }) => {\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />\n})\n"],"names":["Slot","Component","useField","useFormFieldState","useFormInputValidationHandler","useCallback","jsx","dataAttribute","Field"],"mappings":";;;;;;;;;AAQA,MAAM,YAAYA,UAAAA;AAUX,MAAM,iBAAiBC,aAAAA,UAA8B,CAAC,EAAE,OAAO,OAAO,cAAc,cAAc,GAAG,YAAY;AACvH,QAAM,WAAWC,aAAAA,SAAS,KAAK;AAE/B,QAAM,YAAYC,SAAAA,kBAAA;AAClB,QAAM,KAAK,WAAW;AACtB,QAAM,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACvF,QAAM,QAAQ,WAAW,SAAS,SAAS;AAE3C,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAA,IAAWC,8BAAAA,8BAA8B,QAAQ;AAEvE,QAAM,eAAeC,kBAAkD,CAAA,MAAK;AAC3E,mBAAA,EAAiB,YAAY,KAAK;AAAA,EACnC,GAAG,CAAC,gBAAgB,KAAK,CAAC;AAE1B,SACCC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL,OAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,MAC3C,SAAS,SAAS,UAAU;AAAA,MAC5B,gBAAcC,UAAAA,cAAc,SAAS;AAAA,MACrC,cAAYA,UAAAA,cAAc,KAAK;AAAA,MAC/B,MAAM,KAAK,KAAK,WAAW;AAAA,MAC3B,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACT,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAOD,2BAAAA,IAACE,aAAAA,OAAA,EAAM,OAAc,cAA4B,aAAA,CAA4B;AACrF,CAAC;;"}
@@ -0,0 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Component, useField, Field } from "@contember/react-binding";
3
+ import { dataAttribute } from "@contember/utilities";
4
+ import { Slot } from "@radix-ui/react-slot";
5
+ import { useCallback } from "react";
6
+ import { useFormFieldState } from "../contexts.js";
7
+ import { useFormInputValidationHandler } from "../hooks/useFormInputValidationHandler.js";
8
+ const SlotInput = Slot;
9
+ const FormRadioInput = Component(({ field, value, defaultValue, isNonbearing, ...props }) => {
10
+ const accessor = useField(field);
11
+ const formState = useFormFieldState();
12
+ const id = formState?.htmlId;
13
+ const hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0;
14
+ const dirty = formState?.dirty ?? accessor.hasUnpersistedChanges;
15
+ const accessorGetter = accessor.getAccessor;
16
+ const { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor);
17
+ const handleChange = useCallback((e) => {
18
+ accessorGetter().updateValue(value);
19
+ }, [accessorGetter, value]);
20
+ return /* @__PURE__ */ jsx(
21
+ SlotInput,
22
+ {
23
+ ref,
24
+ type: "radio",
25
+ value: typeof value === "string" ? value : void 0,
26
+ checked: accessor.value === value,
27
+ "data-invalid": dataAttribute(hasErrors),
28
+ "data-dirty": dataAttribute(dirty),
29
+ name: id ? id + "-input" : void 0,
30
+ id: id ? `${id}-input` : void 0,
31
+ onFocus,
32
+ onBlur,
33
+ onChange: handleChange,
34
+ ...props
35
+ }
36
+ );
37
+ }, ({ field, isNonbearing, defaultValue }) => {
38
+ return /* @__PURE__ */ jsx(Field, { field, isNonbearing, defaultValue });
39
+ });
40
+ export {
41
+ FormRadioInput
42
+ };
43
+ //# sourceMappingURL=FormRadioInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormRadioInput.js","sources":["../../../../../packages/react-form/src/components/FormRadioInput.tsx"],"sourcesContent":["import { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, useField } from '@contember/react-binding'\nimport { dataAttribute } from '@contember/utilities'\nimport { Slot } from '@radix-ui/react-slot'\nimport * as React from 'react'\nimport { ChangeEventHandler, useCallback } from 'react'\nimport { useFormFieldState } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormRadioItemProps {\n\tfield: SugaredRelativeSingleField['field']\n\tvalue: string | null | number | boolean\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactNode\n}\n\nexport const FormRadioInput = Component<FormRadioItemProps>(({ field, value, defaultValue, isNonbearing, ...props }) => {\n\tconst accessor = useField(field)\n\n\tconst formState = useFormFieldState()\n\tconst id = formState?.htmlId\n\tconst hasErrors = (formState?.errors.length ?? accessor.errors?.errors?.length ?? 0) > 0\n\tconst dirty = formState?.dirty ?? accessor.hasUnpersistedChanges\n\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\tconst handleChange = useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\taccessorGetter().updateValue(value)\n\t}, [accessorGetter, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\ttype=\"radio\"\n\t\t\tvalue={typeof value === 'string' ? value : undefined}\n\t\t\tchecked={accessor.value === value}\n\t\t\tdata-invalid={dataAttribute(hasErrors)}\n\t\t\tdata-dirty={dataAttribute(dirty)}\n\t\t\tname={id ? id + '-input' : undefined}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={handleChange}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }) => {\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />\n})\n"],"names":[],"mappings":";;;;;;;AAQA,MAAM,YAAY;AAUX,MAAM,iBAAiB,UAA8B,CAAC,EAAE,OAAO,OAAO,cAAc,cAAc,GAAG,YAAY;AACvH,QAAM,WAAW,SAAS,KAAK;AAE/B,QAAM,YAAY,kBAAA;AAClB,QAAM,KAAK,WAAW;AACtB,QAAM,aAAa,WAAW,OAAO,UAAU,SAAS,QAAQ,QAAQ,UAAU,KAAK;AACvF,QAAM,QAAQ,WAAW,SAAS,SAAS;AAE3C,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAA,IAAW,8BAA8B,QAAQ;AAEvE,QAAM,eAAe,YAAkD,CAAA,MAAK;AAC3E,mBAAA,EAAiB,YAAY,KAAK;AAAA,EACnC,GAAG,CAAC,gBAAgB,KAAK,CAAC;AAE1B,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL,OAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,MAC3C,SAAS,SAAS,UAAU;AAAA,MAC5B,gBAAc,cAAc,SAAS;AAAA,MACrC,cAAY,cAAc,KAAK;AAAA,MAC/B,MAAM,KAAK,KAAK,WAAW;AAAA,MAC3B,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACT,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAO,oBAAC,OAAA,EAAM,OAAc,cAA4B,aAAA,CAA4B;AACrF,CAAC;"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const reactUtils = require("@contember/react-utils");
4
+ const FormFieldStateContext_ = reactUtils.createContext("FormFieldStateContext", void 0);
5
+ const FormFieldStateContext = FormFieldStateContext_[0];
6
+ const useFormFieldState = FormFieldStateContext_[1];
7
+ const useFormFieldId = () => useFormFieldState()?.htmlId;
8
+ const useFormError = () => useFormFieldState()?.errors;
9
+ exports.FormFieldStateContext = FormFieldStateContext;
10
+ exports.useFormError = useFormError;
11
+ exports.useFormFieldId = useFormFieldId;
12
+ exports.useFormFieldState = useFormFieldState;
13
+ //# sourceMappingURL=contexts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts.cjs","sources":["../../../../packages/react-form/src/contexts.tsx"],"sourcesContent":["import { createContext } from '@contember/react-utils'\nimport { FormFieldState } from './types'\n\nconst FormFieldStateContext_ = createContext<FormFieldState | undefined>('FormFieldStateContext', undefined)\nexport const FormFieldStateContext = FormFieldStateContext_[0]\nexport const useFormFieldState = FormFieldStateContext_[1]\n\n/**\n * @deprecated use `useFormState` instead\n */\nexport const useFormFieldId = () => useFormFieldState()?.htmlId\n\n/**\n * @deprecated use `useFormState` instead\n */\nexport const useFormError = () => useFormFieldState()?.errors\n"],"names":["createContext"],"mappings":";;;AAGA,MAAM,yBAAyBA,WAAAA,cAA0C,yBAAyB,MAAS;AACpG,MAAM,wBAAwB,uBAAuB,CAAC;AACtD,MAAM,oBAAoB,uBAAuB,CAAC;AAKlD,MAAM,iBAAiB,MAAM,qBAAqB;AAKlD,MAAM,eAAe,MAAM,qBAAqB;;;;;"}
@@ -0,0 +1,13 @@
1
+ import { createContext } from "@contember/react-utils";
2
+ const FormFieldStateContext_ = createContext("FormFieldStateContext", void 0);
3
+ const FormFieldStateContext = FormFieldStateContext_[0];
4
+ const useFormFieldState = FormFieldStateContext_[1];
5
+ const useFormFieldId = () => useFormFieldState()?.htmlId;
6
+ const useFormError = () => useFormFieldState()?.errors;
7
+ export {
8
+ FormFieldStateContext,
9
+ useFormError,
10
+ useFormFieldId,
11
+ useFormFieldState
12
+ };
13
+ //# sourceMappingURL=contexts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts.js","sources":["../../../../packages/react-form/src/contexts.tsx"],"sourcesContent":["import { createContext } from '@contember/react-utils'\nimport { FormFieldState } from './types'\n\nconst FormFieldStateContext_ = createContext<FormFieldState | undefined>('FormFieldStateContext', undefined)\nexport const FormFieldStateContext = FormFieldStateContext_[0]\nexport const useFormFieldState = FormFieldStateContext_[1]\n\n/**\n * @deprecated use `useFormState` instead\n */\nexport const useFormFieldId = () => useFormFieldState()?.htmlId\n\n/**\n * @deprecated use `useFormState` instead\n */\nexport const useFormError = () => useFormFieldState()?.errors\n"],"names":[],"mappings":";AAGA,MAAM,yBAAyB,cAA0C,yBAAyB,MAAS;AACpG,MAAM,wBAAwB,uBAAuB,CAAC;AACtD,MAAM,oBAAoB,uBAAuB,CAAC;AAKlD,MAAM,iBAAiB,MAAM,qBAAqB;AAKlD,MAAM,eAAe,MAAM,qBAAqB;"}