@scaleflex/ui-tw 0.0.151 → 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 (44) hide show
  1. package/button/button.types.d.ts +4 -4
  2. package/button/components/copy-button.js +15 -54
  3. package/button/components/copy-to-clipboard-button.d.ts +1 -0
  4. package/button/components/copy-to-clipboard-button.js +17 -53
  5. package/button/components/end-icon.js +3 -0
  6. package/button/components/start-icon.js +12 -6
  7. package/color-picker/color-picker.component.js +6 -3
  8. package/color-picker/color-picker.types.d.ts +4 -4
  9. package/combobox/combobox-multi-checkbox/combobox-multi-checkbox.component.js +8 -4
  10. package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +6 -3
  11. package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +1 -1
  12. package/combobox/combobox-single/combobox-single.component.js +3 -3
  13. package/combobox/combobox-users/combobox-users.component.js +9 -8
  14. package/combobox/combobox.component.js +30 -18
  15. package/combobox/combobox.types.d.ts +9 -8
  16. package/command/command.component.d.ts +2 -2
  17. package/command/command.component.js +28 -13
  18. package/command/command.utils.d.ts +4 -2
  19. package/command/command.utils.js +6 -1
  20. package/copyable-text/copyable-text.component.js +17 -56
  21. package/dialog/dialog.component.d.ts +1 -1
  22. package/dialog/dialog.component.js +4 -2
  23. package/dialog/dialog.types.d.ts +2 -0
  24. package/form/components/form-checkbox-field.component.js +4 -2
  25. package/form/components/form-checkbox-group-field.component.js +7 -5
  26. package/form/components/form-field-group.component.js +7 -5
  27. package/form/components/form-radio-group-field.component.js +7 -5
  28. package/form/components/form-switch-field.component.js +6 -4
  29. package/form/form.types.d.ts +24 -24
  30. package/input-tags/input-tags.component.js +18 -15
  31. package/label/components/label-icon.js +8 -3
  32. package/label/label.types.d.ts +4 -4
  33. package/package.json +2 -2
  34. package/select/components/select-icon.js +3 -0
  35. package/select/components/selector.js +13 -9
  36. package/select/select.types.d.ts +5 -5
  37. package/textarea/components/textarea-with-actions.js +7 -5
  38. package/textarea/textarea.types.d.ts +2 -2
  39. package/tooltip/tooltip.component.js +3 -2
  40. package/tooltip/tooltip.types.d.ts +1 -1
  41. package/utils/copy-to-clipboard.d.ts +10 -0
  42. package/utils/copy-to-clipboard.js +65 -0
  43. package/utils/use-copy-to-clipboard.d.ts +13 -0
  44. package/utils/use-copy-to-clipboard.js +68 -0
@@ -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');
@@ -1,13 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
3
  var _excluded = ["value", "textToCopy", "copiedMessage", "tooltipDuration", "onCopy", "className"];
6
- import _regeneratorRuntime from "@babel/runtime/regenerator";
7
4
  import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
8
5
  import { cn } from '@scaleflex/ui-tw/utils/cn';
6
+ import { useCopyToClipboard } from '@scaleflex/ui-tw/utils/use-copy-to-clipboard';
9
7
  import { Copy } from 'lucide-react';
