@hzblj/kara-components 0.7.0 → 0.8.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 (117) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +5 -5
  3. package/lib/module/atoms/activity-indicator/activity-indicator.android.js +42 -0
  4. package/lib/module/atoms/activity-indicator/activity-indicator.android.js.map +1 -0
  5. package/lib/module/atoms/activity-indicator/activity-indicator.ios.js +19 -0
  6. package/lib/module/atoms/activity-indicator/activity-indicator.ios.js.map +1 -0
  7. package/lib/module/atoms/activity-indicator/activity-indicator.types.js +4 -0
  8. package/lib/module/atoms/activity-indicator/activity-indicator.types.js.map +1 -0
  9. package/lib/module/atoms/activity-indicator/index.js +2 -1
  10. package/lib/module/atoms/activity-indicator/index.js.map +1 -1
  11. package/lib/module/atoms/avatar/avatar.js +2 -4
  12. package/lib/module/atoms/avatar/avatar.js.map +1 -1
  13. package/lib/module/atoms/blur-view/blur-view.android.js +100 -0
  14. package/lib/module/atoms/blur-view/blur-view.android.js.map +1 -0
  15. package/lib/module/atoms/blur-view/blur-view.ios.js +43 -0
  16. package/lib/module/atoms/blur-view/blur-view.ios.js.map +1 -0
  17. package/lib/module/atoms/blur-view/blur-view.types.js +4 -0
  18. package/lib/module/atoms/blur-view/blur-view.types.js.map +1 -0
  19. package/lib/module/atoms/blur-view/index.js +5 -0
  20. package/lib/module/atoms/blur-view/index.js.map +1 -0
  21. package/lib/module/atoms/glass-view/glass-view.android.js +36 -5
  22. package/lib/module/atoms/glass-view/glass-view.android.js.map +1 -1
  23. package/lib/module/atoms/image/image.js +13 -6
  24. package/lib/module/atoms/image/image.js.map +1 -1
  25. package/lib/module/atoms/image/image.types.js +4 -0
  26. package/lib/module/atoms/image/image.types.js.map +1 -0
  27. package/lib/module/atoms/image/index.js +1 -0
  28. package/lib/module/atoms/image/index.js.map +1 -1
  29. package/lib/module/atoms/index.js +1 -0
  30. package/lib/module/atoms/index.js.map +1 -1
  31. package/lib/module/atoms/island/island.android.js +6 -2
  32. package/lib/module/atoms/island/island.android.js.map +1 -1
  33. package/lib/module/atoms/island/island.ios.js +5 -2
  34. package/lib/module/atoms/island/island.ios.js.map +1 -1
  35. package/lib/module/atoms/pressable/pressable.js +38 -6
  36. package/lib/module/atoms/pressable/pressable.js.map +1 -1
  37. package/lib/module/atoms/rn-text/rn-text.js +5 -2
  38. package/lib/module/atoms/rn-text/rn-text.js.map +1 -1
  39. package/lib/module/atoms/skeleton/skeleton.js +5 -5
  40. package/lib/module/atoms/skeleton/skeleton.js.map +1 -1
  41. package/lib/module/atoms/text/text.android.js +5 -2
  42. package/lib/module/atoms/text/text.android.js.map +1 -1
  43. package/lib/module/atoms/text/text.ios.js +14 -3
  44. package/lib/module/atoms/text/text.ios.js.map +1 -1
  45. package/lib/module/molecules/collapsible/collapsible.android.js +37 -7
  46. package/lib/module/molecules/collapsible/collapsible.android.js.map +1 -1
  47. package/lib/module/molecules/navigation-bar/navigation-bar.android.js +2 -8
  48. package/lib/module/molecules/navigation-bar/navigation-bar.android.js.map +1 -1
  49. package/lib/module/molecules/pager/pager.android.js +5 -4
  50. package/lib/module/molecules/pager/pager.android.js.map +1 -1
  51. package/lib/module/molecules/scroll-edge-container/scroll-edge-container.android.js +114 -11
  52. package/lib/module/molecules/scroll-edge-container/scroll-edge-container.android.js.map +1 -1
  53. package/lib/module/molecules/stepper/stepper.ios.js +45 -8
  54. package/lib/module/molecules/stepper/stepper.ios.js.map +1 -1
  55. package/lib/module/ripple-clip.js +9 -1
  56. package/lib/module/ripple-clip.js.map +1 -1
  57. package/lib/typescript/atoms/activity-indicator/activity-indicator.d.ts +1 -3
  58. package/lib/typescript/atoms/activity-indicator/activity-indicator.ios.d.ts +3 -0
  59. package/lib/typescript/atoms/activity-indicator/activity-indicator.types.d.ts +17 -0
  60. package/lib/typescript/atoms/activity-indicator/index.d.ts +1 -0
  61. package/lib/typescript/atoms/blur-view/blur-view.d.ts +1 -0
  62. package/lib/typescript/atoms/blur-view/blur-view.ios.d.ts +3 -0
  63. package/lib/typescript/atoms/blur-view/blur-view.types.d.ts +31 -0
  64. package/lib/typescript/atoms/blur-view/index.d.ts +2 -0
  65. package/lib/typescript/atoms/box/a-box.d.ts +1 -1
  66. package/lib/typescript/atoms/glass-view/glass-view.types.d.ts +12 -5
  67. package/lib/typescript/atoms/image/image.d.ts +12 -4
  68. package/lib/typescript/atoms/image/image.types.d.ts +4 -0
  69. package/lib/typescript/atoms/image/index.d.ts +1 -0
  70. package/lib/typescript/atoms/index.d.ts +1 -0
  71. package/lib/typescript/atoms/island/island.types.d.ts +8 -4
  72. package/lib/typescript/atoms/pressable/pressable.types.d.ts +5 -3
  73. package/lib/typescript/atoms/rn-text/rn-text.types.d.ts +7 -2
  74. package/lib/typescript/atoms/skeleton/skeleton.types.d.ts +8 -4
  75. package/lib/typescript/atoms/text/text.types.d.ts +7 -2
  76. package/lib/typescript/molecules/scroll-edge-container/scroll-edge-container.types.d.ts +6 -4
  77. package/lib/typescript/molecules/stepper/stepper.ios.d.ts +5 -0
  78. package/lib/typescript/molecules/stepper/stepper.types.d.ts +1 -4
  79. package/package.json +5 -5
  80. package/src/atoms/activity-indicator/activity-indicator.android.tsx +32 -0
  81. package/src/atoms/activity-indicator/activity-indicator.ios.tsx +15 -0
  82. package/src/atoms/activity-indicator/activity-indicator.types.ts +20 -0
  83. package/src/atoms/activity-indicator/index.ts +1 -0
  84. package/src/atoms/avatar/avatar.tsx +1 -1
  85. package/src/atoms/blur-view/blur-view.android.tsx +68 -0
  86. package/src/atoms/blur-view/blur-view.ios.tsx +37 -0
  87. package/src/atoms/blur-view/blur-view.types.ts +34 -0
  88. package/src/atoms/blur-view/index.ts +2 -0
  89. package/src/atoms/glass-view/glass-view.android.tsx +41 -3
  90. package/src/atoms/glass-view/glass-view.types.ts +12 -5
  91. package/src/atoms/image/image.tsx +11 -12
  92. package/src/atoms/image/image.types.ts +6 -0
  93. package/src/atoms/image/index.ts +1 -0
  94. package/src/atoms/index.ts +1 -0
  95. package/src/atoms/island/island.android.tsx +10 -2
  96. package/src/atoms/island/island.ios.tsx +4 -2
  97. package/src/atoms/island/island.types.ts +8 -4
  98. package/src/atoms/pressable/pressable.tsx +46 -6
  99. package/src/atoms/pressable/pressable.types.ts +5 -3
  100. package/src/atoms/rn-text/rn-text.tsx +6 -3
  101. package/src/atoms/rn-text/rn-text.types.ts +15 -9
  102. package/src/atoms/skeleton/skeleton.tsx +4 -4
  103. package/src/atoms/skeleton/skeleton.types.ts +8 -4
  104. package/src/atoms/text/text.android.tsx +7 -1
  105. package/src/atoms/text/text.ios.tsx +14 -3
  106. package/src/atoms/text/text.types.ts +7 -2
  107. package/src/molecules/collapsible/collapsible.android.tsx +47 -7
  108. package/src/molecules/navigation-bar/navigation-bar.android.tsx +1 -6
  109. package/src/molecules/pager/pager.android.tsx +4 -1
  110. package/src/molecules/scroll-edge-container/scroll-edge-container.android.tsx +103 -10
  111. package/src/molecules/scroll-edge-container/scroll-edge-container.types.ts +6 -4
  112. package/src/molecules/stepper/stepper.ios.tsx +37 -1
  113. package/src/molecules/stepper/stepper.types.ts +1 -4
  114. package/src/ripple-clip.ts +10 -1
  115. package/lib/module/atoms/activity-indicator/activity-indicator.js +0 -14
  116. package/lib/module/atoms/activity-indicator/activity-indicator.js.map +0 -1
  117. package/src/atoms/activity-indicator/activity-indicator.tsx +0 -9
