@scaleflex/ui-tw 0.0.152 → 0.0.153

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/button/button.types.d.ts +4 -4
  2. package/button/components/end-icon.js +3 -0
  3. package/button/components/start-icon.js +12 -6
  4. package/color-picker/color-picker.component.js +6 -3
  5. package/color-picker/color-picker.types.d.ts +4 -4
  6. package/combobox/combobox-multi-checkbox/combobox-multi-checkbox.component.js +8 -4
  7. package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +6 -3
  8. package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +1 -1
  9. package/combobox/combobox-single/combobox-single.component.js +3 -3
  10. package/combobox/combobox-users/combobox-users.component.js +9 -8
  11. package/combobox/combobox.component.js +30 -18
  12. package/combobox/combobox.types.d.ts +9 -8
  13. package/command/command.component.d.ts +2 -2
  14. package/command/command.component.js +28 -13
  15. package/command/command.utils.d.ts +4 -2
  16. package/command/command.utils.js +6 -1
  17. package/dialog/dialog.component.d.ts +1 -1
  18. package/dialog/dialog.component.js +4 -2
  19. package/dialog/dialog.types.d.ts +2 -0
  20. package/form/components/form-checkbox-field.component.js +4 -2
  21. package/form/components/form-checkbox-group-field.component.js +7 -5
  22. package/form/components/form-field-group.component.js +7 -5
  23. package/form/components/form-radio-group-field.component.js +7 -5
  24. package/form/components/form-switch-field.component.js +6 -4
  25. package/form/form.types.d.ts +24 -24
  26. package/input-tags/input-tags.component.js +18 -15
  27. package/label/components/label-icon.js +8 -3
  28. package/label/label.types.d.ts +4 -4
  29. package/package.json +2 -2
  30. package/select/components/select-icon.js +3 -0
  31. package/select/components/selector.js +13 -9
  32. package/select/select.types.d.ts +5 -5
  33. package/textarea/components/textarea-with-actions.js +7 -5
  34. package/textarea/textarea.types.d.ts +2 -2
  35. package/tooltip/tooltip.component.js +3 -2
  36. package/tooltip/tooltip.types.d.ts +1 -1
@@ -6,15 +6,15 @@ export type ButtonSizeType = (typeof ButtonSize)[keyof typeof ButtonSize];
6
6
  export type ButtonVariantType = (typeof ButtonVariant)[keyof typeof ButtonVariant];
7
7
  export interface ButtonProps extends ComponentProps<'button'>, VariantProps<typeof buttonVariants> {
8
8
  asChild?: boolean;
9
- startIcon?: ReactElement;
10
- endIcon?: ReactElement;
9
+ startIcon?: ReactElement | (() => ReactElement);
10
+ endIcon?: ReactElement | (() => ReactElement);
11
11
  loading?: boolean;
12
12
  disabled?: boolean;
13
13
  }
14
14
  export interface EndIconProps extends ComponentProps<'span'>, Pick<ButtonProps, 'size' | 'variant'> {
15
- icon?: ReactElement;
15
+ icon?: ReactElement | (() => ReactElement);
16
16
  }
17
17
  export interface StartIconProps extends ComponentProps<'span'>, Pick<ButtonProps, 'size' | 'variant'> {
18
- icon?: ReactElement;
18
+ icon?: ReactElement | (() => ReactElement);
19
19
  loading?: boolean;
20
20
  }
