@ankhorage/zora 27.5.3 → 27.6.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.
- package/CHANGELOG.md +12 -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/createGraphRuntime.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +19 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.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/createGraphRuntime.test.ts +102 -3
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +25 -0
- 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 +13 -0
- 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
|
@@ -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">
|
|
@@ -2,15 +2,12 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import type { DatePickerProps } from '../../../types/date-picker';
|
|
4
4
|
import { Button } from '../../button/public';
|
|
5
|
+
import { Calendar } from '../../calendar/public';
|
|
5
6
|
import { View } from '../../layout/public';
|
|
6
7
|
import { PickerHeader } from '../../picker/composition/PickerHeader';
|
|
7
|
-
import {
|
|
8
|
-
import { formatLocalDate, parseLocalDate } from '../utils/localDate';
|
|
8
|
+
import { parseLocalDate } from '../utils/localDate';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const DAY_CELL_WIDTH = 42;
|
|
12
|
-
|
|
13
|
-
/*** Renders the shared calendar content used by native BottomSheet and web Popover hosts. */
|
|
10
|
+
/*** Hosts the shared compact Calendar inside the existing DatePicker overlay surfaces. */
|
|
14
11
|
export function DatePickerContent({
|
|
15
12
|
description,
|
|
16
13
|
interactionPolicy,
|
|
@@ -22,30 +19,21 @@ export function DatePickerContent({
|
|
|
22
19
|
testID,
|
|
23
20
|
value,
|
|
24
21
|
}: DatePickerContentProps) {
|
|
25
|
-
const [displayMonth, setDisplayMonth] = React.useState(() => resolveInitialMonth(value, minDate));
|
|
26
|
-
const monthDays = React.useMemo(() => createMonthDays(displayMonth), [displayMonth]);
|
|
27
22
|
const resolvedMaxDate = React.useMemo(() => parseLocalDate(maxDate), [maxDate]);
|
|
28
23
|
const resolvedMinDate = React.useMemo(() => parseLocalDate(minDate), [minDate]);
|
|
24
|
+
const selectedDate = React.useMemo(() => parseLocalDate(value), [value]);
|
|
29
25
|
|
|
30
26
|
return (
|
|
31
27
|
<View gap="m" p="m" testID={testID ? `${testID}-content` : undefined}>
|
|
32
28
|
<PickerHeader description={description} title={label ?? 'Choose date'} />
|
|
33
|
-
<
|
|
34
|
-
|
|
29
|
+
<Calendar
|
|
30
|
+
density="compact"
|
|
35
31
|
interactionPolicy={interactionPolicy}
|
|
36
32
|
maxDate={resolvedMaxDate}
|
|
37
33
|
minDate={resolvedMinDate}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<DatePickerWeekdays />
|
|
41
|
-
<DatePickerCalendar
|
|
42
|
-
interactionPolicy={interactionPolicy}
|
|
43
|
-
maxDate={resolvedMaxDate}
|
|
44
|
-
minDate={resolvedMinDate}
|
|
45
|
-
monthDays={monthDays}
|
|
46
|
-
onSelect={onSelect}
|
|
34
|
+
onSelectedDateChange={onSelect}
|
|
35
|
+
selectedDate={selectedDate ?? null}
|
|
47
36
|
testID={testID}
|
|
48
|
-
value={value}
|
|
49
37
|
/>
|
|
50
38
|
<Button fullWidth interactionPolicy={interactionPolicy} onPress={onDismiss} variant="ghost">
|
|
51
39
|
Cancel
|
|
@@ -61,175 +49,3 @@ interface DatePickerContentProps extends Pick<
|
|
|
61
49
|
onDismiss: () => void;
|
|
62
50
|
onSelect: (value: Date) => void;
|
|
63
51
|
}
|
|
64
|
-
|
|
65
|
-
/*** Renders previous and next month controls for the calendar. */
|
|
66
|
-
function DatePickerMonthNavigation({
|
|
67
|
-
displayMonth,
|
|
68
|
-
interactionPolicy,
|
|
69
|
-
maxDate,
|
|
70
|
-
minDate,
|
|
71
|
-
onMonthChange,
|
|
72
|
-
}: {
|
|
73
|
-
displayMonth: Date;
|
|
74
|
-
interactionPolicy: DatePickerProps['interactionPolicy'];
|
|
75
|
-
maxDate: Date | undefined;
|
|
76
|
-
minDate: Date | undefined;
|
|
77
|
-
onMonthChange: (month: Date) => void;
|
|
78
|
-
}) {
|
|
79
|
-
const previousMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() - 1, 1);
|
|
80
|
-
const nextMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() + 1, 1);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<View align="center" direction="row" justify="space-between">
|
|
84
|
-
<Button
|
|
85
|
-
disabled={!canNavigateToMonth(previousMonth, minDate, maxDate)}
|
|
86
|
-
interactionPolicy={interactionPolicy}
|
|
87
|
-
onPress={() => onMonthChange(previousMonth)}
|
|
88
|
-
size="s"
|
|
89
|
-
variant="ghost"
|
|
90
|
-
>
|
|
91
|
-
Previous
|
|
92
|
-
</Button>
|
|
93
|
-
<Text align="center" variant="label" weight="semiBold">
|
|
94
|
-
{formatMonthLabel(displayMonth)}
|
|
95
|
-
</Text>
|
|
96
|
-
<Button
|
|
97
|
-
disabled={!canNavigateToMonth(nextMonth, minDate, maxDate)}
|
|
98
|
-
interactionPolicy={interactionPolicy}
|
|
99
|
-
onPress={() => onMonthChange(nextMonth)}
|
|
100
|
-
size="s"
|
|
101
|
-
variant="ghost"
|
|
102
|
-
>
|
|
103
|
-
Next
|
|
104
|
-
</Button>
|
|
105
|
-
</View>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/*** Renders weekday headings for the calendar grid. */
|
|
110
|
-
function DatePickerWeekdays() {
|
|
111
|
-
return (
|
|
112
|
-
<View direction="row" justify="space-between">
|
|
113
|
-
{WEEKDAY_LABELS.map((weekday) => (
|
|
114
|
-
<View key={weekday} width={DAY_CELL_WIDTH}>
|
|
115
|
-
<Text align="center" emphasis="muted" variant="caption" weight="semiBold">
|
|
116
|
-
{weekday}
|
|
117
|
-
</Text>
|
|
118
|
-
</View>
|
|
119
|
-
))}
|
|
120
|
-
</View>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/*** Renders selectable day cells for the current calendar month. */
|
|
125
|
-
function DatePickerCalendar({
|
|
126
|
-
interactionPolicy,
|
|
127
|
-
maxDate,
|
|
128
|
-
minDate,
|
|
129
|
-
monthDays,
|
|
130
|
-
onSelect,
|
|
131
|
-
testID,
|
|
132
|
-
value,
|
|
133
|
-
}: {
|
|
134
|
-
interactionPolicy: DatePickerProps['interactionPolicy'];
|
|
135
|
-
maxDate: Date | undefined;
|
|
136
|
-
minDate: Date | undefined;
|
|
137
|
-
monthDays: readonly (Date | null)[];
|
|
138
|
-
onSelect: (value: Date) => void;
|
|
139
|
-
testID: string | undefined;
|
|
140
|
-
value: DatePickerProps['value'];
|
|
141
|
-
}) {
|
|
142
|
-
return (
|
|
143
|
-
<View direction="row" gap="xs" wrap="wrap">
|
|
144
|
-
{monthDays.map((day, index) => {
|
|
145
|
-
if (!day) return <View key={`empty-${index}`} width={DAY_CELL_WIDTH} />;
|
|
146
|
-
const selected = isSameLocalDay(value, day);
|
|
147
|
-
return (
|
|
148
|
-
<View key={day.toISOString()} width={DAY_CELL_WIDTH}>
|
|
149
|
-
<Button
|
|
150
|
-
color={selected ? 'primary' : 'neutral'}
|
|
151
|
-
disabled={isDateDisabled(day, minDate, maxDate)}
|
|
152
|
-
interactionPolicy={interactionPolicy}
|
|
153
|
-
onPress={() => onSelect(day)}
|
|
154
|
-
size="s"
|
|
155
|
-
testID={testID ? `${testID}-day-${day.getDate()}` : undefined}
|
|
156
|
-
variant={selected ? 'solid' : 'ghost'}
|
|
157
|
-
>
|
|
158
|
-
{day.getDate()}
|
|
159
|
-
</Button>
|
|
160
|
-
</View>
|
|
161
|
-
);
|
|
162
|
-
})}
|
|
163
|
-
</View>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/*** Compares a serialized date to one local calendar day. */
|
|
168
|
-
function isSameLocalDay(left: string | null, right: Date): boolean {
|
|
169
|
-
return left === formatLocalDate(right);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/*** Normalizes a Date to the start of its local calendar day. */
|
|
173
|
-
function startOfLocalDay(value: Date): Date {
|
|
174
|
-
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/*** Reports whether one local calendar day precedes another. */
|
|
178
|
-
function isBeforeLocalDay(left: Date, right: Date): boolean {
|
|
179
|
-
return startOfLocalDay(left).getTime() < startOfLocalDay(right).getTime();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/*** Reports whether one local calendar day follows another. */
|
|
183
|
-
function isAfterLocalDay(left: Date, right: Date): boolean {
|
|
184
|
-
return startOfLocalDay(left).getTime() > startOfLocalDay(right).getTime();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/*** Reports whether a date falls outside the configured picker range. */
|
|
188
|
-
function isDateDisabled(
|
|
189
|
-
value: Date,
|
|
190
|
-
minDate: Date | undefined,
|
|
191
|
-
maxDate: Date | undefined,
|
|
192
|
-
): boolean {
|
|
193
|
-
if (minDate && isBeforeLocalDay(value, minDate)) return true;
|
|
194
|
-
if (maxDate && isAfterLocalDay(value, maxDate)) return true;
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/*** Formats the current calendar month for the picker heading. */
|
|
199
|
-
function formatMonthLabel(value: Date): string {
|
|
200
|
-
return value.toLocaleDateString(undefined, { month: 'long', year: 'numeric' });
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/*** Builds the padded calendar grid for one month. */
|
|
204
|
-
function createMonthDays(month: Date): (Date | null)[] {
|
|
205
|
-
const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);
|
|
206
|
-
const dayCount = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();
|
|
207
|
-
const populatedLength = firstDay.getDay() + dayCount;
|
|
208
|
-
const paddedLength = Math.ceil(populatedLength / 7) * 7;
|
|
209
|
-
|
|
210
|
-
return Array.from({ length: paddedLength }, (_, index) =>
|
|
211
|
-
index < firstDay.getDay()
|
|
212
|
-
? null
|
|
213
|
-
: new Date(month.getFullYear(), month.getMonth(), index - firstDay.getDay() + 1),
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/*** Resolves the month initially shown by the calendar. */
|
|
218
|
-
function resolveInitialMonth(value: string | null, minDate: string | undefined): Date {
|
|
219
|
-
const base = parseLocalDate(value) ?? parseLocalDate(minDate) ?? new Date();
|
|
220
|
-
return new Date(base.getFullYear(), base.getMonth(), 1);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/*** Reports whether the configured range intersects a candidate month. */
|
|
224
|
-
function canNavigateToMonth(
|
|
225
|
-
month: Date,
|
|
226
|
-
minDate: Date | undefined,
|
|
227
|
-
maxDate: Date | undefined,
|
|
228
|
-
): boolean {
|
|
229
|
-
const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);
|
|
230
|
-
const lastDay = new Date(month.getFullYear(), month.getMonth() + 1, 0);
|
|
231
|
-
|
|
232
|
-
if (maxDate && isAfterLocalDay(firstDay, maxDate)) return false;
|
|
233
|
-
if (minDate && isBeforeLocalDay(lastDay, minDate)) return false;
|
|
234
|
-
return true;
|
|
235
|
-
}
|
|
@@ -19,5 +19,6 @@ test('DatePicker keeps one manifest contract across native and web presentation
|
|
|
19
19
|
expect(nativeSource).toContain('useBottomSheet()');
|
|
20
20
|
expect(webSource).toContain('<Popover');
|
|
21
21
|
expect(webSource).not.toContain('useBottomSheet');
|
|
22
|
-
expect(contentSource).toContain('
|
|
22
|
+
expect(contentSource).toContain('<Calendar');
|
|
23
|
+
expect(contentSource).toContain('density="compact"');
|
|
23
24
|
});
|
|
@@ -111,8 +111,18 @@ test('fits changed topology but preserves viewport and avoids relayout for highl
|
|
|
111
111
|
|
|
112
112
|
test('preserves a stable topology removal without relayout, fit, or retained-node movement', async () => {
|
|
113
113
|
const ready = Promise.withResolvers<GraphViewController>();
|
|
114
|
-
const calls = { sort: 0 };
|
|
115
|
-
const runtime = createGraphRuntime(undefined, {
|
|
114
|
+
const calls = { complete: 0, ready: 0, sort: 0 };
|
|
115
|
+
const runtime = createGraphRuntime(undefined, {
|
|
116
|
+
current: {
|
|
117
|
+
onLayoutComplete: () => {
|
|
118
|
+
calls.complete += 1;
|
|
119
|
+
},
|
|
120
|
+
onReady: (controller) => {
|
|
121
|
+
calls.ready += 1;
|
|
122
|
+
ready.resolve(controller);
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
});
|
|
116
126
|
const nodes = Array.from({ length: 87 }, (_, index) => ({ id: `repository-${index}` }));
|
|
117
127
|
const input = {
|
|
118
128
|
nodes,
|
|
@@ -127,7 +137,7 @@ test('preserves a stable topology removal without relayout, fit, or retained-nod
|
|
|
127
137
|
return 0;
|
|
128
138
|
},
|
|
129
139
|
},
|
|
130
|
-
richNodeRendering:
|
|
140
|
+
richNodeRendering: true,
|
|
131
141
|
topologyUpdatePolicy: 'preserve-positions' as const,
|
|
132
142
|
};
|
|
133
143
|
try {
|
|
@@ -146,15 +156,104 @@ test('preserves a stable topology removal without relayout, fit, or retained-nod
|
|
|
146
156
|
nodes: nodes.slice(0, -1),
|
|
147
157
|
edges: input.edges.slice(0, -1),
|
|
148
158
|
});
|
|
159
|
+
runtime.setNodeSize('repository-0', { height: 24, width: 48 });
|
|
160
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
149
161
|
|
|
150
162
|
expect(controller.measureNodes?.(retainedIds)).toEqual(before);
|
|
151
163
|
expect(controller.getViewport()).toEqual(viewport);
|
|
164
|
+
expect(calls.ready).toBe(1);
|
|
165
|
+
expect(calls.complete).toBe(1);
|
|
152
166
|
expect(calls.sort).toBe(sortCount);
|
|
153
167
|
} finally {
|
|
154
168
|
runtime.destroy();
|
|
155
169
|
}
|
|
156
170
|
});
|
|
157
171
|
|
|
172
|
+
test('lays out a late initial rich-node measurement without a topology change', async () => {
|
|
173
|
+
const ready = Promise.withResolvers<GraphViewController>();
|
|
174
|
+
const completed = Promise.withResolvers<void>();
|
|
175
|
+
const calls = { sort: 0 };
|
|
176
|
+
const callbacks: { current: GraphViewCallbacks } = { current: { onReady: ready.resolve } };
|
|
177
|
+
const runtime = createGraphRuntime(undefined, callbacks);
|
|
178
|
+
const input = {
|
|
179
|
+
nodes: [{ id: 'a' }, { id: 'b' }],
|
|
180
|
+
edges: [{ source: 'a', target: 'b' }],
|
|
181
|
+
layout: 'grid' as const,
|
|
182
|
+
layoutOptions: {
|
|
183
|
+
sort: () => {
|
|
184
|
+
calls.sort += 1;
|
|
185
|
+
return 0;
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
richNodeRendering: true,
|
|
189
|
+
topologyUpdatePolicy: 'preserve-positions' as const,
|
|
190
|
+
};
|
|
191
|
+
try {
|
|
192
|
+
runtime.update(input);
|
|
193
|
+
await ready.promise;
|
|
194
|
+
const sortCount = calls.sort;
|
|
195
|
+
callbacks.current = { onLayoutComplete: () => completed.resolve() };
|
|
196
|
+
|
|
197
|
+
runtime.setNodeSize('a', { height: 24, width: 48 });
|
|
198
|
+
await completed.promise;
|
|
199
|
+
|
|
200
|
+
expect(calls.sort).toBeGreaterThan(sortCount);
|
|
201
|
+
} finally {
|
|
202
|
+
runtime.destroy();
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('keeps explicit fit and layout available after preserving a rich-node topology removal', async () => {
|
|
207
|
+
const ready = Promise.withResolvers<GraphViewController>();
|
|
208
|
+
const completed = Promise.withResolvers<void>();
|
|
209
|
+
const calls = { sort: 0 };
|
|
210
|
+
const callbacks: { current: GraphViewCallbacks } = { current: { onReady: ready.resolve } };
|
|
211
|
+
const runtime = createGraphRuntime(undefined, callbacks);
|
|
212
|
+
const nodes = Array.from({ length: 87 }, (_, index) => ({ id: `repository-${index}` }));
|
|
213
|
+
const input = {
|
|
214
|
+
nodes,
|
|
215
|
+
edges: nodes.slice(1).flatMap((node, index) => {
|
|
216
|
+
const source = nodes.at(index);
|
|
217
|
+
return source ? [{ id: `dependency-${index}`, source: source.id, target: node.id }] : [];
|
|
218
|
+
}),
|
|
219
|
+
layout: 'grid' as const,
|
|
220
|
+
layoutOptions: {
|
|
221
|
+
sort: () => {
|
|
222
|
+
calls.sort += 1;
|
|
223
|
+
return 0;
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
richNodeRendering: true,
|
|
227
|
+
topologyUpdatePolicy: 'preserve-positions' as const,
|
|
228
|
+
};
|
|
229
|
+
try {
|
|
230
|
+
runtime.update(input);
|
|
231
|
+
const controller = await ready.promise;
|
|
232
|
+
controller.setZoom(0.7);
|
|
233
|
+
controller.setPan({ x: 40, y: 30 });
|
|
234
|
+
const preservedInput = {
|
|
235
|
+
...input,
|
|
236
|
+
nodes: nodes.slice(0, -1),
|
|
237
|
+
edges: input.edges.slice(0, -1),
|
|
238
|
+
};
|
|
239
|
+
runtime.update(preservedInput);
|
|
240
|
+
runtime.setNodeSize('repository-0', { height: 24, width: 48 });
|
|
241
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
242
|
+
const preservedSorts = calls.sort;
|
|
243
|
+
const preservedViewport = controller.getViewport();
|
|
244
|
+
|
|
245
|
+
controller.fit();
|
|
246
|
+
expect(controller.getViewport()).not.toEqual(preservedViewport);
|
|
247
|
+
callbacks.current = { onLayoutComplete: () => completed.resolve() };
|
|
248
|
+
runtime.update({ ...preservedInput, layout: 'circle' });
|
|
249
|
+
await completed.promise;
|
|
250
|
+
|
|
251
|
+
expect(calls.sort).toBeGreaterThan(preservedSorts);
|
|
252
|
+
} finally {
|
|
253
|
+
runtime.destroy();
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
158
257
|
test('fits a changed layout algorithm even when visible topology is unchanged', async () => {
|
|
159
258
|
const initial = Promise.withResolvers<GraphViewController>();
|
|
160
259
|
const completed = Promise.withResolvers<GraphViewController>();
|