@kanso-labs/react-native-kanso-ui 0.5.0 → 0.6.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 (112) hide show
  1. package/README.md +4 -1
  2. package/dist/badge/index.js +74 -0
  3. package/dist/badge/index.js.map +1 -0
  4. package/dist/badge/styles.js +51 -0
  5. package/dist/badge/styles.js.map +1 -0
  6. package/dist/button/index.d.ts +1 -1
  7. package/dist/button/index.js +1 -1
  8. package/dist/button/pending.js +1 -1
  9. package/dist/button/slots.d.ts +2 -2
  10. package/dist/chip/index.js +2 -2
  11. package/dist/components/app-bar/index.d.ts +111 -0
  12. package/dist/components/app-bar/index.js +341 -0
  13. package/dist/components/app-bar/index.js.map +1 -0
  14. package/dist/components/avatar/index.d.ts +1 -1
  15. package/dist/components/button/index.d.ts +1 -1
  16. package/dist/components/button/index.js +2 -2
  17. package/dist/components/card/index.d.ts +1 -1
  18. package/dist/components/card/index.js +3 -3
  19. package/dist/components/checkbox/index.d.ts +1 -1
  20. package/dist/components/checkbox/index.js +1 -1
  21. package/dist/components/chip/index.d.ts +1 -1
  22. package/dist/components/chip/index.js +1 -1
  23. package/dist/components/chip-group/index.d.ts +1 -1
  24. package/dist/components/chip-group/index.js +4 -4
  25. package/dist/components/copy-field/index.d.ts +1 -1
  26. package/dist/components/copy-field/index.js +1 -1
  27. package/dist/components/currency/index.d.ts +1 -1
  28. package/dist/components/currency/index.js +1 -1
  29. package/dist/components/dialog/index.d.ts +1 -1
  30. package/dist/components/dialog/index.js +2 -2
  31. package/dist/components/icon-button/index.d.ts +1 -1
  32. package/dist/components/icon-button/index.js +2 -2
  33. package/dist/components/link/index.d.ts +1 -1
  34. package/dist/components/link/index.js +3 -3
  35. package/dist/components/list/index.d.ts +1 -1
  36. package/dist/components/list/index.js +5 -5
  37. package/dist/components/list-detail/index.d.ts +56 -0
  38. package/dist/components/list-detail/index.js +169 -0
  39. package/dist/components/list-detail/index.js.map +1 -0
  40. package/dist/components/list-item/index.d.ts +1 -1
  41. package/dist/components/list-item/index.js +1 -1
  42. package/dist/components/menu/index.d.ts +1 -1
  43. package/dist/components/menu/index.js +6 -6
  44. package/dist/components/meter/index.d.ts +1 -1
  45. package/dist/components/meter/index.js +1 -1
  46. package/dist/components/navigation-bar/index.d.ts +170 -0
  47. package/dist/components/navigation-bar/index.js +494 -0
  48. package/dist/components/navigation-bar/index.js.map +1 -0
  49. package/dist/components/number-field/index.d.ts +1 -1
  50. package/dist/components/number-field/index.js +5 -5
  51. package/dist/components/popover/index.d.ts +1 -1
  52. package/dist/components/popover/index.js +2 -2
  53. package/dist/components/product-icon/index.d.ts +1 -1
  54. package/dist/components/progress-indicator/index.d.ts +1 -1
  55. package/dist/components/progress-indicator/index.js +3 -3
  56. package/dist/components/radio-group/index.d.ts +1 -1
  57. package/dist/components/radio-group/index.js +3 -3
  58. package/dist/components/search-field/index.d.ts +1 -1
  59. package/dist/components/search-field/index.js +5 -5
  60. package/dist/components/segmented-button/index.d.ts +1 -1
  61. package/dist/components/segmented-button/index.js +5 -5
  62. package/dist/components/separator/index.d.ts +1 -1
  63. package/dist/components/separator/index.js +1 -1
  64. package/dist/components/sheet/index.d.ts +1 -1
  65. package/dist/components/sheet/index.js +3 -3
  66. package/dist/components/snackbar/index.d.ts +1 -1
  67. package/dist/components/snackbar/index.js +4 -4
  68. package/dist/components/stack/index.d.ts +1 -1
  69. package/dist/components/stack/index.js +1 -1
  70. package/dist/components/switch/index.d.ts +1 -1
  71. package/dist/components/switch/index.js +4 -4
  72. package/dist/components/text/index.d.ts +1 -1
  73. package/dist/components/text/index.js +1 -1
  74. package/dist/components/text-field/index.d.ts +1 -1
  75. package/dist/components/text-field/index.js +1 -1
  76. package/dist/control/checkbox-box.js +2 -2
  77. package/dist/control/index.js +1 -1
  78. package/dist/field/index.d.ts +1 -1
  79. package/dist/field/index.js +4 -4
  80. package/dist/form/index.d.ts +1 -1
  81. package/dist/glyphs/index.js +2 -2
  82. package/dist/hooks/useAppBarScroll.d.ts +56 -0
  83. package/dist/hooks/useAppBarScroll.js +87 -0
  84. package/dist/hooks/useAppBarScroll.js.map +1 -0
  85. package/dist/index.d.ts +7 -3
  86. package/dist/index.js +7 -3
  87. package/dist/indicator/index.d.ts +2 -2
  88. package/dist/indicator/index.js +3 -3
  89. package/dist/indicator/motion.js +1 -1
  90. package/dist/mark/index.d.ts +1 -1
  91. package/dist/mark/index.js +2 -2
  92. package/dist/modal/index.d.ts +1 -1
  93. package/dist/modal/index.js +2 -2
  94. package/dist/navigation/index.d.ts +29 -0
  95. package/dist/navigation/index.js +405 -0
  96. package/dist/navigation/index.js.map +1 -0
  97. package/dist/navigation/styles.js +61 -0
  98. package/dist/navigation/styles.js.map +1 -0
  99. package/dist/overlay/anchored.d.ts +2 -2
  100. package/dist/overlay/anchored.js +1 -1
  101. package/dist/overlay/host.d.ts +2 -2
  102. package/dist/overlay/host.js +1 -1
  103. package/dist/overlay/panel.js +2 -2
  104. package/dist/press/index.js +75 -69
  105. package/dist/press/index.js.map +1 -1
  106. package/dist/router/index.js +1 -1
  107. package/dist/row/index.js +1 -1
  108. package/dist/theme/scope.js +1 -1
  109. package/dist/theme-scope.d.ts +1 -1
  110. package/dist/theme-scope.js +1 -1
  111. package/dist/typography/fonts.js +1 -1
  112. package/package.json +2 -2