@@ -18,6 +18,9 @@ var EndIcon = function EndIcon(props) {
18
18
  variant = props.variant,
19
19
  rest = _objectWithoutProperties(props, _excluded);
20
20
  if (!icon) return null;
21
+ if (typeof icon === 'function') {
22
+ return icon();
23
+ }
21
24
  return /*#__PURE__*/cloneElement(icon, _objectSpread({
22
25
  className: endIconVariants({
23
26
  size: size,
@@ -22,15 +22,21 @@ var StartIcon = function StartIcon(props) {
22
22
  loading = _props$loading === void 0 ? false : _props$loading,
23
23
  rest = _objectWithoutProperties(props, _excluded);
24
24
  if (!icon) return null;
25
- return loading ? /*#__PURE__*/React.createElement(SpinnerIcon, {
26
- className: cn(startIconVariants({
27
- size: size
28
- }), 'animate-spin')
29
- }) : (/*#__PURE__*/cloneElement(icon, _objectSpread({
25
+ if (loading) {
26
+ return /*#__PURE__*/React.createElement(SpinnerIcon, {
27
+ className: cn(startIconVariants({
28
+ size: size
29
+ }), 'animate-spin')
30
+ });
31
+ }
32
+ if (typeof icon === 'function') {
33
+ return icon();
34
+ }
35
+ return /*#__PURE__*/cloneElement(icon, _objectSpread({
30
36
  className: startIconVariants({
31
37
  variant: variant,
32
38
  size: size
33
39
  })
34
- }, rest)));
40
+ }, rest));
35
41
  };
36
42
  export { StartIcon, startIconVariants };
@@ -27,6 +27,9 @@ function ColorPicker(_ref) {
27
27
  _ref$displayAsInput = _ref.displayAsInput,
28
28
  displayAsInput = _ref$displayAsInput === void 0 ? false : _ref$displayAsInput,
29
29
  overlayClassName = _ref.overlayClassName;
30
+ var resolvedTitle = typeof title === 'function' ? title() : title;
31
+ var resolvedCancelLabel = typeof cancelLabel === 'function' ? cancelLabel() : cancelLabel;
32
+ var resolvedSelectLabel = typeof selectLabel === 'function' ? selectLabel() : selectLabel;
30
33
  var _useState = useState(value),
31
34
  _useState2 = _slicedToArray(_useState, 2),
32
35
  tempValue = _useState2[0],
@@ -77,7 +80,7 @@ function ColorPicker(_ref) {
77
80
  variant: "centered",
78
81
  className: cn('w-[316px]', className),
79
82
  overlayClassName: overlayClassName
80
- }, /*#__PURE__*/React.createElement(DialogHeader, null, /*#__PURE__*/React.createElement(DialogIcon, null, /*#__PURE__*/React.createElement(PaletteIcon, null)), /*#__PURE__*/React.createElement(DialogTitle, null, title || 'Pick color')), /*#__PURE__*/React.createElement(DialogBody, {
83
+ }, /*#__PURE__*/React.createElement(DialogHeader, null, /*#__PURE__*/React.createElement(DialogIcon, null, /*#__PURE__*/React.createElement(PaletteIcon, null)), /*#__PURE__*/React.createElement(DialogTitle, null, resolvedTitle || 'Pick color')), /*#__PURE__*/React.createElement(DialogBody, {
81
84
  className: "space-y-4"
82
85
  }, /*#__PURE__*/React.createElement(HexColorPicker, {
83
86
  color: tempValue,
@@ -107,11 +110,11 @@ function ColorPicker(_ref) {
107
110
  variant: "outline",
108
111
  className: "flex-1",
109
112
  onClick: handleCancel
110
- }, cancelLabel || 'Cancel')), /*#__PURE__*/React.createElement(DialogTrigger, {
113
+ }, resolvedCancelLabel || 'Cancel')), /*#__PURE__*/React.createElement(DialogTrigger, {
111
114
  asChild: true
112
115
  }, /*#__PURE__*/React.createElement(Button, {
113
116
  className: "flex-1",
114
117
  onClick: handleSelect
115
- }, selectLabel || 'Select')))));
118
+ }, resolvedSelectLabel || 'Select')))));
116
119
  }
117
120
  export { ColorPicker };
@@ -7,12 +7,12 @@ export type ColorPickerProps = {
7
7
  inputTriggerProps?: InputHTMLAttributes<HTMLInputElement>;
8
8
  className?: string;
9
9
  overlayClassName?: string;
10
- title?: string | ReactElement;
11
- cancelLabel?: string | ReactElement;
12
- selectLabel?: string | ReactElement;
10
+ title?: string | ReactElement | (() => ReactElement);
11
+ cancelLabel?: string | ReactElement | (() => ReactElement);
12
+ selectLabel?: string | ReactElement | (() => ReactElement);
13
13
  inputClassName?: string;
14
14
  children?: ReactNode;
15
- placeholder?: ReactElement | string;
15
+ placeholder?: string;
16
16
  presetColors?: string[];
17
17
  displayAsInput?: boolean;
18
18
  };
