@yelon/util 16.2.5 → 16.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/analysis/global-event.subject.d.ts +7 -7
  4. package/analysis/index.d.ts +1 -1
  5. package/array/array-type.service.d.ts +68 -68
  6. package/array/array.service.d.ts +78 -78
  7. package/array/index.d.ts +2 -2
  8. package/browser/cookie.service.d.ts +67 -67
  9. package/browser/copy.d.ts +6 -6
  10. package/browser/index.d.ts +5 -5
  11. package/browser/is-empty.d.ts +6 -6
  12. package/browser/scroll.service.d.ts +37 -37
  13. package/browser/style.d.ts +21 -21
  14. package/config/abc/cell.type.d.ts +118 -0
  15. package/config/abc/date-picker.type.d.ts +52 -52
  16. package/config/abc/error-collect.type.d.ts +10 -10
  17. package/config/abc/exception.type.d.ts +9 -9
  18. package/config/abc/image.type.d.ts +15 -15
  19. package/config/abc/index.d.ts +18 -17
  20. package/config/abc/loading.type.d.ts +31 -31
  21. package/config/abc/lodop.type.d.ts +33 -33
  22. package/config/abc/media.type.d.ts +11 -11
  23. package/config/abc/onboarding.type.d.ts +4 -4
  24. package/config/abc/page-header.type.d.ts +39 -39
  25. package/config/abc/pdf.type.d.ts +35 -35
  26. package/config/abc/qr.type.d.ts +25 -25
  27. package/config/abc/se.type.d.ts +32 -32
  28. package/config/abc/sg.type.d.ts +10 -10
  29. package/config/abc/st.type.d.ts +465 -465
  30. package/config/abc/sv.type.d.ts +14 -14
  31. package/config/abc/xlsx.type.d.ts +12 -12
  32. package/config/abc/zip.type.d.ts +10 -10
  33. package/config/acl/acl.type.d.ts +32 -32
  34. package/config/auth/auth.type.d.ts +55 -55
  35. package/config/bis/bis.type.d.ts +11 -11
  36. package/config/cache/cache.type.d.ts +40 -40
  37. package/config/chart/chart.type.d.ts +33 -33
  38. package/config/config.service.d.ts +13 -13
  39. package/config/config.types.d.ts +49 -48
  40. package/config/index.d.ts +14 -14
  41. package/config/mock/mock.type.d.ts +18 -18
  42. package/config/sf/sf.type.d.ts +133 -133
  43. package/config/socket/socket.type.d.ts +4 -4
  44. package/config/theme/http.type.d.ts +14 -14
  45. package/config/theme/i18n.type.d.ts +14 -14
  46. package/config/theme/index.d.ts +3 -3
  47. package/config/theme/responsive.type.d.ts +12 -12
  48. package/config/util/array.type.d.ts +22 -22
  49. package/config/util/currency.type.d.ts +39 -39
  50. package/date-time/index.d.ts +2 -2
  51. package/date-time/picker.d.ts +68 -68
  52. package/date-time/time.d.ts +31 -29
  53. package/decorator/convert.d.ts +24 -24
  54. package/decorator/index.d.ts +2 -2
  55. package/decorator/zone-outside.d.ts +35 -35
  56. package/esm2022/analysis/analysis.mjs +4 -4
  57. package/esm2022/analysis/global-event.subject.mjs +16 -16
  58. package/esm2022/analysis/index.mjs +1 -1
  59. package/esm2022/array/array-type.service.mjs +1 -1
  60. package/esm2022/array/array.mjs +4 -4
  61. package/esm2022/array/array.service.mjs +276 -276
  62. package/esm2022/array/index.mjs +2 -2
  63. package/esm2022/browser/browser.mjs +4 -4
  64. package/esm2022/browser/cookie.service.mjs +102 -102
  65. package/esm2022/browser/copy.mjs +27 -27
  66. package/esm2022/browser/index.mjs +5 -5
  67. package/esm2022/browser/is-empty.mjs +18 -18
  68. package/esm2022/browser/scroll.service.mjs +87 -87
  69. package/esm2022/browser/style.mjs +37 -37
  70. package/esm2022/config/abc/cell.type.mjs +2 -0
  71. package/esm2022/config/abc/date-picker.type.mjs +1 -1
  72. package/esm2022/config/abc/error-collect.type.mjs +1 -1
  73. package/esm2022/config/abc/exception.type.mjs +1 -1
  74. package/esm2022/config/abc/image.type.mjs +1 -1
  75. package/esm2022/config/abc/index.mjs +19 -18
  76. package/esm2022/config/abc/loading.type.mjs +1 -1
  77. package/esm2022/config/abc/lodop.type.mjs +1 -1
  78. package/esm2022/config/abc/media.type.mjs +1 -1
  79. package/esm2022/config/abc/onboarding.type.mjs +1 -1
  80. package/esm2022/config/abc/page-header.type.mjs +1 -1
  81. package/esm2022/config/abc/pdf.type.mjs +1 -1
  82. package/esm2022/config/abc/qr.type.mjs +1 -1
  83. package/esm2022/config/abc/se.type.mjs +1 -1
  84. package/esm2022/config/abc/sg.type.mjs +1 -1
  85. package/esm2022/config/abc/st.type.mjs +1 -1
  86. package/esm2022/config/abc/sv.type.mjs +2 -2
  87. package/esm2022/config/abc/xlsx.type.mjs +1 -1
  88. package/esm2022/config/abc/zip.type.mjs +1 -1
  89. package/esm2022/config/acl/acl.type.mjs +1 -1
  90. package/esm2022/config/auth/auth.type.mjs +1 -1
  91. package/esm2022/config/bis/bis.type.mjs +1 -1
  92. package/esm2022/config/cache/cache.type.mjs +1 -1
  93. package/esm2022/config/chart/chart.type.mjs +1 -1
  94. package/esm2022/config/config.mjs +4 -4
  95. package/esm2022/config/config.service.mjs +36 -36
  96. package/esm2022/config/config.types.mjs +9 -9
  97. package/esm2022/config/index.mjs +14 -14
  98. package/esm2022/config/mock/mock.type.mjs +1 -1
  99. package/esm2022/config/sf/sf.type.mjs +1 -1
  100. package/esm2022/config/socket/socket.type.mjs +1 -1
  101. package/esm2022/config/theme/http.type.mjs +1 -1
  102. package/esm2022/config/theme/i18n.type.mjs +1 -1
  103. package/esm2022/config/theme/index.mjs +3 -3
  104. package/esm2022/config/theme/responsive.type.mjs +1 -1
  105. package/esm2022/config/util/array.type.mjs +1 -1
  106. package/esm2022/config/util/currency.type.mjs +1 -1
  107. package/esm2022/date-time/date-time.mjs +4 -4
  108. package/esm2022/date-time/index.mjs +2 -2
  109. package/esm2022/date-time/picker.mjs +115 -115
  110. package/esm2022/date-time/time.mjs +96 -89
  111. package/esm2022/decorator/convert.mjs +57 -57
  112. package/esm2022/decorator/decorator.mjs +4 -4
  113. package/esm2022/decorator/index.mjs +2 -2
  114. package/esm2022/decorator/zone-outside.mjs +56 -56
  115. package/esm2022/form/form.mjs +4 -4
  116. package/esm2022/form/index.mjs +2 -2
  117. package/esm2022/form/match-control.mjs +29 -29
  118. package/esm2022/form/validators.mjs +80 -80
  119. package/esm2022/format/currency.service.mjs +237 -237
  120. package/esm2022/format/currency.types.mjs +8 -8
  121. package/esm2022/format/format.mjs +4 -4
  122. package/esm2022/format/index.mjs +4 -4
  123. package/esm2022/format/string.mjs +84 -84
  124. package/esm2022/format/validate.mjs +93 -93
  125. package/esm2022/index.mjs +14 -14
  126. package/esm2022/math/in-range.mjs +24 -24
  127. package/esm2022/math/index.mjs +2 -2
  128. package/esm2022/math/math.mjs +4 -4
  129. package/esm2022/math/round.mjs +52 -52
  130. package/esm2022/mcache/index.mjs +1 -1
  131. package/esm2022/mcache/localStorageUtils.mjs +58 -58
  132. package/esm2022/mcache/mcache.mjs +4 -4
  133. package/esm2022/mtypes/authority.type.mjs +1 -1
  134. package/esm2022/mtypes/header-menu.type.mjs +1 -1
  135. package/esm2022/mtypes/index.mjs +9 -9
  136. package/esm2022/mtypes/menu.type.mjs +1 -1
  137. package/esm2022/mtypes/mtypes.mjs +4 -4
  138. package/esm2022/mtypes/nav.types.mjs +6 -6
  139. package/esm2022/mtypes/page.mjs +41 -41
  140. package/esm2022/mtypes/project-info.types.mjs +1 -1
  141. package/esm2022/mtypes/response.mjs +1 -1
  142. package/esm2022/mtypes/role.type.mjs +1 -1
  143. package/esm2022/mtypes/user.types.mjs +1 -1
  144. package/esm2022/other/assert.mjs +66 -66
  145. package/esm2022/other/deep.mjs +77 -77
  146. package/esm2022/other/favicon.mjs +28 -28
  147. package/esm2022/other/index.mjs +7 -7
  148. package/esm2022/other/lazy.service.mjs +131 -131
  149. package/esm2022/other/logger.mjs +32 -32
  150. package/esm2022/other/other.mjs +4 -4
  151. package/esm2022/other/path-to-regexp.service.mjs +238 -238
  152. package/esm2022/other/resize.mjs +3 -3
  153. package/esm2022/pipes/currency/cny.pipe.mjs +22 -22
  154. package/esm2022/pipes/currency/index.mjs +4 -4
  155. package/esm2022/pipes/currency/mega.pipe.mjs +28 -28
  156. package/esm2022/pipes/currency/module.mjs +18 -18
  157. package/esm2022/pipes/currency/pipe-currency.mjs +4 -4
  158. package/esm2022/pipes/currency/price.pipe.mjs +26 -26
  159. package/esm2022/pipes/filter/filter.pipe.mjs +18 -18
  160. package/esm2022/pipes/filter/index.mjs +2 -2
  161. package/esm2022/pipes/filter/module.mjs +16 -16
  162. package/esm2022/pipes/filter/pipe-filter.mjs +4 -4
  163. package/esm2022/pipes/format/index.mjs +2 -2
  164. package/esm2022/pipes/format/mask.pipe.mjs +33 -33
  165. package/esm2022/pipes/format/module.mjs +16 -16
  166. package/esm2022/pipes/format/pipe-format.mjs +4 -4
  167. package/esm2022/pipes/index.mjs +3 -3
  168. package/esm2022/pipes/pipes.mjs +4 -4
  169. package/esm2022/token/index.mjs +2 -2
  170. package/esm2022/token/page-visibility.mjs +14 -14
  171. package/esm2022/token/token.mjs +4 -4
  172. package/esm2022/token/window.mjs +16 -16
  173. package/esm2022/yelon-util.mjs +4 -4
  174. package/fesm2022/analysis.mjs +24 -24
  175. package/fesm2022/array.mjs +284 -284
  176. package/fesm2022/browser.mjs +279 -279
  177. package/fesm2022/config.mjs +54 -54
  178. package/fesm2022/config.mjs.map +1 -1
  179. package/fesm2022/date-time.mjs +218 -211
  180. package/fesm2022/date-time.mjs.map +1 -1
  181. package/fesm2022/decorator.mjs +121 -121
  182. package/fesm2022/form.mjs +118 -118
  183. package/fesm2022/format.mjs +431 -431
  184. package/fesm2022/format.mjs.map +1 -1
  185. package/fesm2022/math.mjs +85 -85
  186. package/fesm2022/mcache.mjs +65 -65
  187. package/fesm2022/mtypes.mjs +55 -55
  188. package/fesm2022/other.mjs +586 -586
  189. package/fesm2022/pipe-currency.mjs +94 -94
  190. package/fesm2022/pipe-filter.mjs +40 -40
  191. package/fesm2022/pipe-format.mjs +55 -55
  192. package/fesm2022/pipes.mjs +8 -8
  193. package/fesm2022/token.mjs +37 -37
  194. package/fesm2022/yelon-util.mjs +19 -19
  195. package/form/index.d.ts +2 -2
  196. package/form/match-control.d.ts +15 -15
  197. package/form/validators.d.ts +62 -62
  198. package/format/currency.service.d.ts +37 -37
  199. package/format/currency.types.d.ts +82 -77
  200. package/format/index.d.ts +4 -4
  201. package/format/string.d.ts +44 -44
  202. package/format/validate.d.ts +72 -72
  203. package/index.d.ts +14 -14
  204. package/math/in-range.d.ts +14 -14
  205. package/math/index.d.ts +2 -2
  206. package/math/round.d.ts +33 -33
  207. package/mcache/index.d.ts +1 -1
  208. package/mcache/localStorageUtils.d.ts +18 -18
  209. package/mtypes/authority.type.d.ts +3 -3
  210. package/mtypes/header-menu.type.d.ts +12 -12
  211. package/mtypes/index.d.ts +9 -9
  212. package/mtypes/menu.type.d.ts +40 -40
  213. package/mtypes/nav.types.d.ts +27 -27
  214. package/mtypes/page.d.ts +46 -46
  215. package/mtypes/project-info.types.d.ts +21 -21
  216. package/mtypes/response.d.ts +7 -7
  217. package/mtypes/role.type.d.ts +10 -10
  218. package/mtypes/user.types.d.ts +22 -22
  219. package/other/assert.d.ts +36 -36
  220. package/other/deep.d.ts +35 -35
  221. package/other/favicon.d.ts +2 -2
  222. package/other/index.d.ts +7 -7
  223. package/other/lazy.service.d.ts +48 -48
  224. package/other/logger.d.ts +5 -5
  225. package/other/path-to-regexp.service.d.ts +26 -26
  226. package/other/resize.d.ts +1 -1
  227. package/package.json +141 -141
  228. package/pipes/currency/cny.pipe.d.ts +15 -15
  229. package/pipes/currency/index.d.ts +4 -4
  230. package/pipes/currency/mega.pipe.d.ts +16 -16
  231. package/pipes/currency/module.d.ts +9 -9
  232. package/pipes/currency/price.pipe.d.ts +19 -19
  233. package/pipes/filter/filter.pipe.d.ts +13 -13
  234. package/pipes/filter/index.d.ts +2 -2
  235. package/pipes/filter/module.d.ts +7 -7
  236. package/pipes/format/index.d.ts +2 -2
  237. package/pipes/format/mask.pipe.d.ts +27 -27
  238. package/pipes/format/module.d.ts +7 -7
  239. package/pipes/index.d.ts +3 -3
  240. package/token/index.d.ts +2 -2
  241. package/token/page-visibility.d.ts +8 -8
  242. package/token/window.d.ts +7 -7
