@kanso-labs/react-native-kanso-ui 0.7.0 → 0.9.0

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 (150) hide show
  1. package/README.md +37 -0
  2. package/dist/badge/index.js +9 -68
  3. package/dist/badge/index.js.map +1 -1
  4. package/dist/button/index.d.ts +2 -1
  5. package/dist/button/index.js +1 -1
  6. package/dist/button/index.js.map +1 -1
  7. package/dist/button/palettes.d.ts +2 -0
  8. package/dist/button/pending.js +17 -21
  9. package/dist/button/pending.js.map +1 -1
  10. package/dist/calendar/index.js +1 -1
  11. package/dist/components/autocomplete/index.js +28 -26
  12. package/dist/components/autocomplete/index.js.map +1 -1
  13. package/dist/components/avatar/index.d.ts +2 -2
  14. package/dist/components/avatar/index.js +2 -2
  15. package/dist/components/avatar/index.js.map +1 -1
  16. package/dist/components/badge/index.d.ts +48 -0
  17. package/dist/components/badge/index.js +122 -0
  18. package/dist/components/badge/index.js.map +1 -0
  19. package/dist/{badge → components/badge}/styles.js +10 -6
  20. package/dist/components/badge/styles.js.map +1 -0
  21. package/dist/components/breadcrumbs/index.d.ts +66 -0
  22. package/dist/components/breadcrumbs/index.js +285 -0
  23. package/dist/components/breadcrumbs/index.js.map +1 -0
  24. package/dist/components/calendar/index.d.ts +1 -1
  25. package/dist/components/calendar/index.js +77 -38
  26. package/dist/components/calendar/index.js.map +1 -1
  27. package/dist/components/checkbox/index.d.ts +7 -1
  28. package/dist/components/checkbox/index.js +183 -138
  29. package/dist/components/checkbox/index.js.map +1 -1
  30. package/dist/components/checkbox-group/index.d.ts +93 -0
  31. package/dist/components/checkbox-group/index.js +306 -0
  32. package/dist/components/checkbox-group/index.js.map +1 -0
  33. package/dist/components/chip-group/index.d.ts +4 -3
  34. package/dist/components/chip-group/index.js +47 -45
  35. package/dist/components/chip-group/index.js.map +1 -1
  36. package/dist/components/code/index.d.ts +25 -0
  37. package/dist/components/code/index.js +87 -0
  38. package/dist/components/code/index.js.map +1 -0
  39. package/dist/components/container/index.d.ts +47 -0
  40. package/dist/components/container/index.js +85 -0
  41. package/dist/components/container/index.js.map +1 -0
  42. package/dist/components/copy-field/index.d.ts +5 -5
  43. package/dist/components/copy-field/index.js +30 -28
  44. package/dist/components/copy-field/index.js.map +1 -1
  45. package/dist/components/currency/index.d.ts +2 -2
  46. package/dist/components/currency/index.js +3 -1
  47. package/dist/components/currency/index.js.map +1 -1
  48. package/dist/components/fab/index.d.ts +80 -0
  49. package/dist/components/fab/index.js +231 -0
  50. package/dist/components/fab/index.js.map +1 -0
  51. package/dist/components/fab-menu/index.d.ts +120 -0
  52. package/dist/components/fab-menu/index.js +640 -0
  53. package/dist/components/fab-menu/index.js.map +1 -0
  54. package/dist/components/feed/index.d.ts +57 -0
  55. package/dist/components/feed/index.js +167 -0
  56. package/dist/components/feed/index.js.map +1 -0
  57. package/dist/components/keycap/index.d.ts +27 -0
  58. package/dist/components/keycap/index.js +136 -0
  59. package/dist/components/keycap/index.js.map +1 -0
  60. package/dist/components/list/index.d.ts +6 -5
  61. package/dist/components/list/index.js +97 -106
  62. package/dist/components/list/index.js.map +1 -1
  63. package/dist/components/menu/index.d.ts +4 -3
  64. package/dist/components/menu/index.js +33 -40
  65. package/dist/components/menu/index.js.map +1 -1
  66. package/dist/components/meter/index.d.ts +2 -1
  67. package/dist/components/meter/index.js +9 -7
  68. package/dist/components/meter/index.js.map +1 -1
  69. package/dist/components/number-field/index.d.ts +7 -3
  70. package/dist/components/number-field/index.js +214 -192
  71. package/dist/components/number-field/index.js.map +1 -1
  72. package/dist/components/product-icon/index.d.ts +2 -2
  73. package/dist/components/product-icon/index.js +2 -2
  74. package/dist/components/product-icon/index.js.map +1 -1
  75. package/dist/components/progress-indicator/index.d.ts +2 -1
  76. package/dist/components/progress-indicator/index.js +15 -13
  77. package/dist/components/progress-indicator/index.js.map +1 -1
  78. package/dist/components/search-field/index.d.ts +3 -3
  79. package/dist/components/search-field/index.js +105 -104
  80. package/dist/components/search-field/index.js.map +1 -1
  81. package/dist/components/separator/index.d.ts +3 -2
  82. package/dist/components/separator/index.js +29 -26
  83. package/dist/components/separator/index.js.map +1 -1
  84. package/dist/components/sheet/index.d.ts +2 -2
  85. package/dist/components/sheet/index.js +22 -26
  86. package/dist/components/sheet/index.js.map +1 -1
  87. package/dist/components/snackbar/index.d.ts +3 -3
  88. package/dist/components/snackbar/index.js +36 -34
  89. package/dist/components/snackbar/index.js.map +1 -1
  90. package/dist/components/supporting-pane/index.d.ts +44 -0
  91. package/dist/components/supporting-pane/index.js +109 -0
  92. package/dist/components/supporting-pane/index.js.map +1 -0
  93. package/dist/components/tag/index.d.ts +58 -0
  94. package/dist/components/tag/index.js +205 -0
  95. package/dist/components/tag/index.js.map +1 -0
  96. package/dist/components/text/index.d.ts +1 -1
  97. package/dist/components/text/index.js +49 -21
  98. package/dist/components/text/index.js.map +1 -1
  99. package/dist/components/text-area/index.d.ts +145 -0
  100. package/dist/components/text-area/index.js +231 -0
  101. package/dist/components/text-area/index.js.map +1 -0
  102. package/dist/components/text-field/index.d.ts +6 -3
  103. package/dist/components/text-field/index.js +3 -0
  104. package/dist/components/text-field/index.js.map +1 -1
  105. package/dist/components/toolbar/index.d.ts +53 -0
  106. package/dist/components/toolbar/index.js +185 -0
  107. package/dist/components/toolbar/index.js.map +1 -0
  108. package/dist/control/group.js +23 -0
  109. package/dist/control/group.js.map +1 -0
  110. package/dist/fab/index.d.ts +19 -0
  111. package/dist/fab/index.js +147 -0
  112. package/dist/fab/index.js.map +1 -0
  113. package/dist/field/index.js +123 -79
  114. package/dist/field/index.js.map +1 -1
  115. package/dist/field/styles.js +18 -0
  116. package/dist/field/styles.js.map +1 -1
  117. package/dist/form/index.d.ts +1 -2
  118. package/dist/form/index.js +1 -1
  119. package/dist/form/index.js.map +1 -1
  120. package/dist/i18n/index.js +12 -1
  121. package/dist/i18n/index.js.map +1 -1
  122. package/dist/i18n/messages.js +367 -0
  123. package/dist/i18n/messages.js.map +1 -1
  124. package/dist/i18n/provider.d.ts +53 -0
  125. package/dist/i18n/provider.js +96 -0
  126. package/dist/i18n/provider.js.map +1 -0
  127. package/dist/index.d.ts +19 -4
  128. package/dist/index.js +17 -3
  129. package/dist/indicator/index.js +1 -2
  130. package/dist/indicator/index.js.map +1 -1
  131. package/dist/mark/index.js +77 -117
  132. package/dist/mark/index.js.map +1 -1
  133. package/dist/mark/initials.js.map +1 -1
  134. package/dist/modal/index.js +59 -46
  135. package/dist/modal/index.js.map +1 -1
  136. package/dist/navigation/index.js +8 -5
  137. package/dist/navigation/index.js.map +1 -1
  138. package/dist/number/count.js +15 -0
  139. package/dist/number/count.js.map +1 -0
  140. package/dist/number/locale.js.map +1 -1
  141. package/dist/overlay/host.js +30 -21
  142. package/dist/overlay/host.js.map +1 -1
  143. package/dist/overlay/placement.js +3 -1
  144. package/dist/overlay/placement.js.map +1 -1
  145. package/dist/separator/index.js +7 -0
  146. package/dist/separator/index.js.map +1 -0
  147. package/dist/typography/size.js +14 -0
  148. package/dist/typography/size.js.map +1 -0
  149. package/package.json +1 -1
  150. package/dist/badge/styles.js.map +0 -1
