@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,273 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/auto-resize-text/auto-text-size-standalone.ts
|
|
20
|
+
var auto_text_size_standalone_exports = {};
|
|
21
|
+
__export(auto_text_size_standalone_exports, {
|
|
22
|
+
autoTextSize: () => autoTextSize,
|
|
23
|
+
updateTextSize: () => updateTextSize
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(auto_text_size_standalone_exports);
|
|
26
|
+
function throttleAnimationFrame(func) {
|
|
27
|
+
let wait = false;
|
|
28
|
+
return () => {
|
|
29
|
+
if (!wait) {
|
|
30
|
+
wait = true;
|
|
31
|
+
requestAnimationFrame(() => {
|
|
32
|
+
func();
|
|
33
|
+
wait = false;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var antiOverflowAlgo = ({
|
|
39
|
+
fontSizePx,
|
|
40
|
+
minFontSizePx,
|
|
41
|
+
fontSizePrecisionPx,
|
|
42
|
+
updateFontSizePx,
|
|
43
|
+
breakPredicate: breakPred
|
|
44
|
+
}) => {
|
|
45
|
+
const maxIterCount = Math.ceil(1 / fontSizePrecisionPx);
|
|
46
|
+
let iterCount = 0;
|
|
47
|
+
while (fontSizePx > minFontSizePx && iterCount < maxIterCount) {
|
|
48
|
+
if (breakPred()) break;
|
|
49
|
+
fontSizePx = updateFontSizePx(fontSizePx - fontSizePrecisionPx);
|
|
50
|
+
iterCount++;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var getContentWidth = (element) => {
|
|
54
|
+
const computedStyle = getComputedStyle(element);
|
|
55
|
+
return element.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
|
|
56
|
+
};
|
|
57
|
+
var getContentHeight = (element) => {
|
|
58
|
+
const computedStyle = getComputedStyle(element);
|
|
59
|
+
return element.clientHeight - parseFloat(computedStyle.paddingTop) - parseFloat(computedStyle.paddingBottom);
|
|
60
|
+
};
|
|
61
|
+
var multilineAlgo = (opts) => {
|
|
62
|
+
opts.innerEl.style.whiteSpace = "nowrap";
|
|
63
|
+
onelineAlgo(opts);
|
|
64
|
+
if (opts.innerEl.scrollWidth > getContentWidth(opts.containerEl)) {
|
|
65
|
+
opts.innerEl.style.whiteSpace = "normal";
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var onelineAlgo = ({
|
|
69
|
+
innerEl,
|
|
70
|
+
containerEl,
|
|
71
|
+
fontSizePx,
|
|
72
|
+
minFontSizePx,
|
|
73
|
+
maxFontSizePx,
|
|
74
|
+
fontSizePrecisionPx,
|
|
75
|
+
updateFontSizePx
|
|
76
|
+
}) => {
|
|
77
|
+
const maxIterCount = 10;
|
|
78
|
+
let iterCount = 0;
|
|
79
|
+
let prevOverflowFactor = 1;
|
|
80
|
+
while (iterCount < maxIterCount) {
|
|
81
|
+
const w0 = innerEl.scrollWidth;
|
|
82
|
+
const w1 = getContentWidth(containerEl);
|
|
83
|
+
const canGrow = fontSizePx < maxFontSizePx && w0 < w1;
|
|
84
|
+
const canShrink = fontSizePx > minFontSizePx && w0 > w1;
|
|
85
|
+
const overflowFactor = w0 / w1;
|
|
86
|
+
if (prevOverflowFactor === overflowFactor) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (!(canGrow || canShrink)) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
const updatePx = fontSizePx / overflowFactor - fontSizePx;
|
|
93
|
+
const prevFontSizePx = fontSizePx;
|
|
94
|
+
fontSizePx = updateFontSizePx(fontSizePx + updatePx);
|
|
95
|
+
if (Math.abs(fontSizePx - prevFontSizePx) <= fontSizePrecisionPx) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
prevOverflowFactor = overflowFactor;
|
|
99
|
+
iterCount++;
|
|
100
|
+
}
|
|
101
|
+
antiOverflowAlgo({
|
|
102
|
+
fontSizePx,
|
|
103
|
+
minFontSizePx,
|
|
104
|
+
updateFontSizePx,
|
|
105
|
+
fontSizePrecisionPx,
|
|
106
|
+
breakPredicate: () => innerEl.scrollWidth <= getContentWidth(containerEl)
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
var boxAlgo = ({
|
|
110
|
+
innerEl,
|
|
111
|
+
containerEl,
|
|
112
|
+
fontSizePx,
|
|
113
|
+
minFontSizePx,
|
|
114
|
+
maxFontSizePx,
|
|
115
|
+
fontSizePrecisionPx,
|
|
116
|
+
updateFontSizePx
|
|
117
|
+
}) => {
|
|
118
|
+
const maxIterCount = 100;
|
|
119
|
+
fontSizePx = updateFontSizePx((maxFontSizePx - minFontSizePx) * 0.5);
|
|
120
|
+
let updatePx = (maxFontSizePx - minFontSizePx) * 0.25;
|
|
121
|
+
let iterCount = 0;
|
|
122
|
+
while (updatePx > fontSizePrecisionPx && iterCount < maxIterCount) {
|
|
123
|
+
const w0 = innerEl.scrollWidth;
|
|
124
|
+
const w1 = getContentWidth(containerEl);
|
|
125
|
+
const h0 = innerEl.scrollHeight;
|
|
126
|
+
const h1 = getContentHeight(containerEl);
|
|
127
|
+
if (w0 === w1 && h0 === h1) break;
|
|
128
|
+
if (fontSizePx < maxFontSizePx && w0 <= w1 && h0 <= h1) {
|
|
129
|
+
fontSizePx = updateFontSizePx(fontSizePx + updatePx);
|
|
130
|
+
} else if (fontSizePx > minFontSizePx && (w0 > w1 || h0 > h1)) {
|
|
131
|
+
fontSizePx = updateFontSizePx(fontSizePx - updatePx);
|
|
132
|
+
}
|
|
133
|
+
updatePx *= 0.5;
|
|
134
|
+
iterCount++;
|
|
135
|
+
}
|
|
136
|
+
antiOverflowAlgo({
|
|
137
|
+
fontSizePx,
|
|
138
|
+
minFontSizePx,
|
|
139
|
+
updateFontSizePx,
|
|
140
|
+
fontSizePrecisionPx,
|
|
141
|
+
breakPredicate: () => innerEl.scrollWidth <= getContentWidth(containerEl) && innerEl.scrollHeight <= getContentHeight(containerEl)
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
function updateTextSize({
|
|
145
|
+
innerEl,
|
|
146
|
+
containerEl,
|
|
147
|
+
mode = "multiline",
|
|
148
|
+
minFontSizePx = 8,
|
|
149
|
+
maxFontSizePx = 160,
|
|
150
|
+
fontSizePrecisionPx = 0.1,
|
|
151
|
+
scrollToEnd = false
|
|
152
|
+
}) {
|
|
153
|
+
const t0 = performance.now();
|
|
154
|
+
if (!isFinite(minFontSizePx)) {
|
|
155
|
+
throw new Error(`Invalid minFontSizePx (${minFontSizePx})`);
|
|
156
|
+
}
|
|
157
|
+
if (!isFinite(minFontSizePx)) {
|
|
158
|
+
throw new Error(`Invalid maxFontSizePx (${maxFontSizePx})`);
|
|
159
|
+
}
|
|
160
|
+
if (!isFinite(fontSizePrecisionPx) || fontSizePrecisionPx === 0) {
|
|
161
|
+
throw new Error(`Invalid fontSizePrecisionPx (${fontSizePrecisionPx})`);
|
|
162
|
+
}
|
|
163
|
+
if (containerEl.children.length > 1) {
|
|
164
|
+
console.warn(
|
|
165
|
+
`AutoTextSize has ${containerEl.children.length - 1} siblings. This may interfere with the algorithm.`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const containerStyles = {
|
|
169
|
+
display: "flex",
|
|
170
|
+
alignItems: "start"
|
|
171
|
+
};
|
|
172
|
+
const innerStyles = {
|
|
173
|
+
display: "block"
|
|
174
|
+
};
|
|
175
|
+
if (mode === "oneline") {
|
|
176
|
+
innerStyles.whiteSpace = "nowrap";
|
|
177
|
+
} else if (mode === "multiline") {
|
|
178
|
+
innerStyles.wordBreak = "break-word";
|
|
179
|
+
} else if (mode === "box") {
|
|
180
|
+
innerStyles.whiteSpace = "pre-wrap";
|
|
181
|
+
innerStyles.wordBreak = "break-word";
|
|
182
|
+
} else if (mode === "boxoneline") {
|
|
183
|
+
innerStyles.whiteSpace = "nowrap";
|
|
184
|
+
}
|
|
185
|
+
Object.assign(containerEl.style, containerStyles);
|
|
186
|
+
Object.assign(innerEl.style, innerStyles);
|
|
187
|
+
const fontSizeStr = window.getComputedStyle(innerEl, null).getPropertyValue("font-size");
|
|
188
|
+
let fontSizePx = parseFloat(fontSizeStr);
|
|
189
|
+
let iterations = 0;
|
|
190
|
+
const updateFontSizePx = (px) => {
|
|
191
|
+
px = Math.min(Math.max(px, minFontSizePx), maxFontSizePx);
|
|
192
|
+
fontSizePx = px;
|
|
193
|
+
innerEl.style.fontSize = `${fontSizePx}px`;
|
|
194
|
+
iterations++;
|
|
195
|
+
return fontSizePx;
|
|
196
|
+
};
|
|
197
|
+
if (fontSizePx > maxFontSizePx || fontSizePx < minFontSizePx) {
|
|
198
|
+
updateFontSizePx(fontSizePx);
|
|
199
|
+
}
|
|
200
|
+
const algoOpts = {
|
|
201
|
+
innerEl,
|
|
202
|
+
containerEl,
|
|
203
|
+
fontSizePx,
|
|
204
|
+
minFontSizePx,
|
|
205
|
+
maxFontSizePx,
|
|
206
|
+
fontSizePrecisionPx,
|
|
207
|
+
updateFontSizePx
|
|
208
|
+
};
|
|
209
|
+
if (mode === "oneline") {
|
|
210
|
+
onelineAlgo(algoOpts);
|
|
211
|
+
} else if (mode === "multiline") {
|
|
212
|
+
multilineAlgo(algoOpts);
|
|
213
|
+
} else if (mode === "box") {
|
|
214
|
+
boxAlgo(algoOpts);
|
|
215
|
+
} else if (mode === "boxoneline") {
|
|
216
|
+
boxAlgo(algoOpts);
|
|
217
|
+
}
|
|
218
|
+
if (scrollToEnd) {
|
|
219
|
+
requestAnimationFrame(() => {
|
|
220
|
+
if (mode === "oneline" || mode === "boxoneline") {
|
|
221
|
+
const maxScrollLeft = Math.max(0, innerEl.scrollWidth - innerEl.clientWidth);
|
|
222
|
+
innerEl.scrollLeft = maxScrollLeft;
|
|
223
|
+
} else {
|
|
224
|
+
const maxScrollTop = Math.max(0, innerEl.scrollHeight - innerEl.clientHeight);
|
|
225
|
+
innerEl.scrollTop = maxScrollTop;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function autoTextSize({
|
|
231
|
+
innerEl,
|
|
232
|
+
containerEl,
|
|
233
|
+
mode,
|
|
234
|
+
minFontSizePx,
|
|
235
|
+
maxFontSizePx,
|
|
236
|
+
fontSizePrecisionPx,
|
|
237
|
+
scrollToEnd
|
|
238
|
+
}) {
|
|
239
|
+
let containerDimensions = void 0;
|
|
240
|
+
const throttledUpdateTextSize = throttleAnimationFrame(() => {
|
|
241
|
+
updateTextSize({
|
|
242
|
+
innerEl,
|
|
243
|
+
containerEl,
|
|
244
|
+
mode,
|
|
245
|
+
maxFontSizePx,
|
|
246
|
+
minFontSizePx,
|
|
247
|
+
fontSizePrecisionPx,
|
|
248
|
+
scrollToEnd
|
|
249
|
+
});
|
|
250
|
+
containerDimensions = [
|
|
251
|
+
getContentWidth(containerEl),
|
|
252
|
+
getContentHeight(containerEl)
|
|
253
|
+
];
|
|
254
|
+
});
|
|
255
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
256
|
+
const prevContainerDimensions = containerDimensions;
|
|
257
|
+
containerDimensions = [
|
|
258
|
+
getContentWidth(containerEl),
|
|
259
|
+
getContentHeight(containerEl)
|
|
260
|
+
];
|
|
261
|
+
if ((prevContainerDimensions == null ? void 0 : prevContainerDimensions[0]) !== containerDimensions[0] || (prevContainerDimensions == null ? void 0 : prevContainerDimensions[1]) !== containerDimensions[1]) {
|
|
262
|
+
throttledUpdateTextSize();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
resizeObserver.observe(containerEl);
|
|
266
|
+
throttledUpdateTextSize.disconnect = () => resizeObserver.disconnect();
|
|
267
|
+
return throttledUpdateTextSize;
|
|
268
|
+
}
|
|
269
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
270
|
+
0 && (module.exports = {
|
|
271
|
+
autoTextSize,
|
|
272
|
+
updateTextSize
|
|
273
|
+
});
|
|
@@ -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,71 @@
|
|
|
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 __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/auto-resize-text/index.tsx
|
|
30
|
+
var auto_resize_text_exports = {};
|
|
31
|
+
__export(auto_resize_text_exports, {
|
|
32
|
+
default: () => AutoResizeText
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(auto_resize_text_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_auto_text_size_standalone = require("./auto-text-size-standalone");
|
|
37
|
+
function AutoResizeText({
|
|
38
|
+
mode,
|
|
39
|
+
minFontSizePx,
|
|
40
|
+
maxFontSizePx,
|
|
41
|
+
fontSizePrecisionPx,
|
|
42
|
+
scrollToEnd,
|
|
43
|
+
as: Comp = "div",
|
|
44
|
+
children,
|
|
45
|
+
...rest
|
|
46
|
+
}) {
|
|
47
|
+
const updateTextSizeRef = (0, import_react.useRef)();
|
|
48
|
+
(0, import_react.useEffect)(() => {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = updateTextSizeRef.current) == null ? void 0 : _a.call(updateTextSizeRef);
|
|
51
|
+
}, [children]);
|
|
52
|
+
const refCallback = (0, import_react.useCallback)(
|
|
53
|
+
(innerEl) => {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = updateTextSizeRef.current) == null ? void 0 : _a.disconnect();
|
|
56
|
+
const containerEl = innerEl == null ? void 0 : innerEl.parentElement;
|
|
57
|
+
if (!innerEl || !containerEl) return;
|
|
58
|
+
updateTextSizeRef.current = (0, import_auto_text_size_standalone.autoTextSize)({
|
|
59
|
+
innerEl,
|
|
60
|
+
containerEl,
|
|
61
|
+
mode,
|
|
62
|
+
minFontSizePx,
|
|
63
|
+
maxFontSizePx,
|
|
64
|
+
fontSizePrecisionPx,
|
|
65
|
+
scrollToEnd
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
[mode, minFontSizePx, maxFontSizePx, fontSizePrecisionPx, scrollToEnd]
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ import_react.default.createElement(Comp, { ref: refCallback, ...rest }, children);
|
|
71
|
+
}
|
|
@@ -56,6 +56,7 @@ var BaseTable = (props, ref) => {
|
|
|
56
56
|
columns: propsColumns,
|
|
57
57
|
dataSource,
|
|
58
58
|
operationContent,
|
|
59
|
+
currentSettingKey,
|
|
59
60
|
...others
|
|
60
61
|
} = props;
|
|
61
62
|
const tableRef = (0, import_react.useRef)(null);
|
|
@@ -70,6 +71,9 @@ var BaseTable = (props, ref) => {
|
|
|
70
71
|
}
|
|
71
72
|
return originData;
|
|
72
73
|
}, [originData, __designMode]);
|
|
74
|
+
const formatCurrentSettingKey = (0, import_react.useMemo)(() => {
|
|
75
|
+
return currentSettingKey || props.__id || "";
|
|
76
|
+
}, [currentSettingKey]);
|
|
73
77
|
const { dataSourceKey, dataSourceKeyRef } = (0, import_useDataSourceKey.default)();
|
|
74
78
|
const beforeClose = (0, import_react.useRef)();
|
|
75
79
|
const setBeforeClose = (0, import_react.useCallback)((fn) => {
|
|
@@ -84,7 +88,7 @@ var BaseTable = (props, ref) => {
|
|
|
84
88
|
Container,
|
|
85
89
|
drawerContent
|
|
86
90
|
} = (0, import_useDrawerState.default)(operationContent);
|
|
87
|
-
const { queryPageConfig, handleValuesChange, refreshData, handleFilterChange, refreshCurrentPage } = (0, import_useTableQuery.default)(props);
|
|
91
|
+
const { queryPageConfig, handleValuesChange, refreshData, handleFilterChange, refreshCurrentPage, getInitialValues } = (0, import_useTableQuery.default)(props, formatCurrentSettingKey);
|
|
88
92
|
const handleAllValuesChange = (changedValues, values) => {
|
|
89
93
|
var _a;
|
|
90
94
|
(_a = props == null ? void 0 : props.onValuesChange) == null ? void 0 : _a.call(props, changedValues, values);
|
|
@@ -130,7 +134,8 @@ var BaseTable = (props, ref) => {
|
|
|
130
134
|
closeDrawer,
|
|
131
135
|
refreshData,
|
|
132
136
|
handleFilterChange,
|
|
133
|
-
tableRef
|
|
137
|
+
tableRef,
|
|
138
|
+
getInitialValues
|
|
134
139
|
});
|
|
135
140
|
(0, import_react.useImperativeHandle)(ref, () => {
|
|
136
141
|
if (tableRef.current) {
|
|
@@ -147,6 +152,7 @@ var BaseTable = (props, ref) => {
|
|
|
147
152
|
ref: tableRef,
|
|
148
153
|
...others,
|
|
149
154
|
...transformProps,
|
|
155
|
+
currentSettingKey: formatCurrentSettingKey,
|
|
150
156
|
dataSource: (data == null ? void 0 : data.data) || [],
|
|
151
157
|
loading: list == null ? void 0 : list.loading,
|
|
152
158
|
onValuesChange: handleAllValuesChange
|
|
@@ -52,7 +52,8 @@ var Filter = (props) => {
|
|
|
52
52
|
handleValuesChange,
|
|
53
53
|
search,
|
|
54
54
|
filterBy,
|
|
55
|
-
show
|
|
55
|
+
show,
|
|
56
|
+
getInitialValues
|
|
56
57
|
} = props;
|
|
57
58
|
const [form] = import_antd.Form.useForm();
|
|
58
59
|
const { dataSource } = (0, import_useDataSource.default)();
|
|
@@ -155,6 +156,9 @@ var Filter = (props) => {
|
|
|
155
156
|
}
|
|
156
157
|
) : null;
|
|
157
158
|
}, [search]);
|
|
159
|
+
const initialValues = (0, import_react.useMemo)(() => {
|
|
160
|
+
return getInitialValues == null ? void 0 : getInitialValues();
|
|
161
|
+
}, [search, filterBy]);
|
|
158
162
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
159
163
|
import_antd.Form,
|
|
160
164
|
{
|
|
@@ -163,7 +167,8 @@ var Filter = (props) => {
|
|
|
163
167
|
size: "large",
|
|
164
168
|
layout: "inline",
|
|
165
169
|
className: "filter-form-wrapper",
|
|
166
|
-
onValuesChange
|
|
170
|
+
onValuesChange,
|
|
171
|
+
initialValues
|
|
167
172
|
},
|
|
168
173
|
searchDom,
|
|
169
174
|
filterDom,
|
|
@@ -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;
|
|
@@ -54,7 +54,8 @@ var useTableProps = (props) => {
|
|
|
54
54
|
closeDrawer,
|
|
55
55
|
refreshData,
|
|
56
56
|
handleFilterChange,
|
|
57
|
-
tableRef
|
|
57
|
+
tableRef,
|
|
58
|
+
getInitialValues
|
|
58
59
|
} = props;
|
|
59
60
|
const {
|
|
60
61
|
title: propsTitle,
|
|
@@ -66,7 +67,9 @@ var useTableProps = (props) => {
|
|
|
66
67
|
search,
|
|
67
68
|
clickToDetail,
|
|
68
69
|
onRow: propsOnRow,
|
|
69
|
-
filterBy
|
|
70
|
+
filterBy,
|
|
71
|
+
currentSettingKey,
|
|
72
|
+
__id
|
|
70
73
|
} = originProps;
|
|
71
74
|
const {
|
|
72
75
|
items,
|
|
@@ -260,16 +263,19 @@ var useTableProps = (props) => {
|
|
|
260
263
|
if (!(propsFilter == null ? void 0 : propsFilter.show) && !(search == null ? void 0 : search.show)) {
|
|
261
264
|
return null;
|
|
262
265
|
}
|
|
263
|
-
|
|
266
|
+
const dom = /* @__PURE__ */ import_react.default.createElement(
|
|
264
267
|
import_filter.default,
|
|
265
268
|
{
|
|
266
269
|
...propsFilter,
|
|
267
270
|
componentId,
|
|
268
271
|
search,
|
|
269
272
|
handleValuesChange: handleFilterChange,
|
|
270
|
-
filterBy
|
|
273
|
+
filterBy,
|
|
274
|
+
getInitialValues
|
|
271
275
|
}
|
|
272
276
|
);
|
|
277
|
+
dom.__proto__.__items = propsFilter == null ? void 0 : propsFilter.items;
|
|
278
|
+
return dom;
|
|
273
279
|
}, [propsFilter, search]);
|
|
274
280
|
const onRow = (0, import_ahooks.useMemoizedFn)((record) => {
|
|
275
281
|
if (!(clickToDetail == null ? void 0 : clickToDetail.show)) {
|
|
@@ -300,6 +306,7 @@ var useTableProps = (props) => {
|
|
|
300
306
|
});
|
|
301
307
|
return {
|
|
302
308
|
...originProps,
|
|
309
|
+
currentComponentId: componentId,
|
|
303
310
|
title,
|
|
304
311
|
pagination,
|
|
305
312
|
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;
|
|
@@ -24,25 +24,61 @@ __export(useTableQuery_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(useTableQuery_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
var import_ahooks = require("ahooks");
|
|
27
|
-
var
|
|
27
|
+
var import_utils = require("../../../table/Table/utils");
|
|
28
|
+
var useTableQuery = (props, currentSettingHash) => {
|
|
28
29
|
var _a, _b, _c, _d;
|
|
29
|
-
const { filterBy, sortBy, tabs } = props;
|
|
30
|
+
const { filterBy, sortBy, tabs, localSettings } = props;
|
|
31
|
+
const tableId = (0, import_react.useMemo)(() => {
|
|
32
|
+
if (props.__designMode === "design") {
|
|
33
|
+
return "designMode-mock-table-id";
|
|
34
|
+
}
|
|
35
|
+
return (props == null ? void 0 : props.currentComponentId) || props.__id;
|
|
36
|
+
}, [props.__id, props.__designMode, props == null ? void 0 : props.currentComponentId]);
|
|
37
|
+
const currentViewMode = (0, import_react.useMemo)(() => (0, import_utils.getCurrentViewModeFromLocalStorage)(tableId) || "grid", [tableId]);
|
|
30
38
|
const [queryPageConfig, setQueryPageConfig] = (0, import_react.useState)({
|
|
31
39
|
page: 1,
|
|
32
40
|
pageSize: 20,
|
|
33
41
|
filter: ((_b = (_a = tabs == null ? void 0 : tabs.items) == null ? void 0 : _a[0]) == null ? void 0 : _b.filterBy) || filterBy || {},
|
|
34
42
|
sort: ((_d = (_c = tabs == null ? void 0 : tabs.items) == null ? void 0 : _c[0]) == null ? void 0 : _d.sortBy) || sortBy
|
|
35
43
|
});
|
|
44
|
+
const getInitialValues = (0, import_ahooks.useMemoizedFn)(() => {
|
|
45
|
+
try {
|
|
46
|
+
if (!tableId) return {};
|
|
47
|
+
const setting = (0, import_utils.getTableSettingByCurrentViewMode)(tableId, currentViewMode);
|
|
48
|
+
console.log("setting22", setting);
|
|
49
|
+
return (setting == null ? void 0 : setting.filters) || {};
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
(0, import_react.useEffect)(() => {
|
|
55
|
+
var _a2;
|
|
56
|
+
if (!tableId) return;
|
|
57
|
+
const enable = !!((localSettings == null ? void 0 : localSettings.enable) && ((_a2 = localSettings.scope) == null ? void 0 : _a2.includes("filters")));
|
|
58
|
+
if (!enable) return;
|
|
59
|
+
const setting = (0, import_utils.getTableSettingByCurrentViewMode)(tableId, currentViewMode);
|
|
60
|
+
const persisted = (setting == null ? void 0 : setting.filters) || {};
|
|
61
|
+
if (persisted && Object.keys(persisted).length > 0) {
|
|
62
|
+
setQueryPageConfig((prev) => ({
|
|
63
|
+
...prev,
|
|
64
|
+
filter: { ...prev.filter, ...persisted }
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}, [tableId, currentViewMode, JSON.stringify(localSettings)]);
|
|
36
68
|
const handleValuesChange = (0, import_ahooks.useMemoizedFn)(
|
|
37
69
|
(params, allParams) => {
|
|
70
|
+
var _a2;
|
|
38
71
|
const { page, size } = params.pagination || {};
|
|
72
|
+
let nextFilterForSave = null;
|
|
39
73
|
setQueryPageConfig((prev) => {
|
|
40
|
-
var
|
|
74
|
+
var _a3, _b2, _c2;
|
|
41
75
|
let sort = prev.sort || sortBy;
|
|
42
76
|
let filter = prev.filter;
|
|
43
77
|
if ("tabs" in params) {
|
|
44
|
-
sort = ((
|
|
45
|
-
|
|
78
|
+
sort = ((_a3 = params.tabs) == null ? void 0 : _a3.sortBy) || sortBy || "";
|
|
79
|
+
const tabsFilter = ((_b2 = params.tabs) == null ? void 0 : _b2.filterBy) || {};
|
|
80
|
+
filter = { ...prev.filter, ...tabsFilter };
|
|
81
|
+
nextFilterForSave = filter;
|
|
46
82
|
}
|
|
47
83
|
if ("order_by" in params) {
|
|
48
84
|
sort = params.order_by || ((_c2 = allParams.tabs) == null ? void 0 : _c2.sortBy) || sortBy;
|
|
@@ -55,15 +91,49 @@ var useTableQuery = (props) => {
|
|
|
55
91
|
filter
|
|
56
92
|
};
|
|
57
93
|
});
|
|
94
|
+
const enable = !!((localSettings == null ? void 0 : localSettings.enable) && ((_a2 = localSettings.scope) == null ? void 0 : _a2.includes("filters")));
|
|
95
|
+
if (enable && tableId && nextFilterForSave) {
|
|
96
|
+
const excluded = new Set((localSettings == null ? void 0 : localSettings.excludedFilterFields) || []);
|
|
97
|
+
const filtered = {};
|
|
98
|
+
Object.keys(nextFilterForSave).forEach((k) => {
|
|
99
|
+
if (!excluded.has(k)) {
|
|
100
|
+
filtered[k] = nextFilterForSave[k];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
(0, import_utils.setTableSettingToLocalStorage)({
|
|
104
|
+
tableId,
|
|
105
|
+
tableSettingObj: { filters: filtered },
|
|
106
|
+
currentViewMode,
|
|
107
|
+
currentSettingHash
|
|
108
|
+
});
|
|
109
|
+
}
|
|
58
110
|
}
|
|
59
111
|
);
|
|
60
112
|
const handleFilterChange = (0, import_ahooks.useMemoizedFn)(
|
|
61
113
|
(changedFields, allFields) => {
|
|
114
|
+
var _a2;
|
|
115
|
+
const nextFilter = { ...allFields };
|
|
62
116
|
setQueryPageConfig((prev) => ({
|
|
63
117
|
...prev,
|
|
64
118
|
page: 1,
|
|
65
|
-
filter: { ...prev.filter, ...
|
|
119
|
+
filter: { ...prev.filter, ...nextFilter, ...filterBy || {} }
|
|
66
120
|
}));
|
|
121
|
+
const enable = !!((localSettings == null ? void 0 : localSettings.enable) && ((_a2 = localSettings.scope) == null ? void 0 : _a2.includes("filters")));
|
|
122
|
+
if (enable && tableId) {
|
|
123
|
+
const excluded = new Set((localSettings == null ? void 0 : localSettings.excludedFilterFields) || []);
|
|
124
|
+
const filtered = {};
|
|
125
|
+
Object.keys(nextFilter || {}).forEach((k) => {
|
|
126
|
+
if (!excluded.has(k)) {
|
|
127
|
+
filtered[k] = nextFilter[k];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
(0, import_utils.setTableSettingToLocalStorage)({
|
|
131
|
+
tableId,
|
|
132
|
+
tableSettingObj: { filters: filtered },
|
|
133
|
+
currentViewMode,
|
|
134
|
+
currentSettingHash
|
|
135
|
+
});
|
|
136
|
+
}
|
|
67
137
|
}
|
|
68
138
|
);
|
|
69
139
|
const refreshData = (0, import_ahooks.useMemoizedFn)(() => {
|
|
@@ -83,7 +153,8 @@ var useTableQuery = (props) => {
|
|
|
83
153
|
handleValuesChange,
|
|
84
154
|
refreshData,
|
|
85
155
|
handleFilterChange,
|
|
86
|
-
refreshCurrentPage
|
|
156
|
+
refreshCurrentPage,
|
|
157
|
+
getInitialValues
|
|
87
158
|
};
|
|
88
159
|
};
|
|
89
160
|
var useTableQuery_default = useTableQuery;
|