@uipath/apollo-wind 2.57.1 → 2.59.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 (36) hide show
  1. package/dist/components/ui/field-actions/ai-assist-action.cjs +51 -7
  2. package/dist/components/ui/field-actions/ai-assist-action.d.ts +12 -3
  3. package/dist/components/ui/field-actions/ai-assist-action.js +52 -8
  4. package/dist/components/ui/field-actions/insert-variable-action.cjs +16 -15
  5. package/dist/components/ui/field-actions/insert-variable-action.d.ts +15 -4
  6. package/dist/components/ui/field-actions/insert-variable-action.js +16 -15
  7. package/dist/components/ui/field-addons/built-in-value-modes.cjs +84 -0
  8. package/dist/components/ui/field-addons/built-in-value-modes.d.ts +21 -0
  9. package/dist/components/ui/field-addons/built-in-value-modes.js +44 -0
  10. package/dist/components/ui/field-addons/{value-mode-menu.cjs → field-menu.cjs} +20 -25
  11. package/dist/components/ui/field-addons/{value-mode-menu.d.ts → field-menu.d.ts} +19 -20
  12. package/dist/components/ui/field-addons/{value-mode-menu.js → field-menu.js} +20 -25
  13. package/dist/components/ui/field-addons/index.cjs +12 -11
  14. package/dist/components/ui/field-addons/index.d.ts +3 -2
  15. package/dist/components/ui/field-addons/index.js +4 -3
  16. package/dist/components/ui/field-addons/value-mode-indicator.cjs +4 -4
  17. package/dist/components/ui/field-addons/value-mode-indicator.d.ts +3 -1
  18. package/dist/components/ui/field-addons/value-mode-indicator.js +5 -5
  19. package/dist/components/ui/field-addons/value-mode-strings.cjs +9 -27
  20. package/dist/components/ui/field-addons/value-mode-strings.d.ts +14 -16
  21. package/dist/components/ui/field-addons/value-mode-strings.js +8 -20
  22. package/dist/components/ui/index.cjs +210 -143
  23. package/dist/components/ui/index.d.ts +2 -2
  24. package/dist/components/ui/index.js +2 -2
  25. package/dist/components/ui/lockable-value-field/components/field-header.cjs +20 -1
  26. package/dist/components/ui/lockable-value-field/components/field-header.d.ts +1 -1
  27. package/dist/components/ui/lockable-value-field/components/field-header.js +20 -1
  28. package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +3 -3
  29. package/dist/components/ui/lockable-value-field/lockable-value-field.js +1 -1
  30. package/dist/components/ui/tree-view.cjs +6 -2
  31. package/dist/components/ui/tree-view.d.ts +35 -21
  32. package/dist/components/ui/tree-view.js +4 -3
  33. package/dist/index.cjs +19 -16
  34. package/dist/index.d.ts +8 -8
  35. package/dist/index.js +5 -5
  36. package/package.json +1 -1
@@ -40,16 +40,42 @@ const DEFAULT_AI_ASSIST_ACTION_STRINGS = {
40
40
  tooltip: 'Generate with AI',
41
41
  prompt: 'Describe what you want',
42
42
  promptPlaceholder: 'Display a value from the previous step',
43
- generate: 'Generate'
43
+ generate: 'Generate',
44
+ generating: 'Generating',
45
+ error: 'Could not generate a value. Try again.'
44
46
  };