@@ -1,8 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  import { Stepper as SwiftUIStepper } from '@expo/ui/swift-ui';
4
+ import { labelsHidden } from '@expo/ui/swift-ui/modifiers';
5
+ import { useRef } from 'react';
6
+ import { HStack } from "../../atoms/h-stack/index.js";
7
+ import { Spacer } from "../../atoms/spacer/index.js";
8
+ import { Text } from "../../atoms/text/index.js";
4
9
  import { useHostGuard } from "../../host-context.js";
5
- import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ /** The label stays VoiceOver's, on the control; on screen it is the row's own text. */
12
+ const LABEL_HIDDEN = [labelsHidden()];
13
+
14
+ /**
15
+ * SwiftUI's `Stepper` at the end of a row, the label leading and the value just before the control — the way iOS's own
16
+ * settings show a stepped value. The value rolls to the next one (`numericText`), up or down with the change, in
17
+ * monospaced digits so the row does not jump.
18
+ */
6
19
  export const Stepper = ({
7
20
  label,
8
21
  max,
@@ -12,13 +25,37 @@ export const Stepper = ({
12
25
  value
13
26
  }) => {
14
27
  useHostGuard('Stepper');
15
- return /*#__PURE__*/_jsx(SwiftUIStepper, {
16
- label: label,
17
- max: max,
18
- min: min,
19
- onValueChange: onValueChange,
20
- step: step,
21
- value: value
28
+ const previous = useRef(value);
29
+ const countsDown = value < previous.current;
30
+ previous.current = value;
31
+ return /*#__PURE__*/_jsxs(HStack, {
32
+ align: "center",
33
+ spacing: "s12",
34
+ wide: true,
35
+ children: [/*#__PURE__*/_jsx(Text, {
36
+ children: label
37
+ }), /*#__PURE__*/_jsx(Spacer, {}), /*#__PURE__*/_jsx(Text, {
38
+ color: "content.secondary",
39
+ ios: {
40
+ animation: {
41
+ value
42
+ },
43
+ contentTransition: {
44
+ countsDown,
45
+ type: 'numericText'
46
+ },
47
+ monospacedDigit: true
48
+ },
49
+ children: String(value)
50
+ }), /*#__PURE__*/_jsx(SwiftUIStepper, {
51
+ label: label,
52
+ max: max,
53
+ min: min,
54
+ modifiers: LABEL_HIDDEN,
55
+ onValueChange: onValueChange,
56
+ step: step,
57
+ value: value
58
+ })]
22
59
  });
23
60
  };
24
61
  //# sourceMappingURL=stepper.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Stepper","SwiftUIStepper","useHostGuard","jsx","_jsx","label","max","min","onValueChange","step","value"],"sourceRoot":"../../../../src","sources":["molecules/stepper/stepper.ios.tsx"],"mappings":";;AAAA,SAAQA,OAAO,IAAIC,cAAc,QAAO,mBAAmB;AAE3D,SAAQC,YAAY,QAAO,uBAAoB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG/C,OAAO,MAAMJ,OAAyB,GAAGA,CAAC;EAACK,KAAK;EAAEC,GAAG;EAAEC,GAAG;EAAEC,aAAa;EAAEC,IAAI,GAAG,CAAC;EAAEC;AAAmB,CAAC,KAAK;EAC5GR,YAAY,CAAC,SAAS,CAAC;EAEvB,oBAAOE,IAAA,CAACH,cAAc;IAACI,KAAK,EAAEA,KAAM;IAACC,GAAG,EAAEA,GAAI;IAACC,GAAG,EAAEA,GAAI;IAACC,aAAa,EAAEA,aAAc;IAACC,IAAI,EAAEA,IAAK;IAACC,KAAK,EAAEA;EAAM,CAAE,CAAC;AACrH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Stepper","SwiftUIStepper","labelsHidden","useRef","HStack","Spacer","Text","useHostGuard","jsx","_jsx","jsxs","_jsxs","LABEL_HIDDEN","label","max","min","onValueChange","step","value","previous","countsDown","current","align","spacing","wide","children","color","ios","animation","contentTransition","type","monospacedDigit","String","modifiers"],"sourceRoot":"../../../../src","sources":["molecules/stepper/stepper.ios.tsx"],"mappings":";;AAAA,SAAQA,OAAO,IAAIC,cAAc,QAAO,mBAAmB;AAC3D,SAAQC,YAAY,QAAO,6BAA6B;AACxD,SAAQC,MAAM,QAAO,OAAO;AAE5B,SAAQC,MAAM,QAAO,8BAAqB;AAC1C,SAAQC,MAAM,QAAO,6BAAoB;AACzC,SAAQC,IAAI,QAAO,2BAAkB;AACrC,SAAQC,YAAY,QAAO,uBAAoB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG/C;AACA,MAAMC,YAAY,GAAG,CAACV,YAAY,CAAC,CAAC,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMF,OAAyB,GAAGA,CAAC;EAACa,KAAK;EAAEC,GAAG;EAAEC,GAAG;EAAEC,aAAa;EAAEC,IAAI,GAAG,CAAC;EAAEC;AAAmB,CAAC,KAAK;EAC5GX,YAAY,CAAC,SAAS,CAAC;EACvB,MAAMY,QAAQ,GAAGhB,MAAM,CAACe,KAAK,CAAC;EAC9B,MAAME,UAAU,GAAGF,KAAK,GAAGC,QAAQ,CAACE,OAAO;EAC3CF,QAAQ,CAACE,OAAO,GAAGH,KAAK;EAExB,oBACEP,KAAA,CAACP,MAAM;IAACkB,KAAK,EAAC,QAAQ;IAACC,OAAO,EAAC,KAAK;IAACC,IAAI;IAAAC,QAAA,gBACvChB,IAAA,CAACH,IAAI;MAAAmB,QAAA,EAAEZ;IAAK,CAAO,CAAC,eACpBJ,IAAA,CAACJ,MAAM,IAAE,CAAC,eACVI,IAAA,CAACH,IAAI;MACHoB,KAAK,EAAC,mBAAmB;MACzBC,GAAG,EAAE;QAACC,SAAS,EAAE;UAACV;QAAK,CAAC;QAAEW,iBAAiB,EAAE;UAACT,UAAU;UAAEU,IAAI,EAAE;QAAa,CAAC;QAAEC,eAAe,EAAE;MAAI,CAAE;MAAAN,QAAA,EAEtGO,MAAM,CAACd,KAAK;IAAC,CACV,CAAC,eACPT,IAAA,CAACR,cAAc;MACbY,KAAK,EAAEA,KAAM;MACbC,GAAG,EAAEA,GAAI;MACTC,GAAG,EAAEA,GAAI;MACTkB,SAAS,EAAErB,YAAa;MACxBI,aAAa,EAAEA,aAAc;MAC7BC,IAAI,EAAEA,IAAK;MACXC,KAAK,EAAEA;IAAM,CACd,CAAC;EAAA,CACI,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -8,6 +8,9 @@ const FILL = {
8
8
  flexGrow: 1
9
9
  };
10
10
 
11
+ /** What gives the outer view a height of its own, rather than its content's. */
12
+ const SIZING_KEYS = ['aspectRatio', 'flex', 'flexBasis', 'flexGrow', 'height', 'minHeight'];
13
+
11
14
  /**
12
15
  * Splits a resolved style for a pressable with an Android ripple. The ripple is drawn as the pressable's foreground,
13
16
  * which its own `overflow: hidden` does not clip — so it would spill past rounded corners. A parent clips its
@@ -28,8 +31,13 @@ export const splitForRipple = style => {
28
31
  outer[key] = value;
29
32
  }
30
33
  }
34
+
35
+ // Only a sized outer view needs the pressable stretched to it. Sized by its content it must not be: Yoga grows a
36
+ // `flexGrow` child of a fit-content parent to the most it may take — inside a row centred on its cross axis, the
37
+ // pressable would stretch to the row's full height and leave its content at the top.
38
+ const sized = SIZING_KEYS.some(key => flat[key] !== undefined) || flat.top !== undefined && flat.bottom !== undefined;
31
39
  return {
32
- inner: [FILL, inner],
40
+ inner: sized ? [FILL, inner] : [inner],
33
41
  outer: outer
34
42
  };
35
43
  };
@@ -1 +1 @@
1
- {"version":3,"names":["StyleSheet","CONTENT_KEYS","Set","FILL","flexGrow","splitForRipple","style","flat","flatten","outer","overflow","inner","key","value","Object","entries","has"],"sourceRoot":"../../src","sources":["ripple-clip.ts"],"mappings":";;AAAA,SAAQA,UAAU,QAAuB,cAAc;;AAEvD;AACA,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAS,CACnC,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,QAAQ,CACT,CAAC;AAEF,MAAMC,IAAe,GAAG;EAACC,QAAQ,EAAE;AAAC,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,KAA4B,IAA6C;EACtG,MAAMC,IAAI,GAAGP,UAAU,CAACQ,OAAO,CAACF,KAAK,CAAC,IAAI,CAAC,CAAC;EAC5C,MAAMG,KAA8B,GAAG;IAACC,QAAQ,EAAE;EAAQ,CAAC;EAC3D,MAAMC,KAA8B,GAAG,CAAC,CAAC;EAEzC,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,IAAI,CAAC,EAAE;IAC/C,IAAIN,YAAY,CAACe,GAAG,CAACJ,GAAG,CAAC,EAAE;MACzBD,KAAK,CAACC,GAAG,CAAC,GAAGC,KAAK;IACpB,CAAC,MAAM,IAAID,GAAG,KAAK,UAAU,EAAE;MAC7BH,KAAK,CAACG,GAAG,CAAC,GAAGC,KAAK;IACpB;EACF;EAEA,OAAO;IAACF,KAAK,EAAE,CAACR,IAAI,EAAEQ,KAAK,CAAc;IAAEF,KAAK,EAAEA;EAAkB,CAAC;AACvE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["StyleSheet","CONTENT_KEYS","Set","FILL","flexGrow","SIZING_KEYS","splitForRipple","style","flat","flatten","outer","overflow","inner","key","value","Object","entries","has","sized","some","undefined","top","bottom"],"sourceRoot":"../../src","sources":["ripple-clip.ts"],"mappings":";;AAAA,SAAQA,UAAU,QAAuB,cAAc;;AAEvD;AACA,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAS,CACnC,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,QAAQ,CACT,CAAC;AAEF,MAAMC,IAAe,GAAG;EAACC,QAAQ,EAAE;AAAC,CAAC;;AAErC;AACA,MAAMC,WAAW,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAU;;AAEpG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,KAA4B,IAA6C;EACtG,MAAMC,IAAI,GAAGR,UAAU,CAACS,OAAO,CAACF,KAAK,CAAC,IAAI,CAAC,CAAC;EAC5C,MAAMG,KAA8B,GAAG;IAACC,QAAQ,EAAE;EAAQ,CAAC;EAC3D,MAAMC,KAA8B,GAAG,CAAC,CAAC;EAEzC,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACR,IAAI,CAAC,EAAE;IAC/C,IAAIP,YAAY,CAACgB,GAAG,CAACJ,GAAG,CAAC,EAAE;MACzBD,KAAK,CAACC,GAAG,CAAC,GAAGC,KAAK;IACpB,CAAC,MAAM,IAAID,GAAG,KAAK,UAAU,EAAE;MAC7BH,KAAK,CAACG,GAAG,CAAC,GAAGC,KAAK;IACpB;EACF;;EAEA;EACA;EACA;EACA,MAAMI,KAAK,GACTb,WAAW,CAACc,IAAI,CAACN,GAAG,IAAIL,IAAI,CAACK,GAAG,CAAC,KAAKO,SAAS,CAAC,IAAKZ,IAAI,CAACa,GAAG,KAAKD,SAAS,IAAIZ,IAAI,CAACc,MAAM,KAAKF,SAAU;EAE3G,OAAO;IAACR,KAAK,EAAEM,KAAK,GAAG,CAACf,IAAI,EAAES,KAAK,CAAc,GAAG,CAACA,KAAK,CAAc;IAAEF,KAAK,EAAEA;EAAkB,CAAC;AACtG,CAAC","ignoreList":[]}
@@ -1,3 +1 @@
1
- import type { FC } from 'react';
2
- import { type ActivityIndicatorProps } from 'react-native';
3
- export declare const ActivityIndicator: FC<ActivityIndicatorProps>;
1
+ export * from './activity-indicator.ios';
@@ -0,0 +1,3 @@
1
+ import type { ActivityIndicatorComponent } from './activity-indicator.types';
2
+ /** React Native's spinner, which on iOS is UIKit's own `UIActivityIndicatorView`. */
3
+ export declare const ActivityIndicator: ActivityIndicatorComponent;
@@ -0,0 +1,17 @@
1
+ import type { ColorToken } from '@hzblj/kara-theme';
2
+ import type { ReactNode } from 'react';
3
+ export type ActivityIndicatorSize = 'large' | 'small';
4
+ /**
5
+ * That something is loading, for as long as it takes — UIKit's spinner on iOS, Material 3's expressive
6
+ * `LoadingIndicator` on Android, its shapes morphing as it turns. A React Native view on iOS and a host of its own on
7
+ * Android, so it renders anywhere. For how far along something is, use `Progress`.
8
+ */
9
+ export type ActivityIndicatorProps = {
10
+ /** Its colour. `fill.accent.primary` by default. */
11
+ color?: ColorToken;
12
+ /** `small` sits in a row or a button, `large` holds a screen that is loading. `small` by default. */
13
+ size?: ActivityIndicatorSize;
14
+ /** Test identifier, forwarded to the view. */
15
+ testID?: string;
16
+ };
17
+ export type ActivityIndicatorComponent = (props: ActivityIndicatorProps) => ReactNode;
@@ -1 +1,2 @@
1
1
  export * from './activity-indicator';
2
+ export * from './activity-indicator.types';
@@ -0,0 +1 @@
1
+ export * from './blur-view.ios';
@@ -0,0 +1,3 @@
1
+ import type { BlurViewComponent } from './blur-view.types';
2
+ /** `borderRadius` is the material's shape, so it goes to the effect view — the one that clips — not the layout box. */
3
+ export declare const BlurView: BlurViewComponent;
@@ -0,0 +1,31 @@
1
+ import type { BlurMaterial, BlurVibrancy } from '@hzblj/kara-native/swift-ui';
2
+ import type { ResponsiveViewSx } from '@hzblj/kara-sx';
3
+ import type { ReactNode } from 'react';
4
+ export type { BlurMaterial, BlurVibrancy } from '@hzblj/kara-native/swift-ui';
5
+ /**
6
+ * One of the system's materials behind React Native content — what sheets, bars, menus and HUDs are made of, in
7
+ * SwiftUI's five thicknesses. iOS: UIKit's `system*Material` blur, with optional vibrancy for the content. Android:
8
+ * what lies behind, blurred and saturated (Android 12+), under a Material tonal surface as thick as the material —
9
+ * `surface` at `ultraThin` up to `surfaceContainerHighest` at `ultraThick`; below Android 12 the surface alone. The
10
+ * React Native tier: it needs no host, so it suits a list cell. Shape it with `borderRadius`; it clips its children.
11
+ */
12
+ export type BlurViewProps = ResponsiveViewSx & {
13
+ /**
14
+ * Pins the material to light or dark whatever the app's appearance — a dark HUD over a light screen. Unset, it follows
15
+ * the app theme. Android draws the opposite appearance with Material's inverse surface.
16
+ */
17
+ appearance?: 'dark' | 'light';
18
+ /** React Native content, over the material. */
19
+ children?: ReactNode;
20
+ /** How much of what lies behind shows through, from `ultraThin` (most) to `ultraThick` (least). `regular` by default. */
21
+ material?: BlurMaterial;
22
+ /** Test identifier, forwarded to the view. */
23
+ testID?: string;
24
+ /**
25
+ * iOS: draws the children vibrant at this level, the way iOS draws its own labels and fills on a material — their
26
+ * colour becomes the material's vibrant one and their alpha the mask. Android has no vibrancy: the children keep
27
+ * their colours there.
28
+ */
29
+ vibrancy?: BlurVibrancy;
30
+ };
31
+ export type BlurViewComponent = (props: BlurViewProps) => ReactNode;
@@ -0,0 +1,2 @@
1
+ export * from './blur-view';
2
+ export * from './blur-view.types';
@@ -1,4 +1,4 @@
1
- export declare const ABox: import("react-native-reanimated/lib/typescript/createAnimatedComponent").AnimatedComponentType<Readonly<Omit<import("react-native").ViewProps & import("react").RefAttributes<import("react-native").View>, "align" | "alignContent" | "alignSelf" | "aspectRatio" | "basis" | "bg" | "blur" | "borderColor" | "borderRadius" | "borderWidth" | "bottom" | "columnGap" | "display" | "flex" | "flexDirection" | "gap" | "grow" | "h" | "justify" | "left" | "m" | "maxH" | "maxW" | "mb" | "minH" | "minW" | "ml" | "mr" | "mt" | "mx" | "my" | "offsetX" | "offsetY" | "opacity" | "overflow" | "p" | "pb" | "pl" | "position" | "pr" | "pt" | "px" | "py" | "right" | "rotate" | "rowGap" | "scale" | "shadow" | "shrink" | "style" | "tall" | "top" | "w" | "wide" | "wrap" | "zIndex" | keyof {
1
+ export declare const ABox: import("react-native-reanimated/lib/typescript/createAnimatedComponent").AnimatedComponentType<Readonly<Omit<import("react-native").ViewProps & import("react").RefAttributes<import("react-native").View>, "align" | "alignContent" | "alignSelf" | "aspectRatio" | "basis" | "bg" | "blur" | "borderColor" | "borderRadius" | "borderWidth" | "bottom" | "columnGap" | "display" | "flex" | "flexDirection" | "gap" | "grow" | "h" | "inset" | "justify" | "left" | "m" | "maxH" | "maxW" | "mb" | "minH" | "minW" | "ml" | "mr" | "mt" | "mx" | "my" | "offsetX" | "offsetY" | "opacity" | "overflow" | "p" | "pb" | "pl" | "position" | "pr" | "pt" | "px" | "py" | "right" | "rotate" | "rowGap" | "scale" | "shadow" | "shrink" | "style" | "tall" | "top" | "w" | "wide" | "wrap" | "zIndex" | keyof {
2
2
  borderBottomWidth?: number;
3
3
  borderLeftWidth?: number;
4
4
  borderRightWidth?: number;
@@ -2,18 +2,25 @@ import type { ResponsiveViewSx } from '@hzblj/kara-sx';
2
2
  import type { ColorToken } from '@hzblj/kara-theme';
3
3
  import type { ReactNode } from 'react';
4
4
  /**
5
- * iOS 26 Liquid Glass around a React Native subtree, shaped as a capsule — the React Native tier, so it needs no host
6
- * and costs next to nothing in a list cell. Where there is no Liquid Glass (Android, and iOS before 26) it draws a
7
- * capsule of `tint` instead, or of the glass buttons' translucent fill (`btn.bg.glass.base`) when there is none.
5
+ * Glass around a React Native subtree, shaped as a capsule — the React Native tier, so it needs no host. iOS 26:
6
+ * Liquid Glass. Android: frosted glass — what lies behind, blurred on Android 12+, under a translucent tonal surface
7
+ * (or `tint`) and a hairline. iOS before 26 has no Liquid Glass and draws a capsule of `tint` instead, or of the glass
8
+ * buttons' translucent fill (`btn.bg.glass.base`) when there is none.
9
+ *
10
+ * On Android each glass re-records what lies behind it before every frame: a few buttons cost nothing, but keep it out
11
+ * of the cells of a long list — a plain `tint` reads as well there.
8
12
  */
9
13
  export type GlassViewProps = ResponsiveViewSx & {
10
14
  /** React Native views. Give them `pointerEvents="none"` when `interactive`, so the press reaches the `Pressable`. */
11
15
  children?: ReactNode;
12
- /** Swells toward the finger on touch, carrying the children with it. Wrap the view in a `Pressable` for the press. */
16
+ /**
17
+ * iOS 26: swells toward the finger on touch, carrying the children with it. Android has no swell: wrap the view in a
18
+ * `Pressable` with `borderRadius="full"`, whose ripple then keeps to the capsule. The press is always the `Pressable`'s.
19
+ */
13
20
  interactive?: boolean;
14
21
  /** Test identifier, forwarded to the view. */
15
22
  testID?: string;
16
- /** Tints the material. Unset leaves it clear. */
23
+ /** Tints the material. Unset leaves it clear on iOS, and the translucent surface colour on Android. */
17
24
  tint?: ColorToken;
18
25
  };
19
26
  export type GlassViewComponent = (props: GlassViewProps) => ReactNode;
@@ -1,4 +1,12 @@
1
- import { ImageProps } from 'expo-image';
2
- import { FC } from 'react';
3
- declare const Image: FC<ImageProps>;
4
- export { Image };
1
+ import { Image as ExpoImage, type ImageProps as ExpoImageProps } from 'expo-image';
2
+ import type { Ref } from 'react';
3
+ /**
4
+ * `expo-image` with the `sx` props, the way `Box` is a `View` with them, and the design system's 100 ms linear fade
5
+ * already applied, so a loaded image never pops in. An explicit `transition` wins, and so does an explicit `style`.
6
+ */
7
+ export declare const Image: import("react").MemoExoticComponent<{
8
+ ({ style, ...props }: import("@hzblj/kara-sx").SxProps<ExpoImageProps & {
9
+ ref?: Ref<ExpoImage>;
10
+ }>): import("react").JSX.Element;
11
+ displayName: string;
12
+ }>;
@@ -0,0 +1,4 @@
1
+ import type { ComponentProps } from 'react';
2
+ import type { Image } from './image';
3
+ /** Derived from the component itself, so it cannot drift from what `sx(Image)` actually accepts. */
4
+ export type ImageProps = ComponentProps<typeof Image>;
@@ -1 +1,2 @@
1
1
  export * from './image';
2
+ export * from './image.types';
@@ -1,6 +1,7 @@
1
1
  export * from './activity-indicator';
2
2
  export * from './avatar';
3
3
  export * from './badge';
4
+ export * from './blur-view';
4
5
  export * from './box';
5
6
  export * from './button';
6
7
  export * from './card';
@@ -1,7 +1,11 @@
1
+ import type { ResponsiveViewSx } from '@hzblj/kara-sx';
1
2
  import type { ReactNode } from 'react';
2
3
  import type { StyleProp, ViewStyle } from 'react-native';
3
- /** A host for native atoms in a React Native layout — the SwiftUI / Compose `Host` an `@expo/ui` tree mounts into. */
4
- export type IslandProps = {
4
+ /**
5
+ * A host for native atoms in a React Native layout — the SwiftUI / Compose `Host` an `@expo/ui` tree mounts into. It
6
+ * sits in that layout like a `Box`, and takes `Box`'s `sx` props for it: `h`, `flex`, margins.
7
+ */
8
+ export type IslandProps = ResponsiveViewSx & {
5
9
  /** The native views it hosts. */
6
10
  children?: ReactNode;
7
11
  /**
@@ -10,13 +14,13 @@ export type IslandProps = {
10
14
  * width maps to `fixedSize(horizontal: true)`, so the native side ignores the proposed width and
11
15
  * resolves a `wide` stack's ideal width as unbounded.
12
16
  *
13
- * Turn it off — and give the island an explicit size via `style` — when the subtree contains an
17
+ * Turn it off — and give the island an explicit height, `h` — when the subtree contains an
14
18
  * `RnView`: that host drives its SwiftUI frame from the child's Yoga-laid-out bounds while this one
15
19
  * writes its measured size back into the Yoga style, and the two together spin a layout loop that
16
20
  * hangs the main thread as soon as the views lay out on screen.
17
21
  */
18
22
  matchContents?: boolean;
19
- /** A React Native style for the host view — its size and placement. It needs a height when `matchContents` is off. */
23
+ /** A React Native style for the host view, merged over the `sx` props — for what they cannot say. */
20
24
  style?: StyleProp<ViewStyle>;
21
25
  /** Test identifier, forwarded to the host view on iOS — Android ignores it. */
22
26
  testID?: string;
@@ -2,13 +2,15 @@ import type { ResponsiveViewSx } from '@hzblj/kara-sx';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { Haptic } from '../../haptics';
4
4
  /**
5
- * React Native's `Pressable`, styled through `sx` like a `Box`: it springs down to 96% while pressed and takes
6
- * touches 8 points past its edges. The React Native tier — it needs no host.
5
+ * React Native's `Pressable`, styled through `sx` like a `Box`, taking touches 8 points past its edges. The press is
6
+ * each platform's own: iOS springs it down to 96%; Android draws Material's ripple over the content, clipped to the
7
+ * pressable's shape — give it the `borderRadius` of what it wraps (`full` around a `GlassView`). The React Native
8
+ * tier — it needs no host.
7
9
  */
8
10
  export type PressableProps = ResponsiveViewSx & {
9
11
  /** The pressable content. */
10
12
  children?: ReactNode;
11
- /** Ignores presses — no `onPress`, no haptic, no spring. */
13
+ /** Ignores presses — no `onPress`, no haptic, no spring or ripple. */
12
14
  disabled?: boolean;
13
15
  /** Played on press. `true` is a `light` impact; a name picks the haptic, e.g. `selection` for a choice. */
14
16
  haptic?: boolean | Haptic;
@@ -1,8 +1,13 @@
1
+ import type { ResponsiveViewSx } from '@hzblj/kara-sx';
1
2
  import type { ColorToken, TextVariant } from '@hzblj/kara-theme';
2
3
  import type { ReactNode } from 'react';
3
4
  import type { TextProps as RNTextProps } from 'react-native';
4
- /** React Native's `Text` in a theme typography variant — the React Native tier, for text outside a native host. */
5
- export type RnTextProps = Omit<RNTextProps, 'style'> & {
5
+ /**
6
+ * React Native's `Text` in a theme typography variant — the React Native tier, for text outside a native host. It takes
7
+ * `Box`'s `sx` surface for its own box — margins, flex, padding, a background — all but `align`, which here aligns the
8
+ * lines.
9
+ */
10
+ export type RnTextProps = Omit<RNTextProps, 'style'> & Omit<ResponsiveViewSx, 'align'> & {
6
11
  /** Horizontal alignment, as React Native's `textAlign`. */
7
12
  align?: 'center' | 'left' | 'right';
8
13
  /** The text's colour. `content.primary` by default. */
@@ -1,14 +1,18 @@
1
+ import type { SxDimension } from '@hzblj/kara-sx';
1
2
  import type { RadiiSize } from '@hzblj/kara-theme';
2
3
  import type { ReactNode } from 'react';
3
- /** A loading placeholder that pulses in `fill.quaternary` — a React Native view, so it needs no host. */
4
+ /**
5
+ * A loading placeholder that pulses in `fill.quaternary` — a React Native view, so it needs no host. Sized with the
6
+ * `sx` names: `w`, `h`, `borderRadius`.
7
+ */
4
8
  export type SkeletonProps = {
5
9
  /** The corner radius. `small` by default. */
6
10
  borderRadius?: RadiiSize;
7
11
  /** In points. */
8
- height: number;
12
+ h: number;
9
13
  /** Test identifier, forwarded to the view. */
10
14
  testID?: string;
11
- /** In points. Leave it unset and it fills the available width. */
12
- width?: number;
15
+ /** In points, or a percentage of the row (`60%` for a line that ends early). Unset, it fills the row. */
16
+ w?: SxDimension;
13
17
  };
14
18
  export type SkeletonComponent = (props: SkeletonProps) => ReactNode;
@@ -1,10 +1,15 @@
1
+ import type { ResponsiveSx } from '@hzblj/kara-sx';
1
2
  import type { ColorToken, TextVariant } from '@hzblj/kara-theme';
2
3
  import type { ReactNode } from 'react';
3
4
  export type TextAlign = 'center' | 'left' | 'right';
4
5
  export type TextDecoration = 'none' | 'strikethrough' | 'underline';
5
6
  export type TextTransform = 'lowercase' | 'uppercase';
6
- /** SwiftUI `Text` / Compose `Text` in a theme typography variant — a native atom; outside a host, use `RnText`. */
7
- export type TextProps = {
7
+ /**
8
+ * SwiftUI `Text` / Compose `Text` in a theme typography variant — a native atom; outside a host, use `RnText`. It takes
9
+ * the native `sx` surface too: padding, a frame (`wide` lines it up by `align`), a background, and the `ios` bucket's
10
+ * `contentTransition`, `animation` and `monospacedDigit` for a number that changes in place.
11
+ */
12
+ export type TextProps = ResponsiveSx & {
8
13
  /**
9
14
  * How its lines align. iOS reads `left` and `right` as leading and trailing, so they flip in a right-to-left
10
15
  * layout; Android keeps them as they are.
@@ -3,8 +3,10 @@ import type { ResponsiveViewSx } from '@hzblj/kara-sx';
3
3
  import type { ReactElement, ReactNode } from 'react';
4
4
  export type { ScrollEdgeEffect, ScrollEdgeScrollableProps } from '@hzblj/kara-native/swift-ui';
5
5
  /**
6
- * Bars over one React Native scroll view, with the iOS 26 scroll edge effect under them — the system's progressive
7
- * blur where content scrolls past a bar. The React Native tier: it needs no host.
6
+ * Bars over one React Native scroll view, with each platform's scroll edge under them — on iOS 26 the system's
7
+ * progressive blur where content scrolls past a bar; on Android a Material top app bar's behaviour, the bars stacked
8
+ * around the scroll view and filling with `surface.secondary` once content scrolls under them. The React Native tier:
9
+ * it needs no host.
8
10
  *
9
11
  * A screen-level container: wrap the screen's scroll view with it. Mounted inside a cell of a virtualized list on iOS
10
12
  * it draws only its bottom bar — the hosted scroll view and the top bar stay blank.
@@ -15,7 +17,7 @@ export type ScrollEdgeContainerProps = ResponsiveViewSx & {
15
17
  * content begins below the top bar and scrolls under it. On by default.
16
18
  */
17
19
  automaticInsets?: boolean;
18
- /** Laid over the scroll view's bottom edge on iOS; stacked below it on Android, where it wants a background. */
20
+ /** Laid over the scroll view's bottom edge on iOS; stacked below it on Android, filled while content continues below. */
19
21
  bottomBar?: ReactNode;
20
22
  /** Exactly one React Native scroll view — `RnScrollView`, `RnFlatList`, `RnSectionList`. */
21
23
  children: ReactElement<ScrollEdgeScrollableProps>;
@@ -23,7 +25,7 @@ export type ScrollEdgeContainerProps = ResponsiveViewSx & {
23
25
  effect?: ScrollEdgeEffect;
24
26
  /** Test identifier, forwarded to the container view. */
25
27
  testID?: string;
26
- /** Laid over the scroll view's top edge on iOS; stacked above it on Android, where it wants a background. */
28
+ /** Laid over the scroll view's top edge on iOS; stacked above it on Android, filled once content scrolls under it. */
27
29
  topBar?: ReactNode;
28
30
  };
29
31
  export type ScrollEdgeContainerComponent = (props: ScrollEdgeContainerProps) => ReactNode;
@@ -1,2 +1,7 @@
1
1
  import type { StepperComponent } from './stepper.types';
2
+ /**
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
+ * 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.
6
+ */
2
7
  export declare const Stepper: StepperComponent;
@@ -4,10 +4,7 @@ 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
- * The leading text. iOS shows only the label, not the value — put the value in it if it should be seen. Android
9
- * shows the value between its buttons.
10
- */
7
+ /** The leading text. The value is shown too — before the control on iOS, between the buttons on Android. */
11
8
  label: string;
12
9
  /** The highest value. When unset, Android has no upper limit and iOS stops at `100`. */
13
10
  max?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzblj/kara-components",
3
- "version": "0.7.0",
3
+ "version": "0.8.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",
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/hzblj/kara-ui/issues"
14
14
  },
15
- "homepage": "https://kara.janblazej.dev/docs/components",
15
+ "homepage": "https://www.kara.janblazej.dev/docs/components",
16
16
  "keywords": [
17
17
  "react-native",
18
18
  "expo",
@@ -59,9 +59,9 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
- "@hzblj/kara-native": "^0.7.0",
63
- "@hzblj/kara-sx": "^0.7.0",
64
- "@hzblj/kara-theme": "^0.7.0",
62
+ "@hzblj/kara-native": "^0.8.0",
63
+ "@hzblj/kara-sx": "^0.8.0",
64
+ "@hzblj/kara-theme": "^0.8.0",
65
65
  "sf-symbols-typescript": "^2.2.0"
66
66
  },
67
67
  "peerDependencies": {
@@ -0,0 +1,32 @@
1
+ import {Host, LoadingIndicator} from '@expo/ui/jetpack-compose'
2
+ import {fillMaxSize, testID as testIdModifier} from '@expo/ui/jetpack-compose/modifiers'
3
+ import {useAppTheme} from '@hzblj/kara-theme'
4
+ import {useMemo} from 'react'
5
+ import {StyleSheet} from 'react-native'
6
+
7
+ import type {ActivityIndicatorComponent, ActivityIndicatorProps} from './activity-indicator.types'
8
+
9
+ /** Material's 48dp for a screen; half of it in a row, about where React Native's small spinner sat. */
10
+ const styles = StyleSheet.create({
11
+ large: {height: 48, width: 48},
12
+ small: {height: 24, width: 24},
13
+ })
14
+
15
+ /**
16
+ * Material 3's expressive `LoadingIndicator` in a host of its own, sized here rather than measured, so it renders
17
+ * anywhere and takes its place in the first frame.
18
+ */
19
+ export const ActivityIndicator: ActivityIndicatorComponent = ({
20
+ color = 'fill.accent.primary',
21
+ size = 'small',
22
+ testID,
23
+ }: ActivityIndicatorProps) => {
24
+ const theme = useAppTheme()
25
+ const modifiers = useMemo(() => (testID ? [fillMaxSize(), testIdModifier(testID)] : [fillMaxSize()]), [testID])
26
+
27
+ return (
28
+ <Host colorScheme={theme.dark ? 'dark' : 'light'} seedColor={theme.materialSeed} style={styles[size]}>
29
+ <LoadingIndicator color={theme.color(color)} modifiers={modifiers} />
30
+ </Host>
31
+ )
32
+ }
@@ -0,0 +1,15 @@
1
+ import {useAppTheme} from '@hzblj/kara-theme'
2
+ import {ActivityIndicator as RNActivityIndicator} from 'react-native'
3
+
4
+ import type {ActivityIndicatorComponent, ActivityIndicatorProps} from './activity-indicator.types'
5
+
6
+ /** React Native's spinner, which on iOS is UIKit's own `UIActivityIndicatorView`. */
7
+ export const ActivityIndicator: ActivityIndicatorComponent = ({
8
+ color = 'fill.accent.primary',
9
+ size = 'small',
10
+ testID,
11
+ }: ActivityIndicatorProps) => {
12
+ const theme = useAppTheme()
13
+
14
+ return <RNActivityIndicator color={theme.color(color)} size={size} testID={testID} />
15
+ }
@@ -0,0 +1,20 @@
1
+ import type {ColorToken} from '@hzblj/kara-theme'
2
+ import type {ReactNode} from 'react'
3
+
4
+ export type ActivityIndicatorSize = 'large' | 'small'
5
+
6
+ /**
7
+ * That something is loading, for as long as it takes — UIKit's spinner on iOS, Material 3's expressive
8
+ * `LoadingIndicator` on Android, its shapes morphing as it turns. A React Native view on iOS and a host of its own on
9
+ * Android, so it renders anywhere. For how far along something is, use `Progress`.
10
+ */
11
+ export type ActivityIndicatorProps = {
12
+ /** Its colour. `fill.accent.primary` by default. */
13
+ color?: ColorToken
14
+ /** `small` sits in a row or a button, `large` holds a screen that is loading. `small` by default. */
15
+ size?: ActivityIndicatorSize
16
+ /** Test identifier, forwarded to the view. */
17
+ testID?: string
18
+ }
19
+
20
+ export type ActivityIndicatorComponent = (props: ActivityIndicatorProps) => ReactNode
@@ -1 +1,2 @@
1
1
  export * from './activity-indicator'
2
+ export * from './activity-indicator.types'
@@ -32,7 +32,7 @@ export const Avatar: AvatarComponent = ({initials, size = 'md', source, testID}:
32
32
  w={diameter}
33
33
  >
34
34
  {source ? (
35
- <Image source={source} style={{height: diameter, width: diameter}} />
35
+ <Image h={diameter} source={source} w={diameter} />
36
36
  ) : (
37
37
  <RnText color="content.secondary" variant={VARIANT[size]}>
38
38
  {initials ?? ''}
@@ -0,0 +1,68 @@
1
+ import {BackdropBlurView} from '@hzblj/kara-native/jetpack-compose'
2
+ import {useSx} from '@hzblj/kara-sx'
3
+ import {type ColorToken, type OpacitySize, useAppTheme, withOpacity} from '@hzblj/kara-theme'
4
+ import {useMemo} from 'react'
5
+ import {StyleSheet} from 'react-native'
6
+
7
+ import type {BlurMaterial, BlurViewComponent, BlurViewProps} from './blur-view.types'
8
+
9
+ type MaterialSpec = {
10
+ /** dp. */
11
+ blur: number
12
+ /** A Material tonal surface — the thicker the material, the higher the container. */
13
+ fill: ColorToken
14
+ /**
15
+ * How much of the surface covers the blur, light and dark. A dark material covers more, as iOS's do: a dark surface
16
+ * over a bright backdrop otherwise leaves light content on light colour.
17
+ */
18
+ opacity: {dark: OpacitySize; light: OpacitySize}
19
+ /** iOS's materials lift the colour of what they blur; a plain blur greys it into mud. */
20
+ saturation: number
21
+ }
22
+
23
+ const MATERIALS: Record<BlurMaterial, MaterialSpec> = {
24
+ regular: {blur: 28, fill: 'surface.secondary', opacity: {dark: 'o75', light: 'o60'}, saturation: 1.6},
25
+ thick: {blur: 30, fill: 'surface.secondary', opacity: {dark: 'o85', light: 'o80'}, saturation: 1.4},
26
+ thin: {blur: 24, fill: 'surface.primary', opacity: {dark: 'o60', light: 'o40'}, saturation: 1.7},
27
+ ultraThick: {blur: 32, fill: 'fill.quaternary', opacity: {dark: 'o90', light: 'o90'}, saturation: 1.2},
28
+ ultraThin: {blur: 20, fill: 'surface.base', opacity: {dark: 'o50', light: 'o25'}, saturation: 1.8},
29
+ }
30
+
31
+ /**
32
+ * The materials in Android's terms: kara's `BackdropBlurView` — what lies behind, blurred and saturated — under a
33
+ * Material tonal surface that gets higher and more opaque as the material thickens. Pinned to the appearance the app
34
+ * is not in, the surface is Material's inverse one. `vibrancy` has no Android counterpart and is left out.
35
+ */
36
+ export const BlurView: BlurViewComponent = ({
37
+ appearance,
38
+ children,
39
+ material = 'regular',
40
+ testID,
41
+ vibrancy: _vibrancy,
42
+ ...sx
43
+ }: BlurViewProps) => {
44
+ const theme = useAppTheme()
45
+ const resolved = useSx(sx)
46
+ const spec = MATERIALS[material]
47
+ const inverted = appearance !== undefined && (appearance === 'dark') !== theme.dark
48
+ const dark = appearance ? appearance === 'dark' : theme.dark
49
+ const base = String(theme.color(inverted ? 'surface.high.contrast' : spec.fill))
50
+ const {cornerRadius, style} = useMemo(() => {
51
+ const {borderRadius, ...rest} = StyleSheet.flatten(resolved) ?? {}
52
+ return {cornerRadius: typeof borderRadius === 'number' ? borderRadius : 0, style: rest}
53
+ }, [resolved])
54
+
55
+ return (
56
+ <BackdropBlurView
57
+ blurRadius={spec.blur}
58
+ cornerRadius={cornerRadius}
59
+ fallbackTint={withOpacity(base, 'o95')}
60
+ glassTint={withOpacity(base, spec.opacity[dark ? 'dark' : 'light'])}
61
+ saturation={spec.saturation}
62
+ style={style}
63
+ testID={testID}
64
+ >
65
+ {children}
66
+ </BackdropBlurView>
67
+ )
68
+ }