@servicetitan/anvil2 2.7.0 → 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.
Files changed (238) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{Avatar-CCnbKkCm.js → Avatar-BckUfs1N.js} +48 -46
  3. package/dist/{Avatar-CCnbKkCm.js.map → Avatar-BckUfs1N.js.map} +1 -1
  4. package/dist/Avatar-ChybzixS.js +35 -0
  5. package/dist/Avatar-ChybzixS.js.map +1 -0
  6. package/dist/Avatar.js +2 -2
  7. package/dist/Breadcrumbs-C_WK9Yul.js +107 -0
  8. package/dist/Breadcrumbs-C_WK9Yul.js.map +1 -0
  9. package/dist/Breadcrumbs.js +1 -1
  10. package/dist/{Calendar-C1U2npPP.js → Calendar-BTStJPV1.js} +2 -2
  11. package/dist/{Calendar-C1U2npPP.js.map → Calendar-BTStJPV1.js.map} +1 -1
  12. package/dist/{Calendar-SGlTt-bs.js → Calendar-Frpv5rRY.js} +129 -118
  13. package/dist/Calendar-Frpv5rRY.js.map +1 -0
  14. package/dist/Calendar.css +51 -51
  15. package/dist/Calendar.js +2 -2
  16. package/dist/Checkbox-CTZdZym4.js +52 -0
  17. package/dist/Checkbox-CTZdZym4.js.map +1 -0
  18. package/dist/{Checkbox-CtKUNeyu.js → Checkbox-Drgai_lS.js} +3 -3
  19. package/dist/{Checkbox-CtKUNeyu.js.map → Checkbox-Drgai_lS.js.map} +1 -1
  20. package/dist/Checkbox.js +1 -1
  21. package/dist/{Chip-DjTAR0va.js → Chip-CVyEctAz.js} +2 -2
  22. package/dist/{Chip-DjTAR0va.js.map → Chip-CVyEctAz.js.map} +1 -1
  23. package/dist/Chip.js +1 -1
  24. package/dist/{Combobox-By8-34bw.js → Combobox-BRtfrYyZ.js} +185 -182
  25. package/dist/{Combobox-By8-34bw.js.map → Combobox-BRtfrYyZ.js.map} +1 -1
  26. package/dist/Combobox.js +1 -1
  27. package/dist/{DataTable-BYOS6icI.js → DataTable-BmVPjMMg.js} +667 -622
  28. package/dist/DataTable-BmVPjMMg.js.map +1 -0
  29. package/dist/{DateFieldRange-C8Uzrboc.js → DateFieldRange-D9DtlkSQ.js} +19 -5
  30. package/dist/DateFieldRange-D9DtlkSQ.js.map +1 -0
  31. package/dist/DateFieldRange.js +1 -1
  32. package/dist/{DateFieldSingle-DrhLIjlK.js → DateFieldSingle-CkdeCUJv.js} +7 -7
  33. package/dist/{DateFieldSingle-DrhLIjlK.js.map → DateFieldSingle-CkdeCUJv.js.map} +1 -1
  34. package/dist/DateFieldSingle.js +1 -1
  35. package/dist/{DateFieldYearless-DbivK4Hm.js → DateFieldYearless-b81ZcYdp.js} +3 -3
  36. package/dist/{DateFieldYearless-DbivK4Hm.js.map → DateFieldYearless-b81ZcYdp.js.map} +1 -1
  37. package/dist/DateFieldYearless.js +1 -1
  38. package/dist/{DateFieldYearlessRange-BEqJe4Uf.js → DateFieldYearlessRange-ClAFzIDD.js} +3 -3
  39. package/dist/{DateFieldYearlessRange-BEqJe4Uf.js.map → DateFieldYearlessRange-ClAFzIDD.js.map} +1 -1
  40. package/dist/DateFieldYearlessRange.js +1 -1
  41. package/dist/{DaysOfTheWeek-BR32AA32.js → DaysOfTheWeek-2Zeh79oR.js} +3 -3
  42. package/dist/{DaysOfTheWeek-BR32AA32.js.map → DaysOfTheWeek-2Zeh79oR.js.map} +1 -1
  43. package/dist/DaysOfTheWeek.js +1 -1
  44. package/dist/{Details-Dxq_v3Qg.js → Details-CZOIpNP_.js} +8 -8
  45. package/dist/Details-CZOIpNP_.js.map +1 -0
  46. package/dist/Details.js +1 -1
  47. package/dist/{Dialog-CGhwkwvq.js → Dialog-CloZWa1Q.js} +71 -71
  48. package/dist/Dialog-CloZWa1Q.js.map +1 -0
  49. package/dist/Dialog.js +1 -1
  50. package/dist/{Drawer-DA4iAgt-.js → Drawer-CfkoH081.js} +84 -84
  51. package/dist/Drawer-CfkoH081.js.map +1 -0
  52. package/dist/Drawer.js +1 -1
  53. package/dist/DrillDown.js +1 -1
  54. package/dist/{FieldLabel-DbMosKtd.js → FieldLabel-CQ5QGTVq.js} +2 -2
  55. package/dist/{FieldLabel-DbMosKtd.js.map → FieldLabel-CQ5QGTVq.js.map} +1 -1
  56. package/dist/FieldLabel.js +1 -1
  57. package/dist/Grid-DeYIx5k4.js +149 -0
  58. package/dist/Grid-DeYIx5k4.js.map +1 -0
  59. package/dist/Grid.js +1 -1
  60. package/dist/{InputMask-HjaNCb73.js → InputMask-CI4Q5UwG.js} +3 -3
  61. package/dist/{InputMask-HjaNCb73.js.map → InputMask-CI4Q5UwG.js.map} +1 -1
  62. package/dist/InputMask.js +1 -1
  63. package/dist/{Layout-VfhlilMG.js → Layout-CISAxILX.js} +34 -33
  64. package/dist/Layout-CISAxILX.js.map +1 -0
  65. package/dist/Layout.js +1 -1
  66. package/dist/List--KhCpjZn.js +103 -0
  67. package/dist/List--KhCpjZn.js.map +1 -0
  68. package/dist/List.js +1 -1
  69. package/dist/{ListView-mujFK6mQ.js → ListView-DAbBuss4.js} +6 -6
  70. package/dist/ListView-DAbBuss4.js.map +1 -0
  71. package/dist/ListView.js +1 -1
  72. package/dist/{Listbox-BtAgBDRS.js → Listbox-D_T55BFX.js} +5 -4
  73. package/dist/Listbox-D_T55BFX.js.map +1 -0
  74. package/dist/Listbox.js +1 -1
  75. package/dist/{Menu-BXsmCP20.js → Menu-CRoJYJ53.js} +366 -365
  76. package/dist/Menu-CRoJYJ53.js.map +1 -0
  77. package/dist/Menu.js +1 -1
  78. package/dist/MultiSelectField.js +1 -1
  79. package/dist/{MultiSelectFieldSync-DGpGgu8q.js → MultiSelectFieldSync-CSOitvtu.js} +5 -5
  80. package/dist/{MultiSelectFieldSync-DGpGgu8q.js.map → MultiSelectFieldSync-CSOitvtu.js.map} +1 -1
  81. package/dist/MultiSelectMenu.js +1 -1
  82. package/dist/{MultiSelectMenuSync-DiLddJDw.js → MultiSelectMenuSync-62OeGmkz.js} +29 -9
  83. package/dist/MultiSelectMenuSync-62OeGmkz.js.map +1 -0
  84. package/dist/{NumberField-svhZp1kB.js → NumberField-CHBXBMSj.js} +2 -2
  85. package/dist/{NumberField-svhZp1kB.js.map → NumberField-CHBXBMSj.js.map} +1 -1
  86. package/dist/NumberField.js +1 -1
  87. package/dist/Overflow.css +27 -26
  88. package/dist/Overflow.js +11 -11
  89. package/dist/{Page-Be029Dij.js → Page-DtSjnBJL.js} +217 -205
  90. package/dist/Page-DtSjnBJL.js.map +1 -0
  91. package/dist/Page.css +78 -76
  92. package/dist/Page.js +1 -1
  93. package/dist/{Pagination-BAwqfl_2.js → Pagination-CbBte3GQ.js} +17 -15
  94. package/dist/Pagination-CbBte3GQ.js.map +1 -0
  95. package/dist/Pagination.js +1 -1
  96. package/dist/Popover-CQhLSNYR.js +537 -0
  97. package/dist/Popover-CQhLSNYR.js.map +1 -0
  98. package/dist/{Popover-D0qSKZ1J.js → Popover-Rha0q-Pv.js} +354 -354
  99. package/dist/Popover-Rha0q-Pv.js.map +1 -0
  100. package/dist/Popover.js +1 -1
  101. package/dist/{ProgressBar-JpRDW5vG.js → ProgressBar-DEaMqbM-.js} +2 -2
  102. package/dist/{ProgressBar-JpRDW5vG.js.map → ProgressBar-DEaMqbM-.js.map} +1 -1
  103. package/dist/ProgressBar.js +1 -1
  104. package/dist/{Radio-BQg7exDG.js → Radio-Bw2LDl9G.js} +3 -3
  105. package/dist/{Radio-BQg7exDG.js.map → Radio-Bw2LDl9G.js.map} +1 -1
  106. package/dist/Radio-CCvu8mbI.js +60 -0
  107. package/dist/Radio-CCvu8mbI.js.map +1 -0
  108. package/dist/Radio.js +1 -1
  109. package/dist/{SegmentedControl-7fDLhgvh.js → SegmentedControl-BAi4pnFe.js} +79 -75
  110. package/dist/{SegmentedControl-7fDLhgvh.js.map → SegmentedControl-BAi4pnFe.js.map} +1 -1
  111. package/dist/SegmentedControl.js +1 -1
  112. package/dist/SelectCard-ZaAD0wR1.js +325 -0
  113. package/dist/SelectCard-ZaAD0wR1.js.map +1 -0
  114. package/dist/SelectCard.js +1 -1
  115. package/dist/SelectField.js +1 -1
  116. package/dist/{SelectFieldLabel-Dr8HeW3N.js → SelectFieldLabel-EJCXA02B.js} +2 -2
  117. package/dist/{SelectFieldLabel-Dr8HeW3N.js.map → SelectFieldLabel-EJCXA02B.js.map} +1 -1
  118. package/dist/{SelectFieldSync-CJ2Ie_v1.js → SelectFieldSync-DA54WXOk.js} +4 -4
  119. package/dist/{SelectFieldSync-CJ2Ie_v1.js.map → SelectFieldSync-DA54WXOk.js.map} +1 -1
  120. package/dist/SelectMenu.js +1 -1
  121. package/dist/{SelectMenuSync-CJA_coqD.js → SelectMenuSync-BQaSTcaN.js} +29 -9
  122. package/dist/SelectMenuSync-BQaSTcaN.js.map +1 -0
  123. package/dist/{SelectOptions-Bf4xsFek.js → SelectOptions-D-DzWmKE.js} +2 -2
  124. package/dist/{SelectOptions-Bf4xsFek.js.map → SelectOptions-D-DzWmKE.js.map} +1 -1
  125. package/dist/{SelectTrigger-ObsnAKNp.js → SelectTrigger-DWyRndmY.js} +3 -3
  126. package/dist/{SelectTrigger-ObsnAKNp.js.map → SelectTrigger-DWyRndmY.js.map} +1 -1
  127. package/dist/SelectTrigger.js +1 -1
  128. package/dist/{SelectTriggerBase-DKfOL2RJ.js → SelectTriggerBase-B6aZd2a6.js} +3 -3
  129. package/dist/{SelectTriggerBase-DKfOL2RJ.js.map → SelectTriggerBase-B6aZd2a6.js.map} +1 -1
  130. package/dist/{SideNav-KksbSQn7.js → SideNav-CxHemV3H.js} +127 -125
  131. package/dist/{SideNav-KksbSQn7.js.map → SideNav-CxHemV3H.js.map} +1 -1
  132. package/dist/SideNav.js +1 -1
  133. package/dist/{Stepper-Dt8_ImvJ.js → Stepper-CQUXV6P4.js} +156 -156
  134. package/dist/{Stepper-Dt8_ImvJ.js.map → Stepper-CQUXV6P4.js.map} +1 -1
  135. package/dist/Stepper.js +1 -1
  136. package/dist/{Tab-DO7LaUbw.js → Tab-BGGNcz9S.js} +225 -221
  137. package/dist/Tab-BGGNcz9S.js.map +1 -0
  138. package/dist/Tab.js +1 -1
  139. package/dist/Table.js +1 -1
  140. package/dist/{TextField-BW8sJAls.js → TextField-CMv9CpBq.js} +2 -2
  141. package/dist/{TextField-BW8sJAls.js.map → TextField-CMv9CpBq.js.map} +1 -1
  142. package/dist/{TextField-DeHpgPag.js → TextField-o8zvVFDk.js} +2 -2
  143. package/dist/{TextField-DeHpgPag.js.map → TextField-o8zvVFDk.js.map} +1 -1
  144. package/dist/TextField.js +1 -1
  145. package/dist/{Textarea-DyqdMTvQ.js → Textarea-B4bBvO8c.js} +2 -2
  146. package/dist/{Textarea-DyqdMTvQ.js.map → Textarea-B4bBvO8c.js.map} +1 -1
  147. package/dist/Textarea.js +1 -1
  148. package/dist/{TimeField-Dc0Y1JD-.js → TimeField-BEgnjk4R.js} +4 -4
  149. package/dist/{TimeField-Dc0Y1JD-.js.map → TimeField-BEgnjk4R.js.map} +1 -1
  150. package/dist/TimeField.js +1 -1
  151. package/dist/Toast.js +2 -2
  152. package/dist/{Toaster-b0-Ub3yt.js → Toaster-6_LVKok2.js} +2 -2
  153. package/dist/{Toaster-b0-Ub3yt.js.map → Toaster-6_LVKok2.js.map} +1 -1
  154. package/dist/{Toaster-DikGo_hR.js → Toaster-B38WlKC7.js} +2 -2
  155. package/dist/{Toaster-DikGo_hR.js.map → Toaster-B38WlKC7.js.map} +1 -1
  156. package/dist/{Toolbar-DAuz4Gs2.js → Toolbar-0EKhrvZN.js} +148 -147
  157. package/dist/{Toolbar-DAuz4Gs2.js.map → Toolbar-0EKhrvZN.js.map} +1 -1
  158. package/dist/Toolbar.js +1 -1
  159. package/dist/{Tooltip-Bupqao9B.js → Tooltip-BHwSTwsv.js} +224 -226
  160. package/dist/Tooltip-BHwSTwsv.js.map +1 -0
  161. package/dist/Tooltip.js +1 -1
  162. package/dist/{YearlessDateInputWithPicker-DFi08TLG.js → YearlessDateInputWithPicker-BC4lRuny.js} +3 -3
  163. package/dist/{YearlessDateInputWithPicker-DFi08TLG.js.map → YearlessDateInputWithPicker-BC4lRuny.js.map} +1 -1
  164. package/dist/beta/components/MultiSelectMenu/types.d.ts +15 -0
  165. package/dist/beta/components/SelectMenu/internal/useMenuInteraction.d.ts +3 -1
  166. package/dist/beta/components/SelectMenu/types.d.ts +15 -0
  167. package/dist/beta/components/Table/DataTable/DataTable.d.ts +2 -15
  168. package/dist/beta/components/Table/DataTable/internal/editable-cells/DataTableEditableMultiselectAsyncCell.d.ts +35 -0
  169. package/dist/beta/components/Table/DataTable/internal/editable-cells/DataTableEditableMultiselectCell.d.ts +4 -3
  170. package/dist/beta/components/Table/DataTable/internal/editable-cells/DataTableEditableSelectAsyncCell.d.ts +7 -0
  171. package/dist/beta/components/Table/DataTable/internal/editable-cells/useEditableMenuCell.d.ts +34 -0
  172. package/dist/beta/components/Table/DataTable/internal/util/getTanStackColumnDef.d.ts +2 -4
  173. package/dist/beta/components/Table/DataTable/types.d.ts +18 -1
  174. package/dist/beta/components/Table/createColumnHelper.d.ts +23 -68
  175. package/dist/beta/components/Table/types.d.ts +218 -42
  176. package/dist/beta/components/Toolbar/Toolbar.d.ts +168 -41
  177. package/dist/beta.js +9 -9
  178. package/dist/components/Avatar/Avatar.d.ts +14 -0
  179. package/dist/components/Calendar/Calendar.d.ts +84 -26
  180. package/dist/components/Combobox/Combobox.d.ts +172 -1
  181. package/dist/components/Dialog/Dialog.d.ts +96 -28
  182. package/dist/components/DrillDown/DrillDown.d.ts +7 -1
  183. package/dist/components/Layout/Layout.d.ts +52 -44
  184. package/dist/components/ListView/ListView.d.ts +5 -5
  185. package/dist/components/Listbox/Listbox.d.ts +5 -23
  186. package/dist/components/Menu/Menu.d.ts +1 -4
  187. package/dist/components/Toolbar/Toolbar.d.ts +3 -1
  188. package/dist/{floating-ui.react-C_s3_nEb.js → floating-ui.react-aKYfs-aw.js} +2 -2
  189. package/dist/{floating-ui.react-C_s3_nEb.js.map → floating-ui.react-aKYfs-aw.js.map} +1 -1
  190. package/dist/{index.esm-BZV0wNKZ.js → index.esm-K9kxJhLx.js} +2 -1
  191. package/dist/{index.esm-BZV0wNKZ.js.map → index.esm-K9kxJhLx.js.map} +1 -1
  192. package/dist/index.js +126 -126
  193. package/dist/index.js.map +1 -1
  194. package/dist/{syncFilterUtils-vt8ldsES.js → syncFilterUtils-B03Pc941.js} +191 -191
  195. package/dist/{syncFilterUtils-vt8ldsES.js.map → syncFilterUtils-B03Pc941.js.map} +1 -1
  196. package/dist/{useDrilldown-wwXRpNgb.js → useDrilldown-BW2XkUcK.js} +41 -39
  197. package/dist/{useDrilldown-wwXRpNgb.js.map → useDrilldown-BW2XkUcK.js.map} +1 -1
  198. package/dist/{useInitialFocus-CdoVwSbr.js → useInitialFocus-BRRbylek.js} +2 -2
  199. package/dist/{useInitialFocus-CdoVwSbr.js.map → useInitialFocus-BRRbylek.js.map} +1 -1
  200. package/dist/{useMenuInteraction-zR_78KQC.js → useMenuInteraction-BwZ2ORo9.js} +8 -3
  201. package/dist/useMenuInteraction-BwZ2ORo9.js.map +1 -0
  202. package/dist/{useToggleSelection-BdXW3Zg3.js → useToggleSelection-Dip0eimQ.js} +2 -2
  203. package/dist/{useToggleSelection-BdXW3Zg3.js.map → useToggleSelection-Dip0eimQ.js.map} +1 -1
  204. package/package.json +3 -3
  205. package/dist/Avatar--CnTAnfD.js +0 -35
  206. package/dist/Avatar--CnTAnfD.js.map +0 -1
  207. package/dist/Breadcrumbs-3Y7jnj-F.js +0 -105
  208. package/dist/Breadcrumbs-3Y7jnj-F.js.map +0 -1
  209. package/dist/Calendar-SGlTt-bs.js.map +0 -1
  210. package/dist/Checkbox-CjEKa5Iv.js +0 -50
  211. package/dist/Checkbox-CjEKa5Iv.js.map +0 -1
  212. package/dist/DataTable-BYOS6icI.js.map +0 -1
  213. package/dist/DateFieldRange-C8Uzrboc.js.map +0 -1
  214. package/dist/Details-Dxq_v3Qg.js.map +0 -1
  215. package/dist/Dialog-CGhwkwvq.js.map +0 -1
  216. package/dist/Drawer-DA4iAgt-.js.map +0 -1
  217. package/dist/Grid-ONcUpb__.js +0 -147
  218. package/dist/Grid-ONcUpb__.js.map +0 -1
  219. package/dist/Layout-VfhlilMG.js.map +0 -1
  220. package/dist/List-CJZjElAQ.js +0 -101
  221. package/dist/List-CJZjElAQ.js.map +0 -1
  222. package/dist/ListView-mujFK6mQ.js.map +0 -1
  223. package/dist/Listbox-BtAgBDRS.js.map +0 -1
  224. package/dist/Menu-BXsmCP20.js.map +0 -1
  225. package/dist/MultiSelectMenuSync-DiLddJDw.js.map +0 -1
  226. package/dist/Page-Be029Dij.js.map +0 -1
  227. package/dist/Pagination-BAwqfl_2.js.map +0 -1
  228. package/dist/Popover-D0qSKZ1J.js.map +0 -1
  229. package/dist/Popover-DxZF6lbJ.js +0 -535
  230. package/dist/Popover-DxZF6lbJ.js.map +0 -1
  231. package/dist/Radio-BOq9UkpC.js +0 -60
  232. package/dist/Radio-BOq9UkpC.js.map +0 -1
  233. package/dist/SelectCard-cu4MBuh8.js +0 -320
  234. package/dist/SelectCard-cu4MBuh8.js.map +0 -1
  235. package/dist/SelectMenuSync-CJA_coqD.js.map +0 -1
  236. package/dist/Tab-DO7LaUbw.js.map +0 -1
  237. package/dist/Tooltip-Bupqao9B.js.map +0 -1
  238. 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-DjTAR0va.js';
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 { w as warnOnce } from './warnOnce-Y9PRHcU4.js';
9
- import { C as Checkbox } from './Checkbox-CjEKa5Iv.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 { M as Menu } from './Menu-BXsmCP20.js';
18
- import { P as Popover } from './Popover-D0qSKZ1J.js';
19
- import { S as SearchField } from './SearchField-im7AHGYo.js';
20
- import { L as ListView } from './ListView-mujFK6mQ.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-Bupqao9B.js';
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-BAwqfl_2.js';
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, ...editProps };
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
- return cell.column.columnDef.meta?.onChange;
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 DataTableEditableSelectCellInner(props, ref) {
4542
- const { cell, cellProps, cellPosition, children } = props;
4543
- const { onKeyDown: onCellKeyDown } = cellProps;
4544
- const [isEditing, setIsEditing] = useState(false);
4545
- const columnId = getColumnId(cell);
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 rowId = cell.row.id;
4583
- const menuElement = useRef(null);
4553
+ const triggerClickRef = useRef(null);
4584
4554
  useImperativeHandle(ref, () => ({
4585
- invoke: beginEditing,
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, handleMenuKeydown) => {
4614
- if (isEditing) {
4615
- if (event.key === "Escape" || event.key === "F2") {
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, isEditing, stopEditing]
4571
+ [onCellKeyDown]
4625
4572
  );
4626
- const handleOutsidePress = useCallback(() => {
4627
- stopEditing();
4628
- setTabIndex(-1);
4629
- }, [stopEditing]);
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
- moveFocusToCell(cellPosition);
4636
- beginEditing();
4637
- }, [beginEditing, cellPosition, moveFocusToCell, isEditing, stopEditing]);
4638
- const handleCellBlur = useCallback(
4639
- (e) => {
4640
- if (menuElement.current?.contains(e.relatedTarget)) {
4641
- return;
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
- [setTabIndex, menuElement, stopEditing]
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
- [setTabIndex]
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 && !isEditing }),
4675
- [tabIndex, isEditing]
4610
+ () => ({ isCellFocused: tabIndex === 0 }),
4611
+ [tabIndex]
4676
4612
  );
4677
- if (!isValidValueType) {
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
- Menu,
4673
+ SelectMenuSync,
4683
4674
  {
4684
- open: isEditing,
4685
- onOutsidePress: handleOutsidePress,
4686
4675
  trigger: ({
4687
4676
  ref: triggerRef,
4688
- onKeyDown: menuOnTriggerKeydown,
4689
- ["aria-controls"]: triggerAriaControls,
4690
- ["aria-expanded"]: triggerAriaExpanded,
4691
- ["aria-haspopup"]: triggerAriaHaspopup,
4692
- ["data-open"]: triggerDataOpen,
4693
- ["data-state"]: triggerDataState
4677
+ onClick,
4678
+ onKeyDown: menuKeyDown,
4679
+ "aria-controls": ariaControls,
4680
+ "aria-expanded": ariaExpanded,
4681
+ "aria-haspopup": ariaHaspopup,
4682
+ "data-state": dataState
4694
4683
  }) => {
4695
- menuElement.current = document.querySelector(`#${triggerAriaControls}`) || null;
4696
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
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
- ...cellProps,
4706
- className: cellClasses,
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": triggerAriaControls,
4712
- "aria-expanded": triggerAriaExpanded,
4713
- "aria-haspopup": triggerAriaHaspopup,
4714
- "data-open": triggerDataOpen,
4715
- "data-state": triggerDataState,
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
- !isEditing && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
4709
+ !isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
4721
4710
  ] }),
4722
- /* @__PURE__ */ jsx(SrOnly, { children: isEditing ? "Press Enter or Space to select a cell value. Press Escape or F2 to cancel." : "Press Enter or F2 to edit cell value." })
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 DataTableEditableMultiselectCellInner(props, ref) {
4735
+ function DataTableEditableSelectAsyncCellInner(props, ref) {
4747
4736
  const { cell, cellProps, cellPosition, children } = props;
4748
- const { onKeyDown: onCellKeyDown } = cellProps;
4749
- const [isEditing, setIsEditing] = useState(false);
4750
- const columnId = getColumnId(cell);
4737
+ const { onKeyDown: onCellKeyDown, className, ...restCellProps } = cellProps;
4738
+ getColumnId(cell);
4751
4739
  const cellValue = getCellValue(cell);
4752
- const [initialValue, isValidValueType] = useMemo(() => {
4753
- let value;
4754
- let isValid = true;
4755
- if (cellValue === null || cellValue === void 0) {
4756
- value = [];
4757
- return [value, isValid];
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 [draftValue, setDraftValue] = useState(initialValue);
4783
- const searchFieldRef = useRef(null);
4784
- const [searchValue, setSearchValue] = useState("");
4785
- const listViewRef = useRef(null);
4786
- const popoverElement = useRef(null);
4787
- const { className, ...restCellProps } = cellProps;
4788
- useImperativeHandle(ref, () => ({
4789
- invoke: beginEditing,
4790
- focus: () => {
4791
- cellRef.current?.focus();
4792
- setTabIndex(0);
4793
- }
4794
- }));
4795
- const beginEditing = useCallback(() => {
4796
- setIsEditing(true);
4797
- }, [setIsEditing]);
4798
- const stopEditing = useCallback(() => {
4799
- setIsEditing(false);
4800
- }, [setIsEditing]);
4801
- const onChange = getCellOnChange(cell);
4802
- const commitValue = useCallback(() => {
4803
- setSearchValue("");
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
- onCellKeyDown?.(event);
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
- [onCellKeyDown, isEditing, stopEditing]
4792
+ [cellLoader, context, lazy]
4831
4793
  );
4832
- const handleCellMouseDown = useCallback(() => {
4833
- if (isEditing) {
4834
- return;
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
- const handleCellFocus = useCallback(
4850
- (event) => {
4851
- if (event.target !== cellRef.current) {
4852
- return;
4853
- }
4854
- event.preventDefault();
4855
- setTabIndex(0);
4856
- },
4857
- [setTabIndex]
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 handleListViewKeyDown = useCallback(
4860
- (e) => {
4861
- if (e.key === "Tab" && !e.shiftKey || e.key === "F2") {
4862
- e.preventDefault();
4863
- e.stopPropagation();
4864
- cellRef.current?.focus();
4865
- commitValue();
4866
- }
4867
- if (e.key === "Escape") {
4868
- cellRef.current?.focus();
4869
- e.preventDefault();
4870
- e.stopPropagation();
4871
- resetValue();
4872
- }
4873
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
4874
- e.preventDefault();
4875
- }
4876
- },
4877
- [commitValue, resetValue]
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
- const handleSearchFieldKeyDown = useCallback(
4880
- (e) => {
4881
- if (e.key === "F2") {
4882
- cellRef.current?.focus();
4883
- commitValue();
4884
- }
4885
- if (e.key === "Escape") {
4886
- e.preventDefault();
4887
- e.stopPropagation();
4888
- cellRef.current?.focus();
4889
- resetValue();
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 (e.key === "ArrowDown") {
4892
- e.preventDefault();
4893
- e.stopPropagation();
4894
- listViewRef.current?.focus();
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
- [commitValue, resetValue]
4898
- );
4899
- const handleListViewSelectionChange = useCallback(
4900
- (items) => {
4901
- if (isEditing) {
4902
- const selectedItems2 = items;
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
- [isEditing]
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
- if (!isValidValueType) {
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__ */ jsxs(
4945
- Popover,
5079
+ return /* @__PURE__ */ jsx(
5080
+ MultiSelectMenu,
4946
5081
  {
4947
- open: isEditing,
4948
- onOpenAnimationComplete: handleOpenAnimationComplete,
4949
- onClickOutside: handleOnClickOutside,
4950
- placement: "bottom-start",
4951
- disableCaret: true,
4952
- children: [
4953
- /* @__PURE__ */ jsx(Popover.Trigger, { children: ({
4954
- ref: popoverRef,
4955
- onKeyDown: triggerOnKeyDown,
4956
- ["aria-expanded"]: triggerAriaExpanded,
4957
- ["aria-haspopup"]: triggerAriaHaspopup,
4958
- ["aria-details"]: triggerAriaDetails
4959
- }) => {
4960
- popoverElement.current = (triggerAriaDetails ? document.querySelector(`#${triggerAriaDetails}`) : null) || null;
4961
- return /* @__PURE__ */ jsxs(
4962
- TableBodyCell,
4963
- {
4964
- ref: mergeRefs([
4965
- popoverRef,
4966
- cellRef
4967
- ]),
4968
- tabIndex,
4969
- type: "data-table",
4970
- ...restCellProps,
4971
- className: cellClasses,
4972
- onMouseDown: handleCellMouseDown,
4973
- onBlur: handleCellBlur,
4974
- onFocus: handleCellFocus,
4975
- "data-cell-pos": formatCellPositionString(cellPosition),
4976
- "aria-expanded": triggerAriaExpanded,
4977
- "aria-haspopup": triggerAriaHaspopup,
4978
- onKeyDown: (e) => handleCellKeyDown(e, triggerOnKeyDown),
4979
- children: [
4980
- /* @__PURE__ */ jsxs(CellFocusContext.Provider, { value: cellFocusContextValue, children: [
4981
- children,
4982
- !isEditing && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
4983
- ] }),
4984
- /* @__PURE__ */ jsx(SrOnly, { children: isEditing ? "Press Enter or Space to select cell values. Press F2 to save. Press Escape to cancel." : "Press Enter or F2 to edit cell value." })
4985
- ]
4986
- }
4987
- );
4988
- } }),
4989
- /* @__PURE__ */ jsx(Popover.Content, { children: /* @__PURE__ */ jsxs(Flex, { gap: "4", direction: "column", children: [
4990
- /* @__PURE__ */ jsx(
4991
- SearchField,
4992
- {
4993
- ref: searchFieldRef,
4994
- onChange: handleSearchFieldChange,
4995
- onKeyDown: handleSearchFieldKeyDown,
4996
- value: searchValue
4997
- }
4998
- ),
4999
- /* @__PURE__ */ jsx(
5000
- ListView,
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 DataTableEditableMultiselectCell = Object.assign(
5016
- forwardRef(DataTableEditableMultiselectCellInner),
5017
- { displayName: "DataTableEditableMultiselectCell" }
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 [initialValue, isValidValueType] = useMemo(() => {
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 editConfig = cell.column.columnDef.meta?.editConfig;
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
- value: true,
5188
+ id: "true",
5063
5189
  label: config.trueLabel ?? typeOptions?.trueLabel ?? "True"
5064
5190
  },
5065
5191
  {
5066
- value: false,
5192
+ id: "false",
5067
5193
  label: config.falseLabel ?? typeOptions?.falseLabel ?? "False"
5068
5194
  }
5069
5195
  ];
5070
5196
  if (config.allowNull) {
5071
- items.push({ value: null, label: config.nullLabel ?? "Unset" });
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 menuElement = useRef(null);
5083
- useImperativeHandle(ref, () => ({
5084
- invoke: beginEditing,
5085
- focus: () => {
5086
- cellRef.current?.focus();
5087
- setTabIndex(0);
5088
- }
5089
- }));
5090
- const beginEditing = useCallback(() => {
5091
- setIsEditing(true);
5092
- }, [setIsEditing]);
5093
- const stopEditing = useCallback(() => {
5094
- setIsEditing(false);
5095
- }, [setIsEditing]);
5096
- const onChange = getCellOnChange(cell);
5097
- const commitValue = useCallback(
5098
- (value) => {
5099
- if (value !== initialValue) {
5100
- onChange?.(value, rowId);
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
- Menu,
5225
+ SelectMenuSync,
5182
5226
  {
5183
- open: isEditing,
5184
- onOutsidePress: handleOutsidePress,
5185
5227
  trigger: ({
5186
5228
  ref: triggerRef,
5187
- onKeyDown: menuOnTriggerKeydown,
5188
- ["aria-controls"]: triggerAriaControls,
5189
- ["aria-expanded"]: triggerAriaExpanded,
5190
- ["aria-haspopup"]: triggerAriaHaspopup,
5191
- ["data-open"]: triggerDataOpen,
5192
- ["data-state"]: triggerDataState
5229
+ onClick,
5230
+ onKeyDown: menuKeyDown,
5231
+ "aria-controls": ariaControls,
5232
+ "aria-expanded": ariaExpanded,
5233
+ "aria-haspopup": ariaHaspopup,
5234
+ "data-state": dataState
5193
5235
  }) => {
5194
- menuElement.current = document.querySelector(`#${triggerAriaControls}`) || null;
5195
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
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
- ...cellProps,
5205
- className: cellClasses,
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": triggerAriaControls,
5211
- "aria-expanded": triggerAriaExpanded,
5212
- "aria-haspopup": triggerAriaHaspopup,
5213
- "data-open": triggerDataOpen,
5214
- "data-state": triggerDataState,
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
- !isEditing && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
5261
+ !isOpen && /* @__PURE__ */ jsx(DataTableEditableCellEditIcon, {})
5220
5262
  ] }),
5221
- /* @__PURE__ */ jsx(SrOnly, { children: isEditing ? "Press Enter or Space to select a cell value. Press Escape or F2 to cancel." : "Press Enter or F2 to edit cell value." })
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
  }
@@ -5866,10 +5918,8 @@ function getTanStackColumnDef({
5866
5918
  enableResizing: columnDef.resizable,
5867
5919
  enableSorting: !!columnDef.sortable,
5868
5920
  meta: {
5869
- editMode: columnDef.editMode,
5921
+ editMode: columnDef.editConfig?.mode,
5870
5922
  editConfig: columnDef.editConfig,
5871
- onChange: columnDef.onChange,
5872
- options: columnDef.options,
5873
5923
  columnDef
5874
5924
  // Store original for type narrowing
5875
5925
  },
@@ -6005,7 +6055,7 @@ function DataTableHeaderCellInner(props, forwardedRef) {
6005
6055
  const isDisabled = header.column.columnDef.meta?.disableHeaderAction;
6006
6056
  if (isSelectCell && !isDisabled) {
6007
6057
  event.preventDefault();
6008
- header.table.toggleAllRowsSelected();
6058
+ header.table.toggleAllPageRowsSelected();
6009
6059
  return;
6010
6060
  }
6011
6061
  if (isExpandCell && !isDisabled) {
@@ -6611,6 +6661,7 @@ function DTFocusProvider({
6611
6661
  return /* @__PURE__ */ jsx(DTFocusStateContext.Provider, { value: state, children: /* @__PURE__ */ jsx(DTFocusDispatchContext.Provider, { value: dispatch, children }) });
6612
6662
  }
6613
6663
 
6664
+ const EMPTY_DATA = [];
6614
6665
  function DataTableInner(props, ref) {
6615
6666
  const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
6616
6667
  const {
@@ -6695,7 +6746,8 @@ function DataTableInner(props, ref) {
6695
6746
  }
6696
6747
  return pageLoader({
6697
6748
  pageIndex: currentPageIndex ?? 0,
6698
- pageSize: rowsPerPage
6749
+ pageSize: rowsPerPage,
6750
+ sorting: sorting?.[0]
6699
6751
  });
6700
6752
  }, [
6701
6753
  isAsyncPaginated,
@@ -6703,7 +6755,8 @@ function DataTableInner(props, ref) {
6703
6755
  rowsPerPage,
6704
6756
  dataProp,
6705
6757
  refreshKey,
6706
- refreshCounter
6758
+ refreshCounter,
6759
+ sorting
6707
6760
  ]);
6708
6761
  const {
6709
6762
  data: resolvedData,
@@ -6730,29 +6783,7 @@ function DataTableInner(props, ref) {
6730
6783
  }
6731
6784
  }
6732
6785
  });
6733
- const tableData = useMemo(() => {
6734
- if (isLoading) return [];
6735
- if (!isPaginated || isAsyncPaginated) return resolvedData;
6736
- const maxPageIndex = Math.max(
6737
- 0,
6738
- Math.ceil(totalItemCount / rowsPerPage) - 1
6739
- );
6740
- const clampedPageIndex = Math.max(
6741
- 0,
6742
- Math.min(currentPageIndex ?? 0, maxPageIndex)
6743
- );
6744
- const startIndex = clampedPageIndex * rowsPerPage;
6745
- const endIndex = startIndex + rowsPerPage;
6746
- return resolvedData?.slice(startIndex, endIndex) ?? [];
6747
- }, [
6748
- isLoading,
6749
- isPaginated,
6750
- isAsyncPaginated,
6751
- resolvedData,
6752
- totalItemCount,
6753
- rowsPerPage,
6754
- currentPageIndex
6755
- ]);
6786
+ const tableData = isLoading ? EMPTY_DATA : resolvedData;
6756
6787
  const hasRowStatus = useMemo(() => {
6757
6788
  return tableData?.some((row) => {
6758
6789
  const meta = row.meta;
@@ -6879,10 +6910,10 @@ function DataTableInner(props, ref) {
6879
6910
  Checkbox,
6880
6911
  {
6881
6912
  tabIndex: -1,
6882
- "aria-label": table2.getIsAllRowsSelected() ? "Deselect all rows" : "Select all rows",
6883
- checked: table2.getIsAllRowsSelected(),
6884
- indeterminate: table2.getIsSomeRowsSelected(),
6885
- onChange: table2.getToggleAllRowsSelectedHandler(),
6913
+ "aria-label": table2.getIsAllPageRowsSelected() ? "Deselect all rows" : "Select all rows",
6914
+ checked: table2.getIsAllPageRowsSelected(),
6915
+ indeterminate: table2.getIsSomePageRowsSelected(),
6916
+ onChange: table2.getToggleAllPageRowsSelectedHandler(),
6886
6917
  "data-cell-action": "select"
6887
6918
  }
6888
6919
  ) });
@@ -6922,6 +6953,7 @@ function DataTableInner(props, ref) {
6922
6953
  columns,
6923
6954
  getCoreRowModel: getCoreRowModel(),
6924
6955
  getSortedRowModel: getSortedRowModel(),
6956
+ getPaginationRowModel: getPaginationRowModel(),
6925
6957
  getExpandedRowModel: getExpandedRowModel(),
6926
6958
  getGroupedRowModel: getGroupedRowModel(),
6927
6959
  getRowId: (row) => row.id.toString(),
@@ -6934,8 +6966,18 @@ function DataTableInner(props, ref) {
6934
6966
  columnPinning,
6935
6967
  rowSelection,
6936
6968
  expanded,
6937
- sorting
6969
+ sorting,
6970
+ ...isPaginated && {
6971
+ pagination: {
6972
+ pageIndex: currentPageIndex ?? 0,
6973
+ pageSize: rowsPerPage
6974
+ }
6975
+ }
6938
6976
  },
6977
+ manualPagination: !isPaginated || isAsyncPaginated,
6978
+ // Server provides sorted data via loadPageData; disable client-side sort.
6979
+ manualSorting: isAsyncPaginated,
6980
+ autoResetPageIndex: false,
6939
6981
  columnResizeMode: "onChange",
6940
6982
  enableRowSelection: typeof isSelectable === "function" ? (row) => isSelectable(row.original) : isSelectable,
6941
6983
  onRowSelectionChange: (newRowSelection) => {
@@ -6951,11 +6993,14 @@ function DataTableInner(props, ref) {
6951
6993
  return;
6952
6994
  }
6953
6995
  setSorting(newSorting);
6996
+ if (isPaginated) {
6997
+ setCurrentPageIndex(0);
6998
+ }
6954
6999
  }
6955
7000
  });
6956
7001
  const headers = table.getFlatHeaders();
6957
7002
  const headerRowCount = table.getHeaderGroups().length;
6958
- const bodyRowCount = table.getExpandedRowModel().rows.length;
7003
+ const bodyRowCount = table.getRowModel().rows.length;
6959
7004
  const columnSizing = table.getState().columnSizing;
6960
7005
  const getMaxFooterRows = useCallback((column) => {
6961
7006
  let currentMax = 0;
@@ -7139,4 +7184,4 @@ function DataTableInner(props, ref) {
7139
7184
  const DataTable = forwardRef(DataTableInner);
7140
7185
 
7141
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 };
7142
- //# sourceMappingURL=DataTable-BYOS6icI.js.map
7187
+ //# sourceMappingURL=DataTable-BmVPjMMg.js.map