@yelon/util 16.4.5 → 17.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -2
  3. package/browser/cookie.service.d.ts +2 -5
  4. package/browser/is-empty.d.ts +2 -2
  5. package/browser/scroll.service.d.ts +3 -6
  6. package/config/auth/auth.type.d.ts +2 -10
  7. package/config/cache/cache.type.d.ts +26 -0
  8. package/config/config.types.d.ts +5 -2
  9. package/config/index.d.ts +2 -2
  10. package/config/mock/mock.type.d.ts +0 -4
  11. package/config/theme/http.type.d.ts +3 -2
  12. package/config/theme/pipe.type.d.ts +3 -0
  13. package/date-time/time.d.ts +16 -8
  14. package/decorator/convert.d.ts +8 -0
  15. package/decorator/zone-outside.d.ts +2 -2
  16. package/esm2022/array/array-type.service.mjs +1 -1
  17. package/esm2022/array/array.service.mjs +6 -5
  18. package/esm2022/browser/cookie.service.mjs +11 -14
  19. package/esm2022/browser/copy.mjs +1 -1
  20. package/esm2022/browser/is-empty.mjs +3 -3
  21. package/esm2022/browser/scroll.service.mjs +11 -14
  22. package/esm2022/browser/style.mjs +1 -1
  23. package/esm2022/config/auth/auth.type.mjs +1 -1
  24. package/esm2022/config/cache/cache.type.mjs +1 -1
  25. package/esm2022/config/config.service.mjs +7 -6
  26. package/esm2022/config/config.types.mjs +5 -2
  27. package/esm2022/config/index.mjs +3 -3
  28. package/esm2022/config/mock/mock.type.mjs +1 -1
  29. package/esm2022/config/theme/http.type.mjs +1 -1
  30. package/esm2022/config/theme/pipe.type.mjs +2 -0
  31. package/esm2022/date-time/picker.mjs +1 -1
  32. package/esm2022/date-time/time.mjs +16 -11
  33. package/esm2022/decorator/convert.mjs +9 -1
  34. package/esm2022/decorator/zone-outside.mjs +3 -3
  35. package/esm2022/form/match-control.mjs +1 -1
  36. package/esm2022/format/currency.service.mjs +10 -15
  37. package/esm2022/format/string.mjs +1 -1
  38. package/esm2022/index.mjs +1 -2
  39. package/esm2022/math/in-range.mjs +1 -1
  40. package/esm2022/math/round.mjs +1 -1
  41. package/esm2022/mcache/localStorageUtils.mjs +1 -1
  42. package/esm2022/mtypes/header-menu.type.mjs +1 -1
  43. package/esm2022/mtypes/menu.type.mjs +1 -1
  44. package/esm2022/mtypes/page.mjs +1 -1
  45. package/esm2022/other/assert.mjs +2 -2
  46. package/esm2022/other/deep.mjs +1 -1
  47. package/esm2022/other/favicon.mjs +1 -1
  48. package/esm2022/other/index.mjs +2 -2
  49. package/esm2022/other/lazy.service.mjs +8 -11
  50. package/esm2022/other/logger.mjs +1 -1
  51. package/esm2022/other/path-to-regexp.service.mjs +6 -6
  52. package/esm2022/pipes/currency/cny.pipe.mjs +15 -15
  53. package/esm2022/pipes/currency/mega.pipe.mjs +16 -20
  54. package/esm2022/pipes/currency/module.mjs +6 -6
  55. package/esm2022/pipes/currency/price.pipe.mjs +19 -19
  56. package/esm2022/pipes/filter/filter.pipe.mjs +11 -10
  57. package/esm2022/pipes/filter/module.mjs +6 -6
  58. package/esm2022/pipes/format/mask.pipe.mjs +24 -24
  59. package/esm2022/pipes/format/module.mjs +6 -6
  60. package/esm2022/token/window.mjs +1 -1
  61. package/fesm2022/array.mjs +5 -4
  62. package/fesm2022/array.mjs.map +1 -1
  63. package/fesm2022/browser.mjs +20 -26
  64. package/fesm2022/browser.mjs.map +1 -1
  65. package/fesm2022/config.mjs +11 -7
  66. package/fesm2022/config.mjs.map +1 -1
  67. package/fesm2022/date-time.mjs +15 -10
  68. package/fesm2022/date-time.mjs.map +1 -1
  69. package/fesm2022/decorator.mjs +10 -2
  70. package/fesm2022/decorator.mjs.map +1 -1
  71. package/fesm2022/form.mjs.map +1 -1
  72. package/fesm2022/format.mjs +9 -14
  73. package/fesm2022/format.mjs.map +1 -1
  74. package/fesm2022/math.mjs.map +1 -1
  75. package/fesm2022/mcache.mjs.map +1 -1
  76. package/fesm2022/mtypes.mjs.map +1 -1
  77. package/fesm2022/other.mjs +17 -20
  78. package/fesm2022/other.mjs.map +1 -1
  79. package/fesm2022/pipe-currency.mjs +48 -52
  80. package/fesm2022/pipe-currency.mjs.map +1 -1
  81. package/fesm2022/pipe-filter.mjs +15 -14
  82. package/fesm2022/pipe-filter.mjs.map +1 -1
  83. package/fesm2022/pipe-format.mjs +28 -28
  84. package/fesm2022/pipe-format.mjs.map +1 -1
  85. package/fesm2022/token.mjs.map +1 -1
  86. package/fesm2022/yelon-util.mjs +0 -1
  87. package/fesm2022/yelon-util.mjs.map +1 -1
  88. package/format/currency.service.d.ts +3 -2
  89. package/index.d.ts +0 -1
  90. package/mtypes/header-menu.type.d.ts +3 -2
  91. package/mtypes/menu.type.d.ts +6 -5
  92. package/mtypes/page.d.ts +2 -1
  93. package/other/index.d.ts +1 -1
  94. package/other/lazy.service.d.ts +1 -2
  95. package/other/path-to-regexp.service.d.ts +12 -11
  96. package/package.json +14 -20
  97. package/pipes/currency/cny.pipe.d.ts +8 -9
  98. package/pipes/currency/mega.pipe.d.ts +8 -9
  99. package/pipes/currency/module.d.ts +1 -1
  100. package/pipes/currency/price.pipe.d.ts +12 -13
  101. package/pipes/filter/filter.pipe.d.ts +6 -6
  102. package/pipes/filter/module.d.ts +1 -1
  103. package/pipes/format/mask.pipe.d.ts +20 -20
  104. package/pipes/format/module.d.ts +1 -1
  105. package/analysis/global-event.subject.d.ts +0 -7
  106. package/analysis/index.d.ts +0 -1
  107. package/esm2022/analysis/analysis.mjs +0 -5
  108. package/esm2022/analysis/global-event.subject.mjs +0 -17
  109. package/esm2022/analysis/index.mjs +0 -2
  110. package/fesm2022/analysis.mjs +0 -24
  111. package/fesm2022/analysis.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"array.mjs","sources":["../../../../packages/util/array/array.service.ts","../../../../packages/util/array/array.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { YunzaiConfigService, YunzaiUtilArrayConfig } from '@yelon/util/config';\nimport { NzTreeNode } from 'ng-zorro-antd/core/tree';\n\nimport {\n ArrayServiceArrToTreeNodeOptions,\n ArrayServiceArrToTreeOptions,\n ArrayServiceGetKeysByTreeNodeOptions,\n ArrayServiceGroupByResult,\n ArrayServiceTreeToArrOptions\n} from './array-type.service';\n\n@Injectable({ providedIn: 'root' })\nexport class ArrayService {\n private c: YunzaiUtilArrayConfig;\n\n constructor(cog: YunzaiConfigService) {\n this.c = cog.merge('utilArray', {\n deepMapName: 'deep',\n parentMapName: 'parent',\n idMapName: 'id',\n parentIdMapName: 'parent_id',\n childrenMapName: 'children',\n titleMapName: 'title',\n checkedMapname: 'checked',\n selectedMapname: 'selected',\n expandedMapname: 'expanded',\n disabledMapname: 'disabled'\n })!;\n }\n\n /**\n * Convert tree structure to array structure\n *\n * 将树结构转换成数组结构\n */\n treeToArr<T extends object = any>(tree: readonly T[], options?: ArrayServiceTreeToArrOptions<T>): T[] {\n const opt = {\n deepMapName: this.c.deepMapName,\n parentMapName: this.c.parentMapName,\n childrenMapName: this.c.childrenMapName,\n clearChildren: true,\n cb: null,\n ...options\n } as ArrayServiceTreeToArrOptions;\n const result: Array<{ [key: string]: any }> = [];\n const inFn = (list: ReadonlyArray<{ [key: string]: any }>, parent: T | null, deep: number = 0): void => {\n for (const i of list) {\n i[opt.deepMapName!] = deep;\n i[opt.parentMapName!] = parent;\n if (opt.cb) {\n opt.cb(i, parent, deep);\n }\n result.push(i);\n const children = i[opt.childrenMapName!];\n if (children != null && Array.isArray(children) && children.length > 0) {\n inFn(children, i as T, deep + 1);\n }\n if (opt.clearChildren) {\n delete i[opt.childrenMapName!];\n }\n }\n };\n inFn(tree, null);\n return result as T[];\n }\n\n /**\n * Convert array structure to tree structure\n *\n * 数组转换成树数据\n */\n arrToTree<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeOptions<T>): T[] {\n if (!Array.isArray(arr) || arr.length === 0) {\n return [];\n }\n\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n childrenMapName: this.c.childrenMapName,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeOptions<T>;\n const tree: T[] = [];\n const childrenOf: { [key: string]: T[] } = {};\n let rootPid = opt.rootParentIdValue;\n const arrType = arr as ReadonlyArray<{ [key: string]: any }>;\n if (!rootPid) {\n const pids = arrType.map(i => i[opt.parentIdMapName!]);\n const emptyPid = pids.findIndex(w => w == null);\n rootPid = emptyPid !== -1 ? pids[emptyPid] : pids.sort()[0];\n }\n for (const item of arrType) {\n const id = item[opt.idMapName!];\n const pid = item[opt.parentIdMapName!];\n childrenOf[id] = childrenOf[id] || [];\n item[opt.childrenMapName!] = childrenOf[id];\n if (opt.cb) {\n opt.cb(item as T);\n }\n if (pid !== rootPid) {\n childrenOf[pid] = childrenOf[pid] || [];\n childrenOf[pid].push(item as T);\n } else {\n tree.push(item as T);\n }\n }\n return tree;\n }\n\n /**\n * 数组转换成 `nz-tree` 数据源,通过 `options` 转化项名,也可以使用 `options.cb` 更高级决定数据项\n */\n arrToTreeNode<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeNodeOptions): NzTreeNode[] {\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n titleMapName: this.c.titleMapName,\n isLeafMapName: 'isLeaf',\n checkedMapname: this.c.checkedMapname,\n selectedMapname: this.c.selectedMapname,\n expandedMapname: this.c.expandedMapname,\n disabledMapname: this.c.disabledMapname,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeNodeOptions<T>;\n const tree = this.arrToTree<T>(arr, {\n idMapName: opt.idMapName,\n parentIdMapName: opt.parentIdMapName,\n childrenMapName: 'children'\n });\n this.visitTree<T>(tree, (item: { [key: string]: any }, parent, deep) => {\n item.key = item[opt.idMapName!];\n item.title = item[opt.titleMapName!];\n item.checked = item[opt.checkedMapname!];\n item.selected = item[opt.selectedMapname!];\n item.expanded = item[opt.expandedMapname!];\n item.disabled = item[opt.disabledMapname!];\n if (item[opt.isLeafMapName!] == null) {\n item.isLeaf = item.children.length === 0;\n } else {\n item.isLeaf = item[opt.isLeafMapName!];\n }\n if (opt.cb) {\n opt.cb(item as any, parent, deep);\n }\n });\n return tree.map(node => new NzTreeNode(node as any));\n }\n\n /**\n * 递归访问整个树\n */\n visitTree<T extends object = any>(\n tree: readonly T[],\n cb: (item: T, parent: T | null, deep: number) => void,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): void {\n options = {\n childrenMapName: this.c.childrenMapName,\n ...options\n };\n const inFn = (data: readonly T[], parent: T | null, deep: number): void => {\n for (const item of data) {\n cb(item, parent, deep);\n const childrenVal = (item as { [key: string]: any })[options!.childrenMapName!];\n if (Array.isArray(childrenVal) && childrenVal.length > 0) {\n inFn(childrenVal, item, deep + 1);\n }\n }\n };\n inFn(tree, null, 1);\n }\n\n /**\n * Return the value of the first tree value in the tree where predicate is true, and `undefined` otherwise\n *\n * 根据条件返回树的第一个值,否则返回 `undefined`\n */\n findTree<T extends object = any>(\n tree: readonly T[],\n predicate: (item: T) => boolean,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): T | undefined {\n let res: T | undefined;\n this.visitTree<T>(\n tree,\n item => {\n if (res === undefined && predicate(item)) {\n res = item;\n }\n },\n options\n );\n return res;\n }\n\n /**\n * 获取所有已经选中的 `key` 值\n */\n getKeysByTreeNode(tree: NzTreeNode[], options?: ArrayServiceGetKeysByTreeNodeOptions): any[] {\n const opt = {\n includeHalfChecked: true,\n ...options\n } as ArrayServiceGetKeysByTreeNodeOptions;\n const keys: any[] = [];\n this.visitTree<NzTreeNode>(tree, (item, parent, deep) => {\n if (item.isChecked || (opt.includeHalfChecked && item.isHalfChecked)) {\n keys.push(opt.cb ? opt.cb(item, parent, deep) : opt.keyMapName ? item.origin[opt.keyMapName] : item.key);\n }\n });\n return keys;\n }\n private baseFlat(array: any[], depth: number, result: any[] = []): any[] {\n let index = -1;\n while (++index < array.length) {\n const value = array[index];\n if (depth > 0 && Array.isArray(value)) {\n if (depth > 1) {\n this.baseFlat(value, depth - 1, result);\n } else {\n let pushIndex = -1;\n const offset = result.length;\n\n while (++pushIndex < value.length) {\n result[offset + pushIndex] = value[pushIndex];\n }\n }\n } else {\n result[result.length] = value;\n }\n }\n return result;\n }\n /**\n * Recursively flattens array\n *\n * 递归扁平数组\n * ```ts\n * srv.flat([1, [2, 3, [4, 5, [6]]]]) => [1,2,3,4,5,6]\n * srv.flat([1, [2, 3, [4, 5, [6]]]], 1) => [1,2,3,[4, 5, [6]]]\n * ```\n */\n flat<T>(array: readonly T[], depth: number = 1 / 0): T[] {\n return Array.isArray(array) ? this.baseFlat(array as any[], depth) : (array as T[]);\n }\n /**\n * Group the array\n *\n * 对数组进行分组\n * ```ts\n * srv.groupBy([6.1, 4.2, 6.3], Math.floor) => {\"4\":[4.2],\"6\":[6.1,6.3]}\n * srv.groupBy(['one', 'two', 'three'], v => v.length) => {\"3\":[\"one\",\"two\"],\"5\":[\"three\"]}\n * ```\n */\n groupBy<T>(array: readonly T[], iteratee: (value: T) => string | number): ArrayServiceGroupByResult {\n if (!Array.isArray(array)) {\n return {};\n }\n return array.reduce((result, value) => {\n const key = iteratee(value);\n if (Object.prototype.hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n result[key] = [value];\n }\n return result;\n }, {} as ArrayServiceGroupByResult);\n }\n /**\n * Creates a duplicate-free version of an array\n *\n * 创建去重后的数组\n * ```ts\n * uniq([1, 2, 2, 3, 1]) => [1,2,3]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], 'a') => [{\"a\":1},{\"a\":2}]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], i => (i.a === 1 ? 'a' : 'b')) => [{\"a\":1},{\"a\":2}]\n * ```\n */\n uniq<T>(array: readonly T[], predicate?: string | ((value: T) => string | number | boolean)): T[] {\n return Array.from(\n array\n .reduce((map, value) => {\n const key = predicate\n ? typeof predicate === 'string'\n ? (value as any)[predicate]\n : predicate!(value)\n : value;\n if (!map.has(key)) {\n map.set(key, value);\n }\n return map;\n }, new Map<string | number | boolean, T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CAAA,EAAA;;4FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACblC;;AAEG;;;;"}
