@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
@@ -1,279 +1,279 @@
|
|
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 = { 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
|
-
|
96
|
-
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
98
|
-
type: Injectable,
|
99
|
-
args: [{ providedIn: 'root' }]
|
100
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
101
|
-
type: Inject,
|
102
|
-
args: [DOCUMENT]
|
103
|
-
}] }, { type: i1.Platform }]; } });
|
104
|
-
|
105
|
-
/**
|
106
|
-
* Copy text to clipboard
|
107
|
-
*
|
108
|
-
* 复制字符串文档至剪贴板
|
109
|
-
*/
|
110
|
-
function copy(value) {
|
111
|
-
return new Promise((resolve) => {
|
112
|
-
let copyTextArea = null;
|
113
|
-
try {
|
114
|
-
copyTextArea = document.createElement('textarea');
|
115
|
-
copyTextArea.style.height = '0px';
|
116
|
-
copyTextArea.style.opacity = '0';
|
117
|
-
copyTextArea.style.width = '0px';
|
118
|
-
document.body.appendChild(copyTextArea);
|
119
|
-
copyTextArea.value = value;
|
120
|
-
copyTextArea.select();
|
121
|
-
// eslint-disable-next-line deprecation/deprecation
|
122
|
-
document.execCommand('copy');
|
123
|
-
resolve(value);
|
124
|
-
}
|
125
|
-
finally {
|
126
|
-
if (copyTextArea && copyTextArea.parentNode) {
|
127
|
-
copyTextArea.parentNode.removeChild(copyTextArea);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
});
|
131
|
-
}
|
132
|
-
|
133
|
-
/**
|
134
|
-
* Used to verify `<ng-content></ng-content>` is empty, useful for custom components.
|
135
|
-
*
|
136
|
-
* 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。
|
137
|
-
*/
|
138
|
-
function isEmpty(element) {
|
139
|
-
const nodes = element.childNodes;
|
140
|
-
for (let i = 0; i < nodes.length; i++) {
|
141
|
-
const node = nodes.item(i);
|
142
|
-
if (node.nodeType === 1 && node.outerHTML.toString().trim().length !== 0) {
|
143
|
-
return false;
|
144
|
-
}
|
145
|
-
else if (node.nodeType === 3 && node.textContent.toString().trim().length !== 0) {
|
146
|
-
return false;
|
147
|
-
}
|
148
|
-
}
|
149
|
-
return true;
|
150
|
-
}
|
151
|
-
|
152
|
-
class ScrollService {
|
153
|
-
_getDoc() {
|
154
|
-
return this._doc || document;
|
155
|
-
}
|
156
|
-
_getWin() {
|
157
|
-
const doc = this._getDoc();
|
158
|
-
return doc.defaultView || window;
|
159
|
-
}
|
160
|
-
constructor(_doc, platform) {
|
161
|
-
this._doc = _doc;
|
162
|
-
this.platform = platform;
|
163
|
-
}
|
164
|
-
/**
|
165
|
-
* 获取滚动条位置
|
166
|
-
*
|
167
|
-
* @param element 指定元素,默认 `window`
|
168
|
-
*/
|
169
|
-
getScrollPosition(element) {
|
170
|
-
if (!this.platform.isBrowser) {
|
171
|
-
return [0, 0];
|
172
|
-
}
|
173
|
-
const win = this._getWin();
|
174
|
-
if (element && element !== win) {
|
175
|
-
return [element.scrollLeft, element.scrollTop];
|
176
|
-
}
|
177
|
-
else {
|
178
|
-
return [win.scrollX, win.scrollY];
|
179
|
-
}
|
180
|
-
}
|
181
|
-
/**
|
182
|
-
* 设置滚动条位置
|
183
|
-
*
|
184
|
-
* @param element 指定元素
|
185
|
-
*/
|
186
|
-
scrollToPosition(element, position) {
|
187
|
-
if (!this.platform.isBrowser) {
|
188
|
-
return;
|
189
|
-
}
|
190
|
-
(element || this._getWin()).scrollTo(position[0], position[1]);
|
191
|
-
}
|
192
|
-
/**
|
193
|
-
* 设置滚动条至指定元素
|
194
|
-
*
|
195
|
-
* @param element 指定元素,默认 `document.body`
|
196
|
-
* @param topOffset 偏移值,默认 `0`
|
197
|
-
*/
|
198
|
-
scrollToElement(element, topOffset = 0) {
|
199
|
-
if (!this.platform.isBrowser) {
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
if (!element) {
|
203
|
-
element = this._getDoc().body;
|
204
|
-
}
|
205
|
-
element.scrollIntoView();
|
206
|
-
const win = this._getWin();
|
207
|
-
if (win && win.scrollBy) {
|
208
|
-
win.scrollBy(0, element.getBoundingClientRect().top - topOffset);
|
209
|
-
if (win.scrollY < 20) {
|
210
|
-
win.scrollBy(0, -win.scrollY);
|
211
|
-
}
|
212
|
-
}
|
213
|
-
}
|
214
|
-
/**
|
215
|
-
* 滚动至顶部
|
216
|
-
*
|
217
|
-
* @param topOffset 偏移值,默认 `0`
|
218
|
-
*/
|
219
|
-
scrollToTop(topOffset = 0) {
|
220
|
-
if (!this.platform.isBrowser) {
|
221
|
-
return;
|
222
|
-
}
|
223
|
-
this.scrollToElement(this._getDoc().body, topOffset);
|
224
|
-
}
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
229
|
-
type: Injectable,
|
230
|
-
args: [{ providedIn: 'root' }]
|
231
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
232
|
-
type: Inject,
|
233
|
-
args: [DOCUMENT]
|
234
|
-
}] }, { type: i1.Platform }]; } });
|
235
|
-
|
236
|
-
function removeClass(el, classMap, renderer) {
|
237
|
-
Object.keys(classMap).forEach(key => renderer.removeClass(el, key));
|
238
|
-
}
|
239
|
-
function addClass(el, classMap, renderer) {
|
240
|
-
for (const i in classMap) {
|
241
|
-
if (classMap[i]) {
|
242
|
-
renderer.addClass(el, i);
|
243
|
-
}
|
244
|
-
}
|
245
|
-
}
|
246
|
-
/**
|
247
|
-
* Update host component style `class`
|
248
|
-
*
|
249
|
-
* 更新宿主组件样式 `class`
|
250
|
-
*
|
251
|
-
* ```ts
|
252
|
-
* updateHostClass(
|
253
|
-
* this.el.nativeElement,
|
254
|
-
* this.renderer,
|
255
|
-
* {
|
256
|
-
* [ 'classname' ]: true,
|
257
|
-
* [ 'classname' ]: this.type === '1',
|
258
|
-
* [ this.cls ]: true,
|
259
|
-
* [ `a-${this.cls}` ]: true
|
260
|
-
* })
|
261
|
-
* ```
|
262
|
-
*/
|
263
|
-
function updateHostClass(el, renderer, classMap, preClean = false) {
|
264
|
-
if (preClean === true) {
|
265
|
-
renderer.removeAttribute(el, 'class');
|
266
|
-
}
|
267
|
-
else {
|
268
|
-
removeClass(el, classMap, renderer);
|
269
|
-
}
|
270
|
-
classMap = { ...classMap };
|
271
|
-
addClass(el, classMap, renderer);
|
272
|
-
}
|
273
|
-
|
274
|
-
/**
|
275
|
-
* Generated bundle index. Do not edit.
|
276
|
-
*/
|
277
|
-
|
278
|
-
export { CookieService, ScrollService, copy, isEmpty, updateHostClass };
|
279
|
-
//# sourceMappingURL=browser.mjs.map
|
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 = { 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
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: CookieService, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
95
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: CookieService, providedIn: 'root' }); }
|
96
|
+
}
|
97
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: CookieService, decorators: [{
|
98
|
+
type: Injectable,
|
99
|
+
args: [{ providedIn: 'root' }]
|
100
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
101
|
+
type: Inject,
|
102
|
+
args: [DOCUMENT]
|
103
|
+
}] }, { type: i1.Platform }]; } });
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Copy text to clipboard
|
107
|
+
*
|
108
|
+
* 复制字符串文档至剪贴板
|
109
|
+
*/
|
110
|
+
function copy(value) {
|
111
|
+
return new Promise((resolve) => {
|
112
|
+
let copyTextArea = null;
|
113
|
+
try {
|
114
|
+
copyTextArea = document.createElement('textarea');
|
115
|
+
copyTextArea.style.height = '0px';
|
116
|
+
copyTextArea.style.opacity = '0';
|
117
|
+
copyTextArea.style.width = '0px';
|
118
|
+
document.body.appendChild(copyTextArea);
|
119
|
+
copyTextArea.value = value;
|
120
|
+
copyTextArea.select();
|
121
|
+
// eslint-disable-next-line deprecation/deprecation
|
122
|
+
document.execCommand('copy');
|
123
|
+
resolve(value);
|
124
|
+
}
|
125
|
+
finally {
|
126
|
+
if (copyTextArea && copyTextArea.parentNode) {
|
127
|
+
copyTextArea.parentNode.removeChild(copyTextArea);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Used to verify `<ng-content></ng-content>` is empty, useful for custom components.
|
135
|
+
*
|
136
|
+
* 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。
|
137
|
+
*/
|
138
|
+
function isEmpty(element) {
|
139
|
+
const nodes = element.childNodes;
|
140
|
+
for (let i = 0; i < nodes.length; i++) {
|
141
|
+
const node = nodes.item(i);
|
142
|
+
if (node.nodeType === 1 && node.outerHTML.toString().trim().length !== 0) {
|
143
|
+
return false;
|
144
|
+
}
|
145
|
+
else if (node.nodeType === 3 && node.textContent.toString().trim().length !== 0) {
|
146
|
+
return false;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
return true;
|
150
|
+
}
|
151
|
+
|
152
|
+
class ScrollService {
|
153
|
+
_getDoc() {
|
154
|
+
return this._doc || document;
|
155
|
+
}
|
156
|
+
_getWin() {
|
157
|
+
const doc = this._getDoc();
|
158
|
+
return doc.defaultView || window;
|
159
|
+
}
|
160
|
+
constructor(_doc, platform) {
|
161
|
+
this._doc = _doc;
|
162
|
+
this.platform = platform;
|
163
|
+
}
|
164
|
+
/**
|
165
|
+
* 获取滚动条位置
|
166
|
+
*
|
167
|
+
* @param element 指定元素,默认 `window`
|
168
|
+
*/
|
169
|
+
getScrollPosition(element) {
|
170
|
+
if (!this.platform.isBrowser) {
|
171
|
+
return [0, 0];
|
172
|
+
}
|
173
|
+
const win = this._getWin();
|
174
|
+
if (element && element !== win) {
|
175
|
+
return [element.scrollLeft, element.scrollTop];
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
return [win.scrollX, win.scrollY];
|
179
|
+
}
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* 设置滚动条位置
|
183
|
+
*
|
184
|
+
* @param element 指定元素
|
185
|
+
*/
|
186
|
+
scrollToPosition(element, position) {
|
187
|
+
if (!this.platform.isBrowser) {
|
188
|
+
return;
|
189
|
+
}
|
190
|
+
(element || this._getWin()).scrollTo(position[0], position[1]);
|
191
|
+
}
|
192
|
+
/**
|
193
|
+
* 设置滚动条至指定元素
|
194
|
+
*
|
195
|
+
* @param element 指定元素,默认 `document.body`
|
196
|
+
* @param topOffset 偏移值,默认 `0`
|
197
|
+
*/
|
198
|
+
scrollToElement(element, topOffset = 0) {
|
199
|
+
if (!this.platform.isBrowser) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
if (!element) {
|
203
|
+
element = this._getDoc().body;
|
204
|
+
}
|
205
|
+
element.scrollIntoView();
|
206
|
+
const win = this._getWin();
|
207
|
+
if (win && win.scrollBy) {
|
208
|
+
win.scrollBy(0, element.getBoundingClientRect().top - topOffset);
|
209
|
+
if (win.scrollY < 20) {
|
210
|
+
win.scrollBy(0, -win.scrollY);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
/**
|
215
|
+
* 滚动至顶部
|
216
|
+
*
|
217
|
+
* @param topOffset 偏移值,默认 `0`
|
218
|
+
*/
|
219
|
+
scrollToTop(topOffset = 0) {
|
220
|
+
if (!this.platform.isBrowser) {
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
this.scrollToElement(this._getDoc().body, topOffset);
|
224
|
+
}
|
225
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: ScrollService, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
226
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
|
227
|
+
}
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: ScrollService, decorators: [{
|
229
|
+
type: Injectable,
|
230
|
+
args: [{ providedIn: 'root' }]
|
231
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
232
|
+
type: Inject,
|
233
|
+
args: [DOCUMENT]
|
234
|
+
}] }, { type: i1.Platform }]; } });
|
235
|
+
|
236
|
+
function removeClass(el, classMap, renderer) {
|
237
|
+
Object.keys(classMap).forEach(key => renderer.removeClass(el, key));
|
238
|
+
}
|
239
|
+
function addClass(el, classMap, renderer) {
|
240
|
+
for (const i in classMap) {
|
241
|
+
if (classMap[i]) {
|
242
|
+
renderer.addClass(el, i);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
/**
|
247
|
+
* Update host component style `class`
|
248
|
+
*
|
249
|
+
* 更新宿主组件样式 `class`
|
250
|
+
*
|
251
|
+
* ```ts
|
252
|
+
* updateHostClass(
|
253
|
+
* this.el.nativeElement,
|
254
|
+
* this.renderer,
|
255
|
+
* {
|
256
|
+
* [ 'classname' ]: true,
|
257
|
+
* [ 'classname' ]: this.type === '1',
|
258
|
+
* [ this.cls ]: true,
|
259
|
+
* [ `a-${this.cls}` ]: true
|
260
|
+
* })
|
261
|
+
* ```
|
262
|
+
*/
|
263
|
+
function updateHostClass(el, renderer, classMap, preClean = false) {
|
264
|
+
if (preClean === true) {
|
265
|
+
renderer.removeAttribute(el, 'class');
|
266
|
+
}
|
267
|
+
else {
|
268
|
+
removeClass(el, classMap, renderer);
|
269
|
+
}
|
270
|
+
classMap = { ...classMap };
|
271
|
+
addClass(el, classMap, renderer);
|
272
|
+
}
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Generated bundle index. Do not edit.
|
276
|
+
*/
|
277
|
+
|
278
|
+
export { CookieService, ScrollService, copy, isEmpty, updateHostClass };
|
279
|
+
//# sourceMappingURL=browser.mjs.map
|
@@ -1 +1 @@
|
|
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,IAA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,EAAA,aAAa,cADA,MAAM,EAAA,CAAA,CAAA;2FACnB,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAWnB,MAAM;2BAAC,QAAQ,CAAA;;;ACf9B,SAAS,WAAW,CAAC,EAAe,EAAE,QAAsC,EAAE,QAAmB,EAAA;IAC/F,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,EAAe,EAAE,QAAsC,EAAE,QAAmB,EAAA;AAC5F,IAAA,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE;AACxB,QAAA,IAAI,QAAQ,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;AACD,IAAA,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC3B,IAAA,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACnC;;AC5CA;;AAEG;;;;"}
|
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;AACH,MACa,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;QAA3C,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAW;QAAU,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,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACnC,YAAA,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,KAAK,GAAG,MAAM,CA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