@@ -45,6 +45,7 @@ export function ComboboxMultiCheckbox(_ref) {
45
45
  _ref$displayCount = _ref.displayCount,
46
46
  displayCount = _ref$displayCount === void 0 ? false : _ref$displayCount,
47
47
  rest = _objectWithoutProperties(_ref, _excluded);
48
+ var resolvedLabel = typeof label === 'function' ? label() : label;
48
49
  var _useState = useState(defaultOpen),
49
50
  _useState2 = _slicedToArray(_useState, 2),
50
51
  open = _useState2[0],
@@ -58,7 +59,8 @@ export function ComboboxMultiCheckbox(_ref) {
58
59
  var option = _step.value;
59
60
  if (isOptionGroup(option)) {
60
61
  if (option.value && selectedValue.includes(option.value)) {
61
- labels.push(option.label);
62
+ var l = typeof option.label === 'function' ? option.label() : option.label;
63
+ labels.push(l);
62
64
  }
63
65
  var _iterator2 = _createForOfIteratorHelper(option.options),
64
66
  _step2;
@@ -66,7 +68,8 @@ export function ComboboxMultiCheckbox(_ref) {
66
68
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
67
69
  var sub = _step2.value;
68
70
  if (selectedValue.includes(sub.value)) {
69
- labels.push(sub.label);
71
+ var _l = typeof sub.label === 'function' ? sub.label() : sub.label;
72
+ labels.push(_l);
70
73
  }
71
74
  }
72
75
  } catch (err) {
@@ -76,7 +79,8 @@ export function ComboboxMultiCheckbox(_ref) {
76
79
  }
77
80
  } else {
78
81
  if (selectedValue.includes(option.value)) {
79
- labels.push(option.label);
82
+ var _l2 = typeof option.label === 'function' ? option.label() : option.label;
83
+ labels.push(_l2);
80
84
  }
81
85
  }
82
86
  }
@@ -173,7 +177,7 @@ export function ComboboxMultiCheckbox(_ref) {
173
177
  }, /*#__PURE__*/React.createElement(ComboboxCheckboxTrigger, {
174
178
  open: open,
175
179
  icon: icon,
176
- label: label,
180
+ label: resolvedLabel,
177
181
  disabled: disabled,
178
182
  className: className,
179
183
  size: size,
@@ -53,7 +53,8 @@ export function ComboboxMultiInline(_ref) {
53
53
  var option = _step.value;
54
54
  if (isOptionGroup(option)) {
55
55
  if (option.value && value.includes(option.value)) {
56
- labels.push(option.label);
56
+ var label = typeof option.label === 'function' ? option.label() : option.label;
57
+ labels.push(label);
57
58
  }
58
59
  var _iterator2 = _createForOfIteratorHelper(option.options),
59
60
  _step2;
@@ -61,7 +62,8 @@ export function ComboboxMultiInline(_ref) {
61
62
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
62
63
  var sub = _step2.value;
63
64
  if (value.includes(sub.value)) {
64
- labels.push(sub.label);
65
+ var _label = typeof sub.label === 'function' ? sub.label() : sub.label;
66
+ labels.push(_label);
65
67
  }
66
68
  }
67
69
  } catch (err) {
@@ -71,7 +73,8 @@ export function ComboboxMultiInline(_ref) {
71
73
  }
72
74
  } else {
73
75
  if (value.includes(option.value)) {
74
- labels.push(option.label);
76
+ var _label2 = typeof option.label === 'function' ? option.label() : option.label;
77
+ labels.push(_label2);
75
78
  }
76
79
  }
77
80
  }
@@ -114,7 +114,7 @@ export function ComboboxMultiTag(_ref) {
114
114
  isTriggerOnBlur: true
115
115
  });
116
116
  }
117
- }, option.label);
117
+ }, typeof option.label === 'function' ? option.label() : option.label);
118
118
  })), isSelected ? /*#__PURE__*/React.createElement("div", {
119
119
  className: "flex w-full items-center justify-between p-1.5"
120
120
  }, /*#__PURE__*/React.createElement("div", {
@@ -50,13 +50,13 @@ export function ComboboxSingle(_ref) {
50
50
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
51
51
  var option = _step.value;
52
52
  if (isOptionGroup(option)) {
53
- if (option.value === value) return option.label;
53
+ if (option.value === value) return typeof option.label === 'function' ? option.label() : option.label;
54
54
  var found = option.options.find(function (o) {
55
55
  return o.value === value;
56
56
  });
57
- if (found) return found.label;
57
+ if (found) return typeof found.label === 'function' ? found.label() : found.label;
58
58
  } else if (option.value === value) {
59
- return option.label;
59
+ return typeof option.label === 'function' ? option.label() : option.label;
60
60
  }
61
61
  }
62
62
  } catch (err) {
@@ -152,7 +152,7 @@ export function ComboboxUsers(_ref) {
152
152
  alt: "profile image"
153
153
  }) : /*#__PURE__*/React.createElement(UserCircle2Icon, {
154
154
  className: "text-muted-foreground size-5"
155
- }), /*#__PURE__*/React.createElement("span", null, option.email)));
155
+ }), /*#__PURE__*/React.createElement("span", null, typeof option.email === 'function' ? option.email() : option.email)));
156
156
  })), isSelected ? /*#__PURE__*/React.createElement("div", {
157
157
  className: "flex w-full items-center justify-between p-1.5"
158
158
  }, /*#__PURE__*/React.createElement("div", {
@@ -181,9 +181,10 @@ export function ComboboxUsers(_ref) {
181
181
  className: "border-0 border-none"
182
182
  }), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, null, "No results found."), options === null || options === void 0 ? void 0 : options.map(function (option, groupIndex) {
183
183
  if (isUserOptionGroup(option)) {
184
+ var resolvedGroupLabel = typeof option.label === 'function' ? option.label() : option.label;
184
185
  return /*#__PURE__*/React.createElement(CommandGroup, {
185
186
  key: groupIndex,
186
- heading: !option.value ? option.label : undefined,
187
+ heading: !option.value ? resolvedGroupLabel : undefined,
187
188
  size: size
188
189
  }, option.value && /*#__PURE__*/React.createElement(CommandItem, {
189
190
  size: size,
@@ -202,26 +203,26 @@ export function ComboboxUsers(_ref) {
202
203
  className: cn('text-secondary-foreground', selectLabelVariants({
203
204
  size: size
204
205
  }))
205
- }, option.label), option.options.map(function (_ref3) {
206
+ }, resolvedGroupLabel), option.options.map(function (_ref3) {
206
207
  var name = _ref3.name,
207
208
  email = _ref3.email,
208
209
  profileUrl = _ref3.profileUrl,
209
- value = _ref3.value,
210
+ subValue = _ref3.value,
210
211
  disabled = _ref3.disabled;
211
- var isGroupSelected = option.value && Array.isArray(value) && value.includes(option.value);
212
+ var isGroupSelected = option.value && value.includes(option.value);
212
213
  return /*#__PURE__*/React.createElement(CommandUserItem, {
213
214
  size: size,
214
215
  multiple: true,
215
216
  disabled: disabled || !!isGroupSelected,
216
- key: value,
217
+ key: subValue,
217
218
  name: name,
218
219
  email: email,
219
220
  profileUrl: profileUrl,
220
- value: value,
221
+ value: subValue,
221
222
  isGroup: !!option.label,
222
223
  selectedValue: value,
223
224
  onSelect: function onSelect() {
224
- return toggleValue(value);
225
+ return toggleValue(subValue);
225
226
  }
226
227
  });
227
228
  }), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
@@ -196,7 +196,7 @@ export function ComboboxContent(_ref4) {
196
196
  selectedValue = _ref4.value,
197
197
  _onSelect = _ref4.onSelect,
198
198
  _ref4$size = _ref4.size,
199
- size = _ref4$size === void 0 ? 'md' : _ref4$size,
199
+ size = _ref4$size === void 0 ? FormSize.Md : _ref4$size,
200
200
  _ref4$multiple = _ref4.multiple,
201
201
  multiple = _ref4$multiple === void 0 ? false : _ref4$multiple,
202
202
  className = _ref4.className,
@@ -217,11 +217,11 @@ export function ComboboxContent(_ref4) {
217
217
  placeholder: searchPlaceholder,
218
218
  className: "border-0 border-none"
219
219
  }), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, null, "No results found."), options === null || options === void 0 ? void 0 : options.map(function (option, groupIndex) {
220
- var _option$optionLabel;
221
220
  if (isOptionGroup(option)) {
221
+ var resolvedGroupLabel = typeof option.label === 'function' ? option.label() : option.label;
222
222
  return /*#__PURE__*/React.createElement(CommandGroup, {
223
223
  key: groupIndex,
224
- heading: !option.value || noGroupSelection ? option.label : undefined,
224
+ heading: !option.value || noGroupSelection ? resolvedGroupLabel : undefined,
225
225
  size: size
226
226
  }, !noGroupSelection && option.value && /*#__PURE__*/React.createElement(CommandItem, {
227
227
  size: size,
@@ -240,7 +240,7 @@ export function ComboboxContent(_ref4) {
240
240
  className: cn('text-secondary-foreground', selectLabelVariants({
241
241
  size: size
242
242
  }))
243
- }, option.label), option.options.map(function (_ref5) {
243
+ }, resolvedGroupLabel), option.options.map(function (_ref5) {
244
244
  var label = _ref5.label,
245
245
  optionLabel = _ref5.optionLabel,
246
246
  value = _ref5.value,
@@ -248,6 +248,8 @@ export function ComboboxContent(_ref4) {
248
248
  icon = _ref5.icon,
249
249
  tooltip = _ref5.tooltip,
250
250
  disabledTooltip = _ref5.disabledTooltip;
251
+ var resolvedLabel = typeof label === 'function' ? label() : label;
252
+ var resolvedOptionLabel = typeof optionLabel === 'function' ? optionLabel() : optionLabel;
251
253
  var isGroupSelected = !noGroupSelection && multiple && option.value && Array.isArray(selectedValue) && selectedValue.includes(option.value);
252
254
  return /*#__PURE__*/React.createElement(CommandItem, {
253
255
  size: size,
@@ -258,14 +260,17 @@ export function ComboboxContent(_ref4) {
258
260
  value: value,
259
261
  tooltip: tooltip,
260
262
  disabledTooltip: disabledTooltip,
261
- isGroup: !!option.label,
263
+ isGroup: !!resolvedGroupLabel,
262
264
  selectedValue: selectedValue,
263
265
  onSelect: function onSelect() {
264
266
  return _onSelect(value);
265
- }
266
- }, optionLabel !== null && optionLabel !== void 0 ? optionLabel : label);
267
+ },
268
+ labelTooltip: resolvedOptionLabel && typeof resolvedLabel === 'string' ? resolvedLabel : undefined
269
+ }, resolvedOptionLabel !== null && resolvedOptionLabel !== void 0 ? resolvedOptionLabel : resolvedLabel);
267
270
  }), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
268
271
  }
272
+ var resolvedLabel = typeof option.label === 'function' ? option.label() : option.label;
273
+ var resolvedOptionLabel = typeof option.optionLabel === 'function' ? option.optionLabel() : option.optionLabel;
269
274
  return /*#__PURE__*/React.createElement(CommandGroup, {
270
275
  key: groupIndex
271
276
  }, /*#__PURE__*/React.createElement(CommandItem, {
@@ -280,8 +285,9 @@ export function ComboboxContent(_ref4) {
280
285
  selectedValue: selectedValue,
281
286
  onSelect: function onSelect() {
282
287
  return _onSelect(option.value);
283
- }
284
- }, (_option$optionLabel = option.optionLabel) !== null && _option$optionLabel !== void 0 ? _option$optionLabel : option.label));
288
+ },
289
+ labelTooltip: resolvedOptionLabel && typeof resolvedLabel === 'string' ? resolvedLabel : undefined
290
+ }, resolvedOptionLabel !== null && resolvedOptionLabel !== void 0 ? resolvedOptionLabel : resolvedLabel));
285
291
  }), !fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
286
292
  actions: actions
287
293
  })), fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
