@uipath/apollo-wind 2.60.1 → 2.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/components/forms/field-actions.cjs +181 -0
  2. package/dist/components/forms/field-actions.d.ts +131 -0
  3. package/dist/components/forms/field-actions.js +129 -0
  4. package/dist/components/forms/field-control.cjs +415 -0
  5. package/dist/components/forms/field-control.d.ts +52 -0
  6. package/dist/components/forms/field-control.js +372 -0
  7. package/dist/components/forms/field-renderer.cjs +77 -420
  8. package/dist/components/forms/field-renderer.d.ts +2 -3
  9. package/dist/components/forms/field-renderer.js +78 -421
  10. package/dist/components/forms/form-designer.cjs +7 -1
  11. package/dist/components/forms/form-designer.js +7 -1
  12. package/dist/components/forms/form-schema.d.ts +121 -2
  13. package/dist/components/forms/form-strings.cjs +67 -0
  14. package/dist/components/forms/form-strings.d.ts +30 -0
  15. package/dist/components/forms/form-strings.js +30 -0
  16. package/dist/components/forms/index.cjs +53 -9
  17. package/dist/components/forms/index.d.ts +6 -1
  18. package/dist/components/forms/index.js +6 -1
  19. package/dist/components/forms/literal-value-context.cjs +37 -0
  20. package/dist/components/forms/literal-value-context.d.ts +5 -0
  21. package/dist/components/forms/literal-value-context.js +3 -0
  22. package/dist/components/forms/metadata-form.cjs +100 -21
  23. package/dist/components/forms/metadata-form.d.ts +5 -0
  24. package/dist/components/forms/metadata-form.js +101 -22
  25. package/dist/components/forms/mode-aware-field.cjs +589 -0
  26. package/dist/components/forms/mode-aware-field.d.ts +15 -0
  27. package/dist/components/forms/mode-aware-field.js +555 -0
  28. package/dist/components/forms/opaque-value.cjs +44 -0
  29. package/dist/components/forms/opaque-value.d.ts +7 -0
  30. package/dist/components/forms/opaque-value.js +7 -0
  31. package/dist/components/forms/rules-engine.cjs +13 -0
  32. package/dist/components/forms/rules-engine.js +13 -0
  33. package/dist/components/forms/schema-serializer.cjs +8 -0
  34. package/dist/components/forms/schema-serializer.js +8 -0
  35. package/dist/components/forms/string-list-field.cjs +36 -18
  36. package/dist/components/forms/string-list-field.d.ts +6 -0
  37. package/dist/components/forms/string-list-field.js +35 -20
  38. package/dist/components/forms/validation-converter.cjs +32 -2
  39. package/dist/components/forms/validation-converter.d.ts +17 -1
  40. package/dist/components/forms/validation-converter.js +30 -3
  41. package/dist/components/forms/value-modes.cjs +253 -0
  42. package/dist/components/forms/value-modes.d.ts +236 -0
  43. package/dist/components/forms/value-modes.js +180 -0
  44. package/dist/components/ui/avatar.d.ts +1 -1
  45. package/dist/components/ui/badge.d.ts +1 -1
  46. package/dist/components/ui/boolean-radio-group.cjs +114 -0
  47. package/dist/components/ui/boolean-radio-group.d.ts +24 -0
  48. package/dist/components/ui/boolean-radio-group.js +77 -0
  49. package/dist/components/ui/button.d.ts +2 -2
  50. package/dist/components/ui/command.d.ts +7 -7
  51. package/dist/components/ui/field-addons/field-menu.cjs +1 -0
  52. package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
  53. package/dist/components/ui/field-addons/field-menu.js +1 -0
  54. package/dist/components/ui/field-addons/index.cjs +4 -0
  55. package/dist/components/ui/field-addons/index.d.ts +1 -0
  56. package/dist/components/ui/field-addons/index.js +2 -1
  57. package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
  58. package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
  59. package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
  60. package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
  61. package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
  62. package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
  63. package/dist/components/ui/form-field.cjs +2 -1
  64. package/dist/components/ui/form-field.d.ts +2 -0
  65. package/dist/components/ui/form-field.js +2 -1
  66. package/dist/components/ui/index.cjs +230 -186
  67. package/dist/components/ui/index.d.ts +4 -0
  68. package/dist/components/ui/index.js +4 -0
  69. package/dist/components/ui/input-group.cjs +6 -3
  70. package/dist/components/ui/input-group.d.ts +6 -5
  71. package/dist/components/ui/input-group.js +6 -3
  72. package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
  73. package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
  74. package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
  75. package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
  76. package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
  77. package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
  78. package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
  79. package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
  80. package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
  81. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
  82. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
  83. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
  84. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
  85. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
  86. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
  87. package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
  88. package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
  89. package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
  90. package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
  91. package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
  92. package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
  93. package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
  94. package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
  95. package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
  96. package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
  97. package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
  98. package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
  99. package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
  100. package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
  101. package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
  102. package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
  103. package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
  104. package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
  105. package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
  106. package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
  107. package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
  108. package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
  109. package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
  110. package/dist/components/ui/json-tree-view/RowActions.js +86 -0
  111. package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
  112. package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
  113. package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
  114. package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
  115. package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
  116. package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
  117. package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
  118. package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
  119. package/dist/components/ui/json-tree-view/clipboard.js +29 -0
  120. package/dist/components/ui/json-tree-view/index.cjs +175 -0
  121. package/dist/components/ui/json-tree-view/index.d.ts +10 -0
  122. package/dist/components/ui/json-tree-view/index.js +11 -0
  123. package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
  124. package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
  125. package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
  126. package/dist/components/ui/json-tree-view/strings.cjs +122 -0
  127. package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
  128. package/dist/components/ui/json-tree-view/strings.js +79 -0
  129. package/dist/components/ui/prompt-value-control.cjs +70 -0
  130. package/dist/components/ui/prompt-value-control.d.ts +28 -0
  131. package/dist/components/ui/prompt-value-control.js +36 -0
  132. package/dist/components/ui/sheet.d.ts +1 -1
  133. package/dist/components/ui/spinner.d.ts +1 -1
  134. package/dist/components/ui/switch.d.ts +2 -2
  135. package/dist/components/ui/textarea.cjs +1 -1
  136. package/dist/components/ui/textarea.js +1 -1
  137. package/dist/components/ui/toggle-group.d.ts +2 -2
  138. package/dist/components/ui/toggle.d.ts +2 -2
  139. package/dist/components/ui/variable-value-control.cjs +98 -0
  140. package/dist/components/ui/variable-value-control.d.ts +35 -0
  141. package/dist/components/ui/variable-value-control.js +64 -0
  142. package/dist/index.cjs +145 -16
  143. package/dist/index.d.ts +21 -3
  144. package/dist/index.js +11 -2
  145. package/dist/lib/index.cjs +4 -1
  146. package/dist/lib/index.d.ts +1 -1
  147. package/dist/lib/index.js +2 -2
  148. package/dist/lib/utils.cjs +21 -1
  149. package/dist/lib/utils.d.ts +8 -0
  150. package/dist/lib/utils.js +18 -1
  151. package/dist/styles.css +225 -0
  152. package/package.json +1 -1
