bj-web-components 0.2.28 → 0.2.29
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.js +1 -51
- package/dist/index.mjs +49 -49
- package/dist/style.css +1 -3744
- package/dist/web/BasicInput/BInput.js +1 -208
- package/dist/web/BasicInput/BInput.mjs +132 -164
- package/dist/web/BasicInput/utils.js +1 -47
- package/dist/web/BasicInput/utils.mjs +28 -38
- package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -307
- package/dist/web/CategoryDropdown/CategoryDropdown.mjs +170 -218
- package/dist/web/CheckBox/BCheckBox.js +1 -116
- package/dist/web/CheckBox/BCheckBox.mjs +70 -86
- package/dist/web/CheckBox/Group.js +1 -73
- package/dist/web/CheckBox/Group.mjs +56 -63
- package/dist/web/CheckBox/context.js +1 -5
- package/dist/web/CheckBox/context.mjs +3 -3
- package/dist/web/CheckBox/index.js +1 -8
- package/dist/web/CheckBox/index.mjs +6 -6
- package/dist/web/Dropdown/BDropdown.js +1 -186
- package/dist/web/Dropdown/BDropdown.mjs +106 -132
- package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -77
- package/dist/web/EmptyInputBox/EmptyInputBox.mjs +48 -52
- package/dist/web/FileCard/FileCard.js +1 -157
- package/dist/web/FileCard/FileCard.mjs +82 -112
- package/dist/web/Icon/Icon.js +1 -9
- package/dist/web/Icon/Icon.mjs +6 -6
- package/dist/web/Input/Input.js +1 -181
- package/dist/web/Input/Input.mjs +113 -122
- package/dist/web/InputNumber/BInputNumber.js +1 -311
- package/dist/web/InputNumber/BInputNumber.mjs +167 -275
- package/dist/web/InputNumber/StepHandler.js +1 -69
- package/dist/web/InputNumber/StepHandler.mjs +32 -38
- package/dist/web/InputNumber/hooks/useCursor.js +1 -40
- package/dist/web/InputNumber/hooks/useCursor.mjs +33 -35
- package/dist/web/InputNumber/hooks/useFrame.js +1 -12
- package/dist/web/InputNumber/hooks/useFrame.mjs +6 -9
- package/dist/web/InputNumber/utils/decimal.js +1 -147
- package/dist/web/InputNumber/utils/decimal.mjs +81 -109
- package/dist/web/Modal/Modal.js +1 -84
- package/dist/web/Modal/Modal.mjs +49 -52
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -232
- package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +125 -206
- package/dist/web/Pagination/Pagination.js +1 -328
- package/dist/web/Pagination/Pagination.mjs +178 -254
- package/dist/web/ProductField/ProductField.js +1 -272
- package/dist/web/ProductField/ProductField.mjs +143 -190
- package/dist/web/ProductField/arrow-up.svg.js +1 -3
- package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
- package/dist/web/ProductField/checkbox-no.svg.js +1 -3
- package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
- package/dist/web/ProductField/checkbox-ok.svg.js +1 -3
- package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
- package/dist/web/ProductField/no_data_light.svg.js +1 -3
- package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
- package/dist/web/ProductField/search.svg.js +1 -3
- package/dist/web/ProductField/search.svg.mjs +2 -2
- package/dist/web/ProductField/sort.svg.js +1 -3
- package/dist/web/ProductField/sort.svg.mjs +2 -2
- package/dist/web/SkuInputCard/SkuInputCard.js +1 -276
- package/dist/web/SkuInputCard/SkuInputCard.mjs +149 -188
- package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -3
- package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
- package/dist/web/Switch/Switch.js +1 -70
- package/dist/web/Switch/Switch.mjs +37 -47
- package/dist/web/Table/BTable.js +1 -950
- package/dist/web/Table/BTable.mjs +521 -767
- package/dist/web/Table/Column.js +1 -5
- package/dist/web/Table/Column.mjs +2 -2
- package/dist/web/Table/ColumnGroup.js +1 -5
- package/dist/web/Table/ColumnGroup.mjs +2 -2
- package/dist/web/Table/utils/columns.js +1 -48
- package/dist/web/Table/utils/columns.mjs +30 -35
- package/dist/web/Table/utils/sortFilter.js +1 -84
- package/dist/web/Table/utils/sortFilter.mjs +52 -73
- package/dist/web/Tabs/BTabs.js +1 -150
- package/dist/web/Tabs/BTabs.mjs +98 -118
- package/dist/web/Tabs/TabPane.js +1 -8
- package/dist/web/Tabs/TabPane.mjs +4 -4
- package/dist/web/Tooltip/ConfirmTooltip.js +1 -26
- package/dist/web/Tooltip/ConfirmTooltip.mjs +19 -20
- package/dist/web/Tooltip/ContentTooltip.js +1 -94
- package/dist/web/Tooltip/ContentTooltip.mjs +62 -72
- package/dist/web/Tooltip/ProgressTooltip.js +1 -36
- package/dist/web/Tooltip/ProgressTooltip.mjs +20 -22
- package/dist/web/Tooltip/TooltipWrapper.js +1 -12
- package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
- package/dist/web/Tooltip/useAutoPlacement.js +1 -41
- package/dist/web/Tooltip/useAutoPlacement.mjs +25 -34
- package/dist/web.js +1 -51
- package/dist/web.mjs +49 -49
- package/package.json +1 -1
package/dist/web/Table/Column.js
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
function convertChildrenToColumns(children) {
|
|
5
|
-
return react.Children.toArray(children).flatMap((child, index) => {
|
|
6
|
-
if (!react.isValidElement(child)) return [];
|
|
7
|
-
const props = child.props;
|
|
8
|
-
const { children: nestedChildren, ...columnProps } = props;
|
|
9
|
-
return [{
|
|
10
|
-
...columnProps,
|
|
11
|
-
key: child.key ?? columnProps.key ?? index,
|
|
12
|
-
...nestedChildren ? { children: convertChildrenToColumns(nestedChildren) } : {}
|
|
13
|
-
}];
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
function flattenColumns(columns) {
|
|
17
|
-
return columns.flatMap((column) => "children" in column ? flattenColumns(column.children) : [column]);
|
|
18
|
-
}
|
|
19
|
-
function getDepth(columns) {
|
|
20
|
-
return columns.reduce((depth, column) => Math.max(
|
|
21
|
-
depth,
|
|
22
|
-
"children" in column ? 1 + getDepth(column.children) : 1
|
|
23
|
-
), 1);
|
|
24
|
-
}
|
|
25
|
-
function getLeafCount(column) {
|
|
26
|
-
return "children" in column ? column.children.reduce((count, child) => count + getLeafCount(child), 0) : 1;
|
|
27
|
-
}
|
|
28
|
-
function buildHeaderRows(columns) {
|
|
29
|
-
const maxDepth = getDepth(columns);
|
|
30
|
-
const rows = Array.from({ length: maxDepth }, () => []);
|
|
31
|
-
const visit = (items, depth) => {
|
|
32
|
-
items.forEach((column) => {
|
|
33
|
-
const hasChildren = "children" in column && column.children.length > 0;
|
|
34
|
-
rows[depth].push({
|
|
35
|
-
column,
|
|
36
|
-
colSpan: column.colSpan ?? (hasChildren ? getLeafCount(column) : 1),
|
|
37
|
-
rowSpan: hasChildren ? 1 : maxDepth - depth,
|
|
38
|
-
depth
|
|
39
|
-
});
|
|
40
|
-
if (hasChildren) visit(column.children, depth + 1);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
visit(columns, 0);
|
|
44
|
-
return rows;
|
|
45
|
-
}
|
|
46
|
-
exports.buildHeaderRows = buildHeaderRows;
|
|
47
|
-
exports.convertChildrenToColumns = convertChildrenToColumns;
|
|
48
|
-
exports.flattenColumns = flattenColumns;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");function c(r){return s.Children.toArray(r).flatMap((e,n)=>{if(!s.isValidElement(e))return[];const o=e.props,{children:l,...t}=o;return[{...t,key:e.key??t.key??n,...l?{children:c(l)}:{}}]})}function d(r){return r.flatMap(e=>"children"in e?d(e.children):[e])}function h(r){return r.reduce((e,n)=>Math.max(e,"children"in n?1+h(n.children):1),1)}function u(r){return"children"in r?r.children.reduce((e,n)=>e+u(n),0):1}function f(r){const e=h(r),n=Array.from({length:e},()=>[]),o=(l,t)=>{l.forEach(i=>{const a="children"in i&&i.children.length>0;n[t].push({column:i,colSpan:i.colSpan??(a?u(i):1),rowSpan:a?1:e-t,depth:t}),a&&o(i.children,t+1)})};return o(r,0),n}exports.buildHeaderRows=f;exports.convertChildrenToColumns=c;exports.flattenColumns=d;
|
|
@@ -1,48 +1,43 @@
|
|
|
1
|
-
import { Children, isValidElement } from "react";
|
|
2
|
-
function
|
|
3
|
-
return
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
6
|
-
const { children: nestedChildren, ...columnProps } = props;
|
|
1
|
+
import { Children as d, isValidElement as l } from "react";
|
|
2
|
+
function f(n) {
|
|
3
|
+
return d.toArray(n).flatMap((r, e) => {
|
|
4
|
+
if (!l(r)) return [];
|
|
5
|
+
const o = r.props, { children: a, ...t } = o;
|
|
7
6
|
return [{
|
|
8
|
-
...
|
|
9
|
-
key:
|
|
10
|
-
...
|
|
7
|
+
...t,
|
|
8
|
+
key: r.key ?? t.key ?? e,
|
|
9
|
+
...a ? { children: f(a) } : {}
|
|
11
10
|
}];
|
|
12
11
|
});
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
return
|
|
13
|
+
function p(n) {
|
|
14
|
+
return n.flatMap((r) => "children" in r ? p(r.children) : [r]);
|
|
16
15
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
"children" in
|
|
16
|
+
function c(n) {
|
|
17
|
+
return n.reduce((r, e) => Math.max(
|
|
18
|
+
r,
|
|
19
|
+
"children" in e ? 1 + c(e.children) : 1
|
|
21
20
|
), 1);
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
return "children" in
|
|
22
|
+
function s(n) {
|
|
23
|
+
return "children" in n ? n.children.reduce((r, e) => r + s(e), 0) : 1;
|
|
25
24
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
depth
|
|
37
|
-
});
|
|
38
|
-
if (hasChildren) visit(column.children, depth + 1);
|
|
25
|
+
function C(n) {
|
|
26
|
+
const r = c(n), e = Array.from({ length: r }, () => []), o = (a, t) => {
|
|
27
|
+
a.forEach((i) => {
|
|
28
|
+
const h = "children" in i && i.children.length > 0;
|
|
29
|
+
e[t].push({
|
|
30
|
+
column: i,
|
|
31
|
+
colSpan: i.colSpan ?? (h ? s(i) : 1),
|
|
32
|
+
rowSpan: h ? 1 : r - t,
|
|
33
|
+
depth: t
|
|
34
|
+
}), h && o(i.children, t + 1);
|
|
39
35
|
});
|
|
40
36
|
};
|
|
41
|
-
|
|
42
|
-
return rows;
|
|
37
|
+
return o(n, 0), e;
|
|
43
38
|
}
|
|
44
39
|
export {
|
|
45
|
-
buildHeaderRows,
|
|
46
|
-
convertChildrenToColumns,
|
|
47
|
-
flattenColumns
|
|
40
|
+
C as buildHeaderRows,
|
|
41
|
+
f as convertChildrenToColumns,
|
|
42
|
+
p as flattenColumns
|
|
48
43
|
};
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function getColumnKey(column, index) {
|
|
4
|
-
if (column.key !== void 0 && column.key !== null) {
|
|
5
|
-
return column.key;
|
|
6
|
-
}
|
|
7
|
-
if (column.dataIndex !== void 0) {
|
|
8
|
-
return Array.isArray(column.dataIndex) ? column.dataIndex.join(".") : column.dataIndex;
|
|
9
|
-
}
|
|
10
|
-
return index;
|
|
11
|
-
}
|
|
12
|
-
function renderColumnTitle(title, props) {
|
|
13
|
-
return typeof title === "function" ? title(props) : title;
|
|
14
|
-
}
|
|
15
|
-
function getNextSortOrder(current, directions = ["ascend", "descend", null]) {
|
|
16
|
-
const currentIndex = directions.indexOf(current);
|
|
17
|
-
const nextOrder = directions[currentIndex + 1];
|
|
18
|
-
return nextOrder === void 0 ? directions[0] ?? null : nextOrder;
|
|
19
|
-
}
|
|
20
|
-
function getCompare(column) {
|
|
21
|
-
if (typeof column.sorter === "function") {
|
|
22
|
-
return column.sorter;
|
|
23
|
-
}
|
|
24
|
-
if (column.sorter && typeof column.sorter === "object") {
|
|
25
|
-
return column.sorter.compare;
|
|
26
|
-
}
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
function getMultiplePriority(column) {
|
|
30
|
-
return column.sorter && typeof column.sorter === "object" ? column.sorter.multiple ?? 0 : 0;
|
|
31
|
-
}
|
|
32
|
-
function sortRecords(records, columns, orders, childrenColumnName = "children") {
|
|
33
|
-
const activeSorters = columns.map((column, index) => ({
|
|
34
|
-
column,
|
|
35
|
-
key: getColumnKey(column, index)
|
|
36
|
-
})).filter(({ column, key }) => !("children" in column) && getCompare(column) && orders.get(key)).sort((first, second) => getMultiplePriority(second.column) - getMultiplePriority(first.column));
|
|
37
|
-
if (activeSorters.length === 0) {
|
|
38
|
-
return [...records];
|
|
39
|
-
}
|
|
40
|
-
return [...records].sort((first, second) => {
|
|
41
|
-
for (const { column, key } of activeSorters) {
|
|
42
|
-
const order = orders.get(key);
|
|
43
|
-
const compare = getCompare(column);
|
|
44
|
-
if (order && compare) {
|
|
45
|
-
const result = compare(first, second, order);
|
|
46
|
-
if (result !== 0) {
|
|
47
|
-
return order === "ascend" ? result : -result;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return 0;
|
|
52
|
-
}).map((record) => {
|
|
53
|
-
const children = record[childrenColumnName];
|
|
54
|
-
return Array.isArray(children) ? { ...record, [childrenColumnName]: sortRecords(children, columns, orders, childrenColumnName) } : record;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function filterRecords(records, columns, filters) {
|
|
58
|
-
return columns.reduce((currentRecords, rawColumn, index) => {
|
|
59
|
-
const column = rawColumn;
|
|
60
|
-
const selectedValues = filters.get(getColumnKey(column, index));
|
|
61
|
-
if (!column.onFilter || !(selectedValues == null ? void 0 : selectedValues.length)) {
|
|
62
|
-
return currentRecords;
|
|
63
|
-
}
|
|
64
|
-
return currentRecords.filter((record) => selectedValues.some((value) => {
|
|
65
|
-
var _a;
|
|
66
|
-
return (_a = column.onFilter) == null ? void 0 : _a.call(column, value, record);
|
|
67
|
-
}));
|
|
68
|
-
}, [...records]);
|
|
69
|
-
}
|
|
70
|
-
function getSorterResult(columns, orders) {
|
|
71
|
-
const results = columns.flatMap((rawColumn, index) => {
|
|
72
|
-
const column = rawColumn;
|
|
73
|
-
const key = getColumnKey(column, index);
|
|
74
|
-
const order = orders.get(key);
|
|
75
|
-
return order ? [{ column, order, field: column.dataIndex, columnKey: key }] : [];
|
|
76
|
-
});
|
|
77
|
-
return results.length <= 1 ? results[0] ?? {} : results;
|
|
78
|
-
}
|
|
79
|
-
exports.filterRecords = filterRecords;
|
|
80
|
-
exports.getColumnKey = getColumnKey;
|
|
81
|
-
exports.getNextSortOrder = getNextSortOrder;
|
|
82
|
-
exports.getSorterResult = getSorterResult;
|
|
83
|
-
exports.renderColumnTitle = renderColumnTitle;
|
|
84
|
-
exports.sortRecords = sortRecords;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(t,n){return t.key!==void 0&&t.key!==null?t.key:t.dataIndex!==void 0?Array.isArray(t.dataIndex)?t.dataIndex.join("."):t.dataIndex:n}function x(t,n){return typeof t=="function"?t(n):t}function S(t,n=["ascend","descend",null]){const o=n.indexOf(t),i=n[o+1];return i===void 0?n[0]??null:i}function l(t){if(typeof t.sorter=="function")return t.sorter;if(t.sorter&&typeof t.sorter=="object")return t.sorter.compare}function g(t){return t.sorter&&typeof t.sorter=="object"?t.sorter.multiple??0:0}function p(t,n,o,i="children"){const f=n.map((e,r)=>({column:e,key:a(e,r)})).filter(({column:e,key:r})=>!("children"in e)&&l(e)&&o.get(r)).sort((e,r)=>g(r.column)-g(e.column));return f.length===0?[...t]:[...t].sort((e,r)=>{for(const{column:s,key:c}of f){const u=o.get(c),d=l(s);if(u&&d){const y=d(e,r,u);if(y!==0)return u==="ascend"?y:-y}}return 0}).map(e=>{const r=e[i];return Array.isArray(r)?{...e,[i]:p(r,n,o,i)}:e})}function k(t,n,o){return n.reduce((i,f,e)=>{const r=f,s=o.get(a(r,e));return!r.onFilter||!(s!=null&&s.length)?i:i.filter(c=>s.some(u=>{var d;return(d=r.onFilter)==null?void 0:d.call(r,u,c)}))},[...t])}function v(t,n){const o=t.flatMap((i,f)=>{const e=i,r=a(e,f),s=n.get(r);return s?[{column:e,order:s,field:e.dataIndex,columnKey:r}]:[]});return o.length<=1?o[0]??{}:o}exports.filterRecords=k;exports.getColumnKey=a;exports.getNextSortOrder=S;exports.getSorterResult=v;exports.renderColumnTitle=x;exports.sortRecords=p;
|
|
@@ -1,84 +1,63 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
column,
|
|
33
|
-
key: getColumnKey(column, index)
|
|
34
|
-
})).filter(({ column, key }) => !("children" in column) && getCompare(column) && orders.get(key)).sort((first, second) => getMultiplePriority(second.column) - getMultiplePriority(first.column));
|
|
35
|
-
if (activeSorters.length === 0) {
|
|
36
|
-
return [...records];
|
|
37
|
-
}
|
|
38
|
-
return [...records].sort((first, second) => {
|
|
39
|
-
for (const { column, key } of activeSorters) {
|
|
40
|
-
const order = orders.get(key);
|
|
41
|
-
const compare = getCompare(column);
|
|
42
|
-
if (order && compare) {
|
|
43
|
-
const result = compare(first, second, order);
|
|
44
|
-
if (result !== 0) {
|
|
45
|
-
return order === "ascend" ? result : -result;
|
|
46
|
-
}
|
|
1
|
+
function y(t, n) {
|
|
2
|
+
return t.key !== void 0 && t.key !== null ? t.key : t.dataIndex !== void 0 ? Array.isArray(t.dataIndex) ? t.dataIndex.join(".") : t.dataIndex : n;
|
|
3
|
+
}
|
|
4
|
+
function x(t, n) {
|
|
5
|
+
return typeof t == "function" ? t(n) : t;
|
|
6
|
+
}
|
|
7
|
+
function k(t, n = ["ascend", "descend", null]) {
|
|
8
|
+
const o = n.indexOf(t), i = n[o + 1];
|
|
9
|
+
return i === void 0 ? n[0] ?? null : i;
|
|
10
|
+
}
|
|
11
|
+
function p(t) {
|
|
12
|
+
if (typeof t.sorter == "function")
|
|
13
|
+
return t.sorter;
|
|
14
|
+
if (t.sorter && typeof t.sorter == "object")
|
|
15
|
+
return t.sorter.compare;
|
|
16
|
+
}
|
|
17
|
+
function g(t) {
|
|
18
|
+
return t.sorter && typeof t.sorter == "object" ? t.sorter.multiple ?? 0 : 0;
|
|
19
|
+
}
|
|
20
|
+
function l(t, n, o, i = "children") {
|
|
21
|
+
const s = n.map((r, e) => ({
|
|
22
|
+
column: r,
|
|
23
|
+
key: y(r, e)
|
|
24
|
+
})).filter(({ column: r, key: e }) => !("children" in r) && p(r) && o.get(e)).sort((r, e) => g(e.column) - g(r.column));
|
|
25
|
+
return s.length === 0 ? [...t] : [...t].sort((r, e) => {
|
|
26
|
+
for (const { column: f, key: d } of s) {
|
|
27
|
+
const u = o.get(d), a = p(f);
|
|
28
|
+
if (u && a) {
|
|
29
|
+
const c = a(r, e, u);
|
|
30
|
+
if (c !== 0)
|
|
31
|
+
return u === "ascend" ? c : -c;
|
|
47
32
|
}
|
|
48
33
|
}
|
|
49
34
|
return 0;
|
|
50
|
-
}).map((
|
|
51
|
-
const
|
|
52
|
-
return Array.isArray(
|
|
35
|
+
}).map((r) => {
|
|
36
|
+
const e = r[i];
|
|
37
|
+
return Array.isArray(e) ? { ...r, [i]: l(e, n, o, i) } : r;
|
|
53
38
|
});
|
|
54
39
|
}
|
|
55
|
-
function
|
|
56
|
-
return
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
return currentRecords.filter((record) => selectedValues.some((value) => {
|
|
63
|
-
var _a;
|
|
64
|
-
return (_a = column.onFilter) == null ? void 0 : _a.call(column, value, record);
|
|
40
|
+
function I(t, n, o) {
|
|
41
|
+
return n.reduce((i, s, r) => {
|
|
42
|
+
const e = s, f = o.get(y(e, r));
|
|
43
|
+
return !e.onFilter || !(f != null && f.length) ? i : i.filter((d) => f.some((u) => {
|
|
44
|
+
var a;
|
|
45
|
+
return (a = e.onFilter) == null ? void 0 : a.call(e, u, d);
|
|
65
46
|
}));
|
|
66
|
-
}, [...
|
|
47
|
+
}, [...t]);
|
|
67
48
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const order = orders.get(key);
|
|
73
|
-
return order ? [{ column, order, field: column.dataIndex, columnKey: key }] : [];
|
|
49
|
+
function v(t, n) {
|
|
50
|
+
const o = t.flatMap((i, s) => {
|
|
51
|
+
const r = i, e = y(r, s), f = n.get(e);
|
|
52
|
+
return f ? [{ column: r, order: f, field: r.dataIndex, columnKey: e }] : [];
|
|
74
53
|
});
|
|
75
|
-
return
|
|
54
|
+
return o.length <= 1 ? o[0] ?? {} : o;
|
|
76
55
|
}
|
|
77
56
|
export {
|
|
78
|
-
filterRecords,
|
|
79
|
-
getColumnKey,
|
|
80
|
-
getNextSortOrder,
|
|
81
|
-
getSorterResult,
|
|
82
|
-
renderColumnTitle,
|
|
83
|
-
sortRecords
|
|
57
|
+
I as filterRecords,
|
|
58
|
+
y as getColumnKey,
|
|
59
|
+
k as getNextSortOrder,
|
|
60
|
+
v as getSorterResult,
|
|
61
|
+
x as renderColumnTitle,
|
|
62
|
+
l as sortRecords
|
|
84
63
|
};
|
package/dist/web/Tabs/BTabs.js
CHANGED
|
@@ -1,150 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const react = require("react");
|
|
5
|
-
const TabPane = require("./TabPane.js");
|
|
6
|
-
;/* empty css */
|
|
7
|
-
function classNames(...values) {
|
|
8
|
-
return values.filter(Boolean).join(" ");
|
|
9
|
-
}
|
|
10
|
-
function useMergedState(defaultValue, value) {
|
|
11
|
-
const [innerValue, setInnerValue] = react.useState(defaultValue);
|
|
12
|
-
return [value === void 0 ? innerValue : value, setInnerValue];
|
|
13
|
-
}
|
|
14
|
-
function useLegacyItems(items, children) {
|
|
15
|
-
return react.useMemo(() => {
|
|
16
|
-
if (items) return items.filter((item) => Boolean(item && typeof item === "object" && "key" in item));
|
|
17
|
-
return react.Children.toArray(children).flatMap((child) => {
|
|
18
|
-
if (!react.isValidElement(child)) return [];
|
|
19
|
-
const { tab, tabKey, ...restProps } = child.props;
|
|
20
|
-
const key = tabKey ?? child.key;
|
|
21
|
-
return key === null ? [] : [{ ...restProps, key: String(key), label: tab }];
|
|
22
|
-
});
|
|
23
|
-
}, [children, items]);
|
|
24
|
-
}
|
|
25
|
-
function TabNode({
|
|
26
|
-
active,
|
|
27
|
-
id,
|
|
28
|
-
item,
|
|
29
|
-
onClick,
|
|
30
|
-
onKeyDown,
|
|
31
|
-
tabCount,
|
|
32
|
-
tabIndex
|
|
33
|
-
}) {
|
|
34
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
35
|
-
"button",
|
|
36
|
-
{
|
|
37
|
-
"aria-controls": `${id}-panel-${item.key}`,
|
|
38
|
-
"aria-disabled": item.disabled,
|
|
39
|
-
"aria-selected": active,
|
|
40
|
-
className: classNames("bj-tabs__tab", active && "bj-tabs__tab--active", item.disabled && "bj-tabs__tab--disabled"),
|
|
41
|
-
disabled: item.disabled,
|
|
42
|
-
id: `${id}-tab-${item.key}`,
|
|
43
|
-
onClick,
|
|
44
|
-
onKeyDown,
|
|
45
|
-
role: "tab",
|
|
46
|
-
tabIndex: item.disabled ? -1 : active ? 0 : -1,
|
|
47
|
-
type: "button",
|
|
48
|
-
children: [
|
|
49
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-tabs__tab-btn", children: item.label }),
|
|
50
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-tabs__sr-only", children: `Tab ${tabIndex + 1} of ${tabCount}` })
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
function TabPanelList({ activeKey, id, items }) {
|
|
56
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bj-tabs__content-holder", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bj-tabs__content", children: items.map((item) => {
|
|
57
|
-
const active = item.key === activeKey;
|
|
58
|
-
if (!active && !item.forceRender) return null;
|
|
59
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
-
"div",
|
|
61
|
-
{
|
|
62
|
-
"aria-hidden": !active,
|
|
63
|
-
"aria-labelledby": `${id}-tab-${item.key}`,
|
|
64
|
-
className: classNames("bj-tabs__tabpane", active && "bj-tabs__tabpane--active", item.className),
|
|
65
|
-
id: `${id}-panel-${item.key}`,
|
|
66
|
-
role: "tabpanel",
|
|
67
|
-
style: item.style,
|
|
68
|
-
tabIndex: active ? 0 : -1,
|
|
69
|
-
children: item.children
|
|
70
|
-
},
|
|
71
|
-
item.key
|
|
72
|
-
);
|
|
73
|
-
}) }) });
|
|
74
|
-
}
|
|
75
|
-
function BTabs({
|
|
76
|
-
activeKey,
|
|
77
|
-
children,
|
|
78
|
-
centered,
|
|
79
|
-
className,
|
|
80
|
-
defaultActiveKey,
|
|
81
|
-
id,
|
|
82
|
-
items,
|
|
83
|
-
onChange,
|
|
84
|
-
onTabClick,
|
|
85
|
-
style,
|
|
86
|
-
tabBarGutter,
|
|
87
|
-
tabBarStyle,
|
|
88
|
-
tabPosition = "top",
|
|
89
|
-
type = "line"
|
|
90
|
-
}) {
|
|
91
|
-
const tabs = useLegacyItems(items, children);
|
|
92
|
-
const generatedIdRef = react.useRef(`bj-tabs-${Math.random().toString(36).slice(2, 10)}`);
|
|
93
|
-
const mergedId = id ?? generatedIdRef.current;
|
|
94
|
-
const [mergedActiveKey, setMergedActiveKey] = useMergedState(
|
|
95
|
-
() => {
|
|
96
|
-
var _a;
|
|
97
|
-
return defaultActiveKey ?? ((_a = tabs[0]) == null ? void 0 : _a.key);
|
|
98
|
-
},
|
|
99
|
-
activeKey
|
|
100
|
-
);
|
|
101
|
-
const [activeIndex, setActiveIndex] = react.useState(() => tabs.findIndex((tab) => tab.key === mergedActiveKey));
|
|
102
|
-
react.useEffect(() => {
|
|
103
|
-
var _a;
|
|
104
|
-
let nextActiveIndex = tabs.findIndex((tab) => tab.key === mergedActiveKey);
|
|
105
|
-
if (nextActiveIndex === -1) {
|
|
106
|
-
nextActiveIndex = Math.max(0, Math.min(activeIndex, tabs.length - 1));
|
|
107
|
-
setMergedActiveKey((_a = tabs[nextActiveIndex]) == null ? void 0 : _a.key);
|
|
108
|
-
}
|
|
109
|
-
setActiveIndex(nextActiveIndex);
|
|
110
|
-
}, [activeIndex, mergedActiveKey, setMergedActiveKey, tabs]);
|
|
111
|
-
const activateTab = (key, event) => {
|
|
112
|
-
onTabClick == null ? void 0 : onTabClick(key, event);
|
|
113
|
-
if (key === mergedActiveKey) return;
|
|
114
|
-
setMergedActiveKey(key);
|
|
115
|
-
onChange == null ? void 0 : onChange(key);
|
|
116
|
-
};
|
|
117
|
-
const moveFocus = (event, index) => {
|
|
118
|
-
var _a;
|
|
119
|
-
const isVertical = tabPosition === "left" || tabPosition === "right";
|
|
120
|
-
const nextKey = isVertical ? event.key === "ArrowDown" ? 1 : event.key === "ArrowUp" ? -1 : 0 : event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
121
|
-
if (!nextKey) return;
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
const enabledTabs = tabs.filter((tab) => !tab.disabled);
|
|
124
|
-
const enabledIndex = enabledTabs.findIndex((tab) => {
|
|
125
|
-
var _a2;
|
|
126
|
-
return tab.key === ((_a2 = tabs[index]) == null ? void 0 : _a2.key);
|
|
127
|
-
});
|
|
128
|
-
const nextTab = enabledTabs[(enabledIndex + nextKey + enabledTabs.length) % enabledTabs.length];
|
|
129
|
-
(_a = document.getElementById(`${mergedId}-tab-${nextTab == null ? void 0 : nextTab.key}`)) == null ? void 0 : _a.focus();
|
|
130
|
-
};
|
|
131
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames("bj-tabs", `bj-tabs--${tabPosition}`, `bj-tabs--${type}`, centered && "bj-tabs--centered", className), style, children: [
|
|
132
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bj-tabs__nav", role: "tablist", style: tabBarStyle, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bj-tabs__nav-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bj-tabs__nav-list", children: tabs.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
-
TabNode,
|
|
134
|
-
{
|
|
135
|
-
active: item.key === mergedActiveKey,
|
|
136
|
-
id: mergedId,
|
|
137
|
-
item,
|
|
138
|
-
onClick: (event) => activateTab(item.key, event),
|
|
139
|
-
onKeyDown: (event) => moveFocus(event, index),
|
|
140
|
-
tabCount: tabs.length,
|
|
141
|
-
tabIndex: index
|
|
142
|
-
},
|
|
143
|
-
item.key
|
|
144
|
-
)) }) }) }),
|
|
145
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabPanelList, { activeKey: mergedActiveKey, id: mergedId, items: tabs })
|
|
146
|
-
] });
|
|
147
|
-
}
|
|
148
|
-
BTabs.TabPane = TabPane.TabPane;
|
|
149
|
-
exports.TabPane = TabPane.TabPane;
|
|
150
|
-
exports.default = BTabs;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),c=require("react"),M=require("./TabPane.js");;/* empty css */function I(...s){return s.filter(Boolean).join(" ")}function q(s,n){const[t,a]=c.useState(s);return[n===void 0?t:n,a]}function D(s,n){return c.useMemo(()=>s?s.filter(t=>!!(t&&typeof t=="object"&&"key"in t)):c.Children.toArray(n).flatMap(t=>{if(!c.isValidElement(t))return[];const{tab:a,tabKey:b,...y}=t.props,i=b??t.key;return i===null?[]:[{...y,key:String(i),label:a}]}),[n,s])}function E({active:s,id:n,item:t,onClick:a,onKeyDown:b,tabCount:y,tabIndex:i}){return r.jsxs("button",{"aria-controls":`${n}-panel-${t.key}`,"aria-disabled":t.disabled,"aria-selected":s,className:I("bj-tabs__tab",s&&"bj-tabs__tab--active",t.disabled&&"bj-tabs__tab--disabled"),disabled:t.disabled,id:`${n}-tab-${t.key}`,onClick:a,onKeyDown:b,role:"tab",tabIndex:t.disabled?-1:s?0:-1,type:"button",children:[r.jsx("span",{className:"bj-tabs__tab-btn",children:t.label}),r.jsx("span",{className:"bj-tabs__sr-only",children:`Tab ${i+1} of ${y}`})]})}function L({activeKey:s,id:n,items:t}){return r.jsx("div",{className:"bj-tabs__content-holder",children:r.jsx("div",{className:"bj-tabs__content",children:t.map(a=>{const b=a.key===s;return!b&&!a.forceRender?null:r.jsx("div",{"aria-hidden":!b,"aria-labelledby":`${n}-tab-${a.key}`,className:I("bj-tabs__tabpane",b&&"bj-tabs__tabpane--active",a.className),id:`${n}-panel-${a.key}`,role:"tabpanel",style:a.style,tabIndex:b?0:-1,children:a.children},a.key)})})})}function m({activeKey:s,children:n,centered:t,className:a,defaultActiveKey:b,id:y,items:i,onChange:f,onTabClick:_,style:w,tabBarGutter:F,tabBarStyle:S,tabPosition:x="top",type:T="line"}){const l=D(i,n),K=c.useRef(`bj-tabs-${Math.random().toString(36).slice(2,10)}`),p=y??K.current,[o,v]=q(()=>{var e;return b??((e=l[0])==null?void 0:e.key)},s),[$,P]=c.useState(()=>l.findIndex(e=>e.key===o));c.useEffect(()=>{var d;let e=l.findIndex(u=>u.key===o);e===-1&&(e=Math.max(0,Math.min($,l.length-1)),v((d=l[e])==null?void 0:d.key)),P(e)},[$,o,v,l]);const B=(e,d)=>{_==null||_(e,d),e!==o&&(v(e),f==null||f(e))},R=(e,d)=>{var N;const g=x==="left"||x==="right"?e.key==="ArrowDown"?1:e.key==="ArrowUp"?-1:0:e.key==="ArrowRight"?1:e.key==="ArrowLeft"?-1:0;if(!g)return;e.preventDefault();const j=l.filter(h=>!h.disabled),V=j.findIndex(h=>{var A;return h.key===((A=l[d])==null?void 0:A.key)}),k=j[(V+g+j.length)%j.length];(N=document.getElementById(`${p}-tab-${k==null?void 0:k.key}`))==null||N.focus()};return r.jsxs("div",{className:I("bj-tabs",`bj-tabs--${x}`,`bj-tabs--${T}`,t&&"bj-tabs--centered",a),style:w,children:[r.jsx("div",{className:"bj-tabs__nav",role:"tablist",style:S,children:r.jsx("div",{className:"bj-tabs__nav-wrap",children:r.jsx("div",{className:"bj-tabs__nav-list",children:l.map((e,d)=>r.jsx(E,{active:e.key===o,id:p,item:e,onClick:u=>B(e.key,u),onKeyDown:u=>R(u,d),tabCount:l.length,tabIndex:d},e.key))})})}),r.jsx(L,{activeKey:o,id:p,items:l})]})}m.TabPane=M.TabPane;exports.TabPane=M.TabPane;exports.default=m;
|