10
- import React, { useState } from 'react';
8
+ import React from 'react';
11
9
  function CopyableText(_ref) {
12
10
  var value = _ref.value,
13
11
  textToCopy = _ref.textToCopy,
@@ -18,66 +16,29 @@ function CopyableText(_ref) {
18
16
  onCopy = _ref.onCopy,
19
17
  className = _ref.className,
20
18
  props = _objectWithoutProperties(_ref, _excluded);
21
- var _useState = useState(''),
22
- _useState2 = _slicedToArray(_useState, 2),
23
- tooltipText = _useState2[0],
24
- setTooltipText = _useState2[1];
25
- var _useState3 = useState('default'),
26
- _useState4 = _slicedToArray(_useState3, 2),
27
- tooltipVariant = _useState4[0],
28
- setTooltipVariant = _useState4[1];
29
- var _useState5 = useState(false),
30
- _useState6 = _slicedToArray(_useState5, 2),
31
- open = _useState6[0],
32
- setOpen = _useState6[1];
33
- var handleCopy = /*#__PURE__*/function () {
34
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
35
- var text;
36
- return _regeneratorRuntime.wrap(function _callee$(_context) {
37
- while (1) switch (_context.prev = _context.next) {
38
- case 0:
39
- _context.prev = 0;
40
- text = textToCopy !== null && textToCopy !== void 0 ? textToCopy : typeof value === 'string' ? value : '';
41
- _context.next = 4;
42
- return navigator.clipboard.writeText(text);
43
- case 4:
44
- setTooltipText(copiedMessage);
45
- setTooltipVariant('success');
46
- setOpen(true);
47
- onCopy === null || onCopy === void 0 || onCopy();
48
- setTimeout(function () {
49
- setOpen(false);
50
- }, tooltipDuration - 500);
51
- setTimeout(function () {
52
- setTooltipText('');
53
- setTooltipVariant('default');
54
- }, tooltipDuration);
55
- _context.next = 15;
56
- break;
57
- case 12:
58
- _context.prev = 12;
59
- _context.t0 = _context["catch"](0);
60
- console.error('Failed to copy', _context.t0);
61
- case 15:
62
- case "end":
63
- return _context.stop();
64
- }
65
- }, _callee, null, [[0, 12]]);
66
- }));
67
- return function handleCopy() {
68
- return _ref2.apply(this, arguments);
69
- };
70
- }();
19
+ var effectiveText = textToCopy !== null && textToCopy !== void 0 ? textToCopy : typeof value === 'string' ? value : '';
20
+ var _useCopyToClipboard = useCopyToClipboard({
21
+ copiedMessage: copiedMessage,
22
+ tooltipDuration: tooltipDuration,
23
+ onCopy: onCopy
24
+ }),
25
+ tooltipText = _useCopyToClipboard.tooltipText,
26
+ tooltipVariant = _useCopyToClipboard.tooltipVariant,
27
+ open = _useCopyToClipboard.open,
28
+ handleCopy = _useCopyToClipboard.handleCopy;
71
29
  return /*#__PURE__*/React.createElement("div", _extends({
72
30
  "data-slot": "copyable-text",
73
31
  className: cn('group inline-flex items-center', className)
74
32
  }, props), /*#__PURE__*/React.createElement("span", null, value), /*#__PURE__*/React.createElement(WithTooltip, {
75
33
  content: tooltipText,
76
34
  variant: tooltipVariant,
77
- open: open ? true : undefined
35
+ open: open || undefined
78
36
  }, /*#__PURE__*/React.createElement("button", {
79
37
  type: "button",
80
- onClick: handleCopy,
38
+ onClick: function onClick() {
39
+ return handleCopy(effectiveText);
40
+ },
41
+ disabled: !effectiveText,
81
42
  className: "text-muted-foreground hover:text-foreground cursor-pointer pl-0.5 opacity-0 transition-opacity group-hover:opacity-100"
82
43
  }, /*#__PURE__*/React.createElement(Copy, {
83
44
  className: "size-3.5"
@@ -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;
@@ -2,7 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
2
2
  import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
3
3
  import _extends from "@babel/runtime/helpers/extends";
4
4
  var _excluded = ["className"],
5
- _excluded2 = ["className", "children", "overlayClassName", "variant", "headerSize", "maxWidth"],
5
+ _excluded2 = ["className", "children", "overlayClassName", "variant", "headerSize", "maxWidth", "hideCloseButton"],
6
6
  _excluded3 = ["className", "size"],
7
7
  _excluded4 = ["className", "size", "align"],
8
8
  _excluded5 = ["className"],
@@ -81,6 +81,8 @@ function DialogContent(_ref6) {
81
81
  _ref6$headerSize = _ref6.headerSize,
82
82
  headerSize = _ref6$headerSize === void 0 ? 'md' : _ref6$headerSize,
83
83
  maxWidth = _ref6.maxWidth,
84
+ _ref6$hideCloseButton = _ref6.hideCloseButton,
85
+ hideCloseButton = _ref6$hideCloseButton === void 0 ? false : _ref6$hideCloseButton,
84
86
  props = _objectWithoutProperties(_ref6, _excluded2);
85
87
  var resolvedMaxWidth = maxWidth === 'none' ? undefined : maxWidth !== null && maxWidth !== void 0 ? maxWidth : variant === 'centered' ? 'md' : '4xl';
86
88
  var isCentered = variant === 'centered';
@@ -98,7 +100,7 @@ function DialogContent(_ref6) {
98
100
  className: cn('bg-background text-foreground border-border fixed top-[50%] left-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', resolvedMaxWidth && dialogContentWidthVariants({
99
101
  maxWidth: resolvedMaxWidth
100
102
  }), className)
101
- }, props), children, /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
103
+ }, props), children, !hideCloseButton && /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
102
104
  "data-state": "open",
103
105
  asChild: true,
104
106
  className: cn('text-muted-foreground/70 hover:text-muted-foreground absolute right-3 cursor-pointer rounded-xs transition-opacity disabled:pointer-events-none', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-5", isCentered ? 'top-3' : dialogCloseButtonPositionVariants({
@@ -10,6 +10,8 @@ export interface DialogContentProps extends ComponentProps<typeof DialogPrimitiv
10
10
  headerSize?: DialogHeaderSize;
11
11
  /** Preset max-width. Pass `'none'` to skip the preset and use className for custom width. */
12
12
  maxWidth?: DialogContentWidth;
13
+ /** Hide the built-in close (X) button. */
14
+ hideCloseButton?: boolean;
13
15
  }
14
16
  export interface DialogHeaderProps extends ComponentProps<'div'> {
15
17
  size?: DialogHeaderSize;
@@ -25,6 +25,8 @@ function FormCheckboxField(_ref) {
25
25
  _ref$size = _ref.size,
26
26
  size = _ref$size === void 0 ? FormSize.Md : _ref$size,
27
27
  checkboxProps = _ref.checkboxProps;
28
+ var resolvedLabel = typeof label === 'function' ? label() : label;
29
+ var resolvedDescription = typeof description === 'function' ? description() : description;
28
30
  return /*#__PURE__*/React.createElement(FormField, {
29
31
  control: control,
30
32
  name: name,
@@ -51,9 +53,9 @@ function FormCheckboxField(_ref) {
51
53
  disabledTooltip: disabledTooltip,
52
54
  size: size,
53
55
  disabled: disabled
54
- }, label)), description && /*#__PURE__*/React.createElement(FormDescription, {
56
+ }, resolvedLabel)), resolvedDescription && /*#__PURE__*/React.createElement(FormDescription, {
55
57
  size: size
56
- }, description), /*#__PURE__*/React.createElement(FormMessage, null));
58
+ }, resolvedDescription), /*#__PURE__*/React.createElement(FormMessage, null));
57
59
  }
