@scaleflex/ui-tw 0.0.34 → 0.0.36
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.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 +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/form/components/form-checkbox-field.component.d.ts +5 -0
- package/form/components/form-checkbox-field.component.js +57 -0
- 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-switch-field.component.js +2 -2
- package/form/components/form-textarea-field.component.js +1 -1
- package/form/form.constants.d.ts +6 -1
- package/form/form.constants.js +2 -1
- package/form/form.types.d.ts +43 -10
- package/form/index.d.ts +3 -0
- package/form/index.js +4 -1
- package/package.json +6 -2
- package/pill/pill.utils.d.ts +1 -1
- 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
- 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,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';
|
|
@@ -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-6";
|
|
5
|
+
};
|
|
6
|
+
export declare const checkboxIndicatorSizeOptions: {
|
|
7
|
+
readonly sm: "size-3.5";
|
|
8
|
+
readonly md: "size-4.5";
|
|
9
|
+
readonly lg: "size-5.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-6');
|
|
4
|
+
export var checkboxIndicatorSizeOptions = _defineProperty(_defineProperty(_defineProperty({}, FormSize.Sm, 'size-3.5'), FormSize.Md, 'size-4.5'), FormSize.Lg, 'size-5.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, 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';
|
|
@@ -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 };
|