@uipath/apollo-wind 2.79.2 → 2.80.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/editable-text.cjs +251 -0
  2. package/dist/components/ui/editable-text.d.ts +48 -0
  3. package/dist/components/ui/editable-text.js +217 -0
  4. package/dist/components/ui/field-addons/field-menu.cjs +2 -1
  5. package/dist/components/ui/field-addons/field-menu.d.ts +6 -1
  6. package/dist/components/ui/field-addons/field-menu.js +2 -1
  7. package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +2 -1
  8. package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +6 -1
  9. package/dist/components/ui/field-addons/value-mode-switch-dialog.js +2 -1
  10. package/dist/components/ui/index.cjs +214 -201
  11. package/dist/components/ui/index.d.ts +1 -0
  12. package/dist/components/ui/index.js +1 -0
  13. package/dist/components/ui/input-group.cjs +7 -3
  14. package/dist/components/ui/input-group.d.ts +1 -1
  15. package/dist/components/ui/input-group.js +7 -3
  16. package/dist/components/ui/quick-form-field/components/field-header.cjs +41 -38
  17. package/dist/components/ui/quick-form-field/components/field-header.d.ts +13 -4
  18. package/dist/components/ui/quick-form-field/components/field-header.js +38 -38
  19. package/dist/components/ui/quick-form-field/index.d.ts +1 -1
  20. package/dist/components/ui/quick-form-field/quick-form-field.cjs +134 -17
  21. package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -3
  22. package/dist/components/ui/quick-form-field/quick-form-field.js +136 -19
  23. package/dist/components/ui/quick-form-field/types.cjs +8 -0
  24. package/dist/components/ui/quick-form-field/types.d.ts +81 -14
  25. package/dist/components/ui/quick-form-field/types.js +8 -0
  26. package/dist/components/ui/quick-form-field/utils.cjs +30 -1
  27. package/dist/components/ui/quick-form-field/utils.d.ts +8 -0
  28. package/dist/components/ui/quick-form-field/utils.js +27 -1
  29. package/dist/components/ui/variable-value-control.cjs +7 -4
  30. package/dist/components/ui/variable-value-control.d.ts +5 -1
  31. package/dist/components/ui/variable-value-control.js +7 -4
  32. package/dist/index.cjs +4 -0
  33. package/dist/index.d.ts +3 -1
  34. package/dist/index.js +2 -1
  35. package/dist/styles.css +69 -9
  36. package/package.json +1 -1
@@ -31,6 +31,7 @@ export * from './drawer';
31
31
  export * from './dropdown-menu';
32
32
  export * from './dropzone-overlay';
33
33
  export * from './editable-cell';
34
+ export * from './editable-text';
34
35
  export * from './empty-state';
35
36
  export * from './field-actions';
36
37
  export * from './field-addons';
@@ -34,6 +34,7 @@ export * from "./drawer.js";
34
34
  export * from "./dropdown-menu.js";
35
35
  export * from "./dropzone-overlay.js";
36
36
  export * from "./editable-cell.js";
37
+ export * from "./editable-text.js";
37
38
  export * from "./empty-state.js";
38
39
  export * from "./field-actions/index.js";
39
40
  export * from "./field-addons/index.js";
@@ -64,13 +64,17 @@ const BOXED = [
64
64
  'outline',
65
65
  'agent'
66
66
  ];
