@hanzogui/radio-group 2.0.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/LICENSE +21 -0
- package/dist/cjs/RadioGroup.cjs +132 -0
- package/dist/cjs/RadioGroup.native.js +137 -0
- package/dist/cjs/RadioGroup.native.js.map +1 -0
- package/dist/cjs/RadioGroupStyledContext.cjs +30 -0
- package/dist/cjs/RadioGroupStyledContext.native.js +33 -0
- package/dist/cjs/RadioGroupStyledContext.native.js.map +1 -0
- package/dist/cjs/createRadioGroup.cjs +165 -0
- package/dist/cjs/createRadioGroup.native.js +168 -0
- package/dist/cjs/createRadioGroup.native.js.map +1 -0
- package/dist/cjs/index.cjs +36 -0
- package/dist/cjs/index.native.js +39 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/esm/RadioGroup.mjs +107 -0
- package/dist/esm/RadioGroup.mjs.map +1 -0
- package/dist/esm/RadioGroup.native.js +109 -0
- package/dist/esm/RadioGroup.native.js.map +1 -0
- package/dist/esm/RadioGroupStyledContext.mjs +7 -0
- package/dist/esm/RadioGroupStyledContext.mjs.map +1 -0
- package/dist/esm/RadioGroupStyledContext.native.js +7 -0
- package/dist/esm/RadioGroupStyledContext.native.js.map +1 -0
- package/dist/esm/createRadioGroup.mjs +131 -0
- package/dist/esm/createRadioGroup.mjs.map +1 -0
- package/dist/esm/createRadioGroup.native.js +131 -0
- package/dist/esm/createRadioGroup.native.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +12 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/jsx/RadioGroup.mjs +107 -0
- package/dist/jsx/RadioGroup.mjs.map +1 -0
- package/dist/jsx/RadioGroup.native.js +137 -0
- package/dist/jsx/RadioGroup.native.js.map +1 -0
- package/dist/jsx/RadioGroupStyledContext.mjs +7 -0
- package/dist/jsx/RadioGroupStyledContext.mjs.map +1 -0
- package/dist/jsx/RadioGroupStyledContext.native.js +33 -0
- package/dist/jsx/RadioGroupStyledContext.native.js.map +1 -0
- package/dist/jsx/createRadioGroup.mjs +131 -0
- package/dist/jsx/createRadioGroup.mjs.map +1 -0
- package/dist/jsx/createRadioGroup.native.js +168 -0
- package/dist/jsx/createRadioGroup.native.js.map +1 -0
- package/dist/jsx/index.js +12 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +12 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +39 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/package.json +62 -0
- package/src/RadioGroup.tsx +125 -0
- package/src/RadioGroupStyledContext.tsx +10 -0
- package/src/createRadioGroup.tsx +191 -0
- package/src/index.ts +16 -0
- package/types/RadioGroup.d.ts +18 -0
- package/types/RadioGroupStyledContext.d.ts +6 -0
- package/types/createRadioGroup.d.ts +282 -0
- package/types/index.d.ts +253 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
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
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
34
|
+
var createRadioGroup_exports = {};
|
|
35
|
+
__export(createRadioGroup_exports, {
|
|
36
|
+
createRadioGroup: () => createRadioGroup
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(createRadioGroup_exports);
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
40
|
+
import_gui_core = require("@hanzo/gui-core"),
|
|
41
|
+
import_gui_radio_headless = require("@hanzo/gui-radio-headless"),
|
|
42
|
+
import_gui_roving_focus = require("@hanzo/gui-roving-focus"),
|
|
43
|
+
import_react = __toESM(require("react"), 1),
|
|
44
|
+
import_RadioGroup = require("./RadioGroup.native.js"),
|
|
45
|
+
ensureContext = function (x) {
|
|
46
|
+
x.context || (x.context = RadioGroupContext);
|
|
47
|
+
},
|
|
48
|
+
RadioGroupContext = /* @__PURE__ */import_react.default.createContext({}),
|
|
49
|
+
RadioGroupItemContext = /* @__PURE__ */import_react.default.createContext({
|
|
50
|
+
checked: !1,
|
|
51
|
+
disabled: !1
|
|
52
|
+
});
|
|
53
|
+
function createRadioGroup(createProps) {
|
|
54
|
+
var {
|
|
55
|
+
disableActiveTheme,
|
|
56
|
+
Frame = import_RadioGroup.RadioGroupFrame,
|
|
57
|
+
Indicator = import_RadioGroup.RadioGroupIndicatorFrame,
|
|
58
|
+
Item = import_RadioGroup.RadioGroupItemFrame
|
|
59
|
+
} = createProps;
|
|
60
|
+
ensureContext(Frame), ensureContext(Indicator), ensureContext(Item);
|
|
61
|
+
var RadioGroupImp = Frame.styleable(function (props, ref) {
|
|
62
|
+
var {
|
|
63
|
+
value,
|
|
64
|
+
defaultValue,
|
|
65
|
+
onValueChange,
|
|
66
|
+
required = !1,
|
|
67
|
+
disabled = !1,
|
|
68
|
+
name,
|
|
69
|
+
native,
|
|
70
|
+
accentColor,
|
|
71
|
+
orientation = "vertical",
|
|
72
|
+
...rest
|
|
73
|
+
} = props,
|
|
74
|
+
{
|
|
75
|
+
providerValue,
|
|
76
|
+
frameAttrs,
|
|
77
|
+
rovingFocusGroupAttrs
|
|
78
|
+
} = (0, import_gui_radio_headless.useRadioGroup)({
|
|
79
|
+
orientation,
|
|
80
|
+
name,
|
|
81
|
+
defaultValue,
|
|
82
|
+
value,
|
|
83
|
+
onValueChange,
|
|
84
|
+
required,
|
|
85
|
+
disabled,
|
|
86
|
+
native,
|
|
87
|
+
accentColor
|
|
88
|
+
});
|
|
89
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(RadioGroupContext.Provider, {
|
|
90
|
+
value: providerValue,
|
|
91
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_roving_focus.RovingFocusGroup, {
|
|
92
|
+
...rovingFocusGroupAttrs,
|
|
93
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_RadioGroup.RadioGroupFrame, {
|
|
94
|
+
...frameAttrs,
|
|
95
|
+
ref,
|
|
96
|
+
...rest
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
}),
|
|
101
|
+
RadioGroupItemImp = Item.styleable(function (props, ref) {
|
|
102
|
+
var {
|
|
103
|
+
value,
|
|
104
|
+
labelledBy,
|
|
105
|
+
onPress,
|
|
106
|
+
onKeyDown,
|
|
107
|
+
disabled,
|
|
108
|
+
id,
|
|
109
|
+
...rest
|
|
110
|
+
} = props,
|
|
111
|
+
{
|
|
112
|
+
providerValue,
|
|
113
|
+
bubbleInput,
|
|
114
|
+
rovingFocusGroupAttrs,
|
|
115
|
+
frameAttrs,
|
|
116
|
+
isFormControl,
|
|
117
|
+
native
|
|
118
|
+
} = (0, import_gui_radio_headless.useRadioGroupItem)({
|
|
119
|
+
radioGroupContext: RadioGroupContext,
|
|
120
|
+
value,
|
|
121
|
+
id,
|
|
122
|
+
labelledBy,
|
|
123
|
+
disabled,
|
|
124
|
+
onPress,
|
|
125
|
+
onKeyDown
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(RadioGroupItemContext.Provider, {
|
|
128
|
+
value: providerValue,
|
|
129
|
+
children: import_gui_core.isWeb && native ? bubbleInput : /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
130
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_roving_focus.RovingFocusGroup.Item, {
|
|
131
|
+
...rovingFocusGroupAttrs,
|
|
132
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_RadioGroup.RadioGroupItemFrame, {
|
|
133
|
+
...frameAttrs,
|
|
134
|
+
ref,
|
|
135
|
+
...rest
|
|
136
|
+
})
|
|
137
|
+
}), isFormControl && bubbleInput]
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
RadioGroupItemImp.displayName = "RadioGroupItem";
|
|
142
|
+
var RadioIndicator = Indicator.styleable(function (props, forwardedRef) {
|
|
143
|
+
var {
|
|
144
|
+
forceMount,
|
|
145
|
+
disabled,
|
|
146
|
+
...indicatorProps
|
|
147
|
+
} = props,
|
|
148
|
+
{
|
|
149
|
+
checked,
|
|
150
|
+
...useIndicatorRest
|
|
151
|
+
} = (0, import_gui_radio_headless.useRadioGroupItemIndicator)({
|
|
152
|
+
radioGroupItemContext: RadioGroupItemContext,
|
|
153
|
+
disabled
|
|
154
|
+
});
|
|
155
|
+
return forceMount || checked ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(Indicator, {
|
|
156
|
+
...useIndicatorRest,
|
|
157
|
+
ref: forwardedRef,
|
|
158
|
+
...indicatorProps
|
|
159
|
+
}) : null;
|
|
160
|
+
});
|
|
161
|
+
RadioIndicator.displayName = "RadioIndicator";
|
|
162
|
+
var RadioGroup = (0, import_gui_core.withStaticProperties)(RadioGroupImp, {
|
|
163
|
+
Item: RadioGroupItemImp,
|
|
164
|
+
Indicator: RadioIndicator
|
|
165
|
+
});
|
|
166
|
+
return RadioGroup.displayName = "RadioGroup", RadioGroup;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=createRadioGroup.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","createRadioGroup_exports","createRadioGroup","module","exports","import_jsx_runtime","require","import_gui_core","import_gui_radio_headless","import_gui_roving_focus","import_react","import_RadioGroup","ensureContext","x","context","RadioGroupContext","default","createContext","RadioGroupItemContext","checked","disabled","createProps","disableActiveTheme","Frame","RadioGroupFrame","Indicator","RadioGroupIndicatorFrame","Item","RadioGroupItemFrame","RadioGroupImp","styleable","props","ref","defaultValue","onValueChange","required","native","accentColor","orientation","rest","providerValue","frameAttrs","rovingFocusGroupAttrs","useRadioGroup","jsx","Provider","children","RovingFocusGroup","RadioGroupItemImp","labelledBy","onPress","onKeyDown","id","bubbleInput","isFormControl","useRadioGroupItem","radioGroupContext","isWeb","jsxs","Fragment","displayName","RadioIndicator","forwardedRef","forceMount","indicatorProps","useIndicatorRest","useRadioGroupItemIndicator","radioGroupItemContext"],"sources":["../../src/createRadioGroup.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RadioGroupFrame, RadioGroupIndicatorFrame, RadioGroupItemFrame } from "./RadioGroup.mjs";
|
|
2
|
+
import { createRadioGroup } from "./createRadioGroup.mjs";
|
|
3
|
+
export * from "./createRadioGroup.mjs";
|
|
4
|
+
export * from "./RadioGroup.mjs";
|
|
5
|
+
export * from "./RadioGroupStyledContext.mjs";
|
|
6
|
+
const RadioGroup = createRadioGroup({
|
|
7
|
+
Frame: RadioGroupFrame,
|
|
8
|
+
Indicator: RadioGroupIndicatorFrame,
|
|
9
|
+
Item: RadioGroupItemFrame
|
|
10
|
+
});
|
|
11
|
+
export { RadioGroup };
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RadioGroupFrame","RadioGroupIndicatorFrame","RadioGroupItemFrame","createRadioGroup","RadioGroup","Frame","Indicator","Item"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,eAAA,EACAC,wBAAA,EACAC,mBAAA,QACK;AACP,SAASC,gBAAA,QAAwB;AAEjC,cAAc;AACd,cAAc;AACd,cAAc;AAEP,MAAMC,UAAA,GAAaD,gBAAA,CAAiB;EACzCE,KAAA,EAAOL,eAAA;EACPM,SAAA,EAAWL,wBAAA;EACXM,IAAA,EAAML;AACR,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RadioGroupFrame, RadioGroupIndicatorFrame, RadioGroupItemFrame } from "./RadioGroup.mjs";
|
|
2
|
+
import { createRadioGroup } from "./createRadioGroup.mjs";
|
|
3
|
+
export * from "./createRadioGroup.mjs";
|
|
4
|
+
export * from "./RadioGroup.mjs";
|
|
5
|
+
export * from "./RadioGroupStyledContext.mjs";
|
|
6
|
+
const RadioGroup = createRadioGroup({
|
|
7
|
+
Frame: RadioGroupFrame,
|
|
8
|
+
Indicator: RadioGroupIndicatorFrame,
|
|
9
|
+
Item: RadioGroupItemFrame
|
|
10
|
+
});
|
|
11
|
+
export { RadioGroup };
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RadioGroupFrame","RadioGroupIndicatorFrame","RadioGroupItemFrame","createRadioGroup","RadioGroup","Frame","Indicator","Item"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,eAAA,EACAC,wBAAA,EACAC,mBAAA,QACK;AACP,SAASC,gBAAA,QAAwB;AAEjC,cAAc;AACd,cAAc;AACd,cAAc;AAEP,MAAMC,UAAA,GAAaD,gBAAA,CAAiB;EACzCE,KAAA,EAAOL,eAAA;EACPM,SAAA,EAAWL,wBAAA;EACXM,IAAA,EAAML;AACR,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
},
|
|
20
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
22
|
+
value: !0
|
|
23
|
+
}), mod);
|
|
24
|
+
var index_exports = {};
|
|
25
|
+
__export(index_exports, {
|
|
26
|
+
RadioGroup: () => RadioGroup
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var import_RadioGroup = require("./RadioGroup.native.js"),
|
|
30
|
+
import_createRadioGroup = require("./createRadioGroup.native.js");
|
|
31
|
+
__reExport(index_exports, require("./createRadioGroup.native.js"), module.exports);
|
|
32
|
+
__reExport(index_exports, require("./RadioGroup.native.js"), module.exports);
|
|
33
|
+
__reExport(index_exports, require("./RadioGroupStyledContext.native.js"), module.exports);
|
|
34
|
+
var RadioGroup = (0, import_createRadioGroup.createRadioGroup)({
|
|
35
|
+
Frame: import_RadioGroup.RadioGroupFrame,
|
|
36
|
+
Indicator: import_RadioGroup.RadioGroupIndicatorFrame,
|
|
37
|
+
Item: import_RadioGroup.RadioGroupItemFrame
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__reExport","mod","secondTarget"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;AAAA,IACEA,SAAA,GAAAC,MAAA,CAAAC,cAAA;AAAA,IACAC,gBAAA,GAAAF,MAAA,CAAAG,wBAAA;AAAA,IACAC,iBAAA,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IAAAC,YACK,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AACP,IAAAC,QAAS,GAAAA,CAAAC,MAAA,EAAAC,GAAA;IAET,SAAAC,IAAc,IAAAD,GAAA,EACdZ,SAAA,CAAcW,MAAA,EAAAE,IAAA;MAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;MAAAE,UAAA;IAAA;EACd;EAAAC,WAAc,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;IAEP,IAAMF,IAAA,WAAaA,IAAA,YAAiB,WAAAA,IAAA,gBACzC,KAAO,IAAAG,GAAA,IAAAhB,iBAAA,CAAAa,IAAA,GACP,CAAAX,YAAW,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,IAAAnB,SAAA,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,EAAAA,CAAA,KAAAI,IAAA,CAAAG,GAAA;MAAAN,UAAA,IAAAK,IAAA,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;IACX,OAAME,EAAA;EACR,CAAC;EAAAM,UAAA,GAAAA,CAAAZ,MAAA,EAAAa,GAAA,EAAAC,YAAA,MAAAT,WAAA,CAAAL,MAAA,EAAAa,GAAA,cAAAC,YAAA,IAAAT,WAAA,CAAAS,YAAA,EAAAD,GAAA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanzogui/radio-group",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"source": "src/index.ts",
|
|
5
|
+
"files": [
|
|
6
|
+
"src",
|
|
7
|
+
"types",
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"*.css"
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/cjs",
|
|
15
|
+
"module": "dist/esm",
|
|
16
|
+
"types": "./types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/index.d.ts",
|
|
21
|
+
"react-native": "./dist/esm/index.native.js",
|
|
22
|
+
"browser": "./dist/esm/index.mjs",
|
|
23
|
+
"module": "./dist/esm/index.mjs",
|
|
24
|
+
"import": "./dist/esm/index.mjs",
|
|
25
|
+
"require": "./dist/cjs/index.cjs",
|
|
26
|
+
"default": "./dist/esm/index.mjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "hanzo-gui-build",
|
|
34
|
+
"watch": "hanzo-gui-build --watch",
|
|
35
|
+
"clean": "hanzo-gui-build clean",
|
|
36
|
+
"clean:build": "hanzo-gui-build clean:build"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@hanzogui/compose-refs": "2.0.0-rc.29",
|
|
40
|
+
"@hanzogui/constants": "2.0.0-rc.29",
|
|
41
|
+
"@hanzogui/core": "2.0.0-rc.29",
|
|
42
|
+
"@hanzogui/create-context": "2.0.0-rc.29",
|
|
43
|
+
"@hanzogui/focusable": "2.0.0",
|
|
44
|
+
"@hanzogui/get-token": "2.0.0-rc.29",
|
|
45
|
+
"@hanzogui/helpers": "2.0.0-rc.29",
|
|
46
|
+
"@hanzogui/label": "2.0.0",
|
|
47
|
+
"@hanzogui/radio-headless": "2.0.0",
|
|
48
|
+
"@hanzogui/roving-focus": "2.0.0",
|
|
49
|
+
"@hanzogui/stacks": "2.0.0",
|
|
50
|
+
"@hanzogui/use-controllable-state": "2.0.0-rc.29",
|
|
51
|
+
"@hanzogui/use-previous": "2.0.0-rc.29"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@hanzogui/build": "2.0.0-rc.29",
|
|
55
|
+
"react": ">=19"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"react": ">=19"
|
|
59
|
+
},
|
|
60
|
+
"module:jsx": "dist/jsx",
|
|
61
|
+
"removeSideEffects": true
|
|
62
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { getVariableValue, styled } from '@hanzogui/core'
|
|
2
|
+
import { getSize } from '@hanzogui/get-token'
|
|
3
|
+
import { YStack } from '@hanzogui/stacks'
|
|
4
|
+
|
|
5
|
+
const RADIO_GROUP_ITEM_NAME = 'RadioGroupItem'
|
|
6
|
+
|
|
7
|
+
export const RadioGroupItemFrame = styled(YStack, {
|
|
8
|
+
name: RADIO_GROUP_ITEM_NAME,
|
|
9
|
+
render: 'button',
|
|
10
|
+
|
|
11
|
+
variants: {
|
|
12
|
+
unstyled: {
|
|
13
|
+
false: {
|
|
14
|
+
size: '$true',
|
|
15
|
+
borderRadius: 1000,
|
|
16
|
+
backgroundColor: '$background',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
borderWidth: 1,
|
|
20
|
+
borderColor: '$borderColor',
|
|
21
|
+
padding: 0,
|
|
22
|
+
|
|
23
|
+
hoverStyle: {
|
|
24
|
+
borderColor: '$borderColorHover',
|
|
25
|
+
backgroundColor: '$backgroundHover',
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
focusStyle: {
|
|
29
|
+
borderColor: '$borderColorHover',
|
|
30
|
+
backgroundColor: '$backgroundHover',
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
focusVisibleStyle: {
|
|
34
|
+
outlineStyle: 'solid',
|
|
35
|
+
outlineWidth: 2,
|
|
36
|
+
outlineColor: '$outlineColor',
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
pressStyle: {
|
|
40
|
+
borderColor: '$borderColorFocus',
|
|
41
|
+
backgroundColor: '$backgroundFocus',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
disabled: {
|
|
47
|
+
true: {
|
|
48
|
+
pointerEvents: 'none',
|
|
49
|
+
userSelect: 'none',
|
|
50
|
+
cursor: 'not-allowed',
|
|
51
|
+
|
|
52
|
+
hoverStyle: {
|
|
53
|
+
borderColor: '$borderColor',
|
|
54
|
+
backgroundColor: '$background',
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
pressStyle: {
|
|
58
|
+
borderColor: '$borderColor',
|
|
59
|
+
backgroundColor: '$background',
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
focusVisibleStyle: {
|
|
63
|
+
outlineWidth: 0,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
size: {
|
|
69
|
+
'...size': (value, { props }) => {
|
|
70
|
+
const size = Math.floor(
|
|
71
|
+
getVariableValue(getSize(value)) * (props['scaleSize'] ?? 0.5)
|
|
72
|
+
)
|
|
73
|
+
return {
|
|
74
|
+
width: size,
|
|
75
|
+
height: size,
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
} as const,
|
|
80
|
+
|
|
81
|
+
defaultVariants: {
|
|
82
|
+
unstyled: process.env.HANZO_GUI_HEADLESS === '1',
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const RADIO_GROUP_INDICATOR_NAME = 'RadioGroupIndicator'
|
|
87
|
+
|
|
88
|
+
export const RadioGroupIndicatorFrame = styled(YStack, {
|
|
89
|
+
name: RADIO_GROUP_INDICATOR_NAME,
|
|
90
|
+
|
|
91
|
+
variants: {
|
|
92
|
+
unstyled: {
|
|
93
|
+
false: {
|
|
94
|
+
width: '33%',
|
|
95
|
+
height: '33%',
|
|
96
|
+
borderRadius: 1000,
|
|
97
|
+
backgroundColor: '$color',
|
|
98
|
+
pressTheme: true,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
} as const,
|
|
102
|
+
|
|
103
|
+
defaultVariants: {
|
|
104
|
+
unstyled: process.env.HANZO_GUI_HEADLESS === '1',
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const RADIO_GROUP_NAME = 'RadioGroup'
|
|
109
|
+
|
|
110
|
+
export const RadioGroupFrame = styled(YStack, {
|
|
111
|
+
name: RADIO_GROUP_NAME,
|
|
112
|
+
|
|
113
|
+
variants: {
|
|
114
|
+
orientation: {
|
|
115
|
+
horizontal: {
|
|
116
|
+
flexDirection: 'row',
|
|
117
|
+
spaceDirection: 'horizontal',
|
|
118
|
+
},
|
|
119
|
+
vertical: {
|
|
120
|
+
flexDirection: 'column',
|
|
121
|
+
spaceDirection: 'vertical',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
} as const,
|
|
125
|
+
})
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { GetProps } from '@hanzogui/core'
|
|
2
|
+
import { isWeb, withStaticProperties } from '@hanzogui/core'
|
|
3
|
+
import type {
|
|
4
|
+
RadioGroupContextValue,
|
|
5
|
+
RadioGroupItemContextValue,
|
|
6
|
+
} from '@hanzogui/radio-headless'
|
|
7
|
+
import {
|
|
8
|
+
useRadioGroup,
|
|
9
|
+
useRadioGroupItem,
|
|
10
|
+
useRadioGroupItemIndicator,
|
|
11
|
+
} from '@hanzogui/radio-headless'
|
|
12
|
+
import { RovingFocusGroup } from '@hanzogui/roving-focus'
|
|
13
|
+
import React from 'react'
|
|
14
|
+
import {
|
|
15
|
+
RadioGroupFrame,
|
|
16
|
+
RadioGroupIndicatorFrame,
|
|
17
|
+
RadioGroupItemFrame,
|
|
18
|
+
} from './RadioGroup'
|
|
19
|
+
|
|
20
|
+
const ensureContext = (x: any) => {
|
|
21
|
+
if (!x.context) {
|
|
22
|
+
x.context = RadioGroupContext
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type RadioIndicatorProps = GetProps<typeof RadioGroupIndicatorFrame> & {
|
|
27
|
+
forceMount?: boolean
|
|
28
|
+
unstyled?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const RadioGroupContext = React.createContext<RadioGroupContextValue>({})
|
|
32
|
+
const RadioGroupItemContext = React.createContext<RadioGroupItemContextValue>({
|
|
33
|
+
checked: false,
|
|
34
|
+
disabled: false,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export type RadioGroupItemProps = GetProps<typeof RadioGroupItemFrame> & {
|
|
38
|
+
value: string
|
|
39
|
+
id?: string
|
|
40
|
+
labelledBy?: string
|
|
41
|
+
disabled?: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type RadioGroupProps = GetProps<typeof RadioGroupFrame> & {
|
|
45
|
+
value?: string
|
|
46
|
+
defaultValue?: string
|
|
47
|
+
onValueChange?: (value: string) => void
|
|
48
|
+
required?: boolean
|
|
49
|
+
disabled?: boolean
|
|
50
|
+
name?: string
|
|
51
|
+
native?: boolean
|
|
52
|
+
accentColor?: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type RadioGroupComponent = (props: RadioGroupProps) => any
|
|
56
|
+
|
|
57
|
+
type RadioGroupIndicatorComponent = (props: RadioIndicatorProps) => any
|
|
58
|
+
|
|
59
|
+
type RadioGroupItemComponent = (props: RadioGroupItemProps) => any
|
|
60
|
+
|
|
61
|
+
export function createRadioGroup<
|
|
62
|
+
F extends RadioGroupComponent,
|
|
63
|
+
D extends RadioGroupIndicatorComponent,
|
|
64
|
+
I extends RadioGroupItemComponent,
|
|
65
|
+
>(createProps: { disableActiveTheme?: boolean; Frame?: F; Indicator?: D; Item?: I }) {
|
|
66
|
+
const {
|
|
67
|
+
disableActiveTheme,
|
|
68
|
+
Frame = RadioGroupFrame,
|
|
69
|
+
Indicator = RadioGroupIndicatorFrame,
|
|
70
|
+
Item = RadioGroupItemFrame,
|
|
71
|
+
} = createProps as any as {
|
|
72
|
+
disableActiveTheme?: boolean
|
|
73
|
+
Frame: typeof RadioGroupFrame
|
|
74
|
+
Indicator: typeof RadioGroupIndicatorFrame
|
|
75
|
+
Item: typeof RadioGroupItemFrame
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ensureContext(Frame)
|
|
79
|
+
ensureContext(Indicator)
|
|
80
|
+
ensureContext(Item)
|
|
81
|
+
|
|
82
|
+
type RadioGroupProps = GetProps<typeof RadioGroupFrame> & {
|
|
83
|
+
value?: string
|
|
84
|
+
defaultValue?: string
|
|
85
|
+
onValueChange?: (value: string) => void
|
|
86
|
+
required?: boolean
|
|
87
|
+
disabled?: boolean
|
|
88
|
+
name?: string
|
|
89
|
+
native?: boolean
|
|
90
|
+
accentColor?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const RadioGroupImp = Frame.styleable<RadioGroupProps>((props, ref) => {
|
|
94
|
+
const {
|
|
95
|
+
value,
|
|
96
|
+
defaultValue,
|
|
97
|
+
onValueChange,
|
|
98
|
+
required = false,
|
|
99
|
+
disabled = false,
|
|
100
|
+
name,
|
|
101
|
+
native,
|
|
102
|
+
accentColor,
|
|
103
|
+
orientation = 'vertical',
|
|
104
|
+
...rest
|
|
105
|
+
} = props
|
|
106
|
+
|
|
107
|
+
const { providerValue, frameAttrs, rovingFocusGroupAttrs } = useRadioGroup({
|
|
108
|
+
orientation,
|
|
109
|
+
name,
|
|
110
|
+
defaultValue,
|
|
111
|
+
value,
|
|
112
|
+
onValueChange,
|
|
113
|
+
required,
|
|
114
|
+
disabled,
|
|
115
|
+
native,
|
|
116
|
+
accentColor,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<RadioGroupContext.Provider value={providerValue}>
|
|
121
|
+
<RovingFocusGroup {...rovingFocusGroupAttrs}>
|
|
122
|
+
<RadioGroupFrame {...frameAttrs} ref={ref} {...rest} />
|
|
123
|
+
</RovingFocusGroup>
|
|
124
|
+
</RadioGroupContext.Provider>
|
|
125
|
+
)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const RadioGroupItemImp = Item.styleable<RadioGroupItemProps>((props, ref) => {
|
|
129
|
+
const { value, labelledBy, onPress, onKeyDown, disabled, id, ...rest } = props
|
|
130
|
+
|
|
131
|
+
const {
|
|
132
|
+
providerValue,
|
|
133
|
+
bubbleInput,
|
|
134
|
+
rovingFocusGroupAttrs,
|
|
135
|
+
frameAttrs,
|
|
136
|
+
isFormControl,
|
|
137
|
+
native,
|
|
138
|
+
} = useRadioGroupItem({
|
|
139
|
+
radioGroupContext: RadioGroupContext,
|
|
140
|
+
value,
|
|
141
|
+
id,
|
|
142
|
+
labelledBy,
|
|
143
|
+
disabled,
|
|
144
|
+
onPress: onPress!,
|
|
145
|
+
onKeyDown,
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<RadioGroupItemContext.Provider value={providerValue}>
|
|
150
|
+
{isWeb && native ? (
|
|
151
|
+
bubbleInput
|
|
152
|
+
) : (
|
|
153
|
+
<>
|
|
154
|
+
<RovingFocusGroup.Item {...rovingFocusGroupAttrs}>
|
|
155
|
+
<RadioGroupItemFrame {...frameAttrs} ref={ref} {...rest} />
|
|
156
|
+
</RovingFocusGroup.Item>
|
|
157
|
+
{isFormControl && bubbleInput}
|
|
158
|
+
</>
|
|
159
|
+
)}
|
|
160
|
+
</RadioGroupItemContext.Provider>
|
|
161
|
+
)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
RadioGroupItemImp.displayName = 'RadioGroupItem'
|
|
165
|
+
|
|
166
|
+
const RadioIndicator = Indicator.styleable<RadioIndicatorProps>(
|
|
167
|
+
(props: RadioIndicatorProps, forwardedRef) => {
|
|
168
|
+
const { forceMount, disabled, ...indicatorProps } = props
|
|
169
|
+
const { checked, ...useIndicatorRest } = useRadioGroupItemIndicator({
|
|
170
|
+
radioGroupItemContext: RadioGroupItemContext,
|
|
171
|
+
disabled,
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
if (forceMount || checked) {
|
|
175
|
+
return <Indicator {...useIndicatorRest} ref={forwardedRef} {...indicatorProps} />
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return null
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
RadioIndicator.displayName = 'RadioIndicator'
|
|
183
|
+
|
|
184
|
+
const RadioGroup = withStaticProperties(RadioGroupImp, {
|
|
185
|
+
Item: RadioGroupItemImp,
|
|
186
|
+
Indicator: RadioIndicator,
|
|
187
|
+
})
|
|
188
|
+
RadioGroup.displayName = 'RadioGroup'
|
|
189
|
+
|
|
190
|
+
return RadioGroup
|
|
191
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RadioGroupFrame,
|
|
3
|
+
RadioGroupIndicatorFrame,
|
|
4
|
+
RadioGroupItemFrame,
|
|
5
|
+
} from './RadioGroup'
|
|
6
|
+
import { createRadioGroup } from './createRadioGroup'
|
|
7
|
+
|
|
8
|
+
export * from './createRadioGroup'
|
|
9
|
+
export * from './RadioGroup'
|
|
10
|
+
export * from './RadioGroupStyledContext'
|
|
11
|
+
|
|
12
|
+
export const RadioGroup = createRadioGroup({
|
|
13
|
+
Frame: RadioGroupFrame,
|
|
14
|
+
Indicator: RadioGroupIndicatorFrame,
|
|
15
|
+
Item: RadioGroupItemFrame,
|
|
16
|
+
})
|