@ankhorage/zora 5.0.0 → 7.0.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 (185) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +14 -10
  3. package/dist/components/button/resolveButtonThemeRecipe.d.ts +1 -1
  4. package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
  5. package/dist/components/date-picker/DatePicker.js +92 -86
  6. package/dist/components/date-picker/DatePicker.js.map +1 -1
  7. package/dist/components/date-picker/meta.d.ts +1 -1
  8. package/dist/components/date-picker/meta.js +1 -1
  9. package/dist/components/date-picker/meta.js.map +1 -1
  10. package/dist/components/heading/resolveHeadingThemeRecipe.d.ts +1 -1
  11. package/dist/components/image/Image.d.ts +1 -5
  12. package/dist/components/image/Image.d.ts.map +1 -1
  13. package/dist/components/image/Image.js +79 -8
  14. package/dist/components/image/Image.js.map +1 -1
  15. package/dist/components/image/types.d.ts +4 -2
  16. package/dist/components/image/types.d.ts.map +1 -1
  17. package/dist/components/image/types.js.map +1 -1
  18. package/dist/components/text/resolveTextThemeRecipe.d.ts +1 -1
  19. package/dist/components/time-picker/TimePicker.d.ts +1 -3
  20. package/dist/components/time-picker/TimePicker.d.ts.map +1 -1
  21. package/dist/components/time-picker/TimePicker.js +55 -32
  22. package/dist/components/time-picker/TimePicker.js.map +1 -1
  23. package/dist/components/time-picker/meta.d.ts +1 -1
  24. package/dist/components/time-picker/meta.js +1 -1
  25. package/dist/components/time-picker/meta.js.map +1 -1
  26. package/dist/features/bottom-sheet/public.d.ts +3 -0
  27. package/dist/features/bottom-sheet/public.d.ts.map +1 -0
  28. package/dist/features/bottom-sheet/public.js +2 -0
  29. package/dist/features/bottom-sheet/public.js.map +1 -0
  30. package/dist/features/uploader/adapters/inbound/Uploader.d.ts +5 -0
  31. package/dist/features/uploader/adapters/inbound/Uploader.d.ts.map +1 -0
  32. package/dist/features/uploader/adapters/inbound/Uploader.js +274 -0
  33. package/dist/features/uploader/adapters/inbound/Uploader.js.map +1 -0
  34. package/dist/features/uploader/adapters/outbound/pickDocumentOrFileAsync.d.ts +5 -0
  35. package/dist/features/uploader/adapters/outbound/pickDocumentOrFileAsync.d.ts.map +1 -0
  36. package/dist/features/uploader/adapters/outbound/pickDocumentOrFileAsync.js +38 -0
  37. package/dist/features/uploader/adapters/outbound/pickDocumentOrFileAsync.js.map +1 -0
  38. package/dist/features/uploader/adapters/outbound/pickImageOrVideoAsync.d.ts +5 -0
  39. package/dist/features/uploader/adapters/outbound/pickImageOrVideoAsync.d.ts.map +1 -0
  40. package/dist/features/uploader/adapters/outbound/pickImageOrVideoAsync.js +24 -0
  41. package/dist/features/uploader/adapters/outbound/pickImageOrVideoAsync.js.map +1 -0
  42. package/dist/features/uploader/application/ports/outbound/UploadPickerPort.d.ts +9 -0
  43. package/dist/features/uploader/application/ports/outbound/UploadPickerPort.d.ts.map +1 -0
  44. package/dist/features/uploader/application/ports/outbound/UploadPickerPort.js +2 -0
  45. package/dist/features/uploader/application/ports/outbound/UploadPickerPort.js.map +1 -0
  46. package/dist/features/uploader/application/use-cases/pickUploadAssetAsync.d.ts +5 -0
  47. package/dist/features/uploader/application/use-cases/pickUploadAssetAsync.d.ts.map +1 -0
  48. package/dist/features/uploader/application/use-cases/pickUploadAssetAsync.js +6 -0
  49. package/dist/features/uploader/application/use-cases/pickUploadAssetAsync.js.map +1 -0
  50. package/dist/features/uploader/application/use-cases/validateUploadAsset.d.ts +4 -0
  51. package/dist/features/uploader/application/use-cases/validateUploadAsset.d.ts.map +1 -0
  52. package/dist/features/uploader/application/use-cases/validateUploadAsset.js +77 -0
  53. package/dist/features/uploader/application/use-cases/validateUploadAsset.js.map +1 -0
  54. package/dist/features/uploader/composition/createUploadPicker.d.ts +4 -0
  55. package/dist/features/uploader/composition/createUploadPicker.d.ts.map +1 -0
  56. package/dist/features/uploader/composition/createUploadPicker.js +12 -0
  57. package/dist/features/uploader/composition/createUploadPicker.js.map +1 -0
  58. package/dist/features/uploader/meta.d.ts +10 -0
  59. package/dist/features/uploader/meta.d.ts.map +1 -0
  60. package/dist/features/uploader/meta.js +10 -0
  61. package/dist/features/uploader/meta.js.map +1 -0
  62. package/dist/features/uploader/public.d.ts +4 -0
  63. package/dist/features/uploader/public.d.ts.map +1 -0
  64. package/dist/features/uploader/public.js +3 -0
  65. package/dist/features/uploader/public.js.map +1 -0
  66. package/dist/index.d.ts +2 -6
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +1 -3
  69. package/dist/index.js.map +1 -1
  70. package/dist/metadata/componentMeta.d.ts.map +1 -1
  71. package/dist/metadata/componentMeta.js +2 -7
  72. package/dist/metadata/componentMeta.js.map +1 -1
  73. package/dist/registry.d.ts.map +1 -1
  74. package/dist/registry.js +2 -7
  75. package/dist/registry.js.map +1 -1
  76. package/dist/theme/ZoraProvider.d.ts +1 -1
  77. package/dist/theme/ZoraProvider.d.ts.map +1 -1
  78. package/dist/theme/ZoraProvider.js +3 -2
  79. package/dist/theme/ZoraProvider.js.map +1 -1
  80. package/dist/theme/useZoraTheme.d.ts +1 -1
  81. package/dist/types/upload.d.ts +53 -0
  82. package/dist/types/upload.d.ts.map +1 -0
  83. package/dist/types/upload.js +2 -0
  84. package/dist/types/upload.js.map +1 -0
  85. package/package.json +25 -3
  86. package/src/components/date-picker/DatePicker.tsx +197 -129
  87. package/src/components/date-picker/meta.ts +1 -1
  88. package/src/components/image/Image.tsx +136 -8
  89. package/src/components/image/types.ts +6 -2
  90. package/src/components/time-picker/TimePicker.tsx +147 -60
  91. package/src/components/time-picker/meta.ts +1 -1
  92. package/src/expo57Migration.test.ts +56 -0
  93. package/src/features/bottom-sheet/public.test.ts +39 -0
  94. package/src/features/bottom-sheet/public.ts +5 -0
  95. package/src/features/uploader/adapters/inbound/Uploader.tsx +403 -0
  96. package/src/features/uploader/adapters/outbound/pickDocumentOrFileAsync.ts +50 -0
  97. package/src/features/uploader/adapters/outbound/pickImageOrVideoAsync.ts +30 -0
  98. package/src/features/uploader/application/ports/outbound/UploadPickerPort.ts +10 -0
  99. package/src/features/uploader/application/use-cases/pickUploadAssetAsync.test.ts +48 -0
  100. package/src/features/uploader/application/use-cases/pickUploadAssetAsync.ts +14 -0
  101. package/src/features/uploader/application/use-cases/validateUploadAsset.test.ts +51 -0
  102. package/src/features/uploader/application/use-cases/validateUploadAsset.ts +111 -0
  103. package/src/features/uploader/composition/createUploadPicker.ts +14 -0
  104. package/src/features/uploader/meta.ts +11 -0
  105. package/src/features/uploader/public.test.ts +34 -0
  106. package/src/features/uploader/public.ts +10 -0
  107. package/src/index.ts +9 -14
  108. package/src/metadata/componentMeta.ts +2 -7
  109. package/src/platformAcceptance.test.ts +1 -1
  110. package/src/registry.test.ts +1 -1
  111. package/src/registry.ts +2 -7
  112. package/src/showcaseCoverage.test.ts +1 -2
  113. package/src/theme/ZoraProvider.tsx +3 -2
  114. package/src/types/upload.ts +62 -0
  115. package/dist/components/action-sheet/ActionSheet.d.ts +0 -7
  116. package/dist/components/action-sheet/ActionSheet.d.ts.map +0 -1
  117. package/dist/components/action-sheet/ActionSheet.js +0 -11
  118. package/dist/components/action-sheet/ActionSheet.js.map +0 -1
  119. package/dist/components/action-sheet/ActionSheetItem.d.ts +0 -7
  120. package/dist/components/action-sheet/ActionSheetItem.d.ts.map +0 -1
  121. package/dist/components/action-sheet/ActionSheetItem.js +0 -17
  122. package/dist/components/action-sheet/ActionSheetItem.js.map +0 -1
  123. package/dist/components/action-sheet/index.d.ts +0 -4
  124. package/dist/components/action-sheet/index.d.ts.map +0 -1
  125. package/dist/components/action-sheet/index.js +0 -3
  126. package/dist/components/action-sheet/index.js.map +0 -1
  127. package/dist/components/action-sheet/meta.d.ts +0 -17
  128. package/dist/components/action-sheet/meta.d.ts.map +0 -1
  129. package/dist/components/action-sheet/meta.js +0 -17
  130. package/dist/components/action-sheet/meta.js.map +0 -1
  131. package/dist/components/action-sheet/types.d.ts +0 -13
  132. package/dist/components/action-sheet/types.d.ts.map +0 -1
  133. package/dist/components/action-sheet/types.js +0 -2
  134. package/dist/components/action-sheet/types.js.map +0 -1
  135. package/dist/patterns/image-preview/ImagePreview.d.ts +0 -9
  136. package/dist/patterns/image-preview/ImagePreview.d.ts.map +0 -1
  137. package/dist/patterns/image-preview/ImagePreview.js +0 -46
  138. package/dist/patterns/image-preview/ImagePreview.js.map +0 -1
  139. package/dist/patterns/image-preview/index.d.ts +0 -3
  140. package/dist/patterns/image-preview/index.d.ts.map +0 -1
  141. package/dist/patterns/image-preview/index.js +0 -2
  142. package/dist/patterns/image-preview/index.js.map +0 -1
  143. package/dist/patterns/image-preview/meta.d.ts +0 -9
  144. package/dist/patterns/image-preview/meta.d.ts.map +0 -1
  145. package/dist/patterns/image-preview/meta.js +0 -9
  146. package/dist/patterns/image-preview/meta.js.map +0 -1
  147. package/dist/patterns/image-preview/types.d.ts +0 -36
  148. package/dist/patterns/image-preview/types.d.ts.map +0 -1
  149. package/dist/patterns/image-preview/types.js +0 -2
  150. package/dist/patterns/image-preview/types.js.map +0 -1
  151. package/dist/patterns/image-upload-field/ImageUploadField.d.ts +0 -9
  152. package/dist/patterns/image-upload-field/ImageUploadField.d.ts.map +0 -1
  153. package/dist/patterns/image-upload-field/ImageUploadField.js +0 -222
  154. package/dist/patterns/image-upload-field/ImageUploadField.js.map +0 -1
  155. package/dist/patterns/image-upload-field/index.d.ts +0 -3
  156. package/dist/patterns/image-upload-field/index.d.ts.map +0 -1
  157. package/dist/patterns/image-upload-field/index.js +0 -2
  158. package/dist/patterns/image-upload-field/index.js.map +0 -1
  159. package/dist/patterns/image-upload-field/meta.d.ts +0 -9
  160. package/dist/patterns/image-upload-field/meta.d.ts.map +0 -1
  161. package/dist/patterns/image-upload-field/meta.js +0 -9
  162. package/dist/patterns/image-upload-field/meta.js.map +0 -1
  163. package/dist/patterns/image-upload-field/types.d.ts +0 -35
  164. package/dist/patterns/image-upload-field/types.d.ts.map +0 -1
  165. package/dist/patterns/image-upload-field/types.js +0 -2
  166. package/dist/patterns/image-upload-field/types.js.map +0 -1
  167. package/dist/patterns/image-upload-field/uploadFlow.d.ts +0 -18
  168. package/dist/patterns/image-upload-field/uploadFlow.d.ts.map +0 -1
  169. package/dist/patterns/image-upload-field/uploadFlow.js +0 -106
  170. package/dist/patterns/image-upload-field/uploadFlow.js.map +0 -1
  171. package/src/components/action-sheet/ActionSheet.tsx +0 -14
  172. package/src/components/action-sheet/ActionSheetItem.tsx +0 -30
  173. package/src/components/action-sheet/index.ts +0 -3
  174. package/src/components/action-sheet/meta.ts +0 -19
  175. package/src/components/action-sheet/types.ts +0 -23
  176. package/src/patterns/image-preview/ImagePreview.tsx +0 -82
  177. package/src/patterns/image-preview/index.ts +0 -2
  178. package/src/patterns/image-preview/meta.ts +0 -10
  179. package/src/patterns/image-preview/types.ts +0 -41
  180. package/src/patterns/image-upload-field/ImageUploadField.tsx +0 -319
  181. package/src/patterns/image-upload-field/index.ts +0 -2
  182. package/src/patterns/image-upload-field/meta.ts +0 -10
  183. package/src/patterns/image-upload-field/types.ts +0 -41
  184. package/src/patterns/image-upload-field/uploadFlow.test.ts +0 -117
  185. package/src/patterns/image-upload-field/uploadFlow.ts +0 -145
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 75d39e6: Replace `ImagePreview` and `ImageUploadField` with the canonical `Image` asset renderer and generic `Uploader`, backed by Expo image and document pickers.
8
+
9
+ ## 6.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 8ceb824: Integrate the Surface 4 BottomSheet runtime into `ZoraProvider`, expose the supported controller API
14
+ through `@ankhorage/zora/bottom-sheet`, migrate the date and time pickers, and remove the obsolete
15
+ `ActionSheet` and `ActionSheetItem` exports. Expo hosts must now install the gesture-handler,
16
+ Reanimated, and Worklets peers and own `GestureHandlerRootView` outside `ZoraProvider`.
17
+
3
18
  ## 5.0.0