1
+ {"version":3,"file":"array.mjs","sources":["../../../../packages/util/array/array.service.ts","../../../../packages/util/array/array.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Injectable } from '@angular/core';\n\nimport { YunzaiConfigService, YunzaiUtilArrayConfig } from '@yelon/util/config';\nimport { NzTreeNode } from 'ng-zorro-antd/core/tree';\n\nimport {\n ArrayServiceArrToTreeNodeOptions,\n ArrayServiceArrToTreeOptions,\n ArrayServiceGetKeysByTreeNodeOptions,\n ArrayServiceGroupByResult,\n ArrayServiceTreeToArrOptions\n} from './array-type.service';\n\n@Injectable({ providedIn: 'root' })\nexport class ArrayService {\n private c: YunzaiUtilArrayConfig;\n\n constructor(cog: YunzaiConfigService) {\n this.c = cog.merge('utilArray', {\n deepMapName: 'deep',\n parentMapName: 'parent',\n idMapName: 'id',\n parentIdMapName: 'parent_id',\n childrenMapName: 'children',\n titleMapName: 'title',\n checkedMapname: 'checked',\n selectedMapname: 'selected',\n expandedMapname: 'expanded',\n disabledMapname: 'disabled'\n })!;\n }\n\n /**\n * Convert tree structure to array structure\n *\n * 将树结构转换成数组结构\n */\n treeToArr<T extends object = any>(tree: readonly T[], options?: ArrayServiceTreeToArrOptions<T>): T[] {\n const opt = {\n deepMapName: this.c.deepMapName,\n parentMapName: this.c.parentMapName,\n childrenMapName: this.c.childrenMapName,\n clearChildren: true,\n cb: null,\n ...options\n } as ArrayServiceTreeToArrOptions;\n const result: Array<{ [key: string]: any }> = [];\n const inFn = (list: ReadonlyArray<{ [key: string]: any }>, parent: T | null, deep: number = 0): void => {\n for (const i of list) {\n i[opt.deepMapName!] = deep;\n i[opt.parentMapName!] = parent;\n if (opt.cb) {\n opt.cb(i, parent, deep);\n }\n result.push(i);\n const children = i[opt.childrenMapName!];\n if (children != null && Array.isArray(children) && children.length > 0) {\n inFn(children, i as T, deep + 1);\n }\n if (opt.clearChildren) {\n delete i[opt.childrenMapName!];\n }\n }\n };\n inFn(tree, null);\n return result as T[];\n }\n\n /**\n * Convert array structure to tree structure\n *\n * 数组转换成树数据\n */\n arrToTree<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeOptions<T>): T[] {\n if (!Array.isArray(arr) || arr.length === 0) {\n return [];\n }\n\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n childrenMapName: this.c.childrenMapName,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeOptions<T>;\n const tree: T[] = [];\n const childrenOf: { [key: string]: T[] } = {};\n let rootPid = opt.rootParentIdValue;\n const arrType = arr as ReadonlyArray<{ [key: string]: any }>;\n if (!rootPid) {\n const pids = arrType.map(i => i[opt.parentIdMapName!]);\n const emptyPid = pids.findIndex(w => w == null);\n rootPid = emptyPid !== -1 ? pids[emptyPid] : pids.sort()[0];\n }\n for (const item of arrType) {\n const id = item[opt.idMapName!];\n const pid = item[opt.parentIdMapName!];\n childrenOf[id] = childrenOf[id] || [];\n item[opt.childrenMapName!] = childrenOf[id];\n if (opt.cb) {\n opt.cb(item as T);\n }\n if (pid !== rootPid) {\n childrenOf[pid] = childrenOf[pid] || [];\n childrenOf[pid].push(item as T);\n } else {\n tree.push(item as T);\n }\n }\n return tree;\n }\n\n /**\n * 数组转换成 `nz-tree` 数据源,通过 `options` 转化项名,也可以使用 `options.cb` 更高级决定数据项\n */\n arrToTreeNode<T extends object = any>(arr: readonly T[], options?: ArrayServiceArrToTreeNodeOptions): NzTreeNode[] {\n const opt = {\n idMapName: this.c.idMapName,\n parentIdMapName: this.c.parentIdMapName,\n titleMapName: this.c.titleMapName,\n isLeafMapName: 'isLeaf',\n checkedMapname: this.c.checkedMapname,\n selectedMapname: this.c.selectedMapname,\n expandedMapname: this.c.expandedMapname,\n disabledMapname: this.c.disabledMapname,\n cb: null,\n ...options\n } as ArrayServiceArrToTreeNodeOptions<T>;\n const tree = this.arrToTree<T>(arr, {\n idMapName: opt.idMapName,\n parentIdMapName: opt.parentIdMapName,\n childrenMapName: 'children'\n });\n this.visitTree<T>(tree, (item: { [key: string]: any }, parent, deep) => {\n item.key = item[opt.idMapName!];\n item.title = item[opt.titleMapName!];\n item.checked = item[opt.checkedMapname!];\n item.selected = item[opt.selectedMapname!];\n item.expanded = item[opt.expandedMapname!];\n item.disabled = item[opt.disabledMapname!];\n if (item[opt.isLeafMapName!] == null) {\n item.isLeaf = item.children.length === 0;\n } else {\n item.isLeaf = item[opt.isLeafMapName!];\n }\n if (opt.cb) {\n opt.cb(item as any, parent, deep);\n }\n });\n return tree.map(node => new NzTreeNode(node as any));\n }\n\n /**\n * 递归访问整个树\n */\n visitTree<T extends object = any>(\n tree: readonly T[],\n cb: (item: T, parent: T | null, deep: number) => void,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): void {\n options = {\n childrenMapName: this.c.childrenMapName,\n ...options\n };\n const inFn = (data: readonly T[], parent: T | null, deep: number): void => {\n for (const item of data) {\n cb(item, parent, deep);\n const childrenVal = (item as { [key: string]: any })[options!.childrenMapName!];\n if (Array.isArray(childrenVal) && childrenVal.length > 0) {\n inFn(childrenVal, item, deep + 1);\n }\n }\n };\n inFn(tree, null, 1);\n }\n\n /**\n * Return the value of the first tree value in the tree where predicate is true, and `undefined` otherwise\n *\n * 根据条件返回树的第一个值,否则返回 `undefined`\n */\n findTree<T extends object = any>(\n tree: readonly T[],\n predicate: (item: T) => boolean,\n options?: {\n /** 子项名,默认:`'children'` */\n childrenMapName?: string;\n }\n ): T | undefined {\n let res: T | undefined;\n this.visitTree<T>(\n tree,\n item => {\n if (res === undefined && predicate(item)) {\n res = item;\n }\n },\n options\n );\n return res;\n }\n\n /**\n * 获取所有已经选中的 `key` 值\n */\n getKeysByTreeNode(tree: NzTreeNode[], options?: ArrayServiceGetKeysByTreeNodeOptions): any[] {\n const opt = {\n includeHalfChecked: true,\n ...options\n } as ArrayServiceGetKeysByTreeNodeOptions;\n const keys: any[] = [];\n this.visitTree<NzTreeNode>(tree, (item, parent, deep) => {\n if (item.isChecked || (opt.includeHalfChecked && item.isHalfChecked)) {\n keys.push(opt.cb ? opt.cb(item, parent, deep) : opt.keyMapName ? item.origin[opt.keyMapName] : item.key);\n }\n });\n return keys;\n }\n private baseFlat(array: any[], depth: number, result: any[] = []): any[] {\n let index = -1;\n while (++index < array.length) {\n const value = array[index];\n if (depth > 0 && Array.isArray(value)) {\n if (depth > 1) {\n this.baseFlat(value, depth - 1, result);\n } else {\n let pushIndex = -1;\n const offset = result.length;\n\n while (++pushIndex < value.length) {\n result[offset + pushIndex] = value[pushIndex];\n }\n }\n } else {\n result[result.length] = value;\n }\n }\n return result;\n }\n /**\n * Recursively flattens array\n *\n * 递归扁平数组\n * ```ts\n * srv.flat([1, [2, 3, [4, 5, [6]]]]) => [1,2,3,4,5,6]\n * srv.flat([1, [2, 3, [4, 5, [6]]]], 1) => [1,2,3,[4, 5, [6]]]\n * ```\n */\n flat<T>(array: readonly T[], depth: number = 1 / 0): T[] {\n return Array.isArray(array) ? this.baseFlat(array as any[], depth) : (array as T[]);\n }\n /**\n * Group the array\n *\n * 对数组进行分组\n * ```ts\n * srv.groupBy([6.1, 4.2, 6.3], Math.floor) => {\"4\":[4.2],\"6\":[6.1,6.3]}\n * srv.groupBy(['one', 'two', 'three'], v => v.length) => {\"3\":[\"one\",\"two\"],\"5\":[\"three\"]}\n * ```\n */\n groupBy<T>(array: readonly T[], iteratee: (value: T) => string | number): ArrayServiceGroupByResult {\n if (!Array.isArray(array)) {\n return {};\n }\n return array.reduce((result, value) => {\n const key = iteratee(value);\n if (Object.prototype.hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n result[key] = [value];\n }\n return result;\n }, {} as ArrayServiceGroupByResult);\n }\n /**\n * Creates a duplicate-free version of an array\n *\n * 创建去重后的数组\n * ```ts\n * uniq([1, 2, 2, 3, 1]) => [1,2,3]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], 'a') => [{\"a\":1},{\"a\":2}]\n * uniq([{ a: 1 }, { a: 1 }, { a: 2 }], i => (i.a === 1 ? 'a' : 'b')) => [{\"a\":1},{\"a\":2}]\n * ```\n */\n uniq<T>(array: readonly T[], predicate?: string | ((value: T) => string | number | boolean)): T[] {\n return Array.from(\n array\n .reduce((map, value) => {\n const key = predicate\n ? typeof predicate === 'string'\n ? (value as any)[predicate]\n : predicate!(value)\n : value;\n if (!map.has(key)) {\n map.set(key, value);\n }\n return map;\n }, new Map<string | number | boolean, T>())\n .values()\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAAA;MAea,YAAY,CAAA;AAGvB,IAAA,WAAA,CAAY,GAAwB,EAAA;QAClC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE;AAC9B,YAAA,WAAW,EAAE,MAAM;AACnB,YAAA,aAAa,EAAE,QAAQ;AACvB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,eAAe,EAAE,WAAW;AAC5B,YAAA,eAAe,EAAE,UAAU;AAC3B,YAAA,YAAY,EAAE,OAAO;AACrB,YAAA,cAAc,EAAE,SAAS;AACzB,YAAA,eAAe,EAAE,UAAU;AAC3B,YAAA,eAAe,EAAE,UAAU;AAC3B,YAAA,eAAe,EAAE,UAAU;AAC5B,SAAA,CAAE,CAAC;KACL;AAED;;;;AAIG;IACH,SAAS,CAAyB,IAAkB,EAAE,OAAyC,EAAA;AAC7F,QAAA,MAAM,GAAG,GAAG;AACV,YAAA,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW;AAC/B,YAAA,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa;AACnC,YAAA,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,eAAe;AACvC,YAAA,aAAa,EAAE,IAAI;AACnB,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,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAAZ,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,cADC,MAAM,EAAA,CAAA,CAAA,EAAA;;2FACnB,YAAY,EAAA,UAAA,EAAA,CAAA;kBADxB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;;ACdlC;;AAEG;;;;"}
@@ -1,7 +1,7 @@
1
+ import { Platform } from '@angular/cdk/platform';
1
2
  import { DOCUMENT } from '@angular/common';
2
3
  import * as i0 from '@angular/core';
3
- import { Injectable, Inject } from '@angular/core';
4
- import * as i1 from '@angular/cdk/platform';
4
+ import { inject, Injectable } from '@angular/core';
5
5
 
6
6
  /**
7
7
  * A set of simple Cookie manipulation classes.
@@ -9,6 +9,10 @@ import * as i1 from '@angular/cdk/platform';
9
9
  * 一组简单的 Cookie 操作类。
10
10
  */
11
11
  class CookieService {
12
+ constructor() {
13
+ this._doc = inject(DOCUMENT);
14
+ this.platform = inject(Platform);
15
+ }
12
16
  get doc() {
13
17
  return this._doc || document;
14
18
  }
@@ -20,10 +24,6 @@ class CookieService {
20
24
  get cookie() {
21
25
  return this.platform.isBrowser ? this.doc.cookie : '';
22
26
  }
23
- constructor(_doc, platform) {
24
- this._doc = _doc;
25
- this.platform = platform;
26
- }
27
27
  /**
28
28
  * Get all cookie key-value pairs
29
29
  *
@@ -91,16 +91,13 @@ class CookieService {
91
91
  removeAll() {
92
92
  this.doc.cookie = '';
93
93
  }
94
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", 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.2.12", ngImport: i0, type: CookieService, providedIn: 'root' }); }
94
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CookieService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
95
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CookieService, providedIn: 'root' }); }
96
96
  }
97
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CookieService, decorators: [{
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CookieService, decorators: [{
98
98
  type: Injectable,
99
99
  args: [{ providedIn: 'root' }]
100
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
101
- type: Inject,
102
- args: [DOCUMENT]
103
- }] }, { type: i1.Platform }]; } });
100
+ }] });
104
101
 
105
102
  /**
106
103
  * Copy text to clipboard
@@ -131,9 +128,9 @@ function copy(value) {
131
128
  }
132
129
 
133
130
  /**
134
- * Used to verify `<ng-content></ng-content>` is empty, useful for custom components.
131
+ * Used to verify `<ng-content />` is empty, useful for custom components.
135
132
  *
136
- * 用于校验 `<ng-content></ng-content>` 是否为空,自定义组件时蛮有用。
133
+ * 用于校验 `<ng-content />` 是否为空,自定义组件时蛮有用。
137
134
  */
138
135
  function isEmpty(element) {
139
136
  const nodes = element.childNodes;
@@ -150,6 +147,10 @@ function isEmpty(element) {
150
147
  }
151
148
 
152
149
  class ScrollService {
150
+ constructor() {
151
+ this._doc = inject(DOCUMENT);
152
+ this.platform = inject(Platform);
153
+ }
153
154
  _getDoc() {
154
155
  return this._doc || document;
155
156
  }
@@ -157,10 +158,6 @@ class ScrollService {
157
158
  const doc = this._getDoc();
158
159
  return doc.defaultView || window;
159
160
  }
160
- constructor(_doc, platform) {
161
- this._doc = _doc;
162
- this.platform = platform;
163
- }
164
161
  /**
165
162
  * 获取滚动条位置
166
163
  *
@@ -222,16 +219,13 @@ class ScrollService {
222
219
  }
223
220
  this.scrollToElement(this._getDoc().body, topOffset);
224
221
  }
225
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", 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.2.12", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
222
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
223
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
227
224
  }
228
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScrollService, decorators: [{
225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ScrollService, decorators: [{
229
226
  type: Injectable,
230
227
  args: [{ providedIn: 'root' }]
231
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
232
- type: Inject,
233
- args: [DOCUMENT]
234
- }] }, { type: i1.Platform }]; } });
228
+ }] });
235
229
 
236
230
  function removeClass(el, classMap, renderer) {
237
231
  Object.keys(classMap).forEach(key => renderer.removeClass(el, key));
@@ -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(\n @Inject(DOCUMENT) private _doc: NzSafeAny,\n private platform: Platform\n ) {}\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(\n @Inject(DOCUMENT) private _doc: NzSafeAny,\n private platform: Platform\n ) {}\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,WAC4B,CAAA,IAAe,EACjC,QAAkB,EAAA;QADA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAW;QACjC,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;KACxB;AAEJ;;;;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,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,gBAAA,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,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AK,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 { Injectable, inject } 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 readonly _doc = inject(DOCUMENT);\n private readonly platform = inject(Platform);\n\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 /**\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 />` is empty, useful for custom components.\n *\n * 用于校验 `<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 { Injectable, inject } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class ScrollService {\n private readonly _doc = inject(DOCUMENT);\n private readonly platform = inject(Platform);\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 /**\n * 获取滚动条位置\n *\n * @param element 指定元素,默认 `window`\n */\n getScrollPosition(element?: Element | Window | null): [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;AAD1B,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAwF9C,KAAA;AAtFC,IAAA,IAAY,GAAG,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC;KAC9B;AAED;;;;AAIG;AACH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OA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KAAK,EAAA;AAEzB,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;AACrB,QAAA,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;KACvC;SAAM;AACL,QAAA,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;KACrC;AACD,IAAA,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC3B,IAAA,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACnC;;AC5CA;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Optional, Inject } from '@angular/core';
2
+ import { InjectionToken, makeEnvironmentProviders, Injectable, Optional, Inject } from '@angular/core';
3
3
  import { deepMergeKey } from '@yelon/util/other';
4
4
 
5
5
  class YunzaiSVConfig {
@@ -12,7 +12,11 @@ const YUNZAI_CONFIG = new InjectionToken('yunzai-config', {
12
12
  function YUNZAI_CONFIG_FACTORY() {
13
13
  return {};
14
14
  }
15
+ function provideYunzaiConfig(config) {
16
+ return makeEnvironmentProviders([{ provide: YUNZAI_CONFIG, useValue: config }]);
17
+ }
15
18
 
19
+ /* eslint-disable @typescript-eslint/no-explicit-any */
16
20
  class YunzaiConfigService {
17
21
  constructor(defaultConfig) {
18
22
  this.config = { ...defaultConfig };
@@ -33,22 +37,22 @@ class YunzaiConfigService {
33
37
  set(componentName, value) {
34
38
  this.config[componentName] = { ...this.config[componentName], ...value };
35
39
  }
36
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: YunzaiConfigService, deps: [{ token: YUNZAI_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
37
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: YunzaiConfigService, providedIn: 'root' }); }
40
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: YunzaiConfigService, deps: [{ token: YUNZAI_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
41
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: YunzaiConfigService, providedIn: 'root' }); }
38
42
  }
39
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: YunzaiConfigService, decorators: [{
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: YunzaiConfigService, decorators: [{
40
44
  type: Injectable,
41
45
  args: [{ providedIn: 'root' }]
42
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
46
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
43
47
  type: Optional
44
48
  }, {
45
49
  type: Inject,
46
50
  args: [YUNZAI_CONFIG]
47
- }] }]; } });
51
+ }] }] });
48
52
 
