@react-fabric/form 1.0.0-beta.5 → 1.0.0-beta.7
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/dist/cjs/input/RadioGroup.js +4 -2
- package/dist/cjs/input/Switch.js +25 -4
- package/dist/cjs/utils/getColor.js +6 -0
- package/dist/esm/input/RadioGroup.js +4 -2
- package/dist/esm/input/Switch.js +27 -6
- package/dist/esm/utils/getColor.js +6 -1
- package/dist/types/input/ArrayInput.d.ts +12 -0
- package/dist/types/input/RadioGroup.d.ts +18 -2
- package/dist/types/input/Switch.d.ts +7 -3
- package/dist/types/types/index.d.ts +2 -2
- package/package.json +4 -4
- package/src/input/ArrayInput.tsx +13 -0
- package/src/input/RadioGroup.tsx +24 -2
- package/src/input/Switch.tsx +40 -6
- package/src/types/index.ts +5 -2
|
@@ -6,13 +6,14 @@ var react = require('react');
|
|
|
6
6
|
var FieldWrapper = require('../internal/FieldWrapper.js');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
|
-
var _excluded = ["children", "name", "className", "onChange"];
|
|
9
|
+
var _excluded = ["children", "name", "className", "optionWidth", "onChange"];
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
var RadioGroup = function RadioGroup(_ref) {
|
|
13
13
|
var children = _ref.children,
|
|
14
14
|
name = _ref.name,
|
|
15
15
|
className = _ref.className,
|
|
16
|
+
optionWidth = _ref.optionWidth,
|
|
16
17
|
onChange = _ref.onChange,
|
|
17
18
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
18
19
|
return /*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -21,7 +22,8 @@ var RadioGroup = function RadioGroup(_ref) {
|
|
|
21
22
|
children: react.Children.map(children, function (child) {
|
|
22
23
|
return /*#__PURE__*/react.cloneElement(child, {
|
|
23
24
|
name: name,
|
|
24
|
-
onChange: onChange
|
|
25
|
+
onChange: onChange,
|
|
26
|
+
width: optionWidth
|
|
25
27
|
});
|
|
26
28
|
})
|
|
27
29
|
})
|
package/dist/cjs/input/Switch.js
CHANGED
|
@@ -10,7 +10,7 @@ require('@react-fabric/utilities');
|
|
|
10
10
|
var getColor = require('../utils/getColor.js');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
12
|
|
|
13
|
-
var _excluded = ["ref", "label", "checked", "invalid", "disabled", "error", "width", "color", "name", "defaultColor", "onChange"];
|
|
13
|
+
var _excluded = ["ref", "label", "checked", "invalid", "disabled", "error", "width", "color", "name", "onLabel", "offLabel", "onLabelColor", "offLabelColor", "defaultColor", "onChange"];
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
var Switch = function Switch(_ref) {
|
|
@@ -23,7 +23,11 @@ var Switch = function Switch(_ref) {
|
|
|
23
23
|
width = _ref.width,
|
|
24
24
|
color = _ref.color;
|
|
25
25
|
_ref.name;
|
|
26
|
-
var
|
|
26
|
+
var onLabel = _ref.onLabel,
|
|
27
|
+
offLabel = _ref.offLabel,
|
|
28
|
+
onLabelColor = _ref.onLabelColor,
|
|
29
|
+
offLabelColor = _ref.offLabelColor,
|
|
30
|
+
defaultColor = _ref.defaultColor,
|
|
27
31
|
onChange = _ref.onChange,
|
|
28
32
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
33
|
var _useState = react.useState(false),
|
|
@@ -45,7 +49,7 @@ var Switch = function Switch(_ref) {
|
|
|
45
49
|
width: width
|
|
46
50
|
},
|
|
47
51
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
48
|
-
className: classNames(actualValue && getColor.getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getColor.getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative
|
|
52
|
+
className: classNames(actualValue && getColor.getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getColor.getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative grid grid-cols-2 items-center h-6 min-w-10 cursor-pointer rounded-full p-1 transition-colors duration-200 ease-in-out"),
|
|
49
53
|
style: {
|
|
50
54
|
backgroundColor: actualValue ? getColor.getColor(color) : getColor.getColor(defaultColor)
|
|
51
55
|
},
|
|
@@ -64,7 +68,24 @@ var Switch = function Switch(_ref) {
|
|
|
64
68
|
onChange: handleChange
|
|
65
69
|
}, rest)), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
66
70
|
"aria-hidden": "true",
|
|
67
|
-
className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-
|
|
71
|
+
className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-[100%]" : "translate-x-0", "pointer-events-none inline-block h-4 start-1 absolute rounded-full bg-white ring-0 transition duration-200 ease-in-out"),
|
|
72
|
+
style: {
|
|
73
|
+
width: "calc(50% - 0.25rem)"
|
|
74
|
+
}
|
|
75
|
+
}), (!!onLabel || !!offLabel) && /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
76
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
77
|
+
className: "whitespace-nowrap text-xs px-1 ".concat(getColor.getColorClass(onLabelColor !== null && onLabelColor !== void 0 ? onLabelColor : "white")),
|
|
78
|
+
style: {
|
|
79
|
+
color: getColor.getColor(onLabelColor)
|
|
80
|
+
},
|
|
81
|
+
children: onLabel !== null && onLabel !== void 0 ? onLabel : " "
|
|
82
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
83
|
+
className: "whitespace-nowrap text-xs px-1 ".concat(getColor.getColorClass(offLabelColor !== null && offLabelColor !== void 0 ? offLabelColor : "base")),
|
|
84
|
+
style: {
|
|
85
|
+
color: getColor.getColor(offLabelColor)
|
|
86
|
+
},
|
|
87
|
+
children: offLabel !== null && offLabel !== void 0 ? offLabel : " "
|
|
88
|
+
})]
|
|
68
89
|
})]
|
|
69
90
|
}), /*#__PURE__*/jsxRuntime.jsx(ErrorIcon.ErrorIcon, {
|
|
70
91
|
invalid: invalid,
|
|
@@ -35,6 +35,12 @@ var getBgClass = function getBgClass(bg) {
|
|
|
35
35
|
return "bg-".concat(bg);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var getColorClass = function getColorClass(color) {
|
|
39
|
+
if (color && !utilities.isColor(color)) {
|
|
40
|
+
return "text-".concat(color);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
38
43
|
|
|
39
44
|
exports.getBgClass = getBgClass;
|
|
40
45
|
exports.getColor = getColor;
|
|
46
|
+
exports.getColorClass = getColorClass;
|
|
@@ -6,13 +6,14 @@ import { Children, cloneElement } from 'react';
|
|
|
6
6
|
import { FieldWrapper } from '../internal/FieldWrapper.js';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
|
-
var _excluded = ["children", "name", "className", "onChange"];
|
|
9
|
+
var _excluded = ["children", "name", "className", "optionWidth", "onChange"];
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
var RadioGroup = function RadioGroup(_ref) {
|
|
13
13
|
var children = _ref.children,
|
|
14
14
|
name = _ref.name,
|
|
15
15
|
className = _ref.className,
|
|
16
|
+
optionWidth = _ref.optionWidth,
|
|
16
17
|
onChange = _ref.onChange,
|
|
17
18
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
18
19
|
return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -21,7 +22,8 @@ var RadioGroup = function RadioGroup(_ref) {
|
|
|
21
22
|
children: Children.map(children, function (child) {
|
|
22
23
|
return /*#__PURE__*/cloneElement(child, {
|
|
23
24
|
name: name,
|
|
24
|
-
onChange: onChange
|
|
25
|
+
onChange: onChange,
|
|
26
|
+
width: optionWidth
|
|
25
27
|
});
|
|
26
28
|
})
|
|
27
29
|
})
|
package/dist/esm/input/Switch.js
CHANGED
|
@@ -4,13 +4,13 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
4
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
5
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import { useState, useDeferredValue, useEffect, useCallback } from 'react';
|
|
7
|
+
import { useState, useDeferredValue, useEffect, useCallback, Fragment } from 'react';
|
|
8
8
|
import { ErrorIcon } from '../internal/ErrorIcon.js';
|
|
9
9
|
import '@react-fabric/utilities';
|
|
10
|
-
import { getBgClass, getColor } from '../utils/getColor.js';
|
|
10
|
+
import { getBgClass, getColor, getColorClass } from '../utils/getColor.js';
|
|
11
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
12
|
|
|
13
|
-
var _excluded = ["ref", "label", "checked", "invalid", "disabled", "error", "width", "color", "name", "defaultColor", "onChange"];
|
|
13
|
+
var _excluded = ["ref", "label", "checked", "invalid", "disabled", "error", "width", "color", "name", "onLabel", "offLabel", "onLabelColor", "offLabelColor", "defaultColor", "onChange"];
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
var Switch = function Switch(_ref) {
|
|
@@ -23,7 +23,11 @@ var Switch = function Switch(_ref) {
|
|
|
23
23
|
width = _ref.width,
|
|
24
24
|
color = _ref.color;
|
|
25
25
|
_ref.name;
|
|
26
|
-
var
|
|
26
|
+
var onLabel = _ref.onLabel,
|
|
27
|
+
offLabel = _ref.offLabel,
|
|
28
|
+
onLabelColor = _ref.onLabelColor,
|
|
29
|
+
offLabelColor = _ref.offLabelColor,
|
|
30
|
+
defaultColor = _ref.defaultColor,
|
|
27
31
|
onChange = _ref.onChange,
|
|
28
32
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
33
|
var _useState = useState(false),
|
|
@@ -45,7 +49,7 @@ var Switch = function Switch(_ref) {
|
|
|
45
49
|
width: width
|
|
46
50
|
},
|
|
47
51
|
children: [/*#__PURE__*/jsxs("div", {
|
|
48
|
-
className: classNames(actualValue && getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative
|
|
52
|
+
className: classNames(actualValue && getBgClass(color ? "".concat(color, "-500") : "primary-500"), !actualValue && (defaultColor ? getBgClass("".concat(defaultColor, "-500")) : "bg-tint-200"), "relative grid grid-cols-2 items-center h-6 min-w-10 cursor-pointer rounded-full p-1 transition-colors duration-200 ease-in-out"),
|
|
49
53
|
style: {
|
|
50
54
|
backgroundColor: actualValue ? getColor(color) : getColor(defaultColor)
|
|
51
55
|
},
|
|
@@ -64,7 +68,24 @@ var Switch = function Switch(_ref) {
|
|
|
64
68
|
onChange: handleChange
|
|
65
69
|
}, rest)), /*#__PURE__*/jsx("span", {
|
|
66
70
|
"aria-hidden": "true",
|
|
67
|
-
className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-
|
|
71
|
+
className: classNames(!disabled && "shadow-sm", actualValue ? "translate-x-[100%]" : "translate-x-0", "pointer-events-none inline-block h-4 start-1 absolute rounded-full bg-white ring-0 transition duration-200 ease-in-out"),
|
|
72
|
+
style: {
|
|
73
|
+
width: "calc(50% - 0.25rem)"
|
|
74
|
+
}
|
|
75
|
+
}), (!!onLabel || !!offLabel) && /*#__PURE__*/jsxs(Fragment, {
|
|
76
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
77
|
+
className: "whitespace-nowrap text-xs px-1 ".concat(getColorClass(onLabelColor !== null && onLabelColor !== void 0 ? onLabelColor : "white")),
|
|
78
|
+
style: {
|
|
79
|
+
color: getColor(onLabelColor)
|
|
80
|
+
},
|
|
81
|
+
children: onLabel !== null && onLabel !== void 0 ? onLabel : " "
|
|
82
|
+
}), /*#__PURE__*/jsx("span", {
|
|
83
|
+
className: "whitespace-nowrap text-xs px-1 ".concat(getColorClass(offLabelColor !== null && offLabelColor !== void 0 ? offLabelColor : "base")),
|
|
84
|
+
style: {
|
|
85
|
+
color: getColor(offLabelColor)
|
|
86
|
+
},
|
|
87
|
+
children: offLabel !== null && offLabel !== void 0 ? offLabel : " "
|
|
88
|
+
})]
|
|
68
89
|
})]
|
|
69
90
|
}), /*#__PURE__*/jsx(ErrorIcon, {
|
|
70
91
|
invalid: invalid,
|
|
@@ -35,5 +35,10 @@ var getBgClass = function getBgClass(bg) {
|
|
|
35
35
|
return "bg-".concat(bg);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var getColorClass = function getColorClass(color) {
|
|
39
|
+
if (color && !isColor(color)) {
|
|
40
|
+
return "text-".concat(color);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
38
43
|
|
|
39
|
-
export { getBgClass, getColor };
|
|
44
|
+
export { getBgClass, getColor, getColorClass };
|
|
@@ -60,5 +60,17 @@ export interface ArrayInputProps {
|
|
|
60
60
|
* Add item
|
|
61
61
|
*/
|
|
62
62
|
onAdd?: () => AnyObject;
|
|
63
|
+
/**
|
|
64
|
+
* field width
|
|
65
|
+
*/
|
|
66
|
+
width?: number | string;
|
|
67
|
+
/**
|
|
68
|
+
* inline label and input
|
|
69
|
+
*/
|
|
70
|
+
inline?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* label width for inline
|
|
73
|
+
*/
|
|
74
|
+
labelWidth?: string;
|
|
63
75
|
}
|
|
64
76
|
export declare const ArrayInput: ({ name, children, addLabel, fixedList, focusName, onAdd, arrayRef, enableSorting, disabled, readOnly, minItems, ...rest }: ArrayInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type
|
|
2
|
+
import { type ChildrenProp, type CssProp } from "@react-fabric/core/dist/types/types";
|
|
3
3
|
import { type Radio } from "./Radio";
|
|
4
4
|
export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
5
5
|
/**
|
|
@@ -14,6 +14,22 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
14
14
|
* field info
|
|
15
15
|
*/
|
|
16
16
|
info?: string;
|
|
17
|
+
/**
|
|
18
|
+
* field width
|
|
19
|
+
*/
|
|
20
|
+
width?: number | string;
|
|
21
|
+
/**
|
|
22
|
+
* inline label and input
|
|
23
|
+
*/
|
|
24
|
+
inline?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* label width for inline
|
|
27
|
+
*/
|
|
28
|
+
labelWidth?: string;
|
|
29
|
+
/**
|
|
30
|
+
* label width for inline
|
|
31
|
+
*/
|
|
32
|
+
optionWidth?: string;
|
|
17
33
|
/**
|
|
18
34
|
* field name
|
|
19
35
|
*/
|
|
@@ -27,4 +43,4 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
27
43
|
*/
|
|
28
44
|
onChange?: (value: AnyObject) => void;
|
|
29
45
|
}
|
|
30
|
-
export declare const RadioGroup: ({ children, name, className, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const RadioGroup: ({ children, name, className, optionWidth, onChange, ...rest }: RadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -32,11 +32,15 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
|
32
32
|
/**
|
|
33
33
|
* cutom Switch icon
|
|
34
34
|
*/
|
|
35
|
-
color?: ColorType;
|
|
35
|
+
color?: string | ColorType;
|
|
36
36
|
/**
|
|
37
37
|
* cutom Switch icon
|
|
38
38
|
*/
|
|
39
|
-
defaultColor?: ColorType;
|
|
39
|
+
defaultColor?: string | ColorType;
|
|
40
40
|
name?: string;
|
|
41
|
+
onLabel?: string;
|
|
42
|
+
onLabelColor?: string | ColorType;
|
|
43
|
+
offLabel?: string;
|
|
44
|
+
offLabelColor?: string | ColorType;
|
|
41
45
|
}
|
|
42
|
-
export declare const Switch: ({ ref, label, checked, invalid, disabled, error, width, color, name, defaultColor, onChange, ...rest }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const Switch: ({ ref, label, checked, invalid, disabled, error, width, color, name, onLabel, offLabel, onLabelColor, offLabelColor, defaultColor, onChange, ...rest }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type RefProp } from "@react-fabric/core/dist/types/types";
|
|
3
|
-
export interface InputProps<V = string> {
|
|
2
|
+
import { type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
|
+
export interface InputProps<V = string> extends TestProps {
|
|
4
4
|
/**
|
|
5
5
|
* value
|
|
6
6
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/form",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
4
4
|
"description": "RUF: Form package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@dnd-kit/utilities": "^3.2.2",
|
|
40
40
|
"@floating-ui/react": "0.26.24",
|
|
41
41
|
"@hookform/resolvers": "^3.9.0",
|
|
42
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
43
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
42
|
+
"@react-fabric/core": "^1.0.0-beta.7",
|
|
43
|
+
"@react-fabric/utilities": "^1.0.0-beta.7",
|
|
44
44
|
"classnames": "^2.5.1",
|
|
45
45
|
"color": "^4.2.3",
|
|
46
46
|
"react-color": "^2.19.3",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"node": ">=18.12.0",
|
|
61
61
|
"npm": ">=8.19.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "8e6efedbbb02660c0b64140aff00e633b891bb85"
|
|
64
64
|
}
|
package/src/input/ArrayInput.tsx
CHANGED
|
@@ -104,6 +104,19 @@ export interface ArrayInputProps {
|
|
|
104
104
|
* Add item
|
|
105
105
|
*/
|
|
106
106
|
onAdd?: () => AnyObject;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* field width
|
|
110
|
+
*/
|
|
111
|
+
width?: number | string;
|
|
112
|
+
/**
|
|
113
|
+
* inline label and input
|
|
114
|
+
*/
|
|
115
|
+
inline?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* label width for inline
|
|
118
|
+
*/
|
|
119
|
+
labelWidth?: string;
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
export const ArrayInput = ({
|
package/src/input/RadioGroup.tsx
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
type CssProp,
|
|
26
25
|
type ChildrenProp,
|
|
26
|
+
type CssProp,
|
|
27
27
|
} from "@react-fabric/core/dist/types/types";
|
|
28
28
|
import { Children, cloneElement } from "react";
|
|
29
29
|
import { FieldWrapper } from "../internal/FieldWrapper";
|
|
@@ -42,6 +42,23 @@ export interface RadioGroupProps extends ChildrenProp<typeof Radio>, CssProp {
|
|
|
42
42
|
* field info
|
|
43
43
|
*/
|
|
44
44
|
info?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* field width
|
|
48
|
+
*/
|
|
49
|
+
width?: number | string;
|
|
50
|
+
/**
|
|
51
|
+
* inline label and input
|
|
52
|
+
*/
|
|
53
|
+
inline?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* label width for inline
|
|
56
|
+
*/
|
|
57
|
+
labelWidth?: string;
|
|
58
|
+
/**
|
|
59
|
+
* label width for inline
|
|
60
|
+
*/
|
|
61
|
+
optionWidth?: string;
|
|
45
62
|
/**
|
|
46
63
|
* field name
|
|
47
64
|
*/
|
|
@@ -60,6 +77,7 @@ export const RadioGroup = ({
|
|
|
60
77
|
children,
|
|
61
78
|
name,
|
|
62
79
|
className,
|
|
80
|
+
optionWidth,
|
|
63
81
|
onChange,
|
|
64
82
|
...rest
|
|
65
83
|
}: RadioGroupProps) => {
|
|
@@ -67,7 +85,11 @@ export const RadioGroup = ({
|
|
|
67
85
|
<FieldWrapper {...rest}>
|
|
68
86
|
<div className={className}>
|
|
69
87
|
{Children.map(children, (child) =>
|
|
70
|
-
cloneElement(child as AnyObject, {
|
|
88
|
+
cloneElement(child as AnyObject, {
|
|
89
|
+
name,
|
|
90
|
+
onChange,
|
|
91
|
+
width: optionWidth,
|
|
92
|
+
}),
|
|
71
93
|
)}
|
|
72
94
|
</div>
|
|
73
95
|
</FieldWrapper>
|
package/src/input/Switch.tsx
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
} from "@react-fabric/core/dist/types/types";
|
|
28
28
|
import classNames from "classnames";
|
|
29
29
|
import {
|
|
30
|
+
Fragment,
|
|
30
31
|
useCallback,
|
|
31
32
|
useDeferredValue,
|
|
32
33
|
useEffect,
|
|
@@ -34,7 +35,7 @@ import {
|
|
|
34
35
|
type ChangeEvent,
|
|
35
36
|
} from "react";
|
|
36
37
|
import { ErrorIcon } from "../internal/ErrorIcon";
|
|
37
|
-
import { getBgClass, getColor } from "../utils";
|
|
38
|
+
import { getBgClass, getColor, getColorClass } from "../utils";
|
|
38
39
|
|
|
39
40
|
export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
40
41
|
/**
|
|
@@ -71,13 +72,19 @@ export interface SwitchProps extends RefProp<HTMLInputElement> {
|
|
|
71
72
|
/**
|
|
72
73
|
* cutom Switch icon
|
|
73
74
|
*/
|
|
74
|
-
color?: ColorType;
|
|
75
|
+
color?: string | ColorType;
|
|
75
76
|
/**
|
|
76
77
|
* cutom Switch icon
|
|
77
78
|
*/
|
|
78
|
-
defaultColor?: ColorType;
|
|
79
|
+
defaultColor?: string | ColorType;
|
|
79
80
|
|
|
80
81
|
name?: string;
|
|
82
|
+
|
|
83
|
+
onLabel?: string;
|
|
84
|
+
onLabelColor?: string | ColorType;
|
|
85
|
+
|
|
86
|
+
offLabel?: string;
|
|
87
|
+
offLabelColor?: string | ColorType;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
export const Switch = ({
|
|
@@ -90,6 +97,10 @@ export const Switch = ({
|
|
|
90
97
|
width,
|
|
91
98
|
color,
|
|
92
99
|
name,
|
|
100
|
+
onLabel,
|
|
101
|
+
offLabel,
|
|
102
|
+
onLabelColor,
|
|
103
|
+
offLabelColor,
|
|
93
104
|
defaultColor,
|
|
94
105
|
onChange,
|
|
95
106
|
...rest
|
|
@@ -125,7 +136,7 @@ export const Switch = ({
|
|
|
125
136
|
actualValue && getBgClass(color ? `${color}-500` : "primary-500"),
|
|
126
137
|
!actualValue &&
|
|
127
138
|
(defaultColor ? getBgClass(`${defaultColor}-500`) : "bg-tint-200"),
|
|
128
|
-
"relative
|
|
139
|
+
"relative grid grid-cols-2 items-center h-6 min-w-10 cursor-pointer rounded-full p-1 transition-colors duration-200 ease-in-out",
|
|
129
140
|
)}
|
|
130
141
|
style={{
|
|
131
142
|
backgroundColor: actualValue
|
|
@@ -154,10 +165,33 @@ export const Switch = ({
|
|
|
154
165
|
aria-hidden="true"
|
|
155
166
|
className={classNames(
|
|
156
167
|
!disabled && "shadow-sm",
|
|
157
|
-
actualValue ? "translate-x-
|
|
158
|
-
"pointer-events-none inline-block
|
|
168
|
+
actualValue ? "translate-x-[100%]" : "translate-x-0",
|
|
169
|
+
"pointer-events-none inline-block h-4 start-1 absolute rounded-full bg-white ring-0 transition duration-200 ease-in-out",
|
|
159
170
|
)}
|
|
171
|
+
style={{
|
|
172
|
+
width: "calc(50% - 0.25rem)",
|
|
173
|
+
}}
|
|
160
174
|
/>
|
|
175
|
+
{(!!onLabel || !!offLabel) && (
|
|
176
|
+
<Fragment>
|
|
177
|
+
<span
|
|
178
|
+
className={`whitespace-nowrap text-xs px-1 ${getColorClass(onLabelColor ?? "white")}`}
|
|
179
|
+
style={{
|
|
180
|
+
color: getColor(onLabelColor),
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
{onLabel ?? " "}
|
|
184
|
+
</span>
|
|
185
|
+
<span
|
|
186
|
+
className={`whitespace-nowrap text-xs px-1 ${getColorClass(offLabelColor ?? "base")}`}
|
|
187
|
+
style={{
|
|
188
|
+
color: getColor(offLabelColor),
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
{offLabel ?? " "}
|
|
192
|
+
</span>
|
|
193
|
+
</Fragment>
|
|
194
|
+
)}
|
|
161
195
|
</div>
|
|
162
196
|
<ErrorIcon invalid={invalid} error={error} />
|
|
163
197
|
{label && (
|
package/src/types/index.ts
CHANGED
|
@@ -21,9 +21,12 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
type RefProp,
|
|
26
|
+
type TestProps,
|
|
27
|
+
} from "@react-fabric/core/dist/types/types";
|
|
25
28
|
|
|
26
|
-
export interface InputProps<V = string> {
|
|
29
|
+
export interface InputProps<V = string> extends TestProps {
|
|
27
30
|
/**
|
|
28
31
|
* value
|
|
29
32
|
*/
|