@scaleflex/ui-tw 0.0.35 → 0.0.37
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/calendar/calendar.component.d.ts +9 -0
- package/calendar/calendar.component.js +136 -0
- package/calendar/index.d.ts +1 -0
- package/calendar/index.js +1 -0
- package/checkbox/checkbox.constants.d.ts +2 -2
- package/checkbox/checkbox.constants.js +2 -2
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.d.ts +1 -1
- package/combobox/combobox-multi-inline/combobox-multi-inline.component.js +4 -1
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.d.ts +1 -1
- package/combobox/combobox-multi-tag/combobox-multi-tag.component.js +5 -2
- package/combobox/combobox-single/combobox-single.component.d.ts +1 -1
- package/combobox/combobox-single/combobox-single.component.js +5 -2
- package/combobox/combobox.component.d.ts +1 -1
- package/combobox/combobox.component.js +5 -3
- package/combobox/combobox.types.d.ts +2 -0
- package/date-picker/date-picker.component.d.ts +4 -0
- package/date-picker/date-picker.component.js +129 -0
- package/date-picker/date-picker.constants.d.ts +10 -0
- package/date-picker/date-picker.constants.js +4 -0
- package/date-picker/date-picker.types.d.ts +10 -0
- package/date-picker/date-picker.types.js +1 -0
- package/date-picker/date-picker.utils.d.ts +2 -0
- package/date-picker/date-picker.utils.js +23 -0
- package/date-picker/index.d.ts +1 -0
- package/date-picker/index.js +1 -0
- package/dialog/dialog.component.js +5 -5
- package/form/components/form-checkbox-field.component.js +6 -4
- package/form/components/form-checkbox-group-field.component.d.ts +5 -0
- package/form/components/form-checkbox-group-field.component.js +82 -0
- package/form/components/form-combobox-field.component.d.ts +1 -1
- package/form/components/form-combobox-field.component.js +4 -1
- package/form/components/form-field-group.component.js +1 -0
- package/form/components/form-radio-group-field.component.d.ts +5 -0
- package/form/components/form-radio-group-field.component.js +80 -0
- package/form/components/form-textarea-field.component.js +1 -1
- package/form/form.constants.d.ts +5 -0
- package/form/form.constants.js +2 -1
- package/form/form.types.d.ts +31 -1
- package/form/index.d.ts +2 -0
- package/form/index.js +3 -1
- package/package.json +5 -2
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.js +1 -0
- package/radio-group/radio-group.component.d.ts +5 -0
- package/radio-group/radio-group.component.js +55 -0
- package/radio-group/radio-group.constants.d.ts +10 -0
- package/radio-group/radio-group.constants.js +4 -0
- package/radio-group/radio-group.types.d.ts +8 -0
- package/radio-group/radio-group.types.js +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Button } from '@scaleflex/ui-tw/button';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type ComponentProps } from 'react';
|
|
4
|
+
import { DayButton, DayPicker } from 'react-day-picker';
|
|
5
|
+
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, formatters, components, ...props }: ComponentProps<typeof DayPicker> & {
|
|
6
|
+
buttonVariant?: ComponentProps<typeof Button>['variant'];
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
declare function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps<typeof DayButton>): React.JSX.Element;
|
|
9
|
+
export { Calendar, CalendarDayButton };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _templateObject, _templateObject2;
|
|
6
|
+
var _excluded = ["className", "classNames", "showOutsideDays", "captionLayout", "buttonVariant", "formatters", "components"],
|
|
7
|
+
_excluded2 = ["className", "rootRef"],
|
|
8
|
+
_excluded3 = ["className", "orientation"],
|
|
9
|
+
_excluded4 = ["children"],
|
|
10
|
+
_excluded5 = ["className", "day", "modifiers"];
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
import { Button, buttonVariants } from '@scaleflex/ui-tw/button';
|
|
14
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
15
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { DayPicker, getDefaultClassNames } from 'react-day-picker';
|
|
18
|
+
function Calendar(_ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
classNames = _ref.classNames,
|
|
21
|
+
_ref$showOutsideDays = _ref.showOutsideDays,
|
|
22
|
+
showOutsideDays = _ref$showOutsideDays === void 0 ? true : _ref$showOutsideDays,
|
|
23
|
+
_ref$captionLayout = _ref.captionLayout,
|
|
24
|
+
captionLayout = _ref$captionLayout === void 0 ? 'label' : _ref$captionLayout,
|
|
25
|
+
_ref$buttonVariant = _ref.buttonVariant,
|
|
26
|
+
buttonVariant = _ref$buttonVariant === void 0 ? 'ghost-secondary' : _ref$buttonVariant,
|
|
27
|
+
formatters = _ref.formatters,
|
|
28
|
+
components = _ref.components,
|
|
29
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
var defaultClassNames = getDefaultClassNames();
|
|
31
|
+
return /*#__PURE__*/React.createElement(DayPicker, _extends({
|
|
32
|
+
showOutsideDays: showOutsideDays,
|
|
33
|
+
className: cn('bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent', String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["rtl:**:[.rdp-button_next>svg]:rotate-180"], ["rtl:**:[.rdp-button\\_next>svg]:rotate-180"]))), String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["rtl:**:[.rdp-button_previous>svg]:rotate-180"], ["rtl:**:[.rdp-button\\_previous>svg]:rotate-180"]))), className),
|
|
34
|
+
captionLayout: captionLayout,
|
|
35
|
+
formatters: _objectSpread({
|
|
36
|
+
formatMonthDropdown: function formatMonthDropdown(date) {
|
|
37
|
+
return date.toLocaleString('default', {
|
|
38
|
+
month: 'short'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}, formatters),
|
|
42
|
+
classNames: _objectSpread({
|
|
43
|
+
root: cn('w-fit', defaultClassNames.root),
|
|
44
|
+
months: cn('flex gap-4 flex-col md:flex-row relative', defaultClassNames.months),
|
|
45
|
+
month: cn('flex flex-col w-full gap-4', defaultClassNames.month),
|
|
46
|
+
nav: cn('flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between', defaultClassNames.nav),
|
|
47
|
+
button_previous: cn(buttonVariants({
|
|
48
|
+
variant: buttonVariant
|
|
49
|
+
}), 'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none', defaultClassNames.button_previous),
|
|
50
|
+
button_next: cn(buttonVariants({
|
|
51
|
+
variant: buttonVariant
|
|
52
|
+
}), 'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none', defaultClassNames.button_next),
|
|
53
|
+
month_caption: cn('flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)', defaultClassNames.month_caption),
|
|
54
|
+
dropdowns: cn('w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5', defaultClassNames.dropdowns),
|
|
55
|
+
dropdown_root: cn('relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md', defaultClassNames.dropdown_root),
|
|
56
|
+
dropdown: cn('absolute inset-0 opacity-0', defaultClassNames.dropdown),
|
|
57
|
+
caption_label: cn('select-none font-medium', captionLayout === 'label' ? 'text-sm' : 'rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5', defaultClassNames.caption_label),
|
|
58
|
+
table: 'w-full border-collapse',
|
|
59
|
+
weekdays: cn('flex', defaultClassNames.weekdays),
|
|
60
|
+
weekday: cn('text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none', defaultClassNames.weekday),
|
|
61
|
+
week: cn('flex w-full mt-2', defaultClassNames.week),
|
|
62
|
+
week_number_header: cn('select-none w-(--cell-size)', defaultClassNames.week_number_header),
|
|
63
|
+
week_number: cn('text-[0.8rem] select-none text-muted-foreground', defaultClassNames.week_number),
|
|
64
|
+
day: cn('relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none', defaultClassNames.day),
|
|
65
|
+
range_start: cn('rounded-l-md bg-accent', defaultClassNames.range_start),
|
|
66
|
+
range_middle: cn('rounded-none', defaultClassNames.range_middle),
|
|
67
|
+
range_end: cn('rounded-r-md bg-accent', defaultClassNames.range_end),
|
|
68
|
+
today: cn('bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none', defaultClassNames.today),
|
|
69
|
+
outside: cn('text-muted-foreground aria-selected:text-muted-foreground', defaultClassNames.outside),
|
|
70
|
+
disabled: cn('text-muted-foreground opacity-50', defaultClassNames.disabled),
|
|
71
|
+
hidden: cn('invisible', defaultClassNames.hidden)
|
|
72
|
+
}, classNames),
|
|
73
|
+
components: _objectSpread({
|
|
74
|
+
Root: function Root(_ref2) {
|
|
75
|
+
var className = _ref2.className,
|
|
76
|
+
rootRef = _ref2.rootRef,
|
|
77
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
79
|
+
"data-slot": "calendar",
|
|
80
|
+
ref: rootRef,
|
|
81
|
+
className: cn(className)
|
|
82
|
+
}, props));
|
|
83
|
+
},
|
|
84
|
+
Chevron: function Chevron(_ref3) {
|
|
85
|
+
var className = _ref3.className,
|
|
86
|
+
orientation = _ref3.orientation,
|
|
87
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
88
|
+
if (orientation === 'left') {
|
|
89
|
+
return /*#__PURE__*/React.createElement(ChevronLeftIcon, _extends({
|
|
90
|
+
className: cn('size-4', className)
|
|
91
|
+
}, props));
|
|
92
|
+
}
|
|
93
|
+
if (orientation === 'right') {
|
|
94
|
+
return /*#__PURE__*/React.createElement(ChevronRightIcon, _extends({
|
|
95
|
+
className: cn('size-4', className)
|
|
96
|
+
}, props));
|
|
97
|
+
}
|
|
98
|
+
return /*#__PURE__*/React.createElement(ChevronDownIcon, _extends({
|
|
99
|
+
className: cn('size-4', className)
|
|
100
|
+
}, props));
|
|
101
|
+
},
|
|
102
|
+
DayButton: CalendarDayButton,
|
|
103
|
+
WeekNumber: function WeekNumber(_ref4) {
|
|
104
|
+
var children = _ref4.children,
|
|
105
|
+
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
106
|
+
return /*#__PURE__*/React.createElement("td", props, /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "flex size-(--cell-size) items-center justify-center text-center"
|
|
108
|
+
}, children));
|
|
109
|
+
}
|
|
110
|
+
}, components)
|
|
111
|
+
}, props));
|
|
112
|
+
}
|
|
113
|
+
function CalendarDayButton(_ref5) {
|
|
114
|
+
var className = _ref5.className,
|
|
115
|
+
day = _ref5.day,
|
|
116
|
+
modifiers = _ref5.modifiers,
|
|
117
|
+
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
118
|
+
var defaultClassNames = getDefaultClassNames();
|
|
119
|
+
var ref = React.useRef(null);
|
|
120
|
+
React.useEffect(function () {
|
|
121
|
+
var _ref$current;
|
|
122
|
+
if (modifiers.focused) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
123
|
+
}, [modifiers.focused]);
|
|
124
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
125
|
+
ref: ref,
|
|
126
|
+
variant: "ghost-secondary",
|
|
127
|
+
size: "sm",
|
|
128
|
+
"data-day": day.date.toLocaleDateString(),
|
|
129
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
130
|
+
"data-range-start": modifiers.range_start,
|
|
131
|
+
"data-range-end": modifiers.range_end,
|
|
132
|
+
"data-range-middle": modifiers.range_middle,
|
|
133
|
+
className: cn('data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70', defaultClassNames.day, className)
|
|
134
|
+
}, props));
|
|
135
|
+
}
|
|
136
|
+
export { Calendar, CalendarDayButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Calendar, CalendarDayButton } from './calendar.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Calendar, CalendarDayButton } from './calendar.component';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const checkboxSizeOptions: {
|
|
2
2
|
readonly sm: "size-4";
|
|
3
3
|
readonly md: "size-5";
|
|
4
|
-
readonly lg: "size-
|
|
4
|
+
readonly lg: "size-6";
|
|
5
5
|
};
|
|
6
6
|
export declare const checkboxIndicatorSizeOptions: {
|
|
7
7
|
readonly sm: "size-3.5";
|
|
8
8
|
readonly md: "size-4.5";
|
|
9
|
-
readonly lg: "size-
|
|
9
|
+
readonly lg: "size-5.5";
|
|
10
10
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
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-
|
|
4
|
-
export var checkboxIndicatorSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-3.5'), FormSize.Md, 'size-4.5'), FormSize.Lg, 'size-
|
|
3
|
+
export var checkboxSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-4'), FormSize.Md, 'size-5'), FormSize.Lg, 'size-6');
|
|
4
|
+
export var checkboxIndicatorSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-3.5'), FormSize.Md, 'size-4.5'), FormSize.Lg, 'size-5.5');
|
|
@@ -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, ...rest }: ComboboxMultiInlineProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiInline({ options, value, onChange, placeholder, className, disabled, size, readOnly, showClear, popoverClassName, onBlur, showGroupSeparator, ...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", "onBlur"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "showClear", "popoverClassName", "onBlur", "showGroupSeparator"];
|
|
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';
|
|
@@ -25,6 +25,8 @@ export function ComboboxMultiInline(_ref) {
|
|
|
25
25
|
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
26
26
|
popoverClassName = _ref.popoverClassName,
|
|
27
27
|
onBlur = _ref.onBlur,
|
|
28
|
+
_ref$showGroupSeparat = _ref.showGroupSeparator,
|
|
29
|
+
showGroupSeparator = _ref$showGroupSeparat === void 0 ? false : _ref$showGroupSeparat,
|
|
28
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
31
|
var _useState = useState(false),
|
|
30
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -72,6 +74,7 @@ export function ComboboxMultiInline(_ref) {
|
|
|
72
74
|
onClearAll: onClearAll,
|
|
73
75
|
"aria-invalid": rest['aria-invalid']
|
|
74
76
|
}, displayValue), /*#__PURE__*/React.createElement(ComboboxContent, {
|
|
77
|
+
showGroupSeparator: showGroupSeparator,
|
|
75
78
|
className: popoverClassName,
|
|
76
79
|
options: options,
|
|
77
80
|
value: value,
|
|
@@ -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, ...rest }: ComboboxMultiTagProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxMultiTag({ options, value, onChange, placeholder, className, disabled, size, readOnly, popoverClassName, onBlur, showGroupSeparator, ...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"];
|
|
4
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "size", "readOnly", "popoverClassName", "onBlur", "showGroupSeparator"];
|
|
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';
|
|
@@ -32,6 +32,8 @@ export function ComboboxMultiTag(_ref) {
|
|
|
32
32
|
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
33
33
|
popoverClassName = _ref.popoverClassName,
|
|
34
34
|
onBlur = _ref.onBlur,
|
|
35
|
+
_ref$showGroupSeparat = _ref.showGroupSeparator,
|
|
36
|
+
showGroupSeparator = _ref$showGroupSeparat === void 0 ? false : _ref$showGroupSeparat,
|
|
35
37
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
38
|
var _getToolbarSizes = getToolbarSizes(size),
|
|
37
39
|
buttonSize = _getToolbarSizes.buttonSize;
|
|
@@ -125,6 +127,7 @@ export function ComboboxMultiTag(_ref) {
|
|
|
125
127
|
onSelect: toggleValue,
|
|
126
128
|
size: size,
|
|
127
129
|
multiple: true,
|
|
128
|
-
className: popoverClassName
|
|
130
|
+
className: popoverClassName,
|
|
131
|
+
showGroupSeparator: showGroupSeparator
|
|
129
132
|
}));
|
|
130
133
|
}
|
|
@@ -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, ...rest }: ComboboxSingleProps): React.JSX.Element;
|
|
3
|
+
export declare function ComboboxSingle({ options, value, onChange, placeholder, className, disabled, popoverClassName, size, readOnly, showClear, formItemId, onBlur, showGroupSeparator, ...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", "onBlur"];
|
|
3
|
+
var _excluded = ["options", "value", "onChange", "placeholder", "className", "disabled", "popoverClassName", "size", "readOnly", "showClear", "formItemId", "onBlur", "showGroupSeparator"];
|
|
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';
|
|
@@ -27,6 +27,8 @@ export function ComboboxSingle(_ref) {
|
|
|
27
27
|
showClear = _ref$showClear === void 0 ? true : _ref$showClear,
|
|
28
28
|
formItemId = _ref.formItemId,
|
|
29
29
|
onBlur = _ref.onBlur,
|
|
30
|
+
_ref$showGroupSeparat = _ref.showGroupSeparator,
|
|
31
|
+
showGroupSeparator = _ref$showGroupSeparat === void 0 ? false : _ref$showGroupSeparat,
|
|
30
32
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
31
33
|
var _useState = useState(false),
|
|
32
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -70,6 +72,7 @@ export function ComboboxSingle(_ref) {
|
|
|
70
72
|
options: options,
|
|
71
73
|
value: value,
|
|
72
74
|
onSelect: onSelect,
|
|
73
|
-
size: size
|
|
75
|
+
size: size,
|
|
76
|
+
showGroupSeparator: showGroupSeparator
|
|
74
77
|
}));
|
|
75
78
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ComboboxContentProps, ComboboxTriggerProps } from './combobox.types';
|
|
3
3
|
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, }: ComboboxContentProps): React.JSX.Element;
|
|
4
|
+
export declare function ComboboxContent({ options, value: selectedValue, onSelect, size, multiple, className, showGroupSeparator, }: ComboboxContentProps): React.JSX.Element;
|
|
@@ -6,7 +6,7 @@ import { ButtonVariant, buttonBaseClassNames } from '@scaleflex/ui-tw/button/but
|
|
|
6
6
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@scaleflex/ui-tw/command';
|
|
7
7
|
import { isOptionGroup } from '@scaleflex/ui-tw/form';
|
|
8
8
|
import { PopoverContent, PopoverTrigger } from '@scaleflex/ui-tw/popover';
|
|
9
|
-
import { selectTriggerVariants } from '@scaleflex/ui-tw/select/select.component';
|
|
9
|
+
import { SelectSeparator, selectTriggerVariants } from '@scaleflex/ui-tw/select/select.component';
|
|
10
10
|
import { getBaseSelectClassNames, selectReadOnlyClassNames } from '@scaleflex/ui-tw/select/select.constants';
|
|
11
11
|
import { Separator } from '@scaleflex/ui-tw/separator';
|
|
12
12
|
import { focusRingClassNames, getBaseInputClasses } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
@@ -84,7 +84,9 @@ export function ComboboxContent(_ref2) {
|
|
|
84
84
|
size = _ref2$size === void 0 ? 'md' : _ref2$size,
|
|
85
85
|
_ref2$multiple = _ref2.multiple,
|
|
86
86
|
multiple = _ref2$multiple === void 0 ? false : _ref2$multiple,
|
|
87
|
-
className = _ref2.className
|
|
87
|
+
className = _ref2.className,
|
|
88
|
+
_ref2$showGroupSepara = _ref2.showGroupSeparator,
|
|
89
|
+
showGroupSeparator = _ref2$showGroupSepara === void 0 ? false : _ref2$showGroupSepara;
|
|
88
90
|
return /*#__PURE__*/React.createElement(PopoverContent, {
|
|
89
91
|
className: cn('p-0', className)
|
|
90
92
|
}, /*#__PURE__*/React.createElement(Command, null, /*#__PURE__*/React.createElement(CommandInput, {
|
|
@@ -118,7 +120,7 @@ export function ComboboxContent(_ref2) {
|
|
|
118
120
|
return _onSelect(value);
|
|
119
121
|
}
|
|
120
122
|
}, label);
|
|
121
|
-
}));
|
|
123
|
+
}), showGroupSeparator && groupIndex !== options.length - 1 && /*#__PURE__*/React.createElement(SelectSeparator, null));
|
|
122
124
|
}
|
|
123
125
|
return /*#__PURE__*/React.createElement(CommandGroup, {
|
|
124
126
|
key: "default"
|
|
@@ -25,6 +25,7 @@ export type ComboboxContentProps = {
|
|
|
25
25
|
size?: FormSizeType;
|
|
26
26
|
multiple?: boolean;
|
|
27
27
|
className?: string;
|
|
28
|
+
showGroupSeparator?: boolean;
|
|
28
29
|
};
|
|
29
30
|
export interface CommandInputProps extends Omit<ComponentProps<typeof CommandPrimitive.Input>, 'size'> {
|
|
30
31
|
size?: FormSizeType;
|
|
@@ -51,6 +52,7 @@ interface ComboboxCommonProps {
|
|
|
51
52
|
popoverClassName?: string;
|
|
52
53
|
'aria-invalid'?: boolean;
|
|
53
54
|
formItemId?: string;
|
|
55
|
+
showGroupSeparator?: boolean;
|
|
54
56
|
}
|
|
55
57
|
export interface ComboboxSingleProps extends ComboboxCommonProps {
|
|
56
58
|
value: string;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["minDate", "maxDate", "defaultDate", "readOnly", "size", "invalidDateText", "disabled"];
|
|
6
|
+
import { Button } from '@scaleflex/ui-tw/button';
|
|
7
|
+
import { Calendar } from '@scaleflex/ui-tw/calendar';
|
|
8
|
+
import { Input } from '@scaleflex/ui-tw/input';
|
|
9
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@scaleflex/ui-tw/popover';
|
|
10
|
+
import { selectTriggerVariants } from '@scaleflex/ui-tw/select/select.component';
|
|
11
|
+
import { getBaseSelectClassNames, selectReadOnlyClassNames } from '@scaleflex/ui-tw/select/select.constants';
|
|
12
|
+
import { getBaseInputClasses } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
13
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
14
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
15
|
+
import { CalendarIcon } from 'lucide-react';
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
|
+
import { buttonSizeInTriggerOptions, iconSizeInTriggerOptions } from './date-picker.constants';
|
|
18
|
+
import { parseDateString, toHtmlDateString } from './date-picker.utils';
|
|
19
|
+
function DatePicker(_ref) {
|
|
20
|
+
var minDate = _ref.minDate,
|
|
21
|
+
maxDate = _ref.maxDate,
|
|
22
|
+
_ref$defaultDate = _ref.defaultDate,
|
|
23
|
+
defaultDate = _ref$defaultDate === void 0 ? new Date() : _ref$defaultDate,
|
|
24
|
+
readOnly = _ref.readOnly,
|
|
25
|
+
_ref$size = _ref.size,
|
|
26
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
27
|
+
invalidDateText = _ref.invalidDateText,
|
|
28
|
+
disabled = _ref.disabled,
|
|
29
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
open = _useState2[0],
|
|
33
|
+
setOpen = _useState2[1];
|
|
34
|
+
var _useState3 = useState(toHtmlDateString(defaultDate)),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
inputValue = _useState4[0],
|
|
37
|
+
setInputValue = _useState4[1];
|
|
38
|
+
var _useState5 = useState(defaultDate),
|
|
39
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
40
|
+
selectedDate = _useState6[0],
|
|
41
|
+
setSelectedDate = _useState6[1];
|
|
42
|
+
var _useState7 = useState(defaultDate),
|
|
43
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
44
|
+
calendarMonth = _useState8[0],
|
|
45
|
+
setCalendarMonth = _useState8[1];
|
|
46
|
+
var parsedDate = parseDateString(inputValue);
|
|
47
|
+
var isInputValid = !inputValue || !!parsedDate;
|
|
48
|
+
var handleInputChange = function handleInputChange(e) {
|
|
49
|
+
var value = e.target.value;
|
|
50
|
+
setInputValue(value);
|
|
51
|
+
var parsed = parseDateString(value);
|
|
52
|
+
if (parsed) {
|
|
53
|
+
setSelectedDate(parsed);
|
|
54
|
+
setCalendarMonth(parsed);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var handleCalendarSelect = function handleCalendarSelect(date) {
|
|
58
|
+
if (date) {
|
|
59
|
+
setSelectedDate(date);
|
|
60
|
+
setInputValue(toHtmlDateString(date));
|
|
61
|
+
setCalendarMonth(date);
|
|
62
|
+
setOpen(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "flex flex-col gap-2"
|
|
67
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "relative flex gap-2"
|
|
69
|
+
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
70
|
+
id: "date",
|
|
71
|
+
type: "text",
|
|
72
|
+
inputMode: "numeric",
|
|
73
|
+
autoComplete: "off",
|
|
74
|
+
pattern: "\\d{2}/\\d{2}/\\d{4}",
|
|
75
|
+
placeholder: "dd/mm/yyyy",
|
|
76
|
+
value: inputValue,
|
|
77
|
+
disabled: disabled,
|
|
78
|
+
className: cn.apply(void 0, _toConsumableArray(getBaseSelectClassNames()).concat(_toConsumableArray(getBaseInputClasses()), ['hover:border-secondary-foreground/50', selectTriggerVariants({
|
|
79
|
+
size: size
|
|
80
|
+
}), readOnly && selectReadOnlyClassNames, !isInputValid && 'border-destructive'])),
|
|
81
|
+
onChange: handleInputChange,
|
|
82
|
+
onKeyDown: function onKeyDown(e) {
|
|
83
|
+
var allowed = '0123456789/';
|
|
84
|
+
if (e.key.length === 1 && !allowed.includes(e.key)) {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, rest)), /*#__PURE__*/React.createElement(Popover, {
|
|
89
|
+
open: open,
|
|
90
|
+
onOpenChange: setOpen
|
|
91
|
+
}, /*#__PURE__*/React.createElement(PopoverTrigger, {
|
|
92
|
+
asChild: true
|
|
93
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
94
|
+
id: "date-picker",
|
|
95
|
+
size: buttonSizeInTriggerOptions[size],
|
|
96
|
+
variant: "ghost-secondary",
|
|
97
|
+
className: "absolute top-1/2 right-2 -translate-y-1/2",
|
|
98
|
+
onClick: function onClick() {
|
|
99
|
+
return setOpen(function (prev) {
|
|
100
|
+
return !prev;
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
disabled: readOnly || disabled
|
|
104
|
+
}, /*#__PURE__*/React.createElement(CalendarIcon, {
|
|
105
|
+
className: iconSizeInTriggerOptions[size]
|
|
106
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
107
|
+
className: "sr-only"
|
|
108
|
+
}, "Select date"))), /*#__PURE__*/React.createElement(PopoverContent, {
|
|
109
|
+
className: "w-auto overflow-hidden p-0",
|
|
110
|
+
align: "end",
|
|
111
|
+
alignOffset: -8,
|
|
112
|
+
sideOffset: 10
|
|
113
|
+
}, /*#__PURE__*/React.createElement(Calendar, {
|
|
114
|
+
mode: "single",
|
|
115
|
+
selected: selectedDate,
|
|
116
|
+
captionLayout: "dropdown",
|
|
117
|
+
month: calendarMonth,
|
|
118
|
+
onMonthChange: setCalendarMonth,
|
|
119
|
+
onSelect: handleCalendarSelect,
|
|
120
|
+
disabled: [minDate && {
|
|
121
|
+
before: minDate
|
|
122
|
+
}, maxDate && {
|
|
123
|
+
after: maxDate
|
|
124
|
+
}].filter(Boolean)
|
|
125
|
+
})))), !isInputValid && /*#__PURE__*/React.createElement("span", {
|
|
126
|
+
className: "px-1 text-xs text-red-500"
|
|
127
|
+
}, invalidDateText !== null && invalidDateText !== void 0 ? invalidDateText : 'Invalid date. Use dd/mm/yyyy'));
|
|
128
|
+
}
|
|
129
|
+
export { DatePicker };
|
|
@@ -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 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');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
export function toHtmlDateString(date) {
|
|
3
|
+
var day = String(date.getDate()).padStart(2, '0');
|
|
4
|
+
var month = String(date.getMonth() + 1).padStart(2, '0');
|
|
5
|
+
var year = date.getFullYear();
|
|
6
|
+
return "".concat(day, "/").concat(month, "/").concat(year);
|
|
7
|
+
}
|
|
8
|
+
export function parseDateString(value) {
|
|
9
|
+
if (!/^\d{2}\/\d{2}\/\d{4}$/.test(value)) return undefined;
|
|
10
|
+
var _value$split$map = value.split('/').map(Number),
|
|
11
|
+
_value$split$map2 = _slicedToArray(_value$split$map, 3),
|
|
12
|
+
day = _value$split$map2[0],
|
|
13
|
+
month = _value$split$map2[1],
|
|
14
|
+
year = _value$split$map2[2];
|
|
15
|
+
if (day < 1 || day > 31 || month < 1 || month > 12) return undefined;
|
|
16
|
+
var date = new Date(year, month - 1, day);
|
|
17
|
+
|
|
18
|
+
// Check if the date matches the input (avoids 32/01 → 01 Feb bug)
|
|
19
|
+
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return date;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DatePicker } from './date-picker.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DatePicker } from './date-picker.component';
|
|
@@ -62,7 +62,7 @@ function DialogWideContent(_ref6) {
|
|
|
62
62
|
"data-slot": "dialog-portal"
|
|
63
63
|
}, /*#__PURE__*/React.createElement(DialogOverlay, null), /*#__PURE__*/React.createElement(DialogPrimitive.Content, _extends({
|
|
64
64
|
"data-slot": "dialog-content",
|
|
65
|
-
className: cn('bg-background border-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border shadow-lg duration-200 lg:max-w-[62rem] xl:max-w-5xl', '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', className)
|
|
65
|
+
className: cn('bg-background text-foreground border-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border shadow-lg duration-200 lg:max-w-[62rem] xl:max-w-5xl', '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', className)
|
|
66
66
|
}, props), children, /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
|
|
67
67
|
"data-state": "open",
|
|
68
68
|
className: cn('text-muted-foreground absolute top-3 right-3 cursor-pointer rounded-xs opacity-70 transition-opacity hover:opacity-100 disabled:pointer-events-none', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-6", focusRingClassNames)
|
|
@@ -81,7 +81,7 @@ function DialogFormContent(_ref7) {
|
|
|
81
81
|
"data-slot": "dialog-portal"
|
|
82
82
|
}, /*#__PURE__*/React.createElement(DialogOverlay, null), /*#__PURE__*/React.createElement(DialogPrimitive.Content, _extends({
|
|
83
83
|
"data-slot": "dialog-content",
|
|
84
|
-
className: cn('bg-background border-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-md translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200', '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', className)
|
|
84
|
+
className: cn('bg-background text-foreground border-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-md translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200', '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', className)
|
|
85
85
|
}, props), children, /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
|
|
86
86
|
"data-state": "open",
|
|
87
87
|
className: cn('text-muted-foreground absolute top-3 right-3 cursor-pointer rounded-xs opacity-70 transition-opacity hover:opacity-100 disabled:pointer-events-none', "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-6", focusRingClassNames)
|
|
@@ -97,7 +97,7 @@ function DialogWideHeader(_ref8) {
|
|
|
97
97
|
props = _objectWithoutProperties(_ref8, _excluded4);
|
|
98
98
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
99
99
|
"data-slot": "dialog-header",
|
|
100
|
-
className: cn('border-border flex h-16 items-center justify-center border-b', className)
|
|
100
|
+
className: cn('border-border text-foreground flex h-16 items-center justify-center border-b', className)
|
|
101
101
|
}, props));
|
|
102
102
|
}
|
|
103
103
|
function DialogFormHeader(_ref9) {
|
|
@@ -105,7 +105,7 @@ function DialogFormHeader(_ref9) {
|
|
|
105
105
|
props = _objectWithoutProperties(_ref9, _excluded5);
|
|
106
106
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
107
107
|
"data-slot": "dialog-header",
|
|
108
|
-
className: cn('flex flex-col items-center justify-center p-6 pt-8 text-center', className)
|
|
108
|
+
className: cn('text-foreground flex flex-col items-center justify-center p-6 pt-8 text-center', className)
|
|
109
109
|
}, props));
|
|
110
110
|
}
|
|
111
111
|
function DialogWideBody(_ref10) {
|
|
@@ -137,7 +137,7 @@ function DialogFormTitle(_ref13) {
|
|
|
137
137
|
props = _objectWithoutProperties(_ref13, _excluded9);
|
|
138
138
|
return /*#__PURE__*/React.createElement(DialogPrimitive.Title, _extends({
|
|
139
139
|
"data-slot": "dialog-title",
|
|
140
|
-
className: cn('text-lg leading-7 font-medium', className)
|
|
140
|
+
className: cn('text-foreground text-lg leading-7 font-medium', className)
|
|
141
141
|
}, props));
|
|
142
142
|
}
|
|
143
143
|
function DialogFormDescription(_ref14) {
|
|
@@ -30,11 +30,13 @@ function FormCheckboxField(_ref) {
|
|
|
30
30
|
render: function render(_ref2) {
|
|
31
31
|
var _checkboxProps$id;
|
|
32
32
|
var field = _ref2.field;
|
|
33
|
-
return /*#__PURE__*/React.createElement(FormItem,
|
|
34
|
-
className:
|
|
35
|
-
size: size
|
|
36
|
-
})),
|
|
33
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
34
|
+
className: "group",
|
|
37
35
|
"data-disabled": disabled
|
|
36
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: cn('flex items-center', formCheckboxFieldVariants({
|
|
38
|
+
size: size
|
|
39
|
+
}))
|
|
38
40
|
}, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
39
41
|
id: field.name,
|
|
40
42
|
checked: field.value,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FormCheckboxGroupFieldProps } from '@scaleflex/ui-tw/form/form.types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
|
+
declare function FormCheckboxGroupField<TFieldValues extends FieldValues>({ control, name, label, description, options, className, tooltip, size, disabled, horizontal, horizontalLabelWidth, }: FormCheckboxGroupFieldProps<TFieldValues>): React.JSX.Element;
|
|
5
|
+
export { FormCheckboxGroupField };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { Checkbox } from '@scaleflex/ui-tw/checkbox';
|
|
3
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@scaleflex/ui-tw/form';
|
|
4
|
+
import { labelCheckboxAndRadioSizeOptions } from '@scaleflex/ui-tw/form/form.constants';
|
|
5
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
6
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
7
|
+
import { cva } from 'class-variance-authority';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
var labelCheckboxAndRadioVariants = cva('', {
|
|
10
|
+
variants: {
|
|
11
|
+
size: labelCheckboxAndRadioSizeOptions
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: FormSize.Md
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
function FormCheckboxGroupField(_ref) {
|
|
18
|
+
var control = _ref.control,
|
|
19
|
+
name = _ref.name,
|
|
20
|
+
label = _ref.label,
|
|
21
|
+
description = _ref.description,
|
|
22
|
+
options = _ref.options,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
tooltip = _ref.tooltip,
|
|
25
|
+
_ref$size = _ref.size,
|
|
26
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
27
|
+
_ref$disabled = _ref.disabled,
|
|
28
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
29
|
+
_ref$horizontal = _ref.horizontal,
|
|
30
|
+
horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
|
|
31
|
+
horizontalLabelWidth = _ref.horizontalLabelWidth;
|
|
32
|
+
return /*#__PURE__*/React.createElement(FormField, {
|
|
33
|
+
control: control,
|
|
34
|
+
name: name,
|
|
35
|
+
disabled: disabled,
|
|
36
|
+
render: function render(_ref2) {
|
|
37
|
+
var field = _ref2.field;
|
|
38
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
39
|
+
className: cn('group gap-6', className),
|
|
40
|
+
"data-disabled": disabled,
|
|
41
|
+
horizontal: horizontal,
|
|
42
|
+
firstColumnWidth: horizontalLabelWidth
|
|
43
|
+
}, (label || description) && /*#__PURE__*/React.createElement("div", null, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
44
|
+
className: cn('cursor-default', labelCheckboxAndRadioVariants({
|
|
45
|
+
size: size
|
|
46
|
+
})),
|
|
47
|
+
size: size,
|
|
48
|
+
tooltip: tooltip
|
|
49
|
+
}, label), description && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
50
|
+
size: size
|
|
51
|
+
}, description)), /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: "flex flex-col gap-3"
|
|
53
|
+
}, description && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
54
|
+
className: labelCheckboxAndRadioVariants({
|
|
55
|
+
size: size
|
|
56
|
+
}),
|
|
57
|
+
size: size
|
|
58
|
+
}, description), options.map(function (option) {
|
|
59
|
+
var _field$value;
|
|
60
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
61
|
+
key: option.id,
|
|
62
|
+
className: "flex flex-row items-center gap-2"
|
|
63
|
+
}, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
64
|
+
size: size,
|
|
65
|
+
disabled: disabled || option.disabled,
|
|
66
|
+
checked: (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.includes(option.id),
|
|
67
|
+
onCheckedChange: function onCheckedChange(checked) {
|
|
68
|
+
var _field$value2;
|
|
69
|
+
var updated = checked ? [].concat(_toConsumableArray(field.value), [option.id]) : (_field$value2 = field.value) === null || _field$value2 === void 0 ? void 0 : _field$value2.filter(function (v) {
|
|
70
|
+
return v !== option.id;
|
|
71
|
+
});
|
|
72
|
+
field.onChange(updated);
|
|
73
|
+
}
|
|
74
|
+
})), /*#__PURE__*/React.createElement(FormLabel, {
|
|
75
|
+
size: size,
|
|
76
|
+
className: "text-sm font-normal"
|
|
77
|
+
}, option.label));
|
|
78
|
+
})), /*#__PURE__*/React.createElement(FormMessage, null));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export { FormCheckboxGroupField };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormComboboxFieldProps } from '@scaleflex/ui-tw/form/form.types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FieldValues, Path } from 'react-hook-form';
|
|
4
|
-
declare function FormComboboxField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ variant, comboboxProps, ...rest }: FormComboboxFieldProps<TFieldValues, TName>): React.JSX.Element;
|
|
4
|
+
declare function FormComboboxField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ variant, showGroupSeparator, comboboxProps, ...rest }: FormComboboxFieldProps<TFieldValues, TName>): React.JSX.Element;
|
|
5
5
|
export { FormComboboxField };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["variant", "comboboxProps"];
|
|
4
|
+
var _excluded = ["variant", "showGroupSeparator", "comboboxProps"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import { ComboboxMultiInline, ComboboxMultiTag, ComboboxSingle } from '@scaleflex/ui-tw/combobox';
|
|
@@ -11,6 +11,8 @@ import React from 'react';
|
|
|
11
11
|
function FormComboboxField(_ref) {
|
|
12
12
|
var _ref$variant = _ref.variant,
|
|
13
13
|
variant = _ref$variant === void 0 ? 'single' : _ref$variant,
|
|
14
|
+
_ref$showGroupSeparat = _ref.showGroupSeparator,
|
|
15
|
+
showGroupSeparator = _ref$showGroupSeparat === void 0 ? false : _ref$showGroupSeparat,
|
|
14
16
|
_ref$comboboxProps = _ref.comboboxProps,
|
|
15
17
|
comboboxProps = _ref$comboboxProps === void 0 ? {} : _ref$comboboxProps,
|
|
16
18
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -25,6 +27,7 @@ function FormComboboxField(_ref) {
|
|
|
25
27
|
placeholder: comboboxProps.placeholder,
|
|
26
28
|
readOnly: readOnly,
|
|
27
29
|
disabled: disabled,
|
|
30
|
+
showGroupSeparator: showGroupSeparator,
|
|
28
31
|
size: args === null || args === void 0 ? void 0 : args.size,
|
|
29
32
|
formItemId: formItemId,
|
|
30
33
|
value: field.value,
|
|
@@ -22,6 +22,7 @@ function FormFieldGroup(_ref) {
|
|
|
22
22
|
return /*#__PURE__*/React.createElement(FormField, {
|
|
23
23
|
control: control,
|
|
24
24
|
name: name,
|
|
25
|
+
disabled: disabled,
|
|
25
26
|
render: function render(_ref2) {
|
|
26
27
|
var field = _ref2.field;
|
|
27
28
|
return /*#__PURE__*/React.createElement(FormItem, {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FormRadioGroupFieldProps } from '@scaleflex/ui-tw/form/form.types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
|
+
declare function FormRadioGroupField<TFieldValues extends FieldValues>({ control, name, label, description, options, className, tooltip, size, disabled, horizontal, horizontalLabelWidth, }: FormRadioGroupFieldProps<TFieldValues>): React.JSX.Element;
|
|
5
|
+
export { FormRadioGroupField };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@scaleflex/ui-tw/form';
|
|
2
|
+
import { labelCheckboxAndRadioSizeOptions } from '@scaleflex/ui-tw/form/form.constants';
|
|
3
|
+
import { RadioGroup, RadioGroupItem } from '@scaleflex/ui-tw/radio-group';
|
|
4
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
5
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
6
|
+
import { cva } from 'class-variance-authority';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
var labelCheckboxAndRadioVariants = cva('', {
|
|
9
|
+
variants: {
|
|
10
|
+
size: labelCheckboxAndRadioSizeOptions
|
|
11
|
+
},
|
|
12
|
+
defaultVariants: {
|
|
13
|
+
size: FormSize.Md
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
function FormRadioGroupField(_ref) {
|
|
17
|
+
var control = _ref.control,
|
|
18
|
+
name = _ref.name,
|
|
19
|
+
label = _ref.label,
|
|
20
|
+
description = _ref.description,
|
|
21
|
+
options = _ref.options,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
tooltip = _ref.tooltip,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
26
|
+
_ref$disabled = _ref.disabled,
|
|
27
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
28
|
+
_ref$horizontal = _ref.horizontal,
|
|
29
|
+
horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
|
|
30
|
+
horizontalLabelWidth = _ref.horizontalLabelWidth;
|
|
31
|
+
return /*#__PURE__*/React.createElement(FormField, {
|
|
32
|
+
control: control,
|
|
33
|
+
name: name,
|
|
34
|
+
disabled: disabled,
|
|
35
|
+
render: function render(_ref2) {
|
|
36
|
+
var field = _ref2.field;
|
|
37
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
38
|
+
className: cn('group gap-6', className),
|
|
39
|
+
"data-disabled": disabled,
|
|
40
|
+
horizontal: horizontal,
|
|
41
|
+
firstColumnWidth: horizontalLabelWidth
|
|
42
|
+
}, (label || description) && /*#__PURE__*/React.createElement("div", null, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
43
|
+
className: cn('cursor-default', labelCheckboxAndRadioVariants({
|
|
44
|
+
size: size
|
|
45
|
+
})),
|
|
46
|
+
size: size,
|
|
47
|
+
tooltip: tooltip
|
|
48
|
+
}, label), description && !horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
49
|
+
size: size
|
|
50
|
+
}, description)), /*#__PURE__*/React.createElement(RadioGroup, {
|
|
51
|
+
value: field.value,
|
|
52
|
+
onValueChange: field.onChange,
|
|
53
|
+
disabled: disabled,
|
|
54
|
+
className: "flex flex-col gap-3"
|
|
55
|
+
}, description && horizontal && /*#__PURE__*/React.createElement(FormDescription, {
|
|
56
|
+
className: labelCheckboxAndRadioVariants({
|
|
57
|
+
size: size
|
|
58
|
+
}),
|
|
59
|
+
size: size
|
|
60
|
+
}, description), options.map(function (option) {
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
key: option.id,
|
|
63
|
+
className: "group flex items-center space-x-2",
|
|
64
|
+
"data-disabled": disabled || option.disabled
|
|
65
|
+
}, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(RadioGroupItem, {
|
|
66
|
+
id: option.id,
|
|
67
|
+
value: option.id,
|
|
68
|
+
size: size,
|
|
69
|
+
disabled: disabled || option.disabled
|
|
70
|
+
})), /*#__PURE__*/React.createElement(FormLabel, {
|
|
71
|
+
htmlFor: option.id,
|
|
72
|
+
size: size,
|
|
73
|
+
className: "text-sm font-normal",
|
|
74
|
+
tooltip: option.tooltip
|
|
75
|
+
}, option.label));
|
|
76
|
+
})), /*#__PURE__*/React.createElement(FormMessage, null));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export { FormRadioGroupField };
|
|
@@ -10,7 +10,7 @@ function FormTextareaField(_ref) {
|
|
|
10
10
|
return /*#__PURE__*/React.createElement(FormFieldGroup, rest, function (field, args) {
|
|
11
11
|
return /*#__PURE__*/React.createElement(Textarea, _extends({
|
|
12
12
|
placeholder: textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.placeholder
|
|
13
|
-
}, args, textareaProps
|
|
13
|
+
}, field, args, textareaProps));
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
export { FormTextareaField };
|
package/form/form.constants.d.ts
CHANGED
|
@@ -22,3 +22,8 @@ export declare const formGroupFieldSizeOptions: {
|
|
|
22
22
|
readonly md: "space-x-2.5";
|
|
23
23
|
readonly lg: "space-x-3";
|
|
24
24
|
};
|
|
25
|
+
export declare const labelCheckboxAndRadioSizeOptions: {
|
|
26
|
+
readonly sm: "text-sm";
|
|
27
|
+
readonly md: "text-base";
|
|
28
|
+
readonly lg: "text-lg";
|
|
29
|
+
};
|
package/form/form.constants.js
CHANGED
|
@@ -11,4 +11,5 @@ 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 formGroupFieldSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'space-x-2'), FormMessageSize.Md, 'space-x-2.5'), FormMessageSize.Lg, 'space-x-3');
|
|
14
|
+
export var formGroupFieldSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormMessageSize.Sm, 'space-x-2'), FormMessageSize.Md, 'space-x-2.5'), FormMessageSize.Lg, 'space-x-3');
|
|
15
|
+
export var labelCheckboxAndRadioSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'text-sm'), FormSize.Md, 'text-base'), FormSize.Lg, 'text-lg');
|
package/form/form.types.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { CheckboxProps } from '@scaleflex/ui-tw/checkbox/checkbox.types';
|
|
2
2
|
import type { ComboboxMultiInlineProps, ComboboxMultiTagProps, ComboboxSingleProps } from '@scaleflex/ui-tw/combobox/combobox.types';
|
|
3
3
|
import type { InputProps } from '@scaleflex/ui-tw/input';
|
|
4
|
+
import type { RadioGroupItemProps } from '@scaleflex/ui-tw/radio-group/radio-group.types';
|
|
4
5
|
import type { SelectProps } from '@scaleflex/ui-tw/select/select.types';
|
|
5
6
|
import type { SwitchProps } from '@scaleflex/ui-tw/switch/switch.types';
|
|
6
7
|
import type { TextareaProps } from '@scaleflex/ui-tw/textarea';
|
|
7
8
|
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
8
9
|
import type { Values } from '@scaleflex/ui-tw/types/values';
|
|
9
10
|
import { ReactElement, ReactNode } from 'react';
|
|
10
|
-
import { type ControllerRenderProps, type FieldPath, FieldValues, Path, UseControllerProps } from 'react-hook-form';
|
|
11
|
+
import { Control, type ControllerRenderProps, type FieldPath, type FieldValues, type Path, type UseControllerProps } from 'react-hook-form';
|
|
11
12
|
import { FormMessageSize, SwitchLayout } from './form.constants';
|
|
12
13
|
export type FormMessageSizeType = Values<typeof FormMessageSize>;
|
|
13
14
|
export type SwitchLayoutType = Values<typeof SwitchLayout>;
|
|
@@ -86,4 +87,33 @@ export interface FormSelectInnerProps<TFieldValues extends FieldValues, TName ex
|
|
|
86
87
|
disabled?: boolean;
|
|
87
88
|
className?: string;
|
|
88
89
|
}
|
|
90
|
+
export type CheckboxOption = {
|
|
91
|
+
label: string;
|
|
92
|
+
id: CheckboxProps['id'];
|
|
93
|
+
disabled?: CheckboxProps['disabled'];
|
|
94
|
+
};
|
|
95
|
+
export type RadioOption = {
|
|
96
|
+
label: string;
|
|
97
|
+
id: string;
|
|
98
|
+
disabled?: RadioGroupItemProps['disabled'];
|
|
99
|
+
tooltip?: string;
|
|
100
|
+
};
|
|
101
|
+
interface BaseFormGroupFieldProps<TFieldValues extends FieldValues> {
|
|
102
|
+
control: Control<TFieldValues>;
|
|
103
|
+
name: Path<TFieldValues>;
|
|
104
|
+
label?: ReactElement | string;
|
|
105
|
+
tooltip?: ReactElement | string;
|
|
106
|
+
description?: ReactElement | string;
|
|
107
|
+
className?: string;
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
size?: FormSizeType;
|
|
110
|
+
horizontal?: boolean;
|
|
111
|
+
horizontalLabelWidth?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface FormCheckboxGroupFieldProps<TFieldValues extends FieldValues> extends BaseFormGroupFieldProps<TFieldValues> {
|
|
114
|
+
options: CheckboxOption[];
|
|
115
|
+
}
|
|
116
|
+
export interface FormRadioGroupFieldProps<TFieldValues extends FieldValues> extends BaseFormGroupFieldProps<TFieldValues> {
|
|
117
|
+
options: RadioOption[];
|
|
118
|
+
}
|
|
89
119
|
export {};
|
package/form/index.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ 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
11
|
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
12
|
+
export { FormCheckboxGroupField } from './components/form-checkbox-group-field.component';
|
|
13
|
+
export { FormRadioGroupField } from './components/form-radio-group-field.component';
|
package/form/index.js
CHANGED
|
@@ -7,4 +7,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
9
|
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
10
|
-
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
10
|
+
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
11
|
+
export { FormCheckboxGroupField } from './components/form-checkbox-group-field.component';
|
|
12
|
+
export { FormRadioGroupField } from './components/form-radio-group-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.37",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -16,18 +16,21 @@
|
|
|
16
16
|
"@radix-ui/react-checkbox": "^1.3.2",
|
|
17
17
|
"@radix-ui/react-label": "^2.1.6",
|
|
18
18
|
"@radix-ui/react-popover": "^1.0.2",
|
|
19
|
+
"@radix-ui/react-radio-group": "^1.3.7",
|
|
19
20
|
"@radix-ui/react-select": "^2.2.4",
|
|
20
21
|
"@radix-ui/react-separator": "^1.1.6",
|
|
21
22
|
"@radix-ui/react-slot": "^1.1.2",
|
|
22
23
|
"@radix-ui/react-switch": "^1.0.1",
|
|
23
24
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
24
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
25
|
+
"@scaleflex/icons-tw": "^0.0.37",
|
|
25
26
|
"@types/lodash.merge": "^4.6.9",
|
|
26
27
|
"class-variance-authority": "^0.7.1",
|
|
27
28
|
"cmdk": "^1.1.1",
|
|
29
|
+
"date-fns": "^4.1.0",
|
|
28
30
|
"lodash.merge": "^4.6.2",
|
|
29
31
|
"lucide-react": "^0.487.0",
|
|
30
32
|
"prop-types": "^15.7.2",
|
|
33
|
+
"react-day-picker": "^9.7.0",
|
|
31
34
|
"sonner": "^2.0.3",
|
|
32
35
|
"tailwind-scrollbar": "^4.0.2",
|
|
33
36
|
"tw-animate-css": "^1.2.5"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RadioGroup, RadioGroupItem } from './radio-group.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RadioGroup, RadioGroupItem } from './radio-group.component';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RadioGroupItemProps, RadioGroupProps } from '@scaleflex/ui-tw/radio-group/radio-group.types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare function RadioGroup({ className, ...props }: RadioGroupProps): React.JSX.Element;
|
|
4
|
+
declare function RadioGroupItem({ className, size, ...props }: RadioGroupItemProps): React.JSX.Element;
|
|
5
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["className"],
|
|
4
|
+
_excluded2 = ["className", "size"];
|
|
5
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
6
|
+
import { radioGroupItemIndicatorSizeOptions, radioGroupItemSizeOptions } from '@scaleflex/ui-tw/radio-group/radio-group.constants';
|
|
7
|
+
import { ariaInvalidClassNames, focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
8
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
9
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
10
|
+
import { cva } from 'class-variance-authority';
|
|
11
|
+
import { CircleIcon } from 'lucide-react';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
var radioGroupItemVariants = cva('', {
|
|
14
|
+
variants: {
|
|
15
|
+
size: radioGroupItemSizeOptions
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
size: FormSize.Md
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var radioGroupItemIndicatorVariants = cva('', {
|
|
22
|
+
variants: {
|
|
23
|
+
size: radioGroupItemIndicatorSizeOptions
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
size: FormSize.Md
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
function RadioGroup(_ref) {
|
|
30
|
+
var className = _ref.className,
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
return /*#__PURE__*/React.createElement(RadioGroupPrimitive.Root, _extends({
|
|
33
|
+
"data-slot": "radio-group",
|
|
34
|
+
className: cn('grid gap-3', className)
|
|
35
|
+
}, props));
|
|
36
|
+
}
|
|
37
|
+
function RadioGroupItem(_ref2) {
|
|
38
|
+
var className = _ref2.className,
|
|
39
|
+
size = _ref2.size,
|
|
40
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
41
|
+
return /*#__PURE__*/React.createElement(RadioGroupPrimitive.Item, _extends({
|
|
42
|
+
"data-slot": "radio-group-item",
|
|
43
|
+
className: cn('border-input text-primary aspect-square shrink-0 cursor-pointer rounded-full border shadow-xs transition-[color,box-shadow]', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', ariaInvalidClassNames, focusRingClassNames, radioGroupItemVariants({
|
|
44
|
+
size: size
|
|
45
|
+
}), className)
|
|
46
|
+
}, props), /*#__PURE__*/React.createElement(RadioGroupPrimitive.Indicator, {
|
|
47
|
+
"data-slot": "radio-group-indicator",
|
|
48
|
+
className: "relative flex items-center justify-center"
|
|
49
|
+
}, /*#__PURE__*/React.createElement(CircleIcon, {
|
|
50
|
+
className: cn('fill-primary absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2', radioGroupItemIndicatorVariants({
|
|
51
|
+
size: size
|
|
52
|
+
}))
|
|
53
|
+
})));
|
|
54
|
+
}
|
|
55
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const radioGroupItemSizeOptions: {
|
|
2
|
+
readonly sm: "size-4";
|
|
3
|
+
readonly md: "size-5";
|
|
4
|
+
readonly lg: "size-6";
|
|
5
|
+
};
|
|
6
|
+
export declare const radioGroupItemIndicatorSizeOptions: {
|
|
7
|
+
readonly sm: "size-2";
|
|
8
|
+
readonly md: "size-3";
|
|
9
|
+
readonly lg: "size-4";
|
|
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 radioGroupItemSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-4'), FormSize.Md, 'size-5'), FormSize.Lg, 'size-6');
|
|
4
|
+
export var radioGroupItemIndicatorSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-2'), FormSize.Md, 'size-3'), FormSize.Lg, 'size-4');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
2
|
+
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
export interface RadioGroupProps extends ComponentProps<typeof RadioGroupPrimitive.Root> {
|
|
5
|
+
}
|
|
6
|
+
export interface RadioGroupItemProps extends ComponentProps<typeof RadioGroupPrimitive.Item> {
|
|
7
|
+
size?: FormSizeType;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|