@uipath/apollo-wind 2.60.1 → 2.62.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 (154) 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/checkbox.cjs +10 -5
  51. package/dist/components/ui/checkbox.js +12 -7
  52. package/dist/components/ui/command.d.ts +7 -7
  53. package/dist/components/ui/field-addons/field-menu.cjs +1 -0
  54. package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
  55. package/dist/components/ui/field-addons/field-menu.js +1 -0
  56. package/dist/components/ui/field-addons/index.cjs +4 -0
  57. package/dist/components/ui/field-addons/index.d.ts +1 -0
  58. package/dist/components/ui/field-addons/index.js +2 -1
  59. package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
  60. package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
  61. package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
  62. package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
  63. package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
  64. package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
  65. package/dist/components/ui/form-field.cjs +2 -1
  66. package/dist/components/ui/form-field.d.ts +2 -0
  67. package/dist/components/ui/form-field.js +2 -1
  68. package/dist/components/ui/index.cjs +237 -193
  69. package/dist/components/ui/index.d.ts +4 -0
  70. package/dist/components/ui/index.js +4 -0
  71. package/dist/components/ui/input-group.cjs +6 -3
  72. package/dist/components/ui/input-group.d.ts +6 -5
  73. package/dist/components/ui/input-group.js +6 -3
  74. package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
  75. package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
  76. package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
  77. package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
  78. package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
  79. package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
  80. package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
  81. package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
  82. package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
  83. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
  84. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
  85. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
  86. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
  87. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
  88. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
  89. package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
  90. package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
  91. package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
  92. package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
  93. package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
  94. package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
  95. package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
  96. package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
  97. package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
  98. package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
  99. package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
  100. package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
  101. package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
  102. package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
  103. package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
  104. package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
  105. package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
  106. package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
  107. package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
  108. package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
  109. package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
  110. package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
  111. package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
  112. package/dist/components/ui/json-tree-view/RowActions.js +86 -0
  113. package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
  114. package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
  115. package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
  116. package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
  117. package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
  118. package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
  119. package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
  120. package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
  121. package/dist/components/ui/json-tree-view/clipboard.js +29 -0
  122. package/dist/components/ui/json-tree-view/index.cjs +175 -0
  123. package/dist/components/ui/json-tree-view/index.d.ts +10 -0
  124. package/dist/components/ui/json-tree-view/index.js +11 -0
  125. package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
  126. package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
  127. package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
  128. package/dist/components/ui/json-tree-view/strings.cjs +122 -0
  129. package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
  130. package/dist/components/ui/json-tree-view/strings.js +79 -0
  131. package/dist/components/ui/prompt-value-control.cjs +70 -0
  132. package/dist/components/ui/prompt-value-control.d.ts +28 -0
  133. package/dist/components/ui/prompt-value-control.js +36 -0
  134. package/dist/components/ui/sheet.d.ts +1 -1
  135. package/dist/components/ui/spinner.d.ts +1 -1
  136. package/dist/components/ui/switch.d.ts +2 -2
  137. package/dist/components/ui/textarea.cjs +1 -1
  138. package/dist/components/ui/textarea.js +1 -1
  139. package/dist/components/ui/toggle-group.d.ts +2 -2
  140. package/dist/components/ui/toggle.d.ts +2 -2
  141. package/dist/components/ui/variable-value-control.cjs +98 -0
  142. package/dist/components/ui/variable-value-control.d.ts +35 -0
  143. package/dist/components/ui/variable-value-control.js +64 -0
  144. package/dist/index.cjs +145 -16
  145. package/dist/index.d.ts +21 -3
  146. package/dist/index.js +11 -2
  147. package/dist/lib/index.cjs +4 -1
  148. package/dist/lib/index.d.ts +1 -1
  149. package/dist/lib/index.js +2 -2
  150. package/dist/lib/utils.cjs +21 -1
  151. package/dist/lib/utils.d.ts +8 -0
  152. package/dist/lib/utils.js +18 -1
  153. package/dist/styles.css +279 -0
  154. package/package.json +1 -1
