@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,57 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { Checkbox } from '@scaleflex/ui-tw/checkbox';
|
|
3
|
+
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
4
|
+
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../form.component';
|
|
8
|
+
import { formGroupFieldSizeOptions } from '../form.constants';
|
|
9
|
+
var formCheckboxFieldVariants = cva('', {
|
|
10
|
+
variants: {
|
|
11
|
+
size: formGroupFieldSizeOptions
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
size: FormSize.Md
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
function FormCheckboxField(_ref) {
|
|
18
|
+
var control = _ref.control,
|
|
19
|
+
name = _ref.name,
|
|
20
|
+
label = _ref.label,
|
|
21
|
+
description = _ref.description,
|
|
22
|
+
disabled = _ref.disabled,
|
|
23
|
+
tooltip = _ref.tooltip,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
26
|
+
checkboxProps = _ref.checkboxProps;
|
|
27
|
+
return /*#__PURE__*/React.createElement(FormField, {
|
|
28
|
+
control: control,
|
|
29
|
+
name: name,
|
|
30
|
+
render: function render(_ref2) {
|
|
31
|
+
var _checkboxProps$id;
|
|
32
|
+
var field = _ref2.field;
|
|
33
|
+
return /*#__PURE__*/React.createElement(FormItem, {
|
|
34
|
+
className: "group",
|
|
35
|
+
"data-disabled": disabled
|
|
36
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: cn('flex items-center', formCheckboxFieldVariants({
|
|
38
|
+
size: size
|
|
39
|
+
}))
|
|
40
|
+
}, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Checkbox, _extends({
|
|
41
|
+
id: field.name,
|
|
42
|
+
checked: field.value,
|
|
43
|
+
onCheckedChange: field.onChange,
|
|
44
|
+
disabled: disabled,
|
|
45
|
+
size: size
|
|
46
|
+
}, checkboxProps))), /*#__PURE__*/React.createElement(FormLabel, {
|
|
47
|
+
className: "text-foreground",
|
|
48
|
+
htmlFor: (_checkboxProps$id = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.id) !== null && _checkboxProps$id !== void 0 ? _checkboxProps$id : field.name,
|
|
49
|
+
tooltip: tooltip,
|
|
50
|
+
size: size
|
|
51
|
+
}, label)), description && /*#__PURE__*/React.createElement(FormDescription, {
|
|
52
|
+
size: size
|
|
53
|
+
}, description), /*#__PURE__*/React.createElement(FormMessage, null));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { FormCheckboxField };
|
|
@@ -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 };
|
|
@@ -5,10 +5,10 @@ import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
|
5
5
|
import { cva } from 'class-variance-authority';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../form.component';
|
|
8
|
-
import { SwitchLayout,
|
|
8
|
+
import { SwitchLayout, formGroupFieldSizeOptions } from '../form.constants';
|
|
9
9
|
var formSwitchFieldVariants = cva('', {
|
|
10
10
|
variants: {
|
|
11
|
-
size:
|
|
11
|
+
size: formGroupFieldSizeOptions
|
|
12
12
|
},
|
|
13
13
|
defaultVariants: {
|
|
14
14
|
size: FormSize.Md
|
|
@@ -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
|
@@ -17,8 +17,13 @@ export declare const formMessageSizeOptions: {
|
|
|
17
17
|
readonly md: "text-xs";
|
|
18
18
|
readonly lg: "text-sm";
|
|
19
19
|
};
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const formGroupFieldSizeOptions: {
|
|
21
21
|
readonly sm: "space-x-2";
|
|
22
22
|
readonly md: "space-x-2.5";
|
|
23
23
|
readonly lg: "space-x-3";
|
|
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
|
|
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,12 +1,14 @@
|
|
|
1
|
+
import { CheckboxProps } from '@scaleflex/ui-tw/checkbox/checkbox.types';
|
|
1
2
|
import type { ComboboxMultiInlineProps, ComboboxMultiTagProps, ComboboxSingleProps } from '@scaleflex/ui-tw/combobox/combobox.types';
|
|
2
3
|
import type { InputProps } from '@scaleflex/ui-tw/input';
|
|
4
|
+
import type { RadioGroupItemProps } from '@scaleflex/ui-tw/radio-group/radio-group.types';
|
|
3
5
|
import type { SelectProps } from '@scaleflex/ui-tw/select/select.types';
|
|
4
6
|
import type { SwitchProps } from '@scaleflex/ui-tw/switch/switch.types';
|
|
5
7
|
import type { TextareaProps } from '@scaleflex/ui-tw/textarea';
|
|
6
8
|
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
7
9
|
import type { Values } from '@scaleflex/ui-tw/types/values';
|
|
8
10
|
import { ReactElement, ReactNode } from 'react';
|
|
9
|
-
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';
|
|
10
12
|
import { FormMessageSize, SwitchLayout } from './form.constants';
|
|
11
13
|
export type FormMessageSizeType = Values<typeof FormMessageSize>;
|
|
12
14
|
export type SwitchLayoutType = Values<typeof SwitchLayout>;
|
|
@@ -22,26 +24,27 @@ export interface FormFieldArgs {
|
|
|
22
24
|
readOnly?: boolean;
|
|
23
25
|
disabled?: boolean;
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
|
|
27
|
+
interface FormBaseFieldProps {
|
|
27
28
|
label?: ReactElement | string;
|
|
29
|
+
size?: FormSizeType;
|
|
28
30
|
description?: ReactElement | string;
|
|
31
|
+
disabled?: boolean;
|
|
29
32
|
tooltip?: ReactElement | string;
|
|
30
|
-
|
|
33
|
+
}
|
|
34
|
+
export interface FormFieldGroupProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName>, FormBaseFieldProps {
|
|
35
|
+
children: (field: ControllerRenderProps<TFieldValues, TName>, args?: FormFieldArgs) => ReactNode;
|
|
31
36
|
readOnly?: boolean;
|
|
32
37
|
highlight?: boolean;
|
|
33
38
|
horizontal?: boolean;
|
|
34
39
|
horizontalLabelWidth?: string;
|
|
35
40
|
}
|
|
36
|
-
export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName
|
|
37
|
-
label: ReactElement | string;
|
|
38
|
-
size?: FormSizeType;
|
|
39
|
-
description?: ReactElement | string;
|
|
40
|
-
disabled?: boolean;
|
|
41
|
+
export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName>, FormBaseFieldProps {
|
|
41
42
|
layout?: SwitchLayoutType;
|
|
42
|
-
tooltip?: ReactElement | string;
|
|
43
43
|
switchProps?: SwitchProps;
|
|
44
44
|
}
|
|
45
|
+
export interface FormCheckboxFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> extends UseControllerProps<TFieldValues, TName>, FormBaseFieldProps {
|
|
46
|
+
checkboxProps?: CheckboxProps;
|
|
47
|
+
}
|
|
45
48
|
export type FormInputFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
|
|
46
49
|
inputProps?: InputProps;
|
|
47
50
|
};
|
|
@@ -84,3 +87,33 @@ export interface FormSelectInnerProps<TFieldValues extends FieldValues, TName ex
|
|
|
84
87
|
disabled?: boolean;
|
|
85
88
|
className?: string;
|
|
86
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
|
+
}
|
|
119
|
+
export {};
|
package/form/index.d.ts
CHANGED
|
@@ -8,3 +8,6 @@ export { FormTextareaField } from './components/form-textarea-field.component';
|
|
|
8
8
|
export { FormSwitchField } from './components/form-switch-field.component';
|
|
9
9
|
export { FormSelectField } from './components/form-select-field.component';
|
|
10
10
|
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
11
|
+
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
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
|
@@ -6,4 +6,7 @@ export { FormPasswordField } from './components/form-password-field.component';
|
|
|
6
6
|
export { FormTextareaField } from './components/form-textarea-field.component';
|
|
7
7
|
export { FormSwitchField } from './components/form-switch-field.component';
|
|
8
8
|
export { FormSelectField } from './components/form-select-field.component';
|
|
9
|
-
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
9
|
+
export { FormComboboxField } from './components/form-combobox-field.component';
|
|
10
|
+
export { FormCheckboxField } from './components/form-checkbox-field.component';
|
|
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.36",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -13,20 +13,24 @@
|
|
|
13
13
|
"main": "lib/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@popperjs/core": "^2.6.0",
|
|
16
|
+
"@radix-ui/react-checkbox": "^1.3.2",
|
|
16
17
|
"@radix-ui/react-label": "^2.1.6",
|
|
17
18
|
"@radix-ui/react-popover": "^1.0.2",
|
|
19
|
+
"@radix-ui/react-radio-group": "^1.3.7",
|
|
18
20
|
"@radix-ui/react-select": "^2.2.4",
|
|
19
21
|
"@radix-ui/react-separator": "^1.1.6",
|
|
20
22
|
"@radix-ui/react-slot": "^1.1.2",
|
|
21
23
|
"@radix-ui/react-switch": "^1.0.1",
|
|
22
24
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
23
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
25
|
+
"@scaleflex/icons-tw": "^0.0.36",
|
|
24
26
|
"@types/lodash.merge": "^4.6.9",
|
|
25
27
|
"class-variance-authority": "^0.7.1",
|
|
26
28
|
"cmdk": "^1.1.1",
|
|
29
|
+
"date-fns": "^4.1.0",
|
|
27
30
|
"lodash.merge": "^4.6.2",
|
|
28
31
|
"lucide-react": "^0.487.0",
|
|
29
32
|
"prop-types": "^15.7.2",
|
|
33
|
+
"react-day-picker": "^9.7.0",
|
|
30
34
|
"sonner": "^2.0.3",
|
|
31
35
|
"tailwind-scrollbar": "^4.0.2",
|
|
32
36
|
"tw-animate-css": "^1.2.5"
|
package/pill/pill.utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
2
|
-
export declare const getPillCrossIconClassName: (size?: FormSizeType | null) => "size-
|
|
2
|
+
export declare const getPillCrossIconClassName: (size?: FormSizeType | null) => "size-4" | "size-5" | "size-3";
|
|
@@ -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 {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const focusRingClassNames = "focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none";
|
|
2
2
|
export declare const selectionHighlightClassNames = "selection:bg-primary selection:text-primary-foreground";
|
|
3
3
|
export declare const readOnlyClassNames = "read-only:bg-secondary read-only:text-foreground read-only:cursor-default";
|
|
4
|
+
export declare const ariaInvalidClassNames = "aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive";
|
|
4
5
|
export declare const getBaseInputClasses: () => string[];
|
package/styles/shared-classes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var focusRingClassNames = 'focus-visible:ring-ring ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none';
|
|
2
2
|
export var selectionHighlightClassNames = 'selection:bg-primary selection:text-primary-foreground';
|
|
3
3
|
export var readOnlyClassNames = 'read-only:bg-secondary read-only:text-foreground read-only:cursor-default';
|
|
4
|
+
export var ariaInvalidClassNames = 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive hover:aria-invalid:border-destructive/60 focus-visible:aria-invalid:border-destructive';
|
|
4
5
|
export var getBaseInputClasses = function getBaseInputClasses() {
|
|
5
|
-
return ['rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'border-input text-foreground bg-background', 'placeholder:text-muted-foreground/80 hover:border-secondary-foreground/50', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:border-secondary-foreground/50', '
|
|
6
|
+
return ['rounded-md border shadow-xs transition-[color,box-shadow] outline-none', 'border-input text-foreground bg-background', 'placeholder:text-muted-foreground/80 hover:border-secondary-foreground/50', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'focus-visible:border-secondary-foreground/50', 'focus-visible:group-data-[highlight=true]:border-warning group-data-[highlight=true]:border-warning hover:group-data-[highlight=true]:border-warning/60 group-data-[highlight=true]:focus-visible:ring-warning/20', ariaInvalidClassNames, focusRingClassNames];
|
|
6
7
|
};
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["className", "size"];
|
|
4
4
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
-
import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
5
|
+
import { ariaInvalidClassNames, focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
6
6
|
import { FormSize } from '@scaleflex/ui-tw/types/form-size';
|
|
7
7
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
@@ -31,7 +31,7 @@ function Switch(_ref) {
|
|
|
31
31
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
32
|
return /*#__PURE__*/React.createElement(SwitchPrimitive.Root, _extends({
|
|
33
33
|
"data-slot": "switch",
|
|
34
|
-
className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-all outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input', focusRingClassNames, switchVariants({
|
|
34
|
+
className: cn('peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-all outline-none', 'hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50', 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input', focusRingClassNames, ariaInvalidClassNames, switchVariants({
|
|
35
35
|
size: size
|
|
36
36
|
}), className)
|
|
37
37
|
}, props), /*#__PURE__*/React.createElement(SwitchPrimitive.Thumb, {
|
package/switch/switch.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
2
|
-
import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
2
|
+
import type { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
4
|
export interface SwitchProps extends ComponentProps<typeof SwitchPrimitive.Root> {
|
|
5
5
|
size?: FormSizeType;
|