@xaui/native 0.9.1-alpha.4 → 0.9.1-alpha.40
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-2EGR4LWD.js +145 -0
- package/dist/chunk-2NRZKJG7.js +531 -0
- package/dist/chunk-2PMXMKS5.js +67 -0
- package/dist/chunk-2XPG2243.js +586 -0
- package/dist/chunk-36PRYGAM.js +13 -0
- package/dist/chunk-3E7CDKFO.cjs +696 -0
- package/dist/chunk-3GFRSZYR.js +54 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-4CUZZWFW.js +92 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4KFKWBN5.cjs +89 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5R26NM4M.cjs +402 -0
- package/dist/chunk-5VKYNBNA.js +607 -0
- package/dist/chunk-64MXEVT3.js +66 -0
- package/dist/chunk-6DOLGZVV.cjs +147 -0
- package/dist/chunk-6L2TS2R3.cjs +92 -0
- package/dist/chunk-6UEZJRVI.js +669 -0
- package/dist/chunk-734MFAX4.js +27 -0
- package/dist/chunk-73RKQC5X.js +104 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7GHM4GKL.cjs +119 -0
- package/dist/chunk-7YF5NAHQ.cjs +74 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-ABAGZTXZ.cjs +736 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-ACAPTWE3.cjs} +85 -81
- package/dist/chunk-AMCSSOJT.cjs +104 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BRRXFOBY.js +431 -0
- package/dist/chunk-C5YLPCFC.cjs +293 -0
- package/dist/chunk-DA3OKXHV.cjs +700 -0
- package/dist/chunk-DD4276RF.js +366 -0
- package/dist/chunk-DG2I4PJG.js +701 -0
- package/dist/chunk-DHGLGSH6.js +661 -0
- package/dist/chunk-DIBUQ46Y.js +346 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-EKS3W46M.cjs +66 -0
- package/dist/chunk-EZEYMLO3.js +402 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FHUYHV6J.js +89 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7P3ERYF.cjs +478 -0
- package/dist/chunk-GA6PBWNT.js +147 -0
- package/dist/chunk-GFUZ3MUT.cjs +455 -0
- package/dist/chunk-GGW43Q37.cjs +1 -0
- package/dist/chunk-GTR5X65M.cjs +27 -0
- package/dist/chunk-H4E4HDEP.cjs +13 -0
- package/dist/chunk-H7DS4IO7.js +198 -0
- package/dist/chunk-HDVVZG4S.cjs +198 -0
- package/dist/chunk-IKJVLJKT.js +151 -0
- package/dist/chunk-J3MB4PI5.cjs +531 -0
- package/dist/chunk-K72UDPVN.js +119 -0
- package/dist/chunk-KCMYU7WF.js +86 -0
- package/dist/chunk-LRN3RNDO.js +940 -0
- package/dist/chunk-LTX6TB5I.js +124 -0
- package/dist/chunk-LUPCPLND.cjs +145 -0
- package/dist/chunk-M63GFNKV.js +194 -0
- package/dist/chunk-N3KTZMPG.js +293 -0
- package/dist/chunk-NCTOTTVW.js +13 -0
- package/dist/chunk-NWGLP6JX.cjs +410 -0
- package/dist/chunk-R73XQK7X.cjs +314 -0
- package/dist/chunk-RU7JCMWC.cjs +881 -0
- package/dist/chunk-SNIHUKDA.cjs +184 -0
- package/dist/chunk-T5FV5F7A.cjs +607 -0
- package/dist/chunk-TDTUAIFF.cjs +153 -0
- package/dist/chunk-TJ74XVZN.cjs +431 -0
- package/dist/chunk-TK44VBIE.cjs +194 -0
- package/dist/chunk-UAWBAD4E.cjs +346 -0
- package/dist/chunk-UFTCTTKK.js +381 -0
- package/dist/chunk-WDDXU3OH.cjs +67 -0
- package/dist/chunk-WFEMJCXO.cjs +13 -0
- package/dist/chunk-WHJTBTYM.js +0 -0
- package/dist/{chunk-2KXQATVL.js → chunk-WKCQ6VGW.js} +59 -55
- package/dist/chunk-XFPQFCEK.js +455 -0
- package/dist/chunk-XSQPVDFH.cjs +60 -0
- package/dist/chunk-XTC2SLFT.js +153 -0
- package/dist/chunk-XV735BSA.cjs +366 -0
- package/dist/chunk-XWNG2U4K.cjs +124 -0
- package/dist/chunk-YGYYJ3LQ.js +314 -0
- package/dist/chunk-YVHT2UVW.js +74 -0
- package/dist/chunk-ZFOOJK37.cjs +86 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/accordion/index.cjs +35 -0
- package/dist/components/accordion/index.d.cts +299 -0
- package/dist/components/accordion/index.d.ts +299 -0
- package/dist/components/accordion/index.js +35 -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/avatar/index.cjs +16 -0
- package/dist/components/avatar/index.d.cts +131 -0
- package/dist/components/avatar/index.d.ts +131 -0
- package/dist/components/avatar/index.js +16 -0
- package/dist/components/badge/index.cjs +15 -0
- package/dist/components/badge/index.d.cts +157 -0
- package/dist/components/badge/index.d.ts +157 -0
- package/dist/components/badge/index.js +15 -0
- package/dist/components/button/index.cjs +22 -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 +22 -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/field-group/index.cjs +27 -0
- package/dist/components/field-group/index.d.cts +270 -0
- package/dist/components/field-group/index.d.ts +270 -0
- package/dist/components/field-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/menu/index.cjs +49 -0
- package/dist/components/menu/index.d.cts +351 -0
- package/dist/components/menu/index.d.ts +351 -0
- package/dist/components/menu/index.js +49 -0
- package/dist/components/popover/index.cjs +38 -0
- package/dist/components/popover/index.d.cts +254 -0
- package/dist/components/popover/index.d.ts +254 -0
- package/dist/components/popover/index.js +38 -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/select/index.cjs +50 -0
- package/dist/components/select/index.d.cts +498 -0
- package/dist/components/select/index.d.ts +498 -0
- package/dist/components/select/index.js +50 -0
- package/dist/components/skeleton/index.cjs +11 -0
- package/dist/components/skeleton/index.d.cts +111 -0
- package/dist/components/skeleton/index.d.ts +111 -0
- package/dist/components/skeleton/index.js +11 -0
- package/dist/components/spinner/index.cjs +17 -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 +17 -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/text-field/index.cjs +25 -0
- package/dist/components/text-field/index.d.cts +205 -0
- package/dist/components/text-field/index.d.ts +205 -0
- package/dist/components/text-field/index.js +25 -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 +400 -4
- package/dist/index.d.cts +118 -4
- package/dist/index.d.ts +118 -4
- package/dist/index.js +423 -27
- package/dist/placement-DHa0Rrh1.d.cts +38 -0
- package/dist/placement-DHa0Rrh1.d.ts +38 -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 +73 -4
- package/dist/system/index.d.cts +379 -193
- package/dist/system/index.d.ts +379 -193
- package/dist/system/index.js +87 -18
- package/dist/text-field.type-0l73acce.d.ts +167 -0
- package/dist/text-field.type-DBh06DU5.d.cts +167 -0
- package/dist/theme/index.cjs +5 -3
- package/dist/theme/index.d.cts +55 -24
- package/dist/theme/index.d.ts +55 -24
- package/dist/theme/index.js +4 -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 +254 -18
- package/dist/chunk-ECDWSSHJ.js +0 -688
- package/dist/chunk-IYFGO523.cjs +0 -688
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/system/style-props/use-style-props.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
|
|
4
|
+
// src/utils/stable-hash.ts
|
|
5
|
+
function canonical(value) {
|
|
6
|
+
if (value === null || typeof value !== "object")
|
|
7
|
+
return _nullishCoalesce(JSON.stringify(value), () => ( "null"));
|
|
8
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
9
|
+
const entries = Object.entries(value).filter(([, v]) => typeof v !== "function").sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`);
|
|
10
|
+
return `{${entries.join(",")}}`;
|
|
11
|
+
}
|
|
12
|
+
function stableHash(value) {
|
|
13
|
+
const input = canonical(value);
|
|
14
|
+
let hash = 2166136261;
|
|
15
|
+
for (let i = 0; i < input.length; i++) {
|
|
16
|
+
hash ^= input.charCodeAt(i);
|
|
17
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
18
|
+
}
|
|
19
|
+
return hash.toString(36);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/utils/style-props.ts
|
|
23
|
+
var STYLE_PROP_KEYS = [
|
|
24
|
+
// Flex and layout
|
|
25
|
+
"alignContent",
|
|
26
|
+
"alignItems",
|
|
27
|
+
"alignSelf",
|
|
28
|
+
"aspectRatio",
|
|
29
|
+
"boxSizing",
|
|
30
|
+
"columnGap",
|
|
31
|
+
"direction",
|
|
32
|
+
"display",
|
|
33
|
+
"flex",
|
|
34
|
+
"flexBasis",
|
|
35
|
+
"flexDirection",
|
|
36
|
+
"flexGrow",
|
|
37
|
+
"flexShrink",
|
|
38
|
+
"flexWrap",
|
|
39
|
+
"gap",
|
|
40
|
+
"justifyContent",
|
|
41
|
+
"overflow",
|
|
42
|
+
"rowGap",
|
|
43
|
+
// Position
|
|
44
|
+
"bottom",
|
|
45
|
+
"end",
|
|
46
|
+
"inset",
|
|
47
|
+
"insetBlock",
|
|
48
|
+
"insetBlockEnd",
|
|
49
|
+
"insetBlockStart",
|
|
50
|
+
"insetInline",
|
|
51
|
+
"insetInlineEnd",
|
|
52
|
+
"insetInlineStart",
|
|
53
|
+
"position",
|
|
54
|
+
"start",
|
|
55
|
+
"top",
|
|
56
|
+
"zIndex",
|
|
57
|
+
// Margin
|
|
58
|
+
"margin",
|
|
59
|
+
"marginBlock",
|
|
60
|
+
"marginBlockEnd",
|
|
61
|
+
"marginBlockStart",
|
|
62
|
+
"marginBottom",
|
|
63
|
+
"marginEnd",
|
|
64
|
+
"marginHorizontal",
|
|
65
|
+
"marginInline",
|
|
66
|
+
"marginInlineEnd",
|
|
67
|
+
"marginInlineStart",
|
|
68
|
+
"marginStart",
|
|
69
|
+
"marginTop",
|
|
70
|
+
"marginVertical",
|
|
71
|
+
// Padding
|
|
72
|
+
"padding",
|
|
73
|
+
"paddingBlock",
|
|
74
|
+
"paddingBlockEnd",
|
|
75
|
+
"paddingBlockStart",
|
|
76
|
+
"paddingBottom",
|
|
77
|
+
"paddingEnd",
|
|
78
|
+
"paddingHorizontal",
|
|
79
|
+
"paddingInline",
|
|
80
|
+
"paddingInlineEnd",
|
|
81
|
+
"paddingInlineStart",
|
|
82
|
+
"paddingStart",
|
|
83
|
+
"paddingTop",
|
|
84
|
+
"paddingVertical",
|
|
85
|
+
// Size
|
|
86
|
+
"height",
|
|
87
|
+
"maxHeight",
|
|
88
|
+
"maxWidth",
|
|
89
|
+
"minHeight",
|
|
90
|
+
"minWidth",
|
|
91
|
+
"width",
|
|
92
|
+
// Border
|
|
93
|
+
"borderBlockColor",
|
|
94
|
+
"borderBlockEndColor",
|
|
95
|
+
"borderBlockStartColor",
|
|
96
|
+
"borderBottomColor",
|
|
97
|
+
"borderBottomEndRadius",
|
|
98
|
+
"borderBottomStartRadius",
|
|
99
|
+
"borderBottomWidth",
|
|
100
|
+
"borderColor",
|
|
101
|
+
"borderCurve",
|
|
102
|
+
"borderEndColor",
|
|
103
|
+
"borderEndEndRadius",
|
|
104
|
+
"borderEndStartRadius",
|
|
105
|
+
"borderEndWidth",
|
|
106
|
+
"borderRadius",
|
|
107
|
+
"borderStartColor",
|
|
108
|
+
"borderStartEndRadius",
|
|
109
|
+
"borderStartStartRadius",
|
|
110
|
+
"borderStartWidth",
|
|
111
|
+
"borderStyle",
|
|
112
|
+
"borderTopColor",
|
|
113
|
+
"borderTopEndRadius",
|
|
114
|
+
"borderTopStartRadius",
|
|
115
|
+
"borderTopWidth",
|
|
116
|
+
"borderWidth",
|
|
117
|
+
// Fill, shadow, and the rest of a box's paint
|
|
118
|
+
"backfaceVisibility",
|
|
119
|
+
"backgroundColor",
|
|
120
|
+
"boxShadow",
|
|
121
|
+
"cursor",
|
|
122
|
+
"elevation",
|
|
123
|
+
"experimental_backgroundImage",
|
|
124
|
+
"filter",
|
|
125
|
+
"isolation",
|
|
126
|
+
"mixBlendMode",
|
|
127
|
+
"opacity",
|
|
128
|
+
"outlineColor",
|
|
129
|
+
"outlineOffset",
|
|
130
|
+
"outlineStyle",
|
|
131
|
+
"outlineWidth",
|
|
132
|
+
"shadowColor",
|
|
133
|
+
"shadowOffset",
|
|
134
|
+
"shadowOpacity",
|
|
135
|
+
"shadowRadius",
|
|
136
|
+
// Transform
|
|
137
|
+
"rotation",
|
|
138
|
+
"scaleX",
|
|
139
|
+
"scaleY",
|
|
140
|
+
"transform",
|
|
141
|
+
"transformMatrix",
|
|
142
|
+
"transformOrigin",
|
|
143
|
+
"translateX",
|
|
144
|
+
"translateY",
|
|
145
|
+
// Text — a text slot only
|
|
146
|
+
"color",
|
|
147
|
+
"fontFamily",
|
|
148
|
+
"fontSize",
|
|
149
|
+
"fontStyle",
|
|
150
|
+
"fontVariant",
|
|
151
|
+
"fontWeight",
|
|
152
|
+
"includeFontPadding",
|
|
153
|
+
"letterSpacing",
|
|
154
|
+
"lineHeight",
|
|
155
|
+
"textAlign",
|
|
156
|
+
"textAlignVertical",
|
|
157
|
+
"textDecorationColor",
|
|
158
|
+
"textDecorationLine",
|
|
159
|
+
"textDecorationStyle",
|
|
160
|
+
"textShadowColor",
|
|
161
|
+
"textShadowOffset",
|
|
162
|
+
"textShadowRadius",
|
|
163
|
+
"textTransform",
|
|
164
|
+
"userSelect",
|
|
165
|
+
"verticalAlign",
|
|
166
|
+
"writingDirection",
|
|
167
|
+
// Image — an image slot only
|
|
168
|
+
"objectFit",
|
|
169
|
+
"overlayColor",
|
|
170
|
+
"resizeMode",
|
|
171
|
+
"tintColor"
|
|
172
|
+
];
|
|
173
|
+
var STYLE_PROP_KEY_SET = new Set(STYLE_PROP_KEYS);
|
|
174
|
+
function splitStyleProps(props) {
|
|
175
|
+
const styleProps = {};
|
|
176
|
+
const rest = {};
|
|
177
|
+
for (const [key, value] of Object.entries(props)) {
|
|
178
|
+
if (STYLE_PROP_KEY_SET.has(key)) styleProps[key] = value;
|
|
179
|
+
else rest[key] = value;
|
|
180
|
+
}
|
|
181
|
+
return [styleProps, rest];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/system/style-props/use-style-props.ts
|
|
185
|
+
function useStyleProps(props) {
|
|
186
|
+
const [styleProps, rest] = splitStyleProps(props);
|
|
187
|
+
const key = stableHash(styleProps);
|
|
188
|
+
return [_react.useMemo.call(void 0, () => styleProps, [key]), rest];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
exports.stableHash = stableHash; exports.useStyleProps = useStyleProps;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkF6CQ6CBIcjs = require('./chunk-F6CQ6CBI.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk3E7CDKFOcjs = require('./chunk-3E7CDKFO.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
27
|
+
|
|
28
|
+
// src/components/checkbox/checkbox-indicator.tsx
|
|
29
|
+
var _react = require('react');
|
|
30
|
+
var _reactnative = require('react-native');
|
|
31
|
+
|
|
32
|
+
// src/components/checkbox/checkbox.context.ts
|
|
33
|
+
var [CheckboxProvider, useCheckbox] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "Checkbox");
|
|
34
|
+
|
|
35
|
+
// src/components/checkbox/checkbox-indicator.tsx
|
|
36
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
37
|
+
var CheckboxIndicator = _react.forwardRef.call(void 0,
|
|
38
|
+
function CheckboxIndicator2({ children, animation = true, style, ...props }, ref) {
|
|
39
|
+
const { indicatorStyle, fillStyle, isSelected, isIndeterminate } = useCheckbox();
|
|
40
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
41
|
+
const isFilled = isSelected || isIndeterminate;
|
|
42
|
+
const mark = _nullishCoalesce(children, () => ( (isIndeterminate ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dash, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Check, {}))));
|
|
43
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, ...rest, style: [indicatorStyle, styleProps, style], children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkF6CQ6CBIcjs.SelectionFill, { isVisible: isFilled, style: fillStyle, animation, children: mark }) });
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
CheckboxIndicator.displayName = "XAUI.Checkbox.Indicator";
|
|
47
|
+
function Check() {
|
|
48
|
+
const { checkStyle } = useCheckbox();
|
|
49
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: checkStyle });
|
|
50
|
+
}
|
|
51
|
+
function Dash() {
|
|
52
|
+
const { dashStyle } = useCheckbox();
|
|
53
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: dashStyle });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/components/checkbox/checkbox-label.tsx
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var CheckboxLabel = _react.forwardRef.call(void 0,
|
|
61
|
+
function CheckboxLabel2({ children, style, ...props }, ref) {
|
|
62
|
+
const { labelStyle } = useCheckbox();
|
|
63
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
64
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, style: [labelStyle, styleProps, style], ...rest, children });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
CheckboxLabel.displayName = "XAUI.Checkbox.Label";
|
|
68
|
+
|
|
69
|
+
// src/components/checkbox/checkbox.tsx
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// src/components/checkbox/checkbox.recipe.ts
|
|
73
|
+
var SLOTS = ["root", "indicator", "fill", "check", "dash", "label"];
|
|
74
|
+
var VARIANT_TOKENS = {
|
|
75
|
+
primary: {
|
|
76
|
+
bg: "fieldBackground",
|
|
77
|
+
border: "fieldBorder",
|
|
78
|
+
bgSelected: "accent",
|
|
79
|
+
fgSelected: "accentForeground"
|
|
80
|
+
},
|
|
81
|
+
// `bg: 'default'` is the neutral *token*, not this variant's name — the two namespaces
|
|
82
|
+
// meet here as they do on the `Input`, and for the same reason: on a card,
|
|
83
|
+
// `fieldBackground` is the card's own colour and the box would vanish into it.
|
|
84
|
+
secondary: {
|
|
85
|
+
bg: "default",
|
|
86
|
+
border: "fieldBorder",
|
|
87
|
+
bgSelected: "accent",
|
|
88
|
+
fgSelected: "accentForeground"
|
|
89
|
+
},
|
|
90
|
+
tertiary: {
|
|
91
|
+
border: "fieldBorder",
|
|
92
|
+
bgSelected: "accent",
|
|
93
|
+
fgSelected: "accentForeground"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
function sizeAxis(step) {
|
|
97
|
+
const { box, radius, label, gap, stroke } = step;
|
|
98
|
+
return (theme) => {
|
|
99
|
+
const side = theme.spacing(box);
|
|
100
|
+
return {
|
|
101
|
+
root: { gap: theme.spacing(gap) },
|
|
102
|
+
indicator: { width: side, height: side, borderRadius: theme.radius[radius] },
|
|
103
|
+
check: {
|
|
104
|
+
width: side * CHECK_WIDTH,
|
|
105
|
+
height: side * CHECK_HEIGHT,
|
|
106
|
+
borderStartWidth: stroke,
|
|
107
|
+
borderBottomWidth: stroke,
|
|
108
|
+
// An "L" has its ink in one corner, not in the middle of its box, so rotating it
|
|
109
|
+
// about that box's centre leaves the tick sitting low. Rotating by −45° maps a
|
|
110
|
+
// point to `(dy − dx)·√2/2`, and over the two strokes that spans `H` at the top
|
|
111
|
+
// and `H − t − W` at the bottom — an ink centre `(H − t)·√2/4` **below** the box
|
|
112
|
+
// centre, which flexbox then dutifully centres. Lifting by exactly that is what
|
|
113
|
+
// makes the mark look centred rather than measure centred.
|
|
114
|
+
//
|
|
115
|
+
// Both transforms live here, and not half here and half in a sheet, because
|
|
116
|
+
// `transform` is a whole value: the recipe's merge replaces it rather than
|
|
117
|
+
// blending, so a second step would drop the first.
|
|
118
|
+
transform: [
|
|
119
|
+
{ translateY: -((side * CHECK_HEIGHT - stroke) * Math.SQRT2) / 4 },
|
|
120
|
+
{ rotate: "-45deg" }
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
// The third state's mark: the check's long stroke, on its own and level.
|
|
124
|
+
dash: {
|
|
125
|
+
width: side * CHECK_WIDTH,
|
|
126
|
+
height: stroke,
|
|
127
|
+
borderRadius: stroke / 2
|
|
128
|
+
},
|
|
129
|
+
label: {
|
|
130
|
+
fontSize: theme.fontSizes[label],
|
|
131
|
+
lineHeight: theme.lineHeights[label]
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
var CHECK_WIDTH = 0.5;
|
|
137
|
+
var CHECK_HEIGHT = 0.25;
|
|
138
|
+
var SIZES = {
|
|
139
|
+
sm: { box: 5, radius: "sm", gap: 2, label: "sm", stroke: 2 },
|
|
140
|
+
md: { box: 6, radius: "md", gap: 2, label: "md", stroke: 2 },
|
|
141
|
+
lg: { box: 7, radius: "md", gap: 2.5, label: "lg", stroke: 2.5 }
|
|
142
|
+
};
|
|
143
|
+
var checkboxRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
|
|
144
|
+
slots: SLOTS,
|
|
145
|
+
base: (theme) => ({
|
|
146
|
+
root: { flexDirection: "row", alignItems: "center", alignSelf: "flex-start" },
|
|
147
|
+
indicator: {
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
justifyContent: "center",
|
|
150
|
+
borderWidth: theme.borderWidth.field,
|
|
151
|
+
borderCurve: "continuous",
|
|
152
|
+
// The fill is laid inside the box and has to stop at its corners.
|
|
153
|
+
overflow: "hidden"
|
|
154
|
+
},
|
|
155
|
+
// Laid over the box rather than sized to it: the two corners are the indicator's, and
|
|
156
|
+
// an inset of zero is what keeps the fill inside the border it is clipped by.
|
|
157
|
+
fill: {
|
|
158
|
+
position: "absolute",
|
|
159
|
+
top: 0,
|
|
160
|
+
bottom: 0,
|
|
161
|
+
start: 0,
|
|
162
|
+
end: 0,
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
justifyContent: "center"
|
|
165
|
+
},
|
|
166
|
+
label: {
|
|
167
|
+
fontFamily: theme.fontFamilies.body,
|
|
168
|
+
color: theme.colors.foreground
|
|
169
|
+
}
|
|
170
|
+
}),
|
|
171
|
+
variantTokens: VARIANT_TOKENS,
|
|
172
|
+
/**
|
|
173
|
+
* Where the variant's colours land. The border width follows the *presence* of the
|
|
174
|
+
* border role, exactly as on the `Input`.
|
|
175
|
+
*
|
|
176
|
+
* `bgSelected` and `fgSelected` are painted unconditionally, on two slots the indicator
|
|
177
|
+
* only mounts while it is ticked — which is what keeps selection out of the cache key
|
|
178
|
+
* and inside the tint pass at the same time. An axis would have given up the second.
|
|
179
|
+
*/
|
|
180
|
+
paint: (theme, colors) => ({
|
|
181
|
+
indicator: {
|
|
182
|
+
backgroundColor: colors.bg,
|
|
183
|
+
borderColor: colors.border,
|
|
184
|
+
borderWidth: colors.border ? theme.borderWidth.field : 0
|
|
185
|
+
},
|
|
186
|
+
fill: { backgroundColor: colors.bgSelected },
|
|
187
|
+
check: { borderColor: colors.fgSelected },
|
|
188
|
+
dash: { backgroundColor: colors.fgSelected }
|
|
189
|
+
}),
|
|
190
|
+
variants: {
|
|
191
|
+
size: {
|
|
192
|
+
sm: sizeAxis(SIZES.sm),
|
|
193
|
+
md: sizeAxis(SIZES.md),
|
|
194
|
+
lg: sizeAxis(SIZES.lg)
|
|
195
|
+
},
|
|
196
|
+
radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "indicator"),
|
|
197
|
+
/**
|
|
198
|
+
* Declared after `size` so its border wins. The resting fill is dropped rather than
|
|
199
|
+
* repainted — `undefined` over a colour is what RN reads as "no background" — because
|
|
200
|
+
* a box that is wrong should read as an outline, not as a filled control that happens
|
|
201
|
+
* to be red at the edge. HeroUI reaches the same shape with a compound.
|
|
202
|
+
*/
|
|
203
|
+
isInvalid: {
|
|
204
|
+
true: (theme) => ({
|
|
205
|
+
indicator: { borderColor: theme.colors.danger, backgroundColor: void 0 },
|
|
206
|
+
fill: { backgroundColor: theme.colors.danger },
|
|
207
|
+
check: { borderColor: theme.colors.dangerForeground },
|
|
208
|
+
dash: { backgroundColor: theme.colors.dangerForeground },
|
|
209
|
+
// The label turns with it: on a long form the field that is wrong has to be
|
|
210
|
+
// findable without reading every message.
|
|
211
|
+
label: { color: theme.colors.danger }
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
/** What `primary` adds to a filled box — the `Input`'s compound, on a smaller field. */
|
|
216
|
+
compoundVariants: [
|
|
217
|
+
{
|
|
218
|
+
when: { variant: "primary" },
|
|
219
|
+
style: (theme) => ({ indicator: theme.shadows.field })
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
states: {
|
|
223
|
+
disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
|
|
224
|
+
},
|
|
225
|
+
defaultVariants: { variant: "secondary", size: "md" }
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// src/components/checkbox/checkbox.tsx
|
|
229
|
+
|
|
230
|
+
var CheckboxRoot = _react.forwardRef.call(void 0, function Checkbox({
|
|
231
|
+
children,
|
|
232
|
+
variant,
|
|
233
|
+
size,
|
|
234
|
+
radius,
|
|
235
|
+
color,
|
|
236
|
+
isSelected,
|
|
237
|
+
defaultSelected = false,
|
|
238
|
+
onSelectedChange,
|
|
239
|
+
isIndeterminate = false,
|
|
240
|
+
isInvalid = false,
|
|
241
|
+
isDisabled = false,
|
|
242
|
+
asChild = false,
|
|
243
|
+
accessibilityRole,
|
|
244
|
+
accessibilityState,
|
|
245
|
+
animation,
|
|
246
|
+
style,
|
|
247
|
+
onPress,
|
|
248
|
+
onPressIn,
|
|
249
|
+
onPressOut,
|
|
250
|
+
...props
|
|
251
|
+
}, ref) {
|
|
252
|
+
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
|
|
253
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
254
|
+
const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
|
|
255
|
+
const [selected, setSelected] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
|
|
256
|
+
value: isSelected,
|
|
257
|
+
defaultValue: defaultSelected,
|
|
258
|
+
onChange: onSelectedChange
|
|
259
|
+
});
|
|
260
|
+
const handlePress = _react.useCallback.call(void 0,
|
|
261
|
+
(event) => {
|
|
262
|
+
setSelected((current) => isIndeterminate ? true : !current);
|
|
263
|
+
_optionalChain([onPress, 'optionalCall', _ => _(event)]);
|
|
264
|
+
},
|
|
265
|
+
[setSelected, isIndeterminate, onPress]
|
|
266
|
+
);
|
|
267
|
+
const selection = {
|
|
268
|
+
variant,
|
|
269
|
+
size,
|
|
270
|
+
radius,
|
|
271
|
+
isInvalid: isInvalid ? "true" : void 0
|
|
272
|
+
};
|
|
273
|
+
const states = { pressed: isPressed, disabled: isDisabled };
|
|
274
|
+
const styles = checkboxRecipe.resolve({ theme, selection, states });
|
|
275
|
+
const tint = color && !isInvalid ? checkboxRecipe.tint({ theme, color, selection, states }) : void 0;
|
|
276
|
+
const context = _react.useMemo.call(void 0,
|
|
277
|
+
() => ({
|
|
278
|
+
// The tint never reaches the box **at rest**, only the two nodes that say the box
|
|
279
|
+
// is ticked. `paint` writes the resting fill from `bg` and the tint pass re-runs
|
|
280
|
+
// `paint`, so applying `tint.indicator` here would paint an unticked box in the
|
|
281
|
+
// caller's brand colour — which reads as ticked, which is the one thing it is not.
|
|
282
|
+
indicatorStyle: styles.indicator,
|
|
283
|
+
fillStyle: tint ? [styles.fill, tint.fill] : styles.fill,
|
|
284
|
+
checkStyle: tint ? [styles.check, tint.check] : styles.check,
|
|
285
|
+
dashStyle: tint ? [styles.dash, tint.dash] : styles.dash,
|
|
286
|
+
labelStyle: styles.label,
|
|
287
|
+
isSelected: selected,
|
|
288
|
+
isIndeterminate,
|
|
289
|
+
isDisabled,
|
|
290
|
+
isInvalid
|
|
291
|
+
}),
|
|
292
|
+
[styles, tint, selected, isIndeterminate, isDisabled, isInvalid]
|
|
293
|
+
);
|
|
294
|
+
const rootStyle = [
|
|
295
|
+
styles.root,
|
|
296
|
+
_optionalChain([tint, 'optionalAccess', _2 => _2.root]),
|
|
297
|
+
styleProps,
|
|
298
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
299
|
+
];
|
|
300
|
+
const text = _chunk7GHM4GKLcjs.childrenToString.call(void 0, children);
|
|
301
|
+
const content = text !== null ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
302
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckboxIndicator, {}),
|
|
303
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckboxLabel, { children: text })
|
|
304
|
+
] }) : _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckboxIndicator, {})));
|
|
305
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckboxProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
306
|
+
_chunk3E7CDKFOcjs.PressableFeedback,
|
|
307
|
+
{
|
|
308
|
+
ref,
|
|
309
|
+
isPressed,
|
|
310
|
+
isDisabled,
|
|
311
|
+
asChild,
|
|
312
|
+
animation,
|
|
313
|
+
accessibilityRole: _nullishCoalesce(accessibilityRole, () => ( "checkbox")),
|
|
314
|
+
accessibilityState: {
|
|
315
|
+
// `'mixed'` is the platform's own word for the third state, and it is the only
|
|
316
|
+
// thing that tells a screen reader this box speaks for rows it cannot see.
|
|
317
|
+
checked: isIndeterminate ? "mixed" : selected,
|
|
318
|
+
disabled: isDisabled,
|
|
319
|
+
...accessibilityState
|
|
320
|
+
},
|
|
321
|
+
"aria-invalid": isInvalid,
|
|
322
|
+
...rest,
|
|
323
|
+
style: rootStyle,
|
|
324
|
+
onPress: handlePress,
|
|
325
|
+
onPressIn: press.onPressIn,
|
|
326
|
+
onPressOut: press.onPressOut,
|
|
327
|
+
children: asChild ? children : content
|
|
328
|
+
}
|
|
329
|
+
) });
|
|
330
|
+
});
|
|
331
|
+
CheckboxRoot.displayName = "XAUI.Checkbox.Root";
|
|
332
|
+
|
|
333
|
+
// src/components/checkbox/index.ts
|
|
334
|
+
var Checkbox2 = Object.assign(CheckboxRoot, {
|
|
335
|
+
Indicator: CheckboxIndicator,
|
|
336
|
+
Label: CheckboxLabel
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
exports.useCheckbox = useCheckbox; exports.CheckboxIndicator = CheckboxIndicator; exports.CheckboxLabel = CheckboxLabel; exports.checkboxRecipe = checkboxRecipe; exports.CheckboxRoot = CheckboxRoot; exports.Checkbox = Checkbox2;
|