@yelon/util 15.2.4 → 16.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -21
- package/README.md +22 -22
- package/analysis/global-event.subject.d.ts +7 -7
- package/analysis/index.d.ts +1 -1
- package/array/array-type.service.d.ts +68 -68
- package/array/array.service.d.ts +78 -78
- package/array/index.d.ts +2 -2
- package/browser/cookie.service.d.ts +67 -67
- package/browser/copy.d.ts +6 -6
- package/browser/index.d.ts +5 -5
- package/browser/is-empty.d.ts +6 -6
- package/browser/scroll.service.d.ts +37 -37
- package/browser/style.d.ts +21 -21
- package/config/abc/date-picker.type.d.ts +52 -52
- package/config/abc/error-collect.type.d.ts +10 -10
- package/config/abc/exception.type.d.ts +9 -9
- package/config/abc/image.type.d.ts +15 -15
- package/config/abc/index.d.ts +17 -17
- package/config/abc/loading.type.d.ts +31 -31
- package/config/abc/lodop.type.d.ts +33 -33
- package/config/abc/media.type.d.ts +11 -11
- package/config/abc/onboarding.type.d.ts +4 -4
- package/config/abc/page-header.type.d.ts +39 -39
- package/config/abc/pdf.type.d.ts +35 -35
- package/config/abc/qr.type.d.ts +25 -25
- package/config/abc/se.type.d.ts +32 -32
- package/config/abc/sg.type.d.ts +10 -10
- package/config/abc/st.type.d.ts +465 -465
- package/config/abc/sv.type.d.ts +14 -14
- package/config/abc/xlsx.type.d.ts +12 -12
- package/config/abc/zip.type.d.ts +10 -10
- package/config/acl/acl.type.d.ts +32 -32
- package/config/auth/auth.type.d.ts +55 -55
- package/config/bis/bis.type.d.ts +7 -7
- package/config/cache/cache.type.d.ts +40 -40
- package/config/chart/chart.type.d.ts +33 -33
- package/config/config.service.d.ts +13 -13
- package/config/config.types.d.ts +48 -48
- package/config/index.d.ts +14 -14
- package/config/mock/mock.type.d.ts +18 -18
- package/config/sf/sf.type.d.ts +133 -133
- package/config/socket/socket.type.d.ts +4 -4
- package/config/theme/http.type.d.ts +14 -14
- package/config/theme/i18n.type.d.ts +14 -14
- package/config/theme/index.d.ts +3 -3
- package/config/theme/responsive.type.d.ts +12 -12
- package/config/util/array.type.d.ts +22 -22
- package/config/util/currency.type.d.ts +39 -39
- package/date-time/index.d.ts +2 -2
- package/date-time/picker.d.ts +68 -68
- package/date-time/time.d.ts +29 -29
- package/decorator/convert.d.ts +24 -24
- package/decorator/index.d.ts +2 -2
- package/decorator/zone-outside.d.ts +35 -35
- package/{esm2020 → esm2022}/analysis/analysis.mjs +4 -4
- package/esm2022/analysis/global-event.subject.mjs +18 -0
- package/{esm2020 → esm2022}/analysis/index.mjs +2 -2
- package/{esm2020 → esm2022}/array/array-type.service.mjs +1 -1
- package/{esm2020 → esm2022}/array/array.mjs +4 -4
- package/esm2022/array/array.service.mjs +278 -0
- package/{esm2020 → esm2022}/array/index.mjs +2 -2
- package/{esm2020 → esm2022}/browser/browser.mjs +4 -4
- package/esm2022/browser/cookie.service.mjs +104 -0
- package/{esm2020 → esm2022}/browser/copy.mjs +27 -27
- package/{esm2020 → esm2022}/browser/index.mjs +5 -5
- package/{esm2020 → esm2022}/browser/is-empty.mjs +18 -18
- package/esm2022/browser/scroll.service.mjs +89 -0
- package/{esm2020 → esm2022}/browser/style.mjs +37 -37
- package/{esm2020 → esm2022}/config/abc/date-picker.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/error-collect.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/exception.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/image.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/index.mjs +17 -17
- package/{esm2020 → esm2022}/config/abc/loading.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/lodop.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/media.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/onboarding.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/page-header.type.mjs +1 -1
- package/esm2022/config/abc/pdf.type.mjs +2 -0
- package/{esm2020 → esm2022}/config/abc/qr.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/se.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/sg.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/st.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/sv.type.mjs +2 -2
- package/{esm2020 → esm2022}/config/abc/xlsx.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/abc/zip.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/acl/acl.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/auth/auth.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/bis/bis.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/cache/cache.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/chart/chart.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/config.mjs +4 -4
- package/esm2022/config/config.service.mjs +38 -0
- package/{esm2020 → esm2022}/config/config.types.mjs +8 -8
- package/{esm2020 → esm2022}/config/index.mjs +14 -14
- package/{esm2020 → esm2022}/config/mock/mock.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/sf/sf.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/socket/socket.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/theme/http.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/theme/i18n.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/theme/index.mjs +3 -3
- package/{esm2020 → esm2022}/config/theme/responsive.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/util/array.type.mjs +1 -1
- package/{esm2020 → esm2022}/config/util/currency.type.mjs +1 -1
- package/{esm2020 → esm2022}/date-time/date-time.mjs +4 -4
- package/{esm2020 → esm2022}/date-time/index.mjs +2 -2
- package/{esm2020 → esm2022}/date-time/picker.mjs +115 -115
- package/{esm2020 → esm2022}/date-time/time.mjs +88 -88
- package/{esm2020 → esm2022}/decorator/convert.mjs +57 -57
- package/{esm2020 → esm2022}/decorator/decorator.mjs +4 -4
- package/{esm2020 → esm2022}/decorator/index.mjs +2 -2
- package/{esm2020 → esm2022}/decorator/zone-outside.mjs +56 -56
- package/{esm2020 → esm2022}/form/form.mjs +4 -4
- package/{esm2020 → esm2022}/form/index.mjs +2 -2
- package/{esm2020 → esm2022}/form/match-control.mjs +29 -29
- package/{esm2020 → esm2022}/form/validators.mjs +80 -80
- package/esm2022/format/currency.service.mjs +239 -0
- package/{esm2020 → esm2022}/format/currency.types.mjs +7 -7
- package/{esm2020 → esm2022}/format/format.mjs +4 -4
- package/{esm2020 → esm2022}/format/index.mjs +4 -4
- package/{esm2020 → esm2022}/format/string.mjs +84 -84
- package/{esm2020 → esm2022}/format/validate.mjs +93 -93
- package/{esm2020 → esm2022}/index.mjs +12 -12
- package/{esm2020 → esm2022}/math/in-range.mjs +24 -24
- package/{esm2020 → esm2022}/math/index.mjs +2 -2
- package/{esm2020 → esm2022}/math/math.mjs +4 -4
- package/{esm2020 → esm2022}/math/round.mjs +52 -52
- package/{esm2020 → esm2022}/other/assert.mjs +66 -66
- package/{esm2020 → esm2022}/other/deep.mjs +77 -77
- package/{esm2020 → esm2022}/other/favicon.mjs +28 -28
- package/{esm2020 → esm2022}/other/index.mjs +7 -7
- package/esm2022/other/lazy.service.mjs +133 -0
- package/{esm2020 → esm2022}/other/logger.mjs +32 -32
- package/{esm2020 → esm2022}/other/other.mjs +4 -4
- package/esm2022/other/path-to-regexp.service.mjs +240 -0
- package/{esm2020 → esm2022}/other/resize.mjs +3 -3
- package/esm2022/pipes/currency/cny.pipe.mjs +24 -0
- package/{esm2020 → esm2022}/pipes/currency/index.mjs +4 -4
- package/esm2022/pipes/currency/mega.pipe.mjs +30 -0
- package/esm2022/pipes/currency/module.mjs +20 -0
- package/{esm2020 → esm2022}/pipes/currency/pipe-currency.mjs +4 -4
- package/esm2022/pipes/currency/price.pipe.mjs +28 -0
- package/esm2022/pipes/filter/filter.pipe.mjs +20 -0
- package/{esm2020 → esm2022}/pipes/filter/index.mjs +2 -2
- package/esm2022/pipes/filter/module.mjs +18 -0
- package/{esm2020 → esm2022}/pipes/filter/pipe-filter.mjs +4 -4
- package/{esm2020 → esm2022}/pipes/format/index.mjs +2 -2
- package/esm2022/pipes/format/mask.pipe.mjs +35 -0
- package/esm2022/pipes/format/module.mjs +18 -0
- package/{esm2020 → esm2022}/pipes/format/pipe-format.mjs +4 -4
- package/{esm2020 → esm2022}/pipes/index.mjs +3 -3
- package/{esm2020 → esm2022}/pipes/pipes.mjs +4 -4
- package/{esm2020 → esm2022}/token/index.mjs +2 -2
- package/{esm2020 → esm2022}/token/page-visibility.mjs +14 -14
- package/{esm2020 → esm2022}/token/token.mjs +4 -4
- package/{esm2020 → esm2022}/token/window.mjs +16 -16
- package/{esm2020 → esm2022}/yelon-util.mjs +4 -4
- package/{fesm2020 → fesm2022}/analysis.mjs +24 -24
- package/fesm2022/analysis.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/array.mjs +284 -284
- package/{fesm2015 → fesm2022}/array.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/browser.mjs +279 -279
- package/{fesm2020 → fesm2022}/browser.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/config.mjs +54 -54
- package/{fesm2020 → fesm2022}/config.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/date-time.mjs +211 -211
- package/{fesm2020 → fesm2022}/decorator.mjs +121 -121
- package/{fesm2020 → fesm2022}/form.mjs +118 -118
- package/{fesm2020 → fesm2022}/format.mjs +431 -431
- package/{fesm2020 → fesm2022}/format.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/math.mjs +85 -85
- package/{fesm2020 → fesm2022}/other.mjs +586 -586
- package/{fesm2020 → fesm2022}/other.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/pipe-currency.mjs +94 -94
- package/{fesm2020 → fesm2022}/pipe-currency.mjs.map +1 -1
- package/fesm2022/pipe-filter.mjs +40 -0
- package/{fesm2015 → fesm2022}/pipe-filter.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/pipe-format.mjs +55 -55
- package/{fesm2015 → fesm2022}/pipe-format.mjs.map +1 -1
- package/{fesm2015 → fesm2022}/pipes.mjs +8 -8
- package/{fesm2020 → fesm2022}/token.mjs +37 -37
- package/{fesm2015 → fesm2022}/yelon-util.mjs +17 -17
- package/form/index.d.ts +2 -2
- package/form/match-control.d.ts +15 -15
- package/form/validators.d.ts +62 -62
- package/format/currency.service.d.ts +37 -37
- package/format/currency.types.d.ts +77 -77
- package/format/index.d.ts +4 -4
- package/format/string.d.ts +44 -44
- package/format/validate.d.ts +72 -72
- package/index.d.ts +12 -12
- package/math/in-range.d.ts +14 -14
- package/math/index.d.ts +2 -2
- package/math/round.d.ts +33 -33
- package/other/assert.d.ts +36 -36
- package/other/deep.d.ts +35 -35
- package/other/favicon.d.ts +2 -2
- package/other/index.d.ts +7 -7
- package/other/lazy.service.d.ts +48 -48
- package/other/logger.d.ts +5 -5
- package/other/path-to-regexp.service.d.ts +26 -26
- package/other/resize.d.ts +1 -1
- package/package.json +129 -165
- package/pipes/currency/cny.pipe.d.ts +15 -15
- package/pipes/currency/index.d.ts +4 -4
- package/pipes/currency/mega.pipe.d.ts +16 -16
- package/pipes/currency/module.d.ts +9 -9
- package/pipes/currency/price.pipe.d.ts +19 -19
- package/pipes/filter/filter.pipe.d.ts +13 -13
- package/pipes/filter/index.d.ts +2 -2
- package/pipes/filter/module.d.ts +7 -7
- package/pipes/format/index.d.ts +2 -2
- package/pipes/format/mask.pipe.d.ts +27 -27
- package/pipes/format/module.d.ts +7 -7
- package/pipes/index.d.ts +3 -3
- package/token/index.d.ts +2 -2
- package/token/page-visibility.d.ts +8 -8
- package/token/window.d.ts +7 -7
- package/esm2020/analysis/global-event.subject.mjs +0 -17
- package/esm2020/array/array.service.mjs +0 -277
- package/esm2020/browser/cookie.service.mjs +0 -103
- package/esm2020/browser/scroll.service.mjs +0 -88
- package/esm2020/config/abc/pdf.type.mjs +0 -2
- package/esm2020/config/config.service.mjs +0 -37
- package/esm2020/format/currency.service.mjs +0 -238
- package/esm2020/other/lazy.service.mjs +0 -132
- package/esm2020/other/path-to-regexp.service.mjs +0 -239
- package/esm2020/pipes/currency/cny.pipe.mjs +0 -23
- package/esm2020/pipes/currency/mega.pipe.mjs +0 -29
- package/esm2020/pipes/currency/module.mjs +0 -19
- package/esm2020/pipes/currency/price.pipe.mjs +0 -27
- package/esm2020/pipes/filter/filter.pipe.mjs +0 -19
- package/esm2020/pipes/filter/module.mjs +0 -17
- package/esm2020/pipes/format/mask.pipe.mjs +0 -34
- package/esm2020/pipes/format/module.mjs +0 -17
- package/fesm2015/analysis.mjs +0 -24
- package/fesm2015/analysis.mjs.map +0 -1
- package/fesm2015/array.mjs +0 -254
- package/fesm2015/browser.mjs +0 -283
- package/fesm2015/browser.mjs.map +0 -1
- package/fesm2015/config.mjs +0 -56
- package/fesm2015/config.mjs.map +0 -1
- package/fesm2015/date-time.mjs +0 -207
- package/fesm2015/date-time.mjs.map +0 -1
- package/fesm2015/decorator.mjs +0 -121
- package/fesm2015/decorator.mjs.map +0 -1
- package/fesm2015/form.mjs +0 -118
- package/fesm2015/format.mjs +0 -413
- package/fesm2015/format.mjs.map +0 -1
- package/fesm2015/math.mjs +0 -85
- package/fesm2015/other.mjs +0 -589
- package/fesm2015/other.mjs.map +0 -1
- package/fesm2015/pipe-currency.mjs +0 -96
- package/fesm2015/pipe-currency.mjs.map +0 -1
- package/fesm2015/pipe-filter.mjs +0 -40
- package/fesm2015/pipe-format.mjs +0 -55
- package/fesm2015/token.mjs +0 -37
- package/fesm2020/analysis.mjs.map +0 -1
- package/fesm2020/array.mjs.map +0 -1
- package/fesm2020/form.mjs.map +0 -1
- package/fesm2020/math.mjs.map +0 -1
- package/fesm2020/pipe-filter.mjs +0 -40
- package/fesm2020/pipe-filter.mjs.map +0 -1
- package/fesm2020/pipe-format.mjs.map +0 -1
- package/fesm2020/pipes.mjs +0 -8
- package/fesm2020/pipes.mjs.map +0 -1
- package/fesm2020/token.mjs.map +0 -1
- package/fesm2020/yelon-util.mjs +0 -17
- package/fesm2020/yelon-util.mjs.map +0 -1
- /package/{fesm2020 → fesm2022}/date-time.mjs.map +0 -0
- /package/{fesm2020 → fesm2022}/decorator.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/form.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/math.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/pipes.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/token.mjs.map +0 -0
- /package/{fesm2015 → fesm2022}/yelon-util.mjs.map +0 -0
package/fesm2015/array.mjs
DELETED
@@ -1,254 +0,0 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { Injectable } from '@angular/core';
|
3
|
-
import { NzTreeNode } from 'ng-zorro-antd/core/tree';
|
4
|
-
import * as i1 from '@yelon/util/config';
|
5
|
-
|
6
|
-
class ArrayService {
|
7
|
-
constructor(cog) {
|
8
|
-
this.c = cog.merge('utilArray', {
|
9
|
-
deepMapName: 'deep',
|
10
|
-
parentMapName: 'parent',
|
11
|
-
idMapName: 'id',
|
12
|
-
parentIdMapName: 'parent_id',
|
13
|
-
childrenMapName: 'children',
|
14
|
-
titleMapName: 'title',
|
15
|
-
checkedMapname: 'checked',
|
16
|
-
selectedMapname: 'selected',
|
17
|
-
expandedMapname: 'expanded',
|
18
|
-
disabledMapname: 'disabled'
|
19
|
-
});
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Convert tree structure to array structure
|
23
|
-
*
|
24
|
-
* 将树结构转换成数组结构
|
25
|
-
*/
|
26
|
-
treeToArr(tree, options) {
|
27
|
-
const opt = Object.assign({ deepMapName: this.c.deepMapName, parentMapName: this.c.parentMapName, childrenMapName: this.c.childrenMapName, clearChildren: true, cb: null }, options);
|
28
|
-
const result = [];
|
29
|
-
const inFn = (list, parent, deep = 0) => {
|
30
|
-
for (const i of list) {
|
31
|
-
i[opt.deepMapName] = deep;
|
32
|
-
i[opt.parentMapName] = parent;
|
33
|
-
if (opt.cb) {
|
34
|
-
opt.cb(i, parent, deep);
|
35
|
-
}
|
36
|
-
result.push(i);
|
37
|
-
const children = i[opt.childrenMapName];
|
38
|
-
if (children != null && Array.isArray(children) && children.length > 0) {
|
39
|
-
inFn(children, i, deep + 1);
|
40
|
-
}
|
41
|
-
if (opt.clearChildren) {
|
42
|
-
delete i[opt.childrenMapName];
|
43
|
-
}
|
44
|
-
}
|
45
|
-
};
|
46
|
-
inFn(tree, null);
|
47
|
-
return result;
|
48
|
-
}
|
49
|
-
/**
|
50
|
-
* Convert array structure to tree structure
|
51
|
-
*
|
52
|
-
* 数组转换成树数据
|
53
|
-
*/
|
54
|
-
arrToTree(arr, options) {
|
55
|
-
if (!Array.isArray(arr) || arr.length === 0) {
|
56
|
-
return [];
|
57
|
-
}
|
58
|
-
const opt = Object.assign({ idMapName: this.c.idMapName, parentIdMapName: this.c.parentIdMapName, childrenMapName: this.c.childrenMapName, cb: null }, options);
|
59
|
-
const tree = [];
|
60
|
-
const childrenOf = {};
|
61
|
-
let rootPid = opt.rootParentIdValue;
|
62
|
-
const arrType = arr;
|
63
|
-
if (!rootPid) {
|
64
|
-
const pids = arrType.map(i => i[opt.parentIdMapName]);
|
65
|
-
const emptyPid = pids.findIndex(w => w == null);
|
66
|
-
rootPid = emptyPid !== -1 ? pids[emptyPid] : pids.sort()[0];
|
67
|
-
}
|
68
|
-
for (const item of arrType) {
|
69
|
-
const id = item[opt.idMapName];
|
70
|
-
const pid = item[opt.parentIdMapName];
|
71
|
-
childrenOf[id] = childrenOf[id] || [];
|
72
|
-
item[opt.childrenMapName] = childrenOf[id];
|
73
|
-
if (opt.cb) {
|
74
|
-
opt.cb(item);
|
75
|
-
}
|
76
|
-
if (pid !== rootPid) {
|
77
|
-
childrenOf[pid] = childrenOf[pid] || [];
|
78
|
-
childrenOf[pid].push(item);
|
79
|
-
}
|
80
|
-
else {
|
81
|
-
tree.push(item);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
return tree;
|
85
|
-
}
|
86
|
-
/**
|
87
|
-
* 数组转换成 `nz-tree` 数据源,通过 `options` 转化项名,也可以使用 `options.cb` 更高级决定数据项
|
88
|
-
*/
|
89
|
-
arrToTreeNode(arr, options) {
|
90
|
-
const opt = Object.assign({ idMapName: this.c.idMapName, parentIdMapName: this.c.parentIdMapName, titleMapName: this.c.titleMapName, isLeafMapName: 'isLeaf', checkedMapname: this.c.checkedMapname, selectedMapname: this.c.selectedMapname, expandedMapname: this.c.expandedMapname, disabledMapname: this.c.disabledMapname, cb: null }, options);
|
91
|
-
const tree = this.arrToTree(arr, {
|
92
|
-
idMapName: opt.idMapName,
|
93
|
-
parentIdMapName: opt.parentIdMapName,
|
94
|
-
childrenMapName: 'children'
|
95
|
-
});
|
96
|
-
this.visitTree(tree, (item, parent, deep) => {
|
97
|
-
item.key = item[opt.idMapName];
|
98
|
-
item.title = item[opt.titleMapName];
|
99
|
-
item.checked = item[opt.checkedMapname];
|
100
|
-
item.selected = item[opt.selectedMapname];
|
101
|
-
item.expanded = item[opt.expandedMapname];
|
102
|
-
item.disabled = item[opt.disabledMapname];
|
103
|
-
if (item[opt.isLeafMapName] == null) {
|
104
|
-
item.isLeaf = item.children.length === 0;
|
105
|
-
}
|
106
|
-
else {
|
107
|
-
item.isLeaf = item[opt.isLeafMapName];
|
108
|
-
}
|
109
|
-
if (opt.cb) {
|
110
|
-
opt.cb(item, parent, deep);
|
111
|
-
}
|
112
|
-
});
|
113
|
-
return tree.map(node => new NzTreeNode(node));
|
114
|
-
}
|
115
|
-
/**
|
116
|
-
* 递归访问整个树
|
117
|
-
*/
|
118
|
-
visitTree(tree, cb, options) {
|
119
|
-
options = Object.assign({ childrenMapName: this.c.childrenMapName }, options);
|
120
|
-
const inFn = (data, parent, deep) => {
|
121
|
-
for (const item of data) {
|
122
|
-
cb(item, parent, deep);
|
123
|
-
const childrenVal = item[options.childrenMapName];
|
124
|
-
if (Array.isArray(childrenVal) && childrenVal.length > 0) {
|
125
|
-
inFn(childrenVal, item, deep + 1);
|
126
|
-
}
|
127
|
-
}
|
128
|
-
};
|
129
|
-
inFn(tree, null, 1);
|
130
|
-
}
|
131
|
-
/**
|
132
|
-
* Return the value of the first tree value in the tree where predicate is true, and `undefined` otherwise
|
133
|
-
*
|
134
|
-
* 根据条件返回树的第一个值,否则返回 `undefined`
|
135
|
-
*/
|
136
|
-
findTree(tree, predicate, options) {
|
137
|
-
let res;
|
138
|
-
this.visitTree(tree, item => {
|
139
|
-
if (res === undefined && predicate(item)) {
|
140
|
-
res = item;
|
141
|
-
}
|
142
|
-
}, options);
|
143
|
-
return res;
|
144
|
-
}
|
145
|
-
/**
|
146
|
-
* 获取所有已经选中的 `key` 值
|
147
|
-
*/
|
148
|
-
getKeysByTreeNode(tree, options) {
|
149
|
-
const opt = Object.assign({ includeHalfChecked: true }, options);
|
150
|
-
const keys = [];
|
151
|
-
this.visitTree(tree, (item, parent, deep) => {
|
152
|
-
if (item.isChecked || (opt.includeHalfChecked && item.isHalfChecked)) {
|
153
|
-
keys.push(opt.cb ? opt.cb(item, parent, deep) : opt.keyMapName ? item.origin[opt.keyMapName] : item.key);
|
154
|
-
}
|
155
|
-
});
|
156
|
-
return keys;
|
157
|
-
}
|
158
|
-
baseFlat(array, depth, result = []) {
|
159
|
-
let index = -1;
|
160
|
-
while (++index < array.length) {
|
161
|
-
const value = array[index];
|
162
|
-
if (depth > 0 && Array.isArray(value)) {
|
163
|
-
if (depth > 1) {
|
164
|
-
this.baseFlat(value, depth - 1, result);
|
165
|
-
}
|
166
|
-
else {
|
167
|
-
let pushIndex = -1;
|
168
|
-
const offset = result.length;
|
169
|
-
while (++pushIndex < value.length) {
|
170
|
-
result[offset + pushIndex] = value[pushIndex];
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
result[result.length] = value;
|
176
|
-
}
|
177
|
-
}
|
178
|
-
return result;
|
179
|
-
}
|
180
|
-
/**
|
181
|
-
* Recursively flattens array
|
182
|
-
*
|
183
|
-
* 递归扁平数组
|
184
|
-
* ```ts
|
185
|
-
* srv.flat([1, [2, 3, [4, 5, [6]]]]) => [1,2,3,4,5,6]
|
186
|
-
* srv.flat([1, [2, 3, [4, 5, [6]]]], 1) => [1,2,3,[4, 5, [6]]]
|
187
|
-
* ```
|
188
|
-
*/
|
189
|
-
flat(array, depth = 1 / 0) {
|
190
|
-
return Array.isArray(array) ? this.baseFlat(array, depth) : array;
|
191
|
-
}
|
192
|
-
/**
|
193
|
-
* Group the array
|
194
|
-
*
|
195
|
-
* 对数组进行分组
|
196
|
-
* ```ts
|
197
|
-
* srv.groupBy([6.1, 4.2, 6.3], Math.floor) => {"4":[4.2],"6":[6.1,6.3]}
|
198
|
-
* srv.groupBy(['one', 'two', 'three'], v => v.length) => {"3":["one","two"],"5":["three"]}
|
199
|
-
* ```
|
200
|
-
*/
|
201
|
-
groupBy(array, iteratee) {
|
202
|
-
if (!Array.isArray(array)) {
|
203
|
-
return {};
|
204
|
-
}
|
205
|
-
return array.reduce((result, value) => {
|
206
|
-
const key = iteratee(value);
|
207
|
-
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
208
|
-
result[key].push(value);
|
209
|
-
}
|
210
|
-
else {
|
211
|
-
result[key] = [value];
|
212
|
-
}
|
213
|
-
return result;
|
214
|
-
}, {});
|
215
|
-
}
|
216
|
-
/**
|
217
|
-
* Creates a duplicate-free version of an array
|
218
|
-
*
|
219
|
-
* 创建去重后的数组
|
220
|
-
* ```ts
|
221
|
-
* uniq([1, 2, 2, 3, 1]) => [1,2,3]
|
222
|
-
* uniq([{ a: 1 }, { a: 1 }, { a: 2 }], 'a') => [{"a":1},{"a":2}]
|
223
|
-
* uniq([{ a: 1 }, { a: 1 }, { a: 2 }], i => (i.a === 1 ? 'a' : 'b')) => [{"a":1},{"a":2}]
|
224
|
-
* ```
|
225
|
-
*/
|
226
|
-
uniq(array, predicate) {
|
227
|
-
return Array.from(array
|
228
|
-
.reduce((map, value) => {
|
229
|
-
const key = predicate
|
230
|
-
? typeof predicate === 'string'
|
231
|
-
? value[predicate]
|
232
|
-
: predicate(value)
|
233
|
-
: value;
|
234
|
-
if (!map.has(key)) {
|
235
|
-
map.set(key, value);
|
236
|
-
}
|
237
|
-
return map;
|
238
|
-
}, new Map())
|
239
|
-
.values());
|
240
|
-
}
|
241
|
-
}
|
242
|
-
ArrayService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ArrayService, deps: [{ token: i1.YunzaiConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
243
|
-
ArrayService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ArrayService, providedIn: 'root' });
|
244
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ArrayService, decorators: [{
|
245
|
-
type: Injectable,
|
246
|
-
args: [{ providedIn: 'root' }]
|
247
|
-
}], ctorParameters: function () { return [{ type: i1.YunzaiConfigService }]; } });
|
248
|
-
|
249
|
-
/**
|
250
|
-
* Generated bundle index. Do not edit.
|
251
|
-
*/
|
252
|
-
|
253
|
-
export { ArrayService };
|
254
|
-
//# sourceMappingURL=array.mjs.map
|
package/fesm2015/browser.mjs
DELETED
@@ -1,283 +0,0 @@
|
|
1
|
-
import { DOCUMENT } from '@angular/common';
|
2
|
-
import * as i0 from '@angular/core';
|
3
|
-
import { Injectable, Inject } from '@angular/core';
|
4
|
-
import * as i1 from '@angular/cdk/platform';
|
5
|
-
|
6
|
-
/**
|
7
|
-
* A set of simple Cookie manipulation classes.
|
8
|
-
*
|
9
|
-
* 一组简单的 Cookie 操作类。
|
10
|
-
*/
|
11
|
-
class CookieService {
|
12
|
-
get doc() {
|
13
|
-
return this._doc || document;
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* Original cookie value
|
17
|
-
*
|
18
|
-
* 原始Cookie值
|
19
|
-
*/
|
20
|
-
get cookie() {
|
21
|
-
return this.platform.isBrowser ? this.doc.cookie : '';
|
22
|
-
}
|
23
|
-
constructor(_doc, platform) {
|
24
|
-
this._doc = _doc;
|
25
|
-
this.platform = platform;
|
26
|
-
}
|
27
|
-
/**
|
28
|
-
* Get all cookie key-value pairs
|
29
|
-
*
|
30
|
-
* 获取所有Cookie键值对
|
31
|
-
*/
|
32
|
-
getAll() {
|
33
|
-
const ret = {};
|
34
|
-
const arr = this.cookie.split('; ');
|
35
|
-
for (let i = 0; i < arr.length; i++) {
|
36
|
-
const cookie = arr[i];
|
37
|
-
const index = cookie.indexOf('=');
|
38
|
-
if (index > 0) {
|
39
|
-
const name = decodeURIComponent(cookie.substring(0, index));
|
40
|
-
if (ret[name] == null) {
|
41
|
-
ret[name] = decodeURIComponent(cookie.substring(index + 1));
|
42
|
-
}
|
43
|
-
}
|
44
|
-
}
|
45
|
-
return ret;
|
46
|
-
}
|
47
|
-
/**
|
48
|
-
* Get the value of given cookie `key`
|
49
|
-
*
|
50
|
-
* 获取指定 `key` 的值
|
51
|
-
*/
|
52
|
-
get(key) {
|
53
|
-
return this.getAll()[key];
|
54
|
-
}
|
55
|
-
/**
|
56
|
-
* Sets a value for given cookie key
|
57
|
-
*
|
58
|
-
* 设置指定 Cookie 键的值
|
59
|
-
*/
|
60
|
-
put(key, value, options) {
|
61
|
-
if (!this.platform.isBrowser) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
const opt = Object.assign({ path: '/' }, options);
|
65
|
-
if (typeof opt.expires === 'number') {
|
66
|
-
opt.expires = new Date(+new Date() + opt.expires * 1e3);
|
67
|
-
}
|
68
|
-
if (typeof opt.expires !== 'string') {
|
69
|
-
opt.expires = opt.expires ? opt.expires.toUTCString() : '';
|
70
|
-
}
|
71
|
-
const optStr = opt;
|
72
|
-
const attributes = Object.keys(optStr)
|
73
|
-
.filter(k => optStr[k] && optStr[k] !== true)
|
74
|
-
.map(k => `${k}=${optStr[k].split(';')[0]}`)
|
75
|
-
.join(';');
|
76
|
-
this.doc.cookie = `${encodeURIComponent(String(key))}=${encodeURIComponent(String(value))}${attributes ? `; ${attributes}` : ''}`;
|
77
|
-
}
|
78
|
-
/**
|
79
|
-
* Remove given cookie
|
80
|
-
*
|
81
|
-
* 移除指定 Cookie
|
82
|
-
*/
|
83
|
-
remove(key, options) {
|
84
|
-
this.put(key, '', options);
|
85
|
-
}
|
86
|
-
/**
|
87
|
-
* Remove all cookies
|
88
|
-
*
|
89
|
-
* 移除所有 Cookies
|
90
|
-
*/
|
91
|
-
removeAll() {
|
92
|
-
this.doc.cookie = '';
|
93
|
-
}
|
94
|
-
}
|
95
|
-
CookieService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookieService, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable });
|
96
|
-
CookieService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookieService, providedIn: 'root' });
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookieService, decorators: [{
|
98
|
-
type: Injectable,
|
99
|
-
args: [{ providedIn: 'root' }]
|
100
|
-
}], ctorParameters: function () {
|
101
|
-
return [{ type: undefined, decorators: [{
|
102
|
-
type: Inject,
|
103
|
-
args: [DOCUMENT]
|
104
|
-
}] }, { type: i1.Platform }];
|
105
|
-
} });
|
106
|
-
|
107
|
-
/**
|
108
|
-
* Copy text to clipboard
|
109
|
-
*
|
110
|
-
* 复制字符串文档至剪贴板
|
111
|
-
*/
|
112
|
-
function copy(value) {
|
113
|
-
return new Promise((resolve) => {
|
114
|
-
let copyTextArea = null;
|
115
|
-
try {
|
116
|
-
copyTextArea = document.createElement('textarea');
|
117
|
-
copyTextArea.style.height = '0px';
|
118
|
-
copyTextArea.style.opacity = '0';
|
119
|
-
copyTextArea.style.width = '0px';
|
120
|
-
document.body.appendChild(copyTextArea);
|
121
|
-
copyTextArea.value = value;
|
122
|
-
copyTextArea.select();
|
123
|
-
// eslint-disable-next-line deprecation/deprecation
|
124
|
-
document.execCommand('copy');
|
125
|
-
resolve(value);
|
126
|
-
}
|
127
|
-
finally {
|
128
|
-
if (copyTextArea && copyTextArea.parentNode) {
|
129
|
-
copyTextArea.parentNode.removeChild(copyTextArea);
|
130
|
-
}
|
131
|
-
}
|
132
|
-
});
|
133
|
-
}
|
134
|
-
|
135
|
-
/**
|
136
|
-
* Used to verify `<ng-content></ng-content>` is empty, useful for custom components.
|
137
|
-
*
|
138
|
-
* 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。
|
139
|
-
*/
|
140
|
-
function isEmpty(element) {
|
141
|
-
const nodes = element.childNodes;
|
142
|
-
for (let i = 0; i < nodes.length; i++) {
|
143
|
-
const node = nodes.item(i);
|
144
|
-
if (node.nodeType === 1 && node.outerHTML.toString().trim().length !== 0) {
|
145
|
-
return false;
|
146
|
-
}
|
147
|
-
else if (node.nodeType === 3 && node.textContent.toString().trim().length !== 0) {
|
148
|
-
return false;
|
149
|
-
}
|
150
|
-
}
|
151
|
-
return true;
|
152
|
-
}
|
153
|
-
|
154
|
-
class ScrollService {
|
155
|
-
_getDoc() {
|
156
|
-
return this._doc || document;
|
157
|
-
}
|
158
|
-
_getWin() {
|
159
|
-
const doc = this._getDoc();
|
160
|
-
return doc.defaultView || window;
|
161
|
-
}
|
162
|
-
constructor(_doc, platform) {
|
163
|
-
this._doc = _doc;
|
164
|
-
this.platform = platform;
|
165
|
-
}
|
166
|
-
/**
|
167
|
-
* 获取滚动条位置
|
168
|
-
*
|
169
|
-
* @param element 指定元素,默认 `window`
|
170
|
-
*/
|
171
|
-
getScrollPosition(element) {
|
172
|
-
if (!this.platform.isBrowser) {
|
173
|
-
return [0, 0];
|
174
|
-
}
|
175
|
-
const win = this._getWin();
|
176
|
-
if (element && element !== win) {
|
177
|
-
return [element.scrollLeft, element.scrollTop];
|
178
|
-
}
|
179
|
-
else {
|
180
|
-
return [win.scrollX, win.scrollY];
|
181
|
-
}
|
182
|
-
}
|
183
|
-
/**
|
184
|
-
* 设置滚动条位置
|
185
|
-
*
|
186
|
-
* @param element 指定元素
|
187
|
-
*/
|
188
|
-
scrollToPosition(element, position) {
|
189
|
-
if (!this.platform.isBrowser) {
|
190
|
-
return;
|
191
|
-
}
|
192
|
-
(element || this._getWin()).scrollTo(position[0], position[1]);
|
193
|
-
}
|
194
|
-
/**
|
195
|
-
* 设置滚动条至指定元素
|
196
|
-
*
|
197
|
-
* @param element 指定元素,默认 `document.body`
|
198
|
-
* @param topOffset 偏移值,默认 `0`
|
199
|
-
*/
|
200
|
-
scrollToElement(element, topOffset = 0) {
|
201
|
-
if (!this.platform.isBrowser) {
|
202
|
-
return;
|
203
|
-
}
|
204
|
-
if (!element) {
|
205
|
-
element = this._getDoc().body;
|
206
|
-
}
|
207
|
-
element.scrollIntoView();
|
208
|
-
const win = this._getWin();
|
209
|
-
if (win && win.scrollBy) {
|
210
|
-
win.scrollBy(0, element.getBoundingClientRect().top - topOffset);
|
211
|
-
if (win.scrollY < 20) {
|
212
|
-
win.scrollBy(0, -win.scrollY);
|
213
|
-
}
|
214
|
-
}
|
215
|
-
}
|
216
|
-
/**
|
217
|
-
* 滚动至顶部
|
218
|
-
*
|
219
|
-
* @param topOffset 偏移值,默认 `0`
|
220
|
-
*/
|
221
|
-
scrollToTop(topOffset = 0) {
|
222
|
-
if (!this.platform.isBrowser) {
|
223
|
-
return;
|
224
|
-
}
|
225
|
-
this.scrollToElement(this._getDoc().body, topOffset);
|
226
|
-
}
|
227
|
-
}
|
228
|
-
ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable });
|
229
|
-
ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, providedIn: 'root' });
|
230
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ScrollService, decorators: [{
|
231
|
-
type: Injectable,
|
232
|
-
args: [{ providedIn: 'root' }]
|
233
|
-
}], ctorParameters: function () {
|
234
|
-
return [{ type: undefined, decorators: [{
|
235
|
-
type: Inject,
|
236
|
-
args: [DOCUMENT]
|
237
|
-
}] }, { type: i1.Platform }];
|
238
|
-
} });
|
239
|
-
|
240
|
-
function removeClass(el, classMap, renderer) {
|
241
|
-
Object.keys(classMap).forEach(key => renderer.removeClass(el, key));
|
242
|
-
}
|
243
|
-
function addClass(el, classMap, renderer) {
|
244
|
-
for (const i in classMap) {
|
245
|
-
if (classMap[i]) {
|
246
|
-
renderer.addClass(el, i);
|
247
|
-
}
|
248
|
-
}
|
249
|
-
}
|
250
|
-
/**
|
251
|
-
* Update host component style `class`
|
252
|
-
*
|
253
|
-
* 更新宿主组件样式 `class`
|
254
|
-
*
|
255
|
-
* ```ts
|
256
|
-
* updateHostClass(
|
257
|
-
* this.el.nativeElement,
|
258
|
-
* this.renderer,
|
259
|
-
* {
|
260
|
-
* [ 'classname' ]: true,
|
261
|
-
* [ 'classname' ]: this.type === '1',
|
262
|
-
* [ this.cls ]: true,
|
263
|
-
* [ `a-${this.cls}` ]: true
|
264
|
-
* })
|
265
|
-
* ```
|
266
|
-
*/
|
267
|
-
function updateHostClass(el, renderer, classMap, preClean = false) {
|
268
|
-
if (preClean === true) {
|
269
|
-
renderer.removeAttribute(el, 'class');
|
270
|
-
}
|
271
|
-
else {
|
272
|
-
removeClass(el, classMap, renderer);
|
273
|
-
}
|
274
|
-
classMap = Object.assign({}, classMap);
|
275
|
-
addClass(el, classMap, renderer);
|
276
|
-
}
|
277
|
-
|
278
|
-
/**
|
279
|
-
* Generated bundle index. Do not edit.
|
280
|
-
*/
|
281
|
-
|
282
|
-
export { CookieService, ScrollService, copy, isEmpty, updateHostClass };
|
283
|
-
//# sourceMappingURL=browser.mjs.map
|
package/fesm2015/browser.mjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"browser.mjs","sources":["../../../../packages/util/browser/cookie.service.ts","../../../../packages/util/browser/copy.ts","../../../../packages/util/browser/is-empty.ts","../../../../packages/util/browser/scroll.service.ts","../../../../packages/util/browser/style.ts","../../../../packages/util/browser/browser.ts"],"sourcesContent":["import { Platform } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport interface CookieOptions {\n path?: string;\n domain?: string;\n /**\n * Expiration time, `number` is seconds\n *\n * 过期时间,`number` 类型表示秒数\n */\n expires?: number | Date | string;\n secure?: boolean;\n HttpOnly?: boolean;\n SameSite?: boolean | 'lax' | 'strict' | 'none';\n}\n\n/**\n * A set of simple Cookie manipulation classes.\n *\n * 一组简单的 Cookie 操作类。\n */\n@Injectable({ providedIn: 'root' })\nexport class CookieService {\n private get doc(): Document {\n return this._doc || document;\n }\n\n /**\n * Original cookie value\n *\n * 原始Cookie值\n */\n get cookie(): string {\n return this.platform.isBrowser ? this.doc.cookie : '';\n }\n\n constructor(@Inject(DOCUMENT) private _doc: NzSafeAny, private platform: Platform) {}\n\n /**\n * Get all cookie key-value pairs\n *\n * 获取所有Cookie键值对\n */\n getAll(): { [key: string]: string } {\n const ret: { [key: string]: string } = {};\n const arr = this.cookie.split('; ');\n for (let i = 0; i < arr.length; i++) {\n const cookie = arr[i];\n const index = cookie.indexOf('=');\n if (index > 0) {\n const name = decodeURIComponent(cookie.substring(0, index));\n if (ret[name] == null) {\n ret[name] = decodeURIComponent(cookie.substring(index + 1));\n }\n }\n }\n return ret;\n }\n\n /**\n * Get the value of given cookie `key`\n *\n * 获取指定 `key` 的值\n */\n get(key: string): string | undefined {\n return this.getAll()[key];\n }\n\n /**\n * Sets a value for given cookie key\n *\n * 设置指定 Cookie 键的值\n */\n put(key: string, value: string, options?: CookieOptions): void {\n if (!this.platform.isBrowser) {\n return;\n }\n const opt = { path: '/', ...options };\n if (typeof opt.expires === 'number') {\n opt.expires = new Date(+new Date() + opt.expires * 1e3);\n }\n if (typeof opt.expires !== 'string') {\n opt.expires = opt.expires ? opt.expires.toUTCString() : '';\n }\n const optStr: { [key: string]: string | boolean } = opt as NzSafeAny;\n const attributes = Object.keys(optStr)\n .filter(k => optStr[k] && optStr[k] !== true)\n .map(k => `${k}=${(optStr[k] as string).split(';')[0]}`)\n .join(';');\n this.doc.cookie = `${encodeURIComponent(String(key))}=${encodeURIComponent(String(value))}${\n attributes ? `; ${attributes}` : ''\n }`;\n }\n\n /**\n * Remove given cookie\n *\n * 移除指定 Cookie\n */\n remove(key: string, options?: CookieOptions): void {\n this.put(key, '', options);\n }\n\n /**\n * Remove all cookies\n *\n * 移除所有 Cookies\n */\n removeAll(): void {\n this.doc.cookie = '';\n }\n}\n","/**\n * Copy text to clipboard\n *\n * 复制字符串文档至剪贴板\n */\nexport function copy(value: string): Promise<string> {\n return new Promise<string>((resolve): void => {\n let copyTextArea: HTMLTextAreaElement | null = null;\n try {\n copyTextArea = document.createElement('textarea');\n copyTextArea.style.height = '0px';\n copyTextArea.style.opacity = '0';\n copyTextArea.style.width = '0px';\n document.body.appendChild(copyTextArea);\n copyTextArea.value = value;\n copyTextArea.select();\n // eslint-disable-next-line deprecation/deprecation\n document.execCommand('copy');\n resolve(value);\n } finally {\n if (copyTextArea && copyTextArea.parentNode) {\n copyTextArea.parentNode.removeChild(copyTextArea);\n }\n }\n });\n}\n","/**\n * Used to verify `<ng-content></ng-content>` is empty, useful for custom components.\n *\n * 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。\n */\nexport function isEmpty(element: HTMLElement): boolean {\n const nodes = element.childNodes;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes.item(i);\n if (node.nodeType === 1 && (node as HTMLElement).outerHTML.toString().trim().length !== 0) {\n return false;\n } else if (node.nodeType === 3 && node.textContent!.toString().trim().length !== 0) {\n return false;\n }\n }\n return true;\n}\n","import { Platform } from '@angular/cdk/platform';\nimport { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n@Injectable({ providedIn: 'root' })\nexport class ScrollService {\n private _getDoc(): Document {\n return this._doc || document;\n }\n\n private _getWin(): Window {\n const doc = this._getDoc();\n return doc.defaultView || window;\n }\n\n constructor(@Inject(DOCUMENT) private _doc: NzSafeAny, private platform: Platform) {}\n\n /**\n * 获取滚动条位置\n *\n * @param element 指定元素,默认 `window`\n */\n getScrollPosition(element?: Element | Window): [number, number] {\n if (!this.platform.isBrowser) {\n return [0, 0];\n }\n\n const win = this._getWin();\n if (element && element !== win) {\n return [(element as Element).scrollLeft, (element as Element).scrollTop];\n } else {\n return [win.scrollX, win.scrollY];\n }\n }\n\n /**\n * 设置滚动条位置\n *\n * @param element 指定元素\n */\n scrollToPosition(element: Element | Window | null | undefined, position: [number, number]): void {\n if (!this.platform.isBrowser) {\n return;\n }\n (element || this._getWin()).scrollTo(position[0], position[1]);\n }\n\n /**\n * 设置滚动条至指定元素\n *\n * @param element 指定元素,默认 `document.body`\n * @param topOffset 偏移值,默认 `0`\n */\n scrollToElement(element?: Element | null, topOffset: number = 0): void {\n if (!this.platform.isBrowser) {\n return;\n }\n if (!element) {\n element = this._getDoc().body;\n }\n\n element.scrollIntoView();\n\n const win = this._getWin();\n if (win && win.scrollBy) {\n win.scrollBy(0, element!.getBoundingClientRect().top - topOffset);\n\n if (win.scrollY < 20) {\n win.scrollBy(0, -win.scrollY);\n }\n }\n }\n\n /**\n * 滚动至顶部\n *\n * @param topOffset 偏移值,默认 `0`\n */\n scrollToTop(topOffset: number = 0): void {\n if (!this.platform.isBrowser) {\n return;\n }\n this.scrollToElement(this._getDoc().body, topOffset);\n }\n}\n","import { Renderer2 } from '@angular/core';\n\nfunction removeClass(el: HTMLElement, classMap: { [klass: string]: unknown }, renderer: Renderer2): void {\n Object.keys(classMap).forEach(key => renderer.removeClass(el, key));\n}\n\nfunction addClass(el: HTMLElement, classMap: { [klass: string]: unknown }, renderer: Renderer2): void {\n for (const i in classMap) {\n if (classMap[i]) {\n renderer.addClass(el, i);\n }\n }\n}\n\n/**\n * Update host component style `class`\n *\n * 更新宿主组件样式 `class`\n *\n * ```ts\n * updateHostClass(\n * this.el.nativeElement,\n * this.renderer,\n * {\n * [ 'classname' ]: true,\n * [ 'classname' ]: this.type === '1',\n * [ this.cls ]: true,\n * [ `a-${this.cls}` ]: true\n * })\n * ```\n */\nexport function updateHostClass(\n el: HTMLElement,\n renderer: Renderer2,\n classMap: { [klass: string]: unknown },\n preClean: boolean = false\n): void {\n if (preClean === true) {\n renderer.removeAttribute(el, 'class');\n } else {\n removeClass(el, classMap, renderer);\n }\n classMap = { ...classMap };\n addClass(el, classMap, renderer);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAoBA;;;;AAIG;MAEU,aAAa,CAAA;AACxB,IAAA,IAAY,GAAG,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC;KAC9B;AAED;;;;AAIG;AACH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;KACvD;IAED,WAAsC,CAAA,IAAe,EAAU,QAAkB,EAAA;AAA3C,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAW;AAAU,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;KAAI;AAErF;;;;AAIG;IACH,MAAM,GAAA;QACJ,MAAM,GAAG,GAA8B,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACpC,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,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,CAAC,CAAC,CAAC,EAAE;AACf,YAAA,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1B,SAAA;AACF,KAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,eAAe,CAC7B,EAAe,EACf,QAAmB,EACnB,QAAsC,EACtC,QAAA,GAAoB,KAAK,EAAA;IAEzB,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACvC,KAAA;AAAM,SAAA;AACL,QAAA,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACrC,KAAA;IACD,QAAQ,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,QAAQ,CAAE,CAAC;AAC3B,IAAA,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACnC;;AC5CA;;AAEG;;;;"}
|
package/fesm2015/config.mjs
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { InjectionToken, Injectable, Optional, Inject } from '@angular/core';
|
3
|
-
import { deepMergeKey } from '@yelon/util/other';
|
4
|
-
|
5
|
-
class YunzaiSVConfig {
|
6
|
-
}
|
7
|
-
|
8
|
-
const YUNZAI_CONFIG = new InjectionToken('yunzai-config', {
|
9
|
-
providedIn: 'root',
|
10
|
-
factory: YUNZAI_CONFIG_FACTORY
|
11
|
-
});
|
12
|
-
function YUNZAI_CONFIG_FACTORY() {
|
13
|
-
return {};
|
14
|
-
}
|
15
|
-
|
16
|
-
class YunzaiConfigService {
|
17
|
-
constructor(defaultConfig) {
|
18
|
-
this.config = Object.assign({}, defaultConfig);
|
19
|
-
}
|
20
|
-
get(componentName, key) {
|
21
|
-
const res = (this.config[componentName] || {});
|
22
|
-
return key ? { [key]: res[key] } : res;
|
23
|
-
}
|
24
|
-
merge(componentName, ...defaultValues) {
|
25
|
-
return deepMergeKey({}, true, ...defaultValues, this.get(componentName));
|
26
|
-
}
|
27
|
-
attach(componentThis, componentName, defaultValues) {
|
28
|
-
Object.assign(componentThis, this.merge(componentName, defaultValues));
|
29
|
-
}
|
30
|
-
attachKey(componentThis, componentName, key) {
|
31
|
-
Object.assign(componentThis, this.get(componentName, key));
|
32
|
-
}
|
33
|
-
set(componentName, value) {
|
34
|
-
this.config[componentName] = Object.assign(Object.assign({}, this.config[componentName]), value);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
YunzaiConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: YunzaiConfigService, deps: [{ token: YUNZAI_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
38
|
-
YunzaiConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: YunzaiConfigService, providedIn: 'root' });
|
39
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: YunzaiConfigService, decorators: [{
|
40
|
-
type: Injectable,
|
41
|
-
args: [{ providedIn: 'root' }]
|
42
|
-
}], ctorParameters: function () {
|
43
|
-
return [{ type: undefined, decorators: [{
|
44
|
-
type: Optional
|
45
|
-
}, {
|
46
|
-
type: Inject,
|
47
|
-
args: [YUNZAI_CONFIG]
|
48
|
-
}] }];
|
49
|
-
} });
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Generated bundle index. Do not edit.
|
53
|
-
*/
|
54
|
-
|
55
|
-
export { YUNZAI_CONFIG, YUNZAI_CONFIG_FACTORY, YunzaiConfigService, YunzaiSVConfig };
|
56
|
-
//# sourceMappingURL=config.mjs.map
|
package/fesm2015/config.mjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../../../packages/util/config/abc/sv.type.ts","../../../../packages/util/config/config.types.ts","../../../../packages/util/config/config.service.ts","../../../../packages/util/config/config.ts"],"sourcesContent":["export class YunzaiSVConfig {\n /** 大小,默认:`large` */\n size?: 'small' | 'large';\n /** 间距,默认:`32` */\n gutter?: number;\n /** 布局,默认:`horizontal` */\n layout?: 'horizontal' | 'vertical';\n /** 列数,默认:`3` */\n col?: number;\n /** 是否显示默认值,当内容为空值时显示 `-`,默认:`true` */\n default?: boolean;\n /** `label` 固定宽度,若 `null` 或 `undefined` 表示非固定,默认:`null` */\n labelWidth?: number;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport {\n YunzaiDateRangePickerConfig,\n YunzaiErrorCollectConfig,\n YunzaiExceptionType,\n YunzaiImageConfig,\n YunzaiLoadingConfig,\n YunzaiLodopConfig,\n YunzaiMediaConfig,\n YunzaiOnboardingConfig,\n YunzaiPageHeaderConfig,\n YunzaiPdfConfig,\n YunzaiQRConfig,\n YunzaiSEConfig,\n YunzaiSGConfig,\n YunzaiSTConfig,\n YunzaiSVConfig,\n YunzaiXlsxConfig,\n YunzaiZipConfig\n} from './abc/index';\nimport { YunzaiACLConfig } from './acl/acl.type';\nimport { YunzaiAuthConfig } from './auth/auth.type';\nimport { YunzaiBusinessConfig } from './bis/bis.type';\nimport { YunzaiCacheConfig } from './cache/cache.type';\nimport { YunzaiChartConfig } from './chart/chart.type';\nimport { YunzaiMockConfig } from './mock/mock.type';\nimport { YunzaiSFConfig } from './sf/sf.type';\nimport { YunzaiSocketConfig } from './socket/socket.type';\nimport { YunzaiThemeHttpClientConfig, YunzaiThemeResponsiveConfig, YunzaiThemeI18nConfig } from './theme/index';\nimport { YunzaiUtilArrayConfig } from './util/array.type';\nimport { YunzaiUtilCurrencyConfig } from './util/currency.type';\n\nexport interface YunzaiConfig {\n bis?: YunzaiBusinessConfig;\n socket?: YunzaiSocketConfig;\n dataRange?: YunzaiDateRangePickerConfig;\n exception?: YunzaiExceptionType;\n errorCollect?: YunzaiErrorCollectConfig;\n image?: YunzaiImageConfig;\n loading?: YunzaiLoadingConfig;\n onboarding?: YunzaiOnboardingConfig;\n lodop?: YunzaiLodopConfig;\n pageHeader?: YunzaiPageHeaderConfig;\n qr?: YunzaiQRConfig;\n se?: YunzaiSEConfig;\n sg?: YunzaiSGConfig;\n sv?: YunzaiSVConfig;\n st?: YunzaiSTConfig;\n sf?: YunzaiSFConfig;\n xlsx?: YunzaiXlsxConfig;\n zip?: YunzaiZipConfig;\n pdf?: YunzaiPdfConfig;\n media?: YunzaiMediaConfig;\n acl?: YunzaiACLConfig;\n auth?: YunzaiAuthConfig;\n cache?: YunzaiCacheConfig;\n chart?: YunzaiChartConfig;\n mock?: YunzaiMockConfig;\n utilArray?: YunzaiUtilArrayConfig;\n utilCurrency?: YunzaiUtilCurrencyConfig;\n themeHttp?: YunzaiThemeHttpClientConfig;\n themeResponsive?: YunzaiThemeResponsiveConfig;\n themeI18n?: YunzaiThemeI18nConfig;\n}\n\nexport type YunzaiConfigKey = keyof YunzaiConfig;\n\nexport const YUNZAI_CONFIG = new InjectionToken<YunzaiConfig>('yunzai-config', {\n providedIn: 'root',\n factory: YUNZAI_CONFIG_FACTORY\n});\n\nexport function YUNZAI_CONFIG_FACTORY(): YunzaiConfig {\n return {};\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport { deepMergeKey } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { YunzaiConfig, YunzaiConfigKey, YUNZAI_CONFIG } from './config.types';\n\n@Injectable({ providedIn: 'root' })\nexport class YunzaiConfigService {\n private config: YunzaiConfig;\n\n constructor(@Optional() @Inject(YUNZAI_CONFIG) defaultConfig?: YunzaiConfig) {\n this.config = { ...defaultConfig };\n }\n\n get<T extends YunzaiConfigKey>(componentName: T, key?: string): YunzaiConfig[T] {\n const res = ((this.config[componentName] as { [key: string]: unknown }) || {}) as NzSafeAny;\n return key ? { [key]: res[key] } : res;\n }\n\n merge<T extends YunzaiConfigKey>(componentName: T, ...defaultValues: Array<YunzaiConfig[T]>): YunzaiConfig[T] {\n return deepMergeKey({}, true, ...defaultValues, this.get(componentName));\n }\n\n attach<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, defaultValues: YunzaiConfig[T]): void {\n Object.assign(componentThis as any, this.merge(componentName, defaultValues));\n }\n\n attachKey<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, key: string): void {\n Object.assign(componentThis as any, this.get(componentName, key));\n }\n\n set<T extends YunzaiConfigKey>(componentName: T, value: YunzaiConfig[T]): void {\n this.config[componentName] = { ...this.config[componentName], ...value };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAAa,cAAc,CAAA;AAa1B;;MCuDY,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,qBAAqB;AAC/B,CAAA,EAAE;SAEa,qBAAqB,GAAA;AACnC,IAAA,OAAO,EAAE,CAAC;AACZ;;MCnEa,mBAAmB,CAAA;AAG9B,IAAA,WAAA,CAA+C,aAA4B,EAAA;AACzE,QAAA,IAAI,CAAC,MAAM,GAAQ,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,aAAa,CAAE,CAAC;KACpC;IAED,GAAG,CAA4B,aAAgB,EAAE,GAAY,EAAA;AAC3D,QAAA,MAAM,GAAG,IAAK,IAAI,CAAC,MAAM,CAAC,aAAa,CAAgC,IAAI,EAAE,CAAc,CAAC;AAC5F,QAAA,OAAO,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;KACxC;AAED,IAAA,KAAK,CAA4B,aAAgB,EAAE,GAAG,aAAqC,EAAA;AACzF,QAAA,OAAO,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;KAC1E;AAED,IAAA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