@teppen/react-ui 1.10.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +73 -6
  2. package/dist/cjs/node_modules/react-icons/bi/index.js.map +1 -1
  3. package/dist/cjs/node_modules/react-icons/lib/iconBase.js.map +1 -1
  4. package/dist/cjs/node_modules/react-icons/lib/iconContext.js.map +1 -1
  5. package/dist/cjs/node_modules/react-icons/lu/index.js.map +1 -1
  6. package/dist/cjs/node_modules/react-icons/md/index.js.map +1 -1
  7. package/dist/cjs/node_modules/react-icons/ti/index.js.map +1 -1
  8. package/dist/cjs/node_modules/tslib/tslib.es6.js +1 -1
  9. package/dist/cjs/node_modules/tslib/tslib.es6.js.map +1 -1
  10. package/dist/cjs/src/file-uploader/hook.js +1 -1
  11. package/dist/cjs/src/file-uploader/hook.js.map +1 -1
  12. package/dist/cjs/src/search-bar/condition-search-bar/base.js +1 -2
  13. package/dist/cjs/src/search-bar/condition-search-bar/base.js.map +1 -1
  14. package/dist/cjs/src/search-bar/condition-search-bar/condition-list.js +1 -2
  15. package/dist/cjs/src/search-bar/condition-search-bar/condition-list.js.map +1 -1
  16. package/dist/cjs/src/search-bar/condition-search-bar/input-form.js +1 -2
  17. package/dist/cjs/src/search-bar/condition-search-bar/input-form.js.map +1 -1
  18. package/dist/cjs/src/search-bar/id-generator/provider.js +1 -2
  19. package/dist/cjs/src/search-bar/id-generator/provider.js.map +1 -1
  20. package/dist/cjs/src/select-box/index.js +1 -2
  21. package/dist/cjs/src/select-box/index.js.map +1 -1
  22. package/dist/cjs/src/select-box/parts/input-area.js +1 -2
  23. package/dist/cjs/src/select-box/parts/input-area.js.map +1 -1
  24. package/dist/cjs/src/select-box/provider.js +1 -2
  25. package/dist/cjs/src/select-box/provider.js.map +1 -1
  26. package/dist/cjs/src/table/cell/ui/cell.js +1 -2
  27. package/dist/cjs/src/table/cell/ui/cell.js.map +1 -1
  28. package/dist/cjs/src/table/checkbox/components.js +1 -2
  29. package/dist/cjs/src/table/checkbox/components.js.map +1 -1
  30. package/dist/cjs/src/table/copy/format.js +2 -0
  31. package/dist/cjs/src/table/copy/format.js.map +1 -0
  32. package/dist/cjs/src/table/copy/hooks.js +1 -1
  33. package/dist/cjs/src/table/copy/hooks.js.map +1 -1
  34. package/dist/cjs/src/table/edit/provider.js +1 -2
  35. package/dist/cjs/src/table/edit/provider.js.map +1 -1
  36. package/dist/cjs/src/table/edit/ui/base-input.js +1 -2
  37. package/dist/cjs/src/table/edit/ui/base-input.js.map +1 -1
  38. package/dist/cjs/src/table/edit/ui/editor.js.map +1 -1
  39. package/dist/cjs/src/table/edit/ui/number-input.js +1 -2
  40. package/dist/cjs/src/table/edit/ui/number-input.js.map +1 -1
  41. package/dist/cjs/src/table/edit/ui/select-input.js +1 -2
  42. package/dist/cjs/src/table/edit/ui/select-input.js.map +1 -1
  43. package/dist/cjs/src/table/edit/ui/string-input.js +1 -2
  44. package/dist/cjs/src/table/edit/ui/string-input.js.map +1 -1
  45. package/dist/cjs/src/table/filter-v2/hook.js +1 -1
  46. package/dist/cjs/src/table/filter-v2/hook.js.map +1 -1
  47. package/dist/cjs/src/table/frame/frame.js +1 -2
  48. package/dist/cjs/src/table/frame/frame.js.map +1 -1
  49. package/dist/cjs/src/table/header/columns-width/provider.js +1 -2
  50. package/dist/cjs/src/table/header/columns-width/provider.js.map +1 -1
  51. package/dist/cjs/src/table/header/columns-width/reducer.js +1 -1
  52. package/dist/cjs/src/table/header/columns-width/reducer.js.map +1 -1
  53. package/dist/cjs/src/table/header/header-v2-hook.js +1 -1
  54. package/dist/cjs/src/table/header/header-v2-hook.js.map +1 -1
  55. package/dist/cjs/src/table/header/header-v2.js +1 -1
  56. package/dist/cjs/src/table/header/header-v2.js.map +1 -1
  57. package/dist/cjs/src/table/header/header.js +1 -2
  58. package/dist/cjs/src/table/header/header.js.map +1 -1
  59. package/dist/cjs/src/table/id/provider.js +1 -1
  60. package/dist/cjs/src/table/id/provider.js.map +1 -1
  61. package/dist/cjs/src/table/operation/components/keyboard-setting.js +1 -2
  62. package/dist/cjs/src/table/operation/components/keyboard-setting.js.map +1 -1
  63. package/dist/cjs/src/table/operation/event-target.js +2 -0
  64. package/dist/cjs/src/table/operation/event-target.js.map +1 -0
  65. package/dist/cjs/src/table/pagenation/components.js +1 -2
  66. package/dist/cjs/src/table/pagenation/components.js.map +1 -1
  67. package/dist/cjs/src/table/pagenation/hooks.js +1 -1
  68. package/dist/cjs/src/table/pagenation/hooks.js.map +1 -1
  69. package/dist/cjs/src/table/pagenation/providers.js +1 -2
  70. package/dist/cjs/src/table/pagenation/providers.js.map +1 -1
  71. package/dist/cjs/src/table/paste/hooks.js +1 -1
  72. package/dist/cjs/src/table/paste/hooks.js.map +1 -1
  73. package/dist/cjs/src/table/paste/logic.js +1 -1
  74. package/dist/cjs/src/table/paste/logic.js.map +1 -1
  75. package/dist/cjs/src/table/paste/parse.js +2 -0
  76. package/dist/cjs/src/table/paste/parse.js.map +1 -0
  77. package/dist/cjs/src/table/paste/provider.js +1 -1
  78. package/dist/cjs/src/table/paste/provider.js.map +1 -1
  79. package/dist/cjs/src/table/sheet/components.js +1 -1
  80. package/dist/cjs/src/table/sheet/components.js.map +1 -1
  81. package/dist/cjs/src/table/sheet/providers.js +1 -2
  82. package/dist/cjs/src/table/sheet/providers.js.map +1 -1
  83. package/dist/cjs/src/table/sort/components.js +1 -2
  84. package/dist/cjs/src/table/sort/components.js.map +1 -1
  85. package/dist/cjs/src/table/sort/provider.js +1 -2
  86. package/dist/cjs/src/table/sort/provider.js.map +1 -1
  87. package/dist/cjs/src/table/table/base.js +1 -2
  88. package/dist/cjs/src/table/table/base.js.map +1 -1
  89. package/dist/cjs/src/table/table/component-provider/provider.js +1 -2
  90. package/dist/cjs/src/table/table/component-provider/provider.js.map +1 -1
  91. package/dist/cjs/src/table/table/hook.js +1 -1
  92. package/dist/cjs/src/table/table/hook.js.map +1 -1
  93. package/dist/esm/node_modules/react-icons/bi/index.js.map +1 -1
  94. package/dist/esm/node_modules/react-icons/lib/iconBase.js.map +1 -1
  95. package/dist/esm/node_modules/react-icons/lib/iconContext.js.map +1 -1
  96. package/dist/esm/node_modules/react-icons/lu/index.js.map +1 -1
  97. package/dist/esm/node_modules/react-icons/md/index.js.map +1 -1
  98. package/dist/esm/node_modules/react-icons/ti/index.js.map +1 -1
  99. package/dist/esm/node_modules/tslib/tslib.es6.js +1 -1
  100. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
  101. package/dist/esm/src/file-uploader/hook.js +1 -1
  102. package/dist/esm/src/file-uploader/hook.js.map +1 -1
  103. package/dist/esm/src/search-bar/condition-search-bar/base.js +1 -2
  104. package/dist/esm/src/search-bar/condition-search-bar/base.js.map +1 -1
  105. package/dist/esm/src/search-bar/condition-search-bar/condition-list.js +1 -2
  106. package/dist/esm/src/search-bar/condition-search-bar/condition-list.js.map +1 -1
  107. package/dist/esm/src/search-bar/condition-search-bar/input-form.js +1 -2
  108. package/dist/esm/src/search-bar/condition-search-bar/input-form.js.map +1 -1
  109. package/dist/esm/src/search-bar/id-generator/provider.js +1 -2
  110. package/dist/esm/src/search-bar/id-generator/provider.js.map +1 -1
  111. package/dist/esm/src/select-box/index.js +1 -2
  112. package/dist/esm/src/select-box/index.js.map +1 -1
  113. package/dist/esm/src/select-box/parts/input-area.js +1 -2
  114. package/dist/esm/src/select-box/parts/input-area.js.map +1 -1
  115. package/dist/esm/src/select-box/provider.js +1 -2
  116. package/dist/esm/src/select-box/provider.js.map +1 -1
  117. package/dist/esm/src/table/cell/ui/cell.js +1 -2
  118. package/dist/esm/src/table/cell/ui/cell.js.map +1 -1
  119. package/dist/esm/src/table/checkbox/components.js +1 -2
  120. package/dist/esm/src/table/checkbox/components.js.map +1 -1
  121. package/dist/esm/src/table/copy/format.js +2 -0
  122. package/dist/esm/src/table/copy/format.js.map +1 -0
  123. package/dist/esm/src/table/copy/hooks.js +1 -1
  124. package/dist/esm/src/table/copy/hooks.js.map +1 -1
  125. package/dist/esm/src/table/edit/provider.js +1 -2
  126. package/dist/esm/src/table/edit/provider.js.map +1 -1
  127. package/dist/esm/src/table/edit/ui/base-input.js +1 -2
  128. package/dist/esm/src/table/edit/ui/base-input.js.map +1 -1
  129. package/dist/esm/src/table/edit/ui/editor.js.map +1 -1
  130. package/dist/esm/src/table/edit/ui/number-input.js +1 -2
  131. package/dist/esm/src/table/edit/ui/number-input.js.map +1 -1
  132. package/dist/esm/src/table/edit/ui/select-input.js +1 -2
  133. package/dist/esm/src/table/edit/ui/select-input.js.map +1 -1
  134. package/dist/esm/src/table/edit/ui/string-input.js +1 -2
  135. package/dist/esm/src/table/edit/ui/string-input.js.map +1 -1
  136. package/dist/esm/src/table/filter-v2/hook.js +1 -1
  137. package/dist/esm/src/table/filter-v2/hook.js.map +1 -1
  138. package/dist/esm/src/table/frame/frame.js +1 -2
  139. package/dist/esm/src/table/frame/frame.js.map +1 -1
  140. package/dist/esm/src/table/header/columns-width/provider.js +1 -2
  141. package/dist/esm/src/table/header/columns-width/provider.js.map +1 -1
  142. package/dist/esm/src/table/header/columns-width/reducer.js +1 -1
  143. package/dist/esm/src/table/header/columns-width/reducer.js.map +1 -1
  144. package/dist/esm/src/table/header/header-v2-hook.js +1 -1
  145. package/dist/esm/src/table/header/header-v2-hook.js.map +1 -1
  146. package/dist/esm/src/table/header/header-v2.js +1 -1
  147. package/dist/esm/src/table/header/header-v2.js.map +1 -1
  148. package/dist/esm/src/table/header/header.js +1 -2
  149. package/dist/esm/src/table/header/header.js.map +1 -1
  150. package/dist/esm/src/table/id/provider.js +1 -1
  151. package/dist/esm/src/table/id/provider.js.map +1 -1
  152. package/dist/esm/src/table/operation/components/keyboard-setting.js +1 -2
  153. package/dist/esm/src/table/operation/components/keyboard-setting.js.map +1 -1
  154. package/dist/esm/src/table/operation/event-target.js +2 -0
  155. package/dist/esm/src/table/operation/event-target.js.map +1 -0
  156. package/dist/esm/src/table/pagenation/components.js +1 -2
  157. package/dist/esm/src/table/pagenation/components.js.map +1 -1
  158. package/dist/esm/src/table/pagenation/hooks.js +1 -1
  159. package/dist/esm/src/table/pagenation/hooks.js.map +1 -1
  160. package/dist/esm/src/table/pagenation/providers.js +1 -2
  161. package/dist/esm/src/table/pagenation/providers.js.map +1 -1
  162. package/dist/esm/src/table/paste/hooks.js +1 -1
  163. package/dist/esm/src/table/paste/hooks.js.map +1 -1
  164. package/dist/esm/src/table/paste/logic.js +1 -1
  165. package/dist/esm/src/table/paste/logic.js.map +1 -1
  166. package/dist/esm/src/table/paste/parse.js +2 -0
  167. package/dist/esm/src/table/paste/parse.js.map +1 -0
  168. package/dist/esm/src/table/paste/provider.js +1 -1
  169. package/dist/esm/src/table/paste/provider.js.map +1 -1
  170. package/dist/esm/src/table/sheet/components.js +1 -1
  171. package/dist/esm/src/table/sheet/components.js.map +1 -1
  172. package/dist/esm/src/table/sheet/providers.js +1 -2
  173. package/dist/esm/src/table/sheet/providers.js.map +1 -1
  174. package/dist/esm/src/table/sort/components.js +1 -2
  175. package/dist/esm/src/table/sort/components.js.map +1 -1
  176. package/dist/esm/src/table/sort/provider.js +1 -2
  177. package/dist/esm/src/table/sort/provider.js.map +1 -1
  178. package/dist/esm/src/table/table/base.js +1 -2
  179. package/dist/esm/src/table/table/base.js.map +1 -1
  180. package/dist/esm/src/table/table/component-provider/provider.js +1 -2
  181. package/dist/esm/src/table/table/component-provider/provider.js.map +1 -1
  182. package/dist/esm/src/table/table/hook.js +1 -1
  183. package/dist/esm/src/table/table/hook.js.map +1 -1
  184. package/dist/index.d.ts +13 -1
  185. package/package.json +1 -3
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","sources":["../../../../../../src/table/edit/ui/editor.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useColumnsContext } from \"../../sheet/providers\";\nimport { useEditActionContext, useEditStateContext } from \"../provider\";\nimport { NumberCellInput } from \"./number-input\";\nimport { SelectCellInput } from \"./select-input\";\nimport { StringCellInput } from \"./string-input\";\nimport { DataObject, DataRecord } from \"../../table/type\";\nimport { useRangeStateContext } from \"../../range/provider\";\nimport { useTableIdGenerator } from \"../../id\";\n\ntype TPropsEditor = {\n pageRowIds: (string | number)[];\n rowMaps: {\n [id: string]: {\n data: DataObject<DataRecord>;\n stringValue: string;\n };\n [id: number]: {\n data: DataObject<DataRecord>;\n stringValue: string;\n };\n };\n};\n\nexport function Editor(props: TPropsEditor) {\n const IdGenerator = useTableIdGenerator();\n const range = useRangeStateContext();\n const edit = useEditStateContext();\n const editActions = useEditActionContext();\n const cols = useColumnsContext();\n\n useEffect(() => {\n if (range.isSelecting && !cols[range.start.colIndex].editable) {\n editActions.endEditing();\n }\n }, [edit, range]);\n\n if (!edit.isEditing) return <></>;\n if (!range.isSelecting) return <></>;\n\n const col = cols[range.start.colIndex];\n const row = props.rowMaps[props.pageRowIds[range.start.rowIndex]].data;\n\n if (!col.editable) return <></>;\n\n const id = IdGenerator.getTableCellId({\n rowIndex: range.start.rowIndex,\n columnIndex: range.start.colIndex,\n });\n const cellElement = document.getElementById(id);\n const rect = cellElement?.getBoundingClientRect();\n\n const size = rect\n ? {\n width: rect.width,\n height: rect.height,\n top: rect.top,\n left: rect.left,\n }\n : undefined;\n\n if (!size) return <></>;\n\n const tableElement = document.getElementById(IdGenerator.getTableId());\n if (!tableElement) return <></>;\n const rectTable = tableElement.getBoundingClientRect();\n\n size.top -= rectTable.top - tableElement.scrollTop;\n size.left -= rectTable.left - tableElement.scrollLeft;\n\n return (\n <div\n className=\"absolute top-0 left-0 grid place-items-center z-10 pr-2\"\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n style={{\n width: size.width,\n height: size.height,\n top: size.top - 1,\n left: size.left,\n }}\n >\n {col.type === \"string\" && <StringCellInput col={col} row={row} />}\n {col.type === \"number\" && <NumberCellInput col={col} row={row} />}\n {col.type === \"select\" && <SelectCellInput col={col} row={row} />}\n </div>\n );\n}\n"],"names":["Editor","props","IdGenerator","useTableIdGenerator","range","useRangeStateContext","edit","useEditStateContext","editActions","useEditActionContext","cols","useColumnsContext","useEffect","isSelecting","start","colIndex","editable","endEditing","isEditing","_jsx","col","row","rowMaps","pageRowIds","rowIndex","data","id","getTableCellId","columnIndex","cellElement","document","getElementById","rect","getBoundingClientRect","size","width","height","top","left","undefined","tableElement","getTableId","rectTable","scrollTop","scrollLeft","_jsxs","className","onClick","e","preventDefault","stopPropagation","style","children","type","StringCellInput","NumberCellInput","SelectCellInput"],"mappings":"ogBAwBM,SAAUA,EAAOC,GACrB,IAAMC,EAAcC,IACdC,EAAQC,IACRC,EAAOC,IACPC,EAAcC,IACdC,EAAOC,IAQb,GANAC,GAAU,WACJR,EAAMS,cAAgBH,EAAKN,EAAMU,MAAMC,UAAUC,UACnDR,EAAYS,YAEhB,GAAG,CAACX,EAAMF,KAELE,EAAKY,UAAW,OAAOC,QAC5B,IAAKf,EAAMS,YAAa,OAAOM,QAE/B,IAAMC,EAAMV,EAAKN,EAAMU,MAAMC,UACvBM,EAAMpB,EAAMqB,QAAQrB,EAAMsB,WAAWnB,EAAMU,MAAMU,WAAWC,KAElE,IAAKL,EAAIJ,SAAU,OAAOG,QAE1B,IAAMO,EAAKxB,EAAYyB,eAAe,CACpCH,SAAUpB,EAAMU,MAAMU,SACtBI,YAAaxB,EAAMU,MAAMC,WAErBc,EAAcC,SAASC,eAAeL,GACtCM,EAAOH,eAAAA,EAAaI,wBAEpBC,EAAOF,EACT,CACEG,MAAOH,EAAKG,MACZC,OAAQJ,EAAKI,OACbC,IAAKL,EAAKK,IACVC,KAAMN,EAAKM,WAEbC,EAEJ,IAAKL,EAAM,OAAOf,QAElB,IAAMqB,EAAeV,SAASC,eAAe7B,EAAYuC,cACzD,IAAKD,EAAc,OAAOrB,QAC1B,IAAMuB,EAAYF,EAAaP,wBAK/B,OAHAC,EAAKG,KAAOK,EAAUL,IAAMG,EAAaG,UACzCT,EAAKI,MAAQI,EAAUJ,KAAOE,EAAaI,WAGzCC,SACEC,UAAU,0DACVC,QAAS,SAACC,GACRA,EAAEC,iBACFD,EAAEE,iBACJ,EACAC,MAAO,CACLhB,MAAOD,EAAKC,MACZC,OAAQF,EAAKE,OACbC,IAAKH,EAAKG,IAAM,EAChBC,KAAMJ,EAAKI,MACZc,SAAA,CAEa,WAAbhC,EAAIiC,MAAqBlC,EAACmC,EAAe,CAAClC,IAAKA,EAAKC,IAAKA,IAC5C,WAAbD,EAAIiC,MAAqBlC,EAACoC,EAAe,CAACnC,IAAKA,EAAKC,IAAKA,IAC5C,WAAbD,EAAIiC,MAAqBlC,EAACqC,EAAe,CAACpC,IAAKA,EAAKC,IAAKA,MAGhE"}
1
+ {"version":3,"file":"editor.js","sources":["../../../../../../src/table/edit/ui/editor.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useColumnsContext } from \"../../sheet/providers\";\nimport { useEditActionContext, useEditStateContext } from \"../provider\";\nimport { NumberCellInput } from \"./number-input\";\nimport { SelectCellInput } from \"./select-input\";\nimport { StringCellInput } from \"./string-input\";\nimport { DataObject, DataRecord } from \"../../table/type\";\nimport { useRangeStateContext } from \"../../range/provider\";\nimport { useTableIdGenerator } from \"../../id\";\n\ntype TPropsEditor = {\n pageRowIds: (string | number)[];\n rowMaps: {\n [id: string]: {\n data: DataObject<DataRecord>;\n };\n [id: number]: {\n data: DataObject<DataRecord>;\n };\n };\n};\n\nexport function Editor(props: TPropsEditor) {\n const IdGenerator = useTableIdGenerator();\n const range = useRangeStateContext();\n const edit = useEditStateContext();\n const editActions = useEditActionContext();\n const cols = useColumnsContext();\n\n useEffect(() => {\n if (range.isSelecting && !cols[range.start.colIndex].editable) {\n editActions.endEditing();\n }\n }, [edit, range]);\n\n if (!edit.isEditing) return <></>;\n if (!range.isSelecting) return <></>;\n\n const col = cols[range.start.colIndex];\n const row = props.rowMaps[props.pageRowIds[range.start.rowIndex]].data;\n\n if (!col.editable) return <></>;\n\n const id = IdGenerator.getTableCellId({\n rowIndex: range.start.rowIndex,\n columnIndex: range.start.colIndex,\n });\n const cellElement = document.getElementById(id);\n const rect = cellElement?.getBoundingClientRect();\n\n const size = rect\n ? {\n width: rect.width,\n height: rect.height,\n top: rect.top,\n left: rect.left,\n }\n : undefined;\n\n if (!size) return <></>;\n\n const tableElement = document.getElementById(IdGenerator.getTableId());\n if (!tableElement) return <></>;\n const rectTable = tableElement.getBoundingClientRect();\n\n size.top -= rectTable.top - tableElement.scrollTop;\n size.left -= rectTable.left - tableElement.scrollLeft;\n\n return (\n <div\n className=\"absolute top-0 left-0 grid place-items-center z-10 pr-2\"\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n style={{\n width: size.width,\n height: size.height,\n top: size.top - 1,\n left: size.left,\n }}\n >\n {col.type === \"string\" && <StringCellInput col={col} row={row} />}\n {col.type === \"number\" && <NumberCellInput col={col} row={row} />}\n {col.type === \"select\" && <SelectCellInput col={col} row={row} />}\n </div>\n );\n}\n"],"names":["Editor","props","IdGenerator","useTableIdGenerator","range","useRangeStateContext","edit","useEditStateContext","editActions","useEditActionContext","cols","useColumnsContext","useEffect","isSelecting","start","colIndex","editable","endEditing","isEditing","_jsx","col","row","rowMaps","pageRowIds","rowIndex","data","id","getTableCellId","columnIndex","cellElement","document","getElementById","rect","getBoundingClientRect","size","width","height","top","left","undefined","tableElement","getTableId","rectTable","scrollTop","scrollLeft","_jsxs","className","onClick","e","preventDefault","stopPropagation","style","children","type","StringCellInput","NumberCellInput","SelectCellInput"],"mappings":"ogBAsBM,SAAUA,EAAOC,GACrB,IAAMC,EAAcC,IACdC,EAAQC,IACRC,EAAOC,IACPC,EAAcC,IACdC,EAAOC,IAQb,GANAC,GAAU,WACJR,EAAMS,cAAgBH,EAAKN,EAAMU,MAAMC,UAAUC,UACnDR,EAAYS,YAEhB,GAAG,CAACX,EAAMF,KAELE,EAAKY,UAAW,OAAOC,QAC5B,IAAKf,EAAMS,YAAa,OAAOM,QAE/B,IAAMC,EAAMV,EAAKN,EAAMU,MAAMC,UACvBM,EAAMpB,EAAMqB,QAAQrB,EAAMsB,WAAWnB,EAAMU,MAAMU,WAAWC,KAElE,IAAKL,EAAIJ,SAAU,OAAOG,QAE1B,IAAMO,EAAKxB,EAAYyB,eAAe,CACpCH,SAAUpB,EAAMU,MAAMU,SACtBI,YAAaxB,EAAMU,MAAMC,WAErBc,EAAcC,SAASC,eAAeL,GACtCM,EAAOH,eAAAA,EAAaI,wBAEpBC,EAAOF,EACT,CACEG,MAAOH,EAAKG,MACZC,OAAQJ,EAAKI,OACbC,IAAKL,EAAKK,IACVC,KAAMN,EAAKM,WAEbC,EAEJ,IAAKL,EAAM,OAAOf,QAElB,IAAMqB,EAAeV,SAASC,eAAe7B,EAAYuC,cACzD,IAAKD,EAAc,OAAOrB,QAC1B,IAAMuB,EAAYF,EAAaP,wBAK/B,OAHAC,EAAKG,KAAOK,EAAUL,IAAMG,EAAaG,UACzCT,EAAKI,MAAQI,EAAUJ,KAAOE,EAAaI,WAGzCC,SACEC,UAAU,0DACVC,QAAS,SAACC,GACRA,EAAEC,iBACFD,EAAEE,iBACJ,EACAC,MAAO,CACLhB,MAAOD,EAAKC,MACZC,OAAQF,EAAKE,OACbC,IAAKH,EAAKG,IAAM,EAChBC,KAAMJ,EAAKI,MACZc,SAAA,CAEa,WAAbhC,EAAIiC,MAAqBlC,EAACmC,EAAe,CAAClC,IAAKA,EAAKC,IAAKA,IAC5C,WAAbD,EAAIiC,MAAqBlC,EAACoC,EAAe,CAACnC,IAAKA,EAAKC,IAAKA,IAC5C,WAAbD,EAAIiC,MAAqBlC,EAACqC,EAAe,CAACpC,IAAKA,EAAKC,IAAKA,MAGhE"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsx as t}from"react/jsx-runtime";import{useState as e}from"react";import{useColumnValidateContext as r}from"../../sheet/providers.js";import{CellInput as o}from"./base-input.js";import{useEditActionContext as n}from"../provider.js";function u(u){var a=u.col,i=r(a.key),m=n().endEditing,l=u.row[a.key],f=e(l.toString()),g=f[0],v=f[1];return t(o,{value:g,onChange:function(t){t.preventDefault(),""!==t.target.value?"-"!==t.target.value&&"0-"!==t.target.value?t.target.value.match(/^-?[0-9]+\.$/)?v(t.target.value):isNaN(Number(t.target.value))||v(Number(t.target.value).toString()):v("-0"):v("0")},onBlur:function(t){t.preventDefault(),Number(g)!==l?i(g)?function(t){a.editable&&a.onCellBlur(a.key,Number(t),u.row,m)}(g):setTimeout((function(){t.target.focus()}),100):m()},reset:function(){return v(l.toString())},endEditing:m})}export{u as NumberCellInput};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{useState as e}from"react";import{useColumnValidateContext as r}from"../../sheet/providers.js";import{CellInput as n}from"./base-input.js";import{useEditActionContext as o}from"../provider.js";var i=/^-?[0-9]*\.?[0-9]*$/;function a(a){var u=a.col,c=r(u.key),s=o().endEditing,f=a.row[u.key],l=e(f.toString()),m=l[0],p=l[1];return t(n,{value:m,onChange:function(t){t.preventDefault();var e=t.target.value.replace(/[0-9]/g,(function(t){return String.fromCharCode(t.charCodeAt(0)-65248)})).replace(/[.。]/g,".").replace(/[-ー−]/g,"-");i.test(e)&&p(e)},onBlur:function(t){t.preventDefault();var e,r,n,o=(r=(e=m).startsWith("-"),(n=r?e.slice(1):e).endsWith(".")&&(n=n.slice(0,-1)),n.startsWith(".")&&(n="0".concat(n)),""===n?"0":r?"-".concat(n):n);Number(o)!==f?c(o)?function(t){u.editable&&u.onCellBlur(u.key,Number(t),a.row,s)}(o):setTimeout((function(){t.target.focus()}),100):s()},reset:function(){return p(f.toString())},endEditing:s})}export{a as NumberCellInput};
3
2
  //# sourceMappingURL=number-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"number-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"number-input.js","sources":["../../../../../../src/table/edit/ui/number-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { useColumnValidateContext } from \"../../sheet/providers\";\nimport { CellInput } from \"./base-input\";\nimport { useEditActionContext } from \"../provider\";\nimport {\n DataObject,\n DataRecord,\n TColumnProperty,\n TNumberCellEditingCondition,\n} from \"../../table/type\";\n\ntype TPropsCellInput = {\n col: TColumnProperty<DataRecord> & TNumberCellEditingCondition<DataRecord>;\n row: DataObject<DataRecord>;\n};\n\n// Text that can still become a number while typing, e.g. \"\", \"-\", \"1.\", \".5\".\nconst EDITING_NUMBER_PATTERN = /^-?[0-9]*\\.?[0-9]*$/;\n\n// Converts full-width digits and signs (typed with a Japanese IME) to ASCII.\nfunction toHalfWidth(text: string) {\n return text\n .replace(/[0-9]/g, (ch) => String.fromCharCode(ch.charCodeAt(0) - 0xfee0))\n .replace(/[.。]/g, \".\")\n .replace(/[-ー−]/g, \"-\");\n}\n\n// Turns in-progress text into a complete number string: \"\" and \"-\" become\n// \"0\", \".5\" becomes \"0.5\" and \"3.\" becomes \"3\".\nfunction normalizeNumberText(text: string) {\n const negative = text.startsWith(\"-\");\n let body = negative ? text.slice(1) : text;\n\n if (body.endsWith(\".\")) body = body.slice(0, -1);\n if (body.startsWith(\".\")) body = `0${body}`;\n if (body === \"\") return \"0\";\n\n return negative ? `-${body}` : body;\n}\n\nexport function NumberCellInput(props: TPropsCellInput) {\n const col = props.col;\n const validate = useColumnValidateContext(col.key);\n const { endEditing } = useEditActionContext();\n const prevValue = props.row[col.key] as number;\n const [value, setValue] = useState(prevValue.toString());\n\n const updateCellValue = (value: string) => {\n if (col.editable) {\n col.onCellBlur(col.key, Number(value), props.row, endEditing);\n }\n };\n\n return (\n <CellInput\n value={value}\n onChange={(e) => {\n e.preventDefault();\n\n const next = toHalfWidth(e.target.value);\n\n // Keep the raw text while typing so values like \"1.0\" or \"-\" are not\n // collapsed before the user finishes. It becomes a number on blur.\n if (!EDITING_NUMBER_PATTERN.test(next)) {\n return;\n }\n\n setValue(next);\n }}\n onBlur={(e) => {\n e.preventDefault();\n\n const normalized = normalizeNumberText(value);\n\n if (Number(normalized) === prevValue) {\n endEditing();\n return;\n }\n\n if (!validate(normalized)) {\n setTimeout(() => {\n e.target.focus();\n }, 100);\n return;\n }\n\n updateCellValue(normalized);\n }}\n reset={() => setValue(prevValue.toString())}\n endEditing={endEditing}\n />\n );\n}\n"],"names":["EDITING_NUMBER_PATTERN","NumberCellInput","props","col","validate","useColumnValidateContext","key","endEditing","useEditActionContext","prevValue","row","_a","useState","toString","value","setValue","_jsx","CellInput","onChange","e","preventDefault","next","target","replace","ch","String","fromCharCode","charCodeAt","test","onBlur","text","negative","body","normalized","startsWith","slice","endsWith","concat","Number","editable","onCellBlur","updateCellValue","setTimeout","focus","reset"],"mappings":"4PAmBA,IAAMA,EAAyB,sBAuBzB,SAAUC,EAAgBC,GAC9B,IAAMC,EAAMD,EAAMC,IACZC,EAAWC,EAAyBF,EAAIG,KACtCC,EAAeC,eACjBC,EAAYP,EAAMQ,IAAIP,EAAIG,KAC1BK,EAAoBC,EAASH,EAAUI,YAAtCC,EAAKH,EAAA,GAAEI,OAQd,OACEC,EAACC,EAAS,CACRH,MAAOA,EACPI,SAAU,SAACC,GACTA,EAAEC,iBAEF,IAAMC,EAAmBF,EAAEG,OAAOR,MArCrCS,QAAQ,UAAU,SAACC,GAAO,OAAAC,OAAOC,aAAaF,EAAGG,WAAW,GAAK,MAAvC,IAC1BJ,QAAQ,QAAS,KACjBA,QAAQ,SAAU,KAuCVvB,EAAuB4B,KAAKP,IAIjCN,EAASM,EACX,EACAQ,OAAQ,SAACV,GACPA,EAAEC,iBAEF,IA3CqBU,EACrBC,EACFC,EAyCQC,GA1CNF,GADqBD,EA2CkBhB,GA1CvBoB,WAAW,MAC7BF,EAAOD,EAAWD,EAAKK,MAAM,GAAKL,GAE7BM,SAAS,OAAMJ,EAAOA,EAAKG,MAAM,GAAG,IACzCH,EAAKE,WAAW,OAAMF,EAAO,IAAAK,OAAIL,IACxB,KAATA,EAAoB,IAEjBD,EAAW,IAAAM,OAAIL,GAASA,GAqCrBM,OAAOL,KAAgBxB,EAKtBL,EAAS6B,GAhCI,SAACnB,GACnBX,EAAIoC,UACNpC,EAAIqC,WAAWrC,EAAIG,IAAKgC,OAAOxB,GAAQZ,EAAMQ,IAAKH,EAEtD,CAmCMkC,CAAgBR,GANdS,YAAW,WACTvB,EAAEG,OAAOqB,OACX,GAAG,KAPHpC,GAYJ,EACAqC,MAAO,WAAM,OAAA7B,EAASN,EAAUI,WAAnB,EACbN,WAAYA,GAGlB"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{__spreadArray as e}from"../../../../node_modules/tslib/tslib.es6.js";import{jsx as o,Fragment as n,jsxs as t}from"react/jsx-runtime";import{useState as r,useRef as i,useEffect as u,useMemo as l}from"react";import{useEditActionContext as s}from"../provider.js";import{CancelIcon as c}from"../../../icon/cancel-icon.js";import{SelectBox as a}from"../../../select-box/index.js";import{useTableIdGenerator as f}from"../../id/provider.js";function m(m){var d=f(),p=m.col,v=s().endEditing,w=m.row[p.key],b=r(w),j=b[0],E=b[1],g=i(null),x=i(null);u((function(){x.current&&x.current.focus()}),[x]);var y=function(e){p.editable&&p.onCellBlur(p.key,e,m.row,v)};if(!p.editable)return o(n,{});u((function(){var e=function(e){var o=g.current,n=e.target;n instanceof Node&&(null==o?void 0:o.contains(n))||(j!==w?y(j):v())};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[j,y,v,w]);var N=l((function(){return p.allowEmpty?e([{value:"",label:""===w?"-- 未選択 --":"-- 選択解除 --"}],p.options,!0):p.options}),[p.options,p.allowEmpty,w]);return t("div",{ref:g,className:"flex justify-between gap-1 w-full items-center",children:[o(a,{id:d.getEditorId(),inputRef:x,value:j,defaultIsOpen:!0,options:N,onSelect:function(e){E(e),y(e)}}),o("button",{className:"cursor-pointer",onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){E(w),v()}),300)},children:o(c,{size:16})})]})}export{m as SelectCellInput};
