@hzblj/kara-components 0.17.0 → 0.18.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 (205) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/lib/module/atoms/badge/badge.android.js +5 -0
  3. package/lib/module/atoms/badge/badge.android.js.map +1 -1
  4. package/lib/module/atoms/badge/badge.ios.js +2 -0
  5. package/lib/module/atoms/badge/badge.ios.js.map +1 -1
  6. package/lib/module/atoms/button/button-tokens.js +8 -0
  7. package/lib/module/atoms/button/button-tokens.js.map +1 -1
  8. package/lib/module/atoms/button/button.android.js +43 -15
  9. package/lib/module/atoms/button/button.android.js.map +1 -1
  10. package/lib/module/atoms/button/button.ios.js +66 -10
  11. package/lib/module/atoms/button/button.ios.js.map +1 -1
  12. package/lib/module/atoms/checkbox/checkbox.android.js +5 -1
  13. package/lib/module/atoms/checkbox/checkbox.android.js.map +1 -1
  14. package/lib/module/atoms/checkbox/checkbox.ios.js +3 -1
  15. package/lib/module/atoms/checkbox/checkbox.ios.js.map +1 -1
  16. package/lib/module/atoms/color-picker/color-picker.android.js +4 -0
  17. package/lib/module/atoms/color-picker/color-picker.android.js.map +1 -1
  18. package/lib/module/atoms/color-picker/color-picker.ios.js +24 -2
  19. package/lib/module/atoms/color-picker/color-picker.ios.js.map +1 -1
  20. package/lib/module/atoms/date-picker/date-picker.android.js +85 -10
  21. package/lib/module/atoms/date-picker/date-picker.android.js.map +1 -1
  22. package/lib/module/atoms/date-picker/date-picker.ios.js +9 -7
  23. package/lib/module/atoms/date-picker/date-picker.ios.js.map +1 -1
  24. package/lib/module/atoms/divider/divider.android.js +17 -4
  25. package/lib/module/atoms/divider/divider.android.js.map +1 -1
  26. package/lib/module/atoms/divider/divider.ios.js +4 -0
  27. package/lib/module/atoms/divider/divider.ios.js.map +1 -1
  28. package/lib/module/atoms/fab/fab.android.js +64 -8
  29. package/lib/module/atoms/fab/fab.android.js.map +1 -1
  30. package/lib/module/atoms/fab/fab.ios.js +68 -12
  31. package/lib/module/atoms/fab/fab.ios.js.map +1 -1
  32. package/lib/module/atoms/icon-button/icon-button.android.js +48 -5
  33. package/lib/module/atoms/icon-button/icon-button.android.js.map +1 -1
  34. package/lib/module/atoms/icon-button/icon-button.ios.js +60 -10
  35. package/lib/module/atoms/icon-button/icon-button.ios.js.map +1 -1
  36. package/lib/module/atoms/list/list.android.js +32 -4
  37. package/lib/module/atoms/list/list.android.js.map +1 -1
  38. package/lib/module/atoms/list/list.ios.js +15 -5
  39. package/lib/module/atoms/list/list.ios.js.map +1 -1
  40. package/lib/module/atoms/progress/progress.android.js +21 -7
  41. package/lib/module/atoms/progress/progress.android.js.map +1 -1
  42. package/lib/module/atoms/progress/progress.ios.js +5 -1
  43. package/lib/module/atoms/progress/progress.ios.js.map +1 -1
  44. package/lib/module/atoms/slider/slider.android.js +16 -2
  45. package/lib/module/atoms/slider/slider.android.js.map +1 -1
  46. package/lib/module/atoms/slider/slider.ios.js +22 -2
  47. package/lib/module/atoms/slider/slider.ios.js.map +1 -1
  48. package/lib/module/atoms/switch/switch.android.js +5 -1
  49. package/lib/module/atoms/switch/switch.android.js.map +1 -1
  50. package/lib/module/atoms/switch/switch.ios.js +3 -1
  51. package/lib/module/atoms/switch/switch.ios.js.map +1 -1
  52. package/lib/module/atoms/text/spans.js +2 -1
  53. package/lib/module/atoms/text/spans.js.map +1 -1
  54. package/lib/module/atoms/text/text.android.js +18 -6
  55. package/lib/module/atoms/text/text.android.js.map +1 -1
  56. package/lib/module/atoms/text/text.ios.js +6 -2
  57. package/lib/module/atoms/text/text.ios.js.map +1 -1
  58. package/lib/module/atoms/text-field/text-field-input.js +14 -0
  59. package/lib/module/atoms/text-field/text-field-input.js.map +1 -0
  60. package/lib/module/atoms/text-field/text-field.android.js +113 -6
  61. package/lib/module/atoms/text-field/text-field.android.js.map +1 -1
  62. package/lib/module/atoms/text-field/text-field.ios.js +75 -3
  63. package/lib/module/atoms/text-field/text-field.ios.js.map +1 -1
  64. package/lib/module/molecules/collapsible/collapsible.android.js +4 -3
  65. package/lib/module/molecules/collapsible/collapsible.android.js.map +1 -1
  66. package/lib/module/molecules/collapsible/collapsible.ios.js +3 -1
  67. package/lib/module/molecules/collapsible/collapsible.ios.js.map +1 -1
  68. package/lib/module/molecules/radio-group/radio-group.android.js +10 -2
  69. package/lib/module/molecules/radio-group/radio-group.android.js.map +1 -1
  70. package/lib/module/molecules/radio-group/radio-group.ios.js +6 -2
  71. package/lib/module/molecules/radio-group/radio-group.ios.js.map +1 -1
  72. package/lib/module/molecules/search-bar/search-bar.js +9 -0
  73. package/lib/module/molecules/search-bar/search-bar.js.map +1 -1
  74. package/lib/module/molecules/stepper/stepper.android.js +25 -13
  75. package/lib/module/molecules/stepper/stepper.android.js.map +1 -1
  76. package/lib/module/molecules/stepper/stepper.ios.js +12 -6
  77. package/lib/module/molecules/stepper/stepper.ios.js.map +1 -1
  78. package/lib/module/organisms/action-sheet/action-sheet.android.js +16 -8
  79. package/lib/module/organisms/action-sheet/action-sheet.android.js.map +1 -1
  80. package/lib/module/organisms/action-sheet/action-sheet.ios.js +16 -3
  81. package/lib/module/organisms/action-sheet/action-sheet.ios.js.map +1 -1
  82. package/lib/module/organisms/alert/alert.android.js +4 -3
  83. package/lib/module/organisms/alert/alert.android.js.map +1 -1
  84. package/lib/module/organisms/alert/alert.ios.js +3 -2
  85. package/lib/module/organisms/alert/alert.ios.js.map +1 -1
  86. package/lib/module/organisms/context-menu/context-menu.android.js +3 -1
  87. package/lib/module/organisms/context-menu/context-menu.android.js.map +1 -1
  88. package/lib/module/organisms/context-menu/context-menu.ios.js +1 -0
  89. package/lib/module/organisms/context-menu/context-menu.ios.js.map +1 -1
  90. package/lib/module/organisms/fab-menu/fab-menu.android.js +3 -0
  91. package/lib/module/organisms/fab-menu/fab-menu.android.js.map +1 -1
  92. package/lib/module/organisms/fab-menu/fab-menu.ios.js +3 -0
  93. package/lib/module/organisms/fab-menu/fab-menu.ios.js.map +1 -1
  94. package/lib/module/organisms/menu/menu-parts.js +20 -0
  95. package/lib/module/organisms/menu/menu-parts.js.map +1 -0
  96. package/lib/module/organisms/menu/menu.android.js +51 -19
  97. package/lib/module/organisms/menu/menu.android.js.map +1 -1
  98. package/lib/module/organisms/menu/menu.ios.js +71 -8
  99. package/lib/module/organisms/menu/menu.ios.js.map +1 -1
  100. package/lib/module/organisms/sheet/sheet.js +2 -1
  101. package/lib/module/organisms/sheet/sheet.js.map +1 -1
  102. package/lib/typescript/atoms/badge/badge.types.d.ts +2 -0
  103. package/lib/typescript/atoms/button/button-tokens.d.ts +6 -2
  104. package/lib/typescript/atoms/button/button.types.d.ts +19 -5
  105. package/lib/typescript/atoms/checkbox/checkbox.types.d.ts +2 -0
  106. package/lib/typescript/atoms/color-picker/color-picker.types.d.ts +2 -0
  107. package/lib/typescript/atoms/date-picker/date-picker.ios.d.ts +5 -5
  108. package/lib/typescript/atoms/date-picker/date-picker.types.d.ts +30 -7
  109. package/lib/typescript/atoms/divider/divider.ios.d.ts +4 -0
  110. package/lib/typescript/atoms/divider/divider.types.d.ts +13 -2
  111. package/lib/typescript/atoms/fab/fab.types.d.ts +21 -4
  112. package/lib/typescript/atoms/icon-button/icon-button.types.d.ts +23 -4
  113. package/lib/typescript/atoms/list/list.types.d.ts +15 -1
  114. package/lib/typescript/atoms/progress/progress.types.d.ts +13 -2
  115. package/lib/typescript/atoms/slider/slider.ios.d.ts +4 -0
  116. package/lib/typescript/atoms/slider/slider.types.d.ts +7 -0
  117. package/lib/typescript/atoms/switch/switch.types.d.ts +2 -0
  118. package/lib/typescript/atoms/text/spans.d.ts +2 -0
  119. package/lib/typescript/atoms/text/text.types.d.ts +9 -1
  120. package/lib/typescript/atoms/text-field/text-field-input.d.ts +7 -0
  121. package/lib/typescript/atoms/text-field/text-field.types.d.ts +77 -4
  122. package/lib/typescript/molecules/collapsible/collapsible.types.d.ts +2 -0
  123. package/lib/typescript/molecules/radio-group/radio-group.types.d.ts +4 -0
  124. package/lib/typescript/molecules/search-bar/search-bar.types.d.ts +11 -1
  125. package/lib/typescript/molecules/stepper/stepper.ios.d.ts +2 -1
  126. package/lib/typescript/molecules/stepper/stepper.types.d.ts +17 -0
  127. package/lib/typescript/organisms/action-sheet/action-sheet.ios.d.ts +4 -0
  128. package/lib/typescript/organisms/action-sheet/action-sheet.types.d.ts +8 -3
  129. package/lib/typescript/organisms/alert/alert.types.d.ts +8 -3
  130. package/lib/typescript/organisms/menu/menu-parts.d.ts +14 -0
  131. package/lib/typescript/organisms/menu/menu.types.d.ts +35 -7
  132. package/lib/typescript/organisms/sheet/sheet.types.d.ts +7 -1
  133. package/package.json +4 -4
  134. package/src/atoms/badge/badge.android.tsx +9 -2
  135. package/src/atoms/badge/badge.ios.tsx +2 -2
  136. package/src/atoms/badge/badge.types.ts +2 -0
  137. package/src/atoms/button/button-tokens.ts +6 -3
  138. package/src/atoms/button/button.android.tsx +35 -11
  139. package/src/atoms/button/button.ios.tsx +72 -8
  140. package/src/atoms/button/button.types.ts +20 -5
  141. package/src/atoms/checkbox/checkbox.android.tsx +5 -2
  142. package/src/atoms/checkbox/checkbox.ios.tsx +2 -2
  143. package/src/atoms/checkbox/checkbox.types.ts +2 -0
  144. package/src/atoms/color-picker/color-picker.android.tsx +10 -2
  145. package/src/atoms/color-picker/color-picker.ios.tsx +24 -1
  146. package/src/atoms/color-picker/color-picker.types.ts +2 -0
  147. package/src/atoms/date-picker/date-picker.android.tsx +86 -16
  148. package/src/atoms/date-picker/date-picker.ios.tsx +20 -8
  149. package/src/atoms/date-picker/date-picker.types.ts +31 -7
  150. package/src/atoms/divider/divider.android.tsx +14 -3
  151. package/src/atoms/divider/divider.ios.tsx +4 -0
  152. package/src/atoms/divider/divider.types.ts +14 -2
  153. package/src/atoms/fab/fab.android.tsx +61 -11
  154. package/src/atoms/fab/fab.ios.tsx +48 -13
  155. package/src/atoms/fab/fab.types.ts +22 -4
  156. package/src/atoms/icon-button/icon-button.android.tsx +60 -10
  157. package/src/atoms/icon-button/icon-button.ios.tsx +77 -8
  158. package/src/atoms/icon-button/icon-button.types.ts +24 -4
  159. package/src/atoms/list/list.android.tsx +26 -4
  160. package/src/atoms/list/list.ios.tsx +20 -5
  161. package/src/atoms/list/list.types.ts +16 -1
  162. package/src/atoms/progress/progress.android.tsx +32 -6
  163. package/src/atoms/progress/progress.ios.tsx +11 -5
  164. package/src/atoms/progress/progress.types.ts +13 -2
  165. package/src/atoms/slider/slider.android.tsx +18 -2
  166. package/src/atoms/slider/slider.ios.tsx +38 -2
  167. package/src/atoms/slider/slider.types.ts +7 -0
  168. package/src/atoms/switch/switch.android.tsx +5 -2
  169. package/src/atoms/switch/switch.ios.tsx +2 -2
  170. package/src/atoms/switch/switch.types.ts +2 -0
  171. package/src/atoms/text/spans.ts +2 -1
  172. package/src/atoms/text/text.android.tsx +20 -7
  173. package/src/atoms/text/text.ios.tsx +7 -0
  174. package/src/atoms/text/text.types.ts +10 -1
  175. package/src/atoms/text-field/text-field-input.ts +17 -0
  176. package/src/atoms/text-field/text-field.android.tsx +132 -9
  177. package/src/atoms/text-field/text-field.ios.tsx +110 -6
  178. package/src/atoms/text-field/text-field.types.ts +98 -4
  179. package/src/molecules/collapsible/collapsible.android.tsx +10 -2
  180. package/src/molecules/collapsible/collapsible.ios.tsx +8 -2
  181. package/src/molecules/collapsible/collapsible.types.ts +2 -0
  182. package/src/molecules/radio-group/radio-group.android.tsx +18 -4
  183. package/src/molecules/radio-group/radio-group.ios.tsx +19 -5
  184. package/src/molecules/radio-group/radio-group.types.ts +4 -0
  185. package/src/molecules/search-bar/search-bar.tsx +9 -0
  186. package/src/molecules/search-bar/search-bar.types.ts +12 -1
  187. package/src/molecules/stepper/stepper.android.tsx +24 -4
  188. package/src/molecules/stepper/stepper.ios.tsx +23 -8
  189. package/src/molecules/stepper/stepper.types.ts +17 -0
  190. package/src/organisms/action-sheet/action-sheet.android.tsx +23 -11
  191. package/src/organisms/action-sheet/action-sheet.ios.tsx +20 -3
  192. package/src/organisms/action-sheet/action-sheet.types.ts +8 -3
  193. package/src/organisms/alert/alert.android.tsx +11 -8
  194. package/src/organisms/alert/alert.ios.tsx +2 -1
  195. package/src/organisms/alert/alert.types.ts +8 -3
  196. package/src/organisms/context-menu/context-menu.android.tsx +3 -2
  197. package/src/organisms/context-menu/context-menu.ios.tsx +1 -0
  198. package/src/organisms/fab-menu/fab-menu.android.tsx +3 -0
  199. package/src/organisms/fab-menu/fab-menu.ios.tsx +9 -1
  200. package/src/organisms/menu/menu-parts.ts +21 -0
  201. package/src/organisms/menu/menu.android.tsx +39 -10
  202. package/src/organisms/menu/menu.ios.tsx +55 -5
  203. package/src/organisms/menu/menu.types.ts +30 -7
  204. package/src/organisms/sheet/sheet.tsx +2 -1
  205. package/src/organisms/sheet/sheet.types.ts +7 -1