@@ -182,6 +182,14 @@ function serializeField(field) {
182
182
  if (field.ariaDescribedBy) result.ariaDescribedBy = field.ariaDescribedBy;
183
183
  if (field.tooltip) result.tooltip = field.tooltip;
184
184
  if (field.tooltipAriaLabel) result.tooltipAriaLabel = field.tooltipAriaLabel;
185
+ if (field.valueModes) result.valueModes = field.valueModes;
186
+ if (field.headerActions) result.headerActions = [
187
+ ...field.headerActions
188
+ ];
189
+ if (field.menuActions) result.menuActions = [
190
+ ...field.menuActions
191
+ ];
192
+ if (field.badge) result.badge = field.badge;
185
193
  if ('options' in field && field.options) result.options = serializeOptions(field.options);
186
194
  if ('rows' in field && field.rows) result.rows = field.rows;
187
195
  if ('min' in field && void 0 !== field.min) result.min = field.min;
@@ -153,6 +153,14 @@ function serializeField(field) {
153
153
  if (field.ariaDescribedBy) result.ariaDescribedBy = field.ariaDescribedBy;
154
154
  if (field.tooltip) result.tooltip = field.tooltip;
155
155
  if (field.tooltipAriaLabel) result.tooltipAriaLabel = field.tooltipAriaLabel;
156
+ if (field.valueModes) result.valueModes = field.valueModes;
157
+ if (field.headerActions) result.headerActions = [
158
+ ...field.headerActions
159
+ ];
160
+ if (field.menuActions) result.menuActions = [
161
+ ...field.menuActions
162
+ ];
163
+ if (field.badge) result.badge = field.badge;
156
164
  if ('options' in field && field.options) result.options = serializeOptions(field.options);
157
165
  if ('rows' in field && field.rows) result.rows = field.rows;
158
166
  if ('min' in field && void 0 !== field.min) result.min = field.min;
@@ -24,6 +24,7 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ StringListControl: ()=>StringListControl,
27
28
  formatTemplate: ()=>formatTemplate,
28
29
  StringListField: ()=>StringListField
29
30
  });
