@kanso-labs/react-native-kanso-ui 0.4.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.
- package/README.md +4 -1
- package/dist/autocomplete/index.js +39 -0
- package/dist/autocomplete/index.js.map +1 -0
- package/dist/badge/index.js +74 -0
- package/dist/badge/index.js.map +1 -0
- package/dist/badge/styles.js +51 -0
- package/dist/badge/styles.js.map +1 -0
- package/dist/button/index.d.ts +2 -1
- package/dist/button/index.js +35 -2
- package/dist/button/index.js.map +1 -1
- package/dist/button/slots.d.ts +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/chip/index.js +2 -2
- package/dist/components/app-bar/index.d.ts +111 -0
- package/dist/components/app-bar/index.js +341 -0
- package/dist/components/app-bar/index.js.map +1 -0
- package/dist/components/autocomplete/index.d.ts +49 -0
- package/dist/components/autocomplete/index.js +87 -0
- package/dist/components/autocomplete/index.js.map +1 -0
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/index.js +197 -151
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/card/index.js +2 -2
- package/dist/components/checkbox/index.js +106 -193
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chip-group/index.js +3 -3
- package/dist/components/dialog/index.js +4 -3
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +1 -1
- package/dist/components/icon-button/index.js +206 -160
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/link/index.js +2 -2
- package/dist/components/list/index.d.ts +216 -0
- package/dist/components/list/index.js +1118 -0
- package/dist/components/list/index.js.map +1 -0
- package/dist/components/list-detail/index.d.ts +56 -0
- package/dist/components/list-detail/index.js +169 -0
- package/dist/components/list-detail/index.js.map +1 -0
- package/dist/components/list-item/index.d.ts +63 -0
- package/dist/components/list-item/index.js +275 -0
- package/dist/components/list-item/index.js.map +1 -0
- package/dist/components/menu/index.d.ts +309 -0
- package/dist/components/menu/index.js +1283 -0
- package/dist/components/menu/index.js.map +1 -0
- package/dist/components/navigation-bar/index.d.ts +170 -0
- package/dist/components/navigation-bar/index.js +494 -0
- package/dist/components/navigation-bar/index.js.map +1 -0
- package/dist/components/number-field/index.js +3 -3
- package/dist/components/popover/index.d.ts +140 -0
- package/dist/components/popover/index.js +704 -0
- package/dist/components/popover/index.js.map +1 -0
- package/dist/components/progress-indicator/index.js +3 -3
- package/dist/components/radio-group/index.js +2 -2
- package/dist/components/search-field/index.d.ts +11 -3
- package/dist/components/search-field/index.js +66 -60
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/segmented-button/index.js +4 -4
- package/dist/components/sheet/index.js +5 -4
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.js +4 -4
- package/dist/components/switch/index.js +3 -3
- package/dist/control/checkbox-box.js +137 -0
- package/dist/control/checkbox-box.js.map +1 -0
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.js +3 -3
- package/dist/form/index.d.ts +1 -1
- package/dist/glyphs/index.js +22 -3
- package/dist/glyphs/index.js.map +1 -1
- package/dist/hooks/useAppBarScroll.d.ts +56 -0
- package/dist/hooks/useAppBarScroll.js +87 -0
- package/dist/hooks/useAppBarScroll.js.map +1 -0
- package/dist/i18n/index.js +16 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +272 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.js +12 -3
- package/dist/indicator/index.d.ts +2 -2
- package/dist/indicator/index.js +1 -1
- package/dist/indicator/motion.js +1 -1
- package/dist/mark/index.js +1 -1
- package/dist/modal/index.d.ts +1 -1
- package/dist/modal/index.js +2 -9
- package/dist/modal/index.js.map +1 -1
- package/dist/navigation/index.d.ts +29 -0
- package/dist/navigation/index.js +405 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/styles.js +61 -0
- package/dist/navigation/styles.js.map +1 -0
- package/dist/overlay/anchored.d.ts +2 -0
- package/dist/overlay/anchored.js +182 -0
- package/dist/overlay/anchored.js.map +1 -0
- package/dist/overlay/host.d.ts +2 -0
- package/dist/overlay/index.d.ts +4 -0
- package/dist/overlay/panel.js +215 -0
- package/dist/overlay/panel.js.map +1 -0
- package/dist/overlay/placement.d.ts +8 -0
- package/dist/overlay/placement.js +87 -0
- package/dist/overlay/placement.js.map +1 -0
- package/dist/press/index.js +74 -68
- package/dist/press/index.js.map +1 -1
- package/dist/ref/index.js +15 -0
- package/dist/ref/index.js.map +1 -0
- package/dist/row/index.js +158 -0
- package/dist/row/index.js.map +1 -0
- package/dist/row/styles.js +51 -0
- package/dist/row/styles.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { useTheme } from "../../theme/scope.js";
|
|
2
|
+
import { composeStyles } from "../../theme/styles.js";
|
|
3
|
+
import { usePressFeedback } from "../../press/index.js";
|
|
4
|
+
import { rowContentColor, rowStyles } from "../../row/styles.js";
|
|
5
|
+
import { RowContent, rowStyleOf } from "../../row/index.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import { Pressable, View } from "react-native";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/list-item/index.tsx
|
|
10
|
+
function InteractiveListItem(t0) {
|
|
11
|
+
const $ = c(47);
|
|
12
|
+
let children;
|
|
13
|
+
let leading;
|
|
14
|
+
let onBlur;
|
|
15
|
+
let onFocus;
|
|
16
|
+
let onHoverIn;
|
|
17
|
+
let onHoverOut;
|
|
18
|
+
let onPressIn;
|
|
19
|
+
let onPressOut;
|
|
20
|
+
let overline;
|
|
21
|
+
let props;
|
|
22
|
+
let style;
|
|
23
|
+
let supporting;
|
|
24
|
+
let t1;
|
|
25
|
+
let trailing;
|
|
26
|
+
if ($[0] !== t0) {
|
|
27
|
+
const { children: t2, interactive: _interactive, isDisabled: t3, leading: t4, onBlur: t5, onFocus: t6, onHoverIn: t7, onHoverOut: t8, onPressIn: t9, onPressOut: t10, overline: t11, style: t12, supporting: t13, trailing: t14, ...t15 } = t0;
|
|
28
|
+
children = t2;
|
|
29
|
+
t1 = t3;
|
|
30
|
+
leading = t4;
|
|
31
|
+
onBlur = t5;
|
|
32
|
+
onFocus = t6;
|
|
33
|
+
onHoverIn = t7;
|
|
34
|
+
onHoverOut = t8;
|
|
35
|
+
onPressIn = t9;
|
|
36
|
+
onPressOut = t10;
|
|
37
|
+
overline = t11;
|
|
38
|
+
style = t12;
|
|
39
|
+
supporting = t13;
|
|
40
|
+
trailing = t14;
|
|
41
|
+
props = t15;
|
|
42
|
+
$[0] = t0;
|
|
43
|
+
$[1] = children;
|
|
44
|
+
$[2] = leading;
|
|
45
|
+
$[3] = onBlur;
|
|
46
|
+
$[4] = onFocus;
|
|
47
|
+
$[5] = onHoverIn;
|
|
48
|
+
$[6] = onHoverOut;
|
|
49
|
+
$[7] = onPressIn;
|
|
50
|
+
$[8] = onPressOut;
|
|
51
|
+
$[9] = overline;
|
|
52
|
+
$[10] = props;
|
|
53
|
+
$[11] = style;
|
|
54
|
+
$[12] = supporting;
|
|
55
|
+
$[13] = t1;
|
|
56
|
+
$[14] = trailing;
|
|
57
|
+
} else {
|
|
58
|
+
children = $[1];
|
|
59
|
+
leading = $[2];
|
|
60
|
+
onBlur = $[3];
|
|
61
|
+
onFocus = $[4];
|
|
62
|
+
onHoverIn = $[5];
|
|
63
|
+
onHoverOut = $[6];
|
|
64
|
+
onPressIn = $[7];
|
|
65
|
+
onPressOut = $[8];
|
|
66
|
+
overline = $[9];
|
|
67
|
+
props = $[10];
|
|
68
|
+
style = $[11];
|
|
69
|
+
supporting = $[12];
|
|
70
|
+
t1 = $[13];
|
|
71
|
+
trailing = $[14];
|
|
72
|
+
}
|
|
73
|
+
const isDisabled = t1 === void 0 ? false : t1;
|
|
74
|
+
const theme = useTheme();
|
|
75
|
+
let t2;
|
|
76
|
+
if ($[15] !== isDisabled || $[16] !== theme) {
|
|
77
|
+
t2 = rowContentColor(theme, { isDisabled });
|
|
78
|
+
$[15] = isDisabled;
|
|
79
|
+
$[16] = theme;
|
|
80
|
+
$[17] = t2;
|
|
81
|
+
} else t2 = $[17];
|
|
82
|
+
let t3;
|
|
83
|
+
if ($[18] !== isDisabled || $[19] !== onBlur || $[20] !== onFocus || $[21] !== onHoverIn || $[22] !== onHoverOut || $[23] !== onPressIn || $[24] !== onPressOut || $[25] !== t2) {
|
|
84
|
+
t3 = {
|
|
85
|
+
color: t2,
|
|
86
|
+
disabled: isDisabled,
|
|
87
|
+
onBlur,
|
|
88
|
+
onFocus,
|
|
89
|
+
onHoverIn,
|
|
90
|
+
onHoverOut,
|
|
91
|
+
onPressIn,
|
|
92
|
+
onPressOut
|
|
93
|
+
};
|
|
94
|
+
$[18] = isDisabled;
|
|
95
|
+
$[19] = onBlur;
|
|
96
|
+
$[20] = onFocus;
|
|
97
|
+
$[21] = onHoverIn;
|
|
98
|
+
$[22] = onHoverOut;
|
|
99
|
+
$[23] = onPressIn;
|
|
100
|
+
$[24] = onPressOut;
|
|
101
|
+
$[25] = t2;
|
|
102
|
+
$[26] = t3;
|
|
103
|
+
} else t3 = $[26];
|
|
104
|
+
const feedback = usePressFeedback(t3);
|
|
105
|
+
const t4 = feedback.handlers;
|
|
106
|
+
let t5;
|
|
107
|
+
if ($[27] !== feedback.ring || $[28] !== overline || $[29] !== style || $[30] !== supporting || $[31] !== theme) {
|
|
108
|
+
t5 = composeStyles(rowStyleOf(theme, {
|
|
109
|
+
overline,
|
|
110
|
+
supporting
|
|
111
|
+
}), feedback.ring, feedback.ring === void 0 ? void 0 : rowStyles.ring, style);
|
|
112
|
+
$[27] = feedback.ring;
|
|
113
|
+
$[28] = overline;
|
|
114
|
+
$[29] = style;
|
|
115
|
+
$[30] = supporting;
|
|
116
|
+
$[31] = theme;
|
|
117
|
+
$[32] = t5;
|
|
118
|
+
} else t5 = $[32];
|
|
119
|
+
let t6;
|
|
120
|
+
if ($[33] !== children || $[34] !== isDisabled || $[35] !== leading || $[36] !== overline || $[37] !== supporting || $[38] !== trailing) {
|
|
121
|
+
t6 = /* @__PURE__ */ jsx(RowContent, {
|
|
122
|
+
isDisabled,
|
|
123
|
+
leading,
|
|
124
|
+
overline,
|
|
125
|
+
supporting,
|
|
126
|
+
trailing,
|
|
127
|
+
children
|
|
128
|
+
});
|
|
129
|
+
$[33] = children;
|
|
130
|
+
$[34] = isDisabled;
|
|
131
|
+
$[35] = leading;
|
|
132
|
+
$[36] = overline;
|
|
133
|
+
$[37] = supporting;
|
|
134
|
+
$[38] = trailing;
|
|
135
|
+
$[39] = t6;
|
|
136
|
+
} else t6 = $[39];
|
|
137
|
+
let t7;
|
|
138
|
+
if ($[40] !== feedback.handlers || $[41] !== feedback.layer || $[42] !== isDisabled || $[43] !== props || $[44] !== t5 || $[45] !== t6) {
|
|
139
|
+
t7 = /* @__PURE__ */ jsxs(Pressable, {
|
|
140
|
+
role: "button",
|
|
141
|
+
...props,
|
|
142
|
+
...t4,
|
|
143
|
+
disabled: isDisabled,
|
|
144
|
+
style: t5,
|
|
145
|
+
children: [feedback.layer, t6]
|
|
146
|
+
});
|
|
147
|
+
$[40] = feedback.handlers;
|
|
148
|
+
$[41] = feedback.layer;
|
|
149
|
+
$[42] = isDisabled;
|
|
150
|
+
$[43] = props;
|
|
151
|
+
$[44] = t5;
|
|
152
|
+
$[45] = t6;
|
|
153
|
+
$[46] = t7;
|
|
154
|
+
} else t7 = $[46];
|
|
155
|
+
return t7;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A row of a list, with a headline and up to two lines beside it, and
|
|
159
|
+
* content before and after.
|
|
160
|
+
*
|
|
161
|
+
* ```tsx
|
|
162
|
+
* <ListItem interactive leading={<Avatar name="Ada Lovelace" />} onPress={open} supporting="Supporting line">
|
|
163
|
+
* Headline
|
|
164
|
+
* </ListItem>
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* Which of the lists page's three items it is comes from what it holds: a
|
|
168
|
+
* `supporting` line or an `overline` makes it the two-line item, and both
|
|
169
|
+
* the three-line one. It is a `View` with no role unless `interactive`,
|
|
170
|
+
* when it is a `Pressable` announced as a button. The press props belong to
|
|
171
|
+
* an interactive row alone. `style`, `ref` and `testID` land on the row's
|
|
172
|
+
* own view.
|
|
173
|
+
*/
|
|
174
|
+
function ListItem(props) {
|
|
175
|
+
const $ = c(2);
|
|
176
|
+
let t0;
|
|
177
|
+
if ($[0] !== props) {
|
|
178
|
+
t0 = props.interactive === true ? /* @__PURE__ */ jsx(InteractiveListItem, { ...props }) : /* @__PURE__ */ jsx(StaticListItem, { ...props });
|
|
179
|
+
$[0] = props;
|
|
180
|
+
$[1] = t0;
|
|
181
|
+
} else t0 = $[1];
|
|
182
|
+
return t0;
|
|
183
|
+
}
|
|
184
|
+
function StaticListItem(t0) {
|
|
185
|
+
const $ = c(26);
|
|
186
|
+
let children;
|
|
187
|
+
let leading;
|
|
188
|
+
let overline;
|
|
189
|
+
let props;
|
|
190
|
+
let style;
|
|
191
|
+
let supporting;
|
|
192
|
+
let t1;
|
|
193
|
+
let trailing;
|
|
194
|
+
if ($[0] !== t0) {
|
|
195
|
+
const { children: t2, interactive: _interactive, isDisabled: t3, leading: t4, overline: t5, style: t6, supporting: t7, trailing: t8, ...t9 } = t0;
|
|
196
|
+
children = t2;
|
|
197
|
+
t1 = t3;
|
|
198
|
+
leading = t4;
|
|
199
|
+
overline = t5;
|
|
200
|
+
style = t6;
|
|
201
|
+
supporting = t7;
|
|
202
|
+
trailing = t8;
|
|
203
|
+
props = t9;
|
|
204
|
+
$[0] = t0;
|
|
205
|
+
$[1] = children;
|
|
206
|
+
$[2] = leading;
|
|
207
|
+
$[3] = overline;
|
|
208
|
+
$[4] = props;
|
|
209
|
+
$[5] = style;
|
|
210
|
+
$[6] = supporting;
|
|
211
|
+
$[7] = t1;
|
|
212
|
+
$[8] = trailing;
|
|
213
|
+
} else {
|
|
214
|
+
children = $[1];
|
|
215
|
+
leading = $[2];
|
|
216
|
+
overline = $[3];
|
|
217
|
+
props = $[4];
|
|
218
|
+
style = $[5];
|
|
219
|
+
supporting = $[6];
|
|
220
|
+
t1 = $[7];
|
|
221
|
+
trailing = $[8];
|
|
222
|
+
}
|
|
223
|
+
const isDisabled = t1 === void 0 ? false : t1;
|
|
224
|
+
const theme = useTheme();
|
|
225
|
+
const t2 = isDisabled || void 0;
|
|
226
|
+
let t3;
|
|
227
|
+
if ($[9] !== overline || $[10] !== style || $[11] !== supporting || $[12] !== theme) {
|
|
228
|
+
t3 = composeStyles(rowStyleOf(theme, {
|
|
229
|
+
overline,
|
|
230
|
+
supporting
|
|
231
|
+
}), style);
|
|
232
|
+
$[9] = overline;
|
|
233
|
+
$[10] = style;
|
|
234
|
+
$[11] = supporting;
|
|
235
|
+
$[12] = theme;
|
|
236
|
+
$[13] = t3;
|
|
237
|
+
} else t3 = $[13];
|
|
238
|
+
let t4;
|
|
239
|
+
if ($[14] !== children || $[15] !== isDisabled || $[16] !== leading || $[17] !== overline || $[18] !== supporting || $[19] !== trailing) {
|
|
240
|
+
t4 = /* @__PURE__ */ jsx(RowContent, {
|
|
241
|
+
isDisabled,
|
|
242
|
+
leading,
|
|
243
|
+
overline,
|
|
244
|
+
supporting,
|
|
245
|
+
trailing,
|
|
246
|
+
children
|
|
247
|
+
});
|
|
248
|
+
$[14] = children;
|
|
249
|
+
$[15] = isDisabled;
|
|
250
|
+
$[16] = leading;
|
|
251
|
+
$[17] = overline;
|
|
252
|
+
$[18] = supporting;
|
|
253
|
+
$[19] = trailing;
|
|
254
|
+
$[20] = t4;
|
|
255
|
+
} else t4 = $[20];
|
|
256
|
+
let t5;
|
|
257
|
+
if ($[21] !== props || $[22] !== t2 || $[23] !== t3 || $[24] !== t4) {
|
|
258
|
+
t5 = /* @__PURE__ */ jsx(View, {
|
|
259
|
+
"aria-disabled": t2,
|
|
260
|
+
...props,
|
|
261
|
+
style: t3,
|
|
262
|
+
children: t4
|
|
263
|
+
});
|
|
264
|
+
$[21] = props;
|
|
265
|
+
$[22] = t2;
|
|
266
|
+
$[23] = t3;
|
|
267
|
+
$[24] = t4;
|
|
268
|
+
$[25] = t5;
|
|
269
|
+
} else t5 = $[25];
|
|
270
|
+
return t5;
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
export { ListItem };
|
|
274
|
+
|
|
275
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","PressableProps","StyleProp","ViewProps","ViewStyle","Pressable","View","usePressFeedback","RowContent","rowContentColor","rowStyleOf","rowStyles","useTheme","composeStyles","InteractiveListItemForm","Omit","interactive","ListItemBaseProps","children","isDisabled","leading","overline","ref","style","supporting","trailing","ListItemProps","StaticListItemForm","onPress","InteractiveListItem","t0","$","_c","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","props","t1","t2","_interactive","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13","t14","t15","undefined","theme","color","disabled","feedback","handlers","ring","layer","ListItem","StaticListItem","_c"],"sources":["../../../src/components/list-item/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Pressable, View } from 'react-native'\n\nimport { usePressFeedback } from '../../press'\nimport { RowContent, rowContentColor, rowStyleOf, rowStyles } from '../../row'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\n\n// kanso-ui's ListItem, from the lists page: the one-line item's 56dp\n// container with a body-large headline, the two-line item's 72dp with a\n// body-medium supporting line, and the three-line item's 88dp, where an\n// overline joins them and the slots are held at the top rather than\n// centred. The heights are minimums, so a larger OS text size grows the\n// row. The layout is src/row's, shared with every menu item; what is here\n// is the view around it, a `View` that presents or a `Pressable` that\n// ripples, and the props that fill the slots. Both slots lie along the\n// writing direction, so they swap sides under right-to-left.\n\ntype InteractiveListItemForm = Omit<\n PressableProps,\n 'children' | 'disabled' | 'style'\n> & {\n /**\n * Makes the row the thing you press: a `Pressable` announced as a button,\n * with the state layers, the ripple and the focus ring. Leave it off for a\n * row that only presents.\n */\n readonly interactive: true\n}\n\ntype ListItemBaseProps = {\n /** The row's headline, the one thing it is mostly about. */\n readonly children?: ReactNode\n /**\n * Draws the row disabled: its headline, slots and lines fade to on surface\n * at the disabled content opacity. An interactive row takes no press and\n * is announced as disabled; a row that only presents has nothing to\n * disable, and says it is disabled so the state it draws is announced too.\n * @default false\n */\n readonly isDisabled?: boolean\n /** Content before the headline: an avatar, an icon, a checkbox. */\n readonly leading?: ReactNode\n /**\n * A line above the headline, in label small and the muted role. Given\n * beside `supporting`, it makes the row the three-line item.\n */\n readonly overline?: ReactNode\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n /** A second line under the headline, in body medium and the muted role. */\n readonly supporting?: ReactNode\n /** Content after the headline, such as an amount or a control. */\n readonly trailing?: ReactNode\n}\n\ntype ListItemProps = (InteractiveListItemForm | StaticListItemForm) &\n ListItemBaseProps\n\n/** A row that presents and takes no press: a `View` with no role. */\ntype StaticListItemForm = Omit<ViewProps, 'children' | 'style'> & {\n readonly interactive?: false\n readonly onPress?: never\n}\n\nfunction InteractiveListItem({\n children,\n interactive: _interactive,\n isDisabled = false,\n leading,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n overline,\n style,\n supporting,\n trailing,\n ...props\n}: InteractiveListItemForm & ListItemBaseProps) {\n const theme = useTheme()\n const feedback = usePressFeedback({\n color: rowContentColor(theme, { isDisabled }),\n disabled: isDisabled,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n\n return (\n <Pressable\n role=\"button\"\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n style={composeStyles<ViewStyle>(\n rowStyleOf(theme, { overline, supporting }),\n feedback.ring,\n feedback.ring === undefined ? undefined : rowStyles.ring,\n style,\n )}\n >\n {feedback.layer}\n <RowContent\n isDisabled={isDisabled}\n leading={leading}\n overline={overline}\n supporting={supporting}\n trailing={trailing}\n >\n {children}\n </RowContent>\n </Pressable>\n )\n}\n\n/**\n * A row of a list, with a headline and up to two lines beside it, and\n * content before and after.\n *\n * ```tsx\n * <ListItem interactive leading={<Avatar name=\"Ada Lovelace\" />} onPress={open} supporting=\"Supporting line\">\n * Headline\n * </ListItem>\n * ```\n *\n * Which of the lists page's three items it is comes from what it holds: a\n * `supporting` line or an `overline` makes it the two-line item, and both\n * the three-line one. It is a `View` with no role unless `interactive`,\n * when it is a `Pressable` announced as a button. The press props belong to\n * an interactive row alone. `style`, `ref` and `testID` land on the row's\n * own view.\n */\nfunction ListItem(props: ListItemProps) {\n return props.interactive === true ? (\n <InteractiveListItem {...props} />\n ) : (\n <StaticListItem {...props} />\n )\n}\n\nfunction StaticListItem({\n children,\n interactive: _interactive,\n isDisabled = false,\n leading,\n overline,\n style,\n supporting,\n trailing,\n ...props\n}: ListItemBaseProps & StaticListItemForm) {\n const theme = useTheme()\n\n return (\n <View\n aria-disabled={isDisabled || undefined}\n {...props}\n style={composeStyles<ViewStyle>(\n rowStyleOf(theme, { overline, supporting }),\n style,\n )}\n >\n <RowContent\n isDisabled={isDisabled}\n leading={leading}\n overline={overline}\n supporting={supporting}\n trailing={trailing}\n >\n {children}\n </RowContent>\n </View>\n )\n}\n\nexport type { ListItemProps }\n\nexport { ListItem }\n"],"mappings":";;;;;;;;;AAwEA,SAAA+B,oBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAd;CAAA,IAAAE;CAAA,IAAAa;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAjB;CAAA,IAAAkB;CAAA,IAAAhB;CAAA,IAAAC;CAAA,IAAAgB;CAAA,IAAAf;CAAA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AU,EAAA,MAAAR;EAAAQ,EAAA,MAAAP;EAAAO,EAAA,MAAA0B;EAAA1B,EAAA,MAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAb,YAAAa,EAAA,QAAAZ,cAAAY,EAAA,QAAAX,WAAAW,EAAA,QAAAV,YAAAU,EAAA,QAAAP,cAAAO,EAAA,QAAAN,UAAA;EAEDmB,KAAA,oBAAC,YAAD;GACczB;GACHC;GACCC;GACEG;GACFC;GAETP;EAPQ,CAAA;EAQEa,EAAA,MAAAb;EAAAa,EAAA,MAAAZ;EAAAY,EAAA,MAAAX;EAAAW,EAAA,MAAAV;EAAAU,EAAA,MAAAP;EAAAO,EAAA,MAAAN;EAAAM,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,IAAAc;CAAA,IAAAd,EAAA,QAAAQ,SAAAR,EAAA,QAAAU,MAAAV,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,IAAA;EAhBfC,KAAA,oBAAC,MAAD;GACiB,iBAAAJ;GAAuB,GAClCF;GACG,OAAAI;GAKPC,UAAAA;EARG,CAAA;EAiBEb,EAAA,MAAAQ;EAAAR,EAAA,MAAAU;EAAAV,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OAjBPc;AAiBO"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { OverlayAlign, OverlaySide } from "../../overlay/placement.js";
|
|
2
|
+
import "../../overlay/index.js";
|
|
3
|
+
import { HostInstance, PressableProps, StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
4
|
+
import { ReactElement, ReactNode, Ref } from "react";
|
|
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
|