45
- function AiAssistAction({ onGenerate, hint, strings }) {
47
+ function AiAssistAction({ onGenerate, hint, disabled, strings }) {
46
48
  const promptId = (0, external_react_namespaceObject.useId)();
49
+ const errorId = (0, external_react_namespaceObject.useId)();
47
50
  const [prompt, setPrompt] = (0, external_react_namespaceObject.useState)('');
51
+ const [open, setOpen] = (0, external_react_namespaceObject.useState)(false);
52
+ const [pending, setPending] = (0, external_react_namespaceObject.useState)(false);
53
+ const [failed, setFailed] = (0, external_react_namespaceObject.useState)(false);
48
54
  const text = {
49
55
  ...DEFAULT_AI_ASSIST_ACTION_STRINGS,
50
56
  ...strings
51
57
  };
58
+ const changeOpen = (next)=>{
59
+ setFailed(false);
60
+ setOpen(next);
61
+ };
62
+ const generate = async ()=>{
63
+ setFailed(false);
64
+ const result = onGenerate?.(prompt);
65
+ if (!isThenable(result)) return;
66
+ setPending(true);
67
+ try {
68
+ await result;
69
+ setOpen(false);
70
+ } catch {
71
+ setFailed(true);
72
+ } finally{
73
+ setPending(false);
74
+ }
75
+ };
52
76
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
77
+ open: open && !disabled,
78
+ onOpenChange: changeOpen,
53
79
  children: [
54
80
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_tooltip_cjs_namespaceObject.Tooltip, {
55
81
  children: [
@@ -60,7 +86,8 @@ function AiAssistAction({ onGenerate, hint, strings }) {
60
86
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
61
87
  type: "button",
62
88
  "aria-label": text.trigger,
63
- className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground",
89
+ disabled: disabled,
90
+ className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground disabled:pointer-events-none disabled:opacity-50",
64
91
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Sparkles, {
65
92
  size: 12
66
93
  })
@@ -90,6 +117,7 @@ function AiAssistAction({ onGenerate, hint, strings }) {
90
117
  value: prompt,
91
118
  onChange: (e)=>setPrompt(e.target.value),
92
119
  placeholder: text.promptPlaceholder,
120
+ "aria-describedby": failed ? errorId : void 0,
93
121
  className: "resize-none text-sm"
94
122
  })
95
123
  ]
@@ -98,18 +126,34 @@ function AiAssistAction({ onGenerate, hint, strings }) {
98
126
  className: "block text-[11px] text-foreground-subtle",
99
127
  children: hint
100
128
  }),
101
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
129
+ failed && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
130
+ id: errorId,
131
+ role: "alert",
132
+ className: "text-xs text-error",
133
+ children: text.error
134
+ }),
135
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
102
136
  size: "sm",
103
137
  className: "w-full",
104
- disabled: !onGenerate,
105
- onClick: ()=>onGenerate?.(prompt),
106
- children: text.generate
138
+ disabled: !onGenerate || pending,
139
+ "aria-busy": pending || void 0,
140
+ onClick: ()=>generate(),
141
+ children: [
142
+ pending && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Loader2, {
143
+ className: "animate-spin",
144
+ "aria-hidden": "true"
145
+ }),
146
+ pending ? text.generating : text.generate
147
+ ]
107
148
  })
108
149
  ]
109
150
  })
110
151
  ]
111
152
  });
112
153
  }
154
+ function isThenable(value) {
155
+ return ('object' == typeof value || 'function' == typeof value) && null !== value && 'function' == typeof value.then;
156
+ }
113
157
  exports.AiAssistAction = __webpack_exports__.AiAssistAction;
114
158
  exports.DEFAULT_AI_ASSIST_ACTION_STRINGS = __webpack_exports__.DEFAULT_AI_ASSIST_ACTION_STRINGS;
