@tachybase/components 0.23.8

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 (174) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/LICENSE +201 -0
  3. package/lib/__builtins__/dayjs.d.ts +4 -0
  4. package/lib/__builtins__/dayjs.js +95 -0
  5. package/lib/__builtins__/hooks/index.d.ts +4 -0
  6. package/lib/__builtins__/hooks/index.js +27 -0
  7. package/lib/__builtins__/hooks/useClickAway.d.ts +5 -0
  8. package/lib/__builtins__/hooks/useClickAway.js +64 -0
  9. package/lib/__builtins__/hooks/useConfig.d.ts +1 -0
  10. package/lib/__builtins__/hooks/useConfig.js +31 -0
  11. package/lib/__builtins__/hooks/usePrefixCls.d.ts +3 -0
  12. package/lib/__builtins__/hooks/usePrefixCls.js +38 -0
  13. package/lib/__builtins__/hooks/useToken.d.ts +6 -0
  14. package/lib/__builtins__/hooks/useToken.js +28 -0
  15. package/lib/__builtins__/index.d.ts +7 -0
  16. package/lib/__builtins__/index.js +33 -0
  17. package/lib/__builtins__/loading.d.ts +1 -0
  18. package/lib/__builtins__/loading.js +40 -0
  19. package/lib/__builtins__/pickDataProps.d.ts +1 -0
  20. package/lib/__builtins__/pickDataProps.js +36 -0
  21. package/lib/__builtins__/portal.d.ts +10 -0
  22. package/lib/__builtins__/portal.js +89 -0
  23. package/lib/__builtins__/render.d.ts +9 -0
  24. package/lib/__builtins__/render.js +99 -0
  25. package/lib/__builtins__/sort.d.ts +73 -0
  26. package/lib/__builtins__/sort.js +126 -0
  27. package/lib/__builtins__/style.d.ts +23 -0
  28. package/lib/__builtins__/style.js +88 -0
  29. package/lib/array-base/index.d.ts +64 -0
  30. package/lib/array-base/index.js +345 -0
  31. package/lib/array-base/style.d.ts +2 -0
  32. package/lib/array-base/style.js +68 -0
  33. package/lib/array-cards/index.d.ts +5 -0
  34. package/lib/array-cards/index.js +166 -0
  35. package/lib/array-cards/style.d.ts +2 -0
  36. package/lib/array-cards/style.js +37 -0
  37. package/lib/array-collapse/index.d.ts +10 -0
  38. package/lib/array-collapse/index.js +199 -0
  39. package/lib/array-collapse/style.d.ts +2 -0
  40. package/lib/array-collapse/style.js +33 -0
  41. package/lib/array-items/index.d.ts +8 -0
  42. package/lib/array-items/index.js +122 -0
  43. package/lib/array-items/style.d.ts +2 -0
  44. package/lib/array-items/style.js +82 -0
  45. package/lib/array-table/index.d.ts +9 -0
  46. package/lib/array-table/index.js +376 -0
  47. package/lib/array-table/style.d.ts +2 -0
  48. package/lib/array-table/style.js +71 -0
  49. package/lib/array-tabs/index.d.ts +4 -0
  50. package/lib/array-tabs/index.js +102 -0
  51. package/lib/cascader/index.d.ts +12 -0
  52. package/lib/cascader/index.js +58 -0
  53. package/lib/checkbox/index.d.ts +5 -0
  54. package/lib/checkbox/index.js +51 -0
  55. package/lib/code-mirror/index.d.ts +3 -0
  56. package/lib/code-mirror/index.js +91 -0
  57. package/lib/date-picker/index.d.ts +2 -0
  58. package/lib/date-picker/index.js +70 -0
  59. package/lib/date-picker/style.d.ts +1 -0
  60. package/lib/date-picker/style.js +1 -0
  61. package/lib/editable/index.d.ts +8 -0
  62. package/lib/editable/index.js +181 -0
  63. package/lib/editable/style.d.ts +2 -0
  64. package/lib/editable/style.js +69 -0
  65. package/lib/form/index.d.ts +12 -0
  66. package/lib/form/index.js +71 -0
  67. package/lib/form-button-group/index.d.ts +27 -0
  68. package/lib/form-button-group/index.js +148 -0
  69. package/lib/form-button-group/style.d.ts +2 -0
  70. package/lib/form-button-group/style.js +41 -0
  71. package/lib/form-collapse/index.d.ts +28 -0
  72. package/lib/form-collapse/index.js +150 -0
  73. package/lib/form-dialog/index.d.ts +26 -0
  74. package/lib/form-dialog/index.js +194 -0
  75. package/lib/form-drawer/index.d.ts +25 -0
  76. package/lib/form-drawer/index.js +187 -0
  77. package/lib/form-grid/index.d.ts +34 -0
  78. package/lib/form-grid/index.js +108 -0
  79. package/lib/form-grid/style.d.ts +2 -0
  80. package/lib/form-grid/style.js +31 -0
  81. package/lib/form-item/hooks/index.d.ts +2 -0
  82. package/lib/form-item/hooks/index.js +23 -0
  83. package/lib/form-item/hooks/useFormItemLayout.d.ts +37 -0
  84. package/lib/form-item/hooks/useFormItemLayout.js +66 -0
  85. package/lib/form-item/hooks/useOverflow.d.ts +5 -0
  86. package/lib/form-item/hooks/useOverflow.js +55 -0
  87. package/lib/form-item/index.d.ts +11 -0
  88. package/lib/form-item/index.js +303 -0
  89. package/lib/form-item/style/animation.d.ts +2 -0
  90. package/lib/form-item/style/animation.js +57 -0
  91. package/lib/form-item/style/grid.d.ts +2 -0
  92. package/lib/form-item/style/grid.js +50 -0
  93. package/lib/form-item/style/index.d.ts +2 -0
  94. package/lib/form-item/style/index.js +387 -0
  95. package/lib/form-item/style/other.d.ts +2 -0
  96. package/lib/form-item/style/other.js +490 -0
  97. package/lib/form-item/types.d.ts +35 -0
  98. package/lib/form-item/types.js +15 -0
  99. package/lib/form-layout/index.d.ts +74 -0
  100. package/lib/form-layout/index.js +96 -0
  101. package/lib/form-layout/useResponsiveFormLayout.d.ts +17 -0
  102. package/lib/form-layout/useResponsiveFormLayout.js +89 -0
  103. package/lib/form-step/index.d.ts +27 -0
  104. package/lib/form-step/index.js +154 -0
  105. package/lib/form-tab/index.d.ts +19 -0
  106. package/lib/form-tab/index.js +150 -0
  107. package/lib/index.d.ts +38 -0
  108. package/lib/index.js +95 -0
  109. package/lib/input/index.d.ts +7 -0
  110. package/lib/input/index.js +57 -0
  111. package/lib/lightbox/constant.d.ts +21 -0
  112. package/lib/lightbox/constant.js +79 -0
  113. package/lib/lightbox/index.d.ts +2 -0
  114. package/lib/lightbox/index.js +37 -0
  115. package/lib/lightbox/interface.d.ts +43 -0
  116. package/lib/lightbox/interface.js +15 -0
  117. package/lib/lightbox/react-image-lightbox.d.ts +197 -0
  118. package/lib/lightbox/react-image-lightbox.js +1431 -0
  119. package/lib/lightbox/style.css +305 -0
  120. package/lib/lightbox/util.d.ts +7 -0
  121. package/lib/lightbox/util.js +71 -0
  122. package/lib/number-picker/index.d.ts +4 -0
  123. package/lib/number-picker/index.js +32 -0
  124. package/lib/password/PasswordStrength.d.ts +9 -0
  125. package/lib/password/PasswordStrength.js +188 -0
  126. package/lib/password/index.d.ts +7 -0
  127. package/lib/password/index.js +85 -0
  128. package/lib/preview-text/index.d.ts +12 -0
  129. package/lib/preview-text/index.js +263 -0
  130. package/lib/preview-text/style.d.ts +2 -0
  131. package/lib/preview-text/style.js +37 -0
  132. package/lib/radio/index.d.ts +8 -0
  133. package/lib/radio/index.js +51 -0
  134. package/lib/reset/index.d.ts +10 -0
  135. package/lib/reset/index.js +67 -0
  136. package/lib/select/index.d.ts +4 -0
  137. package/lib/select/index.js +59 -0
  138. package/lib/select-table/hooks/index.d.ts +5 -0
  139. package/lib/select-table/hooks/index.js +29 -0
  140. package/lib/select-table/hooks/useCheckSlackly.d.ts +16 -0
  141. package/lib/select-table/hooks/useCheckSlackly.js +57 -0
  142. package/lib/select-table/hooks/useFilterOptions.d.ts +3 -0
  143. package/lib/select-table/hooks/useFilterOptions.js +97 -0
  144. package/lib/select-table/hooks/useFlatOptions.d.ts +3 -0
  145. package/lib/select-table/hooks/useFlatOptions.js +46 -0
  146. package/lib/select-table/hooks/useSize.d.ts +9 -0
  147. package/lib/select-table/hooks/useSize.js +48 -0
  148. package/lib/select-table/hooks/useTitleAddon.d.ts +7 -0
  149. package/lib/select-table/hooks/useTitleAddon.js +90 -0
  150. package/lib/select-table/index.d.ts +27 -0
  151. package/lib/select-table/index.js +339 -0
  152. package/lib/select-table/style.d.ts +2 -0
  153. package/lib/select-table/style.js +33 -0
  154. package/lib/select-table/utils.d.ts +78 -0
  155. package/lib/select-table/utils.js +166 -0
  156. package/lib/space/index.d.ts +4 -0
  157. package/lib/space/index.js +49 -0
  158. package/lib/submit/index.d.ts +11 -0
  159. package/lib/submit/index.js +67 -0
  160. package/lib/switch/index.d.ts +2 -0
  161. package/lib/switch/index.js +44 -0
  162. package/lib/time-picker/index.d.ts +2 -0
  163. package/lib/time-picker/index.js +60 -0
  164. package/lib/time-picker/style.d.ts +1 -0
  165. package/lib/time-picker/style.js +1 -0
  166. package/lib/transfer/index.d.ts +2 -0
  167. package/lib/transfer/index.js +56 -0
  168. package/lib/tree-select/index.d.ts +2 -0
  169. package/lib/tree-select/index.js +58 -0
  170. package/lib/upload/index.d.ts +18 -0
  171. package/lib/upload/index.js +159 -0
  172. package/lib/upload/placeholder.d.ts +4 -0
  173. package/lib/upload/placeholder.js +88 -0
  174. package/package.json +31 -0
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useCheckSlackly_exports = {};
20
+ __export(useCheckSlackly_exports, {
21
+ getIndeterminate: () => getIndeterminate,
22
+ useCheckSlackly: () => useCheckSlackly
23
+ });
24
+ module.exports = __toCommonJS(useCheckSlackly_exports);
25
+ var import_utils = require("../utils");
26
+ const getIndeterminate = /* @__PURE__ */ __name((record, flatDataSource, selected, primaryKey = "") => {
27
+ if (selected == null ? void 0 : selected.includes(record[primaryKey])) {
28
+ return void 0;
29
+ }
30
+ const wholeRecord = flatDataSource.find((item) => item[primaryKey] === record[primaryKey]);
31
+ return (0, import_utils.hasSelectedKey)(wholeRecord.children, selected, primaryKey) || void 0;
32
+ }, "getIndeterminate");
33
+ const useCheckSlackly = /* @__PURE__ */ __name((currentSelected, selected, flatDataSource, flatFilteredDataSource, primaryKey = "", checkStrictly) => {
34
+ let isSelected = currentSelected.length > selected.length;
35
+ const currentKey = [...currentSelected, ...selected].find(
36
+ (key) => !(currentSelected.includes(key) && selected.includes(key))
37
+ // 当前变化key不同时存在于两个selected
38
+ );
39
+ const currentRecord = flatFilteredDataSource.find((item) => item[primaryKey] === currentKey);
40
+ const currentTreeKeys = (0, import_utils.getTreeKeys)(currentRecord.children, primaryKey);
41
+ if ((0, import_utils.getCompatibleAllSelected)(selected, currentRecord.children, currentTreeKeys, checkStrictly, primaryKey)) {
42
+ isSelected = false;
43
+ }
44
+ let newSelected = [];
45
+ if (isSelected) {
46
+ newSelected = [.../* @__PURE__ */ new Set([...selected, currentKey, ...currentTreeKeys])];
47
+ } else {
48
+ newSelected = selected.filter((key) => ![currentKey, ...currentTreeKeys].includes(key));
49
+ }
50
+ newSelected = (0, import_utils.completedKeys)(flatDataSource, newSelected, primaryKey);
51
+ return { selectedRowKeys: newSelected };
52
+ }, "useCheckSlackly");
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ getIndeterminate,
56
+ useCheckSlackly
57
+ });
@@ -0,0 +1,3 @@
1
+ type IFilterOption = boolean | ((option: any, keyword: string) => boolean);
2
+ declare const useFilterOptions: (options: any[], searchValue?: string | string[], filterOption?: IFilterOption, checkStrictly?: boolean) => any[];
3
+ export { useFilterOptions };
@@ -0,0 +1,97 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useFilterOptions_exports = {};
30
+ __export(useFilterOptions_exports, {
31
+ useFilterOptions: () => useFilterOptions
32
+ });
33
+ module.exports = __toCommonJS(useFilterOptions_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_schema = require("@tachybase/schema");
36
+ function includes(test, search) {
37
+ return toArray(test).join("").toUpperCase().includes(search);
38
+ }
39
+ __name(includes, "includes");
40
+ function includesOption(option, search) {
41
+ const searched = /* @__PURE__ */ new Set();
42
+ const _includesOption = /* @__PURE__ */ __name((option2) => {
43
+ const keys = Object.keys(option2 || {});
44
+ return keys.some((key) => {
45
+ if (key === "__level") {
46
+ return false;
47
+ }
48
+ const value = option2[key];
49
+ if (React.isValidElement(value)) return false;
50
+ if (key !== "children" && !searched.has(value)) {
51
+ if (typeof value === "object") {
52
+ searched.add(value);
53
+ return _includesOption(value);
54
+ }
55
+ return includes(value, search);
56
+ }
57
+ return false;
58
+ });
59
+ }, "_includesOption");
60
+ return _includesOption(option);
61
+ }
62
+ __name(includesOption, "includesOption");
63
+ function toArray(value) {
64
+ if ((0, import_schema.isArr)(value)) {
65
+ return value;
66
+ }
67
+ return value !== void 0 ? [value] : [];
68
+ }
69
+ __name(toArray, "toArray");
70
+ const useFilterOptions = /* @__PURE__ */ __name((options, searchValue, filterOption, checkStrictly) => React.useMemo(() => {
71
+ if (!searchValue || filterOption === false) {
72
+ return options;
73
+ }
74
+ const filterFunc = (0, import_schema.isFn)(filterOption) ? filterOption : (value, option) => includesOption(option, value.toUpperCase());
75
+ const doFilter = /* @__PURE__ */ __name((arr) => {
76
+ const filterArr = [];
77
+ arr == null ? void 0 : arr.forEach((item) => {
78
+ var _a;
79
+ if ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a.length) {
80
+ const filterChildren = doFilter(item.children);
81
+ if (filterChildren.length) {
82
+ filterArr.push({ ...item, children: filterChildren });
83
+ } else if (filterFunc(searchValue, item) && checkStrictly !== false) {
84
+ filterArr.push({ ...item, children: [] });
85
+ }
86
+ } else if (filterFunc(searchValue, item)) {
87
+ filterArr.push(item);
88
+ }
89
+ });
90
+ return filterArr;
91
+ }, "doFilter");
92
+ return doFilter(options);
93
+ }, [options, searchValue, filterOption]), "useFilterOptions");
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ useFilterOptions
97
+ });
@@ -0,0 +1,3 @@
1
+ declare const useFlatOptions: (tree: any[]) => any[];
2
+ declare const getFlatOptions: (tree: any[]) => any[];
3
+ export { useFlatOptions, getFlatOptions };
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useFlatOptions_exports = {};
20
+ __export(useFlatOptions_exports, {
21
+ getFlatOptions: () => getFlatOptions,
22
+ useFlatOptions: () => useFlatOptions
23
+ });
24
+ module.exports = __toCommonJS(useFlatOptions_exports);
25
+ const useFlatOptions = /* @__PURE__ */ __name((tree) => {
26
+ return getFlatOptions(tree);
27
+ }, "useFlatOptions");
28
+ const getFlatOptions = /* @__PURE__ */ __name((tree) => {
29
+ const flatData = /* @__PURE__ */ __name((data) => {
30
+ let list = [];
31
+ data == null ? void 0 : data.forEach((item) => {
32
+ var _a;
33
+ list = [...list, item];
34
+ if ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a.length) {
35
+ list = [...list, ...flatData(item.children)];
36
+ }
37
+ });
38
+ return list;
39
+ }, "flatData");
40
+ return flatData(tree);
41
+ }, "getFlatOptions");
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ getFlatOptions,
45
+ useFlatOptions
46
+ });
@@ -0,0 +1,9 @@
1
+ import { SizeType } from 'antd/es/config-provider/SizeContext';
2
+ interface ISize {
3
+ (fieldSize: SizeType, searchSize: SizeType, tableSize: SizeType): {
4
+ searchSize: SizeType;
5
+ tableSize: SizeType;
6
+ };
7
+ }
8
+ declare const useSize: ISize;
9
+ export { useSize };
@@ -0,0 +1,48 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useSize_exports = {};
20
+ __export(useSize_exports, {
21
+ useSize: () => useSize
22
+ });
23
+ module.exports = __toCommonJS(useSize_exports);
24
+ const useSize = /* @__PURE__ */ __name((fieldSize = "middle", searchSize, tableSize) => {
25
+ const fieldSizeMap = {
26
+ small: {
27
+ searchSize: "small",
28
+ tableSize: "small"
29
+ },
30
+ default: {
31
+ searchSize: "middle",
32
+ tableSize: "middle"
33
+ },
34
+ large: {
35
+ searchSize: "large",
36
+ tableSize: "default"
37
+ }
38
+ };
39
+ const { searchSize: fieldSearchSize, tableSize: fieldTableSize } = fieldSizeMap[fieldSize] || {};
40
+ return {
41
+ searchSize: searchSize || fieldSearchSize,
42
+ tableSize: tableSize || fieldTableSize
43
+ };
44
+ }, "useSize");
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ useSize
48
+ });
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ declare const useTitleAddon: (selected: any[], flatDataSource: any[], flatFilteredDataSource: any[], primaryKey: string | undefined, mode: string | undefined, disabled: boolean, readOnly: boolean, checkStrictly: boolean | undefined, onChange: (selectedRowKeys: any[], record: any[]) => any) => {
3
+ columnTitle?: undefined;
4
+ } | {
5
+ columnTitle: () => React.JSX.Element;
6
+ };
7
+ export { useTitleAddon };
@@ -0,0 +1,90 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useTitleAddon_exports = {};
30
+ __export(useTitleAddon_exports, {
31
+ useTitleAddon: () => useTitleAddon
32
+ });
33
+ module.exports = __toCommonJS(useTitleAddon_exports);
34
+ var import_react = __toESM(require("react"));
35
+ var import_antd = require("antd");
36
+ var import_utils = require("../utils");
37
+ const newCheckbox = /* @__PURE__ */ __name((selected, flatDataSource, flatFilteredDataSource, primaryKey, disabled, readOnly, checkStrictly, onChange) => () => {
38
+ const checked = Boolean(
39
+ (selected == null ? void 0 : selected.length) && (selected == null ? void 0 : selected.length) === flatDataSource.filter((item) => !item.disabled).length
40
+ );
41
+ const indeterminate = Boolean((selected == null ? void 0 : selected.length) && !checked);
42
+ const onInnerChange = /* @__PURE__ */ __name((e) => {
43
+ if (!readOnly) {
44
+ let isSelected = e.target.checked;
45
+ const usableKeys = flatFilteredDataSource.filter((item) => !item.disabled).map((item) => item == null ? void 0 : item[primaryKey]);
46
+ if ((0, import_utils.getCompatibleAllSelected)(selected, flatFilteredDataSource, usableKeys, checkStrictly, primaryKey)) {
47
+ isSelected = false;
48
+ }
49
+ let newSelected = [];
50
+ if (isSelected) {
51
+ newSelected = [.../* @__PURE__ */ new Set([...selected, ...usableKeys])];
52
+ } else {
53
+ newSelected = selected.filter((key) => !usableKeys.includes(key));
54
+ }
55
+ newSelected = (0, import_utils.completedKeys)(flatDataSource, newSelected, primaryKey);
56
+ onChange == null ? void 0 : onChange(newSelected);
57
+ }
58
+ }, "onInnerChange");
59
+ return /* @__PURE__ */ import_react.default.createElement(
60
+ import_antd.Checkbox,
61
+ {
62
+ key: "titleAddons",
63
+ disabled,
64
+ checked,
65
+ indeterminate,
66
+ onChange: onInnerChange
67
+ }
68
+ );
69
+ }, "newCheckbox");
70
+ const useTitleAddon = /* @__PURE__ */ __name((selected, flatDataSource, flatFilteredDataSource, primaryKey, mode, disabled, readOnly, checkStrictly, onChange) => {
71
+ if (mode === "single") {
72
+ return {};
73
+ }
74
+ return {
75
+ columnTitle: newCheckbox(
76
+ selected,
77
+ flatDataSource,
78
+ flatFilteredDataSource,
79
+ primaryKey,
80
+ disabled,
81
+ readOnly,
82
+ checkStrictly,
83
+ onChange
84
+ )
85
+ };
86
+ }, "useTitleAddon");
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ useTitleAddon
90
+ });
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { ReactFC } from '@tachybase/schema';
3
+ import { SearchProps } from 'antd/lib/input';
4
+ import { ColumnProps, TableProps } from 'antd/lib/table';
5
+ type IFilterOption = boolean | ((option: any, keyword: string) => boolean);
6
+ type IFilterSort = (optionA: any, optionB: any) => number;
7
+ export interface ISelectTableColumnProps extends ColumnProps<any> {
8
+ key: string | number;
9
+ }
10
+ export interface ISelectTableProps extends TableProps<any> {
11
+ mode?: 'multiple' | 'single';
12
+ dataSource?: any[];
13
+ optionAsValue?: boolean;
14
+ valueType?: 'all' | 'parent' | 'child' | 'path';
15
+ showSearch?: boolean;
16
+ searchProps?: SearchProps;
17
+ primaryKey?: string | ((record: any) => string);
18
+ filterOption?: IFilterOption;
19
+ filterSort?: IFilterSort;
20
+ onSearch?: (keyword: string) => void;
21
+ onChange?: (value: any, options: any) => void;
22
+ value?: any;
23
+ }
24
+ export declare const SelectTable: ReactFC<ISelectTableProps> & {
25
+ Column: React.FC<React.PropsWithChildren<ISelectTableColumnProps>>;
26
+ };
27
+ export default SelectTable;