@ankhorage/zora 25.0.0 → 25.1.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 (63) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/features/explorer/adapters/inbound/Explorer.d.ts.map +1 -1
  4. package/dist/features/explorer/adapters/inbound/Explorer.js +30 -13
  5. package/dist/features/explorer/adapters/inbound/Explorer.js.map +1 -1
  6. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.d.ts +9 -0
  7. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.d.ts.map +1 -0
  8. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.js +5 -0
  9. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.js.map +1 -0
  10. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.native.d.ts +9 -0
  11. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.native.d.ts.map +1 -0
  12. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.native.js +5 -0
  13. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.native.js.map +1 -0
  14. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.web.d.ts +9 -0
  15. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.web.d.ts.map +1 -0
  16. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.web.js +10 -0
  17. package/dist/features/explorer/adapters/inbound/ExplorerKeyboardProxy.web.js.map +1 -0
  18. package/dist/features/explorer/adapters/inbound/useExplorerKeyboardFocus.d.ts +14 -0
  19. package/dist/features/explorer/adapters/inbound/useExplorerKeyboardFocus.d.ts.map +1 -0
  20. package/dist/features/explorer/adapters/inbound/useExplorerKeyboardFocus.js +54 -0
  21. package/dist/features/explorer/adapters/inbound/useExplorerKeyboardFocus.js.map +1 -0
  22. package/dist/features/explorer/application/getExplorerNextFocusId.d.ts +6 -0
  23. package/dist/features/explorer/application/getExplorerNextFocusId.d.ts.map +1 -0
  24. package/dist/features/explorer/application/getExplorerNextFocusId.js +53 -0
  25. package/dist/features/explorer/application/getExplorerNextFocusId.js.map +1 -0
  26. package/dist/features/explorer/public.d.ts +1 -0
  27. package/dist/features/explorer/public.d.ts.map +1 -1
  28. package/dist/features/explorer/public.js +1 -0
  29. package/dist/features/explorer/public.js.map +1 -1
  30. package/dist/features/grid-view/adapters/inbound/GridView.d.ts +1 -1
  31. package/dist/features/grid-view/adapters/inbound/GridView.d.ts.map +1 -1
  32. package/dist/features/grid-view/adapters/inbound/GridView.js +36 -4
  33. package/dist/features/grid-view/adapters/inbound/GridView.js.map +1 -1
  34. package/dist/features/grid-view/adapters/inbound/TileGrid.d.ts +1 -1
  35. package/dist/features/grid-view/adapters/inbound/TileGrid.d.ts.map +1 -1
  36. package/dist/features/grid-view/adapters/inbound/TileGrid.js +7 -3
  37. package/dist/features/grid-view/adapters/inbound/TileGrid.js.map +1 -1
  38. package/dist/types/grid-view.d.ts +10 -0
  39. package/dist/types/grid-view.d.ts.map +1 -1
  40. package/dist/types/grid-view.js.map +1 -1
  41. package/package.json +3 -3
  42. package/src/features/explorer/adapters/inbound/Explorer.tsx +79 -43
  43. package/src/features/explorer/adapters/inbound/ExplorerKeyboardProxy.native.tsx +11 -0
  44. package/src/features/explorer/adapters/inbound/ExplorerKeyboardProxy.tsx +11 -0
  45. package/src/features/explorer/adapters/inbound/ExplorerKeyboardProxy.web.tsx +20 -0
  46. package/src/features/explorer/adapters/inbound/useExplorerKeyboardFocus.test.tsx +232 -0
  47. package/src/features/explorer/adapters/inbound/useExplorerKeyboardFocus.ts +77 -0
  48. package/src/features/explorer/application/getExplorerNextFocusId.test.ts +37 -0
  49. package/src/features/explorer/application/getExplorerNextFocusId.ts +61 -0
  50. package/src/features/explorer/public.ts +1 -0
  51. package/src/features/grid-view/adapters/inbound/GridView.tsx +49 -1
  52. package/src/features/grid-view/adapters/inbound/TileGrid.tsx +11 -0
  53. package/src/types/grid-view.ts +10 -0
  54. package/web-dist/chunks/{Accordion-8m8p9wpw.js → Accordion-54k0ncs3.js} +83 -0
  55. package/web-dist/chunks/Accordion-fmn31fgf.js +321 -0
  56. package/web-dist/components/explorer/Explorer.js +2 -2
  57. package/web-dist/components/file-explorer/FileExplorer.js +2 -2
  58. package/web-dist/components/grid-view/GridView.js +1 -1
  59. package/web-dist/components/media-explorer/MediaExplorer.js +2 -2
  60. package/web-dist/components/tile-grid/TileGrid.js +1 -1
  61. package/web-dist/components/uploader/Uploader.js +2 -2
  62. package/web-dist/manifest.json +10 -10
  63. package/web-dist/chunks/Accordion-2gvs3frs.js +0 -197