@@ -1,22 +1,39 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { IconName } from '../icon';
3
+ /** Material's three floating action buttons: 40, 56 and 96 across. */
4
+ export type FabSize = 'large' | 'regular' | 'small';
3
5
  /**
4
- * A floating action button: Material's `FloatingActionButton` on Android, a 56pt accent circle (a plain SwiftUI
5
- * `Button`) on iOS. It renders inline; pinning it to a corner is up to the screen.
6
+ * A floating action button: Material's `FloatingActionButton` on Android, an accent circle (a plain SwiftUI `Button`)
7
+ * on iOS. With a `label` it is the extended one, the icon and the text side by side: Material's
8
+ * `ExtendedFloatingActionButton`, an accent capsule on iOS. It renders inline; pinning it to a corner is up to the
9
+ * screen.
6
10
  */
7
11
  export type FabProps = {
8
12
  /**
9
13
  * What VoiceOver and TalkBack say for the button, since an icon has no words of its own: "Share", "Add to
10
- * favourites". Required for that reason.
14
+ * favourites". Required for that reason. With a `label` it is still what they say, in place of the label, so give
15
+ * it the label's words (or words that start with them), and Voice Control finds the button by what it shows.
11
16
  */
12
17
  accessibilityLabel: string;
13
18
  /** What pressing it does, when the label alone does not say. See `AccessibilityProps`. */
14
19
  accessibilityHint?: string;
20
+ /**
21
+ * Text beside the icon, which makes it an extended FAB: "Compose", "New post". For a screen whose main action needs
22
+ * its words. Material's `ExtendedFloatingActionButton` on Android; on iOS the same accent, 56pt tall, as a capsule.
23
+ */
24
+ label?: string;
15
25
  /** The icon, one of the app's, drawn in `content.on.accent`. */
16
26
  name: IconName;
17
27
  /** Called when the button is pressed. */
18
28
  onPress?: () => void;
19
- /** Test identifier, forwarded to the native view on iOS. Android ignores it. */
29
+ /**
30
+ * `regular` by default, 56 across. `small` is 40, for a secondary action beside a regular one; `large` is 96, with a
31
+ * 36 icon, for a screen built around one action. Material's `SmallFloatingActionButton` and
32
+ * `LargeFloatingActionButton` on Android, the same sizes of circle on iOS. A FAB with a `label` has one size and
33
+ * ignores it.
34
+ */
35
+ size?: FabSize;
36
+ /** Test identifier, forwarded to the native view. */
20
37
  testID?: string;
21
38
  };