@@ -1,24 +1,24 @@
1
- import { CheckGlyph, ChevronEndGlyph } from "../../glyphs/index.js";
2
1
  import { useTheme } from "../../theme/scope.js";
3
2
  import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { usePressFeedback } from "../../press/index.js";
4
4
  import { useTypeRole } from "../../typography/roles.js";
5
+ import { rowContentColor, rowStyles } from "../../row/styles.js";
6
+ import { RowContent, rowStyleOf } from "../../row/index.js";
7
+ import { CheckGlyph, ChevronEndGlyph } from "../../glyphs/index.js";
5
8
  import { refsOf } from "../../ref/index.js";
6
9
  import { useOpenLink } from "../../router/index.js";
7
10
  import { ButtonSlotContext } from "../../button/slots.js";
8
11
  import { ProgressIndicator } from "../progress-indicator/index.js";
9
12
  import { messagesFor } from "../../i18n/index.js";
10
- import { usePressFeedback } from "../../press/index.js";
11
13
  import { Overlay } from "../../overlay/host.js";
12
14
  import { useAnchoredPlacement } from "../../overlay/anchored.js";
13
- import { rowContentColor, rowStyles } from "../../row/styles.js";
14
- import { RowContent, rowStyleOf } from "../../row/index.js";
15
15
  import { DismissLayer, PANEL_ORIGINS, useBackToClose, useFocusOnPlaced, usePanelMotion, useReturnFocus } from "../../overlay/panel.js";
16
16
  import { Separator } from "../separator/index.js";
17
17
  import { c } from "react/compiler-runtime";