@@ -0,0 +1,48 @@
1
+ import { View, ViewProps } from "react-native";
2
+ import { ComponentRef, ReactNode, Ref } from "react";
3
+ //#region src/components/badge/index.d.ts
4
+ type BadgeProps = Omit<ViewProps, 'children'> & {
5
+ /**
6
+ * What the badge is drawn on, usually an icon at 24dp. Left out, the badge
7
+ * is the mark alone, standing in the line after what comes before it.
8
+ */
9
+ readonly children?: ReactNode;
10
+ /**
11
+ * The number to show, which draws the page's large badge. Left out, the
12
+ * badge is the small 6dp dot, which flags without counting. A count of 0
13
+ * still draws, so leave the badge out when there is nothing to count.
14
+ */
15
+ readonly count?: number | undefined;
16
+ /**
17
+ * The largest count drawn as itself. Above it the badge reads `max` and a
18
+ * plus, which is the page's 999+ at the default.
19
+ * @default 999
20
+ */
21
+ readonly max?: number;
22
+ readonly ref?: Ref<ComponentRef<typeof View>>;
23
+ };
24
+ /**
25
+ * A badge on the top trailing corner of what it wraps, usually an icon: the
26
+ * small dot, or with `count` the large badge holding a number. The mark is
27
+ * hidden from a screen reader, so put what it says in the name of the
28
+ * control it sits on.
29
+ *
30
+ * ```tsx
31
+ * <IconButton aria-label="Label, 3 new">
32
+ * <Badge count={3}>{icon}</Badge>
33
+ * </IconButton>
34
+ * ```
35
+ *
36
+ * Given no children, the mark stands alone in the line, as a tab draws it
37
+ * after its label. The count is written in the digits of the
38
+ * `I18nProvider`'s locale, or the device's outside one.
39
+ *
40
+ * `style`, `ref` and `testID` land on the view wrapping what the badge is
41
+ * drawn on, and a `style` there applies over the badge's own. Like any view,
42
+ * it stretches across a column it sits in on its own, which moves the mark
43
+ * to the column's edge, so a call site placing one there sets `alignSelf`.
44
+ */
45
+ declare function Badge({ children, count, max, style, ...props }: BadgeProps): import("react").JSX.Element;
46
+ //#endregion
47
+ export { Badge, type BadgeProps };
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,122 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles } from "../../theme/styles.js";
3
+ import { useTypeRole } from "../../typography/roles.js";
4
+ import { formatCount } from "../../number/count.js";
5
+ import { useLocaleOf } from "../../i18n/provider.js";
6
+ import { BadgeInFlowContext } from "../../badge/index.js";
7
+ import { styles, stylesOf } from "./styles.js";
8
+ import { c } from "react/compiler-runtime";
9
+ import { Text, View } from "react-native";
10
+ import { use } from "react";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
+ //#region src/components/badge/index.tsx
13
+ /**
14
+ * A badge on the top trailing corner of what it wraps, usually an icon: the
15
+ * small dot, or with `count` the large badge holding a number. The mark is
16
+ * hidden from a screen reader, so put what it says in the name of the
17
+ * control it sits on.
18
+ *
19
+ * ```tsx
20
+ * <IconButton aria-label="Label, 3 new">
21
+ * <Badge count={3}>{icon}</Badge>
22
+ * </IconButton>
23
+ * ```
24
+ *
25
+ * Given no children, the mark stands alone in the line, as a tab draws it
26
+ * after its label. The count is written in the digits of the
27
+ * `I18nProvider`'s locale, or the device's outside one.
28
+ *
29
+ * `style`, `ref` and `testID` land on the view wrapping what the badge is
30
+ * drawn on, and a `style` there applies over the badge's own. Like any view,
31
+ * it stretches across a column it sits in on its own, which moves the mark
32
+ * to the column's edge, so a call site placing one there sets `alignSelf`.
33
+ */
34
+ function Badge(t0) {
35
+ const $ = c(22);
36
+ let children;
37
+ let count;
38
+ let props;
39
+ let style;
40
+ let t1;
41
+ if ($[0] !== t0) {
42
+ ({children, count, max: t1, style, ...props} = t0);
43
+ $[0] = t0;
44
+ $[1] = children;
45
+ $[2] = count;
46
+ $[3] = props;
47
+ $[4] = style;
48
+ $[5] = t1;
49
+ } else {
50
+ children = $[1];
51
+ count = $[2];
52
+ props = $[3];
53
+ style = $[4];
54
+ t1 = $[5];
55
+ }
56
+ const max = t1 === void 0 ? 999 : t1;
57
+ const own = stylesOf(useTheme());
58
+ const role = useTypeRole("labelSmall");
59
+ const locale = useLocaleOf(void 0);
60
+ const inFlow = use(BadgeInFlowContext);
61
+ let t2;
62
+ if ($[6] !== count || $[7] !== locale || $[8] !== max) {
63
+ t2 = count === void 0 ? void 0 : countOf(count, max, locale);
64
+ $[6] = count;
65
+ $[7] = locale;
66
+ $[8] = max;
67
+ $[9] = t2;
68
+ } else t2 = $[9];
69
+ const label = t2;
70
+ const alone = children === void 0 || children === null;
71
+ const T0 = View;
72
+ let t3;
73
+ if ($[10] !== style) {
74
+ t3 = composeStyles(styles.anchor, style);
75
+ $[10] = style;
76
+ $[11] = t3;
77
+ } else t3 = $[11];
78
+ const T1 = View;
79
+ const t4 = true;
80
+ const t5 = composeStyles(own.mark, label === void 0 ? [styles.small, alone ? styles.alone : styles.smallOver] : [own.large, alone ? styles.alone : inFlow ? styles.inFlow : styles.over]);
81
+ const t6 = label === void 0 ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, {
82
+ style: styles.space,
83
+ children: " "
84
+ }), /* @__PURE__ */ jsx(Text, {
85
+ style: composeStyles(role, own.count),
86
+ children: label
87
+ })] });
88
+ let t7;
89
+ if ($[12] !== T1 || $[13] !== t5 || $[14] !== t6) {
90
+ t7 = /* @__PURE__ */ jsx(T1, {
91
+ "aria-hidden": t4,
92
+ style: t5,
93
+ children: t6
94
+ });
95
+ $[12] = T1;
96
+ $[13] = t5;
97
+ $[14] = t6;
98
+ $[15] = t7;
99
+ } else t7 = $[15];
100
+ let t8;
101
+ if ($[16] !== T0 || $[17] !== children || $[18] !== props || $[19] !== t3 || $[20] !== t7) {
102
+ t8 = /* @__PURE__ */ jsxs(T0, {
103
+ ...props,
104
+ style: t3,
105
+ children: [children, t7]
106
+ });
107
+ $[16] = T0;
108
+ $[17] = children;
109
+ $[18] = props;
110
+ $[19] = t3;
111
+ $[20] = t7;
112
+ $[21] = t8;
113
+ } else t8 = $[21];
114
+ return t8;
115
+ }
116
+ function countOf(count, max, locale) {
117
+ return count > max ? `${formatCount(max, locale)}+` : formatCount(count, locale);
118
+ }
119
+ //#endregion
120
+ export { Badge };
121
+
122
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","TextStyle","ViewProps","ViewStyle","use","Text","NativeText","View","BadgeInFlowContext","useLocaleOf","formatCount","useTheme","composeStyles","useTypeRole","styles","stylesOf","BadgeProps","Omit","children","count","max","ref","Badge","t0","$","_c","props","style","t1","undefined","own","role","locale","inFlow","t2","countOf","label","alone","T0","t3","anchor","T1","t4","t5","mark","small","smallOver","large","over","t6","space","t7","t8","_c","NativeText"],"sources":["../../../src/components/badge/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type { TextStyle, ViewProps, ViewStyle } from 'react-native'\n\nimport { use } from 'react'\nimport { Text as NativeText, View } from 'react-native'\n\nimport { BadgeInFlowContext } from '../../badge'\nimport { useLocaleOf } from '../../i18n/provider'\nimport { formatCount } from '../../number/count'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\nimport { styles, stylesOf } from './styles'\n\n// The badges page's badge, as kanso-ui's Badge draws it: a mark on the corner\n// of an icon that flags something new there, either as the 6dp small badge\n// or as the 16dp large badge holding a count. Both are the error pair, the\n// error role with the count in on error, on a full corner, and the count is\n// label small, capped with a plus, as \"999+\".\n//\n// The badge wraps what it is drawn on, usually an icon, and places the mark\n// against that view's box, which is what the page measures from. The small\n// badge fills the icon's top trailing 6dp square. The large badge's bottom\n// leading corner sits 14dp down and 12dp in from the icon's top trailing\n// corner, so it stands 2dp above the icon and grows toward the end as its\n// count lengthens. Both are placed by `start` and `end`, so the mark stays on\n// the trailing corner under right-to-left.\n//\n// Given nothing to wrap, the badge is the mark alone, standing in the line\n// rather than over a corner. That is the form the tabs page draws after a\n// label with no icon above it.\n//\n// The mark is hidden from a screen reader. A count read on its own is a\n// number with no subject; it belongs in the name of the control it sits on,\n// where a reader meets it with what it counts, \"First item, 3 new\".\n//\n// The count is set apart from the text before it by a space drawn out of the\n// flow. Under React Native Web the count is still text inside the control,\n// and with nothing between them a label and its count ran together as\n// \"Second item3\", a word in no name: what axe's label-in-name check fails,\n// and not what a speech-input user would say. Web draws the count as\n// generated content instead, which a style here has no counterpart for.\n\ntype BadgeProps = Omit<ViewProps, 'children'> & {\n /**\n * What the badge is drawn on, usually an icon at 24dp. Left out, the badge\n * is the mark alone, standing in the line after what comes before it.\n */\n readonly children?: ReactNode\n /**\n * The number to show, which draws the page's large badge. Left out, the\n * badge is the small 6dp dot, which flags without counting. A count of 0\n * still draws, so leave the badge out when there is nothing to count.\n */\n readonly count?: number | undefined\n /**\n * The largest count drawn as itself. Above it the badge reads `max` and a\n * plus, which is the page's 999+ at the default.\n * @default 999\n */\n readonly max?: number\n readonly ref?: Ref<ComponentRef<typeof View>>\n}\n\n/**\n * A badge on the top trailing corner of what it wraps, usually an icon: the\n * small dot, or with `count` the large badge holding a number. The mark is\n * hidden from a screen reader, so put what it says in the name of the\n * control it sits on.\n *\n * ```tsx\n * <IconButton aria-label=\"Label, 3 new\">\n * <Badge count={3}>{icon}</Badge>\n * </IconButton>\n * ```\n *\n * Given no children, the mark stands alone in the line, as a tab draws it\n * after its label. The count is written in the digits of the\n * `I18nProvider`'s locale, or the device's outside one.\n *\n * `style`, `ref` and `testID` land on the view wrapping what the badge is\n * drawn on, and a `style` there applies over the badge's own. Like any view,\n * it stretches across a column it sits in on its own, which moves the mark\n * to the column's edge, so a call site placing one there sets `alignSelf`.\n */\nfunction Badge({ children, count, max = 999, style, ...props }: BadgeProps) {\n const own = stylesOf(useTheme())\n const role = useTypeRole('labelSmall')\n const locale = useLocaleOf(undefined)\n const inFlow = use(BadgeInFlowContext)\n const label = count === undefined ? undefined : countOf(count, max, locale)\n const alone = children === undefined || children === null\n\n return (\n <View {...props} style={composeStyles<ViewStyle>(styles.anchor, style)}>\n {children}\n <View\n aria-hidden\n style={composeStyles<ViewStyle>(\n own.mark,\n label === undefined\n ? [styles.small, alone ? styles.alone : styles.smallOver]\n : [\n own.large,\n alone ? styles.alone : inFlow ? styles.inFlow : styles.over,\n ],\n )}\n >\n {label === undefined ? null : (\n <>\n <NativeText style={styles.space}> </NativeText>\n <NativeText style={composeStyles<TextStyle>(role, own.count)}>\n {label}\n </NativeText>\n </>\n )}\n </View>\n </View>\n )\n}\n\n// The count in the locale's digits and grouping, as web writes it in the\n// provider's.\nfunction countOf(count: number, max: number, locale: string) {\n return count > max\n ? `${formatCount(max, locale)}+`\n : formatCount(count, locale)\n}\n\nexport type { BadgeProps }\n\nexport { Badge }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAAwB,MAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAP;CAAA,IAAAC;CAAA,IAAAO;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAJ,EAAA,OAAAD,IAAA;EAAe,CAA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../theme/styles.js";
2
2
  import { StyleSheet } from "react-native";
