@scaleflex/ui-tw 0.0.152 → 0.0.154
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/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 +22 -14
- package/combobox/combobox.types.d.ts +8 -8
- package/command/command.component.js +23 -12
- package/command/command.utils.d.ts +2 -2
- package/command/command.utils.js +1 -1
- package/dialog/dialog.component.d.ts +1 -1
- package/dialog/dialog.component.js +4 -2
- package/dialog/dialog.types.d.ts +2 -0
- package/dropdown-menu/dropdown-menu.component.d.ts +1 -1
- package/dropdown-menu/dropdown-menu.component.js +10 -4
- package/dropdown-menu/dropdown-menu.constants.d.ts +3 -3
- package/dropdown-menu/dropdown-menu.constants.js +1 -1
- 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 +16 -19
- 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/truncated-text/index.d.ts +2 -0
- package/truncated-text/index.js +1 -0
- package/truncated-text/truncated-text.component.d.ts +4 -0
- package/truncated-text/truncated-text.component.js +40 -0
- package/truncated-text/truncated-text.constants.d.ts +1 -0
- package/truncated-text/truncated-text.constants.js +1 -0
- package/truncated-text/truncated-text.types.d.ts +7 -0
- package/truncated-text/truncated-text.types.js +1 -0
- package/truncated-text/truncated-text.utils.d.ts +1 -0
- package/truncated-text/truncated-text.utils.js +4 -0
|
@@ -3,7 +3,7 @@ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructurin
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
var _excluded = ["className", "sideOffset", "collisionPadding"],
|
|
6
|
-
_excluded2 = ["className", "inset", "variant", "size"],
|
|
6
|
+
_excluded2 = ["className", "inset", "variant", "size", "children"],
|
|
7
7
|
_excluded3 = ["className", "children", "checked", "size", "closeOnSelect", "onSelect"],
|
|
8
8
|
_excluded4 = ["className", "children", "size"],
|
|
9
9
|
_excluded5 = ["className", "size"],
|
|
@@ -16,6 +16,7 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
|
16
16
|
import { Slot } from '@radix-ui/react-slot';
|
|
17
17
|
import { DropdownMenuItemSize, dropdownMenuButtonTriggerOptions, dropdownMenuCheckboxItemSizeOptions, dropdownMenuIconSizeOptions, dropdownMenuItemIconSizeOptions, dropdownMenuItemIndicatorSizeOptions, dropdownMenuItemSizeOptions, dropdownMenuRadioItemSizeOptions, dropdownMenuShortcutSizeOptions } from '@scaleflex/ui-tw/dropdown-menu/dropdown-menu.constants';
|
|
18
18
|
import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
19
|
+
import { TruncatedText } from '@scaleflex/ui-tw/truncated-text';
|
|
19
20
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
20
21
|
import { cva } from 'class-variance-authority';
|
|
21
22
|
import { CheckIcon, ChevronDownIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';
|
|
@@ -131,23 +132,28 @@ function DropdownMenuGroup(_ref5) {
|
|
|
131
132
|
}, props));
|
|
132
133
|
}
|
|
133
134
|
function DropdownMenuItem(_ref6) {
|
|
135
|
+
var _React$Children$map;
|
|
134
136
|
var className = _ref6.className,
|
|
135
137
|
inset = _ref6.inset,
|
|
136
138
|
_ref6$variant = _ref6.variant,
|
|
137
139
|
variant = _ref6$variant === void 0 ? 'default' : _ref6$variant,
|
|
138
140
|
_ref6$size = _ref6.size,
|
|
139
141
|
size = _ref6$size === void 0 ? DropdownMenuItemSize.Sm : _ref6$size,
|
|
142
|
+
children = _ref6.children,
|
|
140
143
|
props = _objectWithoutProperties(_ref6, _excluded2);
|
|
144
|
+
var processedChildren = (_React$Children$map = React.Children.map(children, function (child) {
|
|
145
|
+
return typeof child === 'string' ? /*#__PURE__*/React.createElement(TruncatedText, null, child) : child;
|
|
146
|
+
})) !== null && _React$Children$map !== void 0 ? _React$Children$map : children;
|
|
141
147
|
return /*#__PURE__*/React.createElement(DropdownMenuPrimitive.Item, _extends({
|
|
142
148
|
"data-slot": "dropdown-menu-item",
|
|
143
149
|
"data-inset": inset,
|
|
144
150
|
"data-variant": variant,
|
|
145
|
-
className: cn('relative flex cursor-pointer items-center gap-2 rounded-sm outline-hidden select-none', dropdownMenuItemVariants({
|
|
151
|
+
className: cn('relative flex cursor-pointer items-center gap-2 overflow-hidden rounded-sm outline-hidden select-none', dropdownMenuItemVariants({
|
|
146
152
|
size: size
|
|
147
153
|
}), 'data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive', 'focus:bg-secondary data-[disabled]:pointer-events-none data-[disabled]:opacity-50', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0", dropdownMenuIconVariants({
|
|
148
154
|
size: size
|
|
149
155
|
}), className)
|
|
150
|
-
}, props));
|
|
156
|
+
}, props), processedChildren);
|
|
151
157
|
}
|
|
152
158
|
function DropdownMenuCheckboxItem(_ref7) {
|
|
153
159
|
var className = _ref7.className,
|
|
@@ -234,7 +240,7 @@ function DropdownMenuShortcut(_ref12) {
|
|
|
234
240
|
props = _objectWithoutProperties(_ref12, _excluded7);
|
|
235
241
|
return /*#__PURE__*/React.createElement("span", _extends({
|
|
236
242
|
"data-slot": "dropdown-menu-shortcut",
|
|
237
|
-
className: cn('text-muted-foreground
|
|
243
|
+
className: cn('text-muted-foreground ml-auto shrink-0 tracking-widest', dropdownMenuShortcutVariants({
|
|
238
244
|
size: size
|
|
239
245
|
}), className)
|
|
240
246
|
}, props));
|
|
@@ -34,9 +34,9 @@ export declare const dropdownMenuItemIconSizeOptions: {
|
|
|
34
34
|
readonly lg: "size-5";
|
|
35
35
|
};
|
|
36
36
|
export declare const dropdownMenuShortcutSizeOptions: {
|
|
37
|
-
readonly sm: "
|
|
38
|
-
readonly md: "
|
|
39
|
-
readonly lg: "
|
|
37
|
+
readonly sm: "text-xs";
|
|
38
|
+
readonly md: "text-xs";
|
|
39
|
+
readonly lg: "text-xs";
|
|
40
40
|
};
|
|
41
41
|
export declare const dropdownMenuIconSizeOptions: {
|
|
42
42
|
readonly sm: "[&_svg:not([class*='size-'])]:size-3.5";
|
|
@@ -10,5 +10,5 @@ export var dropdownMenuRadioItemSizeOptions = _defineProperty(_defineProperty(_d
|
|
|
10
10
|
export var dropdownMenuButtonTriggerOptions = _defineProperty(_defineProperty(_defineProperty({}, DropdownMenuItemSize.Sm, 'px-3 py-1.5 gap-1 text-sm'), DropdownMenuItemSize.Md, 'px-4 py-2 gap-2 text-base'), DropdownMenuItemSize.Lg, 'px-5 py-2.5 gap-2 text-lg');
|
|
11
11
|
export var dropdownMenuItemIndicatorSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, DropdownMenuItemSize.Sm, 'right-2 size-3.5'), DropdownMenuItemSize.Md, 'right-3 size-4'), DropdownMenuItemSize.Lg, 'right-3 size-5');
|
|
12
12
|
export var dropdownMenuItemIconSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, DropdownMenuItemSize.Sm, 'size-3.5'), DropdownMenuItemSize.Md, 'size-4'), DropdownMenuItemSize.Lg, 'size-5');
|
|
13
|
-
export var dropdownMenuShortcutSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, DropdownMenuItemSize.Sm, '
|
|
13
|
+
export var dropdownMenuShortcutSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, DropdownMenuItemSize.Sm, 'text-xs'), DropdownMenuItemSize.Md, 'text-xs'), DropdownMenuItemSize.Lg, 'text-xs');
|
|
14
14
|
export var dropdownMenuIconSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, DropdownMenuItemSize.Sm, "[&_svg:not([class*='size-'])]:size-3.5"), DropdownMenuItemSize.Md, "[&_svg:not([class*='size-'])]:size-4.5"), DropdownMenuItemSize.Lg, "[&_svg:not([class*='size-'])]:size-5");
|
|
@@ -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
|
-
},
|
|
56
|
+
}, resolvedLabel)), resolvedDescription && /*#__PURE__*/React.createElement(FormDescription, {
|
|
55
57
|
size: size
|
|
56
|
-
},
|
|
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
|
-
}, (
|
|
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
|
-
},
|
|
54
|
+
}, resolvedLabel), resolvedDescription && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
53
55
|
size: size
|
|
54
|
-
},
|
|
56
|
+
}, resolvedDescription)), /*#__PURE__*/React.createElement("div", {
|
|
55
57
|
className: "flex flex-col gap-3"
|
|
56
|
-
},
|
|
58
|
+
}, resolvedDescription && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
57
59
|
className: labelCheckboxAndRadioVariants({
|
|
58
60
|
size: size
|
|
59
61
|
}),
|
|
60
62
|
size: size
|
|
61
|
-
},
|
|
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 =
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
}))),
|
|
63
|
+
}))), resolvedDescription && /*#__PURE__*/React.createElement(FormDescription, {
|
|
62
64
|
size: size
|
|
63
|
-
},
|
|
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
|
-
}, (
|
|
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
|
-
},
|
|
53
|
+
}, resolvedLabel), resolvedDescription && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
52
54
|
size: size
|
|
53
|
-
},
|
|
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
|
-
},
|
|
60
|
+
}, resolvedDescription && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
59
61
|
className: labelCheckboxAndRadioVariants({
|
|
60
62
|
size: size
|
|
61
63
|
}),
|
|
62
64
|
size: size
|
|
63
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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))))),
|
|
70
|
+
}, switchProps))))), resolvedDescription && /*#__PURE__*/React.createElement(FormDescription, {
|
|
69
71
|
size: size
|
|
70
|
-
},
|
|
72
|
+
}, resolvedDescription), /*#__PURE__*/React.createElement(FormMessage, null));
|
|
71
73
|
}
|
|
72
74
|
});
|
|
73
75
|
}
|
package/form/form.types.d.ts
CHANGED
|
@@ -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;
|
|
@@ -20,6 +20,12 @@ import { cva } from 'class-variance-authority';
|
|
|
20
20
|
import { ChevronsUpDownIcon } from 'lucide-react';
|
|
21
21
|
import * as React from 'react';
|
|
22
22
|
import { useMemo, useState } from 'react';
|
|
23
|
+
var normalizeLabel = function normalizeLabel(label) {
|
|
24
|
+
return label.trim().replace(/\s+/g, ' ');
|
|
25
|
+
};
|
|
26
|
+
var normalizeValue = function normalizeValue(label) {
|
|
27
|
+
return normalizeLabel(label).replace(/\s+/g, '-');
|
|
28
|
+
};
|
|
23
29
|
var inputTagsVariants = cva('', {
|
|
24
30
|
variants: {
|
|
25
31
|
size: textareaSizeOptions
|
|
@@ -68,7 +74,9 @@ export function InputTags(_ref) {
|
|
|
68
74
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
75
|
search = _useState4[0],
|
|
70
76
|
setSearch = _useState4[1];
|
|
71
|
-
var tagsList =
|
|
77
|
+
var tagsList = useMemo(function () {
|
|
78
|
+
return [].concat(_toConsumableArray(suggestedTags), _toConsumableArray(allTags));
|
|
79
|
+
}, [suggestedTags, allTags]);
|
|
72
80
|
var _getToolbarSizes = getToolbarSizes(size),
|
|
73
81
|
buttonSize = _getToolbarSizes.buttonSize;
|
|
74
82
|
var searchTrimmed = search.trim().toLowerCase();
|
|
@@ -80,18 +88,11 @@ export function InputTags(_ref) {
|
|
|
80
88
|
return isSameTag(t, tag);
|
|
81
89
|
});
|
|
82
90
|
};
|
|
83
|
-
var
|
|
84
|
-
return label.trim().replace(/\s+/g, ' ');
|
|
85
|
-
};
|
|
86
|
-
var normalizeValue = function normalizeValue(label) {
|
|
87
|
-
return normalizeLabel(label).replace(/\s+/g, '-');
|
|
88
|
-
};
|
|
89
|
-
var createTag = function createTag(label) {
|
|
91
|
+
var newTag = useMemo(function () {
|
|
90
92
|
return _defineProperty({
|
|
91
|
-
label: normalizeLabel(
|
|
92
|
-
}, valueProp, normalizeValue(
|
|
93
|
-
};
|
|
94
|
-
var newTag = createTag(search);
|
|
93
|
+
label: normalizeLabel(search)
|
|
94
|
+
}, valueProp, normalizeValue(search));
|
|
95
|
+
}, [search, valueProp]);
|
|
95
96
|
var canCreate = useMemo(function () {
|
|
96
97
|
if (!allowCustomTags || !searchTrimmed) return false;
|
|
97
98
|
return !value.some(function (v) {
|
|
@@ -130,7 +131,7 @@ export function InputTags(_ref) {
|
|
|
130
131
|
asChild: true
|
|
131
132
|
}, /*#__PURE__*/React.createElement("button", {
|
|
132
133
|
id: formItemId,
|
|
133
|
-
role: "combobox
|
|
134
|
+
role: "combobox",
|
|
134
135
|
type: "button",
|
|
135
136
|
"aria-expanded": open,
|
|
136
137
|
"aria-invalid": rest['aria-invalid'],
|
|
@@ -203,9 +204,7 @@ export function InputTags(_ref) {
|
|
|
203
204
|
return handleAddTag(tag);
|
|
204
205
|
},
|
|
205
206
|
isGroup: true
|
|
206
|
-
},
|
|
207
|
-
className: "block w-full truncate overflow-hidden text-ellipsis whitespace-nowrap"
|
|
208
|
-
}, tag.label));
|
|
207
|
+
}, tag.label);
|
|
209
208
|
})), filteredAll.length > 0 && /*#__PURE__*/React.createElement(CommandGroup, {
|
|
210
209
|
size: size,
|
|
211
210
|
heading: "All Tags"
|
|
@@ -217,9 +216,7 @@ export function InputTags(_ref) {
|
|
|
217
216
|
return handleAddTag(tag);
|
|
218
217
|
},
|
|
219
218
|
isGroup: true
|
|
220
|
-
},
|
|
221
|
-
className: "block w-full truncate overflow-hidden text-ellipsis whitespace-nowrap"
|
|
222
|
-
}, tag.label));
|
|
219
|
+
}, tag.label);
|
|
223
220
|
})), !canCreate && filteredSuggested.length === 0 && filteredAll.length === 0 && /*#__PURE__*/React.createElement(CommandEmpty, null, "No results found."), canCreate && /*#__PURE__*/React.createElement(CommandItem, {
|
|
224
221
|
size: size,
|
|
225
222
|
onSelect: function onSelect() {
|
|
@@ -22,7 +22,12 @@ var LabelIcon = function LabelIcon(props) {
|
|
|
22
22
|
return getLabelIconSizeInRem(size);
|
|
23
23
|
}, [size]);
|
|
24
24
|
if (!icon && !tooltip) return null;
|
|
25
|
-
var
|
|
25
|
+
var resolvedTooltip = typeof tooltip === 'function' ? tooltip() : tooltip;
|
|
26
|
+
var iconElement = typeof icon === 'function' ? /*#__PURE__*/React.createElement("span", _extends({
|
|
27
|
+
className: cn('text-muted-foreground', labelIconVariants({
|
|
28
|
+
size: size
|
|
29
|
+
}))
|
|
30
|
+
}, rest), icon()) : /*#__PURE__*/React.createElement("span", _extends({
|
|
26
31
|
className: cn('text-muted-foreground', labelIconVariants({
|
|
27
32
|
size: size
|
|
28
33
|
}))
|
|
@@ -33,9 +38,9 @@ var LabelIcon = function LabelIcon(props) {
|
|
|
33
38
|
height: sizeInRem
|
|
34
39
|
}
|
|
35
40
|
}));
|
|
36
|
-
if (!
|
|
41
|
+
if (!resolvedTooltip) return iconElement;
|
|
37
42
|
return /*#__PURE__*/React.createElement(Tooltip, null, /*#__PURE__*/React.createElement(TooltipTrigger, {
|
|
38
43
|
asChild: true
|
|
39
|
-
}, iconElement), /*#__PURE__*/React.createElement(TooltipContent, null,
|
|
44
|
+
}, iconElement), /*#__PURE__*/React.createElement(TooltipContent, null, resolvedTooltip));
|
|
40
45
|
};
|
|
41
46
|
export { LabelIcon };
|
package/label/label.types.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
|
3
3
|
import type { ComponentProps, ReactElement } from 'react';
|
|
4
4
|
export interface LabelProps extends Omit<ComponentProps<typeof LabelPrimitive.Root>, 'size'> {
|
|
5
5
|
size?: FormSizeType;
|
|
6
|
-
icon?: ReactElement;
|
|
7
|
-
tooltip?: ReactElement | string;
|
|
6
|
+
icon?: ReactElement | (() => ReactElement);
|
|
7
|
+
tooltip?: ReactElement | string | (() => ReactElement);
|
|
8
8
|
disabled?: boolean;
|
|
9
|
-
disabledTooltip?: ReactElement | string;
|
|
9
|
+
disabledTooltip?: ReactElement | string | (() => ReactElement);
|
|
10
10
|
noTruncate?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface LabelIconProps extends ComponentProps<'span'>, Pick<LabelProps, 'size' | 'tooltip'> {
|
|
13
|
-
icon?: ReactElement;
|
|
13
|
+
icon?: ReactElement | (() => ReactElement);
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.154",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@radix-ui/react-switch": "^1.0.1",
|
|
30
30
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
31
31
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
32
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
32
|
+
"@scaleflex/icons-tw": "^0.0.154",
|
|
33
33
|
"@tanstack/react-table": "^8.21.3",
|
|
34
34
|
"@types/lodash.merge": "^4.6.9",
|
|
35
35
|
"class-variance-authority": "^0.7.1",
|
|
@@ -12,6 +12,9 @@ export var SelectIcon = function SelectIcon(props) {
|
|
|
12
12
|
return getIconMarginRightInRem(size);
|
|
13
13
|
}, [size]);
|
|
14
14
|
if (!icon) return null;
|
|
15
|
+
if (typeof icon === 'function') {
|
|
16
|
+
return icon();
|
|
17
|
+
}
|
|
15
18
|
return /*#__PURE__*/cloneElement(icon, {
|
|
16
19
|
size: sizeInRem,
|
|
17
20
|
style: {
|
|
@@ -46,13 +46,13 @@ export function Selector(_ref) {
|
|
|
46
46
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
47
47
|
var option = _step.value;
|
|
48
48
|
if (isOptionGroup(option)) {
|
|
49
|
-
if (option.value === val) return option.label;
|
|
49
|
+
if (option.value === val) return typeof option.label === 'function' ? option.label() : option.label;
|
|
50
50
|
var found = option.options.find(function (o) {
|
|
51
51
|
return o.value === val;
|
|
52
52
|
});
|
|
53
|
-
if (found) return found.label;
|
|
53
|
+
if (found) return typeof found.label === 'function' ? found.label() : found.label;
|
|
54
54
|
} else if (option.value === val) {
|
|
55
|
-
return option.label;
|
|
55
|
+
return typeof option.label === 'function' ? option.label() : option.label;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
} catch (err) {
|
|
@@ -79,8 +79,8 @@ export function Selector(_ref) {
|
|
|
79
79
|
}, value ? getLabelByValue(value) : '')), /*#__PURE__*/React.createElement(SelectContent, _extends({
|
|
80
80
|
className: popoverClassName
|
|
81
81
|
}, selectorContentProps), options.map(function (option, groupIndex) {
|
|
82
|
-
var _option$optionLabel;
|
|
83
82
|
if (isOptionGroup(option)) {
|
|
83
|
+
var resolvedGroupLabel = typeof option.label === 'function' ? option.label() : option.label;
|
|
84
84
|
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
85
85
|
key: groupIndex
|
|
86
86
|
}, option.value ? /*#__PURE__*/React.createElement(SelectItem, {
|
|
@@ -95,9 +95,9 @@ export function Selector(_ref) {
|
|
|
95
95
|
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
96
96
|
size: size
|
|
97
97
|
}))
|
|
98
|
-
},
|
|
98
|
+
}, resolvedGroupLabel) : resolvedGroupLabel && /*#__PURE__*/React.createElement(SelectLabel, {
|
|
99
99
|
size: size
|
|
100
|
-
},
|
|
100
|
+
}, resolvedGroupLabel), option.options.map(function (_ref2) {
|
|
101
101
|
var label = _ref2.label,
|
|
102
102
|
optionLabel = _ref2.optionLabel,
|
|
103
103
|
value = _ref2.value,
|
|
@@ -105,6 +105,8 @@ export function Selector(_ref) {
|
|
|
105
105
|
icon = _ref2.icon,
|
|
106
106
|
tooltip = _ref2.tooltip,
|
|
107
107
|
disabledTooltip = _ref2.disabledTooltip;
|
|
108
|
+
var resolvedLabel = typeof label === 'function' ? label() : label;
|
|
109
|
+
var resolvedOptionLabel = typeof optionLabel === 'function' ? optionLabel() : optionLabel;
|
|
108
110
|
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
109
111
|
key: value,
|
|
110
112
|
value: value,
|
|
@@ -113,10 +115,12 @@ export function Selector(_ref) {
|
|
|
113
115
|
icon: icon,
|
|
114
116
|
tooltip: tooltip,
|
|
115
117
|
disabledTooltip: disabledTooltip,
|
|
116
|
-
isGroup: !!
|
|
117
|
-
},
|
|
118
|
+
isGroup: !!resolvedGroupLabel
|
|
119
|
+
}, resolvedOptionLabel !== null && resolvedOptionLabel !== void 0 ? resolvedOptionLabel : resolvedLabel);
|
|
118
120
|
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
119
121
|
}
|
|
122
|
+
var resolvedLabel = typeof option.label === 'function' ? option.label() : option.label;
|
|
123
|
+
var resolvedOptionLabel = typeof option.optionLabel === 'function' ? option.optionLabel() : option.optionLabel;
|
|
120
124
|
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
121
125
|
key: groupIndex
|
|
122
126
|
}, /*#__PURE__*/React.createElement(SelectItem, {
|
|
@@ -126,7 +130,7 @@ export function Selector(_ref) {
|
|
|
126
130
|
icon: option.icon,
|
|
127
131
|
tooltip: option.tooltip,
|
|
128
132
|
disabledTooltip: option.disabledTooltip
|
|
129
|
-
},
|
|
133
|
+
}, resolvedOptionLabel !== null && resolvedOptionLabel !== void 0 ? resolvedOptionLabel : resolvedLabel));
|
|
130
134
|
}), /*#__PURE__*/React.createElement(SelectActions, {
|
|
131
135
|
actions: actions
|
|
132
136
|
})));
|
package/select/select.types.d.ts
CHANGED
|
@@ -6,15 +6,15 @@ export interface SelectProps extends ComponentProps<typeof SelectPrimitive.Root>
|
|
|
6
6
|
}
|
|
7
7
|
export interface SelectTriggerProps extends ComponentProps<typeof SelectPrimitive.Trigger> {
|
|
8
8
|
size?: FormSizeType;
|
|
9
|
-
icon?: ReactElement;
|
|
9
|
+
icon?: ReactElement | (() => ReactElement);
|
|
10
10
|
readOnly?: boolean;
|
|
11
11
|
'aria-invalid'?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export interface SelectItemProps extends ComponentProps<typeof SelectPrimitive.Item> {
|
|
14
|
-
icon?: ReactElement;
|
|
14
|
+
icon?: ReactElement | (() => ReactElement);
|
|
15
15
|
size?: FormSizeType;
|
|
16
|
-
tooltip?: ReactElement | string;
|
|
17
|
-
disabledTooltip?: ReactElement | string;
|
|
16
|
+
tooltip?: ReactElement | string | (() => ReactElement);
|
|
17
|
+
disabledTooltip?: ReactElement | string | (() => ReactElement);
|
|
18
18
|
isGroup?: boolean;
|
|
19
19
|
}
|
|
20
20
|
export interface SelectLabelProps extends ComponentProps<typeof SelectPrimitive.Label> {
|
|
@@ -34,7 +34,7 @@ export interface SelectorProps extends SelectProps {
|
|
|
34
34
|
readOnly?: boolean;
|
|
35
35
|
size?: FormSizeType;
|
|
36
36
|
className?: string;
|
|
37
|
-
icon?: ReactElement;
|
|
37
|
+
icon?: ReactElement | (() => ReactElement);
|
|
38
38
|
defaultOpen?: boolean;
|
|
39
39
|
showGroupSeparator?: boolean;
|
|
40
40
|
formItemId?: string;
|