@xaui/native 0.0.12 → 0.0.14

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.
Files changed (45) hide show
  1. package/README.md +8 -1
  2. package/dist/accordion/index.cjs +7 -2
  3. package/dist/accordion/index.js +7 -2
  4. package/dist/alert/index.cjs +25 -188
  5. package/dist/alert/index.js +1 -2
  6. package/dist/autocomplete/index.cjs +106 -403
  7. package/dist/autocomplete/index.js +1 -3
  8. package/dist/bottom-sheet/index.cjs +470 -0
  9. package/dist/bottom-sheet/index.d.cts +84 -0
  10. package/dist/bottom-sheet/index.d.ts +84 -0
  11. package/dist/bottom-sheet/index.js +7 -0
  12. package/dist/button/index.cjs +126 -4
  13. package/dist/button/index.d.cts +63 -1
  14. package/dist/button/index.d.ts +63 -1
  15. package/dist/button/index.js +117 -3
  16. package/dist/checkbox/index.cjs +5 -1
  17. package/dist/checkbox/index.js +5 -1
  18. package/dist/{chunk-OFYJYQ2M.js → chunk-2T6FKPJW.js} +1 -3
  19. package/dist/{chunk-LM23DOX3.js → chunk-7OFTYKK4.js} +13 -33
  20. package/dist/chunk-GAOI4KIV.js +379 -0
  21. package/dist/{chunk-63LRW4QD.js → chunk-MKHBEJLO.js} +8 -1
  22. package/dist/{chunk-RL47NQAU.js → chunk-NMZUPH3R.js} +7 -12
  23. package/dist/datepicker/index.cjs +115 -836
  24. package/dist/datepicker/index.js +1 -3
  25. package/dist/index.cjs +739 -1174
  26. package/dist/index.d.cts +1 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +8 -6
  29. package/dist/indicator/index.cjs +8 -1
  30. package/dist/indicator/index.js +1 -1
  31. package/dist/menu/index.cjs +371 -0
  32. package/dist/menu/index.d.cts +107 -0
  33. package/dist/menu/index.d.ts +107 -0
  34. package/dist/menu/index.js +298 -0
  35. package/dist/select/index.cjs +40 -16
  36. package/dist/select/index.js +40 -16
  37. package/dist/view/index.cjs +12 -7
  38. package/dist/view/index.js +12 -7
  39. package/package.json +12 -6
  40. package/dist/chunk-CKGZOJVV.js +0 -815
  41. package/dist/chunk-SIXET7TJ.js +0 -172
  42. package/dist/icon/index.cjs +0 -1054
  43. package/dist/icon/index.d.cts +0 -42
  44. package/dist/icon/index.d.ts +0 -42
  45. package/dist/icon/index.js +0 -21
