@kanso-labs/react-native-kanso-ui 0.4.0 → 0.5.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 (122) hide show
  1. package/dist/autocomplete/index.js +39 -0
  2. package/dist/autocomplete/index.js.map +1 -0
  3. package/dist/button/index.d.ts +2 -1
  4. package/dist/button/index.js +35 -2
  5. package/dist/button/index.js.map +1 -1
  6. package/dist/button/pending.js +1 -1
  7. package/dist/button/slots.d.ts +2 -1
  8. package/dist/button/slots.js.map +1 -1
  9. package/dist/chip/index.js +1 -1
  10. package/dist/components/autocomplete/index.d.ts +49 -0
  11. package/dist/components/autocomplete/index.js +87 -0
  12. package/dist/components/autocomplete/index.js.map +1 -0
  13. package/dist/components/avatar/index.d.ts +1 -1
  14. package/dist/components/button/index.d.ts +2 -2
  15. package/dist/components/button/index.js +196 -150
  16. package/dist/components/button/index.js.map +1 -1
  17. package/dist/components/card/index.d.ts +1 -1
  18. package/dist/components/card/index.js +1 -1
  19. package/dist/components/checkbox/index.d.ts +1 -1
  20. package/dist/components/checkbox/index.js +106 -193
  21. package/dist/components/checkbox/index.js.map +1 -1
  22. package/dist/components/chip/index.d.ts +1 -1
  23. package/dist/components/chip-group/index.d.ts +1 -1
  24. package/dist/components/chip-group/index.js +1 -1
  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 +3 -2
  31. package/dist/components/dialog/index.js.map +1 -1
  32. package/dist/components/icon-button/index.d.ts +2 -2
  33. package/dist/components/icon-button/index.js +205 -159
  34. package/dist/components/icon-button/index.js.map +1 -1
  35. package/dist/components/link/index.d.ts +1 -1
  36. package/dist/components/link/index.js +1 -1
  37. package/dist/components/list/index.d.ts +216 -0
  38. package/dist/components/list/index.js +1118 -0
  39. package/dist/components/list/index.js.map +1 -0
  40. package/dist/components/list-item/index.d.ts +63 -0
  41. package/dist/components/list-item/index.js +275 -0
  42. package/dist/components/list-item/index.js.map +1 -0
  43. package/dist/components/menu/index.d.ts +309 -0
  44. package/dist/components/menu/index.js +1283 -0
  45. package/dist/components/menu/index.js.map +1 -0
  46. package/dist/components/meter/index.d.ts +1 -1
  47. package/dist/components/meter/index.js +1 -1
  48. package/dist/components/number-field/index.d.ts +1 -1
  49. package/dist/components/number-field/index.js +2 -2
  50. package/dist/components/popover/index.d.ts +140 -0
  51. package/dist/components/popover/index.js +704 -0
  52. package/dist/components/popover/index.js.map +1 -0
  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 +1 -1
  56. package/dist/components/radio-group/index.d.ts +1 -1
  57. package/dist/components/radio-group/index.js +1 -1
  58. package/dist/components/search-field/index.d.ts +12 -4
  59. package/dist/components/search-field/index.js +64 -58
  60. package/dist/components/search-field/index.js.map +1 -1
  61. package/dist/components/segmented-button/index.d.ts +1 -1
  62. package/dist/components/segmented-button/index.js +1 -1
  63. package/dist/components/separator/index.d.ts +1 -1
  64. package/dist/components/separator/index.js +1 -1
  65. package/dist/components/sheet/index.d.ts +1 -1
  66. package/dist/components/sheet/index.js +3 -2
  67. package/dist/components/sheet/index.js.map +1 -1
  68. package/dist/components/snackbar/index.d.ts +1 -1
  69. package/dist/components/snackbar/index.js +1 -1
  70. package/dist/components/stack/index.d.ts +1 -1
  71. package/dist/components/stack/index.js +1 -1
  72. package/dist/components/switch/index.d.ts +1 -1
  73. package/dist/components/switch/index.js +1 -1
  74. package/dist/components/text/index.d.ts +1 -1
  75. package/dist/components/text/index.js +1 -1
  76. package/dist/components/text-field/index.d.ts +1 -1
  77. package/dist/components/text-field/index.js +1 -1
  78. package/dist/control/checkbox-box.js +137 -0
  79. package/dist/control/checkbox-box.js.map +1 -0
  80. package/dist/control/index.js +1 -1
  81. package/dist/field/index.d.ts +1 -1
  82. package/dist/field/index.js +1 -1
  83. package/dist/form/index.d.ts +1 -1
  84. package/dist/glyphs/index.js +21 -2
  85. package/dist/glyphs/index.js.map +1 -1
  86. package/dist/i18n/index.js +16 -1
  87. package/dist/i18n/index.js.map +1 -1
  88. package/dist/i18n/messages.js +272 -34
  89. package/dist/i18n/messages.js.map +1 -1
  90. package/dist/index.d.ts +6 -1
  91. package/dist/index.js +7 -2
  92. package/dist/indicator/index.d.ts +1 -1
  93. package/dist/indicator/index.js +2 -2
  94. package/dist/mark/index.d.ts +1 -1
  95. package/dist/mark/index.js +1 -1
  96. package/dist/modal/index.d.ts +1 -1
  97. package/dist/modal/index.js +2 -9
  98. package/dist/modal/index.js.map +1 -1
  99. package/dist/overlay/anchored.d.ts +2 -0
  100. package/dist/overlay/anchored.js +182 -0
  101. package/dist/overlay/anchored.js.map +1 -0
  102. package/dist/overlay/host.d.ts +2 -0
  103. package/dist/overlay/host.js +1 -1
  104. package/dist/overlay/index.d.ts +4 -0
  105. package/dist/overlay/panel.js +215 -0
  106. package/dist/overlay/panel.js.map +1 -0
  107. package/dist/overlay/placement.d.ts +8 -0
  108. package/dist/overlay/placement.js +87 -0
  109. package/dist/overlay/placement.js.map +1 -0
  110. package/dist/press/index.js +1 -1
  111. package/dist/ref/index.js +15 -0
  112. package/dist/ref/index.js.map +1 -0
  113. package/dist/router/index.js +1 -1
  114. package/dist/row/index.js +158 -0
  115. package/dist/row/index.js.map +1 -0
  116. package/dist/row/styles.js +51 -0
  117. package/dist/row/styles.js.map +1 -0
  118. package/dist/theme/scope.js +1 -1
  119. package/dist/theme-scope.d.ts +1 -1
  120. package/dist/theme-scope.js +1 -1
  121. package/dist/typography/fonts.js +1 -1
  122. package/package.json +3 -3
