@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.
- package/button/button.types.d.ts +4 -4
- package/button/components/copy-button.js +15 -54
- package/button/components/copy-to-clipboard-button.d.ts +1 -0
- package/button/components/copy-to-clipboard-button.js +17 -53
- package/button/components/end-icon.js +3 -0
- package/button/components/start-icon.js +12 -6
- package/color-picker/color-picker.component.js +6 -3
- package/color-picker/color-picker.types.d.ts +4 -4
- package/combobox/combobox-multi-checkbox/combobox-multi-checkbox.component.js +8 -4
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +6 -3
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +1 -1
- package/combobox/combobox-single/combobox-single.component.js +3 -3
- package/combobox/combobox-users/combobox-users.component.js +9 -8
- package/combobox/combobox.component.js +30 -18
- package/combobox/combobox.types.d.ts +9 -8
- package/command/command.component.d.ts +2 -2
- package/command/command.component.js +28 -13
- package/command/command.utils.d.ts +4 -2
- package/command/command.utils.js +6 -1
- package/copyable-text/copyable-text.component.js +17 -56
- package/dialog/dialog.component.d.ts +1 -1
- package/dialog/dialog.component.js +4 -2
- package/dialog/dialog.types.d.ts +2 -0
- package/form/components/form-checkbox-field.component.js +4 -2
- package/form/components/form-checkbox-group-field.component.js +7 -5
- package/form/components/form-field-group.component.js +7 -5
- package/form/components/form-radio-group-field.component.js +7 -5
- package/form/components/form-switch-field.component.js +6 -4
- package/form/form.types.d.ts +24 -24
- package/input-tags/input-tags.component.js +18 -15
- package/label/components/label-icon.js +8 -3
- package/label/label.types.d.ts +4 -4
- package/package.json +2 -2
- package/select/components/select-icon.js +3 -0
- package/select/components/selector.js +13 -9
- package/select/select.types.d.ts +5 -5
- package/textarea/components/textarea-with-actions.js +7 -5
- package/textarea/textarea.types.d.ts +2 -2
- package/tooltip/tooltip.component.js +3 -2
- package/tooltip/tooltip.types.d.ts +1 -1
- package/utils/copy-to-clipboard.d.ts +10 -0
- package/utils/copy-to-clipboard.js +65 -0
- package/utils/use-copy-to-clipboard.d.ts +13 -0
- package/utils/use-copy-to-clipboard.js +68 -0
package/button/button.types.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
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 = ["textToCopy", "copiedMessage", "tooltipDuration", "onCopy", "children", "disabled"];
|
|
6
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
4
|
import { Button } from '@scaleflex/ui-tw/button';
|
|
8
5
|
import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
|
|
9
|
-
import
|
|
6
|
+
import { useCopyToClipboard } from '@scaleflex/ui-tw/utils/use-copy-to-clipboard';
|
|
7
|
+
import React from 'react';
|
|
10
8
|
export function CopyButton(_ref) {
|
|
11
9
|
var textToCopy = _ref.textToCopy,
|
|
12
10
|
_ref$copiedMessage = _ref.copiedMessage,
|
|
@@ -17,62 +15,25 @@ export function CopyButton(_ref) {
|
|
|
17
15
|
children = _ref.children,
|
|
18
16
|
disabled = _ref.disabled,
|
|
19
17
|
buttonProps = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
tooltipVariant =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
|
-
open = _useState6[0],
|
|
31
|
-
setOpen = _useState6[1];
|
|
32
|
-
var handleCopy = /*#__PURE__*/function () {
|
|
33
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
34
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
-
while (1) switch (_context.prev = _context.next) {
|
|
36
|
-
case 0:
|
|
37
|
-
_context.prev = 0;
|
|
38
|
-
_context.next = 3;
|
|
39
|
-
return navigator.clipboard.writeText(textToCopy);
|
|
40
|
-
case 3:
|
|
41
|
-
setTooltipText(copiedMessage);
|
|
42
|
-
setTooltipVariant('success');
|
|
43
|
-
setOpen(true);
|
|
44
|
-
onCopy === null || onCopy === void 0 || onCopy();
|
|
45
|
-
setTimeout(function () {
|
|
46
|
-
setOpen(false);
|
|
47
|
-
}, tooltipDuration - 500);
|
|
48
|
-
setTimeout(function () {
|
|
49
|
-
setTooltipText('');
|
|
50
|
-
setTooltipVariant('default');
|
|
51
|
-
}, tooltipDuration);
|
|
52
|
-
_context.next = 14;
|
|
53
|
-
break;
|
|
54
|
-
case 11:
|
|
55
|
-
_context.prev = 11;
|
|
56
|
-
_context.t0 = _context["catch"](0);
|
|
57
|
-
console.error('Failed to copy', _context.t0);
|
|
58
|
-
case 14:
|
|
59
|
-
case "end":
|
|
60
|
-
return _context.stop();
|
|
61
|
-
}
|
|
62
|
-
}, _callee, null, [[0, 11]]);
|
|
63
|
-
}));
|
|
64
|
-
return function handleCopy() {
|
|
65
|
-
return _ref2.apply(this, arguments);
|
|
66
|
-
};
|
|
67
|
-
}();
|
|
18
|
+
var _useCopyToClipboard = useCopyToClipboard({
|
|
19
|
+
copiedMessage: copiedMessage,
|
|
20
|
+
tooltipDuration: tooltipDuration,
|
|
21
|
+
onCopy: onCopy
|
|
22
|
+
}),
|
|
23
|
+
tooltipText = _useCopyToClipboard.tooltipText,
|
|
24
|
+
tooltipVariant = _useCopyToClipboard.tooltipVariant,
|
|
25
|
+
open = _useCopyToClipboard.open,
|
|
26
|
+
handleCopy = _useCopyToClipboard.handleCopy;
|
|
68
27
|
return /*#__PURE__*/React.createElement(WithTooltip, {
|
|
69
28
|
content: tooltipText,
|
|
70
29
|
variant: tooltipVariant,
|
|
71
|
-
open: open
|
|
30
|
+
open: open || undefined
|
|
72
31
|
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
73
32
|
"data-slot": "copy-button",
|
|
74
33
|
type: "button",
|
|
75
|
-
onClick:
|
|
34
|
+
onClick: function onClick() {
|
|
35
|
+
return handleCopy(textToCopy);
|
|
36
|
+
},
|
|
76
37
|
disabled: disabled || !textToCopy
|
|
77
38
|
}, buttonProps), children));
|
|
78
39
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
1
|
import { Button, ButtonSize } from '@scaleflex/ui-tw/button';
|
|
5
2
|
import { WithTooltip } from '@scaleflex/ui-tw/tooltip';
|
|
3
|
+
import { useCopyToClipboard } from '@scaleflex/ui-tw/utils/use-copy-to-clipboard';
|
|
6
4
|
import { Copy } from 'lucide-react';
|
|
7
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
8
6
|
|
|
9
7
|
/** @deprecated Use CopyIcon instead */
|
|
10
8
|
|
|
@@ -16,64 +14,30 @@ export function CopyIcon(props) {
|
|
|
16
14
|
initialTooltip = _props$initialTooltip === void 0 ? 'Copy to clipboard' : _props$initialTooltip,
|
|
17
15
|
_props$copiedTooltip = props.copiedTooltip,
|
|
18
16
|
copiedTooltip = _props$copiedTooltip === void 0 ? 'Copied!' : _props$copiedTooltip,
|
|
17
|
+
_props$tooltipDuratio = props.tooltipDuration,
|
|
18
|
+
tooltipDuration = _props$tooltipDuratio === void 0 ? 2000 : _props$tooltipDuratio,
|
|
19
19
|
_props$disabled = props.disabled,
|
|
20
20
|
disabled = _props$disabled === void 0 ? false : _props$disabled;
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tooltipVariant =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
31
|
-
open = _useState6[0],
|
|
32
|
-
setOpen = _useState6[1];
|
|
33
|
-
var handleCopy = /*#__PURE__*/function () {
|
|
34
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
35
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
|
-
while (1) switch (_context.prev = _context.next) {
|
|
37
|
-
case 0:
|
|
38
|
-
_context.prev = 0;
|
|
39
|
-
_context.next = 3;
|
|
40
|
-
return navigator.clipboard.writeText(text);
|
|
41
|
-
case 3:
|
|
42
|
-
setTooltipText(copiedTooltip);
|
|
43
|
-
setTooltipVariant('success');
|
|
44
|
-
setOpen(true);
|
|
45
|
-
setTimeout(function () {
|
|
46
|
-
setOpen(false);
|
|
47
|
-
}, 1500);
|
|
48
|
-
setTimeout(function () {
|
|
49
|
-
setTooltipText(initialTooltip);
|
|
50
|
-
setTooltipVariant('default');
|
|
51
|
-
}, 2000);
|
|
52
|
-
_context.next = 13;
|
|
53
|
-
break;
|
|
54
|
-
case 10:
|
|
55
|
-
_context.prev = 10;
|
|
56
|
-
_context.t0 = _context["catch"](0);
|
|
57
|
-
console.error('Failed to copy', _context.t0);
|
|
58
|
-
case 13:
|
|
59
|
-
case "end":
|
|
60
|
-
return _context.stop();
|
|
61
|
-
}
|
|
62
|
-
}, _callee, null, [[0, 10]]);
|
|
63
|
-
}));
|
|
64
|
-
return function handleCopy() {
|
|
65
|
-
return _ref.apply(this, arguments);
|
|
66
|
-
};
|
|
67
|
-
}();
|
|
21
|
+
var _useCopyToClipboard = useCopyToClipboard({
|
|
22
|
+
copiedMessage: copiedTooltip,
|
|
23
|
+
tooltipDuration: tooltipDuration,
|
|
24
|
+
initialTooltipText: initialTooltip
|
|
25
|
+
}),
|
|
26
|
+
tooltipText = _useCopyToClipboard.tooltipText,
|
|
27
|
+
tooltipVariant = _useCopyToClipboard.tooltipVariant,
|
|
28
|
+
open = _useCopyToClipboard.open,
|
|
29
|
+
handleCopy = _useCopyToClipboard.handleCopy;
|
|
68
30
|
return /*#__PURE__*/React.createElement(WithTooltip, {
|
|
69
31
|
content: tooltipText,
|
|
70
32
|
variant: tooltipVariant,
|
|
71
|
-
open: open
|
|
33
|
+
open: open || undefined
|
|
72
34
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
73
35
|
type: "button",
|
|
74
36
|
variant: "ghost-secondary",
|
|
75
37
|
size: size,
|
|
76
|
-
onClick:
|
|
38
|
+
onClick: function onClick() {
|
|
39
|
+
return handleCopy(text);
|
|
40
|
+
},
|
|
77
41
|
disabled: disabled || !text
|
|
78
42
|
}, /*#__PURE__*/React.createElement(Copy, null)));
|
|
79
43
|
}
|
|
@@ -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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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,
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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?:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 ?
|
|
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
|
-
},
|
|
206
|
+
}, resolvedGroupLabel), option.options.map(function (_ref3) {
|
|
206
207
|
var name = _ref3.name,
|
|
207
208
|
email = _ref3.email,
|
|
208
209
|
profileUrl = _ref3.profileUrl,
|
|
209
|
-
|
|
210
|
+
subValue = _ref3.value,
|
|
210
211
|
disabled = _ref3.disabled;
|
|
211
|
-
var isGroupSelected = 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:
|
|
217
|
+
key: subValue,
|
|
217
218
|
name: name,
|
|
218
219
|
email: email,
|
|
219
220
|
profileUrl: profileUrl,
|
|
220
|
-
value:
|
|
221
|
+
value: subValue,
|
|
221
222
|
isGroup: !!option.label,
|
|
222
223
|
selectedValue: value,
|
|
223
224
|
onSelect: function onSelect() {
|
|
224
|
-
return toggleValue(
|
|
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 ?
|
|
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 ?
|
|
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
|
-
},
|
|
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: !!
|
|
263
|
+
isGroup: !!resolvedGroupLabel,
|
|
262
264
|
selectedValue: selectedValue,
|
|
263
265
|
onSelect: function onSelect() {
|
|
264
266
|
return _onSelect(value);
|
|
265
|
-
}
|
|
266
|
-
|
|
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
|
-
|
|
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 ?
|
|
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 ?
|
|
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
|
-
},
|
|
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: !!
|
|
360
|
+
isGroup: !!resolvedGroupLabel,
|
|
353
361
|
selectedValue: selectedValue,
|
|
354
362
|
onSelect: function onSelect() {
|
|
355
363
|
return _onSelect2(value);
|
|
356
|
-
}
|
|
357
|
-
|
|
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
|
-
|
|
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
|
|
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;
|