@uipath/apollo-wind 2.60.0 → 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.
- package/README.md +13 -0
- package/dist/components/forms/field-actions.cjs +181 -0
- package/dist/components/forms/field-actions.d.ts +131 -0
- package/dist/components/forms/field-actions.js +129 -0
- package/dist/components/forms/field-control.cjs +415 -0
- package/dist/components/forms/field-control.d.ts +52 -0
- package/dist/components/forms/field-control.js +372 -0
- package/dist/components/forms/field-renderer.cjs +77 -420
- package/dist/components/forms/field-renderer.d.ts +2 -3
- package/dist/components/forms/field-renderer.js +78 -421
- package/dist/components/forms/form-designer.cjs +7 -1
- package/dist/components/forms/form-designer.js +7 -1
- package/dist/components/forms/form-schema.d.ts +121 -2
- package/dist/components/forms/form-strings.cjs +67 -0
- package/dist/components/forms/form-strings.d.ts +30 -0
- package/dist/components/forms/form-strings.js +30 -0
- package/dist/components/forms/index.cjs +53 -9
- package/dist/components/forms/index.d.ts +6 -1
- package/dist/components/forms/index.js +6 -1
- package/dist/components/forms/literal-value-context.cjs +37 -0
- package/dist/components/forms/literal-value-context.d.ts +5 -0
- package/dist/components/forms/literal-value-context.js +3 -0
- package/dist/components/forms/metadata-form.cjs +100 -21
- package/dist/components/forms/metadata-form.d.ts +5 -0
- package/dist/components/forms/metadata-form.js +101 -22
- package/dist/components/forms/mode-aware-field.cjs +589 -0
- package/dist/components/forms/mode-aware-field.d.ts +15 -0
- package/dist/components/forms/mode-aware-field.js +555 -0
- package/dist/components/forms/opaque-value.cjs +44 -0
- package/dist/components/forms/opaque-value.d.ts +7 -0
- package/dist/components/forms/opaque-value.js +7 -0
- package/dist/components/forms/rules-engine.cjs +13 -0
- package/dist/components/forms/rules-engine.js +13 -0
- package/dist/components/forms/schema-serializer.cjs +8 -0
- package/dist/components/forms/schema-serializer.js +8 -0
- package/dist/components/forms/string-list-field.cjs +36 -18
- package/dist/components/forms/string-list-field.d.ts +6 -0
- package/dist/components/forms/string-list-field.js +35 -20
- package/dist/components/forms/validation-converter.cjs +32 -2
- package/dist/components/forms/validation-converter.d.ts +17 -1
- package/dist/components/forms/validation-converter.js +30 -3
- package/dist/components/forms/value-modes.cjs +253 -0
- package/dist/components/forms/value-modes.d.ts +236 -0
- package/dist/components/forms/value-modes.js +180 -0
- package/dist/components/ui/accordion.cjs +1 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/avatar.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/boolean-radio-group.cjs +114 -0
- package/dist/components/ui/boolean-radio-group.d.ts +24 -0
- package/dist/components/ui/boolean-radio-group.js +77 -0
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts +7 -7
- package/dist/components/ui/dialog.cjs +1 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/drawer.cjs +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/field-addons/field-menu.cjs +1 -0
- package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
- package/dist/components/ui/field-addons/field-menu.js +1 -0
- package/dist/components/ui/field-addons/index.cjs +4 -0
- package/dist/components/ui/field-addons/index.d.ts +1 -0
- package/dist/components/ui/field-addons/index.js +2 -1
- package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
- package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
- package/dist/components/ui/form-field.cjs +2 -1
- package/dist/components/ui/form-field.d.ts +2 -0
- package/dist/components/ui/form-field.js +2 -1
- package/dist/components/ui/index.cjs +235 -191
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +4 -0
- package/dist/components/ui/input-group.cjs +6 -3
- package/dist/components/ui/input-group.d.ts +6 -5
- package/dist/components/ui/input-group.js +6 -3
- package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
- package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
- package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
- package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
- package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
- package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
- package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
- package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
- package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
- package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
- package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
- package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
- package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
- package/dist/components/ui/json-tree-view/RowActions.js +86 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
- package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
- package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
- package/dist/components/ui/json-tree-view/clipboard.js +29 -0
- package/dist/components/ui/json-tree-view/index.cjs +175 -0
- package/dist/components/ui/json-tree-view/index.d.ts +10 -0
- package/dist/components/ui/json-tree-view/index.js +11 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
- package/dist/components/ui/json-tree-view/strings.cjs +122 -0
- package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
- package/dist/components/ui/json-tree-view/strings.js +79 -0
- package/dist/components/ui/prompt-value-control.cjs +70 -0
- package/dist/components/ui/prompt-value-control.d.ts +28 -0
- package/dist/components/ui/prompt-value-control.js +36 -0
- package/dist/components/ui/sheet.cjs +2 -2
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/spinner.d.ts +1 -1
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/textarea.cjs +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/components/ui/variable-value-control.cjs +98 -0
- package/dist/components/ui/variable-value-control.d.ts +35 -0
- package/dist/components/ui/variable-value-control.js +64 -0
- package/dist/index.cjs +145 -16
- package/dist/index.d.ts +21 -3
- package/dist/index.js +11 -2
- package/dist/lib/index.cjs +4 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/utils.cjs +21 -1
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +18 -1
- package/dist/styles.css +278 -0
- package/dist/tailwind.css +72 -0
- package/package.json +1 -1
|
@@ -0,0 +1,589 @@
|
|
|
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
|
+
ModeAwareField: ()=>ModeAwareField
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
32
|
+
const badge_cjs_namespaceObject = require("../ui/badge.cjs");
|
|
33
|
+
const field_menu_cjs_namespaceObject = require("../ui/field-addons/field-menu.cjs");
|
|
34
|
+
const value_mode_indicator_cjs_namespaceObject = require("../ui/field-addons/value-mode-indicator.cjs");
|
|
35
|
+
const value_mode_switch_dialog_cjs_namespaceObject = require("../ui/field-addons/value-mode-switch-dialog.cjs");
|
|
36
|
+
const form_field_cjs_namespaceObject = require("../ui/form-field.cjs");
|
|
37
|
+
const input_cjs_namespaceObject = require("../ui/input.cjs");
|
|
38
|
+
const input_group_cjs_namespaceObject = require("../ui/input-group.cjs");
|
|
39
|
+
const prompt_value_control_cjs_namespaceObject = require("../ui/prompt-value-control.cjs");
|
|
40
|
+
const variable_value_control_cjs_namespaceObject = require("../ui/variable-value-control.cjs");
|
|
41
|
+
const external_field_actions_cjs_namespaceObject = require("./field-actions.cjs");
|
|
42
|
+
const external_field_control_cjs_namespaceObject = require("./field-control.cjs");
|
|
43
|
+
const external_form_strings_cjs_namespaceObject = require("./form-strings.cjs");
|
|
44
|
+
const external_validation_converter_cjs_namespaceObject = require("./validation-converter.cjs");
|
|
45
|
+
const external_value_modes_cjs_namespaceObject = require("./value-modes.cjs");
|
|
46
|
+
function ModeAwareField(props) {
|
|
47
|
+
const { control } = (0, external_react_hook_form_namespaceObject.useFormContext)();
|
|
48
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.Controller, {
|
|
49
|
+
name: props.field.name,
|
|
50
|
+
control: control,
|
|
51
|
+
defaultValue: props.field.defaultValue,
|
|
52
|
+
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FieldAnatomy, {
|
|
53
|
+
...props,
|
|
54
|
+
formField: formField,
|
|
55
|
+
error: error?.message
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const BUILT_IN_MODE_CONTROLS = {
|
|
60
|
+
variable: {
|
|
61
|
+
component: variable_value_control_cjs_namespaceObject.VariableValueControl
|
|
62
|
+
},
|
|
63
|
+
prompt: {
|
|
64
|
+
component: prompt_value_control_cjs_namespaceObject.PromptValueControl,
|
|
65
|
+
layout: 'grow',
|
|
66
|
+
variant: 'agent',
|
|
67
|
+
insertable: true
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function unfittedGeometry(field) {
|
|
71
|
+
const labelledBy = [
|
|
72
|
+
'radio',
|
|
73
|
+
'slider',
|
|
74
|
+
'datetime',
|
|
75
|
+
'string-list'
|
|
76
|
+
].includes(field.type);
|
|
77
|
+
return {
|
|
78
|
+
layout: 'row',
|
|
79
|
+
variant: 'outline',
|
|
80
|
+
labelTarget: labelledBy ? 'labelledby' : 'control',
|
|
81
|
+
insertable: false
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function registrationGeometry(registration) {
|
|
85
|
+
return {
|
|
86
|
+
layout: registration.layout ?? 'row',
|
|
87
|
+
variant: registration.variant ?? 'default',
|
|
88
|
+
labelTarget: registration.labelTarget ?? 'control',
|
|
89
|
+
insertable: registration.insertable ?? false
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const TEXT_GEOMETRY = {
|
|
93
|
+
layout: 'row',
|
|
94
|
+
variant: 'default',
|
|
95
|
+
labelTarget: 'control',
|
|
96
|
+
insertable: true
|
|
97
|
+
};
|
|
98
|
+
function FieldAnatomy({ field, context, customComponents, disabled, required, options, formField, error }) {
|
|
99
|
+
const form = (0, external_react_hook_form_namespaceObject.useFormContext)();
|
|
100
|
+
const registry = context.valueModes ?? external_value_modes_cjs_namespaceObject.DEFAULT_VALUE_MODE_REGISTRY;
|
|
101
|
+
const actionRegistry = context.fieldActions ?? external_field_actions_cjs_namespaceObject.DEFAULT_FIELD_ACTION_REGISTRY;
|
|
102
|
+
const strings = context.strings ?? external_form_strings_cjs_namespaceObject.DEFAULT_METADATA_FORM_STRINGS;
|
|
103
|
+
const config = field.valueModes;
|
|
104
|
+
const { name } = field;
|
|
105
|
+
const errorId = `${name}-error`;
|
|
106
|
+
const labelId = `${name}-label`;
|
|
107
|
+
const formVariables = context.variables;
|
|
108
|
+
const variables = (0, external_react_namespaceObject.useCallback)(()=>(0, external_field_actions_cjs_namespaceObject.resolveVariables)(formVariables, field), [
|
|
109
|
+
formVariables,
|
|
110
|
+
field
|
|
111
|
+
]);
|
|
112
|
+
const { value } = formField;
|
|
113
|
+
const codec = config ? (0, external_value_modes_cjs_namespaceObject.resolveCodec)(registry.codecs, config) : void 0;
|
|
114
|
+
const codecCtx = (0, external_react_namespaceObject.useMemo)(()=>config && (0, external_value_modes_cjs_namespaceObject.codecContext)(field, config), [
|
|
115
|
+
field,
|
|
116
|
+
config
|
|
117
|
+
]);
|
|
118
|
+
const decoded = codec && codecCtx ? codec.decode(value, codecCtx) : void 0;
|
|
119
|
+
const empty = codec && codecCtx && decoded ? (0, external_value_modes_cjs_namespaceObject.isDecodedEmpty)(codec, decoded, codecCtx) : (0, external_validation_converter_cjs_namespaceObject.isEmptyFieldValue)(value);
|
|
120
|
+
const [held, setHeld] = (0, external_react_namespaceObject.useState)();
|
|
121
|
+
const heldMode = held && empty && Object.is(held.stored, value) ? held.mode : void 0;
|
|
122
|
+
const activeMode = config && decoded ? activeModeOf(config, decoded.mode, empty && (0, external_validation_converter_cjs_namespaceObject.isEmptyFieldValue)(value), heldMode) : 'literal';
|
|
123
|
+
const inner = decoded ? decoded.mode === activeMode ? decoded.value : void 0 : value;
|
|
124
|
+
const [pending, setPending] = (0, external_react_namespaceObject.useState)();
|
|
125
|
+
const groupRef = (0, external_react_namespaceObject.useRef)(null);
|
|
126
|
+
const controlRef = (0, external_react_namespaceObject.useRef)(null);
|
|
127
|
+
const latest = (0, external_react_namespaceObject.useRef)({
|
|
128
|
+
value,
|
|
129
|
+
inner,
|
|
130
|
+
empty,
|
|
131
|
+
activeMode,
|
|
132
|
+
decoded,
|
|
133
|
+
disabled,
|
|
134
|
+
formField,
|
|
135
|
+
insertable: false
|
|
136
|
+
});
|
|
137
|
+
latest.current = {
|
|
138
|
+
...latest.current,
|
|
139
|
+
value,
|
|
140
|
+
inner,
|
|
141
|
+
empty,
|
|
142
|
+
activeMode,
|
|
143
|
+
decoded,
|
|
144
|
+
disabled,
|
|
145
|
+
formField
|
|
146
|
+
};
|
|
147
|
+
const encode = (mode, value)=>codec && codecCtx ? codec.encode(mode, value, codecCtx, latest.current.value) : value;
|
|
148
|
+
const write = (next, via)=>{
|
|
149
|
+
if ('change' === via) latest.current.formField.onChange(next);
|
|
150
|
+
else {
|
|
151
|
+
const liveMode = 'onChange' === context.schema.mode || 'all' === context.schema.mode;
|
|
152
|
+
form.setValue(name, next, {
|
|
153
|
+
shouldDirty: true,
|
|
154
|
+
shouldValidate: liveMode || form.formState.isSubmitted
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return next;
|
|
158
|
+
};
|
|
159
|
+
const commit = (mode, value, via)=>{
|
|
160
|
+
const stored = write(value, via);
|
|
161
|
+
if (codec && codecCtx) {
|
|
162
|
+
const written = codec.decode(stored, codecCtx);
|
|
163
|
+
setHeld((0, external_value_modes_cjs_namespaceObject.isDecodedEmpty)(codec, written, codecCtx) ? {
|
|
164
|
+
mode,
|
|
165
|
+
stored
|
|
166
|
+
} : void 0);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const writeInner = (next, via = 'change')=>{
|
|
170
|
+
const mode = latest.current.activeMode;
|
|
171
|
+
if (config) commit(mode, encode(mode, next), via);
|
|
172
|
+
else write(next, via);
|
|
173
|
+
};
|
|
174
|
+
const setModeValue = (mode, value, options)=>{
|
|
175
|
+
if (options?.confirm && !latest.current.empty) setPending({
|
|
176
|
+
...options.confirm,
|
|
177
|
+
to: mode,
|
|
178
|
+
value
|
|
179
|
+
});
|
|
180
|
+
else commit(mode, encode(mode, value), 'set');
|
|
181
|
+
};
|
|
182
|
+
const handleSelect = (to)=>{
|
|
183
|
+
const current = latest.current;
|
|
184
|
+
if (!codec || !codecCtx || !current.decoded || to === current.activeMode) return;
|
|
185
|
+
const result = (0, external_value_modes_cjs_namespaceObject.convertValue)(codec, {
|
|
186
|
+
...current.decoded,
|
|
187
|
+
mode: current.activeMode
|
|
188
|
+
}, to, codecCtx);
|
|
189
|
+
if ('ok' === result.kind) commit(to, encode(to, result.value), 'set');
|
|
190
|
+
else setPending({
|
|
191
|
+
to,
|
|
192
|
+
value: result.value,
|
|
193
|
+
title: result.title,
|
|
194
|
+
description: result.description
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
const writeInnerRef = (0, external_react_namespaceObject.useRef)(writeInner);
|
|
198
|
+
writeInnerRef.current = writeInner;
|
|
199
|
+
const domHandle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
200
|
+
focus: ()=>controlElement(groupRef.current, name)?.focus(),
|
|
201
|
+
insertText: (text)=>{
|
|
202
|
+
const element = controlElement(groupRef.current, name);
|
|
203
|
+
if (!(element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)) {
|
|
204
|
+
const current = latest.current.inner;
|
|
205
|
+
writeInnerRef.current(`${'string' == typeof current ? current : ''}${text}`, 'set');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const selectable = null !== element.selectionStart;
|
|
209
|
+
const start = element.selectionStart ?? element.value.length;
|
|
210
|
+
const end = element.selectionEnd ?? start;
|
|
211
|
+
writeInnerRef.current(element.value.slice(0, start) + text + element.value.slice(end), 'set');
|
|
212
|
+
const caret = start + text.length;
|
|
213
|
+
setTimeout(()=>{
|
|
214
|
+
element.focus();
|
|
215
|
+
if (selectable) element.setSelectionRange(caret, caret);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}), [
|
|
219
|
+
name
|
|
220
|
+
]);
|
|
221
|
+
const ctx = useActionContext({
|
|
222
|
+
field,
|
|
223
|
+
name,
|
|
224
|
+
form,
|
|
225
|
+
modeAware: !!config,
|
|
226
|
+
latest,
|
|
227
|
+
strings,
|
|
228
|
+
variables,
|
|
229
|
+
control: ()=>{
|
|
230
|
+
const own = controlRef.current;
|
|
231
|
+
if (!own) return domHandle;
|
|
232
|
+
return own.insertText ? own : {
|
|
233
|
+
...own,
|
|
234
|
+
insertText: domHandle.insertText
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
commit,
|
|
238
|
+
write,
|
|
239
|
+
encode,
|
|
240
|
+
setModeValue,
|
|
241
|
+
codec,
|
|
242
|
+
codecCtx
|
|
243
|
+
});
|
|
244
|
+
const binding = {
|
|
245
|
+
value: controlValue(field, inner),
|
|
246
|
+
onChange: (next)=>writeInner(next),
|
|
247
|
+
onBlur: formField.onBlur,
|
|
248
|
+
name: formField.name,
|
|
249
|
+
ref: formField.ref
|
|
250
|
+
};
|
|
251
|
+
const resolved = resolveControl({
|
|
252
|
+
field,
|
|
253
|
+
config,
|
|
254
|
+
mode: activeMode,
|
|
255
|
+
registry,
|
|
256
|
+
strings,
|
|
257
|
+
customComponents,
|
|
258
|
+
binding,
|
|
259
|
+
controlRef,
|
|
260
|
+
labelId,
|
|
261
|
+
options,
|
|
262
|
+
disabled,
|
|
263
|
+
required,
|
|
264
|
+
error,
|
|
265
|
+
errorId,
|
|
266
|
+
valueModeProps: ()=>({
|
|
267
|
+
value: inner,
|
|
268
|
+
onChange: (next)=>writeInner(next),
|
|
269
|
+
onBlur: formField.onBlur,
|
|
270
|
+
name,
|
|
271
|
+
field,
|
|
272
|
+
disabled,
|
|
273
|
+
required,
|
|
274
|
+
error,
|
|
275
|
+
mode: activeMode,
|
|
276
|
+
onModeValueChange: setModeValue,
|
|
277
|
+
requestModeSwitch: handleSelect,
|
|
278
|
+
controlRef,
|
|
279
|
+
inputRef: formField.ref,
|
|
280
|
+
id: name,
|
|
281
|
+
labelId,
|
|
282
|
+
invalid: !!error,
|
|
283
|
+
placeholder: field.placeholder,
|
|
284
|
+
variables,
|
|
285
|
+
strings: strings.valueModes,
|
|
286
|
+
controlProps: {
|
|
287
|
+
'data-slot': 'input-group-control',
|
|
288
|
+
'aria-invalid': error ? true : void 0,
|
|
289
|
+
'aria-describedby': error ? errorId : void 0,
|
|
290
|
+
'aria-errormessage': error ? errorId : void 0
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
latest.current.insertable = resolved.geometry.insertable;
|
|
295
|
+
const { header, menu } = (0, external_field_actions_cjs_namespaceObject.resolveFieldActions)(field, actionRegistry);
|
|
296
|
+
const modeOptions = config ? (0, external_value_modes_cjs_namespaceObject.resolveModeOptions)(field, config, registry, strings.valueModes) : [];
|
|
297
|
+
const switchable = !!config && (config.switchable ?? config.modes.length > 1);
|
|
298
|
+
const menuItems = menu.map((action)=>({
|
|
299
|
+
id: action.id,
|
|
300
|
+
label: 'function' == typeof action.label ? action.label(ctx) : action.label,
|
|
301
|
+
icon: action.icon,
|
|
302
|
+
destructive: action.destructive,
|
|
303
|
+
disabled: action.disabled?.(ctx) ?? false,
|
|
304
|
+
onSelect: ()=>action.onSelect(ctx)
|
|
305
|
+
}));
|
|
306
|
+
const indicator = config && false !== config.indicator && 'literal' !== activeMode ? registry.definitions[activeMode]?.indicator ?? ('expression' === activeMode ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(value_mode_indicator_cjs_namespaceObject.ValueModeIndicator, {
|
|
307
|
+
mode: "expression",
|
|
308
|
+
disabled: disabled,
|
|
309
|
+
strings: strings.valueModes
|
|
310
|
+
}) : null) : null;
|
|
311
|
+
const headerActions = header.map((action)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {
|
|
312
|
+
children: action.render(ctx)
|
|
313
|
+
}, action.id));
|
|
314
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(form_field_cjs_namespaceObject.FormField, {
|
|
315
|
+
children: [
|
|
316
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldHeader, {
|
|
317
|
+
label: field.label,
|
|
318
|
+
labelId: labelId,
|
|
319
|
+
htmlFor: 'control' === resolved.geometry.labelTarget ? name : void 0,
|
|
320
|
+
required: required,
|
|
321
|
+
tooltip: field.tooltip,
|
|
322
|
+
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
323
|
+
badge: field.badge ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(badge_cjs_namespaceObject.Badge, {
|
|
324
|
+
variant: "secondary",
|
|
325
|
+
children: field.badge
|
|
326
|
+
}) : void 0,
|
|
327
|
+
actions: headerActions.length > 0 ? headerActions : void 0
|
|
328
|
+
}),
|
|
329
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(input_group_cjs_namespaceObject.InputGroup, {
|
|
330
|
+
ref: groupRef,
|
|
331
|
+
layout: resolved.geometry.layout,
|
|
332
|
+
variant: resolved.geometry.variant,
|
|
333
|
+
disabled: disabled,
|
|
334
|
+
error: error,
|
|
335
|
+
errorId: errorId,
|
|
336
|
+
"data-value-mode-control": 'production' === process.env.NODE_ENV ? void 0 : resolved.source,
|
|
337
|
+
children: [
|
|
338
|
+
indicator && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
339
|
+
align: "inline-start",
|
|
340
|
+
children: indicator
|
|
341
|
+
}),
|
|
342
|
+
resolved.node,
|
|
343
|
+
(switchable || menuItems.length > 0) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_group_cjs_namespaceObject.InputGroupAddon, {
|
|
344
|
+
align: "inline-end",
|
|
345
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(field_menu_cjs_namespaceObject.FieldMenu, {
|
|
346
|
+
mode: activeMode,
|
|
347
|
+
onSelect: handleSelect,
|
|
348
|
+
modes: modeOptions,
|
|
349
|
+
actions: menuItems,
|
|
350
|
+
modesDisabled: !switchable,
|
|
351
|
+
disabled: disabled,
|
|
352
|
+
strings: strings.valueModes
|
|
353
|
+
})
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
}),
|
|
357
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldDescription, {
|
|
358
|
+
children: field.description
|
|
359
|
+
}),
|
|
360
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(value_mode_switch_dialog_cjs_namespaceObject.ValueModeSwitchDialog, {
|
|
361
|
+
open: !!pending,
|
|
362
|
+
title: pending?.title,
|
|
363
|
+
description: pending?.description,
|
|
364
|
+
confirmLabel: pending?.confirmLabel,
|
|
365
|
+
strings: strings.valueModes,
|
|
366
|
+
onCancel: ()=>setPending(void 0),
|
|
367
|
+
onConfirm: ()=>{
|
|
368
|
+
if (pending && !latest.current.disabled) commit(pending.to, encode(pending.to, pending.value), 'set');
|
|
369
|
+
setPending(void 0);
|
|
370
|
+
}
|
|
371
|
+
})
|
|
372
|
+
]
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function controlValue(field, value) {
|
|
376
|
+
if (null != value) return value;
|
|
377
|
+
switch(field.type){
|
|
378
|
+
case 'text':
|
|
379
|
+
case 'email':
|
|
380
|
+
case 'textarea':
|
|
381
|
+
case 'number':
|
|
382
|
+
case 'select':
|
|
383
|
+
case 'radio':
|
|
384
|
+
return '';
|
|
385
|
+
case 'multiselect':
|
|
386
|
+
case 'string-list':
|
|
387
|
+
return [];
|
|
388
|
+
default:
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function activeModeOf(config, decodedMode, unset, heldMode) {
|
|
393
|
+
if (heldMode) return heldMode;
|
|
394
|
+
if (unset) return config.defaultMode ?? config.modes[0] ?? 'literal';
|
|
395
|
+
return decodedMode;
|
|
396
|
+
}
|
|
397
|
+
function controlElement(group, id) {
|
|
398
|
+
if (!group) return null;
|
|
399
|
+
for (const element of group.querySelectorAll('[id]'))if (element.id === id) return element;
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
function useActionContext(input) {
|
|
403
|
+
const inputRef = (0, external_react_namespaceObject.useRef)(input);
|
|
404
|
+
inputRef.current = input;
|
|
405
|
+
const { field, name, form, modeAware } = input;
|
|
406
|
+
return (0, external_react_namespaceObject.useMemo)(()=>{
|
|
407
|
+
const current = ()=>inputRef.current;
|
|
408
|
+
const setStored = (stored)=>{
|
|
409
|
+
const { codec, codecCtx, commit, write } = current();
|
|
410
|
+
if (codec && codecCtx) commit(codec.decode(stored, codecCtx).mode, stored, 'set');
|
|
411
|
+
else write(stored, 'set');
|
|
412
|
+
};
|
|
413
|
+
const ctx = {
|
|
414
|
+
field,
|
|
415
|
+
name,
|
|
416
|
+
form,
|
|
417
|
+
get value () {
|
|
418
|
+
return current().latest.current.value;
|
|
419
|
+
},
|
|
420
|
+
setValue: setStored,
|
|
421
|
+
clear: ()=>{
|
|
422
|
+
const { latest, encode, commit, write } = current();
|
|
423
|
+
const mode = latest.current.activeMode;
|
|
424
|
+
if (modeAware) commit(mode, encode(mode, null), 'set');
|
|
425
|
+
else write(null, 'set');
|
|
426
|
+
},
|
|
427
|
+
get empty () {
|
|
428
|
+
return current().latest.current.empty;
|
|
429
|
+
},
|
|
430
|
+
get disabled () {
|
|
431
|
+
return current().latest.current.disabled;
|
|
432
|
+
},
|
|
433
|
+
get strings () {
|
|
434
|
+
return current().strings;
|
|
435
|
+
},
|
|
436
|
+
get control () {
|
|
437
|
+
return current().control();
|
|
438
|
+
},
|
|
439
|
+
get insertable () {
|
|
440
|
+
return current().latest.current.insertable;
|
|
441
|
+
},
|
|
442
|
+
variables: ()=>current().variables()
|
|
443
|
+
};
|
|
444
|
+
if (modeAware) {
|
|
445
|
+
Object.defineProperty(ctx, 'mode', {
|
|
446
|
+
enumerable: true,
|
|
447
|
+
get: ()=>{
|
|
448
|
+
const { decoded, activeMode } = current().latest.current;
|
|
449
|
+
return decoded && {
|
|
450
|
+
...decoded,
|
|
451
|
+
mode: activeMode
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
ctx.setModeValue = (mode, value, options)=>current().setModeValue(mode, value, options);
|
|
456
|
+
}
|
|
457
|
+
return ctx;
|
|
458
|
+
}, [
|
|
459
|
+
field,
|
|
460
|
+
name,
|
|
461
|
+
form,
|
|
462
|
+
modeAware
|
|
463
|
+
]);
|
|
464
|
+
}
|
|
465
|
+
function resolveControl(input) {
|
|
466
|
+
const { field, config, mode, registry } = input;
|
|
467
|
+
const named = config?.controls?.[mode];
|
|
468
|
+
let registration;
|
|
469
|
+
let source;
|
|
470
|
+
let componentProps;
|
|
471
|
+
if (named) {
|
|
472
|
+
const controlName = 'string' == typeof named ? named : named.component;
|
|
473
|
+
registration = registry.controlRegistry[controlName];
|
|
474
|
+
source = 'field';
|
|
475
|
+
componentProps = 'string' == typeof named ? void 0 : named.componentProps;
|
|
476
|
+
}
|
|
477
|
+
if (!registration && 'literal' === mode && registry.literalControls[field.type]) {
|
|
478
|
+
registration = registry.literalControls[field.type];
|
|
479
|
+
source = 'literal-controls';
|
|
480
|
+
}
|
|
481
|
+
if (!registration && registry.definitions[mode]?.control) {
|
|
482
|
+
registration = registry.definitions[mode]?.control;
|
|
483
|
+
source = 'definition';
|
|
484
|
+
}
|
|
485
|
+
if (registration && source) {
|
|
486
|
+
const Control = registration.component;
|
|
487
|
+
return {
|
|
488
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Control, {
|
|
489
|
+
...componentProps,
|
|
490
|
+
...input.valueModeProps()
|
|
491
|
+
}),
|
|
492
|
+
geometry: registrationGeometry(registration),
|
|
493
|
+
source
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
if ('literal' === mode) return builtInLiteral(input);
|
|
497
|
+
const builtIn = BUILT_IN_MODE_CONTROLS[mode];
|
|
498
|
+
if (builtIn) {
|
|
499
|
+
const Control = builtIn.component;
|
|
500
|
+
return {
|
|
501
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Control, {
|
|
502
|
+
...input.valueModeProps()
|
|
503
|
+
}),
|
|
504
|
+
geometry: registrationGeometry(builtIn),
|
|
505
|
+
source: 'built-in'
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
if ('expression' === mode) return {
|
|
509
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FallbackControl, {
|
|
510
|
+
...input
|
|
511
|
+
}),
|
|
512
|
+
geometry: TEXT_GEOMETRY,
|
|
513
|
+
source: 'built-in'
|
|
514
|
+
};
|
|
515
|
+
return {
|
|
516
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FallbackControl, {
|
|
517
|
+
...input
|
|
518
|
+
}),
|
|
519
|
+
geometry: TEXT_GEOMETRY,
|
|
520
|
+
source: 'fallback'
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function FallbackControl({ field, binding, disabled, error, errorId }) {
|
|
524
|
+
const { value } = binding;
|
|
525
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
|
|
526
|
+
id: field.name,
|
|
527
|
+
name: binding.name,
|
|
528
|
+
ref: binding.ref,
|
|
529
|
+
value: 'string' == typeof value ? value : null == value ? '' : String(value),
|
|
530
|
+
onChange: (event)=>binding.onChange(event.target.value),
|
|
531
|
+
onBlur: binding.onBlur,
|
|
532
|
+
placeholder: field.placeholder,
|
|
533
|
+
disabled: disabled,
|
|
534
|
+
"aria-invalid": error ? true : void 0,
|
|
535
|
+
"aria-describedby": error ? errorId : void 0,
|
|
536
|
+
"aria-errormessage": error ? errorId : void 0
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
function builtInLiteral(input) {
|
|
540
|
+
const { field, binding, options, disabled, required, error, strings, customComponents } = input;
|
|
541
|
+
if ('custom' === field.type) {
|
|
542
|
+
const entry = customComponents[field.component];
|
|
543
|
+
if (!entry) return {
|
|
544
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FallbackControl, {
|
|
545
|
+
...input
|
|
546
|
+
}),
|
|
547
|
+
geometry: TEXT_GEOMETRY,
|
|
548
|
+
source: 'fallback'
|
|
549
|
+
};
|
|
550
|
+
const registration = (0, external_value_modes_cjs_namespaceObject.isFieldControlRegistration)(entry) ? entry : {
|
|
551
|
+
component: entry
|
|
552
|
+
};
|
|
553
|
+
const Component = registration.component;
|
|
554
|
+
const { ref: _ref, ...bindingProps } = binding;
|
|
555
|
+
return {
|
|
556
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Component, {
|
|
557
|
+
...bindingProps,
|
|
558
|
+
...field.componentProps,
|
|
559
|
+
field: field,
|
|
560
|
+
disabled: disabled,
|
|
561
|
+
required: required,
|
|
562
|
+
error: error,
|
|
563
|
+
controlRef: input.controlRef,
|
|
564
|
+
labelId: input.labelId
|
|
565
|
+
}),
|
|
566
|
+
geometry: registrationGeometry(registration),
|
|
567
|
+
source: 'custom'
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
node: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_field_control_cjs_namespaceObject.FieldControl, {
|
|
572
|
+
field: field,
|
|
573
|
+
formField: binding,
|
|
574
|
+
options: options,
|
|
575
|
+
disabled: disabled,
|
|
576
|
+
invalid: !!error,
|
|
577
|
+
strings: strings.boolean
|
|
578
|
+
}),
|
|
579
|
+
geometry: external_field_control_cjs_namespaceObject.FIELD_CONTROL_GEOMETRY[field.type] ?? unfittedGeometry(field),
|
|
580
|
+
source: 'field-type'
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
exports.ModeAwareField = __webpack_exports__.ModeAwareField;
|
|
584
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
585
|
+
"ModeAwareField"
|
|
586
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
587
|
+
Object.defineProperty(exports, '__esModule', {
|
|
588
|
+
value: true
|
|
589
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CustomComponents, FieldMetadata, FieldOption, FormContext } from './form-schema';
|
|
2
|
+
export interface ModeAwareFieldProps {
|
|
3
|
+
field: FieldMetadata;
|
|
4
|
+
context: FormContext;
|
|
5
|
+
customComponents: CustomComponents;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
required: boolean;
|
|
8
|
+
options: FieldOption[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Renders a field with `valueModes`, `headerActions`, `menuActions` or `badge` as the field anatomy:
|
|
12
|
+
* header with its actions, then an `InputGroup` holding the mode glyph, the active mode's control
|
|
13
|
+
* and the trailing menu of modes and actions.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ModeAwareField(props: ModeAwareFieldProps): import("react/jsx-runtime").JSX.Element;
|