@kanso-labs/react-native-kanso-ui 0.8.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 (78) hide show
  1. package/dist/badge/index.js +9 -70
  2. package/dist/badge/index.js.map +1 -1
  3. package/dist/button/index.js +1 -1
  4. package/dist/button/palettes.d.ts +2 -0
  5. package/dist/components/badge/index.d.ts +48 -0
  6. package/dist/components/badge/index.js +122 -0
  7. package/dist/components/badge/index.js.map +1 -0
  8. package/dist/{badge → components/badge}/styles.js +10 -6
  9. package/dist/components/badge/styles.js.map +1 -0
  10. package/dist/components/breadcrumbs/index.d.ts +66 -0
  11. package/dist/components/breadcrumbs/index.js +285 -0
  12. package/dist/components/breadcrumbs/index.js.map +1 -0
  13. package/dist/components/checkbox/index.d.ts +7 -1
  14. package/dist/components/checkbox/index.js +183 -138
  15. package/dist/components/checkbox/index.js.map +1 -1
  16. package/dist/components/checkbox-group/index.d.ts +93 -0
  17. package/dist/components/checkbox-group/index.js +306 -0
  18. package/dist/components/checkbox-group/index.js.map +1 -0
  19. package/dist/components/code/index.d.ts +25 -0
  20. package/dist/components/code/index.js +87 -0
  21. package/dist/components/code/index.js.map +1 -0
  22. package/dist/components/container/index.d.ts +47 -0
  23. package/dist/components/container/index.js +85 -0
  24. package/dist/components/container/index.js.map +1 -0
  25. package/dist/components/fab/index.d.ts +80 -0
  26. package/dist/components/fab/index.js +231 -0
  27. package/dist/components/fab/index.js.map +1 -0
  28. package/dist/components/fab-menu/index.d.ts +120 -0
  29. package/dist/components/fab-menu/index.js +640 -0
  30. package/dist/components/fab-menu/index.js.map +1 -0
  31. package/dist/components/feed/index.d.ts +57 -0
  32. package/dist/components/feed/index.js +167 -0
  33. package/dist/components/feed/index.js.map +1 -0
  34. package/dist/components/keycap/index.d.ts +27 -0
  35. package/dist/components/keycap/index.js +136 -0
  36. package/dist/components/keycap/index.js.map +1 -0
  37. package/dist/components/menu/index.js +1 -1
  38. package/dist/components/separator/index.d.ts +3 -2
  39. package/dist/components/separator/index.js +29 -26
  40. package/dist/components/separator/index.js.map +1 -1
  41. package/dist/components/supporting-pane/index.d.ts +44 -0
  42. package/dist/components/supporting-pane/index.js +109 -0
  43. package/dist/components/supporting-pane/index.js.map +1 -0
  44. package/dist/components/text/index.d.ts +1 -1
  45. package/dist/components/text/index.js +49 -21
  46. package/dist/components/text/index.js.map +1 -1
  47. package/dist/components/text-area/index.d.ts +145 -0
  48. package/dist/components/text-area/index.js +231 -0
  49. package/dist/components/text-area/index.js.map +1 -0
  50. package/dist/components/toolbar/index.d.ts +53 -0
  51. package/dist/components/toolbar/index.js +185 -0
  52. package/dist/components/toolbar/index.js.map +1 -0
  53. package/dist/control/group.js +23 -0
  54. package/dist/control/group.js.map +1 -0
  55. package/dist/fab/index.d.ts +19 -0
  56. package/dist/fab/index.js +147 -0
  57. package/dist/fab/index.js.map +1 -0
  58. package/dist/field/index.js +84 -43
  59. package/dist/field/index.js.map +1 -1
  60. package/dist/field/styles.js +18 -0
  61. package/dist/field/styles.js.map +1 -1
  62. package/dist/form/index.d.ts +1 -2
  63. package/dist/form/index.js +1 -1
  64. package/dist/form/index.js.map +1 -1
  65. package/dist/index.d.ts +17 -4
  66. package/dist/index.js +15 -3
  67. package/dist/modal/index.js +59 -46
  68. package/dist/modal/index.js.map +1 -1
  69. package/dist/navigation/index.js +8 -5
  70. package/dist/navigation/index.js.map +1 -1
  71. package/dist/overlay/placement.js +3 -1
  72. package/dist/overlay/placement.js.map +1 -1
  73. package/dist/separator/index.js +7 -0
  74. package/dist/separator/index.js.map +1 -0
  75. package/dist/typography/size.js +14 -0
  76. package/dist/typography/size.js.map +1 -0
  77. package/package.json +1 -1
  78. package/dist/badge/styles.js.map +0 -1