22
39
  export type FabComponent = (props: FabProps) => ReactNode;
@@ -1,9 +1,15 @@
1
+ import type { ColorToken } from '@hzblj/kara-theme';
1
2
  import type { ReactNode } from 'react';
2
3
  import type { IconName } from '../icon';
3
4
  /**
4
- * A button that is just an icon: a plain SwiftUI `Button` on iOS, Material's `IconButton` on Android. The icon sits
5
- * centred in a tap target the size each platform asks for, 44pt on iOS and 48dp on Android, so a row of them spaces
6
- * itself the same way on both.
5
+ * How much the button stands out: just the icon (`plain`), on a fill in the accent (`filled`), on a muted fill
6
+ * (`tonal`), in a ring (`outlined`) or on Liquid Glass (`glass`).
7
+ */
8
+ export type IconButtonVariant = 'filled' | 'glass' | 'outlined' | 'plain' | 'tonal';
9
+ /**
10
+ * A button that is just an icon: a SwiftUI `Button` on iOS, one of Material's icon buttons on Android. A `plain` one
11
+ * sits centred in a tap target the size each platform asks for, 44pt on iOS and 48dp on Android, so a row of them
12
+ * spaces itself the same way on both; the other variants draw a circle around the icon.
7
13
  */
8
14
  export type IconButtonProps = {
9
15
  /**
@@ -13,13 +19,26 @@ export type IconButtonProps = {
13
19
  accessibilityLabel: string;
14
20
  /** What pressing it does, when the label alone does not say. See `AccessibilityProps`. */
15
21
  accessibilityHint?: string;
22
+ /**
23
+ * The icon's colour, `content.primary` by default. On `filled` it is the fill instead (`fill.accent.primary` by
24
+ * default) and the icon picks a colour that reads on it, as a `Button`'s `tint` does on a prominent style. On iOS a
25
+ * `tonal` button's circle takes a pale shade of it too.
26
+ */
27
+ color?: ColorToken;
16
28
  /** Dims the icon (iOS's own disabled look, `btn.content.disabled` on Android) and stops the button responding. */
17
29
  disabled?: boolean;
18
30
  /** The icon, one of the app's. */
19
31
  name: IconName;
20
32
  /** Called when the button is pressed. */
21
33
  onPress?: () => void;
22
- /** Test identifier, forwarded to the native view on iOS. Android ignores it. */
34
+ /** Test identifier, forwarded to the native view. */
23
35
  testID?: string;
36
+ /**
37
+ * The look. `plain` by default. iOS draws the others as SwiftUI button styles in a circle: `borderedProminent` for
38
+ * `filled`, `bordered` for `tonal`, `glass` for `glass` (`bordered` below iOS 26), and `outlined` as a plain button
39
+ * in a hairline ring. Android draws Material's `IconButton`, `FilledIconButton`, `FilledTonalIconButton` and
40
+ * `OutlinedIconButton`; Material has no glass, so there `glass` is the tonal one.
41
+ */
42
+ variant?: IconButtonVariant;
24
43
  };
