cnhis-design-vue 3.1.7 → 3.1.8-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/README.md +22 -22
  2. package/env.d.ts +42 -38
  3. package/es/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.mjs +18 -0
  4. package/es/node_modules/date-fns/esm/_lib/requiredArgs/index.mjs +7 -0
  5. package/es/node_modules/date-fns/esm/compareAsc/index.mjs +56 -0
  6. package/es/node_modules/date-fns/esm/differenceInCalendarDays/index.mjs +53 -0
  7. package/es/node_modules/date-fns/esm/differenceInCalendarMonths/index.mjs +39 -0
  8. package/es/node_modules/date-fns/esm/differenceInDays/index.mjs +90 -0
  9. package/es/node_modules/date-fns/esm/differenceInMonths/index.mjs +63 -0
  10. package/es/node_modules/date-fns/esm/endOfDay/index.mjs +34 -0
  11. package/es/node_modules/date-fns/esm/endOfMonth/index.mjs +36 -0
  12. package/es/node_modules/date-fns/esm/isLastDayOfMonth/index.mjs +34 -0
  13. package/es/node_modules/date-fns/esm/startOfDay/index.mjs +34 -0
  14. package/es/node_modules/date-fns/esm/toDate/index.mjs +55 -0
  15. package/es/packages/big-table/index.d.ts +0 -3
  16. package/es/packages/big-table/index2.mjs +6 -4
  17. package/es/packages/big-table/src/BigTable.vue.d.ts +0 -3
  18. package/es/packages/big-table/src/components/edit-form/edit-select-table.d.ts +1 -1
  19. package/es/packages/big-table/style/index.less +557 -557
  20. package/es/packages/bpmn-workflow/index2.mjs +3 -3
  21. package/es/packages/bpmn-workflow/style/index.less +29 -29
  22. package/es/packages/button-print/index.d.ts +2 -7
  23. package/es/packages/button-print/index2.mjs +3 -3
  24. package/es/packages/button-print/src/ButtonPrint.vue.d.ts +2 -7
  25. package/es/packages/button-print/src/components/IdentityVerification.vue.d.ts +2 -4
  26. package/es/packages/button-print/style/index.less +30 -30
  27. package/es/packages/chunk-upload/index2.mjs +5 -3
  28. package/es/packages/chunk-upload/src/chunk-upload-new.vue.d.ts +4 -6
  29. package/es/packages/chunk-upload/src/vod-chunk-upload/vod-chunk-upload.vue.d.ts +0 -3
  30. package/es/packages/chunk-upload/style/index.less +394 -394
  31. package/es/packages/drag-layout/index.d.ts +8 -18
  32. package/es/packages/drag-layout/index2.mjs +5 -3
  33. package/es/packages/drag-layout/src/DragFormLeftItem.vue.d.ts +4 -7
  34. package/es/packages/drag-layout/src/DragFormRightItem.vue.d.ts +1 -4
  35. package/es/packages/drag-layout/src/DragLayout.vue.d.ts +10 -25
  36. package/es/packages/drag-layout/style/index.less +208 -208
  37. package/es/packages/editor/index2.mjs +3 -3
  38. package/es/packages/field-set/index.d.ts +0 -6
  39. package/es/packages/field-set/index2.mjs +3 -3
  40. package/es/packages/field-set/src/FieldSet.vue.d.ts +0 -3
  41. package/es/packages/field-set/src/NewFieldSet.vue.d.ts +0 -3
  42. package/es/packages/field-set/src/NewFieldSet.vue_vue_type_script_setup_true_lang.mjs +1 -3
  43. package/es/packages/field-set/style/index.less +157 -157
  44. package/es/packages/form-render/index.d.ts +402 -0
  45. package/es/packages/form-render/index.mjs +10 -0
  46. package/es/packages/form-render/index2.mjs +15 -0
  47. package/es/packages/form-render/src/FormRender.mjs +2 -0
  48. package/es/packages/form-render/src/FormRender.vue.d.ts +402 -0
  49. package/es/packages/form-render/src/FormRender.vue_vue_type_script_setup_true_lang.mjs +92 -0
  50. package/es/packages/form-render/src/FormRender2.mjs +4 -0
  51. package/es/packages/form-render/src/components/cascader.d.ts +40 -0
  52. package/es/packages/form-render/src/components/cascader.mjs +1 -0
  53. package/es/packages/form-render/src/components/cascader2.mjs +137 -0
  54. package/es/packages/form-render/src/components/checkbox.d.ts +24 -0
  55. package/es/packages/form-render/src/components/checkbox.mjs +1 -0
  56. package/es/packages/form-render/src/components/checkbox2.mjs +42 -0
  57. package/es/packages/form-render/src/components/collapse.d.ts +31 -0
  58. package/es/packages/form-render/src/components/collapse.mjs +1 -0
  59. package/es/packages/form-render/src/components/collapse2.mjs +54 -0
  60. package/es/packages/form-render/src/components/combination.d.ts +142 -0
  61. package/es/packages/form-render/src/components/combination.mjs +1 -0
  62. package/es/packages/form-render/src/components/combination2.mjs +118 -0
  63. package/es/packages/form-render/src/components/date.d.ts +5037 -0
  64. package/es/packages/form-render/src/components/date.mjs +1 -0
  65. package/es/packages/form-render/src/components/date2.mjs +34 -0
  66. package/es/packages/form-render/src/components/formItem.d.ts +294 -0
  67. package/es/packages/form-render/src/components/formItem.mjs +1 -0
  68. package/es/packages/form-render/src/components/formItem2.mjs +22 -0
  69. package/es/packages/form-render/src/components/index.d.ts +15 -0
  70. package/es/packages/form-render/src/components/index.mjs +15 -0
  71. package/es/packages/form-render/src/components/index2.mjs +15 -0
  72. package/es/packages/form-render/src/components/input.d.ts +15 -0
  73. package/es/packages/form-render/src/components/input.mjs +1 -0
  74. package/es/packages/form-render/src/components/input2.mjs +40 -0
  75. package/es/packages/form-render/src/components/inputGroup.d.ts +11 -0
  76. package/es/packages/form-render/src/components/inputGroup.mjs +1 -0
  77. package/es/packages/form-render/src/components/inputGroup2.mjs +8 -0
  78. package/es/packages/form-render/src/components/inputNumber.d.ts +2183 -0
  79. package/es/packages/form-render/src/components/inputNumber.mjs +1 -0
  80. package/es/packages/form-render/src/components/inputNumber2.mjs +7 -0
  81. package/es/packages/form-render/src/components/labelSelect.d.ts +1 -0
  82. package/es/packages/form-render/src/components/labelSelect.mjs +1 -0
  83. package/es/packages/form-render/src/components/labelSelect2.mjs +18 -0
  84. package/es/packages/form-render/src/components/radio.d.ts +24 -0
  85. package/es/packages/form-render/src/components/radio.mjs +1 -0
  86. package/es/packages/form-render/src/components/radio2.mjs +44 -0
  87. package/es/packages/form-render/src/components/select.d.ts +29 -0
  88. package/es/packages/form-render/src/components/select.mjs +1 -0
  89. package/es/packages/form-render/src/components/select2.mjs +97 -0
  90. package/es/packages/form-render/src/components/slider.d.ts +347 -0
  91. package/es/packages/form-render/src/components/slider.mjs +1 -0
  92. package/es/packages/form-render/src/components/slider2.mjs +16 -0
  93. package/es/packages/form-render/src/components/switch.d.ts +21 -0
  94. package/es/packages/form-render/src/components/switch.mjs +1 -0
  95. package/es/packages/form-render/src/components/switch2.mjs +48 -0
  96. package/es/packages/form-render/src/components/textarea.d.ts +846 -0
  97. package/es/packages/form-render/src/components/textarea.mjs +1 -0
  98. package/es/packages/form-render/src/components/textarea2.mjs +11 -0
  99. package/es/packages/form-render/src/constants/index.d.ts +23 -0
  100. package/es/packages/form-render/src/constants/index.mjs +1 -0
  101. package/es/packages/form-render/src/constants/index2.mjs +24 -0
  102. package/es/packages/form-render/src/hooks/index.d.ts +9 -0
  103. package/es/packages/form-render/src/hooks/index.mjs +9 -0
  104. package/es/packages/form-render/src/hooks/useAsyncQueue.d.ts +60 -0
  105. package/es/packages/form-render/src/hooks/useAsyncQueue.mjs +1 -0
  106. package/es/packages/form-render/src/hooks/useAsyncQueue2.mjs +138 -0
  107. package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +13 -0
  108. package/es/packages/form-render/src/hooks/useBusinessBinding.mjs +1 -0
  109. package/es/packages/form-render/src/hooks/useBusinessBinding2.mjs +48 -0
  110. package/es/packages/form-render/src/hooks/useCommonLog.d.ts +3 -0
  111. package/es/packages/form-render/src/hooks/useCommonLog.mjs +1 -0
  112. package/es/packages/form-render/src/hooks/useCommonLog2.mjs +10 -0
  113. package/es/packages/form-render/src/hooks/useFieldList2Schema.d.ts +64 -0
  114. package/es/packages/form-render/src/hooks/useFieldList2Schema.mjs +1 -0
  115. package/es/packages/form-render/src/hooks/useFieldList2Schema2.mjs +184 -0
  116. package/es/packages/form-render/src/hooks/useFieldVisitor.d.ts +4 -0
  117. package/es/packages/form-render/src/hooks/useFieldVisitor.mjs +1 -0
  118. package/es/packages/form-render/src/hooks/useFieldVisitor2.mjs +38 -0
  119. package/es/packages/form-render/src/hooks/useFormField.d.ts +4 -0
  120. package/es/packages/form-render/src/hooks/useFormField.mjs +1 -0
  121. package/es/packages/form-render/src/hooks/useFormField2.mjs +9 -0
  122. package/es/packages/form-render/src/hooks/useFormRequest.d.ts +6 -0
  123. package/es/packages/form-render/src/hooks/useFormRequest.mjs +1 -0
  124. package/es/packages/form-render/src/hooks/useFormRequest2.mjs +12 -0
  125. package/es/packages/form-render/src/hooks/useFormValidator.d.ts +5 -0
  126. package/es/packages/form-render/src/hooks/useFormValidator.mjs +1 -0
  127. package/es/packages/form-render/src/hooks/useFormValidator2.mjs +48 -0
  128. package/es/packages/form-render/src/hooks/useTypeNormalize.d.ts +4 -0
  129. package/es/packages/form-render/src/hooks/useTypeNormalize.mjs +1 -0
  130. package/es/packages/form-render/src/hooks/useTypeNormalize2.mjs +37 -0
  131. package/es/packages/form-render/src/types/fieldItem.d.ts +45 -0
  132. package/es/packages/form-render/src/types/fieldItem.mjs +1 -0
  133. package/es/packages/form-render/src/types/index.d.ts +26 -0
  134. package/es/packages/form-render/src/types/index.mjs +1 -0
  135. package/es/packages/form-render/src/utils/index.d.ts +10 -0
  136. package/es/packages/form-render/src/utils/index.mjs +1 -0
  137. package/es/packages/form-render/src/utils/index2.mjs +59 -0
  138. package/es/packages/form-render/style/index.css +84 -0
  139. package/es/packages/form-render/style/index.less +121 -0
  140. package/es/packages/form-table/index.d.ts +16 -41
  141. package/es/packages/form-table/index2.mjs +3 -3
  142. package/es/packages/form-table/src/FormTable.vue.d.ts +16 -41
  143. package/es/packages/form-table/src/components/index.d.ts +16 -41
  144. package/es/packages/form-table/src/components/table-age.vue.d.ts +1 -4
  145. package/es/packages/form-table/src/components/table-date-picker.vue.d.ts +1 -2
  146. package/es/packages/form-table/src/components/table-digital.vue.d.ts +0 -3
  147. package/es/packages/form-table/src/components/table-input-password.vue.d.ts +2 -7
  148. package/es/packages/form-table/src/components/table-input.vue.d.ts +2 -7
  149. package/es/packages/form-table/src/components/table-month-picker.vue.d.ts +1 -2
  150. package/es/packages/form-table/src/components/table-search.vue.d.ts +1 -1
  151. package/es/packages/form-table/src/components/table-select-multiple.vue.d.ts +1 -1
  152. package/es/packages/form-table/src/components/table-select.vue.d.ts +1 -1
  153. package/es/packages/form-table/src/components/table-textarea.vue.d.ts +2 -7
  154. package/es/packages/form-table/src/components/table-time-picker.vue.d.ts +1 -2
  155. package/es/packages/form-table/src/components/table-tree-select.vue.d.ts +3 -1
  156. package/es/packages/form-table/src/components/text-over-tooltip.vue.d.ts +0 -3
  157. package/es/packages/form-table/style/index.less +301 -301
  158. package/es/packages/grid/index2.mjs +5 -3
  159. package/es/packages/grid/style/index.less +12 -12
  160. package/es/packages/index.css +85 -1
  161. package/es/packages/index.d.ts +5 -2
  162. package/es/packages/index.less +3066 -2944
  163. package/es/packages/index.mjs +10 -0
  164. package/es/packages/index2.mjs +7 -7
  165. package/es/packages/info-header/index.d.ts +20 -16
  166. package/es/packages/info-header/index2.mjs +3 -3
  167. package/es/packages/info-header/src/InfoHeader.vue.d.ts +20 -16
  168. package/es/packages/info-header/src/InfoHeader.vue_vue_type_script_setup_true_lang.mjs +1 -1
  169. package/es/packages/info-header/style/index.css +1 -1
  170. package/es/packages/info-header/style/index.less +153 -153
  171. package/es/packages/map/index.d.ts +2 -4
  172. package/es/packages/map/index2.mjs +3 -3
  173. package/es/packages/map/src/Map.vue.d.ts +2 -4
  174. package/es/packages/map/style/index.less +59 -59
  175. package/es/packages/scale-view/index.d.ts +26 -13
  176. package/es/packages/scale-view/index2.mjs +9 -7
  177. package/es/packages/scale-view/src/ScaleView.vue.d.ts +26 -16
  178. package/es/packages/scale-view/src/ScaleView.vue_vue_type_script_setup_true_lang.mjs +31 -6
  179. package/es/packages/scale-view/src/components/AnswerParse.vue_vue_type_script_setup_true_lang.mjs +2 -2
  180. package/es/packages/scale-view/src/components/ScaleScore2.mjs +1 -1
  181. package/es/packages/scale-view/src/components/formitem/r-checkbox2.mjs +5 -4
  182. package/es/packages/scale-view/src/components/formitem/r-collection2.mjs +1 -1
  183. package/es/packages/scale-view/src/components/formitem/r-datetime2.mjs +5 -3
  184. package/es/packages/scale-view/src/components/formitem/r-radio2.mjs +6 -5
  185. package/es/packages/scale-view/src/components/formitem/r-select2.mjs +3 -3
  186. package/es/packages/scale-view/src/components/formitem/text-over-tooltip/TextOverTooltip.vue.d.ts +0 -3
  187. package/es/packages/scale-view/src/hooks/scaleview-computed.d.ts +1 -1
  188. package/es/packages/scale-view/src/hooks/scaleview-computed2.mjs +33 -13
  189. package/es/packages/scale-view/src/hooks/scaleview-props.d.ts +7 -3
  190. package/es/packages/scale-view/src/hooks/scaleview-props2.mjs +7 -3
  191. package/es/packages/scale-view/src/hooks/use-component.d.ts +7503 -15
  192. package/es/packages/scale-view/src/hooks/use-component2.mjs +4 -2
  193. package/es/packages/scale-view/style/index.less +748 -748
  194. package/es/packages/select-label/index.d.ts +13 -37
  195. package/es/packages/select-label/index2.mjs +4 -4
  196. package/es/packages/select-label/src/LabelFormContent.vue.d.ts +2 -10
  197. package/es/packages/select-label/src/SelectLabel.vue.d.ts +20 -35
  198. package/es/packages/select-label/src/SelectLabel.vue_vue_type_script_setup_true_lang.mjs +13 -7
  199. package/es/packages/select-label/src/components/label-classify.vue.d.ts +2 -7
  200. package/es/packages/select-label/style/index.less +151 -151
  201. package/es/packages/select-person/index.d.ts +2 -4
  202. package/es/packages/select-person/index2.mjs +3 -3
  203. package/es/packages/select-person/src/SelectPerson.vue.d.ts +10 -10
  204. package/es/packages/select-person/src/SelectPerson.vue_vue_type_script_setup_true_lang.mjs +1 -1
  205. package/es/packages/select-person/style/index.less +229 -229
  206. package/es/packages/time-line/index.d.ts +0 -19
  207. package/es/packages/time-line/index2.mjs +3 -3
  208. package/es/packages/time-line/src/TimeLine.vue.d.ts +0 -19
  209. package/es/packages/time-line/style/index.less +34 -34
  210. package/es/src/components/TextOverTooltip/TextOverTooltip.vue.d.ts +0 -3
  211. package/es/src/core/create2.mjs +2 -2
  212. package/es/src/global/variable.d.ts +1 -1
  213. package/es/src/global/variable.mjs +1 -1
  214. package/es/src/global/variable2.mjs +2 -2
  215. package/es/src/utils/anime.d.ts +35 -0
  216. package/es/src/utils/anime.mjs +1 -0
  217. package/es/src/utils/anime2.mjs +126 -0
  218. package/es/src/utils/index.d.ts +0 -1
  219. package/es/src/utils/index.mjs +1 -1
  220. package/es/src/utils/index2.mjs +1 -5
  221. package/es/src/utils/utilExpand.d.ts +1 -0
  222. package/es/src/utils/utilExpand.mjs +1 -0
  223. package/es/src/utils/utilExpand2.mjs +714 -0
  224. package/es/src/utils/vexutils2.mjs +2 -708
  225. package/global.d.ts +8 -8
  226. package/memory-log.ts +62 -0
  227. package/package.json +132 -119
  228. package/sync-w.sh +13 -0
  229. package/yarn-error.log +8659 -103