58
60
  });
59
61
  }
@@ -30,6 +30,8 @@ function FormCheckboxGroupField(_ref) {
30
30
  _ref$horizontal = _ref.horizontal,
31
31
  horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
32
32
  horizontalLabelWidth = _ref.horizontalLabelWidth;
33
+ var resolvedLabel = typeof label === 'function' ? label() : label;
34
+ var resolvedDescription = typeof description === 'function' ? description() : description;
33
35
  return /*#__PURE__*/React.createElement(FormField, {
34
36
  control: control,
35
37
  name: name,
@@ -41,7 +43,7 @@ function FormCheckboxGroupField(_ref) {
41
43
  "data-disabled": disabled,
42
44
  horizontal: horizontal,
43
45
  firstColumnWidth: horizontalLabelWidth
44
- }, (label || description) && /*#__PURE__*/React.createElement("div", null, label && /*#__PURE__*/React.createElement(FormLabel, {
46
+ }, (resolvedLabel || resolvedDescription) && /*#__PURE__*/React.createElement("div", null, resolvedLabel && /*#__PURE__*/React.createElement(FormLabel, {
45
47
  className: cn('cursor-default', labelCheckboxAndRadioVariants({
46
48
  size: size
47
49
  })),
@@ -49,16 +51,16 @@ function FormCheckboxGroupField(_ref) {
49
51
  tooltip: tooltip,
50
52
  disabledTooltip: disabledTooltip,
51
53
  disabled: disabled
52
- }, label), description && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
54
+ }, resolvedLabel), resolvedDescription && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
53
55
  size: size
54
- }, description)), /*#__PURE__*/React.createElement("div", {
56
+ }, resolvedDescription)), /*#__PURE__*/React.createElement("div", {
55
57
  className: "flex flex-col gap-3"
56
- }, description && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
58
+ }, resolvedDescription && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
57
59
  className: labelCheckboxAndRadioVariants({
58
60
  size: size
59
61
  }),
60
62
  size: size
61
- }, description), options.map(function (option) {
63
+ }, resolvedDescription), options.map(function (option) {
62
64
  var _field$value;
63
65
  return /*#__PURE__*/React.createElement(FormItem, {
64
66
  key: option.id,
@@ -26,6 +26,8 @@ function FormFieldGroup(_ref) {
26
26
  showCharCount = _ref$showCharCount === void 0 ? false : _ref$showCharCount,
27
27
  maxLength = _ref.maxLength,
28
28
  children = _ref.children;
29
+ var resolvedLabel = typeof label === 'function' ? label() : label;
30
+ var resolvedDescription = typeof description === 'function' ? description() : description;
29
31
  return /*#__PURE__*/React.createElement(FormField, {
30
32
  control: control,
31
33
  name: name,
@@ -33,7 +35,7 @@ function FormFieldGroup(_ref) {
33
35
  render: function render(_ref2) {
34
36
  var field = _ref2.field;
35
37
  var charCount = typeof field.value === 'string' ? field.value.length : 0;
36
- var showLabelRow = label || showCharCount;
38
+ var showLabelRow = resolvedLabel || showCharCount;
37
39
  return /*#__PURE__*/React.createElement(FormItem, {
38
40
  className: "group",
39
41
  horizontal: horizontal,
@@ -42,13 +44,13 @@ function FormFieldGroup(_ref) {
42
44
  "data-highlight": highlight
43
45
  }, showLabelRow && /*#__PURE__*/React.createElement("div", {
44
46
  className: cn('flex items-center justify-between gap-2', horizontal && labelHeightVariants[size])
45
- }, label ? /*#__PURE__*/React.createElement(FormLabel, {
47
+ }, resolvedLabel ? /*#__PURE__*/React.createElement(FormLabel, {
46
48
  className: cn(horizontal && 'self-start'),
47
49
  size: size,
48
50
  tooltip: tooltip,
49
51
  disabledTooltip: disabledTooltip,
50
52
  disabled: disabled
51
- }, label) : /*#__PURE__*/React.createElement("span", null), showCharCount && /*#__PURE__*/React.createElement("span", {
53
+ }, resolvedLabel) : /*#__PURE__*/React.createElement("span", null), showCharCount && /*#__PURE__*/React.createElement("span", {
52
54
  className: cn('text-muted-foreground shrink-0 tabular-nums', 'group-data-[disabled=true]:opacity-50', maxLength && charCount >= maxLength && 'text-destructive-foreground', formMessageSizeOptions[size])
53
55
  }, maxLength ? "".concat(charCount, " / ").concat(maxLength) : charCount)), /*#__PURE__*/React.createElement("div", {
54
56
  className: "grid gap-1.5"
@@ -58,9 +60,9 @@ function FormFieldGroup(_ref) {
58
60
  disabled: disabled
59
61
  }, maxLength !== undefined && {
60
62
  maxLength: maxLength
61
- }))), description && /*#__PURE__*/React.createElement(FormDescription, {
63
+ }))), resolvedDescription && /*#__PURE__*/React.createElement(FormDescription, {
62
64
  size: size
63
- }, description), /*#__PURE__*/React.createElement(FormMessage, {
65
+ }, resolvedDescription), /*#__PURE__*/React.createElement(FormMessage, {
64
66
  size: size
65
67
  })));
66
68
  }
@@ -29,6 +29,8 @@ function FormRadioGroupField(_ref) {
29
29
  _ref$horizontal = _ref.horizontal,
30
30
  horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
31
31
  horizontalLabelWidth = _ref.horizontalLabelWidth;
32
+ var resolvedLabel = typeof label === 'function' ? label() : label;
33
+ var resolvedDescription = typeof description === 'function' ? description() : description;
32
34
  return /*#__PURE__*/React.createElement(FormField, {
33
35
  control: control,
34
36
  name: name,
@@ -40,7 +42,7 @@ function FormRadioGroupField(_ref) {
40
42
  "data-disabled": disabled,
41
43
  horizontal: horizontal,
42
44
  firstColumnWidth: horizontalLabelWidth
43
- }, (label || description) && /*#__PURE__*/React.createElement("div", null, label && /*#__PURE__*/React.createElement(FormLabel, {
45
+ }, (resolvedLabel || resolvedDescription) && /*#__PURE__*/React.createElement("div", null, resolvedLabel && /*#__PURE__*/React.createElement(FormLabel, {
44
46
  className: cn('cursor-default', labelCheckboxAndRadioVariants({
45
47
  size: size
46
48
  })),
@@ -48,19 +50,19 @@ function FormRadioGroupField(_ref) {
48
50
  tooltip: tooltip,
49
51
  disabled: disabled,
50
52
  disabledTooltip: disabledTooltip
51
- }, label), description && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
53
+ }, resolvedLabel), resolvedDescription && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
52
54
  size: size
53
- }, description)), /*#__PURE__*/React.createElement(RadioGroup, {
55
+ }, resolvedDescription)), /*#__PURE__*/React.createElement(RadioGroup, {
54
56
  value: field.value,
55
57
  onValueChange: field.onChange,
56
58
  disabled: disabled,
57
59
  className: "flex flex-col gap-3"
58
- }, description && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
60
+ }, resolvedDescription && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
59
61
  className: labelCheckboxAndRadioVariants({
60
62
  size: size
61
63
  }),
62
64
  size: size
63
- }, description), options.map(function (option) {
65
+ }, resolvedDescription), options.map(function (option) {
64
66
  return /*#__PURE__*/React.createElement("div", {
65
67
  key: option.id,
66
68
  className: "group flex items-center space-x-2",
@@ -27,6 +27,8 @@ function FormSwitchField(_ref) {
27
27
  _ref$layout = _ref.layout,
28
28
  layout = _ref$layout === void 0 ? SwitchLayout.Inline : _ref$layout,
29
29
  switchProps = _ref.switchProps;
30
+ var resolvedLabel = typeof label === 'function' ? label() : label;
31
+ var resolvedDescription = typeof description === 'function' ? description() : description;
30
32
  var isInlineLayout = layout === SwitchLayout.Inline;
31
33
  return /*#__PURE__*/React.createElement(FormField, {
32
34
  control: control,
@@ -52,22 +54,22 @@ function FormSwitchField(_ref) {
52
54
  disabledTooltip: disabledTooltip,
53
55
  size: size,
54
56
  disabled: disabled
55
- }, label)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormLabel, {
57
+ }, resolvedLabel)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormLabel, {
56
58
  className: "text-foreground",
57
59
  htmlFor: (_switchProps$id2 = switchProps === null || switchProps === void 0 ? void 0 : switchProps.id) !== null && _switchProps$id2 !== void 0 ? _switchProps$id2 : field.name,
58
60
  tooltip: tooltip,
59
61
  disabledTooltip: disabledTooltip,
60
62
  size: size,
61
63
  disabled: disabled
62
- }, label), /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Switch, _extends({
64
+ }, resolvedLabel), /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Switch, _extends({
63
65
  id: field.name,
64
66
  checked: field.value,
65
67
  onCheckedChange: field.onChange,
66
68
  disabled: disabled,
67
69
  size: size
68
- }, switchProps))))), description && /*#__PURE__*/React.createElement(FormDescription, {
70
+ }, switchProps))))), resolvedDescription && /*#__PURE__*/React.createElement(FormDescription, {
69
71
  size: size
70
- }, description), /*#__PURE__*/React.createElement(FormMessage, null));
72
+ }, resolvedDescription), /*#__PURE__*/React.createElement(FormMessage, null));
71
73
  }
