@xaui/native 0.9.1-alpha.42 → 0.9.1-alpha.44

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CloseButton,
3
3
  closeButtonBase
4
- } from "./chunk-EYD4H4X6.js";
4
+ } from "./chunk-VIJTAIGH.js";
5
5
  import {
6
6
  Icon
7
7
  } from "./chunk-FHUYHV6J.js";
@@ -0,0 +1,401 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
+
4
+ var _chunkQ2OCIQOCcjs = require('./chunk-Q2OCIQOC.cjs');
5
+
6
+
7
+ var _chunkWDDXU3OHcjs = require('./chunk-WDDXU3OH.cjs');
8
+
9
+
10
+
11
+ var _chunkEKS3W46Mcjs = require('./chunk-EKS3W46M.cjs');
12
+
13
+
14
+ var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
15
+
16
+
17
+ var _chunkTGMVEHV7cjs = require('./chunk-TGMVEHV7.cjs');
18
+
19
+
20
+ var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
21
+
22
+
23
+ var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
24
+
25
+
26
+
27
+ var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
28
+
29
+
30
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
31
+
32
+
33
+ var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
34
+
35
+ // src/components/dialog/dialog-close.tsx
36
+ var _react = require('react');
37
+
38
+ // src/components/dialog/dialog.context.ts
39
+ var [DialogProvider, useDialog] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "Dialog");
40
+
41
+ // src/components/dialog/dialog-close.tsx
42
+ var _jsxruntime = require('react/jsx-runtime');
43
+ var DialogClose = _react.forwardRef.call(void 0, function DialogClose2({ asChild = false, onPress, ...props }, ref) {
44
+ const { close, closeStyle, closeGlyphStyle } = useDialog();
45
+ const handlePress = _react.useCallback.call(void 0,
46
+ (event) => {
47
+ _optionalChain([onPress, 'optionalCall', _ => _(event)]);
48
+ close();
49
+ },
50
+ [close, onPress]
51
+ );
52
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
53
+ _chunkQ2OCIQOCcjs.CloseButton,
54
+ {
55
+ ref,
56
+ name: "Dialog.Close",
57
+ asChild,
58
+ baseStyle: asChild ? void 0 : closeStyle,
59
+ glyphStyle: closeGlyphStyle,
60
+ onPress: handlePress,
61
+ ...props
62
+ }
63
+ );
64
+ });
65
+ DialogClose.displayName = "XAUI.Dialog.Close";
66
+
67
+ // src/components/dialog/dialog-content.tsx
68
+
69
+ var _reactnative = require('react-native');
70
+ var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
71
+
72
+ // src/components/dialog/dialog.animation.ts
73
+
74
+ var ENTER_MS = 200;
75
+ var EXIT_MS = 150;
76
+ var contentEntering = new (0, _reactnativereanimated.Keyframe)({
77
+ 0: { opacity: 0, transform: [{ scale: 0.94 }] },
78
+ 100: {
79
+ opacity: 1,
80
+ transform: [{ scale: 1 }],
81
+ easing: _reactnativereanimated.Easing.out(_reactnativereanimated.Easing.cubic)
82
+ }
83
+ }).duration(ENTER_MS);
84
+ var contentExiting = new (0, _reactnativereanimated.Keyframe)({
85
+ 0: { opacity: 1, transform: [{ scale: 1 }] },
86
+ 100: {
87
+ opacity: 0,
88
+ transform: [{ scale: 0.94 }],
89
+ easing: _reactnativereanimated.Easing.in(_reactnativereanimated.Easing.cubic)
90
+ }
91
+ }).duration(EXIT_MS);
92
+
93
+ // src/components/dialog/dialog-content.tsx
94
+
95
+ var DialogContent = _react.forwardRef.call(void 0,
96
+ function DialogContent2({ children, accessibilityViewIsModal = true, style, ...props }, ref) {
97
+ const context = useDialog();
98
+ const { panelStyle, contentStyle, isOpen } = context;
99
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
100
+ if (!isOpen) return null;
101
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWDDXU3OHcjs.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { pointerEvents: "box-none", style: panelStyle, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
102
+ _reactnativereanimated2.default.View,
103
+ {
104
+ ref,
105
+ entering: contentEntering,
106
+ exiting: contentExiting,
107
+ accessibilityViewIsModal,
108
+ accessibilityRole: "alert",
109
+ ...rest,
110
+ style: [contentStyle, styleProps, style],
111
+ children
112
+ }
113
+ ) }) }) });
114
+ }
115
+ );
116
+ DialogContent.displayName = "XAUI.Dialog.Content";
117
+
118
+ // src/components/dialog/dialog-description.tsx
119
+
120
+
121
+
122
+ var DialogDescription = _react.forwardRef.call(void 0,
123
+ function DialogDescription2({ children, style, ...props }, ref) {
124
+ const { descriptionStyle } = useDialog();
125
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
126
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, ...rest, style: [descriptionStyle, styleProps, style], children });
127
+ }
128
+ );
129
+ DialogDescription.displayName = "XAUI.Dialog.Description";
130
+
131
+ // src/components/dialog/dialog-overlay.tsx
132
+
133
+
134
+
135
+
136
+ var AnimatedPressable = _reactnativereanimated2.default.createAnimatedComponent(_reactnative.Pressable);
137
+ var DialogOverlay = _react.forwardRef.call(void 0,
138
+ function DialogOverlay2({ children, isDismissable = true, style, ...props }, ref) {
139
+ const context = useDialog();
140
+ const { overlayStyle, isOpen, close } = context;
141
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
142
+ if (!isOpen) return null;
143
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWDDXU3OHcjs.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
144
+ AnimatedPressable,
145
+ {
146
+ ref,
147
+ entering: _chunkEKS3W46Mcjs.overlayEntering,
148
+ exiting: _chunkEKS3W46Mcjs.overlayExiting,
149
+ accessibilityRole: "none",
150
+ importantForAccessibility: "no",
151
+ onPress: isDismissable ? close : void 0,
152
+ ...rest,
153
+ style: [overlayStyle, styleProps, style],
154
+ children
155
+ }
156
+ ) }) });
157
+ }
158
+ );
159
+ DialogOverlay.displayName = "XAUI.Dialog.Overlay";
160
+
161
+ // src/components/dialog/dialog-title.tsx
162
+
163
+
164
+
165
+ var DialogTitle = _react.forwardRef.call(void 0, function DialogTitle2({ children, accessibilityRole = "header", style, ...props }, ref) {
166
+ const { titleStyle } = useDialog();
167
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
168
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
169
+ _reactnative.Text,
170
+ {
171
+ ref,
172
+ accessibilityRole,
173
+ ...rest,
174
+ style: [titleStyle, styleProps, style],
175
+ children
176
+ }
177
+ );
178
+ });
179
+ DialogTitle.displayName = "XAUI.Dialog.Title";
180
+
181
+ // src/components/dialog/dialog-trigger.tsx
182
+
183
+
184
+ var DialogTrigger = _react.forwardRef.call(void 0,
185
+ function DialogTrigger2({
186
+ children,
187
+ asChild = false,
188
+ accessibilityRole = "button",
189
+ accessibilityState,
190
+ style,
191
+ onPress,
192
+ onPressIn,
193
+ onPressOut,
194
+ ...props
195
+ }, ref) {
196
+ const { isOpen, isDisabled, toggle } = useDialog();
197
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
198
+ const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
199
+ const handlePress = _react.useCallback.call(void 0,
200
+ (event) => {
201
+ _optionalChain([onPress, 'optionalCall', _2 => _2(event)]);
202
+ toggle();
203
+ },
204
+ [onPress, toggle]
205
+ );
206
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
207
+ _chunkTGMVEHV7cjs.PressableFeedback,
208
+ {
209
+ ref,
210
+ isPressed,
211
+ isDisabled,
212
+ asChild,
213
+ accessibilityRole,
214
+ accessibilityState: {
215
+ disabled: isDisabled,
216
+ expanded: isOpen,
217
+ ...accessibilityState
218
+ },
219
+ ...rest,
220
+ style: [
221
+ styleProps,
222
+ typeof style === "function" ? style({ pressed: isPressed }) : style
223
+ ],
224
+ onPress: handlePress,
225
+ onPressIn: press.onPressIn,
226
+ onPressOut: press.onPressOut,
227
+ children
228
+ }
229
+ );
230
+ }
231
+ );
232
+ DialogTrigger.displayName = "XAUI.Dialog.Trigger";
233
+
234
+ // src/components/dialog/dialog.tsx
235
+
236
+
237
+ // src/components/dialog/dialog.recipe.ts
238
+ var SLOTS = [
239
+ "overlay",
240
+ "panel",
241
+ "content",
242
+ "title",
243
+ "description",
244
+ "close",
245
+ "closeGlyph"
246
+ ];
247
+ var CLOSE_BOX = 32;
248
+ var CLOSE_BAR = 16;
249
+ var dialogRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
250
+ slots: SLOTS,
251
+ base: (theme) => {
252
+ const shared = _chunkQ2OCIQOCcjs.closeButtonBase.call(void 0, theme);
253
+ return {
254
+ // Unlike the `Popover`'s, this backdrop dims by default. A popover is an aside you can
255
+ // read the page around; a dialog is a question, and the page behind it is not
256
+ // available until it is answered.
257
+ overlay: {
258
+ position: "absolute",
259
+ top: 0,
260
+ bottom: 0,
261
+ start: 0,
262
+ end: 0,
263
+ backgroundColor: theme.colors.backdrop
264
+ },
265
+ /**
266
+ * The layer the panel is centred in, filling the portal. It is not the panel: a
267
+ * centred box cannot also be the thing that centres it, and the padding here is the
268
+ * margin the dialog keeps from the screen's edges rather than its own inner padding.
269
+ */
270
+ panel: {
271
+ position: "absolute",
272
+ top: 0,
273
+ bottom: 0,
274
+ start: 0,
275
+ end: 0,
276
+ justifyContent: "center",
277
+ padding: theme.spacing(5)
278
+ },
279
+ content: {
280
+ backgroundColor: theme.colors.overlay,
281
+ padding: theme.spacing(5),
282
+ // HeroUI's `--radius-3xl` on a base of 8 is 24 points; our base is 12, so the same
283
+ // 24 is `2xl`. Reading their key rather than their number puts a pill on it.
284
+ borderRadius: theme.radius["2xl"],
285
+ borderCurve: "continuous",
286
+ gap: theme.spacing(2),
287
+ ...theme.shadows.overlay
288
+ },
289
+ title: {
290
+ fontFamily: theme.fontFamilies.body,
291
+ fontWeight: theme.fontWeights.medium,
292
+ fontSize: theme.fontSizes.lg,
293
+ lineHeight: theme.lineHeights.lg,
294
+ color: theme.colors.overlayForeground
295
+ },
296
+ description: {
297
+ fontFamily: theme.fontFamilies.body,
298
+ fontSize: theme.fontSizes.md,
299
+ lineHeight: theme.lineHeights.md,
300
+ color: theme.colors.muted
301
+ },
302
+ /**
303
+ * A filled disc, not a bare glyph. Their `CloseButton` is a `tertiary` button, and
304
+ * their `tertiary` is `background-color: var(--color-default)` — the same token our
305
+ * `secondary` names. A cross floating on the panel with nothing under it reads as
306
+ * decoration; the disc is what makes it a target.
307
+ *
308
+ * It positions nothing. Where the cross sits is the caller's, exactly as it is
309
+ * theirs: `alignSelf: 'flex-end'` above a title that spans the panel, or absolute in
310
+ * the corner over one short enough to leave it free. A slot that placed itself would
311
+ * have to guess which, and their own examples use both.
312
+ */
313
+ close: {
314
+ ...shared.close,
315
+ width: CLOSE_BOX,
316
+ height: CLOSE_BOX,
317
+ borderRadius: CLOSE_BOX / 2,
318
+ backgroundColor: theme.colors.default
319
+ },
320
+ // `muted`, like theirs: the cross is the way out, not the answer. The answer is a
321
+ // `Button` in the words the dialog asked for.
322
+ closeGlyph: {
323
+ ...shared.closeGlyph,
324
+ width: CLOSE_BAR,
325
+ backgroundColor: theme.colors.muted
326
+ }
327
+ };
328
+ },
329
+ /**
330
+ * One variant, and it is not a gap. A dialog is the theme's floating surface: it has no
331
+ * emphasis to report — the question it asks is in its words, not in its fill. The recipe
332
+ * keeps a single-entry `variantTokens` because `resolveTint` walks that mapping.
333
+ */
334
+ variantTokens: { default: {} },
335
+ variants: { radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "content") },
336
+ defaultVariants: { variant: "default" }
337
+ });
338
+
339
+ // src/components/dialog/dialog.tsx
340
+
341
+ function Dialog({
342
+ children,
343
+ radius,
344
+ isOpen: controlledOpen,
345
+ defaultOpen = false,
346
+ onOpenChange,
347
+ isDisabled = false
348
+ }) {
349
+ const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
350
+ const [isOpen, setOpen] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
351
+ value: controlledOpen,
352
+ defaultValue: defaultOpen,
353
+ onChange: onOpenChange
354
+ });
355
+ const styles = dialogRecipe.resolve({ theme, selection: { radius } });
356
+ const open = _react.useCallback.call(void 0, () => setOpen(true), [setOpen]);
357
+ const close = _react.useCallback.call(void 0, () => setOpen(false), [setOpen]);
358
+ const toggle = _react.useCallback.call(void 0, () => setOpen((current) => !current), [setOpen]);
359
+ const context = _react.useMemo.call(void 0,
360
+ () => ({
361
+ overlayStyle: styles.overlay,
362
+ panelStyle: styles.panel,
363
+ contentStyle: styles.content,
364
+ titleStyle: styles.title,
365
+ descriptionStyle: styles.description,
366
+ closeStyle: styles.close,
367
+ closeGlyphStyle: styles.closeGlyph,
368
+ isOpen,
369
+ isDisabled,
370
+ open,
371
+ close,
372
+ toggle
373
+ }),
374
+ [styles, isOpen, isDisabled, open, close, toggle]
375
+ );
376
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogProvider, { value: context, children });
377
+ }
378
+ Dialog.displayName = "XAUI.Dialog.Root";
379
+
380
+ // src/components/dialog/index.ts
381
+ var Dialog2 = Object.assign(Dialog, {
382
+ Trigger: DialogTrigger,
383
+ Overlay: DialogOverlay,
384
+ Content: DialogContent,
385
+ Title: DialogTitle,
386
+ Description: DialogDescription,
387
+ Close: DialogClose
388
+ });
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+ exports.useDialog = useDialog; exports.DialogClose = DialogClose; exports.DialogContent = DialogContent; exports.DialogDescription = DialogDescription; exports.DialogOverlay = DialogOverlay; exports.DialogTitle = DialogTitle; exports.DialogTrigger = DialogTrigger; exports.dialogRecipe = dialogRecipe; exports.Dialog = Dialog; exports.Dialog2 = Dialog2;
@@ -1,7 +1,7 @@
1
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
2
 
