@contember/react-form 2.0.0-alpha.5 → 2.0.0-alpha.8

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 (146) hide show
  1. package/api-extractor.json +3 -0
  2. package/dist/development/index.cjs +10 -10
  3. package/dist/development/index.js +10 -10
  4. package/dist/development/{components → src/components}/FormCheckbox.cjs +3 -3
  5. package/dist/development/src/components/FormCheckbox.cjs.map +1 -0
  6. package/dist/development/{components → src/components}/FormCheckbox.js +3 -3
  7. package/dist/development/src/components/FormCheckbox.js.map +1 -0
  8. package/dist/development/src/components/FormError.cjs.map +1 -0
  9. package/dist/development/src/components/FormError.js.map +1 -0
  10. package/dist/development/{components → src/components}/FormFieldScope.cjs +2 -2
  11. package/dist/development/src/components/FormFieldScope.cjs.map +1 -0
  12. package/dist/development/{components → src/components}/FormFieldScope.js +2 -2
  13. package/dist/development/src/components/FormFieldScope.js.map +1 -0
  14. package/dist/development/{components → src/components}/FormHasManyRelationScope.cjs +2 -2
  15. package/dist/development/src/components/FormHasManyRelationScope.cjs.map +1 -0
  16. package/dist/development/{components → src/components}/FormHasManyRelationScope.js +2 -2
  17. package/dist/development/src/components/FormHasManyRelationScope.js.map +1 -0
  18. package/dist/development/{components → src/components}/FormHasOneRelationScope.cjs +2 -2
  19. package/dist/development/src/components/FormHasOneRelationScope.cjs.map +1 -0
  20. package/dist/development/{components → src/components}/FormHasOneRelationScope.js +2 -2
  21. package/dist/development/src/components/FormHasOneRelationScope.js.map +1 -0
  22. package/dist/development/{components → src/components}/FormInput.cjs +2 -2
  23. package/dist/development/src/components/FormInput.cjs.map +1 -0
  24. package/dist/development/{components → src/components}/FormInput.js +2 -2
  25. package/dist/development/src/components/FormInput.js.map +1 -0
  26. package/dist/development/{components → src/components}/FormLabel.cjs +1 -1
  27. package/dist/development/src/components/FormLabel.cjs.map +1 -0
  28. package/dist/development/{components → src/components}/FormLabel.js +1 -1
  29. package/dist/development/src/components/FormLabel.js.map +1 -0
  30. package/dist/development/{components → src/components}/FormRadioInput.cjs +2 -2
  31. package/dist/development/src/components/FormRadioInput.cjs.map +1 -0
  32. package/dist/development/{components → src/components}/FormRadioInput.js +2 -2
  33. package/dist/development/src/components/FormRadioInput.js.map +1 -0
  34. package/dist/development/src/contexts.cjs.map +1 -0
  35. package/dist/development/src/contexts.js.map +1 -0
  36. package/dist/development/src/hooks/useFormInputValidationHandler.cjs.map +1 -0
  37. package/dist/development/src/hooks/useFormInputValidationHandler.js.map +1 -0
  38. package/dist/development/src/internal/useFormInputHandler.cjs.map +1 -0
  39. package/dist/development/src/internal/useFormInputHandler.js.map +1 -0
  40. package/dist/production/index.cjs +10 -10
  41. package/dist/production/index.js +10 -10
  42. package/dist/production/src/components/FormCheckbox.cjs.map +1 -0
  43. package/dist/production/src/components/FormCheckbox.js.map +1 -0
  44. package/dist/production/src/components/FormError.cjs.map +1 -0
  45. package/dist/production/src/components/FormError.js.map +1 -0
  46. package/dist/production/src/components/FormFieldScope.cjs.map +1 -0
  47. package/dist/production/src/components/FormFieldScope.js.map +1 -0
  48. package/dist/production/src/components/FormHasManyRelationScope.cjs.map +1 -0
  49. package/dist/production/src/components/FormHasManyRelationScope.js.map +1 -0
  50. package/dist/production/src/components/FormHasOneRelationScope.cjs.map +1 -0
  51. package/dist/production/src/components/FormHasOneRelationScope.js.map +1 -0
  52. package/dist/production/src/components/FormInput.cjs.map +1 -0
  53. package/dist/production/src/components/FormInput.js.map +1 -0
  54. package/dist/production/src/components/FormLabel.cjs.map +1 -0
  55. package/dist/production/src/components/FormLabel.js.map +1 -0
  56. package/dist/production/src/components/FormRadioInput.cjs.map +1 -0
  57. package/dist/production/src/components/FormRadioInput.js.map +1 -0
  58. package/dist/production/src/contexts.cjs.map +1 -0
  59. package/dist/production/src/contexts.js.map +1 -0
  60. package/dist/production/src/hooks/useFormInputValidationHandler.cjs.map +1 -0
  61. package/dist/production/src/hooks/useFormInputValidationHandler.js.map +1 -0
  62. package/dist/production/src/internal/useFormInputHandler.cjs.map +1 -0
  63. package/dist/production/src/internal/useFormInputHandler.js.map +1 -0
  64. package/dist/types/components/FormError.d.ts.map +1 -1
  65. package/dist/types/components/FormLabel.d.ts.map +1 -1
  66. package/dist/types/hooks/useFormInputValidationHandler.d.ts.map +1 -1
  67. package/dist/types/internal/useFormInputHandler.d.ts.map +1 -1
  68. package/dist/types/tsconfig.tsbuildinfo +1 -1
  69. package/package.json +7 -15
  70. package/src/components/FormCheckbox.tsx +17 -17
  71. package/tsconfig.json +7 -0
  72. package/tsdoc.json +6 -0
  73. package/dist/development/components/FormCheckbox.cjs.map +0 -1
  74. package/dist/development/components/FormCheckbox.js.map +0 -1
  75. package/dist/development/components/FormError.cjs.map +0 -1
  76. package/dist/development/components/FormError.js.map +0 -1
  77. package/dist/development/components/FormFieldScope.cjs.map +0 -1
  78. package/dist/development/components/FormFieldScope.js.map +0 -1
  79. package/dist/development/components/FormHasManyRelationScope.cjs.map +0 -1
  80. package/dist/development/components/FormHasManyRelationScope.js.map +0 -1
  81. package/dist/development/components/FormHasOneRelationScope.cjs.map +0 -1
  82. package/dist/development/components/FormHasOneRelationScope.js.map +0 -1
  83. package/dist/development/components/FormInput.cjs.map +0 -1
  84. package/dist/development/components/FormInput.js.map +0 -1
  85. package/dist/development/components/FormLabel.cjs.map +0 -1
  86. package/dist/development/components/FormLabel.js.map +0 -1
  87. package/dist/development/components/FormRadioInput.cjs.map +0 -1
  88. package/dist/development/components/FormRadioInput.js.map +0 -1
  89. package/dist/development/contexts.cjs.map +0 -1
  90. package/dist/development/contexts.js.map +0 -1
  91. package/dist/development/hooks/useFormInputValidationHandler.cjs.map +0 -1
  92. package/dist/development/hooks/useFormInputValidationHandler.js.map +0 -1
  93. package/dist/development/internal/useFormInputHandler.cjs.map +0 -1
  94. package/dist/development/internal/useFormInputHandler.js.map +0 -1
  95. package/dist/production/components/FormCheckbox.cjs.map +0 -1
  96. package/dist/production/components/FormCheckbox.js.map +0 -1
  97. package/dist/production/components/FormError.cjs.map +0 -1
  98. package/dist/production/components/FormError.js.map +0 -1
  99. package/dist/production/components/FormFieldScope.cjs.map +0 -1
  100. package/dist/production/components/FormFieldScope.js.map +0 -1
  101. package/dist/production/components/FormHasManyRelationScope.cjs.map +0 -1
  102. package/dist/production/components/FormHasManyRelationScope.js.map +0 -1
  103. package/dist/production/components/FormHasOneRelationScope.cjs.map +0 -1
  104. package/dist/production/components/FormHasOneRelationScope.js.map +0 -1
  105. package/dist/production/components/FormInput.cjs.map +0 -1
  106. package/dist/production/components/FormInput.js.map +0 -1
  107. package/dist/production/components/FormLabel.cjs.map +0 -1
  108. package/dist/production/components/FormLabel.js.map +0 -1
  109. package/dist/production/components/FormRadioInput.cjs.map +0 -1
  110. package/dist/production/components/FormRadioInput.js.map +0 -1
  111. package/dist/production/contexts.cjs.map +0 -1
  112. package/dist/production/contexts.js.map +0 -1
  113. package/dist/production/hooks/useFormInputValidationHandler.cjs.map +0 -1
  114. package/dist/production/hooks/useFormInputValidationHandler.js.map +0 -1
  115. package/dist/production/internal/useFormInputHandler.cjs.map +0 -1
  116. package/dist/production/internal/useFormInputHandler.js.map +0 -1
  117. /package/dist/development/{components → src/components}/FormError.cjs +0 -0
  118. /package/dist/development/{components → src/components}/FormError.js +0 -0
  119. /package/dist/development/{contexts.cjs → src/contexts.cjs} +0 -0
  120. /package/dist/development/{contexts.js → src/contexts.js} +0 -0
  121. /package/dist/development/{hooks → src/hooks}/useFormInputValidationHandler.cjs +0 -0
  122. /package/dist/development/{hooks → src/hooks}/useFormInputValidationHandler.js +0 -0
  123. /package/dist/development/{internal → src/internal}/useFormInputHandler.cjs +0 -0
  124. /package/dist/development/{internal → src/internal}/useFormInputHandler.js +0 -0
  125. /package/dist/production/{components → src/components}/FormCheckbox.cjs +0 -0
  126. /package/dist/production/{components → src/components}/FormCheckbox.js +0 -0
  127. /package/dist/production/{components → src/components}/FormError.cjs +0 -0
  128. /package/dist/production/{components → src/components}/FormError.js +0 -0
  129. /package/dist/production/{components → src/components}/FormFieldScope.cjs +0 -0
  130. /package/dist/production/{components → src/components}/FormFieldScope.js +0 -0
  131. /package/dist/production/{components → src/components}/FormHasManyRelationScope.cjs +0 -0
  132. /package/dist/production/{components → src/components}/FormHasManyRelationScope.js +0 -0
  133. /package/dist/production/{components → src/components}/FormHasOneRelationScope.cjs +0 -0
  134. /package/dist/production/{components → src/components}/FormHasOneRelationScope.js +0 -0
  135. /package/dist/production/{components → src/components}/FormInput.cjs +0 -0
  136. /package/dist/production/{components → src/components}/FormInput.js +0 -0
  137. /package/dist/production/{components → src/components}/FormLabel.cjs +0 -0
  138. /package/dist/production/{components → src/components}/FormLabel.js +0 -0
  139. /package/dist/production/{components → src/components}/FormRadioInput.cjs +0 -0
  140. /package/dist/production/{components → src/components}/FormRadioInput.js +0 -0
  141. /package/dist/production/{contexts.cjs → src/contexts.cjs} +0 -0
  142. /package/dist/production/{contexts.js → src/contexts.js} +0 -0
  143. /package/dist/production/{hooks → src/hooks}/useFormInputValidationHandler.cjs +0 -0
  144. /package/dist/production/{hooks → src/hooks}/useFormInputValidationHandler.js +0 -0
  145. /package/dist/production/{internal → src/internal}/useFormInputHandler.cjs +0 -0
  146. /package/dist/production/{internal → src/internal}/useFormInputHandler.js +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../build/api-extractor.json"