@@ -0,0 +1,309 @@
1
+ import { OverlayAlign, OverlaySide } from "../../overlay/placement.js";
2
+ import "../../overlay/index.js";
3
+ import { ReactElement, ReactNode, Ref } from "react";
4
+ import { HostInstance, PressableProps, StyleProp, ViewProps, ViewStyle } from "react-native";
5
+ import { Key, Selection, SelectionMode } from "react-stately";
6
+ //#region src/components/menu/index.d.ts
7
+ type ItemNodeProps = MenuItemProps & {
8
+ readonly submenu?: ReactElement<MenuContentProps>;
9
+ };
10
+ type MenuAlign = OverlayAlign;
11
+ type MenuContentProps<T extends object = object> = Omit<ViewProps, 'children' | 'role' | 'style'> & {
12
+ /**
13
+ * Where the menu lines up along the side it opens on. On `top` and
14
+ * `bottom`, `start` and `end` follow a right-to-left layout.
15
+ * @default 'start'
16
+ */
17
+ readonly align?: MenuAlign;
18
+ /**
19
+ * Moves the menu along that side, in dp: right or down when positive.
20
+ * Left out, a submenu moves up by the surface's own padding, which puts
21
+ * its first item level with the one that opened it.
22
+ */
23
+ readonly alignOffset?: number;
24
+ /**
25
+ * The items, each a `Menu.Item`, `Menu.Section`, `Menu.Separator`,
26
+ * `Menu.Submenu` or `Menu.LoadMore`. With `items`, a function from an item
27
+ * to its part, called for each item in turn.
28
+ */
29
+ readonly children?: ((item: T) => ReactElement) | ReactNode;
30
+ /** The keys selected at first, when the menu keeps its own selection. */
31
+ readonly defaultSelectedKeys?: 'all' | Iterable<Key>;
32
+ /** The keys of the items drawn disabled, which take no presses. */
33
+ readonly disabledKeys?: Iterable<Key>;
34
+ /**
35
+ * Keeps the last selected item selected, so a press on it changes
36
+ * nothing.
37
+ * @default false
38
+ */
39
+ readonly disallowEmptySelection?: boolean;
40
+ /** The entries `children` draws a part for, when it is a function. */
41
+ readonly items?: Iterable<T>;
42
+ /** Called with an item's key when a press on it runs its action. */
43
+ readonly onAction?: (key: Key) => void;
44
+ /** Called when a press on an item closes the menu. */
45
+ readonly onClose?: () => void;
46
+ /** Called with the selected keys whenever a press changes them. */
47
+ readonly onSelectionChange?: (keys: Selection) => void;
48
+ readonly ref?: Ref<HostInstance>;
49
+ /**
50
+ * What the menu shows when nothing is in it. Left out, it is a muted row
51
+ * saying "No results" in the device's language, so the menu keeps a row's
52
+ * height.
53
+ */
54
+ readonly renderEmptyState?: () => ReactNode;
55
+ /**
56
+ * The selected keys, for a call site holding the selection itself with
57
+ * `onSelectionChange`.
58
+ */
59
+ readonly selectedKeys?: 'all' | Iterable<Key>;
60
+ /**
61
+ * Whether a press selects an item: one at a time, several, or none, in
62
+ * which case a press runs the item's action alone.
63
+ * @default 'none'
64
+ */
65
+ readonly selectionMode?: SelectionMode;
66
+ /**
67
+ * Whether a press on an item closes the menu. Left out, it does unless the
68
+ * menu selects several items at once, or the item has an `href`.
69
+ */
70
+ readonly shouldCloseOnSelect?: boolean;
71
+ /**
72
+ * Which side of the trigger the menu opens on. It flips to the opposite
73
+ * side when there is no room. Left out, a menu opens below its trigger and
74
+ * a submenu at the inline end of the item that opens it.
75
+ */
76
+ readonly side?: MenuSide;
77
+ /**
78
+ * The gap between the trigger and the menu, in dp. Left out, a menu sits
79
+ * `spacing.sm` from its trigger and a submenu against its item.
80
+ */
81
+ readonly sideOffset?: number;
82
+ readonly style?: StyleProp<ViewStyle>;
83
+ };
84
+ type MenuItemProps = Omit<PressableProps, 'children' | 'disabled' | 'id' | 'role' | 'style'> & {
85
+ /** The item's label: what it does. */
86
+ readonly children?: ReactNode;
87
+ /**
88
+ * Where a press on the item leads, through the app's router as Button's
89
+ * `href` does. An item with one closes the menu whatever the selection.
90
+ */
91
+ readonly href?: string;
92
+ /**
93
+ * The key the item is selected and reported by. Give one to every item
94
+ * the call site needs to tell apart.
95
+ */
96
+ readonly id?: Key;
97
+ /**
98
+ * Draws the item disabled, and takes no presses on it, as a key in the
99
+ * menu's `disabledKeys` does.
100
+ * @default false
101
+ */
102
+ readonly isDisabled?: boolean;
103
+ /**
104
+ * Content before the label, usually an icon, which takes the label's
105
+ * colour at 24dp. A selected item draws the check here in its place.
106
+ */
107
+ readonly leading?: ReactNode;
108
+ /**
109
+ * Called when a press runs the item's action, in place of the menu's
110
+ * `onAction` for this item.
111
+ */
112
+ readonly onAction?: () => void;
113
+ readonly ref?: Ref<HostInstance>;
114
+ readonly style?: StyleProp<ViewStyle>;
115
+ /**
116
+ * The item's text, read off `children` when they are a plain string, so
117
+ * an item whose label is an element passes it.
118
+ */
119
+ readonly textValue?: string;
120
+ /** Content after the label. */
121
+ readonly trailing?: ReactNode;
122
+ };
123
+ type MenuLoadMoreProps = {
124
+ /**
125
+ * Draws the ring in a row of its own while more items are being fetched.
126
+ * @default false
127
+ */
128
+ readonly isLoading?: boolean;
129
+ /**
130
+ * What a screen reader calls the ring while it shows. Left out, it is the
131
+ * word for it in the device's language, "Loading more" in English.
132
+ */
133
+ readonly label?: string;
134
+ /**
135
+ * Called when the row comes within `scrollOffset` of the menu's visible
136
+ * end, while nothing is loading.
137
+ */
138
+ readonly onLoadMore?: () => void;
139
+ /**
140
+ * How far past the visible end of the menu the row starts loading, as a
141
+ * share of the menu's visible height.
142
+ * @default 1
143
+ */
144
+ readonly scrollOffset?: number;
145
+ readonly style?: StyleProp<ViewStyle>;
146
+ readonly testID?: string;
147
+ };
148
+ type MenuProps = {
149
+ /** The trigger, then the `Menu.Content` it opens. */
150
+ readonly children?: ReactNode;
151
+ /** Whether the menu starts open, when it keeps its own state. */
152
+ readonly defaultOpen?: boolean;
153
+ /** Whether the menu is open, when the call site holds the state. */
154
+ readonly isOpen?: boolean;
155
+ /** Called with the new state as the menu opens or closes. */
156
+ readonly onOpenChange?: (isOpen: boolean) => void;
157
+ /**
158
+ * What opens the menu: a press on the trigger, or a press held on it, in
159
+ * which case a plain press runs the trigger's own `onPress`.
160
+ * @default 'press'
161
+ */
162
+ readonly trigger?: MenuTrigger;
163
+ };
164
+ type MenuSectionProps = {
165
+ readonly 'aria-label'?: string;
166
+ /** The items in the section. */
167
+ readonly children?: ReactNode;
168
+ /**
169
+ * The section's heading, which names the group. A section without one is
170
+ * a group with no name, and takes `aria-label` for one instead.
171
+ */
172
+ readonly header?: ReactNode;
173
+ readonly id?: Key;
174
+ };
175
+ type MenuSeparatorProps = {
176
+ readonly style?: StyleProp<ViewStyle>;
177
+ readonly testID?: string;
178
+ };
179
+ type MenuSide = OverlaySide;
180
+ type MenuSubmenuProps = {
181
+ /**
182
+ * The item that opens the submenu, then the `Menu.Content` it opens.
183
+ * Exactly those two, in that order.
184
+ */
185
+ readonly children: readonly [trigger: ReactElement<MenuItemProps>, content: ReactElement<MenuContentProps>];
186
+ };
187
+ type MenuTrigger = 'longPress' | 'press';
188
+ /**
189
+ * A list of actions or choices opened from a control. Pass `isOpen` with
190
+ * `onOpenChange` to hold the open state, or `defaultOpen` to let it keep its
191
+ * own.
192
+ *
193
+ * ```tsx
194
+ * <Menu>
195
+ * <Button variant="outlined">Open</Button>
196
+ * <Menu.Content>
197
+ * <Menu.Item id="first">First item</Menu.Item>
198
+ * </Menu.Content>
199
+ * </Menu>
200
+ * ```
201
+ *
202
+ * A `Button` or `IconButton` placed directly inside `Menu` is its trigger,
203
+ * and a press on it toggles the menu. Everything the menu shows goes in
204
+ * `Menu.Content`, since the trigger lives in the screen while the menu is
205
+ * drawn above it.
206
+ */
207
+ declare function Menu({ children, defaultOpen, isOpen, onOpenChange, trigger }: MenuProps): import("react").JSX.Element;
208
+ declare namespace Menu {
209
+ var Content: typeof MenuContent;
210
+ var Item: typeof MenuItem;
211
+ var LoadMore: typeof MenuLoadMore;
212
+ var Section: typeof MenuSection;
213
+ var Separator: typeof MenuSeparator;
214
+ var Submenu: typeof MenuSubmenu;
215
+ }
216
+ /**
217
+ * The menu itself, and the surface it is drawn on. Its items scroll when they
218
+ * run past the room the window leaves on the side it opened on.
219
+ *
220
+ * A menu with nothing in it shows a muted "No results" row in place of its
221
+ * items; pass `renderEmptyState` to draw something else.
222
+ *
223
+ * `style`, `ref` and `testID` land on the surface.
224
+ */
225
+ declare function MenuContent<T extends object = object>(props: MenuContentProps<T>): import("react").JSX.Element | null;
226
+ /**
227
+ * One action or choice. Its slots are the row's: `leading` before the label,
228
+ * the label as children, and `trailing` after it. A selected item draws the
229
+ * check, in place of `leading` where it has one and at the end of the row
230
+ * where it has none, so choosing an item moves nothing in the menu. An item
231
+ * that opens a submenu draws the chevron itself.
232
+ *
233
+ * The menu draws it from its entry in the collection, so it renders nothing
234
+ * on its own. `style`, `ref` and `testID` land on the row.
235
+ */
236
+ declare function MenuItem(_props: MenuItemProps): null;
237
+ declare namespace MenuItem {
238
+ var getCollectionNode: (props: ItemNodeProps) => Generator<{
239
+ 'aria-label': string | undefined;
240
+ hasChildNodes: boolean;
241
+ key: Key | undefined;
242
+ props: ItemNodeProps;
243
+ rendered: ReactNode;
244
+ textValue: string;
245
+ type: string;
246
+ }, void, unknown>;
247
+ }
248
+ /**
249
+ * The row shown while more items are being fetched. `onLoadMore` is called
250
+ * when it comes near the visible end of the menu, and the ring is drawn only
251
+ * while `isLoading`. It goes last, after the items it loads more of.
252
+ */
253
+ declare function MenuLoadMore(_props: MenuLoadMoreProps): null;
254
+ declare namespace MenuLoadMore {
255
+ var getCollectionNode: (props: MenuLoadMoreProps) => Generator<{
256
+ hasChildNodes: boolean;
257
+ props: MenuLoadMoreProps;
258
+ rendered: null;
259
+ type: string;
260
+ }, void, unknown>;
261
+ }
262
+ /**
263
+ * A named group of items. `header` names it, and is what a screen reader
264
+ * reads before the items inside.
265
+ */
266
+ declare function MenuSection(_props: MenuSectionProps): null;
267
+ declare namespace MenuSection {
268
+ var getCollectionNode: (props: MenuSectionProps) => Generator<{
269
+ 'aria-label': string | undefined;
270
+ childNodes(): Generator<{
271
+ element: ReactNode;
272
+ }, void, unknown>;
273
+ hasChildNodes: boolean;
274
+ key: Key | undefined;
275
+ props: MenuSectionProps;
276
+ rendered: ReactNode;
277
+ type: string;
278
+ }, void, unknown>;
279
+ }
280
+ /** A rule between groups of items, with the menus page's 8dp either side. */
281
+ declare function MenuSeparator(_props: MenuSeparatorProps): null;
282
+ declare namespace MenuSeparator {
283
+ var getCollectionNode: (props: MenuSeparatorProps) => Generator<{
284
+ hasChildNodes: boolean;
285
+ props: MenuSeparatorProps;
286
+ rendered: null;
287
+ type: string;
288
+ }, void, unknown>;
289
+ }
290
+ /**
291
+ * An item that opens a menu of its own. Takes exactly two children: the
292
+ * `Menu.Item` that opens it, then the `Menu.Content` it opens. A press on
293
+ * the item opens it, and a second press closes it.
294
+ */
295
+ declare function MenuSubmenu(_props: MenuSubmenuProps): null;
296
+ declare namespace MenuSubmenu {
297
+ var getCollectionNode: (props: MenuSubmenuProps) => Generator<{
298
+ 'aria-label': string | undefined;
299
+ hasChildNodes: boolean;
300
+ key: Key | undefined;
301
+ props: ItemNodeProps;
302
+ rendered: ReactNode;
303
+ textValue: string;
304
+ type: string;
305
+ }, void, unknown>;
306
+ }
307
+ //#endregion
308
+ export { Menu, type MenuAlign, MenuContent, type MenuContentProps, MenuItem, type MenuItemProps, MenuLoadMore, type MenuLoadMoreProps, type MenuProps, MenuSection, type MenuSectionProps, MenuSeparator, type MenuSeparatorProps, type MenuSide, MenuSubmenu, type MenuSubmenuProps, type MenuTrigger };
309
+ //# sourceMappingURL=index.d.ts.map