@xaui/native 0.9.1-alpha.91 → 0.9.1-alpha.93
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-2SHWOFQV.js +495 -0
- package/dist/chunk-3A5RK2R7.js +40 -0
- package/dist/chunk-6JAGPPZU.cjs +788 -0
- package/dist/chunk-7NQL5DXY.js +302 -0
- package/dist/chunk-FTPPUTWL.cjs +40 -0
- package/dist/chunk-GGP2ERSV.js +487 -0
- package/dist/chunk-LKRQUQZQ.cjs +487 -0
- package/dist/chunk-OPLPLFGK.cjs +493 -0
- package/dist/{chunk-LIEXFWTN.js → chunk-P5M5URAB.js} +29 -126
- package/dist/chunk-XWIPLZTD.cjs +302 -0
- package/dist/components/carousel/index.cjs +3 -2
- package/dist/components/carousel/index.js +2 -1
- package/dist/components/index.d.cts +3 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/number-pad/index.cjs +40 -0
- package/dist/components/number-pad/index.d.cts +60 -0
- package/dist/components/number-pad/index.d.ts +60 -0
- package/dist/components/number-pad/index.js +40 -0
- package/dist/components/number-pad/number-pad-action.d.cts +24 -0
- package/dist/components/number-pad/number-pad-action.d.ts +24 -0
- package/dist/components/number-pad/number-pad-backspace.d.cts +18 -0
- package/dist/components/number-pad/number-pad-backspace.d.ts +18 -0
- package/dist/components/number-pad/number-pad-cell.d.cts +7 -0
- package/dist/components/number-pad/number-pad-cell.d.ts +7 -0
- package/dist/components/number-pad/number-pad-icon.d.cts +13 -0
- package/dist/components/number-pad/number-pad-icon.d.ts +13 -0
- package/dist/components/number-pad/number-pad-key.d.cts +24 -0
- package/dist/components/number-pad/number-pad-key.d.ts +24 -0
- package/dist/components/number-pad/number-pad-label.d.cts +14 -0
- package/dist/components/number-pad/number-pad-label.d.ts +14 -0
- package/dist/components/number-pad/number-pad.context.d.cts +18 -0
- package/dist/components/number-pad/number-pad.context.d.ts +18 -0
- package/dist/components/number-pad/number-pad.d.cts +57 -0
- package/dist/components/number-pad/number-pad.d.ts +57 -0
- package/dist/components/number-pad/number-pad.recipe.d.cts +11 -0
- package/dist/components/number-pad/number-pad.recipe.d.ts +11 -0
- package/dist/components/number-pad/number-pad.style.d.cts +13 -0
- package/dist/components/number-pad/number-pad.style.d.ts +13 -0
- package/dist/components/number-pad/number-pad.type.d.cts +135 -0
- package/dist/components/number-pad/number-pad.type.d.ts +135 -0
- package/dist/components/number-pad/number-pad.utils.d.cts +34 -0
- package/dist/components/number-pad/number-pad.utils.d.ts +34 -0
- package/dist/components/pager/index.cjs +33 -0
- package/dist/components/pager/index.d.cts +60 -0
- package/dist/components/pager/index.d.ts +60 -0
- package/dist/components/pager/index.js +33 -0
- package/dist/components/pager/pager-content.d.cts +24 -0
- package/dist/components/pager/pager-content.d.ts +24 -0
- package/dist/components/pager/pager-indicator.d.cts +47 -0
- package/dist/components/pager/pager-indicator.d.ts +47 -0
- package/dist/components/pager/pager-page.d.cts +16 -0
- package/dist/components/pager/pager-page.d.ts +16 -0
- package/dist/components/pager/pager.context.d.cts +7 -0
- package/dist/components/pager/pager.context.d.ts +7 -0
- package/dist/components/pager/pager.d.cts +70 -0
- package/dist/components/pager/pager.d.ts +70 -0
- package/dist/components/pager/pager.recipe.d.cts +33 -0
- package/dist/components/pager/pager.recipe.d.ts +33 -0
- package/dist/components/pager/pager.type.d.cts +107 -0
- package/dist/components/pager/pager.type.d.ts +107 -0
- package/dist/components/rating/index.cjs +30 -0
- package/dist/components/rating/index.d.cts +41 -0
- package/dist/components/rating/index.d.ts +41 -0
- package/dist/components/rating/index.js +30 -0
- package/dist/components/rating/rating-icon.d.cts +16 -0
- package/dist/components/rating/rating-icon.d.ts +16 -0
- package/dist/components/rating/rating-item.d.cts +23 -0
- package/dist/components/rating/rating-item.d.ts +23 -0
- package/dist/components/rating/rating-star.d.cts +19 -0
- package/dist/components/rating/rating-star.d.ts +19 -0
- package/dist/components/rating/rating.context.d.cts +16 -0
- package/dist/components/rating/rating.context.d.ts +16 -0
- package/dist/components/rating/rating.d.cts +59 -0
- package/dist/components/rating/rating.d.ts +59 -0
- package/dist/components/rating/rating.recipe.d.cts +11 -0
- package/dist/components/rating/rating.recipe.d.ts +11 -0
- package/dist/components/rating/rating.style.d.cts +24 -0
- package/dist/components/rating/rating.style.d.ts +24 -0
- package/dist/components/rating/rating.type.d.cts +108 -0
- package/dist/components/rating/rating.type.d.ts +108 -0
- package/dist/components/rating/rating.utils.d.cts +28 -0
- package/dist/components/rating/rating.utils.d.ts +28 -0
- package/dist/index.cjs +91 -28
- package/dist/index.js +148 -85
- package/package.json +31 -1
- package/dist/chunk-K5UO3HBW.cjs +0 -1007
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useControllableState
|
|
3
|
+
} from "./chunk-F6W3JQ7K.js";
|
|
4
|
+
import {
|
|
5
|
+
PressableFeedback
|
|
6
|
+
} from "./chunk-2AFA5HA2.js";
|
|
7
|
+
import {
|
|
8
|
+
usePressState
|
|
9
|
+
} from "./chunk-423RQBOX.js";
|
|
10
|
+
import {
|
|
11
|
+
Icon
|
|
12
|
+
} from "./chunk-JN6IRT2M.js";
|
|
13
|
+
import {
|
|
14
|
+
childrenToString
|
|
15
|
+
} from "./chunk-WFZDAXDI.js";
|
|
16
|
+
import {
|
|
17
|
+
createRecipe,
|
|
18
|
+
radiusAxis
|
|
19
|
+
} from "./chunk-DKVXTMIJ.js";
|
|
20
|
+
import {
|
|
21
|
+
createSlotContext
|
|
22
|
+
} from "./chunk-TTZOIXKE.js";
|
|
23
|
+
import {
|
|
24
|
+
useXAUITheme
|
|
25
|
+
} from "./chunk-Z6JBWRPL.js";
|
|
26
|
+
import {
|
|
27
|
+
useStyleProps
|
|
28
|
+
} from "./chunk-M63GFNKV.js";
|
|
29
|
+
|
|
30
|
+
// src/components/number-pad/number-pad-action.tsx
|
|
31
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
32
|
+
|
|
33
|
+
// src/components/number-pad/number-pad-cell.tsx
|
|
34
|
+
import { forwardRef, useMemo } from "react";
|
|
35
|
+
|
|
36
|
+
// src/components/number-pad/number-pad.context.ts
|
|
37
|
+
var [NumberPadProvider, useNumberPad] = createSlotContext("NumberPad");
|
|
38
|
+
var [NumberPadCellProvider, useNumberPadCell] = createSlotContext("NumberPad.Cell");
|
|
39
|
+
|
|
40
|
+
// src/components/number-pad/number-pad-cell.tsx
|
|
41
|
+
import { jsx } from "react/jsx-runtime";
|
|
42
|
+
var NumberPadCell = forwardRef(
|
|
43
|
+
function NumberPadCell2({
|
|
44
|
+
tone,
|
|
45
|
+
onActivate,
|
|
46
|
+
children,
|
|
47
|
+
isDisabled,
|
|
48
|
+
accessibilityRole = "button",
|
|
49
|
+
accessibilityState,
|
|
50
|
+
style,
|
|
51
|
+
onPress,
|
|
52
|
+
onPressIn,
|
|
53
|
+
onPressOut,
|
|
54
|
+
...props
|
|
55
|
+
}, ref) {
|
|
56
|
+
const pad = useNumberPad();
|
|
57
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
58
|
+
const [isPressed, press] = usePressState({ onPressIn, onPressOut });
|
|
59
|
+
const disabled = isDisabled ?? pad.isDisabled;
|
|
60
|
+
const cellStyle = tone === "key" ? pad.keyStyle : pad.ghostStyle;
|
|
61
|
+
const pressedStyle = tone === "key" ? pad.keyPressedStyle : pad.ghostPressedStyle;
|
|
62
|
+
const handlePress = (event) => {
|
|
63
|
+
onPress?.(event);
|
|
64
|
+
onActivate?.();
|
|
65
|
+
};
|
|
66
|
+
const context = useMemo(
|
|
67
|
+
() => ({ tone, isPressed, isDisabled: disabled }),
|
|
68
|
+
[tone, isPressed, disabled]
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
PressableFeedback,
|
|
72
|
+
{
|
|
73
|
+
ref,
|
|
74
|
+
isPressed,
|
|
75
|
+
isDisabled: disabled,
|
|
76
|
+
accessibilityRole,
|
|
77
|
+
accessibilityState: { disabled, ...accessibilityState },
|
|
78
|
+
...rest,
|
|
79
|
+
style: [
|
|
80
|
+
cellStyle,
|
|
81
|
+
isPressed && pressedStyle,
|
|
82
|
+
styleProps,
|
|
83
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
84
|
+
],
|
|
85
|
+
onPress: handlePress,
|
|
86
|
+
onPressIn: press.onPressIn,
|
|
87
|
+
onPressOut: press.onPressOut,
|
|
88
|
+
children: /* @__PURE__ */ jsx(NumberPadCellProvider, { value: context, children })
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
NumberPadCell.displayName = "XAUI.NumberPad.Cell";
|
|
94
|
+
|
|
95
|
+
// src/components/number-pad/number-pad-action.tsx
|
|
96
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
97
|
+
var NumberPadAction = forwardRef2(
|
|
98
|
+
function NumberPadAction2({ children, ...props }, ref) {
|
|
99
|
+
return /* @__PURE__ */ jsx2(NumberPadCell, { ref, tone: "ghost", ...props, children });
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
NumberPadAction.displayName = "XAUI.NumberPad.Action";
|
|
103
|
+
|
|
104
|
+
// src/components/number-pad/number-pad-backspace.tsx
|
|
105
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
106
|
+
import { I18nManager } from "react-native";
|
|
107
|
+
|
|
108
|
+
// src/components/number-pad/number-pad-label.tsx
|
|
109
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
110
|
+
import { Text } from "react-native";
|
|
111
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
112
|
+
var NumberPadLabel = forwardRef3(
|
|
113
|
+
function NumberPadLabel2({ children, style, numberOfLines = 1, ...props }, ref) {
|
|
114
|
+
const { labelStyle, ghostLabelStyle } = useNumberPad();
|
|
115
|
+
const { tone } = useNumberPadCell();
|
|
116
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
117
|
+
return /* @__PURE__ */ jsx3(
|
|
118
|
+
Text,
|
|
119
|
+
{
|
|
120
|
+
ref,
|
|
121
|
+
numberOfLines,
|
|
122
|
+
style: [tone === "key" ? labelStyle : ghostLabelStyle, styleProps, style],
|
|
123
|
+
...rest,
|
|
124
|
+
children
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
NumberPadLabel.displayName = "XAUI.NumberPad.Label";
|
|
130
|
+
|
|
131
|
+
// src/components/number-pad/number-pad-backspace.tsx
|
|
132
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
133
|
+
var NumberPadBackspace = forwardRef4(
|
|
134
|
+
function NumberPadBackspace2({ children, onLongPress, ...props }, ref) {
|
|
135
|
+
const { backspace, clear } = useNumberPad();
|
|
136
|
+
return /* @__PURE__ */ jsx4(
|
|
137
|
+
NumberPadCell,
|
|
138
|
+
{
|
|
139
|
+
ref,
|
|
140
|
+
tone: "ghost",
|
|
141
|
+
onActivate: backspace,
|
|
142
|
+
accessibilityLabel: "Backspace",
|
|
143
|
+
onLongPress: (event) => {
|
|
144
|
+
onLongPress?.(event);
|
|
145
|
+
clear();
|
|
146
|
+
},
|
|
147
|
+
...props,
|
|
148
|
+
children: children ?? /* @__PURE__ */ jsx4(NumberPadLabel, { children: I18nManager.isRTL ? "\u2192" : "\u2190" })
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
NumberPadBackspace.displayName = "XAUI.NumberPad.Backspace";
|
|
154
|
+
|
|
155
|
+
// src/components/number-pad/number-pad-icon.tsx
|
|
156
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
157
|
+
function NumberPadIcon({ size, color, ...rest }) {
|
|
158
|
+
const { icon, ghostIcon } = useNumberPad();
|
|
159
|
+
const { tone } = useNumberPadCell();
|
|
160
|
+
const resolved = tone === "key" ? icon : ghostIcon;
|
|
161
|
+
return /* @__PURE__ */ jsx5(Icon, { size: size ?? resolved.size, color: color ?? resolved.color, ...rest });
|
|
162
|
+
}
|
|
163
|
+
NumberPadIcon.displayName = "XAUI.NumberPad.Icon";
|
|
164
|
+
|
|
165
|
+
// src/components/number-pad/number-pad-key.tsx
|
|
166
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
167
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
168
|
+
var NumberPadKey = forwardRef5(
|
|
169
|
+
function NumberPadKey2({ value, children, ...props }, ref) {
|
|
170
|
+
const { insert } = useNumberPad();
|
|
171
|
+
const text = childrenToString(children);
|
|
172
|
+
return /* @__PURE__ */ jsx6(
|
|
173
|
+
NumberPadCell,
|
|
174
|
+
{
|
|
175
|
+
ref,
|
|
176
|
+
tone: "key",
|
|
177
|
+
onActivate: () => insert(value),
|
|
178
|
+
accessibilityLabel: value,
|
|
179
|
+
...props,
|
|
180
|
+
children: children === void 0 || text !== null ? /* @__PURE__ */ jsx6(NumberPadLabel, { children: text ?? value }) : children
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
NumberPadKey.displayName = "XAUI.NumberPad.Key";
|
|
186
|
+
|
|
187
|
+
// src/components/number-pad/number-pad.tsx
|
|
188
|
+
import { forwardRef as forwardRef6, useCallback, useMemo as useMemo2 } from "react";
|
|
189
|
+
import { StyleSheet as StyleSheet2, View } from "react-native";
|
|
190
|
+
|
|
191
|
+
// src/components/number-pad/number-pad.recipe.ts
|
|
192
|
+
var SLOTS = [
|
|
193
|
+
"root",
|
|
194
|
+
"row",
|
|
195
|
+
"key",
|
|
196
|
+
"label",
|
|
197
|
+
"icon",
|
|
198
|
+
"ghost",
|
|
199
|
+
"ghostLabel",
|
|
200
|
+
"ghostIcon"
|
|
201
|
+
];
|
|
202
|
+
var VARIANT_TOKENS = {
|
|
203
|
+
primary: { bg: "accent", bgPressed: "accentPressed", fg: "accentForeground" },
|
|
204
|
+
secondary: {
|
|
205
|
+
bg: "accentSoft",
|
|
206
|
+
bgPressed: "accentSoftPressed",
|
|
207
|
+
fg: "accentSoftForeground"
|
|
208
|
+
},
|
|
209
|
+
default: { bg: "default", bgPressed: "defaultPressed", fg: "defaultForeground" },
|
|
210
|
+
tertiary: { border: "border", bgPressed: "defaultSoftPressed", fg: "foreground" },
|
|
211
|
+
ghost: { bgPressed: "defaultSoftPressed", fg: "foreground" }
|
|
212
|
+
};
|
|
213
|
+
var KEY_HEIGHT_RATIO = 1.5;
|
|
214
|
+
function keyHeight(theme, size) {
|
|
215
|
+
return theme.controlHeights[size] * KEY_HEIGHT_RATIO;
|
|
216
|
+
}
|
|
217
|
+
function sizeAxis(step) {
|
|
218
|
+
const { size, gap, radius, digit, glyph } = step;
|
|
219
|
+
return (theme) => {
|
|
220
|
+
const height = keyHeight(theme, size);
|
|
221
|
+
const corner = theme.radius[radius];
|
|
222
|
+
return {
|
|
223
|
+
root: { gap: theme.spacing(gap) },
|
|
224
|
+
row: { gap: theme.spacing(gap) },
|
|
225
|
+
key: { height, borderRadius: corner },
|
|
226
|
+
ghost: { height, borderRadius: corner },
|
|
227
|
+
label: {
|
|
228
|
+
fontSize: theme.fontSizes[digit],
|
|
229
|
+
lineHeight: theme.lineHeights[digit]
|
|
230
|
+
},
|
|
231
|
+
ghostLabel: {
|
|
232
|
+
fontSize: theme.fontSizes[glyph],
|
|
233
|
+
lineHeight: theme.lineHeights[glyph]
|
|
234
|
+
},
|
|
235
|
+
icon: { fontSize: theme.fontSizes[glyph] },
|
|
236
|
+
ghostIcon: { fontSize: theme.fontSizes[glyph] }
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
var SIZES = {
|
|
241
|
+
sm: { size: "sm", gap: 2, radius: "xl", digit: "2xl", glyph: "lg" },
|
|
242
|
+
md: { size: "md", gap: 2.5, radius: "xl", digit: "3xl", glyph: "xl" },
|
|
243
|
+
lg: { size: "lg", gap: 3, radius: "2xl", digit: "4xl", glyph: "2xl" }
|
|
244
|
+
};
|
|
245
|
+
var numberPadRecipe = createRecipe({
|
|
246
|
+
slots: SLOTS,
|
|
247
|
+
base: (theme) => ({
|
|
248
|
+
row: { flexDirection: "row" },
|
|
249
|
+
// `flex: 1` on both, so the three columns divide the width the pad was given. The
|
|
250
|
+
// `borderCurve` is iOS's squircle, free on Android and what keeps a corner this large
|
|
251
|
+
// reading as a shape rather than as two arcs meeting a straight edge.
|
|
252
|
+
key: {
|
|
253
|
+
flex: 1,
|
|
254
|
+
alignItems: "center",
|
|
255
|
+
justifyContent: "center",
|
|
256
|
+
borderWidth: 0,
|
|
257
|
+
borderCurve: "continuous"
|
|
258
|
+
},
|
|
259
|
+
ghost: {
|
|
260
|
+
flex: 1,
|
|
261
|
+
alignItems: "center",
|
|
262
|
+
justifyContent: "center",
|
|
263
|
+
borderCurve: "continuous"
|
|
264
|
+
},
|
|
265
|
+
label: {
|
|
266
|
+
fontFamily: theme.fontFamilies.body,
|
|
267
|
+
fontWeight: theme.fontWeights.semibold,
|
|
268
|
+
textAlign: "center"
|
|
269
|
+
},
|
|
270
|
+
/**
|
|
271
|
+
* The bare cells read the **page's** foreground rather than the variant's, and they
|
|
272
|
+
* are painted here rather than in `paint` because that is exactly what makes them
|
|
273
|
+
* independent of it: a `primary` pad puts `accentForeground` on its digits, and a
|
|
274
|
+
* backspace with no ground of its own would take white on white. It is also why a raw
|
|
275
|
+
* `color` does not reach them — `resolveTint` re-runs `paint`, not `base`.
|
|
276
|
+
*/
|
|
277
|
+
ghostLabel: {
|
|
278
|
+
fontFamily: theme.fontFamilies.body,
|
|
279
|
+
fontWeight: theme.fontWeights.medium,
|
|
280
|
+
textAlign: "center",
|
|
281
|
+
color: theme.colors.foreground
|
|
282
|
+
},
|
|
283
|
+
ghostIcon: { color: theme.colors.foreground }
|
|
284
|
+
}),
|
|
285
|
+
variantTokens: VARIANT_TOKENS,
|
|
286
|
+
/**
|
|
287
|
+
* Where the variant's colours land. Only the filled keys: the border width follows the
|
|
288
|
+
* *presence* of the border role rather than a per-variant flag, and `tertiary` is the one
|
|
289
|
+
* variant that names one.
|
|
290
|
+
*/
|
|
291
|
+
paint: (theme, colors) => ({
|
|
292
|
+
key: {
|
|
293
|
+
backgroundColor: colors.bg,
|
|
294
|
+
borderColor: colors.border,
|
|
295
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
296
|
+
},
|
|
297
|
+
label: { color: colors.fg },
|
|
298
|
+
icon: { color: colors.fg }
|
|
299
|
+
}),
|
|
300
|
+
/** Declaration order is application order: `radius` overrides the corner `size` chose. */
|
|
301
|
+
variants: {
|
|
302
|
+
size: { sm: sizeAxis(SIZES.sm), md: sizeAxis(SIZES.md), lg: sizeAxis(SIZES.lg) },
|
|
303
|
+
radius: radiusAxis("key", "ghost")
|
|
304
|
+
},
|
|
305
|
+
/**
|
|
306
|
+
* A filled key presses to the variant's own `…Pressed` token, as the `Button` does. A
|
|
307
|
+
* bare cell has no fill to darken, so it takes the neutral wash instead — the same one
|
|
308
|
+
* `ghost` and `tertiary` take, which is what makes the backspace read as pressed on a
|
|
309
|
+
* pad of any variant.
|
|
310
|
+
*/
|
|
311
|
+
states: {
|
|
312
|
+
pressed: (theme, colors) => ({
|
|
313
|
+
key: { backgroundColor: colors.bgPressed },
|
|
314
|
+
ghost: { backgroundColor: theme.colors.defaultSoftPressed }
|
|
315
|
+
}),
|
|
316
|
+
disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
|
|
317
|
+
},
|
|
318
|
+
defaultVariants: { variant: "default", size: "md" }
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// src/components/number-pad/number-pad.style.ts
|
|
322
|
+
import { StyleSheet } from "react-native";
|
|
323
|
+
var numberPadSheet = StyleSheet.create({
|
|
324
|
+
spacer: { flex: 1 }
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
// src/components/number-pad/number-pad.utils.ts
|
|
328
|
+
var NUMBER_PAD_ROWS = [
|
|
329
|
+
["1", "2", "3"],
|
|
330
|
+
["4", "5", "6"],
|
|
331
|
+
["7", "8", "9"]
|
|
332
|
+
];
|
|
333
|
+
var NUMBER_PAD_ZERO = "0";
|
|
334
|
+
function appendKey({ value, insert, maxLength }) {
|
|
335
|
+
if (maxLength === void 0) return value + insert;
|
|
336
|
+
if (value.length + insert.length > maxLength) return value;
|
|
337
|
+
return value + insert;
|
|
338
|
+
}
|
|
339
|
+
function removeLast(value) {
|
|
340
|
+
return value.slice(0, -1);
|
|
341
|
+
}
|
|
342
|
+
function isComplete(value, maxLength) {
|
|
343
|
+
return maxLength !== void 0 && value.length >= maxLength;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/components/number-pad/number-pad.tsx
|
|
347
|
+
import { jsx as jsx7, jsxs } from "react/jsx-runtime";
|
|
348
|
+
var NumberPadRoot = forwardRef6(function NumberPad({
|
|
349
|
+
children,
|
|
350
|
+
variant,
|
|
351
|
+
size,
|
|
352
|
+
radius,
|
|
353
|
+
color,
|
|
354
|
+
value: controlledValue,
|
|
355
|
+
defaultValue = "",
|
|
356
|
+
onChangeText,
|
|
357
|
+
onComplete,
|
|
358
|
+
maxLength,
|
|
359
|
+
isDisabled = false,
|
|
360
|
+
accessibilityRole = "none",
|
|
361
|
+
style,
|
|
362
|
+
...props
|
|
363
|
+
}, ref) {
|
|
364
|
+
const theme = useXAUITheme();
|
|
365
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
366
|
+
const [value, setValue] = useControllableState({
|
|
367
|
+
value: controlledValue,
|
|
368
|
+
defaultValue,
|
|
369
|
+
onChange: onChangeText
|
|
370
|
+
});
|
|
371
|
+
const selection = { variant, size, radius };
|
|
372
|
+
const states = { disabled: isDisabled };
|
|
373
|
+
const styles = numberPadRecipe.resolve({ theme, selection, states });
|
|
374
|
+
const pressed = numberPadRecipe.resolve({
|
|
375
|
+
theme,
|
|
376
|
+
selection,
|
|
377
|
+
states: { ...states, pressed: true }
|
|
378
|
+
});
|
|
379
|
+
const tint = color ? numberPadRecipe.tint({ theme, color, selection, states }) : void 0;
|
|
380
|
+
const tintPressed = color ? numberPadRecipe.tint({
|
|
381
|
+
theme,
|
|
382
|
+
color,
|
|
383
|
+
selection,
|
|
384
|
+
states: { ...states, pressed: true }
|
|
385
|
+
}) : void 0;
|
|
386
|
+
const insert = useCallback(
|
|
387
|
+
(text) => {
|
|
388
|
+
const next = appendKey({ value, insert: text, maxLength });
|
|
389
|
+
if (next === value) return;
|
|
390
|
+
setValue(next);
|
|
391
|
+
if (isComplete(next, maxLength)) onComplete?.(next);
|
|
392
|
+
},
|
|
393
|
+
[value, maxLength, setValue, onComplete]
|
|
394
|
+
);
|
|
395
|
+
const backspace = useCallback(() => {
|
|
396
|
+
if (value === "") return;
|
|
397
|
+
setValue(removeLast(value));
|
|
398
|
+
}, [value, setValue]);
|
|
399
|
+
const clear = useCallback(() => {
|
|
400
|
+
if (value === "") return;
|
|
401
|
+
setValue("");
|
|
402
|
+
}, [value, setValue]);
|
|
403
|
+
const context = useMemo2(() => {
|
|
404
|
+
const glyph = (...layers) => {
|
|
405
|
+
const flat = StyleSheet2.flatten(layers);
|
|
406
|
+
return {
|
|
407
|
+
size: flat.fontSize,
|
|
408
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot hand
|
|
409
|
+
// to a third-party component expecting a string.
|
|
410
|
+
color: typeof flat.color === "string" ? flat.color : void 0
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
return {
|
|
414
|
+
rowStyle: styles.row,
|
|
415
|
+
keyStyle: tint ? [styles.key, tint.key] : styles.key,
|
|
416
|
+
keyPressedStyle: tintPressed ? [pressed.key, tintPressed.key] : pressed.key,
|
|
417
|
+
labelStyle: tint ? [styles.label, tint.label] : styles.label,
|
|
418
|
+
ghostStyle: styles.ghost,
|
|
419
|
+
ghostPressedStyle: pressed.ghost,
|
|
420
|
+
ghostLabelStyle: styles.ghostLabel,
|
|
421
|
+
icon: glyph(styles.icon, tint?.icon),
|
|
422
|
+
// Never tinted, deliberately: the bare corners read the page's foreground, because a
|
|
423
|
+
// glyph with no ground of its own has nothing tinted to read against.
|
|
424
|
+
ghostIcon: glyph(styles.ghostIcon),
|
|
425
|
+
insert,
|
|
426
|
+
backspace,
|
|
427
|
+
clear,
|
|
428
|
+
value,
|
|
429
|
+
maxLength,
|
|
430
|
+
isDisabled
|
|
431
|
+
};
|
|
432
|
+
}, [
|
|
433
|
+
styles,
|
|
434
|
+
pressed,
|
|
435
|
+
tint,
|
|
436
|
+
tintPressed,
|
|
437
|
+
insert,
|
|
438
|
+
backspace,
|
|
439
|
+
clear,
|
|
440
|
+
value,
|
|
441
|
+
maxLength,
|
|
442
|
+
isDisabled
|
|
443
|
+
]);
|
|
444
|
+
const rootStyle = [styles.root, tint?.root, styleProps, style];
|
|
445
|
+
return /* @__PURE__ */ jsx7(NumberPadProvider, { value: context, children: /* @__PURE__ */ jsxs(
|
|
446
|
+
View,
|
|
447
|
+
{
|
|
448
|
+
ref,
|
|
449
|
+
accessibilityRole,
|
|
450
|
+
...rest,
|
|
451
|
+
style: rootStyle,
|
|
452
|
+
children: [
|
|
453
|
+
NUMBER_PAD_ROWS.map((row) => /* @__PURE__ */ jsx7(View, { style: styles.row, children: row.map((digit) => /* @__PURE__ */ jsx7(NumberPadKey, { value: digit }, digit)) }, row.join(""))),
|
|
454
|
+
/* @__PURE__ */ jsxs(View, { style: styles.row, children: [
|
|
455
|
+
children ?? /* @__PURE__ */ jsx7(View, { style: numberPadSheet.spacer }),
|
|
456
|
+
/* @__PURE__ */ jsx7(NumberPadKey, { value: NUMBER_PAD_ZERO }),
|
|
457
|
+
/* @__PURE__ */ jsx7(NumberPadBackspace, {})
|
|
458
|
+
] })
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
) });
|
|
462
|
+
});
|
|
463
|
+
NumberPadRoot.displayName = "XAUI.NumberPad.Root";
|
|
464
|
+
|
|
465
|
+
// src/components/number-pad/index.ts
|
|
466
|
+
var NumberPad2 = Object.assign(NumberPadRoot, {
|
|
467
|
+
Key: NumberPadKey,
|
|
468
|
+
Backspace: NumberPadBackspace,
|
|
469
|
+
Action: NumberPadAction,
|
|
470
|
+
Label: NumberPadLabel,
|
|
471
|
+
Icon: NumberPadIcon
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
export {
|
|
475
|
+
useNumberPad,
|
|
476
|
+
useNumberPadCell,
|
|
477
|
+
NumberPadAction,
|
|
478
|
+
NumberPadLabel,
|
|
479
|
+
NumberPadBackspace,
|
|
480
|
+
NumberPadIcon,
|
|
481
|
+
NumberPadKey,
|
|
482
|
+
numberPadRecipe,
|
|
483
|
+
NUMBER_PAD_ROWS,
|
|
484
|
+
NUMBER_PAD_ZERO,
|
|
485
|
+
NumberPadRoot,
|
|
486
|
+
NumberPad2 as NumberPad
|
|
487
|
+
};
|