4
19
 
5
20
  ### Major Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # ZORA
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v4.5.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![docs: paradox](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v6.0.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![docs: paradox](././paradox/badges/docs.svg)
7
7
 
8
8
  Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.
9
9
 
@@ -26,6 +26,7 @@ import {
26
26
  ZoraProvider,
27
27
  type ZoraTheme,
28
28
  } from '@ankhorage/zora';
29
+ import { GestureHandlerRootView } from 'react-native-gesture-handler';
29
30
 
30
31
  const basicTheme: ZoraTheme = {
31
32
  id: 'basic-app',
@@ -37,15 +38,17 @@ const basicTheme: ZoraTheme = {
37
38
 
38
39
  export default function BasicApp() {
39
40
  return (
40
- <ZoraProvider initialMode="light" theme={basicTheme}>
41
- <AppShell header={<AppBar title="Dashboard" subtitle="Welcome to ZORA" />}>
42
- <Screen>
43
- <ScreenSection>
44
- <Text variant="lead">Build your app content inside the shell.</Text>
45
- </ScreenSection>
46
- </Screen>
47
- </AppShell>
48
- </ZoraProvider>
41
+ <GestureHandlerRootView style={{ flex: 1 }}>
42
+ <ZoraProvider initialMode="light" theme={basicTheme}>
43
+ <AppShell header={<AppBar title="Dashboard" subtitle="Welcome to ZORA" />}>
44
+ <Screen>
45
+ <ScreenSection>
46
+ <Text variant="lead">Build your app content inside the shell.</Text>
47
+ </ScreenSection>
48
+ </Screen>
49
+ </AppShell>
50
+ </ZoraProvider>
51
+ </GestureHandlerRootView>
49
52
  );
50
53
  }
51
54
  ```
@@ -69,3 +72,4 @@ export default function BasicApp() {
69
72
  - [useZoraTheme sequence](././paradox/diagrams/sequences/use-zora-theme.mmd)
70
73
  - [validateField sequence](././paradox/diagrams/sequences/validate-field.mmd)
71
74
  - [validateFields sequence](././paradox/diagrams/sequences/validate-fields.mmd)
75
+ - [validateUploadAsset sequence](././paradox/diagrams/sequences/validate-upload-asset.mmd)
@@ -5,5 +5,5 @@ export declare function resolveButtonThemeRecipe(input: {
5
5
  readonly variant?: ZoraButtonVariant;
6
6
  readonly size?: ZoraControlSize;
7
7
  readonly themeFields: Readonly<Record<string, ThemeRecipeOverrideValue>>;
8
- }): Pick<import("@ankhorage/surface").ButtonProps, "color" | "variant" | "size">;
8
+ }): Pick<import("@ankhorage/surface").ButtonProps, "color" | "size" | "variant">;
9
9
  //# sourceMappingURL=resolveButtonThemeRecipe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/DatePicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA2Q/C;;GAEG;AACH,eAAO,MAAM,UAAU,uDAAsC,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/date-picker/DatePicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA+U/C;;GAEG;AACH,eAAO,MAAM,UAAU,uDAAsC,CAAC"}
@@ -1,12 +1,13 @@
1
1
  import { Field } from '@ankhorage/surface';
2
2
  import React from 'react';
3
+ import { useBottomSheet } from '../../features/bottom-sheet/public';
3
4
  import { Box, Stack } from '../../foundation';
4
5
  import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
5
- import { ActionSheet } from '../action-sheet';
6
6
  import { Button } from '../button';
7
7
  import { Text } from '../text';
8
8
  const WEEKDAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
9
9
  const DAY_CELL_WIDTH = 42;
10
+ /*** Render the field label and optional supporting description. */
10
11
  function renderLabel(label, description) {
11
12
  return (<Stack gap="xs">
12
13
  <Text variant="label" weight="semiBold">
@@ -17,154 +18,159 @@ function renderLabel(label, description) {
17
18
  </Text>) : null}
18
19
  </Stack>);
19
20
  }
21
+ /*** Normalize a date to the start of its local calendar day. */
20
22
  function startOfLocalDay(value) {
21
23
  return new Date(value.getFullYear(), value.getMonth(), value.getDate());
22
24
  }
25
+ /*** Compare two values by local calendar day. */
23
26
  function isSameLocalDay(left, right) {
24
- if (!left) {
27
+ if (!left)
25
28
  return false;
26
- }
27
29
  return startOfLocalDay(left).getTime() === startOfLocalDay(right).getTime();
28
30
  }
31
+ /*** Report whether one local calendar day precedes another. */
29
32
  function isBeforeLocalDay(left, right) {
30
33
  return startOfLocalDay(left).getTime() < startOfLocalDay(right).getTime();
31
34
  }
35
+ /*** Report whether one local calendar day follows another. */
32
36
  function isAfterLocalDay(left, right) {
33
37
  return startOfLocalDay(left).getTime() > startOfLocalDay(right).getTime();
34
38
  }
39
+ /*** Resolve whether a date falls outside the configured picker range. */
35
40
  function isDateDisabled(value, minDate, maxDate) {
36
- if (minDate && isBeforeLocalDay(value, minDate)) {
41
+ if (minDate && isBeforeLocalDay(value, minDate))
37
42
  return true;
38
- }
39
- if (maxDate && isAfterLocalDay(value, maxDate)) {
43
+ if (maxDate && isAfterLocalDay(value, maxDate))
40
44
  return true;
41
- }
42
45
  return false;
43
46
  }
47
+ /*** Format the current calendar month for the picker heading. */
44
48
  function formatMonthLabel(value) {
45
49
  return value.toLocaleDateString(undefined, { month: 'long', year: 'numeric' });
46
50
  }
51
+ /*** Format a selected date with the platform locale defaults. */
47
52
  function formatDefaultDate(value) {
48
53
  return value.toLocaleDateString();
49
54
  }
55
+ /*** Build the padded calendar grid for one month. */
50
56
  function createMonthDays(month) {
51
57
  const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);
52
58
  const dayCount = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();
53
59
  const days = [];
54
- for (let offset = 0; offset < firstDay.getDay(); offset += 1) {
60
+ for (let offset = 0; offset < firstDay.getDay(); offset += 1)
55
61
  days.push(null);
56
- }
57
62
  for (let day = 1; day <= dayCount; day += 1) {
58
63
  days.push(new Date(month.getFullYear(), month.getMonth(), day));
59
64
  }
60
- while (days.length % 7 !== 0) {
65
+ while (days.length % 7 !== 0)
61
66
  days.push(null);
62
- }
63
67
  return days;
64
68
  }
69
+ /*** Resolve the month initially shown by the calendar sheet. */
65
70
  function resolveInitialMonth(value, minDate) {
66
71
  const base = value ?? minDate ?? new Date();
67
72
  return new Date(base.getFullYear(), base.getMonth(), 1);
68
73
  }
74
+ /*** Report whether the configured range intersects a candidate month. */
69
75
  function canNavigateToMonth(month, minDate, maxDate) {
70
76
  const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);
71
77
  const lastDay = new Date(month.getFullYear(), month.getMonth() + 1, 0);
72
- if (maxDate && isAfterLocalDay(firstDay, maxDate)) {
78
+ if (maxDate && isAfterLocalDay(firstDay, maxDate))
73
79
  return false;
74
- }
75
- if (minDate && isBeforeLocalDay(lastDay, minDate)) {
80
+ if (minDate && isBeforeLocalDay(lastDay, minDate))
76
81
  return false;
77
- }
78
82
  return true;
79
83
  }
80
84
  function DatePickerInner({ themeId: _themeId, mode: _mode, value, onValueChange, label, description, error, placeholder = 'Choose date', minDate, maxDate, disabled = false, required = false, formatDate, testID, interactionPolicy, }) {
85
+ const { dismiss, present } = useBottomSheet();
81
86
  const passive = interactionPolicy === 'passive';
82
- const [visible, setVisible] = React.useState(false);
83
- const [fallbackMonth] = React.useState(() => resolveInitialMonth(null, undefined));
84
- const initialMonth = value || minDate ? resolveInitialMonth(value, minDate) : fallbackMonth;
85
- const initialMonthKey = initialMonth.getTime();
86
- const [displayMonthState, setDisplayMonthState] = React.useState(() => ({
87
- sourceMonthKey: initialMonthKey,
88
- month: initialMonth,
89
- }));
90
- const displayMonth = displayMonthState.sourceMonthKey === initialMonthKey ? displayMonthState.month : initialMonth;
91
- const monthDays = React.useMemo(() => createMonthDays(displayMonth), [displayMonth]);
92
- const previousMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() - 1, 1);
93
- const nextMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() + 1, 1);
94
87
  const displayValue = value
95
88
  ? formatDate
96
89
  ? formatDate(value)
97
90
  : formatDefaultDate(value)
98
91
  : placeholder;
99
- function setDisplayMonth(month) {
100
- setDisplayMonthState({ sourceMonthKey: initialMonthKey, month });
101
- }
92
+ /*** Present the calendar content through the shared BottomSheet controller. */
102
93
  function openPicker() {
103
94
  if (passive)
104
95
  return;
105
- setDisplayMonthState({ sourceMonthKey: initialMonthKey, month: initialMonth });
106
- setVisible(true);
96
+ present({
97
+ content: (<DatePickerSheet description={description} interactionPolicy={interactionPolicy} label={label} maxDate={maxDate} minDate={minDate} onDismiss={dismiss} onSelect={(date) => {
98
+ onValueChange?.(startOfLocalDay(date));
99
+ dismiss();
100
+ }} testID={testID} value={value}/>),
101
+ });
107
102
  }
108
103
  return (<Field disabled={disabled} errorText={error} invalid={Boolean(error)} label={label ? renderLabel(label, description) : undefined} required={required} testID={testID}>
109
104
  <Button disabled={disabled} interactionPolicy={interactionPolicy} onPress={openPicker} testID={testID ? `${testID}-trigger` : undefined} trailingIcon={{ name: 'calendar-outline' }} variant="outline">
110
105
  {displayValue}
111
106
  </Button>
112
- <ActionSheet description={description} interactionPolicy={interactionPolicy} onDismiss={() => {
113
- if (passive)
114
- return;
115
- setVisible(false);
116
- }} testID={testID ? `${testID}-sheet` : undefined} title={label ?? 'Choose date'} visible={visible}>
117
- <Stack gap="m">
118
- <Stack align="center" direction="row" justify="space-between">
119
- <Button disabled={!canNavigateToMonth(previousMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => {
120
- if (passive)
121
- return;
122
- setDisplayMonth(previousMonth);
123
- }} size="s" variant="ghost">
124
- Previous
125
- </Button>
126
- <Text align="center" variant="label" weight="semiBold">
127
- {formatMonthLabel(displayMonth)}
128
- </Text>
129
- <Button disabled={!canNavigateToMonth(nextMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => {
130
- if (passive)
131
- return;
132
- setDisplayMonth(nextMonth);
133
- }} size="s" variant="ghost">
134
- Next
135
- </Button>
136
- </Stack>
137
-
138
- <Stack direction="row" justify="space-between">
139
- {WEEKDAY_LABELS.map((weekday) => (<Box key={weekday} style={{ width: DAY_CELL_WIDTH }}>
140
- <Text align="center" emphasis="muted" variant="caption" weight="semiBold">
141
- {weekday}
142
- </Text>
143
- </Box>))}
144
- </Stack>
145
-
146
- <Stack direction="row" gap="xs" style={{ flexWrap: 'wrap' }}>
147
- {monthDays.map((day, index) => {
148
- if (!day) {
149
- return <Box key={`empty-${index}`} style={{ width: DAY_CELL_WIDTH }}/>;
150
- }
107
+ </Field>);
108
+ }
109
+ /*** Render the calendar-specific content inside the shared BottomSheet host. */
110
+ function DatePickerSheet({ description, interactionPolicy, label, maxDate, minDate, onDismiss, onSelect, testID, value, }) {
111
+ const [displayMonth, setDisplayMonth] = React.useState(() => resolveInitialMonth(value, minDate));
112
+ const monthDays = React.useMemo(() => createMonthDays(displayMonth), [displayMonth]);
113
+ return (<Stack gap="m" p="m" testID={testID ? `${testID}-sheet` : undefined}>
114
+ <PickerSheetHeader description={description} title={label ?? 'Choose date'}/>
115
+ <DatePickerMonthNavigation displayMonth={displayMonth} interactionPolicy={interactionPolicy} maxDate={maxDate} minDate={minDate} onMonthChange={setDisplayMonth}/>
116
+ <DatePickerWeekdays />
117
+ <DatePickerCalendar interactionPolicy={interactionPolicy} maxDate={maxDate} minDate={minDate} monthDays={monthDays} onSelect={onSelect} testID={testID} value={value}/>
118
+ <Button fullWidth interactionPolicy={interactionPolicy} onPress={onDismiss} variant="ghost">
119
+ Cancel
120
+ </Button>
121
+ </Stack>);
122
+ }
123
+ /*** Render the shared title block used by the calendar sheet. */
124
+ function PickerSheetHeader({ description, title, }) {
125
+ return (<Stack gap="xxs">
126
+ <Text align="center" variant="label" weight="semiBold">
127
+ {title}
128
+ </Text>
129
+ {description ? (<Text align="center" emphasis="muted" variant="bodySmall">
130
+ {description}
131
+ </Text>) : null}
132
+ </Stack>);
133
+ }
134
+ /*** Render previous/next month controls for the calendar sheet. */
135
+ function DatePickerMonthNavigation({ displayMonth, interactionPolicy, maxDate, minDate, onMonthChange, }) {
136
+ const previousMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() - 1, 1);
137
+ const nextMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() + 1, 1);
138
+ return (<Stack align="center" direction="row" justify="space-between">
139
+ <Button disabled={!canNavigateToMonth(previousMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => onMonthChange(previousMonth)} size="s" variant="ghost">
140
+ Previous
141
+ </Button>
142
+ <Text align="center" variant="label" weight="semiBold">
143
+ {formatMonthLabel(displayMonth)}
144
+ </Text>
145
+ <Button disabled={!canNavigateToMonth(nextMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => onMonthChange(nextMonth)} size="s" variant="ghost">
146
+ Next
147
+ </Button>
148
+ </Stack>);
149
+ }
150
+ /*** Render weekday headings for the calendar grid. */
151
+ function DatePickerWeekdays() {
152
+ return (<Stack direction="row" justify="space-between">
153
+ {WEEKDAY_LABELS.map((weekday) => (<Box key={weekday} width={DAY_CELL_WIDTH}>
154
+ <Text align="center" emphasis="muted" variant="caption" weight="semiBold">
155
+ {weekday}
156
+ </Text>
157
+ </Box>))}
158
+ </Stack>);
159
+ }
160
+ /*** Render selectable day cells for the current calendar month. */
161
+ function DatePickerCalendar({ interactionPolicy, maxDate, minDate, monthDays, onSelect, testID, value, }) {
162
+ return (<Stack direction="row" gap="xs" wrap="wrap">
163
+ {monthDays.map((day, index) => {
164
+ if (!day)
165
+ return <Box key={`empty-${index}`} width={DAY_CELL_WIDTH}/>;
151
166
  const selected = isSameLocalDay(value, day);
152
- const dayDisabled = isDateDisabled(day, minDate, maxDate);
153
- return (<Box key={day.toISOString()} style={{ width: DAY_CELL_WIDTH }}>
154
- <Button color={selected ? 'primary' : 'neutral'} disabled={dayDisabled} interactionPolicy={interactionPolicy} onPress={() => {
155
- if (passive)
156
- return;
157
- onValueChange?.(startOfLocalDay(day));
158
- setVisible(false);
159
- }} size="s" testID={testID ? `${testID}-day-${day.getDate()}` : undefined} variant={selected ? 'solid' : 'ghost'}>
160
- {day.getDate()}
161
- </Button>
162
- </Box>);
167
+ return (<Box key={day.toISOString()} width={DAY_CELL_WIDTH}>
168
+ <Button color={selected ? 'primary' : 'neutral'} disabled={isDateDisabled(day, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => onSelect(day)} size="s" testID={testID ? `${testID}-day-${day.getDate()}` : undefined} variant={selected ? 'solid' : 'ghost'}>
169
+ {day.getDate()}
170
+ </Button>
171
+ </Box>);
163
172
  })}
164
- </Stack>
165
- </Stack>
166
- </ActionSheet>
167
- </Field>);
173
+ </Stack>);
168
174
  }
169
175
  /***
170
176
  * Date input control with calendar selection and formatted display value.
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/components/date-picker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,WAAW,EAA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G;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { Field } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { Box, Stack } from '../../foundation';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport { ActionSheet } from '../action-sheet';\nimport { Button } from '../button';\nimport { Text } from '../text';\nimport type { DatePickerProps } from './types';\n\nconst WEEKDAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] as const;\nconst DAY_CELL_WIDTH = 42;\n\nfunction renderLabel(label: React.ReactNode, description: React.ReactNode | undefined) {\n return (\n <Stack gap=\"xs\">\n <Text variant=\"label\" weight=\"semiBold\">\n {label}\n </Text>\n {description ? (\n <Text emphasis=\"muted\" variant=\"bodySmall\">\n {description}\n </Text>\n ) : null}\n </Stack>\n );\n}\n\nfunction startOfLocalDay(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), value.getDate());\n}\n\nfunction isSameLocalDay(left: Date | null, right: Date): boolean {\n if (!left) {\n return false;\n }\n\n return startOfLocalDay(left).getTime() === startOfLocalDay(right).getTime();\n}\n\nfunction isBeforeLocalDay(left: Date, right: Date): boolean {\n return startOfLocalDay(left).getTime() < startOfLocalDay(right).getTime();\n}\n\nfunction isAfterLocalDay(left: Date, right: Date): boolean {\n return startOfLocalDay(left).getTime() > startOfLocalDay(right).getTime();\n}\n\nfunction isDateDisabled(\n value: Date,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): boolean {\n if (minDate && isBeforeLocalDay(value, minDate)) {\n return true;\n }\n\n if (maxDate && isAfterLocalDay(value, maxDate)) {\n return true;\n }\n\n return false;\n}\n\nfunction formatMonthLabel(value: Date): string {\n return value.toLocaleDateString(undefined, { month: 'long', year: 'numeric' });\n}\n\nfunction formatDefaultDate(value: Date): string {\n return value.toLocaleDateString();\n}\n\nfunction createMonthDays(month: Date): (Date | null)[] {\n const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);\n const dayCount = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();\n const days: (Date | null)[] = [];\n\n for (let offset = 0; offset < firstDay.getDay(); offset += 1) {\n days.push(null);\n }\n\n for (let day = 1; day <= dayCount; day += 1) {\n days.push(new Date(month.getFullYear(), month.getMonth(), day));\n }\n\n while (days.length % 7 !== 0) {\n days.push(null);\n }\n\n return days;\n}\n\nfunction resolveInitialMonth(value: Date | null, minDate: Date | undefined): Date {\n const base = value ?? minDate ?? new Date();\n return new Date(base.getFullYear(), base.getMonth(), 1);\n}\n\nfunction canNavigateToMonth(\n month: Date,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): boolean {\n const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);\n const lastDay = new Date(month.getFullYear(), month.getMonth() + 1, 0);\n\n if (maxDate && isAfterLocalDay(firstDay, maxDate)) {\n return false;\n }\n\n if (minDate && isBeforeLocalDay(lastDay, minDate)) {\n return false;\n }\n\n return true;\n}\n\nfunction DatePickerInner({\n themeId: _themeId,\n mode: _mode,\n value,\n onValueChange,\n label,\n description,\n error,\n placeholder = 'Choose date',\n minDate,\n maxDate,\n disabled = false,\n required = false,\n formatDate,\n testID,\n interactionPolicy,\n}: DatePickerProps) {\n const passive = interactionPolicy === 'passive';\n const [visible, setVisible] = React.useState(false);\n const [fallbackMonth] = React.useState(() => resolveInitialMonth(null, undefined));\n const initialMonth = value || minDate ? resolveInitialMonth(value, minDate) : fallbackMonth;\n const initialMonthKey = initialMonth.getTime();\n const [displayMonthState, setDisplayMonthState] = React.useState(() => ({\n sourceMonthKey: initialMonthKey,\n month: initialMonth,\n }));\n const displayMonth =\n displayMonthState.sourceMonthKey === initialMonthKey ? displayMonthState.month : initialMonth;\n const monthDays = React.useMemo(() => createMonthDays(displayMonth), [displayMonth]);\n const previousMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() - 1, 1);\n const nextMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() + 1, 1);\n const displayValue = value\n ? formatDate\n ? formatDate(value)\n : formatDefaultDate(value)\n : placeholder;\n\n function setDisplayMonth(month: Date) {\n setDisplayMonthState({ sourceMonthKey: initialMonthKey, month });\n }\n\n function openPicker() {\n if (passive) return;\n\n setDisplayMonthState({ sourceMonthKey: initialMonthKey, month: initialMonth });\n setVisible(true);\n }\n\n return (\n <Field\n disabled={disabled}\n errorText={error}\n invalid={Boolean(error)}\n label={label ? renderLabel(label, description) : undefined}\n required={required}\n testID={testID}\n >\n <Button\n disabled={disabled}\n interactionPolicy={interactionPolicy}\n onPress={openPicker}\n testID={testID ? `${testID}-trigger` : undefined}\n trailingIcon={{ name: 'calendar-outline' }}\n variant=\"outline\"\n >\n {displayValue}\n </Button>\n <ActionSheet\n description={description}\n interactionPolicy={interactionPolicy}\n onDismiss={() => {\n if (passive) return;\n\n setVisible(false);\n }}\n testID={testID ? `${testID}-sheet` : undefined}\n title={label ?? 'Choose date'}\n visible={visible}\n >\n <Stack gap=\"m\">\n <Stack align=\"center\" direction=\"row\" justify=\"space-between\">\n <Button\n disabled={!canNavigateToMonth(previousMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => {\n if (passive) return;\n\n setDisplayMonth(previousMonth);\n }}\n size=\"s\"\n variant=\"ghost\"\n >\n Previous\n </Button>\n <Text align=\"center\" variant=\"label\" weight=\"semiBold\">\n {formatMonthLabel(displayMonth)}\n </Text>\n <Button\n disabled={!canNavigateToMonth(nextMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => {\n if (passive) return;\n\n setDisplayMonth(nextMonth);\n }}\n size=\"s\"\n variant=\"ghost\"\n >\n Next\n </Button>\n </Stack>\n\n <Stack direction=\"row\" justify=\"space-between\">\n {WEEKDAY_LABELS.map((weekday) => (\n <Box key={weekday} style={{ width: DAY_CELL_WIDTH }}>\n <Text align=\"center\" emphasis=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {weekday}\n </Text>\n </Box>\n ))}\n </Stack>\n\n <Stack direction=\"row\" gap=\"xs\" style={{ flexWrap: 'wrap' }}>\n {monthDays.map((day, index) => {\n if (!day) {\n return <Box key={`empty-${index}`} style={{ width: DAY_CELL_WIDTH }} />;\n }\n\n const selected = isSameLocalDay(value, day);\n const dayDisabled = isDateDisabled(day, minDate, maxDate);\n\n return (\n <Box key={day.toISOString()} style={{ width: DAY_CELL_WIDTH }}>\n <Button\n color={selected ? 'primary' : 'neutral'}\n disabled={dayDisabled}\n interactionPolicy={interactionPolicy}\n onPress={() => {\n if (passive) return;\n\n onValueChange?.(startOfLocalDay(day));\n setVisible(false);\n }}\n size=\"s\"\n testID={testID ? `${testID}-day-${day.getDate()}` : undefined}\n variant={selected ? 'solid' : 'ghost'}\n >\n {day.getDate()}\n </Button>\n </Box>\n );\n })}\n </Stack>\n </Stack>\n </ActionSheet>\n </Field>\n );\n}\n\n/***\n * Date input control with calendar selection and formatted display value.\n */\nexport const DatePicker = withZoraThemeScope(DatePickerInner);\n"]}
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/components/date-picker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAC;AAClF,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,mEAAmE;AACnE,S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AK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CACxC,QAAQ,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAChD,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAC7B,IAAI,CAAC,GAAG,CACR,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9D,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAEtC;cAAA,CAAC,GAAG,CAAC,OAAO,EAAE,CAChB;YAAA,EAAE,MAAM,CACV;UAAA,EAAE,GAAG,CAAC,CACP,CAAC;QACJ,CAAC,CAAC,CACJ;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { Field } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { useBottomSheet } from '../../features/bottom-sheet/public';\nimport { Box, Stack } from '../../foundation';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport { Button } from '../button';\nimport { Text } from '../text';\nimport type { DatePickerProps } from './types';\n\nconst WEEKDAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] as const;\nconst DAY_CELL_WIDTH = 42;\n\n/*** Render the field label and optional supporting description. */\nfunction renderLabel(label: React.ReactNode, description: React.ReactNode | undefined) {\n return (\n <Stack gap=\"xs\">\n <Text variant=\"label\" weight=\"semiBold\">\n {label}\n </Text>\n {description ? (\n <Text emphasis=\"muted\" variant=\"bodySmall\">\n {description}\n </Text>\n ) : null}\n </Stack>\n );\n}\n\n/*** Normalize a date to the start of its local calendar day. */\nfunction startOfLocalDay(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), value.getDate());\n}\n\n/*** Compare two values by local calendar day. */\nfunction isSameLocalDay(left: Date | null, right: Date): boolean {\n if (!left) return false;\n return startOfLocalDay(left).getTime() === startOfLocalDay(right).getTime();\n}\n\n/*** Report whether one local calendar day precedes another. */\nfunction isBeforeLocalDay(left: Date, right: Date): boolean {\n return startOfLocalDay(left).getTime() < startOfLocalDay(right).getTime();\n}\n\n/*** Report whether one local calendar day follows another. */\nfunction isAfterLocalDay(left: Date, right: Date): boolean {\n return startOfLocalDay(left).getTime() > startOfLocalDay(right).getTime();\n}\n\n/*** Resolve whether a date falls outside the configured picker range. */\nfunction isDateDisabled(\n value: Date,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): boolean {\n if (minDate && isBeforeLocalDay(value, minDate)) return true;\n if (maxDate && isAfterLocalDay(value, maxDate)) return true;\n return false;\n}\n\n/*** Format the current calendar month for the picker heading. */\nfunction formatMonthLabel(value: Date): string {\n return value.toLocaleDateString(undefined, { month: 'long', year: 'numeric' });\n}\n\n/*** Format a selected date with the platform locale defaults. */\nfunction formatDefaultDate(value: Date): string {\n return value.toLocaleDateString();\n}\n\n/*** Build the padded calendar grid for one month. */\nfunction createMonthDays(month: Date): (Date | null)[] {\n const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);\n const dayCount = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();\n const days: (Date | null)[] = [];\n\n for (let offset = 0; offset < firstDay.getDay(); offset += 1) days.push(null);\n for (let day = 1; day <= dayCount; day += 1) {\n days.push(new Date(month.getFullYear(), month.getMonth(), day));\n }\n while (days.length % 7 !== 0) days.push(null);\n\n return days;\n}\n\n/*** Resolve the month initially shown by the calendar sheet. */\nfunction resolveInitialMonth(value: Date | null, minDate: Date | undefined): Date {\n const base = value ?? minDate ?? new Date();\n return new Date(base.getFullYear(), base.getMonth(), 1);\n}\n\n/*** Report whether the configured range intersects a candidate month. */\nfunction canNavigateToMonth(\n month: Date,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): boolean {\n const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);\n const lastDay = new Date(month.getFullYear(), month.getMonth() + 1, 0);\n\n if (maxDate && isAfterLocalDay(firstDay, maxDate)) return false;\n if (minDate && isBeforeLocalDay(lastDay, minDate)) return false;\n return true;\n}\n\nfunction DatePickerInner({\n themeId: _themeId,\n mode: _mode,\n value,\n onValueChange,\n label,\n description,\n error,\n placeholder = 'Choose date',\n minDate,\n maxDate,\n disabled = false,\n required = false,\n formatDate,\n testID,\n interactionPolicy,\n}: DatePickerProps) {\n const { dismiss, present } = useBottomSheet();\n const passive = interactionPolicy === 'passive';\n const displayValue = value\n ? formatDate\n ? formatDate(value)\n : formatDefaultDate(value)\n : placeholder;\n\n /*** Present the calendar content through the shared BottomSheet controller. */\n function openPicker() {\n if (passive) return;\n present({\n content: (\n <DatePickerSheet\n description={description}\n interactionPolicy={interactionPolicy}\n label={label}\n maxDate={maxDate}\n minDate={minDate}\n onDismiss={dismiss}\n onSelect={(date) => {\n onValueChange?.(startOfLocalDay(date));\n dismiss();\n }}\n testID={testID}\n value={value}\n />\n ),\n });\n }\n\n return (\n <Field\n disabled={disabled}\n errorText={error}\n invalid={Boolean(error)}\n label={label ? renderLabel(label, description) : undefined}\n required={required}\n testID={testID}\n >\n <Button\n disabled={disabled}\n interactionPolicy={interactionPolicy}\n onPress={openPicker}\n testID={testID ? `${testID}-trigger` : undefined}\n trailingIcon={{ name: 'calendar-outline' }}\n variant=\"outline\"\n >\n {displayValue}\n </Button>\n </Field>\n );\n}\n\ninterface DatePickerSheetProps extends Pick<\n DatePickerProps,\n 'description' | 'interactionPolicy' | 'label' | 'maxDate' | 'minDate' | 'testID' | 'value'\n> {\n onDismiss: () => void;\n onSelect: (value: Date) => void;\n}\n\n/*** Render the calendar-specific content inside the shared BottomSheet host. */\nfunction DatePickerSheet({\n description,\n interactionPolicy,\n label,\n maxDate,\n minDate,\n onDismiss,\n onSelect,\n testID,\n value,\n}: DatePickerSheetProps) {\n const [displayMonth, setDisplayMonth] = React.useState(() => resolveInitialMonth(value, minDate));\n const monthDays = React.useMemo(() => createMonthDays(displayMonth), [displayMonth]);\n\n return (\n <Stack gap=\"m\" p=\"m\" testID={testID ? `${testID}-sheet` : undefined}>\n <PickerSheetHeader description={description} title={label ?? 'Choose date'} />\n <DatePickerMonthNavigation\n displayMonth={displayMonth}\n interactionPolicy={interactionPolicy}\n maxDate={maxDate}\n minDate={minDate}\n onMonthChange={setDisplayMonth}\n />\n <DatePickerWeekdays />\n <DatePickerCalendar\n interactionPolicy={interactionPolicy}\n maxDate={maxDate}\n minDate={minDate}\n monthDays={monthDays}\n onSelect={onSelect}\n testID={testID}\n value={value}\n />\n <Button fullWidth interactionPolicy={interactionPolicy} onPress={onDismiss} variant=\"ghost\">\n Cancel\n </Button>\n </Stack>\n );\n}\n\n/*** Render the shared title block used by the calendar sheet. */\nfunction PickerSheetHeader({\n description,\n title,\n}: {\n description: React.ReactNode | undefined;\n title: React.ReactNode;\n}) {\n return (\n <Stack gap=\"xxs\">\n <Text align=\"center\" variant=\"label\" weight=\"semiBold\">\n {title}\n </Text>\n {description ? (\n <Text align=\"center\" emphasis=\"muted\" variant=\"bodySmall\">\n {description}\n </Text>\n ) : null}\n </Stack>\n );\n}\n\n/*** Render previous/next month controls for the calendar sheet. */\nfunction DatePickerMonthNavigation({\n displayMonth,\n interactionPolicy,\n maxDate,\n minDate,\n onMonthChange,\n}: Pick<DatePickerSheetProps, 'interactionPolicy' | 'maxDate' | 'minDate'> & {\n displayMonth: Date;\n onMonthChange: (month: Date) => void;\n}) {\n const previousMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() - 1, 1);\n const nextMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() + 1, 1);\n\n return (\n <Stack align=\"center\" direction=\"row\" justify=\"space-between\">\n <Button\n disabled={!canNavigateToMonth(previousMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => onMonthChange(previousMonth)}\n size=\"s\"\n variant=\"ghost\"\n >\n Previous\n </Button>\n <Text align=\"center\" variant=\"label\" weight=\"semiBold\">\n {formatMonthLabel(displayMonth)}\n </Text>\n <Button\n disabled={!canNavigateToMonth(nextMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => onMonthChange(nextMonth)}\n size=\"s\"\n variant=\"ghost\"\n >\n Next\n </Button>\n </Stack>\n );\n}\n\n/*** Render weekday headings for the calendar grid. */\nfunction DatePickerWeekdays() {\n return (\n <Stack direction=\"row\" justify=\"space-between\">\n {WEEKDAY_LABELS.map((weekday) => (\n <Box key={weekday} width={DAY_CELL_WIDTH}>\n <Text align=\"center\" emphasis=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {weekday}\n </Text>\n </Box>\n ))}\n </Stack>\n );\n}\n\n/*** Render selectable day cells for the current calendar month. */\nfunction DatePickerCalendar({\n interactionPolicy,\n maxDate,\n minDate,\n monthDays,\n onSelect,\n testID,\n value,\n}: Pick<DatePickerSheetProps, 'interactionPolicy' | 'maxDate' | 'minDate' | 'testID' | 'value'> & {\n monthDays: readonly (Date | null)[];\n onSelect: (value: Date) => void;\n}) {\n return (\n <Stack direction=\"row\" gap=\"xs\" wrap=\"wrap\">\n {monthDays.map((day, index) => {\n if (!day) return <Box key={`empty-${index}`} width={DAY_CELL_WIDTH} />;\n const selected = isSameLocalDay(value, day);\n return (\n <Box key={day.toISOString()} width={DAY_CELL_WIDTH}>\n <Button\n color={selected ? 'primary' : 'neutral'}\n disabled={isDateDisabled(day, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => onSelect(day)}\n size=\"s\"\n testID={testID ? `${testID}-day-${day.getDate()}` : undefined}\n variant={selected ? 'solid' : 'ghost'}\n >\n {day.getDate()}\n </Button>\n </Box>\n );\n })}\n </Stack>\n );\n}\n\n/***\n * Date input control with calendar selection and formatted display value.\n */\nexport const DatePicker = withZoraThemeScope(DatePickerInner);\n"]}
@@ -3,7 +3,7 @@ export declare const datePickerMeta: {
3
3
  readonly category: "component";
4
4
  readonly directManifestNode: false;
5
5
  readonly allowedChildren: readonly [];
6
- readonly note: "Code-facing ActionSheet-backed date picker; not represented as a manifest node in v1.";
6
+ readonly note: "Code-facing BottomSheet-backed date picker; not represented as a manifest node in v1.";
7
7
  readonly props: {};
8
8
  };
9
9
  //# sourceMappingURL=meta.d.ts.map
@@ -3,7 +3,7 @@ export const datePickerMeta = {
3
3
  category: 'component',
4
4
  directManifestNode: false,
5
5
  allowedChildren: [],
6
- note: 'Code-facing ActionSheet-backed date picker; not represented as a manifest node in v1.',
6
+ note: 'Code-facing BottomSheet-backed date picker; not represented as a manifest node in v1.',
7
7
  props: {},
8
8
  };
9
9
  //# sourceMappingURL=meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/components/date-picker/meta.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,KAAK;IACzB,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,uFAAuF;IAC7F,KAAK,EAAE,EAAE;CAC2B,CAAC","sourcesContent":["import type { ZoraComponentMeta } from '../../metadata';\n\nexport const datePickerMeta = {\n name: 'DatePicker',\n category: 'component',\n directManifestNode: false,\n allowedChildren: [],\n note: 'Code-facing ActionSheet-backed date picker; not represented as a manifest node in v1.',\n props: {},\n} as const satisfies ZoraComponentMeta;\n"]}
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/components/date-picker/meta.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,KAAK;IACzB,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,uFAAuF;IAC7F,KAAK,EAAE,EAAE;CAC2B,CAAC","sourcesContent":["import type { ZoraComponentMeta } from '../../metadata';\n\nexport const datePickerMeta = {\n name: 'DatePicker',\n category: 'component',\n directManifestNode: false,\n allowedChildren: [],\n note: 'Code-facing BottomSheet-backed date picker; not represented as a manifest node in v1.',\n props: {},\n} as const satisfies ZoraComponentMeta;\n"]}
@@ -3,7 +3,7 @@ import type { HeadingAlign, HeadingSize, HeadingWeight } from './types';
3
3
  export declare function resolveHeadingThemeRecipe(fields: Readonly<Record<string, ThemeRecipeOverrideValue>>): {
4
4
  size: HeadingSize | undefined;
5
5
  color: "primary" | "secondary" | "tertiary" | "quaternary" | "neutral" | "error" | "success" | "warning" | "info" | "danger" | undefined;
6
- emphasis: "default" | "muted" | "subtle" | "inverse" | undefined;
6
+ emphasis: "default" | "subtle" | "muted" | "inverse" | undefined;
7
7
  align: HeadingAlign | undefined;
8
8
  weight: HeadingWeight | undefined;
9
9
  italic: boolean | undefined;
@@ -1,9 +1,5 @@
1
1
  import React from 'react';
2
2
  import type { ImageProps } from './types';
3
- /***
4
- * Displays an image with cross-platform source and fit handling.
5
- *
6
-
7
- */
3
+ /*** Displays an image asset and owns its missing, unrenderable, and failed presentation states. */
8
4
  export declare const Image: (props: ImageProps) => React.ReactElement | null;
9
5
  //# sourceMappingURL=Image.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../src/components/image/Image.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAW1C;;;;GAIG;AACH,eAAO,MAAM,KAAK,kDAAiC,CAAC"}
1
+ {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../src/components/image/Image.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,mGAAmG;AACnG,eAAO,MAAM,KAAK,kDAAiC,CAAC"}
@@ -1,13 +1,84 @@
1
1
  import { Image as SurfaceImage } from '@ankhorage/surface';
2
2
  import React from 'react';
3
+ import { Box } from '../../foundation';
4
+ import { useZoraTheme } from '../../theme/useZoraTheme';
3
5
  import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
4
- function ImageInner({ themeId: _themeId, mode: _mode, interactionPolicy: _interactionPolicy, ...props }) {
5
- return <SurfaceImage {...props}/>;
6
- }
7
- /***
8
- * Displays an image with cross-platform source and fit handling.
9
- *
10
-
11
- */
6
+ import { Icon } from '../icon';
7
+ /*** Displays an image asset and owns its missing, unrenderable, and failed presentation states. */
12
8
  export const Image = withZoraThemeScope(ImageInner);
9
+ /*** Renders the resolved image source or the canonical ZORA image placeholder. */
10
+ function ImageInner({ themeId: _themeId, mode: _mode, interactionPolicy: _interactionPolicy, source, fallbackSource, alt, accessibilityLabel, width, height, aspectRatio, radius, style, testID, onError, ...props }) {
11
+ const { theme } = useZoraTheme();
12
+ const resolvedSource = resolveImageSource(source);
13
+ const sourceKey = resolveImageSourceKey(source);
14
+ const firstFailureKeyRef = React.useRef(null);
15
+ const [failedSourceKey, setFailedSourceKey] = React.useState(null);
16
+ const showPlaceholder = resolvedSource === null || failedSourceKey === sourceKey;
17
+ const resolvedAlt = alt ?? (isUploadAsset(source) ? source.alt : undefined);
18
+ const placeholderLabel = accessibilityLabel ?? resolvedAlt;
19
+ if (showPlaceholder) {
20
+ return (<Box accessibilityLabel={placeholderLabel} accessibilityRole={placeholderLabel ? 'image' : undefined} accessible={Boolean(placeholderLabel)} bg={theme.semantics.neutral.surface} borderColor={theme.semantics.neutral.divider} borderWidth={1} height={height} overflow="hidden" radius={radius} testID={testID} width={width} style={[
21
+ {
22
+ alignItems: 'center',
23
+ aspectRatio: aspectRatio ?? 1,
24
+ justifyContent: 'center',
25
+ },
26
+ style,
27
+ ]}>
28
+ <Icon color={theme.semantics.content.muted} name="image-outline" size={24}/>
29
+ </Box>);
30
+ }
31
+ return (<SurfaceImage {...props} accessibilityLabel={accessibilityLabel} alt={resolvedAlt} aspectRatio={aspectRatio} fallbackSource={fallbackSource} height={height} onError={(event) => {
32
+ onError?.(event);
33
+ if (!sourceKey) {
34
+ return;
35
+ }
36
+ if (fallbackSource && firstFailureKeyRef.current !== sourceKey) {
37
+ firstFailureKeyRef.current = sourceKey;
38
+ return;
39
+ }
40
+ setFailedSourceKey(sourceKey);
41
+ }} radius={radius} source={resolvedSource} style={style} testID={testID} width={width}/>);
42
+ }
43
+ /*** Resolves a generic upload asset into a source understood by the Surface Image primitive. */
44
+ function resolveImageSource(source) {
45
+ if (!isUploadAsset(source)) {
46
+ return source;
47
+ }
48
+ switch (source.kind) {
49
+ case 'local':
50
+ return source.uri;
51
+ case 'url':
52
+ return source.url;
53
+ case 'storage':
54
+ return source.publicUrl ?? null;
55
+ }
56
+ }
57
+ /*** Produces a stable-enough key for tracking image failures across source changes. */
58
+ function resolveImageSourceKey(source) {
59
+ if (source === null || source === undefined) {
60
+ return null;
61
+ }
62
+ if (isUploadAsset(source)) {
63
+ switch (source.kind) {
64
+ case 'local':
65
+ return `local:${source.uri}`;
66
+ case 'url':
67
+ return `url:${source.url}`;
68
+ case 'storage':
69
+ return `storage:${source.bucket}:${source.path}:${source.publicUrl ?? ''}`;
70
+ }
71
+ }
72
+ if (typeof source === 'string' || typeof source === 'number') {
73
+ return `source:${String(source)}`;
74
+ }
75
+ if (!Array.isArray(source) && 'uri' in source && typeof source.uri === 'string') {
76
+ return `source:${source.uri}`;
77
+ }
78
+ return 'source:opaque';
79
+ }
80
+ /*** Identifies the generic ZORA upload asset shape without leaking picker-specific types. */
81
+ function isUploadAsset(source) {
82
+ return (typeof source === 'object' && source !== null && !Array.isArray(source) && 'kind' in source);
83
+ }
13
84
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../src/components/image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,SAAS,UAAU,CAAC,EAClB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,iBAAiB,EAAE,kBAAkB,EACrC,GAAG,KAAK,EACG;IACX,OAAO,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { Image as SurfaceImage } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { ImageProps } from './types';\n\nfunction ImageInner({\n themeId: _themeId,\n mode: _mode,\n interactionPolicy: _interactionPolicy,\n ...props\n}: ImageProps) {\n return <SurfaceImage {...props} />;\n}\n\n/***\n * Displays an image with cross-platform source and fit handling.\n *\n \n */\nexport const Image = withZoraThemeScope(ImageInner);\n"]}
1
+ {"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../src/components/image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,YAAY,EAA2B,MAAM,oBAAoB,CAAC;AACpF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,mGAAmG;AACnG,MAAM,CAAC,MAAM,KAAK,G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C,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QAChF,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,6FAA6F;AAC7F,SAAS,aAAa,CAAC,MAA4B;IACjD,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,MAAM,CAC5F,CAAC;AACJ,CAAC","sourcesContent":["import { Image as SurfaceImage, type SurfaceImageSource } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { Box } from '../../foundation';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { UploadAsset } from '../../types/upload';\nimport { Icon } from '../icon';\nimport type { ImageProps } from './types';\n\n/*** Displays an image asset and owns its missing, unrenderable, and failed presentation states. */\nexport const Image = withZoraThemeScope(ImageInner);\n\n/*** Renders the resolved image source or the canonical ZORA image placeholder. */\nfunction ImageInner({\n themeId: _themeId,\n mode: _mode,\n interactionPolicy: _interactionPolicy,\n source,\n fallbackSource,\n alt,\n accessibilityLabel,\n width,\n height,\n aspectRatio,\n radius,\n style,\n testID,\n onError,\n ...props\n}: ImageProps) {\n const { theme } = useZoraTheme();\n const resolvedSource = resolveImageSource(source);\n const sourceKey = resolveImageSourceKey(source);\n const firstFailureKeyRef = React.useRef<string | null>(null);\n const [failedSourceKey, setFailedSourceKey] = React.useState<string | null>(null);\n const showPlaceholder = resolvedSource === null || failedSourceKey === sourceKey;\n const resolvedAlt = alt ?? (isUploadAsset(source) ? source.alt : undefined);\n const placeholderLabel = accessibilityLabel ?? resolvedAlt;\n\n if (showPlaceholder) {\n return (\n <Box\n accessibilityLabel={placeholderLabel}\n accessibilityRole={placeholderLabel ? 'image' : undefined}\n accessible={Boolean(placeholderLabel)}\n bg={theme.semantics.neutral.surface}\n borderColor={theme.semantics.neutral.divider}\n borderWidth={1}\n height={height}\n overflow=\"hidden\"\n radius={radius}\n testID={testID}\n width={width}\n style={[\n {\n alignItems: 'center',\n aspectRatio: aspectRatio ?? 1,\n justifyContent: 'center',\n },\n style,\n ]}\n >\n <Icon color={theme.semantics.content.muted} name=\"image-outline\" size={24} />\n </Box>\n );\n }\n\n return (\n <SurfaceImage\n {...props}\n accessibilityLabel={accessibilityLabel}\n alt={resolvedAlt}\n aspectRatio={aspectRatio}\n fallbackSource={fallbackSource}\n height={height}\n onError={(event) => {\n onError?.(event);\n\n if (!sourceKey) {\n return;\n }\n\n if (fallbackSource && firstFailureKeyRef.current !== sourceKey) {\n firstFailureKeyRef.current = sourceKey;\n return;\n }\n\n setFailedSourceKey(sourceKey);\n }}\n radius={radius}\n source={resolvedSource}\n style={style}\n testID={testID}\n width={width}\n />\n );\n}\n\n/*** Resolves a generic upload asset into a source understood by the Surface Image primitive. */\nfunction resolveImageSource(source: ImageProps['source']): SurfaceImageSource | null | undefined {\n if (!isUploadAsset(source)) {\n return source;\n }\n\n switch (source.kind) {\n case 'local':\n return source.uri;\n case 'url':\n return source.url;\n case 'storage':\n return source.publicUrl ?? null;\n }\n}\n\n/*** Produces a stable-enough key for tracking image failures across source changes. */\nfunction resolveImageSourceKey(source: ImageProps['source']): string | null {\n if (source === null || source === undefined) {\n return null;\n }\n\n if (isUploadAsset(source)) {\n switch (source.kind) {\n case 'local':\n return `local:${source.uri}`;\n case 'url':\n return `url:${source.url}`;\n case 'storage':\n return `storage:${source.bucket}:${source.path}:${source.publicUrl ?? ''}`;\n }\n }\n\n if (typeof source === 'string' || typeof source === 'number') {\n return `source:${String(source)}`;\n }\n\n if (!Array.isArray(source) && 'uri' in source && typeof source.uri === 'string') {\n return `source:${source.uri}`;\n }\n\n return 'source:opaque';\n}\n\n/*** Identifies the generic ZORA upload asset shape without leaking picker-specific types. */\nfunction isUploadAsset(source: ImageProps['source']): source is UploadAsset {\n return (\n typeof source === 'object' && source !== null && !Array.isArray(source) && 'kind' in source\n );\n}\n"]}