@teppen/react-ui 1.3.2 → 1.4.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 (103) hide show
  1. package/README.md +20 -1
  2. package/dist/cjs/src/table/base.js +1 -1
  3. package/dist/cjs/src/table/cell/provider.js +2 -0
  4. package/dist/cjs/src/table/cell/provider.js.map +1 -0
  5. package/dist/cjs/src/table/cell/ui/base-input.js +2 -0
  6. package/dist/cjs/src/table/cell/ui/base-input.js.map +1 -0
  7. package/dist/cjs/src/table/cell/ui/cell.js +3 -0
  8. package/dist/cjs/src/table/cell/ui/edit-button.js +3 -0
  9. package/dist/cjs/src/table/cell/ui/edit-button.js.map +1 -0
  10. package/dist/cjs/src/table/cell/ui/number-input.js +3 -0
  11. package/dist/cjs/src/table/cell/ui/number-input.js.map +1 -0
  12. package/dist/cjs/src/table/cell/ui/select-input.js +3 -0
  13. package/dist/cjs/src/table/cell/ui/select-input.js.map +1 -0
  14. package/dist/cjs/src/table/cell/ui/string-input.js +3 -0
  15. package/dist/cjs/src/table/cell/ui/string-input.js.map +1 -0
  16. package/dist/cjs/src/table/edit/hooks.js +1 -1
  17. package/dist/cjs/src/table/edit/hooks.js.map +1 -1
  18. package/dist/cjs/src/table/edit/provider.js +1 -1
  19. package/dist/cjs/src/table/focus/hooks.js +2 -0
  20. package/dist/cjs/src/table/focus/hooks.js.map +1 -0
  21. package/dist/cjs/src/table/focus/provider.js +2 -0
  22. package/dist/cjs/src/table/focus/provider.js.map +1 -0
  23. package/dist/cjs/src/table/header/header.js +2 -1
  24. package/dist/cjs/src/table/header/header.js.map +1 -1
  25. package/dist/cjs/src/table/hook.js +1 -1
  26. package/dist/cjs/src/table/hook.js.map +1 -1
  27. package/dist/cjs/src/table/libs/generate-validate-function.js +2 -0
  28. package/dist/cjs/src/table/libs/generate-validate-function.js.map +1 -0
  29. package/dist/cjs/src/table/libs/id-generator.js +2 -0
  30. package/dist/cjs/src/table/libs/id-generator.js.map +1 -0
  31. package/dist/cjs/src/table/operation/components/keyboard-setting.js +2 -0
  32. package/dist/cjs/src/table/operation/components/keyboard-setting.js.map +1 -0
  33. package/dist/cjs/src/table/pagenation/components.js +1 -1
  34. package/dist/cjs/src/table/pagenation/constants.js +1 -1
  35. package/dist/cjs/src/table/pagenation/constants.js.map +1 -1
  36. package/dist/cjs/src/table/pagenation/hooks.js +1 -1
  37. package/dist/cjs/src/table/pagenation/hooks.js.map +1 -1
  38. package/dist/cjs/src/table/pagenation/providers.js +1 -1
  39. package/dist/cjs/src/table/sheet/providers.js +1 -1
  40. package/dist/cjs/src/table/table/components/auto-switch-edit-mode.js +2 -0
  41. package/dist/cjs/src/table/table/components/auto-switch-edit-mode.js.map +1 -0
  42. package/dist/cjs/src/table/table-property/components/auto-update-table-property.js +2 -0
  43. package/dist/cjs/src/table/table-property/components/auto-update-table-property.js.map +1 -0
  44. package/dist/cjs/src/table/table-property/hook.js +2 -0
  45. package/dist/cjs/src/table/table-property/hook.js.map +1 -0
  46. package/dist/cjs/src/table/table-property/provider.js +2 -0
  47. package/dist/cjs/src/table/table-property/provider.js.map +1 -0
  48. package/dist/esm/src/table/base.js +1 -1
  49. package/dist/esm/src/table/cell/provider.js +2 -0
  50. package/dist/esm/src/table/cell/provider.js.map +1 -0
  51. package/dist/esm/src/table/cell/ui/base-input.js +2 -0
  52. package/dist/esm/src/table/cell/ui/base-input.js.map +1 -0
  53. package/dist/esm/src/table/cell/ui/cell.js +3 -0
  54. package/dist/esm/src/table/cell/ui/edit-button.js +3 -0
  55. package/dist/esm/src/table/cell/ui/edit-button.js.map +1 -0
  56. package/dist/esm/src/table/cell/ui/number-input.js +3 -0
  57. package/dist/esm/src/table/cell/ui/number-input.js.map +1 -0
  58. package/dist/esm/src/table/cell/ui/select-input.js +3 -0
  59. package/dist/esm/src/table/cell/ui/select-input.js.map +1 -0
  60. package/dist/esm/src/table/cell/ui/string-input.js +3 -0
  61. package/dist/esm/src/table/cell/ui/string-input.js.map +1 -0
  62. package/dist/esm/src/table/edit/hooks.js +1 -1
  63. package/dist/esm/src/table/edit/hooks.js.map +1 -1
  64. package/dist/esm/src/table/edit/provider.js +1 -1
  65. package/dist/esm/src/table/focus/hooks.js +2 -0
  66. package/dist/esm/src/table/focus/hooks.js.map +1 -0
  67. package/dist/esm/src/table/focus/provider.js +2 -0
  68. package/dist/esm/src/table/focus/provider.js.map +1 -0
  69. package/dist/esm/src/table/header/header.js +2 -1
  70. package/dist/esm/src/table/header/header.js.map +1 -1
  71. package/dist/esm/src/table/hook.js +1 -1
  72. package/dist/esm/src/table/hook.js.map +1 -1
  73. package/dist/esm/src/table/libs/generate-validate-function.js +2 -0
  74. package/dist/esm/src/table/libs/generate-validate-function.js.map +1 -0
  75. package/dist/esm/src/table/libs/id-generator.js +2 -0
  76. package/dist/esm/src/table/libs/id-generator.js.map +1 -0
  77. package/dist/esm/src/table/operation/components/keyboard-setting.js +2 -0
  78. package/dist/esm/src/table/operation/components/keyboard-setting.js.map +1 -0
  79. package/dist/esm/src/table/pagenation/components.js +1 -1
  80. package/dist/esm/src/table/pagenation/constants.js +1 -1
  81. package/dist/esm/src/table/pagenation/constants.js.map +1 -1
  82. package/dist/esm/src/table/pagenation/hooks.js +1 -1
  83. package/dist/esm/src/table/pagenation/hooks.js.map +1 -1
  84. package/dist/esm/src/table/pagenation/providers.js +1 -1
  85. package/dist/esm/src/table/sheet/providers.js +1 -1
  86. package/dist/esm/src/table/table/components/auto-switch-edit-mode.js +2 -0
  87. package/dist/esm/src/table/table/components/auto-switch-edit-mode.js.map +1 -0
  88. package/dist/esm/src/table/table-property/components/auto-update-table-property.js +2 -0
  89. package/dist/esm/src/table/table-property/components/auto-update-table-property.js.map +1 -0
  90. package/dist/esm/src/table/table-property/hook.js +2 -0
  91. package/dist/esm/src/table/table-property/hook.js.map +1 -0
  92. package/dist/esm/src/table/table-property/provider.js +2 -0
  93. package/dist/esm/src/table/table-property/provider.js.map +1 -0
  94. package/dist/index.d.ts +16 -9
  95. package/package.json +1 -1
  96. package/dist/cjs/node_modules/react-intersection-observer/index.js +0 -3
  97. package/dist/cjs/node_modules/react-intersection-observer/index.js.map +0 -1
  98. package/dist/cjs/src/table/cell.js +0 -3
  99. package/dist/esm/node_modules/react-intersection-observer/index.js +0 -3
  100. package/dist/esm/node_modules/react-intersection-observer/index.js.map +0 -1
  101. package/dist/esm/src/table/cell.js +0 -3
  102. /package/dist/cjs/src/table/{cell.js.map → cell/ui/cell.js.map} +0 -0
  103. /package/dist/esm/src/table/{cell.js.map → cell/ui/cell.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";var a=require("../../../node_modules/tslib/tslib.es6.js"),o=require("react"),s=function(o,s){switch(s.type){case"setMaxDisplayRowCount":return a.__assign(a.__assign({},o),{maxDisplayRowCount:s.payload.maxDisplayRowCount});case"setMaxDisplayColCount":return a.__assign(a.__assign({},o),{maxDisplayColCount:s.payload.maxDisplayColCount})}};exports.useTablePropertyReducer=function(){var a=o.useReducer(s,{maxDisplayRowCount:0,maxDisplayColCount:0}),t=a[0],l=a[1],u=o.useCallback((function(a){l({type:"setMaxDisplayRowCount",payload:{maxDisplayRowCount:a}})}),[l]),e=o.useCallback((function(a){l({type:"setMaxDisplayColCount",payload:{maxDisplayColCount:a}})}),[l]);return{maxDisplayRowCount:t.maxDisplayRowCount,maxDisplayColCount:t.maxDisplayColCount,setMaxDisplayRowCount:u,setMaxDisplayColCount:e}};
2
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.js","sources":["../../../../../src/table/table-property/hook.ts"],"sourcesContent":["import { useCallback, useReducer } from \"react\";\nimport { TReturnTablePropertyReducer, TTablePropertyReducer } from \"./type\";\n\nconst reducer: TTablePropertyReducer = (state, action) => {\n switch (action.type) {\n case \"setMaxDisplayRowCount\":\n return {\n ...state,\n maxDisplayRowCount: action.payload.maxDisplayRowCount,\n };\n\n case \"setMaxDisplayColCount\":\n return {\n ...state,\n maxDisplayColCount: action.payload.maxDisplayColCount,\n };\n }\n};\n\nexport function useTablePropertyReducer(): TReturnTablePropertyReducer {\n const [state, dispatch] = useReducer(reducer, {\n maxDisplayRowCount: 0,\n maxDisplayColCount: 0,\n });\n\n const setMaxDisplayRowCount = useCallback(\n (maxDisplayRowCount: number) => {\n dispatch({\n type: \"setMaxDisplayRowCount\",\n payload: { maxDisplayRowCount },\n });\n },\n [dispatch]\n );\n\n const setMaxDisplayColCount = useCallback(\n (maxDisplayColCount: number) => {\n dispatch({\n type: \"setMaxDisplayColCount\",\n payload: { maxDisplayColCount },\n });\n },\n [dispatch]\n );\n\n return {\n maxDisplayRowCount: state.maxDisplayRowCount,\n maxDisplayColCount: state.maxDisplayColCount,\n setMaxDisplayRowCount,\n setMaxDisplayColCount,\n };\n}\n"],"names":["reducer","state","action","type","__assign","maxDisplayRowCount","payload","maxDisplayColCount","_a","useReducer","dispatch","setMaxDisplayRowCount","useCallback","setMaxDisplayColCount"],"mappings":"0FAGMA,EAAiC,SAACC,EAAOC,GAC7C,OAAQA,EAAOC,MACb,IAAK,wBACH,OACKC,WAAAA,EAAAA,SAAA,CAAA,EAAAH,IACHI,mBAAoBH,EAAOI,QAAQD,qBAGvC,IAAK,wBACH,OACKD,WAAAA,EAAAA,SAAA,CAAA,EAAAH,IACHM,mBAAoBL,EAAOI,QAAQC,qBAG3C,6CAGQ,IAAAC,EAAoBC,EAAUA,WAACT,EAAS,CAC5CK,mBAAoB,EACpBE,mBAAoB,IAFfN,EAAKO,EAAA,GAAEE,OAKRC,EAAwBC,eAC5B,SAACP,GACCK,EAAS,CACPP,KAAM,wBACNG,QAAS,CAAED,mBAAkBA,IAEjC,GACA,CAACK,IAGGG,EAAwBD,eAC5B,SAACL,GACCG,EAAS,CACPP,KAAM,wBACNG,QAAS,CAAEC,mBAAkBA,IAEjC,GACA,CAACG,IAGH,MAAO,CACLL,mBAAoBJ,EAAMI,mBAC1BE,mBAAoBN,EAAMM,mBAC1BI,sBAAqBA,EACrBE,sBAAqBA,EAEzB"}
@@ -0,0 +1,2 @@
1
+ "use strict";require("../../../node_modules/tslib/tslib.es6.js");var e=require("react/jsx-runtime"),t=require("react"),o=require("./hook.js"),r=t.createContext({maxDisplayColCount:0,maxDisplayRowCount:0}),n=t.createContext({setMaxDisplayColCount:function(){},setMaxDisplayRowCount:function(){}});exports.TablePropertyProvider=function(u){var a=o.useTablePropertyReducer(),s=t.useMemo((function(){return{maxDisplayColCount:a.maxDisplayColCount,maxDisplayRowCount:a.maxDisplayRowCount}}),[a.maxDisplayColCount,a.maxDisplayRowCount]),i=t.useMemo((function(){return{setMaxDisplayColCount:a.setMaxDisplayColCount,setMaxDisplayRowCount:a.setMaxDisplayRowCount}}),[]);return e.jsx(r.Provider,{value:s,children:e.jsx(n.Provider,{value:i,children:u.children})})},exports.useTablePropertyActionContext=function(){return t.useContext(n)},exports.useTablePropertyStateContext=function(){return t.useContext(r)};
2
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sources":["../../../../../src/table/table-property/provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport {\n TTablePropertyActionContext,\n TTablePropertyStateContext,\n} from \"./type\";\nimport { useTablePropertyReducer } from \"./hook\";\n\nconst TablePropertyStateContext = createContext<TTablePropertyStateContext>({\n maxDisplayColCount: 0,\n maxDisplayRowCount: 0,\n});\n\nconst TablePropertyActionContext = createContext<TTablePropertyActionContext>({\n setMaxDisplayColCount: () => {},\n setMaxDisplayRowCount: () => {},\n});\n\nexport function TablePropertyProvider(props: {\n children: JSX.Element | JSX.Element[];\n}) {\n const tableProperty = useTablePropertyReducer();\n\n const state = useMemo(() => {\n return {\n maxDisplayColCount: tableProperty.maxDisplayColCount,\n maxDisplayRowCount: tableProperty.maxDisplayRowCount,\n };\n }, [tableProperty.maxDisplayColCount, tableProperty.maxDisplayRowCount]);\n\n const action = useMemo(() => {\n return {\n setMaxDisplayColCount: tableProperty.setMaxDisplayColCount,\n setMaxDisplayRowCount: tableProperty.setMaxDisplayRowCount,\n };\n }, []);\n\n return (\n <TablePropertyStateContext.Provider value={state}>\n <TablePropertyActionContext.Provider value={action}>\n {props.children}\n </TablePropertyActionContext.Provider>\n </TablePropertyStateContext.Provider>\n );\n}\n\nexport function useTablePropertyStateContext() {\n return useContext(TablePropertyStateContext);\n}\n\nexport function useTablePropertyActionContext() {\n return useContext(TablePropertyActionContext);\n}\n\nexport function useTablePropertyContext() {\n return {\n ...useTablePropertyStateContext(),\n ...useTablePropertyActionContext(),\n };\n}\n"],"names":["TablePropertyStateContext","createContext","maxDisplayColCount","maxDisplayRowCount","TablePropertyActionContext","setMaxDisplayColCount","setMaxDisplayRowCount","props","tableProperty","useTablePropertyReducer","state","useMemo","action","_jsx","Provider","value","children","useContext"],"mappings":"8IAOMA,EAA4BC,EAAAA,cAA0C,CAC1EC,mBAAoB,EACpBC,mBAAoB,IAGhBC,EAA6BH,EAAAA,cAA2C,CAC5EI,sBAAuB,WAAQ,EAC/BC,sBAAuB,WAAQ,kCAG3B,SAAgCC,GAGpC,IAAMC,EAAgBC,EAAAA,0BAEhBC,EAAQC,EAAAA,SAAQ,WACpB,MAAO,CACLT,mBAAoBM,EAAcN,mBAClCC,mBAAoBK,EAAcL,mBAErC,GAAE,CAACK,EAAcN,mBAAoBM,EAAcL,qBAE9CS,EAASD,EAAAA,SAAQ,WACrB,MAAO,CACLN,sBAAuBG,EAAcH,sBACrCC,sBAAuBE,EAAcF,sBAExC,GAAE,IAEH,OACEO,EAAAA,IAACb,EAA0Bc,UAASC,MAAOL,EAAKM,SAC9CH,MAACT,EAA2BU,SAAQ,CAACC,MAAOH,EAAMI,SAC/CT,EAAMS,YAIf,mDAOE,OAAOC,EAAAA,WAAWb,EACpB,kDALE,OAAOa,EAAAA,WAAWjB,EACpB"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{__assign as e}from"../../node_modules/tslib/tslib.es6.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useEffect as t}from"react";import{useTable as n}from"./hook.js";import{TableCell as i}from"./cell.js";import{TableHeaderElement as l}from"./header/header.js";import{PagenationProvider as c}from"./pagenation/providers.js";import{DisplayRange as a,Pagenation as d}from"./pagenation/components.js";import{FilterProvider as s,useFilterContext as m}from"./filter/provider.js";import{TableFilterRemoveButton as h,TableFilterForm as f}from"./filter/components.js";import"./sort/icon.js";import{SortProvider as p}from"./sort/provider.js";import{ColumnsProvider as u,RowProvider as v,CellProvider as y}from"./sheet/providers.js";import{FocusProvider as g,useFocusContext as w}from"./edit/provider.js";import{CheckboxProvider as k,CheckboxStatusProvider as b}from"./checkbox/provider.js";import{AllCheckbox as x,Checkbox as j}from"./checkbox/components.js";function N(o){var t;return r(s,{children:r(p,{initialCondition:null===(t=o.initialCondition)||void 0===t?void 0:t.sort,children:r(c,{rowCount:o.rows.length,children:r(k,{checkbox:o.checkbox,children:r(b,{checkboxCount:o.rows.length,children:r(u,{cols:o.cols,children:r(g,{columnCount:o.cols.length,children:r(D,e({},o))})})})})})})})}function D(e){var c=n(e),s=c.cols,p=c.rows,u=w(),g=u.isFocus,k=u.isEditing,b=u.edit,N=u.moveLeft,D=u.moveRight,C=u.moveUp,R=u.moveDown,A=u.unfocus,E=u.setMaxRowNumber,F=m().selectedFilterKey;return t((function(){var e=function(e){g&&!k&&("Enter"===e.key?(e.preventDefault(),R()):"Escape"===e.key?(e.preventDefault(),A()):"ArrowRight"===e.key?(e.preventDefault(),D()):"ArrowLeft"===e.key?(e.preventDefault(),N()):"ArrowUp"===e.key?(e.preventDefault(),C()):"ArrowDown"===e.key?(e.preventDefault(),R()):"F2"===e.key&&b())};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[k,g]),t((function(){E(p.length-1)}),[p.length]),o("div",{className:"w-full",children:[r("div",{className:"flex justify-end mb-1 mr-3",children:r(h,{children:r("p",{className:"text-xs underline text-gray-500 hover:text-gray-700",children:"全てのフィルタリング条件を解除する"})})}),r("div",{id:"table-frame",className:"relative h-full max-w-full max-h-[80vh] border border-gray-200 rounded-md overflow-auto",children:o("table",{className:"table",children:[r("thead",{children:o("tr",{className:"sticky top-0 border-gray-200 z-20 bg-gray-200 text-gray-600 h-[32px]",children:[e.checkbox&&r("th",{children:r(x,{rows:e.rows})}),s.map((function(e){return r(l,{columnKey:e.key},e.key)}))]})}),o("tbody",{children:[!!F&&r("tr",{children:r("td",{colSpan:s.length,className:"sticky top-8 left-0 bg-gray-300 w-full shadow-lg rounded-b-2xl z-20 p-0 overflow-hidden",children:r(f,{})})}),0===p.length&&r("tr",{children:r("td",{colSpan:s.length,className:"py-5",children:r("p",{className:"text-center font-bold text-lg",children:"NO DATA"})})}),p.map((function(t,n){return r(v,{row:t,children:o("tr",{className:"relative border border-gray-200 after:absolute after:w-full after:h-full after:top-0 after:left-0 after:pointer-events-none after:hover:bg-gray-500/10 ".concat(e.onClickRow?"hover:cursor-pointer":""," ").concat(e.applyRowFormatting?e.applyRowFormatting(t):""),onClick:function(r){r.preventDefault(),e.onClickRow&&e.onClickRow(t)},"data-testid":t.id,children:[e.checkbox&&r("td",{children:r(j,{})}),s.map((function(e,o){return r(y,{columnKey:e.key,rowIndex:n,colIndex:o,children:r(i,{})},e.key)}))]})},t.id)}))]})]})}),o("div",{className:"mt-1",children:[r(a,{}),r("div",{className:"mt-2",children:r(d,{})})]})]})}export{N as default};
2
+ import{__assign as e}from"../../node_modules/tslib/tslib.es6.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useTable as t}from"./hook.js";import{TableCell as i}from"./cell/ui/cell.js";import{TableHeaderElement as n}from"./header/header.js";import{PagenationProvider as l}from"./pagenation/providers.js";import{DisplayRange as c,Pagenation as a}from"./pagenation/components.js";import{FilterProvider as d,useFilterContext as s}from"./filter/provider.js";import{TableFilterRemoveButton as m,TableFilterForm as p}from"./filter/components.js";import"./sort/icon.js";import{SortProvider as h}from"./sort/provider.js";import{ProcessedDataProvider as f,ColumnsProvider as u,RowProvider as b}from"./sheet/providers.js";import{FocusProvider as v,useFocusActionContext as g}from"./focus/provider.js";import{CheckboxProvider as y,CheckboxStatusProvider as w}from"./checkbox/provider.js";import{AllCheckbox as x,Checkbox as j}from"./checkbox/components.js";import{IdGenerator as k}from"./libs/id-generator.js";import{EditProvider as C}from"./edit/provider.js";import{TablePropertyProvider as N}from"./table-property/provider.js";import{AutoUpdateTableProperty as R}from"./table-property/components/auto-update-table-property.js";import{KeyboardSetting as F}from"./operation/components/keyboard-setting.js";import{AutoSwitchEditMode as I}from"./table/components/auto-switch-edit-mode.js";function K(t){var i,n,c;return r(d,{children:r(h,{initialCondition:null===(i=t.initialCondition)||void 0===i?void 0:i.sort,children:r(l,{rowCount:t.rows.length,perPage:null===(c=null===(n=t.initialCondition)||void 0===n?void 0:n.pagenation)||void 0===c?void 0:c.rowCountPerPage,children:r(y,{checkbox:t.checkbox,children:r(w,{checkboxCount:t.rows.length,children:r(f,{props:t,children:r(u,{cols:t.cols,children:r(v,{children:r(C,{children:o(N,{children:[r(R,{}),r(I,{}),r(F,{}),r(P,e({},t))]})})})})})})})})})})}function P(e){var l=t(e),d=l.cols,h=l.rows,f=s().selectedFilterKey,u=g().unfocus;return o("div",{className:"w-full",children:[r("div",{className:"flex justify-end mb-1 mr-3",children:r(m,{children:r("p",{className:"text-xs underline text-gray-500 hover:text-gray-700",children:"全てのフィルタリング条件を解除する"})})}),r("div",{id:"table-frame",className:"relative h-full max-w-full max-h-[80vh] border border-gray-200 rounded-md overflow-auto",children:o("table",{className:"table",children:[r("thead",{children:o("tr",{className:"sticky top-0 border-gray-200 z-20 bg-gray-200 text-gray-600 h-[32px]",children:[e.checkbox&&r("th",{children:r(x,{rows:e.rows})}),d.map((function(e,o){return r(n,{id:k.getTableColId(o),columnKey:e.key},e.key)}))]})}),o("tbody",{children:[!!f&&r("tr",{children:r("td",{colSpan:d.length,className:"sticky top-8 left-0 bg-gray-300 w-full shadow-lg rounded-b-2xl z-20 p-0 overflow-hidden",children:r(p,{})})}),0===h.length&&r("tr",{children:r("td",{colSpan:d.length,className:"py-5",children:r("p",{className:"text-center font-bold text-lg",children:"NO DATA"})})}),h.map((function(t,n){return r(b,{row:t,children:o("tr",{className:"relative border border-gray-200 after:absolute after:w-full after:h-full after:top-0 after:left-0 after:pointer-events-none after:hover:bg-gray-500/10 ".concat(e.onClickRow?"hover:cursor-pointer":""," ").concat(e.applyRowFormatting?e.applyRowFormatting(t):""),onClick:function(r){r.preventDefault(),e.onClickRow&&(e.onClickRow(t),u())},"data-testid":t.id,children:[e.checkbox&&r("td",{children:r(j,{})}),d.map((function(o,t){return r(i,{rowIndex:n,colIndex:t,columnKey:o.key,isExistOnClickRow:!!e.onClickRow,onUpdateRow:e.onUpdateRow},o.key)}))]})},t.id)}))]})]})}),o("div",{className:"mt-1",children:[r(c,{}),r("div",{className:"mt-2",children:r(a,{})})]})]})}export{K as default};
3
3
  //# sourceMappingURL=base.js.map
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as r,useContext as n,useMemo as t,useCallback as l}from"react";import{useColumnContext as o,useRowContext as i}from"../sheet/providers.js";import{useEditActionContext as u}from"../edit/provider.js";var d=r({columnKey:"",value:"",label:"",type:"string",updateCellValue:function(){}});function a(r){var n,a,c=r.children,p=r.columnKey,m=o(p),v=i(),f=v[p],b=u().endEditing,s="select"===m.type?null===(a=null===(n=m.options)||void 0===n?void 0:n.find((function(e){return e.value===f})))||void 0===a?void 0:a.label:f,y=t((function(){return m.editable?s:m.render?m.render(f,v):s}),[m.editable,s,f,v]),C=l((function(e){m.editable&&("number"===m.type?m.onCellBlur(p,Number(e),v,b):m.onCellBlur(p,e,v,b))}),[m,p,v]),h=!m.editable&&m.render?"component":m.type,j=t((function(){return{columnKey:p,value:f,label:s,component:y,type:h,updateCellValue:C}}),[p,f,s,y,m,C]);return e(d.Provider,{value:j,children:c})}function c(){return n(d)}export{a as CellProvider,c as useCellContext};
2
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sources":["../../../../../src/table/cell/provider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useMemo } from \"react\";\nimport { TColumnType } from \"../type\";\nimport { useColumnContext, useRowContext } from \"../sheet\";\nimport { useEditActionContext } from \"../edit/provider\";\n\nconst CellContext = createContext<{\n columnKey: string;\n value: any;\n label: any;\n type: TColumnType | \"component\";\n component?: React.ReactNode;\n updateCellValue: (value: string) => void;\n}>({\n columnKey: \"\",\n value: \"\",\n label: \"\",\n type: \"string\",\n updateCellValue: () => {},\n});\n\nexport function CellProvider({\n children,\n columnKey,\n}: {\n children: React.ReactNode;\n columnKey: string;\n}) {\n const col = useColumnContext(columnKey);\n const row = useRowContext();\n const value = row[columnKey];\n const { endEditing } = useEditActionContext();\n\n const label =\n col.type === \"select\"\n ? col.options?.find((op) => op.value === value)?.label\n : value;\n\n const component = useMemo(() => {\n if (col.editable) {\n return label;\n } else {\n return col.render ? col.render(value as never, row) : label;\n }\n }, [col.editable, label, value, row]);\n\n const updateCellValue = useCallback(\n (value: string) => {\n if (col.editable) {\n if (col.type === \"number\") {\n col.onCellBlur(columnKey, Number(value), row, endEditing);\n } else {\n col.onCellBlur(columnKey, value, row, endEditing);\n }\n }\n },\n [col, columnKey, row]\n );\n\n const type: TColumnType | \"component\" =\n !col.editable && col.render ? \"component\" : col.type;\n\n const cellStatus = useMemo(\n () => ({\n columnKey,\n value,\n label,\n component,\n type,\n updateCellValue,\n }),\n [columnKey, value, label, component, col, updateCellValue]\n );\n\n return (\n <CellContext.Provider value={cellStatus}>{children}</CellContext.Provider>\n );\n}\n\nexport function useCellContext() {\n return useContext(CellContext);\n}\n"],"names":["CellContext","createContext","columnKey","value","label","type","updateCellValue","CellProvider","_a","children","col","useColumnContext","row","useRowContext","endEditing","useEditActionContext","_b","options","find","op","_c","component","useMemo","editable","render","useCallback","onCellBlur","Number","cellStatus","_jsx","Provider","useCellContext","useContext"],"mappings":"mQAKA,IAAMA,EAAcC,EAOjB,CACDC,UAAW,GACXC,MAAO,GACPC,MAAO,GACPC,KAAM,SACNC,gBAAiB,WAAQ,IAGrB,SAAUC,EAAaC,WAC3BC,EAAQD,EAAAC,SACRP,EAASM,EAAAN,UAKHQ,EAAMC,EAAiBT,GACvBU,EAAMC,IACNV,EAAQS,EAAIV,GACVY,EAAeC,eAEjBX,EACS,WAAbM,EAAIL,KAC6C,UAAlC,QAAXW,EAAAN,EAAIO,eAAO,IAAAD,OAAA,EAAAA,EAAEE,MAAK,SAACC,GAAO,OAAAA,EAAGhB,QAAUA,CAAb,WAAmB,IAAAiB,OAAA,EAAAA,EAAEhB,MAC/CD,EAEAkB,EAAYC,GAAQ,WACxB,OAAIZ,EAAIa,SACCnB,EAEAM,EAAIc,OAASd,EAAIc,OAAOrB,EAAgBS,GAAOR,CAE1D,GAAG,CAACM,EAAIa,SAAUnB,EAAOD,EAAOS,IAE1BN,EAAkBmB,GACtB,SAACtB,GACKO,EAAIa,WACW,WAAbb,EAAIL,KACNK,EAAIgB,WAAWxB,EAAWyB,OAAOxB,GAAQS,EAAKE,GAE9CJ,EAAIgB,WAAWxB,EAAWC,EAAOS,EAAKE,GAG3C,GACD,CAACJ,EAAKR,EAAWU,IAGbP,GACHK,EAAIa,UAAYb,EAAIc,OAAS,YAAcd,EAAIL,KAE5CuB,EAAaN,GACjB,WAAM,MAAC,CACLpB,UAASA,EACTC,MAAKA,EACLC,MAAKA,EACLiB,UAASA,EACThB,KAAIA,EACJC,gBAAeA,EACf,GACF,CAACJ,EAAWC,EAAOC,EAAOiB,EAAWX,EAAKJ,IAG5C,OACEuB,EAAC7B,EAAY8B,SAAQ,CAAC3B,MAAOyB,EAAUnB,SAAGA,GAE9C,UAEgBsB,IACd,OAAOC,EAAWhC,EACpB"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{CancelIcon as n}from"../../cancel-icon.js";function o(o){return e("div",{className:"flex justify-between gap-1 w-full items-center",onClick:function(e){e.preventDefault(),e.stopPropagation()},children:[t("input",{id:"table-cell-form",className:"w-full py-1 px-2 bg-white text-gray-900",type:"text",value:o.value,onChange:o.onChange,onBlur:o.onBlur,onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(o.reset(),o.endEditing())}}),t("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){o.reset(),o.endEditing()}),300)},children:t(n,{size:16})})]})}export{o as CellInput};
2
+ //# sourceMappingURL=base-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-input.js","sources":["../../../../../../src/table/cell/ui/base-input.tsx"],"sourcesContent":["import { CancelIcon } from \"../../cancel-icon\";\n\nexport function CellInput(props: {\n value: string | number;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;\n reset: () => void;\n endEditing: () => void;\n}) {\n return (\n <div\n className={`flex justify-between gap-1 w-full items-center`}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n <input\n id=\"table-cell-form\"\n className=\"w-full py-1 px-2 bg-white text-gray-900\"\n type=\"text\"\n value={props.value}\n onChange={props.onChange}\n onBlur={props.onBlur}\n onKeyUp={(e: React.KeyboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n if (e.key === \"Enter\") {\n (e.target as HTMLInputElement).blur();\n } else if (e.key === \"Escape\") {\n props.reset();\n props.endEditing();\n }\n }}\n />\n <button\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n props.reset();\n props.endEditing();\n }, 300);\n }}\n >\n <CancelIcon size={16} />\n </button>\n </div>\n );\n}\n"],"names":["CellInput","props","_jsxs","className","onClick","e","preventDefault","stopPropagation","children","_jsx","id","type","value","onChange","onBlur","onKeyUp","key","target","blur","reset","endEditing","onMouseDown","setTimeout","CancelIcon","size"],"mappings":"oGAEM,SAAUA,EAAUC,GAOxB,OACEC,SACEC,UAAW,iDACXC,QAAS,SAACC,GACRA,EAAEC,iBACFD,EAAEE,iBACJ,EAEAC,SAAA,CAAAC,EAAA,QAAA,CACEC,GAAG,kBACHP,UAAU,0CACVQ,KAAK,OACLC,MAAOX,EAAMW,MACbC,SAAUZ,EAAMY,SAChBC,OAAQb,EAAMa,OACdC,QAAS,SAACV,GACRA,EAAEC,iBACY,UAAVD,EAAEW,IACHX,EAAEY,OAA4BC,OACZ,WAAVb,EAAEW,MACXf,EAAMkB,QACNlB,EAAMmB,aAEV,IAEFX,EAAA,SAAA,CACEY,YAAa,SAAChB,GACZA,EAAEC,iBACFD,EAAEE,kBACFe,YAAW,WACTrB,EAAMkB,QACNlB,EAAMmB,YACP,GAAE,MACJZ,SAEDC,EAACc,EAAW,CAAAC,KAAM,SAI1B"}
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import{useCell as i}from"../../hook.js";import{EditButton as n}from"./edit-button.js";import{StringCellInput as l}from"./string-input.js";import{NumberCellInput as r}from"./number-input.js";import{SelectCellInput as c}from"./select-input.js";import{memo as a}from"react";import{IdGenerator as p}from"../../libs/id-generator.js";import{useCellContext as s,CellProvider as d}from"../provider.js";import{useColumnContext as u}from"../../sheet/providers.js";var m=a((function(o){return e(t,{children:"component"===o.type?o.component:e("div",{onDoubleClick:o.onDoubleClick,children:e("p",{className:"cell-data text-left whitespace-nowrap",children:o.component})})})})),f=a((function(t){var i=s();return e("td",{id:t.id,onPaste:function(e){e.preventDefault(),t.isExistOnUpdateRow?t.pasteData(e.clipboardData.getData("text")):alert("ペースト機能が有効化されていません。")},children:o("div",{className:"relative",onClick:t.isExistOnClickRow?void 0:function(e){e.preventDefault(),t.focusAtCell()},onDoubleClick:t.isExistOnClickRow?void 0:t.onDoubleClickCellToEdit,children:[e("div",{id:"".concat(t.id,"-display"),children:o("div",{className:"flex items-center gap-3 w-fit p-2 cursor-default",onClick:function(e){e.preventDefault(),e.stopPropagation(),t.focusAtCell()},children:[e(m,{type:i.type,component:i.component,onDoubleClick:t.onDoubleClickCellToEdit}),t.editable&&e(n,{})]})}),t.editable&&o("div",{id:"".concat(t.id,"-editor"),className:"absolute top-0 left-0 w-full h-full grid place-items-center z-10 pr-2",onClick:t.preventPropagation,style:{opacity:0,pointerEvents:"none"},children:["string"===i.type&&e(l,{}),"number"===i.type&&e(r,{}),"select"===i.type&&e(c,{})]})]})})}));function C(t){var o,n=i(t.rowIndex,t.colIndex,t.onUpdateRow),l=n.focusAtCell,r=n.onDoubleClickCellToEdit,c=n.preventPropagation,a=n.pasteData,s=u(t.columnKey);return e(d,{columnKey:t.columnKey,children:e(f,{id:p.getTableCellId(t.rowIndex,t.colIndex),editable:null!==(o=s.editable)&&void 0!==o&&o,focusAtCell:l,onDoubleClickCellToEdit:r,preventPropagation:c,pasteData:a,isExistOnClickRow:t.isExistOnClickRow,isExistOnUpdateRow:!!t.onUpdateRow})})}export{C as TableCell};
3
+ //# sourceMappingURL=cell.js.map
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{jsx as r}from"react/jsx-runtime";import{memo as t}from"react";import{useEditActionContext as i}from"../../edit/provider.js";import{EditIcon as e}from"../../edit-icon.js";var o=t((function(){var t=i().startEditing;return r("button",{className:"w-fit h-fit p-1 rounded-full text-gray-500 hover:bg-gray-200",onClick:function(r){r.preventDefault(),t()},children:r(e,{size:12})})}));export{o as EditButton};
3
+ //# sourceMappingURL=edit-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-button.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{jsx as e}from"react/jsx-runtime";import{useState as t}from"react";import{useColumnContext as r,useColumnValidateContext as o}from"../../sheet/providers.js";import{CellInput as n}from"./base-input.js";import{useCellContext as u}from"../provider.js";import{useEditActionContext as a}from"../../edit/provider.js";function i(){var i=u(),l=r(i.columnKey),m=o(i.columnKey),v=a().endEditing,f=t(i.value.toString()),p=f[0],g=f[1];if(!l.editable||"number"!==l.type)throw new Error("Invalid condition");return e(n,{value:p,onChange:function(e){e.preventDefault(),""!==e.target.value?"-"!==e.target.value&&"0-"!==e.target.value?e.target.value.match(/^-?[0-9]+\.$/)?g(e.target.value):isNaN(Number(e.target.value))||g(Number(e.target.value).toString()):g("-0"):g("0")},onBlur:function(e){e.preventDefault(),Number(p)!==i.value?m(p)?i.updateCellValue(p):setTimeout((function(){e.target.focus()}),100):v()},reset:function(){return g(i.value.toString())},endEditing:v})}export{i as NumberCellInput};
3
+ //# sourceMappingURL=number-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as n}from"react";import{useEditActionContext as o}from"../../edit/provider.js";import{useColumnContext as r}from"../../sheet/providers.js";import{CancelIcon as i}from"../../cancel-icon.js";import{useCellContext as l}from"../provider.js";function a(){var a=l(),u=r(a.columnKey),p=o().endEditing,c=n(a.value),f=c[0],v=c[1];if(!u.editable||"select"!==u.type)throw new Error("Invalid condition");return e("div",{className:"flex justify-between gap-1 w-full items-center",children:[e("select",{className:"w-full py-1 px-2 bg-white text-gray-900",value:f,onChange:function(e){e.preventDefault(),v(e.target.value)},onBlur:function(e){e.preventDefault(),f!==a.value?a.updateCellValue(f):p()},onKeyDown:function(e){"Enter"===e.key&&e.preventDefault()},onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(v(a.value),p())},children:[u.allowEmpty&&t("option",{value:"",children:""==a.value?"-- 未選択 --":"-- 選択解除 --"},"TEPPEN/ReactUI Empty Option"),u.options.map((function(e){return t("option",{value:e.value,children:e.label},e.value)}))]}),t("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){v(a.value),p()}),300)},children:t(i,{size:16})})]})}export{a as SelectCellInput};
3
+ //# sourceMappingURL=select-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{jsx as e}from"react/jsx-runtime";import{memo as t,useState as r}from"react";import{useEditActionContext as o}from"../../edit/provider.js";import{useColumnContext as n,useColumnValidateContext as i}from"../../sheet/providers.js";import{CellInput as u}from"./base-input.js";import{useCellContext as a}from"../provider.js";var m=t((function(){var t=a(),m=n(t.columnKey),f=i(t.columnKey),l=o().endEditing,p=r(t.value),v=p[0],d=p[1];if(!m.editable||"string"!==m.type)throw new Error("Invalid condition");return e(u,{value:v,onChange:function(e){e.preventDefault(),d(e.target.value)},onBlur:function(e){e.preventDefault(),v!==t.value?f(v)?t.updateCellValue(v):setTimeout((function(){e.target.focus()}),100):l()},reset:function(){return d(t.value.toString())},endEditing:l})}));export{m as StringCellInput};
3
+ //# sourceMappingURL=string-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-input.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,2 +1,2 @@
1
- import{__assign as o}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as e,useCallback as u}from"react";var r=function(e,u){switch(u.type){case"focus":return e.isFocus&&e.rowNumber===u.payload.rowNumber&&e.colNumber===u.payload.colNumber?e:o(o({},e),{isFocus:!0,isEditing:!1,rowNumber:u.payload.rowNumber,colNumber:u.payload.colNumber});case"edit":return!e.isFocus||e.isEditing?e:o(o({},e),{isEditing:!0});case"focusAndEdit":return e.isFocus&&e.isEditing&&e.rowNumber===u.payload.rowNumber&&e.colNumber===u.payload.colNumber?e:o(o({},e),{isFocus:!0,isEditing:!0,rowNumber:u.payload.rowNumber,colNumber:u.payload.colNumber});case"move":return!e.isFocus||e.rowNumber===u.payload.rowNumber&&e.colNumber===u.payload.colNumber?e:o(o({},e),{isEditing:!1,rowNumber:u.payload.rowNumber,colNumber:u.payload.colNumber});case"moveLeft":return e.isFocus?e.colNumber-1<0?e:o(o({},e),{isEditing:!1,colNumber:e.colNumber-1}):e;case"moveRight":return e.isFocus?e.colNumber+1>e.maxColNumber?e:o(o({},e),{isEditing:!1,colNumber:e.colNumber+1}):e;case"moveUp":return e.isFocus?e.rowNumber-1<0?e:o(o({},e),{isEditing:!1,rowNumber:e.rowNumber-1}):e;case"moveDown":return e.isFocus?e.rowNumber+1>e.maxRowNumber?e:o(o({},e),{isEditing:!1,rowNumber:e.rowNumber+1}):e;case"unfocus":return e.isFocus?{maxColNumber:e.maxColNumber,maxRowNumber:e.maxRowNumber,isFocus:!1}:e;case"finishEditing":return e.isFocus&&e.isEditing?o(o({},e),{isEditing:!1}):e;case"setMaxRowNumber":return e.maxRowNumber===u.payload.maxRowNumber?e:o(o({},e),{maxRowNumber:u.payload.maxRowNumber});case"setMaxColNumber":return e.maxColNumber===u.payload.maxColNumber?e:o(o({},e),{maxColNumber:u.payload.maxColNumber})}};function m(o,m){var i=e(r,{maxRowNumber:o,maxColNumber:m,isFocus:!1}),s=i[0],t=i[1],a=u((function(o,e){return s.isFocus&&s.rowNumber===o&&s.colNumber===e}),[s]),c=u((function(o,e){t({type:"focus",payload:{rowNumber:o,colNumber:e}})}),[t]),n=u((function(){t({type:"edit"})}),[t]),b=u((function(o,e){t({type:"focusAndEdit",payload:{rowNumber:o,colNumber:e}})}),[t]),N=u((function(o,e){t({type:"move",payload:{rowNumber:o,colNumber:e}})}),[t]),l=u((function(){t({type:"moveLeft"})}),[t]),d=u((function(){t({type:"moveRight"})}),[t]),p=u((function(){t({type:"moveUp"})}),[t]),w=u((function(){t({type:"moveDown"})}),[t]),y=u((function(){t({type:"unfocus"})}),[t]),f=u((function(){t({type:"finishEditing"})}),[t]),x=u((function(o){t({type:"setMaxRowNumber",payload:{maxRowNumber:o}})}),[t]),g=u((function(o){t({type:"setMaxColNumber",payload:{maxColNumber:o}})}),[t]);return{isFocus:s.isFocus,isEditing:s.isFocus&&s.isEditing,checkFocus:a,focus:c,edit:n,focusAndEdit:b,move:N,moveLeft:l,moveRight:d,moveUp:p,moveDown:w,unfocus:y,finishEditing:f,setMaxRowNumber:x,setMaxColNumber:g}}export{m as useFocusReducer};
1
+ import{useReducer as i,useCallback as t}from"react";var n=function(i,t){switch(t.type){case"startEditing":return i.isEditing?i:{isEditing:!0};case"endEditing":return i.isEditing?{isEditing:!1}:i}};function d(){var d=i(n,{isEditing:!1}),r=d[0],e=d[1],g=t((function(){e({type:"startEditing"})}),[]),s=t((function(){e({type:"endEditing"})}),[]);return{isEditing:r.isEditing,startEditing:g,endEditing:s}}export{d as useEditReducer};
2
2
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../../../../../src/table/edit/hooks.ts"],"sourcesContent":["import { useCallback, useReducer } from \"react\";\nimport { TFocusReducer, TReturnFocusReducer } from \"./types\";\n\nconst reducer: TFocusReducer = (state, action) => {\n switch (action.type) {\n case \"focus\":\n if (\n state.isFocus &&\n state.rowNumber === action.payload.rowNumber &&\n state.colNumber === action.payload.colNumber\n ) {\n return state;\n }\n\n return {\n ...state,\n isFocus: true,\n isEditing: false,\n rowNumber: action.payload.rowNumber,\n colNumber: action.payload.colNumber,\n };\n\n case \"edit\":\n if (!state.isFocus || state.isEditing) return state;\n\n return {\n ...state,\n isEditing: true,\n };\n\n case \"focusAndEdit\":\n if (\n state.isFocus &&\n state.isEditing &&\n state.rowNumber === action.payload.rowNumber &&\n state.colNumber === action.payload.colNumber\n ) {\n return state;\n }\n\n return {\n ...state,\n isFocus: true,\n isEditing: true,\n rowNumber: action.payload.rowNumber,\n colNumber: action.payload.colNumber,\n };\n\n case \"move\":\n if (\n !state.isFocus ||\n (state.rowNumber === action.payload.rowNumber &&\n state.colNumber === action.payload.colNumber)\n ) {\n return state;\n }\n\n return {\n ...state,\n isEditing: false,\n rowNumber: action.payload.rowNumber,\n colNumber: action.payload.colNumber,\n };\n\n case \"moveLeft\": {\n if (!state.isFocus) return state;\n\n const newColNumber = state.colNumber - 1;\n\n if (newColNumber < 0) return state;\n\n return {\n ...state,\n isEditing: false,\n colNumber: state.colNumber - 1,\n };\n }\n\n case \"moveRight\": {\n if (!state.isFocus) return state;\n\n const newColNumber = state.colNumber + 1;\n\n if (newColNumber > state.maxColNumber) return state;\n\n return {\n ...state,\n isEditing: false,\n colNumber: state.colNumber + 1,\n };\n }\n\n case \"moveUp\": {\n if (!state.isFocus) return state;\n\n const newRowNumber = state.rowNumber - 1;\n\n if (newRowNumber < 0) return state;\n\n return {\n ...state,\n isEditing: false,\n rowNumber: state.rowNumber - 1,\n };\n }\n\n case \"moveDown\": {\n if (!state.isFocus) return state;\n\n const newRowNumber = state.rowNumber + 1;\n\n if (newRowNumber > state.maxRowNumber) return state;\n\n return {\n ...state,\n isEditing: false,\n rowNumber: state.rowNumber + 1,\n };\n }\n\n case \"unfocus\":\n if (!state.isFocus) return state;\n\n return {\n maxColNumber: state.maxColNumber,\n maxRowNumber: state.maxRowNumber,\n isFocus: false,\n };\n\n case \"finishEditing\":\n if (!state.isFocus || !state.isEditing) return state;\n\n return {\n ...state,\n isEditing: false,\n };\n\n case \"setMaxRowNumber\":\n if (state.maxRowNumber === action.payload.maxRowNumber) return state;\n\n return {\n ...state,\n maxRowNumber: action.payload.maxRowNumber,\n };\n\n case \"setMaxColNumber\":\n if (state.maxColNumber === action.payload.maxColNumber) return state;\n\n return {\n ...state,\n maxColNumber: action.payload.maxColNumber,\n };\n }\n};\n\nexport function useFocusReducer(\n maxRowNumber: number,\n maxColNumber: number\n): TReturnFocusReducer {\n const [state, dispatch] = useReducer(reducer, {\n maxRowNumber,\n maxColNumber,\n isFocus: false,\n });\n\n const checkFocus = useCallback(\n (rowNumber: number, colNumber: number) =>\n state.isFocus &&\n state.rowNumber === rowNumber &&\n state.colNumber === colNumber,\n [state]\n );\n\n const focus = useCallback(\n (rowNumber: number, colNumber: number) => {\n dispatch({ type: \"focus\", payload: { rowNumber, colNumber } });\n },\n [dispatch]\n );\n\n const edit = useCallback(() => {\n dispatch({ type: \"edit\" });\n }, [dispatch]);\n\n const focusAndEdit = useCallback(\n (rowNumber: number, colNumber: number) => {\n dispatch({ type: \"focusAndEdit\", payload: { rowNumber, colNumber } });\n },\n [dispatch]\n );\n\n const move = useCallback(\n (rowNumber: number, colNumber: number) => {\n dispatch({ type: \"move\", payload: { rowNumber, colNumber } });\n },\n [dispatch]\n );\n\n const moveLeft = useCallback(() => {\n dispatch({ type: \"moveLeft\" });\n }, [dispatch]);\n\n const moveRight = useCallback(() => {\n dispatch({ type: \"moveRight\" });\n }, [dispatch]);\n\n const moveUp = useCallback(() => {\n dispatch({ type: \"moveUp\" });\n }, [dispatch]);\n\n const moveDown = useCallback(() => {\n dispatch({ type: \"moveDown\" });\n }, [dispatch]);\n\n const unfocus = useCallback(() => {\n dispatch({ type: \"unfocus\" });\n }, [dispatch]);\n\n const finishEditing = useCallback(() => {\n dispatch({ type: \"finishEditing\" });\n }, [dispatch]);\n\n const setMaxRowNumber = useCallback(\n (maxRowNumber: number) => {\n dispatch({ type: \"setMaxRowNumber\", payload: { maxRowNumber } });\n },\n [dispatch]\n );\n\n const setMaxColNumber = useCallback(\n (maxColNumber: number) => {\n dispatch({ type: \"setMaxColNumber\", payload: { maxColNumber } });\n },\n [dispatch]\n );\n\n return {\n isFocus: state.isFocus,\n isEditing: state.isFocus && state.isEditing,\n checkFocus,\n focus,\n edit,\n focusAndEdit,\n move,\n moveLeft,\n moveRight,\n moveUp,\n moveDown,\n unfocus,\n finishEditing,\n setMaxRowNumber,\n setMaxColNumber,\n };\n}\n"],"names":["reducer","state","action","type","isFocus","rowNumber","payload","colNumber","__assign","isEditing","maxColNumber","maxRowNumber","useFocusReducer","_a","useReducer","dispatch","checkFocus","useCallback","focus","edit","focusAndEdit","move","moveLeft","moveRight","moveUp","moveDown","unfocus","finishEditing","setMaxRowNumber","setMaxColNumber"],"mappings":"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"}
1
+ {"version":3,"file":"hooks.js","sources":["../../../../../src/table/edit/hooks.ts"],"sourcesContent":["import { useCallback, useReducer } from \"react\";\nimport { TEditReducer, TReturnEditReducer } from \"./types\";\n\nconst reducer: TEditReducer = (state, action) => {\n switch (action.type) {\n case \"startEditing\":\n if (state.isEditing) return state;\n\n return {\n isEditing: true,\n };\n\n case \"endEditing\":\n if (!state.isEditing) return state;\n\n return {\n isEditing: false,\n };\n }\n};\n\nexport function useEditReducer(): TReturnEditReducer {\n const [state, dispatch] = useReducer(reducer, {\n isEditing: false,\n });\n\n const startEditing = useCallback(() => {\n dispatch({ type: \"startEditing\" });\n }, []);\n\n const endEditing = useCallback(() => {\n dispatch({ type: \"endEditing\" });\n }, []);\n\n return {\n isEditing: state.isEditing,\n startEditing,\n endEditing,\n };\n}\n"],"names":["reducer","state","action","type","isEditing","useEditReducer","_a","useReducer","dispatch","startEditing","useCallback","endEditing"],"mappings":"oDAGA,IAAMA,EAAwB,SAACC,EAAOC,GACpC,OAAQA,EAAOC,MACb,IAAK,eACH,OAAIF,EAAMG,UAAkBH,EAErB,CACLG,WAAW,GAGf,IAAK,aACH,OAAKH,EAAMG,UAEJ,CACLA,WAAW,GAHgBH,EAMnC,WAEgBI,IACR,IAAAC,EAAoBC,EAAWP,EAAS,CAC5CI,WAAW,IADNH,EAAKK,EAAA,GAAEE,OAIRC,EAAeC,GAAY,WAC/BF,EAAS,CAAEL,KAAM,gBAClB,GAAE,IAEGQ,EAAaD,GAAY,WAC7BF,EAAS,CAAEL,KAAM,cAClB,GAAE,IAEH,MAAO,CACLC,UAAWH,EAAMG,UACjBK,aAAYA,EACZE,WAAUA,EAEd"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{jsx as n}from"react/jsx-runtime";import{createContext as o,useContext as t}from"react";import{useFocusReducer as r}from"./hooks.js";import{usePageContext as e}from"../pagenation/providers.js";var i=o({isEditing:!1,isFocus:!1,checkFocus:function(){throw new Error("Function not implemented.")},focus:function(){throw new Error("Function not implemented.")},edit:function(){throw new Error("Function not implemented.")},move:function(){throw new Error("Function not implemented.")},moveLeft:function(){throw new Error("Function not implemented.")},moveRight:function(){throw new Error("Function not implemented.")},moveUp:function(){throw new Error("Function not implemented.")},moveDown:function(){throw new Error("Function not implemented.")},unfocus:function(){throw new Error("Function not implemented.")},setMaxRowNumber:function(){throw new Error("Function not implemented.")},setMaxColNumber:function(){throw new Error("Function not implemented.")},focusAndEdit:function(){throw new Error("Function not implemented.")},finishEditing:function(){throw new Error("Function not implemented.")}});function m(o){var t=e(),m=t.from,u=t.to,c=t.rowCount;return n(i.Provider,{value:r(u<c?u-m-1:c-m-1,o.columnCount-1),children:o.children})}function u(){return t(i)}export{m as FocusProvider,u as useFocusContext};
2
+ import{__assign as i}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as n}from"react/jsx-runtime";import{createContext as t,useMemo as r,useContext as e}from"react";import{useEditReducer as o}from"./hooks.js";var d=t({isEditing:!1}),u=t({startEditing:function(){},endEditing:function(){}});function s(i){var t=o(),e=r((function(){return{isEditing:t.isEditing}}),[t.isEditing]),s=r((function(){return{startEditing:t.startEditing,endEditing:t.endEditing}}),[]);return n(d.Provider,{value:e,children:n(u.Provider,{value:s,children:i.children})})}function c(){return i(i({},f()),g())}function f(){return e(d)}function g(){return e(u)}export{s as EditProvider,g as useEditActionContext,c as useEditContext,f as useEditStateContext};
3
3
  //# sourceMappingURL=provider.js.map
@@ -0,0 +1,2 @@
1
+ import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as o,useCallback as n,useEffect as t}from"react";import{IdGenerator as s}from"../libs/id-generator.js";var c=function(o,n){switch(n.type){case"focus":return o.isFocus?o:{isFocus:!0,rowIndex:n.payload.rowIndex,colIndex:n.payload.colIndex};case"unfocus":return o.isFocus?{isFocus:!1}:o;case"move":return o.isFocus?{isFocus:!0,rowIndex:n.payload.rowIndex,colIndex:n.payload.colIndex}:o;case"moveLeft":return o.isFocus?e(e({},o),{colIndex:o.colIndex-1}):o;case"moveRight":return o.isFocus?e(e({},o),{colIndex:o.colIndex+1}):o;case"moveUp":return o.isFocus?e(e({},o),{rowIndex:o.rowIndex-1}):o;case"moveDown":return o.isFocus?e(e({},o),{rowIndex:o.rowIndex+1}):o}};function u(){var e=o(c,{isFocus:!1}),u=e[0],l=e[1],r=n((function(e,o){l({type:"focus",payload:{rowIndex:e,colIndex:o}})}),[]),i=n((function(){l({type:"unfocus"})}),[]),d=n((function(e,o){l({type:"move",payload:{rowIndex:e,colIndex:o}})}),[]),a=n((function(){l({type:"moveLeft"})}),[]),m=n((function(){l({type:"moveRight"})}),[]),f=n((function(){l({type:"moveUp"})}),[]),I=n((function(){l({type:"moveDown"})}),[]);return t((function(){var e=function(e){var o=document.getElementById("table-frame"),n=e.target;n instanceof Node&&(null==o?void 0:o.contains(n))||i()};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]),t((function(){if(u.isFocus){var e=document.getElementById(s.getTableCellId(u.rowIndex,u.colIndex));null==e||e.style.setProperty("outline-style","solid"),null==e||e.style.setProperty("outline-width","1px"),null==e||e.style.setProperty("outline-offset","-1px"),null==e||e.style.setProperty("outline-color","#9ca3af"),null==e||e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),null==e||e.focus()}return function(){if(u.isFocus){var e=document.getElementById(s.getTableCellId(u.rowIndex,u.colIndex));null==e||e.style.setProperty("outline-style","none")}}}),[u]),u.isFocus?{isFocus:!0,rowIndex:u.rowIndex,colIndex:u.colIndex,focus:r,unfocus:i,move:d,moveLeft:a,moveRight:m,moveUp:f,moveDown:I}:{isFocus:!1,focus:r,unfocus:i,move:d,moveLeft:a,moveRight:m,moveUp:f,moveDown:I}}export{u as useFocusReducer};
2
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sources":["../../../../../src/table/focus/hooks.ts"],"sourcesContent":["import { useCallback, useEffect, useReducer } from \"react\";\nimport { TFocusReducer, TReturnFocusReducer } from \"./types\";\nimport { IdGenerator } from \"../libs\";\n\nconst reducer: TFocusReducer = (state, action) => {\n switch (action.type) {\n case \"focus\":\n if (state.isFocus) {\n return state;\n }\n\n return {\n isFocus: true,\n rowIndex: action.payload.rowIndex,\n colIndex: action.payload.colIndex,\n };\n case \"unfocus\":\n if (!state.isFocus) {\n return state;\n }\n\n return {\n isFocus: false,\n };\n case \"move\":\n if (!state.isFocus) {\n return state;\n }\n\n return {\n isFocus: true,\n rowIndex: action.payload.rowIndex,\n colIndex: action.payload.colIndex,\n };\n case \"moveLeft\":\n if (!state.isFocus) {\n return state;\n }\n\n return {\n ...state,\n colIndex: state.colIndex - 1,\n };\n case \"moveRight\":\n if (!state.isFocus) {\n return state;\n }\n\n return {\n ...state,\n colIndex: state.colIndex + 1,\n };\n case \"moveUp\":\n if (!state.isFocus) {\n return state;\n }\n\n return {\n ...state,\n rowIndex: state.rowIndex - 1,\n };\n case \"moveDown\":\n if (!state.isFocus) {\n return state;\n }\n\n return {\n ...state,\n rowIndex: state.rowIndex + 1,\n };\n }\n};\n\nexport function useFocusReducer(): TReturnFocusReducer {\n const [state, dispatch] = useReducer(reducer, {\n isFocus: false,\n });\n\n const focus = useCallback((rowIndex: number, colIndex: number) => {\n dispatch({ type: \"focus\", payload: { rowIndex, colIndex } });\n }, []);\n\n const unfocus = useCallback(() => {\n dispatch({ type: \"unfocus\" });\n }, []);\n\n const move = useCallback((rowIndex: number, colIndex: number) => {\n dispatch({ type: \"move\", payload: { rowIndex, colIndex } });\n }, []);\n\n const moveLeft = useCallback(() => {\n dispatch({ type: \"moveLeft\" });\n }, []);\n\n const moveRight = useCallback(() => {\n dispatch({ type: \"moveRight\" });\n }, []);\n\n const moveUp = useCallback(() => {\n dispatch({ type: \"moveUp\" });\n }, []);\n\n const moveDown = useCallback(() => {\n dispatch({ type: \"moveDown\" });\n }, []);\n\n useEffect(() => {\n const onClickOutOfTable = (e: MouseEvent) => {\n const element = document.getElementById(\"table-frame\");\n const ele = e.target;\n if (ele instanceof Node && element?.contains(ele)) return;\n unfocus();\n };\n\n document.addEventListener(\"click\", onClickOutOfTable);\n\n return () => {\n document.removeEventListener(\"click\", onClickOutOfTable);\n };\n }, []);\n\n useEffect(() => {\n if (state.isFocus) {\n const element = document.getElementById(\n IdGenerator.getTableCellId(state.rowIndex, state.colIndex)\n );\n element?.style.setProperty(\"outline-style\", \"solid\");\n element?.style.setProperty(\"outline-width\", \"1px\");\n element?.style.setProperty(\"outline-offset\", \"-1px\");\n element?.style.setProperty(\"outline-color\", \"#9ca3af\");\n\n element?.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n inline: \"nearest\",\n });\n element?.focus();\n }\n\n return () => {\n if (state.isFocus) {\n const element = document.getElementById(\n IdGenerator.getTableCellId(state.rowIndex, state.colIndex)\n );\n element?.style.setProperty(\"outline-style\", \"none\");\n }\n };\n }, [state]);\n\n if (state.isFocus) {\n return {\n isFocus: true,\n rowIndex: state.rowIndex,\n colIndex: state.colIndex,\n focus,\n unfocus,\n move,\n moveLeft,\n moveRight,\n moveUp,\n moveDown,\n };\n } else {\n return {\n isFocus: false,\n focus,\n unfocus,\n move,\n moveLeft,\n moveRight,\n moveUp,\n moveDown,\n };\n }\n}\n"],"names":["reducer","state","action","type","isFocus","rowIndex","payload","colIndex","__assign","useFocusReducer","_a","useReducer","dispatch","focus","useCallback","unfocus","move","moveLeft","moveRight","moveUp","moveDown","useEffect","onClickOutOfTable","e","element","document","getElementById","ele","target","Node","contains","addEventListener","removeEventListener","IdGenerator","getTableCellId","style","setProperty","scrollIntoView","behavior","block","inline"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import{__assign as o}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as n}from"react/jsx-runtime";import{createContext as e,useMemo as u,useContext as r}from"react";import{useFocusReducer as t}from"./hooks.js";var i=e({isFocus:!1}),c=e({focus:function(){},unfocus:function(){},move:function(){},moveLeft:function(){},moveRight:function(){},moveUp:function(){},moveDown:function(){}});function f(o){var e=t(),r=e.isFocus?{isFocus:!0,rowIndex:e.rowIndex,colIndex:e.colIndex}:{isFocus:!1},f=u((function(){return{focus:e.focus,unfocus:e.unfocus,move:e.move,moveLeft:e.moveLeft,moveRight:e.moveRight,moveUp:e.moveUp,moveDown:e.moveDown}}),[]);return n(i.Provider,{value:r,children:n(c.Provider,{value:f,children:o.children})})}function m(){return r(i)}function s(){return r(c)}function v(){return o(o({},m()),s())}export{f as FocusProvider,s as useFocusActionContext,v as useFocusContext,m as useFocusStateContext};
2
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sources":["../../../../../src/table/focus/provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport { TFocusState, TReturnFocusReducer } from \"./types\";\nimport { useFocusReducer } from \"./hooks\";\n\nconst FocusStateContext = createContext<TFocusState>({\n isFocus: false,\n});\n\nconst FocusActionContext = createContext<\n Omit<TReturnFocusReducer, \"isFocus\" | \"rowIndex\" | \"colIndex\">\n>({\n focus: () => {},\n unfocus: () => {},\n move: () => {},\n moveLeft: () => {},\n moveRight: () => {},\n moveUp: () => {},\n moveDown: () => {},\n});\n\nexport function FocusProvider(props: { children: React.ReactNode }) {\n const focus = useFocusReducer();\n\n const state: TFocusState = focus.isFocus\n ? {\n isFocus: true,\n rowIndex: focus.rowIndex,\n colIndex: focus.colIndex,\n }\n : {\n isFocus: false,\n };\n\n const action: Omit<TReturnFocusReducer, \"isFocus\" | \"rowIndex\" | \"colIndex\"> =\n useMemo(() => {\n return {\n focus: focus.focus,\n unfocus: focus.unfocus,\n move: focus.move,\n moveLeft: focus.moveLeft,\n moveRight: focus.moveRight,\n moveUp: focus.moveUp,\n moveDown: focus.moveDown,\n };\n }, []);\n\n return (\n <FocusStateContext.Provider value={state}>\n <FocusActionContext.Provider value={action}>\n {props.children}\n </FocusActionContext.Provider>\n </FocusStateContext.Provider>\n );\n}\n\nexport function useFocusStateContext() {\n return useContext(FocusStateContext);\n}\n\nexport function useFocusActionContext() {\n return useContext(FocusActionContext);\n}\n\nexport function useFocusContext() {\n return { ...useFocusStateContext(), ...useFocusActionContext() };\n}\n"],"names":["FocusStateContext","createContext","isFocus","FocusActionContext","focus","unfocus","move","moveLeft","moveRight","moveUp","moveDown","FocusProvider","props","useFocusReducer","state","rowIndex","colIndex","action","useMemo","_jsx","Provider","value","children","useFocusStateContext","useContext","useFocusActionContext","useFocusContext","__assign"],"mappings":"4NAIA,IAAMA,EAAoBC,EAA2B,CACnDC,SAAS,IAGLC,EAAqBF,EAEzB,CACAG,MAAO,WAAQ,EACfC,QAAS,WAAQ,EACjBC,KAAM,WAAQ,EACdC,SAAU,WAAQ,EAClBC,UAAW,WAAQ,EACnBC,OAAQ,WAAQ,EAChBC,SAAU,WAAQ,IAGd,SAAUC,EAAcC,GAC5B,IAAMR,EAAQS,IAERC,EAAqBV,EAAMF,QAC7B,CACEA,SAAS,EACTa,SAAUX,EAAMW,SAChBC,SAAUZ,EAAMY,UAElB,CACEd,SAAS,GAGTe,EACJC,GAAQ,WACN,MAAO,CACLd,MAAOA,EAAMA,MACbC,QAASD,EAAMC,QACfC,KAAMF,EAAME,KACZC,SAAUH,EAAMG,SAChBC,UAAWJ,EAAMI,UACjBC,OAAQL,EAAMK,OACdC,SAAUN,EAAMM,SAEnB,GAAE,IAEL,OACES,EAACnB,EAAkBoB,UAASC,MAAOP,EAAKQ,SACtCH,EAAChB,EAAmBiB,SAAQ,CAACC,MAAOJ,EAAMK,SACvCV,EAAMU,YAIf,UAEgBC,IACd,OAAOC,EAAWxB,EACpB,UAEgByB,IACd,OAAOD,EAAWrB,EACpB,UAEgBuB,IACd,OAAAC,EAAAA,EAAA,CAAA,EAAYJ,KAA2BE,IACzC"}
@@ -1,2 +1,3 @@
1
- import{jsxs as e,jsx as i}from"react/jsx-runtime";import"../filter/provider.js";import{TableFilter as t}from"../filter/components.js";import{useColumnContext as r}from"../sheet/providers.js";import{SortButton as o}from"../sort/components.js";import"../sort/provider.js";import{useResizeColWidthHook as l}from"./resize-col-width-hook.js";function s(s){var n=r(s.columnKey),m=l({initialWidth:n.initialWidth,minWidth:n.minWidth}),a=m.colWidth,c=m.onMouseDownResizeWidth;return e("th",{className:"relative",style:{minWidth:a},children:[e("div",{className:"flex justify-between items-center bg-gray-200 text-gray-600 h-[32px] min-w-fit",children:[i("div",{className:"px-2",children:n.label&&i("p",{className:"text-left font-bold text-nowrap overflow-hidden text-ellipsis w-[70%] min-w-20",children:n.label})}),e("div",{className:"flex items-center gap-1 px-1",children:[!n.disableSort&&i(o,{columnKey:s.columnKey}),!n.disableFilter&&i(t,{columnKey:s.columnKey})]})]}),i("div",{className:"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize",onMouseDown:c,children:i("div",{className:"w-[1px] h-full bg-white"})})]})}export{s as TableHeaderElement};
1
+ "use client";
2
+ import{jsxs as e,jsx as i}from"react/jsx-runtime";import"../filter/provider.js";import{TableFilter as t}from"../filter/components.js";import{useColumnContext as r}from"../sheet/providers.js";import{SortButton as o}from"../sort/components.js";import"../sort/provider.js";import{useResizeColWidthHook as l}from"./resize-col-width-hook.js";function s(s){var n=r(s.columnKey),m=l({initialWidth:n.initialWidth,minWidth:n.minWidth}),d=m.colWidth,a=m.onMouseDownResizeWidth;return e("th",{id:s.id,className:"relative",style:{minWidth:d},children:[e("div",{className:"flex justify-between items-center bg-gray-200 text-gray-600 h-[32px] min-w-fit",children:[i("div",{className:"px-2",children:n.label&&i("p",{className:"text-left font-bold text-nowrap overflow-hidden text-ellipsis w-[70%] min-w-20",children:n.label})}),e("div",{className:"flex items-center gap-1 px-1",children:[!n.disableSort&&i(o,{columnKey:s.columnKey}),!n.disableFilter&&i(t,{columnKey:s.columnKey})]})]}),i("div",{className:"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize",onMouseDown:a,children:i("div",{className:"w-[1px] h-full bg-white"})})]})}export{s as TableHeaderElement};
2
3
  //# sourceMappingURL=header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.js","sources":["../../../../../src/table/header/header.tsx"],"sourcesContent":["import { TableFilter } from \"../filter\";\nimport { useColumnContext } from \"../sheet\";\nimport { SortButton } from \"../sort\";\nimport { useResizeColWidthHook } from \"./resize-col-width-hook\";\n\ntype TPropsTableHeader = {\n columnKey: string;\n};\n\nexport function TableHeaderElement(props: TPropsTableHeader) {\n const col = useColumnContext(props.columnKey);\n const { colWidth, onMouseDownResizeWidth } = useResizeColWidthHook({\n initialWidth: col.initialWidth,\n minWidth: col.minWidth,\n });\n\n return (\n <th className=\"relative\" style={{ minWidth: colWidth }}>\n <div\n className={`flex justify-between items-center bg-gray-200 text-gray-600 h-[32px] min-w-fit`}\n >\n <div className=\"px-2\">\n {col.label && (\n <p\n className={`text-left font-bold text-nowrap overflow-hidden text-ellipsis w-[70%] min-w-20`}\n >\n {col.label}\n </p>\n )}\n </div>\n\n <div className=\"flex items-center gap-1 px-1\">\n {!col.disableSort && <SortButton columnKey={props.columnKey} />}\n {!col.disableFilter && <TableFilter columnKey={props.columnKey} />}\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 </th>\n );\n}\n"],"names":["TableHeaderElement","props","col","useColumnContext","columnKey","_a","useResizeColWidthHook","initialWidth","minWidth","colWidth","onMouseDownResizeWidth","_jsxs","className","style","children","_jsx","label","disableSort","SortButton","disableFilter","TableFilter","onMouseDown"],"mappings":"iVASM,SAAUA,EAAmBC,GACjC,IAAMC,EAAMC,EAAiBF,EAAMG,WAC7BC,EAAuCC,EAAsB,CACjEC,aAAcL,EAAIK,aAClBC,SAAUN,EAAIM,WAFRC,EAAQJ,EAAAI,SAAEC,2BAKlB,OACEC,QAAIC,UAAU,WAAWC,MAAO,CAAEL,SAAUC,aAC1CE,EACE,MAAA,CAAAC,UAAW,iFAAgFE,SAAA,CAE3FC,SAAKH,UAAU,OACZE,SAAAZ,EAAIc,OACHD,EACE,IAAA,CAAAH,UAAW,iFAAgFE,SAE1FZ,EAAIc,UAKXL,EAAK,MAAA,CAAAC,UAAU,+BACZE,SAAA,EAACZ,EAAIe,aAAeF,EAACG,GAAWd,UAAWH,EAAMG,aAChDF,EAAIiB,eAAiBJ,EAACK,EAAY,CAAAhB,UAAWH,EAAMG,kBAGzDW,SACEH,UAAU,oFACVS,YAAaX,EAAsBI,SAEnCC,SAAKH,UAAW,gCAIxB"}