115
159
  for(var __rspack_i in __webpack_exports__)if (-1 === [
@@ -5,11 +5,20 @@ export interface AiAssistActionStrings {
5
5
  prompt: string;
6
6
  promptPlaceholder: string;
7
7
  generate: string;
8
+ /** Replaces `generate` while a returned promise is pending. */
9
+ generating: string;
10
+ /** Shown when a returned promise rejects. */
11
+ error: string;
8
12
  }
9
13
  export declare const DEFAULT_AI_ASSIST_ACTION_STRINGS: AiAssistActionStrings;
10
14
  export interface AiAssistActionProps {
11
- /** Called with the entered prompt. Omitted, Generate is disabled. */
12
- onGenerate?: (prompt: string) => void;
15
+ /**
16
+ * Called with the entered prompt. Omitted, Generate is disabled. A returned promise keeps the
17
+ * prompt open and busy until it settles: it closes once the promise resolves and stays open,
18
+ * prompt intact and the error shown, if it rejects.
19
+ */
20
+ onGenerate?: (prompt: string) => unknown;
21
+ disabled?: boolean;
13
22
  /** A line under the prompt describing what will be generated, such as the value's type. */
14
23
  hint?: ReactNode;
15
24
  /** Overrides for any subset of the English strings. */
@@ -18,4 +27,4 @@ export interface AiAssistActionProps {
18
27
  /**
19
28
  * The AI-assist header action: a prompt in a popover. Requires an ancestor `TooltipProvider`.
20
29
  */
21
- export declare function AiAssistAction({ onGenerate, hint, strings }: AiAssistActionProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function AiAssistAction({ onGenerate, hint, disabled, strings }: AiAssistActionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Sparkles } from "lucide-react";
2
+ import { Loader2, Sparkles } from "lucide-react";
3
3
  import { useId, useState } from "react";
4
4
  import { Button } from "../button.js";
5
5
  import { Label } from "../label.js";
@@ -11,16 +11,42 @@ const DEFAULT_AI_ASSIST_ACTION_STRINGS = {
11
11
  tooltip: 'Generate with AI',
12
12
  prompt: 'Describe what you want',
13
13
  promptPlaceholder: 'Display a value from the previous step',
14
- generate: 'Generate'
14
+ generate: 'Generate',
15
+ generating: 'Generating',
16
+ error: 'Could not generate a value. Try again.'
15
17
  };
16
- function AiAssistAction({ onGenerate, hint, strings }) {
18
+ function AiAssistAction({ onGenerate, hint, disabled, strings }) {
17
19
  const promptId = useId();
20
+ const errorId = useId();
18
21
  const [prompt, setPrompt] = useState('');
22
+ const [open, setOpen] = useState(false);
23
+ const [pending, setPending] = useState(false);
24
+ const [failed, setFailed] = useState(false);
19
25
  const text = {
20
26
  ...DEFAULT_AI_ASSIST_ACTION_STRINGS,
21
27
  ...strings
22
28
  };
29
+ const changeOpen = (next)=>{
30
+ setFailed(false);
31
+ setOpen(next);
32
+ };
33
+ const generate = async ()=>{
34
+ setFailed(false);
35
+ const result = onGenerate?.(prompt);
36
+ if (!isThenable(result)) return;
37
+ setPending(true);
38
+ try {
39
+ await result;
40
+ setOpen(false);
41
+ } catch {
42
+ setFailed(true);
43
+ } finally{
44
+ setPending(false);
45
+ }
46
+ };
23
47
  return /*#__PURE__*/ jsxs(Popover, {
48
+ open: open && !disabled,
49
+ onOpenChange: changeOpen,
24
50
  children: [
25
51
  /*#__PURE__*/ jsxs(Tooltip, {
26
52
  children: [
@@ -31,7 +57,8 @@ function AiAssistAction({ onGenerate, hint, strings }) {
31
57
  children: /*#__PURE__*/ jsx("button", {
32
58
  type: "button",
33
59
  "aria-label": text.trigger,
34
- className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground",
60
+ disabled: disabled,
61
+ className: "grid size-7 place-items-center rounded-lg text-foreground-subtle transition hover:bg-surface-overlay hover:text-foreground disabled:pointer-events-none disabled:opacity-50",
35
62
  children: /*#__PURE__*/ jsx(Sparkles, {
36
63
  size: 12
37
64
  })
@@ -61,6 +88,7 @@ function AiAssistAction({ onGenerate, hint, strings }) {
61
88
  value: prompt,
62
89
  onChange: (e)=>setPrompt(e.target.value),
63
90
  placeholder: text.promptPlaceholder,
91
+ "aria-describedby": failed ? errorId : void 0,
64
92
  className: "resize-none text-sm"
65
93
  })
66
94
  ]
@@ -69,16 +97,32 @@ function AiAssistAction({ onGenerate, hint, strings }) {
69
97
  className: "block text-[11px] text-foreground-subtle",
70
98
  children: hint
71
99
  }),
72
- /*#__PURE__*/ jsx(Button, {
100
+ failed && /*#__PURE__*/ jsx("p", {
101
+ id: errorId,
102
+ role: "alert",
103
+ className: "text-xs text-error",
104
+ children: text.error
105
+ }),
106
+ /*#__PURE__*/ jsxs(Button, {
73
107
  size: "sm",
74
108
  className: "w-full",
75
- disabled: !onGenerate,
76
- onClick: ()=>onGenerate?.(prompt),
77
- children: text.generate
109
+ disabled: !onGenerate || pending,
110
+ "aria-busy": pending || void 0,
111
+ onClick: ()=>generate(),
112
+ children: [
113
+ pending && /*#__PURE__*/ jsx(Loader2, {
114
+ className: "animate-spin",
115
+ "aria-hidden": "true"
116
+ }),
117
+ pending ? text.generating : text.generate
118
+ ]
78
119
  })
79
120
  ]
80
121
  })
81
122
  ]
82
123
  });
83
124
  }
125
+ function isThenable(value) {
126
+ return ('object' == typeof value || 'function' == typeof value) && null !== value && 'function' == typeof value.then;
127
+ }
84
128
  export { AiAssistAction, DEFAULT_AI_ASSIST_ACTION_STRINGS };
@@ -29,35 +29,36 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  });
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
31
  const external_lucide_react_namespaceObject = require("lucide-react");
32
+ const external_react_namespaceObject = require("react");
32
33
  const index_cjs_namespaceObject = require("../variable-picker/index.cjs");
33
34
  const external_lib_index_cjs_namespaceObject = require("../../../lib/index.cjs");
34
35
  const external_collapse_cjs_namespaceObject = require("./collapse.cjs");
35
36
  const DEFAULT_INSERT_VARIABLE_ACTION_STRINGS = {
36
37
  label: 'Insert',
37
- ariaLabel: 'Insert variable'
38
+ ariaLabel: 'Insert variable',
39
+ searchPlaceholder: 'Search variables...',
40
+ empty: 'No variables found.',
41
+ replaceTitle: 'Replace the value?',
42
+ replaceDescription: 'The variable will replace the current value. This cannot be undone.',
43
+ replaceConfirm: 'Replace'
38
44
  };
39
45
  function InsertVariableAction({ variables, onInsert, disabled, compact, strings }) {
40
46
  const text = {
41
47
  ...DEFAULT_INSERT_VARIABLE_ACTION_STRINGS,
42
48
  ...strings
43
49
  };
44
- const inert = disabled || 0 === variables.length || !onInsert;
50
+ const lazy = 'function' == typeof variables;
51
+ const inert = disabled || !onInsert || !lazy && 0 === variables.length;
52
+ const [openedItems, setOpenedItems] = (0, external_react_namespaceObject.useState)([]);
45
53
  const collapsedTextClass = (0, external_lib_index_cjs_namespaceObject.cn)(external_collapse_cjs_namespaceObject.COLLAPSED_HIDDEN, compact && '!hidden');
46
54
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.VariablePicker, {
47
55
  disabled: inert,
48
- items: [
49
- {
50
- id: 'vars',
51
- label: '$vars',
52
- type: 'object',
53
- children: variables.map((variable)=>({
54
- id: variable.value,
55
- label: variable.label,
56
- value: variable.value,
57
- type: 'string'
58
- }))
59
- }
60
- ],
56
+ items: lazy ? openedItems : variables,
57
+ placeholder: text.searchPlaceholder,
58
+ emptyText: text.empty,
59
+ onOpenChange: (open)=>{
60
+ if (open && lazy) setOpenedItems(variables());
61
+ },
61
62
  onSelect: (variable)=>{
62
63
  if (variable.value) onInsert?.(variable.value);
63
64
  },
@@ -1,15 +1,26 @@
1
+ import { type VariablePickerItem } from '../variable-picker';
1
2
  export interface InsertVariableActionStrings {
2
3
  /** Visible text, hidden when the action collapses to its icon. */
3
4
  label: string;
4
5
  /** Accessible name and hover title. */
5
6
  ariaLabel: string;
7
+ /** The picker's search box. */
8
+ searchPlaceholder: string;
9
+ /** The picker with nothing to show. */
10
+ empty: string;
11
+ /** Confirms replacing a value that cannot take the reference at a caret. */
12
+ replaceTitle: string;
13
+ replaceDescription: string;
14
+ replaceConfirm: string;
6
15
  }
7
16
  export declare const DEFAULT_INSERT_VARIABLE_ACTION_STRINGS: InsertVariableActionStrings;
8
17
  export interface InsertVariableActionProps {
9
- variables: {
10
- label: string;
11
- value: string;
12
- }[];
18
+ /**
19
+ * The variables to offer, rendered as supplied: the picker adds no root and no types. A function
20
+ * is called each time the picker opens, never during render, so a host can hand over a live
21
+ * source without re-rendering the field whenever it changes.
22
+ */
23
+ variables: VariablePickerItem[] | (() => VariablePickerItem[]);
13
24
  /** Called with the picked variable's value. Omitted, the action is disabled. */
14
25
  onInsert?: (value: string) => void;
15
26
  disabled?: boolean;
@@ -1,34 +1,35 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Braces, ChevronDown } from "lucide-react";
3
+ import { useState } from "react";
3
4
  import { VariablePicker } from "../variable-picker/index.js";
4
5
  import { cn } from "../../../lib/index.js";
5
6
  import { COLLAPSED_HIDDEN, COLLAPSED_ICON_PADDING } from "./collapse.js";
6
7
  const DEFAULT_INSERT_VARIABLE_ACTION_STRINGS = {
7
8
  label: 'Insert',
8
- ariaLabel: 'Insert variable'
9
+ ariaLabel: 'Insert variable',
10
+ searchPlaceholder: 'Search variables...',
11
+ empty: 'No variables found.',
12
+ replaceTitle: 'Replace the value?',
13
+ replaceDescription: 'The variable will replace the current value. This cannot be undone.',
14
+ replaceConfirm: 'Replace'
9
15
  };
10
16
  function InsertVariableAction({ variables, onInsert, disabled, compact, strings }) {
11
17
  const text = {
12
18
  ...DEFAULT_INSERT_VARIABLE_ACTION_STRINGS,
13
19
  ...strings
14
20
  };
15
- const inert = disabled || 0 === variables.length || !onInsert;
21
+ const lazy = 'function' == typeof variables;
22
+ const inert = disabled || !onInsert || !lazy && 0 === variables.length;
23
+ const [openedItems, setOpenedItems] = useState([]);
16
24
  const collapsedTextClass = cn(COLLAPSED_HIDDEN, compact && '!hidden');
17
25
  return /*#__PURE__*/ jsx(VariablePicker, {
18
26
  disabled: inert,
19
- items: [
20
- {
21
- id: 'vars',
22
- label: '$vars',
23
- type: 'object',
24
- children: variables.map((variable)=>({
25
- id: variable.value,
26
- label: variable.label,
27
- value: variable.value,
28
- type: 'string'
29
- }))
30
- }
31
- ],
27
+ items: lazy ? openedItems : variables,
28
+ placeholder: text.searchPlaceholder,
29
+ emptyText: text.empty,
30
+ onOpenChange: (open)=>{
31
+ if (open && lazy) setOpenedItems(variables());
32
+ },
32
33
  onSelect: (variable)=>{
33
34
  if (variable.value) onInsert?.(variable.value);
34
35
  },
@@ -0,0 +1,84 @@
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
+ BUILTIN_VALUE_MODES: ()=>BUILTIN_VALUE_MODES,
28
+ isBuiltInValueMode: ()=>isBuiltInValueMode,
29
+ builtInValueModes: ()=>builtInValueModes
30
+ });
31
+ const external_lucide_react_namespaceObject = require("lucide-react");
32
+ const external_value_mode_strings_cjs_namespaceObject = require("./value-mode-strings.cjs");
33
+ function literalDescriptionFor(expectedType, strings) {
34
+ if ('number' === expectedType) return strings.literalNumberDescription;
35
+ if ('boolean' === expectedType) return strings.literalBooleanDescription;
36
+ return strings.literalDescription;
37
+ }
38
+ function builtInValueModes(strings, { expectedType, literalDescription } = {}) {
39
+ const text = {
40
+ ...external_value_mode_strings_cjs_namespaceObject.DEFAULT_VALUE_MODE_STRINGS,
41
+ ...strings
42
+ };
43
+ return {
44
+ literal: {
45
+ id: 'literal',
46
+ title: text.literalTitle,
47
+ description: literalDescription ?? literalDescriptionFor(expectedType, text),
48
+ icon: external_lucide_react_namespaceObject.Type
49
+ },
50
+ expression: {
51
+ id: 'expression',
52
+ title: text.expressionTitle,
53
+ description: text.expressionDescription,
54
+ icon: external_lucide_react_namespaceObject.SquareFunction
55
+ },
56
+ variable: {
57
+ id: 'variable',
58
+ title: text.variableTitle,
59
+ description: text.variableDescription,
60
+ icon: external_lucide_react_namespaceObject.Variable
61
+ },
62
+ prompt: {
63
+ id: 'prompt',
64
+ title: text.promptTitle,
65
+ description: text.promptDescription,
66
+ icon: external_lucide_react_namespaceObject.Sparkles
67
+ }
68
+ };
69
+ }
70
+ const BUILTIN_VALUE_MODES = builtInValueModes();
71
+ function isBuiltInValueMode(id) {
72
+ return id in BUILTIN_VALUE_MODES;
73
+ }
74
+ exports.BUILTIN_VALUE_MODES = __webpack_exports__.BUILTIN_VALUE_MODES;
75
+ exports.builtInValueModes = __webpack_exports__.builtInValueModes;
76
+ exports.isBuiltInValueMode = __webpack_exports__.isBuiltInValueMode;
77
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
78
+ "BUILTIN_VALUE_MODES",
79
+ "builtInValueModes",
80
+ "isBuiltInValueMode"
81
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
82
+ Object.defineProperty(exports, '__esModule', {
83
+ value: true
84
+ });
@@ -0,0 +1,21 @@
1
+ import { type LucideIcon } from 'lucide-react';
2
+ import { type ValueMode, type ValueModeStrings } from './value-mode-strings';
3
+ /** One selectable mode. `id` is the consumer's own vocabulary. */
4
+ export interface ValueModeOption<Id extends string = string> {
5
+ id: Id;
6
+ title: string;
7
+ description?: string;
8
+ icon: LucideIcon;
9
+ disabled?: boolean;
10
+ }
11
+ export interface BuiltInValueModesOptions {
12
+ /** Picks the literal mode's description (`number`, `boolean`, anything else). */
13
+ expectedType?: string;
14
+ /** Overrides the literal mode's description. */
15
+ literalDescription?: string;
16
+ }
17
+ /** The four built-in modes, in `strings` (merged over the English defaults). */
18
+ export declare function builtInValueModes(strings?: Partial<ValueModeStrings>, { expectedType, literalDescription }?: BuiltInValueModesOptions): Record<ValueMode, ValueModeOption<ValueMode>>;
19
+ /** The four built-in modes in English. Call {@link builtInValueModes} for translated ones. */
20
+ export declare const BUILTIN_VALUE_MODES: Record<ValueMode, ValueModeOption<ValueMode>>;
21
+ export declare function isBuiltInValueMode(id: string): id is ValueMode;
@@ -0,0 +1,44 @@
1
+ import { Sparkles, SquareFunction, Type, Variable } from "lucide-react";
2
+ import { DEFAULT_VALUE_MODE_STRINGS } from "./value-mode-strings.js";
3
+ function literalDescriptionFor(expectedType, strings) {
4
+ if ('number' === expectedType) return strings.literalNumberDescription;
5
+ if ('boolean' === expectedType) return strings.literalBooleanDescription;
6
+ return strings.literalDescription;
7
+ }
8
+ function builtInValueModes(strings, { expectedType, literalDescription } = {}) {
9
+ const text = {
10
+ ...DEFAULT_VALUE_MODE_STRINGS,
11
+ ...strings
12
+ };
13
+ return {
14
+ literal: {
15
+ id: 'literal',
16
+ title: text.literalTitle,
17
+ description: literalDescription ?? literalDescriptionFor(expectedType, text),
18
+ icon: Type
19
+ },
20
+ expression: {
21
+ id: 'expression',
22
+ title: text.expressionTitle,
23
+ description: text.expressionDescription,
24
+ icon: SquareFunction
25
+ },
26
+ variable: {
27
+ id: 'variable',
28
+ title: text.variableTitle,
29
+ description: text.variableDescription,
30
+ icon: Variable
31
+ },
32
+ prompt: {
33
+ id: 'prompt',
34
+ title: text.promptTitle,
35
+ description: text.promptDescription,
36
+ icon: Sparkles
37
+ }
38
+ };
39
+ }
40
+ const BUILTIN_VALUE_MODES = builtInValueModes();
41
+ function isBuiltInValueMode(id) {
42
+ return id in BUILTIN_VALUE_MODES;
43
+ }
44
+ export { BUILTIN_VALUE_MODES, builtInValueModes, isBuiltInValueMode };
@@ -24,7 +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
- ValueModeMenu: ()=>ValueModeMenu,
27
+ FieldMenu: ()=>FieldMenu,
28
28
  ValueModeMenuItem: ()=>ValueModeMenuItem
29
29
  });
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
@@ -32,12 +32,12 @@ const external_lucide_react_namespaceObject = require("lucide-react");
32
32
  const external_button_cjs_namespaceObject = require("../button.cjs");
33
33
  const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
34
34
  const index_cjs_namespaceObject = require("../../../lib/index.cjs");
35
+ const external_built_in_value_modes_cjs_namespaceObject = require("./built-in-value-modes.cjs");
35
36
  const external_value_mode_strings_cjs_namespaceObject = require("./value-mode-strings.cjs");
36
- function literalDescriptionFor(expectedType, strings) {
37
- if ('number' === expectedType) return strings.literalNumberDescription;
38
- if ('boolean' === expectedType) return strings.literalBooleanDescription;
39
- return strings.literalDescription;
40
- }
37
+ const DEFAULT_MODES = [
38
+ 'literal',
39
+ 'expression'
40
+ ];
41
41
  function ValueModeMenuItem({ icon: Icon, label, description, active, disabled, onClick }) {
42
42
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
43
43
  role: "menuitemradio",
@@ -67,30 +67,25 @@ function ValueModeMenuItem({ icon: Icon, label, description, active, disabled, o
67
67
  ]
68
68
  });
69
69
  }
70
- function ValueModeMenu({ mode, onSelect, modes, extraModes, actions, checked, modesDisabled, disabled, expectedType, literalDescription }) {
71
- const strings = (0, external_value_mode_strings_cjs_namespaceObject.useValueModeStrings)();
70
+ function FieldMenu({ mode, onSelect, modes, extraModes, actions, checked, modesDisabled, disabled, expectedType, literalDescription, strings }) {
71
+ const text = {
72
+ ...external_value_mode_strings_cjs_namespaceObject.DEFAULT_VALUE_MODE_STRINGS,
73
+ ...strings
74
+ };
72
75
  const checkedMode = checked ?? mode;
73
- const baseModes = modes ?? [
74
- {
75
- id: 'literal',
76
- title: strings.literalTitle,
77
- description: literalDescription ?? literalDescriptionFor(expectedType, strings),
78
- icon: external_lucide_react_namespaceObject.Type
79
- },
80
- {
81
- id: 'expression',
82
- title: strings.expressionTitle,
83
- description: strings.expressionDescription,
84
- icon: external_lucide_react_namespaceObject.SquareFunction
85
- }
86
- ];
76
+ const builtIns = (0, external_built_in_value_modes_cjs_namespaceObject.builtInValueModes)(text, {
77
+ expectedType,
78
+ literalDescription
79
+ });
80
+ const entries = modes ?? DEFAULT_MODES;
81
+ const baseModes = entries.map((entry)=>'string' == typeof entry && (0, external_built_in_value_modes_cjs_namespaceObject.isBuiltInValueMode)(entry) ? builtIns[entry] : entry);
87
82
  const resolvedModes = extraModes ? [
88
83
  ...extraModes,
89
84
  ...baseModes
90
85
  ] : baseModes;
91
86
  const activeMode = resolvedModes.find((item)=>item.id === mode);
92
87
  const TriggerIcon = modesDisabled ? external_lucide_react_namespaceObject.MoreHorizontal : activeMode?.icon ?? external_lucide_react_namespaceObject.Type;
93
- const triggerLabel = modesDisabled ? strings.fieldActions : activeMode?.title ?? strings.literalTitle;
88
+ const triggerLabel = modesDisabled ? text.fieldActions : activeMode?.title ?? text.literalTitle;
94
89
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
95
90
  children: [
96
91
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
@@ -138,10 +133,10 @@ function ValueModeMenu({ mode, onSelect, modes, extraModes, actions, checked, mo
138
133
  ]
139
134
  });
140
135
  }
141
- exports.ValueModeMenu = __webpack_exports__.ValueModeMenu;
136
+ exports.FieldMenu = __webpack_exports__.FieldMenu;
142
137
  exports.ValueModeMenuItem = __webpack_exports__.ValueModeMenuItem;
143
138
  for(var __rspack_i in __webpack_exports__)if (-1 === [
144
- "ValueModeMenu",
139
+ "FieldMenu",
145
140
  "ValueModeMenuItem"
146
141
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
147
142
  Object.defineProperty(exports, '__esModule', {