1
+ "use client";import{__spreadArray as e}from"../../../../node_modules/tslib/tslib.es6.js";import{jsx as o,Fragment as n,jsxs as t}from"react/jsx-runtime";import{useState as r,useRef as i,useEffect as u,useMemo as l}from"react";import{useEditActionContext as s}from"../provider.js";import{CancelIcon as c}from"../../../icon/cancel-icon.js";import{SelectBox as a}from"../../../select-box/index.js";import{useTableIdGenerator as d}from"../../id/provider.js";function f(f){var m=d(),p=f.col,v=s().endEditing,b=f.row[p.key],w=!!p.editable&&p.allowEmpty,j=r(b),g=j[0],x=j[1],E=i(null),y=i(null);u((function(){y.current&&y.current.focus()}),[y]);var N=function(e){p.editable&&p.onCellBlur(p.key,e,f.row,v)};u((function(){var e=function(e){var o=E.current,n=e.target;n instanceof Node&&(null==o?void 0:o.contains(n))||(g!==b?N(g):v())};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}}),[g,N,v,b]);var h=l((function(){return w?e([{value:"",label:""===b?"-- 未選択 --":"-- 選択解除 --"}],p.options,!0):p.options}),[p.options,w,b]);return p.editable?t("div",{ref:E,className:"flex justify-between gap-1 w-full items-center",children:[o(a,{id:m.getEditorId(),inputRef:y,value:g,defaultIsOpen:!0,options:h,onSelect:function(e){x(e),N(e)}}),o("button",{className:"cursor-pointer",onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){x(b),v()}),300)},children:o(c,{size:16})})]}):o(n,{})}export{f as SelectCellInput};
3
2
  //# sourceMappingURL=select-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"select-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"select-input.js","sources":["../../../../../../src/table/edit/ui/select-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useEditActionContext } from \"../provider\";\nimport { CancelIcon } from \"../../../icon/cancel-icon\";\nimport {\n DataObject,\n DataRecord,\n TColumnProperty,\n TSelectCellEditingCondition,\n} from \"../../table/type\";\nimport { SelectBox } from \"../../../select-box\";\nimport { useTableIdGenerator } from \"../../id\";\n\ntype TPropsCellInput = {\n col: TColumnProperty<DataRecord> & TSelectCellEditingCondition<DataRecord>;\n row: DataObject<DataRecord>;\n};\n\nexport function SelectCellInput(props: TPropsCellInput) {\n const IdGenerator = useTableIdGenerator();\n const col = props.col;\n const { endEditing } = useEditActionContext();\n const prevValue = props.row[col.key] as string;\n const allowEmpty = col.editable ? col.allowEmpty : false;\n const [value, setValue] = useState(prevValue);\n const ref = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n }\n }, [inputRef]);\n\n const updateCellValue = (value: string) => {\n if (col.editable) {\n col.onCellBlur(col.key, value, props.row, endEditing);\n }\n };\n\n useEffect(() => {\n const onClickOutOfSelectBox = (e: MouseEvent) => {\n const selectInputElement = ref.current;\n const ele = e.target;\n\n if (ele instanceof Node && selectInputElement?.contains(ele)) return;\n\n if (value === prevValue) {\n endEditing();\n return;\n }\n\n updateCellValue(value);\n };\n\n document.addEventListener(\"mousedown\", onClickOutOfSelectBox);\n\n return () => {\n document.removeEventListener(\"mousedown\", onClickOutOfSelectBox);\n };\n }, [value, updateCellValue, endEditing, prevValue]);\n\n const options = useMemo(() => {\n if (allowEmpty) {\n return [\n {\n value: \"\",\n label: prevValue === \"\" ? \"-- 未選択 --\" : \"-- 選択解除 --\",\n },\n ...col.options,\n ];\n } else {\n return col.options;\n }\n }, [col.options, allowEmpty, prevValue]);\n\n // Return only after every hook has run, so hooks are always called in the\n // same order.\n if (!col.editable) return <></>;\n\n return (\n <div ref={ref} className=\"flex justify-between gap-1 w-full items-center\">\n <SelectBox\n id={IdGenerator.getEditorId()}\n inputRef={inputRef}\n value={value}\n defaultIsOpen={true}\n options={options}\n onSelect={(value) => {\n setValue(value);\n updateCellValue(value);\n }}\n />\n <button\n className=\"cursor-pointer\"\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n setValue(prevValue);\n endEditing();\n }, 300);\n }}\n >\n <CancelIcon size={16} />\n </button>\n </div>\n );\n}\n"],"names":["SelectCellInput","props","IdGenerator","useTableIdGenerator","col","endEditing","useEditActionContext","prevValue","row","key","allowEmpty","editable","_a","useState","value","setValue","ref","useRef","inputRef","useEffect","current","focus","updateCellValue","onCellBlur","onClickOutOfSelectBox","e","selectInputElement","ele","target","Node","contains","document","addEventListener","removeEventListener","options","useMemo","__spreadArray","label","_jsxs","className","children","_jsx","SelectBox","id","getEditorId","defaultIsOpen","onSelect","onMouseDown","preventDefault","stopPropagation","setTimeout","CancelIcon","size"],"mappings":"scAmBM,SAAUA,EAAgBC,GAC9B,IAAMC,EAAcC,IACdC,EAAMH,EAAMG,IACVC,EAAeC,eACjBC,EAAYN,EAAMO,IAAIJ,EAAIK,KAC1BC,IAAaN,EAAIO,UAAWP,EAAIM,WAChCE,EAAoBC,EAASN,GAA5BO,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAChBI,EAAMC,EAAuB,MAC7BC,EAAWD,EAAyB,MAE1CE,GAAU,WACJD,EAASE,SACXF,EAASE,QAAQC,OAErB,GAAG,CAACH,IAEJ,IAAMI,EAAkB,SAACR,GACnBV,EAAIO,UACNP,EAAImB,WAAWnB,EAAIK,IAAKK,EAAOb,EAAMO,IAAKH,EAE9C,EAEAc,GAAU,WACR,IAAMK,EAAwB,SAACC,GAC7B,IAAMC,EAAqBV,EAAII,QACzBO,EAAMF,EAAEG,OAEVD,aAAeE,OAAQH,aAAkB,EAAlBA,EAAoBI,SAASH,MAEpDb,IAAUP,EAKde,EAAgBR,GAJdT,IAKJ,EAIA,OAFA0B,SAASC,iBAAiB,YAAaR,GAEhC,WACLO,SAASE,oBAAoB,YAAaT,EAC5C,CACF,GAAG,CAACV,EAAOQ,EAAiBjB,EAAYE,IAExC,IAAM2B,EAAUC,GAAQ,WACtB,OAAIzB,EACF0B,EAAA,CACE,CACEtB,MAAO,GACPuB,MAAqB,KAAd9B,EAAmB,YAAc,eAEvCH,EAAI8B,SAAO,GAGT9B,EAAI8B,OAEf,GAAG,CAAC9B,EAAI8B,QAASxB,EAAYH,IAI7B,OAAKH,EAAIO,SAGP2B,EAAA,MAAA,CAAKtB,IAAKA,EAAKuB,UAAU,iDAAgDC,SAAA,CACvEC,EAACC,EAAS,CACRC,GAAIzC,EAAY0C,cAChB1B,SAAUA,EACVJ,MAAOA,EACP+B,eAAe,EACfX,QAASA,EACTY,SAAU,SAAChC,GACTC,EAASD,GACTQ,EAAgBR,EAClB,IAEF2B,EAAA,SAAA,CACEF,UAAU,iBACVQ,YAAa,SAACtB,GACZA,EAAEuB,iBACFvB,EAAEwB,kBACFC,YAAW,WACTnC,EAASR,GACTF,GACF,GAAG,IACL,EAACmC,SAEDC,EAACU,EAAU,CAACC,KAAM,UA1BEX,OA8B5B"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsx as t}from"react/jsx-runtime";import{useState as e}from"react";import{useEditActionContext as r}from"../provider.js";import{useColumnValidateContext as o}from"../../sheet/providers.js";import{CellInput as n}from"./base-input.js";function i(i){var u=i.col,f=o(u.key),a=r().endEditing,m=i.row[u.key],p=e(m),c=p[0],l=p[1];return t(n,{value:c,onChange:function(t){t.preventDefault(),l(t.target.value)},onBlur:function(t){t.preventDefault(),c!==m?f(c)?function(t){u.editable&&u.onCellBlur(u.key,t,i.row,a)}(c):setTimeout((function(){t.target.focus()}),100):a()},reset:function(){return l(m.toString())},endEditing:a})}export{i as StringCellInput};