25
44
  export type IconButtonComponent = (props: IconButtonProps) => ReactNode;
@@ -1,4 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
+ /** How the rows are laid out: in a rounded card inset from the edges, or edge to edge. */
3
+ export type ListVariant = 'insetGrouped' | 'plain';
2
4
  /**
3
5
  * A scrolling list: SwiftUI `List`, Compose `LazyColumn`. It has no height of its own, so it needs one from outside:
4
6
  * a `Screen`, or an `Island` with `matchContents={false}` and a height. In an island that sizes itself to its content
@@ -16,7 +18,19 @@ export type ListProps = {
16
18
  * until the promise settles, so neither platform needs a `refreshing` flag kept in sync by hand.
17
19
  */
18
20
  onRefresh?: () => Promise<void>;
19
- /** Test identifier, forwarded to the native view on iOS. Android ignores it. */
21
+ /**
22
+ * Draws a line between rows. On by default. Off, iOS hides SwiftUI's row separators and Android draws no `Divider`,
23
+ * for rows that carry their own spacing (cards, media).
24
+ */
25
+ separators?: boolean;
26
+ /** Test identifier, forwarded to the native view. */
20
27
  testID?: string;
28
+ /**
29
+ * The layout. Each platform's own list by default: `insetGrouped` on iOS, `plain` on Android. `insetGrouped` sets
30
+ * the rows in a rounded card inset from the edges (SwiftUI's `insetGrouped` list style; on Android a `Card` inside the
31
+ * column, the way `Form` draws its sections). `plain` runs the rows edge to edge (SwiftUI's `plain` style; Android's
32
+ * column as it is).
33
+ */
34
+ variant?: ListVariant;
21
35
  };
22
36
  export type ListComponent = (props: ListProps) => ReactNode;
@@ -1,13 +1,24 @@
1
+ import type { ColorToken } from '@hzblj/kara-theme';
1
2
  import type { ReactNode } from 'react';
2
3
  /**
3
- * A progress bar or ring, tinted `fill.accent.primary`: SwiftUI `ProgressView` (a capacity `Gauge` for a ring with a
4
- * value, which `ProgressView` cannot draw on iOS) / Compose's `LinearProgressIndicator` and `CircularProgressIndicator`.
4
+ * A progress bar or ring, tinted `fill.accent.primary` unless `color` names another: SwiftUI `ProgressView` (a capacity
5
+ * `Gauge` for a ring with a value, which `ProgressView` cannot draw on iOS) / Compose's `LinearProgressIndicator` and
6
+ * `CircularProgressIndicator`.
5
7
  */
6
8
  export type ProgressProps = {
7
9
  /** What is in progress, for VoiceOver and TalkBack: "Uploading". They read how far along it is themselves. */
8
10
  accessibilityLabel?: string;
9
11
  /** A circular indicator instead of a bar. Off by default. */
10
12
  circular?: boolean;
13
+ /**
14
+ * Its colour: `fill.destructive.primary` for storage nearly full, `fill.success.primary` for a goal reached.
15
+ * `fill.accent.primary` by default. iOS tints the bar or ring with it. Android draws the indicator in it and, for any
16
+ * colour but the accent, the track in the same colour faded (Material's own track stays under the accent, and an
17
+ * indeterminate ring has none).
18
+ */
19
+ color?: ColorToken;
20
+ /** Test identifier, forwarded to the native view. */
21
+ testID?: string;
11
22
  /** Between `0` and `1`. Leave it unset for an indeterminate indicator. */
12
23
  value?: number;
13
24
  };
@@ -1,2 +1,6 @@
1
1
  import type { SliderComponent } from './slider.types';
2
+ /**
3
+ * SwiftUI's slider. `onValueChangeEnd` is its `onEditingChanged(false)`, with the last value the drag reported: the
4
+ * controlled `value` can still be a render behind when the finger lifts.
5
+ */
2
6
  export declare const Slider: SliderComponent;
@@ -9,8 +9,15 @@ export type SliderProps = {
9
9
  min?: number;
10
10
  /** Called with the new value as the thumb moves. */
11
11
  onValueChange?: (value: number) => void;
12
+ /**
13
+ * Called once with the final value when the user lets go of the slider: where a seek or a volume commits, rather
14
+ * than at every step of the drag.
15
+ */
16
+ onValueChangeEnd?: (value: number) => void;
12
17
  /** The increment between stops; leave it unset for a continuous slider. On Android every stop plays a `tick`. */
13
18
  step?: number;
19
+ /** Test identifier, forwarded to the native view. */
20
+ testID?: string;
14
21
  /** Between `min` and `max`. Controlled: pass back what `onValueChange` reports. */
15
22
  value: number;
16
23
  };