3
3
 
4
- var _chunkAAVCMCJ3cjs = require('./chunk-AAVCMCJ3.cjs');
4
+ var _chunkQ2OCIQOCcjs = require('./chunk-Q2OCIQOC.cjs');
5
5
 
6
6
 
7
7
  var _chunk4KFKWBN5cjs = require('./chunk-4KFKWBN5.cjs');
@@ -32,7 +32,7 @@ var _jsxruntime = require('react/jsx-runtime');
32
32
  var AlertClose = _react.forwardRef.call(void 0, function AlertClose2({ isDisabled, ...props }, ref) {
33
33
  const { closeStyle, closeGlyphStyle, isDisabled: isAlertDisabled } = useAlert();
34
34
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
35
- _chunkAAVCMCJ3cjs.CloseButton,
35
+ _chunkQ2OCIQOCcjs.CloseButton,
36
36
  {
37
37
  ref,
38
38
  name: "Alert.Close",
@@ -194,7 +194,7 @@ var alertRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
194
194
  // The cross's own geometry — thickness and centring — belongs to the shared
195
195
  // `CloseButton`; what stays below is the box and bar size this component's scale sets.
196
196
  base: (theme) => ({
197
- ..._chunkAAVCMCJ3cjs.closeButtonBase.call(void 0, theme),
197
+ ..._chunkQ2OCIQOCcjs.closeButtonBase.call(void 0, theme),
198
198
  root: {
199
199
  flexDirection: "row",
200
200
  // Top-aligned, not centred: an alert's message can run to three lines, and an icon
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CloseButton,
3
3
  closeButtonBase
4
- } from "./chunk-EYD4H4X6.js";
4
+ } from "./chunk-VIJTAIGH.js";
5
5
  import {
6
6
  Icon
7
7
  } from "./chunk-FHUYHV6J.js";