72
74
  });
73
75
  }
@@ -28,12 +28,12 @@ export interface FormFieldArgs {
28
28
  maxLength?: number;
29
29
  }
30
30
  interface FormBaseFieldProps {
31
- label?: ReactElement | string;
31
+ label?: ReactElement | string | (() => ReactElement);
32
32
  size?: FormSizeType;
33
- description?: ReactElement | string;
33
+ description?: ReactElement | string | (() => ReactElement);
34
34
  disabled?: boolean;
35
- tooltip?: ReactElement | string;
36
- disabledTooltip?: ReactElement | string;
35
+ tooltip?: ReactElement | string | (() => ReactElement);
36
+ disabledTooltip?: ReactElement | string | (() => ReactElement);
37
37
  showCharCount?: boolean;
38
38
  maxLength?: number;
39
39
  }
@@ -58,46 +58,46 @@ export type FormTextareaFieldProps<TFieldValues extends FieldValues, TName exten
58
58
  textareaProps?: TextareaProps;
59
59
  };
60
60
  export interface FlatOption {
61
- label: ReactElement | string;
62
- optionLabel?: ReactElement | string;
61
+ label: ReactElement | string | (() => ReactElement);
62
+ optionLabel?: ReactElement | string | (() => ReactElement);
63
63
  value: string;
64
64
  disabled?: boolean;
65
- icon?: ReactElement;
66
- tooltip?: ReactElement | string;
67
- disabledTooltip?: ReactElement | string;
65
+ icon?: ReactElement | (() => ReactElement);
66
+ tooltip?: ReactElement | string | (() => ReactElement);
67
+ disabledTooltip?: ReactElement | string | (() => ReactElement);
68
68
  }
