@scaleflex/ui-tw 0.0.152 → 0.0.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +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/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
|
@@ -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({
|
package/dialog/dialog.types.d.ts
CHANGED
|
@@ -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
|
-
},
|
|
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'],
|
|
@@ -202,7 +203,8 @@ export function InputTags(_ref) {
|
|
|
202
203
|
onSelect: function onSelect() {
|
|
203
204
|
return handleAddTag(tag);
|
|
204
205
|
},
|
|
205
|
-
isGroup: true
|
|
206
|
+
isGroup: true,
|
|
207
|
+
labelTooltip: tag.label
|
|
206
208
|
}, /*#__PURE__*/React.createElement("span", {
|
|
207
209
|
className: "block w-full truncate overflow-hidden text-ellipsis whitespace-nowrap"
|
|
208
210
|
}, tag.label));
|
|
@@ -216,7 +218,8 @@ export function InputTags(_ref) {
|
|
|
216
218
|
onSelect: function onSelect() {
|
|
217
219
|
return handleAddTag(tag);
|
|
218
220
|
},
|
|
219
|
-
isGroup: true
|
|
221
|
+
isGroup: true,
|
|
222
|
+
labelTooltip: tag.label
|
|
220
223
|
}, /*#__PURE__*/React.createElement("span", {
|
|
221
224
|
className: "block w-full truncate overflow-hidden text-ellipsis whitespace-nowrap"
|
|
222
225
|
}, tag.label));
|
|
@@ -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.153",
|
|
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.153",
|
|
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;
|
|
@@ -55,7 +55,9 @@ function TextareaWithActions(_ref) {
|
|
|
55
55
|
}
|
|
56
56
|
onBlur === null || onBlur === void 0 || onBlur(e);
|
|
57
57
|
};
|
|
58
|
-
var
|
|
58
|
+
var resolvedLeftToolbar = typeof leftToolbar === 'function' ? leftToolbar() : leftToolbar;
|
|
59
|
+
var resolvedRightToolbar = typeof rightToolbar === 'function' ? rightToolbar() : rightToolbar;
|
|
60
|
+
var hasBottomArea = resolvedLeftToolbar || resolvedRightToolbar || showCharCount;
|
|
59
61
|
return /*#__PURE__*/React.createElement("div", {
|
|
60
62
|
className: "relative"
|
|
61
63
|
}, /*#__PURE__*/React.createElement(Textarea, _extends({}, textareaProps, {
|
|
@@ -73,12 +75,12 @@ function TextareaWithActions(_ref) {
|
|
|
73
75
|
className: cn('bg-background absolute right-2.5 bottom-0.25 left-1.5', textareaBottomActionAreaPadding[size]),
|
|
74
76
|
onClick: handleActionClick,
|
|
75
77
|
tabIndex: -1
|
|
76
|
-
},
|
|
78
|
+
}, resolvedLeftToolbar && /*#__PURE__*/React.createElement("div", {
|
|
77
79
|
className: "absolute bottom-1.5 left-0 flex items-center gap-0.5"
|
|
78
|
-
},
|
|
80
|
+
}, resolvedLeftToolbar), /*#__PURE__*/React.createElement("div", {
|
|
79
81
|
className: "absolute right-0 bottom-1.5 flex items-center gap-0.5"
|
|
80
82
|
}, showCharCount && /*#__PURE__*/React.createElement("span", {
|
|
81
|
-
className: cn(textareaCharCountTextSizeOptions[size],
|
|
82
|
-
}, currentLength, "/", maxCharCount),
|
|
83
|
+
className: cn(textareaCharCountTextSizeOptions[size], resolvedRightToolbar && 'mr-1', charCountColorClass, disabled && 'opacity-50')
|
|
84
|
+
}, currentLength, "/", maxCharCount), resolvedRightToolbar)));
|
|
83
85
|
}
|
|
84
86
|
export { TextareaWithActions };
|
|
@@ -8,8 +8,8 @@ export interface TextareaProps extends Omit<ComponentProps<'textarea'>, 'size'>
|
|
|
8
8
|
maxCharCount?: number;
|
|
9
9
|
}
|
|
10
10
|
export interface TextareaWithActionsProps extends TextareaProps {
|
|
11
|
-
leftToolbar?: ReactElement;
|
|
12
|
-
rightToolbar?: ReactElement;
|
|
11
|
+
leftToolbar?: ReactElement | (() => ReactElement);
|
|
12
|
+
rightToolbar?: ReactElement | (() => ReactElement);
|
|
13
13
|
}
|
|
14
14
|
export interface RightToolbarButtonsProps {
|
|
15
15
|
size?: FormSizeType;
|
|
@@ -64,7 +64,8 @@ function WithTooltip(_ref5) {
|
|
|
64
64
|
delayDuration = _ref5.delayDuration,
|
|
65
65
|
open = _ref5.open,
|
|
66
66
|
otherProps = _objectWithoutProperties(_ref5, _excluded3);
|
|
67
|
-
|
|
67
|
+
var resolvedContent = typeof content === 'function' ? content() : content;
|
|
68
|
+
if (!resolvedContent) return children;
|
|
68
69
|
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
69
70
|
open: open,
|
|
70
71
|
delayDuration: delayDuration || 700
|
|
@@ -72,6 +73,6 @@ function WithTooltip(_ref5) {
|
|
|
72
73
|
asChild: true
|
|
73
74
|
}, children), /*#__PURE__*/React.createElement(TooltipContent, _extends({
|
|
74
75
|
variant: variant
|
|
75
|
-
}, otherProps),
|
|
76
|
+
}, otherProps), resolvedContent));
|
|
76
77
|
}
|
|
77
78
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, WithTooltip };
|
|
@@ -5,7 +5,7 @@ export type TooltipVariantType = (typeof TooltipVariant)[keyof typeof TooltipVar
|
|
|
5
5
|
export interface WithTooltipProps extends Omit<ComponentProps<typeof TooltipPrimitive.Content>, 'content'> {
|
|
6
6
|
children: ReactElement;
|
|
7
7
|
open?: boolean;
|
|
8
|
-
content?: ReactElement | undefined | string;
|
|
8
|
+
content?: ReactElement | undefined | string | (() => ReactElement);
|
|
9
9
|
variant?: TooltipVariantType;
|
|
10
10
|
delayDuration?: number;
|
|
11
11
|
}
|