@scaleflex/ui-tw 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/button.component.js +4 -3
- package/button/button.constants.d.ts +1 -0
- package/button/button.constants.js +1 -0
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.d.ts +3 -0
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +68 -0
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.d.ts +3 -0
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +117 -0
- package/combobox/combobox-single/combobox-single.component.d.ts +3 -0
- package/combobox/combobox-single/combobox-single.component.js +61 -0
- package/combobox/combobox.component.d.ts +4 -0
- package/combobox/combobox.component.js +137 -0
- package/combobox/combobox.constants.d.ts +15 -0
- package/combobox/combobox.constants.js +5 -0
- package/combobox/combobox.types.d.ts +65 -0
- package/combobox/combobox.types.js +1 -0
- package/combobox/combobox.utils.d.ts +7 -0
- package/combobox/combobox.utils.js +28 -0
- package/combobox/index.d.ts +5 -0
- package/combobox/index.js +5 -0
- package/command/command.component.d.ts +18 -0
- package/command/command.component.js +150 -0
- package/command/command.utils.d.ts +5 -0
- package/command/command.utils.js +3 -0
- package/command/index.d.ts +1 -0
- package/command/index.js +1 -0
- package/dialog/dialog.component.d.ts +22 -0
- package/dialog/dialog.component.js +192 -0
- package/dialog/index.d.ts +1 -0
- package/dialog/index.js +1 -0
- package/form/components/form-combobox-single-field.component.d.ts +5 -0
- package/form/components/form-combobox-single-field.component.js +57 -0
- package/form/components/form-select-field.component.d.ts +1 -1
- package/form/components/form-select-field.component.js +23 -52
- package/form/form.types.d.ts +2 -0
- package/package.json +4 -2
- package/pill/pill.types.d.ts +2 -2
- package/popover/index.d.ts +1 -0
- package/popover/index.js +1 -0
- package/popover/popover.component.d.ts +7 -0
- package/popover/popover.component.js +40 -0
- package/select/components/select-icon.js +4 -2
- package/select/components/selector.d.ts +3 -0
- package/select/components/selector.js +66 -0
- package/select/index.d.ts +1 -0
- package/select/index.js +2 -1
- package/select/select.component.d.ts +3 -0
- package/select/select.component.js +9 -8
- package/select/select.constants.d.ts +5 -3
- package/select/select.constants.js +5 -1
- package/select/select.types.d.ts +15 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
var _excluded = ["className", "align", "sideOffset"];
|
|
5
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
6
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
function Popover(_ref) {
|
|
9
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
10
|
+
return /*#__PURE__*/React.createElement(PopoverPrimitive.Root, _extends({
|
|
11
|
+
"data-slot": "popover"
|
|
12
|
+
}, props));
|
|
13
|
+
}
|
|
14
|
+
function PopoverTrigger(_ref2) {
|
|
15
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
|
|
16
|
+
return /*#__PURE__*/React.createElement(PopoverPrimitive.Trigger, _extends({
|
|
17
|
+
"data-slot": "popover-trigger"
|
|
18
|
+
}, props));
|
|
19
|
+
}
|
|
20
|
+
function PopoverContent(_ref3) {
|
|
21
|
+
var className = _ref3.className,
|
|
22
|
+
_ref3$align = _ref3.align,
|
|
23
|
+
align = _ref3$align === void 0 ? 'start' : _ref3$align,
|
|
24
|
+
_ref3$sideOffset = _ref3.sideOffset,
|
|
25
|
+
sideOffset = _ref3$sideOffset === void 0 ? 4 : _ref3$sideOffset,
|
|
26
|
+
props = _objectWithoutProperties(_ref3, _excluded);
|
|
27
|
+
return /*#__PURE__*/React.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React.createElement(PopoverPrimitive.Content, _extends({
|
|
28
|
+
"data-slot": "popover-content",
|
|
29
|
+
align: align,
|
|
30
|
+
sideOffset: sideOffset,
|
|
31
|
+
className: cn('bg-popover text-popover-foreground border-border z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-sm outline-hidden', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className)
|
|
32
|
+
}, props)));
|
|
33
|
+
}
|
|
34
|
+
function PopoverAnchor(_ref4) {
|
|
35
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
|
|
36
|
+
return /*#__PURE__*/React.createElement(PopoverPrimitive.Anchor, _extends({
|
|
37
|
+
"data-slot": "popover-anchor"
|
|
38
|
+
}, props));
|
|
39
|
+
}
|
|
40
|
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
|
@@ -3,7 +3,8 @@ import { getIconMarginRightInRem } from '@scaleflex/ui-tw/select/select.utils';
|
|
|
3
3
|
import { cloneElement, useMemo } from 'react';
|
|
4
4
|
export var SelectIcon = function SelectIcon(props) {
|
|
5
5
|
var size = props.size,
|
|
6
|
-
icon = props.icon
|
|
6
|
+
icon = props.icon,
|
|
7
|
+
className = props.className;
|
|
7
8
|
var sizeInRem = useMemo(function () {
|
|
8
9
|
return getIconSizeInRem(size);
|
|
9
10
|
}, [size]);
|
|
@@ -17,6 +18,7 @@ export var SelectIcon = function SelectIcon(props) {
|
|
|
17
18
|
width: sizeInRem,
|
|
18
19
|
height: sizeInRem,
|
|
19
20
|
marginRight: marginRight
|
|
20
|
-
}
|
|
21
|
+
},
|
|
22
|
+
className: className
|
|
21
23
|
});
|
|
22
24
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["value", "onChange", "placeholder", "disabled", "readOnly", "size", "className", "icon", "options", "showGroupSeparator", "formItemId"];
|
|
3
|
+
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from '../';
|
|
6
|
+
export function Selector(_ref) {
|
|
7
|
+
var value = _ref.value,
|
|
8
|
+
onChange = _ref.onChange,
|
|
9
|
+
_ref$placeholder = _ref.placeholder,
|
|
10
|
+
placeholder = _ref$placeholder === void 0 ? 'Select' : _ref$placeholder,
|
|
11
|
+
disabled = _ref.disabled,
|
|
12
|
+
readOnly = _ref.readOnly,
|
|
13
|
+
size = _ref.size,
|
|
14
|
+
className = _ref.className,
|
|
15
|
+
icon = _ref.icon,
|
|
16
|
+
options = _ref.options,
|
|
17
|
+
showGroupSeparator = _ref.showGroupSeparator,
|
|
18
|
+
formItemId = _ref.formItemId,
|
|
19
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
21
|
+
value: value,
|
|
22
|
+
onValueChange: readOnly ? undefined : onChange,
|
|
23
|
+
disabled: disabled || readOnly
|
|
24
|
+
}, /*#__PURE__*/React.createElement(SelectTrigger, {
|
|
25
|
+
id: formItemId,
|
|
26
|
+
"aria-invalid": rest['aria-invalid'],
|
|
27
|
+
size: size,
|
|
28
|
+
readOnly: readOnly,
|
|
29
|
+
className: className,
|
|
30
|
+
icon: icon
|
|
31
|
+
}, /*#__PURE__*/React.createElement(SelectValue, {
|
|
32
|
+
placeholder: placeholder
|
|
33
|
+
})), /*#__PURE__*/React.createElement(SelectContent, null, options.map(function (option, groupIndex) {
|
|
34
|
+
if (isOptionGroup(option)) {
|
|
35
|
+
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
36
|
+
key: groupIndex
|
|
37
|
+
}, option.label && /*#__PURE__*/React.createElement(SelectLabel, {
|
|
38
|
+
size: size
|
|
39
|
+
}, option.label), option.options.map(function (_ref2) {
|
|
40
|
+
var label = _ref2.label,
|
|
41
|
+
value = _ref2.value,
|
|
42
|
+
disabled = _ref2.disabled,
|
|
43
|
+
icon = _ref2.icon,
|
|
44
|
+
tooltip = _ref2.tooltip;
|
|
45
|
+
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
46
|
+
key: value,
|
|
47
|
+
value: value,
|
|
48
|
+
disabled: disabled,
|
|
49
|
+
size: size,
|
|
50
|
+
icon: icon,
|
|
51
|
+
tooltip: tooltip,
|
|
52
|
+
isGroup: !!option.label
|
|
53
|
+
}, label);
|
|
54
|
+
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
57
|
+
key: "default"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(SelectItem, {
|
|
59
|
+
value: option.value,
|
|
60
|
+
disabled: option.disabled,
|
|
61
|
+
size: size,
|
|
62
|
+
icon: option.icon,
|
|
63
|
+
tooltip: option.tooltip
|
|
64
|
+
}, option.label));
|
|
65
|
+
})));
|
|
66
|
+
}
|
package/select/index.d.ts
CHANGED
package/select/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { Select, SelectGroup, SelectItem, SelectLabel, SelectContent, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectValue, SelectTrigger } from './select.component';
|
|
1
|
+
export { Select, SelectGroup, SelectItem, SelectLabel, SelectContent, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectValue, SelectTrigger } from './select.component';
|
|
2
|
+
export { Selector } from './components/selector';
|
|
@@ -4,6 +4,9 @@ import React, { ComponentProps } from 'react';
|
|
|
4
4
|
declare function Select({ ...props }: ComponentProps<typeof SelectPrimitive.Root>): React.JSX.Element;
|
|
5
5
|
declare function SelectGroup({ ...props }: ComponentProps<typeof SelectPrimitive.Group>): React.JSX.Element;
|
|
6
6
|
declare function SelectValue({ ...props }: ComponentProps<typeof SelectPrimitive.Value>): React.JSX.Element;
|
|
7
|
+
export declare const selectTriggerVariants: (props?: ({
|
|
8
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
10
|
declare function SelectTrigger({ className, size, children, readOnly, icon, ...props }: SelectTriggerProps): React.JSX.Element;
|
|
8
11
|
declare function SelectContent({ className, children, position, ...props }: ComponentProps<typeof SelectPrimitive.Content>): React.JSX.Element;
|
|
9
12
|
declare function SelectLabel({ className, size, ...props }: SelectLabelProps): React.JSX.Element;
|
|
@@ -13,7 +13,6 @@ import * as SelectPrimitive from '@radix-ui/react-select';
|
|
|
13
13
|
import { inputSizeOptions } from '@scaleflex/ui-tw/input/input.constants';
|
|
14
14
|
import { LabelIcon } from '@scaleflex/ui-tw/label/components/label-icon';
|
|
15
15
|
import { SelectIcon } from '@scaleflex/ui-tw/select/components/select-icon';
|
|
16
|
-
import { selectLabelSizeOptions } from '@scaleflex/ui-tw/select/select.constants';
|
|
17
16
|
import { getOptionInGroupPaddingLeft } from '@scaleflex/ui-tw/select/select.utils';
|
|
18
17
|
import { getBaseInputClasses } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
19
18
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
@@ -21,6 +20,7 @@ import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
|
21
20
|
import { cva } from 'class-variance-authority';
|
|
22
21
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
23
22
|
import React from 'react';
|
|
23
|
+
import { getBaseSelectClassNames, selectLabelSizeOptions, selectReadOnlyClassNames } from './select.constants';
|
|
24
24
|
function Select(_ref) {
|
|
25
25
|
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
26
26
|
return /*#__PURE__*/React.createElement(SelectPrimitive.Root, _extends({
|
|
@@ -39,7 +39,7 @@ function SelectValue(_ref3) {
|
|
|
39
39
|
"data-slot": "select-value"
|
|
40
40
|
}, props));
|
|
41
41
|
}
|
|
42
|
-
var selectTriggerVariants = cva('', {
|
|
42
|
+
export var selectTriggerVariants = cva('', {
|
|
43
43
|
variants: {
|
|
44
44
|
size: inputSizeOptions
|
|
45
45
|
},
|
|
@@ -67,10 +67,10 @@ function SelectTrigger(_ref4) {
|
|
|
67
67
|
return /*#__PURE__*/React.createElement(SelectPrimitive.Trigger, _extends({
|
|
68
68
|
"data-slot": "select-trigger",
|
|
69
69
|
"data-size": size,
|
|
70
|
-
className: cn.apply(void 0,
|
|
70
|
+
className: cn.apply(void 0, _toConsumableArray(getBaseSelectClassNames()).concat(_toConsumableArray(getBaseInputClasses()), ['data-[placeholder]:text-muted-foreground/80 hover:border-secondary-foreground/50', selectTriggerVariants({
|
|
71
71
|
size: size,
|
|
72
72
|
className: className
|
|
73
|
-
}), readOnly &&
|
|
73
|
+
}), readOnly && selectReadOnlyClassNames, className]))
|
|
74
74
|
}, props), /*#__PURE__*/React.createElement("div", {
|
|
75
75
|
className: "flex items-center"
|
|
76
76
|
}, icon && /*#__PURE__*/React.createElement(SelectIcon, {
|
|
@@ -90,7 +90,7 @@ function SelectContent(_ref5) {
|
|
|
90
90
|
props = _objectWithoutProperties(_ref5, _excluded2);
|
|
91
91
|
return /*#__PURE__*/React.createElement(SelectPrimitive.Portal, null, /*#__PURE__*/React.createElement(SelectPrimitive.Content, _extends({
|
|
92
92
|
"data-slot": "select-content",
|
|
93
|
-
className: cn('bg-popover text-popover-foreground relative z-50 max-h-(--max-select-content-available-height)
|
|
93
|
+
className: cn('border-border bg-popover text-popover-foreground relative z-50 min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-md border shadow-md', 'max-h-(--max-select-content-available-height) origin-(--radix-select-content-transform-origin)', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', position === 'popper' && 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className),
|
|
94
94
|
position: position
|
|
95
95
|
}, props), /*#__PURE__*/React.createElement(SelectScrollUpButton, null), /*#__PURE__*/React.createElement(SelectPrimitive.Viewport, {
|
|
96
96
|
className: cn(position === 'popper' && 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1')
|
|
@@ -102,7 +102,7 @@ function SelectLabel(_ref6) {
|
|
|
102
102
|
props = _objectWithoutProperties(_ref6, _excluded3);
|
|
103
103
|
return /*#__PURE__*/React.createElement(SelectPrimitive.Label, _extends({
|
|
104
104
|
"data-slot": "select-label",
|
|
105
|
-
className: cn('text-secondary-foreground
|
|
105
|
+
className: cn('text-secondary-foreground', selectLabelVariants({
|
|
106
106
|
size: size
|
|
107
107
|
}), className)
|
|
108
108
|
}, props));
|
|
@@ -117,7 +117,7 @@ function SelectItem(_ref7) {
|
|
|
117
117
|
props = _objectWithoutProperties(_ref7, _excluded4);
|
|
118
118
|
return /*#__PURE__*/React.createElement(SelectPrimitive.Item, _extends({
|
|
119
119
|
"data-slot": "select-item",
|
|
120
|
-
className: cn('relative flex w-full cursor-pointer items-center gap-2
|
|
120
|
+
className: cn('relative flex w-full cursor-pointer items-center gap-2 outline-hidden select-none', 'focus:bg-accent focus:text-accent-foreground', '*:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2', 'data-[state=checked]:text-accent-foreground', 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", selectTriggerVariants({
|
|
121
121
|
size: size
|
|
122
122
|
}), isGroup && getOptionInGroupPaddingLeft(size), className)
|
|
123
123
|
}, props), /*#__PURE__*/React.createElement("span", {
|
|
@@ -128,7 +128,8 @@ function SelectItem(_ref7) {
|
|
|
128
128
|
className: "flex items-center"
|
|
129
129
|
}, icon && /*#__PURE__*/React.createElement(SelectIcon, {
|
|
130
130
|
size: size,
|
|
131
|
-
icon: icon
|
|
131
|
+
icon: icon,
|
|
132
|
+
className: "text-muted-foreground data-[state=checked]:text-primary"
|
|
132
133
|
}), /*#__PURE__*/React.createElement(SelectPrimitive.ItemText, null, children), tooltip && /*#__PURE__*/React.createElement(LabelIcon, {
|
|
133
134
|
size: size,
|
|
134
135
|
tooltip: tooltip
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const selectLabelSizeOptions: {
|
|
2
|
-
readonly sm: "py-2 px-3 h-8 text-
|
|
3
|
-
readonly md: "py-3 px-4 h-10 text-
|
|
4
|
-
readonly lg: "py-3 px-4 h-12 text-
|
|
2
|
+
readonly sm: "py-2 px-3 h-8 text-xs";
|
|
3
|
+
readonly md: "py-3 px-4 h-10 text-sm ";
|
|
4
|
+
readonly lg: "py-3 px-4 h-12 text-base ";
|
|
5
5
|
};
|
|
6
|
+
export declare const selectReadOnlyClassNames = "bg-secondary text-foreground pointer-events-none cursor-default disabled:opacity-100";
|
|
7
|
+
export declare const getBaseSelectClassNames: () => string[];
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
-
export var selectLabelSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'py-2 px-3 h-8 text-
|
|
3
|
+
export var selectLabelSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'py-2 px-3 h-8 text-xs'), FormSize.Md, 'py-3 px-4 h-10 text-sm '), FormSize.Lg, 'py-3 px-4 h-12 text-base ');
|
|
4
|
+
export var selectReadOnlyClassNames = 'bg-secondary text-foreground pointer-events-none cursor-default disabled:opacity-100';
|
|
5
|
+
export var getBaseSelectClassNames = function getBaseSelectClassNames() {
|
|
6
|
+
return ['flex w-full cursor-pointer items-center justify-between gap-2 whitespace-nowrap', "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"];
|
|
7
|
+
};
|
package/select/select.types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
2
|
+
import { SelectOption } from '@scaleflex/ui-tw/form';
|
|
2
3
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
4
|
import { ComponentProps, ReactElement } from 'react';
|
|
4
5
|
export interface SelectProps extends ComponentProps<typeof SelectPrimitive.Root> {
|
|
@@ -20,3 +21,17 @@ export interface SelectLabelProps extends ComponentProps<typeof SelectPrimitive.
|
|
|
20
21
|
}
|
|
21
22
|
export interface SelectIconProps extends ComponentProps<'span'>, Pick<SelectTriggerProps, 'size' | 'icon'> {
|
|
22
23
|
}
|
|
24
|
+
export interface SelectorProps {
|
|
25
|
+
value?: string;
|
|
26
|
+
onChange?: (value: string) => void;
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
size?: FormSizeType;
|
|
31
|
+
className?: string;
|
|
32
|
+
icon?: ReactElement;
|
|
33
|
+
options: SelectOption[];
|
|
34
|
+
showGroupSeparator?: boolean;
|
|
35
|
+
formItemId?: string;
|
|
36
|
+
'aria-invalid'?: boolean;
|
|
37
|
+
}
|