69
69
  export interface OptionGroup extends Omit<FlatOption, 'value' | 'label'> {
70
- label?: ReactElement | string;
70
+ label?: ReactElement | string | (() => ReactElement);
71
71
  value?: string;
72
72
  options: FlatOption[];
73
73
  }
74
74
  export interface UserFlatOption {
75
- name: ReactElement | string;
76
- email: ReactElement | string;
75
+ name: ReactElement | string | (() => ReactElement);
76
+ email: ReactElement | string | (() => ReactElement);
77
77
  value: string;
78
78
  disabled?: boolean;
79
79
  profileUrl?: string;
80
80
  }
81
81
  export interface UserOptionGroup {
82
- label?: ReactElement | string;
82
+ label?: ReactElement | string | (() => ReactElement);
83
83
  value?: string;
84
84
  options: UserFlatOption[];
85
- icon?: ReactElement;
85
+ icon?: ReactElement | (() => ReactElement);
86
86
  disabled?: boolean;
87
- tooltip?: ReactElement | string;
88
- disabledTooltip?: ReactElement | string;
87
+ tooltip?: ReactElement | string | (() => ReactElement);
88
+ disabledTooltip?: ReactElement | string | (() => ReactElement);
89
89
  }
90
90
  export type SelectOption = FlatOption | OptionGroup;
