@servicetitan/anvil2 2.6.1 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/{Avatar-CCnbKkCm.js → Avatar-BckUfs1N.js} +48 -46
- package/dist/{Avatar-CCnbKkCm.js.map → Avatar-BckUfs1N.js.map} +1 -1
- package/dist/Avatar-ChybzixS.js +35 -0
- package/dist/Avatar-ChybzixS.js.map +1 -0
- package/dist/Avatar.js +2 -2
- package/dist/Breadcrumbs-C_WK9Yul.js +107 -0
- package/dist/Breadcrumbs-C_WK9Yul.js.map +1 -0
- package/dist/Breadcrumbs.js +1 -1
- package/dist/{Calendar-B5d2SUrH.js → Calendar-BTStJPV1.js} +2 -2
- package/dist/{Calendar-B5d2SUrH.js.map → Calendar-BTStJPV1.js.map} +1 -1
- package/dist/{Calendar-B0u3EgCY.js → Calendar-Frpv5rRY.js} +129 -118
- package/dist/Calendar-Frpv5rRY.js.map +1 -0
- package/dist/Calendar.css +51 -51
- package/dist/Calendar.js +2 -2
- package/dist/Checkbox-CTZdZym4.js +52 -0
- package/dist/Checkbox-CTZdZym4.js.map +1 -0
- package/dist/{Checkbox-BwULIo4D.js → Checkbox-Drgai_lS.js} +16 -7
- package/dist/Checkbox-Drgai_lS.js.map +1 -0
- package/dist/Checkbox.js +1 -1
- package/dist/{Chip-DjTAR0va.js → Chip-CVyEctAz.js} +2 -2
- package/dist/{Chip-DjTAR0va.js.map → Chip-CVyEctAz.js.map} +1 -1
- package/dist/Chip.js +1 -1
- package/dist/{Combobox-Clymsgli.js → Combobox-BRtfrYyZ.js} +185 -182
- package/dist/{Combobox-Clymsgli.js.map → Combobox-BRtfrYyZ.js.map} +1 -1
- package/dist/Combobox.js +1 -1
- package/dist/{DataTable-qoseu_e2.js → DataTable-BmVPjMMg.js} +680 -628
- package/dist/DataTable-BmVPjMMg.js.map +1 -0
- package/dist/{DateFieldRange-rks7jQor.js → DateFieldRange-D9DtlkSQ.js} +18 -4
- package/dist/DateFieldRange-D9DtlkSQ.js.map +1 -0
- package/dist/DateFieldRange.js +1 -1
- package/dist/{DateFieldSingle-C0WXU7H1.js → DateFieldSingle-CkdeCUJv.js} +6 -6
- package/dist/{DateFieldSingle-C0WXU7H1.js.map → DateFieldSingle-CkdeCUJv.js.map} +1 -1
- package/dist/DateFieldSingle.js +1 -1
- package/dist/{DateFieldYearless-2p3a7Xgo.js → DateFieldYearless-b81ZcYdp.js} +3 -3
- package/dist/{DateFieldYearless-2p3a7Xgo.js.map → DateFieldYearless-b81ZcYdp.js.map} +1 -1
- package/dist/DateFieldYearless.js +1 -1
- package/dist/{DateFieldYearlessRange-DLmhPug8.js → DateFieldYearlessRange-ClAFzIDD.js} +3 -3
- package/dist/{DateFieldYearlessRange-DLmhPug8.js.map → DateFieldYearlessRange-ClAFzIDD.js.map} +1 -1
- package/dist/DateFieldYearlessRange.js +1 -1
- package/dist/{DaysOfTheWeek-BR32AA32.js → DaysOfTheWeek-2Zeh79oR.js} +3 -3
- package/dist/{DaysOfTheWeek-BR32AA32.js.map → DaysOfTheWeek-2Zeh79oR.js.map} +1 -1
- package/dist/DaysOfTheWeek.js +1 -1
- package/dist/{Details-Dxq_v3Qg.js → Details-CZOIpNP_.js} +8 -8
- package/dist/Details-CZOIpNP_.js.map +1 -0
- package/dist/Details.js +1 -1
- package/dist/{Dialog-CMhypnCD.js → Dialog-CloZWa1Q.js} +70 -70
- package/dist/Dialog-CloZWa1Q.js.map +1 -0
- package/dist/Dialog.js +1 -1
- package/dist/DndSort.js +3 -5
- package/dist/DndSort.js.map +1 -1
- package/dist/{Drawer-CSelPi8t.js → Drawer-CfkoH081.js} +83 -83
- package/dist/Drawer-CfkoH081.js.map +1 -0
- package/dist/Drawer.js +1 -1
- package/dist/DrillDown.js +1 -1
- package/dist/{FieldLabel-DbMosKtd.js → FieldLabel-CQ5QGTVq.js} +2 -2
- package/dist/{FieldLabel-DbMosKtd.js.map → FieldLabel-CQ5QGTVq.js.map} +1 -1
- package/dist/FieldLabel.js +1 -1
- package/dist/Grid-DeYIx5k4.js +149 -0
- package/dist/Grid-DeYIx5k4.js.map +1 -0
- package/dist/Grid.js +1 -1
- package/dist/{InputMask-BKs-x6ds.js → InputMask-CI4Q5UwG.js} +2 -2
- package/dist/{InputMask-BKs-x6ds.js.map → InputMask-CI4Q5UwG.js.map} +1 -1
- package/dist/InputMask.js +1 -1
- package/dist/{Layout-VfhlilMG.js → Layout-CISAxILX.js} +34 -33
- package/dist/Layout-CISAxILX.js.map +1 -0
- package/dist/Layout.js +1 -1
- package/dist/List--KhCpjZn.js +103 -0
- package/dist/List--KhCpjZn.js.map +1 -0
- package/dist/List.js +1 -1
- package/dist/{ListView-CeGwrRbt.js → ListView-DAbBuss4.js} +6 -6
- package/dist/ListView-DAbBuss4.js.map +1 -0
- package/dist/ListView.js +1 -1
- package/dist/{Listbox-BtAgBDRS.js → Listbox-D_T55BFX.js} +5 -4
- package/dist/Listbox-D_T55BFX.js.map +1 -0
- package/dist/Listbox.js +1 -1
- package/dist/{Menu-BXsmCP20.js → Menu-CRoJYJ53.js} +366 -365
- package/dist/Menu-CRoJYJ53.js.map +1 -0
- package/dist/Menu.js +1 -1
- package/dist/MultiSelectField.js +1 -1
- package/dist/{MultiSelectFieldSync-EELhdoD6.js → MultiSelectFieldSync-CSOitvtu.js} +5 -5
- package/dist/{MultiSelectFieldSync-EELhdoD6.js.map → MultiSelectFieldSync-CSOitvtu.js.map} +1 -1
- package/dist/MultiSelectMenu.js +1 -1
- package/dist/{MultiSelectMenuSync-CAPhhkK1.js → MultiSelectMenuSync-62OeGmkz.js} +29 -9
- package/dist/MultiSelectMenuSync-62OeGmkz.js.map +1 -0
- package/dist/{NumberField-svhZp1kB.js → NumberField-CHBXBMSj.js} +2 -2
- package/dist/{NumberField-svhZp1kB.js.map → NumberField-CHBXBMSj.js.map} +1 -1
- package/dist/NumberField.js +1 -1
- package/dist/Overflow.css +27 -26
- package/dist/Overflow.js +11 -11
- package/dist/{Page-BpV1yHkm.js → Page-DtSjnBJL.js} +277 -224
- package/dist/Page-DtSjnBJL.js.map +1 -0
- package/dist/Page.css +87 -73
- package/dist/Page.js +1 -1
- package/dist/{Pagination-BAwqfl_2.js → Pagination-CbBte3GQ.js} +17 -15
- package/dist/Pagination-CbBte3GQ.js.map +1 -0
- package/dist/Pagination.js +1 -1
- package/dist/Popover-CQhLSNYR.js +537 -0
- package/dist/Popover-CQhLSNYR.js.map +1 -0
- package/dist/{Popover-Br6qPgKe.js → Popover-Rha0q-Pv.js} +353 -353
- package/dist/Popover-Rha0q-Pv.js.map +1 -0
- package/dist/Popover.js +1 -1
- package/dist/{ProgressBar-JpRDW5vG.js → ProgressBar-DEaMqbM-.js} +2 -2
- package/dist/{ProgressBar-JpRDW5vG.js.map → ProgressBar-DEaMqbM-.js.map} +1 -1
- package/dist/ProgressBar.js +1 -1
- package/dist/{Radio-8DmfWHYq.js → Radio-Bw2LDl9G.js} +13 -4
- package/dist/{Radio-8DmfWHYq.js.map → Radio-Bw2LDl9G.js.map} +1 -1
- package/dist/Radio-CCvu8mbI.js +60 -0
- package/dist/Radio-CCvu8mbI.js.map +1 -0
- package/dist/Radio.js +1 -1
- package/dist/{SegmentedControl-7fDLhgvh.js → SegmentedControl-BAi4pnFe.js} +79 -75
- package/dist/{SegmentedControl-7fDLhgvh.js.map → SegmentedControl-BAi4pnFe.js.map} +1 -1
- package/dist/SegmentedControl.js +1 -1
- package/dist/SelectCard-ZaAD0wR1.js +325 -0
- package/dist/SelectCard-ZaAD0wR1.js.map +1 -0
- package/dist/SelectCard.css +23 -18
- package/dist/SelectCard.js +1 -1
- package/dist/SelectField.js +1 -1
- package/dist/{SelectFieldLabel-Dr8HeW3N.js → SelectFieldLabel-EJCXA02B.js} +2 -2
- package/dist/{SelectFieldLabel-Dr8HeW3N.js.map → SelectFieldLabel-EJCXA02B.js.map} +1 -1
- package/dist/{SelectFieldSync-BPopU0om.js → SelectFieldSync-DA54WXOk.js} +4 -4
- package/dist/{SelectFieldSync-BPopU0om.js.map → SelectFieldSync-DA54WXOk.js.map} +1 -1
- package/dist/SelectMenu.js +1 -1
- package/dist/{SelectMenuSync-DeMYO1m_.js → SelectMenuSync-BQaSTcaN.js} +29 -9
- package/dist/SelectMenuSync-BQaSTcaN.js.map +1 -0
- package/dist/{SelectOptions-DBe5ZN_-.js → SelectOptions-D-DzWmKE.js} +2 -2
- package/dist/{SelectOptions-DBe5ZN_-.js.map → SelectOptions-D-DzWmKE.js.map} +1 -1
- package/dist/{SelectTrigger-ObsnAKNp.js → SelectTrigger-DWyRndmY.js} +3 -3
- package/dist/{SelectTrigger-ObsnAKNp.js.map → SelectTrigger-DWyRndmY.js.map} +1 -1
- package/dist/SelectTrigger.js +1 -1
- package/dist/{SelectTriggerBase-DKfOL2RJ.js → SelectTriggerBase-B6aZd2a6.js} +3 -3
- package/dist/{SelectTriggerBase-DKfOL2RJ.js.map → SelectTriggerBase-B6aZd2a6.js.map} +1 -1
- package/dist/{SideNav-KksbSQn7.js → SideNav-CxHemV3H.js} +127 -125
- package/dist/{SideNav-KksbSQn7.js.map → SideNav-CxHemV3H.js.map} +1 -1
- package/dist/SideNav.js +1 -1
- package/dist/{Stepper-Dt8_ImvJ.js → Stepper-CQUXV6P4.js} +156 -156
- package/dist/{Stepper-Dt8_ImvJ.js.map → Stepper-CQUXV6P4.js.map} +1 -1
- package/dist/Stepper.js +1 -1
- package/dist/{Tab-DO7LaUbw.js → Tab-BGGNcz9S.js} +225 -221
- package/dist/Tab-BGGNcz9S.js.map +1 -0
- package/dist/Tab.js +1 -1
- package/dist/Table.js +1 -1
- package/dist/{TextField--co7QJ4r.js → TextField-CMv9CpBq.js} +2 -2
- package/dist/{TextField--co7QJ4r.js.map → TextField-CMv9CpBq.js.map} +1 -1
- package/dist/{TextField-Cax4UeNl.js → TextField-o8zvVFDk.js} +8 -3
- package/dist/TextField-o8zvVFDk.js.map +1 -0
- package/dist/TextField.js +1 -1
- package/dist/{Textarea-DyqdMTvQ.js → Textarea-B4bBvO8c.js} +2 -2
- package/dist/{Textarea-DyqdMTvQ.js.map → Textarea-B4bBvO8c.js.map} +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/{TimeField-BfcLCWMG.js → TimeField-BEgnjk4R.js} +4 -5
- package/dist/{TimeField-BfcLCWMG.js.map → TimeField-BEgnjk4R.js.map} +1 -1
- package/dist/TimeField.js +1 -1
- package/dist/Toast.js +2 -2
- package/dist/{Toaster-b0-Ub3yt.js → Toaster-6_LVKok2.js} +2 -2
- package/dist/{Toaster-b0-Ub3yt.js.map → Toaster-6_LVKok2.js.map} +1 -1
- package/dist/{Toaster-DikGo_hR.js → Toaster-B38WlKC7.js} +2 -2
- package/dist/{Toaster-DikGo_hR.js.map → Toaster-B38WlKC7.js.map} +1 -1
- package/dist/{Toolbar-DqYMc_w8.js → Toolbar-0EKhrvZN.js} +147 -146
- package/dist/{Toolbar-DqYMc_w8.js.map → Toolbar-0EKhrvZN.js.map} +1 -1
- package/dist/Toolbar.js +1 -1
- package/dist/{Tooltip-Bupqao9B.js → Tooltip-BHwSTwsv.js} +224 -226
- package/dist/Tooltip-BHwSTwsv.js.map +1 -0
- package/dist/Tooltip.js +1 -1
- package/dist/{YearlessDateInputWithPicker-aq99rKJU.js → YearlessDateInputWithPicker-BC4lRuny.js} +2 -3
- package/dist/YearlessDateInputWithPicker-BC4lRuny.js.map +1 -0
- package/dist/beta/components/MultiSelectMenu/types.d.ts +15 -0
- package/dist/beta/components/SelectMenu/internal/useMenuInteraction.d.ts +3 -1
- package/dist/beta/components/SelectMenu/types.d.ts +15 -0
- package/dist/beta/components/Table/DataTable/DataTable.d.ts +9 -16
- package/dist/beta/components/Table/DataTable/internal/editable-cells/DataTableEditableMultiselectAsyncCell.d.ts +35 -0
- package/dist/beta/components/Table/DataTable/internal/editable-cells/DataTableEditableMultiselectCell.d.ts +4 -3
- package/dist/beta/components/Table/DataTable/internal/editable-cells/DataTableEditableSelectAsyncCell.d.ts +7 -0
- package/dist/beta/components/Table/DataTable/internal/editable-cells/useEditableMenuCell.d.ts +34 -0
- package/dist/beta/components/Table/DataTable/internal/util/getTanStackColumnDef.d.ts +9 -5
- package/dist/beta/components/Table/DataTable/types.d.ts +18 -1
- package/dist/beta/components/Table/createColumnHelper.d.ts +29 -68
- package/dist/beta/components/Table/types.d.ts +222 -40
- package/dist/beta/components/Toolbar/Toolbar.d.ts +168 -41
- package/dist/beta.js +9 -9
- package/dist/components/Announcement/Announcement.figma.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +14 -0
- package/dist/components/Calendar/Calendar.d.ts +84 -26
- package/dist/components/Checkbox/internal/Checkbox.d.ts +8 -0
- package/dist/components/Combobox/Combobox.d.ts +172 -1
- package/dist/components/Dialog/Dialog.d.ts +96 -28
- package/dist/components/DndSort/internal/test-utils.d.ts +15 -8
- package/dist/components/DrillDown/DrillDown.d.ts +7 -1
- package/dist/components/FieldMessage/FieldMessage.figma.d.ts +1 -0
- package/dist/components/Layout/Layout.d.ts +52 -44
- package/dist/components/ListView/ListView.d.ts +5 -5
- package/dist/components/Listbox/Listbox.d.ts +5 -23
- package/dist/components/Menu/Menu.d.ts +1 -4
- package/dist/components/Page/Page.d.ts +1 -1
- package/dist/components/Page/PageContent.d.ts +5 -5
- package/dist/components/Page/PageContext.d.ts +2 -0
- package/dist/components/Page/PageFooter.d.ts +1 -0
- package/dist/components/Radio/internal/Radio.d.ts +8 -0
- package/dist/components/Toolbar/Toolbar.d.ts +3 -1
- package/dist/index.js +126 -126
- package/dist/index.js.map +1 -1
- package/dist/internal/components/Popover/Popover.d.ts +2 -2
- package/dist/internal/components/Popover/internal/PopoverContext.d.ts +2 -2
- package/dist/{syncFilterUtils-BRKjFwxk.js → syncFilterUtils-B03Pc941.js} +190 -190
- package/dist/{syncFilterUtils-BRKjFwxk.js.map → syncFilterUtils-B03Pc941.js.map} +1 -1
- package/dist/{useDrilldown-CqBBB_r1.js → useDrilldown-BW2XkUcK.js} +40 -38
- package/dist/{useDrilldown-CqBBB_r1.js.map → useDrilldown-BW2XkUcK.js.map} +1 -1
- package/dist/{useMenuInteraction-zR_78KQC.js → useMenuInteraction-BwZ2ORo9.js} +8 -3
- package/dist/useMenuInteraction-BwZ2ORo9.js.map +1 -0
- package/dist/{useToggleSelection-JD62Jzqu.js → useToggleSelection-Dip0eimQ.js} +2 -2
- package/dist/{useToggleSelection-JD62Jzqu.js.map → useToggleSelection-Dip0eimQ.js.map} +1 -1
- package/package.json +10 -9
- package/dist/Avatar--CnTAnfD.js +0 -35
- package/dist/Avatar--CnTAnfD.js.map +0 -1
- package/dist/Breadcrumbs-3Y7jnj-F.js +0 -105
- package/dist/Breadcrumbs-3Y7jnj-F.js.map +0 -1
- package/dist/Calendar-B0u3EgCY.js.map +0 -1
- package/dist/Checkbox-BwULIo4D.js.map +0 -1
- package/dist/Checkbox-CIj37_vY.js +0 -50
- package/dist/Checkbox-CIj37_vY.js.map +0 -1
- package/dist/DataTable-qoseu_e2.js.map +0 -1
- package/dist/DateFieldRange-rks7jQor.js.map +0 -1
- package/dist/Details-Dxq_v3Qg.js.map +0 -1
- package/dist/Dialog-CMhypnCD.js.map +0 -1
- package/dist/Drawer-CSelPi8t.js.map +0 -1
- package/dist/Grid-ONcUpb__.js +0 -147
- package/dist/Grid-ONcUpb__.js.map +0 -1
- package/dist/Layout-VfhlilMG.js.map +0 -1
- package/dist/List-CJZjElAQ.js +0 -101
- package/dist/List-CJZjElAQ.js.map +0 -1
- package/dist/ListView-CeGwrRbt.js.map +0 -1
- package/dist/Listbox-BtAgBDRS.js.map +0 -1
- package/dist/Menu-BXsmCP20.js.map +0 -1
- package/dist/MultiSelectMenuSync-CAPhhkK1.js.map +0 -1
- package/dist/Page-BpV1yHkm.js.map +0 -1
- package/dist/Pagination-BAwqfl_2.js.map +0 -1
- package/dist/Popover-Br6qPgKe.js.map +0 -1
- package/dist/Popover-Dkw_8dZx.js +0 -535
- package/dist/Popover-Dkw_8dZx.js.map +0 -1
- package/dist/Radio-M7lc0BsU.js +0 -60
- package/dist/Radio-M7lc0BsU.js.map +0 -1
- package/dist/SelectCard-D5dcOIuf.js +0 -311
- package/dist/SelectCard-D5dcOIuf.js.map +0 -1
- package/dist/SelectMenuSync-DeMYO1m_.js.map +0 -1
- package/dist/Tab-DO7LaUbw.js.map +0 -1
- package/dist/TextField-Cax4UeNl.js.map +0 -1
- package/dist/Tooltip-Bupqao9B.js.map +0 -1
- package/dist/YearlessDateInputWithPicker-aq99rKJU.js.map +0 -1
- package/dist/useMenuInteraction-zR_78KQC.js.map +0 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { C as Chip } from './Chip-
|
|
2
|
+
import { C as Chip } from './Chip-CVyEctAz.js';
|
|
3
3
|
import { F as Flex } from './Flex-WyyZm1bf.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useRef, useState, useLayoutEffect, createContext, useContext, useCallback, forwardRef, useMemo, useImperativeHandle, useEffect, useId, Fragment as Fragment$1, useReducer } from 'react';
|
|
6
6
|
import { c as cx } from './index-De1g9FRV.js';
|
|
7
7
|
import { D as DateTime } from './luxon-wpz4A-OQ.js';
|
|
8
|
-
import {
|
|
9
|
-
import { C as Checkbox } from './Checkbox-CIj37_vY.js';
|
|
8
|
+
import { C as Checkbox } from './Checkbox-CTZdZym4.js';
|
|
10
9
|
import { B as Button } from './Button-CVsGhVJz.js';
|
|
11
10
|
import { S as SvgChevronRight } from './chevron_right-BdpsxX7x.js';
|
|
12
11
|
import { S as SvgEdit } from './edit-DQOiktcu.js';
|
|
@@ -14,17 +13,15 @@ import { I as Icon } from './Icon-DuIlne4x.js';
|
|
|
14
13
|
import { S as SrOnly } from './SrOnly-eUpYGpAT.js';
|
|
15
14
|
import { u as useNumberField } from './useNumberField-eMyk7MB8.js';
|
|
16
15
|
import { u as useMergeRefs, m as mergeRefs } from './useMergeRefs-Dfmtq9cI.js';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { S as SearchField } from './SearchField-im7AHGYo.js';
|
|
20
|
-
import { L as ListView } from './ListView-CeGwrRbt.js';
|
|
16
|
+
import { a as SelectMenuSync, S as SelectMenu } from './SelectMenuSync-BQaSTcaN.js';
|
|
17
|
+
import { a as MultiSelectMenuSync, M as MultiSelectMenu } from './MultiSelectMenuSync-62OeGmkz.js';
|
|
21
18
|
import { S as SvgError } from './error-DR_wWdYY.js';
|
|
22
19
|
import { S as SvgWarning } from './warning-c4Wj1rI4.js';
|
|
23
|
-
import { T as Tooltip } from './Tooltip-
|
|
20
|
+
import { T as Tooltip } from './Tooltip-BHwSTwsv.js';
|
|
24
21
|
import { flushSync } from 'react-dom';
|
|
25
22
|
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-DMDdfIah.js';
|
|
26
23
|
import './anvil-fonts.css';import './DataTable.css';/* empty css */
|
|
27
|
-
import { P as Pagination } from './Pagination-
|
|
24
|
+
import { P as Pagination } from './Pagination-CbBte3GQ.js';
|
|
28
25
|
import { T as ThemeProviderContext } from './ThemeProviderContext-l52GohYT.js';
|
|
29
26
|
import { S as Spinner } from './Spinner-BqmcE2pb.js';
|
|
30
27
|
import { u as useOptionallyControlledState } from './useOptionallyControlledState-DbDuos5L.js';
|
|
@@ -406,53 +403,15 @@ function getColumnTypeDefaults(type) {
|
|
|
406
403
|
return COLUMN_TYPE_DEFAULTS[type];
|
|
407
404
|
}
|
|
408
405
|
|
|
409
|
-
function logDeprecationWarnings(id, column) {
|
|
410
|
-
const columnId = typeof id === "object" && "group" in id ? id.group : String(id);
|
|
411
|
-
if ("editMode" in column && column.editMode && !("editConfig" in column && column.editConfig)) {
|
|
412
|
-
warnOnce(
|
|
413
|
-
`[Anvil2 DataTable] Column "${columnId}" uses deprecated \`editMode\` prop. Migrate to \`editConfig: { mode: "${column.editMode}", onChange: ... }\``
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
if ("onChange" in column && column.onChange && !("editConfig" in column && column.editConfig)) {
|
|
417
|
-
warnOnce(
|
|
418
|
-
`[Anvil2 DataTable] Column "${columnId}" uses deprecated top-level \`onChange\`. Move \`onChange\` inside \`editConfig\`.`
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
if ("options" in column && column.options && !("editConfig" in column && column.editConfig)) {
|
|
422
|
-
warnOnce(
|
|
423
|
-
`[Anvil2 DataTable] Column "${columnId}" uses deprecated top-level \`options\`. Move \`options\` inside \`editConfig\`.`
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
function transformEditConfig(column) {
|
|
428
|
-
if (!("editConfig" in column) || !column.editConfig) {
|
|
429
|
-
return {};
|
|
430
|
-
}
|
|
431
|
-
const { editConfig } = column;
|
|
432
|
-
const result = {
|
|
433
|
-
editMode: editConfig.mode,
|
|
434
|
-
onChange: editConfig.onChange
|
|
435
|
-
};
|
|
436
|
-
if (editConfig.mode === "select" || editConfig.mode === "multiselect") {
|
|
437
|
-
if ("options" in editConfig) {
|
|
438
|
-
result.options = editConfig.options;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
result.editConfig = editConfig;
|
|
442
|
-
return result;
|
|
443
|
-
}
|
|
444
406
|
function createColumnHelper$1() {
|
|
445
407
|
return function createColumn(id, column) {
|
|
446
|
-
logDeprecationWarnings(id, column);
|
|
447
|
-
const editProps = transformEditConfig(column);
|
|
448
408
|
if (typeof id === "object" && "group" in id) {
|
|
449
409
|
return {
|
|
450
410
|
id: id.group,
|
|
451
|
-
...column
|
|
452
|
-
...editProps
|
|
411
|
+
...column
|
|
453
412
|
};
|
|
454
413
|
}
|
|
455
|
-
return { id, ...column
|
|
414
|
+
return { id, ...column };
|
|
456
415
|
};
|
|
457
416
|
}
|
|
458
417
|
|
|
@@ -3597,6 +3556,49 @@ function groupBy(rows, columnId) {
|
|
|
3597
3556
|
}, groupMap);
|
|
3598
3557
|
}
|
|
3599
3558
|
|
|
3559
|
+
function getPaginationRowModel(opts) {
|
|
3560
|
+
return table => memo(() => [table.getState().pagination, table.getPrePaginationRowModel(), table.options.paginateExpandedRows ? undefined : table.getState().expanded], (pagination, rowModel) => {
|
|
3561
|
+
if (!rowModel.rows.length) {
|
|
3562
|
+
return rowModel;
|
|
3563
|
+
}
|
|
3564
|
+
const {
|
|
3565
|
+
pageSize,
|
|
3566
|
+
pageIndex
|
|
3567
|
+
} = pagination;
|
|
3568
|
+
let {
|
|
3569
|
+
rows,
|
|
3570
|
+
flatRows,
|
|
3571
|
+
rowsById
|
|
3572
|
+
} = rowModel;
|
|
3573
|
+
const pageStart = pageSize * pageIndex;
|
|
3574
|
+
const pageEnd = pageStart + pageSize;
|
|
3575
|
+
rows = rows.slice(pageStart, pageEnd);
|
|
3576
|
+
let paginatedRowModel;
|
|
3577
|
+
if (!table.options.paginateExpandedRows) {
|
|
3578
|
+
paginatedRowModel = expandRows({
|
|
3579
|
+
rows,
|
|
3580
|
+
flatRows,
|
|
3581
|
+
rowsById
|
|
3582
|
+
});
|
|
3583
|
+
} else {
|
|
3584
|
+
paginatedRowModel = {
|
|
3585
|
+
rows,
|
|
3586
|
+
flatRows,
|
|
3587
|
+
rowsById
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3590
|
+
paginatedRowModel.flatRows = [];
|
|
3591
|
+
const handleRow = row => {
|
|
3592
|
+
paginatedRowModel.flatRows.push(row);
|
|
3593
|
+
if (row.subRows.length) {
|
|
3594
|
+
row.subRows.forEach(handleRow);
|
|
3595
|
+
}
|
|
3596
|
+
};
|
|
3597
|
+
paginatedRowModel.rows.forEach(handleRow);
|
|
3598
|
+
return paginatedRowModel;
|
|
3599
|
+
}, getMemoOptions(table.options, 'debugTable', 'getPaginationRowModel'));
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3600
3602
|
function getSortedRowModel() {
|
|
3601
3603
|
return table => memo(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3602
3604
|
if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
|
|
@@ -3993,7 +3995,9 @@ function getCellValue(cell, _columnId) {
|
|
|
3993
3995
|
return value;
|
|
3994
3996
|
}
|
|
3995
3997
|
function getCellOnChange(cell, _columnId) {
|
|
3996
|
-
|
|
3998
|
+
const meta = cell.column.columnDef.meta;
|
|
3999
|
+
const onChange = meta?.editConfig?.onChange;
|
|
4000
|
+
return onChange;
|
|
3997
4001
|
}
|
|
3998
4002
|
function logWarningForInvalidCellValueType({
|
|
3999
4003
|
columnId,
|
|
@@ -4538,113 +4542,60 @@ const DataTableEditableNumberCell = Object.assign(
|
|
|
4538
4542
|
{ displayName: "DataTableEditableNumberCell" }
|
|
4539
4543
|
);
|
|
4540
4544
|
|
|
4541
|
-
function
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
const cellValue = getCellValue(cell);
|
|
4547
|
-
const [initialValue, isValidValueType] = useMemo(() => {
|
|
4548
|
-
let value;
|
|
4549
|
-
let isValid = true;
|
|
4550
|
-
if (cellValue === void 0 || cellValue === null) {
|
|
4551
|
-
value = "";
|
|
4552
|
-
isValid = true;
|
|
4553
|
-
return [value, isValid];
|
|
4554
|
-
}
|
|
4555
|
-
switch (typeof cellValue) {
|
|
4556
|
-
case "string":
|
|
4557
|
-
case "number":
|
|
4558
|
-
value = String(cellValue);
|
|
4559
|
-
break;
|
|
4560
|
-
case "boolean":
|
|
4561
|
-
value = String(cellValue);
|
|
4562
|
-
break;
|
|
4563
|
-
default:
|
|
4564
|
-
value = "";
|
|
4565
|
-
isValid = false;
|
|
4566
|
-
break;
|
|
4567
|
-
}
|
|
4568
|
-
if (!isValid) {
|
|
4569
|
-
logWarningForInvalidCellValueType({
|
|
4570
|
-
columnId: String(columnId),
|
|
4571
|
-
editMode: "select",
|
|
4572
|
-
expectedType: "string | number | boolean",
|
|
4573
|
-
receivedType: Array.isArray(cellValue) ? "array" : typeof cellValue
|
|
4574
|
-
});
|
|
4575
|
-
}
|
|
4576
|
-
return [value, isValid];
|
|
4577
|
-
}, [cellValue, columnId]);
|
|
4578
|
-
const options = cell.column.columnDef.meta?.options ?? [];
|
|
4545
|
+
function useEditableMenuCell({
|
|
4546
|
+
cellPosition,
|
|
4547
|
+
onCellKeyDown,
|
|
4548
|
+
ref
|
|
4549
|
+
}) {
|
|
4579
4550
|
const [tabIndex, setTabIndex] = useState(-1);
|
|
4580
4551
|
const { moveFocusToCell } = useDTFocusDispatchContext();
|
|
4581
4552
|
const cellRef = useRef(null);
|
|
4582
|
-
const
|
|
4583
|
-
const menuElement = useRef(null);
|
|
4553
|
+
const triggerClickRef = useRef(null);
|
|
4584
4554
|
useImperativeHandle(ref, () => ({
|
|
4585
|
-
invoke:
|
|
4555
|
+
invoke: () => {
|
|
4556
|
+
triggerClickRef.current?.();
|
|
4557
|
+
},
|
|
4586
4558
|
focus: () => {
|
|
4587
4559
|
cellRef.current?.focus();
|
|
4588
4560
|
setTabIndex(0);
|
|
4589
4561
|
}
|
|
4590
4562
|
}));
|
|
4591
|
-
const beginEditing = useCallback(() => {
|
|
4592
|
-
setIsEditing(true);
|
|
4593
|
-
}, [setIsEditing]);
|
|
4594
|
-
const stopEditing = useCallback(() => {
|
|
4595
|
-
setIsEditing(false);
|
|
4596
|
-
}, [setIsEditing]);
|
|
4597
|
-
const onChange = getCellOnChange(cell);
|
|
4598
|
-
const commitValue = useCallback(
|
|
4599
|
-
(value) => {
|
|
4600
|
-
if (value !== initialValue) {
|
|
4601
|
-
onChange?.(value, rowId);
|
|
4602
|
-
}
|
|
4603
|
-
stopEditing();
|
|
4604
|
-
},
|
|
4605
|
-
[rowId, onChange, initialValue, stopEditing]
|
|
4606
|
-
);
|
|
4607
|
-
const cellClasses = cx(
|
|
4608
|
-
styles$a["data-table-body-cell-editable"],
|
|
4609
|
-
cellProps.className,
|
|
4610
|
-
{ [styles$9["data-table-body-cell-editing"]]: isEditing }
|
|
4611
|
-
);
|
|
4612
4563
|
const handleCellKeyDown = useCallback(
|
|
4613
|
-
(event,
|
|
4614
|
-
if (
|
|
4615
|
-
|
|
4616
|
-
stopEditing();
|
|
4617
|
-
return;
|
|
4618
|
-
}
|
|
4619
|
-
handleMenuKeydown?.(event);
|
|
4564
|
+
(event, menuKeyDown, isOpen) => {
|
|
4565
|
+
if (isOpen) {
|
|
4566
|
+
menuKeyDown?.(event);
|
|
4620
4567
|
return;
|
|
4621
4568
|
}
|
|
4622
4569
|
onCellKeyDown?.(event);
|
|
4623
4570
|
},
|
|
4624
|
-
[onCellKeyDown
|
|
4571
|
+
[onCellKeyDown]
|
|
4625
4572
|
);
|
|
4626
|
-
const
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
const handleCellMouseDown = useCallback(() => {
|
|
4631
|
-
if (isEditing) {
|
|
4632
|
-
stopEditing();
|
|
4633
|
-
return;
|
|
4573
|
+
const handleMenuKeyDown = useCallback((e) => {
|
|
4574
|
+
if (e.key === "F2") {
|
|
4575
|
+
e.preventDefault();
|
|
4576
|
+
triggerClickRef.current?.();
|
|
4634
4577
|
}
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
setTabIndex(-1);
|
|
4644
|
-
stopEditing();
|
|
4578
|
+
}, []);
|
|
4579
|
+
const handleImplicitClose = useCallback(() => {
|
|
4580
|
+
setTabIndex(-1);
|
|
4581
|
+
}, []);
|
|
4582
|
+
const handleCellMouseDown = useCallback(
|
|
4583
|
+
(triggerOnClick) => () => {
|
|
4584
|
+
moveFocusToCell(cellPosition);
|
|
4585
|
+
triggerOnClick();
|
|
4645
4586
|
},
|
|
4646
|
-
[
|
|
4587
|
+
[cellPosition, moveFocusToCell]
|
|
4647
4588
|
);
|
|
4589
|
+
const handleCellBlur = useCallback((e) => {
|
|
4590
|
+
const popoverId = e.currentTarget.getAttribute(
|
|
4591
|
+
"aria-controls"
|
|
4592
|
+
);
|
|
4593
|
+
const popoverEl = popoverId ? document.getElementById(popoverId) : null;
|
|
4594
|
+
if (popoverEl?.contains(e.relatedTarget)) {
|
|
4595
|
+
return;
|
|
4596
|
+
}
|
|
4597
|
+
setTabIndex(-1);
|
|
4598
|
+
}, []);
|
|
4648
4599
|
const handleCellFocus = useCallback(
|
|
4649
4600
|
(event) => {
|
|
4650
4601
|
if (event.target !== cellRef.current) {
|
|
@@ -4653,47 +4604,86 @@ function DataTableEditableSelectCellInner(props, ref) {
|
|
|
4653
4604
|
event.preventDefault();
|
|
4654
4605
|
setTabIndex(0);
|
|
4655
4606
|
},
|
|
4656
|
-
[
|
|
4657
|
-
);
|
|
4658
|
-
const handleMenuItemClick = useCallback(
|
|
4659
|
-
(value) => {
|
|
4660
|
-
commitValue(value);
|
|
4661
|
-
},
|
|
4662
|
-
[commitValue]
|
|
4663
|
-
);
|
|
4664
|
-
const handleMenuItemKeyDown = useCallback(
|
|
4665
|
-
(event) => {
|
|
4666
|
-
if (event.key === "Escape" || event.key === "F2") {
|
|
4667
|
-
cellRef.current?.focus();
|
|
4668
|
-
stopEditing();
|
|
4669
|
-
}
|
|
4670
|
-
},
|
|
4671
|
-
[stopEditing]
|
|
4607
|
+
[]
|
|
4672
4608
|
);
|
|
4673
4609
|
const cellFocusContextValue = useMemo(
|
|
4674
|
-
() => ({ isCellFocused: tabIndex === 0
|
|
4675
|
-
[tabIndex
|
|
4610
|
+
() => ({ isCellFocused: tabIndex === 0 }),
|
|
4611
|
+
[tabIndex]
|
|
4676
4612
|
);
|
|
4677
|
-
|
|
4613
|
+
return {
|
|
4614
|
+
tabIndex,
|
|
4615
|
+
cellRef,
|
|
4616
|
+
triggerClickRef,
|
|
4617
|
+
handleCellKeyDown,
|
|
4618
|
+
handleMenuKeyDown,
|
|
4619
|
+
handleImplicitClose,
|
|
4620
|
+
handleCellMouseDown,
|
|
4621
|
+
handleCellBlur,
|
|
4622
|
+
handleCellFocus,
|
|
4623
|
+
cellFocusContextValue
|
|
4624
|
+
};
|
|
4625
|
+
}
|
|
4626
|
+
|
|
4627
|
+
function DataTableEditableSelectCellInner(props, ref) {
|
|
4628
|
+
const { cell, cellProps, cellPosition, children } = props;
|
|
4629
|
+
const { onKeyDown: onCellKeyDown, className, ...restCellProps } = cellProps;
|
|
4630
|
+
getColumnId(cell);
|
|
4631
|
+
const cellValue = getCellValue(cell);
|
|
4632
|
+
const meta = cell.column.columnDef.meta;
|
|
4633
|
+
const editConfig = meta?.editConfig;
|
|
4634
|
+
const selectEditConfig = editConfig?.mode === "select" ? editConfig : void 0;
|
|
4635
|
+
const options = useMemo(
|
|
4636
|
+
() => selectEditConfig?.options ?? [],
|
|
4637
|
+
[selectEditConfig]
|
|
4638
|
+
);
|
|
4639
|
+
const onChange = selectEditConfig?.onChange;
|
|
4640
|
+
const {
|
|
4641
|
+
mode: _mode,
|
|
4642
|
+
options: _options,
|
|
4643
|
+
onChange: _onChange,
|
|
4644
|
+
...selectMenuPassthroughProps
|
|
4645
|
+
} = selectEditConfig ?? {};
|
|
4646
|
+
const isValidValueType = useMemo(() => {
|
|
4647
|
+
if (Array.isArray(cellValue)) return false;
|
|
4648
|
+
return true;
|
|
4649
|
+
}, [cellValue]);
|
|
4650
|
+
const rowId = cell.row.id;
|
|
4651
|
+
const {
|
|
4652
|
+
tabIndex,
|
|
4653
|
+
cellRef,
|
|
4654
|
+
triggerClickRef,
|
|
4655
|
+
handleCellKeyDown,
|
|
4656
|
+
handleMenuKeyDown,
|
|
4657
|
+
handleImplicitClose,
|
|
4658
|
+
handleCellMouseDown,
|
|
4659
|
+
handleCellBlur,
|
|
4660
|
+
handleCellFocus,
|
|
4661
|
+
cellFocusContextValue
|
|
4662
|
+
} = useEditableMenuCell({ cellPosition, onCellKeyDown, ref });
|
|
4663
|
+
const selectedOption = useMemo(() => {
|
|
4664
|
+
if (cellValue === void 0 || cellValue === null) return null;
|
|
4665
|
+
return options.find((o) => String(o.id) === String(cellValue)) ?? null;
|
|
4666
|
+
}, [options, cellValue]);
|
|
4667
|
+
const hasEditableConfig = !!selectEditConfig;
|
|
4668
|
+
if (!isValidValueType || !hasEditableConfig) {
|
|
4678
4669
|
const { cellProps: _cellProps, ...immutableCellProps } = props;
|
|
4679
4670
|
return /* @__PURE__ */ jsx(DataTableBodyImmutableCell, { ...immutableCellProps });
|
|
4680
4671
|
}
|
|
4681
4672
|
return /* @__PURE__ */ jsx(
|
|
4682
|
-
|
|
4673
|
+
SelectMenuSync,
|
|
4683
4674
|
{
|
|
4684
|
-
open: isEditing,
|
|
4685
|
-
onOutsidePress: handleOutsidePress,
|
|
4686
4675
|
trigger: ({
|
|
4687
4676
|
ref: triggerRef,
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4677
|
+
onClick,
|
|
4678
|
+
onKeyDown: menuKeyDown,
|
|
4679
|
+
"aria-controls": ariaControls,
|
|
4680
|
+
"aria-expanded": ariaExpanded,
|
|
4681
|
+
"aria-haspopup": ariaHaspopup,
|
|
4682
|
+
"data-state": dataState
|
|
4694
4683
|
}) => {
|
|
4695
|
-
|
|
4696
|
-
|
|
4684
|
+
triggerClickRef.current = onClick;
|
|
4685
|
+
const isOpen = ariaExpanded;
|
|
4686
|
+
return /* @__PURE__ */ jsxs(
|
|
4697
4687
|
TableBodyCell,
|
|
4698
4688
|
{
|
|
4699
4689
|
ref: mergeRefs([
|
|
@@ -4702,39 +4692,38 @@ function DataTableEditableSelectCellInner(props, ref) {
|
|
|
4702
4692
|
]),
|
|
4703
4693
|
tabIndex,
|
|
4704
4694
|
type: "data-table",
|
|
4705
|
-
...
|
|
4706
|
-
className:
|
|
4707
|
-
onMouseDown: handleCellMouseDown,
|
|
4695
|
+
...restCellProps,
|
|
4696
|
+
className: cx(styles$a["data-table-body-cell-editable"], className),
|
|
4697
|
+
onMouseDown: handleCellMouseDown(onClick),
|
|
4708
4698
|
onBlur: handleCellBlur,
|
|
4709
4699
|
onFocus: handleCellFocus,
|
|
4710
4700
|
"data-cell-pos": formatCellPositionString(cellPosition),
|
|
4711
|
-
"aria-controls":
|
|
4712
|
-
"aria-expanded":
|
|
4713
|
-
"aria-haspopup":
|
|
4714
|
-
"data-
|
|
4715
|
-
|
|
4716
|
-
onKeyDown: (e) => handleCellKeyDown(e, menuOnTriggerKeydown),
|
|
4701
|
+
"aria-controls": ariaControls,
|
|
4702
|
+
"aria-expanded": ariaExpanded,
|
|
4703
|
+
"aria-haspopup": ariaHaspopup,
|
|
4704
|
+
"data-state": dataState,
|
|
4705
|
+
onKeyDown: (e) => handleCellKeyDown(e, menuKeyDown, isOpen),
|
|
4717
4706
|
children: [
|
|
4718
4707
|
/* @__PURE__ */ jsxs(CellFocusContext.Provider, { value: cellFocusContextValue, children: [
|
|
4719
4708
|
children,
|
|
4720
|
-
!
|
|
4709
|
+
!isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
|
|
4721
4710
|
] }),
|
|
4722
|
-
/* @__PURE__ */ jsx(SrOnly, { children:
|
|
4711
|
+
/* @__PURE__ */ jsx(SrOnly, { children: isOpen ? "Press Enter or Space to select a cell value. Press Escape or F2 to cancel." : "Press Enter or F2 to edit cell value." })
|
|
4723
4712
|
]
|
|
4724
4713
|
}
|
|
4725
|
-
) });
|
|
4726
|
-
},
|
|
4727
|
-
children: isEditing && options.map((item) => {
|
|
4728
|
-
return /* @__PURE__ */ jsx(
|
|
4729
|
-
Menu.Item,
|
|
4730
|
-
{
|
|
4731
|
-
label: item.label,
|
|
4732
|
-
onClick: () => handleMenuItemClick(item.value),
|
|
4733
|
-
onKeyDown: handleMenuItemKeyDown
|
|
4734
|
-
},
|
|
4735
|
-
item.value
|
|
4736
4714
|
);
|
|
4737
|
-
}
|
|
4715
|
+
},
|
|
4716
|
+
label: String(
|
|
4717
|
+
cell.column.columnDef.meta?.columnDef?.headerLabel ?? "Select"
|
|
4718
|
+
),
|
|
4719
|
+
options,
|
|
4720
|
+
value: selectedOption,
|
|
4721
|
+
onSelectedOptionChange: (option) => {
|
|
4722
|
+
onChange?.(option, rowId);
|
|
4723
|
+
},
|
|
4724
|
+
onMenuKeyDown: handleMenuKeyDown,
|
|
4725
|
+
onImplicitClose: handleImplicitClose,
|
|
4726
|
+
...selectMenuPassthroughProps
|
|
4738
4727
|
}
|
|
4739
4728
|
);
|
|
4740
4729
|
}
|
|
@@ -4743,287 +4732,425 @@ const DataTableEditableSelectCell = Object.assign(
|
|
|
4743
4732
|
{ displayName: "DataTableEditableSelectCell" }
|
|
4744
4733
|
);
|
|
4745
4734
|
|
|
4746
|
-
function
|
|
4735
|
+
function DataTableEditableSelectAsyncCellInner(props, ref) {
|
|
4747
4736
|
const { cell, cellProps, cellPosition, children } = props;
|
|
4748
|
-
const { onKeyDown: onCellKeyDown } = cellProps;
|
|
4749
|
-
|
|
4750
|
-
const columnId = getColumnId(cell);
|
|
4737
|
+
const { onKeyDown: onCellKeyDown, className, ...restCellProps } = cellProps;
|
|
4738
|
+
getColumnId(cell);
|
|
4751
4739
|
const cellValue = getCellValue(cell);
|
|
4752
|
-
const
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
if (cellValue
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
} else if (Array.isArray(cellValue)) {
|
|
4759
|
-
value = cellValue.map((v) => String(v));
|
|
4760
|
-
isValid = true;
|
|
4761
|
-
return [value, isValid];
|
|
4762
|
-
} else {
|
|
4763
|
-
value = [];
|
|
4764
|
-
isValid = false;
|
|
4765
|
-
logWarningForInvalidCellValueType({
|
|
4766
|
-
columnId: String(columnId),
|
|
4767
|
-
editMode: "multiselect",
|
|
4768
|
-
expectedType: "array of primitive values",
|
|
4769
|
-
receivedType: typeof cellValue
|
|
4770
|
-
});
|
|
4771
|
-
return [value, isValid];
|
|
4772
|
-
}
|
|
4773
|
-
}, [cellValue, columnId]);
|
|
4774
|
-
const options = useMemo(
|
|
4775
|
-
() => cell.column.columnDef.meta?.options ?? [],
|
|
4776
|
-
[cell.column.columnDef.meta?.options]
|
|
4777
|
-
);
|
|
4778
|
-
const [tabIndex, setTabIndex] = useState(-1);
|
|
4779
|
-
const { moveFocusToCell } = useDTFocusDispatchContext();
|
|
4780
|
-
const cellRef = useRef(null);
|
|
4740
|
+
const editConfig = cell.column.columnDef.meta?.editConfig;
|
|
4741
|
+
const asyncEditConfig = editConfig?.mode === "select-async" ? editConfig : void 0;
|
|
4742
|
+
const isValidValueType = useMemo(() => {
|
|
4743
|
+
if (Array.isArray(cellValue)) return false;
|
|
4744
|
+
return true;
|
|
4745
|
+
}, [cellValue]);
|
|
4781
4746
|
const rowId = cell.row.id;
|
|
4782
|
-
const
|
|
4783
|
-
const
|
|
4784
|
-
const
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
const arraysEqual = draftValue.length === initialValue.length && draftValue.every((val, idx) => val === initialValue[idx]);
|
|
4805
|
-
if (!arraysEqual) {
|
|
4806
|
-
onChange?.(draftValue, rowId);
|
|
4807
|
-
}
|
|
4808
|
-
stopEditing();
|
|
4809
|
-
}, [rowId, onChange, initialValue, stopEditing, draftValue]);
|
|
4810
|
-
const cellClasses = cx(styles$a["data-table-body-cell-editable"], className, {
|
|
4811
|
-
[styles$9["data-table-body-cell-editing"]]: isEditing
|
|
4812
|
-
});
|
|
4813
|
-
const resetValue = useCallback(() => {
|
|
4814
|
-
setDraftValue(initialValue);
|
|
4815
|
-
setSearchValue("");
|
|
4816
|
-
stopEditing();
|
|
4817
|
-
}, [initialValue, stopEditing]);
|
|
4818
|
-
const handleCellKeyDown = useCallback(
|
|
4819
|
-
(event, handlePopoverKeydown) => {
|
|
4820
|
-
if (isEditing) {
|
|
4821
|
-
if (event.key === "Escape" || event.key === "F2") {
|
|
4822
|
-
stopEditing();
|
|
4823
|
-
return;
|
|
4824
|
-
}
|
|
4825
|
-
handlePopoverKeydown?.(event);
|
|
4826
|
-
return;
|
|
4747
|
+
const row = cell.row.original;
|
|
4748
|
+
const context = useMemo(() => ({ row, rowId }), [row, rowId]);
|
|
4749
|
+
const {
|
|
4750
|
+
mode: _mode,
|
|
4751
|
+
lazy,
|
|
4752
|
+
lazyOptions,
|
|
4753
|
+
loadOptions: cellLoader,
|
|
4754
|
+
onChange,
|
|
4755
|
+
cache: cacheProp,
|
|
4756
|
+
...passthroughProps
|
|
4757
|
+
} = asyncEditConfig ?? {};
|
|
4758
|
+
const loadOptions = useCallback(
|
|
4759
|
+
(searchValue, ...rest) => {
|
|
4760
|
+
if (!cellLoader) return [];
|
|
4761
|
+
if (lazy === "page") {
|
|
4762
|
+
const [pageNumber, pageSize] = rest;
|
|
4763
|
+
return cellLoader(
|
|
4764
|
+
searchValue,
|
|
4765
|
+
pageNumber,
|
|
4766
|
+
pageSize,
|
|
4767
|
+
context
|
|
4768
|
+
);
|
|
4827
4769
|
}
|
|
4828
|
-
|
|
4770
|
+
if (lazy === "offset") {
|
|
4771
|
+
const [offset, limit] = rest;
|
|
4772
|
+
return cellLoader(
|
|
4773
|
+
searchValue,
|
|
4774
|
+
offset,
|
|
4775
|
+
limit,
|
|
4776
|
+
context
|
|
4777
|
+
);
|
|
4778
|
+
}
|
|
4779
|
+
if (lazy === "group") {
|
|
4780
|
+
const [previousGroupKey] = rest;
|
|
4781
|
+
return cellLoader(
|
|
4782
|
+
searchValue,
|
|
4783
|
+
previousGroupKey,
|
|
4784
|
+
context
|
|
4785
|
+
);
|
|
4786
|
+
}
|
|
4787
|
+
return cellLoader(
|
|
4788
|
+
searchValue,
|
|
4789
|
+
context
|
|
4790
|
+
);
|
|
4829
4791
|
},
|
|
4830
|
-
[
|
|
4792
|
+
[cellLoader, context, lazy]
|
|
4831
4793
|
);
|
|
4832
|
-
const
|
|
4833
|
-
|
|
4834
|
-
|
|
4794
|
+
const cache = cacheProp ?? { enabled: false };
|
|
4795
|
+
const {
|
|
4796
|
+
tabIndex,
|
|
4797
|
+
cellRef,
|
|
4798
|
+
triggerClickRef,
|
|
4799
|
+
handleCellKeyDown,
|
|
4800
|
+
handleMenuKeyDown,
|
|
4801
|
+
handleImplicitClose,
|
|
4802
|
+
handleCellMouseDown,
|
|
4803
|
+
handleCellBlur,
|
|
4804
|
+
handleCellFocus,
|
|
4805
|
+
cellFocusContextValue
|
|
4806
|
+
} = useEditableMenuCell({ cellPosition, onCellKeyDown, ref });
|
|
4807
|
+
const selectedOption = useMemo(() => {
|
|
4808
|
+
if (cellValue === void 0 || cellValue === null) return null;
|
|
4809
|
+
if (typeof cellValue === "object") return null;
|
|
4810
|
+
return { id: cellValue, label: String(cellValue) };
|
|
4811
|
+
}, [cellValue]);
|
|
4812
|
+
if (!isValidValueType || !asyncEditConfig) {
|
|
4813
|
+
const { cellProps: _cellProps, ...immutableCellProps } = props;
|
|
4814
|
+
return /* @__PURE__ */ jsx(DataTableBodyImmutableCell, { ...immutableCellProps });
|
|
4815
|
+
}
|
|
4816
|
+
return /* @__PURE__ */ jsx(
|
|
4817
|
+
SelectMenu,
|
|
4818
|
+
{
|
|
4819
|
+
lazy,
|
|
4820
|
+
loadOptions,
|
|
4821
|
+
lazyOptions,
|
|
4822
|
+
cache,
|
|
4823
|
+
...passthroughProps,
|
|
4824
|
+
trigger: ({
|
|
4825
|
+
ref: triggerRef,
|
|
4826
|
+
onClick,
|
|
4827
|
+
onKeyDown: menuKeyDown,
|
|
4828
|
+
"aria-controls": ariaControls,
|
|
4829
|
+
"aria-expanded": ariaExpanded,
|
|
4830
|
+
"aria-haspopup": ariaHaspopup,
|
|
4831
|
+
"data-state": dataState
|
|
4832
|
+
}) => {
|
|
4833
|
+
triggerClickRef.current = onClick;
|
|
4834
|
+
const isOpen = ariaExpanded;
|
|
4835
|
+
return /* @__PURE__ */ jsxs(
|
|
4836
|
+
TableBodyCell,
|
|
4837
|
+
{
|
|
4838
|
+
ref: mergeRefs([
|
|
4839
|
+
triggerRef,
|
|
4840
|
+
cellRef
|
|
4841
|
+
]),
|
|
4842
|
+
tabIndex,
|
|
4843
|
+
type: "data-table",
|
|
4844
|
+
...restCellProps,
|
|
4845
|
+
className: cx(styles$a["data-table-body-cell-editable"], className),
|
|
4846
|
+
onMouseDown: handleCellMouseDown(onClick),
|
|
4847
|
+
onBlur: handleCellBlur,
|
|
4848
|
+
onFocus: handleCellFocus,
|
|
4849
|
+
"data-cell-pos": formatCellPositionString(cellPosition),
|
|
4850
|
+
"aria-controls": ariaControls,
|
|
4851
|
+
"aria-expanded": ariaExpanded,
|
|
4852
|
+
"aria-haspopup": ariaHaspopup,
|
|
4853
|
+
"data-state": dataState,
|
|
4854
|
+
onKeyDown: (e) => handleCellKeyDown(e, menuKeyDown, isOpen),
|
|
4855
|
+
children: [
|
|
4856
|
+
/* @__PURE__ */ jsxs(CellFocusContext.Provider, { value: cellFocusContextValue, children: [
|
|
4857
|
+
children,
|
|
4858
|
+
!isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
|
|
4859
|
+
] }),
|
|
4860
|
+
/* @__PURE__ */ jsx(SrOnly, { children: isOpen ? "Press Enter or Space to select a cell value. Press Escape or F2 to cancel." : "Press Enter or F2 to edit cell value." })
|
|
4861
|
+
]
|
|
4862
|
+
}
|
|
4863
|
+
);
|
|
4864
|
+
},
|
|
4865
|
+
label: String(
|
|
4866
|
+
cell.column.columnDef.meta?.columnDef?.headerLabel ?? "Select"
|
|
4867
|
+
),
|
|
4868
|
+
value: selectedOption,
|
|
4869
|
+
onSelectedOptionChange: (option) => {
|
|
4870
|
+
onChange?.(option, rowId);
|
|
4871
|
+
},
|
|
4872
|
+
onMenuKeyDown: handleMenuKeyDown,
|
|
4873
|
+
onImplicitClose: handleImplicitClose
|
|
4835
4874
|
}
|
|
4836
|
-
moveFocusToCell(cellPosition);
|
|
4837
|
-
beginEditing();
|
|
4838
|
-
}, [beginEditing, cellPosition, moveFocusToCell, isEditing]);
|
|
4839
|
-
const handleCellBlur = useCallback(
|
|
4840
|
-
(e) => {
|
|
4841
|
-
if (popoverElement.current?.contains(e.relatedTarget)) {
|
|
4842
|
-
return;
|
|
4843
|
-
}
|
|
4844
|
-
setTabIndex(-1);
|
|
4845
|
-
stopEditing();
|
|
4846
|
-
},
|
|
4847
|
-
[stopEditing]
|
|
4848
4875
|
);
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4876
|
+
}
|
|
4877
|
+
const DataTableEditableSelectAsyncCell = Object.assign(
|
|
4878
|
+
forwardRef(DataTableEditableSelectAsyncCellInner),
|
|
4879
|
+
{ displayName: "DataTableEditableSelectAsyncCell" }
|
|
4880
|
+
);
|
|
4881
|
+
|
|
4882
|
+
function DataTableEditableMultiselectCellInner(props, ref) {
|
|
4883
|
+
const { cell, cellProps, cellPosition, children } = props;
|
|
4884
|
+
const { onKeyDown: onCellKeyDown, className, ...restCellProps } = cellProps;
|
|
4885
|
+
const columnId = getColumnId(cell);
|
|
4886
|
+
const cellValue = getCellValue(cell);
|
|
4887
|
+
const isValidValueType = useMemo(() => {
|
|
4888
|
+
if (cellValue === null || cellValue === void 0) return true;
|
|
4889
|
+
if (Array.isArray(cellValue)) return true;
|
|
4890
|
+
logWarningForInvalidCellValueType({
|
|
4891
|
+
columnId: String(columnId),
|
|
4892
|
+
editMode: "multiselect",
|
|
4893
|
+
expectedType: "array of primitive values",
|
|
4894
|
+
receivedType: typeof cellValue
|
|
4895
|
+
});
|
|
4896
|
+
return false;
|
|
4897
|
+
}, [cellValue, columnId]);
|
|
4898
|
+
const meta = cell.column.columnDef.meta;
|
|
4899
|
+
const editConfig = meta?.editConfig;
|
|
4900
|
+
const multiselectEditConfig = editConfig?.mode === "multiselect" ? editConfig : void 0;
|
|
4901
|
+
const options = useMemo(
|
|
4902
|
+
() => multiselectEditConfig?.options ?? [],
|
|
4903
|
+
[multiselectEditConfig]
|
|
4858
4904
|
);
|
|
4859
|
-
const
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4905
|
+
const onChange = multiselectEditConfig?.onChange;
|
|
4906
|
+
const {
|
|
4907
|
+
mode: _mode,
|
|
4908
|
+
options: _options,
|
|
4909
|
+
onChange: _onChange,
|
|
4910
|
+
...multiSelectMenuPassthroughProps
|
|
4911
|
+
} = multiselectEditConfig ?? {};
|
|
4912
|
+
const rowId = cell.row.id;
|
|
4913
|
+
const {
|
|
4914
|
+
tabIndex,
|
|
4915
|
+
cellRef,
|
|
4916
|
+
triggerClickRef,
|
|
4917
|
+
handleCellKeyDown,
|
|
4918
|
+
handleMenuKeyDown,
|
|
4919
|
+
handleImplicitClose,
|
|
4920
|
+
handleCellMouseDown,
|
|
4921
|
+
handleCellBlur,
|
|
4922
|
+
handleCellFocus,
|
|
4923
|
+
cellFocusContextValue
|
|
4924
|
+
} = useEditableMenuCell({ cellPosition, onCellKeyDown, ref });
|
|
4925
|
+
const selectedOptions = useMemo(() => {
|
|
4926
|
+
if (!Array.isArray(cellValue)) return [];
|
|
4927
|
+
const valueStrings = cellValue.map((v) => String(v));
|
|
4928
|
+
return options.filter((o) => valueStrings.includes(String(o.id)));
|
|
4929
|
+
}, [options, cellValue]);
|
|
4930
|
+
const hasEditableConfig = !!multiselectEditConfig;
|
|
4931
|
+
if (!isValidValueType || !hasEditableConfig) {
|
|
4932
|
+
const { cellProps: _cellProps, ...immutableCellProps } = props;
|
|
4933
|
+
return /* @__PURE__ */ jsx(DataTableBodyImmutableCell, { ...immutableCellProps });
|
|
4934
|
+
}
|
|
4935
|
+
return /* @__PURE__ */ jsx(
|
|
4936
|
+
MultiSelectMenuSync,
|
|
4937
|
+
{
|
|
4938
|
+
trigger: ({
|
|
4939
|
+
ref: triggerRef,
|
|
4940
|
+
onClick,
|
|
4941
|
+
onKeyDown: menuKeyDown,
|
|
4942
|
+
"aria-controls": ariaControls,
|
|
4943
|
+
"aria-expanded": ariaExpanded,
|
|
4944
|
+
"aria-haspopup": ariaHaspopup,
|
|
4945
|
+
"data-state": dataState
|
|
4946
|
+
}) => {
|
|
4947
|
+
triggerClickRef.current = onClick;
|
|
4948
|
+
const isOpen = ariaExpanded;
|
|
4949
|
+
return /* @__PURE__ */ jsxs(
|
|
4950
|
+
TableBodyCell,
|
|
4951
|
+
{
|
|
4952
|
+
ref: mergeRefs([
|
|
4953
|
+
triggerRef,
|
|
4954
|
+
cellRef
|
|
4955
|
+
]),
|
|
4956
|
+
tabIndex,
|
|
4957
|
+
type: "data-table",
|
|
4958
|
+
...restCellProps,
|
|
4959
|
+
className: cx(styles$a["data-table-body-cell-editable"], className),
|
|
4960
|
+
onMouseDown: handleCellMouseDown(onClick),
|
|
4961
|
+
onBlur: handleCellBlur,
|
|
4962
|
+
onFocus: handleCellFocus,
|
|
4963
|
+
"data-cell-pos": formatCellPositionString(cellPosition),
|
|
4964
|
+
"aria-controls": ariaControls,
|
|
4965
|
+
"aria-expanded": ariaExpanded,
|
|
4966
|
+
"aria-haspopup": ariaHaspopup,
|
|
4967
|
+
"data-state": dataState,
|
|
4968
|
+
onKeyDown: (e) => handleCellKeyDown(e, menuKeyDown, isOpen),
|
|
4969
|
+
children: [
|
|
4970
|
+
/* @__PURE__ */ jsxs(CellFocusContext.Provider, { value: cellFocusContextValue, children: [
|
|
4971
|
+
children,
|
|
4972
|
+
!isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
|
|
4973
|
+
] }),
|
|
4974
|
+
/* @__PURE__ */ jsx(SrOnly, { children: isOpen ? "Press Enter or Space to select cell values. Press Escape or F2 to close." : "Press Enter or F2 to edit cell value." })
|
|
4975
|
+
]
|
|
4976
|
+
}
|
|
4977
|
+
);
|
|
4978
|
+
},
|
|
4979
|
+
label: String(
|
|
4980
|
+
cell.column.columnDef.meta?.columnDef?.headerLabel ?? "Select"
|
|
4981
|
+
),
|
|
4982
|
+
options,
|
|
4983
|
+
value: selectedOptions,
|
|
4984
|
+
onSelectedOptionsChange: (selected) => {
|
|
4985
|
+
onChange?.(selected, rowId);
|
|
4986
|
+
},
|
|
4987
|
+
onMenuKeyDown: handleMenuKeyDown,
|
|
4988
|
+
onImplicitClose: handleImplicitClose,
|
|
4989
|
+
...multiSelectMenuPassthroughProps
|
|
4990
|
+
}
|
|
4878
4991
|
);
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4992
|
+
}
|
|
4993
|
+
const DataTableEditableMultiselectCell = Object.assign(
|
|
4994
|
+
forwardRef(DataTableEditableMultiselectCellInner),
|
|
4995
|
+
{ displayName: "DataTableEditableMultiselectCell" }
|
|
4996
|
+
);
|
|
4997
|
+
|
|
4998
|
+
function DataTableEditableMultiselectAsyncCellInner(props, ref) {
|
|
4999
|
+
const { cell, cellProps, cellPosition, children } = props;
|
|
5000
|
+
const { onKeyDown: onCellKeyDown, className, ...restCellProps } = cellProps;
|
|
5001
|
+
getColumnId(cell);
|
|
5002
|
+
const cellValue = getCellValue(cell);
|
|
5003
|
+
const editConfig = cell.column.columnDef.meta?.editConfig;
|
|
5004
|
+
const asyncEditConfig = editConfig?.mode === "multiselect-async" ? editConfig : void 0;
|
|
5005
|
+
const isValidValueType = useMemo(() => {
|
|
5006
|
+
if (cellValue === null || cellValue === void 0) return true;
|
|
5007
|
+
if (Array.isArray(cellValue)) return true;
|
|
5008
|
+
return false;
|
|
5009
|
+
}, [cellValue]);
|
|
5010
|
+
const rowId = cell.row.id;
|
|
5011
|
+
const row = cell.row.original;
|
|
5012
|
+
const context = useMemo(() => ({ row, rowId }), [row, rowId]);
|
|
5013
|
+
const {
|
|
5014
|
+
mode: _mode,
|
|
5015
|
+
lazy,
|
|
5016
|
+
lazyOptions,
|
|
5017
|
+
loadOptions: cellLoader,
|
|
5018
|
+
onChange,
|
|
5019
|
+
cache: cacheProp,
|
|
5020
|
+
...passthroughProps
|
|
5021
|
+
} = asyncEditConfig ?? {};
|
|
5022
|
+
const loadOptions = useCallback(
|
|
5023
|
+
(searchValue, ...rest) => {
|
|
5024
|
+
if (!cellLoader) return [];
|
|
5025
|
+
if (lazy === "page") {
|
|
5026
|
+
const [pageNumber, pageSize] = rest;
|
|
5027
|
+
return cellLoader(
|
|
5028
|
+
searchValue,
|
|
5029
|
+
pageNumber,
|
|
5030
|
+
pageSize,
|
|
5031
|
+
context
|
|
5032
|
+
);
|
|
4890
5033
|
}
|
|
4891
|
-
if (
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
5034
|
+
if (lazy === "offset") {
|
|
5035
|
+
const [offset, limit] = rest;
|
|
5036
|
+
return cellLoader(
|
|
5037
|
+
searchValue,
|
|
5038
|
+
offset,
|
|
5039
|
+
limit,
|
|
5040
|
+
context
|
|
5041
|
+
);
|
|
4895
5042
|
}
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
setDraftValue(selectedItems2.map((item) => String(item.value)));
|
|
5043
|
+
if (lazy === "group") {
|
|
5044
|
+
const [previousGroupKey] = rest;
|
|
5045
|
+
return cellLoader(
|
|
5046
|
+
searchValue,
|
|
5047
|
+
previousGroupKey,
|
|
5048
|
+
context
|
|
5049
|
+
);
|
|
4904
5050
|
}
|
|
5051
|
+
return cellLoader(
|
|
5052
|
+
searchValue,
|
|
5053
|
+
context
|
|
5054
|
+
);
|
|
4905
5055
|
},
|
|
4906
|
-
[
|
|
4907
|
-
);
|
|
4908
|
-
const filteredItems = useMemo(() => {
|
|
4909
|
-
if (searchValue === "") return options;
|
|
4910
|
-
return options.filter(
|
|
4911
|
-
(item) => item.label.toLowerCase().includes(searchValue.toLowerCase())
|
|
4912
|
-
);
|
|
4913
|
-
}, [options, searchValue]);
|
|
4914
|
-
const selectedItems = useMemo(() => {
|
|
4915
|
-
return options.filter(
|
|
4916
|
-
(item) => typeof item.value === "string" && draftValue.includes(item.value)
|
|
4917
|
-
);
|
|
4918
|
-
}, [options, draftValue]);
|
|
4919
|
-
const handleOnClickOutside = useCallback(() => {
|
|
4920
|
-
cellRef.current?.focus();
|
|
4921
|
-
if (isEditing) {
|
|
4922
|
-
commitValue();
|
|
4923
|
-
}
|
|
4924
|
-
}, [commitValue, isEditing]);
|
|
4925
|
-
const handleOpenAnimationComplete = useCallback(() => {
|
|
4926
|
-
if (isEditing) {
|
|
4927
|
-
searchFieldRef.current?.focus();
|
|
4928
|
-
}
|
|
4929
|
-
}, [isEditing]);
|
|
4930
|
-
const handleSearchFieldChange = useCallback(
|
|
4931
|
-
(e) => {
|
|
4932
|
-
setSearchValue(e.target.value);
|
|
4933
|
-
},
|
|
4934
|
-
[]
|
|
4935
|
-
);
|
|
4936
|
-
const cellFocusContextValue = useMemo(
|
|
4937
|
-
() => ({ isCellFocused: tabIndex === 0 && !isEditing }),
|
|
4938
|
-
[tabIndex, isEditing]
|
|
5056
|
+
[cellLoader, context, lazy]
|
|
4939
5057
|
);
|
|
4940
|
-
|
|
5058
|
+
const cache = cacheProp ?? { enabled: false };
|
|
5059
|
+
const {
|
|
5060
|
+
tabIndex,
|
|
5061
|
+
cellRef,
|
|
5062
|
+
triggerClickRef,
|
|
5063
|
+
handleCellKeyDown,
|
|
5064
|
+
handleMenuKeyDown,
|
|
5065
|
+
handleImplicitClose,
|
|
5066
|
+
handleCellMouseDown,
|
|
5067
|
+
handleCellBlur,
|
|
5068
|
+
handleCellFocus,
|
|
5069
|
+
cellFocusContextValue
|
|
5070
|
+
} = useEditableMenuCell({ cellPosition, onCellKeyDown, ref });
|
|
5071
|
+
const selectedOptions = useMemo(() => {
|
|
5072
|
+
if (!Array.isArray(cellValue)) return [];
|
|
5073
|
+
return cellValue;
|
|
5074
|
+
}, [cellValue]);
|
|
5075
|
+
if (!isValidValueType || !asyncEditConfig) {
|
|
4941
5076
|
const { cellProps: _cellProps, ...immutableCellProps } = props;
|
|
4942
5077
|
return /* @__PURE__ */ jsx(DataTableBodyImmutableCell, { ...immutableCellProps });
|
|
4943
5078
|
}
|
|
4944
|
-
return /* @__PURE__ */
|
|
4945
|
-
|
|
5079
|
+
return /* @__PURE__ */ jsx(
|
|
5080
|
+
MultiSelectMenu,
|
|
4946
5081
|
{
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
selected: selectedItems,
|
|
5003
|
-
onKeyDown: handleListViewKeyDown,
|
|
5004
|
-
items: filteredItems,
|
|
5005
|
-
onSelectionChange: handleListViewSelectionChange,
|
|
5006
|
-
ref: listViewRef,
|
|
5007
|
-
children: ({ items }) => items.map((item) => /* @__PURE__ */ jsx(ListView.Option, { item, children: item.label }, item.label))
|
|
5008
|
-
}
|
|
5009
|
-
)
|
|
5010
|
-
] }) })
|
|
5011
|
-
]
|
|
5082
|
+
lazy,
|
|
5083
|
+
loadOptions,
|
|
5084
|
+
lazyOptions,
|
|
5085
|
+
cache,
|
|
5086
|
+
...passthroughProps,
|
|
5087
|
+
trigger: ({
|
|
5088
|
+
ref: triggerRef,
|
|
5089
|
+
onClick,
|
|
5090
|
+
onKeyDown: menuKeyDown,
|
|
5091
|
+
"aria-controls": ariaControls,
|
|
5092
|
+
"aria-expanded": ariaExpanded,
|
|
5093
|
+
"aria-haspopup": ariaHaspopup,
|
|
5094
|
+
"data-state": dataState
|
|
5095
|
+
}) => {
|
|
5096
|
+
triggerClickRef.current = onClick;
|
|
5097
|
+
const isOpen = ariaExpanded;
|
|
5098
|
+
return /* @__PURE__ */ jsxs(
|
|
5099
|
+
TableBodyCell,
|
|
5100
|
+
{
|
|
5101
|
+
ref: mergeRefs([
|
|
5102
|
+
triggerRef,
|
|
5103
|
+
cellRef
|
|
5104
|
+
]),
|
|
5105
|
+
tabIndex,
|
|
5106
|
+
type: "data-table",
|
|
5107
|
+
...restCellProps,
|
|
5108
|
+
className: cx(styles$a["data-table-body-cell-editable"], className),
|
|
5109
|
+
onMouseDown: handleCellMouseDown(onClick),
|
|
5110
|
+
onBlur: handleCellBlur,
|
|
5111
|
+
onFocus: handleCellFocus,
|
|
5112
|
+
"data-cell-pos": formatCellPositionString(cellPosition),
|
|
5113
|
+
"aria-controls": ariaControls,
|
|
5114
|
+
"aria-expanded": ariaExpanded,
|
|
5115
|
+
"aria-haspopup": ariaHaspopup,
|
|
5116
|
+
"data-state": dataState,
|
|
5117
|
+
onKeyDown: (e) => handleCellKeyDown(e, menuKeyDown, isOpen),
|
|
5118
|
+
children: [
|
|
5119
|
+
/* @__PURE__ */ jsxs(CellFocusContext.Provider, { value: cellFocusContextValue, children: [
|
|
5120
|
+
children,
|
|
5121
|
+
!isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
|
|
5122
|
+
] }),
|
|
5123
|
+
/* @__PURE__ */ jsx(SrOnly, { children: isOpen ? "Press Enter or Space to select cell values. Press Escape or F2 to close." : "Press Enter or F2 to edit cell value." })
|
|
5124
|
+
]
|
|
5125
|
+
}
|
|
5126
|
+
);
|
|
5127
|
+
},
|
|
5128
|
+
label: String(
|
|
5129
|
+
cell.column.columnDef.meta?.columnDef?.headerLabel ?? "Select"
|
|
5130
|
+
),
|
|
5131
|
+
value: selectedOptions,
|
|
5132
|
+
onSelectedOptionsChange: (selected) => {
|
|
5133
|
+
onChange?.(selected, rowId);
|
|
5134
|
+
},
|
|
5135
|
+
onMenuKeyDown: handleMenuKeyDown,
|
|
5136
|
+
onImplicitClose: handleImplicitClose
|
|
5012
5137
|
}
|
|
5013
5138
|
);
|
|
5014
5139
|
}
|
|
5015
|
-
const
|
|
5016
|
-
forwardRef(
|
|
5017
|
-
{ displayName: "
|
|
5140
|
+
const DataTableEditableMultiselectAsyncCell = Object.assign(
|
|
5141
|
+
forwardRef(DataTableEditableMultiselectAsyncCellInner),
|
|
5142
|
+
{ displayName: "DataTableEditableMultiselectAsyncCell" }
|
|
5018
5143
|
);
|
|
5019
5144
|
|
|
5020
5145
|
function DataTableEditableBooleanCellInner(props, ref) {
|
|
5021
5146
|
const { cell, cellProps, cellPosition, children } = props;
|
|
5022
|
-
const { onKeyDown: onCellKeyDown } = cellProps;
|
|
5023
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
5147
|
+
const { onKeyDown: onCellKeyDown, className, ...restCellProps } = cellProps;
|
|
5024
5148
|
const columnId = getColumnId(cell);
|
|
5025
5149
|
const cellValue = getCellValue(cell);
|
|
5026
|
-
const
|
|
5150
|
+
const meta = cell.column.columnDef.meta;
|
|
5151
|
+
const editConfig = meta?.editConfig;
|
|
5152
|
+
const booleanEditConfig = editConfig?.mode === "boolean" ? editConfig : void 0;
|
|
5153
|
+
const [, isValidValueType] = useMemo(() => {
|
|
5027
5154
|
let value;
|
|
5028
5155
|
let isValid = true;
|
|
5029
5156
|
if (cellValue === void 0 || cellValue === null) {
|
|
@@ -5048,8 +5175,7 @@ function DataTableEditableBooleanCellInner(props, ref) {
|
|
|
5048
5175
|
return [value, isValid];
|
|
5049
5176
|
}, [cellValue, columnId]);
|
|
5050
5177
|
const options = useMemo(() => {
|
|
5051
|
-
const
|
|
5052
|
-
const config = editConfig?.mode === "boolean" ? editConfig : {
|
|
5178
|
+
const config = booleanEditConfig?.mode === "boolean" ? booleanEditConfig : {
|
|
5053
5179
|
trueLabel: void 0,
|
|
5054
5180
|
falseLabel: void 0,
|
|
5055
5181
|
allowNull: false,
|
|
@@ -5059,140 +5185,57 @@ function DataTableEditableBooleanCellInner(props, ref) {
|
|
|
5059
5185
|
const typeOptions = typeof typeConfig === "object" && typeConfig.type === "boolean" ? typeConfig.options : void 0;
|
|
5060
5186
|
const items = [
|
|
5061
5187
|
{
|
|
5062
|
-
|
|
5188
|
+
id: "true",
|
|
5063
5189
|
label: config.trueLabel ?? typeOptions?.trueLabel ?? "True"
|
|
5064
5190
|
},
|
|
5065
5191
|
{
|
|
5066
|
-
|
|
5192
|
+
id: "false",
|
|
5067
5193
|
label: config.falseLabel ?? typeOptions?.falseLabel ?? "False"
|
|
5068
5194
|
}
|
|
5069
5195
|
];
|
|
5070
5196
|
if (config.allowNull) {
|
|
5071
|
-
items.push({
|
|
5197
|
+
items.push({ id: "null", label: config.nullLabel ?? "Unset" });
|
|
5072
5198
|
}
|
|
5073
5199
|
return items;
|
|
5074
|
-
}, [
|
|
5075
|
-
cell.column.columnDef.meta?.editConfig,
|
|
5076
|
-
cell.column.columnDef.meta?.columnDef?.type
|
|
5077
|
-
]);
|
|
5078
|
-
const [tabIndex, setTabIndex] = useState(-1);
|
|
5079
|
-
const { moveFocusToCell } = useDTFocusDispatchContext();
|
|
5080
|
-
const cellRef = useRef(null);
|
|
5200
|
+
}, [booleanEditConfig, cell.column.columnDef.meta?.columnDef?.type]);
|
|
5081
5201
|
const rowId = cell.row.id;
|
|
5082
|
-
const
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
},
|
|
5096
|
-
const
|
|
5097
|
-
|
|
5098
|
-
(
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
}
|
|
5102
|
-
stopEditing();
|
|
5103
|
-
},
|
|
5104
|
-
[rowId, onChange, initialValue, stopEditing]
|
|
5105
|
-
);
|
|
5106
|
-
const cellClasses = cx(
|
|
5107
|
-
styles$a["data-table-body-cell-editable"],
|
|
5108
|
-
cellProps.className,
|
|
5109
|
-
{ [styles$9["data-table-body-cell-editing"]]: isEditing }
|
|
5110
|
-
);
|
|
5111
|
-
const handleCellKeyDown = useCallback(
|
|
5112
|
-
(event, handleMenuKeydown) => {
|
|
5113
|
-
if (isEditing) {
|
|
5114
|
-
if (event.key === "Escape" || event.key === "F2") {
|
|
5115
|
-
stopEditing();
|
|
5116
|
-
return;
|
|
5117
|
-
}
|
|
5118
|
-
handleMenuKeydown?.(event);
|
|
5119
|
-
return;
|
|
5120
|
-
}
|
|
5121
|
-
onCellKeyDown?.(event);
|
|
5122
|
-
},
|
|
5123
|
-
[onCellKeyDown, isEditing, stopEditing]
|
|
5124
|
-
);
|
|
5125
|
-
const handleOutsidePress = useCallback(() => {
|
|
5126
|
-
stopEditing();
|
|
5127
|
-
setTabIndex(-1);
|
|
5128
|
-
}, [stopEditing]);
|
|
5129
|
-
const handleCellMouseDown = useCallback(() => {
|
|
5130
|
-
if (isEditing) {
|
|
5131
|
-
stopEditing();
|
|
5132
|
-
return;
|
|
5133
|
-
}
|
|
5134
|
-
moveFocusToCell(cellPosition);
|
|
5135
|
-
beginEditing();
|
|
5136
|
-
}, [beginEditing, cellPosition, moveFocusToCell, isEditing, stopEditing]);
|
|
5137
|
-
const handleCellBlur = useCallback(
|
|
5138
|
-
(e) => {
|
|
5139
|
-
if (menuElement.current?.contains(e.relatedTarget)) {
|
|
5140
|
-
return;
|
|
5141
|
-
}
|
|
5142
|
-
setTabIndex(-1);
|
|
5143
|
-
stopEditing();
|
|
5144
|
-
},
|
|
5145
|
-
[setTabIndex, menuElement, stopEditing]
|
|
5146
|
-
);
|
|
5147
|
-
const handleCellFocus = useCallback(
|
|
5148
|
-
(event) => {
|
|
5149
|
-
if (event.target !== cellRef.current) {
|
|
5150
|
-
return;
|
|
5151
|
-
}
|
|
5152
|
-
event.preventDefault();
|
|
5153
|
-
setTabIndex(0);
|
|
5154
|
-
},
|
|
5155
|
-
[setTabIndex]
|
|
5156
|
-
);
|
|
5157
|
-
const handleMenuItemClick = useCallback(
|
|
5158
|
-
(value) => {
|
|
5159
|
-
commitValue(value);
|
|
5160
|
-
},
|
|
5161
|
-
[commitValue]
|
|
5162
|
-
);
|
|
5163
|
-
const handleMenuItemKeyDown = useCallback(
|
|
5164
|
-
(event) => {
|
|
5165
|
-
if (event.key === "Escape" || event.key === "F2") {
|
|
5166
|
-
cellRef.current?.focus();
|
|
5167
|
-
stopEditing();
|
|
5168
|
-
}
|
|
5169
|
-
},
|
|
5170
|
-
[stopEditing]
|
|
5171
|
-
);
|
|
5172
|
-
const cellFocusContextValue = useMemo(
|
|
5173
|
-
() => ({ isCellFocused: tabIndex === 0 && !isEditing }),
|
|
5174
|
-
[tabIndex, isEditing]
|
|
5175
|
-
);
|
|
5176
|
-
if (!isValidValueType) {
|
|
5202
|
+
const onChange = booleanEditConfig?.onChange;
|
|
5203
|
+
const hasEditableConfig = !!booleanEditConfig;
|
|
5204
|
+
const {
|
|
5205
|
+
tabIndex,
|
|
5206
|
+
cellRef,
|
|
5207
|
+
triggerClickRef,
|
|
5208
|
+
handleCellKeyDown,
|
|
5209
|
+
handleMenuKeyDown,
|
|
5210
|
+
handleImplicitClose,
|
|
5211
|
+
handleCellMouseDown,
|
|
5212
|
+
handleCellBlur,
|
|
5213
|
+
handleCellFocus,
|
|
5214
|
+
cellFocusContextValue
|
|
5215
|
+
} = useEditableMenuCell({ cellPosition, onCellKeyDown, ref });
|
|
5216
|
+
const selectedOption = useMemo(() => {
|
|
5217
|
+
if (cellValue === void 0) return null;
|
|
5218
|
+
return options.find((o) => o.id === String(cellValue)) ?? null;
|
|
5219
|
+
}, [options, cellValue]);
|
|
5220
|
+
if (!isValidValueType || !hasEditableConfig) {
|
|
5177
5221
|
const { cellProps: _cellProps, ...immutableCellProps } = props;
|
|
5178
5222
|
return /* @__PURE__ */ jsx(DataTableBodyImmutableCell, { ...immutableCellProps });
|
|
5179
5223
|
}
|
|
5180
5224
|
return /* @__PURE__ */ jsx(
|
|
5181
|
-
|
|
5225
|
+
SelectMenuSync,
|
|
5182
5226
|
{
|
|
5183
|
-
open: isEditing,
|
|
5184
|
-
onOutsidePress: handleOutsidePress,
|
|
5185
5227
|
trigger: ({
|
|
5186
5228
|
ref: triggerRef,
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5229
|
+
onClick,
|
|
5230
|
+
onKeyDown: menuKeyDown,
|
|
5231
|
+
"aria-controls": ariaControls,
|
|
5232
|
+
"aria-expanded": ariaExpanded,
|
|
5233
|
+
"aria-haspopup": ariaHaspopup,
|
|
5234
|
+
"data-state": dataState
|
|
5193
5235
|
}) => {
|
|
5194
|
-
|
|
5195
|
-
|
|
5236
|
+
triggerClickRef.current = onClick;
|
|
5237
|
+
const isOpen = ariaExpanded;
|
|
5238
|
+
return /* @__PURE__ */ jsxs(
|
|
5196
5239
|
TableBodyCell,
|
|
5197
5240
|
{
|
|
5198
5241
|
ref: mergeRefs([
|
|
@@ -5201,39 +5244,42 @@ function DataTableEditableBooleanCellInner(props, ref) {
|
|
|
5201
5244
|
]),
|
|
5202
5245
|
tabIndex,
|
|
5203
5246
|
type: "data-table",
|
|
5204
|
-
...
|
|
5205
|
-
className:
|
|
5206
|
-
onMouseDown: handleCellMouseDown,
|
|
5247
|
+
...restCellProps,
|
|
5248
|
+
className: cx(styles$a["data-table-body-cell-editable"], className),
|
|
5249
|
+
onMouseDown: handleCellMouseDown(onClick),
|
|
5207
5250
|
onBlur: handleCellBlur,
|
|
5208
5251
|
onFocus: handleCellFocus,
|
|
5209
5252
|
"data-cell-pos": formatCellPositionString(cellPosition),
|
|
5210
|
-
"aria-controls":
|
|
5211
|
-
"aria-expanded":
|
|
5212
|
-
"aria-haspopup":
|
|
5213
|
-
"data-
|
|
5214
|
-
|
|
5215
|
-
onKeyDown: (e) => handleCellKeyDown(e, menuOnTriggerKeydown),
|
|
5253
|
+
"aria-controls": ariaControls,
|
|
5254
|
+
"aria-expanded": ariaExpanded,
|
|
5255
|
+
"aria-haspopup": ariaHaspopup,
|
|
5256
|
+
"data-state": dataState,
|
|
5257
|
+
onKeyDown: (e) => handleCellKeyDown(e, menuKeyDown, isOpen),
|
|
5216
5258
|
children: [
|
|
5217
5259
|
/* @__PURE__ */ jsxs(CellFocusContext.Provider, { value: cellFocusContextValue, children: [
|
|
5218
5260
|
children,
|
|
5219
|
-
!
|
|
5261
|
+
!isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
|
|
5220
5262
|
] }),
|
|
5221
|
-
/* @__PURE__ */ jsx(SrOnly, { children:
|
|
5263
|
+
/* @__PURE__ */ jsx(SrOnly, { children: isOpen ? "Press Enter or Space to select a cell value. Press Escape or F2 to cancel." : "Press Enter or F2 to edit cell value." })
|
|
5222
5264
|
]
|
|
5223
5265
|
}
|
|
5224
|
-
) });
|
|
5225
|
-
},
|
|
5226
|
-
children: isEditing && options.map((item) => {
|
|
5227
|
-
return /* @__PURE__ */ jsx(
|
|
5228
|
-
Menu.Item,
|
|
5229
|
-
{
|
|
5230
|
-
label: item.label,
|
|
5231
|
-
onClick: () => handleMenuItemClick(item.value),
|
|
5232
|
-
onKeyDown: handleMenuItemKeyDown
|
|
5233
|
-
},
|
|
5234
|
-
String(item.value)
|
|
5235
5266
|
);
|
|
5236
|
-
}
|
|
5267
|
+
},
|
|
5268
|
+
label: String(
|
|
5269
|
+
cell.column.columnDef.meta?.columnDef?.headerLabel ?? "Select"
|
|
5270
|
+
),
|
|
5271
|
+
options,
|
|
5272
|
+
value: selectedOption,
|
|
5273
|
+
onSelectedOptionChange: (option) => {
|
|
5274
|
+
if (!option) return;
|
|
5275
|
+
const id = String(option.id);
|
|
5276
|
+
const value = id === "true" ? true : id === "false" ? false : null;
|
|
5277
|
+
onChange?.(value, rowId);
|
|
5278
|
+
},
|
|
5279
|
+
disableSearch: true,
|
|
5280
|
+
onMenuKeyDown: handleMenuKeyDown,
|
|
5281
|
+
onImplicitClose: handleImplicitClose,
|
|
5282
|
+
popoverWidth: "reference"
|
|
5237
5283
|
}
|
|
5238
5284
|
);
|
|
5239
5285
|
}
|
|
@@ -5318,9 +5364,15 @@ function DataTableBodyMutableCell(props) {
|
|
|
5318
5364
|
if (editMode === "select") {
|
|
5319
5365
|
return DataTableEditableSelectCell;
|
|
5320
5366
|
}
|
|
5367
|
+
if (editMode === "select-async") {
|
|
5368
|
+
return DataTableEditableSelectAsyncCell;
|
|
5369
|
+
}
|
|
5321
5370
|
if (editMode === "multiselect") {
|
|
5322
5371
|
return DataTableEditableMultiselectCell;
|
|
5323
5372
|
}
|
|
5373
|
+
if (editMode === "multiselect-async") {
|
|
5374
|
+
return DataTableEditableMultiselectAsyncCell;
|
|
5375
|
+
}
|
|
5324
5376
|
if (editMode === "boolean") {
|
|
5325
5377
|
return DataTableEditableBooleanCell;
|
|
5326
5378
|
}
|
|
@@ -5787,7 +5839,8 @@ function CellStatus({ status, variant }) {
|
|
|
5787
5839
|
}
|
|
5788
5840
|
|
|
5789
5841
|
function getTanStackColumnDef({
|
|
5790
|
-
columnDef
|
|
5842
|
+
columnDef,
|
|
5843
|
+
emptyCellContent
|
|
5791
5844
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5792
5845
|
}) {
|
|
5793
5846
|
const columnHelper = createColumnHelper();
|
|
@@ -5797,7 +5850,8 @@ function getTanStackColumnDef({
|
|
|
5797
5850
|
header: columnDef.headerLabel,
|
|
5798
5851
|
columns: columnDef.columns.map(
|
|
5799
5852
|
(column) => getTanStackColumnDef({
|
|
5800
|
-
columnDef: column
|
|
5853
|
+
columnDef: column,
|
|
5854
|
+
emptyCellContent
|
|
5801
5855
|
})
|
|
5802
5856
|
),
|
|
5803
5857
|
footer: columnDef.footerContent ? () => columnDef.footerContent : void 0,
|
|
@@ -5820,6 +5874,7 @@ function getTanStackColumnDef({
|
|
|
5820
5874
|
);
|
|
5821
5875
|
}
|
|
5822
5876
|
}
|
|
5877
|
+
const resolvedEmptyContent = columnDef.emptyCellContent ?? emptyCellContent ?? /* @__PURE__ */ jsx(TableEmptyCellContent, {});
|
|
5823
5878
|
return columnHelper.accessor((row) => row[columnDef.id], {
|
|
5824
5879
|
id: columnDef.id,
|
|
5825
5880
|
cell: (info) => {
|
|
@@ -5833,7 +5888,7 @@ function getTanStackColumnDef({
|
|
|
5833
5888
|
cellContent = info.getValue();
|
|
5834
5889
|
}
|
|
5835
5890
|
if (cellContent === "") {
|
|
5836
|
-
cellContent =
|
|
5891
|
+
cellContent = resolvedEmptyContent;
|
|
5837
5892
|
}
|
|
5838
5893
|
const meta = info.row.original.meta;
|
|
5839
5894
|
const cellError = meta?.errors?.[columnDef.id];
|
|
@@ -5846,11 +5901,12 @@ function getTanStackColumnDef({
|
|
|
5846
5901
|
wrap: "wrap",
|
|
5847
5902
|
gap: "1",
|
|
5848
5903
|
style: {
|
|
5849
|
-
width: "100%"
|
|
5904
|
+
width: "100%",
|
|
5905
|
+
textAlign: resolvedAlign
|
|
5850
5906
|
},
|
|
5851
5907
|
children: [
|
|
5852
5908
|
cellError ? /* @__PURE__ */ jsx(CellStatus, { status: cellError, variant: "error" }) : cellWarning ? /* @__PURE__ */ jsx(CellStatus, { status: cellWarning, variant: "warning" }) : null,
|
|
5853
|
-
cellContent ??
|
|
5909
|
+
cellContent ?? resolvedEmptyContent
|
|
5854
5910
|
]
|
|
5855
5911
|
}
|
|
5856
5912
|
);
|
|
@@ -5862,10 +5918,8 @@ function getTanStackColumnDef({
|
|
|
5862
5918
|
enableResizing: columnDef.resizable,
|
|
5863
5919
|
enableSorting: !!columnDef.sortable,
|
|
5864
5920
|
meta: {
|
|
5865
|
-
editMode: columnDef.
|
|
5921
|
+
editMode: columnDef.editConfig?.mode,
|
|
5866
5922
|
editConfig: columnDef.editConfig,
|
|
5867
|
-
onChange: columnDef.onChange,
|
|
5868
|
-
options: columnDef.options,
|
|
5869
5923
|
columnDef
|
|
5870
5924
|
// Store original for type narrowing
|
|
5871
5925
|
},
|
|
@@ -6001,7 +6055,7 @@ function DataTableHeaderCellInner(props, forwardedRef) {
|
|
|
6001
6055
|
const isDisabled = header.column.columnDef.meta?.disableHeaderAction;
|
|
6002
6056
|
if (isSelectCell && !isDisabled) {
|
|
6003
6057
|
event.preventDefault();
|
|
6004
|
-
header.table.
|
|
6058
|
+
header.table.toggleAllPageRowsSelected();
|
|
6005
6059
|
return;
|
|
6006
6060
|
}
|
|
6007
6061
|
if (isExpandCell && !isDisabled) {
|
|
@@ -6607,6 +6661,7 @@ function DTFocusProvider({
|
|
|
6607
6661
|
return /* @__PURE__ */ jsx(DTFocusStateContext.Provider, { value: state, children: /* @__PURE__ */ jsx(DTFocusDispatchContext.Provider, { value: dispatch, children }) });
|
|
6608
6662
|
}
|
|
6609
6663
|
|
|
6664
|
+
const EMPTY_DATA = [];
|
|
6610
6665
|
function DataTableInner(props, ref) {
|
|
6611
6666
|
const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
|
|
6612
6667
|
const {
|
|
@@ -6627,6 +6682,7 @@ function DataTableInner(props, ref) {
|
|
|
6627
6682
|
selectedRowIds,
|
|
6628
6683
|
sortedColumn,
|
|
6629
6684
|
emptyState,
|
|
6685
|
+
emptyCellContent,
|
|
6630
6686
|
className,
|
|
6631
6687
|
style,
|
|
6632
6688
|
...rest
|
|
@@ -6690,7 +6746,8 @@ function DataTableInner(props, ref) {
|
|
|
6690
6746
|
}
|
|
6691
6747
|
return pageLoader({
|
|
6692
6748
|
pageIndex: currentPageIndex ?? 0,
|
|
6693
|
-
pageSize: rowsPerPage
|
|
6749
|
+
pageSize: rowsPerPage,
|
|
6750
|
+
sorting: sorting?.[0]
|
|
6694
6751
|
});
|
|
6695
6752
|
}, [
|
|
6696
6753
|
isAsyncPaginated,
|
|
@@ -6698,7 +6755,8 @@ function DataTableInner(props, ref) {
|
|
|
6698
6755
|
rowsPerPage,
|
|
6699
6756
|
dataProp,
|
|
6700
6757
|
refreshKey,
|
|
6701
|
-
refreshCounter
|
|
6758
|
+
refreshCounter,
|
|
6759
|
+
sorting
|
|
6702
6760
|
]);
|
|
6703
6761
|
const {
|
|
6704
6762
|
data: resolvedData,
|
|
@@ -6725,29 +6783,7 @@ function DataTableInner(props, ref) {
|
|
|
6725
6783
|
}
|
|
6726
6784
|
}
|
|
6727
6785
|
});
|
|
6728
|
-
const tableData =
|
|
6729
|
-
if (isLoading) return [];
|
|
6730
|
-
if (!isPaginated || isAsyncPaginated) return resolvedData;
|
|
6731
|
-
const maxPageIndex = Math.max(
|
|
6732
|
-
0,
|
|
6733
|
-
Math.ceil(totalItemCount / rowsPerPage) - 1
|
|
6734
|
-
);
|
|
6735
|
-
const clampedPageIndex = Math.max(
|
|
6736
|
-
0,
|
|
6737
|
-
Math.min(currentPageIndex ?? 0, maxPageIndex)
|
|
6738
|
-
);
|
|
6739
|
-
const startIndex = clampedPageIndex * rowsPerPage;
|
|
6740
|
-
const endIndex = startIndex + rowsPerPage;
|
|
6741
|
-
return resolvedData?.slice(startIndex, endIndex) ?? [];
|
|
6742
|
-
}, [
|
|
6743
|
-
isLoading,
|
|
6744
|
-
isPaginated,
|
|
6745
|
-
isAsyncPaginated,
|
|
6746
|
-
resolvedData,
|
|
6747
|
-
totalItemCount,
|
|
6748
|
-
rowsPerPage,
|
|
6749
|
-
currentPageIndex
|
|
6750
|
-
]);
|
|
6786
|
+
const tableData = isLoading ? EMPTY_DATA : resolvedData;
|
|
6751
6787
|
const hasRowStatus = useMemo(() => {
|
|
6752
6788
|
return tableData?.some((row) => {
|
|
6753
6789
|
const meta = row.meta;
|
|
@@ -6778,7 +6814,8 @@ function DataTableInner(props, ref) {
|
|
|
6778
6814
|
const columns = useMemo(() => {
|
|
6779
6815
|
const tableColumns = columnsProp.map(
|
|
6780
6816
|
(column) => getTanStackColumnDef({
|
|
6781
|
-
columnDef: column
|
|
6817
|
+
columnDef: column,
|
|
6818
|
+
emptyCellContent
|
|
6782
6819
|
})
|
|
6783
6820
|
);
|
|
6784
6821
|
if (hasRowStatus) {
|
|
@@ -6873,10 +6910,10 @@ function DataTableInner(props, ref) {
|
|
|
6873
6910
|
Checkbox,
|
|
6874
6911
|
{
|
|
6875
6912
|
tabIndex: -1,
|
|
6876
|
-
"aria-label": table2.
|
|
6877
|
-
checked: table2.
|
|
6878
|
-
indeterminate: table2.
|
|
6879
|
-
onChange: table2.
|
|
6913
|
+
"aria-label": table2.getIsAllPageRowsSelected() ? "Deselect all rows" : "Select all rows",
|
|
6914
|
+
checked: table2.getIsAllPageRowsSelected(),
|
|
6915
|
+
indeterminate: table2.getIsSomePageRowsSelected(),
|
|
6916
|
+
onChange: table2.getToggleAllPageRowsSelectedHandler(),
|
|
6880
6917
|
"data-cell-action": "select"
|
|
6881
6918
|
}
|
|
6882
6919
|
) });
|
|
@@ -6905,6 +6942,7 @@ function DataTableInner(props, ref) {
|
|
|
6905
6942
|
columnsProp,
|
|
6906
6943
|
disableExpandAll,
|
|
6907
6944
|
disableSelectAll,
|
|
6945
|
+
emptyCellContent,
|
|
6908
6946
|
hasRowStatus,
|
|
6909
6947
|
hasSubComponent,
|
|
6910
6948
|
isExpandable,
|
|
@@ -6915,6 +6953,7 @@ function DataTableInner(props, ref) {
|
|
|
6915
6953
|
columns,
|
|
6916
6954
|
getCoreRowModel: getCoreRowModel(),
|
|
6917
6955
|
getSortedRowModel: getSortedRowModel(),
|
|
6956
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
6918
6957
|
getExpandedRowModel: getExpandedRowModel(),
|
|
6919
6958
|
getGroupedRowModel: getGroupedRowModel(),
|
|
6920
6959
|
getRowId: (row) => row.id.toString(),
|
|
@@ -6927,8 +6966,18 @@ function DataTableInner(props, ref) {
|
|
|
6927
6966
|
columnPinning,
|
|
6928
6967
|
rowSelection,
|
|
6929
6968
|
expanded,
|
|
6930
|
-
sorting
|
|
6969
|
+
sorting,
|
|
6970
|
+
...isPaginated && {
|
|
6971
|
+
pagination: {
|
|
6972
|
+
pageIndex: currentPageIndex ?? 0,
|
|
6973
|
+
pageSize: rowsPerPage
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6931
6976
|
},
|
|
6977
|
+
manualPagination: !isPaginated || isAsyncPaginated,
|
|
6978
|
+
// Server provides sorted data via loadPageData; disable client-side sort.
|
|
6979
|
+
manualSorting: isAsyncPaginated,
|
|
6980
|
+
autoResetPageIndex: false,
|
|
6932
6981
|
columnResizeMode: "onChange",
|
|
6933
6982
|
enableRowSelection: typeof isSelectable === "function" ? (row) => isSelectable(row.original) : isSelectable,
|
|
6934
6983
|
onRowSelectionChange: (newRowSelection) => {
|
|
@@ -6944,11 +6993,14 @@ function DataTableInner(props, ref) {
|
|
|
6944
6993
|
return;
|
|
6945
6994
|
}
|
|
6946
6995
|
setSorting(newSorting);
|
|
6996
|
+
if (isPaginated) {
|
|
6997
|
+
setCurrentPageIndex(0);
|
|
6998
|
+
}
|
|
6947
6999
|
}
|
|
6948
7000
|
});
|
|
6949
7001
|
const headers = table.getFlatHeaders();
|
|
6950
7002
|
const headerRowCount = table.getHeaderGroups().length;
|
|
6951
|
-
const bodyRowCount = table.
|
|
7003
|
+
const bodyRowCount = table.getRowModel().rows.length;
|
|
6952
7004
|
const columnSizing = table.getState().columnSizing;
|
|
6953
7005
|
const getMaxFooterRows = useCallback((column) => {
|
|
6954
7006
|
let currentMax = 0;
|
|
@@ -7132,4 +7184,4 @@ function DataTableInner(props, ref) {
|
|
|
7132
7184
|
const DataTable = forwardRef(DataTableInner);
|
|
7133
7185
|
|
|
7134
7186
|
export { COLUMN_TYPE_DEFAULTS as C, DataTable as D, chipsFormatter as a, booleanFormatter as b, createColumnHelper$1 as c, currencyFormatter as d, dateFormatter as e, dateTimeFormatter as f, getColumnTypeDefaults as g, dateFormatPresets as h, timeFormatter as i, numberFormatter as n, percentFormatter as p, resolveColumnTypeConfig as r, timeFormatPresets as t, yearlessDateFormatter as y };
|
|
7135
|
-
//# sourceMappingURL=DataTable-
|
|
7187
|
+
//# sourceMappingURL=DataTable-BmVPjMMg.js.map
|