@xaui/native 0.9.1-alpha.3 → 0.9.1-alpha.31
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/chunk-3FV4COTM.js +68 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-42FMGB5M.js +661 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4XPLPQLM.cjs +147 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5GO7MAVY.cjs +74 -0
- package/dist/chunk-5PTBRJM7.cjs +346 -0
- package/dist/chunk-5RQ7AZPN.cjs +455 -0
- package/dist/chunk-5Z4P6WHR.cjs +525 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7SEZGVTY.js +62 -0
- package/dist/chunk-7XKQJQF2.cjs +70 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-A5OCK3C2.js +525 -0
- package/dist/chunk-AETWQQWU.cjs +92 -0
- package/dist/chunk-ANNUYP55.cjs +431 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BFMTUMTU.js +669 -0
- package/dist/chunk-BVJQ3UPZ.js +62 -0
- package/dist/chunk-DFME724B.js +147 -0
- package/dist/chunk-E2CWBQTV.js +119 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7K652GC.js +145 -0
- package/dist/chunk-GGW42MY4.js +20 -0
- package/dist/chunk-GLGU2WFL.cjs +190 -0
- package/dist/chunk-GPVNCJ3Z.cjs +696 -0
- package/dist/chunk-GVQOD3VW.js +74 -0
- package/dist/chunk-IHOCANCQ.js +293 -0
- package/dist/chunk-JDFV4W6N.cjs +700 -0
- package/dist/chunk-KOC3KQIT.js +124 -0
- package/dist/chunk-KPWZLUES.cjs +124 -0
- package/dist/chunk-L7JN6OBQ.cjs +314 -0
- package/dist/chunk-MC7SY2QH.cjs +20 -0
- package/dist/chunk-MDVSCWJI.js +314 -0
- package/dist/chunk-N527BTY4.cjs +366 -0
- package/dist/chunk-NYRXUGVL.js +104 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-OHEHPQLC.cjs} +72 -72
- package/dist/chunk-Q3WFY5N3.js +366 -0
- package/dist/chunk-QGN2BBJO.cjs +104 -0
- package/dist/chunk-RDTKAAHX.js +346 -0
- package/dist/chunk-TGZZ3RZU.cjs +86 -0
- package/dist/{chunk-2KXQATVL.js → chunk-TZG3DERP.js} +46 -46
- package/dist/chunk-URSKA2VR.js +190 -0
- package/dist/chunk-V4WDMM6Z.js +86 -0
- package/dist/chunk-VJEER76X.js +455 -0
- package/dist/chunk-VZBWYWEI.cjs +736 -0
- package/dist/chunk-WR7YLDVV.cjs +68 -0
- package/dist/chunk-X4HQ4H2V.js +701 -0
- package/dist/chunk-XFSW3ZNI.cjs +145 -0
- package/dist/chunk-XQFAUDR2.cjs +62 -0
- package/dist/chunk-ZH5XVNHG.js +92 -0
- package/dist/chunk-ZH6BHLQR.js +431 -0
- package/dist/chunk-ZP2E2H2G.cjs +119 -0
- package/dist/chunk-ZVWXM3UK.cjs +293 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/alert/index.cjs +20 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +20 -0
- package/dist/components/button/index.cjs +21 -0
- package/dist/components/button/index.d.cts +613 -0
- package/dist/components/button/index.d.ts +613 -0
- package/dist/components/button/index.js +21 -0
- package/dist/components/card/index.cjs +22 -0
- package/dist/components/card/index.d.cts +620 -0
- package/dist/components/card/index.d.ts +620 -0
- package/dist/components/card/index.js +22 -0
- package/dist/components/checkbox/index.cjs +26 -0
- package/dist/components/checkbox/index.d.cts +1136 -0
- package/dist/components/checkbox/index.d.ts +1136 -0
- package/dist/components/checkbox/index.js +26 -0
- package/dist/components/chip/index.cjs +20 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +20 -0
- package/dist/components/divider/index.cjs +13 -0
- package/dist/components/divider/index.d.cts +117 -0
- package/dist/components/divider/index.d.ts +117 -0
- package/dist/components/divider/index.js +13 -0
- package/dist/components/input/index.cjs +25 -0
- package/dist/components/input/index.d.cts +205 -0
- package/dist/components/input/index.d.ts +205 -0
- package/dist/components/input/index.js +25 -0
- package/dist/components/input-group/index.cjs +27 -0
- package/dist/components/input-group/index.d.cts +270 -0
- package/dist/components/input-group/index.d.ts +270 -0
- package/dist/components/input-group/index.js +27 -0
- package/dist/components/input-otp/index.cjs +29 -0
- package/dist/components/input-otp/index.d.cts +325 -0
- package/dist/components/input-otp/index.d.ts +325 -0
- package/dist/components/input-otp/index.js +29 -0
- package/dist/components/radio/index.cjs +26 -0
- package/dist/components/radio/index.d.cts +1102 -0
- package/dist/components/radio/index.d.ts +1102 -0
- package/dist/components/radio/index.js +26 -0
- package/dist/components/spinner/index.cjs +16 -0
- package/dist/components/spinner/index.d.cts +104 -0
- package/dist/components/spinner/index.d.ts +104 -0
- package/dist/components/spinner/index.js +16 -0
- package/dist/components/switch/index.cjs +27 -0
- package/dist/components/switch/index.d.cts +1154 -0
- package/dist/components/switch/index.d.ts +1154 -0
- package/dist/components/switch/index.js +27 -0
- package/dist/components/text-area/index.cjs +14 -0
- package/dist/components/text-area/index.d.cts +73 -0
- package/dist/components/text-area/index.d.ts +73 -0
- package/dist/components/text-area/index.js +14 -0
- package/dist/components/typography/index.cjs +15 -0
- package/dist/components/typography/index.d.cts +116 -0
- package/dist/components/typography/index.d.ts +116 -0
- package/dist/components/typography/index.js +15 -0
- package/dist/components/view/index.cjs +17 -0
- package/dist/components/view/index.d.cts +152 -0
- package/dist/components/view/index.d.ts +152 -0
- package/dist/components/view/index.js +17 -0
- package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
- package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
- package/dist/icon.type-Kml72iSz.d.ts +73 -0
- package/dist/icon.type-d_i9ma-i.d.cts +73 -0
- package/dist/index.cjs +252 -4
- package/dist/index.d.cts +110 -4
- package/dist/index.d.ts +110 -4
- package/dist/index.js +271 -23
- package/dist/input.type-BUMDlzL9.d.cts +167 -0
- package/dist/input.type-D2qgi03E.d.ts +167 -0
- package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
- package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
- package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
- package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
- package/dist/system/index.cjs +60 -3
- package/dist/system/index.d.cts +347 -181
- package/dist/system/index.d.ts +347 -181
- package/dist/system/index.js +71 -14
- package/dist/theme/index.cjs +4 -3
- package/dist/theme/index.d.cts +34 -23
- package/dist/theme/index.d.ts +34 -23
- package/dist/theme/index.js +3 -2
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +184 -18
- package/dist/chunk-QAMNNTGM.js +0 -637
- package/dist/chunk-V63JO65F.cjs +0 -637
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputDescription,
|
|
3
|
+
InputError,
|
|
4
|
+
InputField,
|
|
5
|
+
InputLabel,
|
|
6
|
+
InputRoot,
|
|
7
|
+
useInput
|
|
8
|
+
} from "./chunk-A5OCK3C2.js";
|
|
9
|
+
import {
|
|
10
|
+
createSlotContext
|
|
11
|
+
} from "./chunk-E2CWBQTV.js";
|
|
12
|
+
import {
|
|
13
|
+
useStyleProps
|
|
14
|
+
} from "./chunk-URSKA2VR.js";
|
|
15
|
+
|
|
16
|
+
// src/components/text-area/text-area-field.tsx
|
|
17
|
+
import { forwardRef, useMemo } from "react";
|
|
18
|
+
|
|
19
|
+
// src/components/text-area/text-area.context.ts
|
|
20
|
+
var [TextAreaProvider, useTextArea] = createSlotContext("TextArea");
|
|
21
|
+
|
|
22
|
+
// src/components/text-area/text-area-field.tsx
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
var TextAreaField = forwardRef(
|
|
25
|
+
function TextAreaField2({ style, scrollEnabled, ...props }, ref) {
|
|
26
|
+
const { textAreaStyle, textArea } = useInput();
|
|
27
|
+
const { rows, maxRows } = useTextArea();
|
|
28
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
29
|
+
const height = useMemo(() => {
|
|
30
|
+
const chrome = textArea.paddingVertical * 2;
|
|
31
|
+
return {
|
|
32
|
+
minHeight: rows * textArea.lineHeight + chrome,
|
|
33
|
+
// Unset, the field grows for as long as the text does. With a ceiling it stops
|
|
34
|
+
// there and scrolls, which is the only case that needs `scrollEnabled` — a
|
|
35
|
+
// multiline field that can grow has nothing to scroll.
|
|
36
|
+
maxHeight: maxRows ? maxRows * textArea.lineHeight + chrome : void 0
|
|
37
|
+
};
|
|
38
|
+
}, [rows, maxRows, textArea]);
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
InputField,
|
|
41
|
+
{
|
|
42
|
+
ref,
|
|
43
|
+
multiline: true,
|
|
44
|
+
scrollEnabled: scrollEnabled ?? maxRows !== void 0,
|
|
45
|
+
...rest,
|
|
46
|
+
style: [textAreaStyle, height, styleProps, style]
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
TextAreaField.displayName = "XAUI.TextArea.Field";
|
|
52
|
+
|
|
53
|
+
// src/components/text-area/text-area.tsx
|
|
54
|
+
import { forwardRef as forwardRef2, useMemo as useMemo2 } from "react";
|
|
55
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
56
|
+
var DEFAULT_ROWS = 3;
|
|
57
|
+
var TextAreaRoot = forwardRef2(function TextArea({ rows = DEFAULT_ROWS, maxRows, children, ...props }, ref) {
|
|
58
|
+
const context = useMemo2(() => ({ rows, maxRows }), [rows, maxRows]);
|
|
59
|
+
return /* @__PURE__ */ jsx2(TextAreaProvider, { value: context, children: /* @__PURE__ */ jsx2(InputRoot, { ref, ...props, children }) });
|
|
60
|
+
});
|
|
61
|
+
TextAreaRoot.displayName = "XAUI.TextArea.Root";
|
|
62
|
+
|
|
63
|
+
// src/components/text-area/index.ts
|
|
64
|
+
var TextArea2 = Object.assign(TextAreaRoot, {
|
|
65
|
+
Label: InputLabel,
|
|
66
|
+
Field: TextAreaField,
|
|
67
|
+
Description: InputDescription,
|
|
68
|
+
Error: InputError
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
useTextArea,
|
|
73
|
+
TextArea2 as TextArea
|
|
74
|
+
};
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SelectionFill
|
|
3
|
+
} from "./chunk-BA2DBSAN.js";
|
|
4
|
+
import {
|
|
5
|
+
useControllableState
|
|
6
|
+
} from "./chunk-F6W3JQ7K.js";
|
|
7
|
+
import {
|
|
8
|
+
PressableFeedback
|
|
9
|
+
} from "./chunk-BFMTUMTU.js";
|
|
10
|
+
import {
|
|
11
|
+
usePressState
|
|
12
|
+
} from "./chunk-423RQBOX.js";
|
|
13
|
+
import {
|
|
14
|
+
createRecipe,
|
|
15
|
+
radiusAxis
|
|
16
|
+
} from "./chunk-4GTAZM2C.js";
|
|
17
|
+
import {
|
|
18
|
+
useXAUITheme
|
|
19
|
+
} from "./chunk-A3EGFI6T.js";
|
|
20
|
+
import {
|
|
21
|
+
childrenToString,
|
|
22
|
+
createSlotContext
|
|
23
|
+
} from "./chunk-E2CWBQTV.js";
|
|
24
|
+
import {
|
|
25
|
+
useStyleProps
|
|
26
|
+
} from "./chunk-URSKA2VR.js";
|
|
27
|
+
|
|
28
|
+
// src/components/radio/radio-indicator.tsx
|
|
29
|
+
import { forwardRef } from "react";
|
|
30
|
+
import { View } from "react-native";
|
|
31
|
+
|
|
32
|
+
// src/components/radio/radio.context.ts
|
|
33
|
+
var [RadioProvider, useRadio] = createSlotContext("Radio");
|
|
34
|
+
|
|
35
|
+
// src/components/radio/radio-indicator.tsx
|
|
36
|
+
import { jsx } from "react/jsx-runtime";
|
|
37
|
+
var RadioIndicator = forwardRef(
|
|
38
|
+
function RadioIndicator2({ children, animation = true, style, ...props }, ref) {
|
|
39
|
+
const { indicatorStyle, fillStyle, isSelected } = useRadio();
|
|
40
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
41
|
+
return /* @__PURE__ */ jsx(View, { ref, ...rest, style: [indicatorStyle, styleProps, style], children: /* @__PURE__ */ jsx(
|
|
42
|
+
SelectionFill,
|
|
43
|
+
{
|
|
44
|
+
isVisible: isSelected,
|
|
45
|
+
style: fillStyle,
|
|
46
|
+
animation,
|
|
47
|
+
children: children ?? /* @__PURE__ */ jsx(Thumb, {})
|
|
48
|
+
}
|
|
49
|
+
) });
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
RadioIndicator.displayName = "XAUI.Radio.Indicator";
|
|
53
|
+
function Thumb() {
|
|
54
|
+
const { thumbStyle } = useRadio();
|
|
55
|
+
return /* @__PURE__ */ jsx(View, { style: thumbStyle });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/components/radio/radio-label.tsx
|
|
59
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
60
|
+
import { Text } from "react-native";
|
|
61
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
62
|
+
var RadioLabel = forwardRef2(function RadioLabel2({ children, style, ...props }, ref) {
|
|
63
|
+
const { labelStyle } = useRadio();
|
|
64
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
65
|
+
return /* @__PURE__ */ jsx2(Text, { ref, style: [labelStyle, styleProps, style], ...rest, children });
|
|
66
|
+
});
|
|
67
|
+
RadioLabel.displayName = "XAUI.Radio.Label";
|
|
68
|
+
|
|
69
|
+
// src/components/radio/radio.tsx
|
|
70
|
+
import { forwardRef as forwardRef3, useCallback, useMemo } from "react";
|
|
71
|
+
|
|
72
|
+
// src/components/radio/radio.recipe.ts
|
|
73
|
+
var SLOTS = ["root", "indicator", "fill", "thumb", "label"];
|
|
74
|
+
var VARIANT_TOKENS = {
|
|
75
|
+
primary: {
|
|
76
|
+
bg: "fieldBackground",
|
|
77
|
+
border: "fieldBorder",
|
|
78
|
+
bgSelected: "accent",
|
|
79
|
+
fgSelected: "accentForeground"
|
|
80
|
+
},
|
|
81
|
+
secondary: {
|
|
82
|
+
bg: "default",
|
|
83
|
+
border: "fieldBorder",
|
|
84
|
+
bgSelected: "accent",
|
|
85
|
+
fgSelected: "accentForeground"
|
|
86
|
+
},
|
|
87
|
+
tertiary: {
|
|
88
|
+
border: "fieldBorder",
|
|
89
|
+
bgSelected: "accent",
|
|
90
|
+
fgSelected: "accentForeground"
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function sizeAxis(step) {
|
|
94
|
+
const { box, label, gap } = step;
|
|
95
|
+
return (theme) => {
|
|
96
|
+
const side = theme.spacing(box);
|
|
97
|
+
const dot = Math.round(side * THUMB_RATIO);
|
|
98
|
+
return {
|
|
99
|
+
root: { gap: theme.spacing(gap) },
|
|
100
|
+
indicator: { width: side, height: side },
|
|
101
|
+
thumb: { width: dot, height: dot, borderRadius: dot / 2 },
|
|
102
|
+
label: {
|
|
103
|
+
fontSize: theme.fontSizes[label],
|
|
104
|
+
lineHeight: theme.lineHeights[label]
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
var THUMB_RATIO = 10 / 24;
|
|
110
|
+
var SIZES = {
|
|
111
|
+
sm: { box: 5, gap: 2, label: "sm" },
|
|
112
|
+
md: { box: 6, gap: 2, label: "md" },
|
|
113
|
+
lg: { box: 7, gap: 2.5, label: "lg" }
|
|
114
|
+
};
|
|
115
|
+
var radioRecipe = createRecipe({
|
|
116
|
+
slots: SLOTS,
|
|
117
|
+
base: (theme) => ({
|
|
118
|
+
root: { flexDirection: "row", alignItems: "center", alignSelf: "flex-start" },
|
|
119
|
+
indicator: {
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
justifyContent: "center",
|
|
122
|
+
borderWidth: theme.borderWidth.field,
|
|
123
|
+
// The one shape decision this component makes, and the whole difference between it
|
|
124
|
+
// and the `Checkbox`: a radio is round, at every size. `radius` still overrides it.
|
|
125
|
+
borderRadius: theme.radius.full,
|
|
126
|
+
overflow: "hidden"
|
|
127
|
+
},
|
|
128
|
+
fill: {
|
|
129
|
+
position: "absolute",
|
|
130
|
+
top: 0,
|
|
131
|
+
bottom: 0,
|
|
132
|
+
start: 0,
|
|
133
|
+
end: 0,
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
justifyContent: "center"
|
|
136
|
+
},
|
|
137
|
+
label: {
|
|
138
|
+
fontFamily: theme.fontFamilies.body,
|
|
139
|
+
color: theme.colors.foreground
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
variantTokens: VARIANT_TOKENS,
|
|
143
|
+
/** The `Checkbox`'s paint, with a dot where the check was. */
|
|
144
|
+
paint: (theme, colors) => ({
|
|
145
|
+
indicator: {
|
|
146
|
+
backgroundColor: colors.bg,
|
|
147
|
+
borderColor: colors.border,
|
|
148
|
+
borderWidth: colors.border ? theme.borderWidth.field : 0
|
|
149
|
+
},
|
|
150
|
+
fill: { backgroundColor: colors.bgSelected },
|
|
151
|
+
thumb: { backgroundColor: colors.fgSelected }
|
|
152
|
+
}),
|
|
153
|
+
variants: {
|
|
154
|
+
size: {
|
|
155
|
+
sm: sizeAxis(SIZES.sm),
|
|
156
|
+
md: sizeAxis(SIZES.md),
|
|
157
|
+
lg: sizeAxis(SIZES.lg)
|
|
158
|
+
},
|
|
159
|
+
radius: radiusAxis("indicator"),
|
|
160
|
+
/** Declared after `size` so its border wins. The `Checkbox`'s rule, to the letter. */
|
|
161
|
+
isInvalid: {
|
|
162
|
+
true: (theme) => ({
|
|
163
|
+
indicator: { borderColor: theme.colors.danger, backgroundColor: void 0 },
|
|
164
|
+
fill: { backgroundColor: theme.colors.danger },
|
|
165
|
+
thumb: { backgroundColor: theme.colors.dangerForeground },
|
|
166
|
+
label: { color: theme.colors.danger }
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
compoundVariants: [
|
|
171
|
+
{
|
|
172
|
+
when: { variant: "primary" },
|
|
173
|
+
style: (theme) => ({ indicator: theme.shadows.field })
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
states: {
|
|
177
|
+
disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
|
|
178
|
+
},
|
|
179
|
+
defaultVariants: { variant: "secondary", size: "md" }
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// src/components/radio/radio.tsx
|
|
183
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
184
|
+
var RadioRoot = forwardRef3(function Radio({
|
|
185
|
+
children,
|
|
186
|
+
variant,
|
|
187
|
+
size,
|
|
188
|
+
radius,
|
|
189
|
+
color,
|
|
190
|
+
isSelected,
|
|
191
|
+
defaultSelected = false,
|
|
192
|
+
onSelectedChange,
|
|
193
|
+
isInvalid = false,
|
|
194
|
+
isDisabled = false,
|
|
195
|
+
asChild = false,
|
|
196
|
+
accessibilityRole,
|
|
197
|
+
accessibilityState,
|
|
198
|
+
animation,
|
|
199
|
+
style,
|
|
200
|
+
onPress,
|
|
201
|
+
onPressIn,
|
|
202
|
+
onPressOut,
|
|
203
|
+
...props
|
|
204
|
+
}, ref) {
|
|
205
|
+
const theme = useXAUITheme();
|
|
206
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
207
|
+
const [isPressed, press] = usePressState({ onPressIn, onPressOut });
|
|
208
|
+
const [selected, setSelected] = useControllableState({
|
|
209
|
+
value: isSelected,
|
|
210
|
+
defaultValue: defaultSelected,
|
|
211
|
+
onChange: onSelectedChange
|
|
212
|
+
});
|
|
213
|
+
const handlePress = useCallback(
|
|
214
|
+
(event) => {
|
|
215
|
+
setSelected(true);
|
|
216
|
+
onPress?.(event);
|
|
217
|
+
},
|
|
218
|
+
[setSelected, onPress]
|
|
219
|
+
);
|
|
220
|
+
const selection = {
|
|
221
|
+
variant,
|
|
222
|
+
size,
|
|
223
|
+
radius,
|
|
224
|
+
isInvalid: isInvalid ? "true" : void 0
|
|
225
|
+
};
|
|
226
|
+
const states = { pressed: isPressed, disabled: isDisabled };
|
|
227
|
+
const styles = radioRecipe.resolve({ theme, selection, states });
|
|
228
|
+
const tint = color && !isInvalid ? radioRecipe.tint({ theme, color, selection, states }) : void 0;
|
|
229
|
+
const context = useMemo(
|
|
230
|
+
() => ({
|
|
231
|
+
// The tint never reaches the circle at rest — only the fill and the dot that say it
|
|
232
|
+
// is the chosen one. The `Checkbox` says why, at the same line.
|
|
233
|
+
indicatorStyle: styles.indicator,
|
|
234
|
+
fillStyle: tint ? [styles.fill, tint.fill] : styles.fill,
|
|
235
|
+
thumbStyle: tint ? [styles.thumb, tint.thumb] : styles.thumb,
|
|
236
|
+
labelStyle: styles.label,
|
|
237
|
+
isSelected: selected,
|
|
238
|
+
isDisabled,
|
|
239
|
+
isInvalid
|
|
240
|
+
}),
|
|
241
|
+
[styles, tint, selected, isDisabled, isInvalid]
|
|
242
|
+
);
|
|
243
|
+
const rootStyle = [
|
|
244
|
+
styles.root,
|
|
245
|
+
tint?.root,
|
|
246
|
+
styleProps,
|
|
247
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
248
|
+
];
|
|
249
|
+
const text = childrenToString(children);
|
|
250
|
+
const content = text !== null ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
251
|
+
/* @__PURE__ */ jsx3(RadioIndicator, {}),
|
|
252
|
+
/* @__PURE__ */ jsx3(RadioLabel, { children: text })
|
|
253
|
+
] }) : children ?? /* @__PURE__ */ jsx3(RadioIndicator, {});
|
|
254
|
+
return /* @__PURE__ */ jsx3(RadioProvider, { value: context, children: /* @__PURE__ */ jsx3(
|
|
255
|
+
PressableFeedback,
|
|
256
|
+
{
|
|
257
|
+
ref,
|
|
258
|
+
isPressed,
|
|
259
|
+
isDisabled,
|
|
260
|
+
asChild,
|
|
261
|
+
animation,
|
|
262
|
+
accessibilityRole: accessibilityRole ?? "radio",
|
|
263
|
+
accessibilityState: {
|
|
264
|
+
checked: selected,
|
|
265
|
+
disabled: isDisabled,
|
|
266
|
+
...accessibilityState
|
|
267
|
+
},
|
|
268
|
+
"aria-invalid": isInvalid,
|
|
269
|
+
...rest,
|
|
270
|
+
style: rootStyle,
|
|
271
|
+
onPress: handlePress,
|
|
272
|
+
onPressIn: press.onPressIn,
|
|
273
|
+
onPressOut: press.onPressOut,
|
|
274
|
+
children: asChild ? children : content
|
|
275
|
+
}
|
|
276
|
+
) });
|
|
277
|
+
});
|
|
278
|
+
RadioRoot.displayName = "XAUI.Radio.Root";
|
|
279
|
+
|
|
280
|
+
// src/components/radio/index.ts
|
|
281
|
+
var Radio2 = Object.assign(RadioRoot, {
|
|
282
|
+
Indicator: RadioIndicator,
|
|
283
|
+
Label: RadioLabel
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
export {
|
|
287
|
+
useRadio,
|
|
288
|
+
RadioIndicator,
|
|
289
|
+
RadioLabel,
|
|
290
|
+
radioRecipe,
|
|
291
|
+
RadioRoot,
|
|
292
|
+
Radio2 as Radio
|
|
293
|
+
};
|