18
- import { Children, createContext, use, useEffect, useId, useRef, useState } from "react";
19
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
20
18
  import { I18nManager, Platform, Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
21
19
  import Animated from "react-native-reanimated";
20
+ import { Children, createContext, use, useEffect, useId, useRef, useState } from "react";
21
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
22
22
  import { useMenuTriggerState, useSubmenuTriggerState } from "react-stately/useMenuTriggerState";
23
23
  import { useTreeState } from "react-stately/useTreeState";
24
24
  //#region src/components/menu/index.tsx
@@ -1,6 +1,6 @@
1
1
  import { IndicatorTone } from "../../indicator/index.js";
2
- import { ComponentRef, Ref } from "react";
3
2
  import { StyleProp, View, ViewProps, ViewStyle } from "react-native";
3
+ import { ComponentRef, Ref } from "react";
4
4
  //#region src/components/meter/index.d.ts
5
5
  type MeterProps = Omit<ViewProps, 'children' | 'style'> & {
6
6
  /**
@@ -3,8 +3,8 @@ import { composeStyles } from "../../theme/styles.js";
3
3
  import { DETERMINATE_EASING, stylesOf } from "../../indicator/styles.js";
4
4
  import { IndicatorLabels, IndicatorLine, readingOf, useEased, useIndicatorColors, useMeasuredWidth } from "../../indicator/index.js";
5
5
  import { c } from "react/compiler-runtime";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
6
  import { StyleSheet, View } from "react-native";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region src/components/meter/index.tsx
9
9
  const styles = StyleSheet.create({ line: { alignSelf: "stretch" } });
10
10
  /**
@@ -0,0 +1,170 @@
1
+ import { NavigationDestinationProps } from "../../navigation/index.js";
2
+ import { StyleProp, View, ViewProps, ViewStyle } from "react-native";
3
+ import { ComponentRef, ReactNode, Ref } from "react";
4
+ //#region src/components/navigation-bar/index.d.ts
5
+ type NavigationBarItemProps = NavigationDestinationProps & {
6
+ /**
7
+ * Where the destination goes, through the app's router, and what the
8
+ * bar's `selectedRoute` is matched against.
9
+ */
10
+ readonly href: string;
11
+ };
12
+ type NavigationBarProps = Omit<ViewProps, 'children' | 'style'> & {
13
+ /** The destinations, each a `NavigationBar.Item`. */
14
+ readonly children?: ReactNode;
15
+ readonly ref?: Ref<ComponentRef<typeof View>>;
16
+ /**
17
+ * The route of the current destination, matched against each
18
+ * destination's `href`. The match is the selected tab, and draws the
19
+ * active indicator.
20
+ */
21
+ readonly selectedRoute?: string | undefined;
22
+ readonly style?: StyleProp<ViewStyle>;
23
+ };
24
+ /** The routes a tab navigator hands its tab bar, as both navigators do. */
25
+ type NavigationTabBarProps = Omit<NavigationBarProps, 'children' | 'selectedRoute'> & TabNavigatorProps & {
26
+ /** Each route's options, by the route's key. */
27
+ readonly descriptors: Readonly<Partial<Record<string, {
28
+ readonly options: TabOptions;
29
+ }>>>;
30
+ /**
31
+ * The insets the navigator measured, which the bar measures for itself
32
+ * instead.
33
+ */
34
+ readonly insets?: unknown;
35
+ /** The navigator's routes, and which of them is focused. */
36
+ readonly state: {
37
+ readonly index: number;
38
+ readonly routes: readonly TabRoute[];
39
+ };
40
+ };
41
+ /**
42
+ * What hears a tab bar's events: React Navigation's `navigation` and Expo
43
+ * Router's `emitter` alike.
44
+ */
45
+ type TabEmitter = {
46
+ emit(event: TabEvent): unknown;
47
+ };
48
+ /** The events a tab bar reports, as both navigators name them. */
49
+ type TabEvent = {
50
+ readonly canPreventDefault: true;
51
+ readonly target: string;
52
+ readonly type: 'tabPress';
53
+ } | {
54
+ readonly target: string;
55
+ readonly type: 'tabLongPress';
56
+ };
57
+ /**
58
+ * How a tab bar moves to a tab: through React Navigation's `navigation`, or
59
+ * through Expo Router's `navigateToTab`.
60
+ */
61
+ type TabNavigatorProps = {
62
+ readonly emitter: TabEmitter;
63
+ readonly navigateToTab: (routeKey: string) => void;
64
+ readonly navigation?: never;
65
+ } | {
66
+ readonly emitter?: never;
67
+ readonly navigateToTab?: never;
68
+ readonly navigation: TabEmitter & {
69
+ navigate(name: string, params?: object): void;
70
+ };
71
+ };
72
+ /**
73
+ * A tab's options the bar reads, as React Navigation's bottom tabs and Expo
74
+ * Router's tabs both hand them to a tab bar. Options they take that are not
75
+ * listed here are left to them.
76
+ */
77
+ type TabOptions = {
78
+ /** The tab's name for a screen reader, where it differs from its label. */
79
+ readonly tabBarAccessibilityLabel?: string | undefined;
80
+ /**
81
+ * The badge on the tab's icon. A number, or a string of digits, is the
82
+ * large badge's count; any other string is the small dot, since a badge
83
+ * draws a count and nothing else.
84
+ */
85
+ readonly tabBarBadge?: number | string | undefined;
86
+ readonly tabBarButtonTestID?: string | undefined;
87
+ /** The tab's icon, drawn at the size and in the colour it is handed. */
88
+ readonly tabBarIcon?: ((props: {
89
+ readonly color: string;
90
+ readonly focused: boolean;
91
+ readonly size: number;
92
+ }) => ReactNode) | undefined;
93
+ /** The tab's label, in place of its title. */
94
+ readonly tabBarLabel?: ((props: {
95
+ readonly children: string;
96
+ readonly color: string;
97
+ readonly focused: boolean;
98
+ readonly position: 'below-icon' | 'beside-icon';
99
+ }) => ReactNode) | string | undefined;
100
+ readonly title?: string | undefined;
101
+ };
102
+ type TabRoute = {
103
+ readonly key: string;
104
+ readonly name: string;
105
+ readonly params?: object | undefined;
106
+ };
107
+ /**
108
+ * The bar of three to five top-level destinations a compact window keeps at
109
+ * its bottom edge. Each destination goes to its `href` through the app's
110
+ * router, see `RouterProvider`.
111
+ *
112
+ * ```tsx
113
+ * <NavigationBar selectedRoute="/first">
114
+ * <NavigationBar.Item href="/first" icon={<FirstIcon />}>
115
+ * First item
116
+ * </NavigationBar.Item>
117
+ * <NavigationBar.Item href="/second" icon={<SecondIcon />}>
118
+ * Second item
119
+ * </NavigationBar.Item>
120
+ * <NavigationBar.Item href="/third" icon={<ThirdIcon />}>
121
+ * Third item
122
+ * </NavigationBar.Item>
123
+ * </NavigationBar>
124
+ * ```
125
+ *
126
+ * Draw it below the screen's content, at the bottom of the window: it paints
127
+ * its surface to the bottom edge and keeps its destinations clear of the home
128
+ * indicator itself. From the medium window size class each destination puts
129
+ * its label beside its icon, where the bar is wide enough for every label.
130
+ *
131
+ * `style`, `ref` and `testID` land on the bar's own view, which is announced
132
+ * as a tab list.
133
+ */
134
+ declare function NavigationBar({ children, selectedRoute, style, ...props }: NavigationBarProps): import("react").JSX.Element;
135
+ declare namespace NavigationBar {
136
+ var Item: typeof NavigationBarItem;
137
+ }
138
+ /**
139
+ * One destination of a navigation bar: an icon, a label and, while it is the
140
+ * current one, the active indicator behind the icon. Pressing it calls
141
+ * `onPress`, then goes to its `href`. Renders nothing of its own outside a
142
+ * `NavigationBar`, whose `selectedRoute` says whether it is selected.
143
+ *
144
+ * `style`, `ref` and `testID` land on the destination's `Pressable`.
145
+ */
146
+ declare function NavigationBarItem({ href, onPress, ...props }: NavigationBarItemProps): import("react").JSX.Element;
147
+ /**
148
+ * A navigation bar drawing a tab navigator's routes, for the `tabBar` prop of
149
+ * React Navigation's bottom tabs and of Expo Router's `Tabs` alike.
150
+ *
151
+ * ```tsx
152
+ * <Tabs tabBar={(props) => <NavigationTabBar {...props} />}>
153
+ * <Tabs.Screen name="index" options={{ tabBarIcon: () => <FirstIcon />, title: 'First item' }} />
154
+ * </Tabs>
155
+ * ```
156
+ *
157
+ * Each route is a destination, labelled by its `tabBarLabel` or its title,
158
+ * with the icon `tabBarIcon` draws and the badge `tabBarBadge` asks for, and
159
+ * the focused route is the selected one. Pressing a destination reports
160
+ * `tabPress` to the navigator and moves to its route unless a listener
161
+ * prevents it, and a long press reports `tabLongPress`, as the navigators'
162
+ * own tab bars do.
163
+ *
164
+ * `style`, `ref` and `testID` land on the bar's own view, as on a
165
+ * `NavigationBar`.
166
+ */
167
+ declare function NavigationTabBar({ descriptors, emitter, insets: _insets, navigateToTab, navigation, state, ...props }: NavigationTabBarProps): import("react").JSX.Element;
168
+ //#endregion
169
+ export { NavigationBar, NavigationBarItem, type NavigationBarItemProps, type NavigationBarProps, NavigationTabBar, type NavigationTabBarProps };
170
+ //# sourceMappingURL=index.d.ts.map