@@ -37,6 +38,35 @@ function formatTemplate(template, values) {
37
38
  return template.replace(/\{\{(\w+)\}\}/g, (match, token)=>token in values ? String(values[token]) : match);
38
39
  }
39
40
  function StringListField({ field, value, onChange, onBlur, error, disabled = false, required = false, inputRef }) {
41
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(form_field_cjs_namespaceObject.FormField, {
42
+ "data-slot": "string-list-field",
43
+ children: [
44
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldLabel, {
45
+ required: required,
46
+ tooltip: field.tooltip,
47
+ tooltipAriaLabel: field.tooltipAriaLabel,
48
+ children: field.label
49
+ }),
50
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StringListControl, {
51
+ field: field,
52
+ value: value,
53
+ onChange: onChange,
54
+ onBlur: onBlur,
55
+ invalid: !!error,
56
+ disabled: disabled,
57
+ inputRef: inputRef
58
+ }),
59
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldDescription, {
60
+ children: field.description
61
+ }),
62
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
63
+ id: `${field.name}-error`,
64
+ children: error
65
+ })
66
+ ]
67
+ });
68
+ }
69
+ function StringListControl({ field, value, onChange, onBlur, invalid = false, disabled = false, inputRef }) {
40
70
  const items = value ?? [];
41
71
  const maxItems = field.maxItems ?? 1 / 0;
42
72
  const canAdd = !disabled && items.length < maxItems;
@@ -79,15 +109,8 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
79
109
  items,
80
110
  onChange
81
111
  ]);
82
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(form_field_cjs_namespaceObject.FormField, {
83
- "data-slot": "string-list-field",
112
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
84
113
  children: [
85
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldLabel, {
86
- required: required,
87
- tooltip: field.tooltip,
88
- tooltipAriaLabel: field.tooltipAriaLabel,
89
- children: field.label
90
- }),
91
114
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
92
115
  className: "grid gap-1.5",
93
116
  children: items.map((item, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
@@ -102,9 +125,9 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
102
125
  maxLength: field.maxLength,
103
126
  disabled: disabled,
104
127
  "aria-label": `${field.label} ${index + 1}`,
105
- "aria-invalid": error ? true : void 0,
106
- "aria-describedby": error ? `${field.name}-error` : void 0,
107
- "aria-errormessage": error ? `${field.name}-error` : void 0,
128
+ "aria-invalid": invalid || void 0,
129
+ "aria-describedby": invalid ? `${field.name}-error` : void 0,
130
+ "aria-errormessage": invalid ? `${field.name}-error` : void 0,
108
131
  className: "flex-1"
109
132
  }),
110
133
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
@@ -135,20 +158,15 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
135
158
  addItemLabel
136
159
  ]
137
160
  })
138
- }),
139
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldDescription, {
140
- children: field.description
141
- }),
142
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
143
- id: `${field.name}-error`,
144
- children: error
145
161
  })
146
162
  ]
147
163
  });
148
164
  }
165
+ exports.StringListControl = __webpack_exports__.StringListControl;
149
166
  exports.StringListField = __webpack_exports__.StringListField;
150
167
  exports.formatTemplate = __webpack_exports__.formatTemplate;