@@ -10,6 +10,8 @@ export type SwitchProps = {
10
10
  label?: string;
11
11
  /** Called with the new value when the user flips it. On Android a flip plays `toggleOn` / `toggleOff`. */
12
12
  onValueChange?: (value: boolean) => void;
13
+ /** Test identifier, forwarded to the native switch (on Android the switch itself, not the labelled row). */
14
+ testID?: string;
13
15
  /** Whether it is on. Controlled: pass back what `onValueChange` reports. */
14
16
  value: boolean;
15
17
  };
@@ -5,6 +5,8 @@ export type TextSpan = {
5
5
  color?: ColorToken;
6
6
  text: string;
7
7
  };
8
+ /** The string and number children, joined: the text of a `Text` without spans, however JSX split it. */
9
+ export declare const textOf: (children: ReactNode) => string;
8
10
  /**
9
11
  * The children as runs when any of them is a nested `Text` (`type`, the platform's own component), `null` when they
10
12
  * are only text. A span keeps its `color`; anything else it sets is the outer text's.
@@ -4,6 +4,8 @@ import type { ReactNode } from 'react';
4
4
  export type TextAlign = 'center' | 'left' | 'right';
5
5
  export type TextDecoration = 'none' | 'strikethrough' | 'underline';
6
6
  export type TextTransform = 'lowercase' | 'uppercase';
7
+ /** Where the ellipsis goes in a text cut short: its start, its middle or its end. */
8
+ export type TextTruncation = 'head' | 'middle' | 'tail';
7
9
  /**
8
10
  * SwiftUI `Text` / Compose `Text` in a theme typography variant. A native atom: outside a host, use `RnText`. It takes
9
11
  * the native `sx` surface too: padding, a frame (`wide` lines it up by `align`), a background, and the `ios` bucket's
@@ -29,7 +31,7 @@ export type TextProps = ResponsiveSx & AccessibilityProps & {
29
31
  color?: ColorToken;
30
32
  /** An underline or a strikethrough. */
31
33
  decoration?: TextDecoration;
32
- /** The most lines it wraps to. iOS truncates the last with an ellipsis; Android clips it. */
34
+ /** The most lines it wraps to. A text cut short ends with an ellipsis, where `truncation` puts it. */
33
35
  numberOfLines?: number;
34
36
  /**
35
37
  * Sets it in the theme's fixed-width face, at the variant's size and weight: the app's `fonts.mono`, else Menlo on
@@ -46,6 +48,12 @@ export type TextProps = ResponsiveSx & AccessibilityProps & {
46
48
  testID?: string;
47
49
  /** Upper- or lower-cases the text. Android applies it only when `children` is a plain string. */
48
50
  transform?: TextTransform;
51
+ /**
52
+ * Where the ellipsis goes in a text cut short. `tail` by default: the end of the last line. `head` keeps the end of
53
+ * the text and `middle` both of its ends, for a file name, a path or an address. Android puts it at the head or in
54
+ * the middle of a single line only (`numberOfLines={1}`), as Compose does; a longer text there ends at the tail.
55
+ */
56
+ truncation?: TextTruncation;
49
57
  /** The typography variant. `body` by default. */
50
58
  variant?: TextVariant;
51
59
  };
@@ -0,0 +1,7 @@
1
+ import type { TextFieldAutoCapitalize, TextFieldKeyboard } from './text-field.types';
2
+ /** The capitalisation asked for, else `none` for an address; `undefined` leaves the platform's own. */
3
+ export declare const capitalizationFor: (keyboard: TextFieldKeyboard, autoCapitalize: TextFieldAutoCapitalize | undefined) => TextFieldAutoCapitalize | undefined;
4
+ /** Autocorrection as asked for, else on for everything but an address. */
5
+ export declare const autoCorrectFor: (keyboard: TextFieldKeyboard, autoCorrect: boolean | undefined) => boolean;
6
+ /** A no-op for a ref call that lands after the native view has gone. */
7
+ export declare const ignoreDetachedView: () => undefined;
@@ -1,9 +1,50 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ReactNode, Ref } from 'react';
2
+ /** The keyboard a field brings up. */
3
+ export type TextFieldKeyboard = 'decimal' | 'default' | 'email' | 'number' | 'phone' | 'url';
4
+ /** When the keyboard turns Shift on by itself. */
5
+ export type TextFieldAutoCapitalize = 'characters' | 'none' | 'sentences' | 'words';
6
+ /** What the return key says. */
7
+ export type TextFieldSubmitLabel = 'done' | 'go' | 'next' | 'search' | 'send';
8
+ /**
9
+ * What a field holds, so the system can offer to fill it in: an account's email or password, a new strong password,
10
+ * the code from a text message, the user's own name, phone number or address.
11
+ */
12
+ export type TextFieldContentType = 'addressCity' | 'countryName' | 'creditCardNumber' | 'emailAddress' | 'familyName' | 'fullStreetAddress' | 'givenName' | 'name' | 'newPassword' | 'oneTimeCode' | 'password' | 'postalCode' | 'streetAddressLine1' | 'streetAddressLine2' | 'telephoneNumber' | 'username';
13
+ /** Drives a `TextField` from code, as when `onSubmit` moves on to the next field. */
14
+ export type TextFieldRef = {
15
+ /** Ends editing: the field gives up focus and the keyboard goes down. */
16
+ blur: () => void;
17
+ /** Empties the field and calls `onChangeText` with `''`. */
18
+ clear: () => void;
19
+ /** Starts editing: the field takes focus and brings up the keyboard. */
20
+ focus: () => void;
21
+ };
2
22
  /**
3
23
  * An uncontrolled text field with an optional label above it: SwiftUI `TextField` (`SecureField` when `secure`) /
4
- * Compose `OutlinedTextField`.
24
+ * Compose `OutlinedTextField`. `keyboard`, `autoCapitalize`, `autoCorrect` and `contentType` fit it to the text it
25
+ * takes; `submitLabel`, `onSubmit` and `ref` chain fields so the return key moves on to the next.
5
26
  */
