@teppen/react-ui 1.5.16 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/cjs/node_modules/tslib/tslib.es6.js +1 -1
  2. package/dist/cjs/node_modules/tslib/tslib.es6.js.map +1 -1
  3. package/dist/cjs/src/lib/errors.js +2 -0
  4. package/dist/cjs/src/lib/errors.js.map +1 -0
  5. package/dist/cjs/src/table/cell/hooks.js +1 -1
  6. package/dist/cjs/src/table/cell/hooks.js.map +1 -1
  7. package/dist/cjs/src/table/cell/ui/cell.js +1 -1
  8. package/dist/cjs/src/table/copy/hooks.js +2 -0
  9. package/dist/cjs/src/table/copy/hooks.js.map +1 -0
  10. package/dist/cjs/src/table/copy/provider.js +2 -0
  11. package/dist/cjs/src/table/copy/provider.js.map +1 -0
  12. package/dist/cjs/src/table/edit/ui/editor.js +1 -1
  13. package/dist/cjs/src/table/edit/ui/editor.js.map +1 -1
  14. package/dist/cjs/src/table/lib/errors.js +2 -0
  15. package/dist/cjs/src/table/lib/errors.js.map +1 -0
  16. package/dist/cjs/src/table/libs/id-generator.js +1 -1
  17. package/dist/cjs/src/table/libs/id-generator.js.map +1 -1
  18. package/dist/cjs/src/table/operation/components/keyboard-setting.js +2 -1
  19. package/dist/cjs/src/table/operation/components/keyboard-setting.js.map +1 -1
  20. package/dist/cjs/src/table/paste/hooks.js +1 -1
  21. package/dist/cjs/src/table/paste/hooks.js.map +1 -1
  22. package/dist/cjs/src/table/range/errors.js +2 -0
  23. package/dist/cjs/src/table/range/errors.js.map +1 -0
  24. package/dist/cjs/src/table/range/hooks.js +2 -0
  25. package/dist/cjs/src/table/range/hooks.js.map +1 -0
  26. package/dist/cjs/src/table/range/provider.js +2 -0
  27. package/dist/cjs/src/table/range/provider.js.map +1 -0
  28. package/dist/cjs/src/table/sheet/components.js +1 -1
  29. package/dist/cjs/src/table/sheet/components.js.map +1 -1
  30. package/dist/cjs/src/table/table/base.js +1 -1
  31. package/dist/cjs/src/table/table/hook.js +1 -1
  32. package/dist/cjs/src/table/table/hook.js.map +1 -1
  33. package/dist/esm/node_modules/tslib/tslib.es6.js +1 -1
  34. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
  35. package/dist/esm/src/lib/errors.js +2 -0
  36. package/dist/esm/src/lib/errors.js.map +1 -0
  37. package/dist/esm/src/table/cell/hooks.js +1 -1
  38. package/dist/esm/src/table/cell/hooks.js.map +1 -1
  39. package/dist/esm/src/table/cell/ui/cell.js +1 -1
  40. package/dist/esm/src/table/copy/hooks.js +2 -0
  41. package/dist/esm/src/table/copy/hooks.js.map +1 -0
  42. package/dist/esm/src/table/copy/provider.js +2 -0
  43. package/dist/esm/src/table/copy/provider.js.map +1 -0
  44. package/dist/esm/src/table/edit/ui/editor.js +1 -1
  45. package/dist/esm/src/table/edit/ui/editor.js.map +1 -1
  46. package/dist/esm/src/table/lib/errors.js +2 -0
  47. package/dist/esm/src/table/lib/errors.js.map +1 -0
  48. package/dist/esm/src/table/libs/id-generator.js +1 -1
  49. package/dist/esm/src/table/libs/id-generator.js.map +1 -1
  50. package/dist/esm/src/table/operation/components/keyboard-setting.js +2 -1
  51. package/dist/esm/src/table/operation/components/keyboard-setting.js.map +1 -1
  52. package/dist/esm/src/table/paste/hooks.js +1 -1
  53. package/dist/esm/src/table/paste/hooks.js.map +1 -1
  54. package/dist/esm/src/table/range/errors.js +2 -0
  55. package/dist/esm/src/table/range/errors.js.map +1 -0
  56. package/dist/esm/src/table/range/hooks.js +2 -0
  57. package/dist/esm/src/table/range/hooks.js.map +1 -0
  58. package/dist/esm/src/table/range/provider.js +2 -0
  59. package/dist/esm/src/table/range/provider.js.map +1 -0
  60. package/dist/esm/src/table/sheet/components.js +1 -1
  61. package/dist/esm/src/table/sheet/components.js.map +1 -1
  62. package/dist/esm/src/table/table/base.js +1 -1
  63. package/dist/esm/src/table/table/hook.js +1 -1
  64. package/dist/esm/src/table/table/hook.js.map +1 -1
  65. package/package.json +1 -1
  66. package/dist/cjs/src/table/focus/hooks.js +0 -2
  67. package/dist/cjs/src/table/focus/hooks.js.map +0 -1
  68. package/dist/cjs/src/table/focus/provider.js +0 -2
  69. package/dist/cjs/src/table/focus/provider.js.map +0 -1
  70. package/dist/esm/src/table/focus/hooks.js +0 -2
  71. package/dist/esm/src/table/focus/hooks.js.map +0 -1
  72. package/dist/esm/src/table/focus/provider.js +0 -2
  73. package/dist/esm/src/table/focus/provider.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as t,jsxs as n,Fragment as r}from"react/jsx-runtime";import{createContext as o,useContext as i,useEffect as d}from"react";import{NoImplementeFunction as s}from"../lib/errors.js";import{useRangeReducer as a}from"./hooks.js";import{useTablePropertyStateContext as l}from"../table-property/provider.js";import{IdGenerator as c}from"../libs/id-generator.js";var m=o({isSelecting:!1}),u=o({setMax:s,startSelectRange:s,moveSelectRange:s,endSelectRange:s,moveUp:s,moveDown:s,moveLeft:s,moveRight:s,extendUp:s,extendDown:s,extendLeft:s,extendRight:s,reset:s});function f(){return i(m)}function p(){return i(u)}function v(){return e(e({},f()),p())}function x(){var e=p().setMax,n=l(),o=n.maxDisplayRowCount,i=n.maxDisplayColCount;return d((function(){e({maxRowIndex:o-1,maxColIndex:i-1})}),[o,i]),t(r,{})}function h(e){var o=f();if(d((function(){if(o.isSelecting){var e=document.getElementById(c.getTableCellId(o.end.rowIndex,o.end.colIndex));e&&(e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),e.focus())}}),[o]),!o.isSelecting)return t(r,{});var i=o.rangeBox,s=o.start,a=o.end,l=s.xEnd<a.xEnd?a.xEnd:s.xEnd,m=s.yEnd<a.yEnd?a.yEnd:s.yEnd;return n(r,{children:[t("div",{className:"absolute border border-gray-500 ".concat(e.isCopied?"border-dashed":"border-solid"),style:{top:i.top,left:i.left,width:i.width,height:i.height,pointerEvents:"none"}}),t("div",{className:"absolute bg-gray-700",style:{top:m-5,left:l-5,width:10,height:10,pointerEvents:"none"}})]})}function g(e){var r=e.children,o=a(),i=o.state,d=o.actions;return t(m.Provider,{value:i,children:n(u.Provider,{value:d,children:[t(x,{}),r]})})}export{g as RangeProvider,h as TestRange,p as useRangeActionContext,v as useRangeContext,f as useRangeStateContext};