@@ -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} from './abc/index';\nimport { YunzaiACLConfig } from './acl/acl.type';\nimport { YunzaiAuthConfig } from './auth/auth.type';\nimport { YunzaiBusinessConfig } from './bis/bis.type';\nimport { YunzaiCacheConfig } from './cache/cache.type';\nimport { YunzaiChartConfig } from './chart/chart.type';\nimport { YunzaiMockConfig } from './mock/mock.type';\nimport { YunzaiSFConfig } from './sf/sf.type';\nimport { YunzaiSocketConfig } from './socket/socket.type';\nimport { YunzaiThemeHttpClientConfig, YunzaiThemeResponsiveConfig, YunzaiThemeI18nConfig } from './theme/index';\nimport { YunzaiUtilArrayConfig } from './util/array.type';\nimport { YunzaiUtilCurrencyConfig } from './util/currency.type';\n\nexport interface YunzaiConfig {\n bis?: YunzaiBusinessConfig;\n socket?: YunzaiSocketConfig;\n dataRange?: YunzaiDateRangePickerConfig;\n exception?: YunzaiExceptionType;\n errorCollect?: YunzaiErrorCollectConfig;\n image?: YunzaiImageConfig;\n loading?: YunzaiLoadingConfig;\n onboarding?: YunzaiOnboardingConfig;\n lodop?: YunzaiLodopConfig;\n pageHeader?: YunzaiPageHeaderConfig;\n qr?: YunzaiQRConfig;\n se?: YunzaiSEConfig;\n sg?: YunzaiSGConfig;\n sv?: YunzaiSVConfig;\n st?: YunzaiSTConfig;\n sf?: YunzaiSFConfig;\n xlsx?: YunzaiXlsxConfig;\n zip?: YunzaiZipConfig;\n pdf?: YunzaiPdfConfig;\n media?: YunzaiMediaConfig;\n acl?: YunzaiACLConfig;\n auth?: YunzaiAuthConfig;\n cache?: YunzaiCacheConfig;\n chart?: YunzaiChartConfig;\n mock?: YunzaiMockConfig;\n utilArray?: YunzaiUtilArrayConfig;\n utilCurrency?: YunzaiUtilCurrencyConfig;\n themeHttp?: YunzaiThemeHttpClientConfig;\n themeResponsive?: YunzaiThemeResponsiveConfig;\n themeI18n?: YunzaiThemeI18nConfig;\n}\n\nexport type YunzaiConfigKey = keyof YunzaiConfig;\n\nexport const YUNZAI_CONFIG = new InjectionToken<YunzaiConfig>('yunzai-config', {\n providedIn: 'root',\n factory: YUNZAI_CONFIG_FACTORY\n});\n\nexport function YUNZAI_CONFIG_FACTORY(): YunzaiConfig {\n return {};\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport { deepMergeKey } from '@yelon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\nimport { YunzaiConfig, YunzaiConfigKey, YUNZAI_CONFIG } from './config.types';\n\n@Injectable({ providedIn: 'root' })\nexport class YunzaiConfigService {\n private config: YunzaiConfig;\n\n constructor(@Optional() @Inject(YUNZAI_CONFIG) defaultConfig?: YunzaiConfig) {\n this.config = { ...defaultConfig };\n }\n\n get<T extends YunzaiConfigKey>(componentName: T, key?: string): YunzaiConfig[T] {\n const res = ((this.config[componentName] as { [key: string]: unknown }) || {}) as NzSafeAny;\n return key ? { [key]: res[key] } : res;\n }\n\n merge<T extends YunzaiConfigKey>(componentName: T, ...defaultValues: Array<YunzaiConfig[T]>): YunzaiConfig[T] {\n return deepMergeKey({}, true, ...defaultValues, this.get(componentName));\n }\n\n attach<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, defaultValues: YunzaiConfig[T]): void {\n Object.assign(componentThis as any, this.merge(componentName, defaultValues));\n }\n\n attachKey<T extends YunzaiConfigKey>(componentThis: unknown, componentName: T, key: string): void {\n Object.assign(componentThis as any, this.get(componentName, key));\n }\n\n set<T extends YunzaiConfigKey>(componentName: T, value: YunzaiConfig[T]): void {\n this.config[componentName] = { ...this.config[componentName], ...value };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAAa,cAAc,CAAA;AAa1B;;MCuDY,aAAa,GAAG,IAAI,cAAc,CAAe,eAAe,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,qBAAqB;AAC/B,CAAA,EAAE;SAEa,qBAAqB,GAAA;AACnC,IAAA,OAAO,EAAE,CAAC;AACZ;;MCnEa,mBAAmB,CAAA;AAG9B,IAAA,WAAA,CAA+C,aAA4B,EAAA;AACzE,QAAA,IAAI,CAAC,MAAM,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,C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+ {"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,G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M;2BAAC,aAAa,CAAA;;;ACX/C;;AAEG;;;;"}
@@ -1,211 +1,218 @@
1
- import { parse, addDays, startOfYear, subYears, endOfYear, startOfMonth, subMonths, endOfMonth, startOfWeek, subWeeks, endOfWeek, startOfDay, endOfDay, parseISO, format, differenceInCalendarDays, addSeconds } from 'date-fns';
2
-
3
- /**
4
- * Get the time range, return `[ Date, Date]` for the start and end dates
5
- *
6
- * 获取时间范围
7
- *
8
- * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数
9
- * @param time 开始时间
10
- * @param ignoreMaxTime 忽略追加结束日期的最大时间值
11
- */
12
- function getTimeDistance(type, time, options) {
13
- time = time
14
- ? typeof time === 'string'
15
- ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())
16
- : new Date(time)
17
- : new Date();
18
- const opt = { weekStartsOn: 1 };
19
- let res;
20
- switch (type) {
21
- case 'today':
22
- res = [time, time];
23
- break;
24
- case '-today':
25
- res = [addDays(time, -1), time];
26
- break;
27
- case 'yesterday':
28
- res = [addDays(time, -1), addDays(time, -1)];
29
- break;
30
- case 'week':
31
- res = [startOfWeek(time, opt), endOfWeek(time, opt)];
32
- break;
33
- case '-week':
34
- res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];
35
- break;
36
- case 'month':
37
- res = [startOfMonth(time), endOfMonth(time)];
38
- break;
39
- case '-month':
40
- res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];
41
- break;
42
- case 'year':
43
- res = [startOfYear(time), endOfYear(time)];
44
- break;
45
- case '-year':
46
- res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];
47
- break;
48
- default:
49
- res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];
50
- break;
51
- }
52
- return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);
53
- }
54
- /**
55
- * fix time is the most, big value
56
- */
57
- function fixEndTimeOfRange(dates) {
58
- return [startOfDay(dates[0]), endOfDay(dates[1])];
59
- }
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.
63
- *
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)`
66
- */
67
- function toDate(value, options) {
68
- if (typeof options === 'string')
69
- options = { formatString: options };
70
- const { formatString, defaultValue } = {
71
- formatString: 'yyyy-MM-dd HH:mm:ss',
72
- defaultValue: new Date(NaN),
73
- ...options
74
- };
75
- if (value == null) {
76
- return defaultValue;
77
- }
78
- if (value instanceof Date) {
79
- return value;
80
- }
81
- if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {
82
- return new Date(+value);
83
- }
84
- let tryDate = parseISO(value);
85
- if (isNaN(tryDate)) {
86
- tryDate = parse(value, formatString, new Date());
87
- }
88
- return isNaN(tryDate) ? defaultValue : tryDate;
89
- }
90
-
91
- // TODO: timezone process
92
- class DateTimePickerUtil {
93
- /**
94
- * Current local time
95
- *
96
- * 当前本地时间
97
- */
98
- get now() {
99
- return new Date();
100
- }
101
- /**
102
- * Current local date (not including time part)
103
- *
104
- * 当前本地日期(不包含时间部分)
105
- */
106
- get date() {
107
- return this.removeTime(this.now);
108
- }
109
- /**
110
- * Remove the time part of the date
111
- *
112
- * 移除日期的时间部分
113
- */
114
- removeTime(d) {
115
- return new Date(d.toDateString());
116
- }
117
- /**
118
- * Format date-time
119
- *
120
- * 格式化日期
121
- */
122
- format(d, formatString = 'yyyy-MM-dd HH:mm:ss') {
123
- return format(d, formatString);
124
- }
125
- genTick(count) {
126
- return new Array(count).fill(0).map((_, idx) => idx);
127
- }
128
- /**
129
- * Calculate the number of days between two dates, `0` means the same day
130
- *
131
- * 计算两个日期相差天数,`0` 表示同一天
132
- */
133
- getDiffDays(dateLeft, dateRight) {
134
- return differenceInCalendarDays(dateLeft, typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date);
135
- }
136
- /**
137
- * Disabled Before date (Default: today), Generally serves `nzDisabledDate`
138
- *
139
- * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`
140
- */
141
- disabledBeforeDate(options) {
142
- return (d) => this.getDiffDays(d, options?.offsetDays) < 0;
143
- }
144
- /**
145
- * Disabled After date (Default: today), Generally serves `nzDisabledDate`
146
- *
147
- * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`
148
- */
149
- disabledAfterDate(options) {
150
- return (d) => this.getDiffDays(d, options?.offsetDays) > 0;
151
- }
152
- baseDisabledTime(type, offsetSeconds) {
153
- const tick24 = this.genTick(24);
154
- const tick60 = this.genTick(60);
155
- return (current) => {
156
- const cur = current;
157
- if (cur == null) {
158
- return {};
159
- }
160
- const now = addSeconds(this.now, offsetSeconds || 0);
161
- const nowHours = now.getHours();
162
- const nowMinutes = now.getMinutes();
163
- const curHours = cur.getHours();
164
- const isToday = this.getDiffDays(this.removeTime(cur)) === 0;
165
- return {
166
- nzDisabledHours: () => {
167
- if (!isToday)
168
- return [];
169
- return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);
170
- },
171
- nzDisabledMinutes: () => {
172
- if (isToday && curHours === nowHours) {
173
- return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);
174
- }
175
- return [];
176
- },
177
- nzDisabledSeconds: () => {
178
- if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {
179
- const nowSeconds = now.getSeconds();
180
- return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);
181
- }
182
- return [];
183
- }
184
- };
185
- };
186
- }
187
- /**
188
- * Disabled Before time (Default: now), Generally serves `nzDisabledTime`
189
- *
190
- * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`
191
- */
192
- disabledBeforeTime(options) {
193
- return this.baseDisabledTime('before', options?.offsetSeconds);
194
- }
195
- /**
196
- * Disabled After time (Default: now), Generally serves `nzDisabledTime`
197
- *
198
- * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`
199
- */
200
- disabledAfterTime(options) {
201
- return this.baseDisabledTime('after', options?.offsetSeconds);
202
- }
203
- }
204
- const dateTimePickerUtil = new DateTimePickerUtil();
205
-
206
- /**
207
- * Generated bundle index. Do not edit.
208
- */
209
-
210
- export { DateTimePickerUtil, dateTimePickerUtil, fixEndTimeOfRange, getTimeDistance, toDate };
211
- //# sourceMappingURL=date-time.mjs.map
1
+ import { parse, addDays, startOfYear, subYears, endOfYear, startOfMonth, subMonths, endOfMonth, startOfWeek, subWeeks, endOfWeek, startOfDay, endOfDay, parseISO, formatDistanceToNow, format, differenceInCalendarDays, addSeconds } from 'date-fns';
2
+
3
+ /**
4
+ * Get the time range, return `[ Date, Date]` for the start and end dates
5
+ *
6
+ * 获取时间范围
7
+ *
8
+ * @param type 类型,带 `-` 表示过去一个时间,若指定 `number` 表示天数
9
+ * @param time 开始时间
10
+ * @param ignoreMaxTime 忽略追加结束日期的最大时间值
11
+ */
12
+ function getTimeDistance(type, time, options) {
13
+ time = time
14
+ ? typeof time === 'string'
15
+ ? parse(time, 'yyyy-MM-dd HH:mm:ss', new Date())
16
+ : new Date(time)
17
+ : new Date();
18
+ const opt = { weekStartsOn: 1 };
19
+ let res;
20
+ switch (type) {
21
+ case 'today':
22
+ res = [time, time];
23
+ break;
24
+ case '-today':
25
+ res = [addDays(time, -1), time];
26
+ break;
27
+ case 'yesterday':
28
+ res = [addDays(time, -1), addDays(time, -1)];
29
+ break;
30
+ case 'week':
31
+ res = [startOfWeek(time, opt), endOfWeek(time, opt)];
32
+ break;
33
+ case '-week':
34
+ res = [startOfWeek(subWeeks(time, 1), opt), endOfWeek(subWeeks(time, 1), opt)];
35
+ break;
36
+ case 'month':
37
+ res = [startOfMonth(time), endOfMonth(time)];
38
+ break;
39
+ case '-month':
40
+ res = [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];
41
+ break;
42
+ case 'year':
43
+ res = [startOfYear(time), endOfYear(time)];
44
+ break;
45
+ case '-year':
46
+ res = [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];
47
+ break;
48
+ default:
49
+ res = type > 0 ? [time, addDays(time, type)] : [addDays(time, type), time];
50
+ break;
51
+ }
52
+ return options?.ignoreMaxTime ? res : fixEndTimeOfRange(res);
53
+ }
54
+ /**
55
+ * fix time is the most, big value
56
+ */
57
+ function fixEndTimeOfRange(dates) {
58
+ return [startOfDay(dates[0]), endOfDay(dates[1])];
59
+ }
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.
63
+ *
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)`
66
+ */
67
+ function toDate(value, options) {
68
+ if (typeof options === 'string')
69
+ options = { formatString: options };
70
+ const { formatString, defaultValue } = {
71
+ formatString: 'yyyy-MM-dd HH:mm:ss',
72
+ defaultValue: new Date(NaN),
73
+ ...options
74
+ };
75
+ if (value == null) {
76
+ return defaultValue;
77
+ }
78
+ if (value instanceof Date) {
79
+ return value;
80
+ }
81
+ if (typeof value === 'number' || (typeof value === 'string' && /[0-9]{10,13}/.test(value))) {
82
+ return new Date(+value);
83
+ }
84
+ let tryDate = parseISO(value);
85
+ if (isNaN(tryDate)) {
86
+ tryDate = parse(value, formatString, new Date());
87
+ }
88
+ return isNaN(tryDate) ? defaultValue : tryDate;
89
+ }
90
+ function formatDate(value, formatString, dateLocale) {
91
+ value = toDate(value);
92
+ if (isNaN(value))
93
+ return '';
94
+ const langOpt = { locale: dateLocale };
95
+ return formatString === 'fn' ? formatDistanceToNow(value, langOpt) : format(value, formatString, langOpt);
96
+ }
97
+
98
+ // TODO: timezone process
99
+ class DateTimePickerUtil {
100
+ /**
101
+ * Current local time
102
+ *
103
+ * 当前本地时间
104
+ */
105
+ get now() {
106
+ return new Date();
107
+ }
108
+ /**
109
+ * Current local date (not including time part)
110
+ *
111
+ * 当前本地日期(不包含时间部分)
112
+ */
113
+ get date() {
114
+ return this.removeTime(this.now);
115
+ }
116
+ /**
117
+ * Remove the time part of the date
118
+ *
119
+ * 移除日期的时间部分
120
+ */
121
+ removeTime(d) {
122
+ return new Date(d.toDateString());
123
+ }
124
+ /**
125
+ * Format date-time
126
+ *
127
+ * 格式化日期
128
+ */
129
+ format(d, formatString = 'yyyy-MM-dd HH:mm:ss') {
130
+ return format(d, formatString);
131
+ }
132
+ genTick(count) {
133
+ return new Array(count).fill(0).map((_, idx) => idx);
134
+ }
135
+ /**
136
+ * Calculate the number of days between two dates, `0` means the same day
137
+ *
138
+ * 计算两个日期相差天数,`0` 表示同一天
139
+ */
140
+ getDiffDays(dateLeft, dateRight) {
141
+ return differenceInCalendarDays(dateLeft, typeof dateRight === 'number' ? addDays(this.date, dateRight) : dateRight || this.date);
142
+ }
143
+ /**
144
+ * Disabled Before date (Default: today), Generally serves `nzDisabledDate`
145
+ *
146
+ * 禁用之前日期(默认:今天),一般服务于 `nzDisabledDate`
147
+ */
148
+ disabledBeforeDate(options) {
149
+ return (d) => this.getDiffDays(d, options?.offsetDays) < 0;
150
+ }
151
+ /**
152
+ * Disabled After date (Default: today), Generally serves `nzDisabledDate`
153
+ *
154
+ * 禁用之后日期(默认:今天),一般服务于 `nzDisabledDate`
155
+ */
156
+ disabledAfterDate(options) {
157
+ return (d) => this.getDiffDays(d, options?.offsetDays) > 0;
158
+ }
159
+ baseDisabledTime(type, offsetSeconds) {
160
+ const tick24 = this.genTick(24);
161
+ const tick60 = this.genTick(60);
162
+ return (current) => {
163
+ const cur = current;
164
+ if (cur == null) {
165
+ return {};
166
+ }
167
+ const now = addSeconds(this.now, offsetSeconds || 0);
168
+ const nowHours = now.getHours();
169
+ const nowMinutes = now.getMinutes();
170
+ const curHours = cur.getHours();
171
+ const isToday = this.getDiffDays(this.removeTime(cur)) === 0;
172
+ return {
173
+ nzDisabledHours: () => {
174
+ if (!isToday)
175
+ return [];
176
+ return type === 'before' ? tick24.slice(0, nowHours) : tick24.slice(nowHours + 1);
177
+ },
178
+ nzDisabledMinutes: () => {
179
+ if (isToday && curHours === nowHours) {
180
+ return type === 'before' ? tick60.slice(0, nowMinutes) : tick60.slice(nowMinutes + 1);
181
+ }
182
+ return [];
183
+ },
184
+ nzDisabledSeconds: () => {
185
+ if (isToday && curHours === nowHours && cur.getMinutes() === nowMinutes) {
186
+ const nowSeconds = now.getSeconds();
187
+ return type === 'before' ? tick60.slice(0, nowSeconds) : tick60.slice(nowSeconds + 1);
188
+ }
189
+ return [];
190
+ }
191
+ };
192
+ };
193
+ }
194
+ /**
195
+ * Disabled Before time (Default: now), Generally serves `nzDisabledTime`
196
+ *
197
+ * 禁用之前时间(默认:现在),一般服务于 `nzDisabledTime`
198
+ */
199
+ disabledBeforeTime(options) {
200
+ return this.baseDisabledTime('before', options?.offsetSeconds);
201
+ }
202
+ /**
203
+ * Disabled After time (Default: now), Generally serves `nzDisabledTime`
204
+ *
205
+ * 禁用之后时间(默认:现在),一般服务于 `nzDisabledTime`
206
+ */
207
+ disabledAfterTime(options) {
208
+ return this.baseDisabledTime('after', options?.offsetSeconds);
209
+ }
210
+ }
211
+ const dateTimePickerUtil = new DateTimePickerUtil();
212
+
213
+ /**
214
+ * Generated bundle index. Do not edit.
215
+ */
216
+
217
+ export { DateTimePickerUtil, dateTimePickerUtil, fixEndTimeOfRange, formatDate, getTimeDistance, toDate };
218
+ //# sourceMappingURL=date-time.mjs.map
@@ -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} from 'date-fns';\n\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\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","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 dateTimePickerUt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C,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;AACvF,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 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,EA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