@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
@@ -3,9 +3,9 @@ import { composeStyles } from "../theme/styles.js";
3
3
  import { styles, stylesOf } from "./styles.js";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { View } from "react-native";
6
+ import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
6
7
  import { useRef, useState } from "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
- import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
9
9
  const INITIAL_ORIGIN_SCALE = .2;
10
10
  const FADE_IN = 105;
11
11
  const FADE_OUT = 375;
@@ -59,7 +59,8 @@ function hitSlop(height, width = 48) {
59
59
  *
60
60
  * A control whose layer is a disc of its own beside its label, as a
61
61
  * checkbox's is, passes the disc's side as `disc`, and its ripple grows from
62
- * the disc's centre instead. One whose pressed layer takes another colour
62
+ * the disc's centre instead. One whose layer is drawn on a part of it of a
63
+ * fixed size passes that size as `area`, with the same effect. One whose pressed layer takes another colour
63
64
  * passes it as `pressedColor`.
64
65
  *
65
66
  * The ring shows when focus arrives from a keyboard, and not when it arrives
@@ -75,8 +76,8 @@ function hitSlop(height, width = 48) {
75
76
  * ```
76
77
  */
77
78
  function usePressFeedback(t0) {
78
- const $ = c(58);
79
- const { color, corners, disabled, disableRipple: t1, disc, onBlur, onFocus, onHoverIn, onHoverOut, onPressIn, onPressOut, pending, pressedColor: t2 } = t0;
79
+ const $ = c(59);
80
+ const { area, color, corners, disabled, disableRipple: t1, disc, onBlur, onFocus, onHoverIn, onHoverOut, onPressIn, onPressOut, pending, pressedColor: t2 } = t0;
80
81
  const disableRipple = t1 === void 0 ? false : t1;
81
82
  const pressedColor = t2 === void 0 ? color : t2;
82
83
  const theme = useTheme();
@@ -205,14 +206,18 @@ function usePressFeedback(t0) {
205
206
  $[17] = t8;
206
207
  } else t8 = $[17];
207
208
  let t9;
208
- if ($[18] !== disc || $[19] !== onPressIn || $[20] !== release || $[21] !== ripple || $[22] !== rippled) {
209
+ if ($[18] !== area || $[19] !== disc || $[20] !== onPressIn || $[21] !== release || $[22] !== ripple || $[23] !== rippled) {
209
210
  t9 = (event_3) => {
210
211
  pressedUnfocused.current = !focused.current;
211
212
  setPressed(true);
212
- if (rippled && disc !== void 0) {
213
- ripple(disc, disc, {
214
- x: disc / 2,
215
- y: disc / 2
213
+ const fixed = disc === void 0 ? area : {
214
+ height: disc,
215
+ width: disc
216
+ };
217
+ if (rippled && fixed !== void 0) {
218
+ ripple(fixed.width, fixed.height, {
219
+ x: fixed.width / 2,
220
+ y: fixed.height / 2
216
221
  });
217
222
  phase.current = "shown";
218
223
  } else if (rippled && typeof event_3.currentTarget !== "number") {
@@ -231,15 +236,16 @@ function usePressFeedback(t0) {
231
236
  }
232
237
  onPressIn?.(event_3);
233
238
  };
234
- $[18] = disc;
235
- $[19] = onPressIn;
236
- $[20] = release;
237
- $[21] = ripple;
238
- $[22] = rippled;
239
- $[23] = t9;
240
- } else t9 = $[23];
239
+ $[18] = area;
240
+ $[19] = disc;
241
+ $[20] = onPressIn;
242
+ $[21] = release;
243
+ $[22] = ripple;
244
+ $[23] = rippled;
245
+ $[24] = t9;
246
+ } else t9 = $[24];
241
247
  let t10;
242
- if ($[24] !== onPressOut || $[25] !== release) {
248
+ if ($[25] !== onPressOut || $[26] !== release) {
243
249
  t10 = (event_4) => {
244
250
  pressedUnfocused.current = false;
245
251
  setPressed(false);
@@ -247,12 +253,12 @@ function usePressFeedback(t0) {
247
253
  phase.current = phase.current === "measuring" ? "released" : "idle";
248
254
  onPressOut?.(event_4);
249
255
  };
250
- $[24] = onPressOut;
251
- $[25] = release;
252
- $[26] = t10;
253
- } else t10 = $[26];
256
+ $[25] = onPressOut;
257
+ $[26] = release;
258
+ $[27] = t10;
259
+ } else t10 = $[27];
254
260
  let t11;
255
- if ($[27] !== t10 || $[28] !== t5 || $[29] !== t6 || $[30] !== t7 || $[31] !== t8 || $[32] !== t9) {
261
+ if ($[28] !== t10 || $[29] !== t5 || $[30] !== t6 || $[31] !== t7 || $[32] !== t8 || $[33] !== t9) {
256
262
  t11 = {
257
263
  onBlur: t5,
258
264
  onFocus: t6,
@@ -261,73 +267,73 @@ function usePressFeedback(t0) {
261
267
  onPressIn: t9,
262
268
  onPressOut: t10
263
269
  };
264
- $[27] = t10;
265
- $[28] = t5;
266
- $[29] = t6;
267
- $[30] = t7;
268
- $[31] = t8;
269
- $[32] = t9;
270
- $[33] = t11;
271
- } else t11 = $[33];
270
+ $[28] = t10;
271
+ $[29] = t5;
272
+ $[30] = t6;
273
+ $[31] = t7;
274
+ $[32] = t8;
275
+ $[33] = t9;
276
+ $[34] = t11;
277
+ } else t11 = $[34];
272
278
  const handlers = t11;
273
279
  const layerOpacity = !active ? 0 : interactive && pressed ? stateLayerOpacity.pressed : ringShown ? stateLayerOpacity.focus : interactive && hovered ? stateLayerOpacity.hover : 0;
274
280
  let t12;
275
- if ($[34] !== corners) {
281
+ if ($[35] !== corners) {
276
282
  t12 = composeStyles(styles.surface, corners);
277
- $[34] = corners;
278
- $[35] = t12;
279
- } else t12 = $[35];
283
+ $[35] = corners;
284
+ $[36] = t12;
285
+ } else t12 = $[36];
280
286
  const surface = t12;
281
287
  const t13 = interactive && pressed ? pressedColor : color;
282
288
  let t14;
283
- if ($[36] !== layerOpacity || $[37] !== t13) {
289
+ if ($[37] !== layerOpacity || $[38] !== t13) {
284
290
  t14 = composeStyles(styles.layer, {
285
291
  backgroundColor: t13,
286
292
  opacity: layerOpacity
287
293
  });
288
- $[36] = layerOpacity;
289
- $[37] = t13;
290
- $[38] = t14;
291
- } else t14 = $[38];
294
+ $[37] = layerOpacity;
295
+ $[38] = t13;
296
+ $[39] = t14;
297
+ } else t14 = $[39];
292
298
  const state = t14;
293
299
  const t15 = interactive && hovered;
294
300
  let t16;
295
- if ($[39] !== state) {
301
+ if ($[40] !== state) {
296
302
  t16 = /* @__PURE__ */ jsx(View, { style: state });
297
- $[39] = state;
298
- $[40] = t16;
299
- } else t16 = $[40];
303
+ $[40] = state;
304
+ $[41] = t16;
305
+ } else t16 = $[41];
300
306
  let t17;
301
- if ($[41] !== rippleMotion || $[42] !== rippled) {
307
+ if ($[42] !== rippleMotion || $[43] !== rippled) {
302
308
  t17 = rippled ? /* @__PURE__ */ jsx(Animated.View, { style: rippleMotion }) : null;
303
- $[41] = rippleMotion;
304
- $[42] = rippled;
305
- $[43] = t17;
306
- } else t17 = $[43];
309
+ $[42] = rippleMotion;
310
+ $[43] = rippled;
311
+ $[44] = t17;
312
+ } else t17 = $[44];
307
313
  let t18;
308
- if ($[44] !== surface || $[45] !== t16 || $[46] !== t17) {
314
+ if ($[45] !== surface || $[46] !== t16 || $[47] !== t17) {
309
315
  t18 = /* @__PURE__ */ jsxs(View, {
310
316
  accessibilityElementsHidden: true,
311
317
  importantForAccessibility: "no-hide-descendants",
312
318
  style: surface,
313
319
  children: [t16, t17]
314
320
  });
315
- $[44] = surface;
316
- $[45] = t16;
317
- $[46] = t17;
318
- $[47] = t18;
319
- } else t18 = $[47];
321
+ $[45] = surface;
322
+ $[46] = t16;
323
+ $[47] = t17;
324
+ $[48] = t18;
325
+ } else t18 = $[48];
320
326
  const t19 = interactive && pressed;
321
327
  let t20;
322
- if ($[48] !== active || $[49] !== ringShown || $[50] !== theme) {
328
+ if ($[49] !== active || $[50] !== ringShown || $[51] !== theme) {
323
329
  t20 = active && ringShown ? stylesOf(theme).ring : void 0;
324
- $[48] = active;
325
- $[49] = ringShown;
326
- $[50] = theme;
327
- $[51] = t20;
328
- } else t20 = $[51];
330
+ $[49] = active;
331
+ $[50] = ringShown;
332
+ $[51] = theme;
333
+ $[52] = t20;
334
+ } else t20 = $[52];
329
335
  let t21;
330
- if ($[52] !== handlers || $[53] !== t15 || $[54] !== t18 || $[55] !== t19 || $[56] !== t20) {
336
+ if ($[53] !== handlers || $[54] !== t15 || $[55] !== t18 || $[56] !== t19 || $[57] !== t20) {
331
337
  t21 = {
332
338
  handlers,
333
339
  hovered: t15,
@@ -335,13 +341,13 @@ function usePressFeedback(t0) {
335
341
  pressed: t19,
336
342
  ring: t20
337
343
  };
338
- $[52] = handlers;
339
- $[53] = t15;
340
- $[54] = t18;
341
- $[55] = t19;
342
- $[56] = t20;
343
- $[57] = t21;
344
- } else t21 = $[57];
344
+ $[53] = handlers;
345
+ $[54] = t15;
346
+ $[55] = t18;
347
+ $[56] = t19;
348
+ $[57] = t20;
349
+ $[58] = t21;
350
+ } else t21 = $[58];
345
351
  return t21;
346
352
  }
347
353
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ReactNode","Insets","PressableProps","ViewStyle","useRef","useState","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withDelay","withTiming","useTheme","composeStyles","styles","stylesOf","Corners","Pick","Handlers","Point","x","y","PressFeedback","handlers","NonNullable","Name","hovered","layer","pressed","ring","PressFeedbackOptions","color","corners","disabled","disableRipple","disc","pending","pressedColor","RippleGeometry","end","scale","size","start","RipplePhase","TARGET_SIZE","INITIAL_ORIGIN_SCALE","FADE_IN","FADE_OUT","NO_RIPPLE","hitSlop","height","width","vertical","Math","max","horizontal","undefined","bottom","left","right","top","usePressFeedback","t0","$","_c","t1","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","t2","theme","reduceMotion","setHovered","setPressed","ringShown","setRingShown","focused","pressedUnfocused","pressStarted","phase","geometry","grow","fade","motion","spacing","stateLayerOpacity","active","interactive","rippled","rippleMotion","get","progress","backgroundColor","borderRadius","opacity","position","transform","translateX","translateY","t3","ripple","origin","size_0","floor","set","hypot","sm","duration","durationLong1","easing","bezier","easingStandard","linear","current","Date","now","t4","release","shown","durationMedium1","t5","event","t6","event_0","t7","event_1","t8","event_2","t9","event_3","currentTarget","pageX","pageY","nativeEvent","measure","_x","_y","width_0","height_0","Number","isFinite","t10","event_4","t11","layerOpacity","focus","hover","t12","surface","t13","t14","state","t15","t16","t17","t18","t19","t20","t21","_c"],"sources":["../../src/press/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Insets, PressableProps, ViewStyle } from 'react-native'\n\nimport { useRef, useState } from 'react'\nimport { View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated'\n\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { styles, stylesOf } from './styles'\n\n/** The corners a control is drawn with, which its feedback clips to. */\ntype Corners = Pick<\n ViewStyle,\n | 'borderBottomEndRadius'\n | 'borderBottomStartRadius'\n | 'borderRadius'\n | 'borderTopEndRadius'\n | 'borderTopStartRadius'\n>\n\n/** The handlers the feedback reads its states from. */\ntype Handlers = Pick<\n PressableProps,\n 'onBlur' | 'onFocus' | 'onHoverIn' | 'onHoverOut' | 'onPressIn' | 'onPressOut'\n>\n\ntype Point = { readonly x: number; readonly y: number }\n\ntype PressFeedback = {\n /**\n * The handlers to hand the control's `Pressable`. Each calls the one of\n * the same name it was given after its own.\n */\n readonly handlers: {\n readonly [Name in keyof Handlers]-?: NonNullable<Handlers[Name]>\n }\n /**\n * Whether a pointer is over the control, for a control that draws more\n * than the layer while hovered. Never while disabled or pending.\n */\n readonly hovered: boolean\n /** The state layer and the ripple, to render as the `Pressable`'s first child. */\n readonly layer: ReactNode\n /**\n * Whether the control is pressed, for a control that draws more than the\n * layer while pressed. Never while disabled or pending.\n */\n readonly pressed: boolean\n /** The focus ring while it shows, to compose into the control's style. */\n readonly ring: undefined | ViewStyle\n}\n\ntype PressFeedbackOptions = Handlers & {\n /**\n * The colour the layer and the ripple are drawn in: the theme's value for\n * the control's content colour role.\n */\n readonly color: string\n /** The control's corners, which the layer and the ripple clip to. */\n readonly corners?: Corners | undefined\n readonly disabled?: boolean | null | undefined\n /**\n * Draws no ripple and leaves the state layer, as `disableRipple` does on\n * web's Button.\n */\n readonly disableRipple?: boolean | undefined\n /**\n * The side of a round layer of a fixed size, for a control whose state\n * layer is a disc beside its label rather than the whole control: a\n * checkbox's. The ripple then grows from the disc's centre wherever the\n * press lands, and nothing is measured. Left out, the ripple grows from\n * the press point across the control.\n */\n readonly disc?: number | undefined\n /**\n * Takes no press or hover while true, with no layer and no ripple for\n * either, and keeps the focus and its ring, as a pending button does.\n */\n readonly pending?: boolean | undefined\n /**\n * The colour the pressed layer and the ripple are drawn in, where it\n * differs from the hover and focus layers': a checkbox's swaps between\n * primary and on surface once pressed. Defaults to `color`.\n */\n readonly pressedColor?: string | undefined\n}\n\n/** Where the ripple starts and ends, and how far it grows, for one press. */\ntype RippleGeometry = {\n readonly end: Point\n readonly scale: number\n readonly size: number\n readonly start: Point\n}\n\n// Where the ripple of the latest press is: waiting on the control's\n// measurement, shown, or released before the measurement arrived.\ntype RipplePhase = 'idle' | 'measuring' | 'released' | 'shown'\n\n/**\n * The least a touch target measures each way, from Material Design's\n * accessibility guidance. A floor rather than a token, as web's `TARGET_SIZE`\n * is: a theme changes how big a control is drawn, never how small a target\n * may be.\n */\nconst TARGET_SIZE = 48\n\n// The ripple starts as a disc a fifth of the control's longer side, as on web.\nconst INITIAL_ORIGIN_SCALE = 0.2\n\n// The fade, in milliseconds: quick in and slow out, so a tap reads as a ripple\n// rather than a flicker. These are web's, and deliberately not motion tokens:\n// the two are tuned as a ratio to each other, which snapping either to the\n// scale would undo. Linear for the same reason, since a fade to and from a\n// state layer wants no acceleration.\nconst FADE_IN = 105\nconst FADE_OUT = 375\n\nconst NO_RIPPLE: RippleGeometry = {\n end: { x: 0, y: 0 },\n scale: 1,\n size: 0,\n start: { x: 0, y: 0 },\n}\n\n/**\n * The `hitSlop` that brings a control smaller than 48dp up to a 48dp target,\n * centred on it, as web's controls draw their target with a `::before`.\n * Nothing for a control already that big. A width left out is taken to be\n * wide enough, as a labelled button's is.\n */\nfunction hitSlop(height: number, width = TARGET_SIZE): Insets | undefined {\n const vertical = Math.max(0, (TARGET_SIZE - height) / 2)\n const horizontal = Math.max(0, (TARGET_SIZE - width) / 2)\n\n if (vertical === 0 && horizontal === 0) {\n return undefined\n }\n\n return {\n bottom: vertical,\n left: horizontal,\n right: horizontal,\n top: vertical,\n }\n}\n\n/**\n * The press feedback every interactive control draws: the state layer, the\n * ripple and the focus ring, as Material Design's state layers page sets them\n * out.\n *\n * The state layer is the control's content colour at the state's opacity\n * token, over the whole control: hover for an iPad pointer or an Android\n * mouse, focus while the ring shows, pressed while pressed. React Native has\n * no `color-mix()`, so it is a view of its own rather than a blended\n * background.\n *\n * The ripple grows from the press point to cover the control and fades out\n * once the press ends, held at least `durationMedium1` so a tap reads, and is\n * drawn the same on iOS and Android rather than through Android's own\n * `android_ripple`. It is a solid disc where web's has a soft edge, since\n * React Native draws a gradient only through an experimental style that React\n * Native Web ignores. It is not drawn while the device asks for reduced\n * motion, where the pressed layer alone marks the press.\n *\n * A control whose layer is a disc of its own beside its label, as a\n * checkbox's is, passes the disc's side as `disc`, and its ripple grows from\n * the disc's centre instead. One whose pressed layer takes another colour\n * passes it as `pressedColor`.\n *\n * The ring shows when focus arrives from a keyboard, and not when it arrives\n * with a press, which on web is a click focusing what it presses.\n *\n * ```tsx\n * const feedback = usePressFeedback({ color: colors.onPrimary, corners, onPressIn })\n *\n * <Pressable {...feedback.handlers} style={[styles.button, feedback.ring]}>\n * {feedback.layer}\n * <Text>Label</Text>\n * </Pressable>\n * ```\n */\nfunction usePressFeedback({\n color,\n corners,\n disabled,\n disableRipple = false,\n disc,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n pending,\n pressedColor = color,\n}: PressFeedbackOptions): PressFeedback {\n const theme = useTheme()\n const reduceMotion = useReducedMotion()\n const [hovered, setHovered] = useState(false)\n const [pressed, setPressed] = useState(false)\n const [ringShown, setRingShown] = useState(false)\n const focused = useRef(false)\n // Whether the press in flight began while the control had no focus, which\n // makes the focus that follows it a pointer's.\n const pressedUnfocused = useRef(false)\n const pressStarted = useRef(0)\n const phase = useRef<RipplePhase>('idle')\n const geometry = useSharedValue(NO_RIPPLE)\n const grow = useSharedValue(0)\n const fade = useSharedValue(0)\n\n const { motion, spacing, stateLayerOpacity } = theme\n const active = disabled !== true\n const interactive = active && pending !== true\n const rippled = interactive && !disableRipple && !reduceMotion\n\n const rippleMotion = useAnimatedStyle(() => {\n 'worklet'\n const { end, scale, size, start } = geometry.get()\n const progress = grow.get()\n\n // The whole style is the animation's, so the view takes the one object it\n // hands back.\n return {\n backgroundColor: pressedColor,\n borderRadius: size / 2,\n height: size,\n left: 0,\n opacity: fade.get(),\n position: 'absolute',\n top: 0,\n transform: [\n { translateX: start.x + (end.x - start.x) * progress },\n { translateY: start.y + (end.y - start.y) * progress },\n { scale: 1 + (scale - 1) * progress },\n ],\n width: size,\n }\n })\n\n // Grows a disc a fifth of the control's longer side from the press point\n // to the centre, until it covers the control and `spacing.sm` beyond its\n // corners, as web's does.\n function ripple(width: number, height: number, origin: Point) {\n const size = Math.max(\n 1,\n Math.floor(Math.max(width, height) * INITIAL_ORIGIN_SCALE),\n )\n\n geometry.set({\n end: { x: (width - size) / 2, y: (height - size) / 2 },\n scale: (Math.hypot(width, height) + spacing.sm) / size,\n size,\n start: { x: origin.x - size / 2, y: origin.y - size / 2 },\n })\n grow.set(0)\n grow.set(\n withTiming(1, {\n duration: motion.durationLong1,\n easing: Easing.bezier(...motion.easingStandard),\n }),\n )\n fade.set(\n withTiming(stateLayerOpacity.pressed, {\n duration: FADE_IN,\n easing: Easing.linear,\n }),\n )\n pressStarted.current = Date.now()\n }\n\n // Fades the ripple out, once it has been shown for `durationMedium1`.\n function release() {\n const shown = Date.now() - pressStarted.current\n\n fade.set(\n withDelay(\n Math.max(0, motion.durationMedium1 - shown),\n withTiming(0, { duration: FADE_OUT, easing: Easing.linear }),\n ),\n )\n }\n\n const handlers: PressFeedback['handlers'] = {\n onBlur: (event) => {\n focused.current = false\n setRingShown(false)\n onBlur?.(event)\n },\n onFocus: (event) => {\n focused.current = true\n setRingShown(!pressedUnfocused.current)\n pressedUnfocused.current = false\n onFocus?.(event)\n },\n onHoverIn: (event) => {\n setHovered(true)\n onHoverIn?.(event)\n },\n onHoverOut: (event) => {\n setHovered(false)\n onHoverOut?.(event)\n },\n onPressIn: (event) => {\n pressedUnfocused.current = !focused.current\n setPressed(true)\n\n if (rippled && disc !== undefined) {\n ripple(disc, disc, { x: disc / 2, y: disc / 2 })\n phase.current = 'shown'\n } else if (rippled && typeof event.currentTarget !== 'number') {\n const { pageX, pageY } = event.nativeEvent\n\n // A touch's own location is measured from whichever child it landed\n // on, so the point is taken from the page and the control measured\n // there. A press from a key carries no point, and ripples from the\n // centre. React Native Web measures a frame later, so a press can end\n // first, and its ripple is then drawn whole. React Native types the\n // target as a bare view tag too, which has nothing to measure.\n phase.current = 'measuring'\n event.currentTarget.measure((_x, _y, width, height, left, top) => {\n ripple(width, height, {\n x: Number.isFinite(pageX - left) ? pageX - left : width / 2,\n y: Number.isFinite(pageY - top) ? pageY - top : height / 2,\n })\n\n if (phase.current === 'released') {\n release()\n phase.current = 'idle'\n } else {\n phase.current = 'shown'\n }\n })\n }\n\n onPressIn?.(event)\n },\n onPressOut: (event) => {\n pressedUnfocused.current = false\n setPressed(false)\n\n if (phase.current === 'shown') {\n release()\n }\n phase.current = phase.current === 'measuring' ? 'released' : 'idle'\n\n onPressOut?.(event)\n },\n }\n\n const layerOpacity = !active\n ? 0\n : interactive && pressed\n ? stateLayerOpacity.pressed\n : ringShown\n ? stateLayerOpacity.focus\n : interactive && hovered\n ? stateLayerOpacity.hover\n : 0\n const surface = composeStyles<ViewStyle>(styles.surface, corners)\n const state = composeStyles<ViewStyle>(styles.layer, {\n backgroundColor: interactive && pressed ? pressedColor : color,\n opacity: layerOpacity,\n })\n\n return {\n handlers,\n hovered: interactive && hovered,\n layer: (\n <View\n accessibilityElementsHidden\n importantForAccessibility=\"no-hide-descendants\"\n style={surface}\n >\n <View style={state} />\n {rippled ? <Animated.View style={rippleMotion} /> : null}\n </View>\n ),\n pressed: interactive && pressed,\n ring: active && ringShown ? stylesOf(theme).ring : undefined,\n }\n}\n\nexport { hitSlop, TARGET_SIZE, usePressFeedback }\nexport type { Corners, PressFeedback, PressFeedbackOptions }\n"],"mappings":";;;;;;;;AAoHA,MAAM+C,uBAAuB;AAO7B,MAAMC,UAAU;AAChB,MAAMC,WAAW;AAEjB,MAAMC,YAA4B;CAChCT,KAAK;EAAEnB,GAAG;EAAGC,GAAG;CAAE;CAClBmB,OAAO;CACPC,MAAM;CACNC,OAAO;EAAEtB,GAAG;EAAGC,GAAG;CAAE;AACtB;;;;;;;AAQA,SAAS4B,QAAQC,QAAgBC,QAAAA,IAAyC;CACxE,MAAMC,WAAWC,KAAKC,IAAI,IAAA,KAAkBJ,UAAU,CAAC;CACvD,MAAMK,aAAaF,KAAKC,IAAI,IAAA,KAAkBH,SAAS,C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AAAgG,MAAArE,eAAA9D;CAAsB,IAAAoI;CAAA,IAAAjG,EAAA,QAAA0B,UAAA1B,EAAA,QAAAc,aAAAd,EAAA,QAAAU,OAAA;EACzBuF,MAAAvE,UAAAZ,YAAsB9D,SAAS0D,KAAK,CAAC,CAAA5C,OAArC2B,KAAAA;EAAsDO,EAAA,MAAA0B;EAAA1B,EAAA,MAAAc;EAAAd,EAAA,MAAAU;EAAAV,EAAA,MAAAiG;CAAA,OAAAA,MAAAjG,EAAA;CAAA,IAAAkG;CAAA,IAAAlG,EAAA,QAAAxC,YAAAwC,EAAA,QAAA4F,OAAA5F,EAAA,QAAA+F,OAAA/F,EAAA,QAAAgG,OAAAhG,EAAA,QAAAiG,KAAA;EAdvDC,MAAA;GAAA1I;GAAAG,SAEIiI;GAAsBhI,OAE7BmI;GAOOlI,SAEAmI;GAAsBlI,MACzBmI;EACR;EAACjG,EAAA,MAAAxC;EAAAwC,EAAA,MAAA4F;EAAA5F,EAAA,MAAA+F;EAAA/F,EAAA,MAAAgG;EAAAhG,EAAA,MAAAiG;EAAAjG,EAAA,MAAAkG;CAAA,OAAAA,MAAAlG,EAAA;CAAA,OAfMkG;AAeN"}
1
+ {"version":3,"file":"index.js","names":["ReactNode","Insets","PressableProps","ViewStyle","useRef","useState","View","Animated","Easing","useAnimatedStyle","useReducedMotion","useSharedValue","withDelay","withTiming","useTheme","composeStyles","styles","stylesOf","Corners","Pick","Handlers","Point","x","y","PressFeedback","handlers","NonNullable","Name","hovered","layer","pressed","ring","PressFeedbackOptions","area","Size","color","corners","disabled","disableRipple","disc","pending","pressedColor","RippleGeometry","end","scale","size","start","RipplePhase","height","width","TARGET_SIZE","INITIAL_ORIGIN_SCALE","FADE_IN","FADE_OUT","NO_RIPPLE","hitSlop","vertical","Math","max","horizontal","undefined","bottom","left","right","top","usePressFeedback","t0","$","_c","t1","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","t2","theme","reduceMotion","setHovered","setPressed","ringShown","setRingShown","focused","pressedUnfocused","pressStarted","phase","geometry","grow","fade","motion","spacing","stateLayerOpacity","active","interactive","rippled","rippleMotion","get","progress","backgroundColor","borderRadius","opacity","position","transform","translateX","translateY","t3","ripple","origin","size_0","floor","set","hypot","sm","duration","durationLong1","easing","bezier","easingStandard","linear","current","Date","now","t4","release","shown","durationMedium1","t5","event","t6","event_0","t7","event_1","t8","event_2","t9","event_3","fixed","currentTarget","pageX","pageY","nativeEvent","measure","_x","_y","width_0","height_0","Number","isFinite","t10","event_4","t11","layerOpacity","focus","hover","t12","surface","t13","t14","state","t15","t16","t17","t18","t19","t20","t21","_c"],"sources":["../../src/press/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Insets, PressableProps, ViewStyle } from 'react-native'\n\nimport { useRef, useState } from 'react'\nimport { View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated'\n\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { styles, stylesOf } from './styles'\n\n/** The corners a control is drawn with, which its feedback clips to. */\ntype Corners = Pick<\n ViewStyle,\n | 'borderBottomEndRadius'\n | 'borderBottomStartRadius'\n | 'borderRadius'\n | 'borderTopEndRadius'\n | 'borderTopStartRadius'\n>\n\n/** The handlers the feedback reads its states from. */\ntype Handlers = Pick<\n PressableProps,\n 'onBlur' | 'onFocus' | 'onHoverIn' | 'onHoverOut' | 'onPressIn' | 'onPressOut'\n>\n\ntype Point = { readonly x: number; readonly y: number }\n\ntype PressFeedback = {\n /**\n * The handlers to hand the control's `Pressable`. Each calls the one of\n * the same name it was given after its own.\n */\n readonly handlers: {\n readonly [Name in keyof Handlers]-?: NonNullable<Handlers[Name]>\n }\n /**\n * Whether a pointer is over the control, for a control that draws more\n * than the layer while hovered. Never while disabled or pending.\n */\n readonly hovered: boolean\n /** The state layer and the ripple, to render as the `Pressable`'s first child. */\n readonly layer: ReactNode\n /**\n * Whether the control is pressed, for a control that draws more than the\n * layer while pressed. Never while disabled or pending.\n */\n readonly pressed: boolean\n /** The focus ring while it shows, to compose into the control's style. */\n readonly ring: undefined | ViewStyle\n}\n\ntype PressFeedbackOptions = Handlers & {\n /**\n * The size of a layer drawn on a part of the control rather than across\n * it, as a navigation destination draws its layer on the indicator behind\n * its icon. The ripple then grows from that part's centre wherever the\n * press lands, and nothing is measured, as for `disc`.\n */\n readonly area?: Size | undefined\n /**\n * The colour the layer and the ripple are drawn in: the theme's value for\n * the control's content colour role.\n */\n readonly color: string\n /** The control's corners, which the layer and the ripple clip to. */\n readonly corners?: Corners | undefined\n readonly disabled?: boolean | null | undefined\n /**\n * Draws no ripple and leaves the state layer, as `disableRipple` does on\n * web's Button.\n */\n readonly disableRipple?: boolean | undefined\n /**\n * The side of a round layer of a fixed size, for a control whose state\n * layer is a disc beside its label rather than the whole control: a\n * checkbox's. The ripple then grows from the disc's centre wherever the\n * press lands, and nothing is measured. Left out, the ripple grows from\n * the press point across the control.\n */\n readonly disc?: number | undefined\n /**\n * Takes no press or hover while true, with no layer and no ripple for\n * either, and keeps the focus and its ring, as a pending button does.\n */\n readonly pending?: boolean | undefined\n /**\n * The colour the pressed layer and the ripple are drawn in, where it\n * differs from the hover and focus layers': a checkbox's swaps between\n * primary and on surface once pressed. Defaults to `color`.\n */\n readonly pressedColor?: string | undefined\n}\n\n/** Where the ripple starts and ends, and how far it grows, for one press. */\ntype RippleGeometry = {\n readonly end: Point\n readonly scale: number\n readonly size: number\n readonly start: Point\n}\n\n// Where the ripple of the latest press is: waiting on the control's\n// measurement, shown, or released before the measurement arrived.\ntype RipplePhase = 'idle' | 'measuring' | 'released' | 'shown'\n\ntype Size = { readonly height: number; readonly width: number }\n\n/**\n * The least a touch target measures each way, from Material Design's\n * accessibility guidance. A floor rather than a token, as web's `TARGET_SIZE`\n * is: a theme changes how big a control is drawn, never how small a target\n * may be.\n */\nconst TARGET_SIZE = 48\n\n// The ripple starts as a disc a fifth of the control's longer side, as on web.\nconst INITIAL_ORIGIN_SCALE = 0.2\n\n// The fade, in milliseconds: quick in and slow out, so a tap reads as a ripple\n// rather than a flicker. These are web's, and deliberately not motion tokens:\n// the two are tuned as a ratio to each other, which snapping either to the\n// scale would undo. Linear for the same reason, since a fade to and from a\n// state layer wants no acceleration.\nconst FADE_IN = 105\nconst FADE_OUT = 375\n\nconst NO_RIPPLE: RippleGeometry = {\n end: { x: 0, y: 0 },\n scale: 1,\n size: 0,\n start: { x: 0, y: 0 },\n}\n\n/**\n * The `hitSlop` that brings a control smaller than 48dp up to a 48dp target,\n * centred on it, as web's controls draw their target with a `::before`.\n * Nothing for a control already that big. A width left out is taken to be\n * wide enough, as a labelled button's is.\n */\nfunction hitSlop(height: number, width = TARGET_SIZE): Insets | undefined {\n const vertical = Math.max(0, (TARGET_SIZE - height) / 2)\n const horizontal = Math.max(0, (TARGET_SIZE - width) / 2)\n\n if (vertical === 0 && horizontal === 0) {\n return undefined\n }\n\n return {\n bottom: vertical,\n left: horizontal,\n right: horizontal,\n top: vertical,\n }\n}\n\n/**\n * The press feedback every interactive control draws: the state layer, the\n * ripple and the focus ring, as Material Design's state layers page sets them\n * out.\n *\n * The state layer is the control's content colour at the state's opacity\n * token, over the whole control: hover for an iPad pointer or an Android\n * mouse, focus while the ring shows, pressed while pressed. React Native has\n * no `color-mix()`, so it is a view of its own rather than a blended\n * background.\n *\n * The ripple grows from the press point to cover the control and fades out\n * once the press ends, held at least `durationMedium1` so a tap reads, and is\n * drawn the same on iOS and Android rather than through Android's own\n * `android_ripple`. It is a solid disc where web's has a soft edge, since\n * React Native draws a gradient only through an experimental style that React\n * Native Web ignores. It is not drawn while the device asks for reduced\n * motion, where the pressed layer alone marks the press.\n *\n * A control whose layer is a disc of its own beside its label, as a\n * checkbox's is, passes the disc's side as `disc`, and its ripple grows from\n * the disc's centre instead. One whose layer is drawn on a part of it of a\n * fixed size passes that size as `area`, with the same effect. One whose pressed layer takes another colour\n * passes it as `pressedColor`.\n *\n * The ring shows when focus arrives from a keyboard, and not when it arrives\n * with a press, which on web is a click focusing what it presses.\n *\n * ```tsx\n * const feedback = usePressFeedback({ color: colors.onPrimary, corners, onPressIn })\n *\n * <Pressable {...feedback.handlers} style={[styles.button, feedback.ring]}>\n * {feedback.layer}\n * <Text>Label</Text>\n * </Pressable>\n * ```\n */\nfunction usePressFeedback({\n area,\n color,\n corners,\n disabled,\n disableRipple = false,\n disc,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n pending,\n pressedColor = color,\n}: PressFeedbackOptions): PressFeedback {\n const theme = useTheme()\n const reduceMotion = useReducedMotion()\n const [hovered, setHovered] = useState(false)\n const [pressed, setPressed] = useState(false)\n const [ringShown, setRingShown] = useState(false)\n const focused = useRef(false)\n // Whether the press in flight began while the control had no focus, which\n // makes the focus that follows it a pointer's.\n const pressedUnfocused = useRef(false)\n const pressStarted = useRef(0)\n const phase = useRef<RipplePhase>('idle')\n const geometry = useSharedValue(NO_RIPPLE)\n const grow = useSharedValue(0)\n const fade = useSharedValue(0)\n\n const { motion, spacing, stateLayerOpacity } = theme\n const active = disabled !== true\n const interactive = active && pending !== true\n const rippled = interactive && !disableRipple && !reduceMotion\n\n const rippleMotion = useAnimatedStyle(() => {\n 'worklet'\n const { end, scale, size, start } = geometry.get()\n const progress = grow.get()\n\n // The whole style is the animation's, so the view takes the one object it\n // hands back.\n return {\n backgroundColor: pressedColor,\n borderRadius: size / 2,\n height: size,\n left: 0,\n opacity: fade.get(),\n position: 'absolute',\n top: 0,\n transform: [\n { translateX: start.x + (end.x - start.x) * progress },\n { translateY: start.y + (end.y - start.y) * progress },\n { scale: 1 + (scale - 1) * progress },\n ],\n width: size,\n }\n })\n\n // Grows a disc a fifth of the control's longer side from the press point\n // to the centre, until it covers the control and `spacing.sm` beyond its\n // corners, as web's does.\n function ripple(width: number, height: number, origin: Point) {\n const size = Math.max(\n 1,\n Math.floor(Math.max(width, height) * INITIAL_ORIGIN_SCALE),\n )\n\n geometry.set({\n end: { x: (width - size) / 2, y: (height - size) / 2 },\n scale: (Math.hypot(width, height) + spacing.sm) / size,\n size,\n start: { x: origin.x - size / 2, y: origin.y - size / 2 },\n })\n grow.set(0)\n grow.set(\n withTiming(1, {\n duration: motion.durationLong1,\n easing: Easing.bezier(...motion.easingStandard),\n }),\n )\n fade.set(\n withTiming(stateLayerOpacity.pressed, {\n duration: FADE_IN,\n easing: Easing.linear,\n }),\n )\n pressStarted.current = Date.now()\n }\n\n // Fades the ripple out, once it has been shown for `durationMedium1`.\n function release() {\n const shown = Date.now() - pressStarted.current\n\n fade.set(\n withDelay(\n Math.max(0, motion.durationMedium1 - shown),\n withTiming(0, { duration: FADE_OUT, easing: Easing.linear }),\n ),\n )\n }\n\n const handlers: PressFeedback['handlers'] = {\n onBlur: (event) => {\n focused.current = false\n setRingShown(false)\n onBlur?.(event)\n },\n onFocus: (event) => {\n focused.current = true\n setRingShown(!pressedUnfocused.current)\n pressedUnfocused.current = false\n onFocus?.(event)\n },\n onHoverIn: (event) => {\n setHovered(true)\n onHoverIn?.(event)\n },\n onHoverOut: (event) => {\n setHovered(false)\n onHoverOut?.(event)\n },\n onPressIn: (event) => {\n pressedUnfocused.current = !focused.current\n setPressed(true)\n\n const fixed = disc === undefined ? area : { height: disc, width: disc }\n\n if (rippled && fixed !== undefined) {\n ripple(fixed.width, fixed.height, {\n x: fixed.width / 2,\n y: fixed.height / 2,\n })\n phase.current = 'shown'\n } else if (rippled && typeof event.currentTarget !== 'number') {\n const { pageX, pageY } = event.nativeEvent\n\n // A touch's own location is measured from whichever child it landed\n // on, so the point is taken from the page and the control measured\n // there. A press from a key carries no point, and ripples from the\n // centre. React Native Web measures a frame later, so a press can end\n // first, and its ripple is then drawn whole. React Native types the\n // target as a bare view tag too, which has nothing to measure.\n phase.current = 'measuring'\n event.currentTarget.measure((_x, _y, width, height, left, top) => {\n ripple(width, height, {\n x: Number.isFinite(pageX - left) ? pageX - left : width / 2,\n y: Number.isFinite(pageY - top) ? pageY - top : height / 2,\n })\n\n if (phase.current === 'released') {\n release()\n phase.current = 'idle'\n } else {\n phase.current = 'shown'\n }\n })\n }\n\n onPressIn?.(event)\n },\n onPressOut: (event) => {\n pressedUnfocused.current = false\n setPressed(false)\n\n if (phase.current === 'shown') {\n release()\n }\n phase.current = phase.current === 'measuring' ? 'released' : 'idle'\n\n onPressOut?.(event)\n },\n }\n\n const layerOpacity = !active\n ? 0\n : interactive && pressed\n ? stateLayerOpacity.pressed\n : ringShown\n ? stateLayerOpacity.focus\n : interactive && hovered\n ? stateLayerOpacity.hover\n : 0\n const surface = composeStyles<ViewStyle>(styles.surface, corners)\n const state = composeStyles<ViewStyle>(styles.layer, {\n backgroundColor: interactive && pressed ? pressedColor : color,\n opacity: layerOpacity,\n })\n\n return {\n handlers,\n hovered: interactive && hovered,\n layer: (\n <View\n accessibilityElementsHidden\n importantForAccessibility=\"no-hide-descendants\"\n style={surface}\n >\n <View style={state} />\n {rippled ? <Animated.View style={rippleMotion} /> : null}\n </View>\n ),\n pressed: interactive && pressed,\n ring: active && ringShown ? stylesOf(theme).ring : undefined,\n }\n}\n\nexport { hitSlop, TARGET_SIZE, usePressFeedback }\nexport type { Corners, PressFeedback, PressFeedbackOptions }\n"],"mappings":";;;;;;;;AA6HA,MAAMmD,uBAAuB;AAO7B,MAAMC,UAAU;AAChB,MAAMC,WAAW;AAEjB,MAAMC,YAA4B;CAChCX,KAAK;EAAErB,GAAG;EAAGC,GAAG;CAAE;CAClBqB,OAAO;CACPC,MAAM;CACNC,OAAO;EAAExB,GAAG;EAAGC,GAAG;CAAE;AACtB;;;;;;;AAQA,SAASgC,QAAQP,QAAgBC,QAAAA,IAAyC;CACxE,MAAMO,WAAWC,KAAKC,IAAI,IAAA,KAAkBV,UAAU,CAAC;CACvD,MAAMW,aAAaF,KAAKC,IAAI,IAAA,KAAkBT,SAAS,CAAC;CAExD,IAAIO,aAAa,KAAKG,eAAe,GACnC;CA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ACCC,GANE;;EAOE/F,EAAA,MAAAyF;EAAAzF,EAAA,MAAA8F;EAAA9F,EAAA,MAAA+F;EAAA/F,EAAA,MAAAgG;CAAA,OAAAA,MAAAhG,EAAA;CAEA,MAAAiG,MAAAtE,eAAAhE;CAAsB,IAAAuI;CAAA,IAAAlG,EAAA,QAAA0B,UAAA1B,EAAA,QAAAc,aAAAd,EAAA,QAAAU,OAAA;EACzBwF,MAAAxE,UAAAZ,YAAsBhE,SAAS4D,KAAK,CAAC,CAAA9C,OAArC6B,KAAAA;EAAsDO,EAAA,MAAA0B;EAAA1B,EAAA,MAAAc;EAAAd,EAAA,MAAAU;EAAAV,EAAA,MAAAkG;CAAA,OAAAA,MAAAlG,EAAA;CAAA,IAAAmG;CAAA,IAAAnG,EAAA,QAAA1C,YAAA0C,EAAA,QAAA6F,OAAA7F,EAAA,QAAAgG,OAAAhG,EAAA,QAAAiG,OAAAjG,EAAA,QAAAkG,KAAA;EAdvDC,MAAA;GAAA7I;GAAAG,SAEIoI;GAAsBnI,OAE7BsI;GAOOrI,SAEAsI;GAAsBrI,MACzBsI;EACR;EAAClG,EAAA,MAAA1C;EAAA0C,EAAA,MAAA6F;EAAA7F,EAAA,MAAAgG;EAAAhG,EAAA,MAAAiG;EAAAjG,EAAA,MAAAkG;EAAAlG,EAAA,MAAAmG;CAAA,OAAAA,MAAAnG,EAAA;CAAA,OAfMmG;AAeN"}
@@ -0,0 +1,15 @@
1
+ //#region src/ref/index.ts
2
+ /**
3
+ * A ref callback that hands its node to every ref given, a callback or an
4
+ * object alike, in the order given.
5
+ */
6
+ function refsOf(...refs) {
7
+ return (node) => {
8
+ for (const ref of refs) if (typeof ref === "function") ref(node);
9
+ else if (ref !== null && ref !== void 0) ref.current = node;
10
+ };
11
+ }
12
+ //#endregion
13
+ export { refsOf };
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Ref","refsOf","refs","T","node","ref","undefined","current"],"sources":["../../src/ref/index.ts"],"sourcesContent":["import type { Ref } from 'react'\n\n// Hands one node to several refs, for a part that keeps its node for itself\n// and also lands a call site's `ref` on it. Internal: nothing here is\n// exported from the package.\n\n/**\n * A ref callback that hands its node to every ref given, a callback or an\n * object alike, in the order given.\n */\nfunction refsOf<T>(...refs: readonly (Ref<T> | undefined)[]) {\n return (node: null | T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref !== null && ref !== undefined) {\n ref.current = node\n }\n }\n }\n}\n\nexport { refsOf }\n"],"mappings":";;;;;AAUA,SAASC,OAAU,GAAGC,MAAuC;CAC3D,QAAQE,SAAmB;EACzB,KAAK,MAAMC,OAAOH,MAChB,IAAI,OAAOG,QAAQ,YACjBA,IAAID,IAAI;OACH,IAAIC,QAAQ,QAAQA,QAAQC,KAAAA,GACjCD,IAAIE,UAAUH;CAGpB;AACF"}
@@ -0,0 +1,158 @@
1
+ import { IconStyleContext } from "../glyphs/icon-style.js";
2
+ import { useTheme } from "../theme/scope.js";
3
+ import { composeStyles } from "../theme/styles.js";
4
+ import { useTypeRole } from "../typography/roles.js";
5
+ import { rowContentColor, rowStyles, rowStylesOf } from "./styles.js";
6
+ import { c } from "react/compiler-runtime";
7
+ import { Text, View } from "react-native";
8
+ import "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ //#region src/row/index.tsx
11
+ const ICON_SIZE = 24;
12
+ /** Whether a slot was given something to draw. */
13
+ function hasContent(node) {
14
+ return node !== void 0 && node !== null && node !== false && node !== "";
15
+ }
16
+ /**
17
+ * The inside of a row: the leading slot, the headline with the lines beside
18
+ * it, and the trailing slot, each drawn only when given. The view around it
19
+ * is the caller's, ListItem's or a menu's item, and takes `rowStyleOf`; this
20
+ * is what each of them puts inside it, so a list and a menu draw the same
21
+ * row. Both slots hand an icon the row's content colour at 24dp, through
22
+ * `useIconStyle()`. Not a component of the library's own and not exported.
23
+ */
24
+ function RowContent(t0) {
25
+ const $ = c(29);
26
+ const { children, isDisabled: t1, isSelected: t2, leading, overline, supporting, trailing, variant: t3 } = t0;
27
+ const isDisabled = t1 === void 0 ? false : t1;
28
+ const isSelected = t2 === void 0 ? false : t2;
29
+ const variant = t3 === void 0 ? "list" : t3;
30
+ const theme = useTheme();
31
+ const own = rowStylesOf(theme);
32
+ const headlineRole = useTypeRole(variant === "menu" ? "labelLarge" : "bodyLarge");
33
+ const overlineRole = useTypeRole("labelSmall");
34
+ const supportingRole = useTypeRole("bodyMedium");
35
+ let t4;
36
+ if ($[0] !== isDisabled || $[1] !== isSelected || $[2] !== theme || $[3] !== variant) {
37
+ t4 = rowContentColor(theme, {
38
+ isDisabled,
39
+ isSelected,
40
+ variant
41
+ });
42
+ $[0] = isDisabled;
43
+ $[1] = isSelected;
44
+ $[2] = theme;
45
+ $[3] = variant;
46
+ $[4] = t4;
47
+ } else t4 = $[4];
48
+ const color = t4;
49
+ let t5;
50
+ if ($[5] !== color) {
51
+ t5 = {
52
+ color,
53
+ size: ICON_SIZE
54
+ };
55
+ $[5] = color;
56
+ $[6] = t5;
57
+ } else t5 = $[6];
58
+ const icons = t5;
59
+ const tone = isDisabled || isSelected ? { color } : own.muted;
60
+ const T0 = IconStyleContext;
61
+ let t6;
62
+ if ($[7] !== leading) {
63
+ t6 = hasContent(leading) ? /* @__PURE__ */ jsx(View, {
64
+ style: rowStyles.slot,
65
+ children: leading
66
+ }) : null;
67
+ $[7] = leading;
68
+ $[8] = t6;
69
+ } else t6 = $[8];
70
+ const T1 = View;
71
+ const t7 = own.main;
72
+ const t8 = hasContent(overline) ? /* @__PURE__ */ jsx(Text, {
73
+ style: composeStyles(overlineRole, tone),
74
+ children: overline
75
+ }) : null;
76
+ let t9;
77
+ if ($[9] !== color || $[10] !== headlineRole) {
78
+ t9 = composeStyles(headlineRole, { color });
79
+ $[9] = color;
80
+ $[10] = headlineRole;
81
+ $[11] = t9;
82
+ } else t9 = $[11];
83
+ let t10;
84
+ if ($[12] !== children || $[13] !== t9) {
85
+ t10 = /* @__PURE__ */ jsx(Text, {
86
+ style: t9,
87
+ children
88
+ });
89
+ $[12] = children;
90
+ $[13] = t9;
91
+ $[14] = t10;
92
+ } else t10 = $[14];
93
+ const t11 = hasContent(supporting) ? /* @__PURE__ */ jsx(Text, {
94
+ style: composeStyles(supportingRole, tone),
95
+ children: supporting
96
+ }) : null;
97
+ let t12;
98
+ if ($[15] !== T1 || $[16] !== own || $[17] !== t10 || $[18] !== t11 || $[19] !== t8) {
99
+ t12 = /* @__PURE__ */ jsxs(T1, {
100
+ style: t7,
101
+ children: [
102
+ t8,
103
+ t10,
104
+ t11
105
+ ]
106
+ });
107
+ $[15] = T1;
108
+ $[16] = own;
109
+ $[17] = t10;
110
+ $[18] = t11;
111
+ $[19] = t8;
112
+ $[20] = t12;
113
+ } else t12 = $[20];
114
+ let t13;
115
+ if ($[21] !== trailing) {
116
+ t13 = hasContent(trailing) ? /* @__PURE__ */ jsx(View, {
117
+ style: rowStyles.slot,
118
+ children: trailing
119
+ }) : null;
120
+ $[21] = trailing;
121
+ $[22] = t13;
122
+ } else t13 = $[22];
123
+ let t14;
124
+ if ($[23] !== T0 || $[24] !== icons || $[25] !== t12 || $[26] !== t13 || $[27] !== t6) {
125
+ t14 = /* @__PURE__ */ jsxs(T0, {
126
+ value: icons,
127
+ children: [
128
+ t6,
129
+ t12,
130
+ t13
131
+ ]
132
+ });
133
+ $[23] = T0;
134
+ $[24] = icons;
135
+ $[25] = t12;
136
+ $[26] = t13;
137
+ $[27] = t6;
138
+ $[28] = t14;
139
+ } else t14 = $[28];
140
+ return t14;
141
+ }
142
+ /**
143
+ * The style of the view around a row's content: the padding and gap, the
144
+ * variant's height, the taller item its lines make it, and the selected
145
+ * container. Which of the lists page's three items a row is comes from its
146
+ * content rather than a prop, so a row holding all three lines already says
147
+ * it is the three-line item. A line that wraps grows the shorter item and
148
+ * keeps its slots centred.
149
+ */
150
+ function rowStyleOf(theme, { isSelected = false, overline, supporting, variant = "list" }) {
151
+ const own = rowStylesOf(theme);
152
+ const lines = (hasContent(overline) ? 1 : 0) + (hasContent(supporting) ? 1 : 0);
153
+ return composeStyles(own.base, own[variant], lines === 1 ? own.twoLine : void 0, lines === 2 ? own.threeLine : void 0, isSelected ? own[variant === "menu" ? "selectedMenu" : "selectedList"] : void 0);
154
+ }
155
+ //#endregion
156
+ export { RowContent, hasContent, rowContentColor, rowStyleOf, rowStyles };
157
+
158
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ReactNode","StyleProp","TextStyle","ViewStyle","useMemo","Text","NativeText","View","IconStyle","ResolvedTheme","RowVariant","IconStyleContext","useTheme","composeStyles","useTypeRole","rowContentColor","rowStyles","rowStylesOf","ICON_SIZE","RowContentProps","children","isDisabled","isSelected","leading","overline","supporting","trailing","variant","hasContent","node","undefined","RowContent","t0","$","_c","t1","t2","t3","theme","own","headlineRole","overlineRole","supportingRole","t4","color","t5","size","icons","tone","muted","T0","t6","slot","T1","t7","main","t8","t9","t10","t11","t12","t13","t14","rowStyleOf","Pick","lines","base","twoLine","threeLine","_c","NativeText"],"sources":["../../src/row/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { StyleProp, TextStyle, ViewStyle } from 'react-native'\n\nimport { useMemo } from 'react'\nimport { Text as NativeText, View } from 'react-native'\n\nimport type { IconStyle } from '../glyphs/icon-style'\nimport type { ResolvedTheme } from '../theme/scope'\nimport type { RowVariant } from './styles'\n\nimport { IconStyleContext } from '../glyphs/icon-style'\nimport { useTheme } from '../theme/scope'\nimport { composeStyles } from '../theme/styles'\nimport { useTypeRole } from '../typography/roles'\nimport { rowContentColor, rowStyles, rowStylesOf } from './styles'\n\n// The size an icon in either slot is drawn at, the lists and menus pages'.\nconst ICON_SIZE = 24\n\ntype RowContentProps = {\n /** The row's headline, the one thing it is mostly about. */\n readonly children?: ReactNode\n /**\n * Whether the row is disabled. Its headline, slots and lines take the\n * faded on-surface colour, the supporting line included.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Whether the row is selected. Its headline, slots and lines take the\n * selected container's own on-colour, since the muted role is not\n * guaranteed to be readable over it.\n * @default false\n */\n readonly isSelected?: boolean\n /** Content before the headline: an avatar, an icon, a checkbox. */\n readonly leading?: ReactNode\n /** A line above the headline, in label small and the muted role. */\n readonly overline?: ReactNode\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 * Which spec page's row this is. A list item's headline is body large and\n * a menu item's label large.\n * @default 'list'\n */\n readonly variant?: RowVariant\n}\n\n/** Whether a slot was given something to draw. */\nfunction hasContent(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== ''\n}\n\n/**\n * The inside of a row: the leading slot, the headline with the lines beside\n * it, and the trailing slot, each drawn only when given. The view around it\n * is the caller's, ListItem's or a menu's item, and takes `rowStyleOf`; this\n * is what each of them puts inside it, so a list and a menu draw the same\n * row. Both slots hand an icon the row's content colour at 24dp, through\n * `useIconStyle()`. Not a component of the library's own and not exported.\n */\nfunction RowContent({\n children,\n isDisabled = false,\n isSelected = false,\n leading,\n overline,\n supporting,\n trailing,\n variant = 'list',\n}: RowContentProps) {\n const theme = useTheme()\n const own = rowStylesOf(theme)\n const headlineRole = useTypeRole(\n variant === 'menu' ? 'labelLarge' : 'bodyLarge',\n )\n const overlineRole = useTypeRole('labelSmall')\n const supportingRole = useTypeRole('bodyMedium')\n const color = rowContentColor(theme, { isDisabled, isSelected, variant })\n const icons = useMemo<IconStyle>(() => ({ color, size: ICON_SIZE }), [color])\n // The muted role on the surface; the row's own colour over a selected\n // container, and on a disabled row, which fades the lines with the rest.\n const tone = isDisabled || isSelected ? { color } : own.muted\n\n return (\n <IconStyleContext value={icons}>\n {hasContent(leading) ? (\n <View style={rowStyles.slot}>{leading}</View>\n ) : null}\n <View style={own.main}>\n {hasContent(overline) ? (\n <NativeText style={composeStyles<TextStyle>(overlineRole, tone)}>\n {overline}\n </NativeText>\n ) : null}\n <NativeText style={composeStyles<TextStyle>(headlineRole, { color })}>\n {children}\n </NativeText>\n {hasContent(supporting) ? (\n <NativeText style={composeStyles<TextStyle>(supportingRole, tone)}>\n {supporting}\n </NativeText>\n ) : null}\n </View>\n {hasContent(trailing) ? (\n <View style={rowStyles.slot}>{trailing}</View>\n ) : null}\n </IconStyleContext>\n )\n}\n\n/**\n * The style of the view around a row's content: the padding and gap, the\n * variant's height, the taller item its lines make it, and the selected\n * container. Which of the lists page's three items a row is comes from its\n * content rather than a prop, so a row holding all three lines already says\n * it is the three-line item. A line that wraps grows the shorter item and\n * keeps its slots centred.\n */\nfunction rowStyleOf(\n theme: ResolvedTheme,\n {\n isSelected = false,\n overline,\n supporting,\n variant = 'list',\n }: Pick<\n RowContentProps,\n 'isSelected' | 'overline' | 'supporting' | 'variant'\n >,\n): StyleProp<ViewStyle> {\n const own = rowStylesOf(theme)\n const lines =\n (hasContent(overline) ? 1 : 0) + (hasContent(supporting) ? 1 : 0)\n\n return composeStyles<ViewStyle>(\n own.base,\n own[variant],\n lines === 1 ? own.twoLine : undefined,\n lines === 2 ? own.threeLine : undefined,\n isSelected\n ? own[variant === 'menu' ? 'selectedMenu' : 'selectedList']\n : undefined,\n )\n}\n\nexport type { RowContentProps, RowVariant }\n\nexport { hasContent, RowContent, rowContentColor, rowStyleOf, rowStyles }\n"],"mappings":";;;;;;;;;;AAiBA,MAAMkB,YAAY;;AAmClB,SAASU,WAAWC,MAA0B;CAC5C,OAAOA,SAASC,KAAAA,KAAaD,SAAS,QAAQA,SAAS,SAASA,SAAS;AAC3E;;;;;;;;;AAUA,SAAAE,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAAd,UAAAC,YAAAc,IAAAb,YAAAc,IAAAb,SAAAC,UAAAC,YAAAC,UAAAC,SAAAU,OAAAL;CAElB,MAAAX,aAAAc,OAAAL,KAAAA,IAAA,QAAAK;CACA,MAAAb,aAAA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EAAA,QAAAiB,MAAAjB,EAAA,QAAAc,SAAAd,EAAA,QAAA2B,OAAA3B,EAAA,QAAA4B,OAAA5B,EAAA,QAAAkB,IAAA;EArBVW,MAAA,qBAAC,IAAD;GAAyBf,OAAAA;GAAzB,UAAA;IACGI;IAGDS;IAeCC;GAnBc;;EAsBE5B,EAAA,MAAAiB;EAAAjB,EAAA,MAAAc;EAAAd,EAAA,MAAA2B;EAAA3B,EAAA,MAAA4B;EAAA5B,EAAA,MAAAkB;EAAAlB,EAAA,MAAA6B;CAAA,OAAAA,MAAA7B,EAAA;CAAA,OAtBnB6B;AAsBmB;;;;;;;;;AAYvB,SAASC,WACPzB,OACA,EACEhB,aAAa,OACbE,UACAC,YACAE,UAAU,UAKU;CACtB,MAAMY,MAAMtB,YAAYqB,KAAK;CAC7B,MAAM2B,SACHrC,WAAWJ,QAAQ,IAAI,IAAI,MAAMI,WAAWH,UAAU,IAAI,IAAI;CAEjE,OAAOZ,cACL0B,IAAI2B,MACJ3B,IAAIZ,UACJsC,UAAU,IAAI1B,IAAI4B,UAAUrC,KAAAA,GAC5BmC,UAAU,IAAI1B,IAAI6B,YAAYtC,KAAAA,GAC9BR,aACIiB,IAAIZ,YAAY,SAAS,iBAAiB,kBAC1CG,KAAAA,CACN;AACF"}
@@ -0,0 +1,51 @@
1
+ import { themedStyles } from "../theme/styles.js";
2
+ import { withOpacity } from "../theme/color.js";
3
+ import { StyleSheet } from "react-native";
4
+ //#region src/row/styles.ts
5
+ const rowStylesOf = themedStyles(({ colors, sizing, spacing }) => StyleSheet.create({
6
+ base: {
7
+ alignItems: "center",
8
+ flexDirection: "row",
9
+ gap: spacing.lg,
10
+ paddingHorizontal: spacing.lg,
11
+ paddingVertical: spacing.md
12
+ },
13
+ list: { minHeight: sizing.rowSm },
14
+ main: {
15
+ flexGrow: 1,
16
+ flexShrink: 1,
17
+ gap: spacing.xxs,
18
+ minWidth: 0
19
+ },
20
+ menu: { minHeight: sizing.rowXs },
21
+ muted: { color: colors.onSurfaceVariant },
22
+ selectedList: { backgroundColor: colors.primaryContainer },
23
+ selectedMenu: { backgroundColor: colors.tertiaryContainer },
24
+ threeLine: {
25
+ alignItems: "flex-start",
26
+ minHeight: sizing.rowLg
27
+ },
28
+ twoLine: { minHeight: sizing.rowMd }
29
+ }));
30
+ const rowStyles = StyleSheet.create({
31
+ ring: { outlineOffset: -2 },
32
+ slot: {
33
+ alignItems: "center",
34
+ flexShrink: 0,
35
+ justifyContent: "center"
36
+ }
37
+ });
38
+ /**
39
+ * The colour a row's headline, slots and feedback are drawn in: on surface,
40
+ * the selected container's own on-colour, or on surface faded to the
41
+ * disabled content opacity, which wins over the selected one.
42
+ */
43
+ function rowContentColor({ colors, stateLayerOpacity }, { isDisabled = false, isSelected = false, variant = "list" }) {
44
+ if (isDisabled) return withOpacity(colors.onSurface, stateLayerOpacity.disabledContent);
45
+ if (isSelected) return variant === "menu" ? colors.onTertiaryContainer : colors.onPrimaryContainer;
46
+ return colors.onSurface;
47
+ }
48
+ //#endregion
49
+ export { rowContentColor, rowStyles, rowStylesOf };
50
+
51
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","names":["StyleSheet","ResolvedTheme","withOpacity","themedStyles","RowVariant","rowStylesOf","colors","sizing","spacing","create","base","alignItems","flexDirection","gap","lg","paddingHorizontal","paddingVertical","md","list","minHeight","rowSm","main","flexGrow","flexShrink","xxs","minWidth","menu","rowXs","muted","color","onSurfaceVariant","selectedList","backgroundColor","primaryContainer","selectedMenu","tertiaryContainer","threeLine","rowLg","twoLine","rowMd","rowStyles","ring","outlineOffset","slot","justifyContent","rowContentColor","stateLayerOpacity","isDisabled","isSelected","variant","onSurface","disabledContent","onTertiaryContainer","onPrimaryContainer"],"sources":["../../src/row/styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\nimport type { ResolvedTheme } from '../theme/scope'\n\nimport { withOpacity } from '../theme/color'\nimport { themedStyles } from '../theme/styles'\n\n// The row every list and menu item draws, as web's src/row draws it: the\n// lists page's 16dp inline and 12dp block padding, 16dp between the slots\n// and the text, and a height per spec page and line count. Each height is a\n// `minHeight`, since the lines inside are set in type roles whose sizes are\n// tokens, and a larger OS text size grows the row rather than clipping it.\n\n/** Which spec page's row this is: the lists page's or the menus page's. */\ntype RowVariant = 'list' | 'menu'\n\nconst rowStylesOf = themedStyles(({ colors, sizing, spacing }: ResolvedTheme) =>\n StyleSheet.create({\n base: {\n alignItems: 'center',\n flexDirection: 'row',\n gap: spacing.lg,\n paddingHorizontal: spacing.lg,\n paddingVertical: spacing.md,\n },\n // The lists page's one-line item.\n list: {\n minHeight: sizing.rowSm,\n },\n // The headline and the lines beside it take what the slots leave and\n // wrap past it, so a long one never runs under the trailing slot.\n // `minWidth: 0` is for React Native Web, where a text in a row keeps\n // CSS's automatic minimum, the width of its longest word.\n main: {\n flexGrow: 1,\n flexShrink: 1,\n gap: spacing.xxs,\n minWidth: 0,\n },\n // The menus page's item.\n menu: {\n minHeight: sizing.rowXs,\n },\n muted: {\n color: colors.onSurfaceVariant,\n },\n selectedList: {\n backgroundColor: colors.primaryContainer,\n },\n selectedMenu: {\n backgroundColor: colors.tertiaryContainer,\n },\n // The three-line item, the only one whose slots move: they are held\n // level with the overline rather than centred on the three lines.\n threeLine: {\n alignItems: 'flex-start',\n minHeight: sizing.rowLg,\n },\n twoLine: {\n minHeight: sizing.rowMd,\n },\n }),\n)\n\nconst rowStyles = StyleSheet.create({\n // The focus ring, drawn inside the row as web's is, so a container that\n // clips its rows, such as a menu's surface, leaves the whole ring showing.\n ring: {\n outlineOffset: -2,\n },\n slot: {\n alignItems: 'center',\n flexShrink: 0,\n justifyContent: 'center',\n },\n})\n\n/**\n * The colour a row's headline, slots and feedback are drawn in: on surface,\n * the selected container's own on-colour, or on surface faded to the\n * disabled content opacity, which wins over the selected one.\n */\nfunction rowContentColor(\n { colors, stateLayerOpacity }: ResolvedTheme,\n {\n isDisabled = false,\n isSelected = false,\n variant = 'list',\n }: {\n readonly isDisabled?: boolean\n readonly isSelected?: boolean\n readonly variant?: RowVariant\n },\n): string {\n if (isDisabled) {\n return withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n }\n if (isSelected) {\n return variant === 'menu'\n ? colors.onTertiaryContainer\n : colors.onPrimaryContainer\n }\n return colors.onSurface\n}\n\nexport type { RowVariant }\n\nexport { rowContentColor, rowStyles, rowStylesOf }\n"],"mappings":";;;;AAgBA,MAAMK,cAAcF,cAAc,EAAEG,QAAQC,QAAQC,cAClDR,WAAWS,OAAO;CAChBC,MAAM;EACJC,YAAY;EACZC,eAAe;EACfC,KAAKL,QAAQM;EACbC,mBAAmBP,QAAQM;EAC3BE,iBAAiBR,QAAQS;CAC3B;CAEAC,MAAM,EACJC,WAAWZ,OAAOa,MACpB;CAKAC,MAAM;EACJC,UAAU;EACVC,YAAY;EACZV,KAAKL,QAAQgB;EACbC,UAAU;CACZ;CAEAC,MAAM,EACJP,WAAWZ,OAAOoB,MACpB;CACAC,OAAO,EACLC,OAAOvB,OAAOwB,iBAChB;CACAC,cAAc,EACZC,iBAAiB1B,OAAO2B,iBAC1B;CACAC,cAAc,EACZF,iBAAiB1B,OAAO6B,kBAC1B;CAGAC,WAAW;EACTzB,YAAY;EACZQ,WAAWZ,OAAO8B;CACpB;CACAC,SAAS,EACPnB,WAAWZ,OAAOgC,MACpB;AACF,CAAC,CACH;AAEA,MAAMC,YAAYxC,WAAWS,OAAO;CAGlCgC,MAAM,EACJC,eAAe,GACjB;CACAC,MAAM;EACJhC,YAAY;EACZY,YAAY;EACZqB,gBAAgB;CAClB;AACF,CAAC;;;;;;AAOD,SAASC,gBACP,EAAEvC,QAAQwC,qBACV,EACEC,aAAa,OACbC,aAAa,OACbC,UAAU,UAMJ;CACR,IAAIF,YACF,OAAO7C,YAAYI,OAAO4C,WAAWJ,kBAAkBK,eAAe;CAExE,IAAIH,YACF,OAAOC,YAAY,SACf3C,OAAO8C,sBACP9C,OAAO+C;CAEb,OAAO/C,OAAO4C;AAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanso-labs/react-native-kanso-ui",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Kanso UI's Material Design components for React Native, themed through the same --kui-* design tokens as the web library",
5
5
  "keywords": [
6
6
  "react-native",
@@ -61,8 +61,8 @@
61
61
  "@commitlint/config-conventional": "21.2.3",
62
62
  "@eslint/js": "10.0.1",
63
63
  "@jest/globals": "29.7.0",
64
- "@kanso-labs/kanso-ui": "0.43.4",
65
- "@kanso-labs/unplugin-style-dictionary": "0.10.32",
64
+ "@kanso-labs/kanso-ui": "0.43.6",
65
+ "@kanso-labs/unplugin-style-dictionary": "0.10.33",
66
66
  "@react-native/babel-preset": "0.88.0",
67
67
  "@react-native/jest-preset": "0.88.0",
68
68
  "@rolldown/plugin-babel": "0.2.4",