@scaleflex/ui-tw 0.0.54 → 0.0.57
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/combobox/combobox-multi-inline/combobox-multi-inline.component.d.ts +1 -1
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +69 -13
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.d.ts +1 -1
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +7 -2
- package/combobox/combobox-single/combobox-single.component.d.ts +1 -1
- package/combobox/combobox-single/combobox-single.component.js +33 -7
- package/combobox/combobox.component.d.ts +3 -2
- package/combobox/combobox.component.js +92 -43
- package/combobox/combobox.types.d.ts +8 -0
- package/package.json +2 -2
- package/select/components/selector.d.ts +1 -1
- package/select/components/selector.js +5 -1
- package/select/select.types.d.ts +2 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ComboboxMultiInlineProps } from '../combobox.types';
|
|
3
|
-
export declare function ComboboxMultiInline({ options, value, onChange, placeholder, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, formItemId, searchPlaceholder, ...rest }: ComboboxMultiInlineProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiInline({ options, value, onChange, placeholder, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, formItemId, searchPlaceholder, actions, fixedActions, ...rest }: ComboboxMultiInlineProps): React.JSX.Element;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps", "formItemId", "searchPlaceholder"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps", "formItemId", "searchPlaceholder", "actions", "fixedActions"];
|
|
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 { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
5
9
|
import { Popover } from '@scaleflex/ui-tw/popover';
|
|
6
10
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
11
|
import React from 'react';
|
|
8
12
|
import { useMemo, useState } from 'react';
|
|
9
|
-
import { ComboboxContent, ComboboxTrigger
|
|
13
|
+
import { ComboboxContent, ComboboxTrigger } from '../';
|
|
10
14
|
export function ComboboxMultiInline(_ref) {
|
|
11
15
|
var _ref$options = _ref.options,
|
|
12
16
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
@@ -32,27 +36,77 @@ export function ComboboxMultiInline(_ref) {
|
|
|
32
36
|
popoverContentProps = _ref.popoverContentProps,
|
|
33
37
|
formItemId = _ref.formItemId,
|
|
34
38
|
searchPlaceholder = _ref.searchPlaceholder,
|
|
39
|
+
actions = _ref.actions,
|
|
40
|
+
fixedActions = _ref.fixedActions,
|
|
35
41
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
42
|
var _useState = useState(defaultOpen),
|
|
37
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
38
44
|
open = _useState2[0],
|
|
39
45
|
setOpen = _useState2[1];
|
|
40
46
|
var selectedLabels = useMemo(function () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
var labels = [];
|
|
48
|
+
var _iterator = _createForOfIteratorHelper(options),
|
|
49
|
+
_step;
|
|
50
|
+
try {
|
|
51
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
52
|
+
var option = _step.value;
|
|
53
|
+
if (isOptionGroup(option)) {
|
|
54
|
+
if (option.value && value.includes(option.value)) {
|
|
55
|
+
labels.push(option.label);
|
|
56
|
+
}
|
|
57
|
+
var _iterator2 = _createForOfIteratorHelper(option.options),
|
|
58
|
+
_step2;
|
|
59
|
+
try {
|
|
60
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
61
|
+
var sub = _step2.value;
|
|
62
|
+
if (value.includes(sub.value)) {
|
|
63
|
+
labels.push(sub.label);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
_iterator2.e(err);
|
|
68
|
+
} finally {
|
|
69
|
+
_iterator2.f();
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (value.includes(option.value)) {
|
|
73
|
+
labels.push(option.label);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
_iterator.e(err);
|
|
79
|
+
} finally {
|
|
80
|
+
_iterator.f();
|
|
81
|
+
}
|
|
82
|
+
return labels;
|
|
46
83
|
}, [options, value]);
|
|
47
84
|
var displayValue = selectedLabels.length > 0 ? selectedLabels.join(', ') : placeholder;
|
|
48
85
|
var toggleValue = function toggleValue(v) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
86
|
+
var group = options.find(function (opt) {
|
|
87
|
+
return isOptionGroup(opt) && opt.value === v;
|
|
88
|
+
});
|
|
89
|
+
var nextValue;
|
|
90
|
+
if (group && isOptionGroup(group)) {
|
|
91
|
+
var childValues = group.options.map(function (child) {
|
|
92
|
+
return child.value;
|
|
93
|
+
});
|
|
94
|
+
var isGroupSelected = value.includes(group.value);
|
|
95
|
+
if (isGroupSelected) {
|
|
96
|
+
nextValue = value.filter(function (val) {
|
|
97
|
+
return val !== group.value;
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
nextValue = [].concat(_toConsumableArray(value.filter(function (val) {
|
|
101
|
+
return !childValues.includes(val);
|
|
102
|
+
})), [group.value]);
|
|
103
|
+
}
|
|
53
104
|
} else {
|
|
54
|
-
|
|
105
|
+
nextValue = value.includes(v) ? value.filter(function (val) {
|
|
106
|
+
return val !== v;
|
|
107
|
+
}) : [].concat(_toConsumableArray(value), [v]);
|
|
55
108
|
}
|
|
109
|
+
onChange(nextValue);
|
|
56
110
|
};
|
|
57
111
|
var onOpenChange = function onOpenChange(isOpen) {
|
|
58
112
|
if (!isOpen) {
|
|
@@ -89,6 +143,8 @@ export function ComboboxMultiInline(_ref) {
|
|
|
89
143
|
onSelect: toggleValue,
|
|
90
144
|
size: size,
|
|
91
145
|
multiple: true,
|
|
92
|
-
popoverContentProps: popoverContentProps
|
|
146
|
+
popoverContentProps: popoverContentProps,
|
|
147
|
+
actions: actions,
|
|
148
|
+
fixedActions: fixedActions
|
|
93
149
|
}));
|
|
94
150
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ComboboxMultiTagProps } from '../combobox.types';
|
|
3
|
-
export declare function ComboboxMultiTag({ options, value, onChange, placeholder, className, disabled, size, readOnly, popoverClassName, onBlur, showGroupSeparator, defaultOpen, searchPlaceholder, popoverContentProps, ...rest }: ComboboxMultiTagProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiTag({ options, value, onChange, placeholder, className, disabled, size, readOnly, popoverClassName, onBlur, showGroupSeparator, defaultOpen, searchPlaceholder, popoverContentProps, actions, fixedActions, ...rest }: ComboboxMultiTagProps): React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "searchPlaceholder", "popoverContentProps"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "popoverClassName", "onBlur", "showGroupSeparator", "defaultOpen", "searchPlaceholder", "popoverContentProps", "actions", "fixedActions"];
|
|
5
5
|
import { ButtonVariant, buttonVariants } from '@scaleflex/ui-tw/button';
|
|
6
6
|
import { buttonBaseClassNames } from '@scaleflex/ui-tw/button/button.constants';
|
|
7
7
|
import { createClearHandlers } from '@scaleflex/ui-tw/combobox/combobox.utils';
|
|
@@ -38,6 +38,8 @@ export function ComboboxMultiTag(_ref) {
|
|
|
38
38
|
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
39
39
|
searchPlaceholder = _ref.searchPlaceholder,
|
|
40
40
|
popoverContentProps = _ref.popoverContentProps,
|
|
41
|
+
actions = _ref.actions,
|
|
42
|
+
fixedActions = _ref.fixedActions,
|
|
41
43
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
42
44
|
var _getToolbarSizes = getToolbarSizes(size),
|
|
43
45
|
buttonSize = _getToolbarSizes.buttonSize;
|
|
@@ -133,9 +135,12 @@ export function ComboboxMultiTag(_ref) {
|
|
|
133
135
|
onSelect: toggleValue,
|
|
134
136
|
size: size,
|
|
135
137
|
multiple: true,
|
|
138
|
+
noGroupSelection: true,
|
|
136
139
|
className: popoverClassName,
|
|
137
140
|
searchPlaceholder: searchPlaceholder,
|
|
138
141
|
showGroupSeparator: showGroupSeparator,
|
|
139
|
-
popoverContentProps: popoverContentProps
|
|
142
|
+
popoverContentProps: popoverContentProps,
|
|
143
|
+
actions: actions,
|
|
144
|
+
fixedActions: fixedActions
|
|
140
145
|
}));
|
|
141
146
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ComboboxSingleProps } from '../combobox.types';
|
|
3
|
-
export declare function ComboboxSingle({ options, value, onChange, placeholder, className, disabled, popoverClassName, size, readOnly, showClear, formItemId, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, searchPlaceholder, ...rest }: ComboboxSingleProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxSingle({ options, value, onChange, placeholder, className, disabled, popoverClassName, size, readOnly, showClear, formItemId, onBlur, showGroupSeparator, defaultOpen, popoverContentProps, searchPlaceholder, actions, fixedActions, ...rest }: ComboboxSingleProps): React.JSX.Element;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "popoverClassName", "size", "readOnly", "showClear", "formItemId", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps", "searchPlaceholder"];
|
|
3
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "popoverClassName", "size", "readOnly", "showClear", "formItemId", "onBlur", "showGroupSeparator", "defaultOpen", "popoverContentProps", "searchPlaceholder", "actions", "fixedActions"];
|
|
4
|
+
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; } } }; }
|
|
5
|
+
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; } }
|
|
6
|
+
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; }
|
|
7
|
+
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
4
8
|
import { Popover } from '@scaleflex/ui-tw/popover';
|
|
5
9
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
6
10
|
import * as React from 'react';
|
|
7
11
|
import { useState } from 'react';
|
|
8
12
|
import { ComboboxContent, ComboboxTrigger } from '../combobox.component';
|
|
9
|
-
import { flattenOptions } from '../combobox.utils';
|
|
10
13
|
export function ComboboxSingle(_ref) {
|
|
11
|
-
var _flattenOptions$find;
|
|
12
14
|
var _ref$options = _ref.options,
|
|
13
15
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
14
16
|
value = _ref.value,
|
|
@@ -33,14 +35,36 @@ export function ComboboxSingle(_ref) {
|
|
|
33
35
|
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
34
36
|
popoverContentProps = _ref.popoverContentProps,
|
|
35
37
|
searchPlaceholder = _ref.searchPlaceholder,
|
|
38
|
+
actions = _ref.actions,
|
|
39
|
+
fixedActions = _ref.fixedActions,
|
|
36
40
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
37
41
|
var _useState = useState(defaultOpen),
|
|
38
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
43
|
open = _useState2[0],
|
|
40
44
|
setOpen = _useState2[1];
|
|
41
|
-
var selectedLabel =
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
var selectedLabel = function () {
|
|
46
|
+
var _iterator = _createForOfIteratorHelper(options),
|
|
47
|
+
_step;
|
|
48
|
+
try {
|
|
49
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
50
|
+
var option = _step.value;
|
|
51
|
+
if (isOptionGroup(option)) {
|
|
52
|
+
if (option.value === value) return option.label;
|
|
53
|
+
var found = option.options.find(function (o) {
|
|
54
|
+
return o.value === value;
|
|
55
|
+
});
|
|
56
|
+
if (found) return found.label;
|
|
57
|
+
} else if (option.value === value) {
|
|
58
|
+
return option.label;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
_iterator.e(err);
|
|
63
|
+
} finally {
|
|
64
|
+
_iterator.f();
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
}();
|
|
44
68
|
var onSelect = function onSelect(currentValue) {
|
|
45
69
|
onChange(currentValue === value ? '' : currentValue);
|
|
46
70
|
onBlur === null || onBlur === void 0 || onBlur(currentValue === value ? '' : currentValue);
|
|
@@ -80,6 +104,8 @@ export function ComboboxSingle(_ref) {
|
|
|
80
104
|
onSelect: onSelect,
|
|
81
105
|
size: size,
|
|
82
106
|
showGroupSeparator: showGroupSeparator,
|
|
83
|
-
popoverContentProps: popoverContentProps
|
|
107
|
+
popoverContentProps: popoverContentProps,
|
|
108
|
+
actions: actions,
|
|
109
|
+
fixedActions: fixedActions
|
|
84
110
|
}));
|
|
85
111
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ComboboxContentProps, ComboboxTriggerProps } from './combobox.types';
|
|
2
|
+
import type { ComboboxContentProps, ComboboxTriggerProps, SelectActionsProps } from './combobox.types';
|
|
3
|
+
export declare function SelectActions({ actions }: SelectActionsProps): React.JSX.Element | null;
|
|
3
4
|
export declare function ComboboxTrigger({ children, open, disabled, readOnly, size, className, selected, showClear, onClearAll, formItemId, ...rest }: ComboboxTriggerProps): React.JSX.Element;
|
|
4
|
-
export declare function ComboboxContent({ options, value: selectedValue, onSelect, size, multiple, className, showGroupSeparator, popoverContentProps, searchPlaceholder, }: ComboboxContentProps): React.JSX.Element;
|
|
5
|
+
export declare function ComboboxContent({ options, value: selectedValue, onSelect, size, multiple, className, showGroupSeparator, popoverContentProps, searchPlaceholder, noGroupSelection, actions, fixedActions, }: ComboboxContentProps): React.JSX.Element;
|
|
@@ -8,33 +8,54 @@ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Command
|
|
|
8
8
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
9
9
|
import { PopoverContent, PopoverTrigger } from '@scaleflex/ui-tw/popover';
|
|
10
10
|
import { SelectSeparator, selectTriggerVariants } from '@scaleflex/ui-tw/select/select.component';
|
|
11
|
-
import { getBaseSelectClassNames, selectReadOnlyClassNames } from '@scaleflex/ui-tw/select/select.constants';
|
|
11
|
+
import { getBaseSelectClassNames, selectLabelSizeOptions, selectReadOnlyClassNames } from '@scaleflex/ui-tw/select/select.constants';
|
|
12
12
|
import { Separator } from '@scaleflex/ui-tw/separator';
|
|
13
13
|
import { focusRingClassNames, getBaseInputClasses } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
14
14
|
import { getToolbarSizes } from '@scaleflex/ui-tw/textarea/textarea.utils';
|
|
15
15
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
16
16
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
17
|
+
import { cva } from 'class-variance-authority';
|
|
17
18
|
import { ChevronsUpDownIcon, XIcon } from 'lucide-react';
|
|
18
19
|
import * as React from 'react';
|
|
20
|
+
import { Fragment } from 'react';
|
|
19
21
|
import { iconSizeInTriggerOptions, verticalSeparatorNextToChevronOptions } from './combobox.constants';
|
|
20
22
|
import { createClearHandlers } from './combobox.utils';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
var selectLabelVariants = cva('', {
|
|
24
|
+
variants: {
|
|
25
|
+
size: selectLabelSizeOptions
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
size: FormSize.Md
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export function SelectActions(_ref) {
|
|
32
|
+
var actions = _ref.actions;
|
|
33
|
+
if (!actions || actions.length === 0) return null;
|
|
34
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SelectSeparator, null), /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "space-y-2 px-4 py-3"
|
|
36
|
+
}, actions.map(function (action, idx) {
|
|
37
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
38
|
+
key: idx
|
|
39
|
+
}, action);
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
export function ComboboxTrigger(_ref2) {
|
|
43
|
+
var children = _ref2.children,
|
|
44
|
+
open = _ref2.open,
|
|
45
|
+
_ref2$disabled = _ref2.disabled,
|
|
46
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
47
|
+
_ref2$readOnly = _ref2.readOnly,
|
|
48
|
+
readOnly = _ref2$readOnly === void 0 ? false : _ref2$readOnly,
|
|
49
|
+
_ref2$size = _ref2.size,
|
|
50
|
+
size = _ref2$size === void 0 ? FormSize.Md : _ref2$size,
|
|
51
|
+
className = _ref2.className,
|
|
52
|
+
_ref2$selected = _ref2.selected,
|
|
53
|
+
selected = _ref2$selected === void 0 ? false : _ref2$selected,
|
|
54
|
+
_ref2$showClear = _ref2.showClear,
|
|
55
|
+
showClear = _ref2$showClear === void 0 ? false : _ref2$showClear,
|
|
56
|
+
onClearAll = _ref2.onClearAll,
|
|
57
|
+
formItemId = _ref2.formItemId,
|
|
58
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
38
59
|
var _getToolbarSizes = getToolbarSizes(size),
|
|
39
60
|
iconSize = _getToolbarSizes.iconSize;
|
|
40
61
|
var _createClearHandlers = createClearHandlers(onClearAll),
|
|
@@ -77,20 +98,25 @@ export function ComboboxTrigger(_ref) {
|
|
|
77
98
|
className: cn('ml-1 shrink-0 opacity-50', iconSizeInTriggerOptions[size])
|
|
78
99
|
}))));
|
|
79
100
|
}
|
|
80
|
-
export function ComboboxContent(
|
|
81
|
-
var options =
|
|
82
|
-
selectedValue =
|
|
83
|
-
_onSelect =
|
|
84
|
-
|
|
85
|
-
size =
|
|
86
|
-
|
|
87
|
-
multiple =
|
|
88
|
-
className =
|
|
89
|
-
|
|
90
|
-
showGroupSeparator =
|
|
91
|
-
popoverContentProps =
|
|
92
|
-
|
|
93
|
-
searchPlaceholder =
|
|
101
|
+
export function ComboboxContent(_ref3) {
|
|
102
|
+
var options = _ref3.options,
|
|
103
|
+
selectedValue = _ref3.value,
|
|
104
|
+
_onSelect = _ref3.onSelect,
|
|
105
|
+
_ref3$size = _ref3.size,
|
|
106
|
+
size = _ref3$size === void 0 ? 'md' : _ref3$size,
|
|
107
|
+
_ref3$multiple = _ref3.multiple,
|
|
108
|
+
multiple = _ref3$multiple === void 0 ? false : _ref3$multiple,
|
|
109
|
+
className = _ref3.className,
|
|
110
|
+
_ref3$showGroupSepara = _ref3.showGroupSeparator,
|
|
111
|
+
showGroupSeparator = _ref3$showGroupSepara === void 0 ? false : _ref3$showGroupSepara,
|
|
112
|
+
popoverContentProps = _ref3.popoverContentProps,
|
|
113
|
+
_ref3$searchPlacehold = _ref3.searchPlaceholder,
|
|
114
|
+
searchPlaceholder = _ref3$searchPlacehold === void 0 ? 'Search...' : _ref3$searchPlacehold,
|
|
115
|
+
_ref3$noGroupSelectio = _ref3.noGroupSelection,
|
|
116
|
+
noGroupSelection = _ref3$noGroupSelectio === void 0 ? false : _ref3$noGroupSelectio,
|
|
117
|
+
actions = _ref3.actions,
|
|
118
|
+
_ref3$fixedActions = _ref3.fixedActions,
|
|
119
|
+
fixedActions = _ref3$fixedActions === void 0 ? false : _ref3$fixedActions;
|
|
94
120
|
return /*#__PURE__*/React.createElement(PopoverContent, _extends({
|
|
95
121
|
className: cn('p-0', className)
|
|
96
122
|
}, popoverContentProps), /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
|
|
@@ -101,20 +127,38 @@ export function ComboboxContent(_ref2) {
|
|
|
101
127
|
if (isOptionGroup(option)) {
|
|
102
128
|
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
103
129
|
key: groupIndex,
|
|
104
|
-
heading: option.label,
|
|
130
|
+
heading: !option.value || noGroupSelection ? option.label : undefined,
|
|
105
131
|
size: size
|
|
106
|
-
}, option.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
132
|
+
}, !noGroupSelection && option.value && /*#__PURE__*/React.createElement(CommandItem, {
|
|
133
|
+
size: size,
|
|
134
|
+
multiple: multiple,
|
|
135
|
+
disabled: option.disabled,
|
|
136
|
+
key: option.value,
|
|
137
|
+
icon: option.icon,
|
|
138
|
+
value: option.value,
|
|
139
|
+
tooltip: option.tooltip,
|
|
140
|
+
disabledTooltip: option.disabledTooltip,
|
|
141
|
+
isGroup: true,
|
|
142
|
+
selectedValue: selectedValue,
|
|
143
|
+
onSelect: function onSelect() {
|
|
144
|
+
return _onSelect(option.value);
|
|
145
|
+
},
|
|
146
|
+
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
147
|
+
size: size
|
|
148
|
+
}))
|
|
149
|
+
}, option.label), option.options.map(function (_ref4) {
|
|
150
|
+
var label = _ref4.label,
|
|
151
|
+
optionLabel = _ref4.optionLabel,
|
|
152
|
+
value = _ref4.value,
|
|
153
|
+
disabled = _ref4.disabled,
|
|
154
|
+
icon = _ref4.icon,
|
|
155
|
+
tooltip = _ref4.tooltip,
|
|
156
|
+
disabledTooltip = _ref4.disabledTooltip;
|
|
157
|
+
var isGroupSelected = !noGroupSelection && multiple && option.value && Array.isArray(selectedValue) && selectedValue.includes(option.value);
|
|
114
158
|
return /*#__PURE__*/React.createElement(CommandItem, {
|
|
115
159
|
size: size,
|
|
116
160
|
multiple: multiple,
|
|
117
|
-
disabled: disabled,
|
|
161
|
+
disabled: disabled || !!isGroupSelected,
|
|
118
162
|
key: value,
|
|
119
163
|
icon: icon,
|
|
120
164
|
value: value,
|
|
@@ -138,10 +182,15 @@ export function ComboboxContent(_ref2) {
|
|
|
138
182
|
icon: option.icon,
|
|
139
183
|
value: option.value,
|
|
140
184
|
tooltip: option.tooltip,
|
|
185
|
+
disabledTooltip: option.disabledTooltip,
|
|
141
186
|
selectedValue: selectedValue,
|
|
142
187
|
onSelect: function onSelect() {
|
|
143
188
|
return _onSelect(option.value);
|
|
144
189
|
}
|
|
145
190
|
}, (_option$optionLabel = option.optionLabel) !== null && _option$optionLabel !== void 0 ? _option$optionLabel : option.label));
|
|
146
|
-
})
|
|
191
|
+
}), !fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
192
|
+
actions: actions
|
|
193
|
+
})), fixedActions && /*#__PURE__*/React.createElement(SelectActions, {
|
|
194
|
+
actions: actions
|
|
195
|
+
})));
|
|
147
196
|
}
|
|
@@ -4,6 +4,9 @@ import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
|
4
4
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
5
5
|
import type { ComponentProps, KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
6
6
|
export type ClearEvent = MouseEvent | KeyboardEvent;
|
|
7
|
+
export type SelectActionsProps = {
|
|
8
|
+
actions?: ReactNode[];
|
|
9
|
+
};
|
|
7
10
|
export type ComboboxTriggerProps = {
|
|
8
11
|
children: ReactNode;
|
|
9
12
|
open: boolean;
|
|
@@ -29,6 +32,9 @@ export type ComboboxContentProps = {
|
|
|
29
32
|
showGroupSeparator?: boolean;
|
|
30
33
|
searchPlaceholder?: string;
|
|
31
34
|
popoverContentProps?: ComponentProps<typeof PopoverPrimitive.Content>;
|
|
35
|
+
noGroupSelection?: boolean;
|
|
36
|
+
actions?: ReactNode[];
|
|
37
|
+
fixedActions?: boolean;
|
|
32
38
|
};
|
|
33
39
|
export interface CommandInputProps extends Omit<ComponentProps<typeof CommandPrimitive.Input>, 'size'> {
|
|
34
40
|
size?: FormSizeType;
|
|
@@ -60,6 +66,8 @@ interface ComboboxCommonProps {
|
|
|
60
66
|
showGroupSeparator?: boolean;
|
|
61
67
|
searchPlaceholder?: string;
|
|
62
68
|
popoverContentProps?: ComponentProps<typeof PopoverPrimitive.Content>;
|
|
69
|
+
actions?: ReactNode[];
|
|
70
|
+
fixedActions?: boolean;
|
|
63
71
|
}
|
|
64
72
|
export interface ComboboxSingleProps extends ComboboxCommonProps {
|
|
65
73
|
value: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
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.57",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
28
|
"@types/lodash.merge": "^4.6.9",
|
|
29
29
|
"class-variance-authority": "^0.7.1",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SelectorProps } from '../select.types';
|
|
3
|
-
export declare function Selector({ value, onChange, placeholder, disabled, readOnly, size, className, icon, options, showGroupSeparator, formItemId, popoverClassName, selectorContentProps, defaultOpen, triggerProps, ...rest }: SelectorProps): React.JSX.Element;
|
|
3
|
+
export declare function Selector({ value, onChange, placeholder, disabled, readOnly, size, className, icon, options, showGroupSeparator, formItemId, popoverClassName, selectorContentProps, defaultOpen, triggerProps, actions, ...rest }: SelectorProps): React.JSX.Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["value", "onChange", "placeholder", "disabled", "readOnly", "size", "className", "icon", "options", "showGroupSeparator", "formItemId", "popoverClassName", "selectorContentProps", "defaultOpen", "triggerProps"];
|
|
3
|
+
var _excluded = ["value", "onChange", "placeholder", "disabled", "readOnly", "size", "className", "icon", "options", "showGroupSeparator", "formItemId", "popoverClassName", "selectorContentProps", "defaultOpen", "triggerProps", "actions"];
|
|
4
4
|
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; } } }; }
|
|
5
5
|
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; } }
|
|
6
6
|
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; }
|
|
7
|
+
import { SelectActions } from '@scaleflex/ui-tw/combobox/combobox.component';
|
|
7
8
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
8
9
|
import { selectLabelSizeOptions } from '@scaleflex/ui-tw/select/select.constants';
|
|
9
10
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
@@ -36,6 +37,7 @@ export function Selector(_ref) {
|
|
|
36
37
|
selectorContentProps = _ref.selectorContentProps,
|
|
37
38
|
defaultOpen = _ref.defaultOpen,
|
|
38
39
|
triggerProps = _ref.triggerProps,
|
|
40
|
+
actions = _ref.actions,
|
|
39
41
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
40
42
|
var getLabelByValue = function getLabelByValue(val) {
|
|
41
43
|
var _iterator = _createForOfIteratorHelper(options),
|
|
@@ -125,5 +127,7 @@ export function Selector(_ref) {
|
|
|
125
127
|
tooltip: option.tooltip,
|
|
126
128
|
disabledTooltip: option.disabledTooltip
|
|
127
129
|
}, (_option$optionLabel = option.optionLabel) !== null && _option$optionLabel !== void 0 ? _option$optionLabel : option.label));
|
|
130
|
+
}), /*#__PURE__*/React.createElement(SelectActions, {
|
|
131
|
+
actions: actions
|
|
128
132
|
})));
|
|
129
133
|
}
|
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 } from 'react';
|
|
4
|
+
import type { ComponentProps, 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> {
|
|
@@ -39,4 +39,5 @@ export interface SelectorProps extends SelectProps {
|
|
|
39
39
|
selectorContentProps?: ComponentProps<typeof SelectPrimitive.Content>;
|
|
40
40
|
'aria-invalid'?: boolean;
|
|
41
41
|
triggerProps?: Omit<ComponentProps<typeof SelectPrimitive.Trigger>, 'aria-invalid'>;
|
|
42
|
+
actions?: ReactNode[];
|
|
42
43
|
}
|