@scaleflex/ui-tw 0.0.60 → 0.0.62
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/checkbox/checkbox.component.d.ts +4 -3
- package/checkbox/checkbox.component.js +37 -8
- package/checkbox/checkbox.types.d.ts +7 -0
- package/combobox/combobox-multi-checkbox/combobox-multi-checkbox.component.d.ts +3 -0
- package/combobox/combobox-multi-checkbox/combobox-multi-checkbox.component.js +194 -0
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +2 -2
- package/combobox/combobox.component.d.ts +3 -1
- package/combobox/combobox.component.js +210 -30
- package/combobox/combobox.types.d.ts +20 -1
- package/combobox/combobox.utils.d.ts +2 -0
- package/combobox/combobox.utils.js +12 -0
- package/combobox/index.d.ts +1 -0
- package/combobox/index.js +1 -0
- package/command/command.component.d.ts +2 -1
- package/command/command.component.js +45 -3
- package/date-picker/date-picker.component.d.ts +1 -1
- package/date-picker/date-picker.component.js +29 -13
- package/date-picker/date-picker.constants.d.ts +6 -0
- package/date-picker/date-picker.constants.js +69 -1
- package/date-picker/date-picker.types.d.ts +7 -0
- package/date-picker/index.d.ts +1 -0
- package/date-picker/index.js +2 -1
- package/dialog/dialog.component.js +2 -2
- package/input-tags/input-tags.component.js +2 -2
- package/package.json +2 -2
- package/search/search.component.js +1 -1
- package/select/components/select-icon.d.ts +1 -1
- package/select/select.component.js +3 -3
- package/select/select.types.d.ts +4 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
declare function Checkbox({ className, size, ...
|
|
4
|
-
|
|
2
|
+
import { CheckboxProps, VisualCheckboxProps } from './checkbox.types';
|
|
3
|
+
declare function Checkbox({ className, size, partial, ...rest }: CheckboxProps): React.JSX.Element;
|
|
4
|
+
declare function VisualCheckbox({ checked, partial, size, className, ...rest }: VisualCheckboxProps): React.JSX.Element;
|
|
5
|
+
export { Checkbox, VisualCheckbox };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "size"]
|
|
3
|
+
var _excluded = ["className", "size", "partial"],
|
|
4
|
+
_excluded2 = ["checked", "partial", "size", "className"];
|
|
4
5
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
5
6
|
import { ariaInvalidClassNames, focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
6
7
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
8
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
8
9
|
import { cva } from 'class-variance-authority';
|
|
9
|
-
import { CheckIcon } from 'lucide-react';
|
|
10
|
+
import { CheckIcon, MinusIcon } from 'lucide-react';
|
|
10
11
|
import React from 'react';
|
|
11
12
|
import { checkboxIndicatorSizeOptions, checkboxSizeOptions } from './checkbox.constants';
|
|
12
13
|
var checkboxVariants = cva('', {
|
|
@@ -27,20 +28,48 @@ var checkboxIndicatorVariants = cva('', {
|
|
|
27
28
|
});
|
|
28
29
|
function Checkbox(_ref) {
|
|
29
30
|
var className = _ref.className,
|
|
30
|
-
size = _ref.size,
|
|
31
|
-
|
|
31
|
+
_ref$size = _ref.size,
|
|
32
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
33
|
+
partial = _ref.partial,
|
|
34
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
35
|
return /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, _extends({
|
|
33
36
|
"data-slot": "checkbox",
|
|
34
37
|
className: cn('peer border-input shrink-0 cursor-pointer rounded-sm border shadow-xs transition-shadow outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary', ariaInvalidClassNames, focusRingClassNames, checkboxVariants({
|
|
35
38
|
size: size
|
|
36
39
|
}), className)
|
|
37
|
-
},
|
|
40
|
+
}, rest), /*#__PURE__*/React.createElement(CheckboxPrimitive.Indicator, {
|
|
38
41
|
"data-slot": "checkbox-indicator",
|
|
39
42
|
className: "flex items-center justify-center text-current transition-none"
|
|
40
|
-
}, /*#__PURE__*/React.createElement(
|
|
41
|
-
className: cn(checkboxIndicatorVariants({
|
|
43
|
+
}, partial ? /*#__PURE__*/React.createElement(MinusIcon, {
|
|
44
|
+
className: cn('text-current', checkboxIndicatorVariants({
|
|
45
|
+
size: size
|
|
46
|
+
}))
|
|
47
|
+
}) : /*#__PURE__*/React.createElement(CheckIcon, {
|
|
48
|
+
className: cn('text-current', checkboxIndicatorVariants({
|
|
49
|
+
size: size
|
|
50
|
+
}))
|
|
51
|
+
})));
|
|
52
|
+
}
|
|
53
|
+
function VisualCheckbox(_ref2) {
|
|
54
|
+
var checked = _ref2.checked,
|
|
55
|
+
partial = _ref2.partial,
|
|
56
|
+
_ref2$size = _ref2.size,
|
|
57
|
+
size = _ref2$size === void 0 ? FormSize.Md : _ref2$size,
|
|
58
|
+
className = _ref2.className,
|
|
59
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
60
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
61
|
+
"aria-hidden": "true",
|
|
62
|
+
className: cn('peer border-input shrink-0 cursor-pointer rounded-sm border shadow-xs transition-shadow outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', checked && 'bg-primary text-primary-foreground border-primary', ariaInvalidClassNames, focusRingClassNames, checkboxVariants({
|
|
63
|
+
size: size
|
|
64
|
+
}), className)
|
|
65
|
+
}, rest), checked && (partial ? /*#__PURE__*/React.createElement(MinusIcon, {
|
|
66
|
+
className: cn('text-current', checkboxIndicatorVariants({
|
|
67
|
+
size: size
|
|
68
|
+
}))
|
|
69
|
+
}) : /*#__PURE__*/React.createElement(CheckIcon, {
|
|
70
|
+
className: cn('text-current', checkboxIndicatorVariants({
|
|
42
71
|
size: size
|
|
43
72
|
}))
|
|
44
73
|
})));
|
|
45
74
|
}
|
|
46
|
-
export { Checkbox };
|
|
75
|
+
export { Checkbox, VisualCheckbox };
|
|
@@ -3,4 +3,11 @@ import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
4
|
export interface CheckboxProps extends ComponentProps<typeof CheckboxPrimitive.Root> {
|
|
5
5
|
size?: FormSizeType;
|
|
6
|
+
partial?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface VisualCheckboxProps extends ComponentProps<'div'> {
|
|
9
|
+
size?: FormSizeType;
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
partial?: boolean;
|
|
12
|
+
className?: string;
|
|
6
13
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComboboxMultiCheckboxProps } from '../combobox.types';
|
|
3
|
+
export declare function ComboboxMultiCheckbox({ options, label, icon, value: selectedValue, onChange, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, formItemId, searchPlaceholder, actions, fixedActions, triggerProps, iconClassName, placeholder, displayCount, ...rest }: ComboboxMultiCheckboxProps): React.JSX.Element;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["options", "label", "icon", "value", "onChange", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps", "formItemId", "searchPlaceholder", "actions", "fixedActions", "triggerProps", "iconClassName", "placeholder", "displayCount"];
|
|
5
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
8
|
+
import { ComboboxCheckboxContent, ComboboxCheckboxTrigger } from '@scaleflex/ui-tw/combobox/combobox.component';
|
|
9
|
+
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
10
|
+
import { Popover } from '@scaleflex/ui-tw/popover';
|
|
11
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { useMemo, useState } from 'react';
|
|
14
|
+
export function ComboboxMultiCheckbox(_ref) {
|
|
15
|
+
var _ref$options = _ref.options,
|
|
16
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
17
|
+
label = _ref.label,
|
|
18
|
+
icon = _ref.icon,
|
|
19
|
+
selectedValue = _ref.value,
|
|
20
|
+
onChange = _ref.onChange,
|
|
21
|
+
className = _ref.className,
|
|
22
|
+
_ref$disabled = _ref.disabled,
|
|
23
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
26
|
+
_ref$readOnly = _ref.readOnly,
|
|
27
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
28
|
+
_ref$showClear = _ref.showClear,
|
|
29
|
+
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
30
|
+
popoverClassName = _ref.popoverClassName,
|
|
31
|
+
onBlur = _ref.onBlur,
|
|
32
|
+
_ref$showGroupSeparat = _ref.showGroupSeparator,
|
|
33
|
+
showGroupSeparator = _ref$showGroupSeparat === void 0 ? false : _ref$showGroupSeparat,
|
|
34
|
+
_ref$defaultOpen = _ref.defaultOpen,
|
|
35
|
+
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
36
|
+
popoverContentProps = _ref.popoverContentProps,
|
|
37
|
+
formItemId = _ref.formItemId,
|
|
38
|
+
_ref$searchPlaceholde = _ref.searchPlaceholder,
|
|
39
|
+
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Search options...' : _ref$searchPlaceholde,
|
|
40
|
+
actions = _ref.actions,
|
|
41
|
+
fixedActions = _ref.fixedActions,
|
|
42
|
+
triggerProps = _ref.triggerProps,
|
|
43
|
+
iconClassName = _ref.iconClassName,
|
|
44
|
+
placeholder = _ref.placeholder,
|
|
45
|
+
_ref$displayCount = _ref.displayCount,
|
|
46
|
+
displayCount = _ref$displayCount === void 0 ? false : _ref$displayCount,
|
|
47
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
48
|
+
var _useState = useState(defaultOpen),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
open = _useState2[0],
|
|
51
|
+
setOpen = _useState2[1];
|
|
52
|
+
var selectedLabels = useMemo(function () {
|
|
53
|
+
var labels = [];
|
|
54
|
+
var _iterator = _createForOfIteratorHelper(options),
|
|
55
|
+
_step;
|
|
56
|
+
try {
|
|
57
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
58
|
+
var option = _step.value;
|
|
59
|
+
if (isOptionGroup(option)) {
|
|
60
|
+
if (option.value && selectedValue.includes(option.value)) {
|
|
61
|
+
labels.push(option.label);
|
|
62
|
+
}
|
|
63
|
+
var _iterator2 = _createForOfIteratorHelper(option.options),
|
|
64
|
+
_step2;
|
|
65
|
+
try {
|
|
66
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
67
|
+
var sub = _step2.value;
|
|
68
|
+
if (selectedValue.includes(sub.value)) {
|
|
69
|
+
labels.push(sub.label);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_iterator2.e(err);
|
|
74
|
+
} finally {
|
|
75
|
+
_iterator2.f();
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
if (selectedValue.includes(option.value)) {
|
|
79
|
+
labels.push(option.label);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
_iterator.e(err);
|
|
85
|
+
} finally {
|
|
86
|
+
_iterator.f();
|
|
87
|
+
}
|
|
88
|
+
return labels;
|
|
89
|
+
}, [options, selectedValue]);
|
|
90
|
+
var displayValue = selectedLabels.length > 0 ? selectedLabels.join(', ') : placeholder;
|
|
91
|
+
var toggleValue = function toggleValue(v) {
|
|
92
|
+
var group = options.find(function (opt) {
|
|
93
|
+
return isOptionGroup(opt) && opt.value === v;
|
|
94
|
+
});
|
|
95
|
+
var nextValue;
|
|
96
|
+
if (group && isOptionGroup(group)) {
|
|
97
|
+
var childValues = group.options.map(function (child) {
|
|
98
|
+
return child.value;
|
|
99
|
+
});
|
|
100
|
+
var isGroupSelected = selectedValue.includes(group.value);
|
|
101
|
+
if (isGroupSelected) {
|
|
102
|
+
nextValue = selectedValue.filter(function (val) {
|
|
103
|
+
return val !== group.value;
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
nextValue = [].concat(_toConsumableArray(selectedValue.filter(function (val) {
|
|
107
|
+
return !childValues.includes(val);
|
|
108
|
+
})), [group.value]);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
nextValue = selectedValue.includes(v) ? selectedValue.filter(function (val) {
|
|
112
|
+
return val !== v;
|
|
113
|
+
}) : [].concat(_toConsumableArray(selectedValue), [v]);
|
|
114
|
+
}
|
|
115
|
+
onChange(nextValue);
|
|
116
|
+
};
|
|
117
|
+
var onOpenChange = function onOpenChange(isOpen) {
|
|
118
|
+
if (!isOpen) {
|
|
119
|
+
onBlur === null || onBlur === void 0 || onBlur(selectedValue);
|
|
120
|
+
}
|
|
121
|
+
setOpen(isOpen);
|
|
122
|
+
};
|
|
123
|
+
var onClearAll = function onClearAll() {
|
|
124
|
+
onChange([]);
|
|
125
|
+
onBlur === null || onBlur === void 0 || onBlur([]);
|
|
126
|
+
setOpen(false);
|
|
127
|
+
};
|
|
128
|
+
var handleCheckboxClick = function handleCheckboxClick(event) {
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
var allValues = [];
|
|
131
|
+
var _iterator3 = _createForOfIteratorHelper(options),
|
|
132
|
+
_step3;
|
|
133
|
+
try {
|
|
134
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
135
|
+
var option = _step3.value;
|
|
136
|
+
if (isOptionGroup(option)) {
|
|
137
|
+
allValues.push(option.value);
|
|
138
|
+
allValues.push.apply(allValues, _toConsumableArray(option.options.map(function (sub) {
|
|
139
|
+
return sub.value;
|
|
140
|
+
})));
|
|
141
|
+
} else {
|
|
142
|
+
allValues.push(option.value);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
_iterator3.e(err);
|
|
147
|
+
} finally {
|
|
148
|
+
_iterator3.f();
|
|
149
|
+
}
|
|
150
|
+
var isNoneSelected = selectedLabels.length === 0;
|
|
151
|
+
var isPartiallySelected = selectedLabels.length > 0 && selectedLabels.length < allValues.length;
|
|
152
|
+
var isAllSelected = selectedLabels.length === allValues.length;
|
|
153
|
+
if (isNoneSelected || isPartiallySelected) {
|
|
154
|
+
onChange(_toConsumableArray(new Set(allValues)));
|
|
155
|
+
} else if (isAllSelected) {
|
|
156
|
+
onChange([]);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
160
|
+
open: open,
|
|
161
|
+
defaultOpen: defaultOpen,
|
|
162
|
+
onOpenChange: onOpenChange
|
|
163
|
+
}, /*#__PURE__*/React.createElement(ComboboxCheckboxTrigger, {
|
|
164
|
+
open: open,
|
|
165
|
+
icon: icon,
|
|
166
|
+
label: label,
|
|
167
|
+
disabled: disabled,
|
|
168
|
+
className: className,
|
|
169
|
+
size: size,
|
|
170
|
+
readOnly: readOnly,
|
|
171
|
+
showClear: showClear,
|
|
172
|
+
selected: selectedLabels.length > 0,
|
|
173
|
+
onClearAll: onClearAll,
|
|
174
|
+
"aria-invalid": rest['aria-invalid'],
|
|
175
|
+
formItemId: formItemId,
|
|
176
|
+
triggerProps: triggerProps,
|
|
177
|
+
iconClassName: iconClassName,
|
|
178
|
+
optionsLength: options.length,
|
|
179
|
+
displayCount: displayCount,
|
|
180
|
+
selectedLength: selectedLabels.length,
|
|
181
|
+
onCheckboxClick: handleCheckboxClick
|
|
182
|
+
}, displayValue), /*#__PURE__*/React.createElement(ComboboxCheckboxContent, {
|
|
183
|
+
showGroupSeparator: showGroupSeparator,
|
|
184
|
+
searchPlaceholder: searchPlaceholder,
|
|
185
|
+
className: popoverClassName,
|
|
186
|
+
options: options,
|
|
187
|
+
value: selectedValue,
|
|
188
|
+
onSelect: toggleValue,
|
|
189
|
+
size: size,
|
|
190
|
+
popoverContentProps: popoverContentProps,
|
|
191
|
+
actions: actions,
|
|
192
|
+
fixedActions: fixedActions
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
@@ -128,9 +128,9 @@ export function ComboboxMultiTag(_ref) {
|
|
|
128
128
|
variant: ButtonVariant.GhostSecondary
|
|
129
129
|
})]))
|
|
130
130
|
}, "Clear all"), /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
131
|
-
className: cn('mr-1.5 ml-auto shrink-0
|
|
131
|
+
className: cn('text-muted-foreground/70 mr-1.5 ml-auto shrink-0', iconSizeInTriggerOptions[size])
|
|
132
132
|
})) : /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
133
|
-
className: cn('my-auto ml-auto shrink-0
|
|
133
|
+
className: cn('text-muted-foreground/70 my-auto ml-auto shrink-0', iconSizeInTriggerOptions[size])
|
|
134
134
|
}))), /*#__PURE__*/React.createElement(ComboboxContent, {
|
|
135
135
|
options: options,
|
|
136
136
|
value: value,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { ComboboxCheckboxTriggerProps, ComboboxContentProps, ComboboxTriggerProps, SelectActionsProps } from './combobox.types';
|
|
3
3
|
export declare function SelectActions({ actions }: SelectActionsProps): React.JSX.Element | null;
|
|
4
4
|
export declare function ComboboxTrigger({ children, open, disabled, readOnly, size, className, selected, showClear, onClearAll, formItemId, triggerProps, ...rest }: ComboboxTriggerProps): React.JSX.Element;
|
|
5
|
+
export declare function ComboboxCheckboxTrigger({ children, open, label, disabled, readOnly, size, className, selected, showClear, onClearAll, formItemId, triggerProps, icon: Icon, iconClassName, optionsLength, selectedLength, onCheckboxClick, displayCount, ...rest }: ComboboxCheckboxTriggerProps): React.JSX.Element;
|
|
5
6
|
export declare function ComboboxContent({ options, value: selectedValue, onSelect, size, multiple, className, showGroupSeparator, popoverContentProps, searchPlaceholder, noGroupSelection, actions, fixedActions, }: ComboboxContentProps): React.JSX.Element;
|
|
7
|
+
export declare function ComboboxCheckboxContent({ options, value: selectedValue, onSelect, size, className, showGroupSeparator, popoverContentProps, searchPlaceholder, actions, fixedActions, }: ComboboxContentProps): React.JSX.Element;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["children", "open", "disabled", "readOnly", "size", "className", "selected", "showClear", "onClearAll", "formItemId", "triggerProps"]
|
|
4
|
+
var _excluded = ["children", "open", "disabled", "readOnly", "size", "className", "selected", "showClear", "onClearAll", "formItemId", "triggerProps"],
|
|
5
|
+
_excluded2 = ["children", "open", "label", "disabled", "readOnly", "size", "className", "selected", "showClear", "onClearAll", "formItemId", "triggerProps", "icon", "iconClassName", "optionsLength", "selectedLength", "onCheckboxClick", "displayCount"];
|
|
5
6
|
import { buttonVariants } from '@scaleflex/ui-tw/button';
|
|
6
7
|
import { ButtonVariant, buttonBaseClassNames } from '@scaleflex/ui-tw/button/button.constants';
|
|
8
|
+
import { VisualCheckbox } from '@scaleflex/ui-tw/checkbox/checkbox.component';
|
|
7
9
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@scaleflex/ui-tw/command';
|
|
10
|
+
import { CommandCheckboxItem } from '@scaleflex/ui-tw/command/command.component';
|
|
8
11
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
9
12
|
import { PopoverContent, PopoverTrigger } from '@scaleflex/ui-tw/popover';
|
|
10
13
|
import { SelectSeparator, selectTriggerVariants } from '@scaleflex/ui-tw/select/select.component';
|
|
@@ -15,11 +18,11 @@ import { getToolbarSizes } from '@scaleflex/ui-tw/textarea/textarea.utils';
|
|
|
15
18
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
16
19
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
17
20
|
import { cva } from 'class-variance-authority';
|
|
18
|
-
import { ChevronsUpDownIcon, XIcon } from 'lucide-react';
|
|
21
|
+
import { ChevronDown, ChevronsUpDownIcon, XIcon } from 'lucide-react';
|
|
19
22
|
import * as React from 'react';
|
|
20
23
|
import { Fragment } from 'react';
|
|
21
24
|
import { iconSizeInTriggerOptions, verticalSeparatorNextToChevronOptions } from './combobox.constants';
|
|
22
|
-
import { createClearHandlers } from './combobox.utils';
|
|
25
|
+
import { createClearHandlers, getIconSize } from './combobox.utils';
|
|
23
26
|
var selectLabelVariants = cva('', {
|
|
24
27
|
variants: {
|
|
25
28
|
size: selectLabelSizeOptions
|
|
@@ -90,34 +93,122 @@ export function ComboboxTrigger(_ref2) {
|
|
|
90
93
|
})]))
|
|
91
94
|
}, /*#__PURE__*/React.createElement(XIcon, {
|
|
92
95
|
"data-clear-icon": true,
|
|
93
|
-
className: cn('
|
|
96
|
+
className: cn('text-muted-foreground/70 hover:text-muted-foreground shrink-0', iconSizeInTriggerOptions[size])
|
|
94
97
|
})), /*#__PURE__*/React.createElement("div", {
|
|
95
98
|
className: cn(verticalSeparatorNextToChevronOptions[size])
|
|
96
99
|
}, /*#__PURE__*/React.createElement(Separator, {
|
|
97
100
|
orientation: "vertical"
|
|
98
101
|
}))), /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
99
|
-
className: cn('ml-1 shrink-0
|
|
102
|
+
className: cn('text-muted-foreground/70 ml-1 shrink-0', iconSizeInTriggerOptions[size])
|
|
100
103
|
}))));
|
|
101
104
|
}
|
|
102
|
-
export function
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
export function ComboboxCheckboxTrigger(_ref3) {
|
|
106
|
+
var children = _ref3.children,
|
|
107
|
+
open = _ref3.open,
|
|
108
|
+
label = _ref3.label,
|
|
109
|
+
_ref3$disabled = _ref3.disabled,
|
|
110
|
+
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
|
|
111
|
+
_ref3$readOnly = _ref3.readOnly,
|
|
112
|
+
readOnly = _ref3$readOnly === void 0 ? false : _ref3$readOnly,
|
|
106
113
|
_ref3$size = _ref3.size,
|
|
107
|
-
size = _ref3$size === void 0 ?
|
|
108
|
-
_ref3$multiple = _ref3.multiple,
|
|
109
|
-
multiple = _ref3$multiple === void 0 ? false : _ref3$multiple,
|
|
114
|
+
size = _ref3$size === void 0 ? FormSize.Md : _ref3$size,
|
|
110
115
|
className = _ref3.className,
|
|
111
|
-
_ref3$
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
_ref3$
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
_ref3$selected = _ref3.selected,
|
|
117
|
+
selected = _ref3$selected === void 0 ? false : _ref3$selected,
|
|
118
|
+
_ref3$showClear = _ref3.showClear,
|
|
119
|
+
showClear = _ref3$showClear === void 0 ? false : _ref3$showClear,
|
|
120
|
+
onClearAll = _ref3.onClearAll,
|
|
121
|
+
formItemId = _ref3.formItemId,
|
|
122
|
+
triggerProps = _ref3.triggerProps,
|
|
123
|
+
Icon = _ref3.icon,
|
|
124
|
+
iconClassName = _ref3.iconClassName,
|
|
125
|
+
optionsLength = _ref3.optionsLength,
|
|
126
|
+
selectedLength = _ref3.selectedLength,
|
|
127
|
+
onCheckboxClick = _ref3.onCheckboxClick,
|
|
128
|
+
_ref3$displayCount = _ref3.displayCount,
|
|
129
|
+
displayCount = _ref3$displayCount === void 0 ? false : _ref3$displayCount,
|
|
130
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
131
|
+
var _getToolbarSizes2 = getToolbarSizes(size),
|
|
132
|
+
iconSize = _getToolbarSizes2.iconSize;
|
|
133
|
+
var _createClearHandlers2 = createClearHandlers(onClearAll),
|
|
134
|
+
handleOnTriggerClick = _createClearHandlers2.onClick,
|
|
135
|
+
handleOnTriggerKeyDown = _createClearHandlers2.onKeyDown;
|
|
136
|
+
var handleCheckboxKeyDown = function handleCheckboxKeyDown(event) {
|
|
137
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
onCheckboxClick === null || onCheckboxClick === void 0 || onCheckboxClick(event);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
143
|
+
asChild: true
|
|
144
|
+
}, /*#__PURE__*/React.createElement("button", _extends({
|
|
145
|
+
id: formItemId,
|
|
146
|
+
role: "combobox",
|
|
147
|
+
"aria-expanded": open,
|
|
148
|
+
"aria-invalid": rest['aria-invalid'],
|
|
149
|
+
disabled: disabled,
|
|
150
|
+
className: cn.apply(void 0, _toConsumableArray(getBaseSelectClassNames()).concat(_toConsumableArray(getBaseInputClasses()), [selectTriggerVariants({
|
|
151
|
+
size: size
|
|
152
|
+
}), readOnly && selectReadOnlyClassNames, className, 'min-w-0'])),
|
|
153
|
+
onClick: handleOnTriggerClick,
|
|
154
|
+
onKeyDown: handleOnTriggerKeyDown
|
|
155
|
+
}, triggerProps), /*#__PURE__*/React.createElement(VisualCheckbox, {
|
|
156
|
+
size: size,
|
|
157
|
+
checked: !!selected,
|
|
158
|
+
partial: selectedLength !== optionsLength,
|
|
159
|
+
"aria-hidden": "true",
|
|
160
|
+
tabIndex: 0,
|
|
161
|
+
onClick: onCheckboxClick,
|
|
162
|
+
onKeyDown: handleCheckboxKeyDown
|
|
163
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
164
|
+
className: "flex min-w-0 grow items-center gap-2"
|
|
165
|
+
}, Icon && /*#__PURE__*/React.createElement(Icon, {
|
|
166
|
+
className: cn('text-muted-foreground hover:text-primary shrink-0', getIconSize(size), selected && 'text-primary', disabled && 'opacity-50', iconClassName)
|
|
167
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
168
|
+
className: cn('truncate font-normal', !label && selectedLength === 0 && 'text-muted-foreground')
|
|
169
|
+
}, label || children), displayCount && selectedLength > 0 && optionsLength > 1 && /*#__PURE__*/React.createElement("span", {
|
|
170
|
+
className: "text-muted-foreground text-sm"
|
|
171
|
+
}, selectedLength, "/", optionsLength)), /*#__PURE__*/React.createElement("div", {
|
|
172
|
+
className: "ml-2 flex items-center gap-1 pl-1"
|
|
173
|
+
}, showClear && !!onClearAll && selected && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
174
|
+
role: "button",
|
|
175
|
+
tabIndex: 0,
|
|
176
|
+
"data-clear-icon": "true",
|
|
177
|
+
"aria-label": "Clear all",
|
|
178
|
+
className: cn.apply(void 0, _toConsumableArray(buttonBaseClassNames).concat([focusRingClassNames, buttonVariants({
|
|
179
|
+
size: iconSize,
|
|
180
|
+
variant: ButtonVariant.GhostSecondary
|
|
181
|
+
})]))
|
|
182
|
+
}, /*#__PURE__*/React.createElement(XIcon, {
|
|
183
|
+
"data-clear-icon": true,
|
|
184
|
+
className: cn('text-muted-foreground/70 hover:text-muted-foreground shrink-0', iconSizeInTriggerOptions[size])
|
|
185
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: cn(verticalSeparatorNextToChevronOptions[size])
|
|
187
|
+
}, /*#__PURE__*/React.createElement(Separator, {
|
|
188
|
+
orientation: "vertical"
|
|
189
|
+
}))), /*#__PURE__*/React.createElement(ChevronDown, {
|
|
190
|
+
className: cn('text-muted-foreground/70 ml-1 shrink-0', iconSizeInTriggerOptions[size])
|
|
191
|
+
}))));
|
|
192
|
+
}
|
|
193
|
+
export function ComboboxContent(_ref4) {
|
|
194
|
+
var options = _ref4.options,
|
|
195
|
+
selectedValue = _ref4.value,
|
|
196
|
+
_onSelect = _ref4.onSelect,
|
|
197
|
+
_ref4$size = _ref4.size,
|
|
198
|
+
size = _ref4$size === void 0 ? 'md' : _ref4$size,
|
|
199
|
+
_ref4$multiple = _ref4.multiple,
|
|
200
|
+
multiple = _ref4$multiple === void 0 ? false : _ref4$multiple,
|
|
201
|
+
className = _ref4.className,
|
|
202
|
+
_ref4$showGroupSepara = _ref4.showGroupSeparator,
|
|
203
|
+
showGroupSeparator = _ref4$showGroupSepara === void 0 ? false : _ref4$showGroupSepara,
|
|
204
|
+
popoverContentProps = _ref4.popoverContentProps,
|
|
205
|
+
_ref4$searchPlacehold = _ref4.searchPlaceholder,
|
|
206
|
+
searchPlaceholder = _ref4$searchPlacehold === void 0 ? 'Search...' : _ref4$searchPlacehold,
|
|
207
|
+
_ref4$noGroupSelectio = _ref4.noGroupSelection,
|
|
208
|
+
noGroupSelection = _ref4$noGroupSelectio === void 0 ? false : _ref4$noGroupSelectio,
|
|
209
|
+
actions = _ref4.actions,
|
|
210
|
+
_ref4$fixedActions = _ref4.fixedActions,
|
|
211
|
+
fixedActions = _ref4$fixedActions === void 0 ? false : _ref4$fixedActions;
|
|
121
212
|
return /*#__PURE__*/React.createElement(PopoverContent, _extends({
|
|
122
213
|
className: cn('p-0', className)
|
|
123
214
|
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
|
|
@@ -147,14 +238,14 @@ export function ComboboxContent(_ref3) {
|
|
|
147
238
|
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
148
239
|
size: size
|
|
149
240
|
}))
|
|
150
|
-
}, option.label), option.options.map(function (
|
|
151
|
-
var label =
|
|
152
|
-
optionLabel =
|
|
153
|
-
value =
|
|
154
|
-
disabled =
|
|
155
|
-
icon =
|
|
156
|
-
tooltip =
|
|
157
|
-
disabledTooltip =
|
|
241
|
+
}, option.label), option.options.map(function (_ref5) {
|
|
242
|
+
var label = _ref5.label,
|
|
243
|
+
optionLabel = _ref5.optionLabel,
|
|
244
|
+
value = _ref5.value,
|
|
245
|
+
disabled = _ref5.disabled,
|
|
246
|
+
icon = _ref5.icon,
|
|
247
|
+
tooltip = _ref5.tooltip,
|
|
248
|
+
disabledTooltip = _ref5.disabledTooltip;
|
|
158
249
|
var isGroupSelected = !noGroupSelection && multiple && option.value && Array.isArray(selectedValue) && selectedValue.includes(option.value);
|
|
159
250
|
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
160
251
|
size: size,
|
|
@@ -194,4 +285,93 @@ export function ComboboxContent(_ref3) {
|
|
|
194
285
|
})), fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
195
286
|
actions: actions
|
|
196
287
|
})));
|
|
288
|
+
}
|
|
289
|
+
export function ComboboxCheckboxContent(_ref6) {
|
|
290
|
+
var options = _ref6.options,
|
|
291
|
+
selectedValue = _ref6.value,
|
|
292
|
+
_onSelect2 = _ref6.onSelect,
|
|
293
|
+
_ref6$size = _ref6.size,
|
|
294
|
+
size = _ref6$size === void 0 ? 'md' : _ref6$size,
|
|
295
|
+
className = _ref6.className,
|
|
296
|
+
_ref6$showGroupSepara = _ref6.showGroupSeparator,
|
|
297
|
+
showGroupSeparator = _ref6$showGroupSepara === void 0 ? false : _ref6$showGroupSepara,
|
|
298
|
+
popoverContentProps = _ref6.popoverContentProps,
|
|
299
|
+
_ref6$searchPlacehold = _ref6.searchPlaceholder,
|
|
300
|
+
searchPlaceholder = _ref6$searchPlacehold === void 0 ? 'Search...' : _ref6$searchPlacehold,
|
|
301
|
+
actions = _ref6.actions,
|
|
302
|
+
_ref6$fixedActions = _ref6.fixedActions,
|
|
303
|
+
fixedActions = _ref6$fixedActions === void 0 ? false : _ref6$fixedActions;
|
|
304
|
+
return /*#__PURE__*/React.createElement(PopoverContent, _extends({
|
|
305
|
+
className: cn('p-0', className)
|
|
306
|
+
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
|
|
307
|
+
size: size,
|
|
308
|
+
placeholder: searchPlaceholder
|
|
309
|
+
}), /*#__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) {
|
|
310
|
+
var _option$optionLabel2;
|
|
311
|
+
if (isOptionGroup(option)) {
|
|
312
|
+
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
313
|
+
key: groupIndex,
|
|
314
|
+
heading: !option.value ? option.label : undefined,
|
|
315
|
+
size: size
|
|
316
|
+
}, option.value && /*#__PURE__*/React.createElement(CommandCheckboxItem, {
|
|
317
|
+
size: size,
|
|
318
|
+
disabled: option.disabled,
|
|
319
|
+
key: option.value,
|
|
320
|
+
icon: option.icon,
|
|
321
|
+
value: option.value,
|
|
322
|
+
tooltip: option.tooltip,
|
|
323
|
+
disabledTooltip: option.disabledTooltip,
|
|
324
|
+
isGroup: true,
|
|
325
|
+
selectedValue: selectedValue,
|
|
326
|
+
onSelect: function onSelect() {
|
|
327
|
+
return _onSelect2(option.value);
|
|
328
|
+
},
|
|
329
|
+
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
330
|
+
size: size
|
|
331
|
+
}))
|
|
332
|
+
}, option.label), option.options.map(function (_ref7) {
|
|
333
|
+
var label = _ref7.label,
|
|
334
|
+
optionLabel = _ref7.optionLabel,
|
|
335
|
+
value = _ref7.value,
|
|
336
|
+
disabled = _ref7.disabled,
|
|
337
|
+
icon = _ref7.icon,
|
|
338
|
+
tooltip = _ref7.tooltip,
|
|
339
|
+
disabledTooltip = _ref7.disabledTooltip;
|
|
340
|
+
var isGroupSelected = option.value && Array.isArray(selectedValue) && selectedValue.includes(option.value);
|
|
341
|
+
return /*#__PURE__*/React.createElement(CommandCheckboxItem, {
|
|
342
|
+
size: size,
|
|
343
|
+
disabled: disabled || !!isGroupSelected,
|
|
344
|
+
key: value,
|
|
345
|
+
icon: icon,
|
|
346
|
+
value: value,
|
|
347
|
+
tooltip: tooltip,
|
|
348
|
+
disabledTooltip: disabledTooltip,
|
|
349
|
+
isGroup: !!option.label,
|
|
350
|
+
selectedValue: selectedValue,
|
|
351
|
+
onSelect: function onSelect() {
|
|
352
|
+
return _onSelect2(value);
|
|
353
|
+
}
|
|
354
|
+
}, optionLabel !== null && optionLabel !== void 0 ? optionLabel : label);
|
|
355
|
+
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
356
|
+
}
|
|
357
|
+
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
358
|
+
key: "default"
|
|
359
|
+
}, /*#__PURE__*/React.createElement(CommandCheckboxItem, {
|
|
360
|
+
size: size,
|
|
361
|
+
disabled: option.disabled,
|
|
362
|
+
key: option.value,
|
|
363
|
+
icon: option.icon,
|
|
364
|
+
value: option.value,
|
|
365
|
+
tooltip: option.tooltip,
|
|
366
|
+
disabledTooltip: option.disabledTooltip,
|
|
367
|
+
selectedValue: selectedValue,
|
|
368
|
+
onSelect: function onSelect() {
|
|
369
|
+
return _onSelect2(option.value);
|
|
370
|
+
}
|
|
371
|
+
}, (_option$optionLabel2 = option.optionLabel) !== null && _option$optionLabel2 !== void 0 ? _option$optionLabel2 : option.label));
|
|
372
|
+
}), !fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
373
|
+
actions: actions
|
|
374
|
+
})), fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
375
|
+
actions: actions
|
|
376
|
+
})));
|
|
197
377
|
}
|
|
@@ -2,7 +2,7 @@ import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
|
2
2
|
import { SelectOption } from '@scaleflex/ui-tw/form';
|
|
3
3
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
4
4
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
5
|
-
import type { ButtonHTMLAttributes, ComponentProps, KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
5
|
+
import type { ButtonHTMLAttributes, ComponentProps, ElementType, KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
6
6
|
export type ClearEvent = MouseEvent | KeyboardEvent;
|
|
7
7
|
export type SelectActionsProps = {
|
|
8
8
|
actions?: ReactNode[];
|
|
@@ -21,6 +21,15 @@ export type ComboboxTriggerProps = {
|
|
|
21
21
|
onClearAll?: () => void;
|
|
22
22
|
triggerProps?: ButtonHTMLAttributes<HTMLButtonElement>;
|
|
23
23
|
};
|
|
24
|
+
export type ComboboxCheckboxTriggerProps = ComboboxTriggerProps & {
|
|
25
|
+
optionsLength: number;
|
|
26
|
+
selectedLength: number;
|
|
27
|
+
label?: ReactNode | string;
|
|
28
|
+
displayCount?: boolean;
|
|
29
|
+
icon?: ElementType;
|
|
30
|
+
iconClassName?: string;
|
|
31
|
+
onCheckboxClick?: (event: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>) => void;
|
|
32
|
+
};
|
|
24
33
|
export type ComboboxContentProps = {
|
|
25
34
|
options: SelectOption[];
|
|
26
35
|
value: string | string[];
|
|
@@ -83,6 +92,16 @@ export interface ComboboxMultiInlineProps extends ComboboxCommonProps {
|
|
|
83
92
|
onBlur?: (value: string[]) => void;
|
|
84
93
|
showClear?: boolean;
|
|
85
94
|
}
|
|
95
|
+
export interface ComboboxMultiCheckboxProps extends ComboboxCommonProps {
|
|
96
|
+
value: string[];
|
|
97
|
+
onChange: (value: string[]) => void;
|
|
98
|
+
label?: ReactElement | string;
|
|
99
|
+
displayCount?: boolean;
|
|
100
|
+
iconClassName?: string;
|
|
101
|
+
icon?: ElementType;
|
|
102
|
+
onBlur?: (value: string[]) => void;
|
|
103
|
+
showClear?: boolean;
|
|
104
|
+
}
|
|
86
105
|
export interface ComboboxMultiTagProps extends ComboboxCommonProps {
|
|
87
106
|
value: string[];
|
|
88
107
|
onChange: (value: string[]) => void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FlatOption, SelectOption } from '@scaleflex/ui-tw/form';
|
|
2
|
+
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
2
3
|
import { KeyboardEvent, MouseEvent } from 'react';
|
|
3
4
|
export declare const flattenOptions: (options: SelectOption[]) => FlatOption[];
|
|
4
5
|
export declare const createClearHandlers: (onClearAll?: () => void) => {
|
|
5
6
|
onClick: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
6
7
|
onKeyDown: (e: KeyboardEvent<HTMLButtonElement>) => void;
|
|
7
8
|
};
|
|
9
|
+
export declare const getIconSize: (size: FormSizeType) => string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
2
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
2
3
|
export var flattenOptions = function flattenOptions(options) {
|
|
3
4
|
return options.flatMap(function (option) {
|
|
4
5
|
return isOptionGroup(option) ? option.options : [option];
|
|
@@ -25,4 +26,15 @@ export var createClearHandlers = function createClearHandlers(onClearAll) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
};
|
|
29
|
+
};
|
|
30
|
+
export var getIconSize = function getIconSize(size) {
|
|
31
|
+
switch (size) {
|
|
32
|
+
case FormSize.Lg:
|
|
33
|
+
return 'size-6 ml-2';
|
|
34
|
+
case FormSize.Sm:
|
|
35
|
+
return 'size-4 ml-1';
|
|
36
|
+
case FormSize.Md:
|
|
37
|
+
default:
|
|
38
|
+
return 'size-5 ml-1.5';
|
|
39
|
+
}
|
|
28
40
|
};
|
package/combobox/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { ComboboxTrigger, ComboboxContent } from './combobox.component';
|
|
|
2
2
|
export { ComboboxSingle } from './combobox-single/combobox-single.component';
|
|
3
3
|
export { ComboboxMultiInline } from './combobox-multi-inline/combobox-multi-inline.component';
|
|
4
4
|
export { ComboboxMultiTag } from './combobox-multi-tag/combobox-multi-tag.component';
|
|
5
|
+
export { ComboboxMultiCheckbox } from './combobox-multi-checkbox/combobox-multi-checkbox.component';
|
|
5
6
|
export { flattenOptions } from './combobox.utils';
|
package/combobox/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { ComboboxTrigger, ComboboxContent } from './combobox.component';
|
|
|
2
2
|
export { ComboboxSingle } from './combobox-single/combobox-single.component';
|
|
3
3
|
export { ComboboxMultiInline } from './combobox-multi-inline/combobox-multi-inline.component';
|
|
4
4
|
export { ComboboxMultiTag } from './combobox-multi-tag/combobox-multi-tag.component';
|
|
5
|
+
export { ComboboxMultiCheckbox } from './combobox-multi-checkbox/combobox-multi-checkbox.component';
|
|
5
6
|
export { flattenOptions } from './combobox.utils';
|
|
@@ -14,5 +14,6 @@ declare function CommandEmpty({ className, ...rest }: ComponentProps<typeof Comm
|
|
|
14
14
|
declare function CommandGroup({ className, size, ...props }: CommandGroupProps): React.JSX.Element;
|
|
15
15
|
declare function CommandSeparator({ className, ...props }: ComponentProps<typeof CommandPrimitive.Separator>): React.JSX.Element;
|
|
16
16
|
declare function CommandItem({ className, size, isGroup, icon, tooltip, children, selectedValue, multiple, value, shortcut, disabledTooltip, disabled, ...props }: CommandItemProps): React.JSX.Element;
|
|
17
|
+
declare function CommandCheckboxItem({ className, size, isGroup, children, selectedValue, value, icon, disabled, tooltip, disabledTooltip, ...props }: CommandItemProps): React.JSX.Element;
|
|
17
18
|
declare function CommandShortcut({ className, ...props }: ComponentProps<'span'>): React.JSX.Element;
|
|
18
|
-
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator, };
|
|
19
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator, };
|
|
@@ -8,7 +8,9 @@ var _excluded = ["className"],
|
|
|
8
8
|
_excluded6 = ["className", "size"],
|
|
9
9
|
_excluded7 = ["className"],
|
|
10
10
|
_excluded8 = ["className", "size", "isGroup", "icon", "tooltip", "children", "selectedValue", "multiple", "value", "shortcut", "disabledTooltip", "disabled"],
|
|
11
|
-
_excluded9 = ["className"]
|
|
11
|
+
_excluded9 = ["className", "size", "isGroup", "children", "selectedValue", "value", "icon", "disabled", "tooltip", "disabledTooltip"],
|
|
12
|
+
_excluded10 = ["className"];
|
|
13
|
+
import { Checkbox } from '@scaleflex/ui-tw/checkbox';
|
|
12
14
|
import { Dialog, DialogFormDescription, DialogFormHeader, DialogFormTitle, DialogWideContent } from '@scaleflex/ui-tw/dialog';
|
|
13
15
|
import { LabelIcon } from '@scaleflex/ui-tw/label/components/label-icon';
|
|
14
16
|
import { SelectIcon } from '@scaleflex/ui-tw/select/components/select-icon';
|
|
@@ -150,12 +152,52 @@ function CommandItem(_ref8) {
|
|
|
150
152
|
className: cn('text-primary ml-auto h-4 w-4', selected ? 'opacity-100' : 'opacity-0')
|
|
151
153
|
})));
|
|
152
154
|
}
|
|
153
|
-
function
|
|
155
|
+
function CommandCheckboxItem(_ref9) {
|
|
154
156
|
var className = _ref9.className,
|
|
157
|
+
size = _ref9.size,
|
|
158
|
+
isGroup = _ref9.isGroup,
|
|
159
|
+
children = _ref9.children,
|
|
160
|
+
selectedValue = _ref9.selectedValue,
|
|
161
|
+
value = _ref9.value,
|
|
162
|
+
icon = _ref9.icon,
|
|
163
|
+
disabled = _ref9.disabled,
|
|
164
|
+
tooltip = _ref9.tooltip,
|
|
165
|
+
disabledTooltip = _ref9.disabledTooltip,
|
|
155
166
|
props = _objectWithoutProperties(_ref9, _excluded9);
|
|
167
|
+
var selected = value && (selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value));
|
|
168
|
+
return /*#__PURE__*/React.createElement(CommandPrimitive.Item, _extends({
|
|
169
|
+
"data-slot": "command-checkbox-item",
|
|
170
|
+
className: cn('relative flex w-full cursor-pointer items-center gap-3 outline-none select-none', 'data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground', '!opacity-100 data-[disabled=true]:cursor-not-allowed', selectItemVariants({
|
|
171
|
+
size: size
|
|
172
|
+
}), isGroup && getOptionInGroupPaddingLeft(size), className),
|
|
173
|
+
disabled: disabled
|
|
174
|
+
}, props), /*#__PURE__*/React.createElement(Checkbox, {
|
|
175
|
+
size: size,
|
|
176
|
+
checked: !!selected,
|
|
177
|
+
"aria-hidden": "true",
|
|
178
|
+
tabIndex: -1,
|
|
179
|
+
className: "pointer-events-none"
|
|
180
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
181
|
+
className: "flex items-center gap-1 overflow-hidden"
|
|
182
|
+
}, icon && /*#__PURE__*/React.createElement(SelectIcon, {
|
|
183
|
+
size: size,
|
|
184
|
+
icon: icon,
|
|
185
|
+
className: cn('text-muted-foreground hover:text-primary !mr-1 shrink-0', selected && 'text-primary', disabled && 'opacity-50')
|
|
186
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
187
|
+
className: cn('line-clamp-2 overflow-hidden text-left break-words text-ellipsis', disabled && 'opacity-50')
|
|
188
|
+
}, children), (tooltip || disabledTooltip) && /*#__PURE__*/React.createElement("div", {
|
|
189
|
+
className: "flex shrink-0 items-center"
|
|
190
|
+
}, /*#__PURE__*/React.createElement(LabelIcon, {
|
|
191
|
+
size: size,
|
|
192
|
+
tooltip: disabled ? disabledTooltip : tooltip
|
|
193
|
+
}))));
|
|
194
|
+
}
|
|
195
|
+
function CommandShortcut(_ref10) {
|
|
196
|
+
var className = _ref10.className,
|
|
197
|
+
props = _objectWithoutProperties(_ref10, _excluded10);
|
|
156
198
|
return /*#__PURE__*/React.createElement("span", _extends({
|
|
157
199
|
"data-slot": "command-shortcut",
|
|
158
200
|
className: cn('text-muted-foreground ml-auto text-xs tracking-widest', className)
|
|
159
201
|
}, props));
|
|
160
202
|
}
|
|
161
|
-
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator };
|
|
203
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandCheckboxItem, CommandShortcut, CommandSeparator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DatePickerProps } from './date-picker.types';
|
|
3
|
-
declare function DatePicker({ minDate, maxDate, readOnly, defaultDate, size, invalidDateText, disabled, onChange, popoverClassName, defaultOpen, popoverContentProps, onKeyDown, onBlur, ...rest }: DatePickerProps): React.JSX.Element;
|
|
3
|
+
declare function DatePicker({ minDate, maxDate, readOnly, defaultDate, size, invalidDateText, disabled, onChange, popoverClassName, defaultOpen, popoverContentProps, onKeyDown, onBlur, placeholder, format: dateFormat, locale, calendarProps, ...rest }: DatePickerProps): React.JSX.Element;
|
|
4
4
|
export { DatePicker };
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["minDate", "maxDate", "readOnly", "defaultDate", "size", "invalidDateText", "disabled", "onChange", "popoverClassName", "defaultOpen", "popoverContentProps", "onKeyDown", "onBlur"];
|
|
5
|
+
var _excluded = ["minDate", "maxDate", "readOnly", "defaultDate", "size", "invalidDateText", "disabled", "onChange", "popoverClassName", "defaultOpen", "popoverContentProps", "onKeyDown", "onBlur", "placeholder", "format", "locale", "calendarProps"];
|
|
6
6
|
import { Button } from '@scaleflex/ui-tw/button';
|
|
7
7
|
import { Calendar } from '@scaleflex/ui-tw/calendar';
|
|
8
8
|
import { Input } from '@scaleflex/ui-tw/input';
|
|
@@ -12,10 +12,11 @@ import { getBaseSelectClassNames, selectReadOnlyClassNames } from '@scaleflex/ui
|
|
|
12
12
|
import { getBaseInputClasses } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
13
13
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
14
14
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
15
|
+
import { format, isValid, parse } from 'date-fns';
|
|
16
|
+
import { enGB } from 'date-fns/locale';
|
|
15
17
|
import { CalendarIcon } from 'lucide-react';
|
|
16
18
|
import React, { useRef, useState } from 'react';
|
|
17
19
|
import { buttonSizeInTriggerOptions, iconSizeInTriggerOptions } from './date-picker.constants';
|
|
18
|
-
import { parseDateString, toHtmlDateString } from './date-picker.utils';
|
|
19
20
|
function DatePicker(_ref) {
|
|
20
21
|
var minDate = _ref.minDate,
|
|
21
22
|
maxDate = _ref.maxDate,
|
|
@@ -33,6 +34,12 @@ function DatePicker(_ref) {
|
|
|
33
34
|
popoverContentProps = _ref.popoverContentProps,
|
|
34
35
|
onKeyDown = _ref.onKeyDown,
|
|
35
36
|
onBlur = _ref.onBlur,
|
|
37
|
+
placeholder = _ref.placeholder,
|
|
38
|
+
_ref$format = _ref.format,
|
|
39
|
+
dateFormat = _ref$format === void 0 ? 'dd/MM/yyyy' : _ref$format,
|
|
40
|
+
_ref$locale = _ref.locale,
|
|
41
|
+
locale = _ref$locale === void 0 ? enGB : _ref$locale,
|
|
42
|
+
calendarProps = _ref.calendarProps,
|
|
36
43
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
37
44
|
var inputRef = useRef(null);
|
|
38
45
|
var isEscapeBlur = useRef(false);
|
|
@@ -40,7 +47,9 @@ function DatePicker(_ref) {
|
|
|
40
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
41
48
|
open = _useState2[0],
|
|
42
49
|
setOpen = _useState2[1];
|
|
43
|
-
var _useState3 = useState(
|
|
50
|
+
var _useState3 = useState(defaultDate ? format(defaultDate, dateFormat, {
|
|
51
|
+
locale: locale
|
|
52
|
+
}) : ''),
|
|
44
53
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
54
|
inputValue = _useState4[0],
|
|
46
55
|
setInputValue = _useState4[1];
|
|
@@ -52,13 +61,17 @@ function DatePicker(_ref) {
|
|
|
52
61
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
53
62
|
calendarMonth = _useState8[0],
|
|
54
63
|
setCalendarMonth = _useState8[1];
|
|
55
|
-
var parsedDate = inputValue
|
|
56
|
-
|
|
64
|
+
var parsedDate = inputValue ? parse(inputValue, dateFormat, new Date(), {
|
|
65
|
+
locale: locale
|
|
66
|
+
}) : undefined;
|
|
67
|
+
var isInputValid = !inputValue || parsedDate && isValid(parsedDate);
|
|
57
68
|
var handleInputChange = function handleInputChange(e) {
|
|
58
69
|
var value = e.target.value;
|
|
59
70
|
setInputValue(value);
|
|
60
|
-
var parsed =
|
|
61
|
-
|
|
71
|
+
var parsed = parse(value, dateFormat, new Date(), {
|
|
72
|
+
locale: locale
|
|
73
|
+
});
|
|
74
|
+
if (isValid(parsed)) {
|
|
62
75
|
setSelectedDate(parsed);
|
|
63
76
|
setCalendarMonth(parsed);
|
|
64
77
|
}
|
|
@@ -67,7 +80,9 @@ function DatePicker(_ref) {
|
|
|
67
80
|
if (date) {
|
|
68
81
|
var _inputRef$current;
|
|
69
82
|
setSelectedDate(date);
|
|
70
|
-
setInputValue(
|
|
83
|
+
setInputValue(format(date, dateFormat, {
|
|
84
|
+
locale: locale
|
|
85
|
+
}));
|
|
71
86
|
setCalendarMonth(date);
|
|
72
87
|
setOpen(false);
|
|
73
88
|
onChange === null || onChange === void 0 || onChange(date);
|
|
@@ -108,7 +123,7 @@ function DatePicker(_ref) {
|
|
|
108
123
|
inputMode: "numeric",
|
|
109
124
|
autoComplete: "off",
|
|
110
125
|
pattern: "\\d{2}/\\d{2}/\\d{4}",
|
|
111
|
-
placeholder:
|
|
126
|
+
placeholder: placeholder || dateFormat,
|
|
112
127
|
value: inputValue,
|
|
113
128
|
disabled: disabled,
|
|
114
129
|
className: cn.apply(void 0, _toConsumableArray(getBaseSelectClassNames()).concat(_toConsumableArray(getBaseInputClasses()), ['hover:border-secondary-foreground/50', selectTriggerVariants({
|
|
@@ -143,7 +158,7 @@ function DatePicker(_ref) {
|
|
|
143
158
|
align: "end",
|
|
144
159
|
alignOffset: -8,
|
|
145
160
|
sideOffset: 10
|
|
146
|
-
}, popoverContentProps), /*#__PURE__*/React.createElement(Calendar, {
|
|
161
|
+
}, popoverContentProps), /*#__PURE__*/React.createElement(Calendar, _extends({
|
|
147
162
|
mode: "single",
|
|
148
163
|
selected: selectedDate,
|
|
149
164
|
captionLayout: "dropdown",
|
|
@@ -154,9 +169,10 @@ function DatePicker(_ref) {
|
|
|
154
169
|
before: minDate
|
|
155
170
|
}, maxDate && {
|
|
156
171
|
after: maxDate
|
|
157
|
-
}].filter(Boolean)
|
|
158
|
-
|
|
172
|
+
}].filter(Boolean),
|
|
173
|
+
locale: locale
|
|
174
|
+
}, calendarProps))))), !isInputValid && /*#__PURE__*/React.createElement("span", {
|
|
159
175
|
className: "px-1 text-xs text-red-500"
|
|
160
|
-
}, invalidDateText !== null && invalidDateText !== void 0 ? invalidDateText :
|
|
176
|
+
}, invalidDateText !== null && invalidDateText !== void 0 ? invalidDateText : "Invalid date. Use ".concat(placeholder || dateFormat)));
|
|
161
177
|
}
|
|
162
178
|
export { DatePicker };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Locale } from 'date-fns';
|
|
1
2
|
export declare const iconSizeInTriggerOptions: {
|
|
2
3
|
sm: string;
|
|
3
4
|
md: string;
|
|
@@ -8,3 +9,8 @@ export declare const buttonSizeInTriggerOptions: {
|
|
|
8
9
|
md: string;
|
|
9
10
|
lg: string;
|
|
10
11
|
};
|
|
12
|
+
export declare const SUPPORTED_DATE_LOCALES: Record<string, {
|
|
13
|
+
label: string;
|
|
14
|
+
locale: Locale;
|
|
15
|
+
format: string;
|
|
16
|
+
}>;
|
|
@@ -1,4 +1,72 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
import { de, enGB, enUS, es, fr, id, it, ja, nl, pl, pt, ro, zhCN } from 'date-fns/locale';
|
|
3
4
|
export var iconSizeInTriggerOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-3'), FormSize.Md, 'size-4'), FormSize.Lg, 'size-5');
|
|
4
|
-
export var buttonSizeInTriggerOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'icon-xs'), FormSize.Md, 'icon-sm'), FormSize.Lg, 'icon-md');
|
|
5
|
+
export var buttonSizeInTriggerOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'icon-xs'), FormSize.Md, 'icon-sm'), FormSize.Lg, 'icon-md');
|
|
6
|
+
export var SUPPORTED_DATE_LOCALES = {
|
|
7
|
+
en: {
|
|
8
|
+
label: 'English (US)',
|
|
9
|
+
locale: enUS,
|
|
10
|
+
format: 'MM/dd/yyyy'
|
|
11
|
+
},
|
|
12
|
+
enGB: {
|
|
13
|
+
label: 'English (UK)',
|
|
14
|
+
locale: enGB,
|
|
15
|
+
format: 'dd/MM/yyyy'
|
|
16
|
+
},
|
|
17
|
+
de: {
|
|
18
|
+
label: 'German',
|
|
19
|
+
locale: de,
|
|
20
|
+
format: 'dd.MM.yyyy'
|
|
21
|
+
},
|
|
22
|
+
es: {
|
|
23
|
+
label: 'Spanish',
|
|
24
|
+
locale: es,
|
|
25
|
+
format: 'dd/MM/yyyy'
|
|
26
|
+
},
|
|
27
|
+
fr: {
|
|
28
|
+
label: 'French',
|
|
29
|
+
locale: fr,
|
|
30
|
+
format: 'dd/MM/yyyy'
|
|
31
|
+
},
|
|
32
|
+
id: {
|
|
33
|
+
label: 'Indonesian',
|
|
34
|
+
locale: id,
|
|
35
|
+
format: 'dd/MM/yyyy'
|
|
36
|
+
},
|
|
37
|
+
it: {
|
|
38
|
+
label: 'Italian',
|
|
39
|
+
locale: it,
|
|
40
|
+
format: 'dd/MM/yyyy'
|
|
41
|
+
},
|
|
42
|
+
ja: {
|
|
43
|
+
label: 'Japanese',
|
|
44
|
+
locale: ja,
|
|
45
|
+
format: 'yyyy/MM/dd'
|
|
46
|
+
},
|
|
47
|
+
nl: {
|
|
48
|
+
label: 'Dutch',
|
|
49
|
+
locale: nl,
|
|
50
|
+
format: 'dd-MM-yyyy'
|
|
51
|
+
},
|
|
52
|
+
pl: {
|
|
53
|
+
label: 'Polish',
|
|
54
|
+
locale: pl,
|
|
55
|
+
format: 'dd.MM.yyyy'
|
|
56
|
+
},
|
|
57
|
+
pt: {
|
|
58
|
+
label: 'Portuguese',
|
|
59
|
+
locale: pt,
|
|
60
|
+
format: 'dd/MM/yyyy'
|
|
61
|
+
},
|
|
62
|
+
ro: {
|
|
63
|
+
label: 'Romanian',
|
|
64
|
+
locale: ro,
|
|
65
|
+
format: 'dd.MM.yyyy'
|
|
66
|
+
},
|
|
67
|
+
zh: {
|
|
68
|
+
label: 'Chinese',
|
|
69
|
+
locale: zhCN,
|
|
70
|
+
format: 'yyyy/MM/dd'
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
2
2
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
import type { Locale } from 'date-fns';
|
|
3
4
|
import type { ComponentProps, FocusEvent, KeyboardEvent } from 'react';
|
|
5
|
+
import { DayPicker } from 'react-day-picker';
|
|
4
6
|
export type DatePickerProps = {
|
|
5
7
|
minDate?: Date;
|
|
6
8
|
maxDate?: Date;
|
|
@@ -15,4 +17,9 @@ export type DatePickerProps = {
|
|
|
15
17
|
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
16
18
|
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
17
19
|
popoverContentProps?: ComponentProps<typeof PopoverPrimitive.Content>;
|
|
20
|
+
calendarProps?: Omit<ComponentProps<typeof DayPicker>, 'selected' | 'onSelect' | 'month' | 'mode' | 'captionLayout' | 'onMonthChange' | 'disabled'>;
|
|
21
|
+
pattern?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
format?: string;
|
|
24
|
+
locale?: Locale;
|
|
18
25
|
};
|
package/date-picker/index.d.ts
CHANGED
package/date-picker/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { DatePicker } from './date-picker.component';
|
|
1
|
+
export { DatePicker } from './date-picker.component';
|
|
2
|
+
export { SUPPORTED_DATE_LOCALES } from './date-picker.constants';
|
|
@@ -66,7 +66,7 @@ function DialogWideContent(_ref6) {
|
|
|
66
66
|
}, props), children, /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
|
|
67
67
|
"data-state": "open",
|
|
68
68
|
asChild: true,
|
|
69
|
-
className: cn('text-muted-foreground absolute top-3 right-3 cursor-pointer rounded-xs
|
|
69
|
+
className: cn('text-muted-foreground/70 hover:text-muted-foreground absolute top-3 right-3 cursor-pointer rounded-xs transition-opacity disabled:pointer-events-none', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-6", focusRingClassNames)
|
|
70
70
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
71
71
|
variant: "ghost-secondary",
|
|
72
72
|
size: "icon-md"
|
|
@@ -86,7 +86,7 @@ function DialogFormContent(_ref7) {
|
|
|
86
86
|
}, props), children, /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
|
|
87
87
|
"data-state": "open",
|
|
88
88
|
asChild: true,
|
|
89
|
-
className: cn('text-muted-foreground absolute top-3 right-3 cursor-pointer rounded-xs
|
|
89
|
+
className: cn('text-muted-foreground/70 hover:text-muted-foreground absolute top-3 right-3 cursor-pointer rounded-xs transition-opacity disabled:pointer-events-none', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-6", focusRingClassNames)
|
|
90
90
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
91
91
|
variant: "ghost-secondary",
|
|
92
92
|
size: "icon-md"
|
|
@@ -180,9 +180,9 @@ export function InputTags(_ref) {
|
|
|
180
180
|
onGenerateTags === null || onGenerateTags === void 0 || onGenerateTags();
|
|
181
181
|
}
|
|
182
182
|
}, generateLabel)), /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
183
|
-
className: cn('mr-1.5 ml-auto shrink-0
|
|
183
|
+
className: cn('text-muted-foreground/70 mr-1.5 ml-auto shrink-0', iconSizeInTriggerOptions[size])
|
|
184
184
|
})) : /*#__PURE__*/React.createElement(ChevronsUpDownIcon, {
|
|
185
|
-
className: cn('my-auto mr-1.5 ml-auto shrink-0
|
|
185
|
+
className: cn('text-muted-foreground/70 my-auto mr-1.5 ml-auto shrink-0', iconSizeInTriggerOptions[size])
|
|
186
186
|
})))), /*#__PURE__*/React.createElement(PopoverContent, _extends({
|
|
187
187
|
className: cn('w-[--radix-popover-trigger-width] p-0', popoverClassName)
|
|
188
188
|
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@radix-ui/react-slot": "^1.1.2",
|
|
24
24
|
"@radix-ui/react-switch": "^1.0.1",
|
|
25
25
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
26
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
26
|
+
"@scaleflex/icons-tw": "^0.0.62",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
28
|
"@types/lodash.merge": "^4.6.9",
|
|
29
29
|
"class-variance-authority": "^0.7.1",
|
|
@@ -65,6 +65,6 @@ export function Search(_ref) {
|
|
|
65
65
|
}), 'absolute top-1/2 right-2 -translate-y-1/2']))
|
|
66
66
|
}, /*#__PURE__*/React.createElement(XIcon, {
|
|
67
67
|
"data-clear-icon": true,
|
|
68
|
-
className: cn('
|
|
68
|
+
className: cn('text-muted-foreground/70 hover:text-muted-foreground shrink-0')
|
|
69
69
|
})));
|
|
70
70
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SelectIconProps } from '@scaleflex/ui-tw/select/select.types';
|
|
2
2
|
export declare const SelectIcon: (props: SelectIconProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
|
|
@@ -89,7 +89,7 @@ function SelectTrigger(_ref4) {
|
|
|
89
89
|
}, children)), /*#__PURE__*/React.createElement(SelectPrimitive.Icon, {
|
|
90
90
|
asChild: true
|
|
91
91
|
}, /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
92
|
-
className: cn('
|
|
92
|
+
className: cn('text-muted-foreground/70', size === FormSize.Lg ? 'size-5' : 'size-4.5')
|
|
93
93
|
})));
|
|
94
94
|
}
|
|
95
95
|
function SelectContent(_ref5) {
|
|
@@ -165,7 +165,7 @@ function SelectScrollUpButton(_ref9) {
|
|
|
165
165
|
"data-slot": "select-scroll-up-button",
|
|
166
166
|
className: cn('flex cursor-default items-center justify-center py-1', className)
|
|
167
167
|
}, props), /*#__PURE__*/React.createElement(ChevronUpIcon, {
|
|
168
|
-
className: "size-4"
|
|
168
|
+
className: "text-muted-foreground/70 size-4"
|
|
169
169
|
}));
|
|
170
170
|
}
|
|
171
171
|
function SelectScrollDownButton(_ref10) {
|
|
@@ -175,7 +175,7 @@ function SelectScrollDownButton(_ref10) {
|
|
|
175
175
|
"data-slot": "select-scroll-down-button",
|
|
176
176
|
className: cn('flex cursor-default items-center justify-center py-1', className)
|
|
177
177
|
}, props), /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
178
|
-
className: "size-4"
|
|
178
|
+
className: "text-muted-foreground/70 size-4"
|
|
179
179
|
}));
|
|
180
180
|
}
|
|
181
181
|
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
|
package/select/select.types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
2
2
|
import { SelectOption } from '@scaleflex/ui-tw/form';
|
|
3
3
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
4
|
-
import type { ComponentProps, ReactElement, ReactNode } from 'react';
|
|
4
|
+
import type { ComponentProps, ElementType, ReactElement, ReactNode } from 'react';
|
|
5
5
|
export interface SelectProps extends ComponentProps<typeof SelectPrimitive.Root> {
|
|
6
6
|
}
|
|
7
7
|
export interface SelectTriggerProps extends ComponentProps<typeof SelectPrimitive.Trigger> {
|
|
@@ -22,6 +22,9 @@ export interface SelectLabelProps extends ComponentProps<typeof SelectPrimitive.
|
|
|
22
22
|
}
|
|
23
23
|
export interface SelectIconProps extends ComponentProps<'span'>, Pick<SelectTriggerProps, 'size' | 'icon'> {
|
|
24
24
|
}
|
|
25
|
+
export interface SelectIconElementProps extends ComponentProps<'svg'>, Pick<SelectTriggerProps, 'size'> {
|
|
26
|
+
icon: ElementType;
|
|
27
|
+
}
|
|
25
28
|
export interface SelectorProps extends SelectProps {
|
|
26
29
|
options: SelectOption[];
|
|
27
30
|
value?: string;
|