@@ -0,0 +1,236 @@
1
+ import type { LucideIcon } from 'lucide-react';
2
+ import type * as React from 'react';
3
+ import { type ValueModeOption } from '../ui/field-addons/built-in-value-modes';
4
+ import type { ValueModeStrings } from '../ui/field-addons/value-mode-strings';
5
+ import type { InputGroupLayout, InputGroupProps } from '../ui/input-group';
6
+ import type { VariablePickerItem } from '../ui/variable-picker';
7
+ import type { FieldControlLabelTarget } from './field-control';
8
+ import type { CustomFieldComponentProps, CustomValueType, FieldMetadata, FieldType, FormPlugin, FormSchema, ValueModeId, ValueModesConfig } from './form-schema';
9
+ /** A stored value split into its mode and the value written in that mode. */
10
+ export interface DecodedValue {
11
+ mode: ValueModeId;
12
+ /** For `literal`, the value in its field type's own shape, which that type's validation runs on. */
13
+ value: unknown;
14
+ /** Set by a codec that knows; otherwise `isEmpty` decides. */
15
+ empty?: boolean;
16
+ }
17
+ export interface CodecContext {
18
+ field: FieldMetadata;
19
+ /** The field's type, whose control edits `literal` values. */
20
+ fieldType: FieldType;
21
+ valueType?: CustomValueType;
22
+ /** The value's type as a mode describes it: `valueModes.expectedType`, else the field type's. */
23
+ expectedType?: string;
24
+ config: ValueModesConfig;
25
+ }
26
+ /**
27
+ * A switch's outcome, `value` being the value in the new mode, which the form encodes. `ok` writes
28
+ * it straight away; `lossy` asks first, with the codec's own wording when it gives one.
29
+ */
30
+ export type ConvertResult = {
31
+ kind: 'ok';
32
+ value: unknown;
33
+ } | {
34
+ kind: 'lossy';
35
+ value: unknown;
36
+ title?: string;
37
+ description?: string;
38
+ };
39
+ /**
40
+ * How a field's stored value carries its mode. Validating a value in a mode belongs to the mode:
41
+ * see `ValueModeDefinition.validate`.
42
+ */
43
+ export interface ValueModeCodec {
44
+ /**
45
+ * The active mode and the value in it. Only the active mode's: a shape that keeps other modes'
46
+ * data alongside gets it back as `encode`'s `previous`.
47
+ */
48
+ decode(stored: unknown, ctx: CodecContext): DecodedValue;
49
+ /**
50
+ * The stored value for `inner` in `mode`. `previous` is the value stored until now, so a shape
51
+ * holding more than the active mode's value (another mode's draft, a flag) can carry it over.
52
+ * Never `undefined`: react-hook-form reads it as unset and shows the field's default instead, so
53
+ * an empty value is `null` or a shape of the codec's own. `inner` is `null` or `undefined` when
54
+ * the value is cleared.
55
+ */
56
+ encode(mode: ValueModeId, inner: unknown, ctx: CodecContext, previous?: unknown): unknown;
57
+ /**
58
+ * The value in `to` for a switch from `from`. Called for an empty value too, with `from.empty`
59
+ * set, so a switch can seed a value; an empty value never asks, whatever `kind` says. Without
60
+ * it, an empty value switches to nothing and a non-empty one clears, lossily.
61
+ */
62
+ convert?(from: DecodedValue, to: ValueModeId, ctx: CodecContext): ConvertResult;
63
+ /** Drives `required` and Clear. Defaults to the form's usual notion of empty. */
64
+ isEmpty?(decoded: DecodedValue, ctx: CodecContext): boolean;
65
+ }
66
+ /** How the default codec stores a value, in every mode. A cleared value has no `value`. */
67
+ export interface ValueModeEnvelope {
68
+ $mode: ValueModeId;
69
+ value?: unknown;
70
+ }
71
+ export declare function isValueModeEnvelope(value: unknown): value is ValueModeEnvelope;
72
+ /**
73
+ * The default codec. Every mode is stored as `{ $mode, value }`; a cleared value keeps its
74
+ * envelope without `value`, so its mode survives. A raw value reads as `literal`, so data written
75
+ * before the field had value modes still loads; its first write wraps it. `$mode` rather than
76
+ * `mode`, so an object value that has a `mode` of its own is not misread.
77
+ */
78
+ export declare const envelopeCodec: ValueModeCodec;
79
+ export declare function isDecodedEmpty(codec: ValueModeCodec, decoded: DecodedValue, ctx: CodecContext): boolean;
80
+ /**
81
+ * Switches `from` to `to`, returning the value in `to`: an empty value never asks, and a codec
82
+ * without `convert` clears a non-empty one, lossily.
83
+ */
84
+ export declare function convertValue(codec: ValueModeCodec, from: DecodedValue, to: ValueModeId, ctx: CodecContext): ConvertResult;
85
+ export declare function codecContext(field: FieldMetadata, config: ValueModesConfig): CodecContext;
86
+ export interface ValueModeControlHandle {
87
+ focus(): void;
88
+ /**
89
+ * Inserts at the caret. Needed by a control registered as `insertable` that has no text input
90
+ * of its own for the form to insert into, such as a code editor.
91
+ */
92
+ insertText?(text: string): void;
93
+ }
94
+ /**
95
+ * Props of a registered value-mode control. A superset of `CustomFieldComponentProps`, so an
96
+ * existing custom component can be registered as a control unchanged. In the field anatomy both
97
+ * get the value in the active mode (a custom field's fixed value), never the stored shape.
98
+ */
99
+ export interface ValueModeControlProps extends CustomFieldComponentProps {
100
+ mode: ValueModeId;
101
+ /** The value in `mode`, not the stored shape. */
102
+ value: unknown;
103
+ onChange: (inner: unknown) => void;
104
+ /** Writes a value in another mode without asking, as pasting an expression does. */
105
+ onModeValueChange: (mode: ValueModeId, inner: unknown) => void;
106
+ /** Switches mode the way the menu does, asking first if the value would be lost. */
107
+ requestModeSwitch: (mode: ValueModeId) => void;
108
+ controlRef?: React.Ref<ValueModeControlHandle>;
109
+ inputRef?: React.Ref<unknown>;
110
+ /** The id the field's label points at, when the registration's `labelTarget` is `control`. */
111
+ id: string;
112
+ /** The label's id, for `aria-labelledby` on a control no label can point at. */
113
+ labelId: string;
114
+ invalid: boolean;
115
+ placeholder?: string;
116
+ /** The form's variables for this field, resolved when called; never call it during render. */
117
+ variables: () => VariablePickerItem[];
118
+ /** The form's value-mode strings. */
119
+ strings: ValueModeStrings;
120
+ /** Spread on the element that takes focus, so the group's focus ring and error wiring find it. */
121
+ controlProps: {
122
+ 'data-slot': 'input-group-control';
123
+ 'aria-invalid'?: true;
124
+ 'aria-describedby'?: string;
125
+ 'aria-errormessage'?: string;
126
+ };
127
+ }
128
+ export type InputGroupVariant = NonNullable<InputGroupProps['variant']>;
129
+ /** A component with its geometry inside the field anatomy. */
130
+ export interface FieldControlRegistration<P> {
131
+ component: React.ComponentType<P>;
132
+ /** Defaults to `row`. */
133
+ layout?: InputGroupLayout;
134
+ /** Defaults to `default`. */
135
+ variant?: InputGroupVariant;
136
+ /**
137
+ * How the label reaches the control: `control` points it at the element with `id`;
138
+ * `labelledby` leaves the control to name itself with `aria-labelledby={labelId}`, as a code
139
+ * editor or a radio group must. Defaults to `control`.
140
+ */
141
+ labelTarget?: FieldControlLabelTarget;
142
+ /**
143
+ * Whether Insert variable writes at the caret. The control's `controlRef` handle does it, or,
144
+ * without one, the text input carrying `id`; with neither the reference is appended.
145
+ */
146
+ insertable?: boolean;
147
+ }
148
+ export declare function isFieldControlRegistration<P>(entry: React.ComponentType<P> | FieldControlRegistration<P>): entry is FieldControlRegistration<P>;
149
+ /** A value control with its geometry, for value modes. */
150
+ export type ValueModeControlRegistration = FieldControlRegistration<ValueModeControlProps>;
151
+ /**
152
+ * A mode apollo-wind does not ship, or changes to a built-in one. For a built-in id every member is
153
+ * optional and merges over the built-in, whose localized title and description stay unless given.
154
+ * A mode of the host's own needs `icon` and `title`.
155
+ */
156
+ export interface ValueModeDefinition {
157
+ icon?: LucideIcon;
158
+ title?: string | ((ctx: {
159
+ field: FieldMetadata;
160
+ }) => string);
161
+ description?: string;
162
+ /** The glyph ahead of the value in this mode. */
163
+ indicator?: React.ReactNode;
164
+ /** The control for this mode on every field. A field's own `valueModes.controls[mode]` wins. */
165
+ control?: ValueModeControlRegistration;
166
+ /**
167
+ * Validates a non-empty value in this mode, such as an expression's syntax. Never called for
168
+ * `literal`, which its field type validates.
169
+ */
170
+ validate?(value: unknown, ctx: CodecContext): string | undefined;
171
+ }
172
+ /**
173
+ * Form-wide value-mode behavior.
174
+ *
175
+ * A field's control for its active mode is the first of:
176
+ * 1. the field's `valueModes.controls[mode]`, a name in `controlRegistry`;
177
+ * 2. for `literal`, `literalControls[fieldType]`, since a fixed value is edited per field type;
178
+ * 3. `definitions[mode].control`;
179
+ * 4. the built-in: the field type's own control for `literal`, a plain Input for `expression`,
180
+ * `VariableValueControl` for `variable` and `PromptValueControl` for `prompt`;
181
+ * 5. for a host mode with none of these, a plain Input, with a warning.
182
+ *
183
+ * Only a field schema refers to controls by name, since it has to stay JSON; the plugin's own
184
+ * settings hold the registration itself.
185
+ *
186
+ * @example
187
+ * const code = { component: CodeControl, layout: 'fill', insertable: true };
188
+ * valueModes: {
189
+ * // Every expression edits in the code control…
190
+ * definitions: { expression: { control: code } },
191
+ * // …every fixed textarea value in a rich-text one…
192
+ * literalControls: { textarea: { component: RichTextControl, layout: 'grow', insertable: true } },
193
+ * // …and a field can ask for the code control by name: `controls: { literal: 'code' }`.
194
+ * controlRegistry: { code },
195
+ * }
196
+ */
197
+ export interface ValueModesPluginConfig {
198
+ /** Codecs by name; `default` replaces the envelope codec form-wide. */
199
+ codecs?: Record<string, ValueModeCodec>;
200
+ /** Mode definitions by mode id: a host mode, or changes to a built-in one. */
201
+ definitions?: Partial<Record<ValueModeId, ValueModeDefinition>>;
202
+ /**
203
+ * Controls a field schema can name in `valueModes.controls`. A name is any string of the host's
204
+ * choosing; it is not a mode id or a field type.
205
+ */
206
+ controlRegistry?: Record<string, ValueModeControlRegistration>;
207
+ /**
208
+ * The `literal` control per field type, for those with fixed values the host edits in its own
209
+ * control rather than the default one for that field type.
210
+ */
211
+ literalControls?: Partial<Record<FieldType, ValueModeControlRegistration>>;
212
+ }
213
+ /** Every plugin's `valueModes`, merged with later plugins winning. */
214
+ export interface ValueModeRegistry {
215
+ codecs: Record<string, ValueModeCodec>;
216
+ definitions: Partial<Record<ValueModeId, ValueModeDefinition>>;
217
+ controlRegistry: Record<string, ValueModeControlRegistration>;
218
+ literalControls: Partial<Record<FieldType, ValueModeControlRegistration>>;
219
+ }
220
+ /** The registry of a form whose plugins configure no value modes. Frozen, as it is shared. */
221
+ export declare const DEFAULT_VALUE_MODE_REGISTRY: Readonly<ValueModeRegistry>;
222
+ export declare function buildValueModeRegistry(plugins: readonly FormPlugin[]): ValueModeRegistry;
223
+ export declare function resolveCodec(codecs: Record<string, ValueModeCodec>, config: ValueModesConfig): ValueModeCodec;
224
+ /** The menu entries for a field's modes, in its order. Ids with no definition are left out. */
225
+ export declare function resolveModeOptions(field: FieldMetadata, config: ValueModesConfig, registry: ValueModeRegistry, strings?: Partial<ValueModeStrings>): ValueModeOption<string>[];
226
+ /** Whether a stored value is empty, decoding it first for a field with value modes. */
227
+ export declare function isEmptyModeValue(stored: unknown, field: FieldMetadata, codecs?: Record<string, ValueModeCodec>): boolean;
228
+ export { VALUE_MODE_OPAQUE } from './opaque-value';
229
+ /**
230
+ * Form values as rules, conditions and data sources read them. A field with value modes reads as
231
+ * its `literal` value; a value in another mode as `VALUE_MODE_OPAQUE`, and an empty one as
232
+ * `undefined`. Fields without value modes read as stored.
233
+ */
234
+ export declare function literalValues(values: Record<string, unknown>, schema: FormSchema, codecs?: Record<string, ValueModeCodec>): Record<string, unknown>;
235
+ /** One field's value as `literalValues` reads it: `stored` as it is for a field without modes. */
236
+ export declare function literalValueOf(name: string, stored: unknown, schema: FormSchema, codecs?: Record<string, ValueModeCodec>): unknown;
@@ -0,0 +1,180 @@
1
+ import { builtInValueModes, isBuiltInValueMode } from "../ui/field-addons/built-in-value-modes.js";
2
+ import { get } from "../../lib/index.js";
3
+ import { VALUE_MODE_OPAQUE } from "./opaque-value.js";
4
+ import { isEmptyFieldValue } from "./validation-converter.js";
5
+ function isValueModeEnvelope(value) {
6
+ return 'object' == typeof value && null !== value && !Array.isArray(value) && 'string' == typeof value.$mode;
7
+ }
8
+ const envelopeCodec = {
9
+ decode (stored) {
10
+ if (isValueModeEnvelope(stored)) return {
11
+ mode: stored.$mode,
12
+ value: stored.value
13
+ };
14
+ return {
15
+ mode: 'literal',
16
+ value: stored
17
+ };
18
+ },
19
+ encode (mode, inner) {
20
+ return isCleared(inner) ? {
21
+ $mode: mode
22
+ } : {
23
+ $mode: mode,
24
+ value: inner
25
+ };
26
+ },
27
+ isEmpty (decoded) {
28
+ return isEmptyFieldValue(decoded.value) || Number.isNaN(decoded.value);
29
+ }
30
+ };
31
+ function isCleared(value) {
32
+ return null == value || '' === value || Number.isNaN(value) || Array.isArray(value) && 0 === value.length;
33
+ }
34
+ function isDecodedEmpty(codec, decoded, ctx) {
35
+ return decoded.empty ?? codec.isEmpty?.(decoded, ctx) ?? isEmptyFieldValue(decoded.value);
36
+ }
37
+ function convertValue(codec, from, to, ctx) {
38
+ const empty = isDecodedEmpty(codec, from, ctx);
39
+ const result = codec.convert?.({
40
+ ...from,
41
+ empty
42
+ }, to, ctx);
43
+ if (empty) return {
44
+ kind: 'ok',
45
+ value: result?.value
46
+ };
47
+ return result ?? {
48
+ kind: 'lossy',
49
+ value: void 0
50
+ };
51
+ }
52
+ function codecContext(field, config) {
53
+ return {
54
+ field,
55
+ fieldType: field.type,
56
+ valueType: 'custom' === field.type ? field.valueType : void 0,
57
+ expectedType: expectedType(field, config),
58
+ config
59
+ };
60
+ }
61
+ function isFieldControlRegistration(entry) {
62
+ return 'object' == typeof entry && null !== entry && 'component' in entry;
63
+ }
64
+ const DEFAULT_VALUE_MODE_REGISTRY = Object.freeze({
65
+ codecs: Object.freeze({}),
66
+ definitions: Object.freeze({}),
67
+ controlRegistry: Object.freeze({}),
68
+ literalControls: Object.freeze({})
69
+ });
70
+ function buildValueModeRegistry(plugins) {
71
+ const registry = {
72
+ codecs: {},
73
+ definitions: {},
74
+ controlRegistry: {},
75
+ literalControls: {}
76
+ };
77
+ for (const { valueModes } of plugins)if (valueModes) {
78
+ Object.assign(registry.codecs, valueModes.codecs);
79
+ for (const [id, definition] of Object.entries(valueModes.definitions ?? {}))registry.definitions[id] = {
80
+ ...registry.definitions[id],
81
+ ...definition
82
+ };
83
+ Object.assign(registry.controlRegistry, valueModes.controlRegistry);
84
+ Object.assign(registry.literalControls, valueModes.literalControls);
85
+ }
86
+ return registry;
87
+ }
88
+ function resolveCodec(codecs, config) {
89
+ return codecs[config.codec ?? 'default'] ?? envelopeCodec;
90
+ }
91
+ function expectedType(field, config) {
92
+ if (config?.expectedType) return config.expectedType;
93
+ if ('number' === field.type) return 'number';
94
+ if ('switch' === field.type || 'checkbox' === field.type || 'boolean' === field.type) return 'boolean';
95
+ if ('custom' === field.type) return field.valueType;
96
+ }
97
+ function resolveModeOptions(field, config, registry, strings = {}) {
98
+ const builtIns = builtInValueModes(strings, {
99
+ expectedType: expectedType(field, config)
100
+ });
101
+ const options = [];
102
+ for (const id of config.modes){
103
+ const definition = registry.definitions[id];
104
+ const label = config.labels?.[id];
105
+ const base = isBuiltInValueMode(id) ? builtIns[id] : {};
106
+ const title = 'function' == typeof definition?.title ? definition.title({
107
+ field
108
+ }) : definition?.title;
109
+ const option = {
110
+ ...base,
111
+ id,
112
+ ...void 0 !== title && {
113
+ title
114
+ },
115
+ ...definition?.description !== void 0 && {
116
+ description: definition.description
117
+ },
118
+ ...definition?.icon && {
119
+ icon: definition.icon
120
+ }
121
+ };
122
+ if (option.title && option.icon) options.push({
123
+ ...option,
124
+ title: label?.title ?? option.title,
125
+ icon: option.icon,
126
+ description: label?.description ?? option.description
127
+ });
128
+ }
129
+ return options;
130
+ }
131
+ function isEmptyModeValue(stored, field, codecs = {}) {
132
+ if (!field.valueModes) return isEmptyFieldValue(stored);
133
+ const codec = resolveCodec(codecs, field.valueModes);
134
+ const ctx = codecContext(field, field.valueModes);
135
+ return isDecodedEmpty(codec, codec.decode(stored, ctx), ctx);
136
+ }
137
+ function literalValues(values, schema, codecs = {}) {
138
+ let result = values;
139
+ for (const field of modeFields(schema)){
140
+ const stored = get(values, field.name);
141
+ const read = readLiteral(stored, field, codecs);
142
+ if (read !== stored) result = withPath(result, field.name.split('.'), read);
143
+ }
144
+ return result;
145
+ }
146
+ function literalValueOf(name, stored, schema, codecs = {}) {
147
+ const field = modeFields(schema).find((candidate)=>candidate.name === name);
148
+ return field ? readLiteral(stored, field, codecs) : stored;
149
+ }
150
+ function readLiteral(stored, field, codecs) {
151
+ const config = field.valueModes;
152
+ const codec = resolveCodec(codecs, config);
153
+ const ctx = codecContext(field, config);
154
+ const decoded = codec.decode(stored, ctx);
155
+ if (isDecodedEmpty(codec, decoded, ctx)) return;
156
+ return 'literal' === decoded.mode ? decoded.value : VALUE_MODE_OPAQUE;
157
+ }
158
+ const modeFieldsCache = new WeakMap();
159
+ function modeFields(schema) {
160
+ let fields = modeFieldsCache.get(schema);
161
+ if (!fields) {
162
+ const sections = schema.steps?.flatMap((step)=>step.sections) ?? schema.sections ?? [];
163
+ fields = sections.flatMap((section)=>section.fields).filter((field)=>field.valueModes);
164
+ modeFieldsCache.set(schema, fields);
165
+ }
166
+ return fields;
167
+ }
168
+ function withPath(target, path, value) {
169
+ const [key, ...rest] = path;
170
+ if (void 0 === key) return target;
171
+ const container = 'object' == typeof target && null !== target ? target : {};
172
+ const copy = Array.isArray(container) ? [
173
+ ...container
174
+ ] : {
175
+ ...container
176
+ };
177
+ copy[key] = rest.length ? withPath(copy[key], rest, value) : value;
178
+ return copy;
179
+ }
180
+ export { DEFAULT_VALUE_MODE_REGISTRY, VALUE_MODE_OPAQUE, buildValueModeRegistry, codecContext, convertValue, envelopeCodec, isDecodedEmpty, isEmptyModeValue, isFieldControlRegistration, isValueModeEnvelope, literalValueOf, literalValues, resolveCodec, resolveModeOptions };
@@ -2,7 +2,7 @@ import * as AvatarPrimitive from '@radix-ui/react-avatar';
2
2
  import { type VariantProps } from 'class-variance-authority';