@@ -293,7 +299,7 @@ export function ComboboxCheckboxContent(_ref6) {
293
299
  selectedValue = _ref6.value,
294
300
  _onSelect2 = _ref6.onSelect,
295
301
  _ref6$size = _ref6.size,
296
- size = _ref6$size === void 0 ? 'md' : _ref6$size,
302
+ size = _ref6$size === void 0 ? FormSize.Md : _ref6$size,
297
303
  className = _ref6.className,
298
304
  _ref6$showGroupSepara = _ref6.showGroupSeparator,
299
305
  showGroupSeparator = _ref6$showGroupSepara === void 0 ? false : _ref6$showGroupSepara,
@@ -310,11 +316,11 @@ export function ComboboxCheckboxContent(_ref6) {
310
316
  placeholder: searchPlaceholder,
311
317
  className: "border-0 border-none"
312
318
  }), /*#__PURE__*/React.createElement(CommandList, null, /*#__PURE__*/React.createElement(CommandEmpty, null, "No results found."), options === null || options === void 0 ? void 0 : options.map(function (option, groupIndex) {
313
- var _option$optionLabel2;
314
319
  if (isOptionGroup(option)) {
320
+ var resolvedGroupLabel = typeof option.label === 'function' ? option.label() : option.label;
315
321
  return /*#__PURE__*/React.createElement(CommandGroup, {
316
322
  key: groupIndex,
317
- heading: !option.value ? option.label : undefined,
323
+ heading: !option.value ? resolvedGroupLabel : undefined,
318
324
  size: size
319
325
  }, option.value && /*#__PURE__*/React.createElement(CommandCheckboxItem, {
320
326
  size: size,
@@ -332,7 +338,7 @@ export function ComboboxCheckboxContent(_ref6) {
332
338
  className: cn('text-secondary-foreground', selectLabelVariants({
333
339
  size: size
334
340
  }))
335
- }, option.label), option.options.map(function (_ref7) {
341
+ }, resolvedGroupLabel), option.options.map(function (_ref7) {
336
342
  var label = _ref7.label,
337
343
  optionLabel = _ref7.optionLabel,
338
344
  value = _ref7.value,
@@ -340,6 +346,8 @@ export function ComboboxCheckboxContent(_ref6) {
340
346
  icon = _ref7.icon,
341
347
  tooltip = _ref7.tooltip,
342
348
  disabledTooltip = _ref7.disabledTooltip;
349
+ var resolvedLabel = typeof label === 'function' ? label() : label;
350
+ var resolvedOptionLabel = typeof optionLabel === 'function' ? optionLabel() : optionLabel;
343
351
  var isGroupSelected = option.value && Array.isArray(selectedValue) && selectedValue.includes(option.value);
344
352
  return /*#__PURE__*/React.createElement(CommandCheckboxItem, {
345
353
  size: size,
@@ -349,14 +357,17 @@ export function ComboboxCheckboxContent(_ref6) {
349
357
  value: value,
350
358
  tooltip: tooltip,
351
359
  disabledTooltip: disabledTooltip,
352
- isGroup: !!option.label,
360
+ isGroup: !!resolvedGroupLabel,
353
361
  selectedValue: selectedValue,
354
362
  onSelect: function onSelect() {
355
363
  return _onSelect2(value);
356
- }
357
- }, optionLabel !== null && optionLabel !== void 0 ? optionLabel : label);
364
+ },
365
+ labelTooltip: resolvedOptionLabel && typeof resolvedLabel === 'string' ? resolvedLabel : undefined
366
+ }, resolvedOptionLabel !== null && resolvedOptionLabel !== void 0 ? resolvedOptionLabel : resolvedLabel);
358
367
  }), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
359
368
  }
369
+ var resolvedLabel = typeof option.label === 'function' ? option.label() : option.label;
370
+ var resolvedOptionLabel = typeof option.optionLabel === 'function' ? option.optionLabel() : option.optionLabel;
360
371
  return /*#__PURE__*/React.createElement(CommandGroup, {
361
372
  key: groupIndex
362
373
  }, /*#__PURE__*/React.createElement(CommandCheckboxItem, {
@@ -370,8 +381,9 @@ export function ComboboxCheckboxContent(_ref6) {
370
381
  selectedValue: selectedValue,
371
382
  onSelect: function onSelect() {
372
383
  return _onSelect2(option.value);
373
- }
374
- }, (_option$optionLabel2 = option.optionLabel) !== null && _option$optionLabel2 !== void 0 ? _option$optionLabel2 : option.label));
384
+ },
385
+ labelTooltip: resolvedOptionLabel && typeof resolvedLabel === 'string' ? resolvedLabel : undefined
386
+ }, resolvedOptionLabel !== null && resolvedOptionLabel !== void 0 ? resolvedOptionLabel : resolvedLabel));
375
387
  }), !fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