67
+ const ADDON_BUTTON_TRIMS = 'has-[>[data-slot=input-group-addon][data-align=inline-start]_button]:pl-2 has-[>[data-slot=input-group-addon][data-align=inline-end]_button]:pr-2';
67
68
  const inputGroupVariants = (0, external_class_variance_authority_namespaceObject.cva)([
68
69
  'group/input-group relative flex w-full items-center gap-2 transition-colors has-[>textarea]:h-auto has-[>textarea]:items-start',
69
70
  'has-[[data-slot=input-group-control]:disabled]:cursor-not-allowed has-[[data-slot=input-group-control]:disabled]:opacity-50'
70
71
  ], {
71
72
  variants: {
72
73
  size: {
73
- default: 'h-9 rounded-md px-3 py-1 future:h-10 future:rounded-xl future:py-2 has-[>[data-slot=input-group-addon][data-align=inline-end]]:pr-2 future:has-[>[data-slot=input-group-addon][data-align=inline-end]]:pr-2',
74
+ default: [
75
+ 'h-9 rounded-md px-3 py-1 future:h-10 future:rounded-xl future:py-2',
76
+ ADDON_BUTTON_TRIMS
77
+ ],
74
78
  xs: 'h-6 gap-1 rounded px-2'
75
79
  },
76
80
  layout: {
@@ -99,7 +103,7 @@ const inputGroupVariants = (0, external_class_variance_authority_namespaceObject
99
103
  {
100
104
  variant: 'none',
101
105
  layout: ROW_LAYOUTS,
102
- class: 'px-0 pr-3'
106
+ class: 'px-0'
103
107
  },
104
108
  {
105
109
  layout: ROW_LAYOUTS,
@@ -257,7 +261,7 @@ const InputGroupRow = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({
257
261
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
258
262
  ref: ref,
259
263
  "data-slot": "input-group-row",
260
- className: (0, index_cjs_namespaceObject.cn)('flex min-h-9 min-w-0 items-stretch gap-2 px-3 has-[>[data-slot=input-group-addon][data-align=inline-end]]:pr-2 future:min-h-10', 'rounded-[inherit] has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-inset has-[[data-slot=input-group-control]_:focus-visible]:ring-2 has-[[data-slot=input-group-control]_:focus-visible]:ring-inset has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]_:focus-visible]:ring-error', flagged ? 'has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot=input-group-control]_:focus-visible]:ring-error' : 'has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]_:focus-visible]:ring-ring future:has-[[data-slot=input-group-control]:focus-visible]:ring-primary future:has-[[data-slot=input-group-control]_:focus-visible]:ring-primary', className),
264
+ className: (0, index_cjs_namespaceObject.cn)('flex min-h-9 min-w-0 items-stretch gap-2 px-3 future:min-h-10', ADDON_BUTTON_TRIMS, 'rounded-[inherit] has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-inset has-[[data-slot=input-group-control]_:focus-visible]:ring-2 has-[[data-slot=input-group-control]_:focus-visible]:ring-inset has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]_:focus-visible]:ring-error', flagged ? 'has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot=input-group-control]_:focus-visible]:ring-error' : 'has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]_:focus-visible]:ring-ring future:has-[[data-slot=input-group-control]:focus-visible]:ring-primary future:has-[[data-slot=input-group-control]_:focus-visible]:ring-primary', className),
261
265
  ...props
262
266
  });
263
267
  });
@@ -53,7 +53,7 @@ export interface InputGroupRowProps extends React.HTMLAttributes<HTMLDivElement>
53
53
  }
54
54
  /**
55
55
  * The first row of a `layout="block"` group, holding the control and its addons. The box has no
56
- * padding in that layout, so the row carries the box's usual padding and trailing trim. Padding the
56
+ * padding in that layout, so the row carries the box's usual padding and addon trims. Padding the
57
57
  * control instead would inset its caret out of line with other fields.
58
58
  */
59
59
  declare const InputGroupRow: React.ForwardRefExoticComponent<InputGroupRowProps & React.RefAttributes<HTMLDivElement>>;
@@ -25,13 +25,17 @@ const BOXED = [
25
25
  'outline',
26
26
  'agent'
27
27
  ];
28
+ const ADDON_BUTTON_TRIMS = 'has-[>[data-slot=input-group-addon][data-align=inline-start]_button]:pl-2 has-[>[data-slot=input-group-addon][data-align=inline-end]_button]:pr-2';
28
29
  const inputGroupVariants = cva([
29
30
  'group/input-group relative flex w-full items-center gap-2 transition-colors has-[>textarea]:h-auto has-[>textarea]:items-start',
30
31
  'has-[[data-slot=input-group-control]:disabled]:cursor-not-allowed has-[[data-slot=input-group-control]:disabled]:opacity-50'
31
32
  ], {
32
33
  variants: {
33
34
  size: {
34
- default: 'h-9 rounded-md px-3 py-1 future:h-10 future:rounded-xl future:py-2 has-[>[data-slot=input-group-addon][data-align=inline-end]]:pr-2 future:has-[>[data-slot=input-group-addon][data-align=inline-end]]:pr-2',
35
+ default: [
36
+ 'h-9 rounded-md px-3 py-1 future:h-10 future:rounded-xl future:py-2',
37
+ ADDON_BUTTON_TRIMS
38
+ ],
35
39
  xs: 'h-6 gap-1 rounded px-2'
36
40
  },
37
41
  layout: {
@@ -60,7 +64,7 @@ const inputGroupVariants = cva([
60
64
  {
61
65
  variant: 'none',
62
66
  layout: ROW_LAYOUTS,
63
- class: 'px-0 pr-3'
67
+ class: 'px-0'
64
68
  },
65
69
  {
66
70
  layout: ROW_LAYOUTS,
@@ -218,7 +222,7 @@ const InputGroupRow = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
218
222
  return /*#__PURE__*/ jsx("div", {
219
223
  ref: ref,
220
224
  "data-slot": "input-group-row",
221
- className: cn('flex min-h-9 min-w-0 items-stretch gap-2 px-3 has-[>[data-slot=input-group-addon][data-align=inline-end]]:pr-2 future:min-h-10', 'rounded-[inherit] has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-inset has-[[data-slot=input-group-control]_:focus-visible]:ring-2 has-[[data-slot=input-group-control]_:focus-visible]:ring-inset has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]_:focus-visible]:ring-error', flagged ? 'has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot=input-group-control]_:focus-visible]:ring-error' : 'has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]_:focus-visible]:ring-ring future:has-[[data-slot=input-group-control]:focus-visible]:ring-primary future:has-[[data-slot=input-group-control]_:focus-visible]:ring-primary', className),
225
+ className: cn('flex min-h-9 min-w-0 items-stretch gap-2 px-3 future:min-h-10', ADDON_BUTTON_TRIMS, 'rounded-[inherit] has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-inset has-[[data-slot=input-group-control]_:focus-visible]:ring-2 has-[[data-slot=input-group-control]_:focus-visible]:ring-inset has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]_:focus-visible]:ring-error', flagged ? 'has-[[data-slot=input-group-control]:focus-visible]:ring-error has-[[data-slot=input-group-control]_:focus-visible]:ring-error' : 'has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot=input-group-control]_:focus-visible]:ring-ring future:has-[[data-slot=input-group-control]:focus-visible]:ring-primary future:has-[[data-slot=input-group-control]_:focus-visible]:ring-primary', className),
222
226
  ...props
223
227
  });
224
228
  });
@@ -24,14 +24,15 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ GROW_WHILE_EDITING: ()=>GROW_WHILE_EDITING,
27
28
  FieldHeader: ()=>FieldHeader
28
29
  });
29
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
31
  const external_lucide_react_namespaceObject = require("lucide-react");
31
- const external_react_namespaceObject = require("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 external_form_field_cjs_namespaceObject = require("../../form-field.cjs");
35
+ const external_info_tooltip_cjs_namespaceObject = require("../../info-tooltip.cjs");
35
36
  const external_popover_cjs_namespaceObject = require("../../popover.cjs");
36
37
  const external_switch_cjs_namespaceObject = require("../../switch.cjs");
37
38
  const external_tooltip_cjs_namespaceObject = require("../../tooltip.cjs");
@@ -40,47 +41,50 @@ const ai_assist_action_cjs_namespaceObject = require("../../field-actions/ai-ass
40
41
  const collapse_cjs_namespaceObject = require("../../field-actions/collapse.cjs");
41
42
  const insert_variable_action_cjs_namespaceObject = require("../../field-actions/insert-variable-action.cjs");
42
43
  const external_types_cjs_namespaceObject = require("../types.cjs");
43
- function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTypes = external_types_cjs_namespaceObject.FIELD_TYPE_ORDER, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions }) {
44
- const [pickerItems, optionsBySelectionId] = (0, external_react_namespaceObject.useMemo)(()=>{
45
- const byId = new Map();
46
- const toItem = (v, id)=>{
47
- byId.set(id, v);
48
- return {
49
- id,
50
- label: v.label,
51
- ...v.value ? {
52
- value: v.value
53
- } : {},
54
- ...v.type ? {
55
- type: v.type
56
- } : {},
57
- ...v.children ? {
58
- children: v.children.map((c, i)=>toItem(c, `${id}/${i}`))
59
- } : {}
60
- };
61
- };
62
- return [
63
- variables.map((v, i)=>toItem(v, String(i))),
64
- byId
65
- ];
66
- }, [
67
- variables
68
- ]);
44
+ const GROW_WHILE_EDITING = 'has-[[data-slot=editable-text-input]]:flex-1';
45
+ function FieldHeader({ label, labelAddon, tooltip, fieldId, fieldLabel, required, fieldType, fieldTypes = external_types_cjs_namespaceObject.FIELD_TYPE_ORDER, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions }) {
69
46
  const typeMeta = external_types_cjs_namespaceObject.FIELD_TYPE_META[fieldType];
70
47
  const typeLabel = strings.typeLabels[fieldType] ?? typeMeta.label;
71
48
  const collapsedTextClass = (0, index_cjs_namespaceObject.cn)(collapse_cjs_namespaceObject.COLLAPSED_HIDDEN, compact && '!hidden');
72
49
  const compactOnlyClass = (0, index_cjs_namespaceObject.cn)(collapse_cjs_namespaceObject.COLLAPSED_ONLY, compact && '!flex');
73
50
  const hasActions = !!onFieldTypeChange || !!onRequiredChange || showFieldActions || null != headerActions;
74
- if (null != label && !hasActions) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
75
- children: label
76
- });
51
+ const hasTooltip = null != tooltip && false !== tooltip && !('string' == typeof tooltip && !tooltip.trim());
52
+ const ownLabel = null != label && hasTooltip ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
53
+ className: (0, index_cjs_namespaceObject.cn)('flex min-w-0 items-center', GROW_WHILE_EDITING, '[&:has([data-slot=editable-text-input])>[data-slot=info-tooltip]]:hidden'),
54
+ children: [
55
+ label,
56
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_info_tooltip_cjs_namespaceObject.InfoTooltip, {
57
+ content: tooltip,
58
+ "aria-label": strings.tooltipAriaLabel
59
+ })
60
+ ]
61
+ }) : label;
62
+ const leading = null != labelAddon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
63
+ children: [
64
+ labelAddon,
65
+ ownLabel
66
+ ]
67
+ }) : ownLabel;
68
+ if (null != label && !hasActions) {
69
+ const alone = null != labelAddon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
70
+ className: (0, index_cjs_namespaceObject.cn)('flex min-w-0 items-center gap-2', GROW_WHILE_EDITING),
71
+ children: leading
72
+ }) : ownLabel;
73
+ return hasTooltip ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipProvider, {
74
+ delayDuration: 300,
75
+ children: alone
76
+ }) : alone;
77
+ }
77
78
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipProvider, {
78
79
  delayDuration: 300,
79
80
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldHeader, {
81
+ className: "[&:has([data-slot=editable-text-input])>:first-child]:flex-1 [&:has([data-slot=editable-text-input])>:nth-child(2)]:!hidden",
80
82
  label: null == label ? fieldLabel : void 0,
81
83
  htmlFor: fieldId,
82
84
  required: required,
83
- leading: label,
85
+ tooltip: null == label ? tooltip : void 0,
86
+ tooltipAriaLabel: strings.tooltipAriaLabel,
87
+ leading: leading,
84
88
  actions: hasActions ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
85
89
  children: [
86
90
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
@@ -236,8 +240,8 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
236
240
  error: strings.aiError
237
241
  }
238
242
  }),
