@arkyn/components 3.0.1-beta.55 → 3.0.1-beta.57
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/bundle.js +283 -261
- package/dist/bundle.umd.cjs +3 -3
- package/dist/components/radio/radioBox/index.d.ts.map +1 -1
- package/dist/components/radio/radioBox/index.js +13 -4
- package/dist/components/radio/radioContext.d.ts +2 -0
- package/dist/components/radio/radioContext.d.ts.map +1 -1
- package/dist/components/radio/radioContext.js +2 -2
- package/dist/components/radio/radioGroup/index.d.ts +1 -0
- package/dist/components/radio/radioGroup/index.d.ts.map +1 -1
- package/dist/components/radio/radioGroup/index.js +2 -2
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radioBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,cAAc,CAAC;AAEtB,KAAK,aAAa,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radioBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,cAAc,CAAC;AAEtB,KAAK,aAAa,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAqDrC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
@@ -77,14 +77,23 @@ import "./styles.css";
|
|
77
77
|
* The component handles both click and focus events for accessibility.
|
78
78
|
*/
|
79
79
|
function RadioBox(props) {
|
80
|
-
const { value: componentValue, size: componentSize, disabled, children, className: baseClassName = "", ...rest } = props;
|
81
|
-
const { handleChange, size: groupSize, value, isError } = useRadioGroup();
|
80
|
+
const { value: componentValue, size: componentSize, disabled, children, className: baseClassName = "", onClick, onFocus, ...rest } = props;
|
81
|
+
const { handleChange, size: groupSize, value, isError, disabled: groupDisabled, } = useRadioGroup();
|
82
82
|
const isChecked = value === componentValue;
|
83
83
|
const size = componentSize || groupSize;
|
84
|
+
const isDisabled = disabled || groupDisabled;
|
84
85
|
const checkedClass = isChecked ? "checkedTrue" : "checkedFalse";
|
85
86
|
const errorClass = !!isError ? "errorTrue" : "errorFalse";
|
86
|
-
const disabledClass =
|
87
|
+
const disabledClass = isDisabled ? "disabledTrue" : "disabledFalse";
|
87
88
|
const className = `arkynRadioBox ${size} ${checkedClass} ${errorClass} ${disabledClass} ${baseClassName}`;
|
88
|
-
|
89
|
+
function handleClick(event) {
|
90
|
+
onClick && onClick(event);
|
91
|
+
handleChange(componentValue);
|
92
|
+
}
|
93
|
+
function handleFocus(event) {
|
94
|
+
onFocus && onFocus(event);
|
95
|
+
handleChange(componentValue);
|
96
|
+
}
|
97
|
+
return (_jsxs("label", { className: className.trim(), children: [_jsx("button", { type: "button", disabled: isDisabled, onClick: handleClick, onFocus: handleFocus, ...rest }), children] }));
|
89
98
|
}
|
90
99
|
export { RadioBox };
|
@@ -4,6 +4,7 @@ type RadioGroupContextType = {
|
|
4
4
|
isError: boolean;
|
5
5
|
size: "sm" | "md" | "lg";
|
6
6
|
handleChange: (value: string) => void;
|
7
|
+
disabled: boolean;
|
7
8
|
};
|
8
9
|
type RadioProviderProps = {
|
9
10
|
children: ReactNode;
|
@@ -11,6 +12,7 @@ type RadioProviderProps = {
|
|
11
12
|
size: "sm" | "md" | "lg";
|
12
13
|
value: string;
|
13
14
|
handleChange: (value: string) => void;
|
15
|
+
disabled: boolean;
|
14
16
|
};
|
15
17
|
declare function RadioProvider(props: RadioProviderProps): import("react/jsx-runtime").JSX.Element;
|
16
18
|
declare function useRadioGroup(): RadioGroupContextType;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"radioContext.d.ts","sourceRoot":"","sources":["../../../src/components/radio/radioContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAwB,MAAM,OAAO,CAAC;AAEvE,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"radioContext.d.ts","sourceRoot":"","sources":["../../../src/components/radio/radioContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAwB,MAAM,OAAO,CAAC;AAEvE,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAIF,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAU/C;AAED,iBAAS,aAAa,0BAErB;AAED,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext } from "react";
|
3
3
|
const radioContext = createContext({});
|
4
4
|
function RadioProvider(props) {
|
5
|
-
const { children, size, isError, handleChange, value } = props;
|
6
|
-
return (_jsx(radioContext.Provider, { value: { handleChange, value, size, isError }, children: children }));
|
5
|
+
const { children, size, isError, handleChange, value, disabled } = props;
|
6
|
+
return (_jsx(radioContext.Provider, { value: { handleChange, value, size, isError, disabled }, children: children }));
|
7
7
|
}
|
8
8
|
function useRadioGroup() {
|
9
9
|
return useContext(radioContext);
|
@@ -9,6 +9,7 @@ type RadioGroupProps = Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
|
|
9
9
|
defaultValue?: string;
|
10
10
|
onChange?: (value: string) => void;
|
11
11
|
size?: "sm" | "md" | "lg";
|
12
|
+
disabled?: boolean;
|
12
13
|
};
|
13
14
|
/**
|
14
15
|
* RadioGroup component - used for creating a group of radio button options with shared state management
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAQjD,OAAO,cAAc,CAAC;AAEtB,KAAK,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAQjD,OAAO,cAAc,CAAC;AAEtB,KAAK,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AAEH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAkDzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
@@ -84,7 +84,7 @@ import "./styles.css";
|
|
84
84
|
* ```
|
85
85
|
*/
|
86
86
|
function RadioGroup(props) {
|
87
|
-
const { defaultValue = "", name, label, showAsterisk, errorMessage: baseErrorMessage, value: forceValue, onChange, size = "md", className: baseClassName = "", ...rest } = props;
|
87
|
+
const { defaultValue = "", name, label, showAsterisk, errorMessage: baseErrorMessage, value: forceValue, onChange, size = "md", className: baseClassName = "", disabled = false, ...rest } = props;
|
88
88
|
const [value, setValue] = useState(defaultValue);
|
89
89
|
const { fieldErrors } = useForm();
|
90
90
|
function handleChange(value) {
|
@@ -95,6 +95,6 @@ function RadioGroup(props) {
|
|
95
95
|
const errorMessage = baseErrorMessage || fieldErrors?.[name];
|
96
96
|
const isError = !!errorMessage;
|
97
97
|
const className = `arkynRadioGroup ${size} ${baseClassName}`;
|
98
|
-
return (_jsxs(FieldWrapper, { children: [label && _jsx(FieldLabel, { showAsterisk: showAsterisk, children: label }), _jsxs(RadioProvider, { isError: isError, size: size, value: forceValue || value, handleChange: handleChange, children: [_jsx("input", { style: { display: "none" }, type: "text", readOnly: true, name: name, value: forceValue || value }), _jsx("div", { className: className.trim(), ...rest })] }), errorMessage && _jsx(FieldError, { children: errorMessage })] }));
|
98
|
+
return (_jsxs(FieldWrapper, { children: [label && _jsx(FieldLabel, { showAsterisk: showAsterisk, children: label }), _jsxs(RadioProvider, { isError: isError, size: size, value: forceValue || value, handleChange: handleChange, disabled: disabled, children: [_jsx("input", { style: { display: "none" }, type: "text", readOnly: true, name: name, value: forceValue || value }), _jsx("div", { className: className.trim(), ...rest })] }), errorMessage && _jsx(FieldError, { children: errorMessage })] }));
|
99
99
|
}
|
100
100
|
export { RadioGroup };
|