1
+ "use client";import{jsx as e}from"react/jsx-runtime";import{useState as t}from"react";import{useEditActionContext as r}from"../provider.js";import{useColumnValidateContext as n}from"../../sheet/providers.js";import{CellInput as o}from"./base-input.js";function i(i){var u=i.col,f=n(u.key),a=r().endEditing,m=i.row[u.key],c=t(m),l=c[0],p=c[1];return e(o,{value:l,onChange:function(e){e.preventDefault(),p(e.target.value)},onBlur:function(e){e.preventDefault(),l!==m?f(l)?function(e){u.editable&&u.onCellBlur(u.key,e,i.row,a)}(l):setTimeout((function(){e.target.focus()}),100):a()},reset:function(){return p(m.toString())},endEditing:a})}export{i as StringCellInput};
3
2
  //# sourceMappingURL=string-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"string-input.js","sources":["../../../../../../src/table/edit/ui/string-input.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport { useEditActionContext } from \"../provider\";\nimport { useColumnValidateContext } from \"../../sheet/providers\";\nimport { CellInput } from \"./base-input\";\nimport {\n DataObject,\n DataRecord,\n TColumnProperty,\n TStringCellEditingCondition,\n} from \"../../table/type\";\n\ntype TPropsCellInput = {\n col: TColumnProperty<DataRecord> & TStringCellEditingCondition<DataRecord>;\n row: DataObject<DataRecord>;\n};\n\nexport function StringCellInput(props: TPropsCellInput) {\n const col = props.col;\n const validate = useColumnValidateContext(col.key);\n const { endEditing } = useEditActionContext();\n const prevValue = props.row[col.key] as string;\n const [value, setValue] = useState(prevValue);\n\n const updateCellValue = (value: string) => {\n if (col.editable) {\n col.onCellBlur(col.key, value, props.row, endEditing);\n }\n };\n\n return (\n <CellInput\n value={value}\n onChange={(e) => {\n e.preventDefault();\n setValue(e.target.value);\n }}\n onBlur={(e) => {\n e.preventDefault();\n\n if (value === prevValue) {\n endEditing();\n return;\n }\n\n if (!validate(value)) {\n setTimeout(() => {\n e.target.focus();\n }, 100);\n return;\n }\n\n updateCellValue(value);\n }}\n reset={() => setValue(prevValue.toString())}\n endEditing={endEditing}\n />\n );\n}\n"],"names":["StringCellInput","props","col","validate","useColumnValidateContext","key","endEditing","useEditActionContext","prevValue","row","_a","useState","value","setValue","_jsx","CellInput","onChange","e","preventDefault","target","onBlur","editable","onCellBlur","updateCellValue","setTimeout","focus","reset","toString"],"mappings":"4PAkBM,SAAUA,EAAgBC,GAC9B,IAAMC,EAAMD,EAAMC,IACZC,EAAWC,EAAyBF,EAAIG,KACtCC,EAAeC,eACjBC,EAAYP,EAAMQ,IAAIP,EAAIG,KAC1BK,EAAoBC,EAASH,GAA5BI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAQtB,OACEI,EAACC,EAAS,CACRH,MAAOA,EACPI,SAAU,SAACC,GACTA,EAAEC,iBACFL,EAASI,EAAEE,OAAOP,MACpB,EACAQ,OAAQ,SAACH,GACPA,EAAEC,iBAEEN,IAAUJ,EAKTL,EAASS,GArBI,SAACA,GACnBV,EAAImB,UACNnB,EAAIoB,WAAWpB,EAAIG,IAAKO,EAAOX,EAAMQ,IAAKH,EAE9C,CAwBMiB,CAAgBX,GANdY,YAAW,WACTP,EAAEE,OAAOM,OACX,GAAG,KAPHnB,GAYJ,EACAoB,MAAO,WAAM,OAAAb,EAASL,EAAUmB,WAAnB,EACbrB,WAAYA,GAGlB"}
@@ -1,2 +1,2 @@
1
- import{useReducer as e,useMemo as t}from"react";import{filterReducer as r}from"./reducer.js";var n=function(n){var a=e(r,{conditions:n}),o=a[0],i=a[1],u=t((function(){return{addFilter:function(e){i({type:"add",payload:{condition:e}})},removeFilter:function(e){i({type:"remove",payload:{index:e}})},clearFilter:function(){i({type:"clear"})}}}),[o.conditions]),s=t((function(){return{filter:function(e){return e.filter((function(e){return o.conditions.every((function(t){return function(e,t,r){switch(e.operator.type){case"number":if("single number"===e.operator.inputType){if(r.type!==e.operator.inputType)throw new Error("input type is not match");var n=r.payload.value;switch(e.operator.key){case"number:eq":return t===n;case"number:gt":return t>n;case"number:gte":return t>=n;case"number:lt":return t<n;case"number:lte":return t<=n;case"number:neq":return t!==n}}case"string":switch(e.operator.inputType){case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"string:is_not_null":return null!=t&&""!==t;case"string:is_null":return null==t||""===t}case"single string":if(r.type!==e.operator.inputType)throw new Error("input type is not match");var a=r.payload.value;switch(e.operator.key){case"string:eq":return t===a;case"string:like":return t.includes(a);case"string:neq":return t!==a;case"string:not_like":return!t.includes(a)}}case"select":switch(e.operator.inputType){case"select":if(r.type!==e.operator.inputType)throw new Error("input type is not match");a=r.payload.value;switch(e.operator.key){case"select:eq":return t===a;case"select:neq":return t!==a}case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"select:is_null":return null==t||""===t;case"select:is_not_null":return null!=t&&""!==t}}case"date":switch(e.operator.inputType){case"single date":if(r.type!==e.operator.inputType)throw new Error("input type is not match");var o=r.payload.value;if(!(t instanceof Date))throw new Error("date value is not Date object");switch(e.operator.key){case"date:eq":return t.getFullYear()===o.getFullYear()&&t.getMonth()===o.getMonth()&&t.getDate()===o.getDate();case"date:neq":return t.getFullYear()!==o.getFullYear()||t.getMonth()!==o.getMonth()||t.getDate()!==o.getDate();case"date:gt":return t>o;case"date:gte":return t>=o;case"date:lt":return t<o;case"date:lte":return t<=o}case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"date:is_null":return null==t||""===t;case"date:is_not_null":return null!=t&&""!==t}}case"datetime":switch(e.operator.inputType){case"single datetime":if(r.type!==e.operator.inputType)throw new Error("input type is not match");o=r.payload.value;switch(e.operator.key){case"datetime:gt":return t>o;case"datetime:gte":return t>=o;case"datetime:lt":return t<o;case"datetime:lte":return t<=o}case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"datetime:is_null":return null==t||""===t;case"datetime:is_not_null":return null!=t&&""!==t}}}}(t,e[t.target.key],t.input)}))}))}}}),[o.conditions]);return{state:o,actions:u,functions:s}};export{n as useFilterHook};
1
+ import{useReducer as e,useMemo as t}from"react";import{filterReducer as r}from"./reducer.js";var n=function(n){var a=e(r,{conditions:n}),i=a[0],u=a[1],s=t((function(){return{addFilter:function(e){u({type:"add",payload:{condition:e}})},removeFilter:function(e){u({type:"remove",payload:{index:e}})},clearFilter:function(){u({type:"clear"})}}}),[i.conditions]),c=t((function(){return{filter:function(e){return e.filter((function(e){return i.conditions.every((function(t){return o(t,e[t.target.key],t.input)}))}))}}}),[i.conditions]);return{state:i,actions:s,functions:c}};function a(e){return null==e?"":String(e)}function i(e){if(null==e||""===e)return null;var t=e instanceof Date?e:new Date(e);return isNaN(t.getTime())?null:1e4*t.getFullYear()+100*(t.getMonth()+1)+t.getDate()}function o(e,t,r){switch(e.operator.type){case"number":if("single number"===e.operator.inputType){if(r.type!==e.operator.inputType)throw new Error("input type is not match");var n=r.payload.value;switch(e.operator.key){case"number:eq":return t===n;case"number:gt":return t>n;case"number:gte":return t>=n;case"number:lt":return t<n;case"number:lte":return t<=n;case"number:neq":return t!==n}}case"string":switch(e.operator.inputType){case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"string:is_not_null":return null!=t&&""!==t;case"string:is_null":return null==t||""===t}case"single string":if(r.type!==e.operator.inputType)throw new Error("input type is not match");var o=r.payload.value;switch(e.operator.key){case"string:eq":return t===o;case"string:like":return a(t).includes(o);case"string:neq":return t!==o;case"string:not_like":return!a(t).includes(o)}}case"select":switch(e.operator.inputType){case"select":if(r.type!==e.operator.inputType)throw new Error("input type is not match");o=r.payload.value;switch(e.operator.key){case"select:eq":return t===o;case"select:neq":return t!==o}case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"select:is_null":return null==t||""===t;case"select:is_not_null":return null!=t&&""!==t}}case"date":switch(e.operator.inputType){case"single date":if(r.type!==e.operator.inputType)throw new Error("input type is not match");var u=i(t),s=i(r.payload.value);if(null===u||null===s)return!1;switch(e.operator.key){case"date:eq":return u===s;case"date:neq":return u!==s;case"date:gt":return u>s;case"date:gte":return u>=s;case"date:lt":return u<s;case"date:lte":return u<=s}case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"date:is_null":return null==t||""===t;case"date:is_not_null":return null!=t&&""!==t}}case"datetime":switch(e.operator.inputType){case"single datetime":if(r.type!==e.operator.inputType)throw new Error("input type is not match");var c=r.payload.value;switch(e.operator.key){case"datetime:gt":return t>c;case"datetime:gte":return t>=c;case"datetime:lt":return t<c;case"datetime:lte":return t<=c}case"none":if(r.type!==e.operator.inputType)throw new Error("input type is not match");switch(e.operator.key){case"datetime:is_null":return null==t||""===t;case"datetime:is_not_null":return null!=t&&""!==t}}}}export{o as isMatchCondition,n as useFilterHook};
2
2
  //# sourceMappingURL=hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook.js","sources":["../../../../../src/table/filter-v2/hook.ts"],"sourcesContent":["import { useMemo, useReducer } from \"react\";\nimport { TFilterHook } from \"./type\";\nimport { filterReducer } from \"./reducer\";\nimport { Condition } from \"../../search-bar\";\nimport { DataObject, DataRecord } from \"../table/type\";\nimport { SearchInput } from \"../../search-bar/condition-search-bar/condition-input-management/type\";\n\nexport const useFilterHook: TFilterHook = (initialConditions) => {\n const [state, dispatch] = useReducer(filterReducer, {\n conditions: initialConditions,\n });\n\n const actions = useMemo(\n () => ({\n addFilter: (condition: Condition) => {\n dispatch({ type: \"add\", payload: { condition } });\n },\n removeFilter: (index: number) => {\n dispatch({ type: \"remove\", payload: { index } });\n },\n clearFilter: () => {\n dispatch({ type: \"clear\" });\n },\n }),\n [state.conditions]\n );\n\n const functions = useMemo(\n () => ({\n filter: <T extends DataRecord>(rows: DataObject<T>[]) => {\n return rows.filter((row) => {\n return state.conditions.every((condition) => {\n const value = row[condition.target.key];\n return isMatchCondition(condition, value, condition.input);\n });\n });\n },\n }),\n [state.conditions]\n );\n\n return {\n state,\n actions,\n functions,\n };\n};\n\nfunction isMatchCondition(\n condition: Condition,\n targetValue: any,\n input: SearchInput\n): boolean {\n switch (condition.operator.type) {\n case \"number\":\n switch (condition.operator.inputType) {\n case \"single number\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const numValue = input.payload.value;\n\n switch (condition.operator.key) {\n case \"number:eq\":\n return targetValue === numValue;\n case \"number:gt\":\n return targetValue > numValue;\n case \"number:gte\":\n return targetValue >= numValue;\n case \"number:lt\":\n return targetValue < numValue;\n case \"number:lte\":\n return targetValue <= numValue;\n case \"number:neq\":\n return targetValue !== numValue;\n }\n }\n\n case \"string\":\n switch (condition.operator.inputType) {\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"string:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n case \"string:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n }\n case \"single string\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const value = input.payload.value;\n\n switch (condition.operator.key) {\n case \"string:eq\":\n return targetValue === value;\n case \"string:like\":\n return targetValue.includes(value);\n case \"string:neq\":\n return targetValue !== value;\n case \"string:not_like\":\n return !targetValue.includes(value);\n }\n }\n\n case \"select\":\n switch (condition.operator.inputType) {\n case \"select\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const value = input.payload.value;\n\n switch (condition.operator.key) {\n case \"select:eq\":\n return targetValue === value;\n case \"select:neq\":\n return targetValue !== value;\n }\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"select:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n case \"select:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n }\n }\n case \"date\":\n switch (condition.operator.inputType) {\n case \"single date\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const dateValue = input.payload.value;\n\n if (!(targetValue instanceof Date)) {\n throw new Error(\"date value is not Date object\");\n }\n\n switch (condition.operator.key) {\n case \"date:eq\":\n return (\n targetValue.getFullYear() === dateValue.getFullYear() &&\n targetValue.getMonth() === dateValue.getMonth() &&\n targetValue.getDate() === dateValue.getDate()\n );\n case \"date:neq\":\n return (\n targetValue.getFullYear() !== dateValue.getFullYear() ||\n targetValue.getMonth() !== dateValue.getMonth() ||\n targetValue.getDate() !== dateValue.getDate()\n );\n case \"date:gt\":\n return targetValue > dateValue;\n case \"date:gte\":\n return targetValue >= dateValue;\n case \"date:lt\":\n return targetValue < dateValue;\n case \"date:lte\":\n return targetValue <= dateValue;\n }\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"date:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n case \"date:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n }\n }\n case \"datetime\":\n switch (condition.operator.inputType) {\n case \"single datetime\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const dateValue = input.payload.value;\n\n switch (condition.operator.key) {\n case \"datetime:gt\":\n return targetValue > dateValue;\n case \"datetime:gte\":\n return targetValue >= dateValue;\n case \"datetime:lt\":\n return targetValue < dateValue;\n case \"datetime:lte\":\n return targetValue <= dateValue;\n }\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"datetime:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n case \"datetime:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n }\n }\n }\n}\n"],"names":["useFilterHook","initialConditions","_a","useReducer","filterReducer","conditions","state","dispatch","actions","useMemo","addFilter","condition","type","payload","removeFilter","index","clearFilter","functions","filter","rows","row","every","targetValue","input","operator","inputType","Error","numValue","value","key","includes","dateValue","Date","getFullYear","getMonth","getDate","isMatchCondition","target"],"mappings":"6FAOO,IAAMA,EAA6B,SAACC,GACnC,IAAAC,EAAoBC,EAAWC,EAAe,CAClDC,WAAYJ,IADPK,EAAKJ,EAAA,GAAEK,OAIRC,EAAUC,GACd,WAAM,MAAA,CACJC,UAAW,SAACC,GACVJ,EAAS,CAAEK,KAAM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C,WACzB,IAAK,kBACH,GAAIF,EAAMX,OAASD,EAAUa,SAASC,UACpC,MAAM,IAAIC,MAAM,2BAGZK,EAAYR,EAAMV,QAAQe,MAEhC,OAAQjB,EAAUa,SAASK,KACzB,IAAK,cACH,OAAOP,EAAcS,EACvB,IAAK,eACH,OAAOT,GAAeS,EACxB,IAAK,cACH,OAAOT,EAAcS,EACvB,IAAK,eACH,OAAOT,GAAeS,EAE5B,IAAK,OACH,GAAIR,EAAMX,OAASD,EAAUa,SAASC,UACpC,MAAM,IAAIC,MAAM,2BAGlB,OAAQf,EAAUa,SAASK,KACzB,IAAK,mBACH,OACEP,SAEgB,KAAhBA,EAEJ,IAAK,uBACH,OACEA,SAEgB,KAAhBA,IAKhB,CAxNmBc,CAAiBzB,EADVS,EAAIT,EAAU0B,OAAOR,KACOlB,EAAUY,MACtD,GACF,GACF,EARI,GAUN,CAACjB,EAAMD,aAGT,MAAO,CACLC,MAAKA,EACLE,QAAOA,EACPS,UAASA,EAEb"}