49
53
  /**
50
54
  * Generated bundle index. Do not edit.
51
55
  */
52
56
 
53
- export { YUNZAI_CONFIG, YUNZAI_CONFIG_FACTORY, YunzaiConfigService, YunzaiSVConfig };
57
+ export { YUNZAI_CONFIG, YUNZAI_CONFIG_FACTORY, YunzaiConfigService, YunzaiSVConfig, provideYunzaiConfig };
54
58
  //# sourceMappingURL=config.mjs.map
@@ -1 +1 @@
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 YunzaiCellConfig\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 cell?: YunzaiCellConfig;\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;;MCyDY,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;;MCrEa,mBAAmB,CAAA;AAG9B,IAAA,WAAA,CAA+C,aAA4B,EAAA;AACzE,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,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,MAAM,CAA4B,aAAsB,EAAE,aAAgB,EAAE,aAA8B,EAAA;AACxG,QAAA,MAAM,CAAC,MAAM,CAAC,aAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;KAC/E;AAED,IAAA,SAAS,CAA4B,aAAsB,EAAE,aAAgB,EAAE,GAAW,EAAA;AACxF,QAAA,MAAM,CAAC,MAAM,CAAC,aAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;KACnE;IAED,GAAG,CAA4B,aAAgB,EAAE,KAAsB,EAAA;AACrE,QAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;KAC1E;AA1BU,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,kBAGE,aAAa,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;AAHlC,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cADN,MAAM,EAAA,CAAA,CAAA,EAAA;;4FACnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAInB,QAAQ;;0BAAI,MAAM;2BAAC,aAAa,CAAA;;;ACX/C;;AAEG;;;;"}
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 { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nimport {\n YunzaiCellConfig,\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 { YunzaiThemePipeConfig } from './theme/pipe.type';\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 cell?: YunzaiCellConfig;\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 themePipe?: YunzaiThemePipeConfig;\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\nexport function provideYunzaiConfig(config: YunzaiConfig): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: YUNZAI_CONFIG, useValue: config }]);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { 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;;MC2DY,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,CAAC;AAEK,SAAU,mBAAmB,CAAC,MAAoB,EAAA;AACtD,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAClF;;ACnFA;MASa,mBAAmB,CAAA;AAG9B,IAAA,WAAA,CAA+C,aAA4B,EAAA;AACzE,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,aAAa,EAAE,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,K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A,EAAA,CAAA;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;;0BAInB,QAAQ;;0BAAI,MAAM;2BAAC,aAAa,CAAA;;;ACZ/C;;AAEG;;;;"}
@@ -58,19 +58,16 @@ function fixEndTimeOfRange(dates) {
58
58
  return [startOfDay(dates[0]), endOfDay(dates[1])];
59
59
  }
60
60
  /**
61
- * Return the date parsed from string using the given format string
62
- * - If the argument is a number, it is treated as a timestamp.
61
+ * Convert to `Date` format
63
62
  *
64
- * @param formatString If parsing fails try to parse the date by pressing `formatString`
65
- * @param defaultValue If parsing fails returned default value, default: `new Date(NaN)`
63
+ * @param value When is a number, it's treated as a timestamp; If it's seconds, you need to provide the `options.timestampSecond` parameter.
66
64
  */
67
65
  function toDate(value, options) {
68
- if (typeof options === 'string')
69
- options = { formatString: options };
70
- const { formatString, defaultValue } = {
66
+ const { formatString, defaultValue, timestampSecond } = {
71
67
  formatString: 'yyyy-MM-dd HH:mm:ss',
72
68
  defaultValue: new Date(NaN),
73
- ...options
69
+ timestampSecond: false,
70
+ ...(typeof options === 'string' ? { formatString: options } : options)
74
71
  };
75
72
  if (value == null) {
76
73
  return defaultValue;
@@ -78,8 +75,9 @@ function toDate(value, options) {
78
75
  if (value instanceof Date) {
79
76
  return value;
80
77
  }
81
- if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {
82
- return new Date(+value);
78
+ if (typeof value === 'number' || (typeof value === 'string' && /^[0-9]+$/.test(value))) {
79
+ const valueNumber = +value;
80
+ return new Date(timestampSecond ? valueNumber * 1000 : valueNumber);
83
81
  }
84
82
  let tryDate = parseISO(value);
85
83
  if (isNaN(tryDate)) {
@@ -87,6 +85,13 @@ function toDate(value, options) {
87
85
  }
88
86
  return isNaN(tryDate) ? defaultValue : tryDate;
89
87
  }
88
+ /**
89
+ * Format date, supports `Date, number, string` types
90
+ *
91
+ * @param value When is a number, it is treated as a timestamp (Support seconds and milliseconds timestamp).
92
+ * @param formatString Please refer to [date-fnd format](https://date-fns.org/v2.30.0/docs/format) for string format
93
+ * @param dateLocale Recommended to be consistent with NG-ZORRO by using `inject(NZ_DATE_LOCALE)`
94
+ */
90
95
  function formatDate(value, formatString, dateLocale) {
91
96
  value = toDate(value);
92
97
  if (isNaN(value))
@@ -1 +1 @@
1
- {"version":3,"file":"date-time.mjs","sources":["../../../../packages/util/date-time/time.ts","../../../../packages/util/date-time/picker.ts","../../../../packages/util/date-time/date-time.ts"],"sourcesContent":["import {\n addDays,\n endOfDay,\n endOfMonth,\n endOfWeek,\n endOfYear,\n parse,\n parseISO,\n startOfDay,\n startOfMonth,\n startOfWeek,\n startOfYear,\n subMonths,\n subWeeks,\n subYears,\n format,\n formatDistanceToNow\n} from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport type { DateLocale } from 'ng-zorro-antd/i18n';\n\n/**\n * Get the time range, return `[ Date, Date]` for the start and end dates\n *\n * 获取时间范围\n *\n * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数\n * @param time 开始时间\n * @param ignoreMaxTime 忽略追加结束日期的最大时间值\n */\nexport function getTimeDistance(\n type: 'today' | '-today' | 'yesterday' | 'week' | '-week' | 'month' | '-month' | 'year' | '-year' | number,\n time?: Date | string | number,\n options?: { ignoreMaxTime?: boolean }\n): [Date, Date] {\n time = time\n ? typeof time === 'string'\n ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())\n : new Date(time)\n : new Date();\n const opt: { weekStartsOn: 1 } = { weekStartsOn: 1 };\n\n let res: [Date, Date];\n switch (type) {\n case 'today':\n res = [time, time];\n break;\n case '-today':\n res = [addDays(time, -1), time];\n break;\n case 'yesterday':\n res = [addDays(time, -1), addDays(time, -1)];\n break;\n case 'week':\n res = [startOfWeek(time, opt), endOfWeek(time, opt)];\n break;\n case '-week':\n res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];\n break;\n case 'month':\n res = [startOfMonth(time), endOfMonth(time)];\n break;\n case '-month':\n res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];\n break;\n case 'year':\n res = [startOfYear(time), endOfYear(time)];\n break;\n case '-year':\n res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];\n break;\n default:\n res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];\n break;\n }\n return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);\n}\n\n/**\n * fix time is the most, big value\n */\nexport function fixEndTimeOfRange(dates: [Date, Date]): [Date, Date] {\n return [startOfDay(dates[0]), endOfDay(dates[1])];\n}\n\nexport type ToDateOptions = string | { formatString?: string; defaultValue?: NzSafeAny };\n\n/**\n * Return the date parsed from string using the given format string\n * - If the argument is a number, it is treated as a timestamp.\n *\n * @param formatString If parsing fails try to parse the date by pressing `formatString`\n * @param defaultValue If parsing fails returned default value, default: `new Date(NaN)`\n */\nexport function toDate(value?: Date | string | number | null, options?: ToDateOptions): Date {\n if (typeof options === 'string') options = { formatString: options };\n const { formatString, defaultValue } = {\n formatString: 'yyyy-MM-dd HH:mm:ss',\n defaultValue: new Date(NaN),\n ...options\n };\n if (value == null) {\n return defaultValue;\n }\n if (value instanceof Date) {\n return value;\n }\n if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {\n return new Date(+value);\n }\n let tryDate = parseISO(value);\n if (isNaN(tryDate as NzSafeAny)) {\n tryDate = parse(value, formatString!, new Date());\n }\n\n return isNaN(tryDate as NzSafeAny) ? defaultValue : tryDate;\n}\n\nexport function formatDate(value: Date | string | number, formatString: string, dateLocale?: DateLocale): string {\n value = toDate(value);\n if (isNaN(value as NzSafeAny)) return '';\n\n const langOpt = { locale: dateLocale };\n return formatString === 'fn' ? formatDistanceToNow(value, langOpt) : format(value, formatString, langOpt);\n}\n","import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport type { DisabledDateFn, DisabledTimeConfig, DisabledTimeFn } from 'ng-zorro-antd/date-picker';\n\n// TODO: timezone process\nexport class DateTimePickerUtil {\n /**\n * Current local time\n *\n * 当前本地时间\n */\n get now(): Date {\n return new Date();\n }\n /**\n * Current local date (not including time part)\n *\n * 当前本地日期(不包含时间部分)\n */\n get date(): Date {\n return this.removeTime(this.now);\n }\n /**\n * Remove the time part of the date\n *\n * 移除日期的时间部分\n */\n removeTime(d: Date): Date {\n return new Date(d.toDateString());\n }\n /**\n * Format date-time\n *\n * 格式化日期\n */\n format(d: number | Date, formatString: string = 'yyyy-MM-dd HH:mm:ss'): string {\n return format(d, formatString);\n }\n private genTick(count: number): number[] {\n return new Array(count).fill(0).map((_, idx) => idx);\n }\n /**\n * Calculate the number of days between two dates, `0` means the same day\n *\n * 计算两个日期相差天数,`0` 表示同一天\n */\n getDiffDays(dateLeft: Date | number, dateRight?: Date | number): number {\n return differenceInCalendarDays(\n dateLeft,\n typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date\n );\n }\n /**\n * Disabled Before date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledBeforeDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) < 0;\n }\n /**\n * Disabled After date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledAfterDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) > 0;\n }\n private baseDisabledTime(type: 'before' | 'after', offsetSeconds?: number): DisabledTimeFn {\n const tick24 = this.genTick(24);\n const tick60 = this.genTick(60);\n return (current): DisabledTimeConfig => {\n const cur = current as Date;\n if (cur == null) {\n return {} as NzSafeAny;\n }\n const now = addSeconds(this.now, offsetSeconds || 0);\n const nowHours = now.getHours();\n const nowMinutes = now.getMinutes();\n const curHours = cur.getHours();\n const isToday = this.getDiffDays(this.removeTime(cur)) === 0;\n return {\n nzDisabledHours: () => {\n if (!isToday) return [];\n return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);\n },\n nzDisabledMinutes: () => {\n if (isToday && curHours === nowHours) {\n return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);\n }\n return [];\n },\n nzDisabledSeconds: () => {\n if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {\n const nowSeconds = now.getSeconds();\n return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);\n }\n return [];\n }\n };\n };\n }\n /**\n * Disabled Before time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledBeforeTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('before', options?.offsetSeconds);\n }\n /**\n * Disabled After time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledAfterTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('after', options?.offsetSeconds);\n }\n}\n\nexport const dateTimePickerUtil = new DateTimePickerUtil();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAsBA;;;;;;;;AAQG;SACa,eAAe,CAC7B,IAA0G,EAC1G,IAA6B,EAC7B,OAAqC,EAAA;AAErC,IAAA,IAAI,GAAG,IAAI;AACT,UAAE,OAAO,IAAI,KAAK,QAAQ;cACtB,KAAK,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,IAAI,EAAE,CAAC;AAChD,cAAE,IAAI,IAAI,CAAC,IAAI,CAAC;AAClB,UAAE,IAAI,IAAI,EAAE,CAAC;AACf,IAAA,MAAM,GAAG,GAAwB,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;AAErD,IAAA,IAAI,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ACvF,qBAAA;AACD,oBAAA,OAAO,EAAE,CAAC;iBACX;aACF,CAAC;AACJ,SAAC,CAAC;KACH;AACD;;;;AAIG;AACH,IAAA,kBAAkB,CAAC,OAAoC,EAAA;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;KAChE;AACD;;;;AAIG;AACH,IAAA,iBAAiB,CAAC,OAAoC,EAAA;QACpD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;KAC/D;AACF,CAAA;AAEY,MAAA,kBAAkB,GAAG,IAAI,kBAAkB;;ACzHxD;;AAEG;;;;"}
1
+ {"version":3,"file":"date-time.mjs","sources":["../../../../packages/util/date-time/time.ts","../../../../packages/util/date-time/picker.ts","../../../../packages/util/date-time/date-time.ts"],"sourcesContent":["import {\n addDays,\n endOfDay,\n endOfMonth,\n endOfWeek,\n endOfYear,\n parse,\n parseISO,\n startOfDay,\n startOfMonth,\n startOfWeek,\n startOfYear,\n subMonths,\n subWeeks,\n subYears,\n format,\n formatDistanceToNow\n} from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport { DateLocale } from 'ng-zorro-antd/i18n';\n\n/**\n * Get the time range, return `[ Date, Date]` for the start and end dates\n *\n * 获取时间范围\n *\n * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数\n * @param time 开始时间\n * @param ignoreMaxTime 忽略追加结束日期的最大时间值\n */\nexport function getTimeDistance(\n type: 'today' | '-today' | 'yesterday' | 'week' | '-week' | 'month' | '-month' | 'year' | '-year' | number,\n time?: Date | string | number,\n options?: { ignoreMaxTime?: boolean }\n): [Date, Date] {\n time = time\n ? typeof time === 'string'\n ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())\n : new Date(time)\n : new Date();\n const opt: { weekStartsOn: 1 } = { weekStartsOn: 1 };\n\n let res: [Date, Date];\n switch (type) {\n case 'today':\n res = [time, time];\n break;\n case '-today':\n res = [addDays(time, -1), time];\n break;\n case 'yesterday':\n res = [addDays(time, -1), addDays(time, -1)];\n break;\n case 'week':\n res = [startOfWeek(time, opt), endOfWeek(time, opt)];\n break;\n case '-week':\n res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];\n break;\n case 'month':\n res = [startOfMonth(time), endOfMonth(time)];\n break;\n case '-month':\n res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];\n break;\n case 'year':\n res = [startOfYear(time), endOfYear(time)];\n break;\n case '-year':\n res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];\n break;\n default:\n res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];\n break;\n }\n return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);\n}\n\n/**\n * fix time is the most, big value\n */\nexport function fixEndTimeOfRange(dates: [Date, Date]): [Date, Date] {\n return [startOfDay(dates[0]), endOfDay(dates[1])];\n}\n\nexport interface ToDateOptions {\n /** If parsing fails try to parse the date by pressing `formatString` */\n formatString?: string;\n /** If parsing fails returned default value, default: `new Date(NaN)` */\n defaultValue?: NzSafeAny;\n timestampSecond?: boolean;\n}\n\n/**\n * Convert to `Date` format\n *\n * @param value When is a number, it's treated as a timestamp; If it's seconds, you need to provide the `options.timestampSecond` parameter.\n */\nexport function toDate(value?: Date | string | number | null, options?: string | ToDateOptions): Date {\n const { formatString, defaultValue, timestampSecond } = {\n formatString: 'yyyy-MM-dd HH:mm:ss',\n defaultValue: new Date(NaN),\n timestampSecond: false,\n ...(typeof options === 'string' ? { formatString: options } : options)\n };\n if (value == null) {\n return defaultValue;\n }\n if (value instanceof Date) {\n return value;\n }\n if (typeof value === 'number' || (typeof value === 'string' && /^[0-9]+$/.test(value))) {\n const valueNumber = +value;\n return new Date(timestampSecond ? valueNumber * 1000 : valueNumber);\n }\n let tryDate = parseISO(value);\n if (isNaN(tryDate as NzSafeAny)) {\n tryDate = parse(value, formatString!, new Date());\n }\n\n return isNaN(tryDate as NzSafeAny) ? defaultValue : tryDate;\n}\n\n/**\n * Format date, supports `Date, number, string` types\n *\n * @param value When is a number, it is treated as a timestamp (Support seconds and milliseconds timestamp).\n * @param formatString Please refer to [date-fnd format](https://date-fns.org/v2.30.0/docs/format) for string format\n * @param dateLocale Recommended to be consistent with NG-ZORRO by using `inject(NZ_DATE_LOCALE)`\n */\nexport function formatDate(value: Date | string | number, formatString: string, dateLocale?: DateLocale): string {\n value = toDate(value);\n if (isNaN(value as NzSafeAny)) return '';\n\n const langOpt = { locale: dateLocale };\n return formatString === 'fn' ? formatDistanceToNow(value, langOpt) : format(value, formatString, langOpt);\n}\n","import { addDays, addSeconds, differenceInCalendarDays, format } from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\nimport type { DisabledDateFn, DisabledTimeConfig, DisabledTimeFn } from 'ng-zorro-antd/date-picker';\n\n// TODO: timezone process\nexport class DateTimePickerUtil {\n /**\n * Current local time\n *\n * 当前本地时间\n */\n get now(): Date {\n return new Date();\n }\n /**\n * Current local date (not including time part)\n *\n * 当前本地日期(不包含时间部分)\n */\n get date(): Date {\n return this.removeTime(this.now);\n }\n /**\n * Remove the time part of the date\n *\n * 移除日期的时间部分\n */\n removeTime(d: Date): Date {\n return new Date(d.toDateString());\n }\n /**\n * Format date-time\n *\n * 格式化日期\n */\n format(d: number | Date, formatString: string = 'yyyy-MM-dd HH:mm:ss'): string {\n return format(d, formatString);\n }\n private genTick(count: number): number[] {\n return new Array(count).fill(0).map((_, idx) => idx);\n }\n /**\n * Calculate the number of days between two dates, `0` means the same day\n *\n * 计算两个日期相差天数,`0` 表示同一天\n */\n getDiffDays(dateLeft: Date | number, dateRight?: Date | number): number {\n return differenceInCalendarDays(\n dateLeft,\n typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date\n );\n }\n /**\n * Disabled Before date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledBeforeDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) < 0;\n }\n /**\n * Disabled After date (Default: today), Generally serves `nzDisabledDate`\n *\n * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`\n */\n disabledAfterDate(options?: { offsetDays?: Date | number }): DisabledDateFn {\n return (d): boolean => this.getDiffDays(d, options?.offsetDays) > 0;\n }\n private baseDisabledTime(type: 'before' | 'after', offsetSeconds?: number): DisabledTimeFn {\n const tick24 = this.genTick(24);\n const tick60 = this.genTick(60);\n return (current): DisabledTimeConfig => {\n const cur = current as Date;\n if (cur == null) {\n return {} as NzSafeAny;\n }\n const now = addSeconds(this.now, offsetSeconds || 0);\n const nowHours = now.getHours();\n const nowMinutes = now.getMinutes();\n const curHours = cur.getHours();\n const isToday = this.getDiffDays(this.removeTime(cur)) === 0;\n return {\n nzDisabledHours: () => {\n if (!isToday) return [];\n return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);\n },\n nzDisabledMinutes: () => {\n if (isToday && curHours === nowHours) {\n return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);\n }\n return [];\n },\n nzDisabledSeconds: () => {\n if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {\n const nowSeconds = now.getSeconds();\n return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);\n }\n return [];\n }\n };\n };\n }\n /**\n * Disabled Before time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledBeforeTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('before', options?.offsetSeconds);\n }\n /**\n * Disabled After time (Default: now), Generally serves `nzDisabledTime`\n *\n * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`\n */\n disabledAfterTime(options?: { offsetSeconds?: number }): DisabledTimeFn {\n return this.baseDisabledTime('after', options?.offsetSeconds);\n }\n}\n\nexport const dateTimePickerUtil = new DateTimePickerUtil();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAsBA;;;;;;;;AAQG;SACa,eAAe,CAC7B,IAA0G,EAC1G,IAA6B,EAC7B,OAAqC,EAAA;AAErC,IAAA,IAAI,GAAG,IAAI;AACT,UAAE,OAAO,IAAI,KAAK,QAAQ;cACtB,KAAK,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,IAAI,EAAE,CAAC;AAChD,cAAE,IAAI,IAAI,CAAC,IAAI,CAAC;AAClB,UAAE,IAAI,IAAI,EAAE,CAAC;AACf,IAAA,MAAM,GAAG,GAAwB,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;AAErD,IAAA,IAAI,GAAiB,CAAC;IACtB,QAAQ,IAAI;AACV,QAAA,KAAK,OAAO;AACV,YAAA,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACnB,MAAM;AACR,QAAA,KAAK,QAAQ;AACX,YAAA,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YAChC,MAAM;AACR,QAAA,KAAK,WAAW;AACd,YAAA,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,MAAM;AACR,QAAA,KAAK,MAAM;AACT,YAAA,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACrD,MAAM;AACR,QAAA,KAAK,OAAO;YACV,GAAG,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,SAAS,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,iBAAiB,EAAE,MAAK;AACtB,oBAAA,IAAI,OAAO,IAAI,QAAQ,KAAK,QAAQ,EAAE;wBACpC,OAAO,IAAI,KAAK,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;qBACvF;AACD,oBAAA,OAAO,EAAE,CAAC;iBACX;gBACD,iBAAiB,EAAE,MAAK;AACtB,oBAAA,IAAI,OAAO,IAAI,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,KAAK,UAAU,EAAE;AACvE,wBAAA,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;wBACpC,OAAO,IAAI,KAAK,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;qBACvF;AACD,oBAAA,OAAO,EAAE,CAAC;iBACX;aACF,CAAC;AACJ,SAAC,CAAC;KACH;AACD;;;;AAIG;AACH,IAAA,kBAAkB,CAAC,OAAoC,EAAA;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;KAChE;AACD;;;;AAIG;AACH,IAAA,iBAAiB,CAAC,OAAoC,EAAA;QACpD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;KAC/D;AACF,CAAA;AAEY,MAAA,kBAAkB,GAAG,IAAI,kBAAkB;;ACzHxD;;AAEG;;;;"}
@@ -32,6 +32,10 @@ function toBoolean(value, defaultValue = false) {
32
32
  return value == null ? defaultValue : `${value}` !== 'false';
33
33
  }
34
34
  /**
35
+ * @deprecated Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed
36
+ * - Use `@Input({ transform: booleanAttribute })` instead of `@InputBoolean()`
37
+ * - Use `@Input({ transform: (v: unknown) => (v == null ? null : booleanAttribute(v)) })` instead of `@InputBoolean(null)`
38
+ *
35
39
  * Input decorator that handle a prop to do get/set automatically with toBoolean
36
40
  *
37
41
  * ```ts
@@ -46,6 +50,10 @@ function toNumber(value, fallbackValue = 0) {
46
50
  return !isNaN(parseFloat(value)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;
47
51
  }
48
52
  /**
53
+ * @deprecated Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed
54
+ * - Use `@Input({ transform: numberAttribute })` instead of `@InputNumber()`
55
+ * - Use `@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) })` instead of `@InputNumber(null)`
56
+ *
49
57
  * Input decorator that handle a prop to do get/set automatically with toNumber
50
58
  *
51
59
  * ```ts
@@ -85,7 +93,7 @@ function makeFn(type, options) {
85
93
  *
86
94
  * ```ts
87
95
  * class MockClass {
88
- * constructor(public ngZone: NgZone) {}
96
+ * readonly ngZone = inject(NgZone);
89
97
  *
90
98
  * {AT}ZoneOutside()
91
99
  * runOutsideAngular(): void {}
@@ -102,7 +110,7 @@ function ZoneOutside(options) {
102
110
  *
103
111
  * ```ts
104
112
  * class MockClass {
105
- * constructor(public ngZone: NgZone) {}
113
+ * readonly ngZone = inject(NgZone);
106
114
  *
107
115
  * {AT}ZoneRun()
108
116
  * run(): void {}
@@ -1 +1 @@
1
- {"version":3,"file":"decorator.mjs","sources":["../../../../packages/util/decorator/convert.ts","../../../../packages/util/decorator/zone-outside.ts","../../../../packages/util/decorator/decorator.ts"],"sourcesContent":["import { warn } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport type BooleanInput = boolean | string | undefined | null;\nexport type NumberInput = number | string | undefined | null;\n\nfunction propDecoratorFactory<T, D>(\n name: string,\n fallback: (v: T, defaultValue: D) => D,\n defaultValue: NzSafeAny\n): (target: NzSafeAny, propName: string) => void {\n function propDecorator(\n target: NzSafeAny,\n propName: string,\n originalDescriptor?: TypedPropertyDescriptor<NzSafeAny>\n ): NzSafeAny {\n const privatePropName = `$$__${propName}`;\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {\n warn(`The prop \"${privatePropName}\" is already exist, it will be overrided by ${name} decorator.`);\n }\n }\n\n Object.defineProperty(target, privatePropName, {\n configurable: true,\n writable: true\n });\n\n return {\n get(): string {\n return originalDescriptor && originalDescriptor.get\n ? originalDescriptor.get.bind(this)()\n : this[privatePropName];\n },\n set(value: T): void {\n if (originalDescriptor && originalDescriptor.set) {\n originalDescriptor.set.bind(this)(fallback(value, defaultValue));\n }\n this[privatePropName] = fallback(value, defaultValue);\n }\n };\n }\n\n return propDecorator;\n}\n\nexport function toBoolean(\n value: unknown,\n defaultValue: boolean | null | undefined = false\n): boolean | null | undefined {\n return value == null ? defaultValue : `${value}` !== 'false';\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toBoolean\n *\n * ```ts\n * {AT}Input() {AT}InputBoolean() visible: boolean = false;\n * {AT}Input() {AT}InputBoolean(null) visible: boolean = false;\n * ```\n */\nexport function InputBoolean(defaultValue: boolean | null = false): NzSafeAny {\n return propDecoratorFactory('InputBoolean', toBoolean, defaultValue);\n}\n\nexport function toNumber(value: unknown): number;\nexport function toNumber<D>(value: unknown, fallback: D): number | D;\nexport function toNumber(value: unknown, fallbackValue: number = 0): number {\n return !isNaN(parseFloat(value as NzSafeAny)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * Input decorator that handle a prop to do get/set automatically with toNumber\n *\n * ```ts\n * {AT}Input() {AT}InputNumber() visible: number = 1;\n * {AT}Input() {AT}InputNumber(null) visible: number = 2;\n * ```\n */\nexport function InputNumber(defaultValue: number | null = 0): NzSafeAny {\n return propDecoratorFactory('InputNumber', toNumber, defaultValue);\n}\n","import { warn } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport interface ZoneOptions {\n ngZoneName?: string;\n}\n\ntype DecoratorType = (target: unknown, fn: string, descriptor: PropertyDescriptor) => PropertyDescriptor;\n\nfunction makeFn(type: 'runOutsideAngular' | 'run', options?: ZoneOptions): DecoratorType {\n return (_, __, descriptor) => {\n const source = descriptor.value;\n descriptor.value = function (...data: NzSafeAny[]): () => void {\n const that = this as NzSafeAny;\n const ngZone = that[options?.ngZoneName || 'ngZone'];\n if (!ngZone) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n warn(`ZoneOutside: Decorator should have 'ngZone' property with 'NgZone' class.`);\n }\n return source.call(this, ...data);\n }\n let res: NzSafeAny;\n ngZone[type](() => {\n res = source.call(this, ...data);\n });\n return res;\n };\n\n return descriptor;\n };\n}\n\n/**\n * The decoration method runs in `runOutsideAngular`\n *\n * 装饰方法运行在 `runOutsideAngular` 内\n *\n * ```ts\n * class MockClass {\n * constructor(public ngZone: NgZone) {}\n *\n * {AT}ZoneOutside()\n * runOutsideAngular(): void {}\n * }\n * ```\n */\nexport function ZoneOutside(options?: ZoneOptions): DecoratorType {\n return makeFn('runOutsideAngular', options);\n}\n\n/**\n * The decoration method runs in `run`\n *\n * 装饰方法运行在 `run` 内\n *\n * ```ts\n * class MockClass {\n * constructor(public ngZone: NgZone) {}\n *\n * {AT}ZoneRun()\n * run(): void {}\n * }\n * ```\n */\nexport function ZoneRun(options?: ZoneOptions): DecoratorType {\n return makeFn('run', options);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAMA,SAAS,oBAAoB,CAC3B,IAAY,EACZ,QAAsC,EACtC,YAAuB,EAAA;AAEvB,IAAA,SAAS,aAAa,CACpB,MAAiB,EACjB,QAAgB,EAChB,kBAAuD,EAAA;AAEvD,QAAA,MAAM,eAAe,GAAG,CAAO,IAAA,EAAA,QAAQ,EAAE,CAAC;AAE1C,QAAA,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,EAAE;AACjD,YAA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;AACJ,CAAC;AAED;;;;;;;;;;;;;AAaG;AACG,SAAU,WAAW,CAAC,OAAqB,EAAA;AAC/C,IAAA,OAAO,MAAM,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;;AAaG;AACG,SAAU,OAAO,CAAC,OAAqB,EAAA;AAC3C,IAAA,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAChC;;AClEA;;AAEG;;;;"}
1
+ {"version":3,"file":"decorator.mjs","sources":["../../../../packages/util/decorator/convert.ts","../../../../packages/util/decorator/zone-outside.ts","../../../../packages/util/decorator/decorator.ts"],"sourcesContent":["import { warn } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport type BooleanInput = boolean | string | undefined | null;\nexport type NumberInput = number | string | undefined | null;\n\nfunction propDecoratorFactory<T, D>(\n name: string,\n fallback: (v: T, defaultValue: D) => D,\n defaultValue: NzSafeAny\n): (target: NzSafeAny, propName: string) => void {\n function propDecorator(\n target: NzSafeAny,\n propName: string,\n originalDescriptor?: TypedPropertyDescriptor<NzSafeAny>\n ): NzSafeAny {\n const privatePropName = `$$__${propName}`;\n\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {\n warn(`The prop \"${privatePropName}\" is already exist, it will be overrided by ${name} decorator.`);\n }\n }\n\n Object.defineProperty(target, privatePropName, {\n configurable: true,\n writable: true\n });\n\n return {\n get(): string {\n return originalDescriptor && originalDescriptor.get\n ? originalDescriptor.get.bind(this)()\n : this[privatePropName];\n },\n set(value: T): void {\n if (originalDescriptor && originalDescriptor.set) {\n originalDescriptor.set.bind(this)(fallback(value, defaultValue));\n }\n this[privatePropName] = fallback(value, defaultValue);\n }\n };\n }\n\n return propDecorator;\n}\n\nexport function toBoolean(\n value: unknown,\n defaultValue: boolean | null | undefined = false\n): boolean | null | undefined {\n return value == null ? defaultValue : `${value}` !== 'false';\n}\n\n/**\n * @deprecated Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed\n * - Use `@Input({ transform: booleanAttribute })` instead of `@InputBoolean()`\n * - Use `@Input({ transform: (v: unknown) => (v == null ? null : booleanAttribute(v)) })` instead of `@InputBoolean(null)`\n *\n * Input decorator that handle a prop to do get/set automatically with toBoolean\n *\n * ```ts\n * {AT}Input() {AT}InputBoolean() visible: boolean = false;\n * {AT}Input() {AT}InputBoolean(null) visible: boolean = false;\n * ```\n */\nexport function InputBoolean(defaultValue: boolean | null = false): NzSafeAny {\n return propDecoratorFactory('InputBoolean', toBoolean, defaultValue);\n}\n\nexport function toNumber(value: unknown): number;\nexport function toNumber<D>(value: unknown, fallback: D): number | D;\nexport function toNumber(value: unknown, fallbackValue: number = 0): number {\n return !isNaN(parseFloat(value as NzSafeAny)) && !isNaN(Number(value)) ? Number(value) : fallbackValue;\n}\n\n/**\n * @deprecated Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed\n * - Use `@Input({ transform: numberAttribute })` instead of `@InputNumber()`\n * - Use `@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) })` instead of `@InputNumber(null)`\n *\n * Input decorator that handle a prop to do get/set automatically with toNumber\n *\n * ```ts\n * {AT}Input() {AT}InputNumber() visible: number = 1;\n * {AT}Input() {AT}InputNumber(null) visible: number = 2;\n * ```\n */\nexport function InputNumber(defaultValue: number | null = 0): NzSafeAny {\n return propDecoratorFactory('InputNumber', toNumber, defaultValue);\n}\n","import { warn } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nexport interface ZoneOptions {\n ngZoneName?: string;\n}\n\ntype DecoratorType = (target: unknown, fn: string, descriptor: PropertyDescriptor) => PropertyDescriptor;\n\nfunction makeFn(type: 'runOutsideAngular' | 'run', options?: ZoneOptions): DecoratorType {\n return (_, __, descriptor) => {\n const source = descriptor.value;\n descriptor.value = function (...data: NzSafeAny[]): () => void {\n const that = this as NzSafeAny;\n const ngZone = that[options?.ngZoneName || 'ngZone'];\n if (!ngZone) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n warn(`ZoneOutside: Decorator should have 'ngZone' property with 'NgZone' class.`);\n }\n return source.call(this, ...data);\n }\n let res: NzSafeAny;\n ngZone[type](() => {\n res = source.call(this, ...data);\n });\n return res;\n };\n\n return descriptor;\n };\n}\n\n/**\n * The decoration method runs in `runOutsideAngular`\n *\n * 装饰方法运行在 `runOutsideAngular` 内\n *\n * ```ts\n * class MockClass {\n * readonly ngZone = inject(NgZone);\n *\n * {AT}ZoneOutside()\n * runOutsideAngular(): void {}\n * }\n * ```\n */\nexport function ZoneOutside(options?: ZoneOptions): DecoratorType {\n return makeFn('runOutsideAngular', options);\n}\n\n/**\n * The decoration method runs in `run`\n *\n * 装饰方法运行在 `run` 内\n *\n * ```ts\n * class MockClass {\n * readonly ngZone = inject(NgZone);\n *\n * {AT}ZoneRun()\n * run(): void {}\n * }\n * ```\n */\nexport function ZoneRun(options?: ZoneOptions): DecoratorType {\n return makeFn('run', options);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAMA,SAAS,oBAAoB,CAC3B,IAAY,EACZ,QAAsC,EACtC,YAAuB,EAAA;AAEvB,IAAA,SAAS,aAAa,CACpB,MAAiB,EACjB,QAAgB,EAChB,kBAAuD,EAAA;AAEvD,QAAA,MAAM,eAAe,GAAG,CAAO,IAAA,EAAA,QAAQ,EAAE,CAAC;AAE1C,QAAA,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,EAAE;AACjD,YAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE;AACjE,gBAAA,IAAI,CAAC,CAAa,UAAA,EAAA,eAAe,+CAA+C,IAAI,CAAA,WAAA,CAAa,CAAC,CAAC;aACpG;SACF;AAED,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EA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,OAAO,CAAC,CAAC;AAChC;;AClEA;;AAEG;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"form.mjs","sources":["../../../../packages/util/form/validators.ts","../../../../packages/util/form/match-control.ts","../../../../packages/util/form/form.ts"],"sourcesContent":["import { AbstractControl, ValidationErrors } from '@angular/forms';\n\nimport { isChinese, isColor, isDecimal, isIdCard, isInt, isIp, isMobile, isNum, isUrl } from '@yelon/util/format';\n\n/**\n * A set of validators for reactive forms\n *\n * 一套用于响应式表单的验证器\n */\nexport class _Validators {\n /**\n * Wheter is number\n *\n * 是否为数字\n */\n static num(control: AbstractControl): ValidationErrors | null {\n return isNum(control.value) ? null : { num: true };\n }\n\n /**\n * Wheter is integer\n *\n * 是否为整数\n */\n static int(control: AbstractControl): ValidationErrors | null {\n return isInt(control.value) ? null : { int: true };\n }\n\n /**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\n static decimal(control: AbstractControl): ValidationErrors | null {\n return isDecimal(control.value) ? null : { decimal: true };\n }\n\n /**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\n static idCard(control: AbstractControl): ValidationErrors | null {\n return isIdCard(control.value) ? null : { idCard: true };\n }\n\n /**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\n static mobile(control: AbstractControl): ValidationErrors | null {\n return isMobile(control.value) ? null : { mobile: true };\n }\n\n /**\n * Wheter is url address\n *\n * 是否URL地址\n */\n static url(control: AbstractControl): ValidationErrors | null {\n return isUrl(control.value) ? null : { url: true };\n }\n\n /**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\n static ip(control: AbstractControl): ValidationErrors | null {\n return isIp(control.value) ? null : { ip: true };\n }\n\n /**\n * Wheter is color\n *\n * 是否颜色代码值\n */\n static color(control: AbstractControl): ValidationErrors | null {\n return isColor(control.value) ? null : { color: true };\n }\n\n /**\n * Wheter is chinese\n *\n * 是否中文\n */\n static chinese(control: AbstractControl): ValidationErrors | null {\n return isChinese(control.value) ? null : { chinese: true };\n }\n}\n","import { AbstractControl, ValidatorFn } from '@angular/forms';\n\n/**\n * Match two control values\n *\n * 匹配两个控件值\n * ```ts\n * this.form = new FormGroup({\n * pwd: new FormControl(''),\n * repwd: new FormControl(''),\n * }, {\n * validators: MatchControl('pwd', 'repwd'),\n * });\n * ```\n */\nexport function MatchControl(controlName: string, matchingControlName: string): ValidatorFn {\n return (formGroup: AbstractControl) => {\n const control = formGroup.get(controlName)!;\n const matchingControl = formGroup.get(matchingControlName)!;\n if (matchingControl.errors && !matchingControl.errors.matchControl) {\n return null;\n }\n if (control.value !== matchingControl.value) {\n matchingControl.setErrors({ matchControl: true });\n } else {\n matchingControl.setErrors(null);\n }\n return null;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAIA;;;;AAIG;MACU,WAAW,CAAA;AACtB;;;;AAIG;IACH,OAAO,GAAG,CAAC,OAAwB,EAAA;AACjC,QAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;KACpD;AAED;;;;AAIG;IACH,OAAO,GAAG,CAAC,OAAwB,EAAA;AACjC,QAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;KACpD;AAED;;;;AAIG;IACH,OAAO,OAAO,CAAC,OAAwB,EAAA;AACrC,QAAA,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC5D;AAED;;;;AAIG;IACH,OAAO,MAAM,CAAC,OAAwB,EAAA;AACpC,QAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KAC1D;A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,KAAK,eAAe,CAAC,KAAK,EAAE;YAC3C,eAAe,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;AACnD,SAAA;AAAM,aAAA;AACL,YAAA,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACjC,SAAA;AACD,QAAA,OAAO,IAAI,CAAC;AACd,KAAC,CAAC;AACJ;;AC7BA;;AAEG;;;;"}
1
+ {"version":3,"file":"form.mjs","sources":["../../../../packages/util/form/validators.ts","../../../../packages/util/form/match-control.ts","../../../../packages/util/form/form.ts"],"sourcesContent":["import { AbstractControl, ValidationErrors } from '@angular/forms';\n\nimport { isChinese, isColor, isDecimal, isIdCard, isInt, isIp, isMobile, isNum, isUrl } from '@yelon/util/format';\n\n/**\n * A set of validators for reactive forms\n *\n * 一套用于响应式表单的验证器\n */\nexport class _Validators {\n /**\n * Wheter is number\n *\n * 是否为数字\n */\n static num(control: AbstractControl): ValidationErrors | null {\n return isNum(control.value) ? null : { num: true };\n }\n\n /**\n * Wheter is integer\n *\n * 是否为整数\n */\n static int(control: AbstractControl): ValidationErrors | null {\n return isInt(control.value) ? null : { int: true };\n }\n\n /**\n * Wheter is decimal\n *\n * 是否为小数点数值\n */\n static decimal(control: AbstractControl): ValidationErrors | null {\n return isDecimal(control.value) ? null : { decimal: true };\n }\n\n /**\n * Wheter is People's Republic of China identity card\n *\n * 是否为中华人民共和国居民身份证\n */\n static idCard(control: AbstractControl): ValidationErrors | null {\n return isIdCard(control.value) ? null : { idCard: true };\n }\n\n /**\n * Wheter is china mobile (China)\n *\n * 是否为手机号(中国)\n */\n static mobile(control: AbstractControl): ValidationErrors | null {\n return isMobile(control.value) ? null : { mobile: true };\n }\n\n /**\n * Wheter is url address\n *\n * 是否URL地址\n */\n static url(control: AbstractControl): ValidationErrors | null {\n return isUrl(control.value) ? null : { url: true };\n }\n\n /**\n * Wheter is IPv4 address (Support v4, v6)\n *\n * 是否IP4地址(支持v4、v6)\n */\n static ip(control: AbstractControl): ValidationErrors | null {\n return isIp(control.value) ? null : { ip: true };\n }\n\n /**\n * Wheter is color\n *\n * 是否颜色代码值\n */\n static color(control: AbstractControl): ValidationErrors | null {\n return isColor(control.value) ? null : { color: true };\n }\n\n /**\n * Wheter is chinese\n *\n * 是否中文\n */\n static chinese(control: AbstractControl): ValidationErrors | null {\n return isChinese(control.value) ? null : { chinese: true };\n }\n}\n","import { AbstractControl, ValidatorFn } from '@angular/forms';\n\n/**\n * Match two control values\n *\n * 匹配两个控件值\n * ```ts\n * this.form = new FormGroup({\n * pwd: new FormControl(''),\n * repwd: new FormControl(''),\n * }, {\n * validators: MatchControl('pwd', 'repwd'),\n * });\n * ```\n */\nexport function MatchControl(controlName: string, matchingControlName: string): ValidatorFn {\n return (formGroup: AbstractControl) => {\n const control = formGroup.get(controlName)!;\n const matchingControl = formGroup.get(matchingControlName)!;\n if (matchingControl.errors && !matchingControl.errors.matchControl) {\n return null;\n }\n if (control.value !== matchingControl.value) {\n matchingControl.setErrors({ matchControl: true });\n } else {\n matchingControl.setErrors(null);\n }\n return null;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAIA;;;;AAIG;MACU,WAAW,CAAA;AACtB;;;;AAIG;IACH,OAAO,GAAG,CAAC,OAAwB,EAAA;AACjC,QAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;KACpD;AAED;;;;AAIG;IACH,OAAO,GAAG,CAAC,OAAwB,EAAA;AACjC,QAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;KACpD;AAED;;;;AAIG;IACH,OAAO,OAAO,CAAC,OAAwB,EAAA;AACrC,QAAA,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAA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