package/README.md CHANGED
@@ -1,23 +1,23 @@
1
- # Vue 3 + Typescript + Vite
2
-
3
- This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
-
5
- ## Recommended IDE Setup
6
-
7
- - [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
8
-
9
- ## Type Support For `.vue` Imports in TS
10
-
11
- Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette.
12
-
13
- ## 使用
14
- ```JavaScript
15
- import { createApp } from "vue";
16
- import App from "./App.vue";
17
- import cui from "cnhis-design-vue";
18
- import "cnhis-design-vue/es/index.css";
19
-
20
- const app = createApp(App);
21
- app.use(cui);
22
- app.mount("#app");
1
+ # Vue 3 + Typescript + Vite
2
+
3
+ This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
+
5
+ ## Recommended IDE Setup
6
+
7
+ - [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
8
+
9
+ ## Type Support For `.vue` Imports in TS
10
+
11
+ Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette.
12
+
13
+ ## 使用
14
+ ```JavaScript
15
+ import { createApp } from "vue";
16
+ import App from "./App.vue";
17
+ import cui from "cnhis-design-vue";
18
+ import "cnhis-design-vue/es/index.css";
19
+
20
+ const app = createApp(App);
21
+ app.use(cui);
22
+ app.mount("#app");
23
23
  ```
package/env.d.ts CHANGED
@@ -1,38 +1,42 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_APP_TYPE: string;
5
- // 更多环境变量...
6
- }
7
-
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv;
10
- }
11
-
12
- import * as Vue from 'vue';
13
-
14
- declare module '*.vue' {
15
- import type { App, defineComponent } from 'vue';
16
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
17
- // // const component: DefineComponent<{}, {}, any>
18
- const component: ReturnType<typeof defineComponent> & {
19
- install(app: App): void;
20
- };
21
- export default component;
22
- }
23
-
24
- import { SlateDescendant, SlateElement, SlateText } from '@wangeditor/editor';
25
- declare module '@wangeditor/editor' {
26
- // 扩展 Text
27
- interface SlateText {
28
- text: string;
29
- }
30
-
31
- // 扩展 Element
32
- interface SlateElement {
33
- type: string;
34
- children: SlateDescendant[];
35
- }
36
- }
37
-
38
- declare module '*.js';
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_TYPE: string;
5
+ // 更多环境变量...
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv;
10
+ }
11
+
12
+ import * as Vue from 'vue';
13
+
14
+
15
+ declare module '*.vue' {
16
+ // @ts-ignore
17
+ import type { App, defineComponent } from 'vue';
18
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
19
+ // // const component: DefineComponent<{}, {}, any>
20
+ const component: ReturnType<typeof defineComponent> & {
21
+ install(app: App): void;
22
+ };
23
+ // @ts-ignore
24
+ export default component;
25
+ }
26
+
27
+ import { SlateDescendant, SlateElement, SlateText } from '@wangeditor/editor';
28
+
29
+ declare module '@wangeditor/editor' {
30
+ // 扩展 Text
31
+ interface SlateText {
32
+ text: string;
33
+ }
34
+
35
+ // 扩展 Element
36
+ interface SlateElement {
37
+ type: string;
38
+ children: SlateDescendant[];
39
+ }
40
+ }
41
+
42
+ declare module '*.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
3
+ * They usually appear for dates that denote time before the timezones were introduced
4
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
5
+ * and GMT+01:00:00 after that date)
6
+ *
7
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
8
+ * which would lead to incorrect calculations.
9
+ *
10
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
11
+ */
12
+ function getTimezoneOffsetInMilliseconds(date) {
13
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
14
+ utcDate.setUTCFullYear(date.getFullYear());
15
+ return date.getTime() - utcDate.getTime();
16
+ }
17
+
18
+ export { getTimezoneOffsetInMilliseconds as default };
@@ -0,0 +1,7 @@
1
+ function requiredArgs(required, args) {
2
+ if (args.length < required) {
3
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
4
+ }
5
+ }
6
+
7
+ export { requiredArgs as default };
@@ -0,0 +1,56 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
3
+
4
+ /**
5
+ * @name compareAsc
6
+ * @category Common Helpers
7
+ * @summary Compare the two dates and return -1, 0 or 1.
8
+ *
9
+ * @description
10
+ * Compare the two dates and return 1 if the first date is after the second,
11
+ * -1 if the first date is before the second or 0 if dates are equal.
12
+ *
13
+ * ### v2.0.0 breaking changes:
14
+ *
15
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
16
+ *
17
+ * @param {Date|Number} dateLeft - the first date to compare
18
+ * @param {Date|Number} dateRight - the second date to compare
19
+ * @returns {Number} the result of the comparison
20
+ * @throws {TypeError} 2 arguments required
21
+ *
22
+ * @example
23
+ * // Compare 11 February 1987 and 10 July 1989:
24
+ * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
25
+ * //=> -1
26
+ *
27
+ * @example
28
+ * // Sort the array of dates:
29
+ * const result = [
30
+ * new Date(1995, 6, 2),
31
+ * new Date(1987, 1, 11),
32
+ * new Date(1989, 6, 10)
33
+ * ].sort(compareAsc)
34
+ * //=> [
35
+ * // Wed Feb 11 1987 00:00:00,
36
+ * // Mon Jul 10 1989 00:00:00,
37
+ * // Sun Jul 02 1995 00:00:00
38
+ * // ]
39
+ */
40
+
41
+ function compareAsc(dirtyDateLeft, dirtyDateRight) {
42
+ requiredArgs(2, arguments);
43
+ var dateLeft = toDate(dirtyDateLeft);
44
+ var dateRight = toDate(dirtyDateRight);
45
+ var diff = dateLeft.getTime() - dateRight.getTime();
46
+
47
+ if (diff < 0) {
48
+ return -1;
49
+ } else if (diff > 0) {
50
+ return 1; // Return 0 if diff is 0; return NaN if diff is NaN
51
+ } else {
52
+ return diff;
53
+ }
54
+ }
55
+
56
+ export { compareAsc as default };
@@ -0,0 +1,53 @@
1
+ import getTimezoneOffsetInMilliseconds from '../_lib/getTimezoneOffsetInMilliseconds/index.mjs';
2
+ import startOfDay from '../startOfDay/index.mjs';
3
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
4
+
5
+ var MILLISECONDS_IN_DAY = 86400000;
6
+ /**
7
+ * @name differenceInCalendarDays
8
+ * @category Day Helpers
9
+ * @summary Get the number of calendar days between the given dates.
10
+ *
11
+ * @description
12
+ * Get the number of calendar days between the given dates. This means that the times are removed
13
+ * from the dates and then the difference in days is calculated.
14
+ *
15
+ * ### v2.0.0 breaking changes:
16
+ *
17
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
18
+ *
19
+ * @param {Date|Number} dateLeft - the later date
20
+ * @param {Date|Number} dateRight - the earlier date
21
+ * @returns {Number} the number of calendar days
22
+ * @throws {TypeError} 2 arguments required
23
+ *
24
+ * @example
25
+ * // How many calendar days are between
26
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
27
+ * const result = differenceInCalendarDays(
28
+ * new Date(2012, 6, 2, 0, 0),
29
+ * new Date(2011, 6, 2, 23, 0)
30
+ * )
31
+ * //=> 366
32
+ * // How many calendar days are between
33
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
34
+ * const result = differenceInCalendarDays(
35
+ * new Date(2011, 6, 3, 0, 1),
36
+ * new Date(2011, 6, 2, 23, 59)
37
+ * )
38
+ * //=> 1
39
+ */
40
+
41
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
42
+ requiredArgs(2, arguments);
43
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
44
+ var startOfDayRight = startOfDay(dirtyDateRight);
45
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
46
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight); // Round the number of days to the nearest integer
47
+ // because the number of milliseconds in a day is not constant
48
+ // (e.g. it's different in the day of the daylight saving time clock shift)
49
+
50
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
51
+ }
52
+
53
+ export { differenceInCalendarDays as default };
@@ -0,0 +1,39 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
3
+
4
+ /**
5
+ * @name differenceInCalendarMonths
6
+ * @category Month Helpers
7
+ * @summary Get the number of calendar months between the given dates.
8
+ *
9
+ * @description
10
+ * Get the number of calendar months between the given dates.
11
+ *
12
+ * ### v2.0.0 breaking changes:
13
+ *
14
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
15
+ *
16
+ * @param {Date|Number} dateLeft - the later date
17
+ * @param {Date|Number} dateRight - the earlier date
18
+ * @returns {Number} the number of calendar months
19
+ * @throws {TypeError} 2 arguments required
20
+ *
21
+ * @example
22
+ * // How many calendar months are between 31 January 2014 and 1 September 2014?
23
+ * var result = differenceInCalendarMonths(
24
+ * new Date(2014, 8, 1),
25
+ * new Date(2014, 0, 31)
26
+ * )
27
+ * //=> 8
28
+ */
29
+
30
+ function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
31
+ requiredArgs(2, arguments);
32
+ var dateLeft = toDate(dirtyDateLeft);
33
+ var dateRight = toDate(dirtyDateRight);
34
+ var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
35
+ var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
36
+ return yearDiff * 12 + monthDiff;
37
+ }
38
+
39
+ export { differenceInCalendarMonths as default };
@@ -0,0 +1,90 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import differenceInCalendarDays from '../differenceInCalendarDays/index.mjs';
3
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
4
+
5
+ // for accurate equality comparisons of UTC timestamps that end up
6
+ // having the same representation in local time, e.g. one hour before
7
+ // DST ends vs. the instant that DST ends.
8
+
9
+ function compareLocalAsc(dateLeft, dateRight) {
10
+ var diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();
11
+
12
+ if (diff < 0) {
13
+ return -1;
14
+ } else if (diff > 0) {
15
+ return 1; // Return 0 if diff is 0; return NaN if diff is NaN
16
+ } else {
17
+ return diff;
18
+ }
19
+ }
20
+ /**
21
+ * @name differenceInDays
22
+ * @category Day Helpers
23
+ * @summary Get the number of full days between the given dates.
24
+ *
25
+ * @description
26
+ * Get the number of full day periods between two dates. Fractional days are
27
+ * truncated towards zero.
28
+ *
29
+ * One "full day" is the distance between a local time in one day to the same
30
+ * local time on the next or previous day. A full day can sometimes be less than
31
+ * or more than 24 hours if a daylight savings change happens between two dates.
32
+ *
33
+ * To ignore DST and only measure exact 24-hour periods, use this instead:
34
+ * `Math.floor(differenceInHours(dateLeft, dateRight)/24)|0`.
35
+ *
36
+ *
37
+ * ### v2.0.0 breaking changes:
38
+ *
39
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
40
+ *
41
+ * @param {Date|Number} dateLeft - the later date
42
+ * @param {Date|Number} dateRight - the earlier date
43
+ * @returns {Number} the number of full days according to the local timezone
44
+ * @throws {TypeError} 2 arguments required
45
+ *
46
+ * @example
47
+ * // How many full days are between
48
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
49
+ * const result = differenceInDays(
50
+ * new Date(2012, 6, 2, 0, 0),
51
+ * new Date(2011, 6, 2, 23, 0)
52
+ * )
53
+ * //=> 365
54
+ * // How many full days are between
55
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
56
+ * const result = differenceInDays(
57
+ * new Date(2011, 6, 3, 0, 1),
58
+ * new Date(2011, 6, 2, 23, 59)
59
+ * )
60
+ * //=> 0
61
+ * // How many full days are between
62
+ * // 1 March 2020 0:00 and 1 June 2020 0:00 ?
63
+ * // Note: because local time is used, the
64
+ * // result will always be 92 days, even in
65
+ * // time zones where DST starts and the
66
+ * // period has only 92*24-1 hours.
67
+ * const result = differenceInDays(
68
+ * new Date(2020, 5, 1),
69
+ * new Date(2020, 2, 1)
70
+ * )
71
+ //=> 92
72
+ */
73
+
74
+
75
+ function differenceInDays(dirtyDateLeft, dirtyDateRight) {
76
+ requiredArgs(2, arguments);
77
+ var dateLeft = toDate(dirtyDateLeft);
78
+ var dateRight = toDate(dirtyDateRight);
79
+ var sign = compareLocalAsc(dateLeft, dateRight);
80
+ var difference = Math.abs(differenceInCalendarDays(dateLeft, dateRight));
81
+ dateLeft.setDate(dateLeft.getDate() - sign * difference); // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full
82
+ // If so, result must be decreased by 1 in absolute value
83
+
84
+ var isLastDayNotFull = Number(compareLocalAsc(dateLeft, dateRight) === -sign);
85
+ var result = sign * (difference - isLastDayNotFull); // Prevent negative zero
86
+
87
+ return result === 0 ? 0 : result;
88
+ }
89
+
90
+ export { differenceInDays as default };
@@ -0,0 +1,63 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import differenceInCalendarMonths from '../differenceInCalendarMonths/index.mjs';
3
+ import compareAsc from '../compareAsc/index.mjs';
4
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
5
+ import isLastDayOfMonth from '../isLastDayOfMonth/index.mjs';
6
+
7
+ /**
8
+ * @name differenceInMonths
9
+ * @category Month Helpers
10
+ * @summary Get the number of full months between the given dates.
11
+ *
12
+ * @description
13
+ * Get the number of full months between the given dates using trunc as a default rounding method.
14
+ *
15
+ * ### v2.0.0 breaking changes:
16
+ *
17
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
18
+ *
19
+ * @param {Date|Number} dateLeft - the later date
20
+ * @param {Date|Number} dateRight - the earlier date
21
+ * @returns {Number} the number of full months
22
+ * @throws {TypeError} 2 arguments required
23
+ *
24
+ * @example
25
+ * // How many full months are between 31 January 2014 and 1 September 2014?
26
+ * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))
27
+ * //=> 7
28
+ */
29
+
30
+ function differenceInMonths(dirtyDateLeft, dirtyDateRight) {
31
+ requiredArgs(2, arguments);
32
+ var dateLeft = toDate(dirtyDateLeft);
33
+ var dateRight = toDate(dirtyDateRight);
34
+ var sign = compareAsc(dateLeft, dateRight);
35
+ var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));
36
+ var result; // Check for the difference of less than month
37
+
38
+ if (difference < 1) {
39
+ result = 0;
40
+ } else {
41
+ if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {
42
+ // This will check if the date is end of Feb and assign a higher end of month date
43
+ // to compare it with Jan
44
+ dateLeft.setDate(30);
45
+ }
46
+
47
+ dateLeft.setMonth(dateLeft.getMonth() - sign * difference); // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full
48
+ // If so, result must be decreased by 1 in absolute value
49
+
50
+ var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign; // Check for cases of one full calendar month
51
+
52
+ if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {
53
+ isLastMonthNotFull = false;
54
+ }
55
+
56
+ result = sign * (difference - Number(isLastMonthNotFull));
57
+ } // Prevent negative zero
58
+
59
+
60
+ return result === 0 ? 0 : result;
61
+ }
62
+
63
+ export { differenceInMonths as default };
@@ -0,0 +1,34 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
3
+
4
+ /**
5
+ * @name endOfDay
6
+ * @category Day Helpers
7
+ * @summary Return the end of a day for the given date.
8
+ *
9
+ * @description
10
+ * Return the end of a day for the given date.
11
+ * The result will be in the local timezone.
12
+ *
13
+ * ### v2.0.0 breaking changes:
14
+ *
15
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
16
+ *
17
+ * @param {Date|Number} date - the original date
18
+ * @returns {Date} the end of a day
19
+ * @throws {TypeError} 1 argument required
20
+ *
21
+ * @example
22
+ * // The end of a day for 2 September 2014 11:55:00:
23
+ * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
24
+ * //=> Tue Sep 02 2014 23:59:59.999
25
+ */
26
+
27
+ function endOfDay(dirtyDate) {
28
+ requiredArgs(1, arguments);
29
+ var date = toDate(dirtyDate);
30
+ date.setHours(23, 59, 59, 999);
31
+ return date;
32
+ }
33
+
34
+ export { endOfDay as default };
@@ -0,0 +1,36 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
3
+
4
+ /**
5
+ * @name endOfMonth
6
+ * @category Month Helpers
7
+ * @summary Return the end of a month for the given date.
8
+ *
9
+ * @description
10
+ * Return the end of a month for the given date.
11
+ * The result will be in the local timezone.
12
+ *
13
+ * ### v2.0.0 breaking changes:
14
+ *
15
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
16
+ *
17
+ * @param {Date|Number} date - the original date
18
+ * @returns {Date} the end of a month
19
+ * @throws {TypeError} 1 argument required
20
+ *
21
+ * @example
22
+ * // The end of a month for 2 September 2014 11:55:00:
23
+ * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
24
+ * //=> Tue Sep 30 2014 23:59:59.999
25
+ */
26
+
27
+ function endOfMonth(dirtyDate) {
28
+ requiredArgs(1, arguments);
29
+ var date = toDate(dirtyDate);
30
+ var month = date.getMonth();
31
+ date.setFullYear(date.getFullYear(), month + 1, 0);
32
+ date.setHours(23, 59, 59, 999);
33
+ return date;
34
+ }
35
+
36
+ export { endOfMonth as default };
@@ -0,0 +1,34 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import endOfDay from '../endOfDay/index.mjs';
3
+ import endOfMonth from '../endOfMonth/index.mjs';
4
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
5
+
6
+ /**
7
+ * @name isLastDayOfMonth
8
+ * @category Month Helpers
9
+ * @summary Is the given date the last day of a month?
10
+ *
11
+ * @description
12
+ * Is the given date the last day of a month?
13
+ *
14
+ * ### v2.0.0 breaking changes:
15
+ *
16
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
17
+ *
18
+ * @param {Date|Number} date - the date to check
19
+ * @returns {Boolean} the date is the last day of a month
20
+ * @throws {TypeError} 1 argument required
21
+ *
22
+ * @example
23
+ * // Is 28 February 2014 the last day of a month?
24
+ * var result = isLastDayOfMonth(new Date(2014, 1, 28))
25
+ * //=> true
26
+ */
27
+
28
+ function isLastDayOfMonth(dirtyDate) {
29
+ requiredArgs(1, arguments);
30
+ var date = toDate(dirtyDate);
31
+ return endOfDay(date).getTime() === endOfMonth(date).getTime();
32
+ }
33
+
34
+ export { isLastDayOfMonth as default };
@@ -0,0 +1,34 @@
1
+ import toDate from '../toDate/index.mjs';
2
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
3
+
4
+ /**
5
+ * @name startOfDay
6
+ * @category Day Helpers
7
+ * @summary Return the start of a day for the given date.
8
+ *
9
+ * @description
10
+ * Return the start of a day for the given date.
11
+ * The result will be in the local timezone.
12
+ *
13
+ * ### v2.0.0 breaking changes:
14
+ *
15
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
16
+ *
17
+ * @param {Date|Number} date - the original date
18
+ * @returns {Date} the start of a day
19
+ * @throws {TypeError} 1 argument required
20
+ *
21
+ * @example
22
+ * // The start of a day for 2 September 2014 11:55:00:
23
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
24
+ * //=> Tue Sep 02 2014 00:00:00
25
+ */
26
+
27
+ function startOfDay(dirtyDate) {
28
+ requiredArgs(1, arguments);
29
+ var date = toDate(dirtyDate);
30
+ date.setHours(0, 0, 0, 0);
31
+ return date;
32
+ }
33
+
34
+ export { startOfDay as default };
@@ -0,0 +1,55 @@
1
+ import requiredArgs from '../_lib/requiredArgs/index.mjs';
2
+
3
+ /**
4
+ * @name toDate
5
+ * @category Common Helpers
6
+ * @summary Convert the given argument to an instance of Date.
7
+ *
8
+ * @description
9
+ * Convert the given argument to an instance of Date.
10
+ *
11
+ * If the argument is an instance of Date, the function returns its clone.
12
+ *
13
+ * If the argument is a number, it is treated as a timestamp.
14
+ *
15
+ * If the argument is none of the above, the function returns Invalid Date.
16
+ *
17
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
18
+ *
19
+ * @param {Date|Number} argument - the value to convert
20
+ * @returns {Date} the parsed date in the local time zone
21
+ * @throws {TypeError} 1 argument required
22
+ *
23
+ * @example
24
+ * // Clone the date:
25
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
26
+ * //=> Tue Feb 11 2014 11:30:30
27
+ *
28
+ * @example
29
+ * // Convert the timestamp to date:
30
+ * const result = toDate(1392098430000)
31
+ * //=> Tue Feb 11 2014 11:30:30
32
+ */
33
+
34
+ function toDate(argument) {
35
+ requiredArgs(1, arguments);
36
+ var argStr = Object.prototype.toString.call(argument); // Clone the date
37
+
38
+ if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
39
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
40
+ return new Date(argument.getTime());
41
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
42
+ return new Date(argument);
43
+ } else {
44
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
45
+ // eslint-disable-next-line no-console
46
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
47
+
48
+ console.warn(new Error().stack);
49
+ }
50
+
51
+ return new Date(NaN);
52
+ }
53
+ }
54
+
55
+ export { toDate as default };