bj-web-components 0.2.27 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/index.js +51 -1
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +3744 -1
  4. package/dist/web/BasicInput/BInput.js +208 -1
  5. package/dist/web/BasicInput/BInput.mjs +164 -132
  6. package/dist/web/BasicInput/utils.js +47 -1
  7. package/dist/web/BasicInput/utils.mjs +38 -28
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -1
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +218 -170
  10. package/dist/web/CheckBox/BCheckBox.js +116 -1
  11. package/dist/web/CheckBox/BCheckBox.mjs +86 -70
  12. package/dist/web/CheckBox/Group.js +73 -1
  13. package/dist/web/CheckBox/Group.mjs +63 -56
  14. package/dist/web/CheckBox/context.js +5 -1
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +8 -1
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +186 -1
  19. package/dist/web/Dropdown/BDropdown.mjs +132 -106
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -1
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +52 -48
  22. package/dist/web/FileCard/FileCard.js +157 -1
  23. package/dist/web/FileCard/FileCard.mjs +112 -82
  24. package/dist/web/Icon/Icon.js +9 -1
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +181 -1
  27. package/dist/web/Input/Input.mjs +122 -113
  28. package/dist/web/InputNumber/BInputNumber.js +311 -1
  29. package/dist/web/InputNumber/BInputNumber.mjs +275 -167
  30. package/dist/web/InputNumber/StepHandler.js +69 -1
  31. package/dist/web/InputNumber/StepHandler.mjs +38 -32
  32. package/dist/web/InputNumber/hooks/useCursor.js +40 -1
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +35 -33
  34. package/dist/web/InputNumber/hooks/useFrame.js +12 -1
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +9 -6
  36. package/dist/web/InputNumber/utils/decimal.js +147 -1
  37. package/dist/web/InputNumber/utils/decimal.mjs +109 -81
  38. package/dist/web/Modal/Modal.js +84 -1
  39. package/dist/web/Modal/Modal.mjs +52 -49
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -1
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +206 -125
  42. package/dist/web/Pagination/Pagination.js +328 -1
  43. package/dist/web/Pagination/Pagination.mjs +254 -178
  44. package/dist/web/ProductField/ProductField.js +272 -1
  45. package/dist/web/ProductField/ProductField.mjs +190 -143
  46. package/dist/web/ProductField/arrow-up.svg.js +3 -1
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +3 -1
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +3 -1
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +3 -1
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +3 -1
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +3 -1
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +276 -1
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +188 -149
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -1
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +70 -1
  63. package/dist/web/Switch/Switch.mjs +47 -37
  64. package/dist/web/Table/BTable.js +950 -1
  65. package/dist/web/Table/BTable.mjs +771 -519
  66. package/dist/web/Table/Column.js +5 -1
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +5 -1
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +48 -1
  71. package/dist/web/Table/utils/columns.mjs +35 -30
  72. package/dist/web/Table/utils/sortFilter.js +84 -1
  73. package/dist/web/Table/utils/sortFilter.mjs +73 -52
  74. package/dist/web/Tabs/BTabs.js +150 -1
  75. package/dist/web/Tabs/BTabs.mjs +118 -98
  76. package/dist/web/Tabs/TabPane.js +8 -1
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +26 -1
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +20 -19
  80. package/dist/web/Tooltip/ContentTooltip.js +94 -1
  81. package/dist/web/Tooltip/ContentTooltip.mjs +72 -62
  82. package/dist/web/Tooltip/ProgressTooltip.js +36 -1
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +22 -20
  84. package/dist/web/Tooltip/TooltipWrapper.js +12 -1
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +41 -1
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +34 -25
  88. package/dist/web.js +51 -1
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1 +1,5 @@
1
- "use strict";function n(t){return null}module.exports=n;
1
+ "use strict";
2
+ function Column(_) {
3
+ return null;
4
+ }
5
+ module.exports = Column;
@@ -1,6 +1,6 @@
1
- function u(n) {
1
+ function Column(_) {
2
2
  return null;
3
3
  }
4
4
  export {
5
- u as default
5
+ Column as default
6
6
  };
@@ -1 +1,5 @@
1
- "use strict";function u(n){return null}module.exports=u;
1
+ "use strict";
2
+ function ColumnGroup(_) {
3
+ return null;
4
+ }
5
+ module.exports = ColumnGroup;
@@ -1,6 +1,6 @@
1
- function n(u) {
1
+ function ColumnGroup(_) {
2
2
  return null;
3
3
  }
4
4
  export {
5
- n as default
5
+ ColumnGroup as default
6
6
  };
@@ -1 +1,48 @@
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
+ "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,43 +1,48 @@
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;
1
+ import { Children, isValidElement } from "react";
2
+ function convertChildrenToColumns(children) {
3
+ return Children.toArray(children).flatMap((child, index) => {
4
+ if (!isValidElement(child)) return [];
5
+ const props = child.props;
6
+ const { children: nestedChildren, ...columnProps } = props;
6
7
  return [{
7
- ...t,
8
- key: r.key ?? t.key ?? e,
9
- ...a ? { children: f(a) } : {}
8
+ ...columnProps,
9
+ key: child.key ?? columnProps.key ?? index,
10
+ ...nestedChildren ? { children: convertChildrenToColumns(nestedChildren) } : {}
10
11
  }];
11
12
  });
12
13
  }
13
- function p(n) {
14
- return n.flatMap((r) => "children" in r ? p(r.children) : [r]);
14
+ function flattenColumns(columns) {
15
+ return columns.flatMap((column) => "children" in column ? flattenColumns(column.children) : [column]);
15
16
  }
16
- function c(n) {
17
- return n.reduce((r, e) => Math.max(
18
- r,
19
- "children" in e ? 1 + c(e.children) : 1
17
+ function getDepth(columns) {
18
+ return columns.reduce((depth, column) => Math.max(
19
+ depth,
20
+ "children" in column ? 1 + getDepth(column.children) : 1
20
21
  ), 1);
21
22
  }
22
- function s(n) {
23
- return "children" in n ? n.children.reduce((r, e) => r + s(e), 0) : 1;
23
+ function getLeafCount(column) {
24
+ return "children" in column ? column.children.reduce((count, child) => count + getLeafCount(child), 0) : 1;
24
25
  }
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);
26
+ function buildHeaderRows(columns) {
27
+ const maxDepth = getDepth(columns);
28
+ const rows = Array.from({ length: maxDepth }, () => []);
29
+ const visit = (items, depth) => {
30
+ items.forEach((column) => {
31
+ const hasChildren = "children" in column && column.children.length > 0;
32
+ rows[depth].push({
33
+ column,
34
+ colSpan: column.colSpan ?? (hasChildren ? getLeafCount(column) : 1),
35
+ rowSpan: hasChildren ? 1 : maxDepth - depth,
36
+ depth
37
+ });
38
+ if (hasChildren) visit(column.children, depth + 1);
35
39
  });
36
40
  };
37
- return o(n, 0), e;
41
+ visit(columns, 0);
42
+ return rows;
38
43
  }
39
44
  export {
40
- C as buildHeaderRows,
41
- f as convertChildrenToColumns,
42
- p as flattenColumns
45
+ buildHeaderRows,
46
+ convertChildrenToColumns,
47
+ flattenColumns
43
48
  };
@@ -1 +1,84 @@
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
+ "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,63 +1,84 @@
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;
1
+ function getColumnKey(column, index) {
2
+ if (column.key !== void 0 && column.key !== null) {
3
+ return column.key;
4
+ }
5
+ if (column.dataIndex !== void 0) {
6
+ return Array.isArray(column.dataIndex) ? column.dataIndex.join(".") : column.dataIndex;
7
+ }
8
+ return index;
9
+ }
10
+ function renderColumnTitle(title, props) {
11
+ return typeof title === "function" ? title(props) : title;
12
+ }
13
+ function getNextSortOrder(current, directions = ["ascend", "descend", null]) {
14
+ const currentIndex = directions.indexOf(current);
15
+ const nextOrder = directions[currentIndex + 1];
16
+ return nextOrder === void 0 ? directions[0] ?? null : nextOrder;
17
+ }
18
+ function getCompare(column) {
19
+ if (typeof column.sorter === "function") {
20
+ return column.sorter;
21
+ }
22
+ if (column.sorter && typeof column.sorter === "object") {
23
+ return column.sorter.compare;
24
+ }
25
+ return void 0;
26
+ }
27
+ function getMultiplePriority(column) {
28
+ return column.sorter && typeof column.sorter === "object" ? column.sorter.multiple ?? 0 : 0;
29
+ }
30
+ function sortRecords(records, columns, orders, childrenColumnName = "children") {
31
+ const activeSorters = columns.map((column, index) => ({
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
+ }
32
47
  }
33
48
  }
34
49
  return 0;
35
- }).map((r) => {
36
- const e = r[i];
37
- return Array.isArray(e) ? { ...r, [i]: l(e, n, o, i) } : r;
50
+ }).map((record) => {
51
+ const children = record[childrenColumnName];
52
+ return Array.isArray(children) ? { ...record, [childrenColumnName]: sortRecords(children, columns, orders, childrenColumnName) } : record;
38
53
  });
39
54
  }
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);
55
+ function filterRecords(records, columns, filters) {
56
+ return columns.reduce((currentRecords, rawColumn, index) => {
57
+ const column = rawColumn;
58
+ const selectedValues = filters.get(getColumnKey(column, index));
59
+ if (!column.onFilter || !(selectedValues == null ? void 0 : selectedValues.length)) {
60
+ return currentRecords;
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);
46
65
  }));
47
- }, [...t]);
66
+ }, [...records]);
48
67
  }
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 }] : [];
68
+ function getSorterResult(columns, orders) {
69
+ const results = columns.flatMap((rawColumn, index) => {
70
+ const column = rawColumn;
71
+ const key = getColumnKey(column, index);
72
+ const order = orders.get(key);
73
+ return order ? [{ column, order, field: column.dataIndex, columnKey: key }] : [];
53
74
  });
54
- return o.length <= 1 ? o[0] ?? {} : o;
75
+ return results.length <= 1 ? results[0] ?? {} : results;
55
76
  }
56
77
  export {
57
- I as filterRecords,
58
- y as getColumnKey,
59
- k as getNextSortOrder,
60
- v as getSorterResult,
61
- x as renderColumnTitle,
62
- l as sortRecords
78
+ filterRecords,
79
+ getColumnKey,
80
+ getNextSortOrder,
81
+ getSorterResult,
82
+ renderColumnTitle,
83
+ sortRecords
63
84
  };
@@ -1 +1,150 @@
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;
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;