1
+ {"version":3,"file":"hook.js","sources":["../../../../../src/table/filter-v2/hook.ts"],"sourcesContent":["import { useMemo, useReducer } from \"react\";\nimport { TFilterHook } from \"./type\";\nimport { filterReducer } from \"./reducer\";\nimport { Condition } from \"../../search-bar\";\nimport { DataObject, DataRecord } from \"../table/type\";\nimport { SearchInput } from \"../../search-bar/condition-search-bar/condition-input-management/type\";\n\nexport const useFilterHook: TFilterHook = (initialConditions) => {\n const [state, dispatch] = useReducer(filterReducer, {\n conditions: initialConditions,\n });\n\n const actions = useMemo(\n () => ({\n addFilter: (condition: Condition) => {\n dispatch({ type: \"add\", payload: { condition } });\n },\n removeFilter: (index: number) => {\n dispatch({ type: \"remove\", payload: { index } });\n },\n clearFilter: () => {\n dispatch({ type: \"clear\" });\n },\n }),\n [state.conditions]\n );\n\n const functions = useMemo(\n () => ({\n filter: <T extends DataRecord>(rows: DataObject<T>[]) => {\n return rows.filter((row) => {\n return state.conditions.every((condition) => {\n const value = row[condition.target.key];\n return isMatchCondition(condition, value, condition.input);\n });\n });\n },\n }),\n [state.conditions]\n );\n\n return {\n state,\n actions,\n functions,\n };\n};\n\nfunction toText(value: unknown): string {\n return value === null || value === undefined ? \"\" : String(value);\n}\n\n/** Returns a number like 20240101 for the local calendar day, or null. */\nfunction toDayNumber(value: unknown): number | null {\n if (value === null || value === undefined || value === \"\") return null;\n\n const date = value instanceof Date ? value : new Date(value as string);\n if (isNaN(date.getTime())) return null;\n\n return (\n date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate()\n );\n}\n\n/** Exported for tests. */\nexport function isMatchCondition(\n condition: Condition,\n targetValue: any,\n input: SearchInput\n): boolean {\n switch (condition.operator.type) {\n case \"number\":\n switch (condition.operator.inputType) {\n case \"single number\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const numValue = input.payload.value;\n\n switch (condition.operator.key) {\n case \"number:eq\":\n return targetValue === numValue;\n case \"number:gt\":\n return targetValue > numValue;\n case \"number:gte\":\n return targetValue >= numValue;\n case \"number:lt\":\n return targetValue < numValue;\n case \"number:lte\":\n return targetValue <= numValue;\n case \"number:neq\":\n return targetValue !== numValue;\n }\n }\n\n case \"string\":\n switch (condition.operator.inputType) {\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"string:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n case \"string:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n }\n case \"single string\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const value = input.payload.value;\n\n switch (condition.operator.key) {\n case \"string:eq\":\n return targetValue === value;\n case \"string:like\":\n return toText(targetValue).includes(value);\n case \"string:neq\":\n return targetValue !== value;\n case \"string:not_like\":\n return !toText(targetValue).includes(value);\n }\n }\n\n case \"select\":\n switch (condition.operator.inputType) {\n case \"select\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const value = input.payload.value;\n\n switch (condition.operator.key) {\n case \"select:eq\":\n return targetValue === value;\n case \"select:neq\":\n return targetValue !== value;\n }\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"select:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n case \"select:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n }\n }\n case \"date\":\n switch (condition.operator.inputType) {\n case \"single date\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n // Compare by calendar day, so a row at 10:30 on Jan 1 counts as\n // \"Jan 1\" for every operator, not only for \"=\".\n const targetDay = toDayNumber(targetValue);\n const inputDay = toDayNumber(input.payload.value);\n\n if (targetDay === null || inputDay === null) {\n return false;\n }\n\n switch (condition.operator.key) {\n case \"date:eq\":\n return targetDay === inputDay;\n case \"date:neq\":\n return targetDay !== inputDay;\n case \"date:gt\":\n return targetDay > inputDay;\n case \"date:gte\":\n return targetDay >= inputDay;\n case \"date:lt\":\n return targetDay < inputDay;\n case \"date:lte\":\n return targetDay <= inputDay;\n }\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"date:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n case \"date:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n }\n }\n case \"datetime\":\n switch (condition.operator.inputType) {\n case \"single datetime\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n const dateValue = input.payload.value;\n\n switch (condition.operator.key) {\n case \"datetime:gt\":\n return targetValue > dateValue;\n case \"datetime:gte\":\n return targetValue >= dateValue;\n case \"datetime:lt\":\n return targetValue < dateValue;\n case \"datetime:lte\":\n return targetValue <= dateValue;\n }\n case \"none\":\n if (input.type !== condition.operator.inputType) {\n throw new Error(\"input type is not match\");\n }\n\n switch (condition.operator.key) {\n case \"datetime:is_null\":\n return (\n targetValue === null ||\n targetValue === undefined ||\n targetValue === \"\"\n );\n case \"datetime:is_not_null\":\n return (\n targetValue !== null &&\n targetValue !== undefined &&\n targetValue !== \"\"\n );\n }\n }\n }\n}\n"],"names":["useFilterHook","initialConditions","_a","useReducer","filterReducer","conditions","state","dispatch","actions","useMemo","addFilter","condition","type","payload","removeFilter","index","clearFilter","functions","filter","rows","row","every","isMatchCondition","target","key","input","toText","value","String","toDayNumber","date","Date","isNaN","getTime","getFullYear","getMonth","getDate","targetValue","operator","inputType","Error","numValue","includes","targetDay","inputDay","dateValue"],"mappings":"6FAOO,IAAMA,EAA6B,SAACC,GACnC,IAAAC,EAAoBC,EAAWC,EAAe,CAClDC,WAAYJ,IADPK,EAAKJ,EAAA,GAAEK,OAIRC,EAAUC,GACd,WAAM,MAAA,CACJC,UAAW,SAACC,GACVJ,EAAS,CAAEK,KAAM,MAAOC,QAAS,CAAEF,UAASA,IAC9C,EACAG,aAAc,SAACC,GACbR,EAAS,CAAEK,KAAM,SAAUC,QAAS,CAAEE,MAAKA,IAC7C,EACAC,YAAa,WACXT,EAAS,CAAEK,KAAM,SACnB,EATI,GAWN,CAACN,EAAMD,aAGHY,EAAYR,GAChB,WAAM,MAAA,CACJS,OAAQ,SAAuBC,GAC7B,OAAOA,EAAKD,QAAO,SAACE,GAClB,OAAOd,EAAMD,WAAWgB,OAAM,SAACV,GAE7B,OAAOW,EAAiBX,EADVS,EAAIT,EAAUY,OAAOC,KACOb,EAAUc,MACtD,GACF,GACF,EARI,GAUN,CAACnB,EAAMD,aAGT,MAAO,CACLC,MAAKA,EACLE,QAAOA,EACPS,UAASA,EAEb,EAEA,SAASS,EAAOC,GACd,OAAOA,QAAwC,GAAKC,OAAOD,EAC7D,CAGA,S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IAAK,cACH,OAAOa,EAAcQ,EACvB,IAAK,eACH,OAAOR,GAAeQ,EACxB,IAAK,cACH,OAAOR,EAAcQ,EACvB,IAAK,eACH,OAAOR,GAAeQ,EAE5B,IAAK,OACH,GAAIpB,EAAMb,OAASD,EAAU2B,SAASC,UACpC,MAAM,IAAIC,MAAM,2BAGlB,OAAQ7B,EAAU2B,SAASd,KACzB,IAAK,mBACH,OACEa,SAEgB,KAAhBA,EAEJ,IAAK,uBACH,OACEA,SAEgB,KAAhBA,IAKhB"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsxs as e,jsx as r,Fragment as t}from"react/jsx-runtime";import{useRef as n,useState as o,useEffect as l}from"react";import{useColumnsWidthState as c}from"../header/columns-width/context.js";import"../../../node_modules/tslib/tslib.es6.js";import{useScrollXPosition as i}from"../header/x-scroll-position/context.js";function s(s){var u=i(),a=u.x,d=u.setScrollX,m=n(null),v=o({scrollX:0,scrollY:0,barYHeight:0,barXWidth:0}),h=v[0],b=v[1],f=c();return l((function(){var e=function(){if(m.current){d(m.current.scrollLeft);var e=m.current.scrollLeft/m.current.scrollWidth*100,r=m.current.scrollTop/m.current.scrollHeight*100,t=m.current.clientHeight/m.current.scrollHeight*100,n=m.current.clientWidth/m.current.scrollWidth*100;b({scrollX:e>100?100:e,scrollY:r>100?100:r,barYHeight:t>100?100:t,barXWidth:n>100?100:n})}};return e(),m.current&&m.current.addEventListener("scroll",e),function(){m.current&&m.current.removeEventListener("scroll",e)}}),[d,f]),l((function(){m.current&&(m.current.scrollLeft=a)}),[a]),e("div",{className:"relative",style:{maxWidth:s.maxWidth},children:[r("style",{children:"\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n "}),r("div",{ref:m,id:s.id,className:"relative w-full h-full max-w-full border border-gray-200 bg-white rounded-b-md overflow-auto ".concat(s.displayScroll?"":"teppen-no-scrollbar"),style:{maxHeight:s.maxHeight},children:s.children}),h.barYHeight<100&&e(t,{children:[r("div",{className:"absolute top-0 right-0 h-full w-2 bg-slate-200 opacity-30 pointer-events-none"}),r("div",{className:"absolute right-0 w-2 bg-slate-500 rounded-full cursor-grab active:cursor-grabbing",style:{top:"".concat(h.scrollY,"%"),height:"".concat(h.barYHeight,"%")},onMouseDown:function(e){var r,t=e.clientY,n=(null===(r=m.current)||void 0===r?void 0:r.scrollTop)||0,o=function(e){if(m.current){var r=(e.clientY-t)/h.barYHeight*100;m.current.scrollTop=n+r}},l=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}})]}),h.barXWidth<100&&e(t,{children:[r("div",{className:"absolute bottom-0 left-0 w-full h-2 bg-slate-200 opacity-30 pointer-events-none"}),r("div",{className:"absolute bottom-0 h-2 bg-slate-500 rounded-full cursor-grab active:cursor-grabbing",style:{left:"".concat(h.scrollX,"%"),width:"".concat(h.barXWidth,"%")},onMouseDown:function(e){var r;e.preventDefault(),e.stopPropagation();var t=e.clientX,n=(null===(r=m.current)||void 0===r?void 0:r.scrollLeft)||0,o=function(r){if(m.current){e.preventDefault(),e.stopPropagation();var o=(r.clientX-t)/h.barXWidth*100;m.current.scrollLeft=n+o}},l=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}})]})]})}export{s as Frame};
1
+ "use client";import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{useRef as n,useState as o,useEffect as l}from"react";import{useColumnsWidthState as c}from"../header/columns-width/context.js";import"../../../node_modules/tslib/tslib.es6.js";import{useScrollXPosition as i}from"../header/x-scroll-position/context.js";function s(s){var u=i(),a=u.x,d=u.setScrollX,m=n(null),v=o({scrollX:0,scrollY:0,barYHeight:0,barXWidth:0}),h=v[0],b=v[1],f=c();return l((function(){var e=function(){if(m.current){d(m.current.scrollLeft);var e=m.current.scrollLeft/m.current.scrollWidth*100,t=m.current.scrollTop/m.current.scrollHeight*100,r=m.current.clientHeight/m.current.scrollHeight*100,n=m.current.clientWidth/m.current.scrollWidth*100;b({scrollX:e>100?100:e,scrollY:t>100?100:t,barYHeight:r>100?100:r,barXWidth:n>100?100:n})}};return e(),m.current&&m.current.addEventListener("scroll",e),function(){m.current&&m.current.removeEventListener("scroll",e)}}),[d,f]),l((function(){m.current&&(m.current.scrollLeft=a)}),[a]),e("div",{className:"relative",style:{maxWidth:s.maxWidth},children:[t("style",{children:"\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n "}),t("div",{ref:m,id:s.id,className:"relative w-full h-full max-w-full border border-gray-200 bg-white rounded-b-md overflow-auto ".concat(s.displayScroll?"":"teppen-no-scrollbar"),style:{maxHeight:s.maxHeight},children:s.children}),h.barYHeight<100&&e(r,{children:[t("div",{className:"absolute top-0 right-0 h-full w-2 bg-slate-200 opacity-30 pointer-events-none"}),t("div",{className:"absolute right-0 w-2 bg-slate-500 rounded-full cursor-grab active:cursor-grabbing",style:{top:"".concat(h.scrollY,"%"),height:"".concat(h.barYHeight,"%")},onMouseDown:function(e){var t,r=e.clientY,n=(null===(t=m.current)||void 0===t?void 0:t.scrollTop)||0,o=function(e){if(m.current){var t=(e.clientY-r)/h.barYHeight*100;m.current.scrollTop=n+t}},l=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}})]}),h.barXWidth<100&&e(r,{children:[t("div",{className:"absolute bottom-0 left-0 w-full h-2 bg-slate-200 opacity-30 pointer-events-none"}),t("div",{className:"absolute bottom-0 h-2 bg-slate-500 rounded-full cursor-grab active:cursor-grabbing",style:{left:"".concat(h.scrollX,"%"),width:"".concat(h.barXWidth,"%")},onMouseDown:function(e){var t;e.preventDefault(),e.stopPropagation();var r=e.clientX,n=(null===(t=m.current)||void 0===t?void 0:t.scrollLeft)||0,o=function(t){if(m.current){e.preventDefault(),e.stopPropagation();var o=(t.clientX-r)/h.barXWidth*100;m.current.scrollLeft=n+o}},l=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",l)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",l)}})]})]})}export{s as Frame};
3
2
  //# sourceMappingURL=frame.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"frame.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"frame.js","sources":["../../../../../src/table/frame/frame.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { useColumnsWidthState, useScrollXPosition } from \"../header\";\n\ninterface IPropsFrameDesign {\n maxHeight?: string;\n maxWidth?: string;\n displayScroll?: boolean;\n}\n\ninterface IPropsFrame extends IPropsFrameDesign {\n id?: string;\n children: React.ReactNode;\n}\n\nexport function Frame(props: IPropsFrame) {\n const { x, setScrollX } = useScrollXPosition();\n const ref = useRef<HTMLDivElement>(null);\n // refのdiv内でのスクロール割合を保持\n const [scrollInfo, setScrollInfo] = useState({\n scrollX: 0,\n scrollY: 0,\n barYHeight: 0,\n barXWidth: 0,\n });\n const columnsWidhtState = useColumnsWidthState();\n\n useEffect(() => {\n const handleBodyScroll = () => {\n if (ref.current) {\n setScrollX(ref.current.scrollLeft);\n\n const scrollX =\n (ref.current.scrollLeft / ref.current.scrollWidth) * 100;\n const scrollY =\n (ref.current.scrollTop / ref.current.scrollHeight) * 100;\n const barYHeight =\n (ref.current.clientHeight / ref.current.scrollHeight) * 100;\n const barXWidth =\n (ref.current.clientWidth / ref.current.scrollWidth) * 100;\n\n setScrollInfo({\n scrollX: scrollX > 100 ? 100 : scrollX,\n scrollY: scrollY > 100 ? 100 : scrollY,\n barYHeight: barYHeight > 100 ? 100 : barYHeight,\n barXWidth: barXWidth > 100 ? 100 : barXWidth,\n });\n }\n };\n\n handleBodyScroll();\n\n if (ref.current) {\n ref.current.addEventListener(\"scroll\", handleBodyScroll);\n }\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener(\"scroll\", handleBodyScroll);\n }\n };\n }, [setScrollX, columnsWidhtState]);\n\n useEffect(() => {\n if (ref.current) {\n ref.current.scrollLeft = x;\n }\n }, [x]);\n\n return (\n <div className=\"relative\" style={{ maxWidth: props.maxWidth }}>\n <style>{`\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n `}</style>\n <div\n ref={ref}\n id={props.id}\n className={`relative w-full h-full max-w-full border border-gray-200 bg-white rounded-b-md overflow-auto ${\n props.displayScroll ? \"\" : \"teppen-no-scrollbar\"\n }`}\n style={{ maxHeight: props.maxHeight }}\n >\n {props.children}\n </div>\n\n {scrollInfo.barYHeight < 100 && (\n <>\n <div className=\"absolute top-0 right-0 h-full w-2 bg-slate-200 opacity-30 pointer-events-none\" />\n\n <div\n className={`absolute right-0 w-2 bg-slate-500 rounded-full cursor-grab active:cursor-grabbing`}\n style={{\n top: `${scrollInfo.scrollY}%`,\n height: `${scrollInfo.barYHeight}%`,\n }}\n onMouseDown={(e) => {\n const startY = e.clientY;\n const startScrollY = ref.current?.scrollTop || 0;\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n if (ref.current) {\n const deltaY =\n ((moveEvent.clientY - startY) / scrollInfo.barYHeight) *\n 100;\n ref.current.scrollTop = startScrollY + deltaY;\n }\n };\n\n const onMouseUp = () => {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n }}\n />\n </>\n )}\n\n {scrollInfo.barXWidth < 100 && (\n <>\n <div className=\"absolute bottom-0 left-0 w-full h-2 bg-slate-200 opacity-30 pointer-events-none\" />\n\n <div\n className={`absolute bottom-0 h-2 bg-slate-500 rounded-full cursor-grab active:cursor-grabbing`}\n style={{\n left: `${scrollInfo.scrollX}%`,\n width: `${scrollInfo.barXWidth}%`,\n }}\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n\n const startX = e.clientX;\n const startScrollX = ref.current?.scrollLeft || 0;\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n if (ref.current) {\n e.preventDefault();\n e.stopPropagation();\n\n const deltaX =\n ((moveEvent.clientX - startX) / scrollInfo.barXWidth) * 100;\n ref.current.scrollLeft = startScrollX + deltaX;\n }\n };\n\n const onMouseUp = () => {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n }}\n />\n </>\n )}\n </div>\n );\n}\n"],"names":["Frame","props","_a","useScrollXPosition","x","setScrollX","ref","useRef","_b","useState","scrollX","scrollY","barYHeight","barXWidth","scrollInfo","setScrollInfo","columnsWidhtState","useColumnsWidthState","useEffect","handleBodyScroll","current","scrollLeft","scrollX_1","scrollWidth","scrollY_1","scrollTop","scrollHeight","clientHeight","clientWidth","addEventListener","removeEventListener","_jsxs","className","style","maxWidth","children","_jsx","id","concat","displayScroll","maxHeight","_Fragment","top","height","onMouseDown","e","startY","clientY","startScrollY","onMouseMove","moveEvent","deltaY","onMouseUp","document","left","width","preventDefault","stopPropagation","startX","clientX","startScrollX","deltaX"],"mappings":"gVAgBM,SAAUA,EAAMC,GACd,IAAAC,EAAoBC,IAAlBC,EAACF,EAAAE,EAAEC,EAAUH,EAAAG,WACfC,EAAMC,EAAuB,MAE7BC,EAA8BC,EAAS,CAC3CC,QAAS,EACTC,QAAS,EACTC,WAAY,EACZC,UAAW,IAJNC,EAAUN,EAAA,GAAEO,OAMbC,EAAoBC,IA4C1B,OA1CAC,GAAU,WACR,IAAMC,EAAmB,WACvB,GAAIb,EAAIc,QAAS,CACff,EAAWC,EAAIc,QAAQC,YAEvB,IAAMC,EACHhB,EAAIc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,QAAS,CACf,IAAM+B,GACFD,EAAUH,QAAUD,GAAUhC,EAAWF,WAC3C,IACFN,EAAIc,QAAQK,UAAYuB,EAAeG,CACzC,CACF,EAEMC,EAAY,WAChBC,SAASvB,oBAAoB,YAAamB,GAC1CI,SAASvB,oBAAoB,UAAWsB,EAC1C,EAEAC,SAASxB,iBAAiB,YAAaoB,GACvCI,SAASxB,iBAAiB,UAAWuB,EACvC,OAKLtC,EAAWD,UAAY,KACtBkB,EAAAU,EAAA,CAAAN,SAAA,CACEC,SAAKJ,UAAU,oFAEfI,EAAA,MAAA,CACEJ,UAAW,qFACXC,MAAO,CACLqB,KAAM,GAAAhB,OAAGxB,EAAWJ,QAAO,KAC3B6C,MAAO,GAAAjB,OAAGxB,EAAWD,UAAS,MAEhC+B,YAAa,SAACC,SACZA,EAAEW,iBACFX,EAAEY,kBAEF,IAAMC,EAASb,EAAEc,QACXC,GAA0B,QAAX1D,EAAAI,EAAIc,eAAO,IAAAlB,OAAA,EAAAA,EAAEmB,aAAc,EAE1C4B,EAAc,SAACC,GACnB,GAAI5C,EAAIc,QAAS,CACfyB,EAAEW,iBACFX,EAAEY,kBAEF,IAAMI,GACFX,EAAUS,QAAUD,GAAU5C,EAAWD,UAAa,IAC1DP,EAAIc,QAAQC,WAAauC,EAAeC,CAC1C,CACF,EAEMT,EAAY,WAChBC,SAASvB,oBAAoB,YAAamB,GAC1CI,SAASvB,oBAAoB,UAAWsB,EAC1C,EAEAC,SAASxB,iBAAiB,YAAaoB,GACvCI,SAASxB,iBAAiB,UAAWuB,EACvC,SAMZ"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsx as r}from"react/jsx-runtime";import{DEFAULT_MIN_COL_WIDTH as t,DEFAULT_COL_WIDTH as i}from"../../constant.js";import{ColumnsWidthStateContext as e,ColumnsWidthActionContext as n}from"./context.js";import{useColumnsWidthReducer as o}from"./reducer.js";function c(t){var i=o(d(t.initialState)),c=i.state,a=i.action;return r(e.Provider,{value:c,children:r(n.Provider,{value:a,children:t.children})})}var d=function(r){return r.reduce((function(r,e,n){return r[e.key]={colWidth:e.initialWidth||i,minWidth:e.minWidth||t,index:n},r}),{})};export{c as ColumnsWidthProvider};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{useMemo as n}from"react";import{ColumnsWidthStateContext as i,ColumnsWidthActionContext as r,useColumnsWidthState as c}from"./context.js";import{useColumnsWidthReducer as e}from"./reducer.js";function o(c){var o=n((function(){return c.cols.map((function(t){return{key:t.key.toString(),initialWidth:t.initialWidth,minWidth:t.minWidth}}))}),[c.cols]),a=e(o),d=a.state,l=a.action;return t(i.Provider,{value:d,children:t(r.Provider,{value:l,children:c.children})})}function a(n){var i=c().columns,r='[id="'.concat(n.scopeId.replace(/["\\]/g,"\\$&").replace(/\n/g,"\\a "),'"]'),e=i.map((function(t){var n=t.index,i=t.colWidth;return"".concat(r," .table-col-").concat(n,"{width:").concat(i,"px;min-width:").concat(i,"px;max-width:").concat(i,"px;}")})).join("\n");return t("style",{children:e})}export{o as ColumnsWidthProvider,a as ColumnsWidthStyle};
