@ankhorage/zora 25.8.13 → 25.8.15
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.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/features/button/utils/resolveButtonThemeRecipe.d.ts +1 -1
- package/dist/features/matrix-grid/adapters/inbound/MatrixGrid.d.ts.map +1 -1
- package/dist/features/matrix-grid/adapters/inbound/MatrixGrid.js +11 -8
- package/dist/features/matrix-grid/adapters/inbound/MatrixGrid.js.map +1 -1
- package/dist/features/matrix-grid/adapters/inbound/useMatrixGridKeyboardFocus.d.ts +1 -1
- package/dist/features/matrix-grid/adapters/inbound/useMatrixGridKeyboardFocus.d.ts.map +1 -1
- package/dist/features/matrix-grid/adapters/inbound/useMatrixGridKeyboardFocus.js +25 -5
- package/dist/features/matrix-grid/adapters/inbound/useMatrixGridKeyboardFocus.js.map +1 -1
- package/dist/features/matrix-grid/application/resolveMatrixGridSelection.d.ts +1 -1
- package/dist/features/matrix-grid/application/resolveMatrixGridSelection.d.ts.map +1 -1
- package/dist/features/matrix-grid/application/resolveMatrixGridSelection.js +5 -2
- package/dist/features/matrix-grid/application/resolveMatrixGridSelection.js.map +1 -1
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.d.ts +4 -0
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.d.ts.map +1 -0
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js +187 -0
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js.map +1 -0
- package/dist/features/registry/ZORA_COMPONENT_REGISTRY.d.ts +1 -0
- package/dist/features/registry/ZORA_COMPONENT_REGISTRY.d.ts.map +1 -1
- package/dist/features/registry/ZORA_COMPONENT_REGISTRY.js +4 -185
- package/dist/features/registry/ZORA_COMPONENT_REGISTRY.js.map +1 -1
- package/dist/features/registry/createZoraComponentRegistry.d.ts +4 -0
- package/dist/features/registry/createZoraComponentRegistry.d.ts.map +1 -0
- package/dist/features/registry/createZoraComponentRegistry.js +6 -0
- package/dist/features/registry/createZoraComponentRegistry.js.map +1 -0
- package/dist/features/registry/public.d.ts +2 -0
- package/dist/features/registry/public.d.ts.map +1 -1
- package/dist/features/registry/public.js +2 -0
- package/dist/features/registry/public.js.map +1 -1
- package/dist/features/registry/readerFreeRegistry.d.ts +3 -0
- package/dist/features/registry/readerFreeRegistry.d.ts.map +1 -0
- package/dist/features/registry/readerFreeRegistry.js +3 -0
- package/dist/features/registry/readerFreeRegistry.js.map +1 -0
- package/dist/index.d.ts +1 -126
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -77
- package/dist/index.js.map +1 -1
- package/dist/readerFree.d.ts +129 -0
- package/dist/readerFree.d.ts.map +1 -0
- package/dist/readerFree.js +79 -0
- package/dist/readerFree.js.map +1 -0
- package/dist/types/matrix-grid.d.ts +2 -0
- package/dist/types/matrix-grid.d.ts.map +1 -1
- package/dist/types/matrix-grid.js.map +1 -1
- package/package.json +17 -2
- package/src/features/layout/public.test.ts +2 -1
- package/src/features/matrix-grid/adapters/inbound/MatrixGrid.protected-focus.test.tsx +252 -0
- package/src/features/matrix-grid/adapters/inbound/MatrixGrid.test.tsx +79 -0
- package/src/features/matrix-grid/adapters/inbound/MatrixGrid.tsx +16 -5
- package/src/features/matrix-grid/adapters/inbound/useMatrixGridKeyboardFocus.ts +31 -4
- package/src/features/matrix-grid/application/resolveMatrixGridSelection.test.ts +20 -13
- package/src/features/matrix-grid/application/resolveMatrixGridSelection.ts +3 -0
- package/src/features/progress/adapters/inbound/ProgressRing.test.ts +6 -4
- package/src/features/reader/adapters/inbound/Reader.test.ts +1 -1
- package/src/features/reader/utils/resolveReaderProgress.test.ts +1 -1
- package/src/features/registry/ZORA_BASE_COMPONENT_REGISTRY.ts +236 -0
- package/src/features/registry/ZORA_COMPONENT_REGISTRY.ts +4 -233
- package/src/features/registry/createZoraComponentRegistry.ts +9 -0
- package/src/features/registry/public.ts +2 -0
- package/src/features/registry/readerFreeRegistry.ts +2 -0
- package/src/features/registry/registry.test.ts +36 -5
- package/src/features/uploader/public.test.ts +3 -2
- package/src/index.ts +1 -533
- package/src/interactionPolicy.test.ts +1 -1
- package/src/readerFree.ts +538 -0
- package/src/types/matrix-grid.ts +2 -0
- package/web-dist/components/matrix-grid/MatrixGrid.js +41 -16
|
@@ -110,7 +110,9 @@ function resolveMatrixGridContentSize(layout) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// src/features/matrix-grid/application/resolveMatrixGridSelection.ts
|
|
113
|
-
function resolveMatrixGridSelection(cells, selectedIds, cellId, anchorId, intent, mode) {
|
|
113
|
+
function resolveMatrixGridSelection(cells, selectedIds, cellId, anchorId, intent, mode, protectedCellIds) {
|
|
114
|
+
if (protectedCellIds.has(cellId))
|
|
115
|
+
return selectedIds;
|
|
114
116
|
if (mode === "single")
|
|
115
117
|
return applySelectionIntent(selectedIds, cellId, "replace");
|
|
116
118
|
if (intent !== "range")
|
|
@@ -119,7 +121,7 @@ function resolveMatrixGridSelection(cells, selectedIds, cellId, anchorId, intent
|
|
|
119
121
|
const target = cells.find((cell) => cell.id === cellId);
|
|
120
122
|
if (!anchor || !target)
|
|
121
123
|
return applySelectionIntent(selectedIds, cellId, "replace");
|
|
122
|
-
return cells.filter((cell) => cell.rowIndex >= Math.min(anchor.rowIndex, target.rowIndex) && cell.rowIndex <= Math.max(anchor.rowIndex, target.rowIndex) && cell.columnIndex >= Math.min(anchor.columnIndex, target.columnIndex) && cell.columnIndex <= Math.max(anchor.columnIndex, target.columnIndex)).map((cell) => cell.id);
|
|
124
|
+
return cells.filter((cell) => !protectedCellIds.has(cell.id) && cell.rowIndex >= Math.min(anchor.rowIndex, target.rowIndex) && cell.rowIndex <= Math.max(anchor.rowIndex, target.rowIndex) && cell.columnIndex >= Math.min(anchor.columnIndex, target.columnIndex) && cell.columnIndex <= Math.max(anchor.columnIndex, target.columnIndex)).map((cell) => cell.id);
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
// src/features/matrix-grid/adapters/inbound/MatrixGridKeyboardProxy.web.tsx
|
|
@@ -214,13 +216,22 @@ function getAxisCoordinate2(entry, axis) {
|
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
// src/features/matrix-grid/adapters/inbound/useMatrixGridKeyboardFocus.ts
|
|
217
|
-
function useMatrixGridKeyboardFocus(index, disabled, visibleIds, onNavigate) {
|
|
219
|
+
function useMatrixGridKeyboardFocus(index, disabled, visibleIds, isNavigable, onNavigate) {
|
|
218
220
|
const [focusedId, setFocusedId] = React.useState(null);
|
|
219
221
|
const focusedRef = React.useRef(null);
|
|
220
222
|
const pendingFocusRef = React.useRef(null);
|
|
221
223
|
const cellRefs = React.useRef(new Map);
|
|
222
224
|
const visibleIdSet = React.useMemo(() => new Set(visibleIds), [visibleIds]);
|
|
223
|
-
const tabStopId = focusedId !== null && visibleIdSet.has(focusedId) ? focusedId : visibleIds.find((id) => index.positionById.has(id));
|
|
225
|
+
const tabStopId = focusedId !== null && visibleIdSet.has(focusedId) && isNavigable(focusedId) ? focusedId : visibleIds.find((id) => index.positionById.has(id) && isNavigable(id));
|
|
226
|
+
React.useEffect(() => {
|
|
227
|
+
if (focusedRef.current !== null && !isNavigable(focusedRef.current)) {
|
|
228
|
+
focusedRef.current = null;
|
|
229
|
+
setFocusedId(null);
|
|
230
|
+
}
|
|
231
|
+
if (pendingFocusRef.current !== null && !isNavigable(pendingFocusRef.current)) {
|
|
232
|
+
pendingFocusRef.current = null;
|
|
233
|
+
}
|
|
234
|
+
}, [isNavigable]);
|
|
224
235
|
const onFocus = React.useCallback((id) => {
|
|
225
236
|
pendingFocusRef.current = null;
|
|
226
237
|
focusedRef.current = id;
|
|
@@ -242,7 +253,7 @@ function useMatrixGridKeyboardFocus(index, disabled, visibleIds, onNavigate) {
|
|
|
242
253
|
return false;
|
|
243
254
|
}
|
|
244
255
|
const originId = focusedRef.current ?? id;
|
|
245
|
-
const nextId =
|
|
256
|
+
const nextId = resolveNextNavigableId(index, originId, key, isNavigable);
|
|
246
257
|
if (nextId === null || nextId === originId)
|
|
247
258
|
return true;
|
|
248
259
|
focusedRef.current = nextId;
|
|
@@ -255,9 +266,19 @@ function useMatrixGridKeyboardFocus(index, disabled, visibleIds, onNavigate) {
|
|
|
255
266
|
mounted.focus();
|
|
256
267
|
}
|
|
257
268
|
return true;
|
|
258
|
-
}, [disabled, index, onNavigate]);
|
|
269
|
+
}, [disabled, index, isNavigable, onNavigate]);
|
|
259
270
|
return { focusedId, onFocus, onKeyDown, registerCell, tabStopId };
|
|
260
271
|
}
|
|
272
|
+
function resolveNextNavigableId(index, originId, key, isNavigable) {
|
|
273
|
+
let candidate = getMatrixGridNextFocusId(index, originId, key);
|
|
274
|
+
while (candidate !== null && candidate !== originId && !isNavigable(candidate)) {
|
|
275
|
+
const nextCandidate = getMatrixGridNextFocusId(index, candidate, key);
|
|
276
|
+
if (nextCandidate === candidate)
|
|
277
|
+
return originId;
|
|
278
|
+
candidate = nextCandidate;
|
|
279
|
+
}
|
|
280
|
+
return candidate;
|
|
281
|
+
}
|
|
261
282
|
|
|
262
283
|
// src/features/matrix-grid/adapters/inbound/MatrixGrid.tsx
|
|
263
284
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -270,6 +291,7 @@ function MatrixGridInner({
|
|
|
270
291
|
onSelectionChange,
|
|
271
292
|
onViewportChange,
|
|
272
293
|
overscanPixels = 160,
|
|
294
|
+
protectedCellIds = [],
|
|
273
295
|
readOnly = false,
|
|
274
296
|
renderCell,
|
|
275
297
|
selectedCellIds = [],
|
|
@@ -289,16 +311,18 @@ function MatrixGridInner({
|
|
|
289
311
|
const cellPlacements = React2.useMemo(() => getVisibleMatrixCells(layout, cells, viewport, overscanPixels), [cells, layout, overscanPixels, viewport]);
|
|
290
312
|
const [visibleIds, setVisibleIds] = React2.useState([]);
|
|
291
313
|
const anchorId = React2.useRef(null);
|
|
314
|
+
const protectedCellIdSet = React2.useMemo(() => new Set(protectedCellIds), [protectedCellIds]);
|
|
315
|
+
const isNavigable = React2.useCallback((id) => !protectedCellIdSet.has(id), [protectedCellIdSet]);
|
|
292
316
|
const handleViewportChange = React2.useCallback((proposal) => {
|
|
293
317
|
if (controlledViewport === undefined)
|
|
294
318
|
setUncontrolledViewport(proposal);
|
|
295
319
|
onViewportChange?.(proposal);
|
|
296
320
|
}, [controlledViewport, onViewportChange]);
|
|
297
321
|
const activateCell = React2.useCallback((cell, event) => {
|
|
298
|
-
if (interactionPolicy === "passive" || readOnly)
|
|
322
|
+
if (interactionPolicy === "passive" || readOnly || protectedCellIdSet.has(cell.id))
|
|
299
323
|
return;
|
|
300
324
|
const intent = isRangeSelectionEvent(event) ? "range" : resolveSelectionEventIntent(event, "pointer");
|
|
301
|
-
onSelectionChange?.(resolveMatrixGridSelection(sparseIndex.entries, selectedCellIds, cell.id, anchorId.current, intent, selectionMode));
|
|
325
|
+
onSelectionChange?.(resolveMatrixGridSelection(sparseIndex.entries, selectedCellIds, cell.id, anchorId.current, intent, selectionMode, protectedCellIdSet));
|
|
302
326
|
if (intent !== "range")
|
|
303
327
|
anchorId.current = cell.id;
|
|
304
328
|
}, [
|
|
@@ -307,7 +331,8 @@ function MatrixGridInner({
|
|
|
307
331
|
readOnly,
|
|
308
332
|
selectedCellIds,
|
|
309
333
|
selectionMode,
|
|
310
|
-
sparseIndex.entries
|
|
334
|
+
sparseIndex.entries,
|
|
335
|
+
protectedCellIdSet
|
|
311
336
|
]);
|
|
312
337
|
const handleKeyboardNavigation = React2.useCallback((targetId, originId, shiftKey) => {
|
|
313
338
|
anchorId.current ??= originId;
|
|
@@ -317,7 +342,7 @@ function MatrixGridInner({
|
|
|
317
342
|
if (cell)
|
|
318
343
|
activateCell(getMatrixCellPlacement(layout, cell), { shiftKey: true });
|
|
319
344
|
}, [activateCell, layout, sparseIndex]);
|
|
320
|
-
const keyboard = useMatrixGridKeyboardFocus(sparseIndex, interactionPolicy === "passive", visibleIds, handleKeyboardNavigation);
|
|
345
|
+
const keyboard = useMatrixGridKeyboardFocus(sparseIndex, interactionPolicy === "passive", visibleIds, isNavigable, handleKeyboardNavigation);
|
|
321
346
|
const focusedPlacement = React2.useMemo(() => {
|
|
322
347
|
const focusedCell = keyboard.focusedId === null ? undefined : sparseIndex.cellById.get(keyboard.focusedId);
|
|
323
348
|
return focusedCell ? getMatrixCellPlacement(layout, focusedCell) : undefined;
|
|
@@ -339,7 +364,7 @@ function MatrixGridInner({
|
|
|
339
364
|
const cell = cellById.get(item.id);
|
|
340
365
|
if (!cell)
|
|
341
366
|
return null;
|
|
342
|
-
return renderMatrixCell(cell, selectedCellIds, theme.semantics.neutral.divider, theme.colors.primary, renderCell, activateCell, keyboard, interactionPolicy === "passive", readOnly, testID);
|
|
367
|
+
return renderMatrixCell(cell, selectedCellIds, theme.semantics.neutral.divider, theme.colors.primary, renderCell, activateCell, keyboard, interactionPolicy === "passive", protectedCellIdSet.has(cell.id), readOnly, testID);
|
|
343
368
|
},
|
|
344
369
|
testID,
|
|
345
370
|
viewport,
|
|
@@ -348,7 +373,7 @@ function MatrixGridInner({
|
|
|
348
373
|
})
|
|
349
374
|
});
|
|
350
375
|
}
|
|
351
|
-
function renderMatrixCell(cell, selectedCellIds, dividerColor, selectedColor, renderCell, activateCell, keyboard, passive, readOnly, testID) {
|
|
376
|
+
function renderMatrixCell(cell, selectedCellIds, dividerColor, selectedColor, renderCell, activateCell, keyboard, passive, protectedCell, readOnly, testID) {
|
|
352
377
|
const selected = selectedCellIds.includes(cell.id);
|
|
353
378
|
const canInteract = keyboard.tabStopId === cell.id;
|
|
354
379
|
return /* @__PURE__ */ jsx2(MatrixGridKeyboardProxy, {
|
|
@@ -357,7 +382,7 @@ function renderMatrixCell(cell, selectedCellIds, dividerColor, selectedColor, re
|
|
|
357
382
|
return true;
|
|
358
383
|
if (!["Enter", " "].includes(event.key))
|
|
359
384
|
return false;
|
|
360
|
-
if (passive || readOnly)
|
|
385
|
+
if (passive || protectedCell || readOnly)
|
|
361
386
|
return false;
|
|
362
387
|
activateCell(cell, event);
|
|
363
388
|
return true;
|
|
@@ -366,9 +391,9 @@ function renderMatrixCell(cell, selectedCellIds, dividerColor, selectedColor, re
|
|
|
366
391
|
accessibilityActions: [{ name: "activate" }],
|
|
367
392
|
accessibilityLabel: `Cell ${cell.id}`,
|
|
368
393
|
accessibilityRole: "button",
|
|
369
|
-
accessibilityState: { disabled: passive, selected },
|
|
370
|
-
disabled: passive,
|
|
371
|
-
focusable: import_react_native.Platform.OS !== "web" || canInteract,
|
|
394
|
+
accessibilityState: { disabled: passive || protectedCell, selected },
|
|
395
|
+
disabled: passive || protectedCell,
|
|
396
|
+
focusable: !protectedCell && (import_react_native.Platform.OS !== "web" || canInteract),
|
|
372
397
|
style: [
|
|
373
398
|
styles.cell,
|
|
374
399
|
{
|