3
3
  import * as React from 'react';
4
4
  declare const avatarVariants: (props?: ({
5
- size?: "sm" | "lg" | "default" | null | undefined;
5
+ size?: "default" | "lg" | "sm" | null | undefined;
6
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  export interface AvatarProps extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>, VariantProps<typeof avatarVariants> {
8
8
  }
@@ -1,7 +1,7 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
3
  declare const badgeVariants: (props?: ({
4
- variant?: "default" | "secondary" | "destructive" | "outline" | "error" | "warning" | "info" | "success" | null | undefined;
4
+ variant?: "default" | "destructive" | "outline" | "secondary" | "error" | "warning" | "info" | "success" | null | undefined;
5
5
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
6
  export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
7
7
  }
@@ -0,0 +1,114 @@
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
+ BooleanRadioGroup: ()=>BooleanRadioGroup,
28
+ DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS: ()=>DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS
29
+ });
30
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
+ const external_react_namespaceObject = require("react");
32
+ const index_cjs_namespaceObject = require("../../lib/index.cjs");
33
+ const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
34
+ const external_label_cjs_namespaceObject = require("./label.cjs");
35
+ const external_radio_group_cjs_namespaceObject = require("./radio-group.cjs");
36
+ const DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS = {
37
+ trueLabel: 'True',
38
+ falseLabel: 'False'
39
+ };
40
+ const OPTIONS = [
41
+ {
42
+ value: 'true',
43
+ key: 'trueLabel'
44
+ },
45
+ {
46
+ value: 'false',
47
+ key: 'falseLabel'
48
+ }
49
+ ];
50
+ const BooleanRadioGroup = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ value, onValueChange, strings, disabled: disabledProp, className, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, ...props }, ref)=>{
51
+ const text = {
52
+ ...DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS,
53
+ ...strings
54
+ };
55
+ const groupId = external_react_namespaceObject.useId();
56
+ const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
57
+ const { inGroup } = group;
58
+ const disabled = disabledProp || group.disabled;
59
+ const aria = (0, external_input_group_context_cjs_namespaceObject.controlValidation)(group, {
60
+ 'aria-invalid': ariaInvalid,
61
+ 'aria-describedby': ariaDescribedBy,
62
+ 'aria-errormessage': ariaErrorMessage
63
+ });
64
+ const checked = 'boolean' == typeof value ? String(value) : '';
65
+ const handleValueChange = external_react_namespaceObject.useCallback((next)=>onValueChange('true' === next), [
66
+ onValueChange
67
+ ]);
68
+ const clearIfChecked = external_react_namespaceObject.useCallback((event)=>{
69
+ if (event.currentTarget.value === checked) onValueChange(null);
70
+ }, [
71
+ checked,
72
+ onValueChange
73
+ ]);
74
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_radio_group_cjs_namespaceObject.RadioGroup, {
75
+ ref: ref,
76
+ value: checked,
77
+ onValueChange: handleValueChange,
78
+ disabled: disabled,
79
+ className: (0, index_cjs_namespaceObject.cn)('flex flex-1 items-center gap-4', className),
80
+ ...props,
81
+ ...aria,
82
+ children: OPTIONS.map((option)=>{
83
+ const itemId = `${groupId}-${option.value}`;
84
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
85
+ className: "flex items-center gap-1.5",
86
+ children: [
87
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_radio_group_cjs_namespaceObject.RadioGroupItem, {
88
+ id: itemId,
89
+ value: option.value,
90
+ ...inGroup && {
91
+ 'data-slot': 'input-group-control'
92
+ },
93
+ onClick: clearIfChecked
94
+ }),
95
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
96
+ htmlFor: itemId,
97
+ className: (0, index_cjs_namespaceObject.cn)('font-normal', disabled ? 'cursor-not-allowed' : 'cursor-pointer'),
98
+ children: text[option.key]
99
+ })
100
+ ]
101
+ }, option.value);
102
+ })
103
+ });
104
+ });
105
+ BooleanRadioGroup.displayName = 'BooleanRadioGroup';
106
+ exports.BooleanRadioGroup = __webpack_exports__.BooleanRadioGroup;
107
+ exports.DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS = __webpack_exports__.DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS;
108
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
109
+ "BooleanRadioGroup",
110
+ "DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS"
111
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
112
+ Object.defineProperty(exports, '__esModule', {
113
+ value: true
114
+ });
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { RadioGroup } from './radio-group';
3
+ export interface BooleanRadioGroupStrings {
4
+ trueLabel: string;
5
+ falseLabel: string;
6
+ }
7
+ export declare const DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS: BooleanRadioGroupStrings;
8
+ export interface BooleanRadioGroupProps extends Omit<React.ComponentPropsWithoutRef<typeof RadioGroup>, 'value' | 'defaultValue' | 'onValueChange' | 'children'> {
9
+ /**
10
+ * `null` is the unset state, with neither radio checked; `undefined` reads the same. Unset is
11
+ * reported as `null`, the cleared value form libraries such as react-hook-form expect.
12
+ */
13
+ value: boolean | null | undefined;
14
+ onValueChange: (value: boolean | null) => void;
15
+ /** Overrides for any subset of the English strings. */
16
+ strings?: Partial<BooleanRadioGroupStrings>;
17
+ }
18
+ /**
19
+ * True / False radios with a third, unset state, for a boolean that may have no value: a switch or
20
+ * checkbox can only show two. Clicking the checked radio clears the value. Inside an `InputGroup`
21
+ * both radios are the group's control, so its focus ring answers to either.
22
+ */
23
+ declare const BooleanRadioGroup: React.ForwardRefExoticComponent<BooleanRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
24
+ export { BooleanRadioGroup };
@@ -0,0 +1,77 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useId } from "react";
3
+ import { cn } from "../../lib/index.js";
4
+ import { controlValidation, useInputGroup } from "./input-group-context.js";
5
+ import { Label } from "./label.js";
6
+ import { RadioGroup, RadioGroupItem } from "./radio-group.js";
7
+ const DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS = {
8
+ trueLabel: 'True',
9
+ falseLabel: 'False'
10
+ };
11
+ const OPTIONS = [
12
+ {
13
+ value: 'true',
14
+ key: 'trueLabel'
15
+ },
16
+ {
17
+ value: 'false',
18
+ key: 'falseLabel'
19
+ }
20
+ ];
21
+ const BooleanRadioGroup = /*#__PURE__*/ forwardRef(({ value, onValueChange, strings, disabled: disabledProp, className, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, ...props }, ref)=>{
22
+ const text = {
23
+ ...DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS,
24
+ ...strings
25
+ };
26
+ const groupId = useId();
27
+ const group = useInputGroup();
28
+ const { inGroup } = group;
29
+ const disabled = disabledProp || group.disabled;
30
+ const aria = controlValidation(group, {
31
+ 'aria-invalid': ariaInvalid,
32
+ 'aria-describedby': ariaDescribedBy,
33
+ 'aria-errormessage': ariaErrorMessage
34
+ });
35
+ const checked = 'boolean' == typeof value ? String(value) : '';
36
+ const handleValueChange = useCallback((next)=>onValueChange('true' === next), [
37
+ onValueChange
38
+ ]);
39
+ const clearIfChecked = useCallback((event)=>{
40
+ if (event.currentTarget.value === checked) onValueChange(null);
41
+ }, [
42
+ checked,
43
+ onValueChange
44
+ ]);
45
+ return /*#__PURE__*/ jsx(RadioGroup, {
46
+ ref: ref,
47
+ value: checked,
48
+ onValueChange: handleValueChange,
49
+ disabled: disabled,
50
+ className: cn('flex flex-1 items-center gap-4', className),
51
+ ...props,
52
+ ...aria,
53
+ children: OPTIONS.map((option)=>{
54
+ const itemId = `${groupId}-${option.value}`;
55
+ return /*#__PURE__*/ jsxs("div", {
56
+ className: "flex items-center gap-1.5",
57
+ children: [
58
+ /*#__PURE__*/ jsx(RadioGroupItem, {
59
+ id: itemId,
60
+ value: option.value,
61
+ ...inGroup && {
62
+ 'data-slot': 'input-group-control'
63
+ },
64
+ onClick: clearIfChecked
65
+ }),
66
+ /*#__PURE__*/ jsx(Label, {
67
+ htmlFor: itemId,
68
+ className: cn('font-normal', disabled ? 'cursor-not-allowed' : 'cursor-pointer'),
69
+ children: text[option.key]
70
+ })
71
+ ]
72
+ }, option.value);
73
+ })
74
+ });
75
+ });
76
+ BooleanRadioGroup.displayName = 'BooleanRadioGroup';
77
+ export { BooleanRadioGroup, DEFAULT_BOOLEAN_RADIO_GROUP_STRINGS };
@@ -1,8 +1,8 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "text" | "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | null | undefined;
5
- size?: "sm" | "lg" | "default" | "xs" | "2xs" | "3xs" | "4xs" | "icon" | null | undefined;
4
+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "text" | null | undefined;
5
+ size?: "default" | "lg" | "sm" | "xs" | "2xs" | "3xs" | "4xs" | "icon" | null | undefined;
6
6
  icon?: boolean | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {