@hzblj/kara-components 0.9.0 → 0.11.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 (281) hide show
  1. package/CHANGELOG.md +72 -28
  2. package/README.md +8 -8
  3. package/lib/module/atoms/activity-indicator/activity-indicator.android.js +6 -1
  4. package/lib/module/atoms/activity-indicator/activity-indicator.android.js.map +1 -1
  5. package/lib/module/atoms/activity-indicator/activity-indicator.ios.js +2 -0
  6. package/lib/module/atoms/activity-indicator/activity-indicator.ios.js.map +1 -1
  7. package/lib/module/atoms/avatar/avatar.js +5 -0
  8. package/lib/module/atoms/avatar/avatar.js.map +1 -1
  9. package/lib/module/atoms/button/button-tokens.js +2 -2
  10. package/lib/module/atoms/button/button-tokens.js.map +1 -1
  11. package/lib/module/atoms/button/button.android.js +6 -2
  12. package/lib/module/atoms/button/button.android.js.map +1 -1
  13. package/lib/module/atoms/button/button.ios.js +7 -2
  14. package/lib/module/atoms/button/button.ios.js.map +1 -1
  15. package/lib/module/atoms/card/card.android.js +5 -3
  16. package/lib/module/atoms/card/card.android.js.map +1 -1
  17. package/lib/module/atoms/card/card.ios.js +7 -3
  18. package/lib/module/atoms/card/card.ios.js.map +1 -1
  19. package/lib/module/atoms/checkbox/checkbox.android.js +1 -1
  20. package/lib/module/atoms/checkbox/checkbox.android.js.map +1 -1
  21. package/lib/module/atoms/color-picker/color-picker.android.js +32 -5
  22. package/lib/module/atoms/color-picker/color-picker.android.js.map +1 -1
  23. package/lib/module/atoms/fab/fab.android.js +9 -1
  24. package/lib/module/atoms/fab/fab.android.js.map +1 -1
  25. package/lib/module/atoms/fab/fab.ios.js +9 -3
  26. package/lib/module/atoms/fab/fab.ios.js.map +1 -1
  27. package/lib/module/atoms/glass-view/glass-view.android.js +1 -1
  28. package/lib/module/atoms/glass-view/glass-view.android.js.map +1 -1
  29. package/lib/module/atoms/h-stack/h-stack.ios.js +5 -3
  30. package/lib/module/atoms/h-stack/h-stack.ios.js.map +1 -1
  31. package/lib/module/atoms/icon-button/icon-button.android.js +9 -0
  32. package/lib/module/atoms/icon-button/icon-button.android.js.map +1 -1
  33. package/lib/module/atoms/icon-button/icon-button.ios.js +26 -6
  34. package/lib/module/atoms/icon-button/icon-button.ios.js.map +1 -1
  35. package/lib/module/atoms/image/image.js +4 -4
  36. package/lib/module/atoms/image/image.js.map +1 -1
  37. package/lib/module/atoms/pressable/pressable.js +52 -28
  38. package/lib/module/atoms/pressable/pressable.js.map +1 -1
  39. package/lib/module/atoms/progress/progress.android.js +7 -0
  40. package/lib/module/atoms/progress/progress.android.js.map +1 -1
  41. package/lib/module/atoms/progress/progress.ios.js +6 -1
  42. package/lib/module/atoms/progress/progress.ios.js.map +1 -1
  43. package/lib/module/atoms/segmented-control/segmented-control.android.js +1 -1
  44. package/lib/module/atoms/segmented-control/segmented-control.android.js.map +1 -1
  45. package/lib/module/atoms/segmented-control/segmented-control.ios.js +1 -1
  46. package/lib/module/atoms/segmented-control/segmented-control.ios.js.map +1 -1
  47. package/lib/module/atoms/skeleton/skeleton.js +20 -6
  48. package/lib/module/atoms/skeleton/skeleton.js.map +1 -1
  49. package/lib/module/atoms/surface/surface.android.js +5 -3
  50. package/lib/module/atoms/surface/surface.android.js.map +1 -1
  51. package/lib/module/atoms/surface/surface.ios.js +7 -3
  52. package/lib/module/atoms/surface/surface.ios.js.map +1 -1
  53. package/lib/module/atoms/switch/switch.android.js +1 -1
  54. package/lib/module/atoms/switch/switch.android.js.map +1 -1
  55. package/lib/module/atoms/text/text.android.js +5 -3
  56. package/lib/module/atoms/text/text.android.js.map +1 -1
  57. package/lib/module/atoms/text/text.ios.js +6 -4
  58. package/lib/module/atoms/text/text.ios.js.map +1 -1
  59. package/lib/module/atoms/v-stack/v-stack.ios.js +5 -3
  60. package/lib/module/atoms/v-stack/v-stack.ios.js.map +1 -1
  61. package/lib/module/atoms/z-stack/z-stack.ios.js +5 -3
  62. package/lib/module/atoms/z-stack/z-stack.ios.js.map +1 -1
  63. package/lib/module/glyph/glyph.android.js +2 -0
  64. package/lib/module/glyph/glyph.android.js.map +1 -1
  65. package/lib/module/glyph/glyph.ios.js +5 -2
  66. package/lib/module/glyph/glyph.ios.js.map +1 -1
  67. package/lib/module/molecules/collapsible/collapsible.android.js +18 -8
  68. package/lib/module/molecules/collapsible/collapsible.android.js.map +1 -1
  69. package/lib/module/molecules/labeled-content/labeled-content.js +4 -1
  70. package/lib/module/molecules/labeled-content/labeled-content.js.map +1 -1
  71. package/lib/module/molecules/link/link.js +4 -1
  72. package/lib/module/molecules/link/link.js.map +1 -1
  73. package/lib/module/molecules/list-item/list-item.js +4 -1
  74. package/lib/module/molecules/list-item/list-item.js.map +1 -1
  75. package/lib/module/molecules/navigation-bar/navigation-bar.android.js +1 -1
  76. package/lib/module/molecules/navigation-bar/navigation-bar.android.js.map +1 -1
  77. package/lib/module/molecules/navigation-bar/navigation-bar.ios.js +1 -1
  78. package/lib/module/molecules/navigation-bar/navigation-bar.ios.js.map +1 -1
  79. package/lib/module/molecules/rn-list-item/rn-list-item.js +10 -2
  80. package/lib/module/molecules/rn-list-item/rn-list-item.js.map +1 -1
  81. package/lib/module/molecules/scroll-edge-container/scroll-edge-container.android.js +3 -4
  82. package/lib/module/molecules/scroll-edge-container/scroll-edge-container.android.js.map +1 -1
  83. package/lib/module/molecules/stepper/stepper.ios.js +6 -2
  84. package/lib/module/molecules/stepper/stepper.ios.js.map +1 -1
  85. package/lib/module/motion.js +19 -0
  86. package/lib/module/motion.js.map +1 -0
  87. package/lib/module/organisms/fab-menu/fab-menu.android.js +8 -5
  88. package/lib/module/organisms/fab-menu/fab-menu.android.js.map +1 -1
  89. package/lib/module/organisms/fab-menu/fab-menu.ios.js +5 -2
  90. package/lib/module/organisms/fab-menu/fab-menu.ios.js.map +1 -1
  91. package/lib/module/organisms/snackbar/snackbar.js +142 -17
  92. package/lib/module/organisms/snackbar/snackbar.js.map +1 -1
  93. package/lib/module/organisms/swipe-actions/swipe-actions.android.js +1 -1
  94. package/lib/module/organisms/swipe-actions/swipe-actions.android.js.map +1 -1
  95. package/lib/module/use-stack-modifiers.js +10 -8
  96. package/lib/module/use-stack-modifiers.js.map +1 -1
  97. package/lib/typescript/atoms/activity-indicator/activity-indicator.types.d.ts +3 -1
  98. package/lib/typescript/atoms/avatar/avatar.types.d.ts +7 -2
  99. package/lib/typescript/atoms/badge/badge.types.d.ts +1 -1
  100. package/lib/typescript/atoms/blur-view/blur-view.types.d.ts +6 -6
  101. package/lib/typescript/atoms/button/button-tokens.d.ts +1 -1
  102. package/lib/typescript/atoms/button/button.types.d.ts +9 -7
  103. package/lib/typescript/atoms/card/card.types.d.ts +3 -3
  104. package/lib/typescript/atoms/checkbox/checkbox.types.d.ts +2 -2
  105. package/lib/typescript/atoms/chip/chip.types.d.ts +1 -1
  106. package/lib/typescript/atoms/color-picker/color-picker.types.d.ts +4 -3
  107. package/lib/typescript/atoms/date-picker/date-picker.types.d.ts +4 -4
  108. package/lib/typescript/atoms/divider/divider.types.d.ts +2 -2
  109. package/lib/typescript/atoms/fab/fab.types.d.ts +10 -3
  110. package/lib/typescript/atoms/glass-view/glass-view.types.d.ts +5 -5
  111. package/lib/typescript/atoms/h-stack/h-stack.types.d.ts +8 -5
  112. package/lib/typescript/atoms/icon/icon.types.d.ts +4 -4
  113. package/lib/typescript/atoms/icon-button/icon-button.types.d.ts +14 -3
  114. package/lib/typescript/atoms/image/image.d.ts +2 -2
  115. package/lib/typescript/atoms/island/island.types.d.ts +4 -4
  116. package/lib/typescript/atoms/list/list.types.d.ts +5 -5
  117. package/lib/typescript/atoms/picker/picker.types.d.ts +1 -1
  118. package/lib/typescript/atoms/pressable/pressable.types.d.ts +23 -7
  119. package/lib/typescript/atoms/progress/progress.types.d.ts +3 -1
  120. package/lib/typescript/atoms/rn-flat-list/rn-flat-list.types.d.ts +2 -2
  121. package/lib/typescript/atoms/rn-icon/rn-icon.types.d.ts +1 -1
  122. package/lib/typescript/atoms/rn-scroll-view/rn-scroll-view.types.d.ts +2 -2
  123. package/lib/typescript/atoms/rn-section-list/rn-section-list.types.d.ts +2 -2
  124. package/lib/typescript/atoms/rn-text/rn-text.types.d.ts +2 -2
  125. package/lib/typescript/atoms/rn-view/rn-view.types.d.ts +3 -3
  126. package/lib/typescript/atoms/scroll-view/scroll-view.types.d.ts +3 -3
  127. package/lib/typescript/atoms/segmented-control/segmented-control.types.d.ts +3 -3
  128. package/lib/typescript/atoms/skeleton/skeleton.types.d.ts +2 -1
  129. package/lib/typescript/atoms/spacer/spacer.types.d.ts +1 -1
  130. package/lib/typescript/atoms/surface/surface.types.d.ts +3 -3
  131. package/lib/typescript/atoms/switch/switch.types.d.ts +1 -1
  132. package/lib/typescript/atoms/text/text.types.d.ts +3 -3
  133. package/lib/typescript/atoms/text-field/text-field.types.d.ts +4 -4
  134. package/lib/typescript/atoms/v-stack/v-stack.types.d.ts +4 -4
  135. package/lib/typescript/atoms/z-stack/z-stack.types.d.ts +4 -4
  136. package/lib/typescript/glyph/glyph-button.types.d.ts +1 -1
  137. package/lib/typescript/glyph/glyph.types.d.ts +3 -1
  138. package/lib/typescript/molecules/collapsible/collapsible.types.d.ts +1 -1
  139. package/lib/typescript/molecules/empty-state/empty-state.types.d.ts +1 -1
  140. package/lib/typescript/molecules/label/label.types.d.ts +1 -1
  141. package/lib/typescript/molecules/labeled-content/labeled-content.types.d.ts +6 -4
  142. package/lib/typescript/molecules/link/link.types.d.ts +2 -1
  143. package/lib/typescript/molecules/list-item/list-item.types.d.ts +6 -4
  144. package/lib/typescript/molecules/navigation-bar/navigation-bar.types.d.ts +8 -8
  145. package/lib/typescript/molecules/pager/pager.types.d.ts +2 -2
  146. package/lib/typescript/molecules/radio-group/radio-group.types.d.ts +2 -2
  147. package/lib/typescript/molecules/rn-list-item/rn-list-item.types.d.ts +1 -1
  148. package/lib/typescript/molecules/rn-tooltip/rn-tooltip.types.d.ts +7 -7
  149. package/lib/typescript/molecules/scroll-edge-container/scroll-edge-container.types.d.ts +3 -3
  150. package/lib/typescript/molecules/search-bar/search-bar.types.d.ts +2 -2
  151. package/lib/typescript/molecules/stepper/stepper.ios.d.ts +1 -1
  152. package/lib/typescript/molecules/stepper/stepper.types.d.ts +2 -2
  153. package/lib/typescript/molecules/tooltip/tooltip.types.d.ts +6 -6
  154. package/lib/typescript/motion.d.ts +8 -0
  155. package/lib/typescript/organisms/action-sheet/action-sheet.types.d.ts +3 -3
  156. package/lib/typescript/organisms/alert/alert.types.d.ts +3 -3
  157. package/lib/typescript/organisms/context-menu/context-menu.types.d.ts +9 -9
  158. package/lib/typescript/organisms/fab-menu/fab-menu.types.d.ts +10 -5
  159. package/lib/typescript/organisms/form/form.types.d.ts +1 -1
  160. package/lib/typescript/organisms/menu/menu.types.d.ts +2 -2
  161. package/lib/typescript/organisms/sheet/sheet.types.d.ts +12 -12
  162. package/lib/typescript/organisms/snackbar/snackbar.types.d.ts +39 -6
  163. package/lib/typescript/organisms/swipe-actions/swipe-actions.types.d.ts +5 -5
  164. package/lib/typescript/templates/screen/screen.types.d.ts +2 -2
  165. package/lib/typescript/use-stack-modifiers.d.ts +6 -5
  166. package/package.json +4 -4
  167. package/src/atoms/activity-indicator/activity-indicator.android.tsx +7 -1
  168. package/src/atoms/activity-indicator/activity-indicator.ios.tsx +9 -1
  169. package/src/atoms/activity-indicator/activity-indicator.types.ts +3 -1
  170. package/src/atoms/avatar/avatar.tsx +5 -1
  171. package/src/atoms/avatar/avatar.types.ts +7 -2
  172. package/src/atoms/badge/badge.types.ts +1 -1
  173. package/src/atoms/blur-view/blur-view.types.ts +6 -6
  174. package/src/atoms/button/button-tokens.ts +2 -2
  175. package/src/atoms/button/button.android.tsx +5 -3
  176. package/src/atoms/button/button.ios.tsx +10 -2
  177. package/src/atoms/button/button.types.ts +9 -7
  178. package/src/atoms/card/card.android.tsx +6 -4
  179. package/src/atoms/card/card.ios.tsx +7 -3
  180. package/src/atoms/card/card.types.ts +9 -8
  181. package/src/atoms/checkbox/checkbox.android.tsx +1 -1
  182. package/src/atoms/checkbox/checkbox.types.ts +2 -2
  183. package/src/atoms/chip/chip.types.ts +1 -1
  184. package/src/atoms/color-picker/color-picker.android.tsx +26 -6
  185. package/src/atoms/color-picker/color-picker.types.ts +4 -3
  186. package/src/atoms/date-picker/date-picker.types.ts +4 -4
  187. package/src/atoms/divider/divider.types.ts +2 -2
  188. package/src/atoms/fab/fab.android.tsx +5 -3
  189. package/src/atoms/fab/fab.ios.tsx +8 -4
  190. package/src/atoms/fab/fab.types.ts +10 -3
  191. package/src/atoms/glass-view/glass-view.android.tsx +1 -1
  192. package/src/atoms/glass-view/glass-view.types.ts +5 -5
  193. package/src/atoms/h-stack/h-stack.ios.tsx +6 -4
  194. package/src/atoms/h-stack/h-stack.types.ts +18 -14
  195. package/src/atoms/icon/icon.types.ts +4 -4
  196. package/src/atoms/icon-button/icon-button.android.tsx +16 -3
  197. package/src/atoms/icon-button/icon-button.ios.tsx +24 -5
  198. package/src/atoms/icon-button/icon-button.types.ts +14 -3
  199. package/src/atoms/image/image.tsx +3 -3
  200. package/src/atoms/island/island.types.ts +4 -4
  201. package/src/atoms/list/list.types.ts +5 -5
  202. package/src/atoms/picker/picker.types.ts +1 -1
  203. package/src/atoms/pressable/pressable.tsx +50 -21
  204. package/src/atoms/pressable/pressable.types.ts +35 -17
  205. package/src/atoms/progress/progress.android.tsx +5 -3
  206. package/src/atoms/progress/progress.ios.tsx +5 -2
  207. package/src/atoms/progress/progress.types.ts +3 -1
  208. package/src/atoms/rn-flat-list/rn-flat-list.types.ts +2 -2
  209. package/src/atoms/rn-icon/rn-icon.types.ts +1 -1
  210. package/src/atoms/rn-scroll-view/rn-scroll-view.types.ts +2 -2
  211. package/src/atoms/rn-section-list/rn-section-list.types.ts +2 -2
  212. package/src/atoms/rn-text/rn-text.types.ts +2 -2
  213. package/src/atoms/rn-view/rn-view.types.ts +3 -3
  214. package/src/atoms/scroll-view/scroll-view.types.ts +3 -3
  215. package/src/atoms/segmented-control/segmented-control.android.tsx +1 -1
  216. package/src/atoms/segmented-control/segmented-control.ios.tsx +1 -1
  217. package/src/atoms/segmented-control/segmented-control.types.ts +3 -3
  218. package/src/atoms/skeleton/skeleton.tsx +18 -4
  219. package/src/atoms/skeleton/skeleton.types.ts +2 -1
  220. package/src/atoms/spacer/spacer.types.ts +1 -1
  221. package/src/atoms/surface/surface.android.tsx +6 -4
  222. package/src/atoms/surface/surface.ios.tsx +7 -3
  223. package/src/atoms/surface/surface.types.ts +11 -10
  224. package/src/atoms/switch/switch.android.tsx +1 -1
  225. package/src/atoms/switch/switch.types.ts +1 -1
  226. package/src/atoms/text/text.android.tsx +6 -4
  227. package/src/atoms/text/text.ios.tsx +6 -4
  228. package/src/atoms/text/text.types.ts +24 -23
  229. package/src/atoms/text-field/text-field.types.ts +4 -4
  230. package/src/atoms/v-stack/v-stack.ios.tsx +6 -4
  231. package/src/atoms/v-stack/v-stack.types.ts +18 -17
  232. package/src/atoms/z-stack/z-stack.ios.tsx +6 -4
  233. package/src/atoms/z-stack/z-stack.types.ts +16 -15
  234. package/src/glyph/glyph-button.types.ts +1 -1
  235. package/src/glyph/glyph.android.tsx +14 -2
  236. package/src/glyph/glyph.ios.tsx +13 -3
  237. package/src/glyph/glyph.types.ts +3 -1
  238. package/src/molecules/collapsible/collapsible.android.tsx +27 -7
  239. package/src/molecules/collapsible/collapsible.types.ts +1 -1
  240. package/src/molecules/empty-state/empty-state.types.ts +1 -1
  241. package/src/molecules/label/label.types.ts +1 -1
  242. package/src/molecules/labeled-content/labeled-content.tsx +12 -1
  243. package/src/molecules/labeled-content/labeled-content.types.ts +6 -4
  244. package/src/molecules/link/link.tsx +2 -1
  245. package/src/molecules/link/link.types.ts +2 -1
  246. package/src/molecules/list-item/list-item.tsx +20 -2
  247. package/src/molecules/list-item/list-item.types.ts +6 -4
  248. package/src/molecules/navigation-bar/navigation-bar.android.tsx +1 -1
  249. package/src/molecules/navigation-bar/navigation-bar.ios.tsx +1 -1
  250. package/src/molecules/navigation-bar/navigation-bar.types.ts +8 -8
  251. package/src/molecules/pager/pager.types.ts +2 -2
  252. package/src/molecules/radio-group/radio-group.types.ts +2 -2
  253. package/src/molecules/rn-list-item/rn-list-item.tsx +18 -3
  254. package/src/molecules/rn-list-item/rn-list-item.types.ts +1 -1
  255. package/src/molecules/rn-tooltip/rn-tooltip.types.ts +7 -7
  256. package/src/molecules/scroll-edge-container/scroll-edge-container.android.tsx +3 -2
  257. package/src/molecules/scroll-edge-container/scroll-edge-container.types.ts +3 -3
  258. package/src/molecules/search-bar/search-bar.types.ts +2 -2
  259. package/src/molecules/stepper/stepper.ios.tsx +8 -2
  260. package/src/molecules/stepper/stepper.types.ts +2 -2
  261. package/src/molecules/tooltip/tooltip.types.ts +6 -6
  262. package/src/motion.ts +13 -0
  263. package/src/organisms/action-sheet/action-sheet.types.ts +3 -3
  264. package/src/organisms/alert/alert.types.ts +3 -3
  265. package/src/organisms/context-menu/context-menu.types.ts +9 -9
  266. package/src/organisms/fab-menu/fab-menu.android.tsx +9 -5
  267. package/src/organisms/fab-menu/fab-menu.ios.tsx +6 -2
  268. package/src/organisms/fab-menu/fab-menu.types.ts +10 -5
  269. package/src/organisms/form/form.types.ts +1 -1
  270. package/src/organisms/menu/menu.types.ts +2 -2
  271. package/src/organisms/sheet/sheet.types.ts +12 -12
  272. package/src/organisms/snackbar/snackbar.tsx +143 -19
  273. package/src/organisms/snackbar/snackbar.types.ts +42 -6
  274. package/src/organisms/swipe-actions/swipe-actions.android.tsx +1 -1
  275. package/src/organisms/swipe-actions/swipe-actions.types.ts +5 -5
  276. package/src/templates/screen/screen.types.ts +2 -2
  277. package/src/use-stack-modifiers.ts +20 -7
  278. package/lib/module/platform-support.js +0 -19
  279. package/lib/module/platform-support.js.map +0 -1
  280. package/lib/typescript/platform-support.d.ts +0 -8
  281. package/src/platform-support.ts +0 -20