376
388
  actions: actions
377
389
  })), fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
@@ -25,7 +25,7 @@ export type ComboboxTriggerProps = {
25
25
  export type ComboboxCheckboxTriggerProps = ComboboxTriggerProps & {
26
26
  optionsLength: number;
27
27
  selectedLength: number;
28
- label?: ReactNode | string;
28
+ label?: ReactNode;
29
29
  displayCount?: boolean;
30
30
  icon?: ElementType;
31
31
  iconClassName?: string;
@@ -61,20 +61,21 @@ export interface CommandGroupProps extends ComponentProps<typeof CommandPrimitiv
61
61
  size?: FormSizeType;
62
62
  }
63
63
  export interface CommandItemProps extends ComponentProps<typeof CommandPrimitive.Item> {
64
- icon?: ReactElement;
64
+ icon?: ReactElement | (() => ReactElement);
65
65
  size?: FormSizeType;
66
- tooltip?: ReactElement | string;
67
- disabledTooltip?: ReactElement | string;
66
+ tooltip?: ReactElement | string | (() => ReactElement);
67
+ disabledTooltip?: ReactElement | string | (() => ReactElement);
68
68
  isGroup?: boolean;
69
- shortcut?: ReactElement | string;
69
+ shortcut?: ReactElement | string | (() => ReactElement);
70
70
  selectedValue?: string | string[];
71
71
  multiple?: boolean;
72
72
  iconClassName?: string;
73
73
  textClassName?: string;
74
+ labelTooltip?: string;
74
75
  }
75
76
  export interface CommandUserItemProps extends Omit<CommandItemProps, 'icon' | 'children' | 'tooltip' | 'disabledTooltip'> {
76
- name: ReactElement | string;
77
- email: ReactElement | string;
77
+ name: ReactElement | string | (() => ReactElement);
78
+ email: ReactElement | string | (() => ReactElement);
78
79
  profileUrl?: string;
79
80
  }
80
81
  interface ComboboxCommonProps {
@@ -110,7 +111,7 @@ export interface ComboboxMultiInlineProps extends ComboboxCommonProps {
110
111
  export interface ComboboxMultiCheckboxProps extends ComboboxCommonProps {
111
112
  value: string[];
112
113
  onChange: (value: string[]) => void;
113
- label?: ReactElement | string;
114
+ label?: ReactElement | string | (() => ReactElement);
114
115
  displayCount?: boolean;
115
116
  iconClassName?: string;
116
117
  icon?: ElementType;
@@ -14,8 +14,8 @@ declare function CommandList({ className, ...props }: ComponentProps<typeof Comm
14
14
  declare function CommandEmpty({ className, ...rest }: ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element;
15
15
  declare function CommandGroup({ className, size, ...props }: CommandGroupProps): React.JSX.Element;
16
16
  declare function CommandSeparator({ className, ...props }: ComponentProps<typeof CommandPrimitive.Separator>): React.JSX.Element;
17
- declare function CommandItem({ className, size, isGroup, icon, tooltip, children, selectedValue, multiple, value, shortcut, disabledTooltip, disabled, iconClassName, textClassName, ...props }: CommandItemProps): React.JSX.Element;
17
+ declare function CommandItem({ className, size, isGroup, icon, tooltip, children, selectedValue, multiple, value, shortcut, disabledTooltip, disabled, iconClassName, textClassName, labelTooltip, ...props }: CommandItemProps): React.JSX.Element;
18
18
  declare function CommandUserItem({ className, size, isGroup, name, email, profileUrl, selectedValue, multiple, value, disabled, textClassName, ...props }: CommandUserItemProps): React.JSX.Element;
19
- declare function CommandCheckboxItem({ className, textClassName, size, isGroup, children, selectedValue, value, icon, disabled, tooltip, disabledTooltip, ...props }: CommandItemProps): React.JSX.Element;
19
+ declare function CommandCheckboxItem({ className, textClassName, size, isGroup, children, selectedValue, value, icon, disabled, tooltip, disabledTooltip, labelTooltip, ...props }: CommandItemProps): React.JSX.Element;
20
20
  declare function CommandShortcut({ className, ...props }: ComponentProps<'span'>): React.JSX.Element;
21
21
  export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator, CommandClear, CommandUserItem, };
@@ -9,9 +9,9 @@ var _excluded = ["className"],
9
9
  _excluded6 = ["className"],
10
10
  _excluded7 = ["className", "size"],
11
11
  _excluded8 = ["className"],
12
- _excluded9 = ["className", "size", "isGroup", "icon", "tooltip", "children", "selectedValue", "multiple", "value", "shortcut", "disabledTooltip", "disabled", "iconClassName", "textClassName"],
12
+ _excluded9 = ["className", "size", "isGroup", "icon", "tooltip", "children", "selectedValue", "multiple", "value", "shortcut", "disabledTooltip", "disabled", "iconClassName", "textClassName", "labelTooltip"],
13
13
  _excluded10 = ["className", "size", "isGroup", "name", "email", "profileUrl", "selectedValue", "multiple", "value", "disabled", "textClassName"],
14
- _excluded11 = ["className", "textClassName", "size", "isGroup", "children", "selectedValue", "value", "icon", "disabled", "tooltip", "disabledTooltip"],
14
+ _excluded11 = ["className", "textClassName", "size", "isGroup", "children", "selectedValue", "value", "icon", "disabled", "tooltip", "disabledTooltip", "labelTooltip"],
15
15
  _excluded12 = ["className"];
16
16
  import { ButtonVariant, buttonVariants } from '@scaleflex/ui-tw/button';
17
17
  import { getIconSizeInRem } from '@scaleflex/ui-tw/button/button.utils';
@@ -22,15 +22,15 @@ import { crossSizeOptions } from '@scaleflex/ui-tw/search/search.constants';
22
22
  import { SelectIcon } from '@scaleflex/ui-tw/select/components/select-icon';
23
23
  import { selectItemVariants, selectTriggerVariants } from '@scaleflex/ui-tw/select/select.component';
24
24
  import { getOptionInGroupPaddingLeft } from '@scaleflex/ui-tw/select/select.utils';
25
+ import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
25
26
  import { FormSize } from '@scaleflex/ui-tw/types/form-size';
26
27
  import { cn } from '@scaleflex/ui-tw/utils/cn';
27
28
  import { cva } from 'class-variance-authority';
28
- import { Command as CommandPrimitive } from 'cmdk';
29
- import { useCommandState } from 'cmdk';
29
+ import { Command as CommandPrimitive, useCommandState } from 'cmdk';
30
30
  import { CheckIcon, SearchIcon, UserCircle2Icon, XIcon } from 'lucide-react';
31
31
  import React from 'react';
32
32
  import { useCallback } from 'react';
33
- import { selectCommandHeadingOptions } from './command.utils';
33
+ import { selectCommandHeadingOptions, truncateLabelTooltip } from './command.utils';
34
34
  function Command(_ref) {
35
35
  var className = _ref.className,
36
36
  props = _objectWithoutProperties(_ref, _excluded);
@@ -192,8 +192,11 @@ function CommandItem(_ref9) {
192
192
  disabled = _ref9.disabled,
193
193
  iconClassName = _ref9.iconClassName,
194
194
  textClassName = _ref9.textClassName,
195
+ labelTooltip = _ref9.labelTooltip,
195
196
  props = _objectWithoutProperties(_ref9, _excluded9);
196
197
  var selected = value && (multiple ? selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value) : value === selectedValue);
198
+ var resolvedShortcut = typeof shortcut === 'function' ? shortcut() : shortcut;
199
+ var resolvedLabelTooltip = truncateLabelTooltip(labelTooltip !== null && labelTooltip !== void 0 ? labelTooltip : typeof children === 'string' ? children : undefined);
197
200
  return /*#__PURE__*/React.createElement(CommandPrimitive.Item, _extends({
198
201
  "data-slot": "command-item",
199
202
  className: cn('relative flex w-full cursor-pointer items-center justify-between gap-2 outline-hidden select-none', '*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2', 'data-[selected=true]:bg-secondary data-[selected=true]:text-foreground', '!opacity-100 data-[disabled=true]:cursor-not-allowed', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", selectItemVariants({
@@ -209,16 +212,18 @@ function CommandItem(_ref9) {
209
212
  className: cn('text-muted-foreground hover:text-primary shrink-0', selected && 'text-primary', disabled && 'opacity-50', iconClassName)
210
213
  }), /*#__PURE__*/React.createElement("div", {
211
214
  className: "flex items-center gap-1 overflow-hidden"
215
+ }, /*#__PURE__*/React.createElement(WithTooltip, {
216
+ content: resolvedLabelTooltip
212
217
  }, /*#__PURE__*/React.createElement("div", {
213
218
  className: cn('line-clamp-2 overflow-hidden text-left break-words text-ellipsis', textClassName, disabled && 'opacity-50')
214
- }, children), (tooltip || disabledTooltip) && /*#__PURE__*/React.createElement("div", {
219
+ }, children)), (tooltip || disabledTooltip) && /*#__PURE__*/React.createElement("div", {
215
220
  className: "flex shrink-0 items-center"
216
221
  }, /*#__PURE__*/React.createElement(LabelIcon, {
217
222
  size: size,
218
223
  tooltip: disabled ? disabledTooltip : tooltip
219
- })))), shortcut && /*#__PURE__*/React.createElement(CommandShortcut, {
224
+ })))), resolvedShortcut && /*#__PURE__*/React.createElement(CommandShortcut, {
220
225
  className: cn(disabled && 'opacity-50')
221
- }, shortcut), /*#__PURE__*/React.createElement("span", {
226
+ }, resolvedShortcut), /*#__PURE__*/React.createElement("span", {
222
227
  className: "absolute right-2 flex size-3.5 items-center justify-center"
223
228
  }, /*#__PURE__*/React.createElement(CheckIcon, {
224
229
  className: cn('text-primary ml-auto h-4 w-4', selected ? 'opacity-100' : 'opacity-0')
@@ -238,6 +243,8 @@ function CommandUserItem(_ref10) {
238
243
  textClassName = _ref10.textClassName,
239
244
  props = _objectWithoutProperties(_ref10, _excluded10);
240
245
  var selected = value && (multiple ? selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value) : value === selectedValue);
246
+ var resolvedName = typeof name === 'function' ? name() : name;
247
+ var resolvedEmail = typeof email === 'function' ? email() : email;
241
248
  return /*#__PURE__*/React.createElement(CommandPrimitive.Item, _extends({
242
249
  "data-slot": "command-item",
243
250
  className: cn('relative flex w-full cursor-pointer items-center justify-between gap-2 outline-hidden select-none', '*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2', 'data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground', '!opacity-100 data-[disabled=true]:cursor-not-allowed', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", selectItemVariants({
@@ -258,11 +265,15 @@ function CommandUserItem(_ref10) {
258
265
  className: "size-8"
259
266
  })), /*#__PURE__*/React.createElement("div", {
260
267
  className: "max-w-10/12"
268
+ }, /*#__PURE__*/React.createElement(WithTooltip, {
269
+ content: typeof resolvedName === 'string' ? truncateLabelTooltip(resolvedName) : undefined
261
270
  }, /*#__PURE__*/React.createElement("div", {
262
271
  className: cn('w-full overflow-hidden text-sm text-ellipsis whitespace-nowrap', textClassName)
263
- }, name), /*#__PURE__*/React.createElement("div", {
272
+ }, resolvedName)), /*#__PURE__*/React.createElement(WithTooltip, {
273
+ content: typeof resolvedEmail === 'string' ? truncateLabelTooltip(resolvedEmail) : undefined
274
+ }, /*#__PURE__*/React.createElement("div", {
264
275
  className: cn('text-secondary-foreground w-full overflow-hidden text-xs text-ellipsis whitespace-nowrap', textClassName)
265
- }, email))), /*#__PURE__*/React.createElement("span", {
276
+ }, resolvedEmail)))), /*#__PURE__*/React.createElement("span", {
266
277
  className: "absolute right-2 flex size-3.5 items-center justify-center"
267
278
  }, /*#__PURE__*/React.createElement(CheckIcon, {
268
279
  className: cn('text-primary ml-auto h-4 w-4', selected ? 'opacity-100' : 'opacity-0')
@@ -280,11 +291,13 @@ function CommandCheckboxItem(_ref11) {
280
291
  disabled = _ref11.disabled,
281
292
  tooltip = _ref11.tooltip,
282
293
  disabledTooltip = _ref11.disabledTooltip,
294
+ labelTooltip = _ref11.labelTooltip,
283
295
  props = _objectWithoutProperties(_ref11, _excluded11);
284
296
  var selected = value && (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value));
297
+ var resolvedLabelTooltip = truncateLabelTooltip(labelTooltip !== null && labelTooltip !== void 0 ? labelTooltip : typeof children === 'string' ? children : undefined);
285
298
  return /*#__PURE__*/React.createElement(CommandPrimitive.Item, _extends({
286
299
  "data-slot": "command-checkbox-item",
287
- className: cn('relative flex w-full cursor-pointer items-center gap-3 outline-none select-none', 'data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground', '!opacity-100 data-[disabled=true]:cursor-not-allowed', selectItemVariants({
300
+ className: cn('relative flex w-full cursor-pointer items-center gap-3 outline-hidden select-none', 'data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground', '!opacity-100 data-[disabled=true]:cursor-not-allowed', selectItemVariants({
288
301
  size: size
289
302
  }), isGroup && getOptionInGroupPaddingLeft(size), className),
290
303
  disabled: disabled
@@ -300,9 +313,11 @@ function CommandCheckboxItem(_ref11) {
300
313
  size: size,
301
314
  icon: icon,
302
315
  className: cn('text-muted-foreground hover:text-primary !mr-1 shrink-0', selected && 'text-primary', disabled && 'opacity-50')
303
- }), /*#__PURE__*/React.createElement("div", {
316
+ }), /*#__PURE__*/React.createElement(WithTooltip, {
317
+ content: resolvedLabelTooltip
318
+ }, /*#__PURE__*/React.createElement("div", {
304
319
  className: cn('line-clamp-2 overflow-hidden text-left break-words text-ellipsis', textClassName, disabled && 'opacity-50')
305
- }, children), (tooltip || disabledTooltip) && /*#__PURE__*/React.createElement("div", {
320
+ }, children)), (tooltip || disabledTooltip) && /*#__PURE__*/React.createElement("div", {
306
321
  className: "flex shrink-0 items-center"
307
322
  }, /*#__PURE__*/React.createElement(LabelIcon, {
308
323
  size: size,
@@ -1,5 +1,7 @@
1
+ export declare const LABEL_TOOLTIP_MAX_LENGTH = 250;
2
+ export declare function truncateLabelTooltip(labelTooltip: string | undefined): string | undefined;
1
3
  export declare const selectCommandHeadingOptions: {
2
4
  readonly sm: "[&_[cmdk-group-heading]]:py-2 [&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:min-h-8 [&_[cmdk-group-heading]]:text-xs";
3
- readonly md: "[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-10 [&_[cmdk-group-heading]]:text-sm ";
4
- readonly lg: "[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-12 [&_[cmdk-group-heading]]:text-base ";
5
+ readonly md: "[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-10 [&_[cmdk-group-heading]]:text-sm";
6
+ readonly lg: "[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-12 [&_[cmdk-group-heading]]:text-base";
5
7
  };
@@ -1,3 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { FormSize } from '@scaleflex/ui-tw/types/form-size';
3
- export var selectCommandHeadingOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, '[&_[cmdk-group-heading]]:py-2 [&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:min-h-8 [&_[cmdk-group-heading]]:text-xs'), FormSize.Md, '[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-10 [&_[cmdk-group-heading]]:text-sm '), FormSize.Lg, '[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-12 [&_[cmdk-group-heading]]:text-base ');
3
+ export var LABEL_TOOLTIP_MAX_LENGTH = 250;
4
+ export function truncateLabelTooltip(labelTooltip) {
5
+ if (!labelTooltip) return undefined;
6
+ return labelTooltip.length > LABEL_TOOLTIP_MAX_LENGTH ? "".concat(labelTooltip.slice(0, LABEL_TOOLTIP_MAX_LENGTH), "\u2026") : labelTooltip;
7
+ }
8
+ export var selectCommandHeadingOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, '[&_[cmdk-group-heading]]:py-2 [&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:min-h-8 [&_[cmdk-group-heading]]:text-xs'), FormSize.Md, '[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-10 [&_[cmdk-group-heading]]:text-sm'), FormSize.Lg, '[&_[cmdk-group-heading]]:py-3 [&_[cmdk-group-heading]]:px-4 [&_[cmdk-group-heading]]:min-h-12 [&_[cmdk-group-heading]]:text-base');
@@ -6,7 +6,7 @@ declare function DialogTrigger({ ...props }: ComponentProps<typeof DialogPrimiti
6
6
  declare function DialogPortal({ ...props }: ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
7
7
  declare function DialogClose({ ...props }: ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
8
8
  declare function DialogOverlay({ className, ...props }: ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
9
- declare function DialogContent({ className, children, overlayClassName, variant, headerSize, maxWidth, ...props }: DialogContentProps): React.JSX.Element;
9
+ declare function DialogContent({ className, children, overlayClassName, variant, headerSize, maxWidth, hideCloseButton, ...props }: DialogContentProps): React.JSX.Element;
10
10
  declare function DialogHeader({ className, size, ...props }: DialogHeaderProps): React.JSX.Element;
11
11
  declare function DialogTitle({ className, size, align, ...props }: DialogTitleProps): React.JSX.Element;
12
12
  declare function DialogDescription({ className, ...props }: ComponentProps<typeof DialogPrimitive.Description>): React.JSX.Element;