3
+ }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const contexts = require("./contexts.cjs");
4
- const FormError = require("./components/FormError.cjs");
5
- const FormCheckbox = require("./components/FormCheckbox.cjs");
6
- const FormFieldScope = require("./components/FormFieldScope.cjs");
7
- const FormHasOneRelationScope = require("./components/FormHasOneRelationScope.cjs");
8
- const FormHasManyRelationScope = require("./components/FormHasManyRelationScope.cjs");
9
- const FormInput = require("./components/FormInput.cjs");
10
- const FormLabel = require("./components/FormLabel.cjs");
11
- const FormRadioInput = require("./components/FormRadioInput.cjs");
12
- const useFormInputValidationHandler = require("./hooks/useFormInputValidationHandler.cjs");
3
+ const contexts = require("./src/contexts.cjs");
4
+ const FormError = require("./src/components/FormError.cjs");
5
+ const FormCheckbox = require("./src/components/FormCheckbox.cjs");
6
+ const FormFieldScope = require("./src/components/FormFieldScope.cjs");
7
+ const FormHasOneRelationScope = require("./src/components/FormHasOneRelationScope.cjs");
8
+ const FormHasManyRelationScope = require("./src/components/FormHasManyRelationScope.cjs");
9
+ const FormInput = require("./src/components/FormInput.cjs");
10
+ const FormLabel = require("./src/components/FormLabel.cjs");
11
+ const FormRadioInput = require("./src/components/FormRadioInput.cjs");
12
+ const useFormInputValidationHandler = require("./src/hooks/useFormInputValidationHandler.cjs");
13
13
  exports.FormErrorContext = contexts.FormErrorContext;
14
14
  exports.FormFieldIdContext = contexts.FormFieldIdContext;
15
15
  exports.useFormError = contexts.useFormError;