@@ -9,13 +9,13 @@ export type SheetDetent = 'auto' | number
9
9
 
10
10
  /**
11
11
  * `center` is iOS's own, `leading` Material's. `large` puts the title above the content in a large face, and once
12
- * that scrolls under the bar the bar's own title fades in — centred on iOS, leading on Android.
12
+ * that scrolls under the bar the bar's own title fades in (centred on iOS, leading on Android).
13
13
  */
14
14
  export type SheetTitleStyle = 'center' | 'large' | 'leading'
15
15
 
16
16
  /**
17
17
  * The sheet's header: a `NavigationBar` with the title and items, and anything else that should stay put above the
18
- * content (`children` — a segmented control, a search hint). On iOS 26 a scrollable sheet's content scrolls under it
18
+ * content (`children`: a segmented control, a search hint). On iOS 26 a scrollable sheet's content scrolls under it
19
19
  * with the system's scroll edge effect; elsewhere it sits above the content.
20
20
  */
21
21
  export type SheetHeaderProps = {
@@ -27,11 +27,11 @@ export type SheetHeaderProps = {
27
27
  leadingItems?: NavigationBarItem[]
28
28
  /** A search field in place of the title (iOS). */
29
29
  search?: NavigationBarSearch
30
- /** The title — in the bar, or above the content with a `large` `titleStyle`. */
30
+ /** The title: in the bar, or above the content with a `large` `titleStyle`. */
31
31
  title?: string
32
32
  /** `center` by default. */
33
33
  titleStyle?: SheetTitleStyle
34
- /** In screen order, toward the trailing edge — the close item, by convention. */
34
+ /** In screen order, toward the trailing edge: the close item, by convention. */
35
35
  trailingItems?: NavigationBarItem[]
36
36
  }
37
37
 
@@ -39,14 +39,14 @@ export type SheetHeaderProps = {
39
39
  export type SheetRef = {
40
40
  /** Dismisses it without calling `onDismiss`, which reports the user's dismissals only. */
41
41
  dismiss: () => Promise<void>
42
- /** Presents at a detent — the first by default. */
42
+ /** Presents at a detent, the first by default. */
43
43
  present: (detentIndex?: number) => Promise<void>
44
44
  /** Moves to another detent. */
45
45
  resize: (detentIndex: number) => Promise<void>
46
46
  }
47
47
 
48
48
  /**
49
- * A native sheet — `UISheetPresentationController` on iOS, Material's bottom sheet on Android — with an optional
49
+ * A native sheet (`UISheetPresentationController` on iOS, Material's bottom sheet on Android) with an optional
50
50
  * native header (`<Sheet.Header>` as a direct child). The React Native tier: it needs no host, and must not sit inside
51
51
  * one; native atoms in its content go in an `Island`.
52
52
  */
@@ -55,7 +55,7 @@ export type SheetProps = {
55
55
  bg?: ColorToken
56
56
  /** The content. A `<Sheet.Header>` among the direct children becomes the native header instead. */
57
57
  children: ReactNode
58
- /** Where the sheet can rest, smallest first. `['auto']` — fit the content — by default. */
58
+ /** Where the sheet can rest, smallest first. `['auto']` (fit the content) by default. */
59
59
  detents?: SheetDetent[]
60
60
  /** Dims what is behind. On by default. */
61
61
  dimmed?: boolean
@@ -67,9 +67,9 @@ export type SheetProps = {
67
67
  footer?: ReactElement
68
68
  /** The drag handle. On by default. */
69
69
  grabber?: boolean
70
- /** The user dismissed it — `visible` going false does not call this. */
70
+ /** The user dismissed it; `visible` going false does not call this. */
71
71
  onDismiss: () => void
72
- /** The sheet moved to another detent — its index in `detents`. */
72
+ /** The sheet moved to another detent: its index in `detents`. */
73
73
  onDetentChange?: (detentIndex: number) => void
74
74
  /** The sheet finished presenting. */
75
75
  onPresent?: () => void
@@ -77,7 +77,7 @@ export type SheetProps = {
77
77
  ref?: Ref<SheetRef>
78
78
  /**
79
79
  * The content is a scroll view (`<Sheet.ScrollView>`) the sheet drives: dragging past its top resizes the sheet,
80
- * and a header scrolls with the iOS 26 edge effect. Off by default — set it with a scrolling body.
80
+ * and a header scrolls with the iOS 26 edge effect. Off by default; set it with a scrolling body.
81
81
  */
82
82
  scrollable?: boolean
83
83
  /** Test identifier, forwarded to the native sheet. */
@@ -92,7 +92,7 @@ export type SheetScrollHandler = (event: NativeSyntheticEvent<NativeScrollEvent>
92
92
  export type SheetScrollContextValue = {
93
93
  /** Render it first in the content. `null` unless the header's `titleStyle` is `large`. */
94
94
  largeTitle: ReactNode
95
- /** Forward the scroll view's scroll events to it — it tracks the large title. Unset when there is none. */
95
+ /** Forward the scroll view's scroll events to it; it tracks the large title. Unset when there is none. */
96
96
  onScroll?: SheetScrollHandler
97
97
  /** The room an overlaid header takes, to add to the content's top padding. `0` where the header sits above it. */
98
98
  topInset: number
@@ -105,7 +105,7 @@ export type SheetScrollContextValue = {
105
105
  export type SheetScrollViewProps = Pick<ScrollViewProps, 'keyboardShouldPersistTaps'> & {
106
106
  /** The scrolling content, after the large title if there is one. */
107
107
  children: ReactNode
108
- /** Styles the scrolling content — padding and gap belong here, as with `RnScrollView`. */
108
+ /** Styles the scrolling content: padding and gap belong here, as with `RnScrollView`. */
109
109
  content?: ResponsiveViewSx
110
110
  /** Called on every scroll event, after the sheet's own listener. */
111
111
  onScroll?: SheetScrollHandler
@@ -1,41 +1,165 @@
1
- import {FadeInDown, FadeOutDown} from 'react-native-reanimated'
1
+ import {duration as durations, easing, spacing, useReducedMotion} from '@hzblj/kara-theme'
2
+ import {useEffect, useRef} from 'react'
3
+ import {AccessibilityInfo, Platform} from 'react-native'
4
+ import {
5
+ Easing,
6
+ type EntryExitAnimationFunction,
7
+ FadeIn,
8
+ FadeInDown,
9
+ FadeInUp,
10
+ FadeOut,
11
+ FadeOutDown,
12
+ FadeOutUp,
13
+ ReduceMotion,
14
+ withTiming,
15
+ } from 'react-native-reanimated'
2
16
 
3
- import {ABox} from '../../atoms/box'
17
+ import {ABox, Box} from '../../atoms/box'
4
18
  import {Pressable} from '../../atoms/pressable'
5
19
  import {RnText} from '../../atoms/rn-text'
6
- import type {SnackbarComponent, SnackbarProps} from './snackbar.types'
20
+ import {RnGlyph} from '../../glyph'
21
+ import {timing} from '../../motion'
22
+ import type {SnackbarAnimation, SnackbarComponent, SnackbarDuration, SnackbarProps} from './snackbar.types'
23
+
24
+ /** Material's `SnackbarDuration.Short` and `Long`. */
25
+ const DURATIONS = {long: 10_000, short: 4_000} as const
26
+
27
+ const PLATFORM_ANIMATION: SnackbarAnimation = Platform.OS === 'android' ? 'scale' : 'slide'
28
+
29
+ /** The close glyph at the label's height: an SF Symbol fills its box, Material's icon sits inside a padded one. */
30
+ const CLOSE_SIZE = Platform.OS === 'ios' ? 's12' : 's16'
31
+
32
+ const SMOOTH_OUT = Easing.bezier(...easing.smoothOut)
33
+ const GROW = timing('quick')
34
+
35
+ /** Material's snackbar enter: it fades in while it grows from 80 %, in 150 ms. */
36
+ const scaleIn: EntryExitAnimationFunction = () => {
37
+ 'worklet'
38
+
39
+ return {
40
+ animations: {opacity: withTiming(1, GROW), transform: [{scale: withTiming(1, GROW)}]},
41
+ initialValues: {opacity: 0, transform: [{scale: 0.8}]},
42
+ }
43
+ }
44
+
45
+ /**
46
+ * The presets in and out: arriving in `fast`, leaving in `quick`, both on `smoothOut`. `ReduceMotion.Never`, because
47
+ * `useReducedMotion` has already picked the fade by then, and a fade is what should still run.
48
+ */
49
+ const TRANSITIONS = {
50
+ fade: {
51
+ entering: FadeIn.duration(durations.fast).easing(SMOOTH_OUT).reduceMotion(ReduceMotion.Never),
52
+ exiting: FadeOut.duration(durations.quick).easing(SMOOTH_OUT).reduceMotion(ReduceMotion.Never),
53
+ },
54
+ // Material's exit is a 75 ms fade: `micro`.
55
+ scale: {entering: scaleIn, exiting: FadeOut.duration(durations.micro).reduceMotion(ReduceMotion.Never)},
56
+ // Slide: in from the edge it sits on, and back out toward it.
57
+ slideBottom: {
58
+ entering: FadeInDown.duration(durations.fast).easing(SMOOTH_OUT).reduceMotion(ReduceMotion.Never),
59
+ exiting: FadeOutDown.duration(durations.quick).easing(SMOOTH_OUT).reduceMotion(ReduceMotion.Never),
60
+ },
61
+ slideTop: {
62
+ entering: FadeInUp.duration(durations.fast).easing(SMOOTH_OUT).reduceMotion(ReduceMotion.Never),
63
+ exiting: FadeOutUp.duration(durations.quick).easing(SMOOTH_OUT).reduceMotion(ReduceMotion.Never),
64
+ },
65
+ }
66
+
67
+ const transitionsFor = (animation: SnackbarAnimation, position: 'bottom' | 'top') => {
68
+ if (animation === 'slide') {
69
+ return position === 'top' ? TRANSITIONS.slideTop : TRANSITIONS.slideBottom
70
+ }
71
+
72
+ return TRANSITIONS[animation]
73
+ }
74
+
75
+ const millisecondsOf = (duration: SnackbarDuration) =>
76
+ typeof duration === 'number' ? duration : duration === 'indefinite' ? undefined : DURATIONS[duration]
77
+
78
+ export const Snackbar: SnackbarComponent = ({
79
+ actionLabel,
80
+ actionOnNewLine = false,
81
+ animation = PLATFORM_ANIMATION,
82
+ dismissible = false,
83
+ duration = 'indefinite',
84
+ entering,
85
+ exiting,
86
+ message,
87
+ offset = 's24',
88
+ onAction,
89
+ onDismiss,
90
+ position = 'bottom',
91
+ visible,
92
+ }: SnackbarProps) => {
93
+ const reduced = useReducedMotion()
94
+ // A caller's inline `onDismiss` is a new function every render; the timer must not restart for it.
95
+ const dismiss = useRef(onDismiss)
96
+ dismiss.current = onDismiss
97
+
98
+ // biome-ignore lint/correctness/useExhaustiveDependencies: a new `message` restarts the timer, as a new snackbar
99
+ useEffect(() => {
100
+ const milliseconds = millisecondsOf(duration)
101
+
102
+ if (!visible || milliseconds === undefined) {
103
+ return
104
+ }
105
+
106
+ const timer = setTimeout(() => dismiss.current?.(), milliseconds)
107
+
108
+ return () => clearTimeout(timer)
109
+ }, [duration, message, visible])
110
+
111
+ // Material's snackbar is announced; a React Native view is not unless asked.
112
+ useEffect(() => {
113
+ if (visible) {
114
+ AccessibilityInfo.announceForAccessibility(message)
115
+ }
116
+ }, [message, visible])
7
117
 
8
- export const Snackbar: SnackbarComponent = ({actionLabel, message, onAction, visible}: SnackbarProps) => {
9
118
  if (!visible) {
10
119
  return null
11
120
  }
12
121
 
122
+ const edge = position === 'top' ? {top: spacing[offset]} : {bottom: spacing[offset]}
123
+ const hasTrailing = Boolean(actionLabel) || dismissible
124
+ // With motion reduced it only fades: nothing slides or grows.
125
+ const preset = transitionsFor(reduced ? 'fade' : animation, position)
126
+
13
127
  return (
14
128
  <ABox
15
- align="center"
129
+ align={actionOnNewLine ? 'stretch' : 'center'}
16
130
  bg="surface.high.contrast"
17
131
  borderRadius="medium"
18
- bottom={24}
19
- entering={FadeInDown}
20
- exiting={FadeOutDown}
21
- flexDirection="row"
22
- gap="s12"
23
- left={16}
132
+ flexDirection={actionOnNewLine ? 'column' : 'row'}
133
+ gap={actionOnNewLine ? 's8' : 's12'}
134
+ left={spacing.s16}
24
135
  position="absolute"
25
136
  px="s16"
26
137
  py="s12"
27
- right={16}
138
+ right={spacing.s16}
28
139
  shadow="snackbar"
140
+ {...edge}
141
+ entering={entering ?? preset.entering}
142
+ exiting={exiting ?? preset.exiting}
29
143
  >
30
- <RnText color="content.on.high.contrast" variant="footnote">
144
+ {/* It takes the room, so the action sits at the trailing end, as far in from it as the message is from the start. */}
145
+ <RnText color="content.on.high.contrast" flex={actionOnNewLine ? undefined : 1} variant="footnote">
31
146
  {message}
32
147
  </RnText>
33
- {actionLabel ? (
34
- <Pressable onPress={onAction}>
35
- <RnText color="content.accent" variant="footnoteMedium">
36
- {actionLabel}
37
- </RnText>
38
- </Pressable>
148
+ {hasTrailing ? (
149
+ <Box align="center" alignSelf={actionOnNewLine ? 'flex-end' : undefined} flexDirection="row" gap="s16">
150
+ {actionLabel ? (
151
+ <Pressable onPress={onAction} pressEffect="opacity" ripple={false}>
152
+ <RnText color="content.accent" variant="footnoteMedium">
153
+ {actionLabel}
154
+ </RnText>
155
+ </Pressable>
156
+ ) : null}
157
+ {dismissible ? (
158
+ <Pressable accessibilityLabel="Dismiss" onPress={onDismiss} pressEffect="opacity" ripple={false}>
159
+ <RnGlyph color="content.on.high.contrast" name="close" size={CLOSE_SIZE} />
160
+ </Pressable>
161
+ ) : null}
162
+ </Box>
39
163
  ) : null}
40
164
  </ABox>
41
165
  )
@@ -1,17 +1,53 @@
1
- import type {ReactNode} from 'react'
1
+ import type {SpaceSize} from '@hzblj/kara-theme'
2
+ import type {ComponentProps, ReactNode} from 'react'
3
+ import type Animated from 'react-native-reanimated'
4
+
5
+ type LayoutAnimation = ComponentProps<typeof Animated.View>['entering']
6
+
7
+ /** How it comes and goes. */
8
+ export type SnackbarAnimation = 'fade' | 'scale' | 'slide'
9
+
10
+ /** How long it stays: Material's short (4 s) and long (10 s), never, or a number of milliseconds. */
11
+ export type SnackbarDuration = 'indefinite' | 'long' | 'short' | number
12
+
13
+ /** The edge of its parent it sits on. */
14
+ export type SnackbarPosition = 'bottom' | 'top'
2
15
 
3
16
  /**
4
- * A short message laid over the bottom of its parent, with an optional action. The React Native tier, drawn the same on
5
- * both platforms: it needs no host, and it never hides itself.
17
+ * A short message laid over an edge of its parent, with an optional action at its trailing end. The React Native tier,
18
+ * drawn the same on both platforms (iOS has no snackbar of its own), so it needs no host. Material's options are all
19
+ * here: a duration, a dismiss button, the action on a line of its own. It is announced to VoiceOver and TalkBack when
20
+ * it appears.
6
21
  */
7
22
  export type SnackbarProps = {
8
- /** The action button's text, on the trailing side. No button without it. */
23
+ /** The action button's text, at the trailing end. No button without it. */
9
24
  actionLabel?: string
25
+ /** Puts the action under the message, at its trailing end: Material's layout for a long message or action. */
26
+ actionOnNewLine?: boolean
27
+ /**
28
+ * How it comes and goes. `scale` is Material's own (a fade and a scale from 80 %), `slide` rises from its edge as it
29
+ * fades in, `fade` only fades. `scale` on Android and `slide` on iOS by default. With motion reduced, it fades.
30
+ */
31
+ animation?: SnackbarAnimation
32
+ /** A close button at the trailing end, Material's dismiss action; it calls `onDismiss`. */
33
+ dismissible?: boolean
34
+ /** How long it stays up before `onDismiss` is called. `indefinite` by default: it never hides itself. */
35
+ duration?: SnackbarDuration
36
+ /** A Reanimated entering animation of your own, e.g. `FadeInDown.springify()`. It wins over `animation`. */
37
+ entering?: LayoutAnimation
38
+ /** A Reanimated exiting animation of your own. It wins over `animation`. */
39
+ exiting?: LayoutAnimation
10
40
  /** The message. */
11
41
  message: string
12
- /** The action was pressed. The snackbar stays up — turn `visible` off to hide it. */
42
+ /** Between the snackbar and its edge, a space token. `s24` by default; raise it above a tab bar. */
43
+ offset?: SpaceSize
44
+ /** The action was pressed. The snackbar stays up; turn `visible` off to hide it. */
13
45
  onAction?: () => void
14
- /** Shows the snackbar while true, fading it in and out. It sets no timer of its own. */
46
+ /** It asks to go: its `duration` ran out, or its dismiss button was pressed. Turn `visible` off to hide it. */
47
+ onDismiss?: () => void
48
+ /** The edge of its parent it sits on. `bottom` by default, Material's place for it. */
49
+ position?: SnackbarPosition
50
+ /** Shows the snackbar while true, animating it in and out. */
15
51
  visible: boolean
16
52
  }
17
53
 
@@ -49,7 +49,7 @@ type ActionButtonProps = {action: SwipeAction; onDone: () => void}
49
49
  const ActionButton = ({action, onDone}: ActionButtonProps) => {
50
50
  const theme = useAppTheme()
51
51
  const fill = action.tint ?? (action.destructive ? 'fill.destructive.primary' : 'fill.accent.primary')
52
- const content = !action.tint && action.destructive ? 'content.on.destructive' : 'content.on.bg'
52
+ const content = !action.tint && action.destructive ? 'content.on.destructive' : 'content.on.accent'
53
53
 
54
54
  const onClick = useCallback(() => {
55
55
  onDone()
@@ -7,26 +7,26 @@ import type {IconName} from '../../atoms/icon'
7
7
  export type SwipeAction = {
8
8
  /** Fills the button with `fill.destructive.primary` unless `tint` says otherwise. */
9
9
  destructive?: boolean
10
- /** One of the app's icons, on the button — a round one on iOS 26, as in Mail, a filled stadium on Android. */
10
+ /** One of the app's icons, on the button: a round one on iOS 26, as in Mail, a filled stadium on Android. */
11
11
  icon: IconName
12
12
  /**
13
- * The action's name, written under the button — before iOS 26 a row of the usual height shows the icon alone and
13
+ * The action's name, written under the button; before iOS 26 a row of the usual height shows the icon alone and
14
14
  * keeps the label for VoiceOver. Actions are keyed by it, so keep labels unique within one row.
15
15
  */
16
16
  label: string
17
17
  /** Called when the button is pressed. The row closes by itself. */
18
18
  onPress: () => void
19
19
  /**
20
- * The button's fill — `fill.destructive.primary` for a destructive action, `fill.accent.primary` otherwise. The icon
20
+ * The button's fill: `fill.destructive.primary` for a destructive action, `fill.accent.primary` otherwise. The icon
21
21
  * on it is white, so pick a fill that holds white in both appearances.
22
22
  */
23
23
  tint?: ColorToken
24
24
  }
25
25
 
26
26
  /**
27
- * A list row with buttons behind it, uncovered by a swipe — SwiftUI's `swipeActions` on iOS, and on Android, where
27
+ * A list row with buttons behind it, uncovered by a swipe. SwiftUI's `swipeActions` on iOS, and on Android, where
28
28
  * Compose has none, kara's own: the row slides on an anchored drag and the buttons show in the strip it leaves. One
29
- * row is open at a time on both; a tap on an open row closes it. A native organism — it belongs inside a `List`.
29
+ * row is open at a time on both; a tap on an open row closes it. A native organism: it belongs inside a `List`.
30
30
  */
31
31
  export type SwipeActionsProps = {
32
32
  /**
@@ -2,7 +2,7 @@ import type {Sx} from '@hzblj/kara-sx'
2
2
  import type {ReactNode} from 'react'
3
3
 
4
4
  /**
5
- * The full-bleed native host a screen starts with — a SwiftUI or Compose `Host` filling its parent, so native atoms
5
+ * The full-bleed native host a screen starts with: a SwiftUI or Compose `Host` filling its parent, so native atoms
6
6
  * render anywhere inside it. The background runs to the edges; the content keeps clear of the status bar where the
7
7
  * screen covers it (no navigation bar above), on Android as SwiftUI's safe area does on iOS.
8
8
  */
@@ -13,7 +13,7 @@ export type ScreenProps = {
13
13
  children?: ReactNode
14
14
  /** Keeps the content where it is when the keyboard opens, instead of avoiding it. Android reads it once, on mount. */
15
15
  ignoreKeyboardInset?: boolean
16
- /** Test identifier — on the host view on iOS, on the view around it on Android. */
16
+ /** Test identifier, on the host view on iOS and on the view around it on Android. */
17
17
  testID?: string
18
18
  }
19
19
 
@@ -1,24 +1,37 @@
1
1
  import {clickable, type ModifierConfig, testID as testIdModifier} from '@expo/ui/jetpack-compose/modifiers'
2
- import {type ResponsiveSx, useSxModifiers} from '@hzblj/kara-sx'
2
+ import {
3
+ type AccessibilityProps,
4
+ type ResponsiveSx,
5
+ splitAccessibility,
6
+ useAccessibilityModifiers,
7
+ useSxModifiers,
8
+ } from '@hzblj/kara-sx'
3
9
  import {useMemo} from 'react'
4
10
 
5
11
  /**
6
- * A Compose stack's modifiers in the order a pressable one needs: its frame, shape and background, then the press,
7
- * then its padding. Compose clips a `clickable` to what comes after it, so with the padding first the ripple would stop
8
- * at the padding and a row pressed by its edge would light up only in the middle.
12
+ * A Compose stack's modifiers in the order a pressable one needs: its frame, shape and background, then the press, its
13
+ * semantics, then its padding. Compose clips a `clickable` to what comes after it, so with the padding first the ripple
14
+ * would stop at the padding and a row pressed by its edge would light up only in the middle. The semantics come after
15
+ * the click, because a label that replaces the children's clears whatever semantics are inside it.
9
16
  */
10
- export const useStackModifiers = (sx: ResponsiveSx, onPress?: () => void, testID?: string): ModifierConfig[] => {
11
- const {p, pb, pl, pr, pt, px, py, ...frame} = sx
17
+ export const useStackModifiers = (
18
+ props: ResponsiveSx & AccessibilityProps,
19
+ onPress?: () => void,
20
+ testID?: string
21
+ ): ModifierConfig[] => {
22
+ const [accessibility, {p, pb, pl, pr, pt, px, py, ...frame}] = splitAccessibility(props)
12
23
  const frameModifiers = useSxModifiers(frame)
13
24
  const paddingModifiers = useSxModifiers({p, pb, pl, pr, pt, px, py})
25
+ const accessibilityModifiers = useAccessibilityModifiers(accessibility, onPress !== undefined)
14
26
 
15
27
  return useMemo(
16
28
  () => [
17
29
  ...frameModifiers,
18
30
  ...(testID ? [testIdModifier(testID)] : []),
19
31
  ...(onPress ? [clickable(onPress)] : []),
32
+ ...accessibilityModifiers,
20
33
  ...paddingModifiers,
21
34
  ],
22
- [frameModifiers, onPress, paddingModifiers, testID]
35
+ [accessibilityModifiers, frameModifiers, onPress, paddingModifiers, testID]
23
36
  )
24
37
  }
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- const warned = new Set();
4
-
5
- /**
6
- * Announces an atom that only one platform can implement. The stub still satisfies the shared
7
- * component type, so `contract.check.ts` keeps both files honest — this just makes the gap loud
8
- * in dev instead of leaving a control that mysteriously never appears.
9
- *
10
- * Warns once per atom: the gap is permanent, so repeating it every render would be noise.
11
- */
12
- export const warnUnsupported = (atom, platform) => {
13
- if (!__DEV__ || warned.has(atom)) {
14
- return;
15
- }
16
- warned.add(atom);
17
- console.error(`[kara-ui] <${atom}> has no ${platform} implementation and renders nothing there. Branch on Platform.OS at the call site.`);
18
- };
19
- //# sourceMappingURL=platform-support.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["warned","Set","warnUnsupported","atom","platform","__DEV__","has","add","console","error"],"sourceRoot":"../../src","sources":["platform-support.ts"],"mappings":";;AAAA,MAAMA,MAAM,GAAG,IAAIC,GAAG,CAAS,CAAC;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAACC,IAAY,EAAEC,QAA2B,KAAK;EAC5E,IAAI,CAACC,OAAO,IAAIL,MAAM,CAACM,GAAG,CAACH,IAAI,CAAC,EAAE;IAChC;EACF;EAEAH,MAAM,CAACO,GAAG,CAACJ,IAAI,CAAC;EAEhBK,OAAO,CAACC,KAAK,CACX,cAAcN,IAAI,YAAYC,QAAQ,oFACxC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- /**
2
- * Announces an atom that only one platform can implement. The stub still satisfies the shared
3
- * component type, so `contract.check.ts` keeps both files honest — this just makes the gap loud
4
- * in dev instead of leaving a control that mysteriously never appears.
5
- *
6
- * Warns once per atom: the gap is permanent, so repeating it every render would be noise.
7
- */
8
- export declare const warnUnsupported: (atom: string, platform: 'Android' | 'iOS') => void;
@@ -1,20 +0,0 @@
1
- const warned = new Set<string>()
2
-
3
- /**
4
- * Announces an atom that only one platform can implement. The stub still satisfies the shared
5
- * component type, so `contract.check.ts` keeps both files honest — this just makes the gap loud
6
- * in dev instead of leaving a control that mysteriously never appears.
7
- *
8
- * Warns once per atom: the gap is permanent, so repeating it every render would be noise.
9
- */
10
- export const warnUnsupported = (atom: string, platform: 'Android' | 'iOS') => {
11
- if (!__DEV__ || warned.has(atom)) {
12
- return
13
- }
14
-
15
- warned.add(atom)
16
-
17
- console.error(
18
- `[kara-ui] <${atom}> has no ${platform} implementation and renders nothing there. Branch on Platform.OS at the call site.`
19
- )
20
- }