3
2
  //# sourceMappingURL=provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"provider.js","sources":["../../../../../../src/table/header/columns-width/provider.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport { DataRecord, TTableColumn } from \"../../table/type\";\nimport {\n ColumnsWidthActionContext,\n ColumnsWidthStateContext,\n useColumnsWidthState,\n} from \"./context\";\nimport { useColumnsWidthReducer } from \"./reducer\";\n\nexport function ColumnsWidthProvider(props: {\n children: React.ReactNode;\n cols: TTableColumn<DataRecord>[];\n}) {\n const cols = useMemo(\n () =>\n props.cols.map((col) => ({\n key: col.key.toString(),\n initialWidth: col.initialWidth,\n minWidth: col.minWidth,\n })),\n [props.cols]\n );\n const { state, action } = useColumnsWidthReducer(cols);\n\n return (\n <ColumnsWidthStateContext.Provider value={state}>\n <ColumnsWidthActionContext.Provider value={action}>\n {props.children}\n </ColumnsWidthActionContext.Provider>\n </ColumnsWidthStateContext.Provider>\n );\n}\n\n// Escapes a value for use inside a double-quoted CSS attribute selector.\nfunction escapeCssString(value: string) {\n return value.replace(/[\"\\\\]/g, \"\\\\$&\").replace(/\\n/g, \"\\\\a \");\n}\n\n/**\n * Applies the column widths to the body cells (`.table-col-N`) of one table.\n * The rules are scoped to the element with `scopeId`, so several tables on\n * the same page do not affect each other, and cells rendered later (e.g.\n * after changing pages) get their width automatically.\n */\nexport function ColumnsWidthStyle(props: { scopeId: string }) {\n const { columns } = useColumnsWidthState();\n const scope = `[id=\"${escapeCssString(props.scopeId)}\"]`;\n\n const css = columns\n .map(\n ({ index, colWidth }) =>\n `${scope} .table-col-${index}{width:${colWidth}px;min-width:${colWidth}px;max-width:${colWidth}px;}`\n )\n .join(\"\\n\");\n\n return <style>{css}</style>;\n}\n"],"names":["ColumnsWidthProvider","props","cols","useMemo","map","col","key","toString","initialWidth","minWidth","_a","useColumnsWidthReducer","state","action","_jsx","ColumnsWidthStateContext","Provider","value","children","ColumnsWidthActionContext","ColumnsWidthStyle","columns","useColumnsWidthState","scope","concat","scopeId","replace","css","index","colWidth","join"],"mappings":"4PAWM,SAAUA,EAAqBC,GAInC,IAAMC,EAAOC,GACX,WACE,OAAAF,EAAMC,KAAKE,KAAI,SAACC,GAAQ,MAAA,CACtBC,IAAKD,EAAIC,IAAIC,WACbC,aAAcH,EAAIG,aAClBC,SAAUJ,EAAII,SAHQ,GAAxB,GAKF,CAACR,EAAMC,OAEHQ,EAAoBC,EAAuBT,GAAzCU,EAAKF,EAAAE,MAAEC,EAAMH,EAAAG,OAErB,OACEC,EAACC,EAAyBC,UAASC,MAAOL,EAAKM,SAC7CJ,EAACK,EAA0BH,SAAQ,CAACC,MAAOJ,EAAMK,SAC9CjB,EAAMiB,YAIf,CAaM,SAAUE,EAAkBnB,GACxB,IAAAoB,EAAYC,YACdC,EAAQ,QAAAC,OAAwBvB,EAAMwB,QAX/BC,QAAQ,SAAU,QAAQA,QAAQ,MAAO,QAWF,MAE9CC,EAAMN,EACTjB,KACC,SAACM,OAAEkB,EAAKlB,EAAAkB,MAAEC,EAAQnB,EAAAmB,SAChB,MAAA,GAAAL,OAAGD,EAAK,gBAAAC,OAAeI,EAAK,WAAAJ,OAAUK,EAAQ,iBAAAL,OAAgBK,EAAQ,iBAAAL,OAAgBK,EAAQ,OAA9F,IAEHC,KAAK,MAER,OAAOhB,EAAA,QAAA,CAAAI,SAAQS,GACjB"}
