@pisell/utils 3.0.4 → 3.0.6
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/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +76 -1
- package/es/arrayUtils.js +103 -24
- package/es/common/stateHelper.d.ts +22 -0
- package/es/common/stateHelper.js +23 -0
- package/es/common/types.d.ts +31 -0
- package/es/componentStorage.d.ts +38 -0
- package/es/componentStorage.js +106 -0
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +29 -0
- package/es/format.js +90 -112
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +39 -18
- package/es/index.js +40 -29
- package/es/jsBridge/index.d.ts +14 -106
- package/es/jsBridge/index.js +57 -40
- package/es/jsBridge/regDeviceApi.js +87 -126
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +11 -11
- package/es/locales.js +79 -69
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -71
- package/es/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/es/number-input/hooks/useNumberInputState.js +72 -0
- package/es/number-input/types.d.ts +96 -0
- package/es/number-input/utils/formatter.d.ts +56 -0
- package/es/number-input/utils/formatter.js +56 -0
- package/es/number-input/utils/validation.d.ts +32 -0
- package/es/number-input/utils/validation.js +52 -0
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -120
- package/es/platform.d.ts +12 -9
- package/es/platform.js +61 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/es/select/hooks/useDebouncedSearch.js +41 -0
- package/es/select/hooks/useSelectState.d.ts +19 -0
- package/es/select/hooks/useSelectState.js +60 -0
- package/es/select/index.d.ts +7 -0
- package/es/select/types.d.ts +256 -0
- package/es/select/utils/filterOptions.d.ts +23 -0
- package/es/select/utils/filterOptions.js +29 -0
- package/es/select/utils/helpers.d.ts +43 -0
- package/es/select/utils/helpers.js +51 -0
- package/es/select/utils/index.d.ts +4 -0
- package/es/select/utils/sortOptions.d.ts +13 -0
- package/es/select/utils/sortOptions.js +20 -0
- package/es/select/utils/tagAggregation.d.ts +25 -0
- package/es/select/utils/tagAggregation.js +35 -0
- package/es/text-input/hooks/useTextInputState.d.ts +28 -0
- package/es/text-input/hooks/useTextInputState.js +70 -0
- package/es/text-input/types.d.ts +56 -0
- package/es/text-input/utils/validation.d.ts +28 -0
- package/es/text-input/utils/validation.js +51 -0
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +57 -0
- package/es/walletValidity.js +404 -460
- package/es/weighing.d.ts +65 -0
- package/es/weighing.js +96 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +76 -1
- package/lib/arrayUtils.js +102 -37
- package/lib/common/stateHelper.d.ts +22 -0
- package/lib/common/stateHelper.js +23 -0
- package/lib/common/types.d.ts +31 -0
- package/lib/componentStorage.d.ts +38 -0
- package/lib/componentStorage.js +114 -0
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +29 -0
- package/lib/format.js +91 -93
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +39 -18
- package/lib/index.js +137 -68
- package/lib/jsBridge/index.d.ts +14 -106
- package/lib/jsBridge/index.js +60 -60
- package/lib/jsBridge/regDeviceApi.js +86 -133
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +11 -11
- package/lib/locales.js +79 -63
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -91
- package/lib/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/lib/number-input/hooks/useNumberInputState.js +73 -0
- package/lib/number-input/types.d.ts +96 -0
- package/lib/number-input/utils/formatter.d.ts +56 -0
- package/lib/number-input/utils/formatter.js +58 -0
- package/lib/number-input/utils/validation.d.ts +32 -0
- package/lib/number-input/utils/validation.js +52 -0
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -91
- package/lib/platform.d.ts +12 -9
- package/lib/platform.js +68 -123
- package/lib/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/lib/select/hooks/useDebouncedSearch.js +42 -0
- package/lib/select/hooks/useSelectState.d.ts +19 -0
- package/lib/select/hooks/useSelectState.js +62 -0
- package/lib/select/index.d.ts +7 -0
- package/lib/select/types.d.ts +256 -0
- package/lib/select/utils/filterOptions.d.ts +23 -0
- package/lib/select/utils/filterOptions.js +30 -0
- package/lib/select/utils/helpers.d.ts +43 -0
- package/lib/select/utils/helpers.js +55 -0
- package/lib/select/utils/index.d.ts +4 -0
- package/lib/select/utils/sortOptions.d.ts +13 -0
- package/lib/select/utils/sortOptions.js +20 -0
- package/lib/select/utils/tagAggregation.d.ts +25 -0
- package/lib/select/utils/tagAggregation.js +35 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +28 -0
- package/lib/text-input/hooks/useTextInputState.js +71 -0
- package/lib/text-input/types.d.ts +56 -0
- package/lib/text-input/utils/validation.d.ts +28 -0
- package/lib/text-input/utils/validation.js +51 -0
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +57 -0
- package/lib/walletValidity.js +420 -323
- package/lib/weighing.d.ts +65 -0
- package/lib/weighing.js +114 -0
- package/package.json +1 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
package/es/weighing.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/weighing.d.ts
|
|
2
|
+
/** 商品配置与 NativeScale 使用的重量单位。 */
|
|
3
|
+
type WeightUnitName = 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES';
|
|
4
|
+
/** 订单快照与 UI 使用的标准单位符号。 */
|
|
5
|
+
type WeightUnitSymbol = 'kg' | 'g' | 'lb' | 'oz';
|
|
6
|
+
type WeightUnit = WeightUnitName | WeightUnitSymbol;
|
|
7
|
+
/**
|
|
8
|
+
* Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
|
|
9
|
+
* 后续标准单位变化时,应优先只修改此处。
|
|
10
|
+
*/
|
|
11
|
+
declare const STANDARD_WEIGHT_UNIT: WeightUnitName;
|
|
12
|
+
declare const WEIGHT_PRECISION = 3;
|
|
13
|
+
declare const UNIT_PRICE_PRECISION = 2;
|
|
14
|
+
declare const MAX_RETAIL_SCALE_WEIGHT_KG = 1000;
|
|
15
|
+
declare const WEIGHT_UNIT_SYMBOLS: Record<WeightUnitName, WeightUnitSymbol>;
|
|
16
|
+
declare const WEIGHT_UNIT_NAMES: Record<WeightUnitSymbol, WeightUnitName>;
|
|
17
|
+
/** 单位对应的克数,作为不依赖 NativeScale 的目录价格换算基准。 */
|
|
18
|
+
declare const WEIGHT_UNIT_GRAMS: Record<WeightUnit, number>;
|
|
19
|
+
declare const STANDARD_WEIGHT_UNIT_SYMBOL: WeightUnitSymbol;
|
|
20
|
+
declare const normalizeWeightUnit: (unit?: string | null, fallback?: WeightUnitName) => WeightUnitName;
|
|
21
|
+
declare const getWeightUnitSymbol: (unit?: string | null) => string;
|
|
22
|
+
declare const getWeightUnitGrams: (unit?: string | null) => number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
|
|
25
|
+
* 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
|
|
26
|
+
*/
|
|
27
|
+
declare const getWeightUnitPriceConversionFactor: (params: {
|
|
28
|
+
sourceUnit?: string | null;
|
|
29
|
+
sourceUnitValue?: string | number | null;
|
|
30
|
+
targetUnit?: string | null;
|
|
31
|
+
}) => number | undefined;
|
|
32
|
+
declare const isSupportedWeightUnit: (unit?: unknown) => unit is WeightUnit;
|
|
33
|
+
declare const formatWeightValue: (value: unknown, precision?: number) => string;
|
|
34
|
+
declare const formatUnitPriceValue: (value: unknown, precision?: number) => string;
|
|
35
|
+
type ScaleReadingStatus = 'stable' | 'unstable' | 'overload' | 'negative' | string | null;
|
|
36
|
+
declare const INVALID_SCALE_READING_STATUSES: readonly ["overload", "negative"];
|
|
37
|
+
declare const isInvalidScaleReadingStatus: (status?: ScaleReadingStatus) => boolean;
|
|
38
|
+
declare const getUsableScaleWeight: (status: ScaleReadingStatus | undefined, weight: number) => number;
|
|
39
|
+
interface WeighingSnapshot {
|
|
40
|
+
open_sold_weight?: number | string | boolean;
|
|
41
|
+
mode?: 'auto' | 'manual' | string;
|
|
42
|
+
weight_source?: 'auto' | 'manual' | string;
|
|
43
|
+
weight?: string | number;
|
|
44
|
+
tare?: {
|
|
45
|
+
id?: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
value?: string | number;
|
|
48
|
+
unit?: WeightUnit | string;
|
|
49
|
+
};
|
|
50
|
+
tare_name?: string;
|
|
51
|
+
tare_weight?: string | number;
|
|
52
|
+
net_weight?: string | number;
|
|
53
|
+
unit_price?: string | number;
|
|
54
|
+
unit?: WeightUnit | string;
|
|
55
|
+
unit_weight?: string | number;
|
|
56
|
+
unit_data_snapshot?: unknown;
|
|
57
|
+
scalePriceProduct?: unknown;
|
|
58
|
+
total_amount?: string | number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 解析订单行称重快照:product_sku 是权威源,_extend.weighing 仅用于旧流程兼容。
|
|
62
|
+
*/
|
|
63
|
+
declare const resolveWeighingSnapshot: (dataSource?: Record<string, any> | null) => WeighingSnapshot | undefined;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { INVALID_SCALE_READING_STATUSES, MAX_RETAIL_SCALE_WEIGHT_KG, STANDARD_WEIGHT_UNIT, STANDARD_WEIGHT_UNIT_SYMBOL, ScaleReadingStatus, UNIT_PRICE_PRECISION, WEIGHT_PRECISION, WEIGHT_UNIT_GRAMS, WEIGHT_UNIT_NAMES, WEIGHT_UNIT_SYMBOLS, WeighingSnapshot, WeightUnit, WeightUnitName, WeightUnitSymbol, formatUnitPriceValue, formatWeightValue, getUsableScaleWeight, getWeightUnitGrams, getWeightUnitPriceConversionFactor, getWeightUnitSymbol, isInvalidScaleReadingStatus, isSupportedWeightUnit, normalizeWeightUnit, resolveWeighingSnapshot };
|
package/es/weighing.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//#region src/weighing.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
|
|
4
|
+
* 后续标准单位变化时,应优先只修改此处。
|
|
5
|
+
*/
|
|
6
|
+
const STANDARD_WEIGHT_UNIT = "KILOGRAMS";
|
|
7
|
+
const WEIGHT_PRECISION = 3;
|
|
8
|
+
const UNIT_PRICE_PRECISION = 2;
|
|
9
|
+
const MAX_RETAIL_SCALE_WEIGHT_KG = 1e3;
|
|
10
|
+
const WEIGHT_UNIT_SYMBOLS = {
|
|
11
|
+
KILOGRAMS: "kg",
|
|
12
|
+
GRAMS: "g",
|
|
13
|
+
POUNDS: "lb",
|
|
14
|
+
OUNCES: "oz"
|
|
15
|
+
};
|
|
16
|
+
const WEIGHT_UNIT_NAMES = {
|
|
17
|
+
kg: "KILOGRAMS",
|
|
18
|
+
g: "GRAMS",
|
|
19
|
+
lb: "POUNDS",
|
|
20
|
+
oz: "OUNCES"
|
|
21
|
+
};
|
|
22
|
+
/** 单位对应的克数,作为不依赖 NativeScale 的目录价格换算基准。 */
|
|
23
|
+
const WEIGHT_UNIT_GRAMS = {
|
|
24
|
+
KILOGRAMS: 1e3,
|
|
25
|
+
GRAMS: 1,
|
|
26
|
+
POUNDS: 453.59237,
|
|
27
|
+
OUNCES: 28.349523125,
|
|
28
|
+
kg: 1e3,
|
|
29
|
+
g: 1,
|
|
30
|
+
lb: 453.59237,
|
|
31
|
+
oz: 28.349523125
|
|
32
|
+
};
|
|
33
|
+
const STANDARD_WEIGHT_UNIT_SYMBOL = WEIGHT_UNIT_SYMBOLS[STANDARD_WEIGHT_UNIT];
|
|
34
|
+
const normalizeWeightUnit = (unit, fallback = STANDARD_WEIGHT_UNIT) => {
|
|
35
|
+
if (unit && unit in WEIGHT_UNIT_SYMBOLS) return unit;
|
|
36
|
+
if (unit && unit in WEIGHT_UNIT_NAMES) return WEIGHT_UNIT_NAMES[unit];
|
|
37
|
+
return fallback;
|
|
38
|
+
};
|
|
39
|
+
const getWeightUnitSymbol = (unit) => {
|
|
40
|
+
if (unit && unit in WEIGHT_UNIT_SYMBOLS) return WEIGHT_UNIT_SYMBOLS[unit];
|
|
41
|
+
if (unit && unit in WEIGHT_UNIT_NAMES) return unit;
|
|
42
|
+
return unit || STANDARD_WEIGHT_UNIT_SYMBOL;
|
|
43
|
+
};
|
|
44
|
+
const getWeightUnitGrams = (unit) => unit ? WEIGHT_UNIT_GRAMS[unit] : WEIGHT_UNIT_GRAMS[STANDARD_WEIGHT_UNIT];
|
|
45
|
+
/**
|
|
46
|
+
* 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
|
|
47
|
+
* 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
|
|
48
|
+
*/
|
|
49
|
+
const getWeightUnitPriceConversionFactor = (params) => {
|
|
50
|
+
var _params$sourceUnitVal;
|
|
51
|
+
const sourceGrams = getWeightUnitGrams(params.sourceUnit || "KILOGRAMS");
|
|
52
|
+
const targetGrams = getWeightUnitGrams(params.targetUnit || "KILOGRAMS");
|
|
53
|
+
const sourceUnitValue = Number((_params$sourceUnitVal = params.sourceUnitValue) !== null && _params$sourceUnitVal !== void 0 ? _params$sourceUnitVal : 1);
|
|
54
|
+
if (!sourceGrams || !targetGrams || !Number.isFinite(sourceUnitValue) || sourceUnitValue <= 0) return;
|
|
55
|
+
return targetGrams / (sourceGrams * sourceUnitValue);
|
|
56
|
+
};
|
|
57
|
+
const isSupportedWeightUnit = (unit) => typeof unit === "string" && unit in WEIGHT_UNIT_GRAMS;
|
|
58
|
+
const formatWeightValue = (value, precision = 3) => {
|
|
59
|
+
const parsedValue = Number(value);
|
|
60
|
+
return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
|
|
61
|
+
};
|
|
62
|
+
const formatUnitPriceValue = (value, precision = 2) => {
|
|
63
|
+
const parsedValue = Number(value);
|
|
64
|
+
return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
|
|
65
|
+
};
|
|
66
|
+
const INVALID_SCALE_READING_STATUSES = ["overload", "negative"];
|
|
67
|
+
const isInvalidScaleReadingStatus = (status) => INVALID_SCALE_READING_STATUSES.includes(status);
|
|
68
|
+
const getUsableScaleWeight = (status, weight) => isInvalidScaleReadingStatus(status) ? 0 : weight;
|
|
69
|
+
const hasDisplayWeight = (value) => Boolean(value && (Number(value.weight) > 0 || Number(value.net_weight) > 0));
|
|
70
|
+
const resolveProductSkuSnapshot = (value) => {
|
|
71
|
+
const snapshot = value;
|
|
72
|
+
return Number(snapshot === null || snapshot === void 0 ? void 0 : snapshot.open_sold_weight) === 1 && hasDisplayWeight(snapshot) ? snapshot : void 0;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* 解析订单行称重快照:product_sku 是权威源,_extend.weighing 仅用于旧流程兼容。
|
|
76
|
+
*/
|
|
77
|
+
const resolveWeighingSnapshot = (dataSource) => {
|
|
78
|
+
var _dataSource$_origin, _dataSource$metadata, _dataSource$_origin2, _dataSource$_extend, _dataSource$metadata2;
|
|
79
|
+
if (!dataSource) return void 0;
|
|
80
|
+
const productSkuCandidates = [
|
|
81
|
+
dataSource.product_sku,
|
|
82
|
+
(_dataSource$_origin = dataSource._origin) === null || _dataSource$_origin === void 0 ? void 0 : _dataSource$_origin.product_sku,
|
|
83
|
+
(_dataSource$metadata = dataSource.metadata) === null || _dataSource$metadata === void 0 || (_dataSource$metadata = _dataSource$metadata.origin) === null || _dataSource$metadata === void 0 ? void 0 : _dataSource$metadata.product_sku
|
|
84
|
+
];
|
|
85
|
+
for (const candidate of productSkuCandidates) {
|
|
86
|
+
const snapshot = resolveProductSkuSnapshot(candidate);
|
|
87
|
+
if (snapshot) return snapshot;
|
|
88
|
+
}
|
|
89
|
+
return [
|
|
90
|
+
(_dataSource$_origin2 = dataSource._origin) === null || _dataSource$_origin2 === void 0 || (_dataSource$_origin2 = _dataSource$_origin2._extend) === null || _dataSource$_origin2 === void 0 ? void 0 : _dataSource$_origin2.weighing,
|
|
91
|
+
(_dataSource$_extend = dataSource._extend) === null || _dataSource$_extend === void 0 ? void 0 : _dataSource$_extend.weighing,
|
|
92
|
+
(_dataSource$metadata2 = dataSource.metadata) === null || _dataSource$metadata2 === void 0 || (_dataSource$metadata2 = _dataSource$metadata2.origin) === null || _dataSource$metadata2 === void 0 || (_dataSource$metadata2 = _dataSource$metadata2._extend) === null || _dataSource$metadata2 === void 0 ? void 0 : _dataSource$metadata2.weighing
|
|
93
|
+
].find((candidate) => hasDisplayWeight(candidate));
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { INVALID_SCALE_READING_STATUSES, MAX_RETAIL_SCALE_WEIGHT_KG, STANDARD_WEIGHT_UNIT, STANDARD_WEIGHT_UNIT_SYMBOL, UNIT_PRICE_PRECISION, WEIGHT_PRECISION, WEIGHT_UNIT_GRAMS, WEIGHT_UNIT_NAMES, WEIGHT_UNIT_SYMBOLS, formatUnitPriceValue, formatWeightValue, getUsableScaleWeight, getWeightUnitGrams, getWeightUnitPriceConversionFactor, getWeightUnitSymbol, isInvalidScaleReadingStatus, isSupportedWeightUnit, normalizeWeightUnit, resolveWeighingSnapshot };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/asyncToGenerator.js
|
|
2
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3
|
+
try {
|
|
4
|
+
var i = n[a](c), u = i.value;
|
|
5
|
+
} catch (n) {
|
|
6
|
+
e(n);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
10
|
+
}
|
|
11
|
+
function _asyncToGenerator(n) {
|
|
12
|
+
return function() {
|
|
13
|
+
var t = this, e = arguments;
|
|
14
|
+
return new Promise(function(r, o) {
|
|
15
|
+
var a = n.apply(t, e);
|
|
16
|
+
function _next(n) {
|
|
17
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
18
|
+
}
|
|
19
|
+
function _throw(n) {
|
|
20
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
21
|
+
}
|
|
22
|
+
_next(void 0);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports._asyncToGenerator = _asyncToGenerator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const require_toPropertyKey = require("./toPropertyKey.js");
|
|
2
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = require_toPropertyKey.toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports._defineProperty = _defineProperty;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_defineProperty = require("./defineProperty.js");
|
|
2
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/objectSpread2.js
|
|
3
|
+
function ownKeys(e, r) {
|
|
4
|
+
var t = Object.keys(e);
|
|
5
|
+
if (Object.getOwnPropertySymbols) {
|
|
6
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
7
|
+
r && (o = o.filter(function(r) {
|
|
8
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
9
|
+
})), t.push.apply(t, o);
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
function _objectSpread2(e) {
|
|
14
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
15
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
16
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
17
|
+
require_defineProperty._defineProperty(e, r, t[r]);
|
|
18
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
19
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports._objectSpread2 = _objectSpread2;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const require_typeof = require("./typeof.js");
|
|
2
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != require_typeof._typeof(t) || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != require_typeof._typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.toPrimitive = toPrimitive;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_typeof = require("./typeof.js");
|
|
2
|
+
const require_toPrimitive = require("./toPrimitive.js");
|
|
3
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = require_toPrimitive.toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == require_typeof._typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.toPropertyKey = toPropertyKey;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
Object.defineProperty(exports, "_typeof", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return _typeof;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.__toESM = __toESM;
|
package/lib/arrayUtils.d.ts
CHANGED
|
@@ -1 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/arrayUtils.d.ts
|
|
2
|
+
declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
|
|
3
|
+
/**
|
|
4
|
+
* 分组键的基础类型
|
|
5
|
+
* @description 分组条件计算后得到的标量值
|
|
6
|
+
*/
|
|
7
|
+
type GroupKey = string | number | boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 分组规则
|
|
10
|
+
* @template T - 数据项类型
|
|
11
|
+
* @description
|
|
12
|
+
* - `string`:单字段路径,支持 `'a.b.c'` 点路径
|
|
13
|
+
* - `string[]`:多字段组合,按顺序拼接为组合键
|
|
14
|
+
* - `(item, index) => GroupKey | GroupKey[]`:完全自定义分组键
|
|
15
|
+
*/
|
|
16
|
+
type GroupBySpec<T> = string | string[] | ((item: T, index: number) => GroupKey | GroupKey[]);
|
|
17
|
+
/**
|
|
18
|
+
* 单个分组的结果模型
|
|
19
|
+
* @template T - 数据项类型
|
|
20
|
+
*/
|
|
21
|
+
interface GroupResult<T> {
|
|
22
|
+
/** 分组唯一标识(默认由各分组键以 `|` 拼接) */
|
|
23
|
+
groupId: string;
|
|
24
|
+
/** 分组键值数组,与 `GroupBySpec` 顺序对应 */
|
|
25
|
+
keys: GroupKey[];
|
|
26
|
+
/** 字段名 -> 键值映射,便于头部直接按字段名取值(自定义函数分组时为空对象) */
|
|
27
|
+
keyMap: Record<string, GroupKey>;
|
|
28
|
+
/** 该分组内的原始数据项(保持原数组中的相对顺序) */
|
|
29
|
+
items: T[];
|
|
30
|
+
/** 分组的最终顺序下标 */
|
|
31
|
+
index: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 分组可选项
|
|
35
|
+
* @template T - 数据项类型
|
|
36
|
+
*/
|
|
37
|
+
interface GroupByOptions<T> {
|
|
38
|
+
/** 自定义分组 id 生成(默认 `keys.join('|')`) */
|
|
39
|
+
getGroupId?: (keys: GroupKey[]) => string;
|
|
40
|
+
/** 分组之间的排序;不传则保持各分组首次出现的顺序 */
|
|
41
|
+
sortGroups?: (a: GroupResult<T>, b: GroupResult<T>) => number;
|
|
42
|
+
/** 分组内数据项的排序;不传则保持原始相对顺序 */
|
|
43
|
+
sortItems?: (a: T, b: T) => number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 按点路径安全取值
|
|
47
|
+
* @param obj - 取值对象
|
|
48
|
+
* @param path - 字段路径,支持 `'a.b.c'`
|
|
49
|
+
* @returns 路径对应的值,路径不存在时返回 undefined
|
|
50
|
+
* @example
|
|
51
|
+
* getByPath({ a: { b: 1 } }, 'a.b') // 1
|
|
52
|
+
* getByPath({ id: 9 }, 'id') // 9
|
|
53
|
+
*/
|
|
54
|
+
declare const getByPath: (obj: unknown, path: string) => unknown;
|
|
55
|
+
/**
|
|
56
|
+
* 将数组按指定条件分组
|
|
57
|
+
* @template T - 数据项类型
|
|
58
|
+
* @param dataSource - 待分组的数据数组
|
|
59
|
+
* @param spec - 分组规则,详见 {@link GroupBySpec}
|
|
60
|
+
* @param options - 可选项(自定义 groupId、分组/组内排序)
|
|
61
|
+
* @returns 分组结果数组,默认保持各分组首次出现的顺序、组内保持原始相对顺序
|
|
62
|
+
* @description
|
|
63
|
+
* 该函数为纯函数,不修改入参(排序时对内部拷贝操作)。相同分组键的数据会被归入同一分组。
|
|
64
|
+
* @example
|
|
65
|
+
* // 单字段
|
|
66
|
+
* groupBy(list, 'productId');
|
|
67
|
+
* @example
|
|
68
|
+
* // 商品 + 时间组合
|
|
69
|
+
* groupBy(list, ['productId', 'time']);
|
|
70
|
+
* @example
|
|
71
|
+
* // 自定义键
|
|
72
|
+
* groupBy(list, (item) => `${item.productId}_${item.time}`);
|
|
73
|
+
*/
|
|
74
|
+
declare const groupBy: <T>(dataSource: T[], spec: GroupBySpec<T>, options?: GroupByOptions<T>) => GroupResult<T>[];
|
|
75
|
+
//#endregion
|
|
76
|
+
export { GroupByOptions, GroupBySpec, GroupKey, GroupResult, getByPath, groupBy, uniqueByKey };
|
package/lib/arrayUtils.js
CHANGED
|
@@ -1,40 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/arrayUtils.ts
|
|
2
|
+
const uniqueByKey = (arr, key) => {
|
|
3
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4
|
+
const result = [];
|
|
5
|
+
for (const item of arr) {
|
|
6
|
+
const keyValue = item[key];
|
|
7
|
+
if (!seen.has(keyValue)) {
|
|
8
|
+
seen.add(keyValue);
|
|
9
|
+
result.push(item);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
8
13
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 按点路径安全取值
|
|
16
|
+
* @param obj - 取值对象
|
|
17
|
+
* @param path - 字段路径,支持 `'a.b.c'`
|
|
18
|
+
* @returns 路径对应的值,路径不存在时返回 undefined
|
|
19
|
+
* @example
|
|
20
|
+
* getByPath({ a: { b: 1 } }, 'a.b') // 1
|
|
21
|
+
* getByPath({ id: 9 }, 'id') // 9
|
|
22
|
+
*/
|
|
23
|
+
const getByPath = (obj, path) => {
|
|
24
|
+
if (obj === null || obj === void 0) return;
|
|
25
|
+
if (path.indexOf(".") === -1) return obj[path];
|
|
26
|
+
return path.split(".").reduce((acc, key) => {
|
|
27
|
+
if (acc === null || acc === void 0) return;
|
|
28
|
+
return acc[key];
|
|
29
|
+
}, obj);
|
|
16
30
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var uniqueByKey = (arr, key) => {
|
|
26
|
-
const seen = /* @__PURE__ */ new Set();
|
|
27
|
-
const result = [];
|
|
28
|
-
for (const item of arr) {
|
|
29
|
-
const keyValue = item[key];
|
|
30
|
-
if (!seen.has(keyValue)) {
|
|
31
|
-
seen.add(keyValue);
|
|
32
|
-
result.push(item);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
31
|
+
/**
|
|
32
|
+
* 将任意值规范化为可用于分组的标量键
|
|
33
|
+
* @description null/undefined 统一归一为空字符串,对象/数组等转为字符串,避免分组键不稳定
|
|
34
|
+
*/
|
|
35
|
+
const normalizeGroupKey = (value) => {
|
|
36
|
+
if (value === null || value === void 0) return "";
|
|
37
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
38
|
+
return String(value);
|
|
36
39
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* 将数组按指定条件分组
|
|
42
|
+
* @template T - 数据项类型
|
|
43
|
+
* @param dataSource - 待分组的数据数组
|
|
44
|
+
* @param spec - 分组规则,详见 {@link GroupBySpec}
|
|
45
|
+
* @param options - 可选项(自定义 groupId、分组/组内排序)
|
|
46
|
+
* @returns 分组结果数组,默认保持各分组首次出现的顺序、组内保持原始相对顺序
|
|
47
|
+
* @description
|
|
48
|
+
* 该函数为纯函数,不修改入参(排序时对内部拷贝操作)。相同分组键的数据会被归入同一分组。
|
|
49
|
+
* @example
|
|
50
|
+
* // 单字段
|
|
51
|
+
* groupBy(list, 'productId');
|
|
52
|
+
* @example
|
|
53
|
+
* // 商品 + 时间组合
|
|
54
|
+
* groupBy(list, ['productId', 'time']);
|
|
55
|
+
* @example
|
|
56
|
+
* // 自定义键
|
|
57
|
+
* groupBy(list, (item) => `${item.productId}_${item.time}`);
|
|
58
|
+
*/
|
|
59
|
+
const groupBy = (dataSource, spec, options = {}) => {
|
|
60
|
+
const { getGroupId, sortGroups, sortItems } = options;
|
|
61
|
+
const fieldNames = Array.isArray(spec) ? spec : typeof spec === "string" ? [spec] : [];
|
|
62
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
63
|
+
const order = [];
|
|
64
|
+
(dataSource || []).forEach((item, index) => {
|
|
65
|
+
let keys;
|
|
66
|
+
if (typeof spec === "function") {
|
|
67
|
+
const result = spec(item, index);
|
|
68
|
+
keys = (Array.isArray(result) ? result : [result]).map(normalizeGroupKey);
|
|
69
|
+
} else if (Array.isArray(spec)) keys = spec.map((field) => normalizeGroupKey(getByPath(item, field)));
|
|
70
|
+
else keys = [normalizeGroupKey(getByPath(item, spec))];
|
|
71
|
+
const groupId = getGroupId ? getGroupId(keys) : keys.join("|");
|
|
72
|
+
let group = groupMap.get(groupId);
|
|
73
|
+
if (!group) {
|
|
74
|
+
const keyMap = {};
|
|
75
|
+
fieldNames.forEach((field, i) => {
|
|
76
|
+
keyMap[field] = keys[i];
|
|
77
|
+
});
|
|
78
|
+
group = {
|
|
79
|
+
groupId,
|
|
80
|
+
keys,
|
|
81
|
+
keyMap,
|
|
82
|
+
items: [],
|
|
83
|
+
index: order.length
|
|
84
|
+
};
|
|
85
|
+
groupMap.set(groupId, group);
|
|
86
|
+
order.push(groupId);
|
|
87
|
+
}
|
|
88
|
+
group.items.push(item);
|
|
89
|
+
});
|
|
90
|
+
let groups = order.map((id) => groupMap.get(id));
|
|
91
|
+
if (sortItems) groups.forEach((group) => {
|
|
92
|
+
group.items.sort(sortItems);
|
|
93
|
+
});
|
|
94
|
+
if (sortGroups) {
|
|
95
|
+
groups = groups.slice().sort(sortGroups);
|
|
96
|
+
groups.forEach((group, i) => {
|
|
97
|
+
group.index = i;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return groups;
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
exports.getByPath = getByPath;
|
|
104
|
+
exports.groupBy = groupBy;
|
|
105
|
+
exports.uniqueByKey = uniqueByKey;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DisplayState } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/common/stateHelper.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 根据 mode 和 disabled 计算组件的显示状态
|
|
6
|
+
*
|
|
7
|
+
* 状态优先级:disabled > mode
|
|
8
|
+
* 当 disabled=true 时,无论 mode 是什么,都显示为禁用态
|
|
9
|
+
*
|
|
10
|
+
* @param mode 状态模式('read' | 'edit')
|
|
11
|
+
* @param disabled 是否禁用
|
|
12
|
+
* @returns 显示状态('read' | 'edit' | 'disabled')
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* getDisplayState('edit', false) // 'edit'
|
|
16
|
+
* getDisplayState('read', false) // 'read'
|
|
17
|
+
* getDisplayState('edit', true) // 'disabled'
|
|
18
|
+
* getDisplayState('read', true) // 'disabled'
|
|
19
|
+
*/
|
|
20
|
+
declare function getDisplayState(mode?: 'read' | 'edit', disabled?: boolean): DisplayState;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getDisplayState };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/common/stateHelper.ts
|
|
2
|
+
/**
|
|
3
|
+
* 根据 mode 和 disabled 计算组件的显示状态
|
|
4
|
+
*
|
|
5
|
+
* 状态优先级:disabled > mode
|
|
6
|
+
* 当 disabled=true 时,无论 mode 是什么,都显示为禁用态
|
|
7
|
+
*
|
|
8
|
+
* @param mode 状态模式('read' | 'edit')
|
|
9
|
+
* @param disabled 是否禁用
|
|
10
|
+
* @returns 显示状态('read' | 'edit' | 'disabled')
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* getDisplayState('edit', false) // 'edit'
|
|
14
|
+
* getDisplayState('read', false) // 'read'
|
|
15
|
+
* getDisplayState('edit', true) // 'disabled'
|
|
16
|
+
* getDisplayState('read', true) // 'disabled'
|
|
17
|
+
*/
|
|
18
|
+
function getDisplayState(mode, disabled) {
|
|
19
|
+
if (disabled) return "disabled";
|
|
20
|
+
return mode || "edit";
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.getDisplayState = getDisplayState;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/common/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 公共类型定义
|
|
4
|
+
* 供所有输入组件使用
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 显示状态类型
|
|
8
|
+
*
|
|
9
|
+
* 所有输入组件的三种状态:
|
|
10
|
+
* - read: 只读态,纯文本展示
|
|
11
|
+
* - edit: 编辑态,显示输入控件
|
|
12
|
+
* - disabled: 禁用态,禁用的输入控件
|
|
13
|
+
*/
|
|
14
|
+
type DisplayState = 'read' | 'edit' | 'disabled';
|
|
15
|
+
/**
|
|
16
|
+
* 校验结果类型
|
|
17
|
+
*
|
|
18
|
+
* 所有输入组件的校验结果统一格式
|
|
19
|
+
*/
|
|
20
|
+
interface ValidationResult {
|
|
21
|
+
/**
|
|
22
|
+
* 是否校验通过
|
|
23
|
+
*/
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 错误信息数组
|
|
27
|
+
*/
|
|
28
|
+
errors: string[];
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { DisplayState, ValidationResult };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/componentStorage.d.ts
|
|
2
|
+
/** 生成存储 key 的路径后缀:pathname 或 pathname#memory_key(来自 URL memory_key 参数) */
|
|
3
|
+
declare function getStorageKeySuffix(): string;
|
|
4
|
+
/**
|
|
5
|
+
* 生成组件实例的存储 key。
|
|
6
|
+
* @param componentId 组件实例 id(如 __id)
|
|
7
|
+
* @param prefix 前缀,如 'table-setting'、'record-board-column-visibility'
|
|
8
|
+
*/
|
|
9
|
+
declare function getComponentStorageKey(componentId: string, prefix: string): string;
|
|
10
|
+
interface ColumnSettingStorageItem {
|
|
11
|
+
key: string;
|
|
12
|
+
dataIndex: string;
|
|
13
|
+
title?: unknown;
|
|
14
|
+
titleString?: string;
|
|
15
|
+
isShow: boolean;
|
|
16
|
+
sortIndex?: number;
|
|
17
|
+
fixed?: 'left' | 'right' | boolean;
|
|
18
|
+
}
|
|
19
|
+
declare function saveColumnSettingToLocal(params: {
|
|
20
|
+
componentId: string;
|
|
21
|
+
columnSetting: ColumnSettingStorageItem[];
|
|
22
|
+
}): void;
|
|
23
|
+
declare function getColumnSettingFromLocal(componentId?: string): ColumnSettingStorageItem[] | null;
|
|
24
|
+
declare function clearColumnSettingFromLocal(componentId?: string): void;
|
|
25
|
+
declare function saveColumnVisibilityToLocal(params: {
|
|
26
|
+
componentId: string;
|
|
27
|
+
columnVisibility: Record<string, boolean>; /** 列 key 顺序,用于列设置弹层拖拽排序后持久化 */
|
|
28
|
+
columnOrder?: string[];
|
|
29
|
+
}): void;
|
|
30
|
+
declare function getColumnVisibilityFromLocal(componentId?: string): Record<string, boolean> | null;
|
|
31
|
+
/** RecordBoard 列设置(显隐 + 顺序)从 localStorage 读取,用于列设置弹层拖拽排序与显隐持久化 */
|
|
32
|
+
declare function getRecordBoardColumnSettingFromLocal(componentId?: string): {
|
|
33
|
+
columnVisibility: Record<string, boolean>;
|
|
34
|
+
columnOrder: string[] | null;
|
|
35
|
+
} | null;
|
|
36
|
+
declare function clearColumnVisibilityFromLocal(componentId?: string): void;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ColumnSettingStorageItem, clearColumnSettingFromLocal, clearColumnVisibilityFromLocal, getColumnSettingFromLocal, getColumnVisibilityFromLocal, getComponentStorageKey, getRecordBoardColumnSettingFromLocal, getStorageKeySuffix, saveColumnSettingToLocal, saveColumnVisibilityToLocal };
|