@@ -1,76 +1,15 @@
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 { styles, stylesOf } from "./styles.js";
7
- import { c } from "react/compiler-runtime";
8
- import { Text, View } from "react-native";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
+ import { createContext } from "react";
10
2
  //#region src/badge/index.tsx
11
3
  /**
12
- * A badge on the top trailing corner of the icon it wraps: the small dot, or
13
- * with `count` the large badge holding the number.
4
+ * Whether a large badge joins the flow after what it is drawn on rather than
5
+ * standing over its corner. A navigation destination sets its label beside
6
+ * its icon in its horizontal forms, and a count overhangs the icon by up to
7
+ * 22dp on that side: the destination puts the mark in the flow there, so the
8
+ * label starts after it rather than under it. The small badge stays inside
9
+ * its icon's box, so nothing has to make room for it.
14
10
  */
15
- function Badge(t0) {
16
- const $ = c(13);
17
- const { children, count, inFlow: t1, max: t2 } = t0;
18
- const inFlow = t1 === void 0 ? false : t1;
19
- const max = t2 === void 0 ? 999 : t2;
20
- const own = stylesOf(useTheme());
21
- const role = useTypeRole("labelSmall");
22
- const locale = useLocaleOf(void 0);
23
- let t3;
24
- if ($[0] !== count || $[1] !== locale || $[2] !== max) {
25
- t3 = count === void 0 ? void 0 : countOf(count, max, locale);
26
- $[0] = count;
27
- $[1] = locale;
28
- $[2] = max;
29
- $[3] = t3;
30
- } else t3 = $[3];
31
- const label = t3;
32
- const T0 = View;
33
- const t4 = styles;
34
- const T1 = View;
35
- const t5 = true;
36
- const t6 = composeStyles(own.mark, label === void 0 ? styles.small : [own.large, inFlow ? styles.inFlow : styles.over]);
37
- const t7 = label === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
38
- style: styles.space,
39
- children: " "
40
- }), /* @__PURE__ */ jsx(Text, {
41
- style: composeStyles(role, own.count),
42
- children: label
43
- })] });
44
- let t8;
45
- if ($[4] !== T1 || $[5] !== t6 || $[6] !== t7) {
46
- t8 = /* @__PURE__ */ jsx(T1, {
47
- "aria-hidden": t5,
48
- style: t6,
49
- children: t7
50
- });
51
- $[4] = T1;
52
- $[5] = t6;
53
- $[6] = t7;
54
- $[7] = t8;
55
- } else t8 = $[7];
56
- let t9;
57
- if ($[8] !== T0 || $[9] !== children || $[10] !== t4.anchor || $[11] !== t8) {
58
- t9 = /* @__PURE__ */ jsxs(T0, {
59
- style: t4.anchor,
60
- children: [children, t8]
61
- });
62
- $[8] = T0;
63
- $[9] = children;
64
- $[10] = t4.anchor;
65
- $[11] = t8;
66
- $[12] = t9;
67
- } else t9 = $[12];
68
- return t9;
69
- }
70
- function countOf(count, max, locale) {
71
- return count > max ? `${formatCount(max, locale)}+` : formatCount(count, locale);
72
- }
11
+ const BadgeInFlowContext = createContext(false);
73
12
  //#endregion
74
- export { Badge };
13
+ export { BadgeInFlowContext };
75
14
 