3
- //#region src/badge/styles.ts
3
+ //#region src/components/badge/styles.ts
4
4
  const SMALL_SIZE = 6;
5
5
  const LARGE_SIZE = 16;
6
6
  const styles = StyleSheet.create({
7
+ alone: { position: "relative" },
7
8
  anchor: {
8
9
  alignItems: "flex-start",
9
10
  flexDirection: "row"
@@ -14,17 +15,20 @@ const styles = StyleSheet.create({
14
15
  top: -2
15
16
  },
16
17
  over: {
18
+ marginStart: -12,
17
19
  position: "absolute",
18
- start: 12,
20
+ start: "100%",
19
21
  top: -2
20
22
  },
21
23
  small: {
22
- end: 0,
23
24
  height: SMALL_SIZE,
24
- position: "absolute",
25
- top: 0,
26
25
  width: SMALL_SIZE
27
26
  },
27
+ smallOver: {
28
+ end: 0,
29
+ position: "absolute",
30
+ top: 0
31
+ },
28
32
  space: { position: "absolute" }
29
33
  });
30
34
  const stylesOf = themedStyles(({ colors, radii, spacing }) => StyleSheet.create({
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","names":["StyleSheet","themedStyles","OVERLAP","RISE","SMALL_SIZE","LARGE_SIZE","styles","create","alone","position","anchor","alignItems","flexDirection","inFlow","marginStart","top","over","start","small","height","width","smallOver","end","space","stylesOf","colors","radii","spacing","count","color","onError","fontVariant","large","justifyContent","minHeight","minWidth","paddingHorizontal","xs","mark","backgroundColor","error","borderRadius","pill","pointerEvents"],"sources":["../../../src/components/badge/styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\nimport { themedStyles } from '../../theme/styles'\n\n// How far back over what it is drawn on the large badge reaches, from its\n// trailing edge, and how far above it the badge stands. The page's own\n// figures: its bottom leading corner 14dp down and 12dp in from the icon's\n// top trailing corner, on a 16dp badge.\nconst OVERLAP = 12\nconst RISE = 2\n\n// The small badge's side, and the large badge's least height and width.\nconst SMALL_SIZE = 6\nconst LARGE_SIZE = 16\n\nconst styles = StyleSheet.create({\n // A badge with nothing to be drawn on: the mark in the line, where what\n // comes before it puts it, so neither corner's placement applies.\n alone: {\n position: 'relative',\n },\n // What the badge is drawn on. It shrinks to what it holds along the row,\n // so its box is the icon's and the mark lands where the page puts it, and\n // lays a mark that joins the flow after the icon.\n anchor: {\n alignItems: 'flex-start',\n flexDirection: 'row',\n },\n // The large badge in the flow after the icon, 12dp back over it and 2dp\n // above it, which is where its own placement puts it, so what follows the\n // icon starts after the badge rather than under it.\n inFlow: {\n marginStart: -OVERLAP,\n position: 'relative',\n top: -RISE,\n },\n // The large badge over the top trailing corner of what it is drawn on: its\n // leading edge 12dp inside the trailing edge, whatever the width, as web's\n // `calc(100% - 12px)` places it.\n over: {\n marginStart: -OVERLAP,\n position: 'absolute',\n start: '100%',\n top: -RISE,\n },\n // The small badge's 6dp square.\n small: {\n height: SMALL_SIZE,\n width: SMALL_SIZE,\n },\n // The small badge on what it is drawn on, filling its top trailing 6dp\n // square.\n smallOver: {\n end: 0,\n position: 'absolute',\n top: 0,\n },\n // The space before the count, out of the flow, so it sets the count apart\n // from the text before it without moving anything.\n space: {\n position: 'absolute',\n },\n})\n\nconst stylesOf = themedStyles(({ colors, radii, spacing }) =>\n StyleSheet.create({\n // The count, in label small with tabular figures, so a count that\n // changes does not change the badge's width digit by digit.\n count: {\n color: colors.onError,\n fontVariant: ['tabular-nums'],\n },\n // The page's large badge: at least 16dp tall and as wide, 4dp either\n // side of its count. A minimum rather than a size, so a larger text size\n // the device asks for grows the badge rather than cutting the count.\n large: {\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: LARGE_SIZE,\n minWidth: LARGE_SIZE,\n paddingHorizontal: spacing.xs,\n },\n // The fill and corner both badges share. It takes no touches, so a press\n // on it lands on what it is drawn on.\n mark: {\n backgroundColor: colors.error,\n borderRadius: radii.pill,\n pointerEvents: 'none',\n },\n }),\n)\n\nexport { styles, stylesOf }\n"],"mappings":";;;AAYA,MAAMI,aAAa;AACnB,MAAMC,aAAa;AAEnB,MAAMC,SAASN,WAAWO,OAAO;CAG/BC,OAAO,EACLC,UAAU,WACZ;CAIAC,QAAQ;EACNC,YAAY;EACZC,eAAe;CACjB;CAIAC,QAAQ;EACNC,aAAa;EACbL,UAAU;EACVM,KAAK;CACP;CAIAC,MAAM;EACJF,aAAa;EACbL,UAAU;EACVQ,OAAO;EACPF,KAAK;CACP;CAEAG,OAAO;EACLC,QAAQf;EACRgB,OAAOhB;CACT;CAGAiB,WAAW;EACTC,KAAK;EACLb,UAAU;EACVM,KAAK;CACP;CAGAQ,OAAO,EACLd,UAAU,WACZ;AACF,CAAC;AAED,MAAMe,WAAWvB,cAAc,EAAEwB,QAAQC,OAAOC,cAC9C3B,WAAWO,OAAO;CAGhBqB,OAAO;EACLC,OAAOJ,OAAOK;EACdC,aAAa,CAAC,cAAc;CAC9B;CAIAC,OAAO;EACLrB,YAAY;EACZsB,gBAAgB;EAChBC,WAAW7B;EACX8B,UAAU9B;EACV+B,mBAAmBT,QAAQU;CAC7B;CAGAC,MAAM;EACJC,iBAAiBd,OAAOe;EACxBC,cAAcf,MAAMgB;EACpBC,eAAe;CACjB;AACF,CAAC,CACH"}
@@ -0,0 +1,66 @@
1
+ import { StyleProp, View, ViewProps, ViewStyle } from "react-native";
2
+ import { ComponentRef, ReactNode, Ref } from "react";
3
+ import { Key } from "react-stately";
4
+ //#region src/components/breadcrumbs/index.d.ts
5
+ type BreadcrumbsItemProps = Omit<ViewProps, 'children' | 'id' | 'style'> & {
6
+ /** The item's label. */
7
+ readonly children?: ReactNode;
8
+ /**
9
+ * Where the item leads. Leave it out on an item the screen handles through
10
+ * the trail's `onAction`, and on the current one, which is never a link.
11
+ */
12
+ readonly href?: string;
13
+ /** What the trail's `onAction` is handed when the item is pressed. */
14
+ readonly id?: Key;
15
+ readonly ref?: Ref<ComponentRef<typeof View>>;
16
+ readonly style?: StyleProp<ViewStyle>;
17
+ };
18
+ type BreadcrumbsProps = Omit<ViewProps, 'children' | 'style'> & {
19
+ /** The trail, as `Breadcrumbs.Item` entries. */
20
+ readonly children?: ReactNode;
21
+ /**
22
+ * Disables every link in the trail.
23
+ * @default false
24
+ */
25
+ readonly isDisabled?: boolean;
26
+ /**
27
+ * Called with an item's `id` when its link is pressed, for a screen that
28
+ * navigates without an `href`.
29
+ */
30
+ readonly onAction?: (key: Key) => void;
31
+ readonly ref?: Ref<ComponentRef<typeof View>>;
32
+ readonly style?: StyleProp<ViewStyle>;
33
+ };
34
+ /**
35
+ * A trail of links back up a hierarchy, ending at the screen you are on. The
36
+ * last item is the current one and is drawn as text; everything before it is
37
+ * a link.
38
+ *
39
+ * ```tsx
40
+ * <Breadcrumbs aria-label="Label">
41
+ * <Breadcrumbs.Item href="/first">First item</Breadcrumbs.Item>
42
+ * <Breadcrumbs.Item href="/second">Second item</Breadcrumbs.Item>
43
+ * <Breadcrumbs.Item>Third item</Breadcrumbs.Item>
44
+ * </Breadcrumbs>
45
+ * ```
46
+ *
47
+ * Name it with `aria-label`. A screen that navigates without an `href` gives
48
+ * each item an `id` and the trail an `onAction`, which is handed the `id` of
49
+ * the item pressed. The items may come as one fragment. `style`, `ref` and
50
+ * `testID` land on the row, which is the element a layout positions.
51
+ */
52
+ declare function Breadcrumbs({ children, isDisabled, onAction, style, ...props }: BreadcrumbsProps): import("react").JSX.Element;
53
+ declare namespace Breadcrumbs {
54
+ var Item: typeof BreadcrumbsItem;
55
+ }
56
+ /**
57
+ * One entry in the trail. Give it an `href` to navigate, or an `id` and let
58
+ * the trail's `onAction` handle it. The last entry is the current screen and
59
+ * is drawn as text rather than a link, whatever it is given. `style`, `ref`
60
+ * and `testID` land on the entry's row, which holds its label and the
61
+ * chevron after it.
62
+ */
63
+ declare function BreadcrumbsItem({ children, href, id, style, ...props }: BreadcrumbsItemProps): import("react").JSX.Element;
64
+ //#endregion
65
+ export { Breadcrumbs, BreadcrumbsItem, type BreadcrumbsItemProps, type BreadcrumbsProps };
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,285 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { useTypeRole } from "../../typography/roles.js";
4
+ import { ChevronEndGlyph } from "../../glyphs/index.js";
5
+ import { Link } from "../link/index.js";
6
+ import { c } from "react/compiler-runtime";
7
+ import { Platform, StyleSheet, Text, View } from "react-native";
8
+ import { Children, Fragment, createContext, isValidElement, use } from "react";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
+ //#region src/components/breadcrumbs/index.tsx
11
+ const ItemContext = createContext({
12
+ isCurrent: false,
13
+ isDisabled: false,
14
+ onAction: void 0
15
+ });
16
+ const CURRENT_PAGE = { "aria-current": "page" };
17
+ const CHEVRON_SIZE = 18;
18
+ const stylesOf = themedStyles(({ colors, spacing }) => StyleSheet.create({
19
+ chevron: { flexShrink: 0 },
20
+ current: { color: colors.onSurface },
21
+ item: {
22
+ alignItems: "center",
23
+ columnGap: spacing.xs,
24
+ flexDirection: "row",
25
+ flexShrink: 1
26
+ },
27
+ label: {
28
+ color: colors.onSurfaceVariant,
29
+ flexShrink: 1
30
+ },
31
+ root: {
32
+ alignItems: "center",
33
+ flexDirection: "row",
34
+ flexWrap: "wrap",
35
+ gap: spacing.xs
36
+ }
37
+ }));
38
+ function actionOf(id, onAction) {
39
+ return id === void 0 || onAction === void 0 ? void 0 : () => {
40
+ onAction(id);
41
+ };
42
+ }
43
+ /**
44
+ * A trail of links back up a hierarchy, ending at the screen you are on. The
45
+ * last item is the current one and is drawn as text; everything before it is
46
+ * a link.
47
+ *
48
+ * ```tsx
49
+ * <Breadcrumbs aria-label="Label">
50
+ * <Breadcrumbs.Item href="/first">First item</Breadcrumbs.Item>
51
+ * <Breadcrumbs.Item href="/second">Second item</Breadcrumbs.Item>
52
+ * <Breadcrumbs.Item>Third item</Breadcrumbs.Item>
53
+ * </Breadcrumbs>
54
+ * ```
55
+ *
56
+ * Name it with `aria-label`. A screen that navigates without an `href` gives
57
+ * each item an `id` and the trail an `onAction`, which is handed the `id` of
58
+ * the item pressed. The items may come as one fragment. `style`, `ref` and
59
+ * `testID` land on the row, which is the element a layout positions.
60
+ */
61
+ function Breadcrumbs(t0) {
62
+ const $ = c(26);
63
+ let children;
64
+ let onAction;
65
+ let props;
66
+ let style;
67
+ let t1;
68
+ if ($[0] !== t0) {
69
+ ({children, isDisabled: t1, onAction, style, ...props} = t0);
70
+ $[0] = t0;
71
+ $[1] = children;
72
+ $[2] = onAction;
73
+ $[3] = props;
74
+ $[4] = style;
75
+ $[5] = t1;
76
+ } else {
77
+ children = $[1];
78
+ onAction = $[2];
79
+ props = $[3];
80
+ style = $[4];
81
+ t1 = $[5];
82
+ }
83
+ const isDisabled = t1 === void 0 ? false : t1;
84
+ const theme = useTheme();
85
+ let T0;
86
+ let t2;
87
+ let t3;
88
+ let t4;
89
+ let t5;
90
+ if ($[6] !== children || $[7] !== isDisabled || $[8] !== onAction || $[9] !== props || $[10] !== style || $[11] !== theme) {
91
+ const items = positionsOf(itemsOf(children), isDisabled, onAction);
92
+ T0 = View;
93
+ t2 = props;
94
+ t3 = "group";
95
+ if ($[17] !== style || $[18] !== theme) {
96
+ t4 = composeStyles(stylesOf(theme).root, style);
97
+ $[17] = style;
98
+ $[18] = theme;
99
+ $[19] = t4;
100
+ } else t4 = $[19];
101
+ t5 = items.map(_temp);
102
+ $[6] = children;
103
+ $[7] = isDisabled;
104
+ $[8] = onAction;
105
+ $[9] = props;
106
+ $[10] = style;
107
+ $[11] = theme;
108
+ $[12] = T0;
109
+ $[13] = t2;
110
+ $[14] = t3;
111
+ $[15] = t4;
112
+ $[16] = t5;
113
+ } else {
114
+ T0 = $[12];
115
+ t2 = $[13];
116
+ t3 = $[14];
117
+ t4 = $[15];
118
+ t5 = $[16];
119
+ }
120
+ let t6;
121
+ if ($[20] !== T0 || $[21] !== t2 || $[22] !== t3 || $[23] !== t4 || $[24] !== t5) {
122
+ t6 = /* @__PURE__ */ jsx(T0, {
123
+ ...t2,
124
+ role: t3,
125
+ style: t4,
126
+ children: t5
127
+ });
128
+ $[20] = T0;
129
+ $[21] = t2;
130
+ $[22] = t3;
131
+ $[23] = t4;
132
+ $[24] = t5;
133
+ $[25] = t6;
134
+ } else t6 = $[25];
135
+ return t6;
136
+ }
137
+ /**
138
+ * One entry in the trail. Give it an `href` to navigate, or an `id` and let
139
+ * the trail's `onAction` handle it. The last entry is the current screen and
140
+ * is drawn as text rather than a link, whatever it is given. `style`, `ref`
141
+ * and `testID` land on the entry's row, which holds its label and the
142
+ * chevron after it.
143
+ */
144
+ function _temp(t0) {
145
+ const { element, key, position } = t0;
146
+ return /* @__PURE__ */ jsx(ItemContext, {
147
+ value: position,
148
+ children: element
149
+ }, key);
150
+ }
151
+ function BreadcrumbsItem(t0) {
152
+ const $ = c(31);
153
+ let children;
154
+ let href;
155
+ let id;
156
+ let props;
157
+ let style;
158
+ if ($[0] !== t0) {
159
+ ({children, href, id, style, ...props} = t0);
160
+ $[0] = t0;
161
+ $[1] = children;
162
+ $[2] = href;
163
+ $[3] = id;
164
+ $[4] = props;
165
+ $[5] = style;
166
+ } else {
167
+ children = $[1];
168
+ href = $[2];
169
+ id = $[3];
170
+ props = $[4];
171
+ style = $[5];
172
+ }
173
+ const theme = useTheme();
174
+ const { isCurrent, isDisabled, onAction } = use(ItemContext);
175
+ const labelRole = useTypeRole("labelLarge");
176
+ let T0;
177
+ let label;
178
+ let own;
179
+ let t1;
180
+ let t2;
181
+ if ($[6] !== isCurrent || $[7] !== labelRole || $[8] !== props || $[9] !== style || $[10] !== theme) {
182
+ own = stylesOf(theme);
183
+ label = composeStyles(labelRole, own.label, isCurrent ? own.current : void 0);
184
+ T0 = View;
185
+ t1 = props;
186
+ t2 = composeStyles(own.item, style);
187
+ $[6] = isCurrent;
188
+ $[7] = labelRole;
189
+ $[8] = props;
190
+ $[9] = style;
191
+ $[10] = theme;
192
+ $[11] = T0;
193
+ $[12] = label;
194
+ $[13] = own;
195
+ $[14] = t1;
196
+ $[15] = t2;
197
+ } else {
198
+ T0 = $[11];
199
+ label = $[12];
200
+ own = $[13];
201
+ t1 = $[14];
202
+ t2 = $[15];
203
+ }
204
+ let t3;
205
+ if ($[16] !== children || $[17] !== href || $[18] !== id || $[19] !== isCurrent || $[20] !== isDisabled || $[21] !== label || $[22] !== onAction || $[23] !== own || $[24] !== theme) {
206
+ t3 = isCurrent ? /* @__PURE__ */ jsx(Text, {
207
+ ...Platform.OS === "web" ? CURRENT_PAGE : void 0,
208
+ style: label,
209
+ children
210
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, {
211
+ style: label,
212
+ children: /* @__PURE__ */ jsx(Link, {
213
+ href,
214
+ isDisabled,
215
+ onPress: actionOf(id, isDisabled ? void 0 : onAction),
216
+ tone: "inherit",
217
+ underline: "hover",
218
+ children
219
+ })
220
+ }), /* @__PURE__ */ jsx(ChevronEndGlyph, {
221
+ color: theme.colors.onSurfaceVariant,
222
+ size: CHEVRON_SIZE,
223
+ style: own.chevron
224
+ })] });
225
+ $[16] = children;
226
+ $[17] = href;
227
+ $[18] = id;
228
+ $[19] = isCurrent;
229
+ $[20] = isDisabled;
230
+ $[21] = label;
231
+ $[22] = onAction;
232
+ $[23] = own;
233
+ $[24] = theme;
234
+ $[25] = t3;
235
+ } else t3 = $[25];
236
+ let t4;
237
+ if ($[26] !== T0 || $[27] !== t1 || $[28] !== t2 || $[29] !== t3) {
238
+ t4 = /* @__PURE__ */ jsx(T0, {
239
+ ...t1,
240
+ style: t2,
241
+ children: t3
242
+ });
243
+ $[26] = T0;
244
+ $[27] = t1;
245
+ $[28] = t2;
246
+ $[29] = t3;
247
+ $[30] = t4;
248
+ } else t4 = $[30];
249
+ return t4;
250
+ }
251
+ /**
252
+ * The entries among a trail's children, with any fragment between them
253
+ * opened, so a trail can take its items as one fragment. Each keeps a key
254
+ * made of its own and its fragments', so two fragments' children never share
255
+ * one.
256
+ */
257
+ function itemsOf(children, prefix = "") {
258
+ return Children.toArray(children).flatMap((child) => {
259
+ if (!isValidElement(child)) return [];
260
+ const key = `${prefix}${String(child.key)}`;
261
+ return child.type === Fragment ? itemsOf(child.props.children, `${key}/`) : [{
262
+ element: child,
263
+ key
264
+ }];
265
+ });
266
+ }
267
+ /**
268
+ * Each entry with where it stands: the last is the current one, and the
269
+ * trail's `isDisabled` and `onAction` reach every one.
270
+ */
271
+ function positionsOf(items, isDisabled, onAction) {
272
+ return items.map((item, index) => ({
273
+ ...item,
274
+ position: {
275
+ isCurrent: index === items.length - 1,
276
+ isDisabled,
277
+ onAction
278
+ }
279
+ }));
280
+ }
281
+ Breadcrumbs.Item = BreadcrumbsItem;
282
+ //#endregion
283
+ export { Breadcrumbs, BreadcrumbsItem };
284
+
285
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactElement","ReactNode","Ref","StyleProp","TextStyle","ViewProps","ViewStyle","Key","Children","createContext","Fragment","isValidElement","use","Text","NativeText","Platform","StyleSheet","View","ChevronEndGlyph","useTheme","composeStyles","themedStyles","useTypeRole","Link","BreadcrumbsItemProps","Omit","children","href","id","ref","style","BreadcrumbsProps","isDisabled","onAction","key","ItemPosition","isCurrent","ItemContext","undefined","CURRENT_PAGE","const","CHEVRON_SIZE","stylesOf","colors","spacing","create","chevron","flexShrink","current","color","onSurface","item","alignItems","columnGap","xs","flexDirection","label","onSurfaceVariant","root","flexWrap","gap","actionOf","Breadcrumbs","t0","$","_c","props","t1","theme","T0","t2","t3","t4","t5","items","positionsOf","itemsOf","map","_temp","t6","element","position","BreadcrumbsItem","labelRole","own","OS","prefix","toArray","flatMap","child","String","type","index","length","Item","_c","NativeText"],"sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactElement, ReactNode, Ref } from 'react'\nimport type { StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native'\nimport type { Key } from 'react-stately'\n\nimport { Children, createContext, Fragment, isValidElement, use } from 'react'\nimport { Text as NativeText, Platform, StyleSheet, View } from 'react-native'\n\nimport { ChevronEndGlyph } from '../../glyphs'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\nimport { Link } from '../link'\n\n// kanso-ui's Breadcrumbs: a trail of links back up a hierarchy, ending at the\n// screen you are on. Material Design has no breadcrumbs page, so web's\n// reading stands, taken from the two nearest pages: the row takes the top app\n// bar's muted content role, on-surface variant, and each link the text\n// button's label large type.\n//\n// Three things are this component's own, as they are web's.\n//\n// **The current item is text, not a link.** It is the last item, drawn in\n// the full-strength on-surface role, so the screen you are on is the most\n// legible thing in the row rather than a faded disabled link. Native has no\n// counterpart to web's `aria-current`, so there it is told apart by being the\n// one item that leads nowhere; on the web it carries `aria-current=\"page\"`,\n// as web's does.\n//\n// **The chevron belongs to the item before it.** Each item that is not the\n// current one draws one after its link, which puts a separator between every\n// pair and none at the end. It says \"further in\" rather than \"to the right\",\n// so it mirrors under a right-to-left layout, and a screen reader skips it.\n//\n// **A link is drawn as a link in a place already understood to be links.**\n// Each is the library's Link with `tone=\"inherit\"`, taking the row's muted\n// colour, and `underline=\"hover\"`, leaving the rule for a pointer. A press\n// goes through the `RouterProvider` around the trail, as any Link's does.\n//\n// The trail is one group named by its `aria-label`, and it wraps onto further\n// lines rather than running off the edge.\n\ntype BreadcrumbsItemProps = Omit<ViewProps, 'children' | 'id' | 'style'> & {\n /** The item's label. */\n readonly children?: ReactNode\n /**\n * Where the item leads. Leave it out on an item the screen handles through\n * the trail's `onAction`, and on the current one, which is never a link.\n */\n readonly href?: string\n /** What the trail's `onAction` is handed when the item is pressed. */\n readonly id?: Key\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n}\n\ntype BreadcrumbsProps = Omit<ViewProps, 'children' | 'style'> & {\n /** The trail, as `Breadcrumbs.Item` entries. */\n readonly children?: ReactNode\n /**\n * Disables every link in the trail.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Called with an item's `id` when its link is pressed, for a screen that\n * navigates without an `href`.\n */\n readonly onAction?: (key: Key) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n}\n\n/** Where an item stands in its trail, which the trail tells each one. */\ntype ItemPosition = {\n readonly isCurrent: boolean\n readonly isDisabled: boolean\n readonly onAction: ((key: Key) => void) | undefined\n}\n\n// An item outside a trail is a link like any other.\nconst ItemContext = createContext<ItemPosition>({\n isCurrent: false,\n isDisabled: false,\n onAction: undefined,\n})\n\n// What marks the current item on the web, where a screen reader reads it.\nconst CURRENT_PAGE = { 'aria-current': 'page' } as const\n\n// 18dp, a step under the 20dp the menus page gives the same glyph, as web's\n// is: a separator inside a row of label large links sits heavier than the\n// words either side of it at 20.\nconst CHEVRON_SIZE = 18\n\nconst stylesOf = themedStyles(({ colors, spacing }) =>\n StyleSheet.create({\n chevron: {\n flexShrink: 0,\n },\n // The item you are on: the links' type in the full-strength content role,\n // so it reads as the end of the trail.\n current: {\n color: colors.onSurface,\n },\n // An item's label and chevron. It shrinks to the row's width when its\n // label alone is wider, so the label wraps inside it.\n item: {\n alignItems: 'center',\n columnGap: spacing.xs,\n flexDirection: 'row',\n flexShrink: 1,\n },\n label: {\n color: colors.onSurfaceVariant,\n flexShrink: 1,\n },\n root: {\n alignItems: 'center',\n flexDirection: 'row',\n flexWrap: 'wrap',\n gap: spacing.xs,\n },\n }),\n)\n\n// What a press on an item's link reports, when the item has an `id` and the\n// trail listens. A disabled trail hands its links nothing to call.\nfunction actionOf(id: Key | undefined, onAction: ItemPosition['onAction']) {\n return id === undefined || onAction === undefined\n ? undefined\n : () => {\n onAction(id)\n }\n}\n\n/**\n * A trail of links back up a hierarchy, ending at the screen you are on. The\n * last item is the current one and is drawn as text; everything before it is\n * a link.\n *\n * ```tsx\n * <Breadcrumbs aria-label=\"Label\">\n * <Breadcrumbs.Item href=\"/first\">First item</Breadcrumbs.Item>\n * <Breadcrumbs.Item href=\"/second\">Second item</Breadcrumbs.Item>\n * <Breadcrumbs.Item>Third item</Breadcrumbs.Item>\n * </Breadcrumbs>\n * ```\n *\n * Name it with `aria-label`. A screen that navigates without an `href` gives\n * each item an `id` and the trail an `onAction`, which is handed the `id` of\n * the item pressed. The items may come as one fragment. `style`, `ref` and\n * `testID` land on the row, which is the element a layout positions.\n */\nfunction Breadcrumbs({\n children,\n isDisabled = false,\n onAction,\n style,\n ...props\n}: BreadcrumbsProps) {\n const theme = useTheme()\n const items = positionsOf(itemsOf(children), isDisabled, onAction)\n\n return (\n <View\n {...props}\n role=\"group\"\n style={composeStyles<ViewStyle>(stylesOf(theme).root, style)}\n >\n {items.map(({ element, key, position }) => (\n <ItemContext key={key} value={position}>\n {element}\n </ItemContext>\n ))}\n </View>\n )\n}\n\n/**\n * One entry in the trail. Give it an `href` to navigate, or an `id` and let\n * the trail's `onAction` handle it. The last entry is the current screen and\n * is drawn as text rather than a link, whatever it is given. `style`, `ref`\n * and `testID` land on the entry's row, which holds its label and the\n * chevron after it.\n */\nfunction BreadcrumbsItem({\n children,\n href,\n id,\n style,\n ...props\n}: BreadcrumbsItemProps) {\n const theme = useTheme()\n const { isCurrent, isDisabled, onAction } = use(ItemContext)\n const labelRole = useTypeRole('labelLarge')\n\n const own = stylesOf(theme)\n const label = composeStyles<TextStyle>(\n labelRole,\n own.label,\n isCurrent ? own.current : undefined,\n )\n\n return (\n <View {...props} style={composeStyles<ViewStyle>(own.item, style)}>\n {isCurrent ? (\n <NativeText\n {...(Platform.OS === 'web' ? CURRENT_PAGE : undefined)}\n style={label}\n >\n {children}\n </NativeText>\n ) : (\n <>\n <NativeText style={label}>\n <Link\n href={href}\n isDisabled={isDisabled}\n onPress={actionOf(id, isDisabled ? undefined : onAction)}\n tone=\"inherit\"\n underline=\"hover\"\n >\n {children}\n </Link>\n </NativeText>\n <ChevronEndGlyph\n color={theme.colors.onSurfaceVariant}\n size={CHEVRON_SIZE}\n style={own.chevron}\n />\n </>\n )}\n </View>\n )\n}\n\n/**\n * The entries among a trail's children, with any fragment between them\n * opened, so a trail can take its items as one fragment. Each keeps a key\n * made of its own and its fragments', so two fragments' children never share\n * one.\n */\nfunction itemsOf(\n children: ReactNode,\n prefix = '',\n): { readonly element: ReactElement; readonly key: string }[] {\n return Children.toArray(children).flatMap((child) => {\n if (!isValidElement<{ readonly children?: ReactNode }>(child)) {\n return []\n }\n const key = `${prefix}${String(child.key)}`\n return child.type === Fragment\n ? itemsOf(child.props.children, `${key}/`)\n : [{ element: child, key }]\n })\n}\n\n/**\n * Each entry with where it stands: the last is the current one, and the\n * trail's `isDisabled` and `onAction` reach every one.\n */\nfunction positionsOf(\n items: readonly { readonly element: ReactElement; readonly key: string }[],\n isDisabled: boolean,\n onAction: ItemPosition['onAction'],\n) {\n return items.map((item, index) => ({\n ...item,\n position: {\n isCurrent: index === items.length - 1,\n isDisabled,\n onAction,\n } satisfies ItemPosition,\n }))\n}\n\nBreadcrumbs.Item = BreadcrumbsItem\n\nexport { Breadcrumbs, BreadcrumbsItem }\nexport type { BreadcrumbsItemProps, BreadcrumbsProps }\n"],"mappings":";;;;;;;;;;AAgFA,MAAMsC,cAAc5B,cAA4B;CAC9C2B,WAAW;CACXJ,YAAY;CACZC,UAAUK,KAAAA;AACZ,CAAC;AAGD,MAAMC,eAAe,EAAE,gBAAgB,OAAO;AAK9C,MAAME,eAAe;AAErB,MAAMC,WAAWrB,cAAc,EAAEsB,QAAQC,cACvC5B,WAAW6B,OAAO;CAChBC,SAAS,EACPC,YAAY,EACd;CAGAC,SAAS,EACPC,OAAON,OAAOO,UAChB;CAGAC,MAAM;EACJC,YAAY;EACZC,WAAWT,QAAQU;EACnBC,eAAe;EACfR,YAAY;CACd;CACAS,OAAO;EACLP,OAAON,OAAOc;EACdV,YAAY;CACd;CACAW,MAAM;EACJN,YAAY;EACZG,eAAe;EACfI,UAAU;EACVC,KAAKhB,QAAQU;CACf;AACF,CAAC,CACH;AAIA,SAASO,SAASjC,IAAqBK,UAAoC;CACzE,OAAOL,OAAOU,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MAAMvD,MAAM,GAAGoD,SAASI,OAAOD,MAAMvD,GAAG;EACxC,OAAOuD,MAAME,SAASjF,WAClBkE,QAAQa,MAAMvB,MAAMxC,UAAU,GAAGQ,IAAG,EAAG,IACvC,CAAC;GAAE8C,SAASS;GAAOvD;EAAI,CAAC;CAC9B,CAAC;AACH;;;;;AAMA,SAASyC,YACPD,OACA1C,YACAC,UACA;CACA,OAAOyC,MAAMG,KAAK1B,MAAMyC,WAAW;EACjC,GAAGzC;EACH8B,UAAU;GACR7C,WAAWwD,UAAUlB,MAAMmB,SAAS;GACpC7D;GACAC;EACF;CACF,EAAE;AACJ;AAEA6B,YAAYgC,OAAOZ"}
@@ -11,7 +11,7 @@ type CalendarProps$1<T extends DateValue = DateValue> = Pick<CalendarProps<T>, '
11
11
  /**
12
12
  * The BCP 47 locale the calendar is written in: its month and weekday
13
13
  * names, its digits, its first day of the week and its calendar system.
14
- * Defaults to the device's.
14
+ * Defaults to the `I18nProvider`'s, or the device's outside one.
15
15
  */
16
16
  readonly locale?: string;
17
17
  readonly ref?: Ref<ComponentRef<typeof View>>;