@hanwenbo/x-web-pro-components 0.0.1

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 (150) hide show
  1. package/LICENSE +21 -0
  2. package/es/blocks/index.d.ts +1 -0
  3. package/es/blocks/index.js +2 -0
  4. package/es/blocks/shared.d.ts +24 -0
  5. package/es/blocks/shared.js +77 -0
  6. package/es/components/card/index.d.ts +82 -0
  7. package/es/components/card/index.js +361 -0
  8. package/es/components/descriptions/index.d.ts +31 -0
  9. package/es/components/descriptions/index.js +434 -0
  10. package/es/components/field/index.d.ts +75 -0
  11. package/es/components/field/index.js +761 -0
  12. package/es/components/form/captcha.d.ts +19 -0
  13. package/es/components/form/captcha.js +165 -0
  14. package/es/components/form/colorPicker.d.ts +7 -0
  15. package/es/components/form/colorPicker.js +73 -0
  16. package/es/components/form/fieldControls.d.ts +43 -0
  17. package/es/components/form/fieldControls.js +282 -0
  18. package/es/components/form/index.d.ts +285 -0
  19. package/es/components/form/index.js +2268 -0
  20. package/es/components/form/loginForm.d.ts +22 -0
  21. package/es/components/form/loginForm.js +159 -0
  22. package/es/components/form/schemaForm.d.ts +30 -0
  23. package/es/components/form/schemaForm.js +644 -0
  24. package/es/components/form/stepsForm.d.ts +26 -0
  25. package/es/components/form/stepsForm.js +183 -0
  26. package/es/components/form/uploadButton.d.ts +20 -0
  27. package/es/components/form/uploadButton.js +134 -0
  28. package/es/components/form/uploadDragger.d.ts +13 -0
  29. package/es/components/form/uploadDragger.js +144 -0
  30. package/es/components/index.d.ts +9 -0
  31. package/es/components/index.js +9 -0
  32. package/es/components/layout/components/Help/index.d.ts +72 -0
  33. package/es/components/layout/components/Help/index.js +350 -0
  34. package/es/components/layout/index.d.ts +182 -0
  35. package/es/components/layout/index.js +892 -0
  36. package/es/components/list/index.d.ts +80 -0
  37. package/es/components/list/index.js +431 -0
  38. package/es/components/provider/context.d.ts +7 -0
  39. package/es/components/provider/context.js +21 -0
  40. package/es/components/provider/index.d.ts +28 -0
  41. package/es/components/provider/index.js +117 -0
  42. package/es/components/provider/intl.d.ts +38 -0
  43. package/es/components/provider/intl.js +112 -0
  44. package/es/components/provider/types.d.ts +37 -0
  45. package/es/components/provider/types.js +1 -0
  46. package/es/components/provider/useStyle/index.d.ts +28 -0
  47. package/es/components/provider/useStyle/index.js +208 -0
  48. package/es/components/skeleton/index.d.ts +61 -0
  49. package/es/components/skeleton/index.js +388 -0
  50. package/es/components/table/dragSortTable.d.ts +8 -0
  51. package/es/components/table/dragSortTable.js +229 -0
  52. package/es/components/table/editableTable.d.ts +31 -0
  53. package/es/components/table/editableTable.js +507 -0
  54. package/es/components/table/index.d.ts +52 -0
  55. package/es/components/table/index.js +1554 -0
  56. package/es/components/table/listToolBar.d.ts +48 -0
  57. package/es/components/table/listToolBar.js +194 -0
  58. package/es/components/table/search.d.ts +5 -0
  59. package/es/components/table/search.js +13 -0
  60. package/es/index.d.ts +4 -0
  61. package/es/index.js +4 -0
  62. package/es/types.d.ts +219 -0
  63. package/es/types.js +1 -0
  64. package/es/utils/attachPropertiesToComponent.d.ts +1 -0
  65. package/es/utils/attachPropertiesToComponent.js +6 -0
  66. package/es/utils/getRequestParams.d.ts +19 -0
  67. package/es/utils/getRequestParams.js +57 -0
  68. package/es/utils/getTableListColumns.d.ts +20 -0
  69. package/es/utils/getTableListColumns.js +36 -0
  70. package/es/utils/index.d.ts +4 -0
  71. package/es/utils/index.js +4 -0
  72. package/es/utils/loading.d.ts +3 -0
  73. package/es/utils/loading.js +25 -0
  74. package/es/version.d.ts +2 -0
  75. package/es/version.js +2 -0
  76. package/lib/blocks/index.d.ts +1 -0
  77. package/lib/blocks/index.js +5 -0
  78. package/lib/blocks/shared.d.ts +24 -0
  79. package/lib/blocks/shared.js +83 -0
  80. package/lib/components/card/index.d.ts +82 -0
  81. package/lib/components/card/index.js +368 -0
  82. package/lib/components/descriptions/index.d.ts +31 -0
  83. package/lib/components/descriptions/index.js +440 -0
  84. package/lib/components/field/index.d.ts +75 -0
  85. package/lib/components/field/index.js +767 -0
  86. package/lib/components/form/captcha.d.ts +19 -0
  87. package/lib/components/form/captcha.js +172 -0
  88. package/lib/components/form/colorPicker.d.ts +7 -0
  89. package/lib/components/form/colorPicker.js +79 -0
  90. package/lib/components/form/fieldControls.d.ts +43 -0
  91. package/lib/components/form/fieldControls.js +288 -0
  92. package/lib/components/form/index.d.ts +285 -0
  93. package/lib/components/form/index.js +2332 -0
  94. package/lib/components/form/loginForm.d.ts +22 -0
  95. package/lib/components/form/loginForm.js +165 -0
  96. package/lib/components/form/schemaForm.d.ts +30 -0
  97. package/lib/components/form/schemaForm.js +651 -0
  98. package/lib/components/form/stepsForm.d.ts +26 -0
  99. package/lib/components/form/stepsForm.js +189 -0
  100. package/lib/components/form/uploadButton.d.ts +20 -0
  101. package/lib/components/form/uploadButton.js +141 -0
  102. package/lib/components/form/uploadDragger.d.ts +13 -0
  103. package/lib/components/form/uploadDragger.js +151 -0
  104. package/lib/components/index.d.ts +9 -0
  105. package/lib/components/index.js +104 -0
  106. package/lib/components/layout/components/Help/index.d.ts +72 -0
  107. package/lib/components/layout/components/Help/index.js +356 -0
  108. package/lib/components/layout/index.d.ts +182 -0
  109. package/lib/components/layout/index.js +930 -0
  110. package/lib/components/list/index.d.ts +80 -0
  111. package/lib/components/list/index.js +438 -0
  112. package/lib/components/provider/context.d.ts +7 -0
  113. package/lib/components/provider/context.js +27 -0
  114. package/lib/components/provider/index.d.ts +28 -0
  115. package/lib/components/provider/index.js +174 -0
  116. package/lib/components/provider/intl.d.ts +38 -0
  117. package/lib/components/provider/intl.js +118 -0
  118. package/lib/components/provider/types.d.ts +37 -0
  119. package/lib/components/provider/types.js +5 -0
  120. package/lib/components/provider/useStyle/index.d.ts +28 -0
  121. package/lib/components/provider/useStyle/index.js +217 -0
  122. package/lib/components/skeleton/index.d.ts +61 -0
  123. package/lib/components/skeleton/index.js +394 -0
  124. package/lib/components/table/dragSortTable.d.ts +8 -0
  125. package/lib/components/table/dragSortTable.js +236 -0
  126. package/lib/components/table/editableTable.d.ts +31 -0
  127. package/lib/components/table/editableTable.js +514 -0
  128. package/lib/components/table/index.d.ts +52 -0
  129. package/lib/components/table/index.js +1699 -0
  130. package/lib/components/table/listToolBar.d.ts +48 -0
  131. package/lib/components/table/listToolBar.js +200 -0
  132. package/lib/components/table/search.d.ts +5 -0
  133. package/lib/components/table/search.js +20 -0
  134. package/lib/index.d.ts +4 -0
  135. package/lib/index.js +49 -0
  136. package/lib/types.d.ts +219 -0
  137. package/lib/types.js +5 -0
  138. package/lib/utils/attachPropertiesToComponent.d.ts +1 -0
  139. package/lib/utils/attachPropertiesToComponent.js +12 -0
  140. package/lib/utils/getRequestParams.d.ts +19 -0
  141. package/lib/utils/getRequestParams.js +63 -0
  142. package/lib/utils/getTableListColumns.d.ts +20 -0
  143. package/lib/utils/getTableListColumns.js +42 -0
  144. package/lib/utils/index.d.ts +4 -0
  145. package/lib/utils/index.js +49 -0
  146. package/lib/utils/loading.d.ts +3 -0
  147. package/lib/utils/loading.js +31 -0
  148. package/lib/version.d.ts +2 -0
  149. package/lib/version.js +8 -0
  150. package/package.json +68 -0
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ export interface ListToolBarTabItem {
3
+ key: string;
4
+ tab: React.ReactNode;
5
+ }
6
+ export interface ListToolBarMenuItem {
7
+ key: string;
8
+ label?: React.ReactNode;
9
+ tab?: React.ReactNode;
10
+ }
11
+ export interface ListToolBarSearchProps {
12
+ value?: string;
13
+ placeholder?: string;
14
+ allowClear?: boolean;
15
+ onChange?: (value: string) => void;
16
+ onSearch?: (value: string) => void;
17
+ }
18
+ export interface ListToolBarSetting {
19
+ key?: string;
20
+ icon: React.ReactNode;
21
+ tooltip?: React.ReactNode;
22
+ onClick?: (key?: string) => void;
23
+ }
24
+ export interface ListToolBarProps {
25
+ title?: React.ReactNode;
26
+ subTitle?: React.ReactNode;
27
+ tooltip?: React.ReactNode;
28
+ className?: string;
29
+ style?: React.CSSProperties;
30
+ variant?: 'card' | 'plain';
31
+ actions?: React.ReactNode[];
32
+ settings?: Array<React.ReactNode | ListToolBarSetting>;
33
+ filter?: React.ReactNode;
34
+ search?: React.ReactNode | ListToolBarSearchProps;
35
+ multipleLine?: boolean;
36
+ menu?: {
37
+ activeKey?: string;
38
+ items?: ListToolBarMenuItem[];
39
+ onChange?: (key: string) => void;
40
+ };
41
+ tabs?: {
42
+ activeKey?: string;
43
+ items?: ListToolBarTabItem[];
44
+ onChange?: (key: string) => void;
45
+ };
46
+ }
47
+ export declare const ListToolBar: React.FC<ListToolBarProps>;
48
+ export default ListToolBar;
@@ -0,0 +1,194 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ import React, { useMemo, useState } from 'react';
9
+ import { Button } from '@hanwenbo/x-web-ui/button';
10
+ import { InputItem } from '@hanwenbo/x-web-ui/inputItem';
11
+ import { Segmented } from '@hanwenbo/x-web-ui/segmented';
12
+ import { Tooltip } from '@hanwenbo/x-web-ui/tooltip';
13
+ import { cn } from '@hanwenbo/x-web-ui/utils/cn';
14
+ import { CircleHelp } from 'lucide-react';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ var isSearchConfig = function isSearchConfig(search) {
19
+ return !!search && ! /*#__PURE__*/React.isValidElement(search) && _typeof(search) === 'object';
20
+ };
21
+ var isTextLikeNode = function isTextLikeNode(value) {
22
+ return typeof value === 'string' || typeof value === 'number';
23
+ };
24
+ var renderSettingItem = function renderSettingItem(settingNode, index) {
25
+ if ( /*#__PURE__*/React.isValidElement(settingNode)) {
26
+ return /*#__PURE__*/_jsx(React.Fragment, {
27
+ children: settingNode
28
+ }, "toolbar-setting-".concat(index));
29
+ }
30
+ var setting = settingNode;
31
+ var button = /*#__PURE__*/_jsx("button", {
32
+ type: "button",
33
+ className: "inline-flex h-8 items-center justify-center rounded-md border border-transparent px-2.5 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",
34
+ onClick: function onClick() {
35
+ var _setting$onClick;
36
+ (_setting$onClick = setting.onClick) === null || _setting$onClick === void 0 || _setting$onClick.call(setting, setting.key);
37
+ },
38
+ children: setting.icon
39
+ }, setting.key || "toolbar-setting-".concat(index));
40
+ if (!setting.tooltip) {
41
+ return button;
42
+ }
43
+ return /*#__PURE__*/_jsx(Tooltip, {
44
+ title: setting.tooltip,
45
+ children: /*#__PURE__*/_jsx("span", {
46
+ "data-list-toolbar-setting-tooltip": true,
47
+ className: "inline-flex",
48
+ children: button
49
+ })
50
+ });
51
+ };
52
+ export var ListToolBar = function ListToolBar(_ref) {
53
+ var _search$value, _tabItems$, _ref2, _tabs$activeKey, _search$allowClear;
54
+ var title = _ref.title,
55
+ subTitle = _ref.subTitle,
56
+ tooltip = _ref.tooltip,
57
+ className = _ref.className,
58
+ style = _ref.style,
59
+ _ref$variant = _ref.variant,
60
+ variant = _ref$variant === void 0 ? 'card' : _ref$variant,
61
+ actions = _ref.actions,
62
+ settings = _ref.settings,
63
+ filter = _ref.filter,
64
+ search = _ref.search,
65
+ _ref$multipleLine = _ref.multipleLine,
66
+ multipleLine = _ref$multipleLine === void 0 ? false : _ref$multipleLine,
67
+ menu = _ref.menu,
68
+ tabs = _ref.tabs;
69
+ var _useState = useState(isSearchConfig(search) ? search.value || '' : ''),
70
+ _useState2 = _slicedToArray(_useState, 2),
71
+ innerSearch = _useState2[0],
72
+ setInnerSearch = _useState2[1];
73
+ var searchValue = isSearchConfig(search) ? (_search$value = search.value) !== null && _search$value !== void 0 ? _search$value : innerSearch : '';
74
+ var menuItems = (menu === null || menu === void 0 ? void 0 : menu.items) || [];
75
+ var tabItems = (tabs === null || tabs === void 0 ? void 0 : tabs.items) || menuItems.map(function (item) {
76
+ return {
77
+ key: item.key,
78
+ tab: item.tab || item.label
79
+ };
80
+ });
81
+ var _useState3 = useState((tabs === null || tabs === void 0 ? void 0 : tabs.activeKey) || (menu === null || menu === void 0 ? void 0 : menu.activeKey) || ((_tabItems$ = tabItems[0]) === null || _tabItems$ === void 0 ? void 0 : _tabItems$.key)),
82
+ _useState4 = _slicedToArray(_useState3, 2),
83
+ innerTab = _useState4[0],
84
+ setInnerTab = _useState4[1];
85
+ var activeTab = (_ref2 = (_tabs$activeKey = tabs === null || tabs === void 0 ? void 0 : tabs.activeKey) !== null && _tabs$activeKey !== void 0 ? _tabs$activeKey : menu === null || menu === void 0 ? void 0 : menu.activeKey) !== null && _ref2 !== void 0 ? _ref2 : innerTab;
86
+ var tabOptions = useMemo(function () {
87
+ return tabItems.map(function (item) {
88
+ return {
89
+ label: item.tab,
90
+ value: item.key
91
+ };
92
+ });
93
+ }, [tabItems]);
94
+ var hasHeading = Boolean(title || subTitle);
95
+ var titleNode = title ? isTextLikeNode(title) ? /*#__PURE__*/_jsxs("div", {
96
+ className: "flex min-w-0 items-center gap-2",
97
+ children: [/*#__PURE__*/_jsx("div", {
98
+ className: "truncate text-base font-semibold text-foreground",
99
+ children: title
100
+ }), tooltip ? /*#__PURE__*/_jsx(Tooltip, {
101
+ title: tooltip,
102
+ children: /*#__PURE__*/_jsx("span", {
103
+ "data-list-toolbar-title-tooltip": true,
104
+ className: "inline-flex shrink-0",
105
+ children: /*#__PURE__*/_jsx(CircleHelp, {
106
+ className: "h-4 w-4 text-muted-foreground"
107
+ })
108
+ })
109
+ }) : null]
110
+ }) : /*#__PURE__*/_jsx("div", {
111
+ className: "min-w-0",
112
+ children: title
113
+ }) : null;
114
+ var businessActions = actions !== null && actions !== void 0 && actions.length ? /*#__PURE__*/_jsx("div", {
115
+ className: "flex flex-wrap items-center gap-2",
116
+ children: actions
117
+ }) : null;
118
+ var systemActions = settings !== null && settings !== void 0 && settings.length ? /*#__PURE__*/_jsx("div", {
119
+ className: "flex flex-wrap items-center gap-0.5",
120
+ children: settings.map(renderSettingItem)
121
+ }) : null;
122
+ var leftContent = hasHeading ? /*#__PURE__*/_jsxs("div", {
123
+ className: "min-w-0 flex-1",
124
+ children: [/*#__PURE__*/_jsxs("div", {
125
+ className: "flex flex-wrap items-center gap-2.5",
126
+ children: [titleNode, businessActions]
127
+ }), subTitle ? /*#__PURE__*/_jsx("div", {
128
+ className: "mt-0.5 text-xs text-muted-foreground",
129
+ children: subTitle
130
+ }) : null]
131
+ }) : businessActions ? /*#__PURE__*/_jsx("div", {
132
+ className: "flex min-w-0 flex-1 flex-wrap items-center gap-2",
133
+ children: businessActions
134
+ }) : null;
135
+ var rightContent = /*#__PURE__*/_jsxs(_Fragment, {
136
+ children: [multipleLine ? null : filter, isSearchConfig(search) ? /*#__PURE__*/_jsxs("div", {
137
+ className: "flex flex-wrap items-center gap-2",
138
+ children: [/*#__PURE__*/_jsx(InputItem, {
139
+ value: searchValue,
140
+ placeholder: search.placeholder || '请输入关键词',
141
+ allowClear: (_search$allowClear = search.allowClear) !== null && _search$allowClear !== void 0 ? _search$allowClear : true,
142
+ className: "min-w-[220px]",
143
+ onChange: function onChange(value) {
144
+ var _search$onChange;
145
+ setInnerSearch(value);
146
+ (_search$onChange = search.onChange) === null || _search$onChange === void 0 || _search$onChange.call(search, value);
147
+ },
148
+ onKeyDown: function onKeyDown(event) {
149
+ if (event.key === 'Enter') {
150
+ var _search$onSearch;
151
+ (_search$onSearch = search.onSearch) === null || _search$onSearch === void 0 || _search$onSearch.call(search, searchValue);
152
+ }
153
+ }
154
+ }), /*#__PURE__*/_jsx(Button, {
155
+ htmlType: "button",
156
+ onClick: function onClick() {
157
+ var _search$onSearch2;
158
+ (_search$onSearch2 = search.onSearch) === null || _search$onSearch2 === void 0 || _search$onSearch2.call(search, searchValue);
159
+ },
160
+ children: "\u641C\u7D22"
161
+ })]
162
+ }) : search, systemActions]
163
+ });
164
+ return /*#__PURE__*/_jsx("div", {
165
+ className: cn(variant === 'card' ? 'rounded-2xl border border-border bg-card px-4 py-4' : '', className),
166
+ style: style,
167
+ children: /*#__PURE__*/_jsxs("div", {
168
+ className: "flex flex-col gap-3",
169
+ children: [/*#__PURE__*/_jsxs("div", {
170
+ className: cn('flex flex-col gap-2 lg:flex-row lg:items-start', hasHeading ? 'lg:gap-3' : 'lg:gap-2.5'),
171
+ children: [/*#__PURE__*/_jsx("div", {
172
+ className: "min-w-0 flex-1",
173
+ children: leftContent
174
+ }), /*#__PURE__*/_jsx("div", {
175
+ className: "flex shrink-0 flex-wrap items-center gap-2 lg:ml-auto lg:justify-end lg:self-start",
176
+ children: rightContent
177
+ })]
178
+ }), tabOptions.length ? /*#__PURE__*/_jsx(Segmented, {
179
+ options: tabOptions,
180
+ value: activeTab,
181
+ onChange: function onChange(value) {
182
+ var _tabs$onChange, _menu$onChange;
183
+ var nextKey = String(value);
184
+ setInnerTab(nextKey);
185
+ tabs === null || tabs === void 0 || (_tabs$onChange = tabs.onChange) === null || _tabs$onChange === void 0 || _tabs$onChange.call(tabs, nextKey);
186
+ menu === null || menu === void 0 || (_menu$onChange = menu.onChange) === null || _menu$onChange === void 0 || _menu$onChange.call(menu, nextKey);
187
+ }
188
+ }) : null, multipleLine && filter ? /*#__PURE__*/_jsx("div", {
189
+ children: filter
190
+ }) : null]
191
+ })
192
+ });
193
+ };
194
+ export default ListToolBar;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { QueryLikeFormProps } from '../form';
3
+ export declare type SearchProps<Values = Record<string, any>> = QueryLikeFormProps<Values>;
4
+ export declare const Search: <Values extends Record<string, any> = Record<string, any>>(props: SearchProps<Values>) => React.JSX.Element;
5
+ export default Search;
@@ -0,0 +1,13 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import React from 'react';
8
+ import { QueryFilter } from "../form";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export var Search = function Search(props) {
11
+ return /*#__PURE__*/_jsx(QueryFilter, _objectSpread({}, props));
12
+ };
13
+ export default Search;
package/es/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './components';
3
+ export * from './utils';
4
+ export * from './version';
package/es/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./components";
3
+ export * from "./utils";
4
+ export * from "./version";
package/es/types.d.ts ADDED
@@ -0,0 +1,219 @@
1
+ import type * as React from 'react';
2
+ import { type FormInstance, type FormItemProps, type NamePath } from '@hanwenbo/x-web-ui/form';
3
+ import { type ButtonProps } from '@hanwenbo/x-web-ui/button';
4
+ import { type CardProps } from '@hanwenbo/x-web-ui/card';
5
+ import { type TableColumnType, type TableProps } from '@hanwenbo/x-web-ui/table';
6
+ export declare type ProFieldFCMode = 'read' | 'edit' | 'update';
7
+ export declare type ProSchemaComponentTypes = 'table' | 'form' | 'descriptions' | 'list';
8
+ export declare type ProFieldValueType = 'text' | 'textarea' | 'digit' | 'digitRange' | 'money' | 'percent' | 'date' | 'dateMonth' | 'dateYear' | 'dateTime' | 'time' | 'dateRange' | 'dateMonthRange' | 'dateQuarterRange' | 'dateTimeRange' | 'dateWeekRange' | 'dateYearRange' | 'timeRange' | 'password' | 'fromNow' | 'second' | 'code' | 'jsonCode' | 'color' | 'select' | 'checkbox' | 'radio' | 'cascader' | 'treeSelect' | 'segmented' | 'switch' | 'rate' | 'progress' | 'option' | 'tag' | 'status' | 'image' | 'img' | 'avatar' | 'index' | 'indexBorder' | (string & {});
9
+ export declare type ProFieldEmptyText = React.ReactNode;
10
+ export declare type ProSchemaValueEnumType = {
11
+ text: React.ReactNode;
12
+ status?: 'default' | 'success' | 'processing' | 'warning' | 'error' | 'Default' | 'Success' | 'Processing' | 'Warning' | 'Error';
13
+ color?: string;
14
+ disabled?: boolean;
15
+ };
16
+ export declare type ProSchemaValueEnumMap = Map<string | number | boolean, ProSchemaValueEnumType | React.ReactNode>;
17
+ export declare type ProSchemaValueEnumObj = Record<string, ProSchemaValueEnumType | React.ReactNode>;
18
+ export declare type ProSchemaValueEnum = ProSchemaValueEnumObj | ProSchemaValueEnumMap;
19
+ export declare type ProRenderFieldPropsType = {
20
+ render?: (text: any, props: Record<string, any>, dom: React.JSX.Element) => React.JSX.Element | null;
21
+ formItemRender?: (text: any, props: Record<string, any>, dom: React.JSX.Element) => React.JSX.Element | null;
22
+ };
23
+ export interface RequestData<T> {
24
+ data?: T[];
25
+ success?: boolean;
26
+ total?: number;
27
+ [key: string]: any;
28
+ }
29
+ export declare type ActionType = {
30
+ reload: () => Promise<void>;
31
+ reloadAndRest?: () => Promise<void>;
32
+ reset: () => void;
33
+ fullScreen?: () => void;
34
+ setPageInfo?: (pageInfo: Partial<{
35
+ current: number;
36
+ pageSize: number;
37
+ }>) => void;
38
+ clearSelected?: () => void;
39
+ };
40
+ export interface ProColumnType<RecordType = any, ValueType = 'text'> extends Omit<TableColumnType<RecordType>, 'render'> {
41
+ valueType?: ValueType | ProFieldValueType;
42
+ valueEnum?: ProSchemaValueEnum;
43
+ tooltip?: React.ReactNode | {
44
+ title?: React.ReactNode;
45
+ };
46
+ copyable?: boolean | {
47
+ text?: string;
48
+ onCopy?: (text: string) => void | Promise<void>;
49
+ };
50
+ editable?: boolean | ((text: any, record: RecordType, index: number) => boolean);
51
+ hideInSearch?: boolean;
52
+ hideInTable?: boolean;
53
+ hideInDescriptions?: boolean;
54
+ hideInList?: boolean;
55
+ hideInForm?: boolean;
56
+ /**
57
+ * 普通 Schema 表单的字段默认值。
58
+ * ProTable、QueryFilter 与 LightFilter 等搜索场景不会读取该值。
59
+ */
60
+ initialValue?: any;
61
+ /**
62
+ * 搜索字段的显式默认值。
63
+ * 仅在 ProTable、QueryFilter 与 LightFilter 等搜索场景生效,并以组件挂载时的配置
64
+ * 作为首次请求与重置基线。需要切换整组搜索初值时,应使用新的组件 key 明确重建。
65
+ */
66
+ searchInitialValue?: any;
67
+ order?: number;
68
+ request?: (params?: Record<string, any>) => Promise<any[]>;
69
+ params?: Record<string, any>;
70
+ search?: boolean | {
71
+ transform?: (value: any) => Record<string, any>;
72
+ };
73
+ name?: NamePath;
74
+ dependencies?: NamePath[];
75
+ defaultKeyWords?: string;
76
+ debounceTime?: number;
77
+ formItemProps?: FormItemProps | ((form: FormInstance<RecordType>, schema: ProColumnType<RecordType, ValueType>) => FormItemProps);
78
+ fieldProps?: Record<string, any> | ((form: FormInstance<RecordType>, schema: ProColumnType<RecordType, ValueType>) => Record<string, any>);
79
+ columns?: ProColumnType<RecordType, ValueType | ProFieldValueType>[] | ProColumnType<RecordType, ValueType | ProFieldValueType>[][] | ((values: Record<string, any>) => ProColumnType<RecordType, ValueType | ProFieldValueType>[]);
80
+ readonly?: boolean;
81
+ ignoreFormItem?: boolean;
82
+ convertValue?: (value: any, namePath: NamePath, allValues?: Record<string, any>) => any;
83
+ transform?: (value: any, namePath: NamePath, allValues?: Record<string, any>) => any;
84
+ renderFormItem?: (schema: ProColumnType<RecordType, ValueType>, config: {
85
+ type: ProSchemaComponentTypes;
86
+ }, form: FormInstance<RecordType>) => React.ReactNode;
87
+ formItemRender?: (schema: ProColumnType<RecordType, ValueType>, config: {
88
+ type: ProSchemaComponentTypes;
89
+ }, form: FormInstance<RecordType>) => React.ReactNode;
90
+ listSlot?: 'title' | 'subTitle' | 'avatar' | 'description' | 'content' | 'actions' | 'aside' | 'type' | (string & {});
91
+ renderText?: (value: any, record: RecordType, index: number) => React.ReactNode;
92
+ render?: (value: any, record: RecordType, index: number) => React.ReactNode;
93
+ }
94
+ export declare type ProColumns<RecordType = any, ValueType = 'text'> = ProColumnType<RecordType, ValueType>[];
95
+ export declare type SubmitterProps = {
96
+ submitButtonProps?: Record<string, any>;
97
+ resetButtonProps?: Record<string, any>;
98
+ collapseButtonProps?: Record<string, any>;
99
+ searchConfig?: {
100
+ submitText?: React.ReactNode;
101
+ resetText?: React.ReactNode;
102
+ };
103
+ render?: ((props: SubmitterProps, dom: React.ReactNode[]) => React.ReactNode[] | React.ReactNode | false) | false;
104
+ };
105
+ export interface ProFormFieldItemProps<T = Record<string, any>> extends Omit<FormItemProps, 'children'> {
106
+ fieldProps?: T;
107
+ placeholder?: string | string[];
108
+ valueType?: ProFieldValueType;
109
+ width?: number | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
110
+ emptyText?: React.ReactNode;
111
+ secondary?: boolean;
112
+ allowClear?: boolean;
113
+ bordered?: boolean;
114
+ colSize?: number;
115
+ readonly?: boolean;
116
+ cacheForSwr?: boolean;
117
+ convertValue?: (value: any, namePath: NamePath, allValues?: Record<string, any>) => any;
118
+ formItemProps?: FormItemProps;
119
+ fieldConfig?: Record<string, any>;
120
+ fieldRef?: React.Ref<any>;
121
+ footerRender?: ((onConfirm?: (e?: React.MouseEvent) => void, onClear?: (e?: React.MouseEvent) => void) => React.ReactNode | false) | false;
122
+ }
123
+ export interface ProFormInstance<T = any> extends FormInstance<T> {
124
+ }
125
+ export interface ProFormDependencyProps {
126
+ name: NamePath[];
127
+ children: (values: Record<string, any>, form: FormInstance<any>) => React.ReactNode;
128
+ }
129
+ export interface ProTableProps<RecordType = any, Params extends Record<string, any> = Record<string, any>> extends Omit<TableProps<RecordType>, 'columns' | 'dataSource' | 'title'> {
130
+ columns: ProColumns<RecordType>;
131
+ params?: Params;
132
+ request?: (params: Params & {
133
+ current?: number;
134
+ pageSize?: number;
135
+ }, sort: Record<string, any>, filter: Record<string, any>) => Promise<RequestData<RecordType>>;
136
+ dataSource?: RecordType[];
137
+ actionRef?: React.MutableRefObject<ActionType | undefined>;
138
+ formRef?: React.MutableRefObject<FormInstance<any> | undefined>;
139
+ search?: boolean | Record<string, any>;
140
+ beforeSearchSubmit?: (params: Record<string, any>) => Params | Record<string, any>;
141
+ optionsRender?: ((props: Record<string, any>) => React.ReactNode) | false | React.ReactNode | null;
142
+ searchFormRender?: (props: ProTableProps<RecordType, Params>, dom: JSX.Element) => React.ReactNode;
143
+ tableRender?: (props: ProTableProps<RecordType, Params>, dom: JSX.Element, domList: {
144
+ toolbar: React.ReactNode;
145
+ alert: React.ReactNode;
146
+ table: React.ReactNode;
147
+ }) => React.ReactNode;
148
+ tableExtraRender?: (props: ProTableProps<RecordType, Params>, dataSource: RecordType[]) => React.ReactNode;
149
+ tableClassName?: string;
150
+ tableStyle?: React.CSSProperties;
151
+ onLoad?: (dataSource: RecordType[]) => void;
152
+ onLoadingChange?: (loading: boolean | undefined) => void;
153
+ onRequestError?: (error: Error) => void;
154
+ onSizeChange?: (size: 'large' | 'middle' | 'small' | 'mini') => void;
155
+ tableAlertRender?: ((props: {
156
+ selectedRowKeys: React.Key[];
157
+ selectedRows: RecordType[];
158
+ }) => React.ReactNode) | false;
159
+ tableAlertOptionRender?: ((props: {
160
+ selectedRowKeys: React.Key[];
161
+ selectedRows: RecordType[];
162
+ }) => React.ReactNode) | false;
163
+ /**
164
+ * 透传给 ProTable 外层 Card 的参数。
165
+ * 可用于调整边框、内边距、样式等外层样式变量,不修改 Card 默认实现。
166
+ */
167
+ cardProps?: Omit<CardProps, 'children'>;
168
+ /**
169
+ * 分页布局方式。`outside` 会把底部分页渲染到表格 Card 外部。
170
+ */
171
+ paginationLayout?: 'inside' | 'outside';
172
+ /**
173
+ * 分页尺寸。未指定时会回退到内部默认策略。
174
+ */
175
+ paginationSize?: 'mini' | 'small' | 'middle' | 'large';
176
+ options?: boolean | {
177
+ variant?: 'icon' | 'textDropdown';
178
+ dropdownText?: React.ReactNode;
179
+ /**
180
+ * 渲染在 textDropdown 下拉菜单顶部的自定义内容,位于密度设置前。
181
+ * 可用于放置视图切换等轻量工具。
182
+ */
183
+ dropdownHeader?: React.ReactNode;
184
+ size?: ButtonProps['size'];
185
+ reload?: boolean;
186
+ density?: boolean;
187
+ setting?: boolean;
188
+ fullScreen?: boolean;
189
+ search?: boolean | {
190
+ name?: string;
191
+ placeholder?: string;
192
+ onSearch?: (value: string) => void | false | Promise<void | false>;
193
+ };
194
+ };
195
+ columnsState?: {
196
+ value?: Record<string, {
197
+ fixed?: 'left' | 'right';
198
+ show?: boolean;
199
+ }>;
200
+ defaultValue?: Record<string, {
201
+ fixed?: 'left' | 'right';
202
+ show?: boolean;
203
+ }>;
204
+ onChange?: (value: Record<string, {
205
+ fixed?: 'left' | 'right';
206
+ show?: boolean;
207
+ }>) => void;
208
+ persistenceKey?: string;
209
+ persistenceType?: 'localStorage' | 'sessionStorage';
210
+ };
211
+ headerTitle?: React.ReactNode;
212
+ toolbar?: {
213
+ search?: {
214
+ onSearch?: (value: string) => void | false | Promise<void | false>;
215
+ };
216
+ };
217
+ toolBarRender?: false | ((action: ActionType | undefined, rows?: RecordType[]) => React.ReactNode[] | React.ReactNode);
218
+ onDataSourceChange?: (dataSource: RecordType[]) => void;
219
+ }
package/es/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function attachPropertiesToComponent<ComponentType extends Record<string, any>, Properties extends Record<string, any>>(component: ComponentType, properties: Properties): ComponentType & Properties;
@@ -0,0 +1,6 @@
1
+ export function attachPropertiesToComponent(component, properties) {
2
+ Object.keys(properties).forEach(function (key) {
3
+ component[key] = properties[key];
4
+ });
5
+ return component;
6
+ }
@@ -0,0 +1,19 @@
1
+ export interface RequestParams {
2
+ current?: number;
3
+ pageSize?: number;
4
+ [key: string]: unknown;
5
+ }
6
+ export interface SorterParams {
7
+ [key: string]: 'ascend' | 'descend' | null | undefined;
8
+ }
9
+ export interface Payload {
10
+ page: number;
11
+ rows: number;
12
+ sortby?: string;
13
+ [key: string]: unknown;
14
+ }
15
+ export declare const getRequestParams: ({ params, sorter, filter: _ }: {
16
+ params?: RequestParams | undefined;
17
+ sorter?: SorterParams | undefined;
18
+ filter?: unknown;
19
+ }) => Payload;
@@ -0,0 +1,57 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["current", "pageSize"];
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ var DEFAULT_PAGE = 1;
17
+ var DEFAULT_PAGE_SIZE = 20;
18
+ var FILTER_VALUE_ALL = 'all';
19
+ var filterAllValues = function filterAllValues(fields) {
20
+ return Object.fromEntries(Object.entries(fields).filter(function (_ref) {
21
+ var _ref2 = _slicedToArray(_ref, 2),
22
+ value = _ref2[1];
23
+ return value !== FILTER_VALUE_ALL;
24
+ }));
25
+ };
26
+ var buildSortby = function buildSortby(sorter) {
27
+ var entries = Object.entries(sorter);
28
+ if (entries.length === 0) {
29
+ return undefined;
30
+ }
31
+ var _entries$ = _slicedToArray(entries[0], 2),
32
+ field = _entries$[0],
33
+ direction = _entries$[1];
34
+ if (!direction) {
35
+ return undefined;
36
+ }
37
+ return "".concat(field, " ").concat(direction === 'ascend' ? 'ASC' : 'DESC');
38
+ };
39
+ export var getRequestParams = function getRequestParams(_ref3) {
40
+ var params = _ref3.params,
41
+ _ref3$sorter = _ref3.sorter,
42
+ sorter = _ref3$sorter === void 0 ? {} : _ref3$sorter,
43
+ _ref3$filter = _ref3.filter,
44
+ _ = _ref3$filter === void 0 ? {} : _ref3$filter;
45
+ var _ref4 = params || {},
46
+ current = _ref4.current,
47
+ pageSize = _ref4.pageSize,
48
+ rawFields = _objectWithoutProperties(_ref4, _excluded);
49
+ var filteredFields = filterAllValues(rawFields);
50
+ var sortby = buildSortby(sorter);
51
+ return _objectSpread(_objectSpread({
52
+ page: current !== null && current !== void 0 ? current : DEFAULT_PAGE,
53
+ rows: pageSize !== null && pageSize !== void 0 ? pageSize : DEFAULT_PAGE_SIZE
54
+ }, sortby ? {
55
+ sortby: sortby
56
+ } : {}), filteredFields);
57
+ };
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ export interface ColumnItem {
3
+ dataIndex: string | string[];
4
+ width?: string | number;
5
+ [key: string]: unknown;
6
+ }
7
+ export interface ColumnsMap {
8
+ [key: string]: {
9
+ width?: string | number;
10
+ dataIndex?: string | string[];
11
+ render?: (...args: unknown[]) => React.ReactNode;
12
+ [key: string]: unknown;
13
+ };
14
+ }
15
+ export interface GetTableListColumnsParams {
16
+ columns: ColumnItem[];
17
+ module: string;
18
+ columnsMap: ColumnsMap;
19
+ }
20
+ export declare const getTableListColumns: ({ columns, module, columnsMap }: GetTableListColumnsParams) => ColumnItem[];
@@ -0,0 +1,36 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ var DEFAULT_WIDTH = 'auto';
8
+ var NESTED_SEPARATOR = '.';
9
+ var normalizeDataIndexToString = function normalizeDataIndexToString(dataIndex) {
10
+ return Array.isArray(dataIndex) ? dataIndex.join(NESTED_SEPARATOR) : dataIndex;
11
+ };
12
+ var shouldConvertToArray = function shouldConvertToArray(dataIndex) {
13
+ return typeof dataIndex === 'string' && dataIndex.includes(NESTED_SEPARATOR);
14
+ };
15
+ var convertToArrayDataIndex = function convertToArrayDataIndex(dataIndex) {
16
+ return dataIndex.split(NESTED_SEPARATOR);
17
+ };
18
+ export var getTableListColumns = function getTableListColumns(_ref) {
19
+ var columns = _ref.columns,
20
+ module = _ref.module,
21
+ columnsMap = _ref.columnsMap;
22
+ return columns.map(function (item) {
23
+ var _ref2, _normalizedFieldMap$w;
24
+ var dataIndexString = normalizeDataIndexToString(item.dataIndex);
25
+ var mapKey = "".concat(module, ".").concat(dataIndexString);
26
+ var fieldMap = columnsMap[mapKey];
27
+ var normalizedFieldMap = fieldMap && shouldConvertToArray(fieldMap.dataIndex) ? _objectSpread(_objectSpread({}, fieldMap), {}, {
28
+ dataIndex: convertToArrayDataIndex(fieldMap.dataIndex)
29
+ }) : fieldMap;
30
+ return _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
31
+ dataIndex: shouldConvertToArray(item.dataIndex) ? convertToArrayDataIndex(item.dataIndex) : item.dataIndex
32
+ }, normalizedFieldMap), {}, {
33
+ width: (_ref2 = (_normalizedFieldMap$w = normalizedFieldMap === null || normalizedFieldMap === void 0 ? void 0 : normalizedFieldMap.width) !== null && _normalizedFieldMap$w !== void 0 ? _normalizedFieldMap$w : item.width) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_WIDTH
34
+ });
35
+ });
36
+ };