1
+ {"version":3,"file":"header.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,2 +1,2 @@
1
- import{useMemo as o,useEffect as r,useCallback as t,useRef as e,useState as n}from"react";import{usePageContext as i}from"./pagenation/providers.js";import"react/jsx-runtime";import{useFilterContext as c}from"./filter/provider.js";import"./filter/constants.js";import{useCellContext as u}from"./sheet/providers.js";import"./sort/icon.js";import{useSortContext as s}from"./sort/provider.js";import{useFocusContext as l}from"./edit/provider.js";import{useCheckboxStatusContext as d}from"./checkbox/provider.js";function f(t){var e=c().filter,n=s().sort,u=i(),l=u.setRowCount,f=u.pageFilter,a=d().dispatchCheckboxStatus,p=o((function(){return e(t.rows)}),[e,t.rows]);r((function(){l(p.length)}),[p.length]);var v=o((function(){return t.checkbox?t.rows.filter((function(o){var r;return null===(r=t.checkbox)||void 0===r?void 0:r.checked(o)})):[]}),[t.checkbox,t.rows]);r((function(){a({type:"SET",payload:{checkedRecords:v}})}),[v]);var x=o((function(){return n(p)}),[p,n]),m=o((function(){return f(x)}),[f,x]);return{cols:t.cols,rows:m}}function a(){var o=e(null),i=u(),c=i.rowIndex,s=i.colIndex,d=l(),f=d.isEditing,a=d.checkFocus,p=n(!1),v=p[0],x=p[1],m=a(c,s);r((function(){var r;m&&f&&(null===(r=o.current)||void 0===r||r.focus()),x(!1)}),[m,f,v]);var h=t((function(){x(!0)}),[]);return{ref:o,callbackAfterBlur:h}}function p(){var o=u(),e=l(),n=e.isEditing,i=e.checkFocus,c=e.focus,s=e.focusAndEdit,d=e.finishEditing,f=i(o.rowIndex,o.colIndex);r((function(){!o.editable&&f&&n&&d()}),[o.editable,f,n,d]);var a=t((function(r){r.preventDefault(),r.stopPropagation(),c(o.rowIndex,o.colIndex)}),[c,o.rowIndex,o.colIndex]),p=t((function(r){r.preventDefault(),o.editable&&s(o.rowIndex,o.colIndex)}),[o.editable,s,o.rowIndex,o.colIndex]),v=t((function(o){o.preventDefault(),o.stopPropagation()}),[]);return{cell:o,isFocus:f,isEditing:n,onClickCellToFocus:a,onDoubleClickCellToEdit:p,preventPropagation:v}}export{p as useCell,a as useCellFocus,f as useTable};
1
+ import{__assign as r}from"../../node_modules/tslib/tslib.es6.js";import{useMemo as t,useEffect as o,useCallback as e}from"react";import{usePageContext as n}from"./pagenation/providers.js";import"react/jsx-runtime";import{useFilterContext as i}from"./filter/provider.js";import"./filter/constants.js";import{useProcessedDataContext as c,useColumnsContext as l,useColumnValidatesContext as a}from"./sheet/providers.js";import"./sort/icon.js";import{useSortContext as s}from"./sort/provider.js";import{useFocusActionContext as f}from"./focus/provider.js";import{useCheckboxStatusContext as u}from"./checkbox/provider.js";import{useEditActionContext as p}from"./edit/provider.js";function v(r){var e=i().filter,c=s().sort,l=n(),a=l.setRowCount,f=l.pageFilter,p=u().dispatchCheckboxStatus,v=t((function(){return e(r.rows)}),[e,r.rows]);o((function(){a(v.length)}),[v.length]);var m=t((function(){return r.checkbox?r.rows.filter((function(t){var o;return null===(o=r.checkbox)||void 0===o?void 0:o.checked(t)})):[]}),[r.checkbox,r.rows]);o((function(){p({type:"SET",payload:{checkedRecords:m}})}),[m]);var d=t((function(){return c(v)}),[v,c]),h=t((function(){return f(d)}),[f,d]);return{cols:r.cols,rows:h}}function m(t,o,n){var i=f(),s=p(),u=c().rows,v=l(),m=a(),d=e((function(){i.move(t,o),i.focus(t,o)}),[i,t,o]),h=e((function(e){var i,c,l=0,a=e.trim().replace(/\r\n/g,"\n").split("\n").map((function(r){var t=r.split("\t");return l=Math.max(l,t.length),t}));if(0!==a.length&&0!==l){for(var s=0;s<l;s++){if(!(p=v[o+s]).editable)return void alert("編集できない列にデータを貼り付けることはできません。\n\n編集不可列: ".concat(null!==(i=p.label)&&void 0!==i?i:p.key))}if(a.length+t>u.length)alert("貼り付け先の行数が足りません。");else{for(s=0;s<a.length;s++)for(var f=0;f<a[s].length;f++){var p=v[o+f];if(!(0,m[p.key])(a[s][f]))return void alert("[".concat(null!==(c=p.label)&&void 0!==c?c:p.key,"]列に次の不正なデータが含まれています。\n").concat(a[s][f]))}var d=function(e){for(var i=!1,c=r({},u[t+e]),l=function(r){var t=v[o+r],n="number"===t.type?Number(a[e][r]):"select"===t.type?""===a[e][r]?"":t.options.find((function(t){return t.label===a[e][r]})).value:a[e][r];c[t.key]!==n&&(i=!0,c[t.key]=n)},s=0;s<a[e].length;s++)l(s);i&&n&&n(c,u[t+e])};for(s=0;s<a.length;s++)d(s)}}}),[t,o]);return{focusAtCell:d,onDoubleClickCellToEdit:e((function(r){r.preventDefault(),i.move(t,o),i.focus(t,o),s.startEditing()}),[i,s]),preventPropagation:e((function(r){r.preventDefault(),r.stopPropagation()}),[]),pasteData:h}}export{m as useCell,v as useTable};
2
2
  //# sourceMappingURL=hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook.js","sources":["../../../../src/table/hook.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { DataRecord, TPropsTable } from \"./type\";\nimport { usePageContext } from \"./pagenation/providers\";\nimport { useFilterContext } from \"./filter\";\nimport { useSortContext } from \"./sort\";\nimport { useFocusContext } from \"./edit/provider\";\nimport { useCellContext } from \"./sheet/providers\";\nimport { useCheckboxStatusContext } from \"./checkbox/provider\";\n\nexport function useTable<T extends DataRecord>(props: TPropsTable<T>) {\n const { filter } = useFilterContext();\n const { sort } = useSortContext();\n const { setRowCount, pageFilter } = usePageContext();\n const { dispatchCheckboxStatus } = useCheckboxStatusContext();\n\n const filteredRows = useMemo(() => filter(props.rows), [filter, props.rows]);\n\n useEffect(() => {\n setRowCount(filteredRows.length);\n }, [filteredRows.length]);\n\n const checkBoxes = useMemo(() => {\n if (!props.checkbox) {\n return [];\n }\n\n return props.rows.filter((row) => props.checkbox?.checked(row));\n }, [props.checkbox, props.rows]);\n\n useEffect(() => {\n dispatchCheckboxStatus({\n type: \"SET\",\n payload: { checkedRecords: checkBoxes },\n });\n }, [checkBoxes]);\n\n const sortedRows = useMemo(() => sort(filteredRows), [filteredRows, sort]);\n\n const pageRows = useMemo(\n () => pageFilter(sortedRows),\n [pageFilter, sortedRows]\n );\n\n return {\n cols: props.cols,\n rows: pageRows,\n };\n}\n\nexport function useCellFocus<T extends HTMLElement>() {\n const ref = useRef<T>(null);\n const { rowIndex, colIndex } = useCellContext();\n const { isEditing, checkFocus } = useFocusContext();\n const [occurredOnCellBlur, setOccurredOnCellBlur] = useState(false);\n\n const isFocus = checkFocus(rowIndex, colIndex);\n\n useEffect(() => {\n if (isFocus && isEditing) {\n ref.current?.focus();\n }\n setOccurredOnCellBlur(false);\n }, [isFocus, isEditing, occurredOnCellBlur]);\n\n const callbackAfterBlur = useCallback(() => {\n setOccurredOnCellBlur(true);\n }, []);\n\n return { ref, callbackAfterBlur };\n}\n\nexport function useCell() {\n const cell = useCellContext();\n const { isEditing, checkFocus, focus, focusAndEdit, finishEditing } =\n useFocusContext();\n\n const isFocus = checkFocus(cell.rowIndex, cell.colIndex);\n\n useEffect(() => {\n if (!cell.editable && isFocus && isEditing) {\n finishEditing();\n }\n }, [cell.editable, isFocus, isEditing, finishEditing]);\n\n const onClickCellToFocus: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n e.preventDefault();\n e.stopPropagation();\n focus(cell.rowIndex, cell.colIndex);\n },\n [focus, cell.rowIndex, cell.colIndex]\n );\n\n const onDoubleClickCellToEdit: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n e.preventDefault();\n if (cell.editable) {\n focusAndEdit(cell.rowIndex, cell.colIndex);\n }\n },\n [cell.editable, focusAndEdit, cell.rowIndex, cell.colIndex]\n );\n\n const preventPropagation: React.MouseEventHandler<HTMLDivElement> =\n useCallback((e) => {\n e.preventDefault();\n e.stopPropagation();\n }, []);\n\n return {\n cell,\n isFocus,\n isEditing,\n onClickCellToFocus,\n onDoubleClickCellToEdit,\n preventPropagation,\n };\n}\n"],"names":["useTable","props","filter","useFilterContext","sort","useSortContext","_a","usePageContext","setRowCount","pageFilter","dispatchCheckboxStatus","useCheckboxStatusContext","filteredRows","useMemo","rows","useEffect","length","checkBoxes","checkbox","row","checked","type","payload","checkedRecords","sortedRows","pageRows","cols","useCellFocus","ref","useRef","useCellContext","rowIndex","colIndex","_b","useFocusContext","isEditing","checkFocus","_c","useState","occurredOnCellBlur","setOccurredOnCellBlur","isFocus","current","focus","callbackAfterBlur","useCallback","useCell","cell","focusAndEdit","finishEditing","editable","onClickCellToFocus","e","preventDefault","stopPropagation","onDoubleClickCellToEdit","preventPropagation"],"mappings":"6fASM,SAAUA,EAA+BC,GACrC,IAAAC,EAAWC,WACXC,EAASC,SACXC,EAA8BC,IAA5BC,EAAWF,EAAAE,YAAEC,EAAUH,EAAAG,WACvBC,EAA2BC,2BAE7BC,EAAeC,GAAQ,WAAM,OAAAX,EAAOD,EAAMa,KAAK,GAAE,CAACZ,EAAQD,EAAMa,OAEtEC,GAAU,WACRP,EAAYI,EAAaI,OAC3B,GAAG,CAACJ,EAAaI,SAEjB,IAAMC,EAAaJ,GAAQ,WACzB,OAAKZ,EAAMiB,SAIJjB,EAAMa,KAAKZ,QAAO,SAACiB,GAAG,IAAAb,EAAK,eAAAA,EAAAL,EAAMiB,+BAAUE,QAAQD,EAAI,IAHrD,EAIV,GAAE,CAAClB,EAAMiB,SAAUjB,EAAMa,OAE1BC,GAAU,WACRL,EAAuB,CACrBW,KAAM,MACNC,QAAS,CAAEC,eAAgBN,IAE/B,GAAG,CAACA,IAEJ,IAAMO,EAAaX,GAAQ,WAAM,OAAAT,EAAKQ,KAAe,CAACA,EAAcR,IAE9DqB,EAAWZ,GACf,WAAM,OAAAJ,EAAWe,KACjB,CAACf,EAAYe,IAGf,MAAO,CACLE,KAAMzB,EAAMyB,KACZZ,KAAMW,EAEV,UAEgBE,IACd,IAAMC,EAAMC,EAAU,MAChBvB,EAAyBwB,IAAvBC,EAAQzB,EAAAyB,SAAEC,EAAQ1B,EAAA0B,SACpBC,EAA4BC,IAA1BC,EAASF,EAAAE,UAAEC,EAAUH,EAAAG,WACvBC,EAA8CC,GAAS,GAAtDC,EAAkBF,EAAA,GAAEG,EAAqBH,EAAA,GAE1CI,EAAUL,EAAWL,EAAUC,GAErCjB,GAAU,iBACJ0B,GAAWN,IACA,QAAb7B,EAAAsB,EAAIc,eAAS,IAAApC,GAAAA,EAAAqC,SAEfH,GAAsB,EACvB,GAAE,CAACC,EAASN,EAAWI,IAExB,IAAMK,EAAoBC,GAAY,WACpCL,GAAsB,EACvB,GAAE,IAEH,MAAO,CAAEZ,IAAGA,EAAEgB,kBAAiBA,EACjC,UAEgBE,IACd,IAAMC,EAAOjB,IACPxB,EACJ4B,IADMC,EAAS7B,EAAA6B,UAAEC,EAAU9B,EAAA8B,WAAEO,UAAOK,iBAAcC,kBAG9CR,EAAUL,EAAWW,EAAKhB,SAAUgB,EAAKf,UAE/CjB,GAAU,YACHgC,EAAKG,UAAYT,GAAWN,GAC/Bc,GAEJ,GAAG,CAACF,EAAKG,SAAUT,EAASN,EAAWc,IAEvC,IAAME,EACJN,GACE,SAACO,GACCA,EAAEC,iBACFD,EAAEE,kBACFX,EAAMI,EAAKhB,SAAUgB,EAAKf,SAC5B,GACA,CAACW,EAAOI,EAAKhB,SAAUgB,EAAKf,WAG1BuB,EACJV,GACE,SAACO,GACCA,EAAEC,iBACEN,EAAKG,UACPF,EAAaD,EAAKhB,SAAUgB,EAAKf,SAErC,GACA,CAACe,EAAKG,SAAUF,EAAcD,EAAKhB,SAAUgB,EAAKf,WAGhDwB,EACJX,GAAY,SAACO,GACXA,EAAEC,iBACFD,EAAEE,iBACH,GAAE,IAEL,MAAO,CACLP,KAAIA,EACJN,QAAOA,EACPN,UAASA,EACTgB,mBAAkBA,EAClBI,wBAAuBA,EACvBC,mBAAkBA,EAEtB"}
1
+ {"version":3,"file":"hook.js","sources":["../../../../src/table/hook.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo } from \"react\";\nimport { DataObject, DataRecord, TPropsTable } from \"./type\";\nimport { usePageContext } from \"./pagenation/providers\";\nimport { useFilterContext } from \"./filter\";\nimport { useSortContext } from \"./sort\";\nimport { useFocusActionContext } from \"./focus/provider\";\nimport { useCheckboxStatusContext } from \"./checkbox/provider\";\nimport { useEditActionContext } from \"./edit/provider\";\nimport {\n useColumnsContext,\n useColumnValidatesContext,\n useProcessedDataContext,\n} from \"./sheet/providers\";\n\nexport function useTable<T extends DataRecord>(props: TPropsTable<T>) {\n const { filter } = useFilterContext();\n const { sort } = useSortContext();\n const { setRowCount, pageFilter } = usePageContext();\n const { dispatchCheckboxStatus } = useCheckboxStatusContext();\n\n const filteredRows = useMemo(() => filter(props.rows), [filter, props.rows]);\n\n useEffect(() => {\n setRowCount(filteredRows.length);\n }, [filteredRows.length]);\n\n const checkBoxes = useMemo(() => {\n if (!props.checkbox) {\n return [];\n }\n\n return props.rows.filter((row) => props.checkbox?.checked(row));\n }, [props.checkbox, props.rows]);\n\n useEffect(() => {\n dispatchCheckboxStatus({\n type: \"SET\",\n payload: { checkedRecords: checkBoxes },\n });\n }, [checkBoxes]);\n\n const sortedRows = useMemo(() => sort(filteredRows), [filteredRows, sort]);\n\n const pageRows = useMemo(\n () => pageFilter(sortedRows),\n [pageFilter, sortedRows]\n );\n\n return {\n cols: props.cols,\n rows: pageRows,\n };\n}\n\nexport function useCell<T extends DataRecord>(\n rowIndex: number,\n colIndex: number,\n onUpdateRow?: (newRow: DataObject<T>, oldRow: DataObject<T>) => void\n) {\n const focus = useFocusActionContext();\n const editAction = useEditActionContext();\n const rows = useProcessedDataContext().rows;\n const cols = useColumnsContext();\n const colValidator = useColumnValidatesContext();\n\n const focusAtCell = useCallback(() => {\n focus.move(rowIndex, colIndex);\n focus.focus(rowIndex, colIndex);\n }, [focus, rowIndex, colIndex]);\n\n const pasteData = useCallback(\n (text: string) => {\n let colLength = 0;\n\n const tableData = text\n .trim()\n .replace(/\\r\\n/g, \"\\n\")\n .split(\"\\n\")\n .map((row) => {\n const colsData = row.split(\"\\t\");\n colLength = Math.max(colLength, colsData.length);\n return colsData;\n });\n\n if (tableData.length === 0 || colLength === 0) {\n return;\n }\n\n for (let i = 0; i < colLength; i++) {\n const col = cols[colIndex + i];\n\n if (!col.editable) {\n alert(\n `編集できない列にデータを貼り付けることはできません。\\n\\n編集不可列: ${\n col.label ?? col.key\n }`\n );\n return;\n }\n }\n\n if (tableData.length + rowIndex > rows.length) {\n alert(\"貼り付け先の行数が足りません。\");\n return;\n }\n\n for (let i = 0; i < tableData.length; i++) {\n for (let j = 0; j < tableData[i].length; j++) {\n const col = cols[colIndex + j];\n const validate = colValidator[col.key];\n\n if (!validate(tableData[i][j])) {\n alert(\n `[${\n col.label ?? col.key\n }]列に次の不正なデータが含まれています。\\n${tableData[i][j]}`\n );\n return;\n }\n }\n }\n\n for (let i = 0; i < tableData.length; i++) {\n let checkUpdatedRow = false;\n const row = { ...rows[rowIndex + i] };\n\n for (let j = 0; j < tableData[i].length; j++) {\n const col = cols[colIndex + j];\n const value =\n col.type === \"number\"\n ? Number(tableData[i][j])\n : col.type === \"select\"\n ? tableData[i][j] === \"\"\n ? \"\"\n : col.options.find(\n (option) => option.label === tableData[i][j]\n )!.value\n : tableData[i][j];\n\n if (row[col.key] !== value) {\n checkUpdatedRow = true;\n\n row[col.key] = value;\n }\n }\n if (checkUpdatedRow && onUpdateRow)\n onUpdateRow!(\n row as DataObject<T>,\n rows[rowIndex + i] as DataObject<T>\n );\n }\n },\n [rowIndex, colIndex]\n );\n\n const onDoubleClickCellToEdit: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n e.preventDefault();\n focus.move(rowIndex, colIndex);\n focus.focus(rowIndex, colIndex);\n editAction.startEditing();\n },\n [focus, editAction]\n );\n\n const preventPropagation: React.MouseEventHandler<HTMLDivElement> =\n useCallback((e) => {\n e.preventDefault();\n e.stopPropagation();\n }, []);\n\n return {\n focusAtCell,\n onDoubleClickCellToEdit,\n preventPropagation,\n pasteData,\n };\n}\n"],"names":["useTable","props","filter","useFilterContext","sort","useSortContext","_a","usePageContext","setRowCount","pageFilter","dispatchCheckboxStatus","useCheckboxStatusContext","filteredRows","useMemo","rows","useEffect","length","checkBoxes","checkbox","row","checked","type","payload","checkedRecords","sortedRows","pageRows","cols","useCell","rowIndex","colIndex","onUpdateRow","focus","useFocusActionContext","editAction","useEditActionContext","useProcessedDataContext","useColumnsContext","colValidator","useColumnValidatesContext","focusAtCell","useCallback","move","pasteData","text","colLength","tableData","trim","replace","split","map","colsData","Math","max","i","col","editable","alert","concat","label","key","j","validate","_b","checkUpdatedRow","value","Number","options","find","option","onDoubleClickCellToEdit","e","preventDefault","startEditing","preventPropagation","stopPropagation"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ function t(t){if("string"===t.type)return a=t.constraints,function(t){return(null==a?void 0:a.maxLength)&&t.length>a.maxLength?(alert("最大文字数(".concat(a.maxLength,")を超過しています。(現在").concat(t.length,"文字)")),!1):(null==a?void 0:a.minLength)&&t.length<a.minLength?(alert("最小文字数(".concat(a.minLength,")を下回っています。(現在").concat(t.length,"文字)")),!1):!((null==a?void 0:a.pattern)&&!new RegExp(a.pattern).test(t)&&(alert("パターンに一致しません。(パターン".concat(a.pattern,")")),1))};if("number"===t.type)return function(t){return function(n){if("string"==typeof n){if(!/^-?[0-9]+(\.[0-9]+)?$/.test(n))return alert("数値ではない値が入力されています。"),!1;n=Number(n)}return"number"==typeof(null==t?void 0:t.max)&&n>t.max?(alert("最大値(".concat(t.max,")を超過しています。(入力値:").concat(n,")")),!1):!("number"==typeof(null==t?void 0:t.min)&&n<t.min&&(alert("最小値(".concat(t.min,")を下回っています。(入力値:").concat(n,")")),1))}}(t.constraints);if("select"===t.type)return n=t.options,e=t.allowEmpty,r=new Set(n.map((function(t){return t.label}))),function(t){return!(!e||""!==t)||!!r.has(t)||(alert("選択肢に含まれていない値です。(選択肢:".concat(t,")")),!1)};throw new Error("Invalid type");var n,e,r,a}export{t as generateValidateFunction};
2
+ //# sourceMappingURL=generate-validate-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-validate-function.js","sources":["../../../../../src/table/libs/generate-validate-function.ts"],"sourcesContent":["export type TStringValidateOption = {\n maxLength?: number;\n minLength?: number;\n pattern?: string;\n};\n\nexport type TNumberValidateOption = {\n max?: number;\n min?: number;\n};\n\ntype TPropsGenerateValidateFunction =\n | {\n type: \"string\";\n constraints?: TStringValidateOption;\n }\n | {\n type: \"number\";\n constraints?: TNumberValidateOption;\n }\n | {\n type: \"select\";\n options: { value: string; label: string }[];\n allowEmpty?: boolean;\n };\n\ntype TStringValidateFunction = (value: string) => boolean;\n\nfunction generateStringValidateFunction(\n constraints?: TStringValidateOption\n): TStringValidateFunction {\n return (value: string) => {\n if (constraints?.maxLength) {\n if (value.length > constraints.maxLength) {\n alert(\n `最大文字数(${constraints.maxLength})を超過しています。(現在${value.length}文字)`\n );\n return false;\n }\n }\n if (constraints?.minLength) {\n if (value.length < constraints.minLength) {\n alert(\n `最小文字数(${constraints.minLength})を下回っています。(現在${value.length}文字)`\n );\n return false;\n }\n }\n if (constraints?.pattern) {\n if (!new RegExp(constraints.pattern).test(value)) {\n alert(`パターンに一致しません。(パターン${constraints.pattern})`);\n return false;\n }\n }\n return true;\n };\n}\n\ntype TNumberValidateFunction = (value: number) => boolean;\n\nfunction generateNumberValidateFunction(\n constraints?: TNumberValidateOption\n): TNumberValidateFunction {\n return (value: number | string) => {\n if (typeof value === \"string\") {\n // 小数も含めて数値に変換可能な値かを検査\n if (!/^-?[0-9]+(\\.[0-9]+)?$/.test(value)) {\n alert(\"数値ではない値が入力されています。\");\n return false;\n }\n value = Number(value);\n }\n\n if (typeof constraints?.max === \"number\") {\n if (value > constraints.max) {\n alert(`最大値(${constraints.max})を超過しています。(入力値:${value})`);\n return false;\n }\n }\n\n if (typeof constraints?.min === \"number\") {\n if (value < constraints.min) {\n alert(`最小値(${constraints.min})を下回っています。(入力値:${value})`);\n return false;\n }\n }\n\n return true;\n };\n}\n\ntype TSelectValidateFunction = (label: string) => boolean;\n\nfunction generatSelectValidateFunction(\n options: { value: string; label: string }[],\n allowEmpty?: boolean\n): TSelectValidateFunction {\n const labelSets = new Set(options.map((option) => option.label));\n return (label: string) => {\n if (allowEmpty && label === \"\") {\n return true;\n }\n\n if (!labelSets.has(label)) {\n alert(`選択肢に含まれていない値です。(選択肢:${label})`);\n return false;\n }\n\n return true;\n };\n}\n\nexport function generateValidateFunction(\n props: TPropsGenerateValidateFunction\n) {\n if (props.type === \"string\") {\n return generateStringValidateFunction(props.constraints);\n } else if (props.type === \"number\") {\n return generateNumberValidateFunction(props.constraints);\n } else if (props.type === \"select\") {\n return generatSelectValidateFunction(props.options, props.allowEmpty);\n } else {\n throw new Error(\"Invalid type\");\n }\n}\n"],"names":["generateValidateFunction","props","type","constraints","value","maxLength","length","alert","concat","minLength","pattern","RegExp","test","Number","max","min","generateNumberValidateFunction","options","allowEmpty","labelSets","Set","map","option","label","has","Error"],"mappings":"AAgHM,SAAUA,EACdC,GAEA,GAAmB,WAAfA,EAAMC,KACR,OAvFFC,EAuFwCF,EAAME,YArFvC,SAACC,GACN,OAAID,aAAW,EAAXA,EAAaE,YACXD,EAAME,OAASH,EAAYE,WAC7BE,MACE,SAASC,OAAAL,EAAYE,UAAyB,iBAAAG,OAAAJ,EAAME,OAAW,SAE1D,IAGPH,aAAW,EAAXA,EAAaM,YACXL,EAAME,OAASH,EAAYM,WAC7BF,MACE,SAASC,OAAAL,EAAYM,UAAyB,iBAAAD,OAAAJ,EAAME,OAAW,SAE1D,MAGPH,aAAW,EAAXA,EAAaO,WACV,IAAIC,OAAOR,EAAYO,SAASE,KAAKR,KACxCG,MAAM,oBAAoBC,OAAAL,EAAYO,QAAO,MACtC,GAIb,EA8DO,GAAmB,WAAfT,EAAMC,KACf,OA1DJ,SACEC,GAEA,OAAO,SAACC,GACN,GAAqB,iBAAVA,EAAoB,CAE7B,IAAK,wBAAwBQ,KAAKR,GAEhC,OADAG,MAAM,sBACC,EAETH,EAAQS,OAAOT,EAChB,CAED,MAAgC,iBAArBD,aAAW,EAAXA,EAAaW,MAClBV,EAAQD,EAAYW,KACtBP,MAAM,cAAOJ,EAAYW,IAAqB,mBAAAN,OAAAJ,EAAQ,OAC/C,KAIqB,iBAArBD,aAAW,EAAXA,EAAaY,MAClBX,EAAQD,EAAYY,MACtBR,MAAM,cAAOJ,EAAYY,IAAqB,mBAAAP,OAAAJ,EAAQ,MAC/C,GAKb,CACF,CA6BWY,CAA+Bf,EAAME,aACvC,GAAmB,WAAfF,EAAMC,KACf,OA1BFe,EA0BuChB,EAAMgB,QAzB7CC,EAyBsDjB,EAAMiB,WAvBtDC,EAAY,IAAIC,IAAIH,EAAQI,KAAI,SAACC,GAAW,OAAAA,EAAOC,UAClD,SAACA,GACN,SAAIL,GAAwB,KAAVK,MAIbJ,EAAUK,IAAID,KACjBhB,MAAM,uBAAAC,OAAuBe,EAAK,OAC3B,EAIX,EAaE,MAAM,IAAIE,MAAM,gBA7BpB,IACER,EACAC,EAEMC,EApENhB,CA+FF"}
@@ -0,0 +1,2 @@
1
+ var t={getTableCellId:function(t,e){return"table-cell-".concat(t,"-").concat(e)},getTableColId:function(t){return"table-col-".concat(t)}};export{t as IdGenerator};
2
+ //# sourceMappingURL=id-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-generator.js","sources":["../../../../../src/table/libs/id-generator.ts"],"sourcesContent":["export const IdGenerator = {\n getTableCellId: (rowIndex: number, columnIndex: number) =>\n `table-cell-${rowIndex}-${columnIndex}`,\n getTableColId: (columnIndex: number) => `table-col-${columnIndex}`,\n};\n"],"names":["IdGenerator","getTableCellId","rowIndex","columnIndex","concat","getTableColId"],"mappings":"AAAa,IAAAA,EAAc,CACzBC,eAAgB,SAACC,EAAkBC,GACjC,MAAA,cAAcC,OAAAF,EAAY,KAAAE,OAAAD,EAAa,EACzCE,cAAe,SAACF,GAAwB,MAAA,aAAaC,OAAAD,EAAa"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e,Fragment as r}from"react/jsx-runtime";import{useEffect as t}from"react";import{useTablePropertyStateContext as o}from"../../table-property/provider.js";import{useFocusContext as i}from"../../focus/provider.js";import{useEditContext as n}from"../../edit/provider.js";import{useColumnsContext as s}from"../../sheet/providers.js";function f(){var f=i(),u=n(),d=o(),p=d.maxDisplayColCount,l=d.maxDisplayRowCount,m=s()[f.isFocus?f.colIndex:0],a=f.isFocus?f.rowIndex:-1,c=f.isFocus?f.colIndex:-1;return t((function(){var e=function(e){if(u.isEditing)"Escape"===e.key&&(e.preventDefault(),u.endEditing());else if(f.isFocus)if("Enter"===e.key)e.preventDefault(),f.moveDown();else if("Escape"===e.key)e.preventDefault(),f.unfocus();else if("ArrowRight"===e.key){if(e.preventDefault(),f.colIndex===p-1)return;f.moveRight()}else if("ArrowLeft"===e.key){if(e.preventDefault(),0===f.colIndex)return;f.moveLeft()}else if("ArrowUp"===e.key){if(e.preventDefault(),0===f.rowIndex)return;f.moveUp()}else if("ArrowDown"===e.key){if(e.preventDefault(),f.rowIndex===l-1)return;f.moveDown()}else"F2"===e.key&&(e.preventDefault(),u.startEditing())};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[u.isEditing,f.isFocus,a,c]),t((function(){u.isEditing&&!m.editable&&u.endEditing()}),[u,m]),e(r,{})}export{f as KeyboardSetting};
2
+ //# sourceMappingURL=keyboard-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboard-setting.js","sources":["../../../../../../src/table/operation/components/keyboard-setting.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useTablePropertyStateContext } from \"../../table-property/provider\";\nimport { useFocusContext } from \"../../focus/provider\";\nimport { useEditContext } from \"../../edit/provider\";\nimport { useColumnsContext } from \"../../sheet/providers\";\n\nexport function KeyboardSetting() {\n const focus = useFocusContext();\n const edit = useEditContext();\n const { maxDisplayColCount, maxDisplayRowCount } =\n useTablePropertyStateContext();\n const col = useColumnsContext()[focus.isFocus ? focus.colIndex : 0];\n\n const rowIndex = focus.isFocus ? focus.rowIndex : -1;\n const colIndex = focus.isFocus ? focus.colIndex : -1;\n\n useEffect(() => {\n const listener = (e: KeyboardEvent) => {\n if (edit.isEditing) {\n if (e.key === \"Escape\") {\n e.preventDefault();\n edit.endEditing();\n }\n } else if (focus.isFocus) {\n if (e.key === \"Enter\") {\n e.preventDefault();\n focus.moveDown();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n focus.unfocus();\n } else if (e.key === \"ArrowRight\") {\n e.preventDefault();\n\n if (focus.colIndex === maxDisplayColCount - 1) return;\n\n focus.moveRight();\n } else if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n\n if (focus.colIndex === 0) return;\n\n focus.moveLeft();\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n\n if (focus.rowIndex === 0) return;\n\n focus.moveUp();\n } else if (e.key === \"ArrowDown\") {\n e.preventDefault();\n\n if (focus.rowIndex === maxDisplayRowCount - 1) return;\n\n focus.moveDown();\n } else if (e.key === \"F2\") {\n e.preventDefault();\n edit.startEditing();\n }\n }\n };\n\n document.addEventListener(\"keydown\", listener);\n\n return () => {\n document.removeEventListener(\"keydown\", listener);\n };\n }, [edit.isEditing, focus.isFocus, rowIndex, colIndex]);\n\n useEffect(() => {\n if (edit.isEditing && !col.editable) {\n edit.endEditing();\n }\n }, [edit, col]);\n\n return <></>;\n}\n"],"names":["KeyboardSetting","focus","useFocusContext","edit","useEditContext","_a","useTablePropertyStateContext","maxDisplayColCount","maxDisplayRowCount","col","useColumnsContext","isFocus","colIndex","rowIndex","useEffect","listener","e","isEditing","key","preventDefault","endEditing","moveDown","unfocus","moveRight","moveLeft","moveUp","startEditing","document","addEventListener","removeEventListener","editable","_jsx"],"mappings":"gWAMgBA,IACd,IAAMC,EAAQC,IACRC,EAAOC,IACPC,EACJC,IADMC,EAAkBF,EAAAE,mBAAEC,EAAkBH,EAAAG,mBAExCC,EAAMC,IAAoBT,EAAMU,QAAUV,EAAMW,SAAW,GAE3DC,EAAWZ,EAAMU,QAAUV,EAAMY,UAAY,EAC7CD,EAAWX,EAAMU,QAAUV,EAAMW,UAAY,EA4DnD,OA1DAE,GAAU,WACR,IAAMC,EAAW,SAACC,GAChB,GAAIb,EAAKc,UACO,WAAVD,EAAEE,MACJF,EAAEG,iBACFhB,EAAKiB,mBAEF,GAAInB,EAAMU,QACf,GAAc,UAAVK,EAAEE,IACJF,EAAEG,iBACFlB,EAAMoB,gBACD,GAAc,WAAVL,EAAEE,IACXF,EAAEG,iBACFlB,EAAMqB,eACD,GAAc,eAAVN,EAAEE,IAAsB,CAGjC,GAFAF,EAAEG,iBAEElB,EAAMW,WAAaL,EAAqB,EAAG,OAE/CN,EAAMsB,WACP,MAAM,GAAc,cAAVP,EAAEE,IAAqB,CAGhC,GAFAF,EAAEG,iBAEqB,IAAnBlB,EAAMW,SAAgB,OAE1BX,EAAMuB,UACP,MAAM,GAAc,YAAVR,EAAEE,IAAmB,CAG9B,GAFAF,EAAEG,iBAEqB,IAAnBlB,EAAMY,SAAgB,OAE1BZ,EAAMwB,QACP,MAAM,GAAc,cAAVT,EAAEE,IAAqB,CAGhC,GAFAF,EAAEG,iBAEElB,EAAMY,WAAaL,EAAqB,EAAG,OAE/CP,EAAMoB,UACP,KAAoB,OAAVL,EAAEE,MACXF,EAAEG,iBACFhB,EAAKuB,eAGX,EAIA,OAFAC,SAASC,iBAAiB,UAAWb,GAE9B,WACLY,SAASE,oBAAoB,UAAWd,EAC1C,CACF,GAAG,CAACZ,EAAKc,UAAWhB,EAAMU,QAASE,EAAUD,IAE7CE,GAAU,WACJX,EAAKc,YAAcR,EAAIqB,UACzB3B,EAAKiB,YAET,GAAG,CAACjB,EAAMM,IAEHsB,OACT"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{jsxs as t,jsx as n}from"react/jsx-runtime";import{usePageContext as e}from"./providers.js";function r(){var r=e(),c=r.current,o=r.pageCount,i=r.jump,u=r.prev,s=r.next;return t("div",{className:"flex justify-center gap-2",children:[n("button",{className:"text-sm",onClick:function(){return i(1)},disabled:1===c,children:"≪"}),n("button",{className:"text-sm",onClick:function(){return u()},disabled:1===c,children:"<"}),Array.from({length:o},(function(t,n){return n+1})).filter((function(t){return c-2<=t&&t<=c+2})).map((function(t){return n("button",{className:"text-sm ".concat(c===t?"text-blue-600":""),onClick:function(){return i(t)},children:t},t)})),n("button",{className:"text-sm",onClick:function(){return s()},disabled:c===o,children:">"}),n("button",{className:"text-sm",onClick:function(){return i(o)},disabled:c===o,children:"≫"})]})}function c(){var n=e(),r=n.from,c=n.to,o=n.rowCount;return t("p",{className:"text-center text-sm text-gray-600",children:[r+1," - ",c<o?c:o," of ",o]})}export{c as DisplayRange,r as Pagenation};
2
+ import{jsx as t,Fragment as n,jsxs as e}from"react/jsx-runtime";import{usePageContext as r}from"./providers.js";function c(){var c=r(),o=c.enable,i=c.current,u=c.pageCount,a=c.jump,l=c.prev,s=c.next;return o?e("div",{className:"flex justify-center gap-2",children:[t("button",{className:"text-sm",onClick:function(){return a(1)},disabled:1===i,children:"≪"}),t("button",{className:"text-sm",onClick:function(){return l()},disabled:1===i,children:"<"}),Array.from({length:u},(function(t,n){return n+1})).filter((function(t){return i-2<=t&&t<=i+2})).map((function(n){return t("button",{className:"text-sm ".concat(i===n?"text-blue-600":""),onClick:function(){return a(n)},children:n},n)})),t("button",{className:"text-sm",onClick:function(){return s()},disabled:i===u,children:">"}),t("button",{className:"text-sm",onClick:function(){return a(u)},disabled:i===u,children:"≫"})]}):t(n,{})}function o(){var c=r(),o=c.enable,i=c.from,u=c.to,a=c.rowCount;return o?e("p",{className:"text-center text-sm text-gray-600",children:[i+1," - ",u<a?u:a," of ",a]}):t(n,{})}export{o as DisplayRange,c as Pagenation};
3
3
  //# sourceMappingURL=components.js.map
@@ -1,2 +1,2 @@
1
- var r={perPage:50,currentPage:1,rowCount:0};export{r as INITIAL_PAGE_STATE};
1
+ var e={enable:!0,perPage:50,currentPage:1,rowCount:0};export{e as INITIAL_PAGE_STATE};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../src/table/pagenation/constants.ts"],"sourcesContent":["import { TPageState } from \"./types\";\n\nexport const INITIAL_PAGE_STATE: TPageState = {\n perPage: 50,\n currentPage: 1,\n rowCount: 0,\n};\n"],"names":["INITIAL_PAGE_STATE","perPage","currentPage","rowCount"],"mappings":"AAEa,IAAAA,EAAiC,CAC5CC,QAAS,GACTC,YAAa,EACbC,SAAU"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/table/pagenation/constants.ts"],"sourcesContent":["import { TPageState } from \"./types\";\n\nexport const INITIAL_PAGE_STATE: TPageState = {\n enable: true,\n perPage: 50,\n currentPage: 1,\n rowCount: 0,\n};\n"],"names":["INITIAL_PAGE_STATE","enable","perPage","currentPage","rowCount"],"mappings":"AAEa,IAAAA,EAAiC,CAC5CC,QAAQ,EACRC,QAAS,GACTC,YAAa,EACbC,SAAU"}
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as r,useCallback as t,useMemo as n}from"react";import{INITIAL_PAGE_STATE as u}from"./constants.js";function a(r,t){switch(t.type){case"setRowCount":return e(e({},r),{currentPage:1,rowCount:t.payload.rowCount});case"setPerPage":return e(e({},r),{perPage:t.payload.perPage});case"next":return r.currentPage===Math.ceil(r.rowCount/r.perPage)?r:e(e({},r),{currentPage:r.currentPage+1});case"prev":return 1===r.currentPage?r:e(e({},r),{currentPage:r.currentPage-1});case"jump":return t.payload.pageNumber<1||t.payload.pageNumber>Math.ceil(r.rowCount/r.perPage)||r.currentPage===t.payload.pageNumber?r:e(e({},r),{currentPage:t.payload.pageNumber});default:return r}}function o(e){var o=r(a,null!=e?e:u),p=o[0],c=o[1],g=t((function(){return c({type:"next"})}),[c]),P=t((function(){return c({type:"prev"})}),[c]),i=t((function(e){return c({type:"jump",payload:{pageNumber:e}})}),[c]),l=t((function(e){return c({type:"setRowCount",payload:{rowCount:e}})}),[c]),s=n((function(){return(p.currentPage-1)*p.perPage}),[p]),m=n((function(){return p.currentPage*p.perPage}),[p]),f=t((function(e){return e.slice(s,m)}),[s,m]);return{perPage:p.perPage,current:p.currentPage,rowCount:p.rowCount,pageCount:Math.ceil(p.rowCount/p.perPage),from:s,to:m,next:g,prev:P,jump:i,setRowCount:l,pageFilter:f}}export{o 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
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["../../../../../src/table/pagenation/hooks.ts"],"sourcesContent":["import { useCallback, useMemo, useReducer } from \"react\";\nimport { TPageAction, TPageState } from \"./types\";\nimport { INITIAL_PAGE_STATE } from \"./constants\";\nimport { DataObject, DataRecord } from \"../type\";\n\nfunction pagenationReducer(state: TPageState, action: TPageAction): TPageState {\n switch (action.type) {\n case \"setRowCount\":\n return {\n ...state,\n currentPage: 1,\n rowCount: action.payload.rowCount,\n };\n case \"setPerPage\":\n return {\n ...state,\n perPage: action.payload.perPage,\n };\n case \"next\":\n if (state.currentPage === Math.ceil(state.rowCount / state.perPage)) {\n return state;\n }\n\n return {\n ...state,\n currentPage: state.currentPage + 1,\n };\n case \"prev\":\n if (state.currentPage === 1) {\n return state;\n }\n\n return {\n ...state,\n currentPage: state.currentPage - 1,\n };\n case \"jump\":\n if (\n action.payload.pageNumber < 1 ||\n action.payload.pageNumber > Math.ceil(state.rowCount / state.perPage) ||\n state.currentPage === action.payload.pageNumber\n ) {\n return state;\n }\n\n return {\n ...state,\n currentPage: action.payload.pageNumber,\n };\n default:\n return state;\n }\n}\n\nexport function usePageReducer(initialState?: TPageState) {\n const [state, dispatch] = useReducer(\n pagenationReducer,\n initialState ?? INITIAL_PAGE_STATE\n );\n\n const next = useCallback(() => dispatch({ type: \"next\" }), [dispatch]);\n const prev = useCallback(() => dispatch({ type: \"prev\" }), [dispatch]);\n const jump = useCallback(\n (pageNumber: number) => dispatch({ type: \"jump\", payload: { pageNumber } }),\n [dispatch]\n );\n\n const setRowCount = useCallback(\n (rowCount: number) =>\n dispatch({ type: \"setRowCount\", payload: { rowCount } }),\n [dispatch]\n );\n\n const from = useMemo(() => (state.currentPage - 1) * state.perPage, [state]);\n const to = useMemo(() => state.currentPage * state.perPage, [state]);\n\n const pageFilter = useCallback(\n <U extends DataRecord>(data: DataObject<U>[]): DataObject<U>[] => {\n return data.slice(from, to);\n },\n [from, to]\n );\n\n return {\n perPage: state.perPage,\n current: state.currentPage,\n rowCount: state.rowCount,\n pageCount: Math.ceil(state.rowCount / state.perPage),\n from,\n to,\n next,\n prev,\n jump,\n setRowCount,\n pageFilter,\n };\n}\n"],"names":["pagenationReducer","state","action","type","__assign","currentPage","rowCount","payload","perPage","Math","ceil","pageNumber","usePageReducer","initialState","_a","useReducer","INITIAL_PAGE_STATE","dispatch","next","useCallback","prev","jump","setRowCount","from","useMemo","to","pageFilter","data","slice","current","pageCount"],"mappings":"yLAKA,SAASA,EAAkBC,EAAmBC,GAC5C,OAAQA,EAAOC,MACb,IAAK,cACH,OAAAC,EAAAA,EAAA,GACKH,GAAK,CACRI,YAAa,EACbC,SAAUJ,EAAOK,QAAQD,WAE7B,IAAK,aACH,OACKF,EAAAA,EAAA,CAAA,EAAAH,IACHO,QAASN,EAAOK,QAAQC,UAE5B,IAAK,OACH,OAAIP,EAAMI,cAAgBI,KAAKC,KAAKT,EAAMK,SAAWL,EAAMO,SAClDP,EAIJG,EAAAA,EAAA,CAAA,EAAAH,IACHI,YAAaJ,EAAMI,YAAc,IAErC,IAAK,OACH,OAA0B,IAAtBJ,EAAMI,YACDJ,EAIJG,EAAAA,EAAA,CAAA,EAAAH,IACHI,YAAaJ,EAAMI,YAAc,IAErC,IAAK,OACH,OACEH,EAAOK,QAAQI,WAAa,GAC5BT,EAAOK,QAAQI,WAAaF,KAAKC,KAAKT,EAAMK,SAAWL,EAAMO,UAC7DP,EAAMI,cAAgBH,EAAOK,QAAQI,WAE9BV,EAIJG,EAAAA,EAAA,CAAA,EAAAH,IACHI,YAAaH,EAAOK,QAAQI,aAEhC,QACE,OAAOV,EAEb,CAEM,SAAUW,EAAeC,GACvB,IAAAC,EAAoBC,EACxBf,EACAa,QAAAA,EAAgBG,GAFXf,OAAOgB,OAKRC,EAAOC,GAAY,WAAM,OAAAF,EAAS,CAAEd,KAAM,QAAjB,GAA4B,CAACc,IACtDG,EAAOD,GAAY,WAAM,OAAAF,EAAS,CAAEd,KAAM,QAAjB,GAA4B,CAACc,IACtDI,EAAOF,GACX,SAACR,GAAuB,OAAAM,EAAS,CAAEd,KAAM,OAAQI,QAAS,CAAEI,WAAUA,OACtE,CAACM,IAGGK,EAAcH,GAClB,SAACb,GACC,OAAAW,EAAS,CAAEd,KAAM,cAAeI,QAAS,CAAED,SAAQA,IAAnD,GACF,CAACW,IAGGM,EAAOC,GAAQ,WAAM,OAACvB,EAAMI,YAAc,GAAKJ,EAAMO,OAAO,GAAE,CAACP,IAC/DwB,EAAKD,GAAQ,WAAM,OAAAvB,EAAMI,YAAcJ,EAAMO,UAAS,CAACP,IAEvDyB,EAAaP,GACjB,SAAuBQ,GACrB,OAAOA,EAAKC,MAAML,EAAME,EAC1B,GACA,CAACF,EAAME,IAGT,MAAO,CACLjB,QAASP,EAAMO,QACfqB,QAAS5B,EAAMI,YACfC,SAAUL,EAAMK,SAChBwB,UAAWrB,KAAKC,KAAKT,EAAMK,SAAWL,EAAMO,SAC5Ce,KAAIA,EACJE,GAAEA,EACFP,KAAIA,EACJE,KAAIA,EACJC,KAAIA,EACJC,YAAWA,EACXI,WAAUA,EAEd"}
1
+ {"version":3,"file":"hooks.js","sources":["../../../../../src/table/pagenation/hooks.ts"],"sourcesContent":["import { useCallback, useMemo, useReducer } from \"react\";\nimport { TPageAction, TPageState } from \"./types\";\nimport { INITIAL_PAGE_STATE } from \"./constants\";\nimport { DataObject, DataRecord } from \"../type\";\n\nfunction pagenationReducer(state: TPageState, action: TPageAction): TPageState {\n switch (action.type) {\n case \"setRowCount\":\n if (!state.enable) {\n return {\n ...state,\n rowCount: action.payload.rowCount,\n };\n }\n return {\n ...state,\n currentPage: 1,\n rowCount: action.payload.rowCount,\n };\n case \"setPerPage\":\n if (action.payload.perPage === \"all\") {\n return {\n rowCount: state.rowCount,\n enable: false,\n };\n }\n\n if (!state.enable) {\n return {\n rowCount: state.rowCount,\n enable: true,\n currentPage: 1,\n perPage: action.payload.perPage,\n };\n }\n\n return {\n ...state,\n currentPage: 1,\n perPage: action.payload.perPage,\n };\n case \"next\":\n if (!state.enable) {\n return state;\n }\n\n if (state.currentPage === Math.ceil(state.rowCount / state.perPage)) {\n return state;\n }\n\n return {\n ...state,\n currentPage: state.currentPage + 1,\n };\n case \"prev\":\n if (!state.enable) {\n return state;\n }\n\n if (state.currentPage === 1) {\n return state;\n }\n\n return {\n ...state,\n currentPage: state.currentPage - 1,\n };\n case \"jump\":\n if (!state.enable) {\n return state;\n }\n\n if (\n action.payload.pageNumber < 1 ||\n action.payload.pageNumber > Math.ceil(state.rowCount / state.perPage) ||\n state.currentPage === action.payload.pageNumber\n ) {\n return state;\n }\n\n return {\n ...state,\n currentPage: action.payload.pageNumber,\n };\n default:\n return state;\n }\n}\n\nexport function usePageReducer(initialState?: TPageState) {\n const [state, dispatch] = useReducer(\n pagenationReducer,\n initialState ?? INITIAL_PAGE_STATE\n );\n\n const next = useCallback(() => dispatch({ type: \"next\" }), [dispatch]);\n const prev = useCallback(() => dispatch({ type: \"prev\" }), [dispatch]);\n const jump = useCallback(\n (pageNumber: number) => dispatch({ type: \"jump\", payload: { pageNumber } }),\n [dispatch]\n );\n\n const setRowCount = useCallback(\n (rowCount: number) =>\n dispatch({ type: \"setRowCount\", payload: { rowCount } }),\n [dispatch]\n );\n\n const from = useMemo(() => {\n if (!state.enable) {\n return 0;\n }\n return (state.currentPage - 1) * state.perPage;\n }, [state]);\n\n const to = useMemo(() => {\n if (!state.enable) {\n return state.rowCount;\n }\n return state.currentPage * state.perPage;\n }, [state]);\n\n const pageFilter = useCallback(\n <U extends DataRecord>(data: DataObject<U>[]): DataObject<U>[] => {\n return data.slice(from, to);\n },\n [from, to]\n );\n\n return {\n enable: state.enable,\n perPage: state.enable ? state.perPage : state.rowCount,\n current: state.enable ? state.currentPage : 1,\n rowCount: state.rowCount,\n pageCount: state.enable ? Math.ceil(state.rowCount / state.perPage) : 1,\n from,\n to,\n next,\n prev,\n jump,\n setRowCount,\n pageFilter,\n };\n}\n"],"names":["pagenationReducer","state","action","type","enable","__assign","currentPage","rowCount","payload","perPage","Math","ceil","pageNumber","usePageReducer","initialState","_a","useReducer","INITIAL_PAGE_STATE","dispatch","next","useCallback","prev","jump","setRowCount","from","useMemo","to","pageFilter","data","slice","current","pageCount"],"mappings":"yLAKA,SAASA,EAAkBC,EAAmBC,GAC5C,OAAQA,EAAOC,MACb,IAAK,cACH,OAAKF,EAAMG,OAMXC,EAAAA,EAAA,GACKJ,GAAK,CACRK,YAAa,EACbC,SAAUL,EAAOM,QAAQD,WAPpBF,EAAAA,EAAA,CAAA,EAAAJ,IACHM,SAAUL,EAAOM,QAAQD,WAQ/B,IAAK,aACH,MAA+B,QAA3BL,EAAOM,QAAQC,QACV,CACLF,SAAUN,EAAMM,SAChBH,QAAQ,GAIPH,EAAMG,OASXC,EAAAA,EAAA,GACKJ,GAAK,CACRK,YAAa,EACbG,QAASP,EAAOM,QAAQC,UAXjB,CACLF,SAAUN,EAAMM,SAChBH,QAAQ,EACRE,YAAa,EACbG,QAASP,EAAOM,QAAQC,SAS9B,IAAK,OACH,OAAKR,EAAMG,OAIPH,EAAMK,cAAgBI,KAAKC,KAAKV,EAAMM,SAAWN,EAAMQ,SAClDR,EAIJI,EAAAA,EAAA,CAAA,EAAAJ,IACHK,YAAaL,EAAMK,YAAc,IAT1BL,EAWX,IAAK,OACH,OAAKA,EAAMG,OAIe,IAAtBH,EAAMK,YACDL,EAIJI,EAAAA,EAAA,CAAA,EAAAJ,IACHK,YAAaL,EAAMK,YAAc,IAT1BL,EAWX,IAAK,OACH,OAAKA,EAAMG,OAKTF,EAAOM,QAAQI,WAAa,GAC5BV,EAAOM,QAAQI,WAAaF,KAAKC,KAAKV,EAAMM,SAAWN,EAAMQ,UAC7DR,EAAMK,cAAgBJ,EAAOM,QAAQI,WAE9BX,EAIJI,EAAAA,EAAA,CAAA,EAAAJ,IACHK,YAAaJ,EAAOM,QAAQI,aAbrBX,EAeX,QACE,OAAOA,EAEb,CAEM,SAAUY,EAAeC,GACvB,IAAAC,EAAoBC,EACxBhB,EACAc,QAAAA,EAAgBG,GAFXhB,OAAOiB,OAKRC,EAAOC,GAAY,WAAM,OAAAF,EAAS,CAAEf,KAAM,QAAjB,GAA4B,CAACe,IACtDG,EAAOD,GAAY,WAAM,OAAAF,EAAS,CAAEf,KAAM,QAAjB,GAA4B,CAACe,IACtDI,EAAOF,GACX,SAACR,GAAuB,OAAAM,EAAS,CAAEf,KAAM,OAAQK,QAAS,CAAEI,WAAUA,OACtE,CAACM,IAGGK,EAAcH,GAClB,SAACb,GACC,OAAAW,EAAS,CAAEf,KAAM,cAAeK,QAAS,CAAED,SAAQA,IAAnD,GACF,CAACW,IAGGM,EAAOC,GAAQ,WACnB,OAAKxB,EAAMG,QAGHH,EAAMK,YAAc,GAAKL,EAAMQ,QAF9B,CAGX,GAAG,CAACR,IAEEyB,EAAKD,GAAQ,WACjB,OAAKxB,EAAMG,OAGJH,EAAMK,YAAcL,EAAMQ,QAFxBR,EAAMM,QAGjB,GAAG,CAACN,IAEE0B,EAAaP,GACjB,SAAuBQ,GACrB,OAAOA,EAAKC,MAAML,EAAME,EAC1B,GACA,CAACF,EAAME,IAGT,MAAO,CACLtB,OAAQH,EAAMG,OACdK,QAASR,EAAMG,OAASH,EAAMQ,QAAUR,EAAMM,SAC9CuB,QAAS7B,EAAMG,OAASH,EAAMK,YAAc,EAC5CC,SAAUN,EAAMM,SAChBwB,UAAW9B,EAAMG,OAASM,KAAKC,KAAKV,EAAMM,SAAWN,EAAMQ,SAAW,EACtEe,KAAIA,EACJE,GAAEA,EACFP,KAAIA,EACJE,KAAIA,EACJC,KAAIA,EACJC,YAAWA,EACXI,WAAUA,EAEd"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{jsx as r}from"react/jsx-runtime";import{createContext as n,useContext as o}from"react";import{usePageReducer as t}from"./hooks.js";var e=n({perPage:0,current:0,pageCount:0,from:0,to:0,rowCount:0,next:function(){throw new Error("Function not implemented.")},prev:function(){throw new Error("Function not implemented.")},jump:function(){throw new Error("Function not implemented.")},setRowCount:function(){throw new Error("Function not implemented.")},pageFilter:function(){return[]}});function u(n){var o,u;return r(e.Provider,{value:t({perPage:null!==(o=n.perPage)&&void 0!==o?o:50,currentPage:null!==(u=n.currentPage)&&void 0!==u?u:1,rowCount:n.rowCount}),children:n.children})}function i(){return o(e)}export{u as PagenationProvider,i as usePageContext};
2
+ import{jsx as n}from"react/jsx-runtime";import{createContext as r,useContext as e}from"react";import{usePageReducer as o}from"./hooks.js";var t=r({enable:!0,perPage:0,current:0,pageCount:0,from:0,to:0,rowCount:0,next:function(){throw new Error("Function not implemented.")},prev:function(){throw new Error("Function not implemented.")},jump:function(){throw new Error("Function not implemented.")},setRowCount:function(){throw new Error("Function not implemented.")},pageFilter:function(){return[]}});function u(r){var e,u,i="all"===r.perPage?{enable:!1,rowCount:r.rowCount}:{enable:!0,rowCount:r.rowCount,perPage:null!==(e=r.perPage)&&void 0!==e?e:50,currentPage:null!==(u=r.currentPage)&&void 0!==u?u:1};return n(t.Provider,{value:o(i),children:r.children})}function i(){return e(t)}export{u as PagenationProvider,i as usePageContext};
3
3
  //# sourceMappingURL=providers.js.map
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{jsx as e}from"react/jsx-runtime";import{createContext as r,useContext as n}from"react";var o=r({id:""});function l(r){var n=r.children,l=r.row;return e(o.Provider,{value:l,children:n})}function t(){return n(o)}var i=r({cols:[],colMaps:{}});function c(r){var n=r.children,o=r.cols,l=o.reduce((function(e,r){return e[r.key]=r,e}),{});return e(i.Provider,{value:{cols:o,colMaps:l},children:n})}function u(e){return n(i).colMaps[e]}function d(){return n(i).cols}var a=r({columnKey:"",value:"",label:"",type:"string",rowIndex:0,colIndex:0});function v(r){var n,o,l=r.children,i=r.columnKey,c=r.rowIndex,d=r.colIndex,v=u(i),f=t()[i];return e(a.Provider,{value:{columnKey:i,value:f,label:"select"===v.type?null===(o=null===(n=v.options)||void 0===n?void 0:n.find((function(e){return e.value===f})))||void 0===o?void 0:o.label:f,editable:v.editable,render:v.editable?void 0:v.render,type:v.type,rowIndex:c,colIndex:d},children:l})}function f(){return n(a)}export{v as CellProvider,c as ColumnsProvider,l as RowProvider,f as useCellContext,u as useColumnContext,d as useColumnsContext,t as useRowContext};
2
+ import{jsx as r}from"react/jsx-runtime";import{createContext as n,useContext as e,useMemo as o}from"react";import{useTable as t}from"../hook.js";import{generateValidateFunction as i}from"../libs/generate-validate-function.js";var u=n({cols:[],rows:[]});function c(n){var e=n.children,o=n.props,i=t(o),c=i.cols,a=i.rows;return r(u.Provider,{value:{cols:c,rows:a},children:e})}function a(){return e(u)}var l=n({id:""});function s(n){var e=n.children,t=n.row,i=o((function(){return t}),[t.id]);return r(l.Provider,{value:i,children:e})}function f(){return e(l)}var d=n({cols:[],colMaps:{},validates:{}});function v(n){var e=n.children,t=n.cols,u=o((function(){return t.reduce((function(r,n){return r[n.key]=n,r}),{})}),[t]),c=o((function(){return t.reduce((function(r,n){return r[n.key]=i(n),r}),{})}),[t]),a=o((function(){return{cols:t,colMaps:u,validates:c}}),[t]);return r(d.Provider,{value:a,children:e})}function p(r){return e(d).colMaps[r]}function m(){return e(d).cols}function h(r){return e(d).validates[r]}function w(){return e(d).validates}export{v as ColumnsProvider,c as ProcessedDataProvider,s as RowProvider,p as useColumnContext,h as useColumnValidateContext,w as useColumnValidatesContext,m as useColumnsContext,a as useProcessedDataContext,f as useRowContext};
3
3
  //# sourceMappingURL=providers.js.map
@@ -0,0 +1,2 @@
1
+ import{jsx as e,Fragment as t}from"react/jsx-runtime";import{useEffect as o}from"react";import{useFocusContext as r}from"../../focus/provider.js";import{useEditContext as n}from"../../edit/provider.js";import{IdGenerator as l}from"../../libs/id-generator.js";function i(){var i=r(),s=n();return o((function(){var e,t;if(i.isFocus&&s.isEditing){var o=l.getTableCellId(i.rowIndex,i.colIndex),r=document.getElementById("".concat(o,"-display")),n=document.getElementById("".concat(o,"-editor"));null==r||r.style.setProperty("opacity","0"),null==n||n.style.setProperty("opacity","1"),null==n||n.style.setProperty("pointer-events","auto"),null===(e=null==n?void 0:n.querySelector("input"))||void 0===e||e.focus(),null===(t=null==n?void 0:n.querySelector("select"))||void 0===t||t.focus()}return function(){if(i.isFocus&&s.isEditing){var e=l.getTableCellId(i.rowIndex,i.colIndex),t=document.getElementById("".concat(e,"-display")),o=document.getElementById("".concat(e,"-editor"));null==t||t.style.setProperty("opacity","1"),null==o||o.style.setProperty("opacity","0"),null==o||o.style.setProperty("pointer-events","none")}}}),[s.isEditing]),e(t,{})}export{i as AutoSwitchEditMode};
2
+ //# sourceMappingURL=auto-switch-edit-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-switch-edit-mode.js","sources":["../../../../../../src/table/table/components/auto-switch-edit-mode.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useFocusContext } from \"../../focus/provider\";\nimport { useEditContext } from \"../../edit/provider\";\nimport { IdGenerator } from \"../../libs\";\n\nexport function AutoSwitchEditMode() {\n const focus = useFocusContext();\n const edit = useEditContext();\n\n useEffect(() => {\n if (focus.isFocus && edit.isEditing) {\n const id = IdGenerator.getTableCellId(focus.rowIndex, focus.colIndex);\n\n const cellDisplayElement = document.getElementById(`${id}-display`);\n const cellEditorElement = document.getElementById(`${id}-editor`);\n cellDisplayElement?.style.setProperty(\"opacity\", \"0\");\n cellEditorElement?.style.setProperty(\"opacity\", \"1\");\n cellEditorElement?.style.setProperty(\"pointer-events\", \"auto\");\n cellEditorElement?.querySelector(\"input\")?.focus();\n cellEditorElement?.querySelector(\"select\")?.focus();\n }\n\n return () => {\n if (focus.isFocus && edit.isEditing) {\n const id = IdGenerator.getTableCellId(focus.rowIndex, focus.colIndex);\n\n const cellDisplayElement = document.getElementById(`${id}-display`);\n const cellEditorElement = document.getElementById(`${id}-editor`);\n cellDisplayElement?.style.setProperty(\"opacity\", \"1\");\n cellEditorElement?.style.setProperty(\"opacity\", \"0\");\n cellEditorElement?.style.setProperty(\"pointer-events\", \"none\");\n }\n };\n }, [edit.isEditing]);\n\n return <></>;\n}\n"],"names":["AutoSwitchEditMode","focus","useFocusContext","edit","useEditContext","useEffect","isFocus","isEditing","id","IdGenerator","getTableCellId","rowIndex","colIndex","cellDisplayElement","document","getElementById","concat","cellEditorElement","style","setProperty","_a","querySelector","_b","_jsx"],"mappings":"4QAKgBA,IACd,IAAMC,EAAQC,IACRC,EAAOC,IA4Bb,OA1BAC,GAAU,mBACR,GAAIJ,EAAMK,SAAWH,EAAKI,UAAW,CACnC,IAAMC,EAAKC,EAAYC,eAAeT,EAAMU,SAAUV,EAAMW,UAEtDC,EAAqBC,SAASC,eAAe,GAAGC,OAAAR,EAAY,aAC5DS,EAAoBH,SAASC,eAAe,GAAGC,OAAAR,EAAW,YAChEK,SAAAA,EAAoBK,MAAMC,YAAY,UAAW,KACjDF,SAAAA,EAAmBC,MAAMC,YAAY,UAAW,KAChDF,SAAAA,EAAmBC,MAAMC,YAAY,iBAAkB,QACZ,QAA3CC,EAAAH,aAAiB,EAAjBA,EAAmBI,cAAc,gBAAU,IAAAD,GAAAA,EAAAnB,QACC,QAA5CqB,EAAAL,aAAiB,EAAjBA,EAAmBI,cAAc,iBAAW,IAAAC,GAAAA,EAAArB,OAC7C,CAED,OAAO,WACL,GAAIA,EAAMK,SAAWH,EAAKI,UAAW,CACnC,IAAMC,EAAKC,EAAYC,eAAeT,EAAMU,SAAUV,EAAMW,UAEtDC,EAAqBC,SAASC,eAAe,GAAGC,OAAAR,EAAY,aAC5DS,EAAoBH,SAASC,eAAe,GAAGC,OAAAR,EAAW,YAChEK,SAAAA,EAAoBK,MAAMC,YAAY,UAAW,KACjDF,SAAAA,EAAmBC,MAAMC,YAAY,UAAW,KAChDF,SAAAA,EAAmBC,MAAMC,YAAY,iBAAkB,OACxD,CACH,CACF,GAAG,CAAChB,EAAKI,YAEFgB,OACT"}
@@ -0,0 +1,2 @@
1
+ import{jsx as t,Fragment as o}from"react/jsx-runtime";import{useEffect as r}from"react";import{useProcessedDataContext as e}from"../../sheet/providers.js";import{useTablePropertyActionContext as n}from"../provider.js";function i(){var i=n(),s=i.setMaxDisplayColCount,m=i.setMaxDisplayRowCount,p=e(),l=p.cols,a=p.rows;return r((function(){s(l.length)}),[l.length]),r((function(){m(a.length)}),[a.length]),t(o,{})}export{i as AutoUpdateTableProperty};
2
+ //# sourceMappingURL=auto-update-table-property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-update-table-property.js","sources":["../../../../../../src/table/table-property/components/auto-update-table-property.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useProcessedDataContext } from \"../../sheet/providers\";\nimport { useTablePropertyActionContext } from \"../provider\";\n\nexport function AutoUpdateTableProperty() {\n const { setMaxDisplayColCount, setMaxDisplayRowCount } =\n useTablePropertyActionContext();\n const { cols, rows } = useProcessedDataContext();\n\n useEffect(() => {\n setMaxDisplayColCount(cols.length);\n }, [cols.length]);\n\n useEffect(() => {\n setMaxDisplayRowCount(rows.length);\n }, [rows.length]);\n\n return <></>;\n}\n"],"names":["AutoUpdateTableProperty","_a","useTablePropertyActionContext","setMaxDisplayColCount","setMaxDisplayRowCount","_b","useProcessedDataContext","cols","rows","useEffect","length","_jsx"],"mappings":"mOAIgBA,IACR,IAAAC,EACJC,IADMC,EAAqBF,EAAAE,sBAAEC,EAAqBH,EAAAG,sBAE9CC,EAAiBC,IAAfC,EAAIF,EAAAE,KAAEC,EAAIH,EAAAG,KAUlB,OARAC,GAAU,WACRN,EAAsBI,EAAKG,OAC7B,GAAG,CAACH,EAAKG,SAETD,GAAU,WACRL,EAAsBI,EAAKE,OAC7B,GAAG,CAACF,EAAKE,SAEFC,OACT"}
@@ -0,0 +1,2 @@
1
+ import{__assign as o}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as a,useCallback as t}from"react";var l=function(a,t){switch(t.type){case"setMaxDisplayRowCount":return o(o({},a),{maxDisplayRowCount:t.payload.maxDisplayRowCount});case"setMaxDisplayColCount":return o(o({},a),{maxDisplayColCount:t.payload.maxDisplayColCount})}};function s(){var o=a(l,{maxDisplayRowCount:0,maxDisplayColCount:0}),s=o[0],n=o[1],p=t((function(o){n({type:"setMaxDisplayRowCount",payload:{maxDisplayRowCount:o}})}),[n]),i=t((function(o){n({type:"setMaxDisplayColCount",payload:{maxDisplayColCount:o}})}),[n]);return{maxDisplayRowCount:s.maxDisplayRowCount,maxDisplayColCount:s.maxDisplayColCount,setMaxDisplayRowCount:p,setMaxDisplayColCount:i}}export{s as useTablePropertyReducer};
2
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.js","sources":["../../../../../src/table/table-property/hook.ts"],"sourcesContent":["import { useCallback, useReducer } from \"react\";\nimport { TReturnTablePropertyReducer, TTablePropertyReducer } from \"./type\";\n\nconst reducer: TTablePropertyReducer = (state, action) => {\n switch (action.type) {\n case \"setMaxDisplayRowCount\":\n return {\n ...state,\n maxDisplayRowCount: action.payload.maxDisplayRowCount,\n };\n\n case \"setMaxDisplayColCount\":\n return {\n ...state,\n maxDisplayColCount: action.payload.maxDisplayColCount,\n };\n }\n};\n\nexport function useTablePropertyReducer(): TReturnTablePropertyReducer {\n const [state, dispatch] = useReducer(reducer, {\n maxDisplayRowCount: 0,\n maxDisplayColCount: 0,\n });\n\n const setMaxDisplayRowCount = useCallback(\n (maxDisplayRowCount: number) => {\n dispatch({\n type: \"setMaxDisplayRowCount\",\n payload: { maxDisplayRowCount },\n });\n },\n [dispatch]\n );\n\n const setMaxDisplayColCount = useCallback(\n (maxDisplayColCount: number) => {\n dispatch({\n type: \"setMaxDisplayColCount\",\n payload: { maxDisplayColCount },\n });\n },\n [dispatch]\n );\n\n return {\n maxDisplayRowCount: state.maxDisplayRowCount,\n maxDisplayColCount: state.maxDisplayColCount,\n setMaxDisplayRowCount,\n setMaxDisplayColCount,\n };\n}\n"],"names":["reducer","state","action","type","__assign","maxDisplayRowCount","payload","maxDisplayColCount","useTablePropertyReducer","_a","useReducer","dispatch","setMaxDisplayRowCount","useCallback","setMaxDisplayColCount"],"mappings":"wHAGA,IAAMA,EAAiC,SAACC,EAAOC,GAC7C,OAAQA,EAAOC,MACb,IAAK,wBACH,OACKC,EAAAA,EAAA,CAAA,EAAAH,IACHI,mBAAoBH,EAAOI,QAAQD,qBAGvC,IAAK,wBACH,OACKD,EAAAA,EAAA,CAAA,EAAAH,IACHM,mBAAoBL,EAAOI,QAAQC,qBAG3C,WAEgBC,IACR,IAAAC,EAAoBC,EAAWV,EAAS,CAC5CK,mBAAoB,EACpBE,mBAAoB,IAFfN,EAAKQ,EAAA,GAAEE,OAKRC,EAAwBC,GAC5B,SAACR,GACCM,EAAS,CACPR,KAAM,wBACNG,QAAS,CAAED,mBAAkBA,IAEjC,GACA,CAACM,IAGGG,EAAwBD,GAC5B,SAACN,GACCI,EAAS,CACPR,KAAM,wBACNG,QAAS,CAAEC,mBAAkBA,IAEjC,GACA,CAACI,IAGH,MAAO,CACLN,mBAAoBJ,EAAMI,mBAC1BE,mBAAoBN,EAAMM,mBAC1BK,sBAAqBA,EACrBE,sBAAqBA,EAEzB"}