@xaui/native 0.9.1-alpha.91 → 0.9.1-alpha.92
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-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-KPKEZWZM.js +517 -0
- package/dist/chunk-LKRQUQZQ.cjs +487 -0
- package/dist/{chunk-LIEXFWTN.js → chunk-P5M5URAB.js} +29 -126
- package/dist/chunk-UR37LVPU.cjs +382 -0
- 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 +31 -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 +31 -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 +71 -0
- package/dist/components/pager/pager.d.ts +71 -0
- package/dist/components/pager/pager.recipe.d.cts +15 -0
- package/dist/components/pager/pager.recipe.d.ts +15 -0
- package/dist/components/pager/pager.type.d.cts +108 -0
- package/dist/components/pager/pager.type.d.ts +108 -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 +90 -29
- package/dist/index.js +146 -85
- package/package.json +31 -1
- package/dist/chunk-K5UO3HBW.cjs +0 -1007
|
@@ -0,0 +1,487 @@
|
|
|
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 _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkOW4N2C3Mcjs = require('./chunk-OW4N2C3M.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkGSZDN6EZcjs = require('./chunk-GSZDN6EZ.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkFHNIGHN5cjs = require('./chunk-FHNIGHN5.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkSL3V7R2Ycjs = require('./chunk-SL3V7R2Y.cjs');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _chunkCDRGTUYFcjs = require('./chunk-CDRGTUYF.cjs');
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var _chunkIIAQISBGcjs = require('./chunk-IIAQISBG.cjs');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
29
|
+
|
|
30
|
+
// src/components/number-pad/number-pad-action.tsx
|
|
31
|
+
var _react = require('react');
|
|
32
|
+
|
|
33
|
+
// src/components/number-pad/number-pad-cell.tsx
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// src/components/number-pad/number-pad.context.ts
|
|
37
|
+
var [NumberPadProvider, useNumberPad] = _chunkCDRGTUYFcjs.createSlotContext.call(void 0, "NumberPad");
|
|
38
|
+
var [NumberPadCellProvider, useNumberPadCell] = _chunkCDRGTUYFcjs.createSlotContext.call(void 0, "NumberPad.Cell");
|
|
39
|
+
|
|
40
|
+
// src/components/number-pad/number-pad-cell.tsx
|
|
41
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
42
|
+
var NumberPadCell = _react.forwardRef.call(void 0,
|
|
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] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
58
|
+
const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
|
|
59
|
+
const disabled = _nullishCoalesce(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
|
+
_optionalChain([onPress, 'optionalCall', _ => _(event)]);
|
|
64
|
+
_optionalChain([onActivate, 'optionalCall', _2 => _2()]);
|
|
65
|
+
};
|
|
66
|
+
const context = _react.useMemo.call(void 0,
|
|
67
|
+
() => ({ tone, isPressed, isDisabled: disabled }),
|
|
68
|
+
[tone, isPressed, disabled]
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
71
|
+
_chunkOW4N2C3Mcjs.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__ */ _jsxruntime.jsx.call(void 0, 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
|
+
|
|
97
|
+
var NumberPadAction = _react.forwardRef.call(void 0,
|
|
98
|
+
function NumberPadAction2({ children, ...props }, ref) {
|
|
99
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 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
|
+
|
|
106
|
+
var _reactnative = require('react-native');
|
|
107
|
+
|
|
108
|
+
// src/components/number-pad/number-pad-label.tsx
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
var NumberPadLabel = _react.forwardRef.call(void 0,
|
|
113
|
+
function NumberPadLabel2({ children, style, numberOfLines = 1, ...props }, ref) {
|
|
114
|
+
const { labelStyle, ghostLabelStyle } = useNumberPad();
|
|
115
|
+
const { tone } = useNumberPadCell();
|
|
116
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
117
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
118
|
+
_reactnative.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
|
+
|
|
133
|
+
var NumberPadBackspace = _react.forwardRef.call(void 0,
|
|
134
|
+
function NumberPadBackspace2({ children, onLongPress, ...props }, ref) {
|
|
135
|
+
const { backspace, clear } = useNumberPad();
|
|
136
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
137
|
+
NumberPadCell,
|
|
138
|
+
{
|
|
139
|
+
ref,
|
|
140
|
+
tone: "ghost",
|
|
141
|
+
onActivate: backspace,
|
|
142
|
+
accessibilityLabel: "Backspace",
|
|
143
|
+
onLongPress: (event) => {
|
|
144
|
+
_optionalChain([onLongPress, 'optionalCall', _3 => _3(event)]);
|
|
145
|
+
clear();
|
|
146
|
+
},
|
|
147
|
+
...props,
|
|
148
|
+
children: _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberPadLabel, { children: _reactnative.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
|
+
|
|
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__ */ _jsxruntime.jsx.call(void 0, _chunkGSZDN6EZcjs.Icon, { size: _nullishCoalesce(size, () => ( resolved.size)), color: _nullishCoalesce(color, () => ( resolved.color)), ...rest });
|
|
162
|
+
}
|
|
163
|
+
NumberPadIcon.displayName = "XAUI.NumberPad.Icon";
|
|
164
|
+
|
|
165
|
+
// src/components/number-pad/number-pad-key.tsx
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
var NumberPadKey = _react.forwardRef.call(void 0,
|
|
169
|
+
function NumberPadKey2({ value, children, ...props }, ref) {
|
|
170
|
+
const { insert } = useNumberPad();
|
|
171
|
+
const text = _chunkFHNIGHN5cjs.childrenToString.call(void 0, children);
|
|
172
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, NumberPadLabel, { children: _nullishCoalesce(text, () => ( value)) }) : children
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
NumberPadKey.displayName = "XAUI.NumberPad.Key";
|
|
186
|
+
|
|
187
|
+
// src/components/number-pad/number-pad.tsx
|
|
188
|
+
|
|
189
|
+
|
|
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 = _chunkSL3V7R2Ycjs.createRecipe.call(void 0, {
|
|
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: _chunkSL3V7R2Ycjs.radiusAxis.call(void 0, "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
|
+
|
|
323
|
+
var numberPadSheet = _reactnative.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
|
+
|
|
348
|
+
var NumberPadRoot = _react.forwardRef.call(void 0, 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 = _chunkIIAQISBGcjs.useXAUITheme.call(void 0, );
|
|
365
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
366
|
+
const [value, setValue] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
|
|
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 = _react.useCallback.call(void 0,
|
|
387
|
+
(text) => {
|
|
388
|
+
const next = appendKey({ value, insert: text, maxLength });
|
|
389
|
+
if (next === value) return;
|
|
390
|
+
setValue(next);
|
|
391
|
+
if (isComplete(next, maxLength)) _optionalChain([onComplete, 'optionalCall', _4 => _4(next)]);
|
|
392
|
+
},
|
|
393
|
+
[value, maxLength, setValue, onComplete]
|
|
394
|
+
);
|
|
395
|
+
const backspace = _react.useCallback.call(void 0, () => {
|
|
396
|
+
if (value === "") return;
|
|
397
|
+
setValue(removeLast(value));
|
|
398
|
+
}, [value, setValue]);
|
|
399
|
+
const clear = _react.useCallback.call(void 0, () => {
|
|
400
|
+
if (value === "") return;
|
|
401
|
+
setValue("");
|
|
402
|
+
}, [value, setValue]);
|
|
403
|
+
const context = _react.useMemo.call(void 0, () => {
|
|
404
|
+
const glyph = (...layers) => {
|
|
405
|
+
const flat = _reactnative.StyleSheet.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, _optionalChain([tint, 'optionalAccess', _5 => _5.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, _optionalChain([tint, 'optionalAccess', _6 => _6.root]), styleProps, style];
|
|
445
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberPadProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
446
|
+
_reactnative.View,
|
|
447
|
+
{
|
|
448
|
+
ref,
|
|
449
|
+
accessibilityRole,
|
|
450
|
+
...rest,
|
|
451
|
+
style: rootStyle,
|
|
452
|
+
children: [
|
|
453
|
+
NUMBER_PAD_ROWS.map((row) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: styles.row, children: row.map((digit) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberPadKey, { value: digit }, digit)) }, row.join(""))),
|
|
454
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactnative.View, { style: styles.row, children: [
|
|
455
|
+
_nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: numberPadSheet.spacer }))),
|
|
456
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberPadKey, { value: NUMBER_PAD_ZERO }),
|
|
457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, 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
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
exports.useNumberPad = useNumberPad; exports.useNumberPadCell = useNumberPadCell; exports.NumberPadAction = NumberPadAction; exports.NumberPadLabel = NumberPadLabel; exports.NumberPadBackspace = NumberPadBackspace; exports.NumberPadIcon = NumberPadIcon; exports.NumberPadKey = NumberPadKey; exports.numberPadRecipe = numberPadRecipe; exports.NUMBER_PAD_ROWS = NUMBER_PAD_ROWS; exports.NUMBER_PAD_ZERO = NUMBER_PAD_ZERO; exports.NumberPadRoot = NumberPadRoot; exports.NumberPad = NumberPad2;
|