@@ -1,2 +1,2 @@
1
- import{__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import{useReducer as n,useRef as o,useMemo as c,useLayoutEffect as e}from"react";import{DEFAULT_MIN_COL_WIDTH as i,DEFAULT_COL_WIDTH as a}from"../../constant.js";var r=function(n,o){var c,e;switch(o.type){case"init":return o.payload.columnsWidth;case"setMinWidth":return t(t({},n),((c={})[o.payload.key]=t(t({},n[o.payload.key]),{minWidth:o.payload.minWidth}),c));case"set":return t(t({},n),((e={})[o.payload.key]=t(t({},n[o.payload.key]),{colWidth:o.payload.colWidth}),e));default:return n}},u=function(t){var u=n(r,t),l=u[0],d=u[1],s=o(null),h=c((function(){return{getColumnWidth:function(t){var n=l[t];return n?n.colWidth:(console.warn("Column width state not found: ".concat(t)),a)},getColumnMinWidth:function(t){var n=l[t];return n?n.minWidth:(console.warn("Column width state not found: ".concat(t)),i)}}}),[l]),f=c((function(){return{setColWidth:function(t,n){s.current=t,d({type:"set",payload:{key:t,colWidth:n}})}}}),[]);return e((function(){if(s.current){var t=s.current,n=setTimeout((function(){var n,o,c;n=l[t].colWidth,o=l[t].index,c="table-col-".concat(o),document.querySelectorAll(".".concat(c)).forEach((function(t){t.setAttribute("style","width: ".concat(n,"px; min-width: ").concat(n,"px; max-width: ").concat(n,"px;"))}))}),200);return function(){clearTimeout(n)}}Object.keys(l).forEach((function(t){var n=l[t].colWidth,o=l[t].index,c="table-col-".concat(o);document.querySelectorAll(".".concat(c)).forEach((function(t){t.setAttribute("style","width: ".concat(n,"px; min-width: ").concat(n,"px; max-width: ").concat(n,"px;"))}))}))}),[l]),{state:h,action:f}};export{r as columnsWidthReducer,u as useColumnsWidthReducer};
1
+ import{__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import{useReducer as n,useMemo as o}from"react";import{DEFAULT_MIN_COL_WIDTH as i,DEFAULT_COL_WIDTH as e}from"../../constant.js";var r=function(n,o){var i;return"set"===o.type?n[o.payload.key]===o.payload.colWidth?n:t(t({},n),((i={})[o.payload.key]=o.payload.colWidth,i)):n},a=function(t){var a=n(r,{}),u=a[0],c=a[1],d=o((function(){return t.map((function(t,n){var o,r=t.minWidth||i,a=null!==(o=u[t.key])&&void 0!==o?o:t.initialWidth||e;return{key:t.key,colWidth:Math.max(a,r),minWidth:r,index:n}}))}),[t,u]);return{state:o((function(){var t=new Map(d.map((function(t){return[t.key,t]})));return{columns:d,getColumnWidth:function(n){var o=t.get(n);return o?o.colWidth:(console.warn("Column width state not found: ".concat(n)),e)},getColumnMinWidth:function(n){var o=t.get(n);return o?o.minWidth:(console.warn("Column width state not found: ".concat(n)),i)}}}),[d]),action:o((function(){return{setColWidth:function(t,n){c({type:"set",payload:{key:t,colWidth:n}})}}}),[])}};export{r as columnsWidthReducer,a as useColumnsWidthReducer};
2
2
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reducer.js","sources":["../../../../../../src/table/header/columns-width/reducer.ts"],"sourcesContent":["import { useMemo, useReducer, useRef, useLayoutEffect } from \"react\";\nimport { TColumnsWidthHook, TColumnsWidthReducer } from \"./type\";\nimport { DEFAULT_COL_WIDTH, DEFAULT_MIN_COL_WIDTH } from \"../../constant\";\n\nexport const columnsWidthReducer: TColumnsWidthReducer = (state, action) => {\n switch (action.type) {\n case \"init\":\n return action.payload.columnsWidth;\n case \"setMinWidth\":\n return {\n ...state,\n [action.payload.key]: {\n ...state[action.payload.key],\n minWidth: action.payload.minWidth,\n },\n };\n case \"set\":\n return {\n ...state,\n [action.payload.key]: {\n ...state[action.payload.key],\n colWidth: action.payload.colWidth,\n },\n };\n default:\n return state;\n }\n};\n\nexport const useColumnsWidthReducer: TColumnsWidthHook = (initialState) => {\n const [state, dispatch] = useReducer(columnsWidthReducer, initialState);\n const updateKeyRef = useRef<string | null>(null);\n\n const stateActions = useMemo(\n () => ({\n getColumnWidth: (key: string) => {\n const s = state[key];\n\n if (!s) {\n console.warn(`Column width state not found: ${key}`);\n return DEFAULT_COL_WIDTH;\n }\n\n return s.colWidth;\n },\n getColumnMinWidth: (key: string) => {\n const s = state[key];\n\n if (!s) {\n console.warn(`Column width state not found: ${key}`);\n return DEFAULT_MIN_COL_WIDTH;\n }\n\n return s.minWidth;\n },\n }),\n [state]\n );\n\n const action = useMemo(\n () => ({\n setColWidth: (key: string, colWidth: number) => {\n updateKeyRef.current = key;\n dispatch({ type: \"set\", payload: { key, colWidth } });\n },\n }),\n []\n );\n\n useLayoutEffect(() => {\n if (updateKeyRef.current) {\n const key = updateKeyRef.current;\n\n const updateColWidth = () => {\n const colWidth = state[key].colWidth;\n const index = state[key].index;\n\n const className = `table-col-${index}`;\n const colElements = document.querySelectorAll(`.${className}`);\n colElements.forEach((colElement) => {\n colElement.setAttribute(\n \"style\",\n `width: ${colWidth}px; min-width: ${colWidth}px; max-width: ${colWidth}px;`\n );\n });\n };\n\n const timer = setTimeout(() => {\n updateColWidth();\n }, 200);\n\n return () => {\n clearTimeout(timer);\n };\n } else {\n Object.keys(state).forEach((key) => {\n const colWidth = state[key].colWidth;\n const index = state[key].index;\n\n const className = `table-col-${index}`;\n const colElements = document.querySelectorAll(`.${className}`);\n colElements.forEach((colElement) => {\n colElement.setAttribute(\n \"style\",\n `width: ${colWidth}px; min-width: ${colWidth}px; max-width: ${colWidth}px;`\n );\n });\n });\n }\n }, [state]);\n\n return { state: stateActions, action };\n};\n"],"names":["columnsWidthReducer","state","action","type","payload","columnsWidth","__assign","_a","key","minWidth","_b","colWidth","useColumnsWidthReducer","initialState","useReducer","dispatch","updateKeyRef","useRef","stateActions","useMemo","getColumnWidth","s","console","warn","DEFAULT_COL_WIDTH","getColumnMinWidth","DEFAULT_MIN_COL_WIDTH","setColWidth","current","useLayoutEffect","key_1","timer_1","setTimeout","index","className","concat","document","querySelectorAll","forEach","colElement","setAttribute","clearTimeout","Object","keys"],"mappings":"yOAIO,IAAMA,EAA4C,SAACC,EAAOC,WAC/D,OAAQA,EAAOC,MACb,IAAK,OACH,OAAOD,EAAOE,QAAQC,aACxB,IAAK,cACH,OAAAC,EAAAA,EAAA,CAAA,EACKL,KAAKM,EAAA,CAAA,GACPL,EAAOE,QAAQI,KAAGF,EAAAA,EAAA,CAAA,EACdL,EAAMC,EAAOE,QAAQI,MAAI,CAC5BC,SAAUP,EAAOE,QAAQK,WAAQF,IAGvC,IAAK,MACH,OAAAD,EAAAA,EAAA,CAAA,EACKL,KAAKS,EAAA,CAAA,GACPR,EAAOE,QAAQI,KAAGF,EAAAA,EAAA,CAAA,EACdL,EAAMC,EAAOE,QAAQI,MAAI,CAC5BG,SAAUT,EAAOE,QAAQO,WAAQD,IAGvC,QACE,OAAOT,EAEb,EAEaW,EAA4C,SAACC,GAClD,IAAAN,EAAoBO,EAAWd,EAAqBa,GAAnDZ,EAAKM,EAAA,GAAEQ,OACRC,EAAeC,EAAsB,MAErCC,EAAeC,GACnB,WAAM,MAAA,CACJC,eAAgB,SAACZ,GACf,IAAMa,EAAIpB,EAAMO,GAEhB,OAAKa,EAKEA,EAAEV,UAJPW,QAAQC,KAAK,wCAAiCf,IACvCgB,EAIX,EACAC,kBAAmB,SAACjB,GAClB,IAAMa,EAAIpB,EAAMO,GAEhB,OAAKa,EAKEA,EAAEZ,UAJPa,QAAQC,KAAK,wCAAiCf,IACvCkB,EAIX,EApBI,GAsBN,CAACzB,IAGGC,EAASiB,GACb,WAAM,MAAA,CACJQ,YAAa,SAACnB,EAAaG,GACzBK,EAAaY,QAAUpB,EACvBO,EAAS,CAAEZ,KAAM,MAAOC,QAAS,CAAEI,MAAKG,aAC1C,EAJI,GAMN,IA6CF,OA1CAkB,GAAgB,WACd,GAAIb,EAAaY,QAAS,CACxB,IAAME,EAAMd,EAAaY,QAgBnBG,EAAQC,YAAW,WAdF,IACfrB,EACAsB,EAEAC,EAHAvB,EAAWV,EAAM6B,GAAKnB,SACtBsB,EAAQhC,EAAM6B,GAAKG,MAEnBC,EAAY,aAAAC,OAAaF,GACXG,SAASC,iBAAiB,IAAAF,OAAID,IACtCI,SAAQ,SAACC,GACnBA,EAAWC,aACT,QACA,UAAAL,OAAUxB,EAAQ,mBAAAwB,OAAkBxB,EAAQ,mBAAAwB,OAAkBxB,EAAQ,OAE1E,GAKF,GAAG,KAEH,OAAO,WACL8B,aAAaV,EACf,CACF,CACEW,OAAOC,KAAK1C,GAAOqC,SAAQ,SAAC9B,GAC1B,IAAMG,EAAWV,EAAMO,GAAKG,SACtBsB,EAAQhC,EAAMO,GAAKyB,MAEnBC,EAAY,aAAAC,OAAaF,GACXG,SAASC,iBAAiB,IAAAF,OAAID,IACtCI,SAAQ,SAACC,GACnBA,EAAWC,aACT,QACA,UAAAL,OAAUxB,EAAQ,mBAAAwB,OAAkBxB,EAAQ,mBAAAwB,OAAkBxB,EAAQ,OAE1E,GACF,GAEJ,GAAG,CAACV,IAEG,CAAEA,MAAOiB,EAAchB,OAAMA,EACtC"}
1
+ {"version":3,"file":"reducer.js","sources":["../../../../../../src/table/header/columns-width/reducer.ts"],"sourcesContent":["import { useMemo, useReducer } from \"react\";\nimport { TColumnsWidthHook, TColumnsWidthReducer } from \"./type\";\nimport { DEFAULT_COL_WIDTH, DEFAULT_MIN_COL_WIDTH } from \"../../constant\";\n\nexport const columnsWidthReducer: TColumnsWidthReducer = (state, action) => {\n switch (action.type) {\n case \"set\":\n if (state[action.payload.key] === action.payload.colWidth) {\n return state;\n }\n return { ...state, [action.payload.key]: action.payload.colWidth };\n default:\n return state;\n }\n};\n\nexport const useColumnsWidthReducer: TColumnsWidthHook = (cols) => {\n const [overrides, dispatch] = useReducer(columnsWidthReducer, {});\n\n // Widths are derived from the current columns on every change, so added,\n // removed or reordered columns always have a width. Widths the user set by\n // dragging are kept for columns that still exist.\n const columns = useMemo(\n () =>\n cols.map((col, index) => {\n const minWidth = col.minWidth || DEFAULT_MIN_COL_WIDTH;\n const colWidth =\n overrides[col.key] ?? (col.initialWidth || DEFAULT_COL_WIDTH);\n\n return {\n key: col.key,\n colWidth: Math.max(colWidth, minWidth),\n minWidth,\n index,\n };\n }),\n [cols, overrides]\n );\n\n const state = useMemo(() => {\n const byKey = new Map(columns.map((column) => [column.key, column]));\n\n return {\n columns,\n getColumnWidth: (key: string) => {\n const column = byKey.get(key);\n\n if (!column) {\n console.warn(`Column width state not found: ${key}`);\n return DEFAULT_COL_WIDTH;\n }\n\n return column.colWidth;\n },\n getColumnMinWidth: (key: string) => {\n const column = byKey.get(key);\n\n if (!column) {\n console.warn(`Column width state not found: ${key}`);\n return DEFAULT_MIN_COL_WIDTH;\n }\n\n return column.minWidth;\n },\n };\n }, [columns]);\n\n const action = useMemo(\n () => ({\n setColWidth: (key: string, colWidth: number) => {\n dispatch({ type: \"set\", payload: { key, colWidth } });\n },\n }),\n []\n );\n\n return { state, action };\n};\n"],"names":["columnsWidthReducer","state","action","type","payload","key","colWidth","__assign","_a","useColumnsWidthReducer","cols","useReducer","overrides","dispatch","columns","useMemo","map","col","index","minWidth","DEFAULT_MIN_COL_WIDTH","initialWidth","DEFAULT_COL_WIDTH","Math","max","byKey","Map","column","getColumnWidth","get","console","warn","getColumnMinWidth","setColWidth"],"mappings":"wMAIO,IAAMA,EAA4C,SAACC,EAAOC,SAC/D,MACO,QADCA,EAAOC,KAEPF,EAAMC,EAAOE,QAAQC,OAASH,EAAOE,QAAQE,SACxCL,EAETM,EAAAA,EAAA,CAAA,EAAYN,KAAKO,EAAA,IAAGN,EAAOE,QAAQC,KAAMH,EAAOE,QAAQE,SAAQE,IAEzDP,CAEb,EAEaQ,EAA4C,SAACC,GAClD,IAAAF,EAAwBG,EAAWX,EAAqB,CAAA,GAAvDY,EAASJ,EAAA,GAAEK,OAKZC,EAAUC,GACd,WACE,OAAAL,EAAKM,KAAI,SAACC,EAAKC,SACPC,EAAWF,EAAIE,UAAYC,EAC3Bd,EACc,QAAlBE,EAAAI,EAAUK,EAAIZ,YAAI,IAAAG,EAAAA,EAAKS,EAAII,cAAgBC,EAE7C,MAAO,CACLjB,IAAKY,EAAIZ,IACTC,SAAUiB,KAAKC,IAAIlB,EAAUa,GAC7BA,SAAQA,EACRD,MAAKA,EAET,GAXA,GAYF,CAACR,EAAME,IAwCT,MAAO,CAAEX,MArCKc,GAAQ,WACpB,IAAMU,EAAQ,IAAIC,IAAIZ,EAAQE,KAAI,SAACW,GAAW,MAAA,CAACA,EAAOtB,IAAKsB,EAAb,KAE9C,MAAO,CACLb,QAAOA,EACPc,eAAgB,SAACvB,GACf,IAAMsB,EAASF,EAAMI,IAAIxB,GAEzB,OAAKsB,EAKEA,EAAOrB,UAJZwB,QAAQC,KAAK,wCAAiC1B,IACvCiB,EAIX,EACAU,kBAAmB,SAAC3B,GAClB,IAAMsB,EAASF,EAAMI,IAAIxB,GAEzB,OAAKsB,EAKEA,EAAOR,UAJZW,QAAQC,KAAK,wCAAiC1B,IACvCe,EAIX,EAEJ,GAAG,CAACN,IAWYZ,OATDa,GACb,WAAM,MAAA,CACJkB,YAAa,SAAC5B,EAAaC,GACzBO,EAAS,CAAEV,KAAM,MAAOC,QAAS,CAAEC,MAAKC,aAC1C,EAHI,GAKN,IAIJ"}
@@ -1,2 +1,2 @@
1
- import{useState as e,useCallback as t,useRef as n,useEffect as o}from"react";import{useColumnsWidth as r}from"./columns-width/context.js";import"react/jsx-runtime";import"../../../node_modules/tslib/tslib.es6.js";import{useScrollXPosition as u}from"./x-scroll-position/context.js";function c(n){var o=r(),u=o.getColumnWidth,c=o.getColumnMinWidth,s=o.setColWidth,i=e(!1),l=i[0],m=i[1],d=u(n),v=c(n);return{onMouseDownResizeWidth:t((function(e){if(!l){var t=e.clientX,o=d;document.body.style.cursor="col-resize",document.body.style.userSelect="none";var r=function(e){m(!0);var r=o+(e.clientX-t);s(n,r>v?r:v)},u=function(){m(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",u),document.body.style.cursor="default",document.body.style.userSelect="auto"};document.addEventListener("mousemove",r),document.addEventListener("mouseup",u)}}),[l,v])}}function s(){var e=u(),t=e.x,r=e.setScrollX,c=n(null);return o((function(){var e=function(){c.current&&r(c.current.scrollLeft)};return c.current&&c.current.addEventListener("scroll",e),function(){c.current&&c.current.removeEventListener("scroll",e)}}),[]),o((function(){c.current&&(c.current.scrollLeft=t)}),[t]),c}export{c as useResizeColWidthHook,s as useScrollXRef};
1
+ import{useState as e,useCallback as t,useRef as n,useEffect as o}from"react";import{useColumnsWidth as r}from"./columns-width/context.js";import"react/jsx-runtime";import"../../../node_modules/tslib/tslib.es6.js";import{useScrollXPosition as u}from"./x-scroll-position/context.js";function c(n){var o=r(),u=o.getColumnWidth,c=o.getColumnMinWidth,s=o.setColWidth,i=e(!1),l=i[0],m=i[1],d=u(n),v=c(n);return{onMouseDownResizeWidth:t((function(e){if(!l){var t=e.clientX,o=d;document.body.style.cursor="col-resize",document.body.style.userSelect="none";var r=function(e){m(!0);var r=o+(e.clientX-t);s(n,r>v?r:v)},u=function(){m(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",u),document.body.style.cursor="default",document.body.style.userSelect="auto"};document.addEventListener("mousemove",r),document.addEventListener("mouseup",u)}}),[l,v,d,n,s])}}function s(){var e=u(),t=e.x,r=e.setScrollX,c=n(null);return o((function(){var e=function(){c.current&&r(c.current.scrollLeft)};return c.current&&c.current.addEventListener("scroll",e),function(){c.current&&c.current.removeEventListener("scroll",e)}}),[]),o((function(){c.current&&(c.current.scrollLeft=t)}),[t]),c}export{c as useResizeColWidthHook,s as useScrollXRef};
2
2
  //# sourceMappingURL=header-v2-hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header-v2-hook.js","sources":["../../../../../src/table/header/header-v2-hook.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useColumnsWidth } from \"./columns-width\";\nimport { useScrollXPosition } from \"./x-scroll-position\";\n\nexport function useResizeColWidthHook(keyName: string) {\n const { getColumnWidth, getColumnMinWidth, setColWidth } = useColumnsWidth();\n const [isDragging, setIsDragging] = useState(false);\n\n const colWidth = getColumnWidth(keyName);\n const minWidth = getColumnMinWidth(keyName);\n\n const cursorStyle = \"col-resize\";\n\n const onMouseDownResizeWidth: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n if (isDragging) return;\n\n const startX = e.clientX;\n const startWidth = colWidth;\n\n document.body.style.cursor = cursorStyle;\n document.body.style.userSelect = \"none\";\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n setIsDragging(true);\n const newWidth = startWidth + (moveEvent.clientX - startX);\n setColWidth(keyName, newWidth > minWidth ? newWidth : minWidth);\n };\n\n const onMouseUp = () => {\n setIsDragging(false);\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n document.body.style.cursor = \"default\";\n document.body.style.userSelect = \"auto\";\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n },\n [isDragging, minWidth]\n );\n\n return {\n onMouseDownResizeWidth,\n };\n}\n\nexport function useScrollXRef() {\n const { x, setScrollX } = useScrollXPosition();\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handleHeaderScroll = () => {\n if (ref.current) {\n setScrollX(ref.current.scrollLeft);\n }\n };\n\n if (ref.current) {\n ref.current.addEventListener(\"scroll\", handleHeaderScroll);\n }\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener(\"scroll\", handleHeaderScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n if (ref.current) {\n ref.current.scrollLeft = x;\n }\n }, [x]);\n\n return ref;\n}\n"],"names":["useResizeColWidthHook","keyName","_a","useColumnsWidth","getColumnWidth","getColumnMinWidth","setColWidth","_b","useState","isDragging","setIsDragging","colWidth","minWidth","onMouseDownResizeWidth","useCallback","e","startX","clientX","startWidth","document","body","style","cursor","userSelect","onMouseMove","moveEvent","newWidth","onMouseUp","removeEventListener","addEventListener","useScrollXRef","useScrollXPosition","x","setScrollX","ref","useRef","useEffect","handleHeaderScroll","current","scrollLeft"],"mappings":"yRAIM,SAAUA,EAAsBC,GAC9B,IAAAC,EAAqDC,IAAnDC,EAAcF,EAAAE,eAAEC,EAAiBH,EAAAG,kBAAEC,EAAWJ,EAAAI,YAChDC,EAA8BC,GAAS,GAAtCC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAE1BI,EAAWP,EAAeH,GAC1BW,EAAWP,EAAkBJ,GAmCnC,MAAO,CACLY,uBA/BAC,GACE,SAACC,GACC,IAAIN,EAAJ,CAEA,IAAMO,EAASD,EAAEE,QACXC,EAAaP,EAEnBQ,SAASC,KAAKC,MAAMC,OAVN,aAWdH,SAASC,KAAKC,MAAME,WAAa,OAEjC,IAAMC,EAAc,SAACC,GACnBf,GAAc,GACd,IAAMgB,EAAWR,GAAcO,EAAUR,QAAUD,GACnDV,EAAYL,EAASyB,EAAWd,EAAWc,EAAWd,EACxD,EAEMe,EAAY,WAChBjB,GAAc,GACdS,SAASS,oBAAoB,YAAaJ,GAC1CL,SAASS,oBAAoB,UAAWD,GACxCR,SAASC,KAAKC,MAAMC,OAAS,UAC7BH,SAASC,KAAKC,MAAME,WAAa,MACnC,EAEAJ,SAASU,iBAAiB,YAAaL,GACvCL,SAASU,iBAAiB,UAAWF,EAvBrB,CAwBlB,GACA,CAAClB,EAAYG,IAMnB,UAEgBkB,IACR,IAAA5B,EAAoB6B,IAAlBC,EAAC9B,EAAA8B,EAAEC,EAAU/B,EAAA+B,WACfC,EAAMC,EAAuB,MA0BnC,OAxBAC,GAAU,WACR,IAAMC,EAAqB,WACrBH,EAAII,SACNL,EAAWC,EAAII,QAAQC,WAE3B,EAMA,OAJIL,EAAII,SACNJ,EAAII,QAAQT,iBAAiB,SAAUQ,GAGlC,WACDH,EAAII,SACNJ,EAAII,QAAQV,oBAAoB,SAAUS,EAE9C,CACF,GAAG,IAEHD,GAAU,WACJF,EAAII,UACNJ,EAAII,QAAQC,WAAaP,EAE7B,GAAG,CAACA,IAEGE,CACT"}
1
+ {"version":3,"file":"header-v2-hook.js","sources":["../../../../../src/table/header/header-v2-hook.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useColumnsWidth } from \"./columns-width\";\nimport { useScrollXPosition } from \"./x-scroll-position\";\n\nexport function useResizeColWidthHook(keyName: string) {\n const { getColumnWidth, getColumnMinWidth, setColWidth } = useColumnsWidth();\n const [isDragging, setIsDragging] = useState(false);\n\n const colWidth = getColumnWidth(keyName);\n const minWidth = getColumnMinWidth(keyName);\n\n const cursorStyle = \"col-resize\";\n\n const onMouseDownResizeWidth: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n if (isDragging) return;\n\n const startX = e.clientX;\n const startWidth = colWidth;\n\n document.body.style.cursor = cursorStyle;\n document.body.style.userSelect = \"none\";\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n setIsDragging(true);\n const newWidth = startWidth + (moveEvent.clientX - startX);\n setColWidth(keyName, newWidth > minWidth ? newWidth : minWidth);\n };\n\n const onMouseUp = () => {\n setIsDragging(false);\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n document.body.style.cursor = \"default\";\n document.body.style.userSelect = \"auto\";\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n },\n [isDragging, minWidth, colWidth, keyName, setColWidth]\n );\n\n return {\n onMouseDownResizeWidth,\n };\n}\n\nexport function useScrollXRef() {\n const { x, setScrollX } = useScrollXPosition();\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handleHeaderScroll = () => {\n if (ref.current) {\n setScrollX(ref.current.scrollLeft);\n }\n };\n\n if (ref.current) {\n ref.current.addEventListener(\"scroll\", handleHeaderScroll);\n }\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener(\"scroll\", handleHeaderScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n if (ref.current) {\n ref.current.scrollLeft = x;\n }\n }, [x]);\n\n return ref;\n}\n"],"names":["useResizeColWidthHook","keyName","_a","useColumnsWidth","getColumnWidth","getColumnMinWidth","setColWidth","_b","useState","isDragging","setIsDragging","colWidth","minWidth","onMouseDownResizeWidth","useCallback","e","startX","clientX","startWidth","document","body","style","cursor","userSelect","onMouseMove","moveEvent","newWidth","onMouseUp","removeEventListener","addEventListener","useScrollXRef","useScrollXPosition","x","setScrollX","ref","useRef","useEffect","handleHeaderScroll","current","scrollLeft"],"mappings":"yRAIM,SAAUA,EAAsBC,GAC9B,IAAAC,EAAqDC,IAAnDC,EAAcF,EAAAE,eAAEC,EAAiBH,EAAAG,kBAAEC,EAAWJ,EAAAI,YAChDC,EAA8BC,GAAS,GAAtCC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAE1BI,EAAWP,EAAeH,GAC1BW,EAAWP,EAAkBJ,GAmCnC,MAAO,CACLY,uBA/BAC,GACE,SAACC,GACC,IAAIN,EAAJ,CAEA,IAAMO,EAASD,EAAEE,QACXC,EAAaP,EAEnBQ,SAASC,KAAKC,MAAMC,OAVN,aAWdH,SAASC,KAAKC,MAAME,WAAa,OAEjC,IAAMC,EAAc,SAACC,GACnBf,GAAc,GACd,IAAMgB,EAAWR,GAAcO,EAAUR,QAAUD,GACnDV,EAAYL,EAASyB,EAAWd,EAAWc,EAAWd,EACxD,EAEMe,EAAY,WAChBjB,GAAc,GACdS,SAASS,oBAAoB,YAAaJ,GAC1CL,SAASS,oBAAoB,UAAWD,GACxCR,SAASC,KAAKC,MAAMC,OAAS,UAC7BH,SAASC,KAAKC,MAAME,WAAa,MACnC,EAEAJ,SAASU,iBAAiB,YAAaL,GACvCL,SAASU,iBAAiB,UAAWF,EAvBrB,CAwBlB,GACA,CAAClB,EAAYG,EAAUD,EAAUV,EAASK,IAMhD,UAEgBwB,IACR,IAAA5B,EAAoB6B,IAAlBC,EAAC9B,EAAA8B,EAAEC,EAAU/B,EAAA+B,WACfC,EAAMC,EAAuB,MA0BnC,OAxBAC,GAAU,WACR,IAAMC,EAAqB,WACrBH,EAAII,SACNL,EAAWC,EAAII,QAAQC,WAE3B,EAMA,OAJIL,EAAII,SACNJ,EAAII,QAAQT,iBAAiB,SAAUQ,GAGlC,WACDH,EAAII,SACNJ,EAAII,QAAQV,oBAAoB,SAAUS,EAE9C,CACF,GAAG,IAEHD,GAAU,WACJF,EAAII,UACNJ,EAAII,QAAQC,WAAaP,EAE7B,GAAG,CAACA,IAEGE,CACT"}
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{memo as r,useRef as i,useEffect as n,useCallback as l,useMemo as o}from"react";import{useColumnsWidthState as a}from"./columns-width/context.js";import"../../../node_modules/tslib/tslib.es6.js";import{useResizeColWidthHook as s,useScrollXRef as c}from"./header-v2-hook.js";import{AllCheckbox as d}from"../checkbox/components.js";import{ConditionSearchBar as m}from"../../search-bar/condition-search-bar/base.js";import{useTableIdGenerator as p}from"../id/provider.js";import{useFilter as h}from"../filter-v2/context.js";function u(r){var i=p(),s=a().getColumnWidth,u=h(),b=u.conditions,y=u.addFilter,v=u.removeFilter,x=c();n((function(){if(x.current){var e=x.current,t=function(t){0!==t.deltaY&&(t.preventDefault(),e.scrollLeft+=t.deltaY)};return e.addEventListener("wheel",t),function(){e.removeEventListener("wheel",t)}}}),[x]);var g=l((function(e){switch(e.type){case"add":y(e.payload.condition);break;case"remove":v(e.payload.index)}}),[]),w=o((function(){return r.cols.filter((function(e){return!e.disableFilter})).filter((function(e){return!!e.label&&("datetime"===e.type||"date"===e.type||e.editable)})).map((function(e){switch(e.type){case"string":case"number":case"date":case"datetime":return{key:e.key.toString(),label:e.label,type:e.type};case"select":return{key:e.key.toString(),label:e.label,type:e.type,options:e.options}}}))}),[r.cols]);return e("div",{className:"border-gray-200 bg-gray-200 text-gray-600 rounded-t-md",style:{maxWidth:r.maxWidth},children:[t("div",{className:"py-2 px-2",children:t(m,{id:i.getTableHeaderId(),targets:w,conditions:b,onChangeCondition:g,size:"small"})}),t("style",{children:"\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n "}),t("div",{ref:x,className:"relative max-w-full overflow-x-auto teppen-no-scrollbar",children:e("div",{className:"flex h-[32px]",children:[r.checkbox&&t("div",{className:"w-8 h-full",children:t(d,{rows:r.rows})}),r.cols.map((function(e){return t(f,{keyName:e.key.toString(),label:e.label,colWidth:s(e.key),disableSort:e.disableSort||"datetime"!==e.type&&"date"!==e.type&&!e.editable,generateSortButton:r.generateSortButton},e.key.toString())}))]})})]})}var f=r((function(r){var n=i(null),l=s(r.keyName).onMouseDownResizeWidth,o=n.current?r.colWidth-n.current.clientWidth:r.colWidth;return e("div",{className:"relative",style:{width:r.colWidth,maxWidth:r.colWidth,minWidth:r.colWidth},children:[e("div",{className:"flex justify-between items-center bg-gray-200 text-gray-600 h-[32px]",children:[t("div",{className:"px-2",style:{maxWidth:o},children:r.label&&t("p",{className:"text-left font-bold text-nowrap overflow-hidden text-ellipsis",children:r.label})}),t("div",{ref:n,className:"flex items-center w-fit shrink-0 gap-1 px-1",children:!r.disableSort&&r.generateSortButton&&r.generateSortButton(r.keyName)})]}),t("div",{className:"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize",onMouseDown:l,children:t("div",{className:"w-[1px] h-full bg-white"})})]})}));export{u as TableHeader};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{memo as r,useRef as n,useEffect as i,useCallback as o,useMemo as l}from"react";import{useColumnsWidthState as a}from"./columns-width/context.js";import"../../../node_modules/tslib/tslib.es6.js";import{useResizeColWidthHook as s,useScrollXRef as c}from"./header-v2-hook.js";import{AllCheckbox as d}from"../checkbox/components.js";import{ConditionSearchBar as m}from"../../search-bar/condition-search-bar/base.js";import{useTableIdGenerator as h}from"../id/provider.js";import{useFilter as p}from"../filter-v2/context.js";function u(e){return!("date"!==e.type&&"datetime"!==e.type&&!e.editable)||!e.render}function f(r){var n=h(),s=a().getColumnWidth,f=p(),y=f.conditions,v=f.addFilter,x=f.removeFilter,g=c();i((function(){if(g.current){var e=g.current,t=function(t){0!==t.deltaY&&(t.preventDefault(),e.scrollLeft+=t.deltaY)};return e.addEventListener("wheel",t),function(){e.removeEventListener("wheel",t)}}}),[g]);var w=o((function(e){switch(e.type){case"add":v(e.payload.condition);break;case"remove":x(e.payload.index)}}),[]),k=l((function(){return r.cols.filter((function(e){return!e.disableFilter})).filter((function(e){return!!e.label&&u(e)})).map((function(e){switch(e.type){case"string":case"number":case"date":case"datetime":return{key:e.key.toString(),label:e.label,type:e.type};case"select":return{key:e.key.toString(),label:e.label,type:e.type,options:e.options}}}))}),[r.cols]);return e("div",{className:"border-gray-200 bg-gray-200 text-gray-600 rounded-t-md",style:{maxWidth:r.maxWidth},children:[t("div",{className:"py-2 px-2",children:t(m,{id:n.getTableHeaderId(),targets:k,conditions:y,onChangeCondition:w,size:"small"})}),t("style",{children:"\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n "}),t("div",{ref:g,className:"relative max-w-full overflow-x-auto teppen-no-scrollbar",children:e("div",{className:"flex h-[32px]",children:[r.checkbox&&t("div",{className:"w-8 h-full",children:t(d,{rows:r.rows})}),r.cols.map((function(e){return t(b,{keyName:e.key.toString(),label:e.label,colWidth:s(e.key),disableSort:e.disableSort||!u(e),generateSortButton:r.generateSortButton},e.key.toString())}))]})})]})}var b=r((function(r){var i=n(null),o=s(r.keyName).onMouseDownResizeWidth,l=i.current?r.colWidth-i.current.clientWidth:r.colWidth;return e("div",{className:"relative",style:{width:r.colWidth,maxWidth:r.colWidth,minWidth:r.colWidth},children:[e("div",{className:"flex justify-between items-center bg-gray-200 text-gray-600 h-[32px]",children:[t("div",{className:"px-2",style:{maxWidth:l},children:r.label&&t("p",{className:"text-left font-bold text-nowrap overflow-hidden text-ellipsis",children:r.label})}),t("div",{ref:i,className:"flex items-center w-fit shrink-0 gap-1 px-1",children:!r.disableSort&&r.generateSortButton&&r.generateSortButton(r.keyName)})]}),t("div",{className:"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize",onMouseDown:o,children:t("div",{className:"w-[1px] h-full bg-white"})})]})}));export{f as TableHeader,u as hasComparableValue};
2
2
  //# sourceMappingURL=header-v2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header-v2.js","sources":["../../../../../src/table/header/header-v2.tsx"],"sourcesContent":["import { memo, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { DataObject, DataRecord, TTableColumn } from \"../table/type\";\nimport { useColumnsWidthState } from \"./columns-width\";\nimport { useResizeColWidthHook, useScrollXRef } from \"./header-v2-hook\";\nimport { AllCheckbox } from \"../checkbox/components\";\nimport { ConditionSearchBar } from \"../../search-bar\";\nimport { useTableIdGenerator } from \"../id\";\nimport { useFilter } from \"../filter-v2\";\nimport { TConditionChangeAction } from \"../../search-bar/condition-search-bar/condition-input-management/type\";\n\ninterface IPropsTableHeader<T extends DataRecord> {\n cols: TTableColumn<T>[];\n checkbox?: boolean;\n rows: DataObject<T>[];\n maxWidth?: string;\n generateSortButton?: (columnKey: string) => React.ReactNode;\n}\n\nexport function TableHeader<T extends DataRecord>(props: IPropsTableHeader<T>) {\n const idGenerator = useTableIdGenerator();\n const { getColumnWidth } = useColumnsWidthState();\n const { conditions, addFilter, removeFilter } = useFilter();\n const ref = useScrollXRef();\n\n useEffect(() => {\n if (ref.current) {\n const element = ref.current;\n\n const scrollX = (e: WheelEvent) => {\n if (e.deltaY === 0) return;\n\n e.preventDefault();\n element.scrollLeft += e.deltaY;\n };\n\n element.addEventListener(\"wheel\", scrollX);\n\n return () => {\n element.removeEventListener(\"wheel\", scrollX);\n };\n }\n }, [ref]);\n\n const onChangeCondition = useCallback((action: TConditionChangeAction) => {\n switch (action.type) {\n case \"add\":\n addFilter(action.payload.condition);\n break;\n case \"remove\":\n removeFilter(action.payload.index);\n break;\n }\n }, []);\n\n const targets = useMemo(() => {\n return props.cols\n .filter((col) => !col.disableFilter)\n .filter(\n (col) =>\n !!col.label &&\n (col.type === \"datetime\" || col.type === \"date\" || col.editable)\n )\n .map((col) => {\n switch (col.type) {\n case \"string\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n case \"number\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n case \"select\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n options: col.options,\n };\n case \"date\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n case \"datetime\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n }\n });\n }, [props.cols]);\n\n return (\n <div\n className=\"border-gray-200 bg-gray-200 text-gray-600 rounded-t-md\"\n style={{ maxWidth: props.maxWidth }}\n >\n <div className=\"py-2 px-2\">\n <ConditionSearchBar\n id={idGenerator.getTableHeaderId()}\n targets={targets}\n conditions={conditions}\n onChangeCondition={onChangeCondition}\n size=\"small\"\n />\n </div>\n\n <style>{`\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n `}</style>\n <div\n ref={ref}\n className=\"relative max-w-full overflow-x-auto teppen-no-scrollbar\"\n >\n <div className=\"flex h-[32px]\">\n {props.checkbox && (\n <div className=\"w-8 h-full\">\n <AllCheckbox rows={props.rows} />\n </div>\n )}\n {props.cols.map((col) => {\n return (\n <HeaderElement\n key={col.key.toString()}\n keyName={col.key.toString()}\n label={col.label}\n colWidth={getColumnWidth(col.key as string)}\n disableSort={\n col.disableSort ||\n (col.type !== \"datetime\" &&\n col.type !== \"date\" &&\n !col.editable)\n }\n generateSortButton={props.generateSortButton}\n />\n );\n })}\n </div>\n </div>\n </div>\n );\n}\n\ninterface IPropsHeaderElement {\n keyName: string;\n label?: string;\n colWidth: number;\n disableSort?: boolean;\n generateSortButton?: (columnKey: string) => React.ReactNode;\n}\n\nconst HeaderElement = memo(function HE(props: IPropsHeaderElement) {\n const ref = useRef<HTMLDivElement>(null);\n const { onMouseDownResizeWidth } = useResizeColWidthHook(props.keyName);\n\n const maxWidthLabel = ref.current\n ? props.colWidth - ref.current.clientWidth\n : props.colWidth;\n\n return (\n <div\n className=\"relative\"\n style={{\n width: props.colWidth,\n maxWidth: props.colWidth,\n minWidth: props.colWidth,\n }}\n >\n <div\n className={`flex justify-between items-center bg-gray-200 text-gray-600 h-[32px]`}\n >\n <div className=\"px-2\" style={{ maxWidth: maxWidthLabel }}>\n {props.label && (\n <p\n className={`text-left font-bold text-nowrap overflow-hidden text-ellipsis`}\n >\n {props.label}\n </p>\n )}\n </div>\n\n <div ref={ref} className=\"flex items-center w-fit shrink-0 gap-1 px-1\">\n {!props.disableSort &&\n props.generateSortButton &&\n props.generateSortButton(props.keyName)}\n </div>\n </div>\n <div\n className=\"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize\"\n onMouseDown={onMouseDownResizeWidth}\n >\n <div className={`w-[1px] h-full bg-white`} />\n </div>\n </div>\n );\n});\n"],"names":["TableHeader","props","idGenerator","useTableIdGenerator","getColumnWidth","useColumnsWidthState","_a","useFilter","conditions","addFilter","removeFilter","ref","useScrollXRef","useEffect","current","element_1","scrollX_1","e","deltaY","preventDefault","scrollLeft","addEventListener","removeEventListener","onChangeCondition","useCallback","action","type","payload","condition","index","targets","useMemo","cols","filter","col","disableFilter","label","editable","map","key","toString","options","_jsxs","className","style","maxWidth","children","_jsx","ConditionSearchBar","id","getTableHeaderId","size","checkbox","AllCheckbox","rows","HeaderElement","keyName","colWidth","disableSort","generateSortButton","memo","useRef","onMouseDownResizeWidth","useResizeColWidthHook","maxWidthLabel","clientWidth","width","minWidth","onMouseDown"],"mappings":"ikBAkBM,SAAUA,EAAkCC,GAChD,IAAMC,EAAcC,IACZC,EAAmBC,mBACrBC,EAA0CC,IAAxCC,EAAUF,EAAAE,WAAEC,EAASH,EAAAG,UAAEC,EAAYJ,EAAAI,aACrCC,EAAMC,IAEZC,GAAU,WACR,GAAIF,EAAIG,QAAS,CACf,IAAMC,EAAUJ,EAAIG,QAEdE,EAAU,SAACC,GACE,IAAbA,EAAEC,SAEND,EAAEE,iBACFJ,EAAQK,YAAcH,EAAEC,OAC1B,EAIA,OAFAH,EAAQM,iBAAiB,QAASL,GAE3B,WACLD,EAAQO,oBAAoB,QAASN,EACvC,CACF,CACF,GAAG,CAACL,IAEJ,IAAMY,EAAoBC,GAAY,SAACC,GACrC,OAAQA,EAAOC,MACb,IAAK,MACHjB,EAAUgB,EAAOE,QAAQC,WACzB,MACF,IAAK,SACHlB,EAAae,EAAOE,QAAQE,OAGlC,GAAG,IAEGC,EAAUC,GAAQ,WACtB,OAAO9B,EAAM+B,KACVC,QAAO,SAACC,GAAQ,OAACA,EAAIC,aAAL,IAChBF,QACC,SAACC,GACC,QAAEA,EAAIE,QACQ,aAAbF,EAAIR,MAAoC,SAAbQ,EAAIR,MAAmBQ,EAAIG,SADvD,IAGHC,KAAI,SAACJ,GACJ,OAAQA,EAAIR,MACV,IAAK,SAML,IAAK,SAaL,IAAK,OAML,IAAK,WACH,MAAO,CACLa,IAAKL,EAAIK,IAAIC,WACbJ,MAAOF,EAAIE,MACXV,KAAMQ,EAAIR,MAjBd,IAAK,SACH,MAAO,CACLa,IAAKL,EAAIK,IAAIC,WACbJ,MAAOF,EAAIE,MACXV,KAAMQ,EAAIR,KACVe,QAASP,EAAIO,SAerB,GACJ,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AA,CAAKpC,IAAKA,EAAKgC,UAAU,8CAA6CG,UAClE7C,EAAMyD,aACNzD,EAAM0D,oBACN1D,EAAM0D,mBAAmB1D,EAAMuD,cAGrCT,EAAA,MAAA,CACEJ,UAAU,oFACVyB,YAAaN,EAAsBhB,SAEnCC,EAAA,MAAA,CAAKJ,UAAW,gCAIxB"}
1
+ {"version":3,"file":"header-v2.js","sources":["../../../../../src/table/header/header-v2.tsx"],"sourcesContent":["import { memo, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { DataObject, DataRecord, TTableColumn } from \"../table/type\";\nimport { useColumnsWidthState } from \"./columns-width\";\nimport { useResizeColWidthHook, useScrollXRef } from \"./header-v2-hook\";\nimport { AllCheckbox } from \"../checkbox/components\";\nimport { ConditionSearchBar } from \"../../search-bar\";\nimport { useTableIdGenerator } from \"../id\";\nimport { useFilter } from \"../filter-v2\";\nimport { TConditionChangeAction } from \"../../search-bar/condition-search-bar/condition-input-management/type\";\n\n/**\n * Whether the column shows its value as is, so it can be sorted and\n * filtered. Read-only columns that render their own component are excluded,\n * because what the user sees may not match the underlying value.\n */\nexport function hasComparableValue<T extends DataRecord>(\n col: TTableColumn<T>\n): boolean {\n if (col.type === \"date\" || col.type === \"datetime\" || col.editable) {\n return true;\n }\n\n return !col.render;\n}\n\ninterface IPropsTableHeader<T extends DataRecord> {\n cols: TTableColumn<T>[];\n checkbox?: boolean;\n rows: DataObject<T>[];\n maxWidth?: string;\n generateSortButton?: (columnKey: string) => React.ReactNode;\n}\n\nexport function TableHeader<T extends DataRecord>(props: IPropsTableHeader<T>) {\n const idGenerator = useTableIdGenerator();\n const { getColumnWidth } = useColumnsWidthState();\n const { conditions, addFilter, removeFilter } = useFilter();\n const ref = useScrollXRef();\n\n useEffect(() => {\n if (ref.current) {\n const element = ref.current;\n\n const scrollX = (e: WheelEvent) => {\n if (e.deltaY === 0) return;\n\n e.preventDefault();\n element.scrollLeft += e.deltaY;\n };\n\n element.addEventListener(\"wheel\", scrollX);\n\n return () => {\n element.removeEventListener(\"wheel\", scrollX);\n };\n }\n }, [ref]);\n\n const onChangeCondition = useCallback((action: TConditionChangeAction) => {\n switch (action.type) {\n case \"add\":\n addFilter(action.payload.condition);\n break;\n case \"remove\":\n removeFilter(action.payload.index);\n break;\n }\n }, []);\n\n const targets = useMemo(() => {\n return props.cols\n .filter((col) => !col.disableFilter)\n .filter((col) => !!col.label && hasComparableValue(col))\n .map((col) => {\n switch (col.type) {\n case \"string\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n case \"number\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n case \"select\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n options: col.options,\n };\n case \"date\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n case \"datetime\":\n return {\n key: col.key.toString(),\n label: col.label as string,\n type: col.type,\n };\n }\n });\n }, [props.cols]);\n\n return (\n <div\n className=\"border-gray-200 bg-gray-200 text-gray-600 rounded-t-md\"\n style={{ maxWidth: props.maxWidth }}\n >\n <div className=\"py-2 px-2\">\n <ConditionSearchBar\n id={idGenerator.getTableHeaderId()}\n targets={targets}\n conditions={conditions}\n onChangeCondition={onChangeCondition}\n size=\"small\"\n />\n </div>\n\n <style>{`\n .teppen-no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n }\n .teppen-no-scrollbar::-webkit-scrollbar {\n display: none;\n }\n `}</style>\n <div\n ref={ref}\n className=\"relative max-w-full overflow-x-auto teppen-no-scrollbar\"\n >\n <div className=\"flex h-[32px]\">\n {props.checkbox && (\n <div className=\"w-8 h-full\">\n <AllCheckbox rows={props.rows} />\n </div>\n )}\n {props.cols.map((col) => {\n return (\n <HeaderElement\n key={col.key.toString()}\n keyName={col.key.toString()}\n label={col.label}\n colWidth={getColumnWidth(col.key as string)}\n disableSort={col.disableSort || !hasComparableValue(col)}\n generateSortButton={props.generateSortButton}\n />\n );\n })}\n </div>\n </div>\n </div>\n );\n}\n\ninterface IPropsHeaderElement {\n keyName: string;\n label?: string;\n colWidth: number;\n disableSort?: boolean;\n generateSortButton?: (columnKey: string) => React.ReactNode;\n}\n\nconst HeaderElement = memo(function HE(props: IPropsHeaderElement) {\n const ref = useRef<HTMLDivElement>(null);\n const { onMouseDownResizeWidth } = useResizeColWidthHook(props.keyName);\n\n const maxWidthLabel = ref.current\n ? props.colWidth - ref.current.clientWidth\n : props.colWidth;\n\n return (\n <div\n className=\"relative\"\n style={{\n width: props.colWidth,\n maxWidth: props.colWidth,\n minWidth: props.colWidth,\n }}\n >\n <div\n className={`flex justify-between items-center bg-gray-200 text-gray-600 h-[32px]`}\n >\n <div className=\"px-2\" style={{ maxWidth: maxWidthLabel }}>\n {props.label && (\n <p\n className={`text-left font-bold text-nowrap overflow-hidden text-ellipsis`}\n >\n {props.label}\n </p>\n )}\n </div>\n\n <div ref={ref} className=\"flex items-center w-fit shrink-0 gap-1 px-1\">\n {!props.disableSort &&\n props.generateSortButton &&\n props.generateSortButton(props.keyName)}\n </div>\n </div>\n <div\n className=\"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize\"\n onMouseDown={onMouseDownResizeWidth}\n >\n <div className={`w-[1px] h-full bg-white`} />\n </div>\n </div>\n );\n});\n"],"names":["hasComparableValue","col","type","editable","render","TableHeader","props","idGenerator","useTableIdGenerator","getColumnWidth","useColumnsWidthState","_a","useFilter","conditions","addFilter","removeFilter","ref","useScrollXRef","useEffect","current","element_1","scrollX_1","e","deltaY","preventDefault","scrollLeft","addEventListener","removeEventListener","onChangeCondition","useCallback","action","payload","condition","index","targets","useMemo","cols","filter","disableFilter","label","map","key","toString","options","_jsxs","className","style","maxWidth","children","_jsx","ConditionSearchBar","id","getTableHeaderId","size","checkbox","AllCheckbox","rows","HeaderElement","keyName","colWidth","disableSort","generateSortButton","memo","useRef","onMouseDownResizeWidth","useResizeColWidthHook","maxWidthLabel","clientWidth","width","minWidth","onMouseDown"],"mapp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A,MAAA,CACEJ,UAAU,oFACVyB,YAAaN,EAAsBhB,SAEnCC,EAAA,MAAA,CAAKJ,UAAW,gCAIxB"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsx as t}from"react/jsx-runtime";import{memo as m}from"react";import{useColumnsWidthState as r}from"./columns-width/context.js";import"../../../node_modules/tslib/tslib.es6.js";var e=m((function(m){var e=(0,r().getColumnWidth)(m.keyname);return t("th",{className:"p-px",style:{width:e,maxWidth:e,minWidth:e}})}));export{e as TableHeaderElement};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{memo as e}from"react";import{useColumnsWidthState as i}from"./columns-width/context.js";import"../../../node_modules/tslib/tslib.es6.js";var m=e((function(e){var m=(0,i().getColumnWidth)(e.keyname);return t("th",{className:"p-px",style:{width:m,maxWidth:m,minWidth:m}})}));export{m as TableHeaderElement};
3
2
  //# sourceMappingURL=header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"header.js","sources":["../../../../../src/table/header/header.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo } from \"react\";\nimport { useColumnsWidthState } from \"./columns-width\";\n\ntype TPropsTableHeader = {\n keyname: string;\n};\n\nexport const TableHeaderElement = memo(function THE(props: TPropsTableHeader) {\n const { getColumnWidth } = useColumnsWidthState();\n const colWidth = getColumnWidth(props.keyname);\n\n return (\n <th\n className=\"p-px\"\n style={{ width: colWidth, maxWidth: colWidth, minWidth: colWidth }}\n ></th>\n );\n});\n"],"names":["TableHeaderElement","memo","props","colWidth","getColumnWidth","useColumnsWidthState","keyname","_jsx","className","style","width","maxWidth","minWidth"],"mappings":"yMASaA,EAAqBC,GAAK,SAAaC,GAC1C,IACFC,GAAWC,EADUC,oBACKH,EAAMI,SAEtC,OACEC,QACEC,UAAU,OACVC,MAAO,CAAEC,MAAOP,EAAUQ,SAAUR,EAAUS,SAAUT,IAG9D"}
@@ -1,2 +1,2 @@
1
- import{jsx as r}from"react/jsx-runtime";import{createContext as e,useContext as t}from"react";import{IdGenerator as n}from"./id-generator.js";var o=e(null);function i(e){return r(o.Provider,{value:new n(e.id),children:e.children})}function a(){var r=t(o);if(!r)throw new Error("useTableIdGenerator must be used within TableIdGeneratorProvider");return r}export{i as TableIdGeneratorProvider,a as useTableIdGenerator};
1
+ import{jsx as r}from"react/jsx-runtime";import{createContext as e,useContext as n,useId as t,useMemo as o}from"react";import{IdGenerator as i}from"./id-generator.js";var u=e(null);function a(e){var n,a=t(),d=null!==(n=e.id)&&void 0!==n?n:a,l=o((function(){return new i(d)}),[d]);return r(u.Provider,{value:l,children:e.children})}function d(){var r=n(u);if(!r)throw new Error("useTableIdGenerator must be used within TableIdGeneratorProvider");return r}export{a as TableIdGeneratorProvider,d as useTableIdGenerator};
2
2
  //# sourceMappingURL=provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sources":["../../../../../src/table/id/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { ITableIdGenerator } from \"./interface\";\nimport { IdGenerator } from \"./id-generator\";\n\nconst TableIdContext = createContext<ITableIdGenerator | null>(null);\n\nexport function TableIdGeneratorProvider(props: {\n id?: string;\n children: React.ReactNode;\n}) {\n return (\n <TableIdContext.Provider value={new IdGenerator(props.id)}>\n {props.children}\n </TableIdContext.Provider>\n );\n}\n\nexport function useTableIdGenerator() {\n const context = useContext(TableIdContext);\n\n if (!context) {\n throw new Error(\n \"useTableIdGenerator must be used within TableIdGeneratorProvider\"\n );\n }\n\n return context;\n}\n"],"names":["TableIdContext","createContext","TableIdGeneratorProvider","props","_jsx","Provider","value","IdGenerator","id","children","useTableIdGenerator","context","useContext","Error"],"mappings":"8IAIA,IAAMA,EAAiBC,EAAwC,MAEzD,SAAUC,EAAyBC,GAIvC,OACEC,EAACJ,EAAeK,SAAQ,CAACC,MAAO,IAAIC,EAAYJ,EAAMK,IAAGC,SACtDN,EAAMM,UAGb,UAEgBC,IACd,IAAMC,EAAUC,EAAWZ,GAE3B,IAAKW,EACH,MAAM,IAAIE,MACR,oEAIJ,OAAOF,CACT"}
1
+ {"version":3,"file":"provider.js","sources":["../../../../../src/table/id/provider.tsx"],"sourcesContent":["import { createContext, useContext, useId, useMemo } from \"react\";\nimport { ITableIdGenerator } from \"./interface\";\nimport { IdGenerator } from \"./id-generator\";\n\nconst TableIdContext = createContext<ITableIdGenerator | null>(null);\n\nexport function TableIdGeneratorProvider(props: {\n id?: string;\n children: React.ReactNode;\n}) {\n // Without an id, each table still needs unique element ids so that several\n // tables on one page do not find each other's cells.\n const autoId = useId();\n const id = props.id ?? autoId;\n const generator = useMemo(() => new IdGenerator(id), [id]);\n\n return (\n <TableIdContext.Provider value={generator}>\n {props.children}\n </TableIdContext.Provider>\n );\n}\n\nexport function useTableIdGenerator() {\n const context = useContext(TableIdContext);\n\n if (!context) {\n throw new Error(\n \"useTableIdGenerator must be used within TableIdGeneratorProvider\"\n );\n }\n\n return context;\n}\n"],"names":["TableIdContext","createContext","TableIdGeneratorProvider","props","autoId","useId","id","_a","generator","useMemo","IdGenerator","_jsx","Provider","value","children","useTableIdGenerator","context","useContext","Error"],"mappings":"sKAIA,IAAMA,EAAiBC,EAAwC,MAEzD,SAAUC,EAAyBC,SAMjCC,EAASC,IACTC,EAAa,QAARC,EAAAJ,EAAMG,UAAE,IAAAC,EAAAA,EAAIH,EACjBI,EAAYC,GAAQ,WAAM,OAAA,IAAIC,EAAYJ,EAAhB,GAAqB,CAACA,IAEtD,OACEK,EAACX,EAAeY,SAAQ,CAACC,MAAOL,WAC7BL,EAAMW,UAGb,UAEgBC,IACd,IAAMC,EAAUC,EAAWjB,GAE3B,IAAKgB,EACH,MAAM,IAAIE,MACR,oEAIJ,OAAOF,CACT"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsx as e,Fragment as t}from"react/jsx-runtime";import{useEffect as r}from"react";import{useEditContext as n}from"../../edit/provider.js";import{useColumnsContext as o}from"../../sheet/providers.js";import{useRangeContext as i}from"../../range/provider.js";import{useCopyActionContext as d}from"../../copy/provider.js";import{useTableIdGenerator as p}from"../../id/provider.js";var a=function(e,t){var r,n=document.getElementById(t);if(n){var o=null===(r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value"))||void 0===r?void 0:r.set;o&&o.call(n,e);var i=new Event("input",{bubbles:!0});n.dispatchEvent(i)}};function s(s){var y=p(),f=n(),v=i(),c=d().copy,l=o()[v.isSelecting?v.start.colIndex:0];return r((function(){var e=function(e){f.isEditing?"Escape"===e.key&&(e.preventDefault(),f.endEditing()):v.isSelecting&&("Enter"===e.key?(e.preventDefault(),v.moveDown()):"Escape"===e.key?(e.preventDefault(),v.reset()):"ArrowRight"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?v.extendRightEnd():e.ctrlKey?v.moveRightEnd():e.shiftKey?v.extendRight():v.moveRight()):"ArrowLeft"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?v.extendLeftEnd():e.ctrlKey?v.moveLeftEnd():e.shiftKey?v.extendLeft():v.moveLeft()):"ArrowUp"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?v.extendTop():e.ctrlKey?v.moveTop():e.shiftKey?v.extendUp():v.moveUp()):"ArrowDown"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?v.extendBottom():e.ctrlKey?v.moveBottom():e.shiftKey?v.extendDown():v.moveDown()):"F2"===e.key?(e.preventDefault(),f.startEditing()):e.ctrlKey&&"c"===e.key.toLowerCase()?(e.preventDefault(),c({enableDeprecatedCopy:null==s?void 0:s.enableDeprecatedCopy})):e.altKey||e.ctrlKey||!/^[a-zA-Z0-9]$/.test(e.key)?"Backspace"!==e.key&&"Delete"!==e.key||(e.preventDefault(),e.stopPropagation(),f.startEditing(),setTimeout((function(){a("",y.getEditorId())}),10)):(e.preventDefault(),e.stopPropagation(),f.startEditing(),setTimeout((function(){a(e.key,y.getEditorId())}),10)))};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[v,f.isEditing]),r((function(){f.isEditing&&!l.editable&&f.endEditing()}),[f,l]),e(t,{})}export{s as KeyboardSetting};
1
+ "use client";import{jsx as e,Fragment as t}from"react/jsx-runtime";import{useEffect as r}from"react";import{useEditContext as n}from"../../edit/provider.js";import{useColumnsContext as o}from"../../sheet/providers.js";import{useRangeContext as i}from"../../range/provider.js";import{useCopyActionContext as d}from"../../copy/provider.js";import{useTableIdGenerator as p}from"../../id/provider.js";import{isComposingKey as a,isTextEntryTarget as s}from"../event-target.js";var y=function(e,t){var r,n=document.getElementById(t);if(n){var o=null===(r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value"))||void 0===r?void 0:r.set;o&&o.call(n,e);var i=new Event("input",{bubbles:!0});n.dispatchEvent(i)}};function f(f){var v=p(),c=n(),l=i(),m=d().copy,u=o()[l.isSelecting?l.start.colIndex:0];return r((function(){var e=function(e){a(e)||(c.isEditing?"Escape"===e.key&&(e.preventDefault(),c.endEditing()):l.isSelecting&&!s(e.target)&&("Enter"===e.key?(e.preventDefault(),l.moveDown()):"Escape"===e.key?(e.preventDefault(),l.reset()):"ArrowRight"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?l.extendRightEnd():e.ctrlKey?l.moveRightEnd():e.shiftKey?l.extendRight():l.moveRight()):"ArrowLeft"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?l.extendLeftEnd():e.ctrlKey?l.moveLeftEnd():e.shiftKey?l.extendLeft():l.moveLeft()):"ArrowUp"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?l.extendTop():e.ctrlKey?l.moveTop():e.shiftKey?l.extendUp():l.moveUp()):"ArrowDown"===e.key?(e.preventDefault(),e.ctrlKey&&e.shiftKey?l.extendBottom():e.ctrlKey?l.moveBottom():e.shiftKey?l.extendDown():l.moveDown()):"F2"===e.key?(e.preventDefault(),c.startEditing()):(e.ctrlKey||e.metaKey)&&"c"===e.key.toLowerCase()?(e.preventDefault(),m({enableDeprecatedCopy:null==f?void 0:f.enableDeprecatedCopy})):e.altKey||e.ctrlKey||e.metaKey||!/^[a-zA-Z0-9]$/.test(e.key)?"Backspace"!==e.key&&"Delete"!==e.key||(e.preventDefault(),e.stopPropagation(),c.startEditing(),setTimeout((function(){y("",v.getEditorId())}),10)):(e.preventDefault(),e.stopPropagation(),c.startEditing(),setTimeout((function(){y(e.key,v.getEditorId())}),10))))};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[l,c.isEditing]),r((function(){c.isEditing&&!u.editable&&c.endEditing()}),[c,u]),e(t,{})}export{f as KeyboardSetting};
3
2
  //# sourceMappingURL=keyboard-setting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboard-setting.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"keyboard-setting.js","sources":["../../../../../../src/table/operation/components/keyboard-setting.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useEditContext } from \"../../edit/provider\";\nimport { useColumnsContext } from \"../../sheet/providers\";\nimport { useRangeContext } from \"../../range/provider\";\nimport { useCopyActionContext } from \"../../copy/provider\";\nimport { useTableIdGenerator } from \"../../id\";\nimport { isComposingKey, isTextEntryTarget } from \"../event-target\";\n\nconst setInitialValueToInputForm = (key: string, id: string) => {\n const inputElement = document.getElementById(id);\n if (inputElement) {\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n \"value\"\n )?.set;\n\n if (nativeInputValueSetter) {\n nativeInputValueSetter.call(inputElement, key);\n }\n\n const ev = new Event(\"input\", { bubbles: true });\n inputElement.dispatchEvent(ev);\n }\n};\n\nexport function KeyboardSetting(options?: { enableDeprecatedCopy?: boolean }) {\n const IdGenerator = useTableIdGenerator();\n const edit = useEditContext();\n const range = useRangeContext();\n const { copy } = useCopyActionContext();\n const col = useColumnsContext()[range.isSelecting ? range.start.colIndex : 0];\n\n useEffect(() => {\n const listener = (e: KeyboardEvent) => {\n if (isComposingKey(e)) {\n return;\n }\n\n if (edit.isEditing) {\n if (e.key === \"Escape\") {\n e.preventDefault();\n edit.endEditing();\n }\n } else if (range.isSelecting && !isTextEntryTarget(e.target)) {\n if (e.key === \"Enter\") {\n e.preventDefault();\n range.moveDown();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n range.reset();\n } else if (e.key === \"ArrowRight\") {\n e.preventDefault();\n\n if (e.ctrlKey && e.shiftKey) {\n range.extendRightEnd();\n } else if (e.ctrlKey) {\n range.moveRightEnd();\n } else if (e.shiftKey) {\n range.extendRight();\n } else {\n range.moveRight();\n }\n } else if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n\n if (e.ctrlKey && e.shiftKey) {\n range.extendLeftEnd();\n } else if (e.ctrlKey) {\n range.moveLeftEnd();\n } else if (e.shiftKey) {\n range.extendLeft();\n } else {\n range.moveLeft();\n }\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n\n if (e.ctrlKey && e.shiftKey) {\n range.extendTop();\n } else if (e.ctrlKey) {\n range.moveTop();\n } else if (e.shiftKey) {\n range.extendUp();\n } else {\n range.moveUp();\n }\n } else if (e.key === \"ArrowDown\") {\n e.preventDefault();\n\n if (e.ctrlKey && e.shiftKey) {\n range.extendBottom();\n } else if (e.ctrlKey) {\n range.moveBottom();\n } else if (e.shiftKey) {\n range.extendDown();\n } else {\n range.moveDown();\n }\n } else if (e.key === \"F2\") {\n e.preventDefault();\n edit.startEditing();\n } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === \"c\") {\n e.preventDefault();\n copy({ enableDeprecatedCopy: options?.enableDeprecatedCopy });\n } else if (\n !e.altKey &&\n !e.ctrlKey &&\n !e.metaKey &&\n /^[a-zA-Z0-9]$/.test(e.key)\n ) {\n e.preventDefault();\n e.stopPropagation();\n edit.startEditing();\n\n setTimeout(() => {\n setInitialValueToInputForm(e.key, IdGenerator.getEditorId());\n }, 10);\n } else if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n e.stopPropagation();\n edit.startEditing();\n\n setTimeout(() => {\n setInitialValueToInputForm(\"\", IdGenerator.getEditorId());\n }, 10);\n }\n }\n };\n\n document.addEventListener(\"keydown\", listener);\n\n return () => {\n document.removeEventListener(\"keydown\", listener);\n };\n }, [range, edit.isEditing]);\n\n useEffect(() => {\n if (edit.isEditing && !col.editable) {\n edit.endEditing();\n }\n }, [edit, col]);\n\n return <></>;\n}\n"],"names":["setInitialValueToInputForm","key","id","inputElement","document","getElementById","nativeInputValueSetter","_a","Object","getOwnPropertyDescriptor","window","HTMLInputElement","prototype","set","call","ev","Event","bubbles","dispatchEvent","KeyboardSetting","options","IdGenerator","useTableIdGenerator","edit","useEditContext","range","useRangeContext","copy","useCopyActionContext","col","useColumnsContext","isSelecting","start","colIndex","useEffect","listener","e","isComposingKey","isEditing","preventDefault","endEditing","isTextEntryTarget","target","moveDown","reset","ctrlKey","shiftKey","extendRightEnd","moveRightEnd","extendRight","moveRight","extendLeftEnd","moveLeftEnd","extendLeft","moveLeft","extendTop","moveTop","extendUp","moveUp","extendBottom","moveBottom","extendDown","startEditing","metaKey","toLowerCase","enableDeprecatedCopy","altKey","test","stopPropagation","setTimeout","getEditorId","addEventListener","removeEventListener","editable","_jsx"],"mappings":"wdAUA,IAAMA,EAA6B,SAACC,EAAaC,SACzCC,EAAeC,SAASC,eAAeH,GAC7C,GAAIC,EAAc,CAChB,IAAMG,EAGL,QAH8BC,EAAAC,OAAOC,yBACpCC,OAAOC,iBAAiBC,UACxB,gBACD,IAAAL,OAAA,EAAAA,EAAEM,IAECP,GACFA,EAAuBQ,KAAKX,EAAcF,GAG5C,IAAMc,EAAK,IAAIC,MAAM,QAAS,CAAEC,SAAS,IACzCd,EAAae,cAAcH,EAC7B,CACF,EAEM,SAAUI,EAAgBC,GAC9B,IAAMC,EAAcC,IACdC,EAAOC,IACPC,EAAQC,IACNC,EAASC,SACXC,EAAMC,IAAoBL,EAAMM,YAAcN,EA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C,EAAEG,iBACFH,EAAEgC,kBACF7C,EAAKuC,eAELO,YAAW,WACTrE,EAA2B,GAAIqB,EAAYiD,cAC7C,GAAG,MAdHlC,EAAEG,iBACFH,EAAEgC,kBACF7C,EAAKuC,eAELO,YAAW,WACTrE,EAA2BoC,EAAEnC,IAAKoB,EAAYiD,cAChD,GAAG,MAWT,EAIA,OAFAlE,SAASmE,iBAAiB,UAAWpC,GAE9B,WACL/B,SAASoE,oBAAoB,UAAWrC,EAC1C,CACF,GAAG,CAACV,EAAOF,EAAKe,YAEhBJ,GAAU,WACJX,EAAKe,YAAcT,EAAI4C,UACzBlD,EAAKiB,YAET,GAAG,CAACjB,EAAMM,IAEH6C,OACT"}
@@ -0,0 +1,2 @@
1
+ function e(e){return e instanceof HTMLElement&&(!!e.isContentEditable||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))}function n(e){return e.isComposing||229===e.keyCode}export{n as isComposingKey,e as isTextEntryTarget};
2
+ //# sourceMappingURL=event-target.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-target.js","sources":["../../../../../src/table/operation/event-target.ts"],"sourcesContent":["/**\n * Returns true when the event comes from an element where the user types\n * text (input, textarea, select or contenteditable). The table must not take\n * over keys or pastes aimed at such elements.\n */\nexport function isTextEntryTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n\n if (target.isContentEditable) {\n return true;\n }\n\n return (\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target instanceof HTMLSelectElement\n );\n}\n\n/** True while an IME (e.g. Japanese input) is composing text. */\nexport function isComposingKey(e: KeyboardEvent): boolean {\n return e.isComposing || e.keyCode === 229;\n}\n"],"names":["isTextEntryTarget","target","HTMLElement","isContentEditable","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","isComposingKey","e","isComposing","keyCode"],"mappings":"AAKM,SAAUA,EAAkBC,GAChC,OAAMA,aAAkBC,gBAIpBD,EAAOE,oBAKTF,aAAkBG,kBAClBH,aAAkBI,qBAClBJ,aAAkBK,mBAEtB,CAGM,SAAUC,EAAeC,GAC7B,OAAOA,EAAEC,aAA6B,MAAdD,EAAEE,OAC5B"}
@@ -1,3 +1,2 @@
1
- "use client";
2
- import{jsx as r,Fragment as t,jsxs as e}from"react/jsx-runtime";import{usePageContext as n}from"./providers.js";function o(){var o=n(),u=o.enable,c=o.current,i=o.pageCount,s=o.jump,a=o.prev,l=o.next;return u?e("div",{className:"flex justify-center gap-2",children:[r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return s(1)},disabled:1===c,children:"≪"}),r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return a()},disabled:1===c,children:"<"}),Array.from({length:i},(function(r,t){return t+1})).filter((function(r){return c-2<=r&&r<=c+2})).map((function(t){return r("button",{className:"text-sm cursor-pointer disabled:cursor-default ".concat(c===t?"text-blue-600":""),onClick:function(){return s(t)},children:t},t)})),r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return l()},disabled:c===i,children:">"}),r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return s(i)},disabled:c===i,children:"≫"})]}):r(t,{})}function u(){var o=n(),u=o.enable,c=o.from,i=o.to,s=o.rowCount;return u?e("p",{className:"text-center text-sm text-gray-600",children:[c+1," - ",i<s?i:s," of ",s]}):r(t,{})}export{u as DisplayRange,o as Pagenation};
1
+ "use client";import{jsx as r,Fragment as t,jsxs as e}from"react/jsx-runtime";import{usePageContext as n}from"./providers.js";function o(){var o=n(),u=o.enable,c=o.current,i=o.pageCount,s=o.jump,l=o.prev,a=o.next;return u?e("div",{className:"flex justify-center gap-2",children:[r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return s(1)},disabled:1===c,children:"≪"}),r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return l()},disabled:1===c,children:"<"}),Array.from({length:i},(function(r,t){return t+1})).filter((function(r){return c-2<=r&&r<=c+2})).map((function(t){return r("button",{className:"text-sm cursor-pointer disabled:cursor-default ".concat(c===t?"text-blue-600":""),onClick:function(){return s(t)},children:t},t)})),r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return a()},disabled:c>=i,children:">"}),r("button",{className:"text-sm cursor-pointer disabled:cursor-default",onClick:function(){return s(i)},disabled:c>=i,children:"≫"})]}):r(t,{})}function u(){var o=n(),u=o.enable,c=o.from,i=o.to,s=o.rowCount;return u?e("p",{className:"text-center text-sm text-gray-600",children:[0===s?0:c+1," - ",i<s?i:s," of"," ",s]}):r(t,{})}export{u as DisplayRange,o as Pagenation};
3
2
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"components.js","sources":["../../../../../src/table/pagenation/components.tsx"],"sourcesContent":["\"use client\";\n\nimport { usePageContext } from \"./providers\";\n\nexport function Pagenation() {\n const { enable, current, pageCount, jump, prev, next } = usePageContext();\n\n if (!enable) {\n return <></>;\n }\n\n return (\n <div className=\"flex justify-center gap-2\">\n <button\n className=\"text-sm cursor-pointer disabled:cursor-default\"\n onClick={() => jump(1)}\n disabled={current === 1}\n >\n &#x226A;\n </button>\n <button\n className=\"text-sm cursor-pointer disabled:cursor-default\"\n onClick={() => prev()}\n disabled={current === 1}\n >\n &lt;\n </button>\n {Array.from({ length: pageCount }, (_, i) => i + 1)\n .filter((i) => current - 2 <= i && i <= current + 2)\n .map((i) => (\n <button\n key={i}\n className={`text-sm cursor-pointer disabled:cursor-default ${current === i ? \"text-blue-600\" : \"\"}`}\n onClick={() => jump(i)}\n >\n {i}\n </button>\n ))}\n <button\n className=\"text-sm cursor-pointer disabled:cursor-default\"\n onClick={() => next()}\n disabled={current >= pageCount}\n >\n &gt;\n </button>\n <button\n className=\"text-sm cursor-pointer disabled:cursor-default\"\n onClick={() => jump(pageCount)}\n disabled={current >= pageCount}\n >\n &#x226B;\n </button>\n </div>\n );\n}\n\nexport function DisplayRange() {\n const { enable, from, to, rowCount } = usePageContext();\n\n if (!enable) {\n return <></>;\n }\n\n return (\n <p className=\"text-center text-sm text-gray-600\">\n {rowCount === 0 ? 0 : from + 1} - {to < rowCount ? to : rowCount} of{\" \"}\n {rowCount}\n </p>\n );\n}\n"],"names":["Pagenation","_a","usePageContext","enable","current","pageCount","jump","prev","next","_jsxs","className","children","_jsx","onClick","disabled","Array","from","length","_","i","filter","map","DisplayRange","to","rowCount"],"mappings":"sIAIgBA,IACR,IAAAC,EAAmDC,IAAjDC,EAAMF,EAAAE,OAAEC,EAAOH,EAAAG,QAAEC,EAASJ,EAAAI,UAAEC,EAAIL,EAAAK,KAAEC,EAAIN,EAAAM,KAAEC,EAAIP,EAAAO,KAEpD,OAAKL,EAKHM,EAAA,MAAA,CAAKC,UAAU,4BAA2BC,SAAA,CACxCC,EAAA,SAAA,CACEF,UAAU,iDACVG,QAAS,WAAM,OAAAP,EAAK,EAAL,EACfQ,SAAsB,IAAZV,iBAIZQ,EAAA,SAAA,CACEF,UAAU,iDACVG,QAAS,WAAM,OAAAN,GAAA,EACfO,SAAsB,IAAZV,EAAaO,SAAA,MAIxBI,MAAMC,KAAK,CAAEC,OAAQZ,IAAa,SAACa,EAAGC,GAAM,OAAAA,EAAI,CAAJ,IAC1CC,QAAO,SAACD,GAAM,OAAAf,EAAU,GAAKe,GAAKA,GAAKf,EAAU,CAAnC,IACdiB,KAAI,SAACF,GAAM,OACVP,YAEEF,UAAW,yDAAkDN,IAAYe,EAAI,gBAAkB,IAC/FN,QAAS,WAAM,OAAAP,EAAKa,EAAL,EAAOR,SAErBQ,GAJIA,EAFG,IASdP,EAAA,SAAA,CACEF,UAAU,iDACVG,QAAS,WAAM,OAAAL,GAAA,EACfM,SAAUV,GAAWC,EAASM,SAAA,MAIhCC,YACEF,UAAU,iDACVG,QAAS,WAAM,OAAAP,EAAKD,EAAL,EACfS,SAAUV,GAAWC,EAASM,SAAA,SAxC3BC,OA8CX,UAEgBU,IACR,IAAArB,EAAiCC,IAA/BC,EAAMF,EAAAE,OAAEa,EAAIf,EAAAe,KAAEO,EAAEtB,EAAAsB,GAAEC,aAE1B,OAAKrB,EAKHM,EAAA,IAAA,CAAGC,UAAU,8CACG,IAAbc,EAAiB,EAAIR,EAAO,EAAC,MAAKO,EAAKC,EAAWD,EAAKC,EAAQ,MAAK,IACpEA,KANIZ,OASX"}
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as r,useCallback as n,useMemo as t}from"react";import{INITIAL_PAGE_STATE as a}from"./constants.js";function o(r,n){switch(n.type){case"setRowCount":return r.enable?e(e({},r),{currentPage:1,rowCount:n.payload.rowCount}):e(e({},r),{rowCount:n.payload.rowCount});case"setPerPage":return"all"===n.payload.perPage?{rowCount:r.rowCount,enable:!1}:r.enable?e(e({},r),{currentPage:1,perPage:n.payload.perPage}):{rowCount:r.rowCount,enable:!0,currentPage:1,perPage:n.payload.perPage};case"next":return r.enable?r.currentPage===Math.ceil(r.rowCount/r.perPage)?r:e(e({},r),{currentPage:r.currentPage+1}):r;case"prev":return r.enable?1===r.currentPage?r:e(e({},r),{currentPage:r.currentPage-1}):r;case"jump":return r.enable?n.payload.pageNumber<1||n.payload.pageNumber>Math.ceil(r.rowCount/r.perPage)||r.currentPage===n.payload.pageNumber?r:e(e({},r),{currentPage:n.payload.pageNumber}):r;default:return r}}function u(e){var u=r(o,null!=e?e:a),p=u[0],l=u[1],c=n((function(){return l({type:"next"})}),[l]),g=n((function(){return l({type:"prev"})}),[l]),P=n((function(e){return l({type:"jump",payload:{pageNumber:e}})}),[l]),b=n((function(e){return l({type:"setRowCount",payload:{rowCount:e}})}),[l]),i=t((function(){return p.enable?(p.currentPage-1)*p.perPage:0}),[p]),w=t((function(){return p.enable?p.currentPage*p.perPage:p.rowCount}),[p]),C=n((function(e){return e.slice(i,w)}),[i,w]);return{enable:p.enable,perPage:p.enable?p.perPage:p.rowCount,current:p.enable?p.currentPage:1,rowCount:p.rowCount,pageCount:p.enable?Math.ceil(p.rowCount/p.perPage):1,from:i,to:w,next:c,prev:g,jump:P,setRowCount:b,pageFilter:C}}export{u as usePageReducer};
1
+ import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as r,useCallback as n,useMemo as t}from"react";import{INITIAL_PAGE_STATE as a}from"./constants.js";function o(r,n){switch(n.type){case"setRowCount":return r.enable?e(e({},r),{currentPage:1,rowCount:n.payload.rowCount}):e(e({},r),{rowCount:n.payload.rowCount});case"setPerPage":return"all"===n.payload.perPage?{rowCount:r.rowCount,enable:!1}:r.enable?e(e({},r),{currentPage:1,perPage:n.payload.perPage}):{rowCount:r.rowCount,enable:!0,currentPage:1,perPage:n.payload.perPage};case"next":return r.enable?r.currentPage>=Math.ceil(r.rowCount/r.perPage)?r:e(e({},r),{currentPage:r.currentPage+1}):r;case"prev":return r.enable?1===r.currentPage?r:e(e({},r),{currentPage:r.currentPage-1}):r;case"jump":return r.enable?n.payload.pageNumber<1||n.payload.pageNumber>Math.ceil(r.rowCount/r.perPage)||r.currentPage===n.payload.pageNumber?r:e(e({},r),{currentPage:n.payload.pageNumber}):r;default:return r}}function u(e){var u=r(o,null!=e?e:a),p=u[0],l=u[1],c=n((function(){return l({type:"next"})}),[l]),g=n((function(){return l({type:"prev"})}),[l]),P=n((function(e){return l({type:"jump",payload:{pageNumber:e}})}),[l]),b=n((function(e){return l({type:"setRowCount",payload:{rowCount:e}})}),[l]),i=t((function(){return p.enable?(p.currentPage-1)*p.perPage:0}),[p]),w=t((function(){return p.enable?p.currentPage*p.perPage:p.rowCount}),[p]),C=n((function(e){return e.slice(i,w)}),[i,w]);return{enable:p.enable,perPage:p.enable?p.perPage:p.rowCount,current:p.enable?p.currentPage:1,rowCount:p.rowCount,pageCount:p.enable?Math.ceil(p.rowCount/p.perPage):1,from:i,to:w,next:c,prev:g,jump:P,setRowCount:b,pageFilter:C}}export{u as usePageReducer};
2
2
  //# sourceMappingURL=hooks.js.map