91
91
  export type SelectUserOption = UserFlatOption | UserOptionGroup;
92
92
  export type FormSelectProps = SelectProps & {
93
93
  options: SelectOption[];
94
94
  placeholder?: string;
95
- icon?: ReactElement;
95
+ icon?: ReactElement | (() => ReactElement);
96
96
  popoverClassName?: string;
97
97
  triggerProps?: SelectorProps['triggerProps'];
98
98
  };
99
99
  export type FormSelectFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
100
- icon?: ReactElement;
100
+ icon?: ReactElement | (() => ReactElement);
101
101
  showGroupSeparator?: boolean;
102
102
  selectProps?: FormSelectProps;
103
103
  };
@@ -124,16 +124,16 @@ export type RadioOption = {
124
124
  label: string;
125
125
  id: string;
126
126
  disabled?: RadioGroupItemProps['disabled'];
127
- tooltip?: ReactElement | string;
128
- disabledTooltip?: ReactElement | string;
127
+ tooltip?: ReactElement | string | (() => ReactElement);
128
+ disabledTooltip?: ReactElement | string | (() => ReactElement);
129
129
  };
130
130
  interface BaseFormGroupFieldProps<TFieldValues extends FieldValues> {
131
131
  control: Control<TFieldValues>;
132
132
  name: Path<TFieldValues>;
133
- label?: ReactElement | string;
134
- disabledTooltip?: ReactElement | string;
135
- tooltip?: ReactElement | string;
136
- description?: ReactElement | string;
133
+ label?: ReactElement | string | (() => ReactElement);
134
+ disabledTooltip?: ReactElement | string | (() => ReactElement);
135
+ tooltip?: ReactElement | string | (() => ReactElement);
136
+ description?: ReactElement | string | (() => ReactElement);
137
137
  className?: string;
138
138
  disabled?: boolean;
139
139
  size?: FormSizeType;