239
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(insert_variable_action_cjs_namespaceObject.InsertVariableAction, {
240
- variables: pickerItems,
243
+ onInsertVariable && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(insert_variable_action_cjs_namespaceObject.InsertVariableAction, {
244
+ variables: variables.items,
241
245
  compact: compact,
242
246
  disabled: !onValueChange,
243
247
  strings: {
@@ -246,10 +250,7 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
246
250
  searchPlaceholder: strings.insertSearchPlaceholder,
247
251
  empty: strings.insertEmpty
248
252
  },
249
- onInsert: onInsertVariable && ((value, item)=>onInsertVariable(optionsBySelectionId.get(item.id) ?? {
250
- label: item.label,
251
- value
252
- }))
253
+ onInsert: (_, item)=>onInsertVariable(variables.resolve(item))
253
254
  })
254
255
  ]
255
256
  })
@@ -262,8 +263,10 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
262
263
  });
263
264
  }
264
265
  exports.FieldHeader = __webpack_exports__.FieldHeader;
266
+ exports.GROW_WHILE_EDITING = __webpack_exports__.GROW_WHILE_EDITING;
265
267
  for(var __rspack_i in __webpack_exports__)if (-1 === [
266
- "FieldHeader"
268
+ "FieldHeader",
269
+ "GROW_WHILE_EDITING"
267
270
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
268
271
  Object.defineProperty(exports, '__esModule', {
269
272
  value: true
@@ -1,7 +1,16 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { QuickFieldType, QuickFormFieldOption, QuickFormFieldStrings } from '../types';
3
- export declare function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTypes, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions, }: {
3
+ import type { VariablePickerSource } from '../utils';
4
+ /**
5
+ * While the editable label is open, each box around it grows to the header's actions, so the
6
+ * editor fills that space instead of an `<input>`'s default width. Read mode keeps them sized to
7
+ * the label, so the asterisk and info icon stay beside the text.
8
+ */
9
+ export declare const GROW_WHILE_EDITING = "has-[[data-slot=editable-text-input]]:flex-1";
10
+ export declare function FieldHeader({ label, labelAddon, tooltip, fieldId, fieldLabel, required, fieldType, fieldTypes, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions, }: {
4
11
  label?: ReactNode;
12
+ labelAddon?: ReactNode;
13
+ tooltip?: ReactNode;
5
14
  fieldId: string;
6
15
  fieldLabel: string;
7
16
  required?: boolean;
@@ -16,11 +25,11 @@ export declare function FieldHeader({ label, fieldId, fieldLabel, required, fiel
16
25
  isExpression: boolean;
17
26
  showFieldActions: boolean;
18
27
  onValueChange?: (value: string) => void;
19
- variables: QuickFormFieldOption[];
28
+ variables: VariablePickerSource;
20
29
  onGenerateWithAi?: (prompt: string) => void;
21
- /** See QuickFormFieldProps.onInsertVariable. */
30
+ /** See QuickFormFieldProps.onInsertVariable. Omitted, the Insert action does not render. */
22
31
  onInsertVariable?: (variable: QuickFormFieldOption) => void;
23
32
  /** See QuickFormFieldStrings. */
24
33
  strings: QuickFormFieldStrings;
25
34
  headerActions?: ReactNode;
26
- }): import("react/jsx-runtime").JSX.Element;
35
+ }): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
@@ -1,9 +1,9 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Asterisk, ChevronDown } from "lucide-react";
3
- import { useMemo } from "react";
4
3
  import { Button } from "../../button.js";
5
4
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../dropdown-menu.js";
6
5
  import { FormFieldHeader } from "../../form-field.js";
6
+ import { InfoTooltip } from "../../info-tooltip.js";
7
7
  import { Popover, PopoverContent, PopoverTrigger } from "../../popover.js";
8
8
  import { Switch } from "../../switch.js";
9
9
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../tooltip.js";
@@ -12,47 +12,50 @@ import { AiAssistAction } from "../../field-actions/ai-assist-action.js";
12
12
  import { COLLAPSED_HIDDEN, COLLAPSED_ONLY, FIELD_ACTION_CLASS } from "../../field-actions/collapse.js";
13
13
  import { InsertVariableAction } from "../../field-actions/insert-variable-action.js";
14
14
  import { FIELD_TYPE_META, FIELD_TYPE_ORDER } from "../types.js";
15
- function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTypes = FIELD_TYPE_ORDER, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions }) {
16
- const [pickerItems, optionsBySelectionId] = useMemo(()=>{
17
- const byId = new Map();
18
- const toItem = (v, id)=>{
19
- byId.set(id, v);
20
- return {
21
- id,
22
- label: v.label,
23
- ...v.value ? {
24
- value: v.value
25
- } : {},
26
- ...v.type ? {
27
- type: v.type
28
- } : {},
29
- ...v.children ? {
30
- children: v.children.map((c, i)=>toItem(c, `${id}/${i}`))
31
- } : {}
32
- };
33
- };
34
- return [
35
- variables.map((v, i)=>toItem(v, String(i))),
36
- byId
37
- ];
38
- }, [
39
- variables
40
- ]);
15
+ const GROW_WHILE_EDITING = 'has-[[data-slot=editable-text-input]]:flex-1';
16
+ function FieldHeader({ label, labelAddon, tooltip, fieldId, fieldLabel, required, fieldType, fieldTypes = FIELD_TYPE_ORDER, onFieldTypeChange, onRequiredChange, compact, disabled, isExpression, showFieldActions, onValueChange, variables, onGenerateWithAi, onInsertVariable, strings, headerActions }) {
41
17
  const typeMeta = FIELD_TYPE_META[fieldType];
42
18
  const typeLabel = strings.typeLabels[fieldType] ?? typeMeta.label;
43
19
  const collapsedTextClass = cn(COLLAPSED_HIDDEN, compact && '!hidden');
44
20
  const compactOnlyClass = cn(COLLAPSED_ONLY, compact && '!flex');
45
21
  const hasActions = !!onFieldTypeChange || !!onRequiredChange || showFieldActions || null != headerActions;
46
- if (null != label && !hasActions) return /*#__PURE__*/ jsx(Fragment, {
47
- children: label
48
- });
22
+ const hasTooltip = null != tooltip && false !== tooltip && !('string' == typeof tooltip && !tooltip.trim());
23
+ const ownLabel = null != label && hasTooltip ? /*#__PURE__*/ jsxs("span", {
24
+ className: cn('flex min-w-0 items-center', GROW_WHILE_EDITING, '[&:has([data-slot=editable-text-input])>[data-slot=info-tooltip]]:hidden'),
25
+ children: [
26
+ label,
27
+ /*#__PURE__*/ jsx(InfoTooltip, {
28
+ content: tooltip,
29
+ "aria-label": strings.tooltipAriaLabel
30
+ })
31
+ ]
32
+ }) : label;
33
+ const leading = null != labelAddon ? /*#__PURE__*/ jsxs(Fragment, {
34
+ children: [
35
+ labelAddon,
36
+ ownLabel
37
+ ]
38
+ }) : ownLabel;
39
+ if (null != label && !hasActions) {
40
+ const alone = null != labelAddon ? /*#__PURE__*/ jsx("div", {
41
+ className: cn('flex min-w-0 items-center gap-2', GROW_WHILE_EDITING),
42
+ children: leading
43
+ }) : ownLabel;
44
+ return hasTooltip ? /*#__PURE__*/ jsx(TooltipProvider, {
45
+ delayDuration: 300,
46
+ children: alone
47
+ }) : alone;
48
+ }
49
49
  return /*#__PURE__*/ jsx(TooltipProvider, {
50
50
  delayDuration: 300,
51
51
  children: /*#__PURE__*/ jsx(FormFieldHeader, {
52
+ className: "[&:has([data-slot=editable-text-input])>:first-child]:flex-1 [&:has([data-slot=editable-text-input])>:nth-child(2)]:!hidden",
52
53
  label: null == label ? fieldLabel : void 0,
53
54
  htmlFor: fieldId,
54
55
  required: required,
55
- leading: label,
56
+ tooltip: null == label ? tooltip : void 0,
57
+ tooltipAriaLabel: strings.tooltipAriaLabel,
58
+ leading: leading,
56
59
  actions: hasActions ? /*#__PURE__*/ jsxs(Fragment, {
57
60
  children: [
58
61
  /*#__PURE__*/ jsxs("div", {
@@ -208,8 +211,8 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
208
211
  error: strings.aiError
209
212
  }
210
213
  }),
211
- /*#__PURE__*/ jsx(InsertVariableAction, {
212
- variables: pickerItems,
214
+ onInsertVariable && /*#__PURE__*/ jsx(InsertVariableAction, {
215
+ variables: variables.items,
213
216
  compact: compact,
214
217
  disabled: !onValueChange,
215
218
  strings: {
@@ -218,10 +221,7 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
218
221
  searchPlaceholder: strings.insertSearchPlaceholder,
219
222
  empty: strings.insertEmpty
220
223
  },
221
- onInsert: onInsertVariable && ((value, item)=>onInsertVariable(optionsBySelectionId.get(item.id) ?? {
222
- label: item.label,
223
- value
224
- }))
224
+ onInsert: (_, item)=>onInsertVariable(variables.resolve(item))
225
225
  })
226
226
  ]
227
227
  })
@@ -233,4 +233,4 @@ function FieldHeader({ label, fieldId, fieldLabel, required, fieldType, fieldTyp
233
233
  })
234
234
  });
235
235
  }
236
- export { FieldHeader };
236
+ export { FieldHeader, GROW_WHILE_EDITING };
@@ -1,3 +1,3 @@
1
1
  export { QuickFormField } from './quick-form-field';
2
- export type { QuickFieldType, QuickFormFieldControlProps, QuickFormFieldMode, QuickFormFieldMoreActions, QuickFormFieldOption, QuickFormFieldProps, QuickFormFieldStrings, VariableInsertContext, } from './types';
2
+ export type { QuickFieldType, QuickFormFieldControlProps, QuickFormFieldMode, QuickFormFieldModeSwitchConfirm, QuickFormFieldMoreActions, QuickFormFieldOption, QuickFormFieldProps, QuickFormFieldStrings, VariableInsertContext, } from './types';
3
3
  export { DEFAULT_QUICK_FORM_FIELD_STRINGS, FIELD_TYPE_META, FIELD_TYPE_ORDER } from './types';