151
168
  for(var __rspack_i in __webpack_exports__)if (-1 === [
169
+ "StringListControl",
152
170
  "StringListField",
153
171
  "formatTemplate"
154
172
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
@@ -27,3 +27,9 @@ export interface StringListFieldProps {
27
27
  * is handled for you — it mounts a provider for schemas that use tooltip metadata.
28
28
  */
29
29
  export declare function StringListField({ field, value, onChange, onBlur, error, disabled, required, inputRef, }: StringListFieldProps): import("react/jsx-runtime").JSX.Element;
30
+ export interface StringListControlProps extends Omit<StringListFieldProps, 'error' | 'required'> {
31
+ /** Marks every row invalid and points it at the `${field.name}-error` message. */
32
+ invalid?: boolean;
33
+ }
34
+ /** The rows and Add button of a string list, without its label, description or error. */
35
+ export declare function StringListControl({ field, value, onChange, onBlur, invalid, disabled, inputRef, }: StringListControlProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Plus, Trash2 } from "lucide-react";
3
3
  import { useCallback, useState } from "react";
4
4
  import { Button } from "../ui/button.js";
@@ -8,6 +8,35 @@ function formatTemplate(template, values) {
8
8
  return template.replace(/\{\{(\w+)\}\}/g, (match, token)=>token in values ? String(values[token]) : match);
9
9
  }
10
10
  function StringListField({ field, value, onChange, onBlur, error, disabled = false, required = false, inputRef }) {
11
+ return /*#__PURE__*/ jsxs(FormField, {
12
+ "data-slot": "string-list-field",
13
+ children: [
14
+ /*#__PURE__*/ jsx(FormFieldLabel, {
15
+ required: required,
16
+ tooltip: field.tooltip,
17
+ tooltipAriaLabel: field.tooltipAriaLabel,
18
+ children: field.label
19
+ }),
20
+ /*#__PURE__*/ jsx(StringListControl, {
21
+ field: field,
22
+ value: value,
23
+ onChange: onChange,
24
+ onBlur: onBlur,
25
+ invalid: !!error,
26
+ disabled: disabled,
27
+ inputRef: inputRef
28
+ }),
29
+ /*#__PURE__*/ jsx(FormFieldDescription, {
30
+ children: field.description
31
+ }),
32
+ /*#__PURE__*/ jsx(FormFieldError, {
33
+ id: `${field.name}-error`,
34
+ children: error
35
+ })
36
+ ]
37
+ });
38
+ }
39
+ function StringListControl({ field, value, onChange, onBlur, invalid = false, disabled = false, inputRef }) {
11
40
  const items = value ?? [];
12
41
  const maxItems = field.maxItems ?? 1 / 0;
13
42
  const canAdd = !disabled && items.length < maxItems;
@@ -50,15 +79,8 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
50
79
  items,
51
80
  onChange
52
81
  ]);
53
- return /*#__PURE__*/ jsxs(FormField, {
54
- "data-slot": "string-list-field",
82
+ return /*#__PURE__*/ jsxs(Fragment, {
55
83
  children: [
56
- /*#__PURE__*/ jsx(FormFieldLabel, {
57
- required: required,
58
- tooltip: field.tooltip,
59
- tooltipAriaLabel: field.tooltipAriaLabel,
60
- children: field.label
61
- }),
62
84
  /*#__PURE__*/ jsx("div", {
63
85
  className: "grid gap-1.5",
64
86
  children: items.map((item, index)=>/*#__PURE__*/ jsxs("div", {
@@ -73,9 +95,9 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
73
95
  maxLength: field.maxLength,
74
96
  disabled: disabled,
75
97
  "aria-label": `${field.label} ${index + 1}`,
76
- "aria-invalid": error ? true : void 0,
77
- "aria-describedby": error ? `${field.name}-error` : void 0,
78
- "aria-errormessage": error ? `${field.name}-error` : void 0,
98
+ "aria-invalid": invalid || void 0,
99
+ "aria-describedby": invalid ? `${field.name}-error` : void 0,
100
+ "aria-errormessage": invalid ? `${field.name}-error` : void 0,
79
101
  className: "flex-1"
80
102
  }),
81
103
  /*#__PURE__*/ jsx(Button, {
@@ -106,15 +128,8 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
106
128
  addItemLabel
107
129
  ]
108
130
  })
109
- }),
110
- /*#__PURE__*/ jsx(FormFieldDescription, {
111
- children: field.description
112
- }),
113
- /*#__PURE__*/ jsx(FormFieldError, {
114
- id: `${field.name}-error`,
115
- children: error
116
131
  })
117
132
  ]
118
133
  });
119
134
  }
120
- export { StringListField, formatTemplate };
135
+ export { StringListControl, StringListField, formatTemplate };
@@ -27,13 +27,15 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  mergeValidationConfigs: ()=>mergeValidationConfigs,
28
28
  buildZodSchemaFromFields: ()=>buildZodSchemaFromFields,
29
29
  isEmptyFieldValue: ()=>isEmptyFieldValue,
30
+ modeAwareSchema: ()=>modeAwareSchema,
30
31
  validationConfigToZod: ()=>validationConfigToZod
31
32
  });
32
33
  const external_zod_namespaceObject = require("zod");
34
+ const external_value_modes_cjs_namespaceObject = require("./value-modes.cjs");
33
35
  const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
34
36
  function validationConfigToZod(config, fieldType, customValueType) {
35
37
  let schema = getBaseSchemaForType(fieldType, customValueType);
36
- if (!config) return schema.optional();
38
+ if (!config) return schema.nullish();
37
39
  schema = applyStringConstraints(schema, config, fieldType, customValueType);
38
40
  schema = applyNumberConstraints(schema, config, fieldType, customValueType);
39
41
  schema = applyArrayConstraints(schema, config, fieldType, customValueType);
@@ -45,7 +47,32 @@ function validationConfigToZod(config, fieldType, customValueType) {
45
47
  if (isArrayType(fieldType, customValueType) && (null == config.minItems || config.minItems < 1)) schema = schema.min(1, requiredMessage);
46
48
  return applyCustomExpression(schema, config);
47
49
  }
48
- return applyCustomExpression(schema, config).optional();
50
+ return applyCustomExpression(schema, config).nullish();
51
+ }
52
+ function modeAwareSchema(literalSchema, { codec, context, required, requiredMessage, validators }) {
53
+ return external_zod_namespaceObject.z.any().superRefine((stored, ctx)=>{
54
+ const decoded = codec.decode(stored, context);
55
+ const empty = (0, external_value_modes_cjs_namespaceObject.isDecodedEmpty)(codec, decoded, context);
56
+ if (empty && required) return void ctx.addIssue({
57
+ code: 'custom',
58
+ message: requiredMessage || 'This field is required'
59
+ });
60
+ if (empty) return;
61
+ if ('literal' === decoded.mode) {
62
+ const result = literalSchema.safeParse(decoded.value);
63
+ if (!result.success) for (const issue of result.error.issues)ctx.addIssue({
64
+ code: 'custom',
65
+ message: issue.message,
66
+ path: issue.path
67
+ });
68
+ return;
69
+ }
70
+ const message = validators?.[decoded.mode]?.(decoded.value, context);
71
+ if (message) ctx.addIssue({
72
+ code: 'custom',
73
+ message
74
+ });
75
+ });
49
76
  }
50
77
  function applyCustomExpression(schema, config) {
51
78
  if (!config.custom) return schema;
@@ -74,6 +101,7 @@ function getBaseSchemaForType(fieldType, customValueType) {
74
101
  return external_zod_namespaceObject.z.coerce.number();
75
102
  case 'checkbox':
76
103
  case 'switch':
104
+ case 'boolean':
77
105
  return external_zod_namespaceObject.z.boolean();
78
106
  case 'select':
79
107
  case 'radio':
@@ -187,11 +215,13 @@ function mergeValidationConfigs(base, override) {
187
215
  exports.buildZodSchemaFromFields = __webpack_exports__.buildZodSchemaFromFields;
188
216
  exports.isEmptyFieldValue = __webpack_exports__.isEmptyFieldValue;
189
217
  exports.mergeValidationConfigs = __webpack_exports__.mergeValidationConfigs;
218
+ exports.modeAwareSchema = __webpack_exports__.modeAwareSchema;
190
219
  exports.validationConfigToZod = __webpack_exports__.validationConfigToZod;
191
220
  for(var __rspack_i in __webpack_exports__)if (-1 === [
192
221
  "buildZodSchemaFromFields",
193
222
  "isEmptyFieldValue",
194
223
  "mergeValidationConfigs",
224
+ "modeAwareSchema",
195
225
  "validationConfigToZod"
196
226
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
197
227
  Object.defineProperty(exports, '__esModule', {
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import type { CustomValueType, FieldType, ValidationConfig } from './form-schema';
2
+ import type { CustomValueType, FieldType, ValidationConfig, ValueModeId } from './form-schema';
3
+ import { type CodecContext, type ValueModeCodec } from './value-modes';
3
4
  export type { CustomValueType };
4
5
  /**
5
6
  * Validation Converter
@@ -27,6 +28,21 @@ export declare function validationConfigToZod(config: ValidationConfig | undefin
27
28
  * `z.any()`, where `required` and the array constraints are no-ops.
28
29
  */
29
30
  customValueType?: CustomValueType): z.ZodTypeAny;
31
+ export interface ModeAwareSchemaOptions {
32
+ codec: ValueModeCodec;
33
+ context: CodecContext;
34
+ /** Whether the value, in any mode, must be non-empty. */
35
+ required: boolean;
36
+ requiredMessage?: string;
37
+ /** Validation per mode other than `literal`, from `ValueModeDefinition.validate`. */
38
+ validators?: Partial<Record<ValueModeId, ModeValidator>>;
39
+ }
40
+ export type ModeValidator = (value: unknown, ctx: CodecContext) => string | undefined;
41
+ /**
42
+ * Validation for a field with value modes. A `literal` value is decoded and validated by the
43
+ * field type's own schema; a value in any other mode is checked for `required` and by its mode.
44
+ */
45
+ export declare function modeAwareSchema(literalSchema: z.ZodTypeAny, { codec, context, required, requiredMessage, validators }: ModeAwareSchemaOptions): z.ZodTypeAny;
30
46
  /**
31
47
  * Check if field type uses string schema
32
48
  */
@@ -1,8 +1,9 @@
1
1
  import { z } from "zod";
2
+ import { isDecodedEmpty } from "./value-modes.js";
2
3
  import { RulesEngine } from "./rules-engine.js";
3
4
  function validationConfigToZod(config, fieldType, customValueType) {
4
5
  let schema = getBaseSchemaForType(fieldType, customValueType);
5
- if (!config) return schema.optional();
6
+ if (!config) return schema.nullish();
6
7
  schema = applyStringConstraints(schema, config, fieldType, customValueType);
7
8
  schema = applyNumberConstraints(schema, config, fieldType, customValueType);
8
9
  schema = applyArrayConstraints(schema, config, fieldType, customValueType);
@@ -14,7 +15,32 @@ function validationConfigToZod(config, fieldType, customValueType) {
14
15
  if (isArrayType(fieldType, customValueType) && (null == config.minItems || config.minItems < 1)) schema = schema.min(1, requiredMessage);
15
16
  return applyCustomExpression(schema, config);
16
17
  }
17
- return applyCustomExpression(schema, config).optional();
18
+ return applyCustomExpression(schema, config).nullish();
19
+ }
20
+ function modeAwareSchema(literalSchema, { codec, context, required, requiredMessage, validators }) {
21
+ return z.any().superRefine((stored, ctx)=>{
22
+ const decoded = codec.decode(stored, context);
23
+ const empty = isDecodedEmpty(codec, decoded, context);
24
+ if (empty && required) return void ctx.addIssue({
25
+ code: 'custom',
26
+ message: requiredMessage || 'This field is required'
27
+ });
28
+ if (empty) return;
29
+ if ('literal' === decoded.mode) {
30
+ const result = literalSchema.safeParse(decoded.value);
31
+ if (!result.success) for (const issue of result.error.issues)ctx.addIssue({
32
+ code: 'custom',
33
+ message: issue.message,
34
+ path: issue.path
35
+ });
36
+ return;
37
+ }
38
+ const message = validators?.[decoded.mode]?.(decoded.value, context);
39
+ if (message) ctx.addIssue({
40
+ code: 'custom',
41
+ message
42
+ });
43
+ });
18
44
  }
19
45
  function applyCustomExpression(schema, config) {
20
46
  if (!config.custom) return schema;
@@ -43,6 +69,7 @@ function getBaseSchemaForType(fieldType, customValueType) {
43
69
  return z.coerce.number();
44
70
  case 'checkbox':
45
71
  case 'switch':
72
+ case 'boolean':
46
73
  return z.boolean();
47
74
  case 'select':
48
75
  case 'radio':
@@ -153,4 +180,4 @@ function mergeValidationConfigs(base, override) {
153
180
  }
154
181
  };
155
182
  }
156
- export { buildZodSchemaFromFields, isEmptyFieldValue, mergeValidationConfigs, validationConfigToZod };
183
+ export { buildZodSchemaFromFields, isEmptyFieldValue, mergeValidationConfigs, modeAwareSchema, validationConfigToZod };
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ resolveModeOptions: ()=>resolveModeOptions,
28
+ isValueModeEnvelope: ()=>isValueModeEnvelope,
29
+ codecContext: ()=>codecContext,
30
+ literalValueOf: ()=>literalValueOf,
31
+ convertValue: ()=>convertValue,
32
+ isDecodedEmpty: ()=>isDecodedEmpty,
33
+ DEFAULT_VALUE_MODE_REGISTRY: ()=>DEFAULT_VALUE_MODE_REGISTRY,
34
+ buildValueModeRegistry: ()=>buildValueModeRegistry,
35
+ VALUE_MODE_OPAQUE: ()=>external_opaque_value_cjs_namespaceObject.VALUE_MODE_OPAQUE,
36
+ isFieldControlRegistration: ()=>isFieldControlRegistration,
37
+ envelopeCodec: ()=>envelopeCodec,
38
+ isEmptyModeValue: ()=>isEmptyModeValue,
39
+ literalValues: ()=>literalValues,
40
+ resolveCodec: ()=>resolveCodec
41
+ });
42
+ const built_in_value_modes_cjs_namespaceObject = require("../ui/field-addons/built-in-value-modes.cjs");
43
+ const index_cjs_namespaceObject = require("../../lib/index.cjs");
44
+ const external_opaque_value_cjs_namespaceObject = require("./opaque-value.cjs");
45
+ const external_validation_converter_cjs_namespaceObject = require("./validation-converter.cjs");
46
+ function isValueModeEnvelope(value) {
47
+ return 'object' == typeof value && null !== value && !Array.isArray(value) && 'string' == typeof value.$mode;
48
+ }
49
+ const envelopeCodec = {
50
+ decode (stored) {
51
+ if (isValueModeEnvelope(stored)) return {
52
+ mode: stored.$mode,
53
+ value: stored.value
54
+ };
55
+ return {
56
+ mode: 'literal',
57
+ value: stored
58
+ };
59
+ },
60
+ encode (mode, inner) {
61
+ return isCleared(inner) ? {
62
+ $mode: mode
63
+ } : {
64
+ $mode: mode,
65
+ value: inner
66
+ };
67
+ },
68
+ isEmpty (decoded) {
69
+ return (0, external_validation_converter_cjs_namespaceObject.isEmptyFieldValue)(decoded.value) || Number.isNaN(decoded.value);
70
+ }
71
+ };
72
+ function isCleared(value) {
73
+ return null == value || '' === value || Number.isNaN(value) || Array.isArray(value) && 0 === value.length;
74
+ }
75
+ function isDecodedEmpty(codec, decoded, ctx) {
76
+ return decoded.empty ?? codec.isEmpty?.(decoded, ctx) ?? (0, external_validation_converter_cjs_namespaceObject.isEmptyFieldValue)(decoded.value);
77
+ }
78
+ function convertValue(codec, from, to, ctx) {
79
+ const empty = isDecodedEmpty(codec, from, ctx);
80
+ const result = codec.convert?.({
81
+ ...from,
82
+ empty
83
+ }, to, ctx);
84
+ if (empty) return {
85
+ kind: 'ok',
86
+ value: result?.value
87
+ };
88
+ return result ?? {
89
+ kind: 'lossy',
90
+ value: void 0
91
+ };
92
+ }
93
+ function codecContext(field, config) {
94
+ return {
95
+ field,
96
+ fieldType: field.type,
97
+ valueType: 'custom' === field.type ? field.valueType : void 0,
98
+ expectedType: expectedType(field, config),
99
+ config
100
+ };
101
+ }
102
+ function isFieldControlRegistration(entry) {
103
+ return 'object' == typeof entry && null !== entry && 'component' in entry;
104
+ }
105
+ const DEFAULT_VALUE_MODE_REGISTRY = Object.freeze({
106
+ codecs: Object.freeze({}),
107
+ definitions: Object.freeze({}),
108
+ controlRegistry: Object.freeze({}),
109
+ literalControls: Object.freeze({})
110
+ });
111
+ function buildValueModeRegistry(plugins) {
112
+ const registry = {
113
+ codecs: {},
114
+ definitions: {},
115
+ controlRegistry: {},
116
+ literalControls: {}
117
+ };
118
+ for (const { valueModes } of plugins)if (valueModes) {
119
+ Object.assign(registry.codecs, valueModes.codecs);
120
+ for (const [id, definition] of Object.entries(valueModes.definitions ?? {}))registry.definitions[id] = {
121
+ ...registry.definitions[id],
122
+ ...definition
123
+ };
124
+ Object.assign(registry.controlRegistry, valueModes.controlRegistry);
125
+ Object.assign(registry.literalControls, valueModes.literalControls);
126
+ }
127
+ return registry;
128
+ }
129
+ function resolveCodec(codecs, config) {
130
+ return codecs[config.codec ?? 'default'] ?? envelopeCodec;
131
+ }
132
+ function expectedType(field, config) {
133
+ if (config?.expectedType) return config.expectedType;
134
+ if ('number' === field.type) return 'number';
135
+ if ('switch' === field.type || 'checkbox' === field.type || 'boolean' === field.type) return 'boolean';
136
+ if ('custom' === field.type) return field.valueType;
137
+ }
138
+ function resolveModeOptions(field, config, registry, strings = {}) {
139
+ const builtIns = (0, built_in_value_modes_cjs_namespaceObject.builtInValueModes)(strings, {
140
+ expectedType: expectedType(field, config)
141
+ });
142
+ const options = [];
143
+ for (const id of config.modes){
144
+ const definition = registry.definitions[id];
145
+ const label = config.labels?.[id];
146
+ const base = (0, built_in_value_modes_cjs_namespaceObject.isBuiltInValueMode)(id) ? builtIns[id] : {};
147
+ const title = 'function' == typeof definition?.title ? definition.title({
148
+ field
149
+ }) : definition?.title;
150
+ const option = {
151
+ ...base,
152
+ id,
153
+ ...void 0 !== title && {
154
+ title
155
+ },
156
+ ...definition?.description !== void 0 && {
157
+ description: definition.description
158
+ },
159
+ ...definition?.icon && {
160
+ icon: definition.icon
161
+ }
162
+ };
163
+ if (option.title && option.icon) options.push({
164
+ ...option,
165
+ title: label?.title ?? option.title,
166
+ icon: option.icon,
167
+ description: label?.description ?? option.description
168
+ });
169
+ }
170
+ return options;
171
+ }
172
+ function isEmptyModeValue(stored, field, codecs = {}) {
173
+ if (!field.valueModes) return (0, external_validation_converter_cjs_namespaceObject.isEmptyFieldValue)(stored);
174
+ const codec = resolveCodec(codecs, field.valueModes);
175
+ const ctx = codecContext(field, field.valueModes);
176
+ return isDecodedEmpty(codec, codec.decode(stored, ctx), ctx);
177
+ }
178
+ function literalValues(values, schema, codecs = {}) {
179
+ let result = values;
180
+ for (const field of modeFields(schema)){
181
+ const stored = (0, index_cjs_namespaceObject.get)(values, field.name);
182
+ const read = readLiteral(stored, field, codecs);
183
+ if (read !== stored) result = withPath(result, field.name.split('.'), read);
184
+ }
185
+ return result;
186
+ }
187
+ function literalValueOf(name, stored, schema, codecs = {}) {
188
+ const field = modeFields(schema).find((candidate)=>candidate.name === name);
189
+ return field ? readLiteral(stored, field, codecs) : stored;
190
+ }
191
+ function readLiteral(stored, field, codecs) {
192
+ const config = field.valueModes;
193
+ const codec = resolveCodec(codecs, config);
194
+ const ctx = codecContext(field, config);
195
+ const decoded = codec.decode(stored, ctx);
196
+ if (isDecodedEmpty(codec, decoded, ctx)) return;
197
+ return 'literal' === decoded.mode ? decoded.value : external_opaque_value_cjs_namespaceObject.VALUE_MODE_OPAQUE;
198
+ }
199
+ const modeFieldsCache = new WeakMap();
200
+ function modeFields(schema) {
201
+ let fields = modeFieldsCache.get(schema);
202
+ if (!fields) {
203
+ const sections = schema.steps?.flatMap((step)=>step.sections) ?? schema.sections ?? [];
204
+ fields = sections.flatMap((section)=>section.fields).filter((field)=>field.valueModes);
205
+ modeFieldsCache.set(schema, fields);
206
+ }
207
+ return fields;
208
+ }
209
+ function withPath(target, path, value) {
210
+ const [key, ...rest] = path;
211
+ if (void 0 === key) return target;
212
+ const container = 'object' == typeof target && null !== target ? target : {};
213
+ const copy = Array.isArray(container) ? [
214
+ ...container
215
+ ] : {
216
+ ...container
217
+ };
218
+ copy[key] = rest.length ? withPath(copy[key], rest, value) : value;
219
+ return copy;
220
+ }
221
+ exports.DEFAULT_VALUE_MODE_REGISTRY = __webpack_exports__.DEFAULT_VALUE_MODE_REGISTRY;
222
+ exports.VALUE_MODE_OPAQUE = __webpack_exports__.VALUE_MODE_OPAQUE;
223
+ exports.buildValueModeRegistry = __webpack_exports__.buildValueModeRegistry;
224
+ exports.codecContext = __webpack_exports__.codecContext;
225
+ exports.convertValue = __webpack_exports__.convertValue;
226
+ exports.envelopeCodec = __webpack_exports__.envelopeCodec;
227
+ exports.isDecodedEmpty = __webpack_exports__.isDecodedEmpty;
228
+ exports.isEmptyModeValue = __webpack_exports__.isEmptyModeValue;
229
+ exports.isFieldControlRegistration = __webpack_exports__.isFieldControlRegistration;
230
+ exports.isValueModeEnvelope = __webpack_exports__.isValueModeEnvelope;
231
+ exports.literalValueOf = __webpack_exports__.literalValueOf;
232
+ exports.literalValues = __webpack_exports__.literalValues;
233
+ exports.resolveCodec = __webpack_exports__.resolveCodec;
234
+ exports.resolveModeOptions = __webpack_exports__.resolveModeOptions;
235
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
236
+ "DEFAULT_VALUE_MODE_REGISTRY",
237
+ "VALUE_MODE_OPAQUE",
238
+ "buildValueModeRegistry",
239
+ "codecContext",
240
+ "convertValue",
241
+ "envelopeCodec",
242
+ "isDecodedEmpty",
243
+ "isEmptyModeValue",
244
+ "isFieldControlRegistration",
245
+ "isValueModeEnvelope",
246
+ "literalValueOf",
247
+ "literalValues",
248
+ "resolveCodec",
249
+ "resolveModeOptions"
250
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
251
+ Object.defineProperty(exports, '__esModule', {
252
+ value: true
253
+ });