@ankhorage/zora 27.5.3 → 27.6.1
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 +18 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +13 -1
- package/dist/capabilities/index.js.map +5 -4
- package/dist/features/calendar/adapters/inbound/Calendar.d.ts +5 -0
- package/dist/features/calendar/adapters/inbound/Calendar.d.ts.map +1 -0
- package/dist/features/calendar/adapters/inbound/Calendar.js +126 -0
- package/dist/features/calendar/adapters/inbound/Calendar.js.map +1 -0
- package/dist/features/calendar/application/createCalendarMonth.d.ts +9 -0
- package/dist/features/calendar/application/createCalendarMonth.d.ts.map +1 -0
- package/dist/features/calendar/application/createCalendarMonth.js +25 -0
- package/dist/features/calendar/application/createCalendarMonth.js.map +1 -0
- package/dist/features/calendar/application/isCalendarDateDisabled.d.ts +10 -0
- package/dist/features/calendar/application/isCalendarDateDisabled.d.ts.map +1 -0
- package/dist/features/calendar/application/isCalendarDateDisabled.js +23 -0
- package/dist/features/calendar/application/isCalendarDateDisabled.js.map +1 -0
- package/dist/features/calendar/calendarMeta.d.ts +10 -0
- package/dist/features/calendar/calendarMeta.d.ts.map +1 -0
- package/dist/features/calendar/calendarMeta.js +10 -0
- package/dist/features/calendar/calendarMeta.js.map +1 -0
- package/dist/features/calendar/public.d.ts +2 -0
- package/dist/features/calendar/public.d.ts.map +1 -1
- package/dist/features/calendar/public.js +1 -1
- package/dist/features/calendar/public.js.map +1 -1
- package/dist/features/data-table/adapters/inbound/DataTable.d.ts +1 -1
- package/dist/features/data-table/adapters/inbound/DataTable.d.ts.map +1 -1
- package/dist/features/data-table/adapters/inbound/DataTable.js +82 -23
- package/dist/features/data-table/adapters/inbound/DataTable.js.map +1 -1
- package/dist/features/date-picker/composition/DatePickerContent.d.ts +1 -1
- package/dist/features/date-picker/composition/DatePickerContent.d.ts.map +1 -1
- package/dist/features/date-picker/composition/DatePickerContent.js +5 -104
- package/dist/features/date-picker/composition/DatePickerContent.js.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphController.js +7 -2
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphController.js.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +27 -4
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.js +18 -6
- package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.js.map +1 -1
- package/dist/features/grid-view/adapters/inbound/GridView.d.ts +1 -1
- package/dist/features/grid-view/adapters/inbound/GridView.d.ts.map +1 -1
- package/dist/features/grid-view/adapters/inbound/GridView.js +6 -5
- package/dist/features/grid-view/adapters/inbound/GridView.js.map +1 -1
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.d.ts.map +1 -1
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js +2 -0
- package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js.map +1 -1
- package/dist/features/registry/componentMeta.d.ts.map +1 -1
- package/dist/features/registry/componentMeta.js +2 -0
- package/dist/features/registry/componentMeta.js.map +1 -1
- package/dist/features/timeline/adapters/inbound/Timeline.d.ts.map +1 -1
- package/dist/features/timeline/adapters/inbound/Timeline.js +17 -11
- package/dist/features/timeline/adapters/inbound/Timeline.js.map +1 -1
- package/dist/readerFree.d.ts +1 -0
- package/dist/readerFree.d.ts.map +1 -1
- package/dist/readerFree.js +1 -0
- package/dist/readerFree.js.map +1 -1
- package/dist/types/calendar.d.ts +24 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +2 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/data-table.d.ts +4 -0
- package/dist/types/data-table.d.ts.map +1 -1
- package/dist/types/data-table.js.map +1 -1
- package/dist/types/grid-view.d.ts +2 -0
- package/dist/types/grid-view.d.ts.map +1 -1
- package/dist/types/grid-view.js.map +1 -1
- package/dist/types/timeline.d.ts +3 -0
- package/dist/types/timeline.d.ts.map +1 -1
- package/dist/types/timeline.js.map +1 -1
- package/package.json +2 -2
- package/src/features/calendar/adapters/inbound/Calendar.interaction.test.tsx +115 -0
- package/src/features/calendar/adapters/inbound/Calendar.tsx +219 -0
- package/src/features/calendar/application/createCalendarMonth.test.ts +23 -0
- package/src/features/calendar/application/createCalendarMonth.ts +38 -0
- package/src/features/calendar/application/isCalendarDateDisabled.test.ts +49 -0
- package/src/features/calendar/application/isCalendarDateDisabled.ts +41 -0
- package/src/features/calendar/calendarMeta.ts +11 -0
- package/src/features/calendar/public.test.ts +14 -0
- package/src/features/calendar/public.ts +7 -0
- package/src/features/data-table/adapters/inbound/DataTable.test.tsx +242 -0
- package/src/features/data-table/adapters/inbound/DataTable.tsx +162 -38
- package/src/features/date-picker/composition/DatePickerContent.tsx +8 -192
- package/src/features/date-picker/public.test.ts +2 -1
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphController.ts +9 -2
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +210 -4
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +36 -3
- package/src/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.test.ts +33 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.ts +19 -5
- package/src/features/grid-view/adapters/inbound/GridView.tsx +6 -4
- package/src/features/registry/ZORA_BASE_COMPONENT_REGISTRY.ts +2 -0
- package/src/features/registry/componentMeta.ts +2 -0
- package/src/features/timeline/adapters/inbound/Timeline.test.tsx +175 -0
- package/src/features/timeline/adapters/inbound/Timeline.tsx +47 -26
- package/src/readerFree.ts +7 -0
- package/src/types/calendar.ts +25 -0
- package/src/types/data-table.ts +4 -0
- package/src/types/grid-view.ts +2 -0
- package/src/types/timeline.ts +3 -0
- package/web-dist/chunks/{Accordion-k81eyekh.js → Accordion-0j4xzcwz.js} +2 -2
- package/web-dist/chunks/{Accordion-5f9e10c6.js → Accordion-252dr90x.js} +1 -1
- package/web-dist/chunks/{Accordion-0pryvztw.js → Accordion-260pyaxy.js} +1 -1
- package/web-dist/chunks/{Accordion-g9hn7fht.js → Accordion-4c7hqeg3.js} +1 -1
- package/web-dist/chunks/{Accordion-0z8nry94.js → Accordion-4kmh6s2k.js} +1 -1
- package/web-dist/chunks/{Accordion-g758dqfc.js → Accordion-5pbvgvqc.js} +1 -1
- package/web-dist/chunks/{Accordion-jp5xt2kz.js → Accordion-5z8pbn4z.js} +1 -1
- package/web-dist/chunks/{Accordion-qzx53csd.js → Accordion-6jsea4e0.js} +4 -4
- package/web-dist/chunks/{Accordion-yd025qec.js → Accordion-7788ybcs.js} +2 -2
- package/web-dist/chunks/{Accordion-ppksc4jh.js → Accordion-7mnan4q4.js} +4 -4
- package/web-dist/chunks/{Accordion-0pm8dvcy.js → Accordion-8j7t77tf.js} +2 -2
- package/web-dist/chunks/{Accordion-6tesp7jr.js → Accordion-c44m1q0m.js} +1 -1
- package/web-dist/chunks/{Accordion-a6h4ff7g.js → Accordion-f2n2zz1x.js} +2 -2
- package/web-dist/chunks/{Accordion-ep9xpmbw.js → Accordion-fbehwpr1.js} +3 -3
- package/web-dist/chunks/{Accordion-j09h3pg1.js → Accordion-hf4nfkn0.js} +7 -7
- package/web-dist/chunks/{Accordion-xr81ntxh.js → Accordion-hh48jjhk.js} +4 -4
- package/web-dist/chunks/{Accordion-3qz6s2z9.js → Accordion-j6bs1yfn.js} +1 -1
- package/web-dist/chunks/{Accordion-dnpfe329.js → Accordion-jh94mg56.js} +3 -3
- package/web-dist/chunks/{Accordion-6c2ykyad.js → Accordion-jx9tc6p1.js} +2 -2
- package/web-dist/chunks/{Accordion-8xgdw6ry.js → Accordion-kcca65d8.js} +1 -1
- package/web-dist/chunks/{Accordion-g009pehq.js → Accordion-m3xb7z7j.js} +3 -3
- package/web-dist/chunks/{Accordion-eqkmzs33.js → Accordion-mpebzjby.js} +1 -1
- package/web-dist/chunks/{Accordion-n29svm40.js → Accordion-ms1y70gq.js} +1 -1
- package/web-dist/chunks/{Accordion-t0k1cjca.js → Accordion-neg1cgeh.js} +7 -5
- package/web-dist/chunks/{Accordion-wfrt39d2.js → Accordion-nnhznqgf.js} +1 -1
- package/web-dist/chunks/{Accordion-cqdfhyr9.js → Accordion-np16p9mh.js} +1 -1
- package/web-dist/chunks/{Accordion-zjygy6n2.js → Accordion-p2f0e4pn.js} +3 -3
- package/web-dist/chunks/{Accordion-q1vqpaw6.js → Accordion-p7mxkxhs.js} +4 -4
- package/web-dist/chunks/{Accordion-d6f4vr6s.js → Accordion-r6zvzrkd.js} +1 -1
- package/web-dist/chunks/Accordion-r86ce0wj.js +237 -0
- package/web-dist/chunks/{Accordion-b8659jt9.js → Accordion-rwc34cn2.js} +1 -1
- package/web-dist/chunks/{Accordion-rcff84ws.js → Accordion-s9nbkzky.js} +1 -1
- package/web-dist/chunks/{Accordion-01s50nga.js → Accordion-sxzts6bj.js} +1 -1
- package/web-dist/chunks/{Accordion-36nt5xmp.js → Accordion-t2cvrn0r.js} +4 -4
- package/web-dist/chunks/{Accordion-y5kdx80m.js → Accordion-tnt1txfq.js} +3 -3
- package/web-dist/chunks/{Accordion-bj7hv2dq.js → Accordion-vq8zrnwh.js} +1 -1
- package/web-dist/chunks/{Accordion-hh6jrz1e.js → Accordion-w0prbwy0.js} +4 -4
- package/web-dist/chunks/{Accordion-zqzqg9yc.js → Accordion-wvghkwxx.js} +6 -6
- package/web-dist/chunks/{Accordion-cp82h5jx.js → Accordion-wx0jp5cn.js} +4 -4
- package/web-dist/chunks/{Accordion-bwp6m0zd.js → Accordion-yb4as6wc.js} +2 -2
- package/web-dist/chunks/{Accordion-e9c80kn7.js → Accordion-yrzm02g2.js} +2 -2
- package/web-dist/components/accordion/Accordion.js +3 -3
- package/web-dist/components/accordion-item/AccordionItem.js +3 -3
- package/web-dist/components/app-bar/AppBar.js +8 -8
- package/web-dist/components/app-header/AppHeader.js +8 -8
- package/web-dist/components/app-shell/AppShell.js +2 -2
- package/web-dist/components/auth-screen/AuthScreen.js +12 -12
- package/web-dist/components/avatar/Avatar.js +3 -3
- package/web-dist/components/avatar-group/AvatarGroup.js +3 -3
- package/web-dist/components/badge/Badge.js +2 -2
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +11 -11
- package/web-dist/components/bottom-sheet/BottomSheet.js +3 -3
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +3 -3
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +3 -3
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +3 -3
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +3 -3
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +3 -3
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +5 -5
- package/web-dist/components/button/Button.js +5 -5
- package/web-dist/components/button-group/ButtonGroup.js +5 -5
- package/web-dist/components/calendar/Calendar.d.ts +8 -0
- package/web-dist/components/calendar/Calendar.dependency-0.d.ts +27 -0
- package/web-dist/components/calendar/Calendar.dependency-1.d.ts +3 -0
- package/web-dist/components/calendar/Calendar.js +25 -0
- package/web-dist/components/calendar/Calendar.types-0.d.ts +27 -0
- package/web-dist/components/calendar/Calendar.types-1.d.ts +146 -0
- package/web-dist/components/calendar/index.d.ts +2 -0
- package/web-dist/components/calendar/index.js +2 -0
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +11 -11
- package/web-dist/components/card/Card.js +10 -10
- package/web-dist/components/chat-list-item/ChatListItem.js +6 -6
- package/web-dist/components/checkbox/Checkbox.js +4 -4
- package/web-dist/components/checkbox-group/CheckboxGroup.js +4 -4
- package/web-dist/components/chess-board/ChessBoard.js +2 -2
- package/web-dist/components/chip/Chip.js +4 -4
- package/web-dist/components/chip-group/ChipGroup.js +4 -4
- package/web-dist/components/collection-editor/CollectionEditor.js +10 -10
- package/web-dist/components/color-hue-scale/ColorHueScale.js +6 -6
- package/web-dist/components/color-picker/ColorPicker.js +6 -6
- package/web-dist/components/color-tone/ColorTone.js +6 -6
- package/web-dist/components/color-wheel/ColorWheel.js +6 -6
- package/web-dist/components/content-rail/ContentRail.js +5 -5
- package/web-dist/components/data-table/DataTable.d.ts +1 -1
- package/web-dist/components/data-table/DataTable.js +149 -64
- package/web-dist/components/data-table/DataTable.types-0.d.ts +4 -0
- package/web-dist/components/date-picker/DatePicker.js +19 -160
- package/web-dist/components/dialog/Dialog.js +4 -4
- package/web-dist/components/divider/Divider.js +2 -2
- package/web-dist/components/empty-state/EmptyState.js +11 -11
- package/web-dist/components/explorer/Explorer.js +5 -5
- package/web-dist/components/field/Field.js +4 -4
- package/web-dist/components/file-explorer/FileExplorer.js +5 -5
- package/web-dist/components/flat-list/FlatList.js +5 -5
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +12 -12
- package/web-dist/components/form/Form.js +8 -8
- package/web-dist/components/form-actions/FormActions.js +8 -8
- package/web-dist/components/form-error/FormError.js +8 -8
- package/web-dist/components/game/Game.js +3 -3
- package/web-dist/components/game-entity/GameEntity.js +3 -3
- package/web-dist/components/game-field/GameField.js +3 -3
- package/web-dist/components/game-input-zone/GameInputZone.js +3 -3
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +3 -3
- package/web-dist/components/game-overlay/GameOverlay.js +3 -3
- package/web-dist/components/gradient/Gradient.js +3 -3
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +3 -3
- package/web-dist/components/graph-view/GraphView.js +34 -11
- package/web-dist/components/grid/Grid.js +2 -2
- package/web-dist/components/grid-view/GridView.d.ts +1 -1
- package/web-dist/components/grid-view/GridView.js +1 -1
- package/web-dist/components/grid-view/GridView.types-0.d.ts +2 -0
- package/web-dist/components/hero/Hero.js +10 -10
- package/web-dist/components/icon-button/IconButton.js +5 -5
- package/web-dist/components/image/Image.js +3 -3
- package/web-dist/components/list/List.js +5 -5
- package/web-dist/components/list-item/ListItem.js +5 -5
- package/web-dist/components/list-section/ListSection.js +5 -5
- package/web-dist/components/matrix-grid/MatrixGrid.js +1 -1
- package/web-dist/components/media-card/MediaCard.js +10 -10
- package/web-dist/components/media-explorer/MediaExplorer.js +5 -5
- package/web-dist/components/message-bubble/MessageBubble.js +6 -6
- package/web-dist/components/metric-card/MetricCard.js +10 -10
- package/web-dist/components/missing-element/MissingElement.js +3 -3
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +12 -12
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +12 -12
- package/web-dist/components/opening-book/OpeningBook.js +2 -2
- package/web-dist/components/otp-form/OtpForm.js +12 -12
- package/web-dist/components/pagination/Pagination.js +5 -5
- package/web-dist/components/palette-item/PaletteItem.js +10 -10
- package/web-dist/components/popover-menu/PopoverMenu.js +4 -4
- package/web-dist/components/post-card/PostCard.js +10 -10
- package/web-dist/components/product-card/ProductCard.js +10 -10
- package/web-dist/components/progress/Progress.js +3 -3
- package/web-dist/components/progress-ring/ProgressRing.js +3 -3
- package/web-dist/components/radio/Radio.js +4 -4
- package/web-dist/components/radio-group/RadioGroup.js +4 -4
- package/web-dist/components/rating/Rating.js +2 -2
- package/web-dist/components/reader/Reader.js +11 -11
- package/web-dist/components/scan-overlay/ScanOverlay.js +11 -11
- package/web-dist/components/screen/Screen.js +2 -2
- package/web-dist/components/screen-section/ScreenSection.js +3 -3
- package/web-dist/components/scroll-view/ScrollView.js +2 -2
- package/web-dist/components/search-input/SearchInput.js +6 -6
- package/web-dist/components/section-header/SectionHeader.js +3 -3
- package/web-dist/components/section-list/SectionList.js +5 -5
- package/web-dist/components/select/Select.js +8 -8
- package/web-dist/components/sign-in-form/SignInForm.js +12 -12
- package/web-dist/components/sign-up-form/SignUpForm.js +12 -12
- package/web-dist/components/skeleton/Skeleton.js +13 -13
- package/web-dist/components/skeleton-card/SkeletonCard.js +13 -13
- package/web-dist/components/skeleton-list/SkeletonList.js +13 -13
- package/web-dist/components/skeleton-text/SkeletonText.js +13 -13
- package/web-dist/components/spatial-grid/SpatialGrid.js +1 -1
- package/web-dist/components/surface/Surface.js +3 -3
- package/web-dist/components/switch/Switch.js +2 -2
- package/web-dist/components/tab/Tab.js +2 -2
- package/web-dist/components/tab-list/TabList.js +2 -2
- package/web-dist/components/tab-panel/TabPanel.js +2 -2
- package/web-dist/components/tabs/Tabs.js +2 -2
- package/web-dist/components/text-input/TextInput.js +6 -6
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +5 -5
- package/web-dist/components/tile-grid/TileGrid.js +1 -1
- package/web-dist/components/time-grid/TimeGrid.js +1 -1
- package/web-dist/components/time-picker/TimePicker.js +9 -9
- package/web-dist/components/timeline/Timeline.dependency-2.d.ts +8 -2
- package/web-dist/components/timeline/Timeline.dependency-3.d.ts +23 -0
- package/web-dist/components/timeline/Timeline.dependency-4.d.ts +3 -0
- package/web-dist/components/timeline/Timeline.js +30 -11
- package/web-dist/components/timeline/Timeline.types-0.d.ts +5 -1
- package/web-dist/components/toast/Toast.js +4 -4
- package/web-dist/components/toast-provider/ToastProvider.js +4 -4
- package/web-dist/components/toolbar/Toolbar.js +10 -10
- package/web-dist/components/tree-item/TreeItem.js +7 -7
- package/web-dist/components/uploader/Uploader.js +14 -14
- package/web-dist/components/view/View.js +2 -2
- package/web-dist/manifest.json +720 -673
- package/web-dist/runtime/ZoraProvider.js +3 -3
- /package/web-dist/chunks/{Accordion-kpk964z0.js → Accordion-a8k3cvj0.js} +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { afterAll, expect, mock, test } from 'bun:test';
|
|
2
|
+
import { Window } from 'happy-dom';
|
|
3
|
+
import React, { act } from 'react';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
|
|
6
|
+
let mobilePresentation = false;
|
|
7
|
+
|
|
8
|
+
const browser = new Window();
|
|
9
|
+
const globals = ['window', 'document', 'Node', 'navigator', 'IS_REACT_ACT_ENVIRONMENT'] as const;
|
|
10
|
+
const previousGlobals = globals.map(
|
|
11
|
+
(key) => [key, Object.getOwnPropertyDescriptor(globalThis, key)] as const,
|
|
12
|
+
);
|
|
13
|
+
Object.assign(globalThis, {
|
|
14
|
+
IS_REACT_ACT_ENVIRONMENT: true,
|
|
15
|
+
Node: browser.Node,
|
|
16
|
+
document: browser.document,
|
|
17
|
+
navigator: browser.navigator,
|
|
18
|
+
window: browser,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const View = ({
|
|
22
|
+
children,
|
|
23
|
+
style,
|
|
24
|
+
testID,
|
|
25
|
+
}: {
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
style?: object;
|
|
28
|
+
testID?: string;
|
|
29
|
+
}) => (
|
|
30
|
+
<div data-testid={testID} style={style}>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
await mock.module('react-native', () => ({ ScrollView: View }));
|
|
36
|
+
await mock.module('../../../button/public', () => ({
|
|
37
|
+
Button: ({ children, onPress }: { children?: React.ReactNode; onPress?: () => void }) => (
|
|
38
|
+
<button onClick={onPress}>{children}</button>
|
|
39
|
+
),
|
|
40
|
+
IconButton: ({ onPress }: { onPress?: () => void }) => <button onClick={onPress} />,
|
|
41
|
+
}));
|
|
42
|
+
await mock.module('../../../card/public', () => ({
|
|
43
|
+
Card: ({
|
|
44
|
+
actions,
|
|
45
|
+
children,
|
|
46
|
+
title,
|
|
47
|
+
}: {
|
|
48
|
+
actions?: React.ReactNode;
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
title?: React.ReactNode;
|
|
51
|
+
}) => (
|
|
52
|
+
<div>
|
|
53
|
+
{title}
|
|
54
|
+
{actions}
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
}));
|
|
59
|
+
await mock.module('../../../empty-state/public', () => ({ EmptyState: View }));
|
|
60
|
+
await mock.module('../../../form/checkbox/public', () => ({
|
|
61
|
+
Checkbox: ({
|
|
62
|
+
accessibilityLabel,
|
|
63
|
+
checked,
|
|
64
|
+
disabled,
|
|
65
|
+
onCheckedChange,
|
|
66
|
+
}: {
|
|
67
|
+
accessibilityLabel?: string;
|
|
68
|
+
checked?: boolean;
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
71
|
+
}) => (
|
|
72
|
+
<button
|
|
73
|
+
aria-checked={checked}
|
|
74
|
+
aria-label={accessibilityLabel}
|
|
75
|
+
disabled={disabled}
|
|
76
|
+
onClick={() => onCheckedChange?.(!checked)}
|
|
77
|
+
role="checkbox"
|
|
78
|
+
/>
|
|
79
|
+
),
|
|
80
|
+
}));
|
|
81
|
+
await mock.module('../../../layout/public', () => ({ View }));
|
|
82
|
+
await mock.module('../../../popover-menu/public', () => ({ PopoverMenu: View }));
|
|
83
|
+
await mock.module('../../../skeleton/public', () => ({ SkeletonList: View }));
|
|
84
|
+
await mock.module('../../../theme/adapters/inbound/withZoraThemeScope', () => ({
|
|
85
|
+
withZoraThemeScope: <P,>(Component: React.ComponentType<P>) => Component,
|
|
86
|
+
}));
|
|
87
|
+
await mock.module('../../../typography/public', () => ({
|
|
88
|
+
Text: ({ children }: { children?: React.ReactNode }) => <span>{children}</span>,
|
|
89
|
+
}));
|
|
90
|
+
await mock.module('@ankhorage/surface', () => ({
|
|
91
|
+
Show: ({ children, fallback }: { children?: React.ReactNode; fallback?: React.ReactNode }) => (
|
|
92
|
+
<>{mobilePresentation ? fallback : children}</>
|
|
93
|
+
),
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
const { DataTable } = await import('./DataTable');
|
|
97
|
+
|
|
98
|
+
afterAll(() => {
|
|
99
|
+
browser.close();
|
|
100
|
+
for (const [key, descriptor] of previousGlobals) {
|
|
101
|
+
if (descriptor) Object.defineProperty(globalThis, key, descriptor);
|
|
102
|
+
else Reflect.deleteProperty(globalThis, key);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/*** Renders DataTable against a DOM-backed primitive boundary. */
|
|
107
|
+
function mount() {
|
|
108
|
+
const host = document.createElement('div');
|
|
109
|
+
document.body.append(host);
|
|
110
|
+
const root = createRoot(host);
|
|
111
|
+
return {
|
|
112
|
+
host,
|
|
113
|
+
render: (element: React.ReactNode) =>
|
|
114
|
+
act(() => Promise.resolve().then(() => root.render(element))),
|
|
115
|
+
unmount: () => act(() => Promise.resolve().then(() => root.unmount())),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
test('uses stable row identities for controlled checkbox and all-visible selection', async () => {
|
|
120
|
+
const mounted = mount();
|
|
121
|
+
const changes: string[][] = [];
|
|
122
|
+
const onSelectedRowIdsChange = (selectedRowIds: readonly string[]) =>
|
|
123
|
+
changes.push([...selectedRowIds]);
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
await mounted.render(
|
|
127
|
+
<DataTable
|
|
128
|
+
columns={[{ accessor: 'name', header: 'Company', id: 'company' }]}
|
|
129
|
+
onSelectedRowIdsChange={onSelectedRowIdsChange}
|
|
130
|
+
rowKey="id"
|
|
131
|
+
rows={[
|
|
132
|
+
{ id: 'acme', name: 'Acme' },
|
|
133
|
+
{ id: 'zora', name: 'ZORA' },
|
|
134
|
+
]}
|
|
135
|
+
selectedRowIds={['acme']}
|
|
136
|
+
/>,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const zora = mounted.host.querySelector<HTMLButtonElement>('[aria-label="Select row zora"]');
|
|
140
|
+
expect(zora?.getAttribute('role')).toBe('checkbox');
|
|
141
|
+
expect(zora?.getAttribute('aria-checked')).toBe('false');
|
|
142
|
+
zora?.click();
|
|
143
|
+
expect(changes).toEqual([['acme', 'zora']]);
|
|
144
|
+
|
|
145
|
+
const all = mounted.host.querySelector<HTMLButtonElement>(
|
|
146
|
+
'[aria-label="Select all visible rows"]',
|
|
147
|
+
);
|
|
148
|
+
all?.click();
|
|
149
|
+
expect(changes).toEqual([
|
|
150
|
+
['acme', 'zora'],
|
|
151
|
+
['acme', 'zora'],
|
|
152
|
+
]);
|
|
153
|
+
|
|
154
|
+
await mounted.render(
|
|
155
|
+
<DataTable
|
|
156
|
+
columns={[{ accessor: 'name', header: 'Company', id: 'company' }]}
|
|
157
|
+
onSelectedRowIdsChange={onSelectedRowIdsChange}
|
|
158
|
+
rowKey="id"
|
|
159
|
+
rows={[
|
|
160
|
+
{ id: 'zora', name: 'ZORA' },
|
|
161
|
+
{ id: 'acme', name: 'Acme' },
|
|
162
|
+
]}
|
|
163
|
+
selectedRowIds={['acme', 'zora']}
|
|
164
|
+
/>,
|
|
165
|
+
);
|
|
166
|
+
expect(all?.getAttribute('aria-checked')).toBe('true');
|
|
167
|
+
expect(mounted.host.textContent).not.toContain('Actions');
|
|
168
|
+
expect(mounted.host.innerHTML).not.toContain('min-width: 720px');
|
|
169
|
+
expect(mounted.host.innerHTML).not.toContain('min-width: 140px');
|
|
170
|
+
} finally {
|
|
171
|
+
await mounted.unmount();
|
|
172
|
+
mounted.host.remove();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('keeps controlled selection visibly disabled in passive mode', async () => {
|
|
177
|
+
const mounted = mount();
|
|
178
|
+
const changes: string[][] = [];
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
await mounted.render(
|
|
182
|
+
<DataTable
|
|
183
|
+
columns={[{ accessor: 'name', header: 'Company', id: 'company' }]}
|
|
184
|
+
interactionPolicy="passive"
|
|
185
|
+
onSelectedRowIdsChange={(selectedRowIds) => changes.push([...selectedRowIds])}
|
|
186
|
+
rowKey="id"
|
|
187
|
+
rows={[{ id: 'acme', name: 'Acme' }]}
|
|
188
|
+
selectedRowIds={[]}
|
|
189
|
+
/>,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const checkbox = mounted.host.querySelector<HTMLButtonElement>(
|
|
193
|
+
'[aria-label="Select row acme"]',
|
|
194
|
+
);
|
|
195
|
+
expect(checkbox?.disabled).toBe(true);
|
|
196
|
+
checkbox?.click();
|
|
197
|
+
expect(changes).toEqual([]);
|
|
198
|
+
} finally {
|
|
199
|
+
await mounted.unmount();
|
|
200
|
+
mounted.host.remove();
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('uses desktop stable row ids and the controlled callback in mobile cards', async () => {
|
|
205
|
+
mobilePresentation = true;
|
|
206
|
+
const mounted = mount();
|
|
207
|
+
const changes: string[][] = [];
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
await mounted.render(
|
|
211
|
+
<DataTable
|
|
212
|
+
columns={[
|
|
213
|
+
{ accessor: 'name', header: 'Company', id: 'company' },
|
|
214
|
+
{ accessor: 'location', header: 'Location', id: 'location' },
|
|
215
|
+
]}
|
|
216
|
+
onSelectedRowIdsChange={(selectedRowIds) => changes.push([...selectedRowIds])}
|
|
217
|
+
rowId={(row) => `company-${row.id}`}
|
|
218
|
+
rows={[
|
|
219
|
+
{ id: 'acme', location: 'Zurich', name: 'Acme' },
|
|
220
|
+
{ id: 'zora', location: 'Bern', name: 'ZORA' },
|
|
221
|
+
]}
|
|
222
|
+
selectedRowIds={['company-acme']}
|
|
223
|
+
/>,
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const selected = mounted.host.querySelector<HTMLButtonElement>(
|
|
227
|
+
'[aria-label="Select row company-acme"]',
|
|
228
|
+
);
|
|
229
|
+
const unselected = mounted.host.querySelector<HTMLButtonElement>(
|
|
230
|
+
'[aria-label="Select row company-zora"]',
|
|
231
|
+
);
|
|
232
|
+
expect(selected?.getAttribute('aria-checked')).toBe('true');
|
|
233
|
+
expect(unselected?.getAttribute('aria-checked')).toBe('false');
|
|
234
|
+
|
|
235
|
+
unselected?.click();
|
|
236
|
+
expect(changes).toEqual([['company-acme', 'company-zora']]);
|
|
237
|
+
} finally {
|
|
238
|
+
mobilePresentation = false;
|
|
239
|
+
await mounted.unmount();
|
|
240
|
+
mounted.host.remove();
|
|
241
|
+
}
|
|
242
|
+
});
|
|
@@ -16,6 +16,7 @@ import { Button } from '../../../button/public';
|
|
|
16
16
|
import { IconButton } from '../../../button/public';
|
|
17
17
|
import { Card } from '../../../card/public';
|
|
18
18
|
import { EmptyState } from '../../../empty-state/public';
|
|
19
|
+
import { Checkbox } from '../../../form/checkbox/public';
|
|
19
20
|
import { View } from '../../../layout/public';
|
|
20
21
|
import { PopoverMenu, type PopoverMenuAction } from '../../../popover-menu/public';
|
|
21
22
|
import { SkeletonList } from '../../../skeleton/public';
|
|
@@ -23,7 +24,7 @@ import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThem
|
|
|
23
24
|
import { Text, type TextAlign } from '../../../typography/public';
|
|
24
25
|
import { resolveDataTableRowKey } from '../../utils/resolveDataTableRowKey';
|
|
25
26
|
/***
|
|
26
|
-
* Displays structured tabular data with responsive
|
|
27
|
+
* Displays structured tabular data with responsive columns and optional controlled row selection.
|
|
27
28
|
*/
|
|
28
29
|
export const DataTable = withZoraThemeScope(DataTableInner);
|
|
29
30
|
|
|
@@ -55,12 +56,17 @@ function resolveCellStyle<TRow extends object>(column: DataTableColumn<TRow>): V
|
|
|
55
56
|
return {
|
|
56
57
|
alignItems: resolveCellJustify(column.align),
|
|
57
58
|
flexGrow: column.width === undefined ? 1 : 0,
|
|
58
|
-
flexShrink: 0,
|
|
59
|
-
minWidth: column.minWidth
|
|
59
|
+
flexShrink: column.width === undefined && column.minWidth === undefined ? 1 : 0,
|
|
60
|
+
minWidth: column.minWidth,
|
|
60
61
|
width: column.width,
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
/*** Resolves the compact, fixed width reserved for the optional selection control. */
|
|
66
|
+
function resolveSelectionColumnStyle(): ViewStyle {
|
|
67
|
+
return { alignItems: 'center', flexShrink: 0, width: 40 };
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
function resolveRowPadding(density: DataTableDensity) {
|
|
65
71
|
return density === 'compact'
|
|
66
72
|
? { px: 'm' as const, py: 's' as const }
|
|
@@ -139,6 +145,29 @@ function resolveNextSortDirection(
|
|
|
139
145
|
return current === 'asc' ? 'desc' : 'asc';
|
|
140
146
|
}
|
|
141
147
|
|
|
148
|
+
/*** Applies a single row checkbox change to controlled DataTable selection. */
|
|
149
|
+
function resolveNextSelectedRowIds(
|
|
150
|
+
selectedRowIds: readonly string[],
|
|
151
|
+
rowId: string,
|
|
152
|
+
selected: boolean,
|
|
153
|
+
): readonly string[] {
|
|
154
|
+
return selected
|
|
155
|
+
? [...new Set([...selectedRowIds, rowId])]
|
|
156
|
+
: selectedRowIds.filter((selectedRowId) => selectedRowId !== rowId);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/*** Applies the header checkbox change to the currently visible DataTable rows. */
|
|
160
|
+
function resolveNextVisibleSelection(
|
|
161
|
+
selectedRowIds: readonly string[],
|
|
162
|
+
visibleRowIds: readonly string[],
|
|
163
|
+
selected: boolean,
|
|
164
|
+
): readonly string[] {
|
|
165
|
+
const visibleRowIdSet = new Set(visibleRowIds);
|
|
166
|
+
return selected
|
|
167
|
+
? [...new Set([...selectedRowIds, ...visibleRowIds])]
|
|
168
|
+
: selectedRowIds.filter((selectedRowId) => !visibleRowIdSet.has(selectedRowId));
|
|
169
|
+
}
|
|
170
|
+
|
|
142
171
|
/*** Maps row-scoped DataTable actions into the shared PopoverMenu action contract. */
|
|
143
172
|
function mapRowActions<TRow extends object>(
|
|
144
173
|
row: TRow,
|
|
@@ -200,8 +229,16 @@ function DataTableHeader<TRow extends object>({
|
|
|
200
229
|
onSortChange,
|
|
201
230
|
density,
|
|
202
231
|
interactionPolicy,
|
|
232
|
+
selection,
|
|
233
|
+
hasRowActions,
|
|
203
234
|
}: Pick<DataTableProps<TRow>, 'columns' | 'density' | 'onSortChange' | 'sort'> & {
|
|
204
235
|
interactionPolicy?: InteractionPolicy;
|
|
236
|
+
selection?: {
|
|
237
|
+
allVisibleSelected: boolean;
|
|
238
|
+
disabled: boolean;
|
|
239
|
+
onAllVisibleSelectedChange: (selected: boolean) => void;
|
|
240
|
+
};
|
|
241
|
+
hasRowActions: boolean;
|
|
205
242
|
}) {
|
|
206
243
|
const padding = resolveRowPadding(density ?? 'comfortable');
|
|
207
244
|
const passive = interactionPolicy === 'passive';
|
|
@@ -209,6 +246,17 @@ function DataTableHeader<TRow extends object>({
|
|
|
209
246
|
return (
|
|
210
247
|
<View bg="subtle" borderColor="border" borderWidth={1} radius="m">
|
|
211
248
|
<View direction="row" align="center">
|
|
249
|
+
{selection ? (
|
|
250
|
+
<View px={padding.px} py={padding.py} style={resolveSelectionColumnStyle()}>
|
|
251
|
+
<Checkbox
|
|
252
|
+
accessibilityLabel="Select all visible rows"
|
|
253
|
+
checked={selection.allVisibleSelected}
|
|
254
|
+
disabled={selection.disabled}
|
|
255
|
+
interactionPolicy={interactionPolicy}
|
|
256
|
+
onCheckedChange={selection.onAllVisibleSelectedChange}
|
|
257
|
+
/>
|
|
258
|
+
</View>
|
|
259
|
+
) : null}
|
|
212
260
|
{columns.map((column) => {
|
|
213
261
|
const currentDirection = sort?.columnId === column.id ? sort.direction : undefined;
|
|
214
262
|
const sortable = Boolean(column.sortable && onSortChange);
|
|
@@ -248,11 +296,13 @@ function DataTableHeader<TRow extends object>({
|
|
|
248
296
|
</View>
|
|
249
297
|
);
|
|
250
298
|
})}
|
|
251
|
-
|
|
252
|
-
<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
299
|
+
{hasRowActions ? (
|
|
300
|
+
<View px={padding.px} py={padding.py} style={{ minWidth: 56, width: 56 }}>
|
|
301
|
+
<Text align="right" emphasis="muted" variant="caption" weight="semiBold">
|
|
302
|
+
Actions
|
|
303
|
+
</Text>
|
|
304
|
+
</View>
|
|
305
|
+
) : null}
|
|
256
306
|
</View>
|
|
257
307
|
</View>
|
|
258
308
|
);
|
|
@@ -264,6 +314,8 @@ function DataTableDesktop<TRow extends object>({
|
|
|
264
314
|
rowActions,
|
|
265
315
|
rowId,
|
|
266
316
|
rowKey,
|
|
317
|
+
selectedRowIds,
|
|
318
|
+
onSelectedRowIdsChange,
|
|
267
319
|
sort,
|
|
268
320
|
onSortChange,
|
|
269
321
|
density,
|
|
@@ -271,49 +323,96 @@ function DataTableDesktop<TRow extends object>({
|
|
|
271
323
|
interactionPolicy,
|
|
272
324
|
}: DataTableProps<TRow>) {
|
|
273
325
|
const padding = resolveRowPadding(density ?? 'comfortable');
|
|
326
|
+
const rowIds = rows.map((row, rowIndex) => resolveDataTableRowKey(row, rowIndex, rowKey, rowId));
|
|
327
|
+
const controlledSelectedRowIds = selectedRowIds ?? [];
|
|
328
|
+
const selectedRowIdSet = new Set(controlledSelectedRowIds);
|
|
329
|
+
const selectionEnabled = selectedRowIds !== undefined;
|
|
330
|
+
const selectionDisabled = interactionPolicy === 'passive' || onSelectedRowIdsChange === undefined;
|
|
331
|
+
const hasRowActions = rows.some((row, rowIndex) => (rowActions?.(row, rowIndex).length ?? 0) > 0);
|
|
332
|
+
const selection = selectionEnabled
|
|
333
|
+
? {
|
|
334
|
+
allVisibleSelected: rowIds.every((currentRowId) => selectedRowIdSet.has(currentRowId)),
|
|
335
|
+
disabled: selectionDisabled,
|
|
336
|
+
onAllVisibleSelectedChange: (selected: boolean) => {
|
|
337
|
+
if (selectionDisabled) return;
|
|
338
|
+
onSelectedRowIdsChange(
|
|
339
|
+
resolveNextVisibleSelection(controlledSelectedRowIds, rowIds, selected),
|
|
340
|
+
);
|
|
341
|
+
},
|
|
342
|
+
}
|
|
343
|
+
: undefined;
|
|
274
344
|
|
|
275
345
|
return (
|
|
276
346
|
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
|
277
|
-
<View
|
|
347
|
+
<View style={{ width: '100%' }}>
|
|
278
348
|
<View gap="xs">
|
|
279
349
|
<DataTableHeader
|
|
280
350
|
columns={columns}
|
|
281
351
|
density={density}
|
|
352
|
+
hasRowActions={hasRowActions}
|
|
282
353
|
interactionPolicy={interactionPolicy}
|
|
283
354
|
onSortChange={onSortChange}
|
|
355
|
+
selection={selection}
|
|
284
356
|
sort={sort}
|
|
285
357
|
/>
|
|
286
358
|
<View gap="xs">
|
|
287
|
-
{rows.map((row, rowIndex) =>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
style={
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
359
|
+
{rows.map((row, rowIndex) => {
|
|
360
|
+
const currentRowId = resolveDataTableRowKey(row, rowIndex, rowKey, rowId);
|
|
361
|
+
const selected = selectedRowIdSet.has(currentRowId);
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<View
|
|
365
|
+
bg="surface"
|
|
366
|
+
borderColor="border"
|
|
367
|
+
borderWidth={1}
|
|
368
|
+
key={currentRowId}
|
|
369
|
+
radius="m"
|
|
370
|
+
testID={testID ? `${testID}-row-${rowIndex}` : undefined}
|
|
371
|
+
>
|
|
372
|
+
<View direction="row" align="center">
|
|
373
|
+
{selectionEnabled ? (
|
|
374
|
+
<View px={padding.px} py={padding.py} style={resolveSelectionColumnStyle()}>
|
|
375
|
+
<Checkbox
|
|
376
|
+
accessibilityLabel={`Select row ${currentRowId}`}
|
|
377
|
+
checked={selected}
|
|
378
|
+
disabled={selectionDisabled}
|
|
379
|
+
interactionPolicy={interactionPolicy}
|
|
380
|
+
onCheckedChange={(nextSelected) => {
|
|
381
|
+
if (selectionDisabled) return;
|
|
382
|
+
onSelectedRowIdsChange(
|
|
383
|
+
resolveNextSelectedRowIds(
|
|
384
|
+
controlledSelectedRowIds,
|
|
385
|
+
currentRowId,
|
|
386
|
+
nextSelected,
|
|
387
|
+
),
|
|
388
|
+
);
|
|
389
|
+
}}
|
|
390
|
+
/>
|
|
391
|
+
</View>
|
|
392
|
+
) : null}
|
|
393
|
+
{columns.map((column) => (
|
|
394
|
+
<View
|
|
395
|
+
key={column.id}
|
|
396
|
+
px={padding.px}
|
|
397
|
+
py={padding.py}
|
|
398
|
+
style={resolveCellStyle(column)}
|
|
399
|
+
>
|
|
400
|
+
{renderTableCell(column, row, rowIndex)}
|
|
401
|
+
</View>
|
|
402
|
+
))}
|
|
403
|
+
{hasRowActions ? (
|
|
404
|
+
<View
|
|
405
|
+
px={padding.px}
|
|
406
|
+
py={padding.py}
|
|
407
|
+
style={{ alignItems: 'flex-end', minWidth: 56, width: 56 }}
|
|
408
|
+
>
|
|
409
|
+
{renderRowActions({ row, rowActions, rowIndex, testID, interactionPolicy })}
|
|
410
|
+
</View>
|
|
411
|
+
) : null}
|
|
313
412
|
</View>
|
|
314
413
|
</View>
|
|
315
|
-
|
|
316
|
-
)
|
|
414
|
+
);
|
|
415
|
+
})}
|
|
317
416
|
</View>
|
|
318
417
|
</View>
|
|
319
418
|
</View>
|
|
@@ -327,14 +426,21 @@ function DataTableMobile<TRow extends object>({
|
|
|
327
426
|
rowActions,
|
|
328
427
|
rowId,
|
|
329
428
|
rowKey,
|
|
429
|
+
selectedRowIds,
|
|
430
|
+
onSelectedRowIdsChange,
|
|
330
431
|
testID,
|
|
331
432
|
interactionPolicy,
|
|
332
433
|
}: DataTableProps<TRow>) {
|
|
333
434
|
const [primaryColumn, ...detailColumns] = columns;
|
|
435
|
+
const controlledSelectedRowIds = selectedRowIds ?? [];
|
|
436
|
+
const selectedRowIdSet = new Set(controlledSelectedRowIds);
|
|
437
|
+
const selectionEnabled = selectedRowIds !== undefined;
|
|
438
|
+
const selectionDisabled = interactionPolicy === 'passive' || onSelectedRowIdsChange === undefined;
|
|
334
439
|
|
|
335
440
|
return (
|
|
336
441
|
<View gap="s">
|
|
337
442
|
{rows.map((row, rowIndex) => {
|
|
443
|
+
const currentRowId = resolveDataTableRowKey(row, rowIndex, rowKey, rowId);
|
|
338
444
|
const title = primaryColumn
|
|
339
445
|
? renderCell(primaryColumn, row, rowIndex)
|
|
340
446
|
: `Row ${rowIndex + 1}`;
|
|
@@ -345,11 +451,29 @@ function DataTableMobile<TRow extends object>({
|
|
|
345
451
|
actions={actions}
|
|
346
452
|
compact
|
|
347
453
|
interactionPolicy={interactionPolicy}
|
|
348
|
-
key={
|
|
454
|
+
key={currentRowId}
|
|
349
455
|
testID={testID ? `${testID}-card-${rowIndex}` : undefined}
|
|
350
456
|
title={title}
|
|
351
457
|
>
|
|
352
458
|
<View gap="s">
|
|
459
|
+
{selectionEnabled ? (
|
|
460
|
+
<Checkbox
|
|
461
|
+
accessibilityLabel={`Select row ${currentRowId}`}
|
|
462
|
+
checked={selectedRowIdSet.has(currentRowId)}
|
|
463
|
+
disabled={selectionDisabled}
|
|
464
|
+
interactionPolicy={interactionPolicy}
|
|
465
|
+
onCheckedChange={(nextSelected) => {
|
|
466
|
+
if (selectionDisabled) return;
|
|
467
|
+
onSelectedRowIdsChange(
|
|
468
|
+
resolveNextSelectedRowIds(
|
|
469
|
+
controlledSelectedRowIds,
|
|
470
|
+
currentRowId,
|
|
471
|
+
nextSelected,
|
|
472
|
+
),
|
|
473
|
+
);
|
|
474
|
+
}}
|
|
475
|
+
/>
|
|
476
|
+
) : null}
|
|
353
477
|
{detailColumns.map((column) => (
|
|
354
478
|
<View gap="xxs" key={column.id}>
|
|
355
479
|
<Text emphasis="muted" variant="caption" weight="semiBold">
|