2
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sources":["../../../../../src/table/range/provider.tsx"],"sourcesContent":["import { createContext, useContext, useEffect } from \"react\";\nimport { TRangeActionContext, TRangeStateContext } from \"./type\";\nimport { NoImplementeFunction } from \"../lib/errors\";\nimport { useRangeReducer } from \"./hooks\";\nimport { useTablePropertyStateContext } from \"../table-property/provider\";\nimport { IdGenerator } from \"../libs\";\n\nconst RangeStateContext = createContext<TRangeStateContext>({\n isSelecting: false,\n});\n\nconst RangeActionContext = createContext<TRangeActionContext>({\n setMax: NoImplementeFunction,\n startSelectRange: NoImplementeFunction,\n moveSelectRange: NoImplementeFunction,\n endSelectRange: NoImplementeFunction,\n moveUp: NoImplementeFunction,\n moveDown: NoImplementeFunction,\n moveLeft: NoImplementeFunction,\n moveRight: NoImplementeFunction,\n extendUp: NoImplementeFunction,\n extendDown: NoImplementeFunction,\n extendLeft: NoImplementeFunction,\n extendRight: NoImplementeFunction,\n reset: NoImplementeFunction,\n});\n\nexport function useRangeStateContext() {\n return useContext(RangeStateContext);\n}\n\nexport function useRangeActionContext() {\n return useContext(RangeActionContext);\n}\n\nexport function useRangeContext() {\n return { ...useRangeStateContext(), ...useRangeActionContext() };\n}\n\nfunction EffectSetMax() {\n const { setMax } = useRangeActionContext();\n const { maxDisplayRowCount, maxDisplayColCount } =\n useTablePropertyStateContext();\n\n useEffect(() => {\n setMax({\n maxRowIndex: maxDisplayRowCount - 1,\n maxColIndex: maxDisplayColCount - 1,\n });\n }, [maxDisplayRowCount, maxDisplayColCount]);\n\n return <></>;\n}\n\nexport function TestRange(props: { isCopied?: boolean }) {\n const state = useRangeStateContext();\n\n useEffect(() => {\n if (state.isSelecting) {\n const endElement = document.getElementById(\n IdGenerator.getTableCellId(state.end.rowIndex, state.end.colIndex)\n );\n\n if (endElement) {\n endElement.scrollIntoView({\n behavior: \"smooth\",\n block: \"nearest\",\n inline: \"nearest\",\n });\n endElement.focus();\n }\n }\n }, [state]);\n\n if (!state.isSelecting) {\n return <></>;\n }\n\n const { rangeBox, start, end } = state;\n\n const clickboxPoint = {\n x: start.xEnd < end.xEnd ? end.xEnd : start.xEnd,\n y: start.yEnd < end.yEnd ? end.yEnd : start.yEnd,\n };\n\n return (\n <>\n <div\n className={`absolute border border-gray-500 ${\n props.isCopied ? \"border-dashed\" : \"border-solid\"\n }`}\n style={{\n top: rangeBox.top,\n left: rangeBox.left,\n width: rangeBox.width,\n height: rangeBox.height,\n pointerEvents: \"none\",\n }}\n ></div>\n <div\n className=\"absolute bg-gray-700\"\n style={{\n top: clickboxPoint.y - 5,\n left: clickboxPoint.x - 5,\n width: 10,\n height: 10,\n pointerEvents: \"none\",\n }}\n />\n </>\n );\n}\n\nexport function RangeProvider({\n children,\n}: {\n children: JSX.Element | JSX.Element[];\n}) {\n const { state, actions } = useRangeReducer();\n\n return (\n <RangeStateContext.Provider value={state}>\n <RangeActionContext.Provider value={actions}>\n <EffectSetMax />\n {children}\n </RangeActionContext.Provider>\n </RangeStateContext.Provider>\n );\n}\n"],"names":["RangeStateContext","createContext","isSelecting","RangeActionContext","setMax","NoImplementeFunction","startSelectRange","moveSelectRange","endSelectRange","moveUp","moveDown","moveLeft","moveRight","extendUp","extendDown","extendLeft","extendRight","reset","useRangeStateContext","useContext","useRangeActionContext","useRangeContext","__assign","EffectSetMax","_a","useTablePropertyStateContext","maxDisplayRowCount","maxDisplayColCount","useEffect","maxRowIndex","maxColIndex","_jsx","TestRange","props","state","endElement","document","getElementById","IdGenerator","getTableCellId","end","rowIndex","colIndex","scrollIntoView","behavior","block","inline","focus","rangeBox","start","clickboxPoint","xEnd","yEnd","_jsxs","className","concat","isCopied","style","top","left","width","height","pointerEvents","RangeProvider","children","_b","useRangeReducer","actions","Provider","value"],"mappings":"ibAOA,IAAMA,EAAoBC,EAAkC,CAC1DC,aAAa,IAGTC,EAAqBF,EAAmC,CAC5DG,OAAQC,EACRC,iBAAkBD,EAClBE,gBAAiBF,EACjBG,eAAgBH,EAChBI,OAAQJ,EACRK,SAAUL,EACVM,SAAUN,EACVO,UAAWP,EACXQ,SAAUR,EACVS,WAAYT,EACZU,WAAYV,EACZW,YAAaX,EACbY,MAAOZ,aAGOa,IACd,OAAOC,EAAWnB,EACpB,UAEgBoB,IACd,OAAOD,EAAWhB,EACpB,UAEgBkB,IACd,OAAAC,EAAAA,EAAA,CAAA,EAAYJ,KAA2BE,IACzC,CAEA,SAASG,IACC,IAAAnB,EAAWgB,WACbI,EACJC,IADMC,EAAkBF,EAAAE,mBAAEC,EAAkBH,EAAAG,mBAU9C,OAPAC,GAAU,WACRxB,EAAO,CACLyB,YAAaH,EAAqB,EAClCI,YAAaH,EAAqB,GAEtC,GAAG,CAACD,EAAoBC,IAEjBI,OACT,CAEM,SAAUC,EAAUC,GACxB,IAAMC,EAAQhB,IAmBd,GAjBAU,GAAU,WACR,GAAIM,EAAMhC,YAAa,CACrB,IAAMiC,EAAaC,SAASC,eAC1BC,EAAYC,eAAeL,EAAMM,IAAIC,SAAUP,EAAMM,IAAIE,WAGvDP,IACFA,EAAWQ,eAAe,CACxBC,SAAU,SACVC,MAAO,UACPC,OAAQ,YAEVX,EAAWY,QAEd,CACH,GAAG,CAACb,KAECA,EAAMhC,YACT,OAAO6B,QAGD,IAAAiB,EAAyBd,EAAKc,SAApBC,EAAef,EAAKe,MAAbT,EAAQN,MAE3BgB,EACDD,EAAME,KAAOX,EAAIW,KAAOX,EAAIW,KAAOF,EAAME,KADxCD,EAEDD,EAAMG,KAAOZ,EAAIY,KAAOZ,EAAIY,KAAOH,EAAMG,KAG9C,OACEC,eACEtB,EACE,MAAA,CAAAuB,UAAW,mCACTC,OAAAtB,EAAMuB,SAAW,gBAAkB,gBAErCC,MAAO,CACLC,IAAKV,EAASU,IACdC,KAAMX,EAASW,KACfC,MAAOZ,EAASY,MAChBC,OAAQb,EAASa,OACjBC,cAAe,UAGnB/B,EACE,MAAA,CAAAuB,UAAU,uBACVG,MAAO,CACLC,IAAKR,EAAkB,EACvBS,KAAMT,EAAkB,EACxBU,MAAO,GACPC,OAAQ,GACRC,cAAe,YAKzB,CAEM,SAAUC,EAAcvC,GAC5B,IAAAwC,EAAQxC,EAAAwC,SAIFC,EAAqBC,IAAnBhC,EAAK+B,EAAA/B,MAAEiC,EAAOF,EAAAE,QAEtB,OACEpC,EAAC/B,EAAkBoE,SAAS,CAAAC,MAAOnC,EACjC8B,SAAAX,EAAClD,EAAmBiE,SAAQ,CAACC,MAAOF,EAAOH,SAAA,CACzCjC,EAACR,EAAe,CAAA,GACfyC,MAIT"}
@@ -1,2 +1,2 @@
1
- import{jsxs as r,jsx as o}from"react/jsx-runtime";import{memo as t}from"react";import{useFocusActionContext as e}from"../focus/provider.js";import{Checkbox as i}from"../checkbox/components.js";import{TableCell as a}from"../cell/ui/cell.js";import{IdGenerator as n}from"../libs/id-generator.js";var l=t((function(t){var l=e().unfocus,c=JSON.parse(t.dataString),s=t.conditionalFormattingString.split(",");return r("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(t.onClickRow?"hover:cursor-pointer":""," ").concat(t.applyRowFormatting?t.applyRowFormatting(c):""),onClick:function(r){r.preventDefault(),t.onClickRow&&(t.onClickRow(c),l())},"data-testid":c.id,children:[t.existCheckbox&&o("td",{children:o(i,{row:c})}),t.cols.map((function(r,e){var i;return o(a,{id:n.getTableCellId(t.rowIndex,e),row:c,isExistOnClickRow:!!t.onClickRow,cellFormatClassName:s[e],editable:null!==(i=r.editable)&&void 0!==i&&i},r.key)}))]})}));export{l as Row};
1
+ import{jsxs as r,jsx as t}from"react/jsx-runtime";import{memo as e}from"react";import{Checkbox as o}from"../checkbox/components.js";import{TableCell as i}from"../cell/ui/cell.js";import{IdGenerator as a}from"../libs/id-generator.js";import{useRangeActionContext as n}from"../range/provider.js";var l=e((function(e){var l=n().reset,c=JSON.parse(e.dataString),s=e.conditionalFormattingString.split(",");return r("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(c):""),onClick:function(r){r.preventDefault(),e.onClickRow&&(e.onClickRow(c),l())},"data-testid":c.id,children:[e.existCheckbox&&t("td",{children:t(o,{row:c})}),e.cols.map((function(r,o){var n;return t(i,{id:a.getTableCellId(e.rowIndex,o),row:c,isExistOnClickRow:!!e.onClickRow,cellFormatClassName:s[o],editable:null!==(n=r.editable)&&void 0!==n&&n},r.key)}))]})}));export{l as Row};
2
2
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":["../../../../../src/table/sheet/components.tsx"],"sourcesContent":["import { memo } from \"react\";\nimport { useFocusActionContext } from \"../focus/provider\";\nimport { DataRecord, TTableColumn } from \"../table/type\";\nimport { Checkbox } from \"../checkbox/components\";\nimport { TableCell } from \"../cell/ui/cell\";\nimport { IdGenerator } from \"../libs\";\n\ninterface TPropsRow<T extends DataRecord> {\n dataString: string;\n cols: TTableColumn<T>[];\n existCheckbox?: boolean;\n rowIndex: number;\n conditionalFormattingString: string;\n onClickRow?: (row: any) => void;\n applyRowFormatting?: (row: any) => string;\n}\n\nexport const Row = memo(function R<T extends DataRecord>(props: TPropsRow<T>) {\n const { unfocus } = useFocusActionContext();\n const row = JSON.parse(props.dataString);\n const conditionalFormatting = props.conditionalFormattingString.split(\",\");\n\n return (\n <tr\n 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 ${\n !!props.onClickRow ? \"hover:cursor-pointer\" : \"\"\n } ${props.applyRowFormatting ? props.applyRowFormatting(row) : \"\"}`}\n onClick={(e) => {\n e.preventDefault();\n\n if (!!props.onClickRow) {\n props.onClickRow(row);\n unfocus();\n }\n }}\n data-testid={row.id}\n >\n {props.existCheckbox && (\n <td>\n <Checkbox row={row} />\n </td>\n )}\n {props.cols.map((col, j) => {\n return (\n <TableCell\n key={col.key as string}\n id={IdGenerator.getTableCellId(props.rowIndex, j)}\n row={row}\n isExistOnClickRow={!!props.onClickRow}\n cellFormatClassName={conditionalFormatting[j]}\n editable={col.editable ?? false}\n />\n );\n })}\n </tr>\n );\n});\n"],"names":["Row","memo","props","unfocus","useFocusActionContext","row","JSON","parse","dataString","conditionalFormatting","conditionalFormattingString","split","_jsxs","className","concat","onClickRow","applyRowFormatting","onClick","e","preventDefault","id","children","existCheckbox","_jsx","Checkbox","cols","map","col","j","TableCell","IdGenerator","getTableCellId","rowIndex","isExistOnClickRow","cellFormatClassName","editable","_a","key"],"mappings":"0SAiBaA,EAAMC,GAAK,SAAiCC,GAC/C,IAAAC,EAAYC,YACdC,EAAMC,KAAKC,MAAML,EAAMM,YACvBC,EAAwBP,EAAMQ,4BAA4BC,MAAM,KAEtE,OACEC,EACE,KAAA,CAAAC,UAAW,0JACTC,OAAEZ,EAAMa,WAAa,uBAAyB,GAC5C,KAAAD,OAAAZ,EAAMc,mBAAqBd,EAAMc,mBAAmBX,GAAO,IAC/DY,QAAS,SAACC,GACRA,EAAEC,iBAEIjB,EAAMa,aACVb,EAAMa,WAAWV,GACjBF,IAEH,EACY,cAAAE,EAAIe,GAEhBC,SAAA,CAAAnB,EAAMoB,eACLC,EACE,KAAA,CAAAF,SAAAE,EAACC,EAAS,CAAAnB,IAAKA,MAGlBH,EAAMuB,KAAKC,KAAI,SAACC,EAAKC,SACpB,OACEL,EAACM,EAAS,CAERT,GAAIU,EAAYC,eAAe7B,EAAM8B,SAAUJ,GAC/CvB,IAAKA,EACL4B,oBAAqB/B,EAAMa,WAC3BmB,oBAAqBzB,EAAsBmB,GAC3CO,SAAsB,UAAZR,EAAIQ,gBAAQ,IAAAC,GAAAA,GALjBT,EAAIU,UAWrB"}
1
+ {"version":3,"file":"components.js","sources":["../../../../../src/table/sheet/components.tsx"],"sourcesContent":["import { memo } from \"react\";\nimport { DataRecord, TTableColumn } from \"../table/type\";\nimport { Checkbox } from \"../checkbox/components\";\nimport { TableCell } from \"../cell/ui/cell\";\nimport { IdGenerator } from \"../libs\";\nimport { useRangeActionContext } from \"../range/provider\";\n\ninterface TPropsRow<T extends DataRecord> {\n dataString: string;\n cols: TTableColumn<T>[];\n existCheckbox?: boolean;\n rowIndex: number;\n conditionalFormattingString: string;\n onClickRow?: (row: any) => void;\n applyRowFormatting?: (row: any) => string;\n}\n\nexport const Row = memo(function R<T extends DataRecord>(props: TPropsRow<T>) {\n const { reset } = useRangeActionContext();\n const row = JSON.parse(props.dataString);\n const conditionalFormatting = props.conditionalFormattingString.split(\",\");\n\n return (\n <tr\n 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 ${\n !!props.onClickRow ? \"hover:cursor-pointer\" : \"\"\n } ${props.applyRowFormatting ? props.applyRowFormatting(row) : \"\"}`}\n onClick={(e) => {\n e.preventDefault();\n\n if (!!props.onClickRow) {\n props.onClickRow(row);\n reset();\n }\n }}\n data-testid={row.id}\n >\n {props.existCheckbox && (\n <td>\n <Checkbox row={row} />\n </td>\n )}\n {props.cols.map((col, j) => {\n return (\n <TableCell\n key={col.key as string}\n id={IdGenerator.getTableCellId(props.rowIndex, j)}\n row={row}\n isExistOnClickRow={!!props.onClickRow}\n cellFormatClassName={conditionalFormatting[j]}\n editable={col.editable ?? false}\n />\n );\n })}\n </tr>\n );\n});\n"],"names":["Row","memo","props","reset","useRangeActionContext","row","JSON","parse","dataString","conditionalFormatting","conditionalFormattingString","split","_jsxs","className","concat","onClickRow","applyRowFormatting","onClick","e","preventDefault","id","children","existCheckbox","_jsx","Checkbox","cols","map","col","j","TableCell","IdGenerator","getTableCellId","rowIndex","isExistOnClickRow","cellFormatClassName","editable","_a","key"],"mappings":"0SAiBaA,EAAMC,GAAK,SAAiCC,GAC/C,IAAAC,EAAUC,UACZC,EAAMC,KAAKC,MAAML,EAAMM,YACvBC,EAAwBP,EAAMQ,4BAA4BC,MAAM,KAEtE,OACEC,EACE,KAAA,CAAAC,UAAW,0JACTC,OAAEZ,EAAMa,WAAa,uBAAyB,GAC5C,KAAAD,OAAAZ,EAAMc,mBAAqBd,EAAMc,mBAAmBX,GAAO,IAC/DY,QAAS,SAACC,GACRA,EAAEC,iBAEIjB,EAAMa,aACVb,EAAMa,WAAWV,GACjBF,IAEH,EACY,cAAAE,EAAIe,GAEhBC,SAAA,CAAAnB,EAAMoB,eACLC,EACE,KAAA,CAAAF,SAAAE,EAACC,EAAS,CAAAnB,IAAKA,MAGlBH,EAAMuB,KAAKC,KAAI,SAACC,EAAKC,SACpB,OACEL,EAACM,EAAS,CAERT,GAAIU,EAAYC,eAAe7B,EAAM8B,SAAUJ,GAC/CvB,IAAKA,EACL4B,oBAAqB/B,EAAMa,WAC3BmB,oBAAqBzB,EAAsBmB,GAC3CO,SAAsB,UAAZR,EAAIQ,gBAAQ,IAAAC,GAAAA,GALjBT,EAAIU,UAWrB"}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{__assign as r}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as o,jsxs as e}from"react/jsx-runtime";import{useTable as t}from"./hook.js";import{TableHeaderElement as i}from"../header/header.js";import{PagenationProvider as n}from"../pagenation/providers.js";import{DisplayRange as l,Pagenation as a}from"../pagenation/components.js";import{FilterProvider as s}from"../filter/provider.js";import{TableFilterRemoveButton as d,TableFilterForm as c}from"../filter/components.js";import"../sort/icon.js";import{SortProvider as m}from"../sort/provider.js";import{ColumnsProvider as p}from"../sheet/providers.js";import{FocusProvider as h}from"../focus/provider.js";import{CheckboxProvider as f,CheckboxStatusProvider as g}from"../checkbox/provider.js";import{AllCheckbox as u}from"../checkbox/components.js";import{IdGenerator as v}from"../libs/id-generator.js";import{EditProvider as b}from"../edit/provider.js";import{TablePropertyProvider as w}from"../table-property/provider.js";import{KeyboardSetting as x}from"../operation/components/keyboard-setting.js";import{Row as j}from"../sheet/components.js";import{PasteProvider as y,usePasteActionContext as k}from"../paste/provider.js";import{generateFormattingString as N}from"../libs/conditional-formatting.js";import{Editor as C}from"../edit/ui/editor.js";import{useFilteringColumnStateContext as R}from"../filter/hooks/selectedFilteringColumn/provider.js";function F(t){var i,l,a;return o(s,{children:o(m,{initialCondition:null===(i=t.initialCondition)||void 0===i?void 0:i.sort,children:o(n,{rowCount:t.rows.length,perPage:null===(a=null===(l=t.initialCondition)||void 0===l?void 0:l.pagenation)||void 0===a?void 0:a.rowCountPerPage,children:o(f,{checkbox:t.checkbox,children:o(g,{checkboxCount:t.rows.length,children:o(p,{cols:t.cols,errorHandler:t.errorHandler,children:o(h,{children:o(b,{children:o(w,{children:e(y,{rows:t.rows,cols:t.cols,onUpdateRowFunction:t.onUpdateRow,children:[o(x,{}),o(P,r({},t))]})})})})})})})})})})}function P(r){var n=t(r),s=n.cols,m=n.rowMaps,p=n.pageRowIds,h=R(),f=k().onPaste;return e("div",{className:"w-full",children:[o("div",{className:"flex justify-end mb-1 mr-3",children:o(d,{children:o("p",{className:"text-xs underline text-gray-500 hover:text-gray-700",children:"全てのフィルタリング条件を解除する"})})}),e("div",{id:"table-frame",className:"relative h-full max-w-full max-h-[80vh] border border-gray-200 rounded-md overflow-auto",children:[o(C,{rowMaps:m,pageRowIds:p}),e("table",{className:"table",onPaste:function(r){r.preventDefault();var o=r.clipboardData.getData("Text");f(o.replace(/\t/g,",").trim().replace(/\r\n/g,"\n").split("\n").map((function(r){return r.split(",")})))},children:[o("thead",{children:e("tr",{className:"sticky top-0 border-gray-200 z-20 bg-gray-200 text-gray-600 h-[32px]",children:[r.checkbox&&o("th",{children:o(u,{rows:r.rows})}),s.map((function(r,e){return o(i,{id:v.getTableColId(e),col:r},r.key.toString())}))]})}),e("tbody",{children:[!!h&&o("tr",{children:o("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:o(c,{})})}),0===p.length&&o("tr",{children:o("td",{colSpan:s.length,className:"py-5",children:o("p",{className:"text-center font-bold text-lg",children:"NO DATA"})})}),p.map((function(e,t){return o(j,{existCheckbox:!!r.checkbox,rowIndex:t,dataString:m[e].stringValue,cols:r.cols,onClickRow:r.onClickRow,applyRowFormatting:r.applyRowFormatting,conditionalFormattingString:N(m[e].data,s,r.conditionalFormattings)},e)}))]})]})]}),e("div",{className:"mt-1",children:[o(l,{}),o("div",{className:"mt-2",children:o(a,{})})]})]})}export{F as default};
2
+ import{__assign as o}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as r,jsxs as e}from"react/jsx-runtime";import{useTable as t}from"./hook.js";import{TableHeaderElement as i}from"../header/header.js";import{PagenationProvider as n}from"../pagenation/providers.js";import{DisplayRange as l,Pagenation as a}from"../pagenation/components.js";import{FilterProvider as s}from"../filter/provider.js";import{TableFilterRemoveButton as d,TableFilterForm as c}from"../filter/components.js";import"../sort/icon.js";import{SortProvider as m}from"../sort/provider.js";import{ColumnsProvider as p}from"../sheet/providers.js";import{CheckboxProvider as h,CheckboxStatusProvider as f}from"../checkbox/provider.js";import{AllCheckbox as g}from"../checkbox/components.js";import{IdGenerator as u}from"../libs/id-generator.js";import{EditProvider as v}from"../edit/provider.js";import{TablePropertyProvider as b}from"../table-property/provider.js";import{KeyboardSetting as w}from"../operation/components/keyboard-setting.js";import{Row as j}from"../sheet/components.js";import{PasteProvider as x,usePasteActionContext as k}from"../paste/provider.js";import{generateFormattingString as y}from"../libs/conditional-formatting.js";import{Editor as C}from"../edit/ui/editor.js";import{useFilteringColumnStateContext as N}from"../filter/hooks/selectedFilteringColumn/provider.js";import{RangeProvider as R,useRangeActionContext as P,TestRange as F}from"../range/provider.js";import{CopyProvider as I}from"../copy/provider.js";function S(t){var i,l,a;return r(s,{children:r(m,{initialCondition:null===(i=t.initialCondition)||void 0===i?void 0:i.sort,children:r(n,{rowCount:t.rows.length,perPage:null===(a=null===(l=t.initialCondition)||void 0===l?void 0:l.pagenation)||void 0===a?void 0:a.rowCountPerPage,children:r(h,{checkbox:t.checkbox,children:r(f,{checkboxCount:t.rows.length,children:r(p,{cols:t.cols,errorHandler:t.errorHandler,children:r(v,{children:r(b,{children:r(R,{children:r(I,{rows:t.rows,cols:t.cols,children:e(x,{rows:t.rows,cols:t.cols,onUpdateRowFunction:t.onUpdateRow,children:[r(w,{}),r(D,o({},t))]})})})})})})})})})})})}function D(o){var n=t(o),s=n.cols,m=n.rowMaps,p=n.pageRowIds,h=N(),f=P().reset,v=k().onPaste;return e("div",{className:"w-full",children:[r("div",{className:"flex justify-end mb-1 mr-3",children:r(d,{children:r("p",{className:"text-xs underline text-gray-500 hover:text-gray-700",children:"全てのフィルタリング条件を解除する"})})}),e("div",{id:u.getTableId(),className:"relative h-full max-w-full max-h-[80vh] border border-gray-200 rounded-md overflow-auto",children:[r(F,{}),r(C,{rowMaps:m,pageRowIds:p}),e("table",{className:"table",onPaste:function(o){o.preventDefault();var r=o.clipboardData.getData("Text");v(r.replace(/\t/g,",").trim().replace(/\r\n/g,"\n").split("\n").map((function(o){return o.split(",")})))},children:[r("thead",{children:e("tr",{className:"sticky top-0 border-gray-200 z-20 bg-gray-200 text-gray-600 h-[32px]",onClick:function(o){o.stopPropagation(),f()},children:[o.checkbox&&r("th",{children:r(g,{rows:o.rows})}),s.map((function(o,e){return r(i,{id:u.getTableColId(e),col:o},o.key.toString())}))]})}),e("tbody",{children:[!!h&&r("tr",{onClick:function(o){o.stopPropagation(),f()},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(c,{})})}),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(e,t){return r(j,{existCheckbox:!!o.checkbox,rowIndex:t,dataString:m[e].stringValue,cols:o.cols,onClickRow:o.onClickRow,applyRowFormatting:o.applyRowFormatting,conditionalFormattingString:y(m[e].data,s,o.conditionalFormattings)},e)}))]})]})]}),e("div",{className:"mt-1",children:[r(l,{}),r("div",{className:"mt-2",children:r(a,{})})]})]})}export{S as default};
3
3
  //# sourceMappingURL=base.js.map
@@ -1,2 +1,2 @@
1
- import{useMemo as r,useEffect as t}from"react";import{usePageContext as o}from"../pagenation/providers.js";import"react/jsx-runtime";import{useFilterContext as e}from"../filter/provider.js";import"../filter/constants.js";import"../sheet/providers.js";import"../filter/hooks/selectedFilteringColumn/provider.js";import{useCheckboxStatusContext as n}from"../checkbox/provider.js";import{useSortActionContext as i,useSortTimingContext as s}from"../sort/provider.js";import{useTablePropertyActionContext as c}from"../table-property/provider.js";import{usePasteActionContext as u}from"../paste/provider.js";function a(a){var p=e().filter,f=i(),l=f.sort,d=f.updatedData,m=s(),h=o(),v=h.setRowCount,g=h.pageFilter,w=n().dispatchCheckboxStatus,j=u().setRows,k=c(),x=k.setMaxDisplayColCount,b=k.setMaxDisplayRowCount,y=r((function(){return p(a.rows)}),[p,m,a.rows.length]);t((function(){v(y.length)}),[y.length]);var C=r((function(){return a.checkbox?a.rows.filter((function(r){var t;return null===(t=a.checkbox)||void 0===t?void 0:t.checked(r)})):[]}),[a.checkbox,a.rows]);t((function(){w({type:"SET",payload:{checkedRecords:C}})}),[C]);var R=r((function(){return l(y)}),[y,m]);t((function(){d()}),[a.rows]);var S=r((function(){return g(R)}),[g,R]),D=r((function(){return S.map((function(r){return r.id}))}),[S]),M=r((function(){return new Set(D)}),[D]),F=r((function(){return a.rows.filter((function(r){return M.has(r.id)})).reduce((function(r,t){var o=Object.keys(t).sort().reduce((function(r,o){return r[o]=t[o],r}),{});return r[t.id]={data:o,stringValue:JSON.stringify(o)},r}),{})}),[a.rows,M]);return t((function(){x(a.cols.length)}),[a.cols.length]),t((function(){b(D.length)}),[D.length]),t((function(){j(D.map((function(r){return F[r].data})))}),[F]),{cols:a.cols,rowMaps:F,pageRowIds:D}}export{a as useTable};
1
+ import{useMemo as r,useEffect as t}from"react";import{usePageContext as o}from"../pagenation/providers.js";import"react/jsx-runtime";import{useFilterContext as e}from"../filter/provider.js";import"../filter/constants.js";import"../sheet/providers.js";import"../filter/hooks/selectedFilteringColumn/provider.js";import{useCheckboxStatusContext as n}from"../checkbox/provider.js";import{useSortActionContext as i,useSortTimingContext as s}from"../sort/provider.js";import{useTablePropertyActionContext as c}from"../table-property/provider.js";import{usePasteActionContext as u}from"../paste/provider.js";import{useCopyActionContext as p}from"../copy/provider.js";function a(a){var f=e().filter,l=i(),d=l.sort,m=l.updatedData,h=s(),v=o(),w=v.setRowCount,g=v.pageFilter,j=n().dispatchCheckboxStatus,k=u().setRows,x=p().setRows,y=c(),b=y.setMaxDisplayColCount,C=y.setMaxDisplayRowCount,R=r((function(){return f(a.rows)}),[f,h,a.rows.length]);t((function(){w(R.length)}),[R.length]);var S=r((function(){return a.checkbox?a.rows.filter((function(r){var t;return null===(t=a.checkbox)||void 0===t?void 0:t.checked(r)})):[]}),[a.checkbox,a.rows]);t((function(){j({type:"SET",payload:{checkedRecords:S}})}),[S]);var D=r((function(){return d(R)}),[R,h]);t((function(){m()}),[a.rows]);var M=r((function(){return g(D)}),[g,D]),F=r((function(){return M.map((function(r){return r.id}))}),[M]),O=r((function(){return new Set(F)}),[F]),E=r((function(){return a.rows.filter((function(r){return O.has(r.id)})).reduce((function(r,t){var o=Object.keys(t).sort().reduce((function(r,o){return r[o]=t[o],r}),{});return r[t.id]={data:o,stringValue:JSON.stringify(o)},r}),{})}),[a.rows,O]);return t((function(){b(a.cols.length)}),[a.cols.length]),t((function(){C(F.length)}),[F.length]),t((function(){var r=F.map((function(r){return E[r].data}));x(r),k(r)}),[E]),{cols:a.cols,rowMaps:E,pageRowIds:F}}export{a as useTable};
2
2
  //# sourceMappingURL=hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook.js","sources":["../../../../../src/table/table/hook.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { DataObject, DataRecord, TPropsTable } from \"./type\";\nimport { usePageContext } from \"../pagenation/providers\";\nimport { useFilterContext } from \"../filter\";\nimport { useCheckboxStatusContext } from \"../checkbox/provider\";\nimport { useSortActionContext, useSortTimingContext } from \"../sort/provider\";\nimport { useTablePropertyActionContext } from \"../table-property/provider\";\nimport { usePasteActionContext } from \"../paste/provider\";\n\nexport function useTable<T extends DataRecord>(props: TPropsTable<T>) {\n const { filter } = useFilterContext();\n const { sort, updatedData } = useSortActionContext();\n const sortTiming = useSortTimingContext();\n const { setRowCount, pageFilter } = usePageContext();\n const { dispatchCheckboxStatus } = useCheckboxStatusContext();\n const { setRows } = usePasteActionContext();\n const { setMaxDisplayColCount, setMaxDisplayRowCount } =\n useTablePropertyActionContext();\n\n const filteredRows = useMemo(\n () => filter(props.rows),\n [filter, sortTiming, props.rows.length]\n );\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(\n () => sort(filteredRows),\n [filteredRows, sortTiming]\n );\n\n useEffect(() => {\n updatedData();\n }, [props.rows]);\n\n const pageRows = useMemo(\n () => pageFilter(sortedRows),\n [pageFilter, sortedRows]\n );\n\n const pageRowIds = useMemo(() => pageRows.map((row) => row.id), [pageRows]);\n const pageRowIdSets = useMemo(() => new Set(pageRowIds), [pageRowIds]);\n\n const rowMaps = useMemo(\n () =>\n props.rows\n .filter((row) => pageRowIdSets.has(row.id))\n .reduce((acc, row) => {\n const rowSortedByKey = Object.keys(row)\n .sort()\n .reduce((acc, key) => {\n acc[key] = row[key];\n return acc;\n }, {} as { [key: string]: string | number });\n\n acc[row.id] = {\n data: rowSortedByKey,\n stringValue: JSON.stringify(rowSortedByKey),\n };\n return acc;\n }, {} as { [id: string | number]: { data: DataObject<any>; stringValue: string } }),\n [props.rows, pageRowIdSets]\n );\n\n useEffect(() => {\n setMaxDisplayColCount(props.cols.length);\n }, [props.cols.length]);\n\n useEffect(() => {\n setMaxDisplayRowCount(pageRowIds.length);\n }, [pageRowIds.length]);\n\n useEffect(() => {\n setRows(pageRowIds.map((id) => rowMaps[id].data));\n }, [rowMaps]);\n\n return {\n cols: props.cols,\n rowMaps,\n pageRowIds,\n };\n}\n"],"names":["useTable","props","filter","useFilterContext","_a","useSortActionContext","sort","updatedData","sortTiming","useSortTimingContext","_b","usePageContext","setRowCount","pageFilter","dispatchCheckboxStatus","useCheckboxStatusContext","setRows","usePasteActionContext","_c","useTablePropertyActionContext","setMaxDisplayColCount","setMaxDisplayRowCount","filteredRows","useMemo","rows","length","useEffect","checkBoxes","checkbox","row","checked","type","payload","checkedRecords","sortedRows","pageRows","pageRowIds","map","id","pageRowIdSets","Set","rowMaps","has","reduce","acc","rowSortedByKey","Object","keys","key","data","stringValue","JSON","stringify","cols"],"mappings":"0lBASM,SAAUA,EAA+BC,GACrC,IAAAC,EAAWC,WACbC,EAAwBC,IAAtBC,EAAIF,EAAAE,KAAEC,EAAWH,EAAAG,YACnBC,EAAaC,IACbC,EAA8BC,IAA5BC,EAAWF,EAAAE,YAAEC,EAAUH,EAAAG,WACvBC,EAA2BC,2BAC3BC,EAAYC,YACdC,EACJC,IADMC,EAAqBF,EAAAE,sBAAEC,EAAqBH,EAAAG,sBAG9CC,EAAeC,GACnB,WAAM,OAAArB,EAAOD,EAAMuB,KAAK,GACxB,CAACtB,EAAQM,EAAYP,EAAMuB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L,EAAsBe,EAAWX,OACnC,GAAG,CAACW,EAAWX,SAEfC,GAAU,WACRV,EAAQoB,EAAWC,KAAI,SAACC,GAAO,OAAAG,EAAQH,GAAIW,QAC7C,GAAG,CAACR,IAEG,CACLY,KAAMpD,EAAMoD,KACZZ,QAAOA,EACPL,WAAUA,EAEd"}
1
+ {"version":3,"file":"hook.js","sources":["../../../../../src/table/table/hook.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { DataObject, DataRecord, TPropsTable } from \"./type\";\nimport { usePageContext } from \"../pagenation/providers\";\nimport { useFilterContext } from \"../filter\";\nimport { useCheckboxStatusContext } from \"../checkbox/provider\";\nimport { useSortActionContext, useSortTimingContext } from \"../sort/provider\";\nimport { useTablePropertyActionContext } from \"../table-property/provider\";\nimport { usePasteActionContext } from \"../paste/provider\";\nimport { useCopyActionContext } from \"../copy/provider\";\n\nexport function useTable<T extends DataRecord>(props: TPropsTable<T>) {\n const { filter } = useFilterContext();\n const { sort, updatedData } = useSortActionContext();\n const sortTiming = useSortTimingContext();\n const { setRowCount, pageFilter } = usePageContext();\n const { dispatchCheckboxStatus } = useCheckboxStatusContext();\n const { setRows: setRowsForPaste } = usePasteActionContext();\n const { setRows: setRowsForCopy } = useCopyActionContext();\n const { setMaxDisplayColCount, setMaxDisplayRowCount } =\n useTablePropertyActionContext();\n\n const filteredRows = useMemo(\n () => filter(props.rows),\n [filter, sortTiming, props.rows.length]\n );\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(\n () => sort(filteredRows),\n [filteredRows, sortTiming]\n );\n\n useEffect(() => {\n updatedData();\n }, [props.rows]);\n\n const pageRows = useMemo(\n () => pageFilter(sortedRows),\n [pageFilter, sortedRows]\n );\n\n const pageRowIds = useMemo(() => pageRows.map((row) => row.id), [pageRows]);\n const pageRowIdSets = useMemo(() => new Set(pageRowIds), [pageRowIds]);\n\n const rowMaps = useMemo(\n () =>\n props.rows\n .filter((row) => pageRowIdSets.has(row.id))\n .reduce((acc, row) => {\n const rowSortedByKey = Object.keys(row)\n .sort()\n .reduce((acc, key) => {\n acc[key] = row[key];\n return acc;\n }, {} as { [key: string]: string | number });\n\n acc[row.id] = {\n data: rowSortedByKey,\n stringValue: JSON.stringify(rowSortedByKey),\n };\n return acc;\n }, {} as { [id: string | number]: { data: DataObject<any>; stringValue: string } }),\n [props.rows, pageRowIdSets]\n );\n\n useEffect(() => {\n setMaxDisplayColCount(props.cols.length);\n }, [props.cols.length]);\n\n useEffect(() => {\n setMaxDisplayRowCount(pageRowIds.length);\n }, [pageRowIds.length]);\n\n useEffect(() => {\n const rows = pageRowIds.map((id) => rowMaps[id].data);\n setRowsForCopy(rows);\n setRowsForPaste(rows);\n }, [rowMaps]);\n\n return {\n cols: props.cols,\n rowMaps,\n pageRowIds,\n };\n}\n"],"names":["useTable","props","filter","useFilterContext","_a","useSortActionContext","sort","updatedData","sortTiming","useSortTimingContext","_b","usePageContext","setRowCount","pageFilter","dispatchCheckboxStatus","useCheckboxStatusContext","setRowsForPaste","usePasteActionContext","setRowsForCopy","useCopyActionContext","_c","useTablePropertyActionContext","setMaxDisplayColCount","setMaxDisplayRowCount","filteredRows","useMemo","rows","length","useEffect","checkBoxes","checkbox","row","checked","type","payload","checkedRecords","sortedRows","pageRows","pageRowIds","map","id","pageRowIdSets","Set","rowMaps","has","reduce","acc","rowSortedByKey","Object","keys","key","data","stringValue","JSON","stringify","cols"],"mappings":"qpBAUM,SAAUA,EAA+BC,GACrC,IAAAC,EAAWC,WACbC,EAAwBC,IAAtBC,EAAIF,EAAAE,KAAEC,EAAWH,EAAAG,YACnBC,EAAaC,IACbC,EAA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E,CAAwC,GAM7C,OAJAA,EAAIf,EAAIS,IAAM,CACZW,KAAMJ,EACNK,YAAaC,KAAKC,UAAUP,IAEvBD,CACR,GAAE,CAA+E,EAAC,GACvF,CAAC7C,EAAMyB,KAAMe,IAiBf,OAdAb,GAAU,WACRN,EAAsBrB,EAAMsD,KAAK5B,OAClC,GAAE,CAAC1B,EAAMsD,KAAK5B,SAEfC,GAAU,WACRL,EAAsBe,EAAWX,OACnC,GAAG,CAACW,EAAWX,SAEfC,GAAU,WACR,IAAMF,EAAOY,EAAWC,KAAI,SAACC,GAAO,OAAAG,EAAQH,GAAIW,IAAI,IACpDjC,EAAeQ,GACfV,EAAgBU,EAClB,GAAG,CAACiB,IAEG,CACLY,KAAMtD,EAAMsD,KACZZ,QAAOA,EACPL,WAAUA,EAEd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teppen/react-ui",
3
- "version": "1.5.16",
3
+ "version": "1.6.0",
4
4
  "description": "React UI Component",
5
5
  "main": "dist/cjs/src/index.js",
6
6
  "module": "dist/esm/src/index.js",
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),o=require("react"),n=require("../libs/id-generator.js"),t=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.__assign(e.__assign({},o),{colIndex:o.colIndex-1}):o;case"moveRight":return o.isFocus?e.__assign(e.__assign({},o),{colIndex:o.colIndex+1}):o;case"moveUp":return o.isFocus?e.__assign(e.__assign({},o),{rowIndex:o.rowIndex-1}):o;case"moveDown":return o.isFocus?e.__assign(e.__assign({},o),{rowIndex:o.rowIndex+1}):o}};exports.useFocusReducer=function(){var e=o.useReducer(t,{isFocus:!1}),s=e[0],u=e[1],c=o.useMemo((function(){return{focus:function(e,o){u({type:"focus",payload:{rowIndex:e,colIndex:o}})},unfocus:function(){u({type:"unfocus"})},move:function(e,o){u({type:"move",payload:{rowIndex:e,colIndex:o}})},moveLeft:function(){u({type:"moveLeft"})},moveRight:function(){u({type:"moveRight"})},moveUp:function(){u({type:"moveUp"})},moveDown:function(){u({type:"moveDown"})}}}),[]);return o.useEffect((function(){var e=function(e){var o=document.getElementById("table-frame"),n=e.target;n instanceof Node&&(null==o?void 0:o.contains(n))||c.unfocus()};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]),o.useEffect((function(){if(s.isFocus){var e=document.getElementById(n.IdGenerator.getTableCellId(s.rowIndex,s.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(s.isFocus){var e=document.getElementById(n.IdGenerator.getTableCellId(s.rowIndex,s.colIndex));null==e||e.style.setProperty("outline-style","none")}}}),[s]),{state:s,actions:c}};
2
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.js","sources":["../../../../../src/table/focus/hooks.ts"],"sourcesContent":["import { useEffect, useMemo, 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 actions = useMemo(\n () => ({\n focus: (rowIndex: number, colIndex: number) => {\n dispatch({ type: \"focus\", payload: { rowIndex, colIndex } });\n },\n unfocus: () => {\n dispatch({ type: \"unfocus\" });\n },\n move: (rowIndex: number, colIndex: number) => {\n dispatch({ type: \"move\", payload: { rowIndex, colIndex } });\n },\n moveLeft: () => {\n dispatch({ type: \"moveLeft\" });\n },\n moveRight: () => {\n dispatch({ type: \"moveRight\" });\n },\n moveUp: () => {\n dispatch({ type: \"moveUp\" });\n },\n moveDown: () => {\n dispatch({ type: \"moveDown\" });\n },\n }),\n []\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 actions.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 return {\n state,\n actions,\n };\n}\n"],"names":["reducer","state","action","type","isFocus","rowIndex","payload","colIndex","__assign","_a","useReducer","dispatch","actions","useMemo","focus","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":"+HAIMA,EAAyB,SAACC,EAAOC,GACrC,OAAQA,EAAOC,MACb,IAAK,QACH,OAAIF,EAAMG,QACDH,EAGF,CACLG,SAAS,EACTC,SAAUH,EAAOI,QAAQD,SACzBE,SAAUL,EAAOI,QAAQC,UAE7B,IAAK,UACH,OAAKN,EAAMG,QAIJ,CACLA,SAAS,GAJFH,EAMX,IAAK,OACH,OAAKA,EAAMG,QAIJ,CACLA,SAAS,EACTC,SAAUH,EAAOI,QAAQD,SACzBE,SAAUL,EAAOI,QAAQC,UANlBN,EAQX,IAAK,WACH,OAAKA,EAAMG,QAKNI,WAAAA,EAAAA,SAAA,CAAA,EAAAP,IACHM,SAAUN,EAAMM,SAAW,IALpBN,EAOX,IAAK,YACH,OAAKA,EAAMG,QAKNI,WAAAA,EAAAA,SAAA,CAAA,EAAAP,IACHM,SAAUN,EAAMM,SAAW,IALpBN,EAOX,IAAK,SACH,OAAKA,EAAMG,QAKNI,WAAAA,EAAAA,SAAA,CAAA,EAAAP,IACHI,SAAUJ,EAAMI,SAAW,IALpBJ,EAOX,IAAK,WACH,OAAKA,EAAMG,QAKNI,WAAAA,EAAAA,SAAA,CAAA,EAAAP,IACHI,SAAUJ,EAAMI,SAAW,IALpBJ,EAQf,qCAGQ,IAAAQ,EAAoBC,EAAUA,WAACV,EAAS,CAC5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nDiB,SAAAA,EAASW,MAAMC,YAAY,gBAAiB,OAC7C,CACH,CACF,GAAG,CAACnC,IAEG,CACLA,MAAKA,EACLW,QAAOA,EAEX"}
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("./hooks.js"),u=o.createContext({isFocus:!1}),r=o.createContext({focus:function(){},unfocus:function(){},move:function(){},moveLeft:function(){},moveRight:function(){},moveUp:function(){},moveDown:function(){}});function s(){return o.useContext(u)}function i(){return o.useContext(r)}exports.FocusProvider=function(e){var o=n.useFocusReducer(),s=o.state,i=o.actions;return t.jsx(u.Provider,{value:s,children:t.jsx(r.Provider,{value:i,children:e.children})})},exports.useFocusActionContext=i,exports.useFocusContext=function(){return e.__assign(e.__assign({},s()),i())},exports.useFocusStateContext=s;
2
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sources":["../../../../../src/table/focus/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { TFocusActionContext, TFocusStateContext } from \"./types\";\nimport { useFocusReducer } from \"./hooks\";\n\nconst FocusStateContext = createContext<TFocusStateContext>({\n isFocus: false,\n});\n\nconst FocusActionContext = createContext<TFocusActionContext>({\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 { state, actions } = useFocusReducer();\n\n return (\n <FocusStateContext.Provider value={state}>\n <FocusActionContext.Provider value={actions}>\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","useFocusStateContext","useContext","useFocusActionContext","props","_a","useFocusReducer","state","actions","_jsx","Provider","value","children","__assign"],"mappings":"iJAIMA,EAAoBC,EAAAA,cAAkC,CAC1DC,SAAS,IAGLC,EAAqBF,EAAAA,cAAmC,CAC5DG,MAAO,WAAQ,EACfC,QAAS,WAAQ,EACjBC,KAAM,WAAQ,EACdC,SAAU,WAAQ,EAClBC,UAAW,WAAQ,EACnBC,OAAQ,WAAQ,EAChBC,SAAU,WAAQ,aAeJC,IACd,OAAOC,EAAAA,WAAWZ,EACpB,UAEgBa,IACd,OAAOD,EAAAA,WAAWT,EACpB,uBAlBM,SAAwBW,GACtB,IAAAC,EAAqBC,EAAeA,kBAAlCC,EAAKF,EAAAE,MAAEC,EAAOH,EAAAG,QAEtB,OACEC,EAAAA,IAACnB,EAAkBoB,UAASC,MAAOJ,EAAKK,SACtCH,MAAChB,EAAmBiB,SAAQ,CAACC,MAAOH,EAAOI,SACxCR,EAAMQ,YAIf,qEAWE,OAAAC,EAAAA,SAAAA,EAAAA,SAAA,CAAA,EAAYZ,KAA2BE,IACzC"}
@@ -1,2 +0,0 @@
1
- import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as o,useMemo as n,useEffect as t}from"react";import{IdGenerator as c}from"../libs/id-generator.js";var s=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 r(){var e=o(s,{isFocus:!1}),r=e[0],u=e[1],l=n((function(){return{focus:function(e,o){u({type:"focus",payload:{rowIndex:e,colIndex:o}})},unfocus:function(){u({type:"unfocus"})},move:function(e,o){u({type:"move",payload:{rowIndex:e,colIndex:o}})},moveLeft:function(){u({type:"moveLeft"})},moveRight:function(){u({type:"moveRight"})},moveUp:function(){u({type:"moveUp"})},moveDown:function(){u({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))||l.unfocus()};return document.addEventListener("click",e),function(){document.removeEventListener("click",e)}}),[]),t((function(){if(r.isFocus){var e=document.getElementById(c.getTableCellId(r.rowIndex,r.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(r.isFocus){var e=document.getElementById(c.getTableCellId(r.rowIndex,r.colIndex));null==e||e.style.setProperty("outline-style","none")}}}),[r]),{state:r,actions:l}}export{r as useFocusReducer};
2
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.js","sources":["../../../../../src/table/focus/hooks.ts"],"sourcesContent":["import { useEffect, useMemo, 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 actions = useMemo(\n () => ({\n focus: (rowIndex: number, colIndex: number) => {\n dispatch({ type: \"focus\", payload: { rowIndex, colIndex } });\n },\n unfocus: () => {\n dispatch({ type: \"unfocus\" });\n },\n move: (rowIndex: number, colIndex: number) => {\n dispatch({ type: \"move\", payload: { rowIndex, colIndex } });\n },\n moveLeft: () => {\n dispatch({ type: \"moveLeft\" });\n },\n moveRight: () => {\n dispatch({ type: \"moveRight\" });\n },\n moveUp: () => {\n dispatch({ type: \"moveUp\" });\n },\n moveDown: () => {\n dispatch({ type: \"moveDown\" });\n },\n }),\n []\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 actions.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 return {\n state,\n actions,\n };\n}\n"],"names":["reducer","state","action","type","isFocus","rowIndex","payload","colIndex","__assign","useFocusReducer","_a","useReducer","dispatch","actions","useMemo","focus","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":"yLAIA,IAAMA,EAAyB,SAACC,EAAOC,GACrC,OAAQA,EAAOC,MACb,IAAK,QACH,OAAIF,EAAMG,QACDH,EAGF,CACLG,SAAS,EACTC,SAAUH,EAAOI,QAAQD,SACzBE,SAAUL,EAAOI,QAAQC,UAE7B,IAAK,UACH,OAAKN,EAAMG,QAIJ,CACLA,SAAS,GAJFH,EAMX,IAAK,OACH,OAAKA,EAAMG,QAIJ,CACLA,SAAS,EACTC,SAAUH,EAAOI,QAAQD,SACzBE,SAAUL,EAAOI,QAAQC,UANlBN,EAQX,IAAK,WACH,OAAKA,EAAMG,QAKNI,EAAAA,EAAA,CAAA,EAAAP,IACHM,SAAUN,EAAMM,SAAW,IALpBN,EAOX,IAAK,YACH,OAAKA,EAAMG,QAKNI,EAAAA,EAAA,CAAA,EAAAP,IACHM,SAAUN,EAAMM,SAAW,IALpBN,EAOX,IAAK,SACH,OAAKA,EAAMG,QAKNI,EAAAA,EAAA,CAAA,EAAAP,IACHI,SAAUJ,EAAMI,SAAW,IALpBJ,EAOX,IAAK,WACH,OAAKA,EAAMG,QAKNI,EAAAA,EAAA,CAAA,EAAAP,IACHI,SAAUJ,EAAMI,SAAW,IALpBJ,EAQf,WAEgBQ,IACR,IAAAC,EAAoBC,EAAWX,EAAS,CAC5CI,SAAS,IADJH,EAAKS,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B,OAC7C,CACH,CACF,GAAG,CAACpC,IAEG,CACLA,MAAKA,EACLY,QAAOA,EAEX"}
@@ -1,2 +0,0 @@
1
- import{__assign as o}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as n}from"react/jsx-runtime";import{createContext as t,useContext as r}from"react";import{useFocusReducer as i}from"./hooks.js";var e=t({isFocus:!1}),u=t({focus:function(){},unfocus:function(){},move:function(){},moveLeft:function(){},moveRight:function(){},moveUp:function(){},moveDown:function(){}});function c(o){var t=i(),r=t.state,c=t.actions;return n(e.Provider,{value:r,children:n(u.Provider,{value:c,children:o.children})})}function f(){return r(e)}function m(){return r(u)}function s(){return o(o({},f()),m())}export{c as FocusProvider,m as useFocusActionContext,s as useFocusContext,f as useFocusStateContext};
2
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sources":["../../../../../src/table/focus/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { TFocusActionContext, TFocusStateContext } from \"./types\";\nimport { useFocusReducer } from \"./hooks\";\n\nconst FocusStateContext = createContext<TFocusStateContext>({\n isFocus: false,\n});\n\nconst FocusActionContext = createContext<TFocusActionContext>({\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 { state, actions } = useFocusReducer();\n\n return (\n <FocusStateContext.Provider value={state}>\n <FocusActionContext.Provider value={actions}>\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","_a","useFocusReducer","state","actions","_jsx","Provider","value","children","useFocusStateContext","useContext","useFocusActionContext","useFocusContext","__assign"],"mappings":"+MAIA,IAAMA,EAAoBC,EAAkC,CAC1DC,SAAS,IAGLC,EAAqBF,EAAmC,CAC5DG,MAAO,WAAQ,EACfC,QAAS,WAAQ,EACjBC,KAAM,WAAQ,EACdC,SAAU,WAAQ,EAClBC,UAAW,WAAQ,EACnBC,OAAQ,WAAQ,EAChBC,SAAU,WAAQ,IAGd,SAAUC,EAAcC,GACtB,IAAAC,EAAqBC,IAAnBC,EAAKF,EAAAE,MAAEC,EAAOH,EAAAG,QAEtB,OACEC,EAACjB,EAAkBkB,UAASC,MAAOJ,EAAKK,SACtCH,EAACd,EAAmBe,SAAQ,CAACC,MAAOH,EAAOI,SACxCR,EAAMQ,YAIf,UAEgBC,IACd,OAAOC,EAAWtB,EACpB,UAEgBuB,IACd,OAAOD,EAAWnB,EACpB,UAEgBqB,IACd,OAAAC,EAAAA,EAAA,CAAA,EAAYJ,KAA2BE,IACzC"}