@aristobyte-ui/radio 1.0.112 → 2.1.0
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/es/main/components/Radio/Radio.scss +773 -0
- package/dist/es/main/components/Radio/index.js +14 -0
- package/dist/es/main/components/RadioGroup/RadioGroup.scss +15 -0
- package/dist/es/main/components/RadioGroup/index.js +48 -0
- package/dist/es/main/components/index.js +2 -0
- package/dist/es/main/index.js +1 -0
- package/dist/lib/main/components/Radio/Radio.scss +773 -0
- package/dist/lib/main/components/Radio/index.js +51 -0
- package/dist/lib/main/components/RadioGroup/RadioGroup.scss +15 -0
- package/dist/lib/main/components/RadioGroup/index.js +85 -0
- package/dist/lib/main/components/index.js +18 -0
- package/dist/lib/main/index.js +17 -0
- package/package.json +3 -27
- package/dist/index.d.mts +0 -37
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -207
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -170
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Radio = void 0;
|
|
37
|
+
var React = __importStar(require("react"));
|
|
38
|
+
require("./Radio.scss");
|
|
39
|
+
var Radio = function (_a) {
|
|
40
|
+
var children = _a.children, value = _a.value, checked = _a.checked, name = _a.name, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.highlightLabel, highlightLabel = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.variant, variant = _e === void 0 ? 'default' : _e, _f = _a.appearance, appearance = _f === void 0 ? 'default' : _f, _g = _a.alignLabel, alignLabel = _g === void 0 ? 'right' : _g, onChange = _a.onChange, _h = _a.className, className = _h === void 0 ? '' : _h, _j = _a.style, style = _j === void 0 ? {} : _j;
|
|
41
|
+
var handleChange = function () {
|
|
42
|
+
if (!disabled && onChange) {
|
|
43
|
+
onChange(value);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return (React.createElement("label", { className: "radio ".concat("radio-align-label--".concat(alignLabel), " ").concat("radio-appearance--".concat(appearance), " ").concat("radio-variant--".concat(variant), " ").concat("radio-size--".concat(size), " ").concat(disabled ? 'radio--disabled' : '', " ").concat(className), style: style },
|
|
47
|
+
React.createElement("input", { type: "radio", name: name, value: value, checked: checked, disabled: disabled, onChange: handleChange, className: "radio__input" }),
|
|
48
|
+
React.createElement("span", { className: "radio__control" }),
|
|
49
|
+
children && (React.createElement("span", { className: "radio__label ".concat(highlightLabel ? 'radio__label--highlight-label' : '') }, children))));
|
|
50
|
+
};
|
|
51
|
+
exports.Radio = Radio;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
+
if (!m) return o;
|
|
50
|
+
var i = m.call(o), r, ar = [], e;
|
|
51
|
+
try {
|
|
52
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) { e = { error: error }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e) throw e.error; }
|
|
60
|
+
}
|
|
61
|
+
return ar;
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.RadioGroup = void 0;
|
|
65
|
+
var React = __importStar(require("react"));
|
|
66
|
+
var Radio_1 = require("../Radio");
|
|
67
|
+
require("./RadioGroup.scss");
|
|
68
|
+
var RadioGroup = function (_a) {
|
|
69
|
+
var name = _a.name, value = _a.value, onChange = _a.onChange, children = _a.children, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.highlightLabel, highlightLabel = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? 'md' : _d, _e = _a.variant, variant = _e === void 0 ? 'default' : _e, _f = _a.appearance, appearance = _f === void 0 ? 'outline' : _f, _g = _a.align, align = _g === void 0 ? 'horizontal' : _g, _h = _a.alignLabel, alignLabel = _h === void 0 ? 'right' : _h, _j = _a.className, className = _j === void 0 ? '' : _j, _k = _a.style, style = _k === void 0 ? {} : _k;
|
|
70
|
+
var uniqueId = React.useId();
|
|
71
|
+
var _l = __read(React.useState(value), 2), currentValue = _l[0], setCurrentValue = _l[1];
|
|
72
|
+
var radios = React.Children.toArray(children).filter(function (child) { return React.isValidElement(child) && child.type === Radio_1.Radio; });
|
|
73
|
+
var handleChange = function (currentRadioValue) {
|
|
74
|
+
if (onChange) {
|
|
75
|
+
onChange(currentRadioValue);
|
|
76
|
+
}
|
|
77
|
+
setCurrentValue(currentRadioValue);
|
|
78
|
+
};
|
|
79
|
+
return (React.createElement("div", { key: uniqueId, className: "radio-group ".concat("radio-group--".concat(align), " ").concat(className), style: style }, radios.map(function (_a) {
|
|
80
|
+
var _b, _c, _d, _e, _f, _g;
|
|
81
|
+
var props = _a.props;
|
|
82
|
+
return (React.createElement(Radio_1.Radio, __assign({}, props, { key: "".concat(name, "-").concat(props.value, "-").concat(uniqueId), name: "".concat(name, "-").concat(props.value, "-").concat(uniqueId), checked: props.value === currentValue, onChange: function () { return handleChange(props.value); }, disabled: (_b = props.disabled) !== null && _b !== void 0 ? _b : disabled, size: (_c = props.size) !== null && _c !== void 0 ? _c : size, variant: (_d = props.variant) !== null && _d !== void 0 ? _d : variant, appearance: (_e = props.appearance) !== null && _e !== void 0 ? _e : appearance, highlightLabel: (_f = props.highlightLabel) !== null && _f !== void 0 ? _f : highlightLabel, alignLabel: (_g = props.alignLabel) !== null && _g !== void 0 ? _g : alignLabel })));
|
|
83
|
+
})));
|
|
84
|
+
};
|
|
85
|
+
exports.RadioGroup = RadioGroup;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Radio"), exports);
|
|
18
|
+
__exportStar(require("./RadioGroup"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aristobyte-ui/radio",
|
|
3
3
|
"description": "Composable and fully-typed Radio and RadioGroup components for AristoByteUI. Supports multiple variants, sizes, appearances, alignments, and optional label highlights, optimized for performance and developer experience.",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "AristoByte <info@aristobyte.com>",
|
|
@@ -42,34 +42,10 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"main": "dist/index.js",
|
|
46
|
-
"module": "dist/index.
|
|
47
|
-
"types": "dist/index.d.ts",
|
|
48
|
-
"exports": {
|
|
49
|
-
".": {
|
|
50
|
-
"import": "./dist/index.mjs",
|
|
51
|
-
"require": "./dist/index.js"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"scripts": {
|
|
55
|
-
"build": "tsup",
|
|
56
|
-
"lint": "eslint . --max-warnings 0",
|
|
57
|
-
"generate:component": "turbo gen react-component",
|
|
58
|
-
"check-types": "tsc --noEmit"
|
|
59
|
-
},
|
|
45
|
+
"main": "dist/lib/main/index.js",
|
|
46
|
+
"module": "dist/es/main/index.js",
|
|
60
47
|
"peerDependencies": {
|
|
61
48
|
"react": "^19.1.0",
|
|
62
49
|
"react-dom": "^19.1.0"
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@aristobyte-ui/eslint-config": "^1.0.112",
|
|
66
|
-
"@aristobyte-ui/typescript-config": "^1.0.112",
|
|
67
|
-
"@turbo/gen": "^2.5.0",
|
|
68
|
-
"@types/node": "^24.3.0",
|
|
69
|
-
"@types/react": "19.1.0",
|
|
70
|
-
"@types/react-dom": "19.1.1",
|
|
71
|
-
"eslint": "^9.27.0",
|
|
72
|
-
"tsup": "^8.5.0",
|
|
73
|
-
"typescript": "^5.8.3"
|
|
74
50
|
}
|
|
75
51
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
interface IRadio {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
value: string;
|
|
6
|
-
checked?: boolean;
|
|
7
|
-
onChange?: (value: string) => void;
|
|
8
|
-
name?: string;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
className?: string;
|
|
11
|
-
highlightLabel?: boolean;
|
|
12
|
-
size?: "xsm" | "sm" | "md" | "lg" | "xlg";
|
|
13
|
-
variant?: "default" | "primary" | "secondary" | "success" | "error" | "warning";
|
|
14
|
-
appearance?: "default" | "solid" | "outline" | "outline-dashed" | "no-outline" | "glowing";
|
|
15
|
-
alignLabel?: "top" | "right" | "bottom" | "left";
|
|
16
|
-
style?: React.CSSProperties;
|
|
17
|
-
}
|
|
18
|
-
declare const Radio: React.FC<IRadio>;
|
|
19
|
-
|
|
20
|
-
interface IRadioGroup {
|
|
21
|
-
name: string;
|
|
22
|
-
value: string;
|
|
23
|
-
children: React.ReactElement<IRadio> | React.ReactElement<IRadio>[];
|
|
24
|
-
onChange?: (newValue: string) => void;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
size?: "xsm" | "sm" | "md" | "lg" | "xlg";
|
|
27
|
-
variant?: "default" | "primary" | "secondary" | "success" | "error" | "warning";
|
|
28
|
-
appearance?: "solid" | "outline" | "outline-dashed" | "no-outline" | "glowing";
|
|
29
|
-
align?: "horizontal" | "vertical";
|
|
30
|
-
alignLabel?: "top" | "right" | "bottom" | "left";
|
|
31
|
-
highlightLabel?: boolean;
|
|
32
|
-
className?: string;
|
|
33
|
-
style?: React.CSSProperties;
|
|
34
|
-
}
|
|
35
|
-
declare const RadioGroup: React.FC<IRadioGroup>;
|
|
36
|
-
|
|
37
|
-
export { type IRadio, type IRadioGroup, Radio, RadioGroup };
|
package/dist/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
interface IRadio {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
value: string;
|
|
6
|
-
checked?: boolean;
|
|
7
|
-
onChange?: (value: string) => void;
|
|
8
|
-
name?: string;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
className?: string;
|
|
11
|
-
highlightLabel?: boolean;
|
|
12
|
-
size?: "xsm" | "sm" | "md" | "lg" | "xlg";
|
|
13
|
-
variant?: "default" | "primary" | "secondary" | "success" | "error" | "warning";
|
|
14
|
-
appearance?: "default" | "solid" | "outline" | "outline-dashed" | "no-outline" | "glowing";
|
|
15
|
-
alignLabel?: "top" | "right" | "bottom" | "left";
|
|
16
|
-
style?: React.CSSProperties;
|
|
17
|
-
}
|
|
18
|
-
declare const Radio: React.FC<IRadio>;
|
|
19
|
-
|
|
20
|
-
interface IRadioGroup {
|
|
21
|
-
name: string;
|
|
22
|
-
value: string;
|
|
23
|
-
children: React.ReactElement<IRadio> | React.ReactElement<IRadio>[];
|
|
24
|
-
onChange?: (newValue: string) => void;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
size?: "xsm" | "sm" | "md" | "lg" | "xlg";
|
|
27
|
-
variant?: "default" | "primary" | "secondary" | "success" | "error" | "warning";
|
|
28
|
-
appearance?: "solid" | "outline" | "outline-dashed" | "no-outline" | "glowing";
|
|
29
|
-
align?: "horizontal" | "vertical";
|
|
30
|
-
alignLabel?: "top" | "right" | "bottom" | "left";
|
|
31
|
-
highlightLabel?: boolean;
|
|
32
|
-
className?: string;
|
|
33
|
-
style?: React.CSSProperties;
|
|
34
|
-
}
|
|
35
|
-
declare const RadioGroup: React.FC<IRadioGroup>;
|
|
36
|
-
|
|
37
|
-
export { type IRadio, type IRadioGroup, Radio, RadioGroup };
|
package/dist/index.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
Radio: () => Radio,
|
|
35
|
-
RadioGroup: () => RadioGroup
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
|
|
39
|
-
// ../../node_modules/clsx/dist/clsx.mjs
|
|
40
|
-
function r(e) {
|
|
41
|
-
var t, f, n = "";
|
|
42
|
-
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
43
|
-
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
44
|
-
var o = e.length;
|
|
45
|
-
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
46
|
-
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
47
|
-
return n;
|
|
48
|
-
}
|
|
49
|
-
function clsx() {
|
|
50
|
-
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
51
|
-
return n;
|
|
52
|
-
}
|
|
53
|
-
var clsx_default = clsx;
|
|
54
|
-
|
|
55
|
-
// components/Radio.tsx
|
|
56
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
|
-
var Radio = ({
|
|
58
|
-
children,
|
|
59
|
-
value,
|
|
60
|
-
checked,
|
|
61
|
-
name,
|
|
62
|
-
disabled = false,
|
|
63
|
-
highlightLabel = false,
|
|
64
|
-
size = "md",
|
|
65
|
-
variant = "default",
|
|
66
|
-
appearance = "default",
|
|
67
|
-
alignLabel = "right",
|
|
68
|
-
onChange,
|
|
69
|
-
className,
|
|
70
|
-
style
|
|
71
|
-
}) => {
|
|
72
|
-
const handleChange = () => {
|
|
73
|
-
if (!disabled && onChange) {
|
|
74
|
-
onChange(value);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const alignClasses = {
|
|
78
|
-
top: "flex-col",
|
|
79
|
-
right: "flex-row",
|
|
80
|
-
bottom: "flex-col",
|
|
81
|
-
left: "flex-row"
|
|
82
|
-
};
|
|
83
|
-
const controlOrder = {
|
|
84
|
-
top: "order-2",
|
|
85
|
-
right: "",
|
|
86
|
-
bottom: "",
|
|
87
|
-
left: "order-2"
|
|
88
|
-
};
|
|
89
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
90
|
-
"label",
|
|
91
|
-
{
|
|
92
|
-
className: clsx_default(
|
|
93
|
-
"flex items-center relative cursor-pointer select-none",
|
|
94
|
-
alignClasses[alignLabel],
|
|
95
|
-
disabled && "cursor-not-allowed opacity-50 pointer-events-none",
|
|
96
|
-
`radio-size--${size}`,
|
|
97
|
-
`radio-variant--${variant}`,
|
|
98
|
-
`radio-appearance--${appearance}`,
|
|
99
|
-
className
|
|
100
|
-
),
|
|
101
|
-
style,
|
|
102
|
-
children: [
|
|
103
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
104
|
-
"input",
|
|
105
|
-
{
|
|
106
|
-
type: "radio",
|
|
107
|
-
name,
|
|
108
|
-
value,
|
|
109
|
-
checked,
|
|
110
|
-
disabled,
|
|
111
|
-
onChange: handleChange,
|
|
112
|
-
className: "peer sr-only"
|
|
113
|
-
}
|
|
114
|
-
),
|
|
115
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
-
"span",
|
|
117
|
-
{
|
|
118
|
-
className: clsx_default(
|
|
119
|
-
"radio__control flex-shrink-0 rounded-full transition-all duration-200",
|
|
120
|
-
controlOrder[alignLabel]
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
),
|
|
124
|
-
children && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
-
"span",
|
|
126
|
-
{
|
|
127
|
-
className: clsx_default(
|
|
128
|
-
"ml-2 select-none",
|
|
129
|
-
highlightLabel && `text-${variant}`
|
|
130
|
-
),
|
|
131
|
-
children
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
]
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// components/RadioGroup.tsx
|
|
140
|
-
var React = __toESM(require("react"));
|
|
141
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
142
|
-
var import_react = require("react");
|
|
143
|
-
var RadioGroup = ({
|
|
144
|
-
name,
|
|
145
|
-
value,
|
|
146
|
-
onChange,
|
|
147
|
-
children,
|
|
148
|
-
disabled = false,
|
|
149
|
-
highlightLabel = false,
|
|
150
|
-
size = "md",
|
|
151
|
-
variant = "default",
|
|
152
|
-
appearance = "outline",
|
|
153
|
-
align = "horizontal",
|
|
154
|
-
alignLabel = "right",
|
|
155
|
-
className = "",
|
|
156
|
-
style = {}
|
|
157
|
-
}) => {
|
|
158
|
-
const uniqueId = React.useId();
|
|
159
|
-
const [currentValue, setCurrentValue] = React.useState(value);
|
|
160
|
-
const radios = React.Children.toArray(
|
|
161
|
-
children
|
|
162
|
-
);
|
|
163
|
-
const handleChange = (currentRadioValue) => {
|
|
164
|
-
if (onChange) onChange(currentRadioValue);
|
|
165
|
-
setCurrentValue(currentRadioValue);
|
|
166
|
-
};
|
|
167
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
168
|
-
"div",
|
|
169
|
-
{
|
|
170
|
-
className: clsx_default(
|
|
171
|
-
"radio-group",
|
|
172
|
-
`radio-group--${align}`,
|
|
173
|
-
`radio-group-size--${size}`,
|
|
174
|
-
`radio-group-variant--${variant}`,
|
|
175
|
-
`radio-group-appearance--${appearance}`,
|
|
176
|
-
className
|
|
177
|
-
),
|
|
178
|
-
style,
|
|
179
|
-
children: radios.map(({ props }) => {
|
|
180
|
-
var _a, _b, _c, _d, _e, _f;
|
|
181
|
-
return /* @__PURE__ */ (0, import_react.createElement)(
|
|
182
|
-
Radio,
|
|
183
|
-
{
|
|
184
|
-
...props,
|
|
185
|
-
key: `${name}-${props.value}-${uniqueId}`,
|
|
186
|
-
name: `${name}-${props.value}-${uniqueId}`,
|
|
187
|
-
checked: props.value === currentValue,
|
|
188
|
-
onChange: () => handleChange(props.value),
|
|
189
|
-
disabled: (_a = props.disabled) != null ? _a : disabled,
|
|
190
|
-
size: (_b = props.size) != null ? _b : size,
|
|
191
|
-
variant: (_c = props.variant) != null ? _c : variant,
|
|
192
|
-
appearance: (_d = props.appearance) != null ? _d : appearance,
|
|
193
|
-
highlightLabel: (_e = props.highlightLabel) != null ? _e : highlightLabel,
|
|
194
|
-
alignLabel: (_f = props.alignLabel) != null ? _f : alignLabel
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
})
|
|
198
|
-
},
|
|
199
|
-
uniqueId
|
|
200
|
-
);
|
|
201
|
-
};
|
|
202
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
203
|
-
0 && (module.exports = {
|
|
204
|
-
Radio,
|
|
205
|
-
RadioGroup
|
|
206
|
-
});
|
|
207
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../../../node_modules/clsx/dist/clsx.mjs","../components/Radio.tsx","../components/RadioGroup.tsx"],"sourcesContent":["export * from \"./components\";\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import * as React from \"react\";\nimport clsx from \"clsx\";\n\nexport interface IRadio {\n children: React.ReactNode;\n value: string;\n checked?: boolean;\n onChange?: (value: string) => void;\n name?: string;\n disabled?: boolean;\n className?: string;\n highlightLabel?: boolean;\n size?: \"xsm\" | \"sm\" | \"md\" | \"lg\" | \"xlg\";\n variant?:\n | \"default\"\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"error\"\n | \"warning\";\n appearance?:\n | \"default\"\n | \"solid\"\n | \"outline\"\n | \"outline-dashed\"\n | \"no-outline\"\n | \"glowing\";\n alignLabel?: \"top\" | \"right\" | \"bottom\" | \"left\";\n style?: React.CSSProperties;\n}\n\nexport const Radio: React.FC<IRadio> = ({\n children,\n value,\n checked,\n name,\n disabled = false,\n highlightLabel = false,\n size = \"md\",\n variant = \"default\",\n appearance = \"default\",\n alignLabel = \"right\",\n onChange,\n className,\n style,\n}) => {\n const handleChange = () => {\n if (!disabled && onChange) {\n onChange(value);\n }\n };\n\n const alignClasses: Record<string, string> = {\n top: \"flex-col\",\n right: \"flex-row\",\n bottom: \"flex-col\",\n left: \"flex-row\",\n };\n\n const controlOrder: Record<string, string> = {\n top: \"order-2\",\n right: \"\",\n bottom: \"\",\n left: \"order-2\",\n };\n\n return (\n <label\n className={clsx(\n \"flex items-center relative cursor-pointer select-none\",\n alignClasses[alignLabel],\n disabled && \"cursor-not-allowed opacity-50 pointer-events-none\",\n `radio-size--${size}`,\n `radio-variant--${variant}`,\n `radio-appearance--${appearance}`,\n className\n )}\n style={style}\n >\n <input\n type=\"radio\"\n name={name}\n value={value}\n checked={checked}\n disabled={disabled}\n onChange={handleChange}\n className=\"peer sr-only\"\n />\n <span\n className={clsx(\n \"radio__control flex-shrink-0 rounded-full transition-all duration-200\",\n controlOrder[alignLabel]\n )}\n />\n {children && (\n <span\n className={clsx(\n \"ml-2 select-none\",\n highlightLabel && `text-${variant}`\n )}\n >\n {children}\n </span>\n )}\n </label>\n );\n};\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Radio, type IRadio } from \"./Radio\";\nimport clsx from \"clsx\";\n\nexport interface IRadioGroup {\n name: string;\n value: string;\n children: React.ReactElement<IRadio> | React.ReactElement<IRadio>[];\n onChange?: (newValue: string) => void;\n disabled?: boolean;\n size?: \"xsm\" | \"sm\" | \"md\" | \"lg\" | \"xlg\";\n variant?:\n | \"default\"\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"error\"\n | \"warning\";\n appearance?:\n | \"solid\"\n | \"outline\"\n | \"outline-dashed\"\n | \"no-outline\"\n | \"glowing\";\n align?: \"horizontal\" | \"vertical\";\n alignLabel?: \"top\" | \"right\" | \"bottom\" | \"left\";\n highlightLabel?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport const RadioGroup: React.FC<IRadioGroup> = ({\n name,\n value,\n onChange,\n children,\n disabled = false,\n highlightLabel = false,\n size = \"md\",\n variant = \"default\",\n appearance = \"outline\",\n align = \"horizontal\",\n alignLabel = \"right\",\n className = \"\",\n style = {},\n}) => {\n const uniqueId = React.useId();\n const [currentValue, setCurrentValue] = React.useState<string>(value);\n\n const radios = React.Children.toArray(\n children\n ) as React.ReactElement<IRadio>[];\n\n const handleChange = (currentRadioValue: string) => {\n if (onChange) onChange(currentRadioValue);\n setCurrentValue(currentRadioValue);\n };\n\n return (\n <div\n key={uniqueId}\n className={clsx(\n \"radio-group\",\n `radio-group--${align}`,\n `radio-group-size--${size}`,\n `radio-group-variant--${variant}`,\n `radio-group-appearance--${appearance}`,\n className\n )}\n style={style}\n >\n {radios.map(({ props }) => (\n <Radio\n {...props}\n key={`${name}-${props.value}-${uniqueId}`}\n name={`${name}-${props.value}-${uniqueId}`}\n checked={props.value === currentValue}\n onChange={() => handleChange(props.value)}\n disabled={props.disabled ?? disabled}\n size={props.size ?? size}\n variant={props.variant ?? variant}\n appearance={props.appearance ?? appearance}\n highlightLabel={props.highlightLabel ?? highlightLabel}\n alignLabel={props.alignLabel ?? alignLabel}\n />\n ))}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,EAAE,GAAE;AAAC,MAAI,GAAE,GAAE,IAAE;AAAG,MAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;AAAA,WAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,CAAC,GAAE;AAAC,QAAI,IAAE,EAAE;AAAO,SAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,CAAC,MAAI,IAAE,EAAE,EAAE,CAA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