package/README.md CHANGED
@@ -57,6 +57,7 @@ function Banner() {
57
57
  ## Key components
58
58
 
59
59
  ### `Button`
60
+
60
61
  - Variants: `solid`, `outlined`, `flat`, `light`, `elevated`, `faded`
61
62
  - Sizes: `xs`, `sm`, `md`, `lg`
62
63
  - Radii: `none`, `sm`, `md`, `lg`, `full`
@@ -80,12 +81,18 @@ function Banner() {
80
81
  `useButtonStyles` exposes the internal calculations if you need to derive custom layouts (spacing, colors, shadows, spinner size).
81
82
 
82
83
  ### `ActivityIndicator`
84
+
83
85
  - Variants: `circular` (default size 40) and `linear` (custom height)
84
86
  - Draws from the theme colors (`primary`, `secondary`, etc.) and optionally renders a track with `showTrack`
85
87
  - `disableAnimation` is provided for snapshots or silent loading states
86
88
 
87
89
  ```tsx
88
- <ActivityIndicator variant="linear" themeColor="secondary" showTrack borderRadius={4} />
90
+ <ActivityIndicator
91
+ variant="linear"
92
+ themeColor="secondary"
93
+ showTrack
94
+ borderRadius={4}
95
+ />
89
96
  ```
90
97
 
91
98
  ## Theme hooks & utilities
@@ -41,7 +41,9 @@ var import_react_native9 = require("react-native");
41
41
 
42
42
  // src/components/accordion/accordion-context.ts
43
43
  var import_react = require("react");
44
- var AccordionContext = (0, import_react.createContext)(void 0);
44
+ var AccordionContext = (0, import_react.createContext)(
45
+ void 0
46
+ );
45
47
  var useAccordionContext = () => {
46
48
  const context = (0, import_react.useContext)(AccordionContext);
47
49
  if (!context) {
@@ -563,7 +565,10 @@ var Accordion = (props) => {
563
565
  return /* @__PURE__ */ import_react14.default.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { style: [containerStyles, customAppearance?.container] }, childrenArray.map((child, index) => {
564
566
  const isLast = index === childrenArray.length - 1;
565
567
  const showBottomDivider = (showDivider || variant === "bordered") && !isLast && variant !== "splitted";
566
- const resolvedChildKey = isAccordionItem(child) ? getItemKey(child.props.itemKey ?? normalizeElementKey(child.key), index) : getItemKey(
568
+ const resolvedChildKey = isAccordionItem(child) ? getItemKey(
569
+ child.props.itemKey ?? normalizeElementKey(child.key),
570
+ index
571
+ ) : getItemKey(
567
572
  import_react14.default.isValidElement(child) ? normalizeElementKey(child.key) : void 0,
568
573
  index
569
574
  );
@@ -12,7 +12,9 @@ import { View as View2 } from "react-native";
12
12
 
13
13
  // src/components/accordion/accordion-context.ts
14
14
  import { createContext, useContext } from "react";
15
- var AccordionContext = createContext(void 0);
15
+ var AccordionContext = createContext(
16
+ void 0
17
+ );
16
18
  var useAccordionContext = () => {
17
19
  const context = useContext(AccordionContext);
18
20
  if (!context) {
@@ -424,7 +426,10 @@ var Accordion = (props) => {
424
426
  return /* @__PURE__ */ React4.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ React4.createElement(View2, { style: [containerStyles, customAppearance?.container] }, childrenArray.map((child, index) => {
425
427
  const isLast = index === childrenArray.length - 1;
426
428
  const showBottomDivider = (showDivider || variant === "bordered") && !isLast && variant !== "splitted";
427
- const resolvedChildKey = isAccordionItem(child) ? getItemKey(child.props.itemKey ?? normalizeElementKey(child.key), index) : getItemKey(
429
+ const resolvedChildKey = isAccordionItem(child) ? getItemKey(
430
+ child.props.itemKey ?? normalizeElementKey(child.key),
431
+ index
432
+ ) : getItemKey(
428
433
  React4.isValidElement(child) ? normalizeElementKey(child.key) : void 0,
429
434
  index
430
435
  );
@@ -35,8 +35,8 @@ __export(alert_exports, {
35
35
  module.exports = __toCommonJS(alert_exports);
36
36
 
37
37
  // src/components/alert/alert.tsx
38
- var import_react9 = __toESM(require("react"), 1);
39
- var import_react_native6 = require("react-native");
38
+ var import_react8 = __toESM(require("react"), 1);
39
+ var import_react_native5 = require("react-native");
40
40
  var import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
41
41
 
42
42
  // src/components/alert/alert.style.ts
@@ -277,171 +277,8 @@ function DangerIcon({ color, size }) {
277
277
  ));
278
278
  }
279
279
 
280
- // src/components/icon/icons/close.tsx
281
- var import_react8 = __toESM(require("react"), 1);
282
- var import_react_native5 = require("react-native");
283
- var import_react_native_svg2 = __toESM(require("react-native-svg"), 1);
284
-
285
- // src/components/icon/icon.utils.ts
286
- var isThemeColor = (color) => {
287
- const themeColors = [
288
- "primary",
289
- "secondary",
290
- "tertiary",
291
- "danger",
292
- "warning",
293
- "success",
294
- "default"
295
- ];
296
- return themeColors.includes(color);
297
- };
298
-
299
- // src/components/icon/icons/close.tsx
300
- var AnimatedPath = import_react_native5.Animated.createAnimatedComponent(import_react_native_svg2.Path);
301
- var CloseIcon = ({
302
- variant = "baseline",
303
- size = 24,
304
- color = "default",
305
- isAnimated = false
306
- }) => {
307
- const theme = useXUITheme();
308
- const scaleAnim = (0, import_react8.useRef)(new import_react_native5.Animated.Value(isAnimated ? 0 : 1)).current;
309
- const opacityAnim = (0, import_react8.useRef)(new import_react_native5.Animated.Value(isAnimated ? 0 : 1)).current;
310
- const resolvedColor = (0, import_react8.useMemo)(() => {
311
- if (typeof color === "string" && isThemeColor(color)) {
312
- return theme.colors[color].main;
313
- }
314
- return color;
315
- }, [color, theme]);
316
- (0, import_react8.useEffect)(() => {
317
- if (isAnimated) {
318
- import_react_native5.Animated.parallel([
319
- import_react_native5.Animated.spring(scaleAnim, {
320
- toValue: 1,
321
- useNativeDriver: true,
322
- tension: 50,
323
- friction: 7
324
- }),
325
- import_react_native5.Animated.timing(opacityAnim, {
326
- toValue: 1,
327
- duration: 200,
328
- useNativeDriver: true
329
- })
330
- ]).start();
331
- }
332
- }, [isAnimated, scaleAnim, opacityAnim]);
333
- const animatedProps = isAnimated ? {
334
- transform: [{ scale: scaleAnim }],
335
- opacity: opacityAnim
336
- } : void 0;
337
- const renderBaseline = () => /* @__PURE__ */ import_react8.default.createElement(
338
- AnimatedPath,
339
- {
340
- fill: resolvedColor,
341
- d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
342
- ...animatedProps
343
- }
344
- );
345
- const renderFilled = () => /* @__PURE__ */ import_react8.default.createElement(
346
- AnimatedPath,
347
- {
348
- fill: resolvedColor,
349
- d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm75.31 260.69a16 16 0 1 1-22.62 22.62L256 278.63l-52.69 52.68a16 16 0 0 1-22.62-22.62L233.37 256l-52.68-52.69a16 16 0 0 1 22.62-22.62L256 233.37l52.69-52.68a16 16 0 0 1 22.62 22.62L278.63 256z",
350
- ...animatedProps
351
- }
352
- );
353
- const renderDuotone = () => /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(
354
- import_react_native_svg2.Path,
355
- {
356
- fill: resolvedColor,
357
- opacity: 0.3,
358
- d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48z"
359
- }
360
- ), /* @__PURE__ */ import_react8.default.createElement(
361
- AnimatedPath,
362
- {
363
- fill: resolvedColor,
364
- d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
365
- ...animatedProps
366
- }
367
- ));
368
- const renderRoundOutlined = () => /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(
369
- import_react_native_svg2.Circle,
370
- {
371
- cx: "256",
372
- cy: "256",
373
- r: "192",
374
- fill: "none",
375
- stroke: resolvedColor,
376
- strokeWidth: 32
377
- }
378
- ), /* @__PURE__ */ import_react8.default.createElement(
379
- AnimatedPath,
380
- {
381
- fill: resolvedColor,
382
- d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
383
- ...animatedProps
384
- }
385
- ));
386
- const renderSquareOutlined = () => /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(
387
- import_react_native_svg2.Rect,
388
- {
389
- x: "64",
390
- y: "64",
391
- width: "384",
392
- height: "384",
393
- rx: "48",
394
- fill: "none",
395
- stroke: resolvedColor,
396
- strokeWidth: 32
397
- }
398
- ), /* @__PURE__ */ import_react8.default.createElement(
399
- AnimatedPath,
400
- {
401
- fill: resolvedColor,
402
- d: "m289.94 256l95-95A24 24 0 0 0 351 127l-95 95l-95-95a24 24 0 0 0-34 34l95 95l-95 95a24 24 0 1 0 34 34l95-95l95 95a24 24 0 0 0 34-34Z",
403
- ...animatedProps
404
- }
405
- ));
406
- const renderRoundFilled = () => /* @__PURE__ */ import_react8.default.createElement(
407
- AnimatedPath,
408
- {
409
- fill: resolvedColor,
410
- d: "M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm75.31 260.69a16 16 0 1 1-22.62 22.62L256 278.63l-52.69 52.68a16 16 0 0 1-22.62-22.62L233.37 256l-52.68-52.69a16 16 0 0 1 22.62-22.62L256 233.37l52.69-52.68a16 16 0 0 1 22.62 22.62L278.63 256z",
411
- ...animatedProps
412
- }
413
- );
414
- const renderSquareFilled = () => /* @__PURE__ */ import_react8.default.createElement(
415
- AnimatedPath,
416
- {
417
- fill: resolvedColor,
418
- d: "M400 64H112a48 48 0 0 0-48 48v288a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V112a48 48 0 0 0-48-48zm-59.31 244.69a16 16 0 1 1-22.62 22.62L256 278.63l-62.07 52.68a16 16 0 0 1-22.62-22.62L223.37 256l-52.06-52.69a16 16 0 0 1 22.62-22.62L256 233.37l62.07-52.68a16 16 0 0 1 22.62 22.62L288.63 256z",
419
- ...animatedProps
420
- }
421
- );
422
- const renderVariant = () => {
423
- switch (variant) {
424
- case "filled":
425
- return renderFilled();
426
- case "duotone":
427
- return renderDuotone();
428
- case "round-outlined":
429
- return renderRoundOutlined();
430
- case "square-outlined":
431
- return renderSquareOutlined();
432
- case "round-filled":
433
- return renderRoundFilled();
434
- case "square-filled":
435
- return renderSquareFilled();
436
- case "baseline":
437
- default:
438
- return renderBaseline();
439
- }
440
- };
441
- return /* @__PURE__ */ import_react8.default.createElement(import_react_native_svg2.default, { width: size, height: size, viewBox: "0 0 512 512" }, renderVariant());
442
- };
443
-
444
280
  // src/components/alert/alert.tsx
281
+ var import_icons = require("@xaui/icons");
445
282
  var iconMap = {
446
283
  default: InfoIcon,
447
284
  primary: InfoIcon,
@@ -467,8 +304,8 @@ var Alert = ({
467
304
  onClose,
468
305
  onVisibleChange
469
306
  }) => {
470
- const [internalVisible, setInternalVisible] = (0, import_react9.useState)(isVisible ?? true);
471
- const [shouldRender, setShouldRender] = (0, import_react9.useState)(isVisible ?? true);
307
+ const [internalVisible, setInternalVisible] = (0, import_react8.useState)(isVisible ?? true);
308
+ const [shouldRender, setShouldRender] = (0, import_react8.useState)(isVisible ?? true);
472
309
  const isControlled = typeof isVisible === "boolean";
473
310
  const visible = isControlled ? isVisible : internalVisible;
474
311
  const opacity = (0, import_react_native_reanimated.useSharedValue)(1);
@@ -477,7 +314,7 @@ var Alert = ({
477
314
  const containerStyles = useAlertContainerStyles(themeColor, variant);
478
315
  const iconWrapperStyles = useAlertIconWrapperStyles(themeColor, variant);
479
316
  const { titleStyles, descriptionStyles, iconColor, closeButtonColor } = useAlertTextStyles(themeColor, variant);
480
- const finishClosing = (0, import_react9.useCallback)(() => {
317
+ const finishClosing = (0, import_react8.useCallback)(() => {
481
318
  setShouldRender(false);
482
319
  if (!isControlled) {
483
320
  setInternalVisible(false);
@@ -485,7 +322,7 @@ var Alert = ({
485
322
  onVisibleChange?.(false);
486
323
  onClose?.();
487
324
  }, [isControlled, onClose, onVisibleChange]);
488
- const handleClose = (0, import_react9.useCallback)(() => {
325
+ const handleClose = (0, import_react8.useCallback)(() => {
489
326
  if (!visible) return;
490
327
  opacity.value = (0, import_react_native_reanimated.withTiming)(0, { duration: 250 });
491
328
  scale.value = (0, import_react_native_reanimated.withTiming)(0.95, { duration: 250 }, (finished) => {
@@ -494,7 +331,7 @@ var Alert = ({
494
331
  }
495
332
  });
496
333
  }, [finishClosing, opacity, scale, visible]);
497
- (0, import_react9.useEffect)(() => {
334
+ (0, import_react8.useEffect)(() => {
498
335
  if (visible && !shouldRender) {
499
336
  setShouldRender(true);
500
337
  opacity.value = 0;
@@ -515,19 +352,19 @@ var Alert = ({
515
352
  const shouldShowClose = Boolean(closeButton || isClosable || onClose);
516
353
  const renderIcon = () => {
517
354
  if (hideIcon) return null;
518
- if (icon && (0, import_react9.isValidElement)(icon)) {
519
- return (0, import_react9.cloneElement)(icon, { color: iconColor, size: 22 });
355
+ if (icon && (0, import_react8.isValidElement)(icon)) {
356
+ return (0, import_react8.cloneElement)(icon, { color: iconColor, size: 22 });
520
357
  }
521
358
  if (icon) {
522
- return /* @__PURE__ */ import_react9.default.createElement(import_react_native6.Text, { style: [styles.iconText, { color: iconColor }] }, icon);
359
+ return /* @__PURE__ */ import_react8.default.createElement(import_react_native5.Text, { style: [styles.iconText, { color: iconColor }] }, icon);
523
360
  }
524
- return /* @__PURE__ */ import_react9.default.createElement(IconComponent, { color: iconColor, size: 22 });
361
+ return /* @__PURE__ */ import_react8.default.createElement(IconComponent, { color: iconColor, size: 22 });
525
362
  };
526
363
  const renderContentText = (content) => {
527
364
  if (content === null || content === void 0) return null;
528
365
  if (typeof content === "string" || typeof content === "number") {
529
- return /* @__PURE__ */ import_react9.default.createElement(
530
- import_react_native6.Text,
366
+ return /* @__PURE__ */ import_react8.default.createElement(
367
+ import_react_native5.Text,
531
368
  {
532
369
  style: [
533
370
  styles.description,
@@ -540,20 +377,20 @@ var Alert = ({
540
377
  }
541
378
  return content;
542
379
  };
543
- const titleNode = (0, import_react9.useMemo)(() => {
380
+ const titleNode = (0, import_react8.useMemo)(() => {
544
381
  if (title === null || title === void 0) return null;
545
382
  if (typeof title === "string" || typeof title === "number") {
546
- return /* @__PURE__ */ import_react9.default.createElement(import_react_native6.Text, { style: [styles.title, titleStyles, customAppearance?.title] }, title);
383
+ return /* @__PURE__ */ import_react8.default.createElement(import_react_native5.Text, { style: [styles.title, titleStyles, customAppearance?.title] }, title);
547
384
  }
548
385
  return title;
549
386
  }, [title, customAppearance?.title, titleStyles]);
550
387
  const descriptionNode = renderContentText(description);
551
388
  const childrenNode = renderContentText(children);
552
- const closeButtonNode = (0, import_react9.useMemo)(() => {
389
+ const closeButtonNode = (0, import_react8.useMemo)(() => {
553
390
  if (!closeButton) return null;
554
- if (!(0, import_react9.isValidElement)(closeButton)) return closeButton;
391
+ if (!(0, import_react8.isValidElement)(closeButton)) return closeButton;
555
392
  const existingOnPress = closeButton.props.onPress;
556
- return (0, import_react9.cloneElement)(closeButton, {
393
+ return (0, import_react8.cloneElement)(closeButton, {
557
394
  onPress: (event) => {
558
395
  existingOnPress?.(event);
559
396
  handleClose();
@@ -561,7 +398,7 @@ var Alert = ({
561
398
  });
562
399
  }, [closeButton, handleClose]);
563
400
  if (!shouldRender) return null;
564
- return /* @__PURE__ */ import_react9.default.createElement(
401
+ return /* @__PURE__ */ import_react8.default.createElement(
565
402
  import_react_native_reanimated.default.View,
566
403
  {
567
404
  accessibilityRole: "alert",
@@ -573,17 +410,17 @@ var Alert = ({
573
410
  animatedStyle
574
411
  ]
575
412
  },
576
- !hideIcon && /* @__PURE__ */ import_react9.default.createElement(import_react_native6.View, { style: [styles.iconWrapper, iconWrapperStyles] }, renderIcon()),
577
- /* @__PURE__ */ import_react9.default.createElement(import_react_native6.View, { style: styles.mainWrapper }, titleNode, descriptionNode, childrenNode && /* @__PURE__ */ import_react9.default.createElement(import_react_native6.View, { style: styles.extraContent }, childrenNode)),
578
- shouldShowClose && /* @__PURE__ */ import_react9.default.createElement(import_react_native6.View, null, closeButtonNode ?? /* @__PURE__ */ import_react9.default.createElement(
579
- import_react_native6.Pressable,
413
+ !hideIcon && /* @__PURE__ */ import_react8.default.createElement(import_react_native5.View, { style: [styles.iconWrapper, iconWrapperStyles] }, renderIcon()),
414
+ /* @__PURE__ */ import_react8.default.createElement(import_react_native5.View, { style: styles.mainWrapper }, titleNode, descriptionNode, childrenNode && /* @__PURE__ */ import_react8.default.createElement(import_react_native5.View, { style: styles.extraContent }, childrenNode)),
415
+ shouldShowClose && /* @__PURE__ */ import_react8.default.createElement(import_react_native5.View, null, closeButtonNode ?? /* @__PURE__ */ import_react8.default.createElement(
416
+ import_react_native5.Pressable,
580
417
  {
581
418
  accessibilityRole: "button",
582
419
  accessibilityLabel: "Close",
583
420
  onPress: handleClose,
584
421
  style: styles.closeButton
585
422
  },
586
- /* @__PURE__ */ import_react9.default.createElement(CloseIcon, { size: 20, color: closeButtonColor })
423
+ /* @__PURE__ */ import_react8.default.createElement(import_icons.CloseIcon, { size: 20, color: closeButtonColor })
587
424
  ))
588
425
  );
589
426
  };
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Alert
3
- } from "../chunk-OFYJYQ2M.js";
4
- import "../chunk-SIXET7TJ.js";
3
+ } from "../chunk-2T6FKPJW.js";
5
4
  import "../chunk-NBRASCX4.js";
6
5
  export {
7
6
  Alert