@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.
Files changed (109) hide show
  1. package/README.md +4 -1
  2. package/dist/autocomplete/index.js +39 -0
  3. package/dist/autocomplete/index.js.map +1 -0
  4. package/dist/badge/index.js +74 -0
  5. package/dist/badge/index.js.map +1 -0
  6. package/dist/badge/styles.js +51 -0
  7. package/dist/badge/styles.js.map +1 -0
  8. package/dist/button/index.d.ts +2 -1
  9. package/dist/button/index.js +35 -2
  10. package/dist/button/index.js.map +1 -1
  11. package/dist/button/slots.d.ts +2 -1
  12. package/dist/button/slots.js.map +1 -1
  13. package/dist/chip/index.js +2 -2
  14. package/dist/components/app-bar/index.d.ts +111 -0
  15. package/dist/components/app-bar/index.js +341 -0
  16. package/dist/components/app-bar/index.js.map +1 -0
  17. package/dist/components/autocomplete/index.d.ts +49 -0
  18. package/dist/components/autocomplete/index.js +87 -0
  19. package/dist/components/autocomplete/index.js.map +1 -0
  20. package/dist/components/button/index.d.ts +1 -1
  21. package/dist/components/button/index.js +197 -151
  22. package/dist/components/button/index.js.map +1 -1
  23. package/dist/components/card/index.js +2 -2
  24. package/dist/components/checkbox/index.js +106 -193
  25. package/dist/components/checkbox/index.js.map +1 -1
  26. package/dist/components/chip/index.js +1 -1
  27. package/dist/components/chip-group/index.js +3 -3
  28. package/dist/components/dialog/index.js +4 -3
  29. package/dist/components/dialog/index.js.map +1 -1
  30. package/dist/components/icon-button/index.d.ts +1 -1
  31. package/dist/components/icon-button/index.js +206 -160
  32. package/dist/components/icon-button/index.js.map +1 -1
  33. package/dist/components/link/index.js +2 -2
  34. package/dist/components/list/index.d.ts +216 -0
  35. package/dist/components/list/index.js +1118 -0
  36. package/dist/components/list/index.js.map +1 -0
  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 +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/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.js +3 -3
  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/progress-indicator/index.js +3 -3
  54. package/dist/components/radio-group/index.js +2 -2
  55. package/dist/components/search-field/index.d.ts +11 -3
  56. package/dist/components/search-field/index.js +66 -60
  57. package/dist/components/search-field/index.js.map +1 -1
  58. package/dist/components/segmented-button/index.js +4 -4
  59. package/dist/components/sheet/index.js +5 -4
  60. package/dist/components/sheet/index.js.map +1 -1
  61. package/dist/components/snackbar/index.js +4 -4
  62. package/dist/components/switch/index.js +3 -3
  63. package/dist/control/checkbox-box.js +137 -0
  64. package/dist/control/checkbox-box.js.map +1 -0
  65. package/dist/field/index.d.ts +1 -1
  66. package/dist/field/index.js +3 -3
  67. package/dist/form/index.d.ts +1 -1
  68. package/dist/glyphs/index.js +22 -3
  69. package/dist/glyphs/index.js.map +1 -1
  70. package/dist/hooks/useAppBarScroll.d.ts +56 -0
  71. package/dist/hooks/useAppBarScroll.js +87 -0
  72. package/dist/hooks/useAppBarScroll.js.map +1 -0
  73. package/dist/i18n/index.js +16 -1
  74. package/dist/i18n/index.js.map +1 -1
  75. package/dist/i18n/messages.js +272 -34
  76. package/dist/i18n/messages.js.map +1 -1
  77. package/dist/index.d.ts +12 -3
  78. package/dist/index.js +12 -3
  79. package/dist/indicator/index.d.ts +2 -2
  80. package/dist/indicator/index.js +1 -1
  81. package/dist/indicator/motion.js +1 -1
  82. package/dist/mark/index.js +1 -1
  83. package/dist/modal/index.d.ts +1 -1
  84. package/dist/modal/index.js +2 -9
  85. package/dist/modal/index.js.map +1 -1
  86. package/dist/navigation/index.d.ts +29 -0
  87. package/dist/navigation/index.js +405 -0
  88. package/dist/navigation/index.js.map +1 -0
  89. package/dist/navigation/styles.js +61 -0
  90. package/dist/navigation/styles.js.map +1 -0
  91. package/dist/overlay/anchored.d.ts +2 -0
  92. package/dist/overlay/anchored.js +182 -0
  93. package/dist/overlay/anchored.js.map +1 -0
  94. package/dist/overlay/host.d.ts +2 -0
  95. package/dist/overlay/index.d.ts +4 -0
  96. package/dist/overlay/panel.js +215 -0
  97. package/dist/overlay/panel.js.map +1 -0
  98. package/dist/overlay/placement.d.ts +8 -0
  99. package/dist/overlay/placement.js +87 -0
  100. package/dist/overlay/placement.js.map +1 -0
  101. package/dist/press/index.js +74 -68
  102. package/dist/press/index.js.map +1 -1
  103. package/dist/ref/index.js +15 -0
  104. package/dist/ref/index.js.map +1 -0
  105. package/dist/row/index.js +158 -0
  106. package/dist/row/index.js.map +1 -0
  107. package/dist/row/styles.js +51 -0
  108. package/dist/row/styles.js.map +1 -0
  109. package/package.json +3 -3
