@scaleflex/ui-tw 0.0.53 → 0.0.54
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/form/form.types.d.ts
CHANGED
|
@@ -63,8 +63,9 @@ export interface FlatOption {
|
|
|
63
63
|
tooltip?: ReactElement | string;
|
|
64
64
|
disabledTooltip?: ReactElement | string;
|
|
65
65
|
}
|
|
66
|
-
export interface OptionGroup {
|
|
66
|
+
export interface OptionGroup extends Omit<FlatOption, 'value' | 'label'> {
|
|
67
67
|
label?: ReactElement | string;
|
|
68
|
+
value?: string;
|
|
68
69
|
options: FlatOption[];
|
|
69
70
|
}
|
|
70
71
|
export type SelectOption = FlatOption | OptionGroup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
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.54",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
28
|
"@types/lodash.merge": "^4.6.9",
|
|
29
29
|
"class-variance-authority": "^0.7.1",
|
|
@@ -5,8 +5,20 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
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
7
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
8
|
+
import { selectLabelSizeOptions } from '@scaleflex/ui-tw/select/select.constants';
|
|
9
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
10
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
8
12
|
import React from 'react';
|
|
9
13
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from '../';
|
|
14
|
+
var selectLabelVariants = cva('', {
|
|
15
|
+
variants: {
|
|
16
|
+
size: selectLabelSizeOptions
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: FormSize.Md
|
|
20
|
+
}
|
|
21
|
+
});
|
|
10
22
|
export function Selector(_ref) {
|
|
11
23
|
var value = _ref.value,
|
|
12
24
|
onChange = _ref.onChange,
|
|
@@ -32,6 +44,7 @@ export function Selector(_ref) {
|
|
|
32
44
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
45
|
var option = _step.value;
|
|
34
46
|
if (isOptionGroup(option)) {
|
|
47
|
+
if (option.value === val) return option.label;
|
|
35
48
|
var found = option.options.find(function (o) {
|
|
36
49
|
return o.value === val;
|
|
37
50
|
});
|
|
@@ -68,7 +81,19 @@ export function Selector(_ref) {
|
|
|
68
81
|
if (isOptionGroup(option)) {
|
|
69
82
|
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
70
83
|
key: groupIndex
|
|
71
|
-
}, option.
|
|
84
|
+
}, option.value ? /*#__PURE__*/React.createElement(SelectItem, {
|
|
85
|
+
key: option.value,
|
|
86
|
+
value: option.value,
|
|
87
|
+
disabled: option.disabled,
|
|
88
|
+
size: size,
|
|
89
|
+
icon: option.icon,
|
|
90
|
+
tooltip: option.tooltip,
|
|
91
|
+
disabledTooltip: option.disabledTooltip,
|
|
92
|
+
isGroup: true,
|
|
93
|
+
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
94
|
+
size: size
|
|
95
|
+
}))
|
|
96
|
+
}, option.label) : option.label && /*#__PURE__*/React.createElement(SelectLabel, {
|
|
72
97
|
size: size
|
|
73
98
|
}, option.label), option.options.map(function (_ref2) {
|
|
74
99
|
var label = _ref2.label,
|