@teppen/react-ui 1.5.5 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/icon/cancel-icon.js.map +1 -0
- package/dist/cjs/src/icon/edit-icon.js.map +1 -0
- package/dist/cjs/src/table/base.js +1 -1
- package/dist/cjs/src/table/cell/ui/cell.js +1 -1
- package/dist/cjs/src/table/cell/ui/edit-button.js +1 -1
- package/dist/cjs/src/table/checkbox/components.js +1 -1
- package/dist/cjs/src/table/edit/ui/base-input.js +3 -0
- package/dist/cjs/src/table/edit/ui/number-input.js +1 -1
- package/dist/cjs/src/table/edit/ui/select-input.js +1 -1
- package/dist/cjs/src/table/edit/ui/string-input.js +1 -1
- package/dist/cjs/src/table/filter/components.js +1 -1
- package/dist/cjs/src/table/filter/hooks/selectedFilteringColumn/hooks.js +2 -0
- package/dist/cjs/src/table/filter/hooks/selectedFilteringColumn/hooks.js.map +1 -0
- package/dist/cjs/src/table/filter/hooks/selectedFilteringColumn/provider.js +2 -0
- package/dist/cjs/src/table/filter/hooks/selectedFilteringColumn/provider.js.map +1 -0
- package/dist/cjs/src/table/filter/provider.js +1 -1
- package/dist/cjs/src/table/header/header.js +1 -1
- package/dist/cjs/src/table/header/resize-col-width-hook.js +1 -1
- package/dist/cjs/src/table/header/resize-col-width-hook.js.map +1 -1
- package/dist/cjs/src/table/hook.js +1 -1
- package/dist/cjs/src/table/hook.js.map +1 -1
- package/dist/cjs/src/table/paste/hooks.js +1 -1
- package/dist/cjs/src/table/paste/hooks.js.map +1 -1
- package/dist/cjs/src/table/paste/provider.js +1 -1
- package/dist/cjs/src/table/paste/provider.js.map +1 -1
- package/dist/cjs/src/table/sheet/components.js +1 -1
- package/dist/cjs/src/table/sheet/components.js.map +1 -1
- package/dist/cjs/src/table/sheet/providers.js +1 -1
- package/dist/esm/src/icon/cancel-icon.js.map +1 -0
- package/dist/esm/src/icon/edit-icon.js.map +1 -0
- package/dist/esm/src/table/base.js +1 -1
- package/dist/esm/src/table/cell/ui/cell.js +1 -1
- package/dist/esm/src/table/cell/ui/edit-button.js +1 -1
- package/dist/esm/src/table/checkbox/components.js +1 -1
- package/dist/esm/src/table/edit/ui/base-input.js +3 -0
- package/dist/esm/src/table/edit/ui/number-input.js +1 -1
- package/dist/esm/src/table/edit/ui/select-input.js +1 -1
- package/dist/esm/src/table/edit/ui/string-input.js +1 -1
- package/dist/esm/src/table/filter/components.js +1 -1
- package/dist/esm/src/table/filter/hooks/selectedFilteringColumn/hooks.js +2 -0
- package/dist/esm/src/table/filter/hooks/selectedFilteringColumn/hooks.js.map +1 -0
- package/dist/esm/src/table/filter/hooks/selectedFilteringColumn/provider.js +2 -0
- package/dist/esm/src/table/filter/hooks/selectedFilteringColumn/provider.js.map +1 -0
- package/dist/esm/src/table/filter/provider.js +1 -1
- package/dist/esm/src/table/header/header.js +1 -1
- package/dist/esm/src/table/header/resize-col-width-hook.js +1 -1
- package/dist/esm/src/table/header/resize-col-width-hook.js.map +1 -1
- package/dist/esm/src/table/hook.js +1 -1
- package/dist/esm/src/table/hook.js.map +1 -1
- package/dist/esm/src/table/paste/hooks.js +1 -1
- package/dist/esm/src/table/paste/hooks.js.map +1 -1
- package/dist/esm/src/table/paste/provider.js +1 -1
- package/dist/esm/src/table/paste/provider.js.map +1 -1
- package/dist/esm/src/table/sheet/components.js +1 -1
- package/dist/esm/src/table/sheet/components.js.map +1 -1
- package/dist/esm/src/table/sheet/providers.js +1 -1
- package/package.json +4 -6
- package/dist/cjs/src/table/cancel-icon.js.map +0 -1
- package/dist/cjs/src/table/cell/provider.js +0 -2
- package/dist/cjs/src/table/cell/provider.js.map +0 -1
- package/dist/cjs/src/table/cell/ui/base-input.js +0 -3
- package/dist/cjs/src/table/edit-icon.js.map +0 -1
- package/dist/esm/src/table/cancel-icon.js.map +0 -1
- package/dist/esm/src/table/cell/provider.js +0 -2
- package/dist/esm/src/table/cell/provider.js.map +0 -1
- package/dist/esm/src/table/cell/ui/base-input.js +0 -3
- package/dist/esm/src/table/edit-icon.js.map +0 -1
- /package/dist/cjs/src/{table → icon}/cancel-icon.js +0 -0
- /package/dist/cjs/src/{table → icon}/edit-icon.js +0 -0
- /package/dist/cjs/src/table/{cell → edit}/ui/base-input.js.map +0 -0
- /package/dist/esm/src/{table → icon}/cancel-icon.js +0 -0
- /package/dist/esm/src/{table → icon}/edit-icon.js +0 -0
- /package/dist/esm/src/table/{cell → edit}/ui/base-input.js.map +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-icon.js","sources":["../../../../src/icon/cancel-icon.tsx"],"sourcesContent":["import { MdOutlineCancel } from \"react-icons/md\";\n\ntype TPropsCancelIcon = {\n size: number;\n};\n\nexport function CancelIcon(props: TPropsCancelIcon) {\n return <MdOutlineCancel size={`${props.size}px`} />;\n}\n"],"names":["props","_jsx","MdOutlineCancel","size","concat"],"mappings":"2HAMM,SAAqBA,GACzB,OAAOC,MAACC,EAAAA,gBAAe,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-icon.js","sources":["../../../../src/icon/edit-icon.tsx"],"sourcesContent":["import { LiaEdit } from \"react-icons/lia\";\n\ntype TPropsEditIcon = {\n size: number;\n};\n\nexport function EditIcon(props: TPropsEditIcon) {\n return <LiaEdit size={`${props.size}px`} />;\n}\n"],"names":["props","_jsx","LiaEdit","size","concat"],"mappings":"0HAMM,SAAmBA,GACvB,OAAOC,MAACC,EAAAA,QAAO,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACzC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime"),o=require("./hook.js"),i=require("./header/header.js"),t=require("./pagenation/providers.js"),s=require("./pagenation/components.js"),n=require("./filter/provider.js"),l=require("./filter/components.js");require("./sort/icon.js");var a=require("./sort/provider.js"),d=require("./sheet/providers.js"),c=require("./focus/provider.js"),
|
|
2
|
+
"use strict";var e=require("../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime"),o=require("./hook.js"),i=require("./header/header.js"),t=require("./pagenation/providers.js"),s=require("./pagenation/components.js"),n=require("./filter/provider.js"),l=require("./filter/components.js");require("./sort/icon.js");var a=require("./sort/provider.js"),d=require("./sheet/providers.js"),c=require("./focus/provider.js"),u=require("./checkbox/provider.js"),x=require("./checkbox/components.js"),j=require("./libs/id-generator.js"),h=require("./edit/provider.js"),p=require("./table-property/provider.js"),g=require("./operation/components/keyboard-setting.js"),m=require("./sheet/components.js"),v=require("./paste/provider.js"),b=require("./libs/conditional-formatting.js"),w=require("./edit/ui/editor.js"),f=require("./filter/hooks/selectedFilteringColumn/provider.js");function q(e){var t=o.useTable(e),n=t.cols,a=t.rowMaps,d=t.pageRowIds,c=f.useFilteringColumnStateContext(),u=v.usePasteActionContext().onPaste;return r.jsxs("div",{className:"w-full",children:[r.jsx("div",{className:"flex justify-end mb-1 mr-3",children:r.jsx(l.TableFilterRemoveButton,{children:r.jsx("p",{className:"text-xs underline text-gray-500 hover:text-gray-700",children:"全てのフィルタリング条件を解除する"})})}),r.jsxs("div",{id:"table-frame",className:"relative h-full max-w-full max-h-[80vh] border border-gray-200 rounded-md overflow-auto",children:[r.jsx(w.Editor,{rowMaps:a,pageRowIds:d}),r.jsxs("table",{className:"table",onPaste:function(e){e.preventDefault();var r=e.clipboardData.getData("Text");u(r.replace(/\t/g,",").trim().replace(/\r\n/g,"\n").split("\n").map((function(e){return e.split(",")})))},children:[r.jsx("thead",{children:r.jsxs("tr",{className:"sticky top-0 border-gray-200 z-20 bg-gray-200 text-gray-600 h-[32px]",children:[e.checkbox&&r.jsx("th",{children:r.jsx(x.AllCheckbox,{rows:e.rows})}),n.map((function(e,o){return r.jsx(i.TableHeaderElement,{id:j.IdGenerator.getTableColId(o),col:e},e.key.toString())}))]})}),r.jsxs("tbody",{children:[!!c&&r.jsx("tr",{children:r.jsx("td",{colSpan:n.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.jsx(l.TableFilterForm,{})})}),0===d.length&&r.jsx("tr",{children:r.jsx("td",{colSpan:n.length,className:"py-5",children:r.jsx("p",{className:"text-center font-bold text-lg",children:"NO DATA"})})}),d.map((function(o,i){return r.jsx(m.Row,{existCheckbox:!!e.checkbox,rowIndex:i,dataString:a[o].stringValue,cols:e.cols,onClickRow:e.onClickRow,applyRowFormatting:e.applyRowFormatting,conditionalFormattingString:b.generateFormattingString(a[o].data,n,e.conditionalFormattings),onUpdateRow:e.onUpdateRow},o)}))]})]})]}),r.jsxs("div",{className:"mt-1",children:[r.jsx(s.DisplayRange,{}),r.jsx("div",{className:"mt-2",children:r.jsx(s.Pagenation,{})})]})]})}module.exports=function(o){var i,s,l;return r.jsx(n.FilterProvider,{children:r.jsx(a.SortProvider,{initialCondition:null===(i=o.initialCondition)||void 0===i?void 0:i.sort,children:r.jsx(t.PagenationProvider,{rowCount:o.rows.length,perPage:null===(l=null===(s=o.initialCondition)||void 0===s?void 0:s.pagenation)||void 0===l?void 0:l.rowCountPerPage,children:r.jsx(u.CheckboxProvider,{checkbox:o.checkbox,children:r.jsx(u.CheckboxStatusProvider,{checkboxCount:o.rows.length,children:r.jsx(d.ColumnsProvider,{cols:o.cols,errorHandler:o.errorHandler,children:r.jsx(c.FocusProvider,{children:r.jsx(h.EditProvider,{children:r.jsx(p.TablePropertyProvider,{children:r.jsxs(v.PasteProvider,{rows:o.rows,cols:o.cols,onUpdateRowFunction:o.onUpdateRow,children:[r.jsx(g.KeyboardSetting,{}),r.jsx(q,e.__assign({},o))]})})})})})})})})})})};
|
|
3
3
|
//# sourceMappingURL=base.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),l=require("../../hook.js"),
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),l=require("../../hook.js"),t=require("./edit-button.js"),i=require("../../libs/id-generator.js");exports.TableCell=function(o){var n=l.useCell(o.rowIndex,o.colIndex,o.row),r=n.type,s=n.component,c=n.focusAtCell,a=n.onDoubleClickCellToEdit,d=i.IdGenerator.getTableCellId(o.rowIndex,o.colIndex);return e.jsx("td",{id:d,className:"".concat(o.cellFormatClassName),children:e.jsx("div",{className:"relative",onClick:o.isExistOnClickRow?void 0:function(e){e.preventDefault(),c()},onDoubleClick:o.isExistOnClickRow?void 0:a,children:e.jsxs("div",{className:"flex items-center gap-3 w-f-displayit p-2 cursor-default",onClick:function(e){e.preventDefault(),e.stopPropagation(),c()},children:["component"===r?s:e.jsx("div",{onDoubleClick:a,children:e.jsx("p",{className:"cell-data text-left whitespace-nowrap",children:s})}),o.editable&&e.jsx(t.EditButton,{})]})})})};
|
|
3
3
|
//# sourceMappingURL=cell.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var t=require("react/jsx-runtime"),e=require("react"),r=require("../../edit/provider.js"),i=require("
|
|
2
|
+
"use strict";var t=require("react/jsx-runtime"),e=require("react"),r=require("../../edit/provider.js"),i=require("../../../icon/edit-icon.js"),n=e.memo((function(){var e=r.useEditActionContext().startEditing;return t.jsx("button",{className:"w-fit h-fit p-1 rounded-full text-gray-500 hover:bg-gray-200",onClick:function(t){t.preventDefault(),e()},children:t.jsx(i.EditIcon,{size:12})})}));exports.EditButton=n;
|
|
3
3
|
//# sourceMappingURL=edit-button.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("./provider.js"),c=t.memo((function(c){var r=n.useCheckboxContext(),o=n.useCheckboxStatusContext().checkboxStatusState,u=c.row,i=t.useMemo((function(){return o.checkedRecords.map((function(e){return e.id}))}),[o.checkedRecords]);return r?e.jsx("div",{className:"flex justify-center gap-1 w-full items-center",children:e.jsx("input",{type:"checkbox",checked:i.includes(u.id),onChange:function(e){e.preventDefault(),e.target.checked?r.onChecked(u):r.onUnchecked(u)},onClick:function(e){e.preventDefault(),e.stopPropagation()}})}):e.jsx(e.Fragment,{})})),r=t.memo((function(c){var r=t.useRef(null),o=n.useCheckboxContext(),u=n.useCheckboxStatusContext(),i=u.checkboxStatusState,s=u.existChecked,a=u.indeterminate,d=t.useMemo((function(){return i.checkedRecords.map((function(e){return e.id}))}),[i.checkedRecords]),f=t.useMemo((function(){return c.rows.filter((function(e){return!d.includes(e.id)}))}),[c.rows,d]);return t.useEffect((function(){null!=r.current&&(r.current.indeterminate=!0===a)}),[a]),o?e.jsx("div",{className:"grid place-items-center w-full px-1",children:e.jsx("input",{ref:r,type:"checkbox",checked:s,onChange:function(e){e.preventDefault(),e.target.checked?f.forEach((function(e){o.onChecked(e)})):i.checkedRecords.forEach((function(e){o.onUnchecked(e)}))},onClick:function(e){e.preventDefault(),e.stopPropagation()}})}):e.jsx(e.Fragment,{})}));exports.AllCheckbox=r,exports.Checkbox=c;
|
|
3
3
|
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),n=require("react"),t=require("../../../icon/cancel-icon.js");exports.CellInput=function(r){var u=n.useRef(null);return n.useEffect((function(){u.current&&u.current.focus()}),[u]),e.jsxs("div",{className:"flex justify-between gap-1 w-full items-center",onClick:function(e){e.preventDefault(),e.stopPropagation()},children:[e.jsx("input",{ref:u,className:"w-full py-1 px-2 bg-white text-gray-900",type:"text",value:r.value,onChange:r.onChange,onBlur:r.onBlur,onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(r.reset(),r.endEditing())}}),e.jsx("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){r.reset(),r.endEditing()}),300)},children:e.jsx(t.CancelIcon,{size:16})})]})};
|
|
3
|
+
//# sourceMappingURL=base-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../../sheet/providers.js"),u=require("
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../../sheet/providers.js"),u=require("./base-input.js"),n=require("../provider.js");exports.NumberCellInput=function(a){var i=a.col,o=r.useColumnValidateContext(i.key),l=n.useEditActionContext().endEditing,s=a.row[i.key],g=t.useState(s.toString()),v=g[0],c=g[1];return e.jsx(u.CellInput,{value:v,onChange:function(e){e.preventDefault(),""!==e.target.value?"-"!==e.target.value&&"0-"!==e.target.value?e.target.value.match(/^-?[0-9]+\.$/)?c(e.target.value):isNaN(Number(e.target.value))||c(Number(e.target.value).toString()):c("-0"):c("0")},onBlur:function(e){e.preventDefault(),Number(v)!==s?o(v)?function(e){i.editable&&i.onCellBlur(i.key,Number(e),a.row,l)}(v):setTimeout((function(){e.target.focus()}),100):l()},reset:function(){return c(s.toString())},endEditing:l})};
|
|
3
3
|
//# sourceMappingURL=number-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("../provider.js"),r=require("
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("../provider.js"),r=require("../../../icon/cancel-icon.js");exports.SelectCellInput=function(l){var o=l.col,i=n.useEditActionContext().endEditing,u=l.row[o.key],a=t.useState(u),c=a[0],s=a[1];return o.editable?e.jsxs("div",{className:"flex justify-between gap-1 w-full items-center",children:[e.jsxs("select",{className:"w-full py-1 px-2 bg-white text-gray-900",value:c,onChange:function(e){e.preventDefault(),s(e.target.value)},onBlur:function(e){e.preventDefault(),c!==u?function(e){o.editable&&o.onCellBlur(o.key,e,l.row,i)}(c):i()},onKeyDown:function(e){"Enter"===e.key&&e.preventDefault()},onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(s(u),i())},children:[o.allowEmpty&&e.jsx("option",{value:"",children:""==u?"-- 未選択 --":"-- 選択解除 --"},"TEPPEN/ReactUI Empty Option"),o.options.map((function(t){return e.jsx("option",{value:t.value,children:t.label},t.value)}))]}),e.jsx("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){s(u),i()}),300)},children:e.jsx(r.CancelIcon,{size:16})})]}):e.jsx(e.Fragment,{})};
|
|
3
3
|
//# sourceMappingURL=select-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../provider.js"),n=require("../../sheet/providers.js"),u=require("
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../provider.js"),n=require("../../sheet/providers.js"),u=require("./base-input.js");exports.StringCellInput=function(i){var o=i.col,s=n.useColumnValidateContext(o.key),a=r.useEditActionContext().endEditing,l=i.row[o.key],c=t.useState(l),d=c[0],f=c[1];return e.jsx(u.CellInput,{value:d,onChange:function(e){e.preventDefault(),f(e.target.value)},onBlur:function(e){e.preventDefault(),d!==l?s(d)?function(e){o.editable&&o.onCellBlur(o.key,e,i.row,a)}(d):setTimeout((function(){e.target.focus()}),100):a()},reset:function(){return f(l.toString())},endEditing:a})};
|
|
3
3
|
//# sourceMappingURL=string-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("./filter-icon.js"),
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("./filter-icon.js"),n=require("./provider.js"),l=require("react"),r=require("../../icon/cancel-icon.js"),i=require("./constants.js"),a=require("../sheet/providers.js"),o=require("./hooks/selectedFilteringColumn/provider.js");function u(t){var l=t.children,r=n.useFilterContext(),i=r.removeFilter,a=r.filterConditions,u=o.useFilteringColumnStateContext();if(null!==u&&0!==a.filter((function(e){return e.key===u.key})).length){return e.jsx("button",{onClick:function(e){e.preventDefault(),a.filter((function(e){return e.key===u.key})).forEach((function(e){i(e.id)}))},children:l})}}function s(t){var n=t.value,l=t.onChange,r=o.useFilteringColumnStateContext();return r?e.jsxs("select",{value:n,onChange:l,className:"px-2 py-1 rounded-md",children:[e.jsx("option",{value:"",children:r.key?"-- 条件を選択 --":"-- 列を選択してください --"}),"string"===r.type&&i.STRING_FILTER_OPERATOR.map((function(t){return e.jsx("option",{value:t.key,children:t.label},t.key)})),"number"===r.type&&i.NUMBER_FILTER_OPERATOR.map((function(t){return e.jsx("option",{value:t.key,children:t.label},t.key)})),"select"===r.type&&i.SELECT_FILTER_OPERATOR.map((function(t){return e.jsx("option",{value:t.key,children:t.label},t.key)}))]}):e.jsx(e.Fragment,{})}function c(t){return e.jsxs("select",{className:"w-full px-2 py-1 rounded-md min-w-32",value:t.value,onChange:function(e){e.preventDefault(),t.setValue(e.target.value)},children:[e.jsx("option",{value:"",children:"-- 未選択 --"}),t.options.map((function(t){return e.jsx("option",{value:t.value,children:t.label},t.value)}))]})}function x(t){return e.jsx("input",{className:"w-full px-2 py-1 rounded-md min-w-32",type:"text",value:t.value,onChange:function(e){e.preventDefault(),t.setValue(e.target.value)},placeholder:"-- 値を入力 --"})}function d(t){var l=n.useFilterContext().addFilter,r=o.useFilteringColumnStateContext();return r?e.jsx("button",{className:"bg-gray-900 text-white py-1 px-2 rounded-md text-nowrap",onClick:function(e){var n;e.preventDefault(),r.key&&t.selectingOperator&&("select"===r.type||t.value)?l("string"===r.type?{key:r.key,operator:t.selectingOperator,value:[t.value]}:"select"===r.type?{key:r.key,operator:t.selectingOperator,value:t.value,label:null===(n=r.options.find((function(e){return e.value===t.value})))||void 0===n?void 0:n.label}:{key:r.key,operator:t.selectingOperator,value:Number(t.value)}):alert("全ての項目を入力してください")},children:"追加"}):e.jsx(e.Fragment,{})}exports.TableFilter=function(l){var r=n.useFilterContext().filterConditions,i=o.useFilteringColumnStateContext(),a=o.useFilteringColumnActionContext(),u=a.setFilteringColumn,s=a.clearFilteringColumn;return e.jsx("div",{className:"relative cursor-pointer",onClick:function(e){e.preventDefault(),i&&i.key===l.col.key?s():u(l.col)},children:e.jsx(t.FIlterIcon,{isFilterTarget:!!i&&i.key===l.col.key,isFilterActive:r.filter((function(e){return e.key===l.col.key})).length>0})})},exports.TableFilterForm=function(){var t=o.useFilteringColumnStateContext(),f=o.useFilteringColumnActionContext(),p=f.setFilteringColumn,v=f.clearFilteringColumn,m=a.useColumnsContext(),y=n.useFilterContext(),h=y.removeFilter,g=y.filterConditions,j=l.useState(""),k=j[0],C=j[1],b=l.useState(""),F=b[0],N=b[1];if(l.useEffect((function(){N(""),C("")}),[t]),!t)return e.jsx(e.Fragment,{});var w=l.useCallback((function(e){e.preventDefault,C(e.target.value)}),[]);return e.jsxs("div",{className:"flex w-full max-h-[50vh] bg-gray-200",children:[e.jsx("ul",{className:"flex flex-col items-end min-w-16 md:w-[20%] max-h-full overflow-y-auto no_scrollbar bg-white",children:m.filter((function(e){return!!e.label&&!e.disableFilter})).map((function(n){return e.jsxs("li",{className:"relative pl-2 pr-8 md:px-8 py-3 w-full cursor-pointer border-y border-gray-300 ".concat(t.key===n.key?"bg-gray-200":"hover:bg-gray-100"),onClick:function(e){e.preventDefault(),p(n)},children:[e.jsx("p",{className:"text-right text-nowrap ".concat(t.key===n.key?"underline underline-offset-2 decoration-2 decoration-neutral-500":""),children:n.label}),g.filter((function(e){return e.key===n.key})).length>0&&e.jsx("div",{className:"absolute top-1/2 right-1",children:e.jsx("div",{className:"-translate-y-1/2 rounded-full border border-gray-400 bg-gray-100 aspect-square w-5",children:e.jsx("p",{className:"text-xs text-center",children:g.filter((function(e){return e.key===n.key})).length})})})]},n.key)}))}),e.jsxs("div",{className:"relative flex flex-col gap-4 ml-4 mr-4 md:ml-16 md:mr-auto py-5",children:[e.jsx("div",{className:"absolute top-5 right-0",children:e.jsx("button",{onClick:function(e){e.preventDefault(),v()},children:"閉じる"})}),e.jsx("p",{className:"font-bold text-xl",children:"フィルタリング条件"}),e.jsxs("div",{className:"flex items-center gap-3 max-w-6xl",children:[e.jsxs("p",{className:"text-gray-600 text-lg text-nowrap",children:["「",e.jsx("strong",{children:t.label}),"」 は"]}),e.jsx(s,{value:k,onChange:w}),"select"===t.type?e.jsx(c,{value:F,options:t.options,setValue:N}):e.jsx(x,{value:F,setValue:N}),e.jsx(d,{value:F,selectingOperator:k})]}),e.jsx("ul",{className:"flex flex-col gap-1 my-5 max-h-32 overflow-auto",children:g.filter((function(e){return e.key===t.key})).map((function(t){var n,l;return e.jsxs("li",{className:"flex justify-between mr-5",children:[e.jsxs("p",{children:["「",e.jsx("strong",{children:null===(n=m.find((function(e){return e.key===t.key})))||void 0===n?void 0:n.label}),"」 は",e.jsx("span",{children:null===(l=i.FILTER_OPERATOR.find((function(e){return e.key===t.operator})))||void 0===l?void 0:l.label}),":",e.jsx("span",{children:t.label?t.label:t.value})]}),e.jsx("button",{onClick:function(e){e.preventDefault(),h(t.id)},children:e.jsx(r.CancelIcon,{size:16})})]},t.id)}))}),e.jsx("div",{className:"flex justify-center",children:e.jsx(u,{children:e.jsxs("p",{className:"text-xs text-gray-600 underline hover:text-gray-800",children:["「",t.label,"」のフィルタを全て解除"]})})})]})]})},exports.TableFilterRemoveButton=function(t){var l=t.children,r=n.useFilterContext(),i=r.clearFilter;if(0!==r.filterConditions.length)return e.jsx("button",{onClick:function(e){e.preventDefault(),i()},children:l})},exports.TableSpecifyKeyFilterRemoveButton=u;
|
|
3
3
|
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react"),l=function(e,l){switch(l.type){case"set":return e&&e.key===l.payload.col.key?e:"string"===l.payload.col.type||"number"===l.payload.col.type?{key:l.payload.col.key,type:l.payload.col.type,label:l.payload.col.label}:{key:l.payload.col.key,type:l.payload.col.type,label:l.payload.col.label,options:l.payload.col.options};case"clear":return null}};exports.useFilteringColumnReducer=function(){var o=e.useReducer(l,null),t=o[0],a=o[1];return{state:t,actions:e.useMemo((function(){return{setFilteringColumn:function(e){return a({type:"set",payload:{col:e}})},clearFilteringColumn:function(){return a({type:"clear"})}}}),[])}};
|
|
2
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../../../../../src/table/filter/hooks/selectedFilteringColumn/hooks.ts"],"sourcesContent":["import { useMemo, useReducer } from \"react\";\nimport { TFilteringColumnReducer, TReturnFilteringColumnReducer } from \"./type\";\nimport { DataRecord, TTableColumn } from \"../../../type\";\n\nconst filteringColumnReducer: TFilteringColumnReducer = (state, action) => {\n switch (action.type) {\n case \"set\":\n if (!!state && state.key === action.payload.col.key) return state;\n\n if (\n action.payload.col.type === \"string\" ||\n action.payload.col.type === \"number\"\n ) {\n return {\n key: action.payload.col.key,\n type: action.payload.col.type,\n label: action.payload.col.label,\n };\n } else {\n return {\n key: action.payload.col.key,\n type: action.payload.col.type,\n label: action.payload.col.label,\n options: action.payload.col.options,\n };\n }\n case \"clear\":\n return null;\n }\n};\n\nexport function useFilteringColumnReducer(): TReturnFilteringColumnReducer {\n const [state, dispatch] = useReducer(filteringColumnReducer, null);\n\n const actions = useMemo(\n () => ({\n setFilteringColumn: (col: TTableColumn<DataRecord>) =>\n dispatch({ type: \"set\", payload: { col } }),\n clearFilteringColumn: () => dispatch({ type: \"clear\" }),\n }),\n []\n );\n\n return { state, actions };\n}\n"],"names":["filteringColumnReducer","state","action","type","key","payload","col","label","options","_a","useReducer","dispatch","actions","useMemo","setFilteringColumn","clearFilteringColumn"],"mappings":"oCAIMA,EAAkD,SAACC,EAAOC,GAC9D,OAAQA,EAAOC,MACb,IAAK,MACH,OAAMF,GAASA,EAAMG,MAAQF,EAAOG,QAAQC,IAAIF,IAAYH,EAG9B,WAA5BC,EAAOG,QAAQC,IAAIH,MACS,WAA5BD,EAAOG,QAAQC,IAAIH,KAEZ,CACLC,IAAKF,EAAOG,QAAQC,IAAIF,IACxBD,KAAMD,EAAOG,QAAQC,IAAIH,KACzBI,MAAOL,EAAOG,QAAQC,IAAIC,OAGrB,CACLH,IAAKF,EAAOG,QAAQC,IAAIF,IACxBD,KAAMD,EAAOG,QAAQC,IAAIH,KACzBI,MAAOL,EAAOG,QAAQC,IAAIC,MAC1BC,QAASN,EAAOG,QAAQC,IAAIE,SAGlC,IAAK,QACH,OAAO,KAEb,+CAGQ,IAAAC,EAAoBC,EAAAA,WAAWV,EAAwB,MAAtDC,EAAKQ,EAAA,GAAEE,OAWd,MAAO,CAAEV,MAAKA,EAAEW,QATAC,WACd,WAAM,MAAC,CACLC,mBAAoB,SAACR,GACnB,OAAAK,EAAS,CAAER,KAAM,MAAOE,QAAS,CAAEC,IAAGA,IAAK,EAC7CS,qBAAsB,WAAM,OAAAJ,EAAS,CAAER,KAAM,SAAU,EAHnD,GAKN,IAIJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";require("../../../../../node_modules/tslib/tslib.es6.js");var e=require("react/jsx-runtime"),t=require("react"),r=require("./hooks.js"),n=t.createContext(null),i=t.createContext({setFilteringColumn:function(){},clearFilteringColumn:function(){}});exports.FilteringColumnProvider=function(t){var u=r.useFilteringColumnReducer(),o=u.state,l=u.actions;return e.jsx(n.Provider,{value:o,children:e.jsx(i.Provider,{value:l,children:t.children})})},exports.useFilteringColumnActionContext=function(){return t.useContext(i)},exports.useFilteringColumnStateContext=function(){return t.useContext(n)};
|
|
2
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../../../../../../src/table/filter/hooks/selectedFilteringColumn/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport {\n TFilteringColumnActionContext,\n TFilteringColumnStateContext,\n} from \"./type\";\nimport { useFilteringColumnReducer } from \"./hooks\";\n\nconst FilteringColumnStateContext =\n createContext<TFilteringColumnStateContext>(null);\n\nconst FilteringColumnActionContext =\n createContext<TFilteringColumnActionContext>({\n setFilteringColumn: () => {},\n clearFilteringColumn: () => {},\n });\n\ntype TPropsFilteringColumnProvider = {\n children: JSX.Element | JSX.Element[];\n};\n\nexport function FilteringColumnProvider(props: TPropsFilteringColumnProvider) {\n const { state, actions } = useFilteringColumnReducer();\n return (\n <FilteringColumnStateContext.Provider value={state}>\n <FilteringColumnActionContext.Provider value={actions}>\n {props.children}\n </FilteringColumnActionContext.Provider>\n </FilteringColumnStateContext.Provider>\n );\n}\n\nexport function useFilteringColumnStateContext() {\n return useContext(FilteringColumnStateContext);\n}\n\nexport function useFilteringColumnActionContext() {\n return useContext(FilteringColumnActionContext);\n}\n\nexport function useFilteringColumnContext() {\n return {\n ...useFilteringColumnStateContext(),\n ...useFilteringColumnActionContext(),\n };\n}\n"],"names":["FilteringColumnStateContext","createContext","FilteringColumnActionContext","setFilteringColumn","clearFilteringColumn","props","_a","useFilteringColumnReducer","state","actions","_jsx","Provider","value","children","useContext"],"mappings":"qJAOMA,EACJC,EAAAA,cAA4C,MAExCC,EACJD,EAAAA,cAA6C,CAC3CE,mBAAoB,WAAQ,EAC5BC,qBAAsB,WAAQ,oCAO5B,SAAkCC,GAChC,IAAAC,EAAqBC,EAAyBA,4BAA5CC,EAAKF,EAAAE,MAAEC,EAAOH,EAAAG,QACtB,OACEC,EAAAA,IAACV,EAA4BW,UAASC,MAAOJ,EAAKK,SAChDH,MAACR,EAA6BS,SAAQ,CAACC,MAAOH,EAAOI,SAClDR,EAAMQ,YAIf,qDAOE,OAAOC,EAAAA,WAAWZ,EACpB,oDALE,OAAOY,EAAAA,WAAWd,EACpB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),
|
|
2
|
+
"use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime"),i=require("react"),t=require("./hooks.js"),n=require("./hooks/selectedFilteringColumn/provider.js"),o=i.createContext({addFilter:function(){},removeFilter:function(){},clearFilter:function(){},filter:function(){return[]},filterConditions:[]});exports.FilterProvider=function(e){var i=e.children;return r.jsx(n.FilteringColumnProvider,{children:r.jsx(o.Provider,{value:t.useFilterReducer(),children:i})})},exports.useFilterContext=function(){return e.__assign({},i.useContext(o))};
|
|
3
3
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),i=require("react");require("../filter/provider.js");var t=require("../filter/components.js"),r=require("../
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),i=require("react");require("../filter/provider.js");var t=require("../filter/components.js"),r=require("../sort/components.js");require("../sort/provider.js");var s=require("./resize-col-width-hook.js");exports.TableHeaderElement=function(l){var a=l.col,n=s.useResizeColWidthHook({initialWidth:a.initialWidth,minWidth:a.minWidth}),o=n.colWidth,d=n.onMouseDownResizeWidth,c=i.useRef(null),h=c.current?o-c.current.clientWidth:o;return e.jsxs("th",{id:l.id,className:"relative",style:{width:o,maxWidth:o,minWidth:o},children:[e.jsxs("div",{className:"flex justify-between items-center bg-gray-200 text-gray-600 h-[32px]",children:[e.jsx("div",{className:"px-2",style:{maxWidth:h},children:a.label&&e.jsx("p",{className:"text-left font-bold text-nowrap overflow-hidden text-ellipsis",children:a.label})}),e.jsxs("div",{ref:c,className:"flex items-center w-fit shrink-0 gap-1 px-1",children:[!a.disableSort&&e.jsx(r.SortButton,{columnKey:a.key.toString()}),!a.disableFilter&&!!a.label&&e.jsx(t.TableFilter,{col:a})]})]}),e.jsx("div",{className:"absolute top-0 right-0 grid place-items-end py-1 w-[4px] h-full cursor-col-resize",onMouseDown:d,children:e.jsx("div",{className:"w-[1px] h-full bg-white"})})]})};
|
|
3
3
|
//# sourceMappingURL=header.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("../constant.js");exports.useResizeColWidthHook=function(o){var n,u=e.useState(null!==(n=null==o?void 0:o.initialWidth)&&void 0!==n?n:t.DEFAULT_COL_WIDTH),i
|
|
1
|
+
"use strict";var e=require("react"),t=require("../constant.js");exports.useResizeColWidthHook=function(o){var n,u,i=e.useState(null!==(n=null==o?void 0:o.initialWidth)&&void 0!==n?n:t.DEFAULT_COL_WIDTH),s=i[0],r=i[1],d=e.useState(!1),c=d[0],l=d[1],m=null!==(u=null==o?void 0:o.minWidth)&&void 0!==u?u:t.DEFAULT_MIN_COL_WIDTH,v=e.useCallback((function(e){if(!c){var t=e.clientX,o=s;document.body.style.cursor="col-resize",document.body.style.userSelect="none";var n=function(e){l(!0);var n=o+(e.clientX-t);r(n>m?n:m)},u=function(){l(!1),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",u),document.body.style.cursor="default",document.body.style.userSelect="auto"};document.addEventListener("mousemove",n),document.addEventListener("mouseup",u)}}),[c,m]);return{colWidth:s,onMouseDownResizeWidth:v}};
|
|
2
2
|
//# sourceMappingURL=resize-col-width-hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize-col-width-hook.js","sources":["../../../../../src/table/header/resize-col-width-hook.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\nimport { DEFAULT_COL_WIDTH, DEFAULT_MIN_COL_WIDTH } from \"../constant\";\n\nexport function useResizeColWidthHook(options?: {\n initialWidth?: number;\n minWidth?: number;\n}) {\n const [colWidth, setColWidth] = useState(\n options?.initialWidth ?? DEFAULT_COL_WIDTH\n );\n\n const cursorStyle = \"col-resize\";\n\n const onMouseDownResizeWidth: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n const startX = e.clientX;\n const startWidth = colWidth;\n\n document.body.style.cursor = cursorStyle;\n document.body.style.userSelect = \"none\";\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n const newWidth = startWidth + (moveEvent.clientX - startX);\n setColWidth(
|
|
1
|
+
{"version":3,"file":"resize-col-width-hook.js","sources":["../../../../../src/table/header/resize-col-width-hook.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\nimport { DEFAULT_COL_WIDTH, DEFAULT_MIN_COL_WIDTH } from \"../constant\";\n\nexport function useResizeColWidthHook(options?: {\n initialWidth?: number;\n minWidth?: number;\n}) {\n const [colWidth, setColWidth] = useState(\n options?.initialWidth ?? DEFAULT_COL_WIDTH\n );\n const [isDragging, setIsDragging] = useState(false);\n const minWidth = options?.minWidth ?? DEFAULT_MIN_COL_WIDTH;\n\n const cursorStyle = \"col-resize\";\n\n const onMouseDownResizeWidth: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n if (isDragging) return;\n\n const startX = e.clientX;\n const startWidth = colWidth;\n\n document.body.style.cursor = cursorStyle;\n document.body.style.userSelect = \"none\";\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n setIsDragging(true);\n const newWidth = startWidth + (moveEvent.clientX - startX);\n setColWidth(newWidth > minWidth ? newWidth : minWidth);\n };\n\n const onMouseUp = () => {\n setIsDragging(false);\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n document.body.style.cursor = \"default\";\n document.body.style.userSelect = \"auto\";\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n },\n [isDragging, minWidth]\n );\n\n return {\n colWidth,\n onMouseDownResizeWidth,\n };\n}\n"],"names":["options","_c","useState","_a","initialWidth","DEFAULT_COL_WIDTH","colWidth","setColWidth","_d","isDragging","setIsDragging","minWidth","_b","DEFAULT_MIN_COL_WIDTH","onMouseDownResizeWidth","useCallback","e","startX","clientX","startWidth","document","body","style","cursor","userSelect","onMouseMove","moveEvent","newWidth","onMouseUp","removeEventListener","addEventListener"],"mappings":"8FAGM,SAAgCA,WAI9BC,EAA0BC,EAAAA,SACL,QAAzBC,EAAAH,eAAAA,EAASI,oBAAgB,IAAAD,EAAAA,EAAAE,EAAiBA,mBADrCC,OAAUC,OAGXC,EAA8BN,EAAAA,UAAS,GAAtCO,EAAUD,EAAA,GAAEE,EAAaF,EAAA,GAC1BG,EAAgC,QAArBC,EAAAZ,aAAA,EAAAA,EAASW,gBAAY,IAAAC,EAAAA,EAAAC,wBAIhCC,EACJC,eACE,SAACC,GACC,IAAIP,EAAJ,CAEA,IAAMQ,EAASD,EAAEE,QACXC,EAAab,EAEnBc,SAASC,KAAKC,MAAMC,OAVN,aAWdH,SAASC,KAAKC,MAAME,WAAa,OAEjC,IAAMC,EAAc,SAACC,GACnBhB,GAAc,GACd,IAAMiB,EAAWR,GAAcO,EAAUR,QAAUD,GACnDV,EAAYoB,EAAWhB,EAAWgB,EAAWhB,EAC/C,EAEMiB,EAAY,WAChBlB,GAAc,GACdU,SAASS,oBAAoB,YAAaJ,GAC1CL,SAASS,oBAAoB,UAAWD,GACxCR,SAASC,KAAKC,MAAMC,OAAS,UAC7BH,SAASC,KAAKC,MAAME,WAAa,MACnC,EAEAJ,SAASU,iBAAiB,YAAaL,GACvCL,SAASU,iBAAiB,UAAWF,EAvBd,CAwBzB,GACA,CAACnB,EAAYE,IAGjB,MAAO,CACLL,SAAQA,EACRQ,uBAAsBA,EAE1B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("./pagenation/providers.js");require("react/jsx-runtime");var r=require("./filter/provider.js");require("./filter/constants.js")
|
|
1
|
+
"use strict";var e=require("react"),t=require("./pagenation/providers.js");require("react/jsx-runtime");var r=require("./filter/provider.js");require("./filter/constants.js");var o=require("./sheet/providers.js");require("./filter/hooks/selectedFilteringColumn/provider.js");var n=require("./focus/provider.js"),u=require("./checkbox/provider.js"),i=require("./edit/provider.js"),s=require("./sort/provider.js"),c=require("./table-property/provider.js"),l=require("./paste/provider.js");exports.useCell=function(t,r,u){var s,c,l=n.useFocusActionContext(),a=i.useEditActionContext(),f=o.useColumnsContext()[r],d=u[f.key],p="select"===f.type?null===(c=null===(s=f.options)||void 0===s?void 0:s.find((function(e){return e.value===d})))||void 0===c?void 0:c.label:d,v=e.useMemo((function(){return f.editable?p:f.render?f.render(d,u):p}),[f.editable,p,d,u]);return{type:!f.editable&&f.render?"component":f.type,component:v,focusAtCell:e.useCallback((function(){l.move(t,r),l.focus(t,r)}),[l,t,r]),onDoubleClickCellToEdit:e.useCallback((function(e){e.preventDefault(),l.move(t,r),l.focus(t,r),a.startEditing()}),[l,a,t,r])}},exports.useTable=function(o){var n=r.useFilterContext().filter,i=s.useSortActionContext(),a=i.sort,f=i.updatedData,d=s.useSortTimingContext(),p=t.usePageContext(),v=p.setRowCount,C=p.pageFilter,x=u.useCheckboxStatusContext().dispatchCheckboxStatus,h=l.usePasteActionContext().setRows,m=c.useTablePropertyActionContext(),b=m.setMaxDisplayColCount,g=m.setMaxDisplayRowCount,k=e.useMemo((function(){return n(o.rows)}),[n,d,o.rows.length]);e.useEffect((function(){v(k.length)}),[k.length]);var j=e.useMemo((function(){return o.checkbox?o.rows.filter((function(e){var t;return null===(t=o.checkbox)||void 0===t?void 0:t.checked(e)})):[]}),[o.checkbox,o.rows]);e.useEffect((function(){x({type:"SET",payload:{checkedRecords:j}})}),[j]);var q=e.useMemo((function(){return a(k)}),[k,d]);e.useEffect((function(){f()}),[o.rows]);var w=e.useMemo((function(){return C(q)}),[C,q]),y=e.useMemo((function(){return w.map((function(e){return e.id}))}),[w]),M=e.useMemo((function(){return new Set(y)}),[y]),E=e.useMemo((function(){return o.rows.filter((function(e){return M.has(e.id)})).reduce((function(e,t){var r=Object.keys(t).sort().reduce((function(e,r){return e[r]=t[r],e}),{});return e[t.id]={data:r,stringValue:JSON.stringify(r)},e}),{})}),[o.rows,M]);return e.useEffect((function(){b(o.cols.length)}),[o.cols.length]),e.useEffect((function(){g(y.length)}),[y.length]),e.useEffect((function(){h(y.map((function(e){return E[e].data})))}),[E]),{cols:o.cols,rowMaps:E,pageRowIds:y}};
|
|
2
2
|
//# sourceMappingURL=hook.js.map
|
|
@@ -1 +1 @@
|
|
|
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 { useFocusActionContext } from \"./focus/provider\";\nimport { useCheckboxStatusContext } from \"./checkbox/provider\";\nimport { useEditActionContext } from \"./edit/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\nexport function useCell(rowIndex: number
|
|
1
|
+
{"version":3,"file":"hook.js","sources":["../../../../src/table/hook.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo } from \"react\";\nimport { DataObject, DataRecord, TColumnType, TPropsTable } from \"./type\";\nimport { usePageContext } from \"./pagenation/providers\";\nimport { useFilterContext } from \"./filter\";\nimport { useFocusActionContext } from \"./focus/provider\";\nimport { useCheckboxStatusContext } from \"./checkbox/provider\";\nimport { useEditActionContext } from \"./edit/provider\";\nimport { useSortActionContext, useSortTimingContext } from \"./sort/provider\";\nimport { useTablePropertyActionContext } from \"./table-property/provider\";\nimport { usePasteActionContext } from \"./paste/provider\";\nimport { useColumnsContext } from \"./sheet/providers\";\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\nexport function useCell(\n rowIndex: number,\n colIndex: number,\n row: DataObject<DataRecord>\n) {\n const focus = useFocusActionContext();\n const editAction = useEditActionContext();\n const col = useColumnsContext()[colIndex];\n const value = row[col.key as string];\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 type: TColumnType | \"component\" =\n !col.editable && col.render ? \"component\" : col.type;\n\n const focusAtCell = useCallback(() => {\n focus.move(rowIndex, colIndex);\n focus.focus(rowIndex, colIndex);\n }, [focus, rowIndex, colIndex]);\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, rowIndex, colIndex]\n );\n\n return {\n type,\n component,\n focusAtCell,\n onDoubleClickCellToEdit,\n };\n}\n"],"names":["rowIndex","colIndex","row","focus","useFocusActionContext","editAction","useEditActionContext","col","useColumnsContext","value","key","label","type","_a","options","find","op","_b","component","useMemo","editable","render","focusAtCell","useCallback","move","onDoubleClickCellToEdit","e","preventDefault","startEditing","props","filter","useFilterContext","useSortActionContext","sort","updatedData","sortTiming","useSortTimingContext","usePageContext","setRowCount","pageFilter","dispatchCheckboxStatus","useCheckboxStatusContext","setRows","usePasteActionContext","_c","useTablePropertyActionContext","setMaxDisplayColCount","setMaxDisplayRowCount","filteredRows","rows","length","useEffect","checkBoxes","checkbox","checked","payload","checkedRecords","sortedRows","pageRows","pageRowIds","map","id","pageRowIdSets","Set","rowMaps","has","reduce","acc","rowSortedByKey","Object","keys","data","stringValue","JSON","stringify","cols"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),a=require("react"),t=require("../sheet/providers.js"),n=require("../focus/provider.js"),s=function(a,t){var n;switch(t.type){case"setRows":return e.__assign(e.__assign({},a),{rows:t.payload.rows});case"setCols":return e.__assign(e.__assign({},a),{cols:t.payload.cols});case"setColValidators":return e.__assign(e.__assign({},a),{colValidators:t.payload.colValidators});case"setOnUpdateRowFunction":return e.__assign(e.__assign({},a),{onUpdateRowFunction:t.payload.onUpdateRowFunction});case"onPaste":if(!a.isFocused)return a;var s=t.payload.pasteData,o=a.rows,r=a.cols,u=a.colValidators,i=a.rowIndex,l=a.colIndex;if(!a.onUpdateRowFunction)return a;var c={arguments:[],timing:a.updateParameters.timing+1},d=s.length,p=Math.max.apply(Math,s.map((function(e){return e.length})));if(0===d||0===p)return a;if(s.length+i>o.length)return alert("貼り付け先の行数が足りません。"),a;for(var f=0;f<p;f++){if(!(w=r[l+f]).editable)return alert("編集できない列にデータを貼り付けることはできません。\n\n編集不可列: ".concat(null!==(n=w.label)&&void 0!==n?n:w.key)),a}if(p+l>r.length)return alert("貼り付け先の列数が足りません。"),a;for(f=0;f<d;f++)for(var g=s[f],_=0;_<g.length;_++){var w,y=g[_];if(!(0,u[(w=r[l+_]).key])(y))return a}return s.forEach((function(a,t){var n=e.__assign({},o[i+t]),s=!1;a.forEach((function(e,a){var t=r[l+a],o="number"===t.type?Number(e):"select"===t.type?""===e?"":t.options.find((function(a){return a.label===e})).value:e;n[t.key]!==o&&(s=!0,n[t.key]=o)})),s&&c.arguments.push({newRow:n,oldRow:o[i+t]})})),c.arguments.length>0?e.__assign(e.__assign({},a),{updateParameters:c}):a;case"focus":return e.__assign(e.__assign({},a),{isFocused:!0,rowIndex:t.payload.rowIndex,colIndex:t.payload.colIndex});case"unfocus":return e.__assign(e.__assign({},a),{isFocused:!1})}};exports.usePasteReducer=function(o){var r=a.useReducer(s,e.__assign(e.__assign({},o),{isFocused:!1,updateParameters:{arguments:[],timing:0}})),u=r[0],i=r[1],l=t.useColumnValidatesContext(),c=n.useFocusStateContext();a.useEffect((function(){c.isFocus?i({type:"focus",payload:{rowIndex:c.rowIndex,colIndex:c.colIndex}}):i({type:"unfocus"})}),[c]);var d=a.useCallback((function(e){i({type:"setRows",payload:{rows:e}})}),[]),p=a.useCallback((function(e){i({type:"setCols",payload:{cols:e}})}),[]),f=a.useCallback((function(e){i({type:"setColValidators",payload:{colValidators:e}})}),[]);a.useEffect((function(){f(l)}),[l]);var g=a.useCallback((function(e){i({type:"setOnUpdateRowFunction",payload:{onUpdateRowFunction:e}})}),[]),_=a.useCallback((function(e){i({type:"onPaste",payload:{pasteData:e}})}),[]);return a.useEffect((function(){u.updateParameters.arguments.length>0&&u.updateParameters.arguments.forEach((function(e){var a,t=e.newRow,n=e.oldRow;null===(a=u.onUpdateRowFunction)||void 0===a||a.call(u,t,n)}))}),[u.updateParameters.timing,u.onUpdateRowFunction]),a.useMemo((function(){return{setRows:d,setCols:p,setColValidators:f,setOnUpdateRowFunction:g,onPaste:_}}),[])};
|
|
1
|
+
"use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),a=require("react"),t=require("../sheet/providers.js"),n=require("../focus/provider.js"),s=function(a,t){var n;switch(t.type){case"setRows":return e.__assign(e.__assign({},a),{rows:t.payload.rows});case"setCols":return e.__assign(e.__assign({},a),{cols:t.payload.cols});case"setColValidators":return e.__assign(e.__assign({},a),{colValidators:t.payload.colValidators});case"setOnUpdateRowFunction":return e.__assign(e.__assign({},a),{onUpdateRowFunction:t.payload.onUpdateRowFunction});case"onPaste":if(!a.isFocused)return a;var s=t.payload.pasteData,o=a.rows,r=a.cols,u=a.colValidators,i=a.rowIndex,l=a.colIndex;if(!a.onUpdateRowFunction)return a;var c={arguments:[],timing:a.updateParameters.timing+1},d=s.length,p=Math.max.apply(Math,s.map((function(e){return e.length})));if(0===d||0===p)return a;if(s.length+i>o.length)return alert("貼り付け先の行数が足りません。"),a;for(var f=0;f<p;f++){if(!(w=r[l+f]).editable)return alert("編集できない列にデータを貼り付けることはできません。\n\n編集不可列: ".concat(null!==(n=w.label)&&void 0!==n?n:w.key)),a}if(p+l>r.length)return alert("貼り付け先の列数が足りません。"),a;for(f=0;f<d;f++)for(var g=s[f],_=0;_<g.length;_++){var w,y=g[_];if(!(0,u[(w=r[l+_]).key])(y))return a}return s.forEach((function(a,t){var n=e.__assign({},o[i+t]),s=!1;a.forEach((function(e,a){var t=r[l+a],o="number"===t.type?Number(e):"select"===t.type?""===e?"":t.options.find((function(a){return a.label===e})).value:e;n[t.key]!==o&&(s=!0,n[t.key]=o)})),s&&c.arguments.push({newRow:n,oldRow:o[i+t]})})),c.arguments.length>0?e.__assign(e.__assign({},a),{updateParameters:c}):a;case"focus":return e.__assign(e.__assign({},a),{isFocused:!0,rowIndex:t.payload.rowIndex,colIndex:t.payload.colIndex});case"unfocus":return e.__assign(e.__assign({},a),{isFocused:!1})}};exports.usePasteReducer=function(o){var r=a.useReducer(s,e.__assign(e.__assign({},o),{colValidators:{},isFocused:!1,updateParameters:{arguments:[],timing:0}})),u=r[0],i=r[1],l=t.useColumnValidatesContext(),c=n.useFocusStateContext();a.useEffect((function(){c.isFocus?i({type:"focus",payload:{rowIndex:c.rowIndex,colIndex:c.colIndex}}):i({type:"unfocus"})}),[c]);var d=a.useCallback((function(e){i({type:"setRows",payload:{rows:e}})}),[]),p=a.useCallback((function(e){i({type:"setCols",payload:{cols:e}})}),[]),f=a.useCallback((function(e){i({type:"setColValidators",payload:{colValidators:e}})}),[]);a.useEffect((function(){f(l)}),[l]);var g=a.useCallback((function(e){i({type:"setOnUpdateRowFunction",payload:{onUpdateRowFunction:e}})}),[]),_=a.useCallback((function(e){i({type:"onPaste",payload:{pasteData:e}})}),[]);return a.useEffect((function(){u.updateParameters.arguments.length>0&&u.updateParameters.arguments.forEach((function(e){var a,t=e.newRow,n=e.oldRow;null===(a=u.onUpdateRowFunction)||void 0===a||a.call(u,t,n)}))}),[u.updateParameters.timing,u.onUpdateRowFunction]),a.useMemo((function(){return{setRows:d,setCols:p,setColValidators:f,setOnUpdateRowFunction:g,onPaste:_}}),[])};
|
|
2
2
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../../../src/table/paste/hooks.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer } from \"react\";\nimport { TPasteReducer, TPasteReducerReturn } from \"./types\";\nimport { useColumnValidatesContext } from \"../sheet/providers\";\nimport { useFocusStateContext } from \"../focus/provider\";\n\nconst reducer: TPasteReducer = (state, action) => {\n switch (action.type) {\n case \"setRows\":\n return { ...state, rows: action.payload.rows };\n case \"setCols\":\n return { ...state, cols: action.payload.cols };\n case \"setColValidators\":\n return { ...state, colValidators: action.payload.colValidators };\n case \"setOnUpdateRowFunction\":\n return {\n ...state,\n onUpdateRowFunction: action.payload.onUpdateRowFunction,\n };\n case \"onPaste\":\n if (!state.isFocused) {\n return state;\n }\n\n const { pasteData } = action.payload;\n const {\n rows,\n cols,\n colValidators,\n rowIndex,\n colIndex,\n onUpdateRowFunction,\n } = state;\n\n if (!onUpdateRowFunction) {\n return state;\n }\n\n const updateParameters = {\n arguments: [] as { newRow: any; oldRow: any }[],\n timing: state.updateParameters.timing + 1,\n };\n\n const rowLength = pasteData.length;\n const colLength = Math.max(...pasteData.map((row) => row.length));\n\n if (rowLength === 0 || colLength === 0) return state;\n\n if (pasteData.length + rowIndex > rows.length) {\n alert(\"貼り付け先の行数が足りません。\");\n return state;\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 as string)\n }`\n );\n return state;\n }\n }\n\n if (colLength + colIndex > cols.length) {\n alert(\"貼り付け先の列数が足りません。\");\n return state;\n }\n\n for (let i = 0; i < rowLength; i++) {\n const pasteRow = pasteData[i];\n\n for (let j = 0; j < pasteRow.length; j++) {\n const pasteValue = pasteRow[j];\n const col = cols[colIndex + j];\n const validate = colValidators[col.key as string];\n\n if (!validate(pasteValue)) {\n return state;\n }\n }\n }\n\n pasteData.forEach((pasteRow, i) => {\n const row = { ...rows[rowIndex + i] };\n let checkUpdatedRow = false;\n\n pasteRow.forEach((pasteValue, j) => {\n const col = cols[colIndex + j];\n const value =\n col.type === \"number\"\n ? Number(pasteValue)\n : col.type === \"select\"\n ? pasteValue === \"\"\n ? \"\"\n : col.options.find((option) => option.label === pasteValue)!\n .value\n : pasteValue;\n if (row[col.key] !== value) {\n checkUpdatedRow = true;\n row[col.key] = value;\n }\n });\n\n if (checkUpdatedRow) {\n updateParameters.arguments.push({\n newRow: row,\n oldRow: rows[rowIndex + i],\n });\n }\n });\n\n if (updateParameters.arguments.length > 0) {\n return { ...state, updateParameters };\n } else {\n return state;\n }\n case \"focus\":\n return {\n ...state,\n isFocused: true,\n rowIndex: action.payload.rowIndex,\n colIndex: action.payload.colIndex,\n };\n case \"unfocus\":\n return { ...state, isFocused: false };\n }\n};\n\nexport function usePasteReducer(initial: {\n rows: any[];\n cols: any[];\n
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../../../src/table/paste/hooks.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer } from \"react\";\nimport { TPasteReducer, TPasteReducerReturn } from \"./types\";\nimport { useColumnValidatesContext } from \"../sheet/providers\";\nimport { useFocusStateContext } from \"../focus/provider\";\n\nconst reducer: TPasteReducer = (state, action) => {\n switch (action.type) {\n case \"setRows\":\n return { ...state, rows: action.payload.rows };\n case \"setCols\":\n return { ...state, cols: action.payload.cols };\n case \"setColValidators\":\n return { ...state, colValidators: action.payload.colValidators };\n case \"setOnUpdateRowFunction\":\n return {\n ...state,\n onUpdateRowFunction: action.payload.onUpdateRowFunction,\n };\n case \"onPaste\":\n if (!state.isFocused) {\n return state;\n }\n\n const { pasteData } = action.payload;\n const {\n rows,\n cols,\n colValidators,\n rowIndex,\n colIndex,\n onUpdateRowFunction,\n } = state;\n\n if (!onUpdateRowFunction) {\n return state;\n }\n\n const updateParameters = {\n arguments: [] as { newRow: any; oldRow: any }[],\n timing: state.updateParameters.timing + 1,\n };\n\n const rowLength = pasteData.length;\n const colLength = Math.max(...pasteData.map((row) => row.length));\n\n if (rowLength === 0 || colLength === 0) return state;\n\n if (pasteData.length + rowIndex > rows.length) {\n alert(\"貼り付け先の行数が足りません。\");\n return state;\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 as string)\n }`\n );\n return state;\n }\n }\n\n if (colLength + colIndex > cols.length) {\n alert(\"貼り付け先の列数が足りません。\");\n return state;\n }\n\n for (let i = 0; i < rowLength; i++) {\n const pasteRow = pasteData[i];\n\n for (let j = 0; j < pasteRow.length; j++) {\n const pasteValue = pasteRow[j];\n const col = cols[colIndex + j];\n const validate = colValidators[col.key as string];\n\n if (!validate(pasteValue)) {\n return state;\n }\n }\n }\n\n pasteData.forEach((pasteRow, i) => {\n const row = { ...rows[rowIndex + i] };\n let checkUpdatedRow = false;\n\n pasteRow.forEach((pasteValue, j) => {\n const col = cols[colIndex + j];\n const value =\n col.type === \"number\"\n ? Number(pasteValue)\n : col.type === \"select\"\n ? pasteValue === \"\"\n ? \"\"\n : col.options.find((option) => option.label === pasteValue)!\n .value\n : pasteValue;\n if (row[col.key] !== value) {\n checkUpdatedRow = true;\n row[col.key] = value;\n }\n });\n\n if (checkUpdatedRow) {\n updateParameters.arguments.push({\n newRow: row,\n oldRow: rows[rowIndex + i],\n });\n }\n });\n\n if (updateParameters.arguments.length > 0) {\n return { ...state, updateParameters };\n } else {\n return state;\n }\n case \"focus\":\n return {\n ...state,\n isFocused: true,\n rowIndex: action.payload.rowIndex,\n colIndex: action.payload.colIndex,\n };\n case \"unfocus\":\n return { ...state, isFocused: false };\n }\n};\n\nexport function usePasteReducer(initial: {\n rows: any[];\n cols: any[];\n onUpdateRowFunction?: (newRow: any, oldRow: any) => void;\n}): TPasteReducerReturn {\n const [state, dispatch] = useReducer(reducer, {\n ...initial,\n colValidators: {},\n isFocused: false,\n updateParameters: { arguments: [], timing: 0 },\n });\n const validators = useColumnValidatesContext();\n const focus = useFocusStateContext();\n\n useEffect(() => {\n if (focus.isFocus) {\n dispatch({\n type: \"focus\",\n payload: { rowIndex: focus.rowIndex, colIndex: focus.colIndex },\n });\n } else {\n dispatch({ type: \"unfocus\" });\n }\n }, [focus]);\n\n const setRows = useCallback((rows: any[]) => {\n dispatch({ type: \"setRows\", payload: { rows } });\n }, []);\n\n const setCols = useCallback((cols: any[]) => {\n dispatch({ type: \"setCols\", payload: { cols } });\n }, []);\n\n const setColValidators = useCallback(\n (colValidators: { [key: string]: (value: any) => boolean }) => {\n dispatch({ type: \"setColValidators\", payload: { colValidators } });\n },\n []\n );\n\n useEffect(() => {\n setColValidators(validators);\n }, [validators]);\n\n const setOnUpdateRowFunction = useCallback(\n (onUpdateRowFunction?: (newRow: any, oldRow: any) => void) => {\n dispatch({\n type: \"setOnUpdateRowFunction\",\n payload: { onUpdateRowFunction },\n });\n },\n []\n );\n\n const onPaste = useCallback((pasteData: string[][]) => {\n dispatch({ type: \"onPaste\", payload: { pasteData } });\n }, []);\n\n useEffect(() => {\n if (state.updateParameters.arguments.length > 0) {\n state.updateParameters.arguments.forEach(({ newRow, oldRow }) => {\n state.onUpdateRowFunction?.(newRow, oldRow);\n });\n }\n }, [state.updateParameters.timing, state.onUpdateRowFunction]);\n\n const actions: TPasteReducerReturn = useMemo(\n () => ({\n setRows,\n setCols,\n setColValidators,\n setOnUpdateRowFunction,\n onPaste,\n }),\n []\n );\n\n return actions;\n}\n"],"names":["reducer","state","action","type","__assign","rows","payload","cols","colValidators","onUpdateRowFunction","isFocused","pasteData","rows_1","cols_1","rowIndex_1","rowIndex","colIndex_1","colIndex","updateParameters_1","arguments","timing","updateParameters","rowLength","length","colLength","Math","max","apply","map","row","alert","i","col","editable","concat","_a","label","key","pasteRow","j","pasteValue","validate","forEach","checkUpdatedRow","value","Number","options","find","option","push","newRow","oldRow","initial","useReducer","dispatch","validators","useColumnValidatesContext","focus","useFocusStateContext","useEffect","isFocus","setRows","useCallback","setCols","setColValidators","setOnUpdateRowFunction","onPaste","_b","call","useMemo"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),o=require("./hooks.js"),n=t.createContext({setRows:function(){},setCols:function(){},setColValidators:function(){},setOnUpdateRowFunction:function(){},onPaste:function(){}});exports.PasteProvider=function(t){var r=t.children,s=t.rows,i=t.cols,u=t.onUpdateRowFunction,c=void 0===u?function(){}:u;return e.jsx(n.Provider,{value:o.usePasteReducer({rows:s,cols:i,onUpdateRowFunction:c}),children:r})},exports.usePasteActionContext=function(){return t.useContext(n)};
|
|
2
2
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sources":["../../../../../src/table/paste/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { TPasteReducerReturn } from \"./types\";\nimport { usePasteReducer } from \"./hooks\";\n\nconst PasteContext = createContext<TPasteReducerReturn>({\n setRows: () => {},\n setCols: () => {},\n setColValidators: () => {},\n setOnUpdateRowFunction: () => {},\n onPaste: () => {},\n});\n\nexport function PasteProvider({\n children,\n rows,\n cols,\n
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../../../../src/table/paste/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { TPasteReducerReturn } from \"./types\";\nimport { usePasteReducer } from \"./hooks\";\n\nconst PasteContext = createContext<TPasteReducerReturn>({\n setRows: () => {},\n setCols: () => {},\n setColValidators: () => {},\n setOnUpdateRowFunction: () => {},\n onPaste: () => {},\n});\n\nexport function PasteProvider({\n children,\n rows,\n cols,\n onUpdateRowFunction = () => {},\n}: {\n children: JSX.Element | JSX.Element[];\n rows: any[];\n cols: any[];\n onUpdateRowFunction?: (newRow: any, oldRow: any) => void;\n}) {\n return (\n <PasteContext.Provider\n value={usePasteReducer({\n rows,\n cols,\n onUpdateRowFunction,\n })}\n >\n {children}\n </PasteContext.Provider>\n );\n}\n\nexport function usePasteActionContext() {\n return useContext(PasteContext);\n}\n"],"names":["PasteContext","createContext","setRows","setCols","setColValidators","setOnUpdateRowFunction","onPaste","_a","children","rows","cols","_b","onUpdateRowFunction","_jsx","Provider","value","usePasteReducer","useContext"],"mappings":"2FAIMA,EAAeC,EAAAA,cAAmC,CACtDC,QAAS,WAAQ,EACjBC,QAAS,WAAQ,EACjBC,iBAAkB,WAAQ,EAC1BC,uBAAwB,WAAQ,EAChCC,QAAS,WAAQ,0BAGb,SAAwBC,GAC5B,IAAAC,EAAQD,EAAAC,SACRC,EAAIF,EAAAE,KACJC,EAAIH,EAAAG,KACJC,EAAAJ,EAAAK,oBAAAA,OAAsB,IAAAD,EAAA,WAAQ,EAAAA,EAO9B,OACEE,MAACb,EAAac,SACZ,CAAAC,MAAOC,EAAAA,gBAAgB,CACrBP,KAAIA,EACJC,KAAIA,EACJE,oBAAmBA,IAGpBJ,SAAAA,GAGP,2CAGE,OAAOS,EAAAA,WAAWjB,EACpB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),o=require("
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),o=require("../focus/provider.js"),t=require("../checkbox/components.js"),n=require("../cell/ui/cell.js"),i=r.memo((function(r){var i=o.useFocusActionContext().unfocus,a=JSON.parse(r.dataString),l=r.conditionalFormattingString.split(",");return e.jsxs("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(r.onClickRow?"hover:cursor-pointer":""," ").concat(r.applyRowFormatting?r.applyRowFormatting(a):""),onClick:function(e){e.preventDefault(),r.onClickRow&&(r.onClickRow(a),i())},"data-testid":a.id,children:[r.existCheckbox&&e.jsx("td",{children:e.jsx(t.Checkbox,{row:a})}),r.cols.map((function(o,t){var i;return e.jsx(n.TableCell,{rowIndex:r.rowIndex,colIndex:t,row:a,columnKey:o.key,isExistOnClickRow:!!r.onClickRow,cellFormatClassName:l[t],isExistOnUpdateRow:!!r.onUpdateRow,editable:null!==(i=o.editable)&&void 0!==i&&i},o.key)}))]})}));exports.Row=i;
|
|
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 {
|
|
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 \"../type\";\nimport { Checkbox } from \"../checkbox/components\";\nimport { TableCell } from \"../cell/ui/cell\";\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 onUpdateRow?: (newRow: any, oldRow: any) => void;\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 rowIndex={props.rowIndex}\n colIndex={j}\n row={row}\n columnKey={col.key as string}\n isExistOnClickRow={!!props.onClickRow}\n cellFormatClassName={conditionalFormatting[j]}\n isExistOnUpdateRow={!!props.onUpdateRow}\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","jsx","Checkbox","cols","map","col","j","TableCell","rowIndex","colIndex","columnKey","key","isExistOnClickRow","cellFormatClassName","isExistOnUpdateRow","onUpdateRow","editable","_a"],"mappings":"4KAiBaA,EAAMC,EAAIA,MAAC,SAAiCC,GAC/C,IAAAC,EAAYC,kCACdC,EAAMC,KAAKC,MAAML,EAAMM,YACvBC,EAAwBP,EAAMQ,4BAA4BC,MAAM,KAEtE,OACEC,OACE,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,EACEC,IAAA,KAAA,CAAAH,SAAAE,EAAAA,IAACE,EAAQA,SAAC,CAAApB,IAAKA,MAGlBH,EAAMwB,KAAKC,KAAI,SAACC,EAAKC,SACpB,OACEN,EAAAA,IAACO,EAAAA,UAAS,CAERC,SAAU7B,EAAM6B,SAChBC,SAAUH,EACVxB,IAAKA,EACL4B,UAAWL,EAAIM,IACfC,oBAAqBjC,EAAMa,WAC3BqB,oBAAqB3B,EAAsBoB,GAC3CQ,qBAAsBnC,EAAMoC,YAC5BC,SAAsB,QAAZC,EAAAZ,EAAIW,gBAAQ,IAAAC,GAAAA,GARjBZ,EAAIM,UAcrB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../libs/generate-validate-function.js"),n=t.createContext({
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../libs/generate-validate-function.js"),n=t.createContext({cols:[],validates:{}});exports.ColumnsProvider=function(u){var o=u.children,s=u.cols,i=u.errorHandler,a=t.useMemo((function(){return s.reduce((function(e,t){return e[t.key]=r.generateValidateFunction(t,i),e}),{})}),[s]),l=t.useMemo((function(){return{cols:s,validates:a}}),[s]);return e.jsx(n.Provider,{value:l,children:o})},exports.useColumnValidateContext=function(e){return t.useContext(n).validates[e]},exports.useColumnValidatesContext=function(){return t.useContext(n).validates},exports.useColumnsContext=function(){return t.useContext(n).cols};
|
|
3
3
|
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-icon.js","sources":["../../../../src/icon/cancel-icon.tsx"],"sourcesContent":["import { MdOutlineCancel } from \"react-icons/md\";\n\ntype TPropsCancelIcon = {\n size: number;\n};\n\nexport function CancelIcon(props: TPropsCancelIcon) {\n return <MdOutlineCancel size={`${props.size}px`} />;\n}\n"],"names":["CancelIcon","props","_jsx","MdOutlineCancel","size","concat"],"mappings":"qHAMM,SAAUA,EAAWC,GACzB,OAAOC,EAACC,EAAe,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-icon.js","sources":["../../../../src/icon/edit-icon.tsx"],"sourcesContent":["import { LiaEdit } from \"react-icons/lia\";\n\ntype TPropsEditIcon = {\n size: number;\n};\n\nexport function EditIcon(props: TPropsEditIcon) {\n return <LiaEdit size={`${props.size}px`} />;\n}\n"],"names":["EditIcon","props","_jsx","LiaEdit","size","concat"],"mappings":"8GAMM,SAAUA,EAASC,GACvB,OAAOC,EAACC,EAAO,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACzC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
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 d
|
|
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 d}from"./filter/provider.js";import{TableFilterRemoveButton as s,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 r(d,{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(f,{checkbox:t.checkbox,children:r(g,{checkboxCount:t.rows.length,children:r(p,{cols:t.cols,errorHandler:t.errorHandler,children:r(h,{children:r(b,{children:r(w,{children:e(y,{rows:t.rows,cols:t.cols,onUpdateRowFunction:t.onUpdateRow,children:[r(x,{}),r(P,o({},t))]})})})})})})})})})})}function P(o){var n=t(o),d=n.cols,m=n.rowMaps,p=n.pageRowIds,h=R(),f=k().onPaste;return e("div",{className:"w-full",children:[r("div",{className:"flex justify-end mb-1 mr-3",children:r(s,{children:r("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:[r(C,{rowMaps:m,pageRowIds:p}),e("table",{className:"table",onPaste:function(o){o.preventDefault();var r=o.clipboardData.getData("Text");f(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]",children:[o.checkbox&&r("th",{children:r(u,{rows:o.rows})}),d.map((function(o,e){return r(i,{id:v.getTableColId(e),col:o},o.key.toString())}))]})}),e("tbody",{children:[!!h&&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(c,{})})}),0===p.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"})})}),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:N(m[e].data,d,o.conditionalFormattings),onUpdateRow:o.onUpdateRow},e)}))]})]})]}),e("div",{className:"mt-1",children:[r(l,{}),r("div",{className:"mt-2",children:r(a,{})})]})]})}export{F as default};
|
|
3
3
|
//# sourceMappingURL=base.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,
|
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useCell as t}from"../../hook.js";import{EditButton as l}from"./edit-button.js";import{IdGenerator as i}from"../../libs/id-generator.js";function n(n){var r=t(n.rowIndex,n.colIndex,n.row),c=r.type,a=r.component,s=r.focusAtCell,d=r.onDoubleClickCellToEdit,m=i.getTableCellId(n.rowIndex,n.colIndex);return e("td",{id:m,className:"".concat(n.cellFormatClassName),children:e("div",{className:"relative",onClick:n.isExistOnClickRow?void 0:function(e){e.preventDefault(),s()},onDoubleClick:n.isExistOnClickRow?void 0:d,children:o("div",{className:"flex items-center gap-3 w-f-displayit p-2 cursor-default",onClick:function(e){e.preventDefault(),e.stopPropagation(),s()},children:["component"===c?a:e("div",{onDoubleClick:d,children:e("p",{className:"cell-data text-left whitespace-nowrap",children:a})}),n.editable&&e(l,{})]})})})}export{n as TableCell};
|
|
3
3
|
//# sourceMappingURL=cell.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
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
|
|
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 o}from"../../../icon/edit-icon.js";var e=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(o,{size:12})})}));export{e as EditButton};
|
|
3
3
|
//# sourceMappingURL=edit-button.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as n}from"react/jsx-runtime";import{memo as t,useMemo as c,useRef as r,useEffect as o}from"react";import{
|
|
2
|
+
import{jsx as e,Fragment as n}from"react/jsx-runtime";import{memo as t,useMemo as c,useRef as r,useEffect as o}from"react";import{useCheckboxContext as i,useCheckboxStatusContext as u}from"./provider.js";var a=t((function(t){var r=i(),o=u().checkboxStatusState,a=t.row,d=c((function(){return o.checkedRecords.map((function(e){return e.id}))}),[o.checkedRecords]);return r?e("div",{className:"flex justify-center gap-1 w-full items-center",children:e("input",{type:"checkbox",checked:d.includes(a.id),onChange:function(e){e.preventDefault(),e.target.checked?r.onChecked(a):r.onUnchecked(a)},onClick:function(e){e.preventDefault(),e.stopPropagation()}})}):e(n,{})})),d=t((function(t){var a=r(null),d=i(),f=u(),h=f.checkboxStatusState,l=f.existChecked,s=f.indeterminate,p=c((function(){return h.checkedRecords.map((function(e){return e.id}))}),[h.checkedRecords]),k=c((function(){return t.rows.filter((function(e){return!p.includes(e.id)}))}),[t.rows,p]);return o((function(){null!=a.current&&(a.current.indeterminate=!0===s)}),[s]),d?e("div",{className:"grid place-items-center w-full px-1",children:e("input",{ref:a,type:"checkbox",checked:l,onChange:function(e){e.preventDefault(),e.target.checked?k.forEach((function(e){d.onChecked(e)})):h.checkedRecords.forEach((function(e){d.onUnchecked(e)}))},onClick:function(e){e.preventDefault(),e.stopPropagation()}})}):e(n,{})}));export{d as AllCheckbox,a as Checkbox};
|
|
3
3
|
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as n,useEffect as r}from"react";import{CancelIcon as o}from"../../../icon/cancel-icon.js";function i(i){var u=n(null);return r((function(){u.current&&u.current.focus()}),[u]),e("div",{className:"flex justify-between gap-1 w-full items-center",onClick:function(e){e.preventDefault(),e.stopPropagation()},children:[t("input",{ref:u,className:"w-full py-1 px-2 bg-white text-gray-900",type:"text",value:i.value,onChange:i.onChange,onBlur:i.onBlur,onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(i.reset(),i.endEditing())}}),t("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){i.reset(),i.endEditing()}),300)},children:t(o,{size:16})})]})}export{i as CellInput};
|
|
3
|
+
//# sourceMappingURL=base-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t}from"react/jsx-runtime";import{useState as e}from"react";import{useColumnValidateContext as r}from"../../sheet/providers.js";import{CellInput as o}from"
|
|
2
|
+
import{jsx as t}from"react/jsx-runtime";import{useState as e}from"react";import{useColumnValidateContext as r}from"../../sheet/providers.js";import{CellInput as o}from"./base-input.js";import{useEditActionContext as n}from"../provider.js";function u(u){var a=u.col,i=r(a.key),m=n().endEditing,l=u.row[a.key],f=e(l.toString()),g=f[0],v=f[1];return t(o,{value:g,onChange:function(t){t.preventDefault(),""!==t.target.value?"-"!==t.target.value&&"0-"!==t.target.value?t.target.value.match(/^-?[0-9]+\.$/)?v(t.target.value):isNaN(Number(t.target.value))||v(Number(t.target.value).toString()):v("-0"):v("0")},onBlur:function(t){t.preventDefault(),Number(g)!==l?i(g)?function(t){a.editable&&a.onCellBlur(a.key,Number(t),u.row,m)}(g):setTimeout((function(){t.target.focus()}),100):m()},reset:function(){return v(l.toString())},endEditing:m})}export{u as NumberCellInput};
|
|
3
3
|
//# sourceMappingURL=number-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import{useState as o}from"react";import{useEditActionContext as r}from"../provider.js";import{CancelIcon as
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import{useState as o}from"react";import{useEditActionContext as r}from"../provider.js";import{CancelIcon as i}from"../../../icon/cancel-icon.js";function l(l){var a=l.col,u=r().endEditing,c=l.row[a.key],p=o(c),f=p[0],m=p[1];return a.editable?n("div",{className:"flex justify-between gap-1 w-full items-center",children:[n("select",{className:"w-full py-1 px-2 bg-white text-gray-900",value:f,onChange:function(e){e.preventDefault(),m(e.target.value)},onBlur:function(e){e.preventDefault(),f!==c?function(e){a.editable&&a.onCellBlur(a.key,e,l.row,u)}(f):u()},onKeyDown:function(e){"Enter"===e.key&&e.preventDefault()},onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(m(c),u())},children:[a.allowEmpty&&e("option",{value:"",children:""==c?"-- 未選択 --":"-- 選択解除 --"},"TEPPEN/ReactUI Empty Option"),a.options.map((function(t){return e("option",{value:t.value,children:t.label},t.value)}))]}),e("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){m(c),u()}),300)},children:e(i,{size:16})})]}):e(t,{})}export{l as SelectCellInput};
|
|
3
3
|
//# sourceMappingURL=select-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as
|
|
2
|
+
import{jsx as t}from"react/jsx-runtime";import{useState as e}from"react";import{useEditActionContext as r}from"../provider.js";import{useColumnValidateContext as o}from"../../sheet/providers.js";import{CellInput as n}from"./base-input.js";function i(i){var u=i.col,f=o(u.key),a=r().endEditing,m=i.row[u.key],p=e(m),c=p[0],l=p[1];return t(n,{value:c,onChange:function(t){t.preventDefault(),l(t.target.value)},onBlur:function(t){t.preventDefault(),c!==m?f(c)?function(t){u.editable&&u.onCellBlur(u.key,t,i.row,a)}(c):setTimeout((function(){t.target.focus()}),100):a()},reset:function(){return l(m.toString())},endEditing:a})}export{i as StringCellInput};
|
|
3
3
|
//# sourceMappingURL=string-input.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import{FIlterIcon as l}from"./filter-icon.js";import{useFilterContext as r}from"./provider.js";import{useState as i,useEffect as a,useCallback as o}from"react";import{CancelIcon as u}from"../../icon/cancel-icon.js";import{FILTER_OPERATOR as c,STRING_FILTER_OPERATOR as s,NUMBER_FILTER_OPERATOR as d,SELECT_FILTER_OPERATOR as f}from"./constants.js";import{useColumnsContext as p}from"../sheet/providers.js";import{useFilteringColumnStateContext as v,useFilteringColumnActionContext as m}from"./hooks/selectedFilteringColumn/provider.js";function y(t){var n=r().filterConditions,i=v(),a=m(),o=a.setFilteringColumn,u=a.clearFilteringColumn;return e("div",{className:"relative cursor-pointer",onClick:function(e){e.preventDefault(),i&&i.key===t.col.key?u():o(t.col)},children:e(l,{isFilterTarget:!!i&&i.key===t.col.key,isFilterActive:n.filter((function(e){return e.key===t.col.key})).length>0})})}function h(t){var n=t.children,l=r(),i=l.clearFilter;if(0!==l.filterConditions.length)return e("button",{onClick:function(e){e.preventDefault(),i()},children:n})}function g(t){var n=t.children,l=r(),i=l.removeFilter,a=l.filterConditions,o=v();if(null!==o&&0!==a.filter((function(e){return e.key===o.key})).length){return e("button",{onClick:function(e){e.preventDefault(),a.filter((function(e){return e.key===o.key})).forEach((function(e){i(e.id)}))},children:n})}}function k(l){var r=l.value,i=l.onChange,a=v();return a?n("select",{value:r,onChange:i,className:"px-2 py-1 rounded-md",children:[e("option",{value:"",children:a.key?"-- 条件を選択 --":"-- 列を選択してください --"}),"string"===a.type&&s.map((function(t){return e("option",{value:t.key,children:t.label},t.key)})),"number"===a.type&&d.map((function(t){return e("option",{value:t.key,children:t.label},t.key)})),"select"===a.type&&f.map((function(t){return e("option",{value:t.key,children:t.label},t.key)}))]}):e(t,{})}function x(t){return n("select",{className:"w-full px-2 py-1 rounded-md min-w-32",value:t.value,onChange:function(e){e.preventDefault(),t.setValue(e.target.value)},children:[e("option",{value:"",children:"-- 未選択 --"}),t.options.map((function(t){return e("option",{value:t.value,children:t.label},t.value)}))]})}function b(t){return e("input",{className:"w-full px-2 py-1 rounded-md min-w-32",type:"text",value:t.value,onChange:function(e){e.preventDefault(),t.setValue(e.target.value)},placeholder:"-- 値を入力 --"})}function N(n){var l=r().addFilter,i=v();return i?e("button",{className:"bg-gray-900 text-white py-1 px-2 rounded-md text-nowrap",onClick:function(e){var t;e.preventDefault(),i.key&&n.selectingOperator&&("select"===i.type||n.value)?l("string"===i.type?{key:i.key,operator:n.selectingOperator,value:[n.value]}:"select"===i.type?{key:i.key,operator:n.selectingOperator,value:n.value,label:null===(t=i.options.find((function(e){return e.value===n.value})))||void 0===t?void 0:t.label}:{key:i.key,operator:n.selectingOperator,value:Number(n.value)}):alert("全ての項目を入力してください")},children:"追加"}):e(t,{})}function C(){var l=v(),s=m(),d=s.setFilteringColumn,f=s.clearFilteringColumn,y=p(),h=r(),C=h.removeFilter,w=h.filterConditions,F=i(""),D=F[0],j=F[1],O=i(""),V=O[0],q=O[1];if(a((function(){q(""),j("")}),[l]),!l)return e(t,{});var z=o((function(e){e.preventDefault,j(e.target.value)}),[]);return n("div",{className:"flex w-full max-h-[50vh] bg-gray-200",children:[e("ul",{className:"flex flex-col items-end min-w-16 md:w-[20%] max-h-full overflow-y-auto no_scrollbar bg-white",children:y.filter((function(e){return!!e.label&&!e.disableFilter})).map((function(t){return n("li",{className:"relative pl-2 pr-8 md:px-8 py-3 w-full cursor-pointer border-y border-gray-300 ".concat(l.key===t.key?"bg-gray-200":"hover:bg-gray-100"),onClick:function(e){e.preventDefault(),d(t)},children:[e("p",{className:"text-right text-nowrap ".concat(l.key===t.key?"underline underline-offset-2 decoration-2 decoration-neutral-500":""),children:t.label}),w.filter((function(e){return e.key===t.key})).length>0&&e("div",{className:"absolute top-1/2 right-1",children:e("div",{className:"-translate-y-1/2 rounded-full border border-gray-400 bg-gray-100 aspect-square w-5",children:e("p",{className:"text-xs text-center",children:w.filter((function(e){return e.key===t.key})).length})})})]},t.key)}))}),n("div",{className:"relative flex flex-col gap-4 ml-4 mr-4 md:ml-16 md:mr-auto py-5",children:[e("div",{className:"absolute top-5 right-0",children:e("button",{onClick:function(e){e.preventDefault(),f()},children:"閉じる"})}),e("p",{className:"font-bold text-xl",children:"フィルタリング条件"}),n("div",{className:"flex items-center gap-3 max-w-6xl",children:[n("p",{className:"text-gray-600 text-lg text-nowrap",children:["「",e("strong",{children:l.label}),"」 は"]}),e(k,{value:D,onChange:z}),"select"===l.type?e(x,{value:V,options:l.options,setValue:q}):e(b,{value:V,setValue:q}),e(N,{value:V,selectingOperator:D})]}),e("ul",{className:"flex flex-col gap-1 my-5 max-h-32 overflow-auto",children:w.filter((function(e){return e.key===l.key})).map((function(t){var l,r;return n("li",{className:"flex justify-between mr-5",children:[n("p",{children:["「",e("strong",{children:null===(l=y.find((function(e){return e.key===t.key})))||void 0===l?void 0:l.label}),"」 は",e("span",{children:null===(r=c.find((function(e){return e.key===t.operator})))||void 0===r?void 0:r.label}),":",e("span",{children:t.label?t.label:t.value})]}),e("button",{onClick:function(e){e.preventDefault(),C(t.id)},children:e(u,{size:16})})]},t.id)}))}),e("div",{className:"flex justify-center",children:e(g,{children:n("p",{className:"text-xs text-gray-600 underline hover:text-gray-800",children:["「",l.label,"」のフィルタを全て解除"]})})})]})]})}export{y as TableFilter,C as TableFilterForm,h as TableFilterRemoveButton,g as TableSpecifyKeyFilterRemoveButton};
|
|
3
3
|
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useReducer as l,useMemo as e}from"react";var o=function(l,e){switch(e.type){case"set":return l&&l.key===e.payload.col.key?l:"string"===e.payload.col.type||"number"===e.payload.col.type?{key:e.payload.col.key,type:e.payload.col.type,label:e.payload.col.label}:{key:e.payload.col.key,type:e.payload.col.type,label:e.payload.col.label,options:e.payload.col.options};case"clear":return null}};function a(){var a=l(o,null),t=a[0],n=a[1];return{state:t,actions:e((function(){return{setFilteringColumn:function(l){return n({type:"set",payload:{col:l}})},clearFilteringColumn:function(){return n({type:"clear"})}}}),[])}}export{a as useFilteringColumnReducer};
|
|
2
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../../../../../src/table/filter/hooks/selectedFilteringColumn/hooks.ts"],"sourcesContent":["import { useMemo, useReducer } from \"react\";\nimport { TFilteringColumnReducer, TReturnFilteringColumnReducer } from \"./type\";\nimport { DataRecord, TTableColumn } from \"../../../type\";\n\nconst filteringColumnReducer: TFilteringColumnReducer = (state, action) => {\n switch (action.type) {\n case \"set\":\n if (!!state && state.key === action.payload.col.key) return state;\n\n if (\n action.payload.col.type === \"string\" ||\n action.payload.col.type === \"number\"\n ) {\n return {\n key: action.payload.col.key,\n type: action.payload.col.type,\n label: action.payload.col.label,\n };\n } else {\n return {\n key: action.payload.col.key,\n type: action.payload.col.type,\n label: action.payload.col.label,\n options: action.payload.col.options,\n };\n }\n case \"clear\":\n return null;\n }\n};\n\nexport function useFilteringColumnReducer(): TReturnFilteringColumnReducer {\n const [state, dispatch] = useReducer(filteringColumnReducer, null);\n\n const actions = useMemo(\n () => ({\n setFilteringColumn: (col: TTableColumn<DataRecord>) =>\n dispatch({ type: \"set\", payload: { col } }),\n clearFilteringColumn: () => dispatch({ type: \"clear\" }),\n }),\n []\n );\n\n return { state, actions };\n}\n"],"names":["filteringColumnReducer","state","action","type","key","payload","col","label","options","useFilteringColumnReducer","_a","useReducer","dispatch","actions","useMemo","setFilteringColumn","clearFilteringColumn"],"mappings":"gDAIA,IAAMA,EAAkD,SAACC,EAAOC,GAC9D,OAAQA,EAAOC,MACb,IAAK,MACH,OAAMF,GAASA,EAAMG,MAAQF,EAAOG,QAAQC,IAAIF,IAAYH,EAG9B,WAA5BC,EAAOG,QAAQC,IAAIH,MACS,WAA5BD,EAAOG,QAAQC,IAAIH,KAEZ,CACLC,IAAKF,EAAOG,QAAQC,IAAIF,IACxBD,KAAMD,EAAOG,QAAQC,IAAIH,KACzBI,MAAOL,EAAOG,QAAQC,IAAIC,OAGrB,CACLH,IAAKF,EAAOG,QAAQC,IAAIF,IACxBD,KAAMD,EAAOG,QAAQC,IAAIH,KACzBI,MAAOL,EAAOG,QAAQC,IAAIC,MAC1BC,QAASN,EAAOG,QAAQC,IAAIE,SAGlC,IAAK,QACH,OAAO,KAEb,WAEgBC,IACR,IAAAC,EAAoBC,EAAWX,EAAwB,MAAtDC,EAAKS,EAAA,GAAEE,OAWd,MAAO,CAAEX,MAAKA,EAAEY,QATAC,GACd,WAAM,MAAC,CACLC,mBAAoB,SAACT,GACnB,OAAAM,EAAS,CAAET,KAAM,MAAOE,QAAS,CAAEC,IAAGA,IAAK,EAC7CU,qBAAsB,WAAM,OAAAJ,EAAS,CAAET,KAAM,SAAU,EAHnD,GAKN,IAIJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../../../../../node_modules/tslib/tslib.es6.js";import{jsx as r}from"react/jsx-runtime";import{createContext as n,useContext as t}from"react";import{useFilteringColumnReducer as e}from"./hooks.js";var i=n(null),o=n({setFilteringColumn:function(){},clearFilteringColumn:function(){}});function l(n){var t=e(),l=t.state,u=t.actions;return r(i.Provider,{value:l,children:r(o.Provider,{value:u,children:n.children})})}function u(){return t(i)}function c(){return t(o)}export{l as FilteringColumnProvider,c as useFilteringColumnActionContext,u as useFilteringColumnStateContext};
|
|
2
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../../../../../../src/table/filter/hooks/selectedFilteringColumn/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport {\n TFilteringColumnActionContext,\n TFilteringColumnStateContext,\n} from \"./type\";\nimport { useFilteringColumnReducer } from \"./hooks\";\n\nconst FilteringColumnStateContext =\n createContext<TFilteringColumnStateContext>(null);\n\nconst FilteringColumnActionContext =\n createContext<TFilteringColumnActionContext>({\n setFilteringColumn: () => {},\n clearFilteringColumn: () => {},\n });\n\ntype TPropsFilteringColumnProvider = {\n children: JSX.Element | JSX.Element[];\n};\n\nexport function FilteringColumnProvider(props: TPropsFilteringColumnProvider) {\n const { state, actions } = useFilteringColumnReducer();\n return (\n <FilteringColumnStateContext.Provider value={state}>\n <FilteringColumnActionContext.Provider value={actions}>\n {props.children}\n </FilteringColumnActionContext.Provider>\n </FilteringColumnStateContext.Provider>\n );\n}\n\nexport function useFilteringColumnStateContext() {\n return useContext(FilteringColumnStateContext);\n}\n\nexport function useFilteringColumnActionContext() {\n return useContext(FilteringColumnActionContext);\n}\n\nexport function useFilteringColumnContext() {\n return {\n ...useFilteringColumnStateContext(),\n ...useFilteringColumnActionContext(),\n };\n}\n"],"names":["FilteringColumnStateContext","createContext","FilteringColumnActionContext","setFilteringColumn","clearFilteringColumn","FilteringColumnProvider","props","_a","useFilteringColumnReducer","state","actions","_jsx","Provider","value","children","useFilteringColumnStateContext","useContext","useFilteringColumnActionContext"],"mappings":"4MAOA,IAAMA,EACJC,EAA4C,MAExCC,EACJD,EAA6C,CAC3CE,mBAAoB,WAAQ,EAC5BC,qBAAsB,WAAQ,IAO5B,SAAUC,EAAwBC,GAChC,IAAAC,EAAqBC,IAAnBC,EAAKF,EAAAE,MAAEC,EAAOH,EAAAG,QACtB,OACEC,EAACX,EAA4BY,UAASC,MAAOJ,EAAKK,SAChDH,EAACT,EAA6BU,SAAQ,CAACC,MAAOH,EAAOI,SAClDR,EAAMQ,YAIf,UAEgBC,IACd,OAAOC,EAAWhB,EACpB,UAEgBiB,IACd,OAAOD,EAAWd,EACpB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{__assign as
|
|
2
|
+
import{__assign as r}from"../../../node_modules/tslib/tslib.es6.js";import{jsx as o}from"react/jsx-runtime";import{createContext as e,useContext as i}from"react";import{useFilterReducer as t}from"./hooks.js";import{FilteringColumnProvider as n}from"./hooks/selectedFilteringColumn/provider.js";var l=e({addFilter:function(){},removeFilter:function(){},clearFilter:function(){},filter:function(){return[]},filterConditions:[]});function m(r){var e=r.children;return o(n,{children:o(l.Provider,{value:t(),children:e})})}function c(){return r({},i(l))}export{m as FilterProvider,c as useFilterContext};
|
|
3
3
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsxs as e,jsx as i}from"react/jsx-runtime";import{useRef as t}from"react";import"../filter/provider.js";import{TableFilter as r}from"../filter/components.js";import{
|
|
2
|
+
import{jsxs as e,jsx as i}from"react/jsx-runtime";import{useRef as t}from"react";import"../filter/provider.js";import{TableFilter as r}from"../filter/components.js";import{SortButton as l}from"../sort/components.js";import"../sort/provider.js";import{useResizeColWidthHook as o}from"./resize-col-width-hook.js";function s(s){var n=s.col,d=o({initialWidth:n.initialWidth,minWidth:n.minWidth}),a=d.colWidth,c=d.onMouseDownResizeWidth,m=t(null),h=m.current?a-m.current.clientWidth:a;return e("th",{id:s.id,className:"relative",style:{width:a,maxWidth:a,minWidth:a},children:[e("div",{className:"flex justify-between items-center bg-gray-200 text-gray-600 h-[32px]",children:[i("div",{className:"px-2",style:{maxWidth:h},children:n.label&&i("p",{className:"text-left font-bold text-nowrap overflow-hidden text-ellipsis",children:n.label})}),e("div",{ref:m,className:"flex items-center w-fit shrink-0 gap-1 px-1",children:[!n.disableSort&&i(l,{columnKey:n.key.toString()}),!n.disableFilter&&!!n.label&&i(r,{col:n})]})]}),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};
|
|
3
3
|
//# sourceMappingURL=header.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as e,useCallback as o}from"react";import{DEFAULT_COL_WIDTH as
|
|
1
|
+
import{useState as e,useCallback as o}from"react";import{DEFAULT_COL_WIDTH as t,DEFAULT_MIN_COL_WIDTH as n}from"../constant.js";function u(u){var i,d,r=e(null!==(i=null==u?void 0:u.initialWidth)&&void 0!==i?i:t),c=r[0],m=r[1],s=e(!1),l=s[0],v=s[1],a=null!==(d=null==u?void 0:u.minWidth)&&void 0!==d?d:n,f=o((function(e){if(!l){var o=e.clientX,t=c;document.body.style.cursor="col-resize",document.body.style.userSelect="none";var n=function(e){v(!0);var n=t+(e.clientX-o);m(n>a?n:a)},u=function(){v(!1),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",u),document.body.style.cursor="default",document.body.style.userSelect="auto"};document.addEventListener("mousemove",n),document.addEventListener("mouseup",u)}}),[l,a]);return{colWidth:c,onMouseDownResizeWidth:f}}export{u as useResizeColWidthHook};
|
|
2
2
|
//# sourceMappingURL=resize-col-width-hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize-col-width-hook.js","sources":["../../../../../src/table/header/resize-col-width-hook.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\nimport { DEFAULT_COL_WIDTH, DEFAULT_MIN_COL_WIDTH } from \"../constant\";\n\nexport function useResizeColWidthHook(options?: {\n initialWidth?: number;\n minWidth?: number;\n}) {\n const [colWidth, setColWidth] = useState(\n options?.initialWidth ?? DEFAULT_COL_WIDTH\n );\n\n const cursorStyle = \"col-resize\";\n\n const onMouseDownResizeWidth: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n const startX = e.clientX;\n const startWidth = colWidth;\n\n document.body.style.cursor = cursorStyle;\n document.body.style.userSelect = \"none\";\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n const newWidth = startWidth + (moveEvent.clientX - startX);\n setColWidth(
|
|
1
|
+
{"version":3,"file":"resize-col-width-hook.js","sources":["../../../../../src/table/header/resize-col-width-hook.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\nimport { DEFAULT_COL_WIDTH, DEFAULT_MIN_COL_WIDTH } from \"../constant\";\n\nexport function useResizeColWidthHook(options?: {\n initialWidth?: number;\n minWidth?: number;\n}) {\n const [colWidth, setColWidth] = useState(\n options?.initialWidth ?? DEFAULT_COL_WIDTH\n );\n const [isDragging, setIsDragging] = useState(false);\n const minWidth = options?.minWidth ?? DEFAULT_MIN_COL_WIDTH;\n\n const cursorStyle = \"col-resize\";\n\n const onMouseDownResizeWidth: React.MouseEventHandler<HTMLDivElement> =\n useCallback(\n (e) => {\n if (isDragging) return;\n\n const startX = e.clientX;\n const startWidth = colWidth;\n\n document.body.style.cursor = cursorStyle;\n document.body.style.userSelect = \"none\";\n\n const onMouseMove = (moveEvent: MouseEvent) => {\n setIsDragging(true);\n const newWidth = startWidth + (moveEvent.clientX - startX);\n setColWidth(newWidth > minWidth ? newWidth : minWidth);\n };\n\n const onMouseUp = () => {\n setIsDragging(false);\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n document.body.style.cursor = \"default\";\n document.body.style.userSelect = \"auto\";\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n },\n [isDragging, minWidth]\n );\n\n return {\n colWidth,\n onMouseDownResizeWidth,\n };\n}\n"],"names":["useResizeColWidthHook","options","_c","useState","_a","initialWidth","DEFAULT_COL_WIDTH","colWidth","setColWidth","_d","isDragging","setIsDragging","minWidth","_b","DEFAULT_MIN_COL_WIDTH","onMouseDownResizeWidth","useCallback","e","startX","clientX","startWidth","document","body","style","cursor","userSelect","onMouseMove","moveEvent","newWidth","onMouseUp","removeEventListener","addEventListener"],"mappings":"gIAGM,SAAUA,EAAsBC,WAI9BC,EAA0BC,EACL,QAAzBC,EAAAH,eAAAA,EAASI,oBAAgB,IAAAD,EAAAA,EAAAE,GADpBC,OAAUC,OAGXC,EAA8BN,GAAS,GAAtCO,EAAUD,EAAA,GAAEE,EAAaF,EAAA,GAC1BG,EAAgC,QAArBC,EAAAZ,aAAA,EAAAA,EAASW,gBAAY,IAAAC,EAAAA,EAAAC,EAIhCC,EACJC,GACE,SAACC,GACC,IAAIP,EAAJ,CAEA,IAAMQ,EAASD,EAAEE,QACXC,EAAab,EAEnBc,SAASC,KAAKC,MAAMC,OAVN,aAWdH,SAASC,KAAKC,MAAME,WAAa,OAEjC,IAAMC,EAAc,SAACC,GACnBhB,GAAc,GACd,IAAMiB,EAAWR,GAAcO,EAAUR,QAAUD,GACnDV,EAAYoB,EAAWhB,EAAWgB,EAAWhB,EAC/C,EAEMiB,EAAY,WAChBlB,GAAc,GACdU,SAASS,oBAAoB,YAAaJ,GAC1CL,SAASS,oBAAoB,UAAWD,GACxCR,SAASC,KAAKC,MAAMC,OAAS,UAC7BH,SAASC,KAAKC,MAAME,WAAa,MACnC,EAEAJ,SAASU,iBAAiB,YAAaL,GACvCL,SAASU,iBAAiB,UAAWF,EAvBd,CAwBzB,GACA,CAACnB,EAAYE,IAGjB,MAAO,CACLL,SAAQA,EACRQ,uBAAsBA,EAE1B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useMemo as r,useEffect as t,useCallback as o}from"react";import{usePageContext as e}from"./pagenation/providers.js";import"react/jsx-runtime";import{useFilterContext as n}from"./filter/provider.js";import"./filter/constants.js";import"./sheet/providers.js";import{useFocusActionContext as
|
|
1
|
+
import{useMemo as r,useEffect as t,useCallback as o}from"react";import{usePageContext as e}from"./pagenation/providers.js";import"react/jsx-runtime";import{useFilterContext as n}from"./filter/provider.js";import"./filter/constants.js";import{useColumnsContext as i}from"./sheet/providers.js";import"./filter/hooks/selectedFilteringColumn/provider.js";import{useFocusActionContext as u}from"./focus/provider.js";import{useCheckboxStatusContext as c}from"./checkbox/provider.js";import{useEditActionContext as s}from"./edit/provider.js";import{useSortActionContext as f,useSortTimingContext as l}from"./sort/provider.js";import{useTablePropertyActionContext as p}from"./table-property/provider.js";import{usePasteActionContext as a}from"./paste/provider.js";function d(o){var i=n().filter,u=f(),s=u.sort,d=u.updatedData,m=l(),v=e(),h=v.setRowCount,g=v.pageFilter,j=c().dispatchCheckboxStatus,w=a().setRows,b=p(),k=b.setMaxDisplayColCount,y=b.setMaxDisplayRowCount,x=r((function(){return i(o.rows)}),[i,m,o.rows.length]);t((function(){h(x.length)}),[x.length]);var C=r((function(){return o.checkbox?o.rows.filter((function(r){var t;return null===(t=o.checkbox)||void 0===t?void 0:t.checked(r)})):[]}),[o.checkbox,o.rows]);t((function(){j({type:"SET",payload:{checkedRecords:C}})}),[C]);var D=r((function(){return s(x)}),[x,m]);t((function(){d()}),[o.rows]);var R=r((function(){return g(D)}),[g,D]),S=r((function(){return R.map((function(r){return r.id}))}),[R]),E=r((function(){return new Set(S)}),[S]),M=r((function(){return o.rows.filter((function(r){return E.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}),{})}),[o.rows,E]);return t((function(){k(o.cols.length)}),[o.cols.length]),t((function(){y(S.length)}),[S.length]),t((function(){w(S.map((function(r){return M[r].data})))}),[M]),{cols:o.cols,rowMaps:M,pageRowIds:S}}function m(t,e,n){var c,f,l=u(),p=s(),a=i()[e],d=n[a.key],m="select"===a.type?null===(f=null===(c=a.options)||void 0===c?void 0:c.find((function(r){return r.value===d})))||void 0===f?void 0:f.label:d,v=r((function(){return a.editable?m:a.render?a.render(d,n):m}),[a.editable,m,d,n]);return{type:!a.editable&&a.render?"component":a.type,component:v,focusAtCell:o((function(){l.move(t,e),l.focus(t,e)}),[l,t,e]),onDoubleClickCellToEdit:o((function(r){r.preventDefault(),l.move(t,e),l.focus(t,e),p.startEditing()}),[l,p,t,e])}}export{m as useCell,d 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 } from \"react\";\nimport { DataObject, DataRecord, TPropsTable } from \"./type\";\nimport { usePageContext } from \"./pagenation/providers\";\nimport { useFilterContext } from \"./filter\";\nimport { useFocusActionContext } from \"./focus/provider\";\nimport { useCheckboxStatusContext } from \"./checkbox/provider\";\nimport { useEditActionContext } from \"./edit/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\nexport function useCell(rowIndex: number
|
|
1
|
+
{"version":3,"file":"hook.js","sources":["../../../../src/table/hook.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo } from \"react\";\nimport { DataObject, DataRecord, TColumnType, TPropsTable } from \"./type\";\nimport { usePageContext } from \"./pagenation/providers\";\nimport { useFilterContext } from \"./filter\";\nimport { useFocusActionContext } from \"./focus/provider\";\nimport { useCheckboxStatusContext } from \"./checkbox/provider\";\nimport { useEditActionContext } from \"./edit/provider\";\nimport { useSortActionContext, useSortTimingContext } from \"./sort/provider\";\nimport { useTablePropertyActionContext } from \"./table-property/provider\";\nimport { usePasteActionContext } from \"./paste/provider\";\nimport { useColumnsContext } from \"./sheet/providers\";\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\nexport function useCell(\n rowIndex: number,\n colIndex: number,\n row: DataObject<DataRecord>\n) {\n const focus = useFocusActionContext();\n const editAction = useEditActionContext();\n const col = useColumnsContext()[colIndex];\n const value = row[col.key as string];\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 type: TColumnType | \"component\" =\n !col.editable && col.render ? \"component\" : col.type;\n\n const focusAtCell = useCallback(() => {\n focus.move(rowIndex, colIndex);\n focus.focus(rowIndex, colIndex);\n }, [focus, rowIndex, colIndex]);\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, rowIndex, colIndex]\n );\n\n return {\n type,\n component,\n focusAtCell,\n onDoubleClickCellToEdit,\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","useCell","rowIndex","colIndex","focus","useFocusActionContext","editAction","useEditActionContext","col","useColumnsContext","value","label","options","find","op","component","editable","render","focusAtCell","useCallback","move","onDoubleClickCellToEdit","e","preventDefault","startEditing"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as
|
|
1
|
+
import{__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import{useReducer as o,useEffect as e,useCallback as a,useMemo as n}from"react";import{useColumnValidatesContext as r}from"../sheet/providers.js";import{useFocusStateContext as s}from"../focus/provider.js";var u=function(o,e){var a;switch(e.type){case"setRows":return t(t({},o),{rows:e.payload.rows});case"setCols":return t(t({},o),{cols:e.payload.cols});case"setColValidators":return t(t({},o),{colValidators:e.payload.colValidators});case"setOnUpdateRowFunction":return t(t({},o),{onUpdateRowFunction:e.payload.onUpdateRowFunction});case"onPaste":if(!o.isFocused)return o;var n=e.payload.pasteData,r=o.rows,s=o.cols,u=o.colValidators,l=o.rowIndex,i=o.colIndex;if(!o.onUpdateRowFunction)return o;var c={arguments:[],timing:o.updateParameters.timing+1},d=n.length,p=Math.max.apply(Math,n.map((function(t){return t.length})));if(0===d||0===p)return o;if(n.length+l>r.length)return alert("貼り付け先の行数が足りません。"),o;for(var f=0;f<p;f++){if(!(y=s[i+f]).editable)return alert("編集できない列にデータを貼り付けることはできません。\n\n編集不可列: ".concat(null!==(a=y.label)&&void 0!==a?a:y.key)),o}if(p+i>s.length)return alert("貼り付け先の列数が足りません。"),o;for(f=0;f<d;f++)for(var m=n[f],w=0;w<m.length;w++){var y,g=m[w];if(!(0,u[(y=s[i+w]).key])(g))return o}return n.forEach((function(o,e){var a=t({},r[l+e]),n=!1;o.forEach((function(t,o){var e=s[i+o],r="number"===e.type?Number(t):"select"===e.type?""===t?"":e.options.find((function(o){return o.label===t})).value:t;a[e.key]!==r&&(n=!0,a[e.key]=r)})),n&&c.arguments.push({newRow:a,oldRow:r[l+e]})})),c.arguments.length>0?t(t({},o),{updateParameters:c}):o;case"focus":return t(t({},o),{isFocused:!0,rowIndex:e.payload.rowIndex,colIndex:e.payload.colIndex});case"unfocus":return t(t({},o),{isFocused:!1})}};function l(l){var i=o(u,t(t({},l),{colValidators:{},isFocused:!1,updateParameters:{arguments:[],timing:0}})),c=i[0],d=i[1],p=r(),f=s();e((function(){f.isFocus?d({type:"focus",payload:{rowIndex:f.rowIndex,colIndex:f.colIndex}}):d({type:"unfocus"})}),[f]);var m=a((function(t){d({type:"setRows",payload:{rows:t}})}),[]),w=a((function(t){d({type:"setCols",payload:{cols:t}})}),[]),y=a((function(t){d({type:"setColValidators",payload:{colValidators:t}})}),[]);e((function(){y(p)}),[p]);var g=a((function(t){d({type:"setOnUpdateRowFunction",payload:{onUpdateRowFunction:t}})}),[]),v=a((function(t){d({type:"onPaste",payload:{pasteData:t}})}),[]);return e((function(){c.updateParameters.arguments.length>0&&c.updateParameters.arguments.forEach((function(t){var o,e=t.newRow,a=t.oldRow;null===(o=c.onUpdateRowFunction)||void 0===o||o.call(c,e,a)}))}),[c.updateParameters.timing,c.onUpdateRowFunction]),n((function(){return{setRows:m,setCols:w,setColValidators:y,setOnUpdateRowFunction:g,onPaste:v}}),[])}export{l as usePasteReducer};
|
|
2
2
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../../../../src/table/paste/hooks.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer } from \"react\";\nimport { TPasteReducer, TPasteReducerReturn } from \"./types\";\nimport { useColumnValidatesContext } from \"../sheet/providers\";\nimport { useFocusStateContext } from \"../focus/provider\";\n\nconst reducer: TPasteReducer = (state, action) => {\n switch (action.type) {\n case \"setRows\":\n return { ...state, rows: action.payload.rows };\n case \"setCols\":\n return { ...state, cols: action.payload.cols };\n case \"setColValidators\":\n return { ...state, colValidators: action.payload.colValidators };\n case \"setOnUpdateRowFunction\":\n return {\n ...state,\n onUpdateRowFunction: action.payload.onUpdateRowFunction,\n };\n case \"onPaste\":\n if (!state.isFocused) {\n return state;\n }\n\n const { pasteData } = action.payload;\n const {\n rows,\n cols,\n colValidators,\n rowIndex,\n colIndex,\n onUpdateRowFunction,\n } = state;\n\n if (!onUpdateRowFunction) {\n return state;\n }\n\n const updateParameters = {\n arguments: [] as { newRow: any; oldRow: any }[],\n timing: state.updateParameters.timing + 1,\n };\n\n const rowLength = pasteData.length;\n const colLength = Math.max(...pasteData.map((row) => row.length));\n\n if (rowLength === 0 || colLength === 0) return state;\n\n if (pasteData.length + rowIndex > rows.length) {\n alert(\"貼り付け先の行数が足りません。\");\n return state;\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 as string)\n }`\n );\n return state;\n }\n }\n\n if (colLength + colIndex > cols.length) {\n alert(\"貼り付け先の列数が足りません。\");\n return state;\n }\n\n for (let i = 0; i < rowLength; i++) {\n const pasteRow = pasteData[i];\n\n for (let j = 0; j < pasteRow.length; j++) {\n const pasteValue = pasteRow[j];\n const col = cols[colIndex + j];\n const validate = colValidators[col.key as string];\n\n if (!validate(pasteValue)) {\n return state;\n }\n }\n }\n\n pasteData.forEach((pasteRow, i) => {\n const row = { ...rows[rowIndex + i] };\n let checkUpdatedRow = false;\n\n pasteRow.forEach((pasteValue, j) => {\n const col = cols[colIndex + j];\n const value =\n col.type === \"number\"\n ? Number(pasteValue)\n : col.type === \"select\"\n ? pasteValue === \"\"\n ? \"\"\n : col.options.find((option) => option.label === pasteValue)!\n .value\n : pasteValue;\n if (row[col.key] !== value) {\n checkUpdatedRow = true;\n row[col.key] = value;\n }\n });\n\n if (checkUpdatedRow) {\n updateParameters.arguments.push({\n newRow: row,\n oldRow: rows[rowIndex + i],\n });\n }\n });\n\n if (updateParameters.arguments.length > 0) {\n return { ...state, updateParameters };\n } else {\n return state;\n }\n case \"focus\":\n return {\n ...state,\n isFocused: true,\n rowIndex: action.payload.rowIndex,\n colIndex: action.payload.colIndex,\n };\n case \"unfocus\":\n return { ...state, isFocused: false };\n }\n};\n\nexport function usePasteReducer(initial: {\n rows: any[];\n cols: any[];\n
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../../../../src/table/paste/hooks.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer } from \"react\";\nimport { TPasteReducer, TPasteReducerReturn } from \"./types\";\nimport { useColumnValidatesContext } from \"../sheet/providers\";\nimport { useFocusStateContext } from \"../focus/provider\";\n\nconst reducer: TPasteReducer = (state, action) => {\n switch (action.type) {\n case \"setRows\":\n return { ...state, rows: action.payload.rows };\n case \"setCols\":\n return { ...state, cols: action.payload.cols };\n case \"setColValidators\":\n return { ...state, colValidators: action.payload.colValidators };\n case \"setOnUpdateRowFunction\":\n return {\n ...state,\n onUpdateRowFunction: action.payload.onUpdateRowFunction,\n };\n case \"onPaste\":\n if (!state.isFocused) {\n return state;\n }\n\n const { pasteData } = action.payload;\n const {\n rows,\n cols,\n colValidators,\n rowIndex,\n colIndex,\n onUpdateRowFunction,\n } = state;\n\n if (!onUpdateRowFunction) {\n return state;\n }\n\n const updateParameters = {\n arguments: [] as { newRow: any; oldRow: any }[],\n timing: state.updateParameters.timing + 1,\n };\n\n const rowLength = pasteData.length;\n const colLength = Math.max(...pasteData.map((row) => row.length));\n\n if (rowLength === 0 || colLength === 0) return state;\n\n if (pasteData.length + rowIndex > rows.length) {\n alert(\"貼り付け先の行数が足りません。\");\n return state;\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 as string)\n }`\n );\n return state;\n }\n }\n\n if (colLength + colIndex > cols.length) {\n alert(\"貼り付け先の列数が足りません。\");\n return state;\n }\n\n for (let i = 0; i < rowLength; i++) {\n const pasteRow = pasteData[i];\n\n for (let j = 0; j < pasteRow.length; j++) {\n const pasteValue = pasteRow[j];\n const col = cols[colIndex + j];\n const validate = colValidators[col.key as string];\n\n if (!validate(pasteValue)) {\n return state;\n }\n }\n }\n\n pasteData.forEach((pasteRow, i) => {\n const row = { ...rows[rowIndex + i] };\n let checkUpdatedRow = false;\n\n pasteRow.forEach((pasteValue, j) => {\n const col = cols[colIndex + j];\n const value =\n col.type === \"number\"\n ? Number(pasteValue)\n : col.type === \"select\"\n ? pasteValue === \"\"\n ? \"\"\n : col.options.find((option) => option.label === pasteValue)!\n .value\n : pasteValue;\n if (row[col.key] !== value) {\n checkUpdatedRow = true;\n row[col.key] = value;\n }\n });\n\n if (checkUpdatedRow) {\n updateParameters.arguments.push({\n newRow: row,\n oldRow: rows[rowIndex + i],\n });\n }\n });\n\n if (updateParameters.arguments.length > 0) {\n return { ...state, updateParameters };\n } else {\n return state;\n }\n case \"focus\":\n return {\n ...state,\n isFocused: true,\n rowIndex: action.payload.rowIndex,\n colIndex: action.payload.colIndex,\n };\n case \"unfocus\":\n return { ...state, isFocused: false };\n }\n};\n\nexport function usePasteReducer(initial: {\n rows: any[];\n cols: any[];\n onUpdateRowFunction?: (newRow: any, oldRow: any) => void;\n}): TPasteReducerReturn {\n const [state, dispatch] = useReducer(reducer, {\n ...initial,\n colValidators: {},\n isFocused: false,\n updateParameters: { arguments: [], timing: 0 },\n });\n const validators = useColumnValidatesContext();\n const focus = useFocusStateContext();\n\n useEffect(() => {\n if (focus.isFocus) {\n dispatch({\n type: \"focus\",\n payload: { rowIndex: focus.rowIndex, colIndex: focus.colIndex },\n });\n } else {\n dispatch({ type: \"unfocus\" });\n }\n }, [focus]);\n\n const setRows = useCallback((rows: any[]) => {\n dispatch({ type: \"setRows\", payload: { rows } });\n }, []);\n\n const setCols = useCallback((cols: any[]) => {\n dispatch({ type: \"setCols\", payload: { cols } });\n }, []);\n\n const setColValidators = useCallback(\n (colValidators: { [key: string]: (value: any) => boolean }) => {\n dispatch({ type: \"setColValidators\", payload: { colValidators } });\n },\n []\n );\n\n useEffect(() => {\n setColValidators(validators);\n }, [validators]);\n\n const setOnUpdateRowFunction = useCallback(\n (onUpdateRowFunction?: (newRow: any, oldRow: any) => void) => {\n dispatch({\n type: \"setOnUpdateRowFunction\",\n payload: { onUpdateRowFunction },\n });\n },\n []\n );\n\n const onPaste = useCallback((pasteData: string[][]) => {\n dispatch({ type: \"onPaste\", payload: { pasteData } });\n }, []);\n\n useEffect(() => {\n if (state.updateParameters.arguments.length > 0) {\n state.updateParameters.arguments.forEach(({ newRow, oldRow }) => {\n state.onUpdateRowFunction?.(newRow, oldRow);\n });\n }\n }, [state.updateParameters.timing, state.onUpdateRowFunction]);\n\n const actions: TPasteReducerReturn = useMemo(\n () => ({\n setRows,\n setCols,\n setColValidators,\n setOnUpdateRowFunction,\n onPaste,\n }),\n []\n );\n\n return actions;\n}\n"],"names":["reducer","state","action","type","__assign","rows","payload","cols","colValidators","onUpdateRowFunction","isFocused","pasteData","rows_1","cols_1","rowIndex_1","rowIndex","colIndex_1","colIndex","updateParameters_1","arguments","timing","updateParameters","rowLength","length","colLength","Math","max","apply","map","row","alert","i","col","editable","concat","_a","label","key","pasteRow","j","pasteValue","validate","forEach","checkUpdatedRow","value","Number","options","find","option","push","newRow","oldRow","usePasteReducer","initial","useReducer","dispatch","validators","useColumnValidatesContext","focus","useFocusStateContext","useEffect","isFocus","setRows","useCallback","setCols","setColValidators","setOnUpdateRowFunction","onPaste","_b","call","useMemo"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as o}from"react/jsx-runtime";import{createContext as n,useContext as t}from"react";import{usePasteReducer as r}from"./hooks.js";var i=n({setRows:function(){},setCols:function(){},setColValidators:function(){},setOnUpdateRowFunction:function(){},onPaste:function(){}});function
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{createContext as n,useContext as t}from"react";import{usePasteReducer as r}from"./hooks.js";var i=n({setRows:function(){},setCols:function(){},setColValidators:function(){},setOnUpdateRowFunction:function(){},onPaste:function(){}});function e(n){var t=n.children,e=n.rows,c=n.cols,s=n.onUpdateRowFunction,u=void 0===s?function(){}:s;return o(i.Provider,{value:r({rows:e,cols:c,onUpdateRowFunction:u}),children:t})}function c(){return t(i)}export{e as PasteProvider,c as usePasteActionContext};
|
|
2
2
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sources":["../../../../../src/table/paste/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { TPasteReducerReturn } from \"./types\";\nimport { usePasteReducer } from \"./hooks\";\n\nconst PasteContext = createContext<TPasteReducerReturn>({\n setRows: () => {},\n setCols: () => {},\n setColValidators: () => {},\n setOnUpdateRowFunction: () => {},\n onPaste: () => {},\n});\n\nexport function PasteProvider({\n children,\n rows,\n cols,\n
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../../../../src/table/paste/provider.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { TPasteReducerReturn } from \"./types\";\nimport { usePasteReducer } from \"./hooks\";\n\nconst PasteContext = createContext<TPasteReducerReturn>({\n setRows: () => {},\n setCols: () => {},\n setColValidators: () => {},\n setOnUpdateRowFunction: () => {},\n onPaste: () => {},\n});\n\nexport function PasteProvider({\n children,\n rows,\n cols,\n onUpdateRowFunction = () => {},\n}: {\n children: JSX.Element | JSX.Element[];\n rows: any[];\n cols: any[];\n onUpdateRowFunction?: (newRow: any, oldRow: any) => void;\n}) {\n return (\n <PasteContext.Provider\n value={usePasteReducer({\n rows,\n cols,\n onUpdateRowFunction,\n })}\n >\n {children}\n </PasteContext.Provider>\n );\n}\n\nexport function usePasteActionContext() {\n return useContext(PasteContext);\n}\n"],"names":["PasteContext","createContext","setRows","setCols","setColValidators","setOnUpdateRowFunction","onPaste","PasteProvider","_a","children","rows","cols","_b","onUpdateRowFunction","_jsx","Provider","value","usePasteReducer","usePasteActionContext","useContext"],"mappings":"2IAIA,IAAMA,EAAeC,EAAmC,CACtDC,QAAS,WAAQ,EACjBC,QAAS,WAAQ,EACjBC,iBAAkB,WAAQ,EAC1BC,uBAAwB,WAAQ,EAChCC,QAAS,WAAQ,IAGb,SAAUC,EAAcC,GAC5B,IAAAC,EAAQD,EAAAC,SACRC,EAAIF,EAAAE,KACJC,EAAIH,EAAAG,KACJC,EAAAJ,EAAAK,oBAAAA,OAAsB,IAAAD,EAAA,WAAQ,EAAAA,EAO9B,OACEE,EAACd,EAAae,SACZ,CAAAC,MAAOC,EAAgB,CACrBP,KAAIA,EACJC,KAAIA,EACJE,oBAAmBA,IAGpBJ,SAAAA,GAGP,UAEgBS,IACd,OAAOC,EAAWnB,EACpB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsxs as o,jsx as r}from"react/jsx-runtime";import{memo as t}from"react";import{useFocusActionContext as e}from"../focus/provider.js";import{Checkbox as n}from"../checkbox/components.js";import{TableCell as a}from"../cell/ui/cell.js";var i=t((function(t){var i=e().unfocus,l=JSON.parse(t.dataString),c=t.conditionalFormattingString.split(",");return 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(t.onClickRow?"hover:cursor-pointer":""," ").concat(t.applyRowFormatting?t.applyRowFormatting(l):""),onClick:function(o){o.preventDefault(),t.onClickRow&&(t.onClickRow(l),i())},"data-testid":l.id,children:[t.existCheckbox&&r("td",{children:r(n,{row:l})}),t.cols.map((function(o,e){var n;return r(a,{rowIndex:t.rowIndex,colIndex:e,row:l,columnKey:o.key,isExistOnClickRow:!!t.onClickRow,cellFormatClassName:c[e],isExistOnUpdateRow:!!t.onUpdateRow,editable:null!==(n=o.editable)&&void 0!==n&&n},o.key)}))]})}));export{i 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 {
|
|
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 \"../type\";\nimport { Checkbox } from \"../checkbox/components\";\nimport { TableCell } from \"../cell/ui/cell\";\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 onUpdateRow?: (newRow: any, oldRow: any) => void;\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 rowIndex={props.rowIndex}\n colIndex={j}\n row={row}\n columnKey={col.key as string}\n isExistOnClickRow={!!props.onClickRow}\n cellFormatClassName={conditionalFormatting[j]}\n isExistOnUpdateRow={!!props.onUpdateRow}\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","rowIndex","colIndex","columnKey","key","isExistOnClickRow","cellFormatClassName","isExistOnUpdateRow","onUpdateRow","editable","_a"],"mappings":"oPAiBaA,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,CAERC,SAAU5B,EAAM4B,SAChBC,SAAUH,EACVvB,IAAKA,EACL2B,UAAWL,EAAIM,IACfC,oBAAqBhC,EAAMa,WAC3BoB,oBAAqB1B,EAAsBmB,GAC3CQ,qBAAsBlC,EAAMmC,YAC5BC,SAAsB,QAAZC,EAAAZ,EAAIW,gBAAQ,IAAAC,GAAAA,GARjBZ,EAAIM,UAcrB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r}from"react/jsx-runtime";import{createContext as
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import{createContext as e,useMemo as n,useContext as t}from"react";import{generateValidateFunction as i}from"../libs/generate-validate-function.js";var o=e({cols:[],validates:{}});function u(e){var t=e.children,u=e.cols,a=e.errorHandler,c=n((function(){return u.reduce((function(r,e){return r[e.key]=i(e,a),r}),{})}),[u]),l=n((function(){return{cols:u,validates:c}}),[u]);return r(o.Provider,{value:l,children:t})}function a(){return t(o).cols}function c(r){return t(o).validates[r]}function l(){return t(o).validates}export{u as ColumnsProvider,c as useColumnValidateContext,l as useColumnValidatesContext,a as useColumnsContext};
|
|
3
3
|
//# sourceMappingURL=providers.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teppen/react-ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "React UI Component",
|
|
5
5
|
"main": "dist/cjs/src/index.js",
|
|
6
6
|
"module": "dist/esm/src/index.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"rollup": "npm run clean && rollup -c --bundleConfigAsCjs --forceExit",
|
|
11
11
|
"storybook": "storybook dev -p 6006",
|
|
12
12
|
"build-storybook": "storybook build",
|
|
13
|
-
"test": "jest"
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"test:lint": "tsc --noEmit"
|
|
14
15
|
},
|
|
15
16
|
"author": "Yasufumi Kamiyama <yk.iteppen@gmail.com>",
|
|
16
17
|
"license": "MIT",
|
|
@@ -72,8 +73,5 @@
|
|
|
72
73
|
"front-end",
|
|
73
74
|
"ui",
|
|
74
75
|
"table"
|
|
75
|
-
]
|
|
76
|
-
"dependencies": {
|
|
77
|
-
"react-intersection-observer": "^9.10.3"
|
|
78
|
-
}
|
|
76
|
+
]
|
|
79
77
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cancel-icon.js","sources":["../../../../src/table/cancel-icon.tsx"],"sourcesContent":["import { MdOutlineCancel } from \"react-icons/md\";\n\ntype TPropsCancelIcon = {\n size: number;\n};\n\nexport function CancelIcon(props: TPropsCancelIcon) {\n return <MdOutlineCancel size={`${props.size}px`} />;\n}\n"],"names":["props","_jsx","MdOutlineCancel","size","concat"],"mappings":"2HAMM,SAAqBA,GACzB,OAAOC,MAACC,EAAAA,gBAAe,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACjD"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("../sheet/providers.js"),n=t.createContext({type:"string"});exports.CellProvider=function(o){var u,i,l=o.children,s=o.columnKey,d=r.useColumnContext(s),c=r.useRowContext(),a=c[s],v="select"===d.type?null===(i=null===(u=d.options)||void 0===u?void 0:u.find((function(e){return e.value===a})))||void 0===i?void 0:i.label:a,p=t.useMemo((function(){return d.editable?v:d.render?d.render(a,c):v}),[d.editable,v,a,c]),x=!d.editable&&d.render?"component":d.type,C=t.useMemo((function(){return{component:p,type:x}}),[x,p]);return e.jsx(n.Provider,{value:C,children:l})},exports.useCellContext=function(){return t.useContext(n)};
|
|
2
|
-
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sources":["../../../../../src/table/cell/provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport { TColumnType } from \"../type\";\nimport { useColumnContext, useRowContext } from \"../sheet\";\n\nconst CellContext = createContext<{\n type: TColumnType | \"component\";\n component?: React.ReactNode;\n}>({\n type: \"string\",\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\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 type: TColumnType | \"component\" =\n !col.editable && col.render ? \"component\" : col.type;\n\n const cellStatus = useMemo(\n () => ({\n component,\n type,\n }),\n [type, component]\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","type","_a","children","columnKey","col","useColumnContext","row","useRowContext","value","label","_b","options","find","op","_c","component","useMemo","editable","render","cellStatus","_jsx","jsx","Provider","useContext"],"mappings":"sGAIMA,EAAcC,EAAAA,cAGjB,CACDC,KAAM,gCAGF,SAAuBC,WAC3BC,EAAQD,EAAAC,SACRC,EAASF,EAAAE,UAKHC,EAAMC,mBAAiBF,GACvBG,EAAMC,EAAAA,gBACNC,EAAQF,EAAIH,GAEZM,EACS,WAAbL,EAAIJ,KAC6C,UAAlC,QAAXU,EAAAN,EAAIO,eAAO,IAAAD,OAAA,EAAAA,EAAEE,MAAK,SAACC,GAAO,OAAAA,EAAGL,QAAUA,CAAb,WAAmB,IAAAM,OAAA,EAAAA,EAAEL,MAC/CD,EAEAO,EAAYC,EAAAA,SAAQ,WACxB,OAAIZ,EAAIa,SACCR,EAEAL,EAAIc,OAASd,EAAIc,OAAOV,EAAgBF,GAAOG,CAE1D,GAAG,CAACL,EAAIa,SAAUR,EAAOD,EAAOF,IAE1BN,GACHI,EAAIa,UAAYb,EAAIc,OAAS,YAAcd,EAAIJ,KAE5CmB,EAAaH,WACjB,WAAM,MAAC,CACLD,UAASA,EACTf,KAAIA,KAEN,CAACA,EAAMe,IAGT,OACEK,EAAAC,IAACvB,EAAYwB,SAAQ,CAACd,MAAOW,EAAUjB,SAAGA,GAE9C,oCAGE,OAAOqB,EAAAA,WAAWzB,EACpB"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("../../cancel-icon.js");exports.CellInput=function(r){var u=t.useRef(null);return t.useEffect((function(){u.current&&u.current.focus()}),[u]),e.jsxs("div",{className:"flex justify-between gap-1 w-full items-center",onClick:function(e){e.preventDefault(),e.stopPropagation()},children:[e.jsx("input",{ref:u,className:"w-full py-1 px-2 bg-white text-gray-900",type:"text",value:r.value,onChange:r.onChange,onBlur:r.onBlur,onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(r.reset(),r.endEditing())}}),e.jsx("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){r.reset(),r.endEditing()}),300)},children:e.jsx(n.CancelIcon,{size:16})})]})};
|
|
3
|
-
//# sourceMappingURL=base-input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edit-icon.js","sources":["../../../../src/table/edit-icon.tsx"],"sourcesContent":["import { LiaEdit } from \"react-icons/lia\";\n\ntype TPropsEditIcon = {\n size: number;\n};\n\nexport function EditIcon(props: TPropsEditIcon) {\n return <LiaEdit size={`${props.size}px`} />;\n}\n"],"names":["props","_jsx","LiaEdit","size","concat"],"mappings":"0HAMM,SAAmBA,GACvB,OAAOC,MAACC,EAAAA,QAAO,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cancel-icon.js","sources":["../../../../src/table/cancel-icon.tsx"],"sourcesContent":["import { MdOutlineCancel } from \"react-icons/md\";\n\ntype TPropsCancelIcon = {\n size: number;\n};\n\nexport function CancelIcon(props: TPropsCancelIcon) {\n return <MdOutlineCancel size={`${props.size}px`} />;\n}\n"],"names":["CancelIcon","props","_jsx","MdOutlineCancel","size","concat"],"mappings":"qHAMM,SAAUA,EAAWC,GACzB,OAAOC,EAACC,EAAe,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACjD"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{createContext as r,useContext as n,useMemo as t}from"react";import{useColumnContext as o,useRowContext as i}from"../sheet/providers.js";var u=r({type:"string"});function d(r){var n,d,l=r.children,c=r.columnKey,p=o(c),a=i(),m=a[c],v="select"===p.type?null===(d=null===(n=p.options)||void 0===n?void 0:n.find((function(e){return e.value===m})))||void 0===d?void 0:d.label:m,f=t((function(){return p.editable?v:p.render?p.render(m,a):v}),[p.editable,v,m,a]),s=!p.editable&&p.render?"component":p.type,y=t((function(){return{component:f,type:s}}),[s,f]);return e(u.Provider,{value:y,children:l})}function l(){return n(u)}export{d as CellProvider,l as useCellContext};
|
|
2
|
-
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sources":["../../../../../src/table/cell/provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport { TColumnType } from \"../type\";\nimport { useColumnContext, useRowContext } from \"../sheet\";\n\nconst CellContext = createContext<{\n type: TColumnType | \"component\";\n component?: React.ReactNode;\n}>({\n type: \"string\",\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\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 type: TColumnType | \"component\" =\n !col.editable && col.render ? \"component\" : col.type;\n\n const cellStatus = useMemo(\n () => ({\n component,\n type,\n }),\n [type, component]\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","type","CellProvider","_a","children","columnKey","col","useColumnContext","row","useRowContext","value","label","_b","options","find","op","_c","component","useMemo","editable","render","cellStatus","_jsx","Provider","useCellContext","useContext"],"mappings":"uLAIA,IAAMA,EAAcC,EAGjB,CACDC,KAAM,WAGF,SAAUC,EAAaC,WAC3BC,EAAQD,EAAAC,SACRC,EAASF,EAAAE,UAKHC,EAAMC,EAAiBF,GACvBG,EAAMC,IACNC,EAAQF,EAAIH,GAEZM,EACS,WAAbL,EAAIL,KAC6C,UAAlC,QAAXW,EAAAN,EAAIO,eAAO,IAAAD,OAAA,EAAAA,EAAEE,MAAK,SAACC,GAAO,OAAAA,EAAGL,QAAUA,CAAb,WAAmB,IAAAM,OAAA,EAAAA,EAAEL,MAC/CD,EAEAO,EAAYC,GAAQ,WACxB,OAAIZ,EAAIa,SACCR,EAEAL,EAAIc,OAASd,EAAIc,OAAOV,EAAgBF,GAAOG,CAE1D,GAAG,CAACL,EAAIa,SAAUR,EAAOD,EAAOF,IAE1BP,GACHK,EAAIa,UAAYb,EAAIc,OAAS,YAAcd,EAAIL,KAE5CoB,EAAaH,GACjB,WAAM,MAAC,CACLD,UAASA,EACThB,KAAIA,KAEN,CAACA,EAAMgB,IAGT,OACEK,EAACvB,EAAYwB,SAAQ,CAACb,MAAOW,EAAUjB,SAAGA,GAE9C,UAEgBoB,IACd,OAAOC,EAAW1B,EACpB"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as n,useEffect as r}from"react";import{CancelIcon as o}from"../../cancel-icon.js";function i(i){var u=n(null);return r((function(){u.current&&u.current.focus()}),[u]),e("div",{className:"flex justify-between gap-1 w-full items-center",onClick:function(e){e.preventDefault(),e.stopPropagation()},children:[t("input",{ref:u,className:"w-full py-1 px-2 bg-white text-gray-900",type:"text",value:i.value,onChange:i.onChange,onBlur:i.onBlur,onKeyUp:function(e){e.preventDefault(),"Enter"===e.key?e.target.blur():"Escape"===e.key&&(i.reset(),i.endEditing())}}),t("button",{onMouseDown:function(e){e.preventDefault(),e.stopPropagation(),setTimeout((function(){i.reset(),i.endEditing()}),300)},children:t(o,{size:16})})]})}export{i as CellInput};
|
|
3
|
-
//# sourceMappingURL=base-input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edit-icon.js","sources":["../../../../src/table/edit-icon.tsx"],"sourcesContent":["import { LiaEdit } from \"react-icons/lia\";\n\ntype TPropsEditIcon = {\n size: number;\n};\n\nexport function EditIcon(props: TPropsEditIcon) {\n return <LiaEdit size={`${props.size}px`} />;\n}\n"],"names":["EditIcon","props","_jsx","LiaEdit","size","concat"],"mappings":"8GAMM,SAAUA,EAASC,GACvB,OAAOC,EAACC,EAAO,CAACC,KAAM,GAAGC,OAAAJ,EAAMG,KAAQ,OACzC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|