@@ -1,197 +0,0 @@
1
- 'use client';
2
- import {
3
- TileGrid2
4
- } from "./Accordion-8m8p9wpw.js";
5
- import {
6
- withZoraThemeScope
7
- } from "./Accordion-42jfy1a1.js";
8
- import {
9
- Icon2
10
- } from "./Accordion-bb8y34wh.js";
11
- import {
12
- Image2
13
- } from "./Accordion-mej71qnw.js";
14
- import {
15
- Text3
16
- } from "./Accordion-afmybp67.js";
17
- import {
18
- applySelectionIntent
19
- } from "./Accordion-n4et7etk.js";
20
- import {
21
- useZoraTheme2
22
- } from "./Accordion-srjya6dz.js";
23
- import {
24
- require_cjs
25
- } from "./Accordion-xgpzh4wq.js";
26
- import {
27
- __toESM
28
- } from "./Accordion-nh0cs9hq.js";
29
-
30
- // src/features/explorer/adapters/inbound/Explorer.tsx
31
- var import_react_native = __toESM(require_cjs(), 1);
32
- import React from "react";
33
-
34
- // src/features/explorer/application/resolveExplorerSelection.ts
35
- function resolveExplorerSelection(orderedIds, currentIds, targetId, anchorId, intent, mode) {
36
- const targetIndex = orderedIds.indexOf(targetId);
37
- if (targetIndex < 0)
38
- return currentIds;
39
- if (mode === "single" || intent === "replace")
40
- return applySelectionIntent(currentIds, targetId, "replace");
41
- if (intent === "toggle") {
42
- return applySelectionIntent(currentIds, targetId, "toggle");
43
- }
44
- const anchorIndex = anchorId === null ? -1 : orderedIds.indexOf(anchorId);
45
- if (anchorIndex < 0)
46
- return [targetId];
47
- const start = Math.min(anchorIndex, targetIndex);
48
- const end = Math.max(anchorIndex, targetIndex);
49
- return orderedIds.slice(start, end + 1);
50
- }
51
-
52
- // src/features/explorer/adapters/inbound/Explorer.tsx
53
- import { jsx, jsxs } from "react/jsx-runtime";
54
- var Explorer2 = withZoraThemeScope(ExplorerInner);
55
- function ExplorerInner({
56
- items,
57
- selectedIds,
58
- defaultSelectedIds = [],
59
- selectionMode = "single",
60
- onSelectionChange,
61
- onActivate,
62
- width,
63
- height,
64
- tileSize = 120,
65
- zoom = 1,
66
- loading = false,
67
- errorText,
68
- emptyText = "No items",
69
- disabled = false,
70
- readOnly = false,
71
- interactionPolicy,
72
- testID
73
- }) {
74
- const { theme } = useZoraTheme2();
75
- const [internalSelectedIds, setInternalSelectedIds] = React.useState(defaultSelectedIds);
76
- const anchorId = React.useRef(null);
77
- const effectiveSelectedIds = selectedIds ?? internalSelectedIds;
78
- const itemLookup = React.useMemo(() => new Map(items.map((item) => [item.id, item])), [items]);
79
- const ids = items.filter((item) => !item.disabled).map((item) => item.id);
80
- const selected = new Set(effectiveSelectedIds);
81
- const passive = interactionPolicy === "passive" || disabled || readOnly;
82
- const select = (item, intent) => {
83
- if (passive || item.disabled)
84
- return;
85
- const next = resolveExplorerSelection(ids, effectiveSelectedIds, item.id, anchorId.current, intent, selectionMode);
86
- if (intent !== "range")
87
- anchorId.current = item.id;
88
- if (selectedIds === undefined)
89
- setInternalSelectedIds(next);
90
- onSelectionChange?.({ selectedIds: next });
91
- };
92
- const renderTile = (tile) => {
93
- const item = itemLookup.get(tile.id);
94
- if (!item)
95
- return null;
96
- const isSelected = selected.has(item.id);
97
- const canInteract = !passive && !item.disabled;
98
- return /* @__PURE__ */ jsxs(import_react_native.Pressable, {
99
- accessibilityLabel: item.name,
100
- accessibilityRole: "button",
101
- accessibilityState: { selected: isSelected, disabled: !canInteract },
102
- disabled: !canInteract,
103
- onLongPress: () => select(item, "toggle"),
104
- onPress: (event) => {
105
- const intent = resolveExplorerPressIntent(event.nativeEvent);
106
- select(item, intent);
107
- if (selectionMode === "single" && intent === "replace") {
108
- onActivate?.({ id: item.id });
109
- }
110
- },
111
- style: {
112
- flex: 1,
113
- overflow: "hidden",
114
- borderRadius: 8,
115
- borderWidth: isSelected ? 2 : 1,
116
- borderColor: isSelected ? theme.colors.primary : theme.semantics.neutral.divider,
117
- backgroundColor: theme.semantics.neutral.surface,
118
- padding: 8,
119
- gap: 4
120
- },
121
- testID: `explorer-item-${item.id}`,
122
- children: [
123
- /* @__PURE__ */ jsx(import_react_native.View, {
124
- style: { flex: 1, alignItems: "center", justifyContent: "center" },
125
- children: item.thumbnailUri ? /* @__PURE__ */ jsx(Image2, {
126
- accessibilityLabel: item.name,
127
- aspectRatio: 1,
128
- source: item.thumbnailUri,
129
- width: "100%"
130
- }) : /* @__PURE__ */ jsx(Icon2, {
131
- name: item.kind === "folder" ? "folder-outline" : "document-outline",
132
- size: 32
133
- })
134
- }),
135
- /* @__PURE__ */ jsx(Text3, {
136
- numberOfLines: 1,
137
- variant: "caption",
138
- children: item.name
139
- })
140
- ]
141
- });
142
- };
143
- if (errorText)
144
- return /* @__PURE__ */ jsx(Text3, {
145
- testID,
146
- children: errorText
147
- });
148
- if (loading)
149
- return /* @__PURE__ */ jsx(Text3, {
150
- testID,
151
- children: "Loading…"
152
- });
153
- if (items.length === 0)
154
- return /* @__PURE__ */ jsx(Text3, {
155
- testID,
156
- children: emptyText
157
- });
158
- return /* @__PURE__ */ jsx(TileGrid2, {
159
- height,
160
- interactionPolicy,
161
- items,
162
- renderItem: renderTile,
163
- testID,
164
- tileSize,
165
- width,
166
- zoom
167
- });
168
- }
169
- function resolveExplorerPressIntent(event) {
170
- if (typeof event !== "object" || event === null)
171
- return "replace";
172
- if ("shiftKey" in event && event.shiftKey === true)
173
- return "range";
174
- if ("ctrlKey" in event && event.ctrlKey === true)
175
- return "toggle";
176
- if ("metaKey" in event && event.metaKey === true)
177
- return "toggle";
178
- return "replace";
179
- }
180
-
181
- // src/features/explorer/adapters/inbound/FileExplorer.tsx
182
- import { jsx as jsx2 } from "react/jsx-runtime";
183
- function FileExplorer2(props) {
184
- return /* @__PURE__ */ jsx2(Explorer2, {
185
- ...props
186
- });
187
- }
188
-
189
- // src/features/explorer/adapters/inbound/MediaExplorer.tsx
190
- import { jsx as jsx3 } from "react/jsx-runtime";
191
- function MediaExplorer2(props) {
192
- return /* @__PURE__ */ jsx3(Explorer2, {
193
- ...props,
194
- items: props.items.filter((item) => item.kind === "image" || item.kind === "video" || item.kind === "audio")
195
- });
196
- }
197
- export { Explorer2, FileExplorer2, MediaExplorer2 };