@@ -1,13 +1,13 @@
1
- import { FormErrorContext, FormFieldIdContext, useFormError, useFormFieldId } from "./contexts.js";
2
- import { FormError } from "./components/FormError.js";
3
- import { FormCheckbox } from "./components/FormCheckbox.js";
4
- import { FormFieldScope } from "./components/FormFieldScope.js";
5
- import { FormHasOneRelationScope } from "./components/FormHasOneRelationScope.js";
6
- import { FormHasManyRelationScope } from "./components/FormHasManyRelationScope.js";
7
- import { FormInput } from "./components/FormInput.js";
8
- import { FormLabel } from "./components/FormLabel.js";
9
- import { FormRadioInput } from "./components/FormRadioInput.js";
10
- import { useFormInputValidationHandler } from "./hooks/useFormInputValidationHandler.js";
1
+ import { FormErrorContext, FormFieldIdContext, useFormError, useFormFieldId } from "./src/contexts.js";
2
+ import { FormError } from "./src/components/FormError.js";
3
+ import { FormCheckbox } from "./src/components/FormCheckbox.js";
4
+ import { FormFieldScope } from "./src/components/FormFieldScope.js";
5
+ import { FormHasOneRelationScope } from "./src/components/FormHasOneRelationScope.js";
6
+ import { FormHasManyRelationScope } from "./src/components/FormHasManyRelationScope.js";
7
+ import { FormInput } from "./src/components/FormInput.js";
8
+ import { FormLabel } from "./src/components/FormLabel.js";
9
+ import { FormRadioInput } from "./src/components/FormRadioInput.js";
10
+ import { useFormInputValidationHandler } from "./src/hooks/useFormInputValidationHandler.js";
11
11
  export {
12
12
  FormCheckbox,
13
13
  FormError,
@@ -61,9 +61,9 @@ const FormCheckbox = reactBinding.Component(({ field, isNonbearing, defaultValue
61
61
  void 0,
62
62
  false,
63
63
  {
64
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormCheckbox.tsx",
64
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormCheckbox.tsx",
65
65
  lineNumber: 35,
66
- columnNumber: 4
66
+ columnNumber: 3
67
67
  },
68
68
  void 0
69
69
  );
@@ -71,7 +71,7 @@ const FormCheckbox = reactBinding.Component(({ field, isNonbearing, defaultValue
71
71
  const node = reactBinding.TreeNodeEnvironmentFactory.createEnvironmentForField(env, { field }).getSubTreeNode();
72
72
  const resolvedDefaultValue = defaultValue !== void 0 ? defaultValue : node.field.defaultValue ?? (node.field.nullable ? null : false);
73
73
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Field, { field, isNonbearing, defaultValue: resolvedDefaultValue }, void 0, false, {
74
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormCheckbox.tsx",
74
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormCheckbox.tsx",
75
75
  lineNumber: 57,
76
76
  columnNumber: 9
77
77
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormCheckbox.cjs","sources":["../../../../../packages/react-form/src/components/FormCheckbox.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ReactElement, useCallback, useEffect } from 'react'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, TreeNodeEnvironmentFactory, useField } from '@contember/react-binding'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputValidationHandler } from '../hooks'\nimport { Slot } from '@radix-ui/react-slot'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormCheckboxProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: ReactElement<HTMLInputElement, 'input'>\n}\n\nexport const FormCheckbox = Component<FormCheckboxProps>(({ field, isNonbearing, defaultValue, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField<boolean>(field)\n\tconst value = accessor.value\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\tconst [checkboxRef, setCheckboxRef] = React.useState<HTMLInputElement | null>(null)\n\n\tuseEffect(() => {\n\t\tif (!checkboxRef) {\n\t\t\treturn\n\t\t}\n\t\tcheckboxRef.indeterminate = value === null\n\t}, [checkboxRef, ref, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={it => {\n\t\t\t\t(ref as any).current = checkboxRef\n\t\t\t\tsetCheckboxRef(it)\n\t\t\t}}\n\t\t\ttype=\"checkbox\"\n\t\t\tchecked={accessor.value === true}\n\t\t\tdata-state={value === null ? 'indeterminate' : (value ? 'checked' : 'unchecked')}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tid={`${id}-input`}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(e.target.checked)\n\t\t\t}, [accessorGetter])}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }, env) => {\n\tconst node = TreeNodeEnvironmentFactory.createEnvironmentForField(env, { field }).getSubTreeNode()\n\tconst resolvedDefaultValue = defaultValue !== undefined ? defaultValue : (node.field.defaultValue ?? (node.field.nullable ? null : false))\n\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={resolvedDefaultValue} />\n})\n"],"names":["Slot","Component","useFormFieldId","useField","useFormError","useFormInputValidationHandler","React","useEffect","jsxDEV","dataAttribute","useCallback","this","TreeNodeEnvironmentFactory","Field"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,YAAYA,UAAAA;AASL,MAAA,eAAeC,uBAA6B,CAAC,EAAE,OAAO,cAAc,cAAc,GAAG,YAAY;AAC7G,QAAM,KAAKC,SAAAA;AACL,QAAA,WAAWC,sBAAkB,KAAK;AACxC,QAAM,QAAQ,SAAS;AACvB,QAAM,SAASC,SAAAA,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAIC,8BAAAA,8BAA8B,QAAQ;AACvE,QAAM,CAAC,aAAa,cAAc,IAAIC,iBAAM,SAAkC,IAAI;AAElFC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IACD;AACA,gBAAY,gBAAgB,UAAU;AAAA,EACpC,GAAA,CAAC,aAAa,KAAK,KAAK,CAAC;AAG3B,SAAAC,8BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,KAAK,CAAM,OAAA;AACT,YAAY,UAAU;AACvB,uBAAe,EAAE;AAAA,MAClB;AAAA,MACA,MAAK;AAAA,MACL,SAAS,SAAS,UAAU;AAAA,MAC5B,cAAY,UAAU,OAAO,kBAAmB,QAAQ,YAAY;AAAA,MACpE,gBAAcC,UAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,IAAI,GAAG,EAAE;AAAA,MACT;AAAA,MACA;AAAA,MACA,UAAUC,MAAAA,YAAkD,CAAK,MAAA;AAChE,uBAAiB,EAAA,YAAY,EAAE,OAAO,OAAO;AAAA,MAAA,GAC3C,CAAC,cAAc,CAAC;AAAA,MAClB,GAAG;AAAA,IAAA;AAAA,IAfL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA;AAkBF,GAAG,CAAC,EAAE,OAAO,cAAc,aAAA,GAAgB,QAAQ;AAC5C,QAAA,OAAOC,wCAA2B,0BAA0B,KAAK,EAAE,MAAO,CAAA,EAAE;AAC5E,QAAA,uBAAuB,iBAAiB,SAAY,eAAgB,KAAK,MAAM,iBAAiB,KAAK,MAAM,WAAW,OAAO;AAEnI,SAAQJ,8BAAA,OAAAK,oBAAA,EAAM,OAAc,cAA4B,cAAc,qBAA/D,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAqF,GAAAF,MAAA;AAC7F,CAAC;;"}
@@ -43,9 +43,9 @@ const FormCheckbox = Component(({ field, isNonbearing, defaultValue, ...props })
43
43
  void 0,
44
44
  false,
45
45
  {
46
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormCheckbox.tsx",
46
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormCheckbox.tsx",
47
47
  lineNumber: 35,
48
- columnNumber: 4
48
+ columnNumber: 3
49
49
  },
50
50
  void 0
51
51
  );
@@ -53,7 +53,7 @@ const FormCheckbox = Component(({ field, isNonbearing, defaultValue, ...props })
53
53
  const node = TreeNodeEnvironmentFactory.createEnvironmentForField(env, { field }).getSubTreeNode();
54
54
  const resolvedDefaultValue = defaultValue !== void 0 ? defaultValue : node.field.defaultValue ?? (node.field.nullable ? null : false);
55
55
  return /* @__PURE__ */ jsxDEV(Field, { field, isNonbearing, defaultValue: resolvedDefaultValue }, void 0, false, {
56
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormCheckbox.tsx",
56
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormCheckbox.tsx",
57
57
  lineNumber: 57,
58
58
  columnNumber: 9
59
59
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormCheckbox.js","sources":["../../../../../packages/react-form/src/components/FormCheckbox.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ReactElement, useCallback, useEffect } from 'react'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, TreeNodeEnvironmentFactory, useField } from '@contember/react-binding'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputValidationHandler } from '../hooks'\nimport { Slot } from '@radix-ui/react-slot'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormCheckboxProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: ReactElement<HTMLInputElement, 'input'>\n}\n\nexport const FormCheckbox = Component<FormCheckboxProps>(({ field, isNonbearing, defaultValue, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField<boolean>(field)\n\tconst value = accessor.value\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\tconst [checkboxRef, setCheckboxRef] = React.useState<HTMLInputElement | null>(null)\n\n\tuseEffect(() => {\n\t\tif (!checkboxRef) {\n\t\t\treturn\n\t\t}\n\t\tcheckboxRef.indeterminate = value === null\n\t}, [checkboxRef, ref, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={it => {\n\t\t\t\t(ref as any).current = checkboxRef\n\t\t\t\tsetCheckboxRef(it)\n\t\t\t}}\n\t\t\ttype=\"checkbox\"\n\t\t\tchecked={accessor.value === true}\n\t\t\tdata-state={value === null ? 'indeterminate' : (value ? 'checked' : 'unchecked')}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tid={`${id}-input`}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(e.target.checked)\n\t\t\t}, [accessorGetter])}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }, env) => {\n\tconst node = TreeNodeEnvironmentFactory.createEnvironmentForField(env, { field }).getSubTreeNode()\n\tconst resolvedDefaultValue = defaultValue !== undefined ? defaultValue : (node.field.defaultValue ?? (node.field.nullable ? null : false))\n\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={resolvedDefaultValue} />\n})\n"],"names":["this"],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AASL,MAAA,eAAe,UAA6B,CAAC,EAAE,OAAO,cAAc,cAAc,GAAG,YAAY;AAC7G,QAAM,KAAK;AACL,QAAA,WAAW,SAAkB,KAAK;AACxC,QAAM,QAAQ,SAAS;AACvB,QAAM,SAAS,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAI,8BAA8B,QAAQ;AACvE,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAkC,IAAI;AAElF,YAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IACD;AACA,gBAAY,gBAAgB,UAAU;AAAA,EACpC,GAAA,CAAC,aAAa,KAAK,KAAK,CAAC;AAG3B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,KAAK,CAAM,OAAA;AACT,YAAY,UAAU;AACvB,uBAAe,EAAE;AAAA,MAClB;AAAA,MACA,MAAK;AAAA,MACL,SAAS,SAAS,UAAU;AAAA,MAC5B,cAAY,UAAU,OAAO,kBAAmB,QAAQ,YAAY;AAAA,MACpE,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,IAAI,GAAG,EAAE;AAAA,MACT;AAAA,MACA;AAAA,MACA,UAAU,YAAkD,CAAK,MAAA;AAChE,uBAAiB,EAAA,YAAY,EAAE,OAAO,OAAO;AAAA,MAAA,GAC3C,CAAC,cAAc,CAAC;AAAA,MAClB,GAAG;AAAA,IAAA;AAAA,IAfL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAkBF,GAAG,CAAC,EAAE,OAAO,cAAc,aAAA,GAAgB,QAAQ;AAC5C,QAAA,OAAO,2BAA2B,0BAA0B,KAAK,EAAE,MAAO,CAAA,EAAE;AAC5E,QAAA,uBAAuB,iBAAiB,SAAY,eAAgB,KAAK,MAAM,iBAAiB,KAAK,MAAM,WAAW,OAAO;AAEnI,SAAQ,uBAAA,OAAA,EAAM,OAAc,cAA4B,cAAc,qBAA/D,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAqF,GAAAA,MAAA;AAC7F,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormError.cjs","sources":["../../../../../packages/react-form/src/components/FormError.tsx"],"sourcesContent":["import { cloneElement, ReactElement, ReactNode, useMemo } from 'react'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { BindingError, ErrorAccessor } from '@contember/react-binding'\n\nexport const FormError = ({ children, formatter }: {\n\tformatter: (errors: ErrorAccessor.Error[]) => ReactNode[]\n\tchildren: ReactElement\n}) => {\n\tconst errors = useFormError()\n\tconst id = useFormFieldId()\n\tconst formatted = useMemo(() => formatter(errors ?? []), [errors, formatter])\n\tif (errors === undefined || id === undefined) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\treturn formatted.map((it, index) => {\n\t\treturn cloneElement(children, {\n\t\t\tkey: index,\n\t\t\t...{ id: `${id}-error-${index}` },\n\t\t\tchildren: it,\n\t\t})\n\t})\n}\n"],"names":["useFormError","useFormFieldId","useMemo","BindingError","cloneElement"],"mappings":";;;;;AAIO,MAAM,YAAY,CAAC,EAAE,UAAU,gBAGhC;AACL,QAAM,SAASA,SAAAA;AACf,QAAM,KAAKC,SAAAA;AACL,QAAA,YAAYC,cAAQ,MAAM,UAAU,UAAU,CAAE,CAAA,GAAG,CAAC,QAAQ,SAAS,CAAC;AACxE,MAAA,WAAW,UAAa,OAAO,QAAW;AACvC,UAAA,IAAIC,aAAAA,aAAa,2CAA2C;AAAA,EACnE;AACA,SAAO,UAAU,IAAI,CAAC,IAAI,UAAU;AACnC,WAAOC,MAAAA,aAAa,UAAU;AAAA,MAC7B,KAAK;AAAA,MACL,GAAG,EAAE,IAAI,GAAG,EAAE,UAAU,KAAK,GAAG;AAAA,MAChC,UAAU;AAAA,IAAA,CACV;AAAA,EAAA,CACD;AACF;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormError.js","sources":["../../../../../packages/react-form/src/components/FormError.tsx"],"sourcesContent":["import { cloneElement, ReactElement, ReactNode, useMemo } from 'react'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { BindingError, ErrorAccessor } from '@contember/react-binding'\n\nexport const FormError = ({ children, formatter }: {\n\tformatter: (errors: ErrorAccessor.Error[]) => ReactNode[]\n\tchildren: ReactElement\n}) => {\n\tconst errors = useFormError()\n\tconst id = useFormFieldId()\n\tconst formatted = useMemo(() => formatter(errors ?? []), [errors, formatter])\n\tif (errors === undefined || id === undefined) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\treturn formatted.map((it, index) => {\n\t\treturn cloneElement(children, {\n\t\t\tkey: index,\n\t\t\t...{ id: `${id}-error-${index}` },\n\t\t\tchildren: it,\n\t\t})\n\t})\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,YAAY,CAAC,EAAE,UAAU,gBAGhC;AACL,QAAM,SAAS;AACf,QAAM,KAAK;AACL,QAAA,YAAY,QAAQ,MAAM,UAAU,UAAU,CAAE,CAAA,GAAG,CAAC,QAAQ,SAAS,CAAC;AACxE,MAAA,WAAW,UAAa,OAAO,QAAW;AACvC,UAAA,IAAI,aAAa,2CAA2C;AAAA,EACnE;AACA,SAAO,UAAU,IAAI,CAAC,IAAI,UAAU;AACnC,WAAO,aAAa,UAAU;AAAA,MAC7B,KAAK;AAAA,MACL,GAAG,EAAE,IAAI,GAAG,EAAE,UAAU,KAAK,GAAG;AAAA,MAChC,UAAU;AAAA,IAAA,CACV;AAAA,EAAA,CACD;AACF;"}
@@ -10,11 +10,11 @@ const FormFieldScope = ({ field, children }) => {
10
10
  const fieldAccessor = reactBinding.useField({ field });
11
11
  const errors = fieldAccessor.errors?.errors;
12
12
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormFieldIdContext.Provider, { value: id, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormErrorContext.Provider, { value: errors ?? emptyArr, children }, void 0, false, {
13
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormFieldScope.tsx",
13
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldScope.tsx",
14
14
  lineNumber: 19,
15
15
  columnNumber: 4
16
16
  }, void 0) }, void 0, false, {
17
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormFieldScope.tsx",
17
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldScope.tsx",
18
18
  lineNumber: 18,
19
19
  columnNumber: 3
20
20
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormFieldScope.cjs","sources":["../../../../../packages/react-form/src/components/FormFieldScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useId } from 'react'\nimport { FormErrorContext, FormFieldIdContext } from '../contexts'\nimport { SugaredRelativeSingleField, useField } from '@contember/react-binding'\n\nconst emptyArr: [] = []\n\nexport type FormFieldScopeProps = {\n\tfield: SugaredRelativeSingleField['field']\n\tchildren: React.ReactNode\n}\n\nexport const FormFieldScope = ({ field, children }: FormFieldScopeProps) => {\n\tconst id = useId()\n\tconst fieldAccessor = useField({ field })\n\tconst errors = fieldAccessor.errors?.errors\n\treturn (\n\t\t<FormFieldIdContext.Provider value={id}>\n\t\t\t<FormErrorContext.Provider value={errors ?? emptyArr}>\n\t\t\t\t{children}\n\t\t\t</FormErrorContext.Provider>\n\t\t</FormFieldIdContext.Provider>\n\t)\n}\n"],"names":["useId","useField","jsxDEV","FormFieldIdContext","FormErrorContext","this"],"mappings":";;;;;;AAKA,MAAM,WAAe,CAAA;AAOd,MAAM,iBAAiB,CAAC,EAAE,OAAO,eAAoC;AAC3E,QAAM,KAAKA,MAAAA;AACX,QAAM,gBAAgBC,aAAAA,SAAS,EAAE,MAAO,CAAA;AAClC,QAAA,SAAS,cAAc,QAAQ;AACrC,SACEC,8BAAAA,OAAAC,SAAAA,mBAAmB,UAAnB,EAA4B,OAAO,IACnC,UAACD,qCAAAE,SAAAA,iBAAiB,UAAjB,EAA0B,OAAO,UAAU,UAC1C,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAAA,MAAA;AAEF;;"}
@@ -8,11 +8,11 @@ const FormFieldScope = ({ field, children }) => {
8
8
  const fieldAccessor = useField({ field });
9
9
  const errors = fieldAccessor.errors?.errors;
10
10
  return /* @__PURE__ */ jsxDEV(FormFieldIdContext.Provider, { value: id, children: /* @__PURE__ */ jsxDEV(FormErrorContext.Provider, { value: errors ?? emptyArr, children }, void 0, false, {
11
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormFieldScope.tsx",
11
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldScope.tsx",
12
12
  lineNumber: 19,
13
13
  columnNumber: 4
14
14
  }, void 0) }, void 0, false, {
15
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormFieldScope.tsx",
15
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormFieldScope.tsx",
16
16
  lineNumber: 18,
17
17
  columnNumber: 3
18
18
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormFieldScope.js","sources":["../../../../../packages/react-form/src/components/FormFieldScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useId } from 'react'\nimport { FormErrorContext, FormFieldIdContext } from '../contexts'\nimport { SugaredRelativeSingleField, useField } from '@contember/react-binding'\n\nconst emptyArr: [] = []\n\nexport type FormFieldScopeProps = {\n\tfield: SugaredRelativeSingleField['field']\n\tchildren: React.ReactNode\n}\n\nexport const FormFieldScope = ({ field, children }: FormFieldScopeProps) => {\n\tconst id = useId()\n\tconst fieldAccessor = useField({ field })\n\tconst errors = fieldAccessor.errors?.errors\n\treturn (\n\t\t<FormFieldIdContext.Provider value={id}>\n\t\t\t<FormErrorContext.Provider value={errors ?? emptyArr}>\n\t\t\t\t{children}\n\t\t\t</FormErrorContext.Provider>\n\t\t</FormFieldIdContext.Provider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAKA,MAAM,WAAe,CAAA;AAOd,MAAM,iBAAiB,CAAC,EAAE,OAAO,eAAoC;AAC3E,QAAM,KAAK;AACX,QAAM,gBAAgB,SAAS,EAAE,MAAO,CAAA;AAClC,QAAA,SAAS,cAAc,QAAQ;AACrC,SACE,uBAAA,mBAAmB,UAAnB,EAA4B,OAAO,IACnC,UAAC,uBAAA,iBAAiB,UAAjB,EAA0B,OAAO,UAAU,UAC1C,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAAA,MAAA;AAEF;"}
@@ -10,11 +10,11 @@ const FormHasManyRelationScope = ({ field, children }) => {
10
10
  const entityRelation = reactBinding.useEntityList({ field });
11
11
  const errors = entityRelation.errors?.errors;
12
12
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormFieldIdContext.Provider, { value: id, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormErrorContext.Provider, { value: errors ?? emptyArr, children }, void 0, false, {
13
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasManyRelationScope.tsx",
13
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasManyRelationScope.tsx",
14
14
  lineNumber: 19,
15
15
  columnNumber: 4
16
16
  }, void 0) }, void 0, false, {
17
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasManyRelationScope.tsx",
17
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasManyRelationScope.tsx",
18
18
  lineNumber: 18,
19
19
  columnNumber: 3
20
20
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasManyRelationScope.cjs","sources":["../../../../../packages/react-form/src/components/FormHasManyRelationScope.tsx"],"sourcesContent":["import { SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport * as React from 'react'\nimport { useId } from 'react'\nimport { FormErrorContext, FormFieldIdContext } from '../contexts'\n\nconst emptyArr: [] = []\n\nexport type FormHasManyRelationScopeProps = {\n\tfield: SugaredRelativeEntityList['field']\n\tchildren: React.ReactNode\n}\n\nexport const FormHasManyRelationScope = ({ field, children }: FormHasManyRelationScopeProps) => {\n\tconst id = useId()\n\tconst entityRelation = useEntityList({ field })\n\tconst errors = entityRelation.errors?.errors\n\treturn (\n\t\t<FormFieldIdContext.Provider value={id}>\n\t\t\t<FormErrorContext.Provider value={errors ?? emptyArr}>\n\t\t\t\t{children}\n\t\t\t</FormErrorContext.Provider>\n\t\t</FormFieldIdContext.Provider>\n\t)\n}\n"],"names":["useId","useEntityList","jsxDEV","FormFieldIdContext","FormErrorContext","this"],"mappings":";;;;;;AAKA,MAAM,WAAe,CAAA;AAOd,MAAM,2BAA2B,CAAC,EAAE,OAAO,eAA8C;AAC/F,QAAM,KAAKA,MAAAA;AACX,QAAM,iBAAiBC,aAAAA,cAAc,EAAE,MAAO,CAAA;AACxC,QAAA,SAAS,eAAe,QAAQ;AACtC,SACEC,8BAAAA,OAAAC,SAAAA,mBAAmB,UAAnB,EAA4B,OAAO,IACnC,UAACD,qCAAAE,SAAAA,iBAAiB,UAAjB,EAA0B,OAAO,UAAU,UAC1C,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAAA,MAAA;AAEF;;"}
@@ -8,11 +8,11 @@ const FormHasManyRelationScope = ({ field, children }) => {
8
8
  const entityRelation = useEntityList({ field });
9
9
  const errors = entityRelation.errors?.errors;
10
10
  return /* @__PURE__ */ jsxDEV(FormFieldIdContext.Provider, { value: id, children: /* @__PURE__ */ jsxDEV(FormErrorContext.Provider, { value: errors ?? emptyArr, children }, void 0, false, {
11
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasManyRelationScope.tsx",
11
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasManyRelationScope.tsx",
12
12
  lineNumber: 19,
13
13
  columnNumber: 4
14
14
  }, void 0) }, void 0, false, {
15
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasManyRelationScope.tsx",
15
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasManyRelationScope.tsx",
16
16
  lineNumber: 18,
17
17
  columnNumber: 3
18
18
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasManyRelationScope.js","sources":["../../../../../packages/react-form/src/components/FormHasManyRelationScope.tsx"],"sourcesContent":["import { SugaredRelativeEntityList, useEntityList } from '@contember/react-binding'\nimport * as React from 'react'\nimport { useId } from 'react'\nimport { FormErrorContext, FormFieldIdContext } from '../contexts'\n\nconst emptyArr: [] = []\n\nexport type FormHasManyRelationScopeProps = {\n\tfield: SugaredRelativeEntityList['field']\n\tchildren: React.ReactNode\n}\n\nexport const FormHasManyRelationScope = ({ field, children }: FormHasManyRelationScopeProps) => {\n\tconst id = useId()\n\tconst entityRelation = useEntityList({ field })\n\tconst errors = entityRelation.errors?.errors\n\treturn (\n\t\t<FormFieldIdContext.Provider value={id}>\n\t\t\t<FormErrorContext.Provider value={errors ?? emptyArr}>\n\t\t\t\t{children}\n\t\t\t</FormErrorContext.Provider>\n\t\t</FormFieldIdContext.Provider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAKA,MAAM,WAAe,CAAA;AAOd,MAAM,2BAA2B,CAAC,EAAE,OAAO,eAA8C;AAC/F,QAAM,KAAK;AACX,QAAM,iBAAiB,cAAc,EAAE,MAAO,CAAA;AACxC,QAAA,SAAS,eAAe,QAAQ;AACtC,SACE,uBAAA,mBAAmB,UAAnB,EAA4B,OAAO,IACnC,UAAC,uBAAA,iBAAiB,UAAjB,EAA0B,OAAO,UAAU,UAC1C,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAAA,MAAA;AAEF;"}
@@ -10,11 +10,11 @@ const FormHasOneRelationScope = ({ field, children }) => {
10
10
  const entityRelation = reactBinding.useEntity({ field });
11
11
  const errors = entityRelation.errors?.errors;
12
12
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormFieldIdContext.Provider, { value: id, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.FormErrorContext.Provider, { value: errors ?? emptyArr, children }, void 0, false, {
13
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasOneRelationScope.tsx",
13
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasOneRelationScope.tsx",
14
14
  lineNumber: 19,
15
15
  columnNumber: 4
16
16
  }, void 0) }, void 0, false, {
17
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasOneRelationScope.tsx",
17
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasOneRelationScope.tsx",
18
18
  lineNumber: 18,
19
19
  columnNumber: 3
20
20
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasOneRelationScope.cjs","sources":["../../../../../packages/react-form/src/components/FormHasOneRelationScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useId } from 'react'\nimport { FormErrorContext, FormFieldIdContext } from '../contexts'\nimport { SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\n\nconst emptyArr: [] = []\n\nexport type FormHasOneRelationScopeProps = {\n\tfield: SugaredRelativeSingleEntity['field']\n\tchildren: React.ReactNode\n}\n\nexport const FormHasOneRelationScope = ({ field, children }: FormHasOneRelationScopeProps) => {\n\tconst id = useId()\n\tconst entityRelation = useEntity({ field })\n\tconst errors = entityRelation.errors?.errors\n\treturn (\n\t\t<FormFieldIdContext.Provider value={id}>\n\t\t\t<FormErrorContext.Provider value={errors ?? emptyArr}>\n\t\t\t\t{children}\n\t\t\t</FormErrorContext.Provider>\n\t\t</FormFieldIdContext.Provider>\n\t)\n}\n"],"names":["useId","useEntity","jsxDEV","FormFieldIdContext","FormErrorContext","this"],"mappings":";;;;;;AAKA,MAAM,WAAe,CAAA;AAOd,MAAM,0BAA0B,CAAC,EAAE,OAAO,eAA6C;AAC7F,QAAM,KAAKA,MAAAA;AACX,QAAM,iBAAiBC,aAAAA,UAAU,EAAE,MAAO,CAAA;AACpC,QAAA,SAAS,eAAe,QAAQ;AACtC,SACEC,8BAAAA,OAAAC,SAAAA,mBAAmB,UAAnB,EAA4B,OAAO,IACnC,UAACD,qCAAAE,SAAAA,iBAAiB,UAAjB,EAA0B,OAAO,UAAU,UAC1C,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAAA,MAAA;AAEF;;"}
@@ -8,11 +8,11 @@ const FormHasOneRelationScope = ({ field, children }) => {
8
8
  const entityRelation = useEntity({ field });
9
9
  const errors = entityRelation.errors?.errors;
10
10
  return /* @__PURE__ */ jsxDEV(FormFieldIdContext.Provider, { value: id, children: /* @__PURE__ */ jsxDEV(FormErrorContext.Provider, { value: errors ?? emptyArr, children }, void 0, false, {
11
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasOneRelationScope.tsx",
11
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasOneRelationScope.tsx",
12
12
  lineNumber: 19,
13
13
  columnNumber: 4
14
14
  }, void 0) }, void 0, false, {
15
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormHasOneRelationScope.tsx",
15
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormHasOneRelationScope.tsx",
16
16
  lineNumber: 18,
17
17
  columnNumber: 3
18
18
  }, void 0);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormHasOneRelationScope.js","sources":["../../../../../packages/react-form/src/components/FormHasOneRelationScope.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useId } from 'react'\nimport { FormErrorContext, FormFieldIdContext } from '../contexts'\nimport { SugaredRelativeSingleEntity, useEntity } from '@contember/react-binding'\n\nconst emptyArr: [] = []\n\nexport type FormHasOneRelationScopeProps = {\n\tfield: SugaredRelativeSingleEntity['field']\n\tchildren: React.ReactNode\n}\n\nexport const FormHasOneRelationScope = ({ field, children }: FormHasOneRelationScopeProps) => {\n\tconst id = useId()\n\tconst entityRelation = useEntity({ field })\n\tconst errors = entityRelation.errors?.errors\n\treturn (\n\t\t<FormFieldIdContext.Provider value={id}>\n\t\t\t<FormErrorContext.Provider value={errors ?? emptyArr}>\n\t\t\t\t{children}\n\t\t\t</FormErrorContext.Provider>\n\t\t</FormFieldIdContext.Provider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAKA,MAAM,WAAe,CAAA;AAOd,MAAM,0BAA0B,CAAC,EAAE,OAAO,eAA6C;AAC7F,QAAM,KAAK;AACX,QAAM,iBAAiB,UAAU,EAAE,MAAO,CAAA;AACpC,QAAA,SAAS,eAAe,QAAQ;AACtC,SACE,uBAAA,mBAAmB,UAAnB,EAA4B,OAAO,IACnC,UAAC,uBAAA,iBAAiB,UAAjB,EAA0B,OAAO,UAAU,UAC1C,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAAA,MAAA;AAEF;"}
@@ -35,7 +35,7 @@ const FormInput = reactBinding.Component(({ field, isNonbearing, defaultValue, f
35
35
  void 0,
36
36
  false,
37
37
  {
38
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormInput.tsx",
38
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
39
39
  lineNumber: 32,
40
40
  columnNumber: 3
41
41
  },
@@ -43,7 +43,7 @@ const FormInput = reactBinding.Component(({ field, isNonbearing, defaultValue, f
43
43
  );
44
44
  }, ({ field, isNonbearing, defaultValue }) => {
45
45
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Field, { field, isNonbearing, defaultValue }, void 0, false, {
46
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormInput.tsx",
46
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
47
47
  lineNumber: 48,
48
48
  columnNumber: 9
49
49
  }, void 0);
@@ -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 } 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 { useFormError, useFormFieldId } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks/useFormInputValidationHandler'\nimport { FormInputHandler } from '../types'\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>(({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField(field)\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn })\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\tvalue={formatValue(accessor.value)}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(parseValue(e.target.value))\n\t\t\t}, [accessorGetter, parseValue])}\n\t\t\t{...defaultInputProps}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\trequired={!accessor.schema.nullable}\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","useFormFieldId","useField","useFormError","useFormInputHandler","useFormInputValidationHandler","jsxDEV","dataAttribute","useCallback","this","Field"],"mappings":";;;;;;;;;;AAWA,MAAM,YAAYA,UAAAA;AAWX,MAAM,YAAYC,aAAA,UAA0B,CAAC,EAAE,OAAO,cAAc,cAAc,aAAa,eAAe,YAAY,cAAc,GAAG,YAAY;AAC7J,QAAM,KAAKC,SAAAA;AACL,QAAA,WAAWC,sBAAS,KAAK;AAC/B,QAAM,SAASC,SAAAA,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,EAAE,YAAY,aAAa,kBAAsB,IAAAC,oBAAA,oBAAoB,UAAU,EAAE,aAAa,eAAe,YAAY,aAAc,CAAA;AAC7I,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAIC,8BAAAA,8BAA8B,QAAQ;AAGtE,SAAAC,8BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,OAAO,YAAY,SAAS,KAAK;AAAA,MACjC,gBAAcC,UAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C;AAAA,MACA;AAAA,MACA,UAAUC,MAAAA,YAAkD,CAAK,MAAA;AAChE,uBAAA,EAAiB,YAAY,WAAW,EAAE,OAAO,KAAK,CAAC;AAAA,MAAA,GACrD,CAAC,gBAAgB,UAAU,CAAC;AAAA,MAC9B,GAAG;AAAA,MACJ,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB,UAAU,CAAC,SAAS,OAAO;AAAA,MAC1B,GAAG;AAAA,IAAA;AAAA,IAZL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA;AAeF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQH,8BAAA,OAAAI,aAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA6E,GAAAD,MAAA;AACrF,CAAC;;"}
@@ -33,7 +33,7 @@ const FormInput = Component(({ field, isNonbearing, defaultValue, formatValue: f
33
33
  void 0,
34
34
  false,
35
35
  {
36
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormInput.tsx",
36
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
37
37
  lineNumber: 32,
38
38
  columnNumber: 3
39
39
  },
@@ -41,7 +41,7 @@ const FormInput = Component(({ field, isNonbearing, defaultValue, formatValue: f
41
41
  );
42
42
  }, ({ field, isNonbearing, defaultValue }) => {
43
43
  return /* @__PURE__ */ jsxDEV(Field, { field, isNonbearing, defaultValue }, void 0, false, {
44
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormInput.tsx",
44
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormInput.tsx",
45
45
  lineNumber: 48,
46
46
  columnNumber: 9
47
47
  }, void 0);
@@ -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 } 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 { useFormError, useFormFieldId } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks/useFormInputValidationHandler'\nimport { FormInputHandler } from '../types'\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>(({ field, isNonbearing, defaultValue, formatValue: formatValueIn, parseValue: parseValueIn, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField(field)\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst { parseValue, formatValue, defaultInputProps } = useFormInputHandler(accessor, { formatValue: formatValueIn, parseValue: parseValueIn })\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\tvalue={formatValue(accessor.value)}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(parseValue(e.target.value))\n\t\t\t}, [accessorGetter, parseValue])}\n\t\t\t{...defaultInputProps}\n\t\t\tid={id ? `${id}-input` : undefined}\n\t\t\trequired={!accessor.schema.nullable}\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":["this"],"mappings":";;;;;;;;AAWA,MAAM,YAAY;AAWX,MAAM,YAAY,UAA0B,CAAC,EAAE,OAAO,cAAc,cAAc,aAAa,eAAe,YAAY,cAAc,GAAG,YAAY;AAC7J,QAAM,KAAK;AACL,QAAA,WAAW,SAAS,KAAK;AAC/B,QAAM,SAAS,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,EAAE,YAAY,aAAa,kBAAsB,IAAA,oBAAoB,UAAU,EAAE,aAAa,eAAe,YAAY,aAAc,CAAA;AAC7I,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAI,8BAA8B,QAAQ;AAGtE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,OAAO,YAAY,SAAS,KAAK;AAAA,MACjC,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C;AAAA,MACA;AAAA,MACA,UAAU,YAAkD,CAAK,MAAA;AAChE,uBAAA,EAAiB,YAAY,WAAW,EAAE,OAAO,KAAK,CAAC;AAAA,MAAA,GACrD,CAAC,gBAAgB,UAAU,CAAC;AAAA,MAC9B,GAAG;AAAA,MACJ,IAAI,KAAK,GAAG,EAAE,WAAW;AAAA,MACzB,UAAU,CAAC,SAAS,OAAO;AAAA,MAC1B,GAAG;AAAA,IAAA;AAAA,IAZL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAeF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQ,uBAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA6E,GAAAA,MAAA;AACrF,CAAC;"}
@@ -21,7 +21,7 @@ const FormLabel = (props) => {
21
21
  void 0,
22
22
  false,
23
23
  {
24
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormLabel.tsx",
24
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormLabel.tsx",
25
25
  lineNumber: 16,
26
26
  columnNumber: 3
27
27
  },
@@ -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 { useFormError, useFormFieldId } from '../contexts'\nimport { BindingError } from '@contember/react-binding'\n\nexport const FormLabel = (props: {\n\tchildren: React.ReactElement\n}) => {\n\tconst id = useFormFieldId()\n\tconst errors = useFormError()\n\tif (errors === undefined || id === undefined) {\n\t\tthrow new BindingError('FormLabel must be used inside a FormField')\n\t}\n\treturn (\n\t\t<Slot\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\t{...{ htmlFor: `${id}-input` }}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["useFormFieldId","useFormError","BindingError","jsxDEV","Slot","dataAttribute","this"],"mappings":";;;;;;;AAMa,MAAA,YAAY,CAAC,UAEpB;AACL,QAAM,KAAKA,SAAAA;AACX,QAAM,SAASC,SAAAA;AACX,MAAA,WAAW,UAAa,OAAO,QAAW;AACvC,UAAA,IAAIC,aAAAA,aAAa,2CAA2C;AAAA,EACnE;AAEC,SAAAC,8BAAA;AAAA,IAACC,UAAA;AAAA,IAAA;AAAA,MACA,gBAAcC,UAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC5C,GAAG,EAAE,SAAS,GAAG,EAAE,SAAS;AAAA,MAC5B,GAAG;AAAA,IAAA;AAAA,IAHL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA;AAMF;;"}
@@ -19,7 +19,7 @@ const FormLabel = (props) => {
19
19
  void 0,
20
20
  false,
21
21
  {
22
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormLabel.tsx",
22
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormLabel.tsx",
23
23
  lineNumber: 16,
24
24
  columnNumber: 3
25
25
  },
@@ -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 { useFormError, useFormFieldId } from '../contexts'\nimport { BindingError } from '@contember/react-binding'\n\nexport const FormLabel = (props: {\n\tchildren: React.ReactElement\n}) => {\n\tconst id = useFormFieldId()\n\tconst errors = useFormError()\n\tif (errors === undefined || id === undefined) {\n\t\tthrow new BindingError('FormLabel must be used inside a FormField')\n\t}\n\treturn (\n\t\t<Slot\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\t{...{ htmlFor: `${id}-input` }}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;AAMa,MAAA,YAAY,CAAC,UAEpB;AACL,QAAM,KAAK;AACX,QAAM,SAAS;AACX,MAAA,WAAW,UAAa,OAAO,QAAW;AACvC,UAAA,IAAI,aAAa,2CAA2C;AAAA,EACnE;AAEC,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC5C,GAAG,EAAE,SAAS,GAAG,EAAE,SAAS;AAAA,MAC5B,GAAG;AAAA,IAAA;AAAA,IAHL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAMF;"}
@@ -34,7 +34,7 @@ const FormRadioInput = reactBinding.Component(({ field, value, defaultValue, isN
34
34
  void 0,
35
35
  false,
36
36
  {
37
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormRadioInput.tsx",
37
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormRadioInput.tsx",
38
38
  lineNumber: 27,
39
39
  columnNumber: 3
40
40
  },
@@ -42,7 +42,7 @@ const FormRadioInput = reactBinding.Component(({ field, value, defaultValue, isN
42
42
  );
43
43
  }, ({ field, isNonbearing, defaultValue }) => {
44
44
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Field, { field, isNonbearing, defaultValue }, void 0, false, {
45
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormRadioInput.tsx",
45
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormRadioInput.tsx",
46
46
  lineNumber: 44,
47
47
  columnNumber: 9
48
48
  }, void 0);
@@ -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 * as React from 'react'\nimport { ChangeEventHandler, useCallback } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks'\nimport { dataAttribute } from '@contember/utilities'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormRadioItemProps {\n\tfield: SugaredRelativeSingleField['field']\n\tvalue: string\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactNode\n}\n\nexport const FormRadioInput = Component<FormRadioItemProps>(({ field, value, defaultValue, isNonbearing, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField<string>(field)\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\ttype=\"radio\"\n\t\t\tvalue={value}\n\t\t\tchecked={accessor.value === value}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tname={id + '-input'}\n\t\t\tid={`${id}-input-${value}`}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(value)\n\t\t\t}, [accessorGetter, value])}\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","useFormFieldId","useField","useFormError","useFormInputValidationHandler","jsxDEV","dataAttribute","useCallback","this","Field"],"mappings":";;;;;;;;;AAQA,MAAM,YAAYA,UAAAA;AAUL,MAAA,iBAAiBC,aAAAA,UAA8B,CAAC,EAAE,OAAO,OAAO,cAAc,cAAc,GAAG,YAAY;AACvH,QAAM,KAAKC,SAAAA;AACL,QAAA,WAAWC,sBAAiB,KAAK;AACvC,QAAM,SAASC,SAAAA,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAIC,8BAAAA,8BAA8B,QAAQ;AAGtE,SAAAC,8BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MACA,SAAS,SAAS,UAAU;AAAA,MAC5B,gBAAcC,UAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,MAAM,KAAK;AAAA,MACX,IAAI,GAAG,EAAE,UAAU,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,MACA,UAAUC,MAAAA,YAAkD,CAAK,MAAA;AACjD,uBAAA,EAAE,YAAY,KAAK;AAAA,MAAA,GAChC,CAAC,gBAAgB,KAAK,CAAC;AAAA,MACzB,GAAG;AAAA,IAAA;AAAA,IAbL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA;AAgBF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQH,8BAAA,OAAAI,aAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA6E,GAAAD,MAAA;AACrF,CAAC;;"}
@@ -32,7 +32,7 @@ const FormRadioInput = Component(({ field, value, defaultValue, isNonbearing, ..
32
32
  void 0,
33
33
  false,
34
34
  {
35
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormRadioInput.tsx",
35
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormRadioInput.tsx",
36
36
  lineNumber: 27,
37
37
  columnNumber: 3
38
38
  },
@@ -40,7 +40,7 @@ const FormRadioInput = Component(({ field, value, defaultValue, isNonbearing, ..
40
40
  );
41
41
  }, ({ field, isNonbearing, defaultValue }) => {
42
42
  return /* @__PURE__ */ jsxDEV(Field, { field, isNonbearing, defaultValue }, void 0, false, {
43
- fileName: "/__w/interface/interface/packages/react-form/src/components/FormRadioInput.tsx",
43
+ fileName: "/home/runner/work/contember/contember/packages/react-form/src/components/FormRadioInput.tsx",
44
44
  lineNumber: 44,
45
45
  columnNumber: 9
46
46
  }, void 0);
@@ -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 * as React from 'react'\nimport { ChangeEventHandler, useCallback } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { useFormInputValidationHandler } from '../hooks'\nimport { dataAttribute } from '@contember/utilities'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormRadioItemProps {\n\tfield: SugaredRelativeSingleField['field']\n\tvalue: string\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: React.ReactNode\n}\n\nexport const FormRadioInput = Component<FormRadioItemProps>(({ field, value, defaultValue, isNonbearing, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField<string>(field)\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={ref}\n\t\t\ttype=\"radio\"\n\t\t\tvalue={value}\n\t\t\tchecked={accessor.value === value}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tname={id + '-input'}\n\t\t\tid={`${id}-input-${value}`}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(value)\n\t\t\t}, [accessorGetter, value])}\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":["this"],"mappings":";;;;;;;AAQA,MAAM,YAAY;AAUL,MAAA,iBAAiB,UAA8B,CAAC,EAAE,OAAO,OAAO,cAAc,cAAc,GAAG,YAAY;AACvH,QAAM,KAAK;AACL,QAAA,WAAW,SAAiB,KAAK;AACvC,QAAM,SAAS,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAI,8BAA8B,QAAQ;AAGtE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MACA,SAAS,SAAS,UAAU;AAAA,MAC5B,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,MAAM,KAAK;AAAA,MACX,IAAI,GAAG,EAAE,UAAU,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,MACA,UAAU,YAAkD,CAAK,MAAA;AACjD,uBAAA,EAAE,YAAY,KAAK;AAAA,MAAA,GAChC,CAAC,gBAAgB,KAAK,CAAC;AAAA,MACzB,GAAG;AAAA,IAAA;AAAA,IAbL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAgBF,GAAG,CAAC,EAAE,OAAO,cAAc,mBAAmB;AAC7C,SAAQ,uBAAA,OAAA,EAAM,OAAc,cAA4B,aAAjD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA6E,GAAAA,MAAA;AACrF,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts.cjs","sources":["../../../../packages/react-form/src/contexts.ts"],"sourcesContent":["import { createContext } from '@contember/react-utils'\nimport { ErrorAccessor } from '@contember/react-binding'\n\nconst FormFieldIdContext_ = createContext<string | undefined>('FormFieldIdContext', undefined)\n/** @internal */\nexport const FormFieldIdContext = FormFieldIdContext_[0]\nexport const useFormFieldId = FormFieldIdContext_[1]\n\nconst FormErrorContext_ = createContext<ErrorAccessor.Error[] | undefined>('FormErrorContext', undefined)\n/** @internal */\nexport const FormErrorContext = FormErrorContext_[0]\nexport const useFormError = FormErrorContext_[1]\n"],"names":["createContext"],"mappings":";;;AAGA,MAAM,sBAAsBA,WAAkC,cAAA,sBAAsB,MAAS;AAEhF,MAAA,qBAAqB,oBAAoB,CAAC;AAC1C,MAAA,iBAAiB,oBAAoB,CAAC;AAEnD,MAAM,oBAAoBA,WAAiD,cAAA,oBAAoB,MAAS;AAE3F,MAAA,mBAAmB,kBAAkB,CAAC;AACtC,MAAA,eAAe,kBAAkB,CAAC;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts.js","sources":["../../../../packages/react-form/src/contexts.ts"],"sourcesContent":["import { createContext } from '@contember/react-utils'\nimport { ErrorAccessor } from '@contember/react-binding'\n\nconst FormFieldIdContext_ = createContext<string | undefined>('FormFieldIdContext', undefined)\n/** @internal */\nexport const FormFieldIdContext = FormFieldIdContext_[0]\nexport const useFormFieldId = FormFieldIdContext_[1]\n\nconst FormErrorContext_ = createContext<ErrorAccessor.Error[] | undefined>('FormErrorContext', undefined)\n/** @internal */\nexport const FormErrorContext = FormErrorContext_[0]\nexport const useFormError = FormErrorContext_[1]\n"],"names":[],"mappings":";AAGA,MAAM,sBAAsB,cAAkC,sBAAsB,MAAS;AAEhF,MAAA,qBAAqB,oBAAoB,CAAC;AAC1C,MAAA,iBAAiB,oBAAoB,CAAC;AAEnD,MAAM,oBAAoB,cAAiD,oBAAoB,MAAS;AAE3F,MAAA,mBAAmB,kBAAkB,CAAC;AACtC,MAAA,eAAe,kBAAkB,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormInputValidationHandler.cjs","sources":["../../../../../packages/react-form/src/hooks/useFormInputValidationHandler.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useCallback, useEffect, useRef } from 'react'\nimport { FieldAccessor, useEntityBeforePersist } from '@contember/react-binding'\n\nexport const useFormInputValidationHandler = (field: FieldAccessor<any>) => {\n\tconst accessorGetter = field.getAccessor\n\tconst validationMessage = useRef<string>()\n\tconst [focus, setFocus] = React.useState(false)\n\tconst inputRef = React.useRef<HTMLInputElement>(null)\n\tuseEntityBeforePersist(useCallback(() => {\n\t\tif (validationMessage.current) {\n\t\t\taccessorGetter().addError(validationMessage.current)\n\t\t}\n\t}, [accessorGetter]))\n\n\tuseEffect(() => {\n\t\tif (!inputRef.current) {\n\t\t\treturn\n\t\t}\n\n\t\tconst input = inputRef.current\n\t\tconst valid = input.validity?.valid\n\n\t\tconst message = valid ? undefined : input?.validationMessage\n\t\tconst previousMessage = validationMessage.current\n\t\tvalidationMessage.current = message\n\n\t\t// if there is no message, we want to clear the error\n\t\tif (!message) {\n\t\t\taccessorGetter().clearErrors()\n\t\t\treturn\n\t\t}\n\t\tif (message === previousMessage) {\n\t\t\treturn\n\t\t}\n\t\t// if the input is not touched, we don't want to show the error message\n\t\tif (!field.isTouched) {\n\t\t\treturn\n\t\t}\n\n\t\t// if the input is not focused, we want to show the error message\n\t\t// also, even the input is focused, we want to replace the previous message\n\t\tif (!focus || !!previousMessage) {\n\t\t\taccessorGetter().clearErrors()\n\t\t\taccessorGetter().addError(message)\n\t\t}\n\t})\n\n\treturn {\n\t\tref: inputRef,\n\t\tonFocus: useCallback(() => {\n\t\t\tsetFocus(true)\n\t\t}, []),\n\t\tonBlur: useCallback(() => {\n\t\t\tsetFocus(false)\n\t\t\taccessorGetter().clearErrors()\n\t\t\tif (validationMessage.current) {\n\t\t\t\taccessorGetter().addError(validationMessage.current)\n\t\t\t}\n\t\t}, [accessorGetter]),\n\t}\n}\n"],"names":["useRef","React","useEntityBeforePersist","useCallback","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIa,MAAA,gCAAgC,CAAC,UAA8B;AAC3E,QAAM,iBAAiB,MAAM;AAC7B,QAAM,oBAAoBA,MAAAA;AAC1B,QAAM,CAAC,OAAO,QAAQ,IAAIC,iBAAM,SAAS,KAAK;AACxC,QAAA,WAAWA,iBAAM,OAAyB,IAAI;AACpDC,eAAA,uBAAuBC,kBAAY,MAAM;AACxC,QAAI,kBAAkB,SAAS;AACf,uBAAE,SAAS,kBAAkB,OAAO;AAAA,IACpD;AAAA,EAAA,GACE,CAAC,cAAc,CAAC,CAAC;AAEpBC,QAAAA,UAAU,MAAM;AACX,QAAA,CAAC,SAAS,SAAS;AACtB;AAAA,IACD;AAEA,UAAM,QAAQ,SAAS;AACjB,UAAA,QAAQ,MAAM,UAAU;AAExB,UAAA,UAAU,QAAQ,SAAY,OAAO;AAC3C,UAAM,kBAAkB,kBAAkB;AAC1C,sBAAkB,UAAU;AAG5B,QAAI,CAAC,SAAS;AACb,qBAAA,EAAiB;AACjB;AAAA,IACD;AACA,QAAI,YAAY,iBAAiB;AAChC;AAAA,IACD;AAEI,QAAA,CAAC,MAAM,WAAW;AACrB;AAAA,IACD;AAIA,QAAI,CAAC,SAAS,CAAC,CAAC,iBAAiB;AAChC,qBAAA,EAAiB;AACF,qBAAA,EAAE,SAAS,OAAO;AAAA,IAClC;AAAA,EAAA,CACA;AAEM,SAAA;AAAA,IACN,KAAK;AAAA,IACL,SAASD,kBAAY,MAAM;AAC1B,eAAS,IAAI;AAAA,IACd,GAAG,EAAE;AAAA,IACL,QAAQA,kBAAY,MAAM;AACzB,eAAS,KAAK;AACd,qBAAA,EAAiB;AACjB,UAAI,kBAAkB,SAAS;AACf,yBAAE,SAAS,kBAAkB,OAAO;AAAA,MACpD;AAAA,IAAA,GACE,CAAC,cAAc,CAAC;AAAA,EAAA;AAErB;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormInputValidationHandler.js","sources":["../../../../../packages/react-form/src/hooks/useFormInputValidationHandler.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useCallback, useEffect, useRef } from 'react'\nimport { FieldAccessor, useEntityBeforePersist } from '@contember/react-binding'\n\nexport const useFormInputValidationHandler = (field: FieldAccessor<any>) => {\n\tconst accessorGetter = field.getAccessor\n\tconst validationMessage = useRef<string>()\n\tconst [focus, setFocus] = React.useState(false)\n\tconst inputRef = React.useRef<HTMLInputElement>(null)\n\tuseEntityBeforePersist(useCallback(() => {\n\t\tif (validationMessage.current) {\n\t\t\taccessorGetter().addError(validationMessage.current)\n\t\t}\n\t}, [accessorGetter]))\n\n\tuseEffect(() => {\n\t\tif (!inputRef.current) {\n\t\t\treturn\n\t\t}\n\n\t\tconst input = inputRef.current\n\t\tconst valid = input.validity?.valid\n\n\t\tconst message = valid ? undefined : input?.validationMessage\n\t\tconst previousMessage = validationMessage.current\n\t\tvalidationMessage.current = message\n\n\t\t// if there is no message, we want to clear the error\n\t\tif (!message) {\n\t\t\taccessorGetter().clearErrors()\n\t\t\treturn\n\t\t}\n\t\tif (message === previousMessage) {\n\t\t\treturn\n\t\t}\n\t\t// if the input is not touched, we don't want to show the error message\n\t\tif (!field.isTouched) {\n\t\t\treturn\n\t\t}\n\n\t\t// if the input is not focused, we want to show the error message\n\t\t// also, even the input is focused, we want to replace the previous message\n\t\tif (!focus || !!previousMessage) {\n\t\t\taccessorGetter().clearErrors()\n\t\t\taccessorGetter().addError(message)\n\t\t}\n\t})\n\n\treturn {\n\t\tref: inputRef,\n\t\tonFocus: useCallback(() => {\n\t\t\tsetFocus(true)\n\t\t}, []),\n\t\tonBlur: useCallback(() => {\n\t\t\tsetFocus(false)\n\t\t\taccessorGetter().clearErrors()\n\t\t\tif (validationMessage.current) {\n\t\t\t\taccessorGetter().addError(validationMessage.current)\n\t\t\t}\n\t\t}, [accessorGetter]),\n\t}\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,gCAAgC,CAAC,UAA8B;AAC3E,QAAM,iBAAiB,MAAM;AAC7B,QAAM,oBAAoB;AAC1B,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AACxC,QAAA,WAAW,MAAM,OAAyB,IAAI;AACpD,yBAAuB,YAAY,MAAM;AACxC,QAAI,kBAAkB,SAAS;AACf,uBAAE,SAAS,kBAAkB,OAAO;AAAA,IACpD;AAAA,EAAA,GACE,CAAC,cAAc,CAAC,CAAC;AAEpB,YAAU,MAAM;AACX,QAAA,CAAC,SAAS,SAAS;AACtB;AAAA,IACD;AAEA,UAAM,QAAQ,SAAS;AACjB,UAAA,QAAQ,MAAM,UAAU;AAExB,UAAA,UAAU,QAAQ,SAAY,OAAO;AAC3C,UAAM,kBAAkB,kBAAkB;AAC1C,sBAAkB,UAAU;AAG5B,QAAI,CAAC,SAAS;AACb,qBAAA,EAAiB;AACjB;AAAA,IACD;AACA,QAAI,YAAY,iBAAiB;AAChC;AAAA,IACD;AAEI,QAAA,CAAC,MAAM,WAAW;AACrB;AAAA,IACD;AAIA,QAAI,CAAC,SAAS,CAAC,CAAC,iBAAiB;AAChC,qBAAA,EAAiB;AACF,qBAAA,EAAE,SAAS,OAAO;AAAA,IAClC;AAAA,EAAA,CACA;AAEM,SAAA;AAAA,IACN,KAAK;AAAA,IACL,SAAS,YAAY,MAAM;AAC1B,eAAS,IAAI;AAAA,IACd,GAAG,EAAE;AAAA,IACL,QAAQ,YAAY,MAAM;AACzB,eAAS,KAAK;AACd,qBAAA,EAAiB;AACjB,UAAI,kBAAkB,SAAS;AACf,yBAAE,SAAS,kBAAkB,OAAO;AAAA,MACpD;AAAA,IAAA,GACE,CAAC,cAAc,CAAC;AAAA,EAAA;AAErB;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormInputHandler.cjs","sources":["../../../../../packages/react-form/src/internal/useFormInputHandler.ts"],"sourcesContent":["import { FieldAccessor, SchemaColumn, SchemaKnownColumnType } from '@contember/react-binding'\nimport { useMemo } from 'react'\nimport { FormInputHandler } from '../types'\n\nexport const useFormInputHandler = (field: FieldAccessor, { formatValue, parseValue }: Partial<FormInputHandler>): FormInputHandler => {\n\treturn useMemo(() => {\n\t\tconst schema = field.schema\n\t\tconst columnType = schema.type\n\t\tconst handlerFactory = ColumnTypeHandlerFactories[columnType as SchemaKnownColumnType] ?? defaultHandlerFactory\n\t\tconst handler = handlerFactory(schema, field.getAccessor)\n\t\treturn {\n\t\t\tdefaultInputProps: handler.defaultInputProps,\n\t\t\tformatValue: formatValue ?? handler.formatValue,\n\t\t\tparseValue: parseValue ?? handler.parseValue,\n\t\t}\n\t}, [field.getAccessor, field.schema, formatValue, parseValue])\n}\n\ntype ColumnTypeHandlerFactory = (column: SchemaColumn, getAccessor: FieldAccessor.GetFieldAccessor) => FormInputHandler\n\nconst defaultHandlerFactory: ColumnTypeHandlerFactory = (schema, field) => ({\n\tparseValue: (value: string) => {\n\t\tif (value === '' && schema.nullable && field().valueOnServer === null) {\n\t\t\treturn null\n\t\t}\n\t\treturn value\n\t},\n\tformatValue: (value: string | null) => value ?? '',\n})\n\nconst ColumnTypeHandlerFactories: Record<SchemaKnownColumnType, ColumnTypeHandlerFactory | undefined> = {\n\tString: defaultHandlerFactory,\n\tInteger: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseInt(value, 10)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\tDouble: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseFloat(value)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\n\tDate: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : (new Date(parsed)).toISOString().split('T')[0]\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : new Date(parsed).toISOString().split('T')[0]\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'date',\n\t\t},\n\t}),\n\tDateTime: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : (new Date(parsed)).toISOString()\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : toLocalDate(new Date(parsed))\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'datetime-local',\n\t\t},\n\t}),\n\tBool: undefined,\n\tEnum: undefined,\n\tUuid: undefined,\n}\n\nconst toLocalDate = (date: Date) => {\n\tconst pad = (num: number, length: number = 2) => {\n\t\tconst str = num.toString()\n\t\treturn '0'.repeat(Math.max(0, length - str.length)) + str\n\t}\n\n\treturn pad(date.getFullYear(), 4) +\n\t\t'-' + pad(date.getMonth() + 1) +\n\t\t'-' + pad(date.getDate()) +\n\t\t'T' + pad(date.getHours()) +\n\t\t':' + pad(date.getMinutes()) +\n\t\t':' + pad(date.getSeconds())\n}\n"],"names":["useMemo"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormInputHandler.js","sources":["../../../../../packages/react-form/src/internal/useFormInputHandler.ts"],"sourcesContent":["import { FieldAccessor, SchemaColumn, SchemaKnownColumnType } from '@contember/react-binding'\nimport { useMemo } from 'react'\nimport { FormInputHandler } from '../types'\n\nexport const useFormInputHandler = (field: FieldAccessor, { formatValue, parseValue }: Partial<FormInputHandler>): FormInputHandler => {\n\treturn useMemo(() => {\n\t\tconst schema = field.schema\n\t\tconst columnType = schema.type\n\t\tconst handlerFactory = ColumnTypeHandlerFactories[columnType as SchemaKnownColumnType] ?? defaultHandlerFactory\n\t\tconst handler = handlerFactory(schema, field.getAccessor)\n\t\treturn {\n\t\t\tdefaultInputProps: handler.defaultInputProps,\n\t\t\tformatValue: formatValue ?? handler.formatValue,\n\t\t\tparseValue: parseValue ?? handler.parseValue,\n\t\t}\n\t}, [field.getAccessor, field.schema, formatValue, parseValue])\n}\n\ntype ColumnTypeHandlerFactory = (column: SchemaColumn, getAccessor: FieldAccessor.GetFieldAccessor) => FormInputHandler\n\nconst defaultHandlerFactory: ColumnTypeHandlerFactory = (schema, field) => ({\n\tparseValue: (value: string) => {\n\t\tif (value === '' && schema.nullable && field().valueOnServer === null) {\n\t\t\treturn null\n\t\t}\n\t\treturn value\n\t},\n\tformatValue: (value: string | null) => value ?? '',\n})\n\nconst ColumnTypeHandlerFactories: Record<SchemaKnownColumnType, ColumnTypeHandlerFactory | undefined> = {\n\tString: defaultHandlerFactory,\n\tInteger: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseInt(value, 10)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\tDouble: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseFloat(value)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\n\tDate: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : (new Date(parsed)).toISOString().split('T')[0]\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : new Date(parsed).toISOString().split('T')[0]\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'date',\n\t\t},\n\t}),\n\tDateTime: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : (new Date(parsed)).toISOString()\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : toLocalDate(new Date(parsed))\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'datetime-local',\n\t\t},\n\t}),\n\tBool: undefined,\n\tEnum: undefined,\n\tUuid: undefined,\n}\n\nconst toLocalDate = (date: Date) => {\n\tconst pad = (num: number, length: number = 2) => {\n\t\tconst str = num.toString()\n\t\treturn '0'.repeat(Math.max(0, length - str.length)) + str\n\t}\n\n\treturn pad(date.getFullYear(), 4) +\n\t\t'-' + pad(date.getMonth() + 1) +\n\t\t'-' + pad(date.getDate()) +\n\t\t'T' + pad(date.getHours()) +\n\t\t':' + pad(date.getMinutes()) +\n\t\t':' + pad(date.getSeconds())\n}\n"],"names":[],"mappings":"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"}
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const contexts = require("./contexts.cjs");
4
- const FormError = require("./components/FormError.cjs");
5
- const FormCheckbox = require("./components/FormCheckbox.cjs");
6
- const FormFieldScope = require("./components/FormFieldScope.cjs");
7
- const FormHasOneRelationScope = require("./components/FormHasOneRelationScope.cjs");
8
- const FormHasManyRelationScope = require("./components/FormHasManyRelationScope.cjs");
9
- const FormInput = require("./components/FormInput.cjs");
10
- const FormLabel = require("./components/FormLabel.cjs");
11
- const FormRadioInput = require("./components/FormRadioInput.cjs");
12
- const useFormInputValidationHandler = require("./hooks/useFormInputValidationHandler.cjs");
3
+ const contexts = require("./src/contexts.cjs");
4
+ const FormError = require("./src/components/FormError.cjs");
5
+ const FormCheckbox = require("./src/components/FormCheckbox.cjs");
6
+ const FormFieldScope = require("./src/components/FormFieldScope.cjs");
7
+ const FormHasOneRelationScope = require("./src/components/FormHasOneRelationScope.cjs");
8
+ const FormHasManyRelationScope = require("./src/components/FormHasManyRelationScope.cjs");
9
+ const FormInput = require("./src/components/FormInput.cjs");
10
+ const FormLabel = require("./src/components/FormLabel.cjs");
11
+ const FormRadioInput = require("./src/components/FormRadioInput.cjs");
12
+ const useFormInputValidationHandler = require("./src/hooks/useFormInputValidationHandler.cjs");
13
13
  exports.FormErrorContext = contexts.FormErrorContext;
14
14
  exports.FormFieldIdContext = contexts.FormFieldIdContext;
15
15
  exports.useFormError = contexts.useFormError;
@@ -1,13 +1,13 @@
1
- import { FormErrorContext, FormFieldIdContext, useFormError, useFormFieldId } from "./contexts.js";
2
- import { FormError } from "./components/FormError.js";
3
- import { FormCheckbox } from "./components/FormCheckbox.js";
4
- import { FormFieldScope } from "./components/FormFieldScope.js";
5
- import { FormHasOneRelationScope } from "./components/FormHasOneRelationScope.js";
6
- import { FormHasManyRelationScope } from "./components/FormHasManyRelationScope.js";
7
- import { FormInput } from "./components/FormInput.js";
8
- import { FormLabel } from "./components/FormLabel.js";
9
- import { FormRadioInput } from "./components/FormRadioInput.js";
10
- import { useFormInputValidationHandler } from "./hooks/useFormInputValidationHandler.js";
1
+ import { FormErrorContext, FormFieldIdContext, useFormError, useFormFieldId } from "./src/contexts.js";
2
+ import { FormError } from "./src/components/FormError.js";
3
+ import { FormCheckbox } from "./src/components/FormCheckbox.js";
4
+ import { FormFieldScope } from "./src/components/FormFieldScope.js";
5
+ import { FormHasOneRelationScope } from "./src/components/FormHasOneRelationScope.js";
6
+ import { FormHasManyRelationScope } from "./src/components/FormHasManyRelationScope.js";
7
+ import { FormInput } from "./src/components/FormInput.js";
8
+ import { FormLabel } from "./src/components/FormLabel.js";
9
+ import { FormRadioInput } from "./src/components/FormRadioInput.js";
10
+ import { useFormInputValidationHandler } from "./src/hooks/useFormInputValidationHandler.js";
11
11
  export {
12
12
  FormCheckbox,
13
13
  FormError,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormCheckbox.cjs","sources":["../../../../../packages/react-form/src/components/FormCheckbox.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ReactElement, useCallback, useEffect } from 'react'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, TreeNodeEnvironmentFactory, useField } from '@contember/react-binding'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputValidationHandler } from '../hooks'\nimport { Slot } from '@radix-ui/react-slot'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormCheckboxProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: ReactElement<HTMLInputElement, 'input'>\n}\n\nexport const FormCheckbox = Component<FormCheckboxProps>(({ field, isNonbearing, defaultValue, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField<boolean>(field)\n\tconst value = accessor.value\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\tconst [checkboxRef, setCheckboxRef] = React.useState<HTMLInputElement | null>(null)\n\n\tuseEffect(() => {\n\t\tif (!checkboxRef) {\n\t\t\treturn\n\t\t}\n\t\tcheckboxRef.indeterminate = value === null\n\t}, [checkboxRef, ref, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={it => {\n\t\t\t\t(ref as any).current = checkboxRef\n\t\t\t\tsetCheckboxRef(it)\n\t\t\t}}\n\t\t\ttype=\"checkbox\"\n\t\t\tchecked={accessor.value === true}\n\t\t\tdata-state={value === null ? 'indeterminate' : (value ? 'checked' : 'unchecked')}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tid={`${id}-input`}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(e.target.checked)\n\t\t\t}, [accessorGetter])}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }, env) => {\n\tconst node = TreeNodeEnvironmentFactory.createEnvironmentForField(env, { field }).getSubTreeNode()\n\tconst resolvedDefaultValue = defaultValue !== undefined ? defaultValue : (node.field.defaultValue ?? (node.field.nullable ? null : false))\n\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={resolvedDefaultValue} />\n})\n"],"names":["Slot","Component","useFormFieldId","useField","useFormError","useFormInputValidationHandler","React","useEffect","jsx","dataAttribute","useCallback","TreeNodeEnvironmentFactory","Field"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,YAAYA,UAAAA;AASL,MAAA,eAAeC,uBAA6B,CAAC,EAAE,OAAO,cAAc,cAAc,GAAG,YAAY;AAC7G,QAAM,KAAKC,SAAAA;AACL,QAAA,WAAWC,sBAAkB,KAAK;AACxC,QAAM,QAAQ,SAAS;AACvB,QAAM,SAASC,SAAAA,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAIC,8BAAAA,8BAA8B,QAAQ;AACvE,QAAM,CAAC,aAAa,cAAc,IAAIC,iBAAM,SAAkC,IAAI;AAElFC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IACD;AACA,gBAAY,gBAAgB,UAAU;AAAA,EACpC,GAAA,CAAC,aAAa,KAAK,KAAK,CAAC;AAG3B,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,KAAK,CAAM,OAAA;AACT,YAAY,UAAU;AACvB,uBAAe,EAAE;AAAA,MAClB;AAAA,MACA,MAAK;AAAA,MACL,SAAS,SAAS,UAAU;AAAA,MAC5B,cAAY,UAAU,OAAO,kBAAmB,QAAQ,YAAY;AAAA,MACpE,gBAAcC,UAAA,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,IAAI,GAAG,EAAE;AAAA,MACT;AAAA,MACA;AAAA,MACA,UAAUC,MAAAA,YAAkD,CAAK,MAAA;AAChE,uBAAiB,EAAA,YAAY,EAAE,OAAO,OAAO;AAAA,MAAA,GAC3C,CAAC,cAAc,CAAC;AAAA,MAClB,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,GAAG,CAAC,EAAE,OAAO,cAAc,aAAA,GAAgB,QAAQ;AAC5C,QAAA,OAAOC,wCAA2B,0BAA0B,KAAK,EAAE,MAAO,CAAA,EAAE;AAC5E,QAAA,uBAAuB,iBAAiB,SAAY,eAAgB,KAAK,MAAM,iBAAiB,KAAK,MAAM,WAAW,OAAO;AAEnI,SAAQH,2BAAAA,IAAAI,aAAAA,OAAA,EAAM,OAAc,cAA4B,cAAc,qBAAsB,CAAA;AAC7F,CAAC;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormCheckbox.js","sources":["../../../../../packages/react-form/src/components/FormCheckbox.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ChangeEventHandler, ReactElement, useCallback, useEffect } from 'react'\nimport { Component, Field, OptionallyVariableFieldValue, SugaredRelativeSingleField, TreeNodeEnvironmentFactory, useField } from '@contember/react-binding'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { dataAttribute } from '@contember/utilities'\nimport { useFormInputValidationHandler } from '../hooks'\nimport { Slot } from '@radix-ui/react-slot'\n\nconst SlotInput = Slot as React.ForwardRefExoticComponent<React.RefAttributes<HTMLInputElement> & React.InputHTMLAttributes<HTMLInputElement>>\n\nexport interface FormCheckboxProps {\n\tfield: SugaredRelativeSingleField['field']\n\tisNonbearing?: boolean\n\tdefaultValue?: OptionallyVariableFieldValue\n\tchildren: ReactElement<HTMLInputElement, 'input'>\n}\n\nexport const FormCheckbox = Component<FormCheckboxProps>(({ field, isNonbearing, defaultValue, ...props }) => {\n\tconst id = useFormFieldId()\n\tconst accessor = useField<boolean>(field)\n\tconst value = accessor.value\n\tconst errors = useFormError() ?? accessor.errors?.errors ?? []\n\tconst accessorGetter = accessor.getAccessor\n\tconst { ref, onFocus, onBlur } = useFormInputValidationHandler(accessor)\n\tconst [checkboxRef, setCheckboxRef] = React.useState<HTMLInputElement | null>(null)\n\n\tuseEffect(() => {\n\t\tif (!checkboxRef) {\n\t\t\treturn\n\t\t}\n\t\tcheckboxRef.indeterminate = value === null\n\t}, [checkboxRef, ref, value])\n\n\treturn (\n\t\t<SlotInput\n\t\t\tref={it => {\n\t\t\t\t(ref as any).current = checkboxRef\n\t\t\t\tsetCheckboxRef(it)\n\t\t\t}}\n\t\t\ttype=\"checkbox\"\n\t\t\tchecked={accessor.value === true}\n\t\t\tdata-state={value === null ? 'indeterminate' : (value ? 'checked' : 'unchecked')}\n\t\t\tdata-invalid={dataAttribute(errors.length > 0)}\n\t\t\tid={`${id}-input`}\n\t\t\tonFocus={onFocus}\n\t\t\tonBlur={onBlur}\n\t\t\tonChange={useCallback<ChangeEventHandler<HTMLInputElement>>(e => {\n\t\t\t\taccessorGetter().updateValue(e.target.checked)\n\t\t\t}, [accessorGetter])}\n\t\t\t{...props}\n\t\t/>\n\t)\n}, ({ field, isNonbearing, defaultValue }, env) => {\n\tconst node = TreeNodeEnvironmentFactory.createEnvironmentForField(env, { field }).getSubTreeNode()\n\tconst resolvedDefaultValue = defaultValue !== undefined ? defaultValue : (node.field.defaultValue ?? (node.field.nullable ? null : false))\n\n\treturn <Field field={field} isNonbearing={isNonbearing} defaultValue={resolvedDefaultValue} />\n})\n"],"names":[],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AASL,MAAA,eAAe,UAA6B,CAAC,EAAE,OAAO,cAAc,cAAc,GAAG,YAAY;AAC7G,QAAM,KAAK;AACL,QAAA,WAAW,SAAkB,KAAK;AACxC,QAAM,QAAQ,SAAS;AACvB,QAAM,SAAS,aAAa,KAAK,SAAS,QAAQ,UAAU;AAC5D,QAAM,iBAAiB,SAAS;AAChC,QAAM,EAAE,KAAK,SAAS,OAAO,IAAI,8BAA8B,QAAQ;AACvE,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAkC,IAAI;AAElF,YAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IACD;AACA,gBAAY,gBAAgB,UAAU;AAAA,EACpC,GAAA,CAAC,aAAa,KAAK,KAAK,CAAC;AAG3B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,KAAK,CAAM,OAAA;AACT,YAAY,UAAU;AACvB,uBAAe,EAAE;AAAA,MAClB;AAAA,MACA,MAAK;AAAA,MACL,SAAS,SAAS,UAAU;AAAA,MAC5B,cAAY,UAAU,OAAO,kBAAmB,QAAQ,YAAY;AAAA,MACpE,gBAAc,cAAc,OAAO,SAAS,CAAC;AAAA,MAC7C,IAAI,GAAG,EAAE;AAAA,MACT;AAAA,MACA;AAAA,MACA,UAAU,YAAkD,CAAK,MAAA;AAChE,uBAAiB,EAAA,YAAY,EAAE,OAAO,OAAO;AAAA,MAAA,GAC3C,CAAC,cAAc,CAAC;AAAA,MAClB,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,GAAG,CAAC,EAAE,OAAO,cAAc,aAAA,GAAgB,QAAQ;AAC5C,QAAA,OAAO,2BAA2B,0BAA0B,KAAK,EAAE,MAAO,CAAA,EAAE;AAC5E,QAAA,uBAAuB,iBAAiB,SAAY,eAAgB,KAAK,MAAM,iBAAiB,KAAK,MAAM,WAAW,OAAO;AAEnI,SAAQ,oBAAA,OAAA,EAAM,OAAc,cAA4B,cAAc,qBAAsB,CAAA;AAC7F,CAAC;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormError.cjs","sources":["../../../../../packages/react-form/src/components/FormError.tsx"],"sourcesContent":["import { cloneElement, ReactElement, ReactNode, useMemo } from 'react'\nimport { useFormError, useFormFieldId } from '../contexts'\nimport { BindingError, ErrorAccessor } from '@contember/react-binding'\n\nexport const FormError = ({ children, formatter }: {\n\tformatter: (errors: ErrorAccessor.Error[]) => ReactNode[]\n\tchildren: ReactElement\n}) => {\n\tconst errors = useFormError()\n\tconst id = useFormFieldId()\n\tconst formatted = useMemo(() => formatter(errors ?? []), [errors, formatter])\n\tif (errors === undefined || id === undefined) {\n\t\tthrow new BindingError('FormError must be used inside a FormField')\n\t}\n\treturn formatted.map((it, index) => {\n\t\treturn cloneElement(children, {\n\t\t\tkey: index,\n\t\t\t...{ id: `${id}-error-${index}` },\n\t\t\tchildren: it,\n\t\t})\n\t})\n}\n"],"names":["useFormError","useFormFieldId","useMemo","BindingError","cloneElement"],"mappings":";;;;;AAIO,MAAM,YAAY,CAAC,EAAE,UAAU,gBAGhC;AACL,QAAM,SAASA,SAAAA;AACf,QAAM,KAAKC,SAAAA;AACL,QAAA,YAAYC,cAAQ,MAAM,UAAU,UAAU,CAAE,CAAA,GAAG,CAAC,QAAQ,SAAS,CAAC;AACxE,MAAA,WAAW,UAAa,OAAO,QAAW;AACvC,UAAA,IAAIC,aAAAA,aAAa,2CAA2C;AAAA,EACnE;AACA,SAAO,UAAU,IAAI,CAAC,IAAI,UAAU;AACnC,WAAOC,MAAAA,aAAa,UAAU;AAAA,MAC7B,KAAK;AAAA,MACL,GAAG,EAAE,IAAI,GAAG,EAAE,UAAU,KAAK,GAAG;AAAA,MAChC,UAAU;AAAA,IAAA,CACV;AAAA,EAAA,CACD;AACF;;"}