76
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ReactNode","TextStyle","ViewStyle","Text","NativeText","View","useLocaleOf","formatCount","useTheme","composeStyles","useTypeRole","styles","stylesOf","BadgeProps","children","count","inFlow","max","Badge","t0","$","_c","t1","t2","undefined","own","role","locale","t3","countOf","label","T0","T1","t5","t6","mark","small","large","over","t7","space","t8","t9","t4","anchor","_c","NativeText"],"sources":["../../src/badge/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { TextStyle, ViewStyle } from 'react-native'\n\nimport { Text as NativeText, View } from 'react-native'\n\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 on a navigation\n// destination: a mark on the corner of an icon that flags something new\n// there, either as the 6dp small badge or as the 16dp large badge holding a\n// count. Both are the error pair, the error role with the count in on error,\n// on a full corner, and the count is label small, capped with a plus, as\n// \"999+\".\n//\n// The badge wraps the icon and places the mark against the icon's box,\n// which is what the page measures from. The small badge fills the icon's top\n// trailing 6dp square. The large badge's bottom leading corner sits 14dp\n// down and 12dp in from the icon's top trailing corner, so it stands 2dp\n// above the icon and grows toward the end as its count lengthens. Both are\n// placed by `start` and `end`, so the mark stays on the trailing corner under\n// right-to-left.\n//\n// Where a label stands beside the icon rather than under it, the large badge\n// joins the flow after the icon instead, so the label starts after it rather\n// than under it: `inFlow`. The small badge stays inside the icon's box, so\n// nothing has to make room for 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 = {\n /** What the badge is drawn on: an icon, at 24dp. */\n readonly children?: ReactNode\n /**\n * The number to show, which draws the large badge. Left out, the badge is\n * the small dot, which flags without counting.\n */\n readonly count?: number | undefined\n /**\n * Draws the large badge in the flow after the icon rather than over its\n * corner, for a label beside the icon.\n * @default false\n */\n readonly inFlow?: boolean\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}\n\n/**\n * A badge on the top trailing corner of the icon it wraps: the small dot, or\n * with `count` the large badge holding the number.\n */\nfunction Badge({ children, count, inFlow = false, max = 999 }: BadgeProps) {\n const own = stylesOf(useTheme())\n const role = useTypeRole('labelSmall')\n const locale = useLocaleOf(undefined)\n const label = count === undefined ? undefined : countOf(count, max, locale)\n\n return (\n <View style={styles.anchor}>\n {children}\n <View\n aria-hidden\n style={composeStyles<ViewStyle>(\n own.mark,\n label === undefined\n ? styles.small\n : [own.large, inFlow ? styles.inFlow : styles.over],\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":";;;;;;;;;;;;;;AAqEA,SAAAkB,MAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAe,MAAA,EAAAP,UAAAC,OAAAC,QAAAM,IAAAL,KAAAM,OAAAJ;CAAmB,MAAAH,SAAAM,OAAAE,KAAAA,IAAA,QAAAF;CAAgB,MAAAL,MAAAM,OAAAC,KAAAA,IAAA,MAAAD;CAChD,MAAAE,MAAYb,SAASJ,SAAS,CAAC;CAC/B,MAAAkB,OAAahB,YAAY,YAAY;CACrC,MAAAiB,SAAerB,YAAYkB,KAAAA,CAAS;CAAC,IAAAI;CAAA,IAAAR,EAAA,OAAAL,SAAAK,EAAA,OAAAO,UAAAP,EAAA,OAAAH,KAAA;EACvBW,KAAAb,UAAUS,KAAAA,IAAVA,KAAAA,IAAkCK,QAAQd,OAAOE,KAAKU,MAAM;EAACP,EAAA,KAAAL;EAAAK,EAAA,KAAAO;EAAAP,EAAA,KAAAH;EAAAG,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAA3E,MAAAU,QAAcF;CAGX,MAAAG,KAAA1B;CAAYM,MAAAA,KAAAA;CAEV,MAAAqB,KAAA3B;CACC,MAAA4B,KAAA;CACO,MAAAC,KAAAzB,cACLgB,IAAGU,MACHL,UAAUN,KAAAA,IACNb,OAAMyB,QADV,CAEKX,IAAGY,OAAQrB,SAASL,OAAMK,SAAUL,OAAM2B,IAAK,CACtD;CAEC,MAAAC,KAAAT,UAAUN,KAAAA,IAAV,OAAA,qBAAA,UAAA,EAAA,UAAA,CAEG,oBAACsB,MAAD;EAAmB,OAAAnC,OAAM6B;EAAQ,UAAA;CAAtB,CAAA,GACX,oBAACM,MAAD;EAAmB,OAAArC,cAAyBiB,MAAMD,IAAGV,KAAM;EACxDe,UAAAA;CADQ,CAAA,CAEE,EAAA,CAAA;CAEhB,IAAAW;CAAA,IAAArB,EAAA,OAAAY,MAAAZ,EAAA,OAAAc,MAAAd,EAAA,OAAAmB,IAAA;EAhBHE,KAAA,oBAAC,IAAD;GACE,eAAAR;GACO,OAAAC;GAONK,UAAAA;EATE,CAAA;EAiBEnB,EAAA,KAAAY;EAAAZ,EAAA,KAAAc;EAAAd,EAAA,KAAAmB;EAAAnB,EAAA,KAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,IAAAsB;CAAA,IAAAtB,EAAA,OAAAW,MAAAX,EAAA,OAAAN,YAAAM,EAAA,QAAAuB,GAAAC,UAAAxB,EAAA,QAAAqB,IAAA;EAnBTC,KAAA,qBAAC,IAAD;GAAa,OAAA/B,GAAMiC;GAAnB,UAAA,CACG9B,UACD2B,EAFG;;EAoBErB,EAAA,KAAAW;EAAAX,EAAA,KAAAN;EAAAM,EAAA,MAAAuB,GAAAC;EAAAxB,EAAA,MAAAqB;EAAArB,EAAA,MAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,OApBPsB;AAoBO;AAMX,SAASb,QAAQd,OAAeE,KAAaU,QAAgB;CAC3D,OAAOZ,QAAQE,MACX,GAAGV,YAAYU,KAAKU,MAAM,EAAC,KAC3BpB,YAAYQ,OAAOY,MAAM;AAC/B"}
1
+ {"version":3,"file":"index.js","names":["createContext","BadgeInFlowContext"],"sources":["../../src/badge/index.tsx"],"sourcesContent":["import { createContext } from 'react'\n\n// What a component drawing a badge can say about where its large mark goes,\n// as src/badge does on web. A module of its own rather than a part of the one\n// place that uses it, since the badge reads it and that place draws the\n// badge.\n\n/**\n * Whether a large badge joins the flow after what it is drawn on rather than\n * standing over its corner. A navigation destination sets its label beside\n * its icon in its horizontal forms, and a count overhangs the icon by up to\n * 22dp on that side: the destination puts the mark in the flow there, so the\n * label starts after it rather than under it. The small badge stays inside\n * its icon's box, so nothing has to make room for it.\n */\nconst BadgeInFlowContext = createContext(false)\n\nexport { BadgeInFlowContext }\n"],"mappings":";;;;;;;;;;AAeA,MAAMC,qBAAqBD,cAAc,KAAK"}
@@ -1,7 +1,7 @@
1
1
  import { useTheme } from "../theme/scope.js";
2
+ import { useOpenLink } from "../router/index.js";
2
3
  import { FormContext } from "../form/index.js";
3
4
  import { refsOf } from "../ref/index.js";
4
- import { useOpenLink } from "../router/index.js";
5
5
  import { ButtonSlotContext } from "./slots.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import { Platform, Pressable, StyleSheet } from "react-native";
@@ -0,0 +1,2 @@
1
+ import "../index.js";
2
+ import { ViewStyle } from "react-native";
@@ -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":"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"}
@@ -1,9 +1,10 @@
1
- import { themedStyles } from "../theme/styles.js";
1
+ import { themedStyles } from "../../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