@pisell/materials 6.4.7 → 6.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +146 -146
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +24 -23
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +25 -24
- package/es/components/auto-resize-text/auto-text-size-standalone.d.ts +20 -0
- package/es/components/auto-resize-text/auto-text-size-standalone.js +258 -0
- package/es/components/auto-resize-text/index.d.ts +6 -0
- package/es/components/auto-resize-text/index.js +40 -0
- package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +11 -4
- package/es/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +1 -0
- package/es/components/dataSourceComponents/dataSourceTable/filter/index.js +7 -2
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +6 -7
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +11 -4
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +2 -1
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +92 -6
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +5 -0
- package/es/components/filter/types.d.ts +2 -0
- package/es/components/keyboard/index.d.ts +22 -0
- package/es/components/keyboard/index.js +159 -0
- package/es/components/keyboard/index.less +44 -0
- package/es/components/pisellQRScanner/index.d.ts +0 -13
- package/es/components/pisellQRScanner/index.js +0 -8
- package/es/components/pisellWalletPassCard/index.d.ts +1 -1
- package/es/components/pisellWalletPassCard/index.js +2 -1
- package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
- package/es/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +1 -0
- package/es/components/productCard/cartSkuCard/components/swipeAction/index.js +73 -5
- package/es/components/productCard/cartSkuCard/components/swipeAction/index.less +39 -0
- package/es/components/productCard/cartSkuCard/index.js +2 -11
- package/es/components/productCard/components/Packages/utils.d.ts +1 -1
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/table/Table/utils.js +22 -1
- package/es/components/table/hooks/useTableSetting.d.ts +3 -4
- package/es/components/table/hooks/useTableSetting.js +113 -5
- package/es/components/table/index.js +14 -3
- package/es/components/table/types.d.ts +17 -0
- package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +5 -1
- package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +21 -7
- package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +9 -5
- package/es/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +4 -0
- package/es/components/virtual-keyboard/BaseNumberKeyboard/index.js +44 -25
- package/es/components/virtualInput/BaseVirtualInput/index.d.ts +40 -0
- package/es/components/virtualInput/BaseVirtualInput/index.js +163 -0
- package/es/components/virtualInput/BaseVirtualInput/index.less +78 -0
- package/es/components/virtualInput/index.d.ts +24 -0
- package/es/components/virtualInput/index.js +60 -0
- package/es/components/virtualInput/index.less +42 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/es/locales/en-US.d.ts +1 -0
- package/es/locales/en-US.js +1 -0
- package/es/locales/zh-CN.d.ts +1 -0
- package/es/locales/zh-CN.js +1 -0
- package/es/locales/zh-TW.d.ts +1 -0
- package/es/locales/zh-TW.js +1 -0
- package/es/utils/platform.d.ts +1 -1
- package/lib/components/auto-resize-text/auto-text-size-standalone.d.ts +20 -0
- package/lib/components/auto-resize-text/auto-text-size-standalone.js +273 -0
- package/lib/components/auto-resize-text/index.d.ts +6 -0
- package/lib/components/auto-resize-text/index.js +71 -0
- package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +8 -2
- package/lib/components/dataSourceComponents/dataSourceTable/filter/index.d.ts +1 -0
- package/lib/components/dataSourceComponents/dataSourceTable/filter/index.js +7 -2
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +6 -7
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +11 -4
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.d.ts +2 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableQuery.js +78 -7
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +5 -0
- package/lib/components/filter/types.d.ts +2 -0
- package/lib/components/keyboard/index.d.ts +22 -0
- package/lib/components/keyboard/index.js +223 -0
- package/lib/components/keyboard/index.less +44 -0
- package/lib/components/pisellQRScanner/index.d.ts +0 -13
- package/lib/components/pisellWalletPassCard/index.d.ts +1 -1
- package/lib/components/pisellWalletPassCard/index.js +2 -1
- package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
- package/lib/components/productCard/cartSkuCard/components/swipeAction/index.d.ts +1 -0
- package/lib/components/productCard/cartSkuCard/components/swipeAction/index.js +45 -11
- package/lib/components/productCard/cartSkuCard/components/swipeAction/index.less +39 -0
- package/lib/components/productCard/cartSkuCard/index.js +2 -13
- package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/table/Table/utils.js +18 -1
- package/lib/components/table/hooks/useTableSetting.d.ts +3 -4
- package/lib/components/table/hooks/useTableSetting.js +114 -4
- package/lib/components/table/index.js +12 -1
- package/lib/components/table/types.d.ts +17 -0
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +5 -1
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +19 -2
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +9 -5
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +4 -0
- package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.js +45 -27
- package/lib/components/virtualInput/BaseVirtualInput/index.d.ts +40 -0
- package/lib/components/virtualInput/BaseVirtualInput/index.js +179 -0
- package/lib/components/virtualInput/BaseVirtualInput/index.less +78 -0
- package/lib/components/virtualInput/index.d.ts +24 -0
- package/lib/components/virtualInput/index.js +102 -0
- package/lib/components/virtualInput/index.less +42 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -0
- package/lib/locales/en-US.d.ts +1 -0
- package/lib/locales/en-US.js +1 -0
- package/lib/locales/zh-CN.d.ts +1 -0
- package/lib/locales/zh-CN.js +1 -0
- package/lib/locales/zh-TW.d.ts +1 -0
- package/lib/locales/zh-TW.js +1 -0
- package/lib/utils/platform.d.ts +1 -1
- package/lowcode/data-source-table/meta.ts +239 -0
- package/lowcode/table/meta.ts +104 -0
- package/package.json +1 -1
- package/dist/umd/materials.min.css +0 -1
- package/dist/umd/materials.min.js +0 -1
- package/dist/umd/static/DotsSix.57d66266.svg +0 -1
- package/dist/umd/static/arrow-left.e542294f.svg +0 -1
- package/dist/umd/static/arrow-right.763f03e0.svg +0 -1
- package/dist/umd/static/filter-lines.04a54ae9.svg +0 -1
- package/dist/umd/static/help-circle.31c9be40.svg +0 -1
- package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare type Options = {
|
|
2
|
+
mode?: 'oneline' | 'multiline' | 'box' | 'boxoneline' | undefined;
|
|
3
|
+
minFontSizePx?: number | undefined;
|
|
4
|
+
maxFontSizePx?: number | undefined;
|
|
5
|
+
fontSizePrecisionPx?: number | undefined;
|
|
6
|
+
scrollToEnd?: boolean | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare function updateTextSize({ innerEl, containerEl, mode, minFontSizePx, maxFontSizePx, fontSizePrecisionPx, scrollToEnd, }: Options & {
|
|
9
|
+
innerEl: HTMLElement;
|
|
10
|
+
containerEl: HTMLElement;
|
|
11
|
+
}): void;
|
|
12
|
+
declare type DisconnectableFunction = {
|
|
13
|
+
(): void;
|
|
14
|
+
disconnect: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function autoTextSize({ innerEl, containerEl, mode, minFontSizePx, maxFontSizePx, fontSizePrecisionPx, scrollToEnd, }: Options & {
|
|
17
|
+
innerEl: HTMLElement;
|
|
18
|
+
containerEl: HTMLElement;
|
|
19
|
+
}): DisconnectableFunction;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
function throttleAnimationFrame(func) {
|
|
2
|
+
var wait = false;
|
|
3
|
+
return function () {
|
|
4
|
+
if (!wait) {
|
|
5
|
+
wait = true;
|
|
6
|
+
requestAnimationFrame(function () {
|
|
7
|
+
func();
|
|
8
|
+
wait = false;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var antiOverflowAlgo = function antiOverflowAlgo(_ref) {
|
|
14
|
+
var fontSizePx = _ref.fontSizePx,
|
|
15
|
+
minFontSizePx = _ref.minFontSizePx,
|
|
16
|
+
fontSizePrecisionPx = _ref.fontSizePrecisionPx,
|
|
17
|
+
updateFontSizePx = _ref.updateFontSizePx,
|
|
18
|
+
breakPred = _ref.breakPredicate;
|
|
19
|
+
var maxIterCount = Math.ceil(1 / fontSizePrecisionPx); // 1 px should always be enough.
|
|
20
|
+
var iterCount = 0;
|
|
21
|
+
while (fontSizePx > minFontSizePx && iterCount < maxIterCount) {
|
|
22
|
+
if (breakPred()) break;
|
|
23
|
+
fontSizePx = updateFontSizePx(fontSizePx - fontSizePrecisionPx);
|
|
24
|
+
iterCount++;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var getContentWidth = function getContentWidth(element) {
|
|
28
|
+
var computedStyle = getComputedStyle(element);
|
|
29
|
+
return element.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
|
|
30
|
+
};
|
|
31
|
+
var getContentHeight = function getContentHeight(element) {
|
|
32
|
+
var computedStyle = getComputedStyle(element);
|
|
33
|
+
return element.clientHeight - parseFloat(computedStyle.paddingTop) - parseFloat(computedStyle.paddingBottom);
|
|
34
|
+
};
|
|
35
|
+
var multilineAlgo = function multilineAlgo(opts) {
|
|
36
|
+
opts.innerEl.style.whiteSpace = 'nowrap';
|
|
37
|
+
onelineAlgo(opts);
|
|
38
|
+
if (opts.innerEl.scrollWidth > getContentWidth(opts.containerEl)) {
|
|
39
|
+
opts.innerEl.style.whiteSpace = 'normal';
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var onelineAlgo = function onelineAlgo(_ref2) {
|
|
43
|
+
var innerEl = _ref2.innerEl,
|
|
44
|
+
containerEl = _ref2.containerEl,
|
|
45
|
+
fontSizePx = _ref2.fontSizePx,
|
|
46
|
+
minFontSizePx = _ref2.minFontSizePx,
|
|
47
|
+
maxFontSizePx = _ref2.maxFontSizePx,
|
|
48
|
+
fontSizePrecisionPx = _ref2.fontSizePrecisionPx,
|
|
49
|
+
updateFontSizePx = _ref2.updateFontSizePx;
|
|
50
|
+
var maxIterCount = 10;
|
|
51
|
+
var iterCount = 0;
|
|
52
|
+
var prevOverflowFactor = 1;
|
|
53
|
+
while (iterCount < maxIterCount) {
|
|
54
|
+
var w0 = innerEl.scrollWidth;
|
|
55
|
+
var w1 = getContentWidth(containerEl);
|
|
56
|
+
var canGrow = fontSizePx < maxFontSizePx && w0 < w1;
|
|
57
|
+
var canShrink = fontSizePx > minFontSizePx && w0 > w1;
|
|
58
|
+
var overflowFactor = w0 / w1;
|
|
59
|
+
|
|
60
|
+
// The browser cannot render a difference based on the previous font size update
|
|
61
|
+
if (prevOverflowFactor === overflowFactor) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (!(canGrow || canShrink)) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
var updatePx = fontSizePx / overflowFactor - fontSizePx;
|
|
68
|
+
var prevFontSizePx = fontSizePx;
|
|
69
|
+
fontSizePx = updateFontSizePx(fontSizePx + updatePx);
|
|
70
|
+
if (Math.abs(fontSizePx - prevFontSizePx) <= fontSizePrecisionPx) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
prevOverflowFactor = overflowFactor;
|
|
74
|
+
iterCount++;
|
|
75
|
+
}
|
|
76
|
+
antiOverflowAlgo({
|
|
77
|
+
fontSizePx: fontSizePx,
|
|
78
|
+
minFontSizePx: minFontSizePx,
|
|
79
|
+
updateFontSizePx: updateFontSizePx,
|
|
80
|
+
fontSizePrecisionPx: fontSizePrecisionPx,
|
|
81
|
+
breakPredicate: function breakPredicate() {
|
|
82
|
+
return innerEl.scrollWidth <= getContentWidth(containerEl);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
var boxAlgo = function boxAlgo(_ref3) {
|
|
87
|
+
var innerEl = _ref3.innerEl,
|
|
88
|
+
containerEl = _ref3.containerEl,
|
|
89
|
+
fontSizePx = _ref3.fontSizePx,
|
|
90
|
+
minFontSizePx = _ref3.minFontSizePx,
|
|
91
|
+
maxFontSizePx = _ref3.maxFontSizePx,
|
|
92
|
+
fontSizePrecisionPx = _ref3.fontSizePrecisionPx,
|
|
93
|
+
updateFontSizePx = _ref3.updateFontSizePx;
|
|
94
|
+
var maxIterCount = 100;
|
|
95
|
+
fontSizePx = updateFontSizePx((maxFontSizePx - minFontSizePx) * 0.5);
|
|
96
|
+
var updatePx = (maxFontSizePx - minFontSizePx) * 0.25;
|
|
97
|
+
var iterCount = 0;
|
|
98
|
+
while (updatePx > fontSizePrecisionPx && iterCount < maxIterCount) {
|
|
99
|
+
var w0 = innerEl.scrollWidth;
|
|
100
|
+
var w1 = getContentWidth(containerEl);
|
|
101
|
+
var h0 = innerEl.scrollHeight;
|
|
102
|
+
var h1 = getContentHeight(containerEl);
|
|
103
|
+
if (w0 === w1 && h0 === h1) break;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Use `<=` rather than `<` since equality is possible even though there is
|
|
107
|
+
* room for resizing in the other dimension.
|
|
108
|
+
*/
|
|
109
|
+
if (fontSizePx < maxFontSizePx && w0 <= w1 && h0 <= h1) {
|
|
110
|
+
fontSizePx = updateFontSizePx(fontSizePx + updatePx);
|
|
111
|
+
} else if (fontSizePx > minFontSizePx && (w0 > w1 || h0 > h1)) {
|
|
112
|
+
fontSizePx = updateFontSizePx(fontSizePx - updatePx);
|
|
113
|
+
}
|
|
114
|
+
updatePx *= 0.5; // Binary search. Don't change this number.
|
|
115
|
+
iterCount++;
|
|
116
|
+
}
|
|
117
|
+
antiOverflowAlgo({
|
|
118
|
+
fontSizePx: fontSizePx,
|
|
119
|
+
minFontSizePx: minFontSizePx,
|
|
120
|
+
updateFontSizePx: updateFontSizePx,
|
|
121
|
+
fontSizePrecisionPx: fontSizePrecisionPx,
|
|
122
|
+
breakPredicate: function breakPredicate() {
|
|
123
|
+
return innerEl.scrollWidth <= getContentWidth(containerEl) && innerEl.scrollHeight <= getContentHeight(containerEl);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
export function updateTextSize(_ref4) {
|
|
128
|
+
var innerEl = _ref4.innerEl,
|
|
129
|
+
containerEl = _ref4.containerEl,
|
|
130
|
+
_ref4$mode = _ref4.mode,
|
|
131
|
+
mode = _ref4$mode === void 0 ? 'multiline' : _ref4$mode,
|
|
132
|
+
_ref4$minFontSizePx = _ref4.minFontSizePx,
|
|
133
|
+
minFontSizePx = _ref4$minFontSizePx === void 0 ? 8 : _ref4$minFontSizePx,
|
|
134
|
+
_ref4$maxFontSizePx = _ref4.maxFontSizePx,
|
|
135
|
+
maxFontSizePx = _ref4$maxFontSizePx === void 0 ? 160 : _ref4$maxFontSizePx,
|
|
136
|
+
_ref4$fontSizePrecisi = _ref4.fontSizePrecisionPx,
|
|
137
|
+
fontSizePrecisionPx = _ref4$fontSizePrecisi === void 0 ? 0.1 : _ref4$fontSizePrecisi,
|
|
138
|
+
_ref4$scrollToEnd = _ref4.scrollToEnd,
|
|
139
|
+
scrollToEnd = _ref4$scrollToEnd === void 0 ? false : _ref4$scrollToEnd;
|
|
140
|
+
var t0 = performance.now();
|
|
141
|
+
if (!isFinite(minFontSizePx)) {
|
|
142
|
+
throw new Error("Invalid minFontSizePx (".concat(minFontSizePx, ")"));
|
|
143
|
+
}
|
|
144
|
+
if (!isFinite(minFontSizePx)) {
|
|
145
|
+
throw new Error("Invalid maxFontSizePx (".concat(maxFontSizePx, ")"));
|
|
146
|
+
}
|
|
147
|
+
if (!isFinite(fontSizePrecisionPx) || fontSizePrecisionPx === 0) {
|
|
148
|
+
throw new Error("Invalid fontSizePrecisionPx (".concat(fontSizePrecisionPx, ")"));
|
|
149
|
+
}
|
|
150
|
+
if (containerEl.children.length > 1) {
|
|
151
|
+
console.warn("AutoTextSize has ".concat(containerEl.children.length - 1, " siblings. This may interfere with the algorithm."));
|
|
152
|
+
}
|
|
153
|
+
var containerStyles = {
|
|
154
|
+
display: 'flex',
|
|
155
|
+
alignItems: 'start'
|
|
156
|
+
};
|
|
157
|
+
var innerStyles = {
|
|
158
|
+
display: 'block'
|
|
159
|
+
};
|
|
160
|
+
if (mode === 'oneline') {
|
|
161
|
+
innerStyles.whiteSpace = 'nowrap';
|
|
162
|
+
} else if (mode === 'multiline') {
|
|
163
|
+
innerStyles.wordBreak = 'break-word';
|
|
164
|
+
} else if (mode === 'box') {
|
|
165
|
+
innerStyles.whiteSpace = 'pre-wrap';
|
|
166
|
+
innerStyles.wordBreak = 'break-word';
|
|
167
|
+
} else if (mode === 'boxoneline') {
|
|
168
|
+
innerStyles.whiteSpace = 'nowrap';
|
|
169
|
+
}
|
|
170
|
+
Object.assign(containerEl.style, containerStyles);
|
|
171
|
+
Object.assign(innerEl.style, innerStyles);
|
|
172
|
+
var fontSizeStr = window.getComputedStyle(innerEl, null).getPropertyValue('font-size');
|
|
173
|
+
var fontSizePx = parseFloat(fontSizeStr);
|
|
174
|
+
var iterations = 0;
|
|
175
|
+
var updateFontSizePx = function updateFontSizePx(px) {
|
|
176
|
+
px = Math.min(Math.max(px, minFontSizePx), maxFontSizePx);
|
|
177
|
+
// console.debug(
|
|
178
|
+
// `setFontSizePx ${px > fontSizePx ? "up" : "down"} (abs: ${
|
|
179
|
+
// px / fontSizePx
|
|
180
|
+
// }, rel: ${(px - fontSizePx) / fontSizePx}) ${px}`
|
|
181
|
+
// );
|
|
182
|
+
fontSizePx = px;
|
|
183
|
+
innerEl.style.fontSize = "".concat(fontSizePx, "px");
|
|
184
|
+
iterations++;
|
|
185
|
+
return fontSizePx;
|
|
186
|
+
};
|
|
187
|
+
if (fontSizePx > maxFontSizePx || fontSizePx < minFontSizePx) {
|
|
188
|
+
updateFontSizePx(fontSizePx);
|
|
189
|
+
}
|
|
190
|
+
var algoOpts = {
|
|
191
|
+
innerEl: innerEl,
|
|
192
|
+
containerEl: containerEl,
|
|
193
|
+
fontSizePx: fontSizePx,
|
|
194
|
+
minFontSizePx: minFontSizePx,
|
|
195
|
+
maxFontSizePx: maxFontSizePx,
|
|
196
|
+
fontSizePrecisionPx: fontSizePrecisionPx,
|
|
197
|
+
updateFontSizePx: updateFontSizePx
|
|
198
|
+
};
|
|
199
|
+
if (mode === 'oneline') {
|
|
200
|
+
onelineAlgo(algoOpts);
|
|
201
|
+
} else if (mode === 'multiline') {
|
|
202
|
+
multilineAlgo(algoOpts);
|
|
203
|
+
} else if (mode === 'box') {
|
|
204
|
+
boxAlgo(algoOpts);
|
|
205
|
+
} else if (mode === 'boxoneline') {
|
|
206
|
+
boxAlgo(algoOpts);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 如果启用了 scrollToEnd,滚动到内容末端
|
|
210
|
+
if (scrollToEnd) {
|
|
211
|
+
// 使用 requestAnimationFrame 确保在 DOM 更新后执行滚动
|
|
212
|
+
requestAnimationFrame(function () {
|
|
213
|
+
if (mode === 'oneline' || mode === 'boxoneline') {
|
|
214
|
+
// 对于单行模式,滚动到最右端
|
|
215
|
+
var maxScrollLeft = Math.max(0, innerEl.scrollWidth - innerEl.clientWidth);
|
|
216
|
+
innerEl.scrollLeft = maxScrollLeft;
|
|
217
|
+
} else {
|
|
218
|
+
// 对于多行模式,滚动到最底端
|
|
219
|
+
var maxScrollTop = Math.max(0, innerEl.scrollHeight - innerEl.clientHeight);
|
|
220
|
+
innerEl.scrollTop = maxScrollTop;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export function autoTextSize(_ref5) {
|
|
226
|
+
var innerEl = _ref5.innerEl,
|
|
227
|
+
containerEl = _ref5.containerEl,
|
|
228
|
+
mode = _ref5.mode,
|
|
229
|
+
minFontSizePx = _ref5.minFontSizePx,
|
|
230
|
+
maxFontSizePx = _ref5.maxFontSizePx,
|
|
231
|
+
fontSizePrecisionPx = _ref5.fontSizePrecisionPx,
|
|
232
|
+
scrollToEnd = _ref5.scrollToEnd;
|
|
233
|
+
var containerDimensions = undefined;
|
|
234
|
+
var throttledUpdateTextSize = throttleAnimationFrame(function () {
|
|
235
|
+
updateTextSize({
|
|
236
|
+
innerEl: innerEl,
|
|
237
|
+
containerEl: containerEl,
|
|
238
|
+
mode: mode,
|
|
239
|
+
maxFontSizePx: maxFontSizePx,
|
|
240
|
+
minFontSizePx: minFontSizePx,
|
|
241
|
+
fontSizePrecisionPx: fontSizePrecisionPx,
|
|
242
|
+
scrollToEnd: scrollToEnd
|
|
243
|
+
});
|
|
244
|
+
containerDimensions = [getContentWidth(containerEl), getContentHeight(containerEl)];
|
|
245
|
+
});
|
|
246
|
+
var resizeObserver = new ResizeObserver(function () {
|
|
247
|
+
var prevContainerDimensions = containerDimensions;
|
|
248
|
+
containerDimensions = [getContentWidth(containerEl), getContentHeight(containerEl)];
|
|
249
|
+
if ((prevContainerDimensions === null || prevContainerDimensions === void 0 ? void 0 : prevContainerDimensions[0]) !== containerDimensions[0] || (prevContainerDimensions === null || prevContainerDimensions === void 0 ? void 0 : prevContainerDimensions[1]) !== containerDimensions[1]) {
|
|
250
|
+
throttledUpdateTextSize();
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
resizeObserver.observe(containerEl);
|
|
254
|
+
throttledUpdateTextSize.disconnect = function () {
|
|
255
|
+
return resizeObserver.disconnect();
|
|
256
|
+
};
|
|
257
|
+
return throttledUpdateTextSize;
|
|
258
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React, { DetailedHTMLProps, HTMLAttributes, ReactElement, ReactHTML } from 'react';
|
|
2
|
+
import { Options } from './auto-text-size-standalone';
|
|
3
|
+
export default function AutoResizeText({ mode, minFontSizePx, maxFontSizePx, fontSizePrecisionPx, scrollToEnd, as: Comp, children, ...rest }: Options & {
|
|
4
|
+
as?: keyof ReactHTML | React.ComponentType<any>;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
} & DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>): ReactElement;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var _excluded = ["mode", "minFontSizePx", "maxFontSizePx", "fontSizePrecisionPx", "scrollToEnd", "as", "children"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
6
|
+
import { autoTextSize } from "./auto-text-size-standalone";
|
|
7
|
+
export default function AutoResizeText(_ref) {
|
|
8
|
+
var mode = _ref.mode,
|
|
9
|
+
minFontSizePx = _ref.minFontSizePx,
|
|
10
|
+
maxFontSizePx = _ref.maxFontSizePx,
|
|
11
|
+
fontSizePrecisionPx = _ref.fontSizePrecisionPx,
|
|
12
|
+
scrollToEnd = _ref.scrollToEnd,
|
|
13
|
+
_ref$as = _ref.as,
|
|
14
|
+
Comp = _ref$as === void 0 ? 'div' : _ref$as,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
17
|
+
var updateTextSizeRef = useRef();
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
var _updateTextSizeRef$cu;
|
|
20
|
+
(_updateTextSizeRef$cu = updateTextSizeRef.current) === null || _updateTextSizeRef$cu === void 0 || _updateTextSizeRef$cu.call(updateTextSizeRef);
|
|
21
|
+
}, [children]);
|
|
22
|
+
var refCallback = useCallback(function (innerEl) {
|
|
23
|
+
var _updateTextSizeRef$cu2;
|
|
24
|
+
(_updateTextSizeRef$cu2 = updateTextSizeRef.current) === null || _updateTextSizeRef$cu2 === void 0 || _updateTextSizeRef$cu2.disconnect();
|
|
25
|
+
var containerEl = innerEl === null || innerEl === void 0 ? void 0 : innerEl.parentElement;
|
|
26
|
+
if (!innerEl || !containerEl) return;
|
|
27
|
+
updateTextSizeRef.current = autoTextSize({
|
|
28
|
+
innerEl: innerEl,
|
|
29
|
+
containerEl: containerEl,
|
|
30
|
+
mode: mode,
|
|
31
|
+
minFontSizePx: minFontSizePx,
|
|
32
|
+
maxFontSizePx: maxFontSizePx,
|
|
33
|
+
fontSizePrecisionPx: fontSizePrecisionPx,
|
|
34
|
+
scrollToEnd: scrollToEnd
|
|
35
|
+
});
|
|
36
|
+
}, [mode, minFontSizePx, maxFontSizePx, fontSizePrecisionPx, scrollToEnd]);
|
|
37
|
+
return /*#__PURE__*/React.createElement(Comp, _extends({
|
|
38
|
+
ref: refCallback
|
|
39
|
+
}, rest), children);
|
|
40
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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 = ["columns", "dataSource", "operationContent"];
|
|
2
|
+
var _excluded = ["columns", "dataSource", "operationContent", "currentSettingKey"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -29,6 +29,7 @@ var BaseTable = function BaseTable(props, ref) {
|
|
|
29
29
|
var propsColumns = props.columns,
|
|
30
30
|
dataSource = props.dataSource,
|
|
31
31
|
operationContent = props.operationContent,
|
|
32
|
+
currentSettingKey = props.currentSettingKey,
|
|
32
33
|
others = _objectWithoutProperties(props, _excluded);
|
|
33
34
|
var tableRef = useRef(null);
|
|
34
35
|
var componentId = useComponentId(props);
|
|
@@ -45,6 +46,9 @@ var BaseTable = function BaseTable(props, ref) {
|
|
|
45
46
|
}
|
|
46
47
|
return originData;
|
|
47
48
|
}, [originData, __designMode]);
|
|
49
|
+
var formatCurrentSettingKey = useMemo(function () {
|
|
50
|
+
return currentSettingKey || props.__id || "";
|
|
51
|
+
}, [currentSettingKey]);
|
|
48
52
|
var _useDataSourceKey = useDataSourceKey(),
|
|
49
53
|
dataSourceKey = _useDataSourceKey.dataSourceKey,
|
|
50
54
|
dataSourceKeyRef = _useDataSourceKey.dataSourceKeyRef;
|
|
@@ -60,12 +64,13 @@ var BaseTable = function BaseTable(props, ref) {
|
|
|
60
64
|
containerProps = _useDrawerState.containerProps,
|
|
61
65
|
Container = _useDrawerState.Container,
|
|
62
66
|
drawerContent = _useDrawerState.drawerContent;
|
|
63
|
-
var _useTableQuery = useTableQuery(props),
|
|
67
|
+
var _useTableQuery = useTableQuery(props, formatCurrentSettingKey),
|
|
64
68
|
queryPageConfig = _useTableQuery.queryPageConfig,
|
|
65
69
|
handleValuesChange = _useTableQuery.handleValuesChange,
|
|
66
70
|
refreshData = _useTableQuery.refreshData,
|
|
67
71
|
handleFilterChange = _useTableQuery.handleFilterChange,
|
|
68
|
-
refreshCurrentPage = _useTableQuery.refreshCurrentPage
|
|
72
|
+
refreshCurrentPage = _useTableQuery.refreshCurrentPage,
|
|
73
|
+
getInitialValues = _useTableQuery.getInitialValues;
|
|
69
74
|
var handleAllValuesChange = function handleAllValuesChange(changedValues, values) {
|
|
70
75
|
var _props$onValuesChange;
|
|
71
76
|
props === null || props === void 0 || (_props$onValuesChange = props.onValuesChange) === null || _props$onValuesChange === void 0 || _props$onValuesChange.call(props, changedValues, values);
|
|
@@ -137,7 +142,8 @@ var BaseTable = function BaseTable(props, ref) {
|
|
|
137
142
|
closeDrawer: closeDrawer,
|
|
138
143
|
refreshData: refreshData,
|
|
139
144
|
handleFilterChange: handleFilterChange,
|
|
140
|
-
tableRef: tableRef
|
|
145
|
+
tableRef: tableRef,
|
|
146
|
+
getInitialValues: getInitialValues
|
|
141
147
|
});
|
|
142
148
|
useImperativeHandle(ref, function () {
|
|
143
149
|
if (tableRef.current) {
|
|
@@ -151,6 +157,7 @@ var BaseTable = function BaseTable(props, ref) {
|
|
|
151
157
|
return /*#__PURE__*/React.createElement(TableSettingProvider, null, /*#__PURE__*/React.createElement(Table, _extends({
|
|
152
158
|
ref: tableRef
|
|
153
159
|
}, others, transformProps, {
|
|
160
|
+
currentSettingKey: formatCurrentSettingKey,
|
|
154
161
|
dataSource: (data === null || data === void 0 ? void 0 : data.data) || [],
|
|
155
162
|
loading: list === null || list === void 0 ? void 0 : list.loading,
|
|
156
163
|
onValuesChange: handleAllValuesChange
|
|
@@ -37,7 +37,8 @@ var Filter = function Filter(props) {
|
|
|
37
37
|
handleValuesChange = props.handleValuesChange,
|
|
38
38
|
search = props.search,
|
|
39
39
|
filterBy = props.filterBy,
|
|
40
|
-
show = props.show
|
|
40
|
+
show = props.show,
|
|
41
|
+
getInitialValues = props.getInitialValues;
|
|
41
42
|
var _Form$useForm = Form.useForm(),
|
|
42
43
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
43
44
|
form = _Form$useForm2[0];
|
|
@@ -149,6 +150,9 @@ var Filter = function Filter(props) {
|
|
|
149
150
|
allowClear: true
|
|
150
151
|
}) : null;
|
|
151
152
|
}, [search]);
|
|
153
|
+
var initialValues = useMemo(function () {
|
|
154
|
+
return getInitialValues === null || getInitialValues === void 0 ? void 0 : getInitialValues();
|
|
155
|
+
}, [search, filterBy]);
|
|
152
156
|
return /*#__PURE__*/React.createElement(Form, {
|
|
153
157
|
labelCol: {
|
|
154
158
|
span: 0
|
|
@@ -157,7 +161,8 @@ var Filter = function Filter(props) {
|
|
|
157
161
|
size: "large",
|
|
158
162
|
layout: "inline",
|
|
159
163
|
className: "filter-form-wrapper",
|
|
160
|
-
onValuesChange: onValuesChange
|
|
164
|
+
onValuesChange: onValuesChange,
|
|
165
|
+
initialValues: initialValues
|
|
161
166
|
}, searchDom, filterDom, show && sortButtonShow && /*#__PURE__*/React.createElement(FilterButton, {
|
|
162
167
|
value: list,
|
|
163
168
|
quickFilterMaxLength: quickFilterMaxLength,
|
|
@@ -9,6 +9,7 @@ interface UseTablePropsProps {
|
|
|
9
9
|
refreshData: () => void;
|
|
10
10
|
handleFilterChange: (changedFields: any, allFields: any) => void;
|
|
11
11
|
tableRef: any;
|
|
12
|
+
getInitialValues: () => Record<string, any>;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* 处理table的props
|
|
@@ -17,6 +18,7 @@ interface UseTablePropsProps {
|
|
|
17
18
|
* @returns
|
|
18
19
|
*/
|
|
19
20
|
declare const useTableProps: (props: UseTablePropsProps) => {
|
|
21
|
+
currentComponentId: any;
|
|
20
22
|
title: number | boolean | React.ReactFragment | JSX.Element | (() => React.ReactNode) | null | undefined;
|
|
21
23
|
pagination: {
|
|
22
24
|
total: number;
|
|
@@ -28,9 +30,11 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
28
30
|
columns: import("./useColumns").Column[];
|
|
29
31
|
subTitle: number | boolean | React.ReactFragment | JSX.Element | (() => React.ReactNode) | null | undefined;
|
|
30
32
|
buttons: any[] | null;
|
|
31
|
-
filter:
|
|
33
|
+
filter: any;
|
|
32
34
|
onRow: (record: any) => any;
|
|
33
35
|
actionButtons: any[] | null;
|
|
36
|
+
__id?: string | undefined;
|
|
37
|
+
currentSettingKey?: string | undefined;
|
|
34
38
|
titleButtons?: {
|
|
35
39
|
show: boolean;
|
|
36
40
|
maxCount: number;
|
|
@@ -42,12 +46,6 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
42
46
|
items: OperationItem[];
|
|
43
47
|
} | undefined;
|
|
44
48
|
operation?: {
|
|
45
|
-
/**
|
|
46
|
-
* 处理table的props
|
|
47
|
-
* 转换title
|
|
48
|
-
* @param props
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
49
|
show: boolean;
|
|
52
50
|
title: string;
|
|
53
51
|
width: number;
|
|
@@ -94,5 +92,6 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
94
92
|
create?: Record<string, any> | undefined;
|
|
95
93
|
destroy?: Record<string, any> | undefined;
|
|
96
94
|
} | undefined;
|
|
95
|
+
localSettings?: import("../../../table/types").LocalSettingsType | undefined;
|
|
97
96
|
};
|
|
98
97
|
export default useTableProps;
|
|
@@ -35,7 +35,8 @@ var useTableProps = function useTableProps(props) {
|
|
|
35
35
|
closeDrawer = props.closeDrawer,
|
|
36
36
|
refreshData = props.refreshData,
|
|
37
37
|
handleFilterChange = props.handleFilterChange,
|
|
38
|
-
tableRef = props.tableRef
|
|
38
|
+
tableRef = props.tableRef,
|
|
39
|
+
getInitialValues = props.getInitialValues;
|
|
39
40
|
var propsTitle = originProps.title,
|
|
40
41
|
propsSubTitle = originProps.subTitle,
|
|
41
42
|
titleButtons = originProps.titleButtons,
|
|
@@ -45,7 +46,9 @@ var useTableProps = function useTableProps(props) {
|
|
|
45
46
|
search = originProps.search,
|
|
46
47
|
clickToDetail = originProps.clickToDetail,
|
|
47
48
|
propsOnRow = originProps.onRow,
|
|
48
|
-
filterBy = originProps.filterBy
|
|
49
|
+
filterBy = originProps.filterBy,
|
|
50
|
+
currentSettingKey = originProps.currentSettingKey,
|
|
51
|
+
__id = originProps.__id;
|
|
49
52
|
var _ref = operation || {},
|
|
50
53
|
items = _ref.items,
|
|
51
54
|
show = _ref.show,
|
|
@@ -279,12 +282,15 @@ var useTableProps = function useTableProps(props) {
|
|
|
279
282
|
if (!(propsFilter !== null && propsFilter !== void 0 && propsFilter.show) && !(search !== null && search !== void 0 && search.show)) {
|
|
280
283
|
return null;
|
|
281
284
|
}
|
|
282
|
-
|
|
285
|
+
var dom = /*#__PURE__*/React.createElement(Filter, _extends({}, propsFilter, {
|
|
283
286
|
componentId: componentId,
|
|
284
287
|
search: search,
|
|
285
288
|
handleValuesChange: handleFilterChange,
|
|
286
|
-
filterBy: filterBy
|
|
289
|
+
filterBy: filterBy,
|
|
290
|
+
getInitialValues: getInitialValues
|
|
287
291
|
}));
|
|
292
|
+
dom.__proto__.__items = propsFilter === null || propsFilter === void 0 ? void 0 : propsFilter.items;
|
|
293
|
+
return dom;
|
|
288
294
|
}, [propsFilter, search]);
|
|
289
295
|
var onRow = useMemoizedFn(function (record) {
|
|
290
296
|
if (!(clickToDetail !== null && clickToDetail !== void 0 && clickToDetail.show)) {
|
|
@@ -315,6 +321,7 @@ var useTableProps = function useTableProps(props) {
|
|
|
315
321
|
});
|
|
316
322
|
});
|
|
317
323
|
return _objectSpread(_objectSpread({}, originProps), {}, {
|
|
324
|
+
currentComponentId: componentId,
|
|
318
325
|
title: title,
|
|
319
326
|
pagination: pagination,
|
|
320
327
|
columns: columns,
|
|
@@ -11,7 +11,7 @@ declare type Params = {
|
|
|
11
11
|
sortBy: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
declare const useTableQuery: (props: DataSourceTableProps) => {
|
|
14
|
+
declare const useTableQuery: (props: DataSourceTableProps, currentSettingHash: string) => {
|
|
15
15
|
queryPageConfig: {
|
|
16
16
|
page: number;
|
|
17
17
|
pageSize: number;
|
|
@@ -28,5 +28,6 @@ declare const useTableQuery: (props: DataSourceTableProps) => {
|
|
|
28
28
|
refreshData: () => void;
|
|
29
29
|
handleFilterChange: (changedFields: any, allFields: any) => void;
|
|
30
30
|
refreshCurrentPage: () => void;
|
|
31
|
+
getInitialValues: () => Record<string, any>;
|
|
31
32
|
};
|
|
32
33
|
export default useTableQuery;
|