@shoplflow/templates 0.2.14 → 0.2.16
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/index.cjs +50 -50
- package/dist/index.js +4 -4
- package/package.json +4 -10
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var base = require('@shoplflow/base');
|
|
4
|
-
var
|
|
4
|
+
var React2 = require('react');
|
|
5
5
|
var styled2 = require('@emotion/styled');
|
|
6
6
|
var shoplAssets = require('@shoplflow/shopl-assets');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -12,7 +12,7 @@ var utils = require('@shoplflow/utils');
|
|
|
12
12
|
|
|
13
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
16
16
|
var styled2__default = /*#__PURE__*/_interopDefault(styled2);
|
|
17
17
|
|
|
18
18
|
var __defProp = Object.defineProperty;
|
|
@@ -64,9 +64,9 @@ var StyledRequired = styled2__default.default.div`
|
|
|
64
64
|
line-height: 18px;
|
|
65
65
|
padding-top: 1px;
|
|
66
66
|
`;
|
|
67
|
-
var TitleGroupContext =
|
|
67
|
+
var TitleGroupContext = React2.createContext(null);
|
|
68
68
|
var useTitleGroupContext = () => {
|
|
69
|
-
const context =
|
|
69
|
+
const context = React2.useContext(TitleGroupContext);
|
|
70
70
|
return context != null ? context : { depth: 1 };
|
|
71
71
|
};
|
|
72
72
|
var TitleGroupHelpIcon = ({
|
|
@@ -126,9 +126,9 @@ TitleGroup.Header = Header;
|
|
|
126
126
|
TitleGroup.Actions = Actions;
|
|
127
127
|
TitleGroup.Description = Description;
|
|
128
128
|
exports.TitleGroup = TitleGroup;
|
|
129
|
-
var TableContext =
|
|
129
|
+
var TableContext = React2.createContext(void 0);
|
|
130
130
|
var useTable = () => {
|
|
131
|
-
const context =
|
|
131
|
+
const context = React2.useContext(TableContext);
|
|
132
132
|
if (!context) {
|
|
133
133
|
throw new Error("useTable must be used within a TableProvider");
|
|
134
134
|
}
|
|
@@ -523,7 +523,7 @@ var PAGE_SIZE = [
|
|
|
523
523
|
{ key: "100", label: "100" }
|
|
524
524
|
];
|
|
525
525
|
var useIntersectionObserver = (target, callback, options) => {
|
|
526
|
-
|
|
526
|
+
React2.useEffect(() => {
|
|
527
527
|
if (!target.current) {
|
|
528
528
|
return;
|
|
529
529
|
}
|
|
@@ -544,8 +544,8 @@ var TablePagination = ({
|
|
|
544
544
|
}) => {
|
|
545
545
|
const { table, headerRef, bodyRef, tableScrollRef, footerRef, hasFilterBar, hasToolbar } = useTable();
|
|
546
546
|
const { pageSize, pageIndex } = table.getState().pagination;
|
|
547
|
-
const [isEndOfPage, setIsEndOfPage] =
|
|
548
|
-
const handleScroll =
|
|
547
|
+
const [isEndOfPage, setIsEndOfPage] = React2.useState(false);
|
|
548
|
+
const handleScroll = React2.useCallback(() => {
|
|
549
549
|
if (!headerRef.current || !bodyRef.current || !tableScrollRef.current) {
|
|
550
550
|
return;
|
|
551
551
|
}
|
|
@@ -553,7 +553,7 @@ var TablePagination = ({
|
|
|
553
553
|
headerRef.current.scrollLeft = scrollLeft;
|
|
554
554
|
bodyRef.current.scrollLeft = scrollLeft;
|
|
555
555
|
}, []);
|
|
556
|
-
const onIntersect =
|
|
556
|
+
const onIntersect = React2.useCallback(
|
|
557
557
|
(entries) => {
|
|
558
558
|
const entry = entries[0];
|
|
559
559
|
entry.isIntersecting ? setIsEndOfPage(true) : setIsEndOfPage(false);
|
|
@@ -565,7 +565,7 @@ var TablePagination = ({
|
|
|
565
565
|
threshold: 1,
|
|
566
566
|
rootMargin: "0px 0px -1px"
|
|
567
567
|
});
|
|
568
|
-
const handlePageChange =
|
|
568
|
+
const handlePageChange = React2.useCallback(
|
|
569
569
|
(updater) => {
|
|
570
570
|
const newPage = typeof updater === "function" ? updater(pageIndex) : updater;
|
|
571
571
|
table.setPageIndex(newPage);
|
|
@@ -573,7 +573,7 @@ var TablePagination = ({
|
|
|
573
573
|
},
|
|
574
574
|
[pageIndex, pageSize, table, setCurrentPage]
|
|
575
575
|
);
|
|
576
|
-
const handlePageSizeChange =
|
|
576
|
+
const handlePageSizeChange = React2.useCallback(
|
|
577
577
|
(value) => {
|
|
578
578
|
const newSize = Number(value);
|
|
579
579
|
table.setPageSize(newSize);
|
|
@@ -593,10 +593,10 @@ var TablePagination = ({
|
|
|
593
593
|
};
|
|
594
594
|
return /* @__PURE__ */ jsxRuntime.jsx("col", { style }, column.id);
|
|
595
595
|
}) });
|
|
596
|
-
|
|
596
|
+
React2.useEffect(() => {
|
|
597
597
|
table.setPageSize(defaultPageSize);
|
|
598
598
|
}, [defaultPageSize, table]);
|
|
599
|
-
|
|
599
|
+
React2.useEffect(() => {
|
|
600
600
|
table.setPageIndex(currentPage != null ? currentPage : 0);
|
|
601
601
|
}, [table, currentPage]);
|
|
602
602
|
return /* @__PURE__ */ jsxRuntime.jsxs(BottomContainer, { ref: footerRef, isEndOfPage, hasFilterBar, hasToolbar, children: [
|
|
@@ -629,10 +629,10 @@ var TablePagination = ({
|
|
|
629
629
|
] })
|
|
630
630
|
] });
|
|
631
631
|
};
|
|
632
|
-
var TableFilterBar =
|
|
632
|
+
var TableFilterBar = React2.memo(({ outsideFilters }) => {
|
|
633
633
|
const { table, setFilterValue, hasToolbar } = useTable();
|
|
634
634
|
const filters = table.getState().columnFilters;
|
|
635
|
-
const prevFiltersRef =
|
|
635
|
+
const prevFiltersRef = React2.useRef();
|
|
636
636
|
const onSearch = (value) => {
|
|
637
637
|
setFilterValue(value);
|
|
638
638
|
table.resetColumnFilters();
|
|
@@ -667,7 +667,7 @@ var TableFilterBar = React6.memo(({ outsideFilters }) => {
|
|
|
667
667
|
const filterOption = column.columnDef.meta.filterOptions.find((option) => option.value === value);
|
|
668
668
|
return filterOption ? filterOption.label : value;
|
|
669
669
|
};
|
|
670
|
-
|
|
670
|
+
React2.useEffect(() => {
|
|
671
671
|
const validFilters = outsideFilters == null ? void 0 : outsideFilters.filter((item) => item.value !== void 0 && item.value !== "").map((item) => ({ id: item.id, value: item.value }));
|
|
672
672
|
if (!lodashEs.isEqual(prevFiltersRef.current, validFilters)) {
|
|
673
673
|
prevFiltersRef.current = validFilters;
|
|
@@ -742,14 +742,14 @@ var Table = ({
|
|
|
742
742
|
onSelectedRowsChange,
|
|
743
743
|
onClickRow
|
|
744
744
|
}) => {
|
|
745
|
-
const [sorting, setSorting] =
|
|
746
|
-
const [columnFilters, setColumnFilters] =
|
|
747
|
-
const [globalFilter, setGlobalFilter] =
|
|
748
|
-
const [columnVisibility, setColumnVisibility] =
|
|
749
|
-
const [columnPinning, setColumnPinning] =
|
|
750
|
-
const [rowSelection, setRowSelection] =
|
|
751
|
-
const [filterValue, setFilterValue] =
|
|
752
|
-
const visibleColumns =
|
|
745
|
+
const [sorting, setSorting] = React2.useState([]);
|
|
746
|
+
const [columnFilters, setColumnFilters] = React2.useState([]);
|
|
747
|
+
const [globalFilter, setGlobalFilter] = React2.useState([]);
|
|
748
|
+
const [columnVisibility, setColumnVisibility] = React2.useState({});
|
|
749
|
+
const [columnPinning, setColumnPinning] = React2.useState({});
|
|
750
|
+
const [rowSelection, setRowSelection] = React2.useState({});
|
|
751
|
+
const [filterValue, setFilterValue] = React2.useState("");
|
|
752
|
+
const visibleColumns = React2.useMemo(() => columns.filter((column) => {
|
|
753
753
|
var _a;
|
|
754
754
|
return !((_a = column.meta) == null ? void 0 : _a.hiddenColumn);
|
|
755
755
|
}), [columns]);
|
|
@@ -836,16 +836,16 @@ var Table = ({
|
|
|
836
836
|
manualFiltering,
|
|
837
837
|
manualSorting
|
|
838
838
|
});
|
|
839
|
-
const headerRef =
|
|
840
|
-
const bodyRef =
|
|
841
|
-
const footerRef =
|
|
842
|
-
const tableScrollRef =
|
|
843
|
-
const hasToolbar =
|
|
844
|
-
const hasPagination =
|
|
845
|
-
(child) =>
|
|
839
|
+
const headerRef = React2.useRef(null);
|
|
840
|
+
const bodyRef = React2.useRef(null);
|
|
841
|
+
const footerRef = React2.useRef(null);
|
|
842
|
+
const tableScrollRef = React2.useRef(null);
|
|
843
|
+
const hasToolbar = React2.Children.toArray(children).some((child) => React2.isValidElement(child) && child.type === TableToolbar);
|
|
844
|
+
const hasPagination = React2.Children.toArray(children).some(
|
|
845
|
+
(child) => React2.isValidElement(child) && child.type === TablePagination
|
|
846
846
|
);
|
|
847
|
-
const hasFilterBar =
|
|
848
|
-
(child) =>
|
|
847
|
+
const hasFilterBar = React2.Children.toArray(children).some(
|
|
848
|
+
(child) => React2.isValidElement(child) && child.type === TableFilterBar
|
|
849
849
|
);
|
|
850
850
|
const contextValue = {
|
|
851
851
|
table,
|
|
@@ -862,7 +862,7 @@ var Table = ({
|
|
|
862
862
|
filterValue,
|
|
863
863
|
setFilterValue
|
|
864
864
|
};
|
|
865
|
-
|
|
865
|
+
React2.useEffect(() => {
|
|
866
866
|
if (selectedRows.length === 0) {
|
|
867
867
|
table.resetRowSelection();
|
|
868
868
|
}
|
|
@@ -876,9 +876,9 @@ var FilterMenu = ({ header, onFilterChange, triggerWidth }) => {
|
|
|
876
876
|
var _a;
|
|
877
877
|
const columnFilterValue = header.column.getFilterValue();
|
|
878
878
|
const { filterOptions } = (_a = header.column.columnDef.meta) != null ? _a : {};
|
|
879
|
-
const [maxLabelWidth, setMaxLabelWidth] =
|
|
880
|
-
const labelRefs =
|
|
881
|
-
|
|
879
|
+
const [maxLabelWidth, setMaxLabelWidth] = React2.useState(0);
|
|
880
|
+
const labelRefs = React2.useRef([]);
|
|
881
|
+
React2.useEffect(() => {
|
|
882
882
|
const widths = labelRefs.current.map((ref) => (ref == null ? void 0 : ref.offsetWidth) || 0);
|
|
883
883
|
setMaxLabelWidth(Math.max(...widths, 0));
|
|
884
884
|
}, [filterOptions]);
|
|
@@ -1042,8 +1042,8 @@ var TableHeadTrigger = ({
|
|
|
1042
1042
|
);
|
|
1043
1043
|
};
|
|
1044
1044
|
var TableHeadCell = ({ header, onFilterChange, onSortChange }) => {
|
|
1045
|
-
const tableHeadRef =
|
|
1046
|
-
const [triggerWidth, setTriggerWidth] =
|
|
1045
|
+
const tableHeadRef = React2.useRef(null);
|
|
1046
|
+
const [triggerWidth, setTriggerWidth] = React2.useState(0);
|
|
1047
1047
|
const uniqueClass = `filter-menu-${header.column.id}`;
|
|
1048
1048
|
const [isOpen, setIsOpen] = utils.useOutsideClick({
|
|
1049
1049
|
selector: `.${uniqueClass}`
|
|
@@ -1052,7 +1052,7 @@ var TableHeadCell = ({ header, onFilterChange, onSortChange }) => {
|
|
|
1052
1052
|
const showSortMenu = header.column.getCanSort();
|
|
1053
1053
|
const hasInteraction = showFilterMenu || showSortMenu;
|
|
1054
1054
|
const cursorStyle = hasInteraction ? "pointer" : "default";
|
|
1055
|
-
|
|
1055
|
+
React2.useEffect(() => {
|
|
1056
1056
|
if (tableHeadRef.current) {
|
|
1057
1057
|
setTriggerWidth(tableHeadRef.current.clientWidth);
|
|
1058
1058
|
}
|
|
@@ -1123,7 +1123,7 @@ var FixedTable = ({ tableState }) => {
|
|
|
1123
1123
|
maxHeight = "100%",
|
|
1124
1124
|
emptyRowCount = 8
|
|
1125
1125
|
} = tableState;
|
|
1126
|
-
const handleScroll =
|
|
1126
|
+
const handleScroll = React2.useCallback(() => {
|
|
1127
1127
|
if (!bodyRef.current) {
|
|
1128
1128
|
return;
|
|
1129
1129
|
}
|
|
@@ -1242,7 +1242,7 @@ var FixedTable = ({ tableState }) => {
|
|
|
1242
1242
|
const isPinned = cell.column.getIsPinned();
|
|
1243
1243
|
const isLastLeftPinned = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
1244
1244
|
const isFirstRightPinned = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
1245
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1245
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React2.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1246
1246
|
TableCell,
|
|
1247
1247
|
{
|
|
1248
1248
|
"data-last-left-pinned": isLastLeftPinned,
|
|
@@ -1287,14 +1287,14 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1287
1287
|
maxHeight = "100%",
|
|
1288
1288
|
emptyRowCount = 8
|
|
1289
1289
|
} = tableState;
|
|
1290
|
-
const handleScroll =
|
|
1290
|
+
const handleScroll = React2.useCallback(() => {
|
|
1291
1291
|
if (headerRef.current && bodyRef.current && tableScrollRef.current) {
|
|
1292
1292
|
const scrollLeft = bodyRef.current.scrollLeft;
|
|
1293
1293
|
headerRef.current.scrollLeft = scrollLeft;
|
|
1294
1294
|
tableScrollRef.current.scrollLeft = scrollLeft;
|
|
1295
1295
|
}
|
|
1296
1296
|
}, []);
|
|
1297
|
-
const columnSizeVars =
|
|
1297
|
+
const columnSizeVars = React2__default.default.useMemo(() => {
|
|
1298
1298
|
var _a;
|
|
1299
1299
|
const headers = table.getFlatHeaders();
|
|
1300
1300
|
const colSizes = {};
|
|
@@ -1482,7 +1482,7 @@ var TableMain = ({
|
|
|
1482
1482
|
}) => {
|
|
1483
1483
|
const { table, hasToolbar, hasFilterBar, columnResizing } = useTable();
|
|
1484
1484
|
const { rows } = table.getRowModel();
|
|
1485
|
-
const scrollToFn =
|
|
1485
|
+
const scrollToFn = React2.useCallback((offset) => {
|
|
1486
1486
|
window.scrollTo({
|
|
1487
1487
|
top: offset - 120,
|
|
1488
1488
|
behavior: "smooth"
|
|
@@ -1507,7 +1507,7 @@ var TableMain = ({
|
|
|
1507
1507
|
const paddingTop = displayedRows.length > 0 && hasVirtualRow(displayedRows[0]) ? displayedRows[0].virtualRow.start : 0;
|
|
1508
1508
|
const lastRow = displayedRows[displayedRows.length - 1];
|
|
1509
1509
|
const paddingBottom = displayedRows.length > 0 && lastRow && hasVirtualRow(lastRow) ? rowVirtualizer.getTotalSize() - lastRow.virtualRow.end : 0;
|
|
1510
|
-
|
|
1510
|
+
React2.useEffect(() => {
|
|
1511
1511
|
const pinningState = {
|
|
1512
1512
|
left: [],
|
|
1513
1513
|
right: []
|
|
@@ -1522,8 +1522,8 @@ var TableMain = ({
|
|
|
1522
1522
|
}, []);
|
|
1523
1523
|
const isEmpty = rows.length === 0;
|
|
1524
1524
|
let emptyElement;
|
|
1525
|
-
|
|
1526
|
-
if (
|
|
1525
|
+
React2__default.default.Children.forEach(children, (child) => {
|
|
1526
|
+
if (React2__default.default.isValidElement(child) && child.type === TableEmpty) {
|
|
1527
1527
|
emptyElement = child;
|
|
1528
1528
|
}
|
|
1529
1529
|
});
|
|
@@ -1612,7 +1612,7 @@ exports.Table = Object.assign(Table, {
|
|
|
1612
1612
|
Button: exports.TableButton,
|
|
1613
1613
|
Badge: exports.TableBadge
|
|
1614
1614
|
});
|
|
1615
|
-
var AttachmentListContext =
|
|
1615
|
+
var AttachmentListContext = React2.createContext({});
|
|
1616
1616
|
var AttachmentList = (_a) => {
|
|
1617
1617
|
var _b = _a, {
|
|
1618
1618
|
onClick,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { colorTokens, IconButton, StackContainer, Icon, Tag, Text, Stack, Pagination, Checkbox, Tooltip, ScrollArea, Popper, Menu } from '@shoplflow/base';
|
|
2
|
-
import
|
|
2
|
+
import React2, { createContext, memo, useRef, useEffect, useContext, useState, useCallback, useMemo, Children, isValidElement, Fragment as Fragment$1 } from 'react';
|
|
3
3
|
import styled2 from '@emotion/styled';
|
|
4
4
|
import { RefreshIcon, CloseSmallIcon, HelpLineIcon, DeleteIcon, DescIcon, AscIcon, MoreIcon, UpArrowSolidXsmallIcon, DownArrowSolidXsmallIcon } from '@shoplflow/shopl-assets';
|
|
5
5
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
@@ -1288,7 +1288,7 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1288
1288
|
tableScrollRef.current.scrollLeft = scrollLeft;
|
|
1289
1289
|
}
|
|
1290
1290
|
}, []);
|
|
1291
|
-
const columnSizeVars =
|
|
1291
|
+
const columnSizeVars = React2.useMemo(() => {
|
|
1292
1292
|
var _a;
|
|
1293
1293
|
const headers = table.getFlatHeaders();
|
|
1294
1294
|
const colSizes = {};
|
|
@@ -1516,8 +1516,8 @@ var TableMain = ({
|
|
|
1516
1516
|
}, []);
|
|
1517
1517
|
const isEmpty = rows.length === 0;
|
|
1518
1518
|
let emptyElement;
|
|
1519
|
-
|
|
1520
|
-
if (
|
|
1519
|
+
React2.Children.forEach(children, (child) => {
|
|
1520
|
+
if (React2.isValidElement(child) && child.type === TableEmpty) {
|
|
1521
1521
|
emptyElement = child;
|
|
1522
1522
|
}
|
|
1523
1523
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoplflow/templates",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"@types/react": "^18.2.0",
|
|
52
52
|
"@types/react-dom": "^18.2.1",
|
|
53
53
|
"classnames": "^2.3.2",
|
|
54
|
-
"eslint-plugin-storybook": "9.1.17",
|
|
55
54
|
"storybook": "^10.2.1",
|
|
56
55
|
"storybook-addon-code-editor": "^6.1.3",
|
|
57
56
|
"ts-node": "^10.9.1",
|
|
@@ -59,11 +58,6 @@
|
|
|
59
58
|
"tsup": "7.2.0",
|
|
60
59
|
"typescript": "^5.9.0"
|
|
61
60
|
},
|
|
62
|
-
"eslintConfig": {
|
|
63
|
-
"extends": [
|
|
64
|
-
"plugin:storybook/recommended"
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
61
|
"dependencies": {
|
|
68
62
|
"@floating-ui/core": "^1.5.0",
|
|
69
63
|
"@floating-ui/react": "^0.26.2",
|
|
@@ -77,10 +71,10 @@
|
|
|
77
71
|
"react-datepicker": "^7.3.0",
|
|
78
72
|
"react-dom": "^18.2.0",
|
|
79
73
|
"simplebar-react": "^3.2.6",
|
|
74
|
+
"@shoplflow/base": "^0.46.14",
|
|
80
75
|
"@shoplflow/hada-assets": "^0.1.10",
|
|
81
|
-
"@shoplflow/
|
|
82
|
-
"@shoplflow/
|
|
83
|
-
"@shoplflow/utils": "^0.8.0"
|
|
76
|
+
"@shoplflow/utils": "^0.8.0",
|
|
77
|
+
"@shoplflow/shopl-assets": "^0.12.38"
|
|
84
78
|
},
|
|
85
79
|
"repository": {
|
|
86
80
|
"type": "git",
|