@pisell/utils 3.0.6 → 3.0.7
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/arrayUtils.d.ts +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
package/es/weighing.d.ts
CHANGED
|
@@ -1,65 +1,62 @@
|
|
|
1
|
-
//#region src/weighing.d.ts
|
|
2
1
|
/** 商品配置与 NativeScale 使用的重量单位。 */
|
|
3
|
-
type WeightUnitName = 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES';
|
|
2
|
+
export declare type WeightUnitName = 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES';
|
|
4
3
|
/** 订单快照与 UI 使用的标准单位符号。 */
|
|
5
|
-
type WeightUnitSymbol = 'kg' | 'g' | 'lb' | 'oz';
|
|
6
|
-
type WeightUnit = WeightUnitName | WeightUnitSymbol;
|
|
4
|
+
export declare type WeightUnitSymbol = 'kg' | 'g' | 'lb' | 'oz';
|
|
5
|
+
export declare type WeightUnit = WeightUnitName | WeightUnitSymbol;
|
|
7
6
|
/**
|
|
8
7
|
* Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
|
|
9
8
|
* 后续标准单位变化时,应优先只修改此处。
|
|
10
9
|
*/
|
|
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>;
|
|
10
|
+
export declare const STANDARD_WEIGHT_UNIT: WeightUnitName;
|
|
11
|
+
export declare const WEIGHT_PRECISION = 3;
|
|
12
|
+
export declare const UNIT_PRICE_PRECISION = 2;
|
|
13
|
+
export declare const MAX_RETAIL_SCALE_WEIGHT_KG = 1000;
|
|
14
|
+
export declare const WEIGHT_UNIT_SYMBOLS: Record<WeightUnitName, WeightUnitSymbol>;
|
|
15
|
+
export declare const WEIGHT_UNIT_NAMES: Record<WeightUnitSymbol, WeightUnitName>;
|
|
17
16
|
/** 单位对应的克数,作为不依赖 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;
|
|
17
|
+
export declare const WEIGHT_UNIT_GRAMS: Record<WeightUnit, number>;
|
|
18
|
+
export declare const STANDARD_WEIGHT_UNIT_SYMBOL: WeightUnitSymbol;
|
|
19
|
+
export declare const normalizeWeightUnit: (unit?: string | null, fallback?: WeightUnitName) => WeightUnitName;
|
|
20
|
+
export declare const getWeightUnitSymbol: (unit?: string | null) => string;
|
|
21
|
+
export declare const getWeightUnitGrams: (unit?: string | null) => number | undefined;
|
|
23
22
|
/**
|
|
24
23
|
* 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
|
|
25
24
|
* 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
|
|
26
25
|
*/
|
|
27
|
-
declare const getWeightUnitPriceConversionFactor: (params: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
export declare const getWeightUnitPriceConversionFactor: (params: {
|
|
27
|
+
sourceUnit?: string | null;
|
|
28
|
+
sourceUnitValue?: string | number | null;
|
|
29
|
+
targetUnit?: string | null;
|
|
31
30
|
}) => 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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
export declare const isSupportedWeightUnit: (unit?: unknown) => unit is WeightUnit;
|
|
32
|
+
export declare const formatWeightValue: (value: unknown, precision?: number) => string;
|
|
33
|
+
export declare const formatUnitPriceValue: (value: unknown, precision?: number) => string;
|
|
34
|
+
export declare type ScaleReadingStatus = 'stable' | 'unstable' | 'overload' | 'negative' | string | null;
|
|
35
|
+
export declare const INVALID_SCALE_READING_STATUSES: readonly ["overload", "negative"];
|
|
36
|
+
export declare const isInvalidScaleReadingStatus: (status?: ScaleReadingStatus) => boolean;
|
|
37
|
+
export declare const getUsableScaleWeight: (status: ScaleReadingStatus | undefined, weight: number) => number;
|
|
38
|
+
export interface WeighingSnapshot {
|
|
39
|
+
open_sold_weight?: number | string | boolean;
|
|
40
|
+
mode?: 'auto' | 'manual' | string;
|
|
41
|
+
weight_source?: 'auto' | 'manual' | string;
|
|
42
|
+
weight?: string | number;
|
|
43
|
+
tare?: {
|
|
44
|
+
id?: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
value?: string | number;
|
|
47
|
+
unit?: WeightUnit | string;
|
|
48
|
+
};
|
|
49
|
+
tare_name?: string;
|
|
50
|
+
tare_weight?: string | number;
|
|
51
|
+
net_weight?: string | number;
|
|
52
|
+
unit_price?: string | number;
|
|
48
53
|
unit?: WeightUnit | string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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;
|
|
54
|
+
unit_weight?: string | number;
|
|
55
|
+
unit_data_snapshot?: unknown;
|
|
56
|
+
scalePriceProduct?: unknown;
|
|
57
|
+
total_amount?: string | number;
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
60
|
* 解析订单行称重快照:product_sku 是权威源,_extend.weighing 仅用于旧流程兼容。
|
|
62
61
|
*/
|
|
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 };
|
|
62
|
+
export declare const resolveWeighingSnapshot: (dataSource?: Record<string, any> | null) => WeighingSnapshot | undefined;
|
package/es/weighing.js
CHANGED
|
@@ -1,96 +1,119 @@
|
|
|
1
|
-
|
|
1
|
+
/** 商品配置与 NativeScale 使用的重量单位。 */
|
|
2
|
+
|
|
3
|
+
/** 订单快照与 UI 使用的标准单位符号。 */
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
|
-
* Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
|
|
4
|
-
* 后续标准单位变化时,应优先只修改此处。
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
* Pisell 的标准重量单位。目录单价、缺省秤单位和缺省展示均以它为准。
|
|
7
|
+
* 后续标准单位变化时,应优先只修改此处。
|
|
8
|
+
*/
|
|
9
|
+
export var STANDARD_WEIGHT_UNIT = 'KILOGRAMS';
|
|
10
|
+
export var WEIGHT_PRECISION = 3;
|
|
11
|
+
export var UNIT_PRICE_PRECISION = 2;
|
|
12
|
+
export var MAX_RETAIL_SCALE_WEIGHT_KG = 1000;
|
|
13
|
+
export var WEIGHT_UNIT_SYMBOLS = {
|
|
14
|
+
KILOGRAMS: 'kg',
|
|
15
|
+
GRAMS: 'g',
|
|
16
|
+
POUNDS: 'lb',
|
|
17
|
+
OUNCES: 'oz'
|
|
15
18
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export var WEIGHT_UNIT_NAMES = {
|
|
20
|
+
kg: 'KILOGRAMS',
|
|
21
|
+
g: 'GRAMS',
|
|
22
|
+
lb: 'POUNDS',
|
|
23
|
+
oz: 'OUNCES'
|
|
21
24
|
};
|
|
25
|
+
|
|
22
26
|
/** 单位对应的克数,作为不依赖 NativeScale 的目录价格换算基准。 */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
export var WEIGHT_UNIT_GRAMS = {
|
|
28
|
+
KILOGRAMS: 1000,
|
|
29
|
+
GRAMS: 1,
|
|
30
|
+
POUNDS: 453.59237,
|
|
31
|
+
OUNCES: 28.349523125,
|
|
32
|
+
kg: 1000,
|
|
33
|
+
g: 1,
|
|
34
|
+
lb: 453.59237,
|
|
35
|
+
oz: 28.349523125
|
|
32
36
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
export var STANDARD_WEIGHT_UNIT_SYMBOL = WEIGHT_UNIT_SYMBOLS[STANDARD_WEIGHT_UNIT];
|
|
38
|
+
export var normalizeWeightUnit = function normalizeWeightUnit(unit) {
|
|
39
|
+
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STANDARD_WEIGHT_UNIT;
|
|
40
|
+
if (unit && unit in WEIGHT_UNIT_SYMBOLS) {
|
|
41
|
+
return unit;
|
|
42
|
+
}
|
|
43
|
+
if (unit && unit in WEIGHT_UNIT_NAMES) {
|
|
44
|
+
return WEIGHT_UNIT_NAMES[unit];
|
|
45
|
+
}
|
|
46
|
+
return fallback;
|
|
38
47
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
export var getWeightUnitSymbol = function getWeightUnitSymbol(unit) {
|
|
49
|
+
if (unit && unit in WEIGHT_UNIT_SYMBOLS) {
|
|
50
|
+
return WEIGHT_UNIT_SYMBOLS[unit];
|
|
51
|
+
}
|
|
52
|
+
if (unit && unit in WEIGHT_UNIT_NAMES) {
|
|
53
|
+
return unit;
|
|
54
|
+
}
|
|
55
|
+
return unit || STANDARD_WEIGHT_UNIT_SYMBOL;
|
|
43
56
|
};
|
|
44
|
-
|
|
57
|
+
export var getWeightUnitGrams = function getWeightUnitGrams(unit) {
|
|
58
|
+
return unit ? WEIGHT_UNIT_GRAMS[unit] : WEIGHT_UNIT_GRAMS[STANDARD_WEIGHT_UNIT];
|
|
59
|
+
};
|
|
60
|
+
|
|
45
61
|
/**
|
|
46
|
-
* 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
|
|
47
|
-
* 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
* 将“每 sourceUnitValue 个 sourceUnit 的价格”换算到每 1 个目标单位的倍率。
|
|
63
|
+
* 这里只处理目录单价的单位关系;实际秤读数计价仍应使用 NativeScale。
|
|
64
|
+
*/
|
|
65
|
+
export var getWeightUnitPriceConversionFactor = function getWeightUnitPriceConversionFactor(params) {
|
|
66
|
+
var _params$sourceUnitVal;
|
|
67
|
+
var sourceGrams = getWeightUnitGrams(params.sourceUnit || STANDARD_WEIGHT_UNIT);
|
|
68
|
+
var targetGrams = getWeightUnitGrams(params.targetUnit || STANDARD_WEIGHT_UNIT);
|
|
69
|
+
var sourceUnitValue = Number((_params$sourceUnitVal = params.sourceUnitValue) !== null && _params$sourceUnitVal !== void 0 ? _params$sourceUnitVal : 1);
|
|
70
|
+
if (!sourceGrams || !targetGrams || !Number.isFinite(sourceUnitValue) || sourceUnitValue <= 0) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return targetGrams / (sourceGrams * sourceUnitValue);
|
|
56
74
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const parsedValue = Number(value);
|
|
60
|
-
return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
|
|
75
|
+
export var isSupportedWeightUnit = function isSupportedWeightUnit(unit) {
|
|
76
|
+
return typeof unit === 'string' && unit in WEIGHT_UNIT_GRAMS;
|
|
61
77
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
export var formatWeightValue = function formatWeightValue(value) {
|
|
79
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : WEIGHT_PRECISION;
|
|
80
|
+
var parsedValue = Number(value);
|
|
81
|
+
return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
|
|
65
82
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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;
|
|
83
|
+
export var formatUnitPriceValue = function formatUnitPriceValue(value) {
|
|
84
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : UNIT_PRICE_PRECISION;
|
|
85
|
+
var parsedValue = Number(value);
|
|
86
|
+
return (Number.isFinite(parsedValue) ? parsedValue : 0).toFixed(precision);
|
|
73
87
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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));
|
|
88
|
+
export var INVALID_SCALE_READING_STATUSES = ['overload', 'negative'];
|
|
89
|
+
export var isInvalidScaleReadingStatus = function isInvalidScaleReadingStatus(status) {
|
|
90
|
+
return INVALID_SCALE_READING_STATUSES.includes(status);
|
|
91
|
+
};
|
|
92
|
+
export var getUsableScaleWeight = function getUsableScaleWeight(status, weight) {
|
|
93
|
+
return isInvalidScaleReadingStatus(status) ? 0 : weight;
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
var hasDisplayWeight = function hasDisplayWeight(value) {
|
|
96
|
+
return Boolean(value && (Number(value.weight) > 0 || Number(value.net_weight) > 0));
|
|
97
|
+
};
|
|
98
|
+
var resolveProductSkuSnapshot = function resolveProductSkuSnapshot(value) {
|
|
99
|
+
var snapshot = value;
|
|
100
|
+
return Number(snapshot === null || snapshot === void 0 ? void 0 : snapshot.open_sold_weight) === 1 && hasDisplayWeight(snapshot) ? snapshot : undefined;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 解析订单行称重快照:product_sku 是权威源,_extend.weighing 仅用于旧流程兼容。
|
|
105
|
+
*/
|
|
106
|
+
export var resolveWeighingSnapshot = function resolveWeighingSnapshot(dataSource) {
|
|
107
|
+
var _dataSource$_origin, _dataSource$metadata, _dataSource$_origin2, _dataSource$_extend, _dataSource$metadata2;
|
|
108
|
+
if (!dataSource) return undefined;
|
|
109
|
+
var productSkuCandidates = [dataSource.product_sku, (_dataSource$_origin = dataSource._origin) === null || _dataSource$_origin === void 0 ? void 0 : _dataSource$_origin.product_sku, (_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];
|
|
110
|
+
for (var _i = 0, _productSkuCandidates = productSkuCandidates; _i < _productSkuCandidates.length; _i++) {
|
|
111
|
+
var candidate = _productSkuCandidates[_i];
|
|
112
|
+
var snapshot = resolveProductSkuSnapshot(candidate);
|
|
113
|
+
if (snapshot) return snapshot;
|
|
114
|
+
}
|
|
115
|
+
var legacyCandidates = [(_dataSource$_origin2 = dataSource._origin) === null || _dataSource$_origin2 === void 0 || (_dataSource$_origin2 = _dataSource$_origin2._extend) === null || _dataSource$_origin2 === void 0 ? void 0 : _dataSource$_origin2.weighing, (_dataSource$_extend = dataSource._extend) === null || _dataSource$_extend === void 0 ? void 0 : _dataSource$_extend.weighing, (_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];
|
|
116
|
+
return legacyCandidates.find(function (candidate) {
|
|
117
|
+
return hasDisplayWeight(candidate);
|
|
118
|
+
});
|
|
119
|
+
};
|
package/lib/arrayUtils.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
|
|
1
|
+
export declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
|
|
3
2
|
/**
|
|
4
3
|
* 分组键的基础类型
|
|
5
4
|
* @description 分组条件计算后得到的标量值
|
|
6
5
|
*/
|
|
7
|
-
type GroupKey = string | number | boolean;
|
|
6
|
+
export declare type GroupKey = string | number | boolean;
|
|
8
7
|
/**
|
|
9
8
|
* 分组规则
|
|
10
9
|
* @template T - 数据项类型
|
|
@@ -13,34 +12,34 @@ type GroupKey = string | number | boolean;
|
|
|
13
12
|
* - `string[]`:多字段组合,按顺序拼接为组合键
|
|
14
13
|
* - `(item, index) => GroupKey | GroupKey[]`:完全自定义分组键
|
|
15
14
|
*/
|
|
16
|
-
type GroupBySpec<T> = string | string[] | ((item: T, index: number) => GroupKey | GroupKey[]);
|
|
15
|
+
export declare type GroupBySpec<T> = string | string[] | ((item: T, index: number) => GroupKey | GroupKey[]);
|
|
17
16
|
/**
|
|
18
17
|
* 单个分组的结果模型
|
|
19
18
|
* @template T - 数据项类型
|
|
20
19
|
*/
|
|
21
|
-
interface GroupResult<T> {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
export interface GroupResult<T> {
|
|
21
|
+
/** 分组唯一标识(默认由各分组键以 `|` 拼接) */
|
|
22
|
+
groupId: string;
|
|
23
|
+
/** 分组键值数组,与 `GroupBySpec` 顺序对应 */
|
|
24
|
+
keys: GroupKey[];
|
|
25
|
+
/** 字段名 -> 键值映射,便于头部直接按字段名取值(自定义函数分组时为空对象) */
|
|
26
|
+
keyMap: Record<string, GroupKey>;
|
|
27
|
+
/** 该分组内的原始数据项(保持原数组中的相对顺序) */
|
|
28
|
+
items: T[];
|
|
29
|
+
/** 分组的最终顺序下标 */
|
|
30
|
+
index: number;
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
34
33
|
* 分组可选项
|
|
35
34
|
* @template T - 数据项类型
|
|
36
35
|
*/
|
|
37
|
-
interface GroupByOptions<T> {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
export interface GroupByOptions<T> {
|
|
37
|
+
/** 自定义分组 id 生成(默认 `keys.join('|')`) */
|
|
38
|
+
getGroupId?: (keys: GroupKey[]) => string;
|
|
39
|
+
/** 分组之间的排序;不传则保持各分组首次出现的顺序 */
|
|
40
|
+
sortGroups?: (a: GroupResult<T>, b: GroupResult<T>) => number;
|
|
41
|
+
/** 分组内数据项的排序;不传则保持原始相对顺序 */
|
|
42
|
+
sortItems?: (a: T, b: T) => number;
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
45
|
* 按点路径安全取值
|
|
@@ -51,7 +50,7 @@ interface GroupByOptions<T> {
|
|
|
51
50
|
* getByPath({ a: { b: 1 } }, 'a.b') // 1
|
|
52
51
|
* getByPath({ id: 9 }, 'id') // 9
|
|
53
52
|
*/
|
|
54
|
-
declare const getByPath: (obj: unknown, path: string) => unknown;
|
|
53
|
+
export declare const getByPath: (obj: unknown, path: string) => unknown;
|
|
55
54
|
/**
|
|
56
55
|
* 将数组按指定条件分组
|
|
57
56
|
* @template T - 数据项类型
|
|
@@ -71,6 +70,4 @@ declare const getByPath: (obj: unknown, path: string) => unknown;
|
|
|
71
70
|
* // 自定义键
|
|
72
71
|
* groupBy(list, (item) => `${item.productId}_${item.time}`);
|
|
73
72
|
*/
|
|
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 };
|
|
73
|
+
export declare const groupBy: <T>(dataSource: T[], spec: GroupBySpec<T>, options?: GroupByOptions<T>) => GroupResult<T>[];
|
package/lib/arrayUtils.js
CHANGED
|
@@ -1,105 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
seen.add(keyValue);
|
|
9
|
-
result.push(item);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
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 });
|
|
13
8
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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);
|
|
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;
|
|
30
16
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/arrayUtils.ts
|
|
20
|
+
var arrayUtils_exports = {};
|
|
21
|
+
__export(arrayUtils_exports, {
|
|
22
|
+
getByPath: () => getByPath,
|
|
23
|
+
groupBy: () => groupBy,
|
|
24
|
+
uniqueByKey: () => uniqueByKey
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(arrayUtils_exports);
|
|
27
|
+
var uniqueByKey = (arr, key) => {
|
|
28
|
+
const seen = /* @__PURE__ */ new Set();
|
|
29
|
+
const result = [];
|
|
30
|
+
for (const item of arr) {
|
|
31
|
+
const keyValue = item[key];
|
|
32
|
+
if (!seen.has(keyValue)) {
|
|
33
|
+
seen.add(keyValue);
|
|
34
|
+
result.push(item);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
39
38
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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;
|
|
39
|
+
var getByPath = (obj, path) => {
|
|
40
|
+
if (obj === null || obj === void 0) {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
if (path.indexOf(".") === -1) {
|
|
44
|
+
return obj[path];
|
|
45
|
+
}
|
|
46
|
+
return path.split(".").reduce((acc, key) => {
|
|
47
|
+
if (acc === null || acc === void 0) {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
return acc[key];
|
|
51
|
+
}, obj);
|
|
101
52
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
53
|
+
var normalizeGroupKey = (value) => {
|
|
54
|
+
if (value === null || value === void 0) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return String(value);
|
|
61
|
+
};
|
|
62
|
+
var groupBy = (dataSource, spec, options = {}) => {
|
|
63
|
+
const { getGroupId, sortGroups, sortItems } = options;
|
|
64
|
+
const fieldNames = Array.isArray(spec) ? spec : typeof spec === "string" ? [spec] : [];
|
|
65
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
66
|
+
const order = [];
|
|
67
|
+
(dataSource || []).forEach((item, index) => {
|
|
68
|
+
let keys;
|
|
69
|
+
if (typeof spec === "function") {
|
|
70
|
+
const result = spec(item, index);
|
|
71
|
+
keys = (Array.isArray(result) ? result : [result]).map(normalizeGroupKey);
|
|
72
|
+
} else if (Array.isArray(spec)) {
|
|
73
|
+
keys = spec.map((field) => normalizeGroupKey(getByPath(item, field)));
|
|
74
|
+
} else {
|
|
75
|
+
keys = [normalizeGroupKey(getByPath(item, spec))];
|
|
76
|
+
}
|
|
77
|
+
const groupId = getGroupId ? getGroupId(keys) : keys.join("|");
|
|
78
|
+
let group = groupMap.get(groupId);
|
|
79
|
+
if (!group) {
|
|
80
|
+
const keyMap = {};
|
|
81
|
+
fieldNames.forEach((field, i) => {
|
|
82
|
+
keyMap[field] = keys[i];
|
|
83
|
+
});
|
|
84
|
+
group = {
|
|
85
|
+
groupId,
|
|
86
|
+
keys,
|
|
87
|
+
keyMap,
|
|
88
|
+
items: [],
|
|
89
|
+
index: order.length
|
|
90
|
+
};
|
|
91
|
+
groupMap.set(groupId, group);
|
|
92
|
+
order.push(groupId);
|
|
93
|
+
}
|
|
94
|
+
group.items.push(item);
|
|
95
|
+
});
|
|
96
|
+
let groups = order.map((id) => groupMap.get(id));
|
|
97
|
+
if (sortItems) {
|
|
98
|
+
groups.forEach((group) => {
|
|
99
|
+
group.items.sort(sortItems);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (sortGroups) {
|
|
103
|
+
groups = groups.slice().sort(sortGroups);
|
|
104
|
+
groups.forEach((group, i) => {
|
|
105
|
+
group.index = i;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return groups;
|
|
109
|
+
};
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
getByPath,
|
|
113
|
+
groupBy,
|
|
114
|
+
uniqueByKey
|
|
115
|
+
});
|