@scaleflex/ui-tw 0.0.33 → 0.0.35
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 -0
- package/checkbox/checkbox.component.js +46 -0
- package/checkbox/checkbox.constants.d.ts +10 -0
- package/checkbox/checkbox.constants.js +4 -0
- package/checkbox/checkbox.types.d.ts +6 -0
- package/checkbox/checkbox.types.js +1 -0
- package/checkbox/index.d.ts +1 -0
- package/checkbox/index.js +1 -0
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.d.ts +1 -1
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +15 -5
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.d.ts +1 -1
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +24 -11
- package/combobox/combobox-single/combobox-single.component.d.ts +1 -1
- package/combobox/combobox-single/combobox-single.component.js +21 -9
- package/combobox/combobox.types.d.ts +6 -1
- package/form/components/form-checkbox-field.component.d.ts +5 -0
- package/form/components/form-checkbox-field.component.js +55 -0
- package/form/components/form-switch-field.component.js +2 -2
- package/form/form.constants.d.ts +1 -1
- package/form/form.constants.js +1 -1
- package/form/form.types.d.ts +12 -9
- package/form/index.d.ts +1 -0
- package/form/index.js +2 -1
- package/package.json +3 -2
- package/pill/pill.utils.d.ts +1 -1
- package/select/components/selector.d.ts +1 -1
- package/select/components/selector.js +5 -2
- package/select/select.types.d.ts +1 -0
- package/styles/shared-classes.d.ts +1 -0
- package/styles/shared-classes.js +2 -1
- package/switch/switch.component.js +2 -2
- package/switch/switch.types.d.ts +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["className", "size"];
|
|
4
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
5
|
+
import { ariaInvalidClassNames, focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
6
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
8
|
+
import { cva } from 'class-variance-authority';
|
|
9
|
+
import { CheckIcon } from 'lucide-react';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { checkboxIndicatorSizeOptions, checkboxSizeOptions } from './checkbox.constants';
|
|
12
|
+
var checkboxVariants = cva('', {
|
|
13
|
+
variants: {
|
|
14
|
+
size: checkboxSizeOptions
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
size: FormSize.Md
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var checkboxIndicatorVariants = cva('', {
|
|
21
|
+
variants: {
|
|
22
|
+
size: checkboxIndicatorSizeOptions
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
size: FormSize.Md
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
function Checkbox(_ref) {
|
|
29
|
+
var className = _ref.className,
|
|
30
|
+
size = _ref.size,
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
return /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, _extends({
|
|
33
|
+
"data-slot": "checkbox",
|
|
34
|
+
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
|
+
size: size
|
|
36
|
+
}), className)
|
|
37
|
+
}, props), /*#__PURE__*/React.createElement(CheckboxPrimitive.Indicator, {
|
|
38
|
+
"data-slot": "checkbox-indicator",
|
|
39
|
+
className: "flex items-center justify-center text-current transition-none"
|
|
40
|
+
}, /*#__PURE__*/React.createElement(CheckIcon, {
|
|
41
|
+
className: cn(checkboxIndicatorVariants({
|
|
42
|
+
size: size
|
|
43
|
+
}))
|
|
44
|
+
})));
|
|
45
|
+
}
|
|
46
|
+
export { Checkbox };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const checkboxSizeOptions: {
|
|
2
|
+
readonly sm: "size-4";
|
|
3
|
+
readonly md: "size-5";
|
|
4
|
+
readonly lg: "size-7";
|
|
5
|
+
};
|
|
6
|
+
export declare const checkboxIndicatorSizeOptions: {
|
|
7
|
+
readonly sm: "size-3.5";
|
|
8
|
+
readonly md: "size-4.5";
|
|
9
|
+
readonly lg: "size-6.5";
|
|
10
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
export var checkboxSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-4'), FormSize.Md, 'size-5'), FormSize.Lg, 'size-7');
|
|
4
|
+
export var checkboxIndicatorSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-3.5'), FormSize.Md, 'size-4.5'), FormSize.Lg, 'size-6.5');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
2
|
+
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
export interface CheckboxProps extends ComponentProps<typeof CheckboxPrimitive.Root> {
|
|
5
|
+
size?: FormSizeType;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from './checkbox.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox } from './checkbox.component';
|
|
@@ -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, ...rest }: ComboboxMultiInlineProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiInline({ options, value, onChange, placeholder, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, ...rest }: ComboboxMultiInlineProps): 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", "showClear", "popoverClassName"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur"];
|
|
5
5
|
import { Popover } from '@scaleflex/ui-tw/popover';
|
|
6
6
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
7
|
import React from 'react';
|
|
@@ -24,6 +24,7 @@ export function ComboboxMultiInline(_ref) {
|
|
|
24
24
|
_ref$showClear = _ref.showClear,
|
|
25
25
|
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
26
26
|
popoverClassName = _ref.popoverClassName,
|
|
27
|
+
onBlur = _ref.onBlur,
|
|
27
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
29
|
var _useState = useState(false),
|
|
29
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -46,9 +47,20 @@ export function ComboboxMultiInline(_ref) {
|
|
|
46
47
|
onChange([].concat(_toConsumableArray(value), [v]));
|
|
47
48
|
}
|
|
48
49
|
};
|
|
50
|
+
var onOpenChange = function onOpenChange(isOpen) {
|
|
51
|
+
if (!isOpen) {
|
|
52
|
+
onBlur === null || onBlur === void 0 || onBlur(value);
|
|
53
|
+
}
|
|
54
|
+
setOpen(isOpen);
|
|
55
|
+
};
|
|
56
|
+
var onClearAll = function onClearAll() {
|
|
57
|
+
onChange([]);
|
|
58
|
+
onBlur === null || onBlur === void 0 || onBlur([]);
|
|
59
|
+
setOpen(false);
|
|
60
|
+
};
|
|
49
61
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
50
62
|
open: open,
|
|
51
|
-
onOpenChange:
|
|
63
|
+
onOpenChange: onOpenChange
|
|
52
64
|
}, /*#__PURE__*/React.createElement(ComboboxTrigger, {
|
|
53
65
|
open: open,
|
|
54
66
|
disabled: disabled,
|
|
@@ -57,9 +69,7 @@ export function ComboboxMultiInline(_ref) {
|
|
|
57
69
|
readOnly: readOnly,
|
|
58
70
|
showClear: showClear,
|
|
59
71
|
selected: selectedLabels.length > 0,
|
|
60
|
-
onClearAll:
|
|
61
|
-
return onChange([]);
|
|
62
|
-
},
|
|
72
|
+
onClearAll: onClearAll,
|
|
63
73
|
"aria-invalid": rest['aria-invalid']
|
|
64
74
|
}, displayValue), /*#__PURE__*/React.createElement(ComboboxContent, {
|
|
65
75
|
className: popoverClassName,
|
|
@@ -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, ...rest }: ComboboxMultiTagProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiTag({ options, value, onChange, placeholder, className, disabled, size, readOnly, popoverClassName, onBlur, ...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"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "popoverClassName", "onBlur"];
|
|
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';
|
|
@@ -31,6 +31,7 @@ export function ComboboxMultiTag(_ref) {
|
|
|
31
31
|
_ref$readOnly = _ref.readOnly,
|
|
32
32
|
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
33
33
|
popoverClassName = _ref.popoverClassName,
|
|
34
|
+
onBlur = _ref.onBlur,
|
|
34
35
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
35
36
|
var _getToolbarSizes = getToolbarSizes(size),
|
|
36
37
|
buttonSize = _getToolbarSizes.buttonSize;
|
|
@@ -43,16 +44,26 @@ export function ComboboxMultiTag(_ref) {
|
|
|
43
44
|
});
|
|
44
45
|
var isSelected = selectedOptions.length > 0;
|
|
45
46
|
var toggleValue = function toggleValue(v) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
48
|
+
_ref2$isTriggerOnBlur = _ref2.isTriggerOnBlur,
|
|
49
|
+
isTriggerOnBlur = _ref2$isTriggerOnBlur === void 0 ? false : _ref2$isTriggerOnBlur;
|
|
50
|
+
var nextValue = value.includes(v) ? value.filter(function (val) {
|
|
51
|
+
return val !== v;
|
|
52
|
+
}) : [].concat(_toConsumableArray(value), [v]);
|
|
53
|
+
onChange(nextValue);
|
|
54
|
+
if (isTriggerOnBlur) {
|
|
55
|
+
onBlur === null || onBlur === void 0 || onBlur(nextValue);
|
|
52
56
|
}
|
|
53
57
|
};
|
|
58
|
+
var onOpenChange = function onOpenChange(isOpen) {
|
|
59
|
+
if (!isOpen) {
|
|
60
|
+
onBlur === null || onBlur === void 0 || onBlur(value);
|
|
61
|
+
}
|
|
62
|
+
setOpen(isOpen);
|
|
63
|
+
};
|
|
54
64
|
var onClearAll = function onClearAll() {
|
|
55
65
|
onChange([]);
|
|
66
|
+
onBlur === null || onBlur === void 0 || onBlur([]);
|
|
56
67
|
setOpen(false);
|
|
57
68
|
};
|
|
58
69
|
var _createClearHandlers = createClearHandlers(onClearAll),
|
|
@@ -60,7 +71,7 @@ export function ComboboxMultiTag(_ref) {
|
|
|
60
71
|
handleOnTriggerKeyDown = _createClearHandlers.onKeyDown;
|
|
61
72
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
62
73
|
open: open,
|
|
63
|
-
onOpenChange:
|
|
74
|
+
onOpenChange: onOpenChange
|
|
64
75
|
}, /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
65
76
|
asChild: true
|
|
66
77
|
}, /*#__PURE__*/React.createElement("button", {
|
|
@@ -76,7 +87,7 @@ export function ComboboxMultiTag(_ref) {
|
|
|
76
87
|
}, !isSelected ? /*#__PURE__*/React.createElement("span", {
|
|
77
88
|
className: "text-muted-foreground"
|
|
78
89
|
}, placeholder) : /*#__PURE__*/React.createElement("div", {
|
|
79
|
-
className: cn('flex w-full flex-wrap justify-start gap-2', textareaVariants({
|
|
90
|
+
className: cn('flex w-full flex-wrap justify-start gap-2 overflow-y-auto', textareaVariants({
|
|
80
91
|
size: size
|
|
81
92
|
}), 'min-h-auto')
|
|
82
93
|
}, selectedOptions.map(function (option) {
|
|
@@ -88,11 +99,13 @@ export function ComboboxMultiTag(_ref) {
|
|
|
88
99
|
onRemove: function onRemove(event) {
|
|
89
100
|
event.preventDefault();
|
|
90
101
|
event.stopPropagation();
|
|
91
|
-
toggleValue(option.value
|
|
102
|
+
toggleValue(option.value, {
|
|
103
|
+
isTriggerOnBlur: true
|
|
104
|
+
});
|
|
92
105
|
}
|
|
93
106
|
}, option.label);
|
|
94
107
|
})), isSelected ? /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
className: "flex w-full items-center justify-between
|
|
108
|
+
className: "flex w-full items-center justify-between p-1.5"
|
|
96
109
|
}, /*#__PURE__*/React.createElement("div", {
|
|
97
110
|
role: "button",
|
|
98
111
|
tabIndex: 0,
|
|
@@ -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, ...rest }: ComboboxSingleProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxSingle({ options, value, onChange, placeholder, className, disabled, popoverClassName, size, readOnly, showClear, formItemId, onBlur, ...rest }: ComboboxSingleProps): React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
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"];
|
|
3
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "popoverClassName", "size", "readOnly", "showClear", "formItemId", "onBlur"];
|
|
4
4
|
import { Popover } from '@scaleflex/ui-tw/popover';
|
|
5
5
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
6
6
|
import * as React from 'react';
|
|
@@ -26,6 +26,7 @@ export function ComboboxSingle(_ref) {
|
|
|
26
26
|
_ref$showClear = _ref.showClear,
|
|
27
27
|
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
28
28
|
formItemId = _ref.formItemId,
|
|
29
|
+
onBlur = _ref.onBlur,
|
|
29
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
31
|
var _useState = useState(false),
|
|
31
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -34,18 +35,32 @@ export function ComboboxSingle(_ref) {
|
|
|
34
35
|
var selectedLabel = (_flattenOptions$find = flattenOptions(options).find(function (opt) {
|
|
35
36
|
return opt.value === value;
|
|
36
37
|
})) === null || _flattenOptions$find === void 0 ? void 0 : _flattenOptions$find.label;
|
|
38
|
+
var onSelect = function onSelect(currentValue) {
|
|
39
|
+
onChange(currentValue === value ? '' : currentValue);
|
|
40
|
+
onBlur === null || onBlur === void 0 || onBlur(currentValue === value ? '' : currentValue);
|
|
41
|
+
setOpen(false);
|
|
42
|
+
};
|
|
43
|
+
var onOpenChange = function onOpenChange(isOpen) {
|
|
44
|
+
if (!isOpen) {
|
|
45
|
+
onBlur === null || onBlur === void 0 || onBlur(value);
|
|
46
|
+
}
|
|
47
|
+
setOpen(isOpen);
|
|
48
|
+
};
|
|
49
|
+
var onClearAll = function onClearAll() {
|
|
50
|
+
onChange('');
|
|
51
|
+
onBlur === null || onBlur === void 0 || onBlur('');
|
|
52
|
+
setOpen(false);
|
|
53
|
+
};
|
|
37
54
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
38
55
|
open: open,
|
|
39
|
-
onOpenChange:
|
|
56
|
+
onOpenChange: onOpenChange
|
|
40
57
|
}, /*#__PURE__*/React.createElement(ComboboxTrigger, {
|
|
41
58
|
open: open,
|
|
42
59
|
disabled: disabled,
|
|
43
60
|
className: className,
|
|
44
61
|
size: size,
|
|
45
62
|
readOnly: readOnly,
|
|
46
|
-
onClearAll:
|
|
47
|
-
return onChange('');
|
|
48
|
-
},
|
|
63
|
+
onClearAll: onClearAll,
|
|
49
64
|
selected: !!selectedLabel,
|
|
50
65
|
showClear: showClear,
|
|
51
66
|
"aria-invalid": rest['aria-invalid'],
|
|
@@ -54,10 +69,7 @@ export function ComboboxSingle(_ref) {
|
|
|
54
69
|
className: popoverClassName,
|
|
55
70
|
options: options,
|
|
56
71
|
value: value,
|
|
57
|
-
onSelect:
|
|
58
|
-
onChange(currentValue === value ? '' : currentValue);
|
|
59
|
-
setOpen(false);
|
|
60
|
-
},
|
|
72
|
+
onSelect: onSelect,
|
|
61
73
|
size: size
|
|
62
74
|
}));
|
|
63
75
|
}
|
|
@@ -19,7 +19,9 @@ export type ComboboxTriggerProps = {
|
|
|
19
19
|
export type ComboboxContentProps = {
|
|
20
20
|
options: SelectOption[];
|
|
21
21
|
value: string | string[];
|
|
22
|
-
onSelect: (value: string
|
|
22
|
+
onSelect: (value: string, options?: {
|
|
23
|
+
isTriggerOnBlur?: boolean;
|
|
24
|
+
}) => void;
|
|
23
25
|
size?: FormSizeType;
|
|
24
26
|
multiple?: boolean;
|
|
25
27
|
className?: string;
|
|
@@ -53,15 +55,18 @@ interface ComboboxCommonProps {
|
|
|
53
55
|
export interface ComboboxSingleProps extends ComboboxCommonProps {
|
|
54
56
|
value: string;
|
|
55
57
|
onChange: (value: string) => void;
|
|
58
|
+
onBlur?: (value: string) => void;
|
|
56
59
|
showClear?: boolean;
|
|
57
60
|
}
|
|
58
61
|
export interface ComboboxMultiInlineProps extends ComboboxCommonProps {
|
|
59
62
|
value: string[];
|
|
60
63
|
onChange: (value: string[]) => void;
|
|
64
|
+
onBlur?: (value: string[]) => void;
|
|
61
65
|
showClear?: boolean;
|
|
62
66
|
}
|
|
63
67
|
export interface ComboboxMultiTagProps extends ComboboxCommonProps {
|
|
64
68
|
value: string[];
|
|
65
69
|
onChange: (value: string[]) => void;
|
|
70
|
+
onBlur?: (value: string[]) => void;
|
|
66
71
|
}
|
|
67
72
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
3
|
+
import type { FormCheckboxFieldProps } from '../form.types';
|
|
4
|
+
declare function FormCheckboxField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ control, name, label, description, disabled, tooltip, size, checkboxProps, }: FormCheckboxFieldProps<TFieldValues, TName>): React.JSX.Element;
|
|
5
|
+
export { FormCheckboxField };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { Checkbox } from '@scaleflex/ui-tw/checkbox';
|
|
3
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
4
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../form.component';
|
|
8
|
+
import { formGroupFieldSizeOptions } from '../form.constants';
|
|
9
|
+
var formCheckboxFieldVariants = cva('', {
|
|
10
|
+
variants: {
|
|
11
|
+
size: formGroupFieldSizeOptions
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: FormSize.Md
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
function FormCheckboxField(_ref) {
|
|
18
|
+
var control = _ref.control,
|
|
19
|
+
name = _ref.name,
|
|
20
|
+
label = _ref.label,
|
|
21
|
+
description = _ref.description,
|
|
22
|
+
disabled = _ref.disabled,
|
|
23
|
+
tooltip = _ref.tooltip,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
26
|
+
checkboxProps = _ref.checkboxProps;
|
|
27
|
+
return /*#__PURE__*/React.createElement(FormField, {
|
|
28
|
+
control: control,
|
|
29
|
+
name: name,
|
|
30
|
+
render: function render(_ref2) {
|
|
31
|
+
var _checkboxProps$id;
|
|
32
|
+
var field = _ref2.field;
|
|
33
|
+
return /*#__PURE__*/React.createElement(FormItem, null, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: cn('group flex items-center', formCheckboxFieldVariants({
|
|
35
|
+
size: size
|
|
36
|
+
})),
|
|
37
|
+
"data-disabled": disabled
|
|
38
|
+
}, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
39
|
+
id: field.name,
|
|
40
|
+
checked: field.value,
|
|
41
|
+
onCheckedChange: field.onChange,
|
|
42
|
+
disabled: disabled,
|
|
43
|
+
size: size
|
|
44
|
+
}, checkboxProps))), /*#__PURE__*/React.createElement(FormLabel, {
|
|
45
|
+
className: "text-foreground",
|
|
46
|
+
htmlFor: (_checkboxProps$id = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.id) !== null && _checkboxProps$id !== void 0 ? _checkboxProps$id : field.name,
|
|
47
|
+
tooltip: tooltip,
|
|
48
|
+
size: size
|
|
49
|
+
}, label)), description && /*#__PURE__*/React.createElement(FormDescription, {
|
|
50
|
+
size: size
|
|
51
|
+
}, description), /*#__PURE__*/React.createElement(FormMessage, null));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export { FormCheckboxField };
|
|
@@ -5,10 +5,10 @@ import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
|
5
5
|
import { cva } from 'class-variance-authority';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../form.component';
|
|
8
|
-
import { SwitchLayout,
|
|
8
|
+
import { SwitchLayout, formGroupFieldSizeOptions } from '../form.constants';
|
|
9
9
|
var formSwitchFieldVariants = cva('', {
|
|
10
10
|
variants: {
|
|
11
|
-
size:
|
|
11
|
+
size: formGroupFieldSizeOptions
|
|
12
12
|
},
|
|
13
13
|
defaultVariants: {
|
|
14
14
|
size: FormSize.Md
|
package/form/form.constants.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const formMessageSizeOptions: {
|
|
|
17
17
|
readonly md: "text-xs";
|
|
18
18
|
readonly lg: "text-sm";
|
|
19
19
|
};
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const formGroupFieldSizeOptions: {
|
|
21
21
|
readonly sm: "space-x-2";
|
|
22
22
|
readonly md: "space-x-2.5";
|
|
23
23
|
readonly lg: "space-x-3";
|
package/form/form.constants.js
CHANGED
|
@@ -11,4 +11,4 @@ export var SwitchLayout = {
|
|
|
11
11
|
Justified: 'justified'
|
|
12
12
|
};
|
|
13
13
|
export var formMessageSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'text-xs'), FormMessageSize.Md, 'text-xs'), FormMessageSize.Lg, 'text-sm');
|
|
14
|
-
export var
|
|
14
|
+
export var formGroupFieldSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'space-x-2'), FormMessageSize.Md, 'space-x-2.5'), FormMessageSize.Lg, 'space-x-3');
|
package/form/form.types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CheckboxProps } from '@scaleflex/ui-tw/checkbox/checkbox.types';
|
|
1
2
|
import type { ComboboxMultiInlineProps, ComboboxMultiTagProps, ComboboxSingleProps } from '@scaleflex/ui-tw/combobox/combobox.types';
|
|
2
3
|
import type { InputProps } from '@scaleflex/ui-tw/input';
|
|
3
4
|
import type { SelectProps } from '@scaleflex/ui-tw/select/select.types';
|
|
@@ -22,26 +23,27 @@ export interface FormFieldArgs {
|
|
|
22
23
|
readOnly?: boolean;
|
|
23
24
|
disabled?: boolean;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
|
|
26
|
+
interface FormBaseFieldProps {
|
|
27
27
|
label?: ReactElement | string;
|
|
28
|
+
size?: FormSizeType;
|
|
28
29
|
description?: ReactElement | string;
|
|
30
|
+
disabled?: boolean;
|
|
29
31
|
tooltip?: ReactElement | string;
|
|
30
|
-
|
|
32
|
+
}
|
|
33
|
+
export interface FormFieldGroupProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName>, FormBaseFieldProps {
|
|
34
|
+
children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
|
|
31
35
|
readOnly?: boolean;
|
|
32
36
|
highlight?: boolean;
|
|
33
37
|
horizontal?: boolean;
|
|
34
38
|
horizontalLabelWidth?: string;
|
|
35
39
|
}
|
|
36
|
-
export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName
|
|
37
|
-
label: ReactElement | string;
|
|
38
|
-
size?: FormSizeType;
|
|
39
|
-
description?: ReactElement | string;
|
|
40
|
-
disabled?: boolean;
|
|
40
|
+
export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName>, FormBaseFieldProps {
|
|
41
41
|
layout?: SwitchLayoutType;
|
|
42
|
-
tooltip?: ReactElement | string;
|
|
43
42
|
switchProps?: SwitchProps;
|
|
44
43
|
}
|
|
44
|
+
export interface FormCheckboxFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName>, FormBaseFieldProps {
|
|
45
|
+
checkboxProps?: CheckboxProps;
|
|
46
|
+
}
|
|
45
47
|
export type FormInputFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
|
|
46
48
|
inputProps?: InputProps;
|
|
47
49
|
};
|
|
@@ -84,3 +86,4 @@ export interface FormSelectInnerProps<TFieldValues extends FieldValues, TName ex
|
|
|
84
86
|
disabled?: boolean;
|
|
85
87
|
className?: string;
|
|
86
88
|
}
|
|
89
|
+
export {};
|
package/form/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { FormTextareaField } from './components/form-textarea-field.component';
|
|
|
8
8
|
export { FormSwitchField } from './components/form-switch-field.component';
|
|
9
9
|
export { FormSelectField } from './components/form-select-field.component';
|
|
10
10
|
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
11
|
+
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
package/form/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export { FormPasswordField } from './components/form-password-field.component';
|
|
|
6
6
|
export { FormTextareaField } from './components/form-textarea-field.component';
|
|
7
7
|
export { FormSwitchField } from './components/form-switch-field.component';
|
|
8
8
|
export { FormSelectField } from './components/form-select-field.component';
|
|
9
|
-
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
9
|
+
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
10
|
+
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"main": "lib/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@popperjs/core": "^2.6.0",
|
|
16
|
+
"@radix-ui/react-checkbox": "^1.3.2",
|
|
16
17
|
"@radix-ui/react-label": "^2.1.6",
|
|
17
18
|
"@radix-ui/react-popover": "^1.0.2",
|
|
18
19
|
"@radix-ui/react-select": "^2.2.4",
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"@radix-ui/react-slot": "^1.1.2",
|
|
21
22
|
"@radix-ui/react-switch": "^1.0.1",
|
|
22
23
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
23
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
24
|
+
"@scaleflex/icons-tw": "^0.0.35",
|
|
24
25
|
"@types/lodash.merge": "^4.6.9",
|
|
25
26
|
"class-variance-authority": "^0.7.1",
|
|
26
27
|
"cmdk": "^1.1.1",
|
package/pill/pill.utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
2
|
-
export declare const getPillCrossIconClassName: (size?: FormSizeType | null) => "size-
|
|
2
|
+
export declare const getPillCrossIconClassName: (size?: FormSizeType | null) => "size-4" | "size-5" | "size-3";
|
|
@@ -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, ...rest }: SelectorProps): React.JSX.Element;
|
|
3
|
+
export declare function Selector({ value, onChange, placeholder, disabled, readOnly, size, className, icon, options, showGroupSeparator, formItemId, popoverClassName, ...rest }: SelectorProps): React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
var _excluded = ["value", "onChange", "placeholder", "disabled", "readOnly", "size", "className", "icon", "options", "showGroupSeparator", "formItemId"];
|
|
2
|
+
var _excluded = ["value", "onChange", "placeholder", "disabled", "readOnly", "size", "className", "icon", "options", "showGroupSeparator", "formItemId", "popoverClassName"];
|
|
3
3
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from '../';
|
|
@@ -16,6 +16,7 @@ export function Selector(_ref) {
|
|
|
16
16
|
options = _ref.options,
|
|
17
17
|
showGroupSeparator = _ref.showGroupSeparator,
|
|
18
18
|
formItemId = _ref.formItemId,
|
|
19
|
+
popoverClassName = _ref.popoverClassName,
|
|
19
20
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
21
|
return /*#__PURE__*/React.createElement(Select, {
|
|
21
22
|
value: value,
|
|
@@ -30,7 +31,9 @@ export function Selector(_ref) {
|
|
|
30
31
|
icon: icon
|
|
31
32
|
}, /*#__PURE__*/React.createElement(SelectValue, {
|
|
32
33
|
placeholder: placeholder
|
|
33
|
-
})), /*#__PURE__*/React.createElement(SelectContent,
|
|
34
|
+
})), /*#__PURE__*/React.createElement(SelectContent, {
|
|
35
|
+
className: popoverClassName
|
|
36
|
+
}, options.map(function (option, groupIndex) {
|
|
34
37
|
if (isOptionGroup(option)) {
|
|
35
38
|
return /*#__PURE__*/React.createElement(SelectGroup, {
|
|
36
39
|
key: groupIndex
|
package/select/select.types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const focusRingClassNames = "focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none";
|
|
2
2
|
export declare const selectionHighlightClassNames = "selection:bg-primary selection:text-primary-foreground";
|
|
3
3
|
export declare const readOnlyClassNames = "read-only:bg-secondary read-only:text-foreground read-only:cursor-default";
|
|
4
|
+
export declare const ariaInvalidClassNames = "aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive";
|
|
4
5
|
export declare const getBaseInputClasses: () => string[];
|
package/styles/shared-classes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var focusRingClassNames = 'focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none';
|
|
2
2
|
export var selectionHighlightClassNames = 'selection:bg-primary selection:text-primary-foreground';
|
|
3
3
|
export var readOnlyClassNames = 'read-only:bg-secondary read-only:text-foreground read-only:cursor-default';
|
|
4
|
+
export var ariaInvalidClassNames = 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive';
|
|
4
5
|
export var getBaseInputClasses = function getBaseInputClasses() {
|
|
5
|
-
return ['rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'border-input text-foreground bg-background', 'placeholder:text-muted-foreground/80 hover:border-secondary-foreground/50', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:border-secondary-foreground/50', '
|
|
6
|
+
return ['rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'border-input text-foreground bg-background', 'placeholder:text-muted-foreground/80 hover:border-secondary-foreground/50', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:border-secondary-foreground/50', 'focus-visible:group-data-[highlight=true]:border-warning group-data-[highlight=true]:border-warning hover:group-data-[highlight=true]:border-warning/60 group-data-[highlight=true]:focus-visible:ring-warning/20', ariaInvalidClassNames, focusRingClassNames];
|
|
6
7
|
};
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["className", "size"];
|
|
4
4
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
-
import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
5
|
+
import { ariaInvalidClassNames, focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
6
6
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
7
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
@@ -31,7 +31,7 @@ function Switch(_ref) {
|
|
|
31
31
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
32
|
return /*#__PURE__*/React.createElement(SwitchPrimitive.Root, _extends({
|
|
33
33
|
"data-slot": "switch",
|
|
34
|
-
className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-all outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input', focusRingClassNames, switchVariants({
|
|
34
|
+
className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-all outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input', focusRingClassNames, ariaInvalidClassNames, switchVariants({
|
|
35
35
|
size: size
|
|
36
36
|
}), className)
|
|
37
37
|
}, props), /*#__PURE__*/React.createElement(SwitchPrimitive.Thumb, {
|
package/switch/switch.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
2
|
-
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
2
|
+
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
4
|
export interface SwitchProps extends ComponentProps<typeof SwitchPrimitive.Root> {
|
|
5
5
|
size?: FormSizeType;
|