6
27
  export type TextFieldProps = {
28
+ /**
29
+ * When the keyboard turns Shift on by itself: never (`none`), at the start of `sentences`, of `words`, or for all
30
+ * `characters`. Unset, it is `none` for the `email` and `url` keyboards, and otherwise each platform's own:
31
+ * `sentences` on iOS, `none` on Android.
32
+ */
33
+ autoCapitalize?: TextFieldAutoCapitalize;
34
+ /**
35
+ * Lets the keyboard correct words as they are typed and suggest the next. On unless the keyboard is `email` or
36
+ * `url`, where a correction would only break an address. A `secure` field never corrects.
37
+ */
38
+ autoCorrect?: boolean;
39
+ /** Takes focus, and brings up the keyboard, as soon as the field appears. Off by default. */
40
+ autoFocus?: boolean;
41
+ /**
42
+ * What the field holds, so the system can offer to fill it in: a saved `username` or `password` from the keychain
43
+ * or a password manager, a strong `newPassword` for a sign-up, the `oneTimeCode` from a text message, the user's own
44
+ * `emailAddress`, `name`, `telephoneNumber` or address. iOS's `textContentType`; on Android a Compose autofill
45
+ * hint, which an autofill service (Google's, a password manager) answers.
46
+ */
47
+ contentType?: TextFieldContentType;
7
48
  /** The text it starts with. Read once, on mount: the field is uncontrolled. */
8
49
  defaultValue?: string;
9
50
  /** Stops editing and dims the field. On iOS it outranks `error`. */
@@ -14,15 +55,47 @@ export type TextFieldProps = {
14
55
  * colour is a pale red in dark mode. `true` marks it without a message.
15
56
  */
16
57
  error?: boolean | string;
58
+ /**
59
+ * The keyboard it brings up. `default` by default. `email` and `url` add their `@` and `.` keys and turn
60
+ * capitals and corrections off unless `autoCapitalize` or `autoCorrect` say otherwise; `number` is a pad of digits,
61
+ * `decimal` adds the locale's decimal separator, `phone` is a dial pad. With `secure`, Android brings up its password
62
+ * keyboard (a numeric one for `number`).
63
+ */
64
+ keyboard?: TextFieldKeyboard;
17
65
  /** Shown above the field, in `labelMedium`. */
18
66
  label?: string;
67
+ /**
68
+ * The most characters it takes. What is typed past it is cut off as the user types; `defaultValue` is not. No limit
69
+ * by default.
70
+ */
71
+ maxLength?: number;
19
72
  /** Wraps the text and grows the field to fit it. iOS ignores it when `secure`. */
20
73
  multiline?: boolean;
21
- /** Called with the whole text after every change. */
74
+ /** Called with the whole text after every change, `clear()` included. */
22
75
  onChangeText?: (text: string) => void;
76
+ /** Called with `true` when the field starts editing and `false` when it stops. */
77
+ onFocusChange?: (focused: boolean) => void;
78
+ /**
79
+ * Called with the whole text when the return key is pressed. A `multiline` field never calls it: its return key
80
+ * starts a new line. Neither do iOS's `number`, `decimal` and `phone` pads, which have no return key.
81
+ */
82
+ onSubmit?: (text: string) => void;
83
+ /**
84
+ * Shown in the empty field, in the platform's placeholder colour, until the first character is typed. A hint at
85
+ * the format (`name@example.com`), not a replacement for `label`.
86
+ */
87
+ placeholder?: string;
88
+ /** `focus`, `blur` and `clear`, for moving to the next field from `onSubmit`. */
89
+ ref?: Ref<TextFieldRef>;
23
90
  /** Masks the text, for a password. */
24
91
  secure?: boolean;
25
- /** iOS: forwarded to the native field. Android ignores it. */
92
+ /**
93
+ * What the return key says. Unset, each platform's own (`return` on iOS). It names the key; what pressing it does
94
+ * is up to `onSubmit`, so a `next` focuses the following field through its `ref`. Android's `next` also moves focus
95
+ * to the next field in the same host by itself. A `multiline` field ignores it: its return key starts a new line.
96
+ */
97
+ submitLabel?: TextFieldSubmitLabel;
98
+ /** Test identifier, forwarded to the native field (not the label above it). */
26
99
  testID?: string;
27
100
  };
28
101
  export type TextFieldComponent = (props: TextFieldProps) => ReactNode;
@@ -12,5 +12,7 @@ export type CollapsibleProps = {
12
12
  label: string;
13
13
  /** The user pressed the row; it passes the state the row asks for. */
14
14
  onExpandedChange: (expanded: boolean) => void;
15
+ /** Test identifier: on SwiftUI's `DisclosureGroup` on iOS, on the pressable row on Android. */
16
+ testID?: string;
15
17
  };
16
18
  export type CollapsibleComponent = (props: CollapsibleProps) => ReactNode;
@@ -11,10 +11,14 @@ export type RadioOption = {
11
11
  * native atom: it renders inside `<Screen>` or `<Island>`.
12
12
  */
13
13
  export type RadioGroupProps = {
14
+ /** Stops the user changing the selection, and dims the options. */
15
+ disabled?: boolean;
14
16
  /** The user pressed an option; it passes that option's `value`. */
15
17
  onValueChange?: (value: string) => void;
16
18
  /** The choices, top to bottom. */
17
19
  options: RadioOption[];
20
+ /** Test identifier, on the whole group. Reach an option by its label. */
21
+ testID?: string;
18
22
  /** The selected option's `value`. Update it from `onValueChange`. */
19
23
  value: string;
20
24
  };
@@ -1,11 +1,21 @@
1
1
  import type { ReactNode } from 'react';
2
+ import type { TextFieldAutoCapitalize } from '../../atoms/text-field';
2
3
  /**
3
4
  * A search field drawn the same on both platforms: a rounded box with a magnifier, a `TextInput` and a clear button
4
- * while there is text. The React Native tier: it needs no host.
5
+ * while there is text. The keyboard's return key reads Search, and a query is taken as typed: no capitals and no
6
+ * corrections unless asked for. The React Native tier: it needs no host.
5
7
  */
6
8
  export type SearchBarProps = {
9
+ /** When the keyboard turns Shift on by itself. `none` by default: a query is not a sentence. */
10
+ autoCapitalize?: TextFieldAutoCapitalize;
11
+ /** Lets the keyboard correct words as they are typed. Off by default, so a query is searched as typed. */
12
+ autoCorrect?: boolean;
13
+ /** Takes focus, and brings up the keyboard, as soon as the field appears. Off by default. */
14
+ autoFocus?: boolean;
7
15
  /** Every edit, and `''` when the clear button is pressed. */
8
16
  onChangeText?: (text: string) => void;
17
+ /** Called with the query when the keyboard's Search key is pressed. The keyboard goes down after it. */
18
+ onSubmit?: (text: string) => void;
9
19
  /** Shown while the field is empty. `Search` by default. */
10
20
  placeholder?: string;
11
21
  /** Test identifier, put on the field's container view rather than on the `TextInput`. */
@@ -2,6 +2,7 @@ import type { StepperComponent } from './stepper.types';
2
2
  /**
3
3
  * SwiftUI's `Stepper` at the end of a row, the label leading and the value just before the control — the way iOS's own
4
4
  * settings show a stepped value. The value rolls to the next one (`numericText`), up or down with the change, in
5
- * monospaced digits so the row does not jump. With motion reduced it cross-fades instead.
5
+ * monospaced digits so the row does not jump. With motion reduced it cross-fades instead. Its buttons are labelled by
6
+ * the system, so `decrementLabel` and `incrementLabel` are Android's alone.
6
7
  */
7
8
  export declare const Stepper: StepperComponent;
@@ -4,6 +4,18 @@ import type { ReactNode } from 'react';
4
4
  * two icon buttons in a row. A native atom: it renders inside `<Screen>` or `<Island>`.
5
5
  */
6
6
  export type StepperProps = {
7
+ /**
8
+ * What TalkBack says for the minus button. `Decrement` by default: pass the app's own words, in its language.
9
+ * Android only. iOS ignores it: its native stepper labels its buttons itself, in the device's language.
10
+ */
11
+ decrementLabel?: string;
12
+ /** Stops the user changing the value, and dims the row. */
13
+ disabled?: boolean;
14
+ /**
15
+ * What TalkBack says for the plus button. `Increment` by default: pass the app's own words, in its language. Android
16
+ * only. iOS ignores it: its native stepper labels its buttons itself, in the device's language.
17
+ */
18
+ incrementLabel?: string;
7
19
  /** The leading text. The value is shown too: before the control on iOS, between the buttons on Android. */
8
20
  label: string;
9
21
  /** The highest value. When unset, Android has no upper limit and iOS stops at `100`. */
@@ -14,6 +26,11 @@ export type StepperProps = {
14
26
  onValueChange: (value: number) => void;
15
27
  /** How much one press adds or takes away. `1` by default. */
16
28
  step?: number;
29
+ /**
30
+ * Test identifier, on the control rather than the row: SwiftUI's `Stepper` on iOS, the minus and plus buttons with
31
+ * the value between them on Android. Reach a button by what screen readers say for it.
32
+ */
33
+ testID?: string;
17
34
  /** The current value. Update it from `onValueChange`. iOS's native stepper counts in whole numbers. */
18
35
  value: number;
19
36
  };
@@ -1,2 +1,6 @@
1
1
  import type { ActionSheetComponent } from './action-sheet.types';
2
+ /**
3
+ * `titleVisibility="visible"`: left to `automatic`, SwiftUI drops the title of a dialog presented as an action sheet,
4
+ * and the actions lose what they are about.
5
+ */
2
6
  export declare const ActionSheet: ActionSheetComponent;
@@ -2,14 +2,19 @@ import type { ReactNode } from 'react';
2
2
  import type { MenuAction } from '../menu';
3
3
  /**
4
4
  * A list of actions to pick one from: SwiftUI's confirmation dialog on iOS, a `Sheet` of Material rows (icon and label)
5
- * under the title on Android. A native atom: it renders inside `<Screen>` or `<Island>`.
5
+ * under the title and message on Android. A native atom: it renders inside `<Screen>` or `<Island>`.
6
6
  */
7
7
  export type ActionSheetProps = {
8
- /** The choices, top to bottom. Picking one closes the sheet. */
8
+ /** The choices, top to bottom. Picking one closes the sheet. A `disabled` one stays in the list, greyed. */
9
9
  actions: MenuAction[];
10
+ /**
11
+ * A line under the title saying what the choice is about: "The photo will be removed from all your devices." Unset,
12
+ * the title stands alone.
13
+ */
14
+ message?: string;
10
15
  /** The sheet closed (after a pick too), so turn `visible` off. */
11
16
  onDismiss: () => void;
12
- /** The heading above the actions. Android always shows it; on iOS the system decides, and may hide it. */
17
+ /** The heading above the actions, shown on both platforms. */
13
18
  title: string;
14
19
  /** Presents the sheet while true. */
15
20
  visible: boolean;
@@ -1,9 +1,14 @@
1
1
  import type { ReactNode } from 'react';
2
2
  /**
3
- * A modal alert with a confirm button and Cancel: SwiftUI's alert on iOS, Material's `AlertDialog` on Android. A native
4
- * atom: it renders inside `<Screen>` or `<Island>`.
3
+ * A modal alert with a confirm button and a cancel button (or the confirm button alone): SwiftUI's alert on iOS,
4
+ * Material's `AlertDialog` on Android. A native atom: it renders inside `<Screen>` or `<Island>`.
5
5
  */
6
6
  export type AlertProps = {
7
+ /**
8
+ * The cancel button's label, in the app's language: "Zrušit". `Cancel` by default. `null` leaves the button out, for
9
+ * an alert that only informs and is closed by its confirm button alone ("OK").
10
+ */
11
+ cancelLabel?: string | null;
7
12
  /** The confirm button's label. `OK` by default. */
8
13
  confirmLabel?: string;
9
14
  /** Marks the confirm button destructive: the system's destructive role on iOS, the destructive colour on Android. */
@@ -12,7 +17,7 @@ export type AlertProps = {
12
17
  message?: string;
13
18
  /** The confirm button was pressed. `onDismiss` follows, as it does for every way the alert closes. */
14
19
  onConfirm?: () => void;
15
- /** The alert closed (either button, or on Android a tap outside or back), so turn `visible` off. */
20
+ /** The alert closed (any of its buttons, or on Android a tap outside or back), so turn `visible` off. */
16
21
  onDismiss: () => void;
17
22
  /** The alert's heading. */
18
23
  title: string;
@@ -0,0 +1,14 @@
1
+ import type { ColorToken } from '@hzblj/kara-theme';
2
+ import type { IconName } from '../../atoms/icon';
3
+ import type { MenuAction, MenuProps } from './menu.types';
4
+ /**
5
+ * An action's colour in a row kara draws itself (the Android menus and sheets): greyed when disabled, as `IconButton`
6
+ * greys, red when destructive. A Compose `DropdownMenuItem` cannot grey its own text here, since the text sets its
7
+ * colour explicitly.
8
+ */
9
+ export declare const menuActionColor: ({ destructive, disabled }: MenuAction) => ColorToken;
10
+ /** A trigger with no text: the props' union guarantees its icon and the words a screen reader says for it. */
11
+ export declare const isIconOnly: (props: MenuProps) => props is MenuProps & {
12
+ accessibilityLabel: string;
13
+ icon: IconName;
14
+ };
@@ -8,8 +8,13 @@ export type MenuAction = {
8
8
  */
9
9
  destructive?: boolean;
10
10
  /**
11
- * One of the app's icons, before the label. `ContextMenu` and `FabMenu` show it on both platforms, `Menu` and
12
- * `ActionSheet` on Android only.
11
+ * Greys the action out and stops it responding, for one that does not apply right now: "Paste" with nothing copied.
12
+ * Off by default. `FabMenu` ignores it on Android, where Material's FAB menu items have no disabled state.
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * One of the app's icons, before the label. `Menu`, `ContextMenu` and `FabMenu` show it on both platforms,
17
+ * `ActionSheet` on Android only: an iOS confirmation dialog draws text alone.
13
18
  */
14
19
  icon?: IconName;
15
20
  /** The action's text. Rows are keyed by it, so keep labels unique within one list. */
@@ -17,14 +22,37 @@ export type MenuAction = {
17
22
  /** Called when the action is chosen; the menu closes by itself. */
18
23
  onPress: () => void;
19
24
  };
25
+ /** What the trigger needs: its text, or an icon and the words a screen reader says for it. */
26
+ type MenuTrigger = {
27
+ label: string;
28
+ } | {
29
+ accessibilityLabel: string;
30
+ icon: IconName;
31
+ };
20
32
  /**
21
- * A text button that opens a list of actions: a SwiftUI `Menu` on iOS, a Material dropdown anchored to it on Android.
22
- * A native atom: it renders inside `<Screen>` or `<Island>`.
33
+ * A button that opens a list of actions: a SwiftUI `Menu` on iOS, a Material dropdown anchored to it on Android. The
34
+ * trigger is text, an icon and text, or an icon alone. A native atom: it renders inside `<Screen>` or `<Island>`.
23
35
  */
24
- export type MenuProps = {
36
+ export type MenuProps = MenuTrigger & {
37
+ /**
38
+ * What VoiceOver and TalkBack say for the trigger: "More options". Required with an `icon` and no `label`, since an
39
+ * icon has no words of its own. With a label, it replaces the label for screen readers.
40
+ */
41
+ accessibilityLabel?: string;
25
42
  /** The menu's actions, top to bottom. */
26
43
  actions: MenuAction[];
27
- /** The trigger's text. Android draws it in the accent colour, with a chevron. */
28
- label: string;
44
+ /**
45
+ * One of the app's icons on the trigger. Before the `label`, in the same colour, when there is one; alone, the
46
+ * trigger is drawn as an `IconButton` (`content.primary`, in a 44pt target on iOS and 48dp on Android) and needs an
47
+ * `accessibilityLabel`.
48
+ */
49
+ icon?: IconName;
50
+ /**
51
+ * The trigger's text. Android draws it in the accent colour, with a chevron. Required unless there is an `icon`.
52
+ */
53
+ label?: string;
54
+ /** Test identifier, forwarded to the trigger. Reach an action by its label once the menu is open. */
55
+ testID?: string;
29
56
  };
30
57
  export type MenuComponent = (props: MenuProps) => ReactNode;
58
+ export {};
@@ -46,7 +46,7 @@ export type SheetRef = {
46
46
  * one; native atoms in its content go in an `Island`.
47
47
  */
48
48
  export type SheetProps = {
49
- /** The sheet's colour. `surface.primary` by default. */
49
+ /** The sheet's colour. `surface.primary` by default; ignored on iOS with `systemBackground`. */
50
50
  bg?: ColorToken;
51
51
  /** The content. A `<Sheet.Header>` among the direct children becomes the native header instead. */
52
52
  children: ReactNode;
@@ -75,6 +75,12 @@ export type SheetProps = {
75
75
  * and a header scrolls with the iOS 26 edge effect. Off by default; set it with a scrolling body.
76
76
  */
77
77
  scrollable?: boolean;
78
+ /**
79
+ * iOS: the system's own sheet background instead of `bg` — untinted Liquid Glass on iOS 26, a material blur before
80
+ * it — for a sheet that floats over content it should let through, like a map. Keep the content free of fills. Android
81
+ * keeps `bg`. Off by default.
82
+ */
83
+ systemBackground?: boolean;
78
84
  /** Test identifier, forwarded to the native sheet. */
79
85
  testID?: string;
80
86
  /** Presents the sheet while true; going false dismisses it. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzblj/kara-components",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "The atoms, molecules, organisms and templates of @hzblj/kara-ui — real SwiftUI and Jetpack Compose views through @expo/ui.",
5
5
  "author": "Jan Blazej",
6
6
  "license": "MIT",
@@ -61,9 +61,9 @@
61
61
  "dependencies": {
62
62
  "@hzblj/expo-native-icons": "^0.1.0",
63
63
  "@hzblj/expo-rich-haptics": "^0.1.0",
64
- "@hzblj/kara-native": "^0.17.0",
65
- "@hzblj/kara-sx": "^0.17.0",
66
- "@hzblj/kara-theme": "^0.17.0",
64
+ "@hzblj/kara-native": "^0.18.0",
65
+ "@hzblj/kara-sx": "^0.18.0",
66
+ "@hzblj/kara-theme": "^0.18.0",
67
67
  "sf-symbols-typescript": "^2.2.0"
68
68
  },
69
69
  "peerDependencies": {
@@ -1,17 +1,24 @@
1
1
  import {Badge as ComposeBadge, Text as ComposeText} from '@expo/ui/jetpack-compose'
2
+ import {testID as testIdModifier} from '@expo/ui/jetpack-compose/modifiers'
2
3
  import {useAppTheme} from '@hzblj/kara-theme'
4
+ import {useMemo} from 'react'
3
5
  import {useHostGuard} from '../../host-context'
4
6
  import type {BadgeComponent, BadgeProps} from './badge.types'
5
7
  import {BADGE_TOKENS} from './badge-tokens'
6
8
 
7
9
  /** Material's badge. Its content is a Compose `Text` — `@expo/ui`'s badge takes composable content, not a string. */
8
- export const Badge: BadgeComponent = ({label, tone = 'neutral'}: BadgeProps) => {
10
+ export const Badge: BadgeComponent = ({label, testID, tone = 'neutral'}: BadgeProps) => {
9
11
  useHostGuard('Badge')
10
12
  const theme = useAppTheme()
11
13
  const tokens = BADGE_TOKENS[tone]
14
+ const modifiers = useMemo(() => (testID ? [testIdModifier(testID)] : undefined), [testID])
12
15
 
13
16
  return (
14
- <ComposeBadge containerColor={theme.color(tokens.fill)} contentColor={theme.color(tokens.content)}>
17
+ <ComposeBadge
18
+ containerColor={theme.color(tokens.fill)}
19
+ contentColor={theme.color(tokens.content)}
20
+ modifiers={modifiers}
21
+ >
15
22
  <ComposeText color={theme.colorString(tokens.content)} style={theme.typography.captionMedium}>
16
23
  {label}
17
24
  </ComposeText>