@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
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CalendarProps } from '../../../../types/calendar';
|
|
3
|
+
/*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */
|
|
4
|
+
export declare const Calendar: (props: CalendarProps) => React.ReactElement | null;
|
|
5
|
+
//# sourceMappingURL=Calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../../src/features/calendar/adapters/inbound/Calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAYhE,4FAA4F;AAC5F,eAAO,MAAM,QAAQ,qDAAoC,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '../../../button/public';
|
|
3
|
+
import { GridView } from '../../../grid-view/public';
|
|
4
|
+
import { View } from '../../../layout/public';
|
|
5
|
+
import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';
|
|
6
|
+
import { Text } from '../../../typography/public';
|
|
7
|
+
import { createCalendarMonth } from '../../application/createCalendarMonth';
|
|
8
|
+
import { isCalendarDateDisabled } from '../../application/isCalendarDateDisabled';
|
|
9
|
+
const GRID_COLUMNS = 7;
|
|
10
|
+
const GRID_ROWS = 6;
|
|
11
|
+
/*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */
|
|
12
|
+
export const Calendar = withZoraThemeScope(CalendarInner);
|
|
13
|
+
/*** Connects controlled Calendar state to the shared month grid presentation. */
|
|
14
|
+
function CalendarInner({ defaultDisplayedMonth, density = 'regular', disabledDates = [], displayedMonth: controlledDisplayedMonth, interactionPolicy, isDateDisabled, locale, maxDate, minDate, onDisplayedMonthChange, onSelectedDateChange, selectedDate, testID, weekStartsOn = 0, }) {
|
|
15
|
+
const [uncontrolledDisplayedMonth, setUncontrolledDisplayedMonth] = React.useState(() => startOfLocalMonth(defaultDisplayedMonth ?? selectedDate ?? minDate ?? new Date()));
|
|
16
|
+
const displayedMonth = startOfLocalMonth(controlledDisplayedMonth ?? uncontrolledDisplayedMonth);
|
|
17
|
+
const cellSize = density === 'compact' ? 42 : 48;
|
|
18
|
+
const gridWidth = cellSize * GRID_COLUMNS;
|
|
19
|
+
const gridHeight = cellSize * GRID_ROWS;
|
|
20
|
+
const cells = React.useMemo(() => createCalendarMonth(displayedMonth, weekStartsOn), [displayedMonth, weekStartsOn]);
|
|
21
|
+
const gridItems = React.useMemo(() => cells.map((cell, index) => ({
|
|
22
|
+
height: cellSize,
|
|
23
|
+
id: cell.id,
|
|
24
|
+
width: cellSize,
|
|
25
|
+
x: (index % GRID_COLUMNS) * cellSize,
|
|
26
|
+
y: Math.floor(index / GRID_COLUMNS) * cellSize,
|
|
27
|
+
})), [cellSize, cells]);
|
|
28
|
+
const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);
|
|
29
|
+
const disabledDateIds = React.useMemo(() => new Set(disabledDates.map(formatCalendarDate)), [disabledDates]);
|
|
30
|
+
const weekdays = React.useMemo(() => createWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);
|
|
31
|
+
const setDisplayedMonth = React.useCallback((month) => {
|
|
32
|
+
const nextMonth = startOfLocalMonth(month);
|
|
33
|
+
if (controlledDisplayedMonth === undefined)
|
|
34
|
+
setUncontrolledDisplayedMonth(nextMonth);
|
|
35
|
+
onDisplayedMonthChange?.(nextMonth);
|
|
36
|
+
}, [controlledDisplayedMonth, onDisplayedMonthChange]);
|
|
37
|
+
const previousMonth = addMonths(displayedMonth, -1);
|
|
38
|
+
const nextMonth = addMonths(displayedMonth, 1);
|
|
39
|
+
return (<View accessibilityLabel="Calendar" gap={density === 'compact' ? 's' : 'm'} testID={testID}>
|
|
40
|
+
<View align="center" direction="row" justify="space-between">
|
|
41
|
+
<Button disabled={!monthIntersectsRange(previousMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => setDisplayedMonth(previousMonth)} size="s" variant="ghost">
|
|
42
|
+
Previous
|
|
43
|
+
</Button>
|
|
44
|
+
<Text accessibilityRole="header" align="center" variant="label" weight="semiBold">
|
|
45
|
+
{formatMonthLabel(displayedMonth, locale)}
|
|
46
|
+
</Text>
|
|
47
|
+
<Button disabled={!monthIntersectsRange(nextMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => setDisplayedMonth(nextMonth)} size="s" variant="ghost">
|
|
48
|
+
Next
|
|
49
|
+
</Button>
|
|
50
|
+
</View>
|
|
51
|
+
<View direction="row">
|
|
52
|
+
{weekdays.map((weekday) => (<View key={weekday.id} width={cellSize}>
|
|
53
|
+
<Text align="center" emphasis="muted" variant="caption" weight="semiBold">
|
|
54
|
+
{weekday.label}
|
|
55
|
+
</Text>
|
|
56
|
+
</View>))}
|
|
57
|
+
</View>
|
|
58
|
+
<GridView contentHeight={gridHeight} contentWidth={gridWidth} height={gridHeight} interactionPolicy={interactionPolicy} items={gridItems} overscanPixels={0} renderItem={(item) => {
|
|
59
|
+
const cell = cellsById.get(item.id);
|
|
60
|
+
if (!cell)
|
|
61
|
+
return null;
|
|
62
|
+
const selected = selectedDate !== null &&
|
|
63
|
+
selectedDate !== undefined &&
|
|
64
|
+
isSameLocalDay(selectedDate, cell.date);
|
|
65
|
+
const disabled = isCalendarDateDisabled({
|
|
66
|
+
date: cell.date,
|
|
67
|
+
disabledDateIds,
|
|
68
|
+
isDateDisabled,
|
|
69
|
+
maxDate,
|
|
70
|
+
minDate,
|
|
71
|
+
});
|
|
72
|
+
const selectCell = () => {
|
|
73
|
+
if (!cell.inDisplayedMonth)
|
|
74
|
+
setDisplayedMonth(cell.date);
|
|
75
|
+
onSelectedDateChange?.(cell.date);
|
|
76
|
+
};
|
|
77
|
+
return (<Button accessibilityState={{ disabled, selected }} color={selected ? 'primary' : 'neutral'} disabled={disabled} interactionPolicy={interactionPolicy} onPress={selectCell} size="s" testID={testID ? `${testID}-day-${cell.id}` : undefined} variant={selected ? 'solid' : cell.inDisplayedMonth ? 'ghost' : 'outline'}>
|
|
78
|
+
{cell.date.getDate()}
|
|
79
|
+
</Button>);
|
|
80
|
+
}} testID={testID ? `${testID}-grid` : undefined} viewportInteraction="locked" width={gridWidth}/>
|
|
81
|
+
</View>);
|
|
82
|
+
}
|
|
83
|
+
/*** Produces the ordered weekday labels for one local calendar week. */
|
|
84
|
+
function createWeekdayLabels(locale, weekStartsOn) {
|
|
85
|
+
const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' });
|
|
86
|
+
const sunday = new Date(2023, 0, 1);
|
|
87
|
+
return Array.from({ length: GRID_COLUMNS }, (_, index) => {
|
|
88
|
+
const day = new Date(sunday.getFullYear(), sunday.getMonth(), sunday.getDate() + ((weekStartsOn + index) % GRID_COLUMNS));
|
|
89
|
+
return { id: String(index), label: formatter.format(day) };
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/*** Moves a local month without carrying a day-of-month overflow into the target month. */
|
|
93
|
+
function addMonths(month, count) {
|
|
94
|
+
return new Date(month.getFullYear(), month.getMonth() + count, 1);
|
|
95
|
+
}
|
|
96
|
+
/*** Normalizes a value to the first local day of its month. */
|
|
97
|
+
function startOfLocalMonth(value) {
|
|
98
|
+
return new Date(value.getFullYear(), value.getMonth(), 1);
|
|
99
|
+
}
|
|
100
|
+
/*** Formats a Date as a timezone-independent local calendar identifier. */
|
|
101
|
+
function formatCalendarDate(value) {
|
|
102
|
+
const year = String(value.getFullYear()).padStart(4, '0');
|
|
103
|
+
const month = String(value.getMonth() + 1).padStart(2, '0');
|
|
104
|
+
const day = String(value.getDate()).padStart(2, '0');
|
|
105
|
+
return `${year}-${month}-${day}`;
|
|
106
|
+
}
|
|
107
|
+
/*** Compares local calendar dates using their canonical date-only identifiers. */
|
|
108
|
+
function compareLocalDates(left, right) {
|
|
109
|
+
return formatCalendarDate(left).localeCompare(formatCalendarDate(right));
|
|
110
|
+
}
|
|
111
|
+
/*** Reports whether a candidate month contains at least one date inside the configured range. */
|
|
112
|
+
function monthIntersectsRange(month, minDate, maxDate) {
|
|
113
|
+
const first = startOfLocalMonth(month);
|
|
114
|
+
const last = new Date(first.getFullYear(), first.getMonth() + 1, 0);
|
|
115
|
+
return ((!minDate || compareLocalDates(last, minDate) >= 0) &&
|
|
116
|
+
(!maxDate || compareLocalDates(first, maxDate) <= 0));
|
|
117
|
+
}
|
|
118
|
+
/*** Reports whether two values identify the same local calendar day. */
|
|
119
|
+
function isSameLocalDay(left, right) {
|
|
120
|
+
return formatCalendarDate(left) === formatCalendarDate(right);
|
|
121
|
+
}
|
|
122
|
+
/*** Formats a display month with the caller's locale. */
|
|
123
|
+
function formatMonthLabel(value, locale) {
|
|
124
|
+
return new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(value);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=Calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../../../../src/features/calendar/adapters/inbound/Calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAE1D,iFAAiF;AACjF,SAAS,aAAa,CAAC,EACrB,qBAAqB,EACrB,OAAO,GAAG,SAAS,EACnB,aAAa,GAAG,EAAE,EAClB,cAAc,EAAE,wBAAwB,EACxC,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,OAAO,EACP,OAAO,EACP,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,MAAM,EACN,YAAY,GAAG,CAAC,GACF;IACd,MAAM,CAAC,0BAA0B,EAAE,6BAA6B,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CACtF,iBAAiB,CAAC,qBAAqB,IAAI,YAAY,IAAI,OAAO,IAAI,IAAI,IAAI,EAAE,CAAC,CAClF,CAAC;IACF,MAAM,cAAc,GAAG,iBAAiB,CAAC,wBAAwB,IAAI,0BAA0B,CAAC,CAAC;IACjG,MAAM,QAAQ,GAAG,OAAO,KAAK,SAAS,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AO,kBAAkB,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,yDAAyD;AACzD,SAAS,gBAAgB,CAAC,KAAW,EAAE,MAA0B;IAC/D,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import type { GridRectItem } from '@ankhorage/grid-view';\nimport React from 'react';\n\nimport type { CalendarProps } from '../../../../types/calendar';\nimport { Button } from '../../../button/public';\nimport { GridView } from '../../../grid-view/public';\nimport { View } from '../../../layout/public';\nimport { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';\nimport { Text } from '../../../typography/public';\nimport { createCalendarMonth } from '../../application/createCalendarMonth';\nimport { isCalendarDateDisabled } from '../../application/isCalendarDateDisabled';\n\nconst GRID_COLUMNS = 7;\nconst GRID_ROWS = 6;\n\n/*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */\nexport const Calendar = withZoraThemeScope(CalendarInner);\n\n/*** Connects controlled Calendar state to the shared month grid presentation. */\nfunction CalendarInner({\n defaultDisplayedMonth,\n density = 'regular',\n disabledDates = [],\n displayedMonth: controlledDisplayedMonth,\n interactionPolicy,\n isDateDisabled,\n locale,\n maxDate,\n minDate,\n onDisplayedMonthChange,\n onSelectedDateChange,\n selectedDate,\n testID,\n weekStartsOn = 0,\n}: CalendarProps) {\n const [uncontrolledDisplayedMonth, setUncontrolledDisplayedMonth] = React.useState(() =>\n startOfLocalMonth(defaultDisplayedMonth ?? selectedDate ?? minDate ?? new Date()),\n );\n const displayedMonth = startOfLocalMonth(controlledDisplayedMonth ?? uncontrolledDisplayedMonth);\n const cellSize = density === 'compact' ? 42 : 48;\n const gridWidth = cellSize * GRID_COLUMNS;\n const gridHeight = cellSize * GRID_ROWS;\n const cells = React.useMemo(\n () => createCalendarMonth(displayedMonth, weekStartsOn),\n [displayedMonth, weekStartsOn],\n );\n const gridItems = React.useMemo<readonly GridRectItem[]>(\n () =>\n cells.map((cell, index) => ({\n height: cellSize,\n id: cell.id,\n width: cellSize,\n x: (index % GRID_COLUMNS) * cellSize,\n y: Math.floor(index / GRID_COLUMNS) * cellSize,\n })),\n [cellSize, cells],\n );\n const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);\n const disabledDateIds = React.useMemo(\n () => new Set(disabledDates.map(formatCalendarDate)),\n [disabledDates],\n );\n const weekdays = React.useMemo(\n () => createWeekdayLabels(locale, weekStartsOn),\n [locale, weekStartsOn],\n );\n const setDisplayedMonth = React.useCallback(\n (month: Date) => {\n const nextMonth = startOfLocalMonth(month);\n if (controlledDisplayedMonth === undefined) setUncontrolledDisplayedMonth(nextMonth);\n onDisplayedMonthChange?.(nextMonth);\n },\n [controlledDisplayedMonth, onDisplayedMonthChange],\n );\n const previousMonth = addMonths(displayedMonth, -1);\n const nextMonth = addMonths(displayedMonth, 1);\n\n return (\n <View accessibilityLabel=\"Calendar\" gap={density === 'compact' ? 's' : 'm'} testID={testID}>\n <View align=\"center\" direction=\"row\" justify=\"space-between\">\n <Button\n disabled={!monthIntersectsRange(previousMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => setDisplayedMonth(previousMonth)}\n size=\"s\"\n variant=\"ghost\"\n >\n Previous\n </Button>\n <Text accessibilityRole=\"header\" align=\"center\" variant=\"label\" weight=\"semiBold\">\n {formatMonthLabel(displayedMonth, locale)}\n </Text>\n <Button\n disabled={!monthIntersectsRange(nextMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => setDisplayedMonth(nextMonth)}\n size=\"s\"\n variant=\"ghost\"\n >\n Next\n </Button>\n </View>\n <View direction=\"row\">\n {weekdays.map((weekday) => (\n <View key={weekday.id} width={cellSize}>\n <Text align=\"center\" emphasis=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {weekday.label}\n </Text>\n </View>\n ))}\n </View>\n <GridView\n contentHeight={gridHeight}\n contentWidth={gridWidth}\n height={gridHeight}\n interactionPolicy={interactionPolicy}\n items={gridItems}\n overscanPixels={0}\n renderItem={(item) => {\n const cell = cellsById.get(item.id);\n if (!cell) return null;\n const selected =\n selectedDate !== null &&\n selectedDate !== undefined &&\n isSameLocalDay(selectedDate, cell.date);\n const disabled = isCalendarDateDisabled({\n date: cell.date,\n disabledDateIds,\n isDateDisabled,\n maxDate,\n minDate,\n });\n const selectCell = () => {\n if (!cell.inDisplayedMonth) setDisplayedMonth(cell.date);\n onSelectedDateChange?.(cell.date);\n };\n return (\n <Button\n accessibilityState={{ disabled, selected }}\n color={selected ? 'primary' : 'neutral'}\n disabled={disabled}\n interactionPolicy={interactionPolicy}\n onPress={selectCell}\n size=\"s\"\n testID={testID ? `${testID}-day-${cell.id}` : undefined}\n variant={selected ? 'solid' : cell.inDisplayedMonth ? 'ghost' : 'outline'}\n >\n {cell.date.getDate()}\n </Button>\n );\n }}\n testID={testID ? `${testID}-grid` : undefined}\n viewportInteraction=\"locked\"\n width={gridWidth}\n />\n </View>\n );\n}\n\n/*** Produces the ordered weekday labels for one local calendar week. */\nfunction createWeekdayLabels(locale: string | undefined, weekStartsOn: number) {\n const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' });\n const sunday = new Date(2023, 0, 1);\n return Array.from({ length: GRID_COLUMNS }, (_, index) => {\n const day = new Date(\n sunday.getFullYear(),\n sunday.getMonth(),\n sunday.getDate() + ((weekStartsOn + index) % GRID_COLUMNS),\n );\n return { id: String(index), label: formatter.format(day) };\n });\n}\n\n/*** Moves a local month without carrying a day-of-month overflow into the target month. */\nfunction addMonths(month: Date, count: number): Date {\n return new Date(month.getFullYear(), month.getMonth() + count, 1);\n}\n\n/*** Normalizes a value to the first local day of its month. */\nfunction startOfLocalMonth(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), 1);\n}\n\n/*** Formats a Date as a timezone-independent local calendar identifier. */\nfunction formatCalendarDate(value: Date): string {\n const year = String(value.getFullYear()).padStart(4, '0');\n const month = String(value.getMonth() + 1).padStart(2, '0');\n const day = String(value.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/*** Compares local calendar dates using their canonical date-only identifiers. */\nfunction compareLocalDates(left: Date, right: Date): number {\n return formatCalendarDate(left).localeCompare(formatCalendarDate(right));\n}\n\n/*** Reports whether a candidate month contains at least one date inside the configured range. */\nfunction monthIntersectsRange(\n month: Date,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): boolean {\n const first = startOfLocalMonth(month);\n const last = new Date(first.getFullYear(), first.getMonth() + 1, 0);\n return (\n (!minDate || compareLocalDates(last, minDate) >= 0) &&\n (!maxDate || compareLocalDates(first, maxDate) <= 0)\n );\n}\n\n/*** Reports whether two values identify the same local calendar day. */\nfunction isSameLocalDay(left: Date, right: Date): boolean {\n return formatCalendarDate(left) === formatCalendarDate(right);\n}\n\n/*** Formats a display month with the caller's locale. */\nfunction formatMonthLabel(value: Date, locale: string | undefined): string {\n return new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(value);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CalendarWeekStart } from '../../../types/calendar';
|
|
2
|
+
export type CalendarMonthCell = Readonly<{
|
|
3
|
+
date: Date;
|
|
4
|
+
id: string;
|
|
5
|
+
inDisplayedMonth: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
/*** Creates the fixed six-week local-date month geometry shared by every Calendar density. */
|
|
8
|
+
export declare function createCalendarMonth(month: Date, weekStartsOn: CalendarWeekStart): readonly CalendarMonthCell[];
|
|
9
|
+
//# sourceMappingURL=createCalendarMonth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCalendarMonth.d.ts","sourceRoot":"","sources":["../../../../src/features/calendar/application/createCalendarMonth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC,CAAC;AAEH,8FAA8F;AAC9F,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,EACX,YAAY,EAAE,iBAAiB,GAC9B,SAAS,iBAAiB,EAAE,CAY9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*** Creates the fixed six-week local-date month geometry shared by every Calendar density. */
|
|
2
|
+
export function createCalendarMonth(month, weekStartsOn) {
|
|
3
|
+
const firstDay = startOfLocalMonth(month);
|
|
4
|
+
const leadingDays = (firstDay.getDay() - weekStartsOn + 7) % 7;
|
|
5
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
6
|
+
const date = new Date(firstDay.getFullYear(), firstDay.getMonth(), index - leadingDays + 1);
|
|
7
|
+
return {
|
|
8
|
+
date,
|
|
9
|
+
id: formatLocalDate(date),
|
|
10
|
+
inDisplayedMonth: date.getMonth() === firstDay.getMonth(),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/*** Formats a Date as a timezone-independent local calendar identifier. */
|
|
15
|
+
function formatLocalDate(value) {
|
|
16
|
+
const year = String(value.getFullYear()).padStart(4, '0');
|
|
17
|
+
const month = String(value.getMonth() + 1).padStart(2, '0');
|
|
18
|
+
const day = String(value.getDate()).padStart(2, '0');
|
|
19
|
+
return `${year}-${month}-${day}`;
|
|
20
|
+
}
|
|
21
|
+
/*** Normalizes a value to the first local day of its month. */
|
|
22
|
+
function startOfLocalMonth(value) {
|
|
23
|
+
return new Date(value.getFullYear(), value.getMonth(), 1);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=createCalendarMonth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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C,CAAC;AAED,+DAA+D;AAC/D,SAAS,iBAAiB,CAAC,KAAW;IACpC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import type { CalendarWeekStart } from '../../../types/calendar';\n\nexport type CalendarMonthCell = Readonly<{\n date: Date;\n id: string;\n inDisplayedMonth: boolean;\n}>;\n\n/*** Creates the fixed six-week local-date month geometry shared by every Calendar density. */\nexport function createCalendarMonth(\n month: Date,\n weekStartsOn: CalendarWeekStart,\n): readonly CalendarMonthCell[] {\n const firstDay = startOfLocalMonth(month);\n const leadingDays = (firstDay.getDay() - weekStartsOn + 7) % 7;\n\n return Array.from({ length: 42 }, (_, index) => {\n const date = new Date(firstDay.getFullYear(), firstDay.getMonth(), index - leadingDays + 1);\n return {\n date,\n id: formatLocalDate(date),\n inDisplayedMonth: date.getMonth() === firstDay.getMonth(),\n };\n });\n}\n\n/*** Formats a Date as a timezone-independent local calendar identifier. */\nfunction formatLocalDate(value: Date): string {\n const year = String(value.getFullYear()).padStart(4, '0');\n const month = String(value.getMonth() + 1).padStart(2, '0');\n const day = String(value.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/*** Normalizes a value to the first local day of its month. */\nfunction startOfLocalMonth(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), 1);\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CalendarProps } from '../../../types/calendar';
|
|
2
|
+
/*** Resolves whether local-date range and disabled-date policy prevent selecting a calendar day. */
|
|
3
|
+
export declare function isCalendarDateDisabled({ date, disabledDateIds, isDateDisabled, maxDate, minDate, }: {
|
|
4
|
+
date: Date;
|
|
5
|
+
disabledDateIds: ReadonlySet<string>;
|
|
6
|
+
isDateDisabled: CalendarProps['isDateDisabled'];
|
|
7
|
+
maxDate: Date | undefined;
|
|
8
|
+
minDate: Date | undefined;
|
|
9
|
+
}): boolean;
|
|
10
|
+
//# sourceMappingURL=isCalendarDateDisabled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCalendarDateDisabled.d.ts","sourceRoot":"","sources":["../../../../src/features/calendar/application/isCalendarDateDisabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,oGAAoG;AACpG,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,eAAe,EACf,cAAc,EACd,OAAO,EACP,OAAO,GACR,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAChD,OAAO,EAAE,IAAI,GAAG,SAAS,CAAC;IAC1B,OAAO,EAAE,IAAI,GAAG,SAAS,CAAC;CAC3B,GAAG,OAAO,CAOV"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*** Resolves whether local-date range and disabled-date policy prevent selecting a calendar day. */
|
|
2
|
+
export function isCalendarDateDisabled({ date, disabledDateIds, isDateDisabled, maxDate, minDate, }) {
|
|
3
|
+
return ((minDate !== undefined && compareLocalDates(date, minDate) < 0) ||
|
|
4
|
+
(maxDate !== undefined && compareLocalDates(date, maxDate) > 0) ||
|
|
5
|
+
disabledDateIds.has(formatCalendarDate(date)) ||
|
|
6
|
+
isDateDisabled?.(date) === true);
|
|
7
|
+
}
|
|
8
|
+
/*** Compares values by local calendar date rather than their instant or time of day. */
|
|
9
|
+
function compareLocalDates(left, right) {
|
|
10
|
+
return startOfLocalDay(left).getTime() - startOfLocalDay(right).getTime();
|
|
11
|
+
}
|
|
12
|
+
/*** Removes a time-of-day component while retaining the caller's local calendar date. */
|
|
13
|
+
function startOfLocalDay(value) {
|
|
14
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
15
|
+
}
|
|
16
|
+
/*** Formats a Date as a timezone-independent local calendar identifier. */
|
|
17
|
+
function formatCalendarDate(value) {
|
|
18
|
+
const year = String(value.getFullYear()).padStart(4, '0');
|
|
19
|
+
const month = String(value.getMonth() + 1).padStart(2, '0');
|
|
20
|
+
const day = String(value.getDate()).padStart(2, '0');
|
|
21
|
+
return `${year}-${month}-${day}`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=isCalendarDateDisabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCalendarDateDisabled.js","sourceRoot":"","sources":["../../../../src/features/calendar/application/isCalendarDateDisabled.ts"],"names":[],"mappings":"AAEA,oGAAoG;AACpG,MAAM,UAAU,sBAAsB,CAAC,EACrC,IAAI,EACJ,eAAe,EACf,cAAc,EACd,OAAO,EACP,OAAO,GAOR;IACC,OAAO,CACL,CAAC,OAAO,KAAK,SAAS,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/D,CAAC,OAAO,KAAK,SAAS,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/D,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC7C,cAAc,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,CAChC,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,SAAS,iBAAiB,CAAC,IAAU,EAAE,KAAW;IAChD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5E,CAAC;AAED,yFAAyF;AACzF,SAAS,eAAe,CAAC,KAAW;IAClC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,2EAA2E;AAC3E,SAAS,kBAAkB,CAAC,KAAW;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { CalendarProps } from '../../../types/calendar';\n\n/*** Resolves whether local-date range and disabled-date policy prevent selecting a calendar day. */\nexport function isCalendarDateDisabled({\n date,\n disabledDateIds,\n isDateDisabled,\n maxDate,\n minDate,\n}: {\n date: Date;\n disabledDateIds: ReadonlySet<string>;\n isDateDisabled: CalendarProps['isDateDisabled'];\n maxDate: Date | undefined;\n minDate: Date | undefined;\n}): boolean {\n return (\n (minDate !== undefined && compareLocalDates(date, minDate) < 0) ||\n (maxDate !== undefined && compareLocalDates(date, maxDate) > 0) ||\n disabledDateIds.has(formatCalendarDate(date)) ||\n isDateDisabled?.(date) === true\n );\n}\n\n/*** Compares values by local calendar date rather than their instant or time of day. */\nfunction compareLocalDates(left: Date, right: Date): number {\n return startOfLocalDay(left).getTime() - startOfLocalDay(right).getTime();\n}\n\n/*** Removes a time-of-day component while retaining the caller's local calendar date. */\nfunction startOfLocalDay(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), value.getDate());\n}\n\n/*** Formats a Date as a timezone-independent local calendar identifier. */\nfunction formatCalendarDate(value: Date): string {\n const year = String(value.getFullYear()).padStart(4, '0');\n const month = String(value.getMonth() + 1).padStart(2, '0');\n const day = String(value.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const calendarMeta: {
|
|
2
|
+
readonly name: "Calendar";
|
|
3
|
+
readonly category: "component";
|
|
4
|
+
readonly description: "Reusable local-date calendar with a month view backed by GridView geometry.";
|
|
5
|
+
readonly directManifestNode: false;
|
|
6
|
+
readonly note: "Uses Date values and executable change callbacks; available through the public code API.";
|
|
7
|
+
readonly allowedChildren: readonly [];
|
|
8
|
+
readonly props: {};
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=calendarMeta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendarMeta.d.ts","sourceRoot":"","sources":["../../../src/features/calendar/calendarMeta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;CAQa,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const calendarMeta = {
|
|
2
|
+
name: 'Calendar',
|
|
3
|
+
category: 'component',
|
|
4
|
+
description: 'Reusable local-date calendar with a month view backed by GridView geometry.',
|
|
5
|
+
directManifestNode: false,
|
|
6
|
+
note: 'Uses Date values and executable change callbacks; available through the public code API.',
|
|
7
|
+
allowedChildren: [],
|
|
8
|
+
props: {},
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=calendarMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendarMeta.js","sourceRoot":"","sources":["../../../src/features/calendar/calendarMeta.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,WAAW;IACrB,WAAW,EAAE,6EAA6E;IAC1F,kBAAkB,EAAE,KAAK;IACzB,IAAI,EAAE,0FAA0F;IAChG,eAAe,EAAE,EAAE;IACnB,KAAK,EAAE,EAAE;CAC2B,CAAC","sourcesContent":["import type { ZoraComponentMeta } from '../../types/authoring';\n\nexport const calendarMeta = {\n name: 'Calendar',\n category: 'component',\n description: 'Reusable local-date calendar with a month view backed by GridView geometry.',\n directManifestNode: false,\n note: 'Uses Date values and executable change callbacks; available through the public code API.',\n allowedChildren: [],\n props: {},\n} as const satisfies ZoraComponentMeta;\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export type { CalendarDensity, CalendarProps, CalendarView, CalendarWeekStart, } from '../../types/calendar';
|
|
1
2
|
export type { TemporalAllDayEvent, TemporalAllDayRange, TemporalAvailability, TemporalDataValue, TemporalDate, TemporalDuration, TemporalEvent, TemporalEventStatus, TemporalInstant, TemporalInteroperabilityData, TemporalParticipant, TemporalRange, TemporalRecurrence, TemporalRecurrenceException, TemporalRecurrenceRule, TemporalReminder, TemporalTimedEvent, TemporalTimedRange, TemporalTimeZone, TemporalTone, } from '../../types/temporal';
|
|
3
|
+
export { Calendar } from './adapters/inbound/Calendar';
|
|
2
4
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/features/calendar/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/features/calendar/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { Calendar } from './adapters/inbound/Calendar';
|
|
2
2
|
//# sourceMappingURL=public.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/features/calendar/public.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n TemporalAllDayEvent,\n TemporalAllDayRange,\n TemporalAvailability,\n TemporalDataValue,\n TemporalDate,\n TemporalDuration,\n TemporalEvent,\n TemporalEventStatus,\n TemporalInstant,\n TemporalInteroperabilityData,\n TemporalParticipant,\n TemporalRange,\n TemporalRecurrence,\n TemporalRecurrenceException,\n TemporalRecurrenceRule,\n TemporalReminder,\n TemporalTimedEvent,\n TemporalTimedRange,\n TemporalTimeZone,\n TemporalTone,\n} from '../../types/temporal';\n"]}
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/features/calendar/public.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export type {\n CalendarDensity,\n CalendarProps,\n CalendarView,\n CalendarWeekStart,\n} from '../../types/calendar';\nexport type {\n TemporalAllDayEvent,\n TemporalAllDayRange,\n TemporalAvailability,\n TemporalDataValue,\n TemporalDate,\n TemporalDuration,\n TemporalEvent,\n TemporalEventStatus,\n TemporalInstant,\n TemporalInteroperabilityData,\n TemporalParticipant,\n TemporalRange,\n TemporalRecurrence,\n TemporalRecurrenceException,\n TemporalRecurrenceRule,\n TemporalReminder,\n TemporalTimedEvent,\n TemporalTimedRange,\n TemporalTimeZone,\n TemporalTone,\n} from '../../types/temporal';\nexport { Calendar } from './adapters/inbound/Calendar';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DataTableProps } from '../../../../types/data-table';
|
|
3
3
|
/***
|
|
4
|
-
* Displays structured tabular data with responsive
|
|
4
|
+
* Displays structured tabular data with responsive columns and optional controlled row selection.
|
|
5
5
|
*/
|
|
6
6
|
export declare const DataTable: <TRow extends object>(props: DataTableProps<TRow>) => React.ReactElement | null;
|
|
7
7
|
//# sourceMappingURL=DataTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../../../src/features/data-table/adapters/inbound/DataTable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAKV,cAAc,EAGf,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../../../src/features/data-table/adapters/inbound/DataTable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAKV,cAAc,EAGf,MAAM,8BAA8B,CAAC;AAYtC;;GAEG;AACH,eAAO,MAAM,SAAS,GAsdE,IAAI,SAAS,MAAM,2DAtdgB,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { Button } from '../../../button/public';
|
|
|
5
5
|
import { IconButton } from '../../../button/public';
|
|
6
6
|
import { Card } from '../../../card/public';
|
|
7
7
|
import { EmptyState } from '../../../empty-state/public';
|
|
8
|
+
import { Checkbox } from '../../../form/checkbox/public';
|
|
8
9
|
import { View } from '../../../layout/public';
|
|
9
10
|
import { PopoverMenu } from '../../../popover-menu/public';
|
|
10
11
|
import { SkeletonList } from '../../../skeleton/public';
|
|
@@ -12,7 +13,7 @@ import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThem
|
|
|
12
13
|
import { Text } from '../../../typography/public';
|
|
13
14
|
import { resolveDataTableRowKey } from '../../utils/resolveDataTableRowKey';
|
|
14
15
|
/***
|
|
15
|
-
* Displays structured tabular data with responsive
|
|
16
|
+
* Displays structured tabular data with responsive columns and optional controlled row selection.
|
|
16
17
|
*/
|
|
17
18
|
export const DataTable = withZoraThemeScope(DataTableInner);
|
|
18
19
|
function resolveTextAlign(align) {
|
|
@@ -41,11 +42,15 @@ function resolveCellStyle(column) {
|
|
|
41
42
|
return {
|
|
42
43
|
alignItems: resolveCellJustify(column.align),
|
|
43
44
|
flexGrow: column.width === undefined ? 1 : 0,
|
|
44
|
-
flexShrink: 0,
|
|
45
|
-
minWidth: column.minWidth
|
|
45
|
+
flexShrink: column.width === undefined && column.minWidth === undefined ? 1 : 0,
|
|
46
|
+
minWidth: column.minWidth,
|
|
46
47
|
width: column.width,
|
|
47
48
|
};
|
|
48
49
|
}
|
|
50
|
+
/*** Resolves the compact, fixed width reserved for the optional selection control. */
|
|
51
|
+
function resolveSelectionColumnStyle() {
|
|
52
|
+
return { alignItems: 'center', flexShrink: 0, width: 40 };
|
|
53
|
+
}
|
|
49
54
|
function resolveRowPadding(density) {
|
|
50
55
|
return density === 'compact'
|
|
51
56
|
? { px: 'm', py: 's' }
|
|
@@ -95,6 +100,19 @@ function renderTableCell(column, row, rowIndex) {
|
|
|
95
100
|
function resolveNextSortDirection(current) {
|
|
96
101
|
return current === 'asc' ? 'desc' : 'asc';
|
|
97
102
|
}
|
|
103
|
+
/*** Applies a single row checkbox change to controlled DataTable selection. */
|
|
104
|
+
function resolveNextSelectedRowIds(selectedRowIds, rowId, selected) {
|
|
105
|
+
return selected
|
|
106
|
+
? [...new Set([...selectedRowIds, rowId])]
|
|
107
|
+
: selectedRowIds.filter((selectedRowId) => selectedRowId !== rowId);
|
|
108
|
+
}
|
|
109
|
+
/*** Applies the header checkbox change to the currently visible DataTable rows. */
|
|
110
|
+
function resolveNextVisibleSelection(selectedRowIds, visibleRowIds, selected) {
|
|
111
|
+
const visibleRowIdSet = new Set(visibleRowIds);
|
|
112
|
+
return selected
|
|
113
|
+
? [...new Set([...selectedRowIds, ...visibleRowIds])]
|
|
114
|
+
: selectedRowIds.filter((selectedRowId) => !visibleRowIdSet.has(selectedRowId));
|
|
115
|
+
}
|
|
98
116
|
/*** Maps row-scoped DataTable actions into the shared PopoverMenu action contract. */
|
|
99
117
|
function mapRowActions(row, actions) {
|
|
100
118
|
return actions.map((action) => ({
|
|
@@ -115,11 +133,14 @@ function renderRowActions({ row, rowIndex, rowActions, testID, interactionPolicy
|
|
|
115
133
|
}
|
|
116
134
|
return (<PopoverMenu actions={mapRowActions(row, actions)} interactionPolicy={interactionPolicy} testID={testID ? `${testID}-row-actions-${rowIndex}` : undefined} trigger={({ toggle }) => (<IconButton icon={{ name: 'ellipsis-horizontal' }} interactionPolicy={interactionPolicy} label="Row actions" onPress={toggle} size="s" variant="ghost"/>)}/>);
|
|
117
135
|
}
|
|
118
|
-
function DataTableHeader({ columns, sort, onSortChange, density, interactionPolicy, }) {
|
|
136
|
+
function DataTableHeader({ columns, sort, onSortChange, density, interactionPolicy, selection, hasRowActions, }) {
|
|
119
137
|
const padding = resolveRowPadding(density ?? 'comfortable');
|
|
120
138
|
const passive = interactionPolicy === 'passive';
|
|
121
139
|
return (<View bg="subtle" borderColor="border" borderWidth={1} radius="m">
|
|
122
140
|
<View direction="row" align="center">
|
|
141
|
+
{selection ? (<View px={padding.px} py={padding.py} style={resolveSelectionColumnStyle()}>
|
|
142
|
+
<Checkbox accessibilityLabel="Select all visible rows" checked={selection.allVisibleSelected} disabled={selection.disabled} interactionPolicy={interactionPolicy} onCheckedChange={selection.onAllVisibleSelectedChange}/>
|
|
143
|
+
</View>) : null}
|
|
123
144
|
{columns.map((column) => {
|
|
124
145
|
const currentDirection = sort?.columnId === column.id ? sort.direction : undefined;
|
|
125
146
|
const sortable = Boolean(column.sortable && onSortChange);
|
|
@@ -140,46 +161,84 @@ function DataTableHeader({ columns, sort, onSortChange, density, interactionPoli
|
|
|
140
161
|
</Text>)}
|
|
141
162
|
</View>);
|
|
142
163
|
})}
|
|
143
|
-
<View px={padding.px} py={padding.py} style={{ minWidth: 56, width: 56 }}>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
{hasRowActions ? (<View px={padding.px} py={padding.py} style={{ minWidth: 56, width: 56 }}>
|
|
165
|
+
<Text align="right" emphasis="muted" variant="caption" weight="semiBold">
|
|
166
|
+
Actions
|
|
167
|
+
</Text>
|
|
168
|
+
</View>) : null}
|
|
148
169
|
</View>
|
|
149
170
|
</View>);
|
|
150
171
|
}
|
|
151
|
-
function DataTableDesktop({ columns, rows, rowActions, rowId, rowKey, sort, onSortChange, density, testID, interactionPolicy, }) {
|
|
172
|
+
function DataTableDesktop({ columns, rows, rowActions, rowId, rowKey, selectedRowIds, onSelectedRowIdsChange, sort, onSortChange, density, testID, interactionPolicy, }) {
|
|
152
173
|
const padding = resolveRowPadding(density ?? 'comfortable');
|
|
174
|
+
const rowIds = rows.map((row, rowIndex) => resolveDataTableRowKey(row, rowIndex, rowKey, rowId));
|
|
175
|
+
const controlledSelectedRowIds = selectedRowIds ?? [];
|
|
176
|
+
const selectedRowIdSet = new Set(controlledSelectedRowIds);
|
|
177
|
+
const selectionEnabled = selectedRowIds !== undefined;
|
|
178
|
+
const selectionDisabled = interactionPolicy === 'passive' || onSelectedRowIdsChange === undefined;
|
|
179
|
+
const hasRowActions = rows.some((row, rowIndex) => (rowActions?.(row, rowIndex).length ?? 0) > 0);
|
|
180
|
+
const selection = selectionEnabled
|
|
181
|
+
? {
|
|
182
|
+
allVisibleSelected: rowIds.every((currentRowId) => selectedRowIdSet.has(currentRowId)),
|
|
183
|
+
disabled: selectionDisabled,
|
|
184
|
+
onAllVisibleSelectedChange: (selected) => {
|
|
185
|
+
if (selectionDisabled)
|
|
186
|
+
return;
|
|
187
|
+
onSelectedRowIdsChange(resolveNextVisibleSelection(controlledSelectedRowIds, rowIds, selected));
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
: undefined;
|
|
153
191
|
return (<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
|
154
|
-
<View
|
|
192
|
+
<View style={{ width: '100%' }}>
|
|
155
193
|
<View gap="xs">
|
|
156
|
-
<DataTableHeader columns={columns} density={density} interactionPolicy={interactionPolicy} onSortChange={onSortChange} sort={sort}/>
|
|
194
|
+
<DataTableHeader columns={columns} density={density} hasRowActions={hasRowActions} interactionPolicy={interactionPolicy} onSortChange={onSortChange} selection={selection} sort={sort}/>
|
|
157
195
|
<View gap="xs">
|
|
158
|
-
{rows.map((row, rowIndex) =>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
196
|
+
{rows.map((row, rowIndex) => {
|
|
197
|
+
const currentRowId = resolveDataTableRowKey(row, rowIndex, rowKey, rowId);
|
|
198
|
+
const selected = selectedRowIdSet.has(currentRowId);
|
|
199
|
+
return (<View bg="surface" borderColor="border" borderWidth={1} key={currentRowId} radius="m" testID={testID ? `${testID}-row-${rowIndex}` : undefined}>
|
|
200
|
+
<View direction="row" align="center">
|
|
201
|
+
{selectionEnabled ? (<View px={padding.px} py={padding.py} style={resolveSelectionColumnStyle()}>
|
|
202
|
+
<Checkbox accessibilityLabel={`Select row ${currentRowId}`} checked={selected} disabled={selectionDisabled} interactionPolicy={interactionPolicy} onCheckedChange={(nextSelected) => {
|
|
203
|
+
if (selectionDisabled)
|
|
204
|
+
return;
|
|
205
|
+
onSelectedRowIdsChange(resolveNextSelectedRowIds(controlledSelectedRowIds, currentRowId, nextSelected));
|
|
206
|
+
}}/>
|
|
207
|
+
</View>) : null}
|
|
208
|
+
{columns.map((column) => (<View key={column.id} px={padding.px} py={padding.py} style={resolveCellStyle(column)}>
|
|
209
|
+
{renderTableCell(column, row, rowIndex)}
|
|
210
|
+
</View>))}
|
|
211
|
+
{hasRowActions ? (<View px={padding.px} py={padding.py} style={{ alignItems: 'flex-end', minWidth: 56, width: 56 }}>
|
|
212
|
+
{renderRowActions({ row, rowActions, rowIndex, testID, interactionPolicy })}
|
|
213
|
+
</View>) : null}
|
|
165
214
|
</View>
|
|
166
|
-
</View>
|
|
167
|
-
|
|
215
|
+
</View>);
|
|
216
|
+
})}
|
|
168
217
|
</View>
|
|
169
218
|
</View>
|
|
170
219
|
</View>
|
|
171
220
|
</ScrollView>);
|
|
172
221
|
}
|
|
173
|
-
function DataTableMobile({ columns, rows, rowActions, rowId, rowKey, testID, interactionPolicy, }) {
|
|
222
|
+
function DataTableMobile({ columns, rows, rowActions, rowId, rowKey, selectedRowIds, onSelectedRowIdsChange, testID, interactionPolicy, }) {
|
|
174
223
|
const [primaryColumn, ...detailColumns] = columns;
|
|
224
|
+
const controlledSelectedRowIds = selectedRowIds ?? [];
|
|
225
|
+
const selectedRowIdSet = new Set(controlledSelectedRowIds);
|
|
226
|
+
const selectionEnabled = selectedRowIds !== undefined;
|
|
227
|
+
const selectionDisabled = interactionPolicy === 'passive' || onSelectedRowIdsChange === undefined;
|
|
175
228
|
return (<View gap="s">
|
|
176
229
|
{rows.map((row, rowIndex) => {
|
|
230
|
+
const currentRowId = resolveDataTableRowKey(row, rowIndex, rowKey, rowId);
|
|
177
231
|
const title = primaryColumn
|
|
178
232
|
? renderCell(primaryColumn, row, rowIndex)
|
|
179
233
|
: `Row ${rowIndex + 1}`;
|
|
180
234
|
const actions = renderRowActions({ row, rowActions, rowIndex, testID, interactionPolicy });
|
|
181
|
-
return (<Card actions={actions} compact interactionPolicy={interactionPolicy} key={
|
|
235
|
+
return (<Card actions={actions} compact interactionPolicy={interactionPolicy} key={currentRowId} testID={testID ? `${testID}-card-${rowIndex}` : undefined} title={title}>
|
|
182
236
|
<View gap="s">
|
|
237
|
+
{selectionEnabled ? (<Checkbox accessibilityLabel={`Select row ${currentRowId}`} checked={selectedRowIdSet.has(currentRowId)} disabled={selectionDisabled} interactionPolicy={interactionPolicy} onCheckedChange={(nextSelected) => {
|
|
238
|
+
if (selectionDisabled)
|
|
239
|
+
return;
|
|
240
|
+
onSelectedRowIdsChange(resolveNextSelectedRowIds(controlledSelectedRowIds, currentRowId, nextSelected));
|
|
241
|
+
}}/>) : null}
|
|
183
242
|
{detailColumns.map((column) => (<View gap="xxs" key={column.id}>
|
|
184
243
|
<Text emphasis="muted" variant="caption" weight="semiBold">
|
|
185
244
|
{column.header}
|