@@ -0,0 +1,341 @@
1
+ import { IconStyleContext } from "../../glyphs/icon-style.js";
2
+ import { useTheme } from "../../theme/scope.js";
3
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
4
+ import { hasContent } from "../../row/index.js";
5
+ import { Text as Text$1 } from "../text/index.js";
6
+ import { c } from "react/compiler-runtime";
7
+ import { StyleSheet, View } from "react-native";
8
+ import Animated, { Easing, useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
9
+ import { SafeAreaView } from "react-native-safe-area-context";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ //#region src/components/app-bar/index.tsx
12
+ const ICON_SIZE = 24;
13
+ const GLYPH_INSET = 12;
14
+ const HEIGHTS = {
15
+ lg: {
16
+ plain: 120,
17
+ withSubtitle: 152
18
+ },
19
+ md: {
20
+ plain: 112,
21
+ withSubtitle: 136
22
+ },
23
+ sm: {
24
+ plain: 64,
25
+ withSubtitle: 64
26
+ }
27
+ };
28
+ const HEADLINE_ROLES = {
29
+ lg: "headlineMedium",
30
+ md: "headlineSmall",
31
+ sm: "titleLarge"
32
+ };
33
+ const EDGES = [
34
+ "left",
35
+ "right",
36
+ "top"
37
+ ];
38
+ const styles = StyleSheet.create({
39
+ center: { textAlign: "center" },
40
+ pinned: { zIndex: 1 },
41
+ row: {
42
+ alignItems: "center",
43
+ flexDirection: "row",
44
+ width: "100%"
45
+ },
46
+ safeArea: { alignItems: "center" }
47
+ });
48
+ const stylesOf = themedStyles(({ sizing, spacing }) => StyleSheet.create({
49
+ row: { gap: spacing.xs },
50
+ slot: {
51
+ alignItems: "center",
52
+ flexDirection: "row",
53
+ flexShrink: 0,
54
+ gap: 48 - sizing.controlSm,
55
+ paddingHorizontal: (48 - sizing.controlSm) / 2
56
+ },
57
+ text: {
58
+ flexGrow: 1,
59
+ flexShrink: 1,
60
+ justifyContent: "center",
61
+ minWidth: 0,
62
+ paddingVertical: spacing.sm
63
+ }
64
+ }));
65
+ /**
66
+ * Material Design's top app bar: the bar at the top of a screen carrying its
67
+ * title, one or two actions, and the way back out.
68
+ *
69
+ * ```tsx
70
+ * <AppBar
71
+ * headline="Headline"
72
+ * leading={<IconButton aria-label="Back"><ArrowBackGlyph /></IconButton>}
73
+ * />
74
+ * ```
75
+ *
76
+ * Three sizes. `sm` is a 64dp bar for a screen whose title is a label; `md`
77
+ * and `lg` are the flexible bars, which give the headline a larger type role
78
+ * and grow to fit a subtitle or a headline that wraps.
79
+ *
80
+ * It paints its own surface, from the screen's top edge, and keeps its
81
+ * contents clear of the status bar and the notch. Separating itself from the
82
+ * content beneath is its job, which is why `scrolled` and `collapsed` exist;
83
+ * `useAppBarScroll` sets both from the screen's scroll view.
84
+ */
85
+ function AppBar(t0) {
86
+ const $ = c(58);
87
+ let contentInset;
88
+ let contentMaxInlineSize;
89
+ let headline;
90
+ let leading;
91
+ let props;
92
+ let style;
93
+ let subtitle;
94
+ let t1;
95
+ let t2;
96
+ let t3;
97
+ let t4;
98
+ let t5;
99
+ let trailing;
100
+ if ($[0] !== t0) {
101
+ ({align: t1, collapsed: t2, contentInset, contentMaxInlineSize, headline, leading, pinned: t3, scrolled: t4, size: t5, style, subtitle, trailing, ...props} = t0);
102
+ $[0] = t0;
103
+ $[1] = contentInset;
104
+ $[2] = contentMaxInlineSize;
105
+ $[3] = headline;
106
+ $[4] = leading;
107
+ $[5] = props;
108
+ $[6] = style;
109
+ $[7] = subtitle;
110
+ $[8] = t1;
111
+ $[9] = t2;
112
+ $[10] = t3;
113
+ $[11] = t4;
114
+ $[12] = t5;
115
+ $[13] = trailing;
116
+ } else {
117
+ contentInset = $[1];
118
+ contentMaxInlineSize = $[2];
119
+ headline = $[3];
120
+ leading = $[4];
121
+ props = $[5];
122
+ style = $[6];
123
+ subtitle = $[7];
124
+ t1 = $[8];
125
+ t2 = $[9];
126
+ t3 = $[10];
127
+ t4 = $[11];
128
+ t5 = $[12];
129
+ trailing = $[13];
130
+ }
131
+ const align = t1 === void 0 ? "start" : t1;
132
+ const collapsed = t2 === void 0 ? false : t2;
133
+ const pinned = t3 === void 0 ? false : t3;
134
+ const scrolled = t4 === void 0 ? false : t4;
135
+ const size = t5 === void 0 ? "sm" : t5;
136
+ const theme = useTheme();
137
+ const own = stylesOf(theme);
138
+ const inset = contentInset ?? theme.spacing.lg;
139
+ const collapse = collapsed && size !== "sm";
140
+ const hasLeading = hasContent(leading);
141
+ const hasTrailing = hasContent(trailing);
142
+ let t6;
143
+ if ($[14] !== collapse || $[15] !== subtitle) {
144
+ t6 = hasContent(subtitle) && !collapse;
145
+ $[14] = collapse;
146
+ $[15] = subtitle;
147
+ $[16] = t6;
148
+ } else t6 = $[16];
149
+ const showsSubtitle = t6;
150
+ const heights = HEIGHTS[collapse ? "sm" : size];
151
+ const fill = useFill(scrolled);
152
+ const t7 = Animated;
153
+ const t8 = pinned ? styles.pinned : null;
154
+ let t9;
155
+ if ($[17] !== fill || $[18] !== style || $[19] !== t8) {
156
+ t9 = composeStyles(fill, t8, style);
157
+ $[17] = fill;
158
+ $[18] = style;
159
+ $[19] = t8;
160
+ $[20] = t9;
161
+ } else t9 = $[20];
162
+ const T0 = SafeAreaView;
163
+ const t10 = EDGES;
164
+ const t11 = styles;
165
+ const T1 = View;
166
+ const t12 = composeStyles(styles.row, own.row, {
167
+ maxWidth: contentMaxInlineSize,
168
+ minHeight: showsSubtitle ? heights.withSubtitle : heights.plain,
169
+ paddingEnd: edgePadding(inset, hasTrailing),
170
+ paddingStart: edgePadding(inset, hasLeading)
171
+ });
172
+ let t13;
173
+ if ($[21] !== hasLeading || $[22] !== leading || $[23] !== theme) {
174
+ t13 = hasLeading ? /* @__PURE__ */ jsx(Slot, {
175
+ color: theme.colors.onSurface,
176
+ children: leading
177
+ }) : null;
178
+ $[21] = hasLeading;
179
+ $[22] = leading;
180
+ $[23] = theme;
181
+ $[24] = t13;
182
+ } else t13 = $[24];
183
+ let t14;
184
+ if ($[25] !== align || $[26] !== collapse || $[27] !== headline || $[28] !== size) {
185
+ t14 = hasContent(headline) ? /* @__PURE__ */ jsx(Text$1, {
186
+ role: "heading",
187
+ style: align === "center" ? styles.center : void 0,
188
+ variant: HEADLINE_ROLES[collapse ? "sm" : size],
189
+ children: headline
190
+ }) : null;
191
+ $[25] = align;
192
+ $[26] = collapse;
193
+ $[27] = headline;
194
+ $[28] = size;
195
+ $[29] = t14;
196
+ } else t14 = $[29];
197
+ let t15;
198
+ if ($[30] !== align || $[31] !== showsSubtitle || $[32] !== subtitle) {
199
+ t15 = showsSubtitle ? /* @__PURE__ */ jsx(Text$1, {
200
+ style: align === "center" ? styles.center : void 0,
201
+ tone: "muted",
202
+ variant: "bodyMedium",
203
+ children: subtitle
204
+ }) : null;
205
+ $[30] = align;
206
+ $[31] = showsSubtitle;
207
+ $[32] = subtitle;
208
+ $[33] = t15;
209
+ } else t15 = $[33];
210
+ let t16;
211
+ if ($[34] !== own.text || $[35] !== t14 || $[36] !== t15) {
212
+ t16 = /* @__PURE__ */ jsxs(View, {
213
+ style: own.text,
214
+ children: [t14, t15]
215
+ });
216
+ $[34] = own.text;
217
+ $[35] = t14;
218
+ $[36] = t15;
219
+ $[37] = t16;
220
+ } else t16 = $[37];
221
+ let t17;
222
+ if ($[38] !== hasTrailing || $[39] !== theme || $[40] !== trailing) {
223
+ t17 = hasTrailing ? /* @__PURE__ */ jsx(Slot, {
224
+ color: theme.colors.onSurfaceVariant,
225
+ children: trailing
226
+ }) : null;
227
+ $[38] = hasTrailing;
228
+ $[39] = theme;
229
+ $[40] = trailing;
230
+ $[41] = t17;
231
+ } else t17 = $[41];
232
+ let t18;
233
+ if ($[42] !== T1 || $[43] !== t12 || $[44] !== t13 || $[45] !== t16 || $[46] !== t17) {
234
+ t18 = /* @__PURE__ */ jsxs(T1, {
235
+ style: t12,
236
+ children: [
237
+ t13,
238
+ t16,
239
+ t17
240
+ ]
241
+ });
242
+ $[42] = T1;
243
+ $[43] = t12;
244
+ $[44] = t13;
245
+ $[45] = t16;
246
+ $[46] = t17;
247
+ $[47] = t18;
248
+ } else t18 = $[47];
249
+ let t19;
250
+ if ($[48] !== T0 || $[49] !== t10 || $[50] !== t11.safeArea || $[51] !== t18) {
251
+ t19 = /* @__PURE__ */ jsx(T0, {
252
+ edges: t10,
253
+ style: t11.safeArea,
254
+ children: t18
255
+ });
256
+ $[48] = T0;
257
+ $[49] = t10;
258
+ $[50] = t11.safeArea;
259
+ $[51] = t18;
260
+ $[52] = t19;
261
+ } else t19 = $[52];
262
+ let t20;
263
+ if ($[53] !== props || $[54] !== t19 || $[55] !== t7.View || $[56] !== t9) {
264
+ t20 = /* @__PURE__ */ jsx(t7.View, {
265
+ ...props,
266
+ style: t9,
267
+ children: t19
268
+ });
269
+ $[53] = props;
270
+ $[54] = t19;
271
+ $[55] = t7.View;
272
+ $[56] = t9;
273
+ $[57] = t20;
274
+ } else t20 = $[57];
275
+ return t20;
276
+ }
277
+ function edgePadding(inset, hasSlot) {
278
+ return hasSlot ? Math.max(0, inset - GLYPH_INSET) : inset;
279
+ }
280
+ function iconStyleOf(color) {
281
+ return {
282
+ color,
283
+ size: ICON_SIZE
284
+ };
285
+ }
286
+ function Slot(t0) {
287
+ const $ = c(10);
288
+ const { children, color } = t0;
289
+ const t1 = useTheme();
290
+ let t2;
291
+ if ($[0] !== t1) {
292
+ t2 = stylesOf(t1);
293
+ $[0] = t1;
294
+ $[1] = t2;
295
+ } else t2 = $[1];
296
+ const own = t2;
297
+ let t3;
298
+ if ($[2] !== color) {
299
+ t3 = iconStyleOf(color);
300
+ $[2] = color;
301
+ $[3] = t3;
302
+ } else t3 = $[3];
303
+ let t4;
304
+ if ($[4] !== children || $[5] !== own.slot) {
305
+ t4 = /* @__PURE__ */ jsx(View, {
306
+ style: own.slot,
307
+ children
308
+ });
309
+ $[4] = children;
310
+ $[5] = own.slot;
311
+ $[6] = t4;
312
+ } else t4 = $[6];
313
+ let t5;
314
+ if ($[7] !== t3 || $[8] !== t4) {
315
+ t5 = /* @__PURE__ */ jsx(IconStyleContext, {
316
+ value: t3,
317
+ children: t4
318
+ });
319
+ $[7] = t3;
320
+ $[8] = t4;
321
+ $[9] = t5;
322
+ } else t5 = $[9];
323
+ return t5;
324
+ }
325
+ function useFill(scrolled) {
326
+ const { colors, motion } = useTheme();
327
+ const reduceMotion = useReducedMotion();
328
+ const fill = scrolled ? colors.surfaceContainer : colors.surface;
329
+ const timing = {
330
+ duration: motion.durationMedium1,
331
+ easing: Easing.bezier(...motion.easingEmphasized)
332
+ };
333
+ return useAnimatedStyle(() => {
334
+ "worklet";
335
+ return { backgroundColor: reduceMotion ? fill : withTiming(fill, timing) };
336
+ });
337
+ }
338
+ //#endregion
339
+ export { AppBar };
340
+
341
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","ColorValue","ViewProps","ViewStyle","AnimatedStyle","Edge","StyleSheet","View","Animated","Easing","useAnimatedStyle","useReducedMotion","withTiming","SafeAreaView","IconStyle","TypeRole","IconStyleContext","COLLAPSED_BLOCK_SIZE","TARGET_SIZE","hasContent","useTheme","composeStyles","themedStyles","Text","ICON_SIZE","GLYPH_INSET","HEIGHTS","lg","plain","withSubtitle","md","sm","const","HEADLINE_ROLES","Readonly","Record","AppBarSize","EDGES","styles","create","center","textAlign","pinned","zIndex","row","alignItems","flexDirection","width","safeArea","stylesOf","sizing","spacing","gap","xs","slot","flexShrink","controlSm","paddingHorizontal","text","flexGrow","justifyContent","minWidth","paddingVertical","AppBarProps","Omit","align","collapsed","contentInset","contentMaxInlineSize","headline","leading","ref","scrolled","size","subtitle","trailing","SlotProps","children","color","AppBar","t0","$","_c","props","style","t1","t2","t3","t4","t5","undefined","theme","own","inset","collapse","hasLeading","hasTrailing","t6","showsSubtitle","heights","fill","useFill","t7","t8","t9","T0","T1","t12","maxWidth","minHeight","paddingEnd","edgePadding","paddingStart","t13","colors","onSurface","t14","t15","t16","t17","onSurfaceVariant","t18","t19","t10","t11","t20","hasSlot","Math","max","iconStyleOf","Slot","motion","reduceMotion","surfaceContainer","surface","timing","duration","durationMedium1","easing","bezier","easingEmphasized","backgroundColor","_c","Text"],"sources":["../../../src/components/app-bar/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type { ColorValue, ViewProps, ViewStyle } from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\nimport type { Edge } from 'react-native-safe-area-context'\n\nimport { StyleSheet, View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n withTiming,\n} from 'react-native-reanimated'\nimport { SafeAreaView } from 'react-native-safe-area-context'\n\nimport type { IconStyle } from '../../glyphs/icon-style'\nimport type { TypeRole } from '../../typography/roles'\n\nimport { IconStyleContext } from '../../glyphs/icon-style'\nimport { COLLAPSED_BLOCK_SIZE } from '../../hooks/useAppBarScroll'\nimport { TARGET_SIZE } from '../../press'\nimport { hasContent } from '../../row'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { Text } from '../text'\n\n// kanso-ui's AppBar, Material Design's top app bar in the three sizes the spec\n// recommends. `md` and `lg` are its medium and large *flexible* bars, the\n// newer of the two sets the spec gives and the one it recommends. The old\n// center-aligned variant is a configuration of every size, which is why\n// alignment is a prop.\n//\n// Heights are minimums rather than fixed. The flexible bars hug their text,\n// so a headline that wraps, or a larger text size the device asks for, makes\n// the bar taller rather than being cut off.\n//\n// The bar paints its surface from the screen's top edge, under the status\n// bar, and keeps its contents inside the safe area: a `SafeAreaView` pads it\n// by the status bar, the notch and a rounded corner wherever the bar meets\n// them, and by nothing where it does not, so a bar drawn below another view\n// takes no inset of its own.\n//\n// Three things differ from web's, each because of the platform.\n//\n// - **No heading level.** Native screen readers have no levels to move\n// between, so the headline is a header and `headingLevel` is gone.\n// - **`pinned` means outside the scroll view.** Native has no sticky\n// position, so a pinned bar is one the screen draws above its scroll view\n// rather than inside it, and the content scrolls beneath its lower edge.\n// - **The fill eases and the height does not.** Collapsing moves the height\n// and the headline's type role at once. React Native has no transition for\n// a type role, and easing the height alone would leave the text jumping\n// inside a moving bar. The fill a scrolled bar takes eases over medium 1\n// on the emphasized curve, as web's does, and arrives at once under\n// reduced motion.\n\n// The geometry Material Design lays a bar's icon buttons out on: a 48dp\n// target per button, edge to edge, with a 24dp icon centred in each, and the\n// outermost target 4dp in from the bar's edge, so a glyph lands at the\n// page's margin. IconButton draws a 40dp box with its 48dp target spilling\n// out through `hitSlop`, so a slot pads half the difference either side and\n// puts the whole of it between two buttons, which lays the targets edge to\n// edge as the spec does.\nconst ICON_SIZE = 24\n\n// How far an icon sits inside its target, which is how much less than the\n// content inset the row is padded on an edge that holds a slot. That puts a\n// leading glyph, rather than the edge of its target, at the inset.\nconst GLYPH_INSET = (TARGET_SIZE - ICON_SIZE) / 2\n\nconst HEIGHTS = {\n lg: { plain: 120, withSubtitle: 152 },\n md: { plain: 112, withSubtitle: 136 },\n sm: { plain: COLLAPSED_BLOCK_SIZE, withSubtitle: COLLAPSED_BLOCK_SIZE },\n} as const\n\n// One type role per size, as Material Design's own title tokens alias the\n// type scale rather than giving sizes of their own. A collapsed bar takes the\n// small one's.\nconst HEADLINE_ROLES: Readonly<Record<AppBarSize, TypeRole>> = {\n lg: 'headlineMedium',\n md: 'headlineSmall',\n sm: 'titleLarge',\n}\n\n// The bar's sides as well as its top, so a landscape notch is cleared too.\n// The bottom is the content's.\nconst EDGES: readonly Edge[] = ['left', 'right', 'top']\n\nconst styles = StyleSheet.create({\n center: {\n textAlign: 'center',\n },\n // Drawn over what follows it, so whatever strays past the scroll view's\n // top edge, an overscroll or a shadow, passes beneath the bar.\n pinned: {\n zIndex: 1,\n },\n row: {\n alignItems: 'center',\n flexDirection: 'row',\n width: '100%',\n },\n // The row, centred once it reaches `contentMaxInlineSize`.\n safeArea: {\n alignItems: 'center',\n },\n})\n\nconst stylesOf = themedStyles(({ sizing, spacing }) =>\n StyleSheet.create({\n row: {\n gap: spacing.xs,\n },\n // Slots hold their own size rather than being squeezed by a long\n // headline, and space their icon buttons by the spec's targets.\n slot: {\n alignItems: 'center',\n flexDirection: 'row',\n flexShrink: 0,\n gap: TARGET_SIZE - sizing.controlSm,\n paddingHorizontal: (TARGET_SIZE - sizing.controlSm) / 2,\n },\n // The text takes the room the slots leave, and wraps inside it.\n text: {\n flexGrow: 1,\n flexShrink: 1,\n justifyContent: 'center',\n minWidth: 0,\n paddingVertical: spacing.sm,\n },\n }),\n)\n\ntype AppBarProps = Omit<ViewProps, 'children'> & {\n /**\n * Which of Material Design's alignments the text takes. `center` is the\n * configuration that replaced the old center-aligned variant.\n * @default 'start'\n */\n readonly align?: 'center' | 'start'\n /**\n * Collapses a flexible bar to the height and headline of the small one,\n * for a `pinned` bar over content that has been scrolled. Without it a\n * pinned `lg` keeps 152dp of the screen for as long as the screen is open.\n *\n * Controlled, as `scrolled` is: only the app knows which view scrolls and\n * how far into it the bar should have collapsed. `useAppBarScroll` derives\n * both from that view's scroll, and is the way to set them unless the app\n * needs a rule of its own. Ignored on `sm`, which is already the height\n * this collapses to, and the subtitle goes with the height.\n * @default false\n */\n readonly collapsed?: boolean\n /**\n * Where the bar's content starts on each edge, in dp: the headline where\n * nothing comes before it, and the leading icon's glyph where something\n * does. The trailing edge is the same mirrored. `0` draws a bar flush.\n *\n * The default is Material Design's margin for a top app bar, the spacing\n * scale's `lg` step, which is also the margin it gives body content, so a\n * bar and the screen beneath line up without either being told about the\n * other.\n * @default spacing.lg\n */\n readonly contentInset?: number\n /**\n * How wide the bar's contents may run, in dp, before they stop growing,\n * with the row centred in what is left. The bar's surface still paints\n * edge to edge. Unset, the row is as wide as the bar.\n */\n readonly contentMaxInlineSize?: number\n /**\n * The screen's title, a header for a screen reader. Wraps rather than\n * truncating, and grows the bar with it.\n */\n readonly headline?: ReactNode\n /**\n * Usually a back or menu icon button. Sits before the text, and hands an\n * icon the on-surface colour and a 24dp size through `useIconStyle()`.\n */\n readonly leading?: ReactNode\n /**\n * Marks a bar drawn above the screen's scroll view rather than inside it,\n * so it stays put while the content scrolls beneath its lower edge, and is\n * drawn over that content. A pinned bar is the one `collapsed` and\n * `scrolled` are for.\n * @default false\n */\n readonly pinned?: boolean\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * Whether the content beneath has been scrolled. Material Design separates\n * a bar from scrolled content with a fill colour rather than a shadow, the\n * surface container role, and this is what applies it.\n *\n * Controlled, with no listener of its own: only the app knows which view\n * scrolls. `useAppBarScroll` derives it.\n * @default false\n */\n readonly scrolled?: boolean\n /**\n * `sm` is Material Design's small bar, 64dp; `md` and `lg` are its medium\n * and large flexible bars, 112dp and 120dp, or 136dp and 152dp with a\n * subtitle, which hug their text. The headline is title large, headline\n * small and headline medium in turn.\n * @default 'sm'\n */\n readonly size?: AppBarSize\n /** A second line under the headline. Makes `md` and `lg` taller. */\n readonly subtitle?: ReactNode\n /**\n * Actions, at the far end, usually icon buttons. An icon here takes the\n * on-surface-variant colour and a 24dp size through `useIconStyle()`.\n */\n readonly trailing?: ReactNode\n}\n\ntype AppBarSize = 'lg' | 'md' | 'sm'\n\ntype SlotProps = {\n readonly children: ReactNode\n readonly color: ColorValue\n}\n\n/**\n * Material Design's top app bar: the bar at the top of a screen carrying its\n * title, one or two actions, and the way back out.\n *\n * ```tsx\n * <AppBar\n * headline=\"Headline\"\n * leading={<IconButton aria-label=\"Back\"><ArrowBackGlyph /></IconButton>}\n * />\n * ```\n *\n * Three sizes. `sm` is a 64dp bar for a screen whose title is a label; `md`\n * and `lg` are the flexible bars, which give the headline a larger type role\n * and grow to fit a subtitle or a headline that wraps.\n *\n * It paints its own surface, from the screen's top edge, and keeps its\n * contents clear of the status bar and the notch. Separating itself from the\n * content beneath is its job, which is why `scrolled` and `collapsed` exist;\n * `useAppBarScroll` sets both from the screen's scroll view.\n */\nfunction AppBar({\n align = 'start',\n collapsed = false,\n contentInset,\n contentMaxInlineSize,\n headline,\n leading,\n pinned = false,\n scrolled = false,\n size = 'sm',\n style,\n subtitle,\n trailing,\n ...props\n}: AppBarProps) {\n const theme = useTheme()\n const own = stylesOf(theme)\n const inset = contentInset ?? theme.spacing.lg\n // `sm` is already what the flexible bars collapse to, so collapsing it is\n // a no-op rather than an error, for a size chosen by the window.\n const collapse = collapsed && size !== 'sm'\n const hasLeading = hasContent(leading)\n const hasTrailing = hasContent(trailing)\n const showsSubtitle = hasContent(subtitle) && !collapse\n const heights = HEIGHTS[collapse ? 'sm' : size]\n const fill = useFill(scrolled)\n\n return (\n <Animated.View\n {...props}\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n fill,\n pinned ? styles.pinned : null,\n style,\n )}\n >\n <SafeAreaView edges={EDGES} style={styles.safeArea}>\n <View\n style={composeStyles<ViewStyle>(styles.row, own.row, {\n maxWidth: contentMaxInlineSize,\n minHeight: showsSubtitle ? heights.withSubtitle : heights.plain,\n paddingEnd: edgePadding(inset, hasTrailing),\n paddingStart: edgePadding(inset, hasLeading),\n })}\n >\n {hasLeading ? (\n <Slot color={theme.colors.onSurface}>{leading}</Slot>\n ) : null}\n <View style={own.text}>\n {hasContent(headline) ? (\n <Text\n role=\"heading\"\n style={align === 'center' ? styles.center : undefined}\n variant={HEADLINE_ROLES[collapse ? 'sm' : size]}\n >\n {headline}\n </Text>\n ) : null}\n {showsSubtitle ? (\n <Text\n style={align === 'center' ? styles.center : undefined}\n tone=\"muted\"\n variant=\"bodyMedium\"\n >\n {subtitle}\n </Text>\n ) : null}\n </View>\n {hasTrailing ? (\n <Slot color={theme.colors.onSurfaceVariant}>{trailing}</Slot>\n ) : null}\n </View>\n </SafeAreaView>\n </Animated.View>\n )\n}\n\n// The row's padding on one edge, for the inset the call site gave. Where the\n// edge holds a slot the row stops short of the inset by GLYPH_INSET, clamped\n// at zero for an inset smaller than a glyph's own room.\nfunction edgePadding(inset: number, hasSlot: boolean): number {\n return hasSlot ? Math.max(0, inset - GLYPH_INSET) : inset\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's jsx-no-new-object-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction iconStyleOf(color: ColorValue): IconStyle {\n return { color, size: ICON_SIZE }\n}\n\n// A slot's icons draw at 24dp in the slot's colour. An icon button inside it\n// hands its own icon the button's colour instead.\nfunction Slot({ children, color }: SlotProps) {\n const own = stylesOf(useTheme())\n\n return (\n <IconStyleContext value={iconStyleOf(color)}>\n <View style={own.slot}>{children}</View>\n </IconStyleContext>\n )\n}\n\n// The bar's surface, which takes the surface container role once the\n// content beneath has scrolled. It eases over medium 1 on the emphasized\n// curve, and arrives at once under reduced motion.\nfunction useFill(scrolled: boolean) {\n const { colors, motion } = useTheme()\n const reduceMotion = useReducedMotion()\n const fill = scrolled ? colors.surfaceContainer : colors.surface\n const timing = {\n duration: motion.durationMedium1,\n easing: Easing.bezier(...motion.easingEmphasized),\n }\n\n return useAnimatedStyle(() => {\n 'worklet'\n return {\n backgroundColor: reduceMotion ? fill : withTiming(fill, timing),\n }\n })\n}\n\nexport { AppBar }\nexport type { AppBarProps }\n"],"mappings":";;;;;;;;;;;AA8DA,MAAM0B,YAAY;AAKlB,MAAMC,cAAAA;AAEN,MAAMC,UAAU;CACdC,IAAI;EAAEC,OAAO;EAAKC,cAAc;CAAI;CACpCC,IAAI;EAAEF,OAAO;EAAKC,cAAc;CAAI;CACpCE,IAAI;EAAEH,OAAAA;EAA6BC,cAAAA;CAAmC;AACxE;AAKA,MAAMI,iBAAyD;CAC7DN,IAAI;CACJG,IAAI;CACJC,IAAI;AACN;AAIA,MAAMM,QAAyB;CAAC;CAAQ;CAAS;AAAK;AAEtD,MAAMC,SAAShC,WAAWiC,OAAO;CAC/BC,QAAQ,EACNC,WAAW,SACb;CAGAC,QAAQ,EACNC,QAAQ,EACV;CACAC,KAAK;EACHC,YAAY;EACZC,eAAe;EACfC,OAAO;CACT;CAEAC,UAAU,EACRH,YAAY,SACd;AACF,CAAC;AAED,MAAMI,WAAW3B,cAAc,EAAE4B,QAAQC,cACvC7C,WAAWiC,OAAO;CAChBK,KAAK,EACHQ,KAAKD,QAAQE,GACf;CAGAC,MAAM;EACJT,YAAY;EACZC,eAAe;EACfS,YAAY;EACZH,KAAAA,KAAmBF,OAAOM;EAC1BC,oBAAAA,KAAkCP,OAAOM,aAAa;CACxD;CAEAE,MAAM;EACJC,UAAU;EACVJ,YAAY;EACZK,gBAAgB;EAChBC,UAAU;EACVC,iBAAiBX,QAAQpB;CAC3B;AACF,CAAC,CACH;;;;;;;;;;;;;;;;;;;;;AAiHA,SAAAgD,OAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAf;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAa;CAAA,IAAAC;CAAA,IAAAV;CAAA,IAAAW;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAA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B,SAAAY,QAAA7B,UAAA;CACE,MAAA,EAAA0C,QAAAiB,WAA2B/G,SAAS;CACpC,MAAAgH,eAAqBzH,iBAAiB;CACtC,MAAAyF,OAAa5B,WAAW0C,OAAMmB,mBAAoBnB,OAAMoB;CACxD,MAAAC,SAAe;EAAAC,UACHL,OAAMM;EAAgBC,QACxBjI,OAAMkI,OAAO,GAAIR,OAAMS,gBAAiB;CAClD;CAAC,OAEMlI,uBAAiB;EAAA;EAAA,OAEf,EAAAmI,iBACYT,eAAAhC,OAAsBxF,WAAWwF,MAAMmC,MAAM,EAChE;CAAC,CACF;AAAC"}
@@ -0,0 +1,49 @@
1
+ import { ReactNode } from "react";
2
+ import { Node } from "react-stately";
3
+ //#region src/components/autocomplete/index.d.ts
4
+ /**
5
+ * Whether a search keeps a row: handed the row's text, what has been typed
6
+ * and the row's entry in the collection, as React Aria's is.
7
+ */
8
+ type AutocompleteFilter<T extends object = object> = (textValue: string, inputValue: string, node: Node<T>) => boolean;
9
+ type AutocompleteProps<T extends object = object> = {
10
+ /**
11
+ * The search field and the list it filters, in whatever the page puts
12
+ * around them.
13
+ */
14
+ readonly children?: ReactNode;
15
+ /** What has been typed at first, when the autocomplete keeps its own. */
16
+ readonly defaultInputValue?: string;
17
+ /**
18
+ * Which rows a search keeps. Left out, a row is kept when its text
19
+ * contains what has been typed anywhere in it, ignoring case and accents.
20
+ */
21
+ readonly filter?: AutocompleteFilter<T>;
22
+ /** What has been typed, when the call site holds it. */
23
+ readonly inputValue?: string;
24
+ /** Called with what has been typed whenever an edit changes it. */
25
+ readonly onInputChange?: (value: string) => void;
26
+ };
27
+ /**
28
+ * A search field that filters the list under it. What has been typed is the
29
+ * autocomplete's: pass `inputValue` with `onInputChange` to control it, or
30
+ * `defaultInputValue` to let it keep its own. The field inside shows it, and
31
+ * its own `value` and `defaultValue` are not read there.
32
+ *
33
+ * ```tsx
34
+ * <Autocomplete>
35
+ * <SearchField label="Search" placeholder="Search" />
36
+ * <List aria-label="Results" selectionMode="single">
37
+ * <List.Item id="first">First item</List.Item>
38
+ * </List>
39
+ * </Autocomplete>
40
+ * ```
41
+ *
42
+ * It renders nothing of its own, so the field and the list sit wherever the
43
+ * page puts them, and the list says how many rows each search leaves to a
44
+ * screen reader.
45
+ */
46
+ declare function Autocomplete<T extends object = object>({ children, defaultInputValue, filter, inputValue, onInputChange }: AutocompleteProps<T>): import("react").JSX.Element;
47
+ //#endregion
48
+ export { Autocomplete, type AutocompleteFilter, type AutocompleteProps };
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,87 @@
1
+ import { AutocompleteContext, containsIn } from "../../autocomplete/index.js";
2
+ import { localeOf } from "../../number/locale.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { useState } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/components/autocomplete/index.tsx
7
+ /**
8
+ * A search field that filters the list under it. What has been typed is the
9
+ * autocomplete's: pass `inputValue` with `onInputChange` to control it, or
10
+ * `defaultInputValue` to let it keep its own. The field inside shows it, and
11
+ * its own `value` and `defaultValue` are not read there.
12
+ *
13
+ * ```tsx
14
+ * <Autocomplete>
15
+ * <SearchField label="Search" placeholder="Search" />
16
+ * <List aria-label="Results" selectionMode="single">
17
+ * <List.Item id="first">First item</List.Item>
18
+ * </List>
19
+ * </Autocomplete>
20
+ * ```
21
+ *
22
+ * It renders nothing of its own, so the field and the list sit wherever the
23
+ * page puts them, and the list says how many rows each search leaves to a
24
+ * screen reader.
25
+ */
26
+ function Autocomplete(t0) {
27
+ const $ = c(14);
28
+ const { children, defaultInputValue: t1, filter, inputValue, onInputChange } = t0;
29
+ const [own, setOwn] = useState(t1 === void 0 ? "" : t1);
30
+ const current = inputValue ?? own;
31
+ let t2;
32
+ if ($[0] !== filter) {
33
+ t2 = filter ?? containsIn(localeOf(void 0));
34
+ $[0] = filter;
35
+ $[1] = t2;
36
+ } else t2 = $[1];
37
+ let t3;
38
+ if ($[2] !== current || $[3] !== t2) {
39
+ t3 = matchesOf(t2, current);
40
+ $[2] = current;
41
+ $[3] = t2;
42
+ $[4] = t3;
43
+ } else t3 = $[4];
44
+ let t4;
45
+ if ($[5] !== onInputChange) {
46
+ t4 = setterOf(setOwn, onInputChange);
47
+ $[5] = onInputChange;
48
+ $[6] = t4;
49
+ } else t4 = $[6];
50
+ let t5;
51
+ if ($[7] !== current || $[8] !== t3 || $[9] !== t4) {
52
+ t5 = {
53
+ inputValue: current,
54
+ matches: t3,
55
+ setInputValue: t4
56
+ };
57
+ $[7] = current;
58
+ $[8] = t3;
59
+ $[9] = t4;
60
+ $[10] = t5;
61
+ } else t5 = $[10];
62
+ const value = t5;
63
+ let t6;
64
+ if ($[11] !== children || $[12] !== value) {
65
+ t6 = /* @__PURE__ */ jsx(AutocompleteContext, {
66
+ value,
67
+ children
68
+ });
69
+ $[11] = children;
70
+ $[12] = value;
71
+ $[13] = t6;
72
+ } else t6 = $[13];
73
+ return t6;
74
+ }
75
+ function matchesOf(filter, inputValue) {
76
+ return (textValue, node) => filter(textValue, inputValue, node);
77
+ }
78
+ function setterOf(setOwn, onInputChange) {
79
+ return (value) => {
80
+ setOwn(value);
81
+ onInputChange?.(value);
82
+ };
83
+ }
84
+ //#endregion
85
+ export { Autocomplete };
86
+
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ReactNode","Node","useMemo","useState","AutocompleteValue","AutocompleteContext","containsIn","localeOf","AutocompleteFilter","textValue","inputValue","node","T","AutocompleteProps","children","defaultInputValue","filter","onInputChange","value","Autocomplete","t0","$","_c","t1","undefined","own","setOwn","current","t2","t3","matchesOf","t4","setterOf","t5","matches","setInputValue","t6","_c"],"sources":["../../../src/components/autocomplete/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Node } from 'react-stately'\n\nimport { useMemo, useState } from 'react'\n\nimport type { AutocompleteValue } from '../../autocomplete'\n\nimport { AutocompleteContext, containsIn } from '../../autocomplete'\nimport { localeOf } from '../../number/locale'\n\n// kanso-ui's Autocomplete, from the search page's search with suggestions: a\n// SearchField over a List, where typing narrows the rows the list shows. It\n// draws nothing of its own, as web's draws nothing: the bar is SearchField's,\n// the rows are List's, and where the two sit is the page's business. So it\n// takes no `style`, since there is nothing for one to land on.\n//\n// Three things are worth knowing, and the last two differ from web's.\n//\n// **Filtering is on by default,** as on web: `filter` falls back to a match\n// anywhere in a row's text, compared by an `Intl.Collator` in the device's\n// locale at base sensitivity, so case and accents are ignored, which is what\n// web's falls back to as well.\n//\n// **There is no virtual focus.** Web keeps the keyboard in the input while\n// the arrow keys move through the list. A touch screen has no arrow keys, so\n// the list's rows are pressed where they are, and a press on one selects it\n// or runs its action, as it does in any List. A list inside an Autocomplete\n// keeps the keyboard up through that press, with `keyboardShouldPersistTaps`\n// at `handled`, so a row is reached on the first tap rather than the one\n// that would otherwise only close the keyboard.\n//\n// **The count is announced.** Web says only that a search left nothing.\n// Here the list says how many rows a search leaves each time the number\n// changes, in React Aria's words for a ComboBox's count, and that it left\n// none in the empty row's: through a polite live region on Android and\n// under React Native Web, and `AccessibilityInfo` on iOS, which has no live\n// regions. The list's empty row is drawn as ever when nothing matches.\n\n/**\n * Whether a search keeps a row: handed the row's text, what has been typed\n * and the row's entry in the collection, as React Aria's is.\n */\ntype AutocompleteFilter<T extends object = object> = (\n textValue: string,\n inputValue: string,\n node: Node<T>,\n) => boolean\n\ntype AutocompleteProps<T extends object = object> = {\n /**\n * The search field and the list it filters, in whatever the page puts\n * around them.\n */\n readonly children?: ReactNode\n /** What has been typed at first, when the autocomplete keeps its own. */\n readonly defaultInputValue?: string\n /**\n * Which rows a search keeps. Left out, a row is kept when its text\n * contains what has been typed anywhere in it, ignoring case and accents.\n */\n readonly filter?: AutocompleteFilter<T>\n /** What has been typed, when the call site holds it. */\n readonly inputValue?: string\n /** Called with what has been typed whenever an edit changes it. */\n readonly onInputChange?: (value: string) => void\n}\n\n/**\n * A search field that filters the list under it. What has been typed is the\n * autocomplete's: pass `inputValue` with `onInputChange` to control it, or\n * `defaultInputValue` to let it keep its own. The field inside shows it, and\n * its own `value` and `defaultValue` are not read there.\n *\n * ```tsx\n * <Autocomplete>\n * <SearchField label=\"Search\" placeholder=\"Search\" />\n * <List aria-label=\"Results\" selectionMode=\"single\">\n * <List.Item id=\"first\">First item</List.Item>\n * </List>\n * </Autocomplete>\n * ```\n *\n * It renders nothing of its own, so the field and the list sit wherever the\n * page puts them, and the list says how many rows each search leaves to a\n * screen reader.\n */\nfunction Autocomplete<T extends object = object>({\n children,\n defaultInputValue = '',\n filter,\n inputValue,\n onInputChange,\n}: AutocompleteProps<T>) {\n const [own, setOwn] = useState(defaultInputValue)\n const current = inputValue ?? own\n const value = useMemo<AutocompleteValue>(\n () => ({\n inputValue: current,\n matches: matchesOf(filter ?? containsIn(localeOf(undefined)), current),\n setInputValue: setterOf(setOwn, onInputChange),\n }),\n [current, filter, onInputChange],\n )\n\n return <AutocompleteContext value={value}>{children}</AutocompleteContext>\n}\n\n// The filter with what has been typed already in it, which is all a list\n// asks of a row.\nfunction matchesOf<T extends object>(\n filter: AutocompleteFilter<T>,\n inputValue: string,\n): AutocompleteValue['matches'] {\n return (textValue, node) =>\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the rows are the call site's, which typed the filter it wrote for them\n filter(textValue, inputValue, node as Node<T>)\n}\n\n// Keeps an edit as the autocomplete's own value and reports it, so one the\n// call site controls is told and one it does not still filters.\nfunction setterOf(\n setOwn: (value: string) => void,\n onInputChange: ((value: string) => void) | undefined,\n) {\n return (value: string) => {\n setOwn(value)\n onInputChange?.(value)\n }\n}\n\nexport { Autocomplete }\nexport type { AutocompleteFilter, AutocompleteProps }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAAmB,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAiD,MAAA,EAAAR,UAAAC,mBAAAQ,IAAAP,QAAAN,YAAAO,kBAAAG;CAO/C,MAAA,CAAAK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ACPN,QACAT,eACA;CACA,QAAQC,UAAkB;EACxBQ,OAAOR,KAAK;EACZD,gBAAgBC,KAAK;CACvB;AACF"}
@@ -81,7 +81,7 @@ type ButtonVariant = 'elevated' | 'filled' | 'outlined' | 'text' | 'tonal';
81
81
  * target through `hitSlop`, which a `hitSlop` of the call site's own replaces.
82
82
  * `style`, `ref` and `testID` land on the `Pressable`.
83
83
  */
84
- declare function Button({ children, defaultSelected, disableRipple, hitSlop: ownHitSlop, href, icon, isDisabled, isPending, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onLongPress, onPress, onPressIn, onPressOut, pendingLabel, shape, size, slot, style, type, variant, ...props }: ButtonProps): import("react").JSX.Element;
84
+ declare function Button({ children, defaultSelected, delayLongPress, disableRipple, hitSlop: ownHitSlop, href, icon, isDisabled, isPending, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onLongPress, onPress, onPressIn, onPressOut, pendingLabel, ref, shape, size, slot, style, type, variant, ...props }: ButtonProps): import("react").JSX.Element;
85
85
  //#endregion
86
86
  export { Button, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant };
87
87
  //# sourceMappingURL=index.d.ts.map