aloha-vue 2.84.0 → 2.86.0

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 (246) hide show
  1. package/CHANGELOG.md +1208 -1196
  2. package/README.md +117 -117
  3. package/dist/aloha-vue.css +13806 -13601
  4. package/dist/aloha-vue.css.map +1 -1
  5. package/dist/aloha-vue.es.js +60168 -57382
  6. package/dist/aloha-vue.umd.js +319 -319
  7. package/package.json +1 -1
  8. package/scss/components/AButton.scss +6 -6
  9. package/scss/components/ADivider.scss +9 -9
  10. package/scss/components/AElement.scss +6 -6
  11. package/scss/components/AGroupButtonDropdown.scss +4 -4
  12. package/scss/components/AIcon.scss +17 -17
  13. package/scss/components/ALoading.scss +18 -18
  14. package/scss/components/AMenu.scss +634 -634
  15. package/scss/components/AProgressCirle.scss +43 -43
  16. package/scss/components/AShowMore.scss +9 -9
  17. package/scss/components/ATableForm.scss +7 -7
  18. package/scss/components/ATabs.scss +186 -186
  19. package/scss/components/ui/AColorPicker.scss +223 -0
  20. package/scss/components/ui/AJson.scss +11 -11
  21. package/scss/components/ui/ui.scss +1 -0
  22. package/scss/text/text_line_height.scss +17 -17
  23. package/scss/text/text_size.scss +88 -88
  24. package/scss/utils/acordion.scss +173 -173
  25. package/scss/utils/alert.scss +81 -81
  26. package/scss/utils/aloha_prefix.scss +1 -1
  27. package/scss/utils/backdrop.scss +24 -24
  28. package/scss/utils/border.scss +65 -65
  29. package/scss/utils/breakpoint.scss +48 -48
  30. package/scss/utils/button_close.scss +22 -22
  31. package/scss/utils/button_group.scss +69 -69
  32. package/scss/utils/color_utils.scss +234 -234
  33. package/scss/utils/display.scss +67 -67
  34. package/scss/utils/flex.scss +141 -141
  35. package/scss/utils/float.scss +10 -10
  36. package/scss/utils/global.scss +44 -44
  37. package/scss/utils/global_variables.scss +26 -26
  38. package/scss/utils/grid.scss +95 -95
  39. package/scss/utils/list_columns.scss +31 -31
  40. package/scss/utils/list_group.scss +127 -127
  41. package/scss/utils/notification.scss +36 -36
  42. package/scss/utils/overflow.scss +40 -40
  43. package/scss/utils/pagination.scss +94 -94
  44. package/scss/utils/position.scss +90 -90
  45. package/scss/utils/progress.scss +70 -70
  46. package/scss/utils/screenreader.scss +16 -16
  47. package/scss/utils/spinner.scss +35 -35
  48. package/scss/utils/utils.scss +19 -19
  49. package/scss/utils/vars_global.scss +12 -12
  50. package/src/AAlert/i18n/AAlertI18n.js +4 -0
  51. package/src/AAlert/i18n/nl.json +3 -0
  52. package/src/AAlert/i18n/pl.json +3 -0
  53. package/src/ACarousel/i18n/ACarouselI18n.js +4 -0
  54. package/src/ACarousel/i18n/nl.json +9 -0
  55. package/src/ACarousel/i18n/pl.json +9 -0
  56. package/src/ACloak/i18n/ACloakI18n.js +4 -0
  57. package/src/ACloak/i18n/nl.json +3 -0
  58. package/src/ACloak/i18n/pl.json +3 -0
  59. package/src/ADisclosure/i18n/ADisclosureI18n.js +4 -0
  60. package/src/ADisclosure/i18n/nl.json +4 -0
  61. package/src/ADisclosure/i18n/pl.json +4 -0
  62. package/src/AFilters/i18n/AFiltersI18n.js +4 -0
  63. package/src/AFilters/i18n/nl.json +30 -0
  64. package/src/AFilters/i18n/pl.json +30 -0
  65. package/src/AGroupButtonDropdown/AGroupButtonDropdown.js +119 -119
  66. package/src/ALinkCopy/i18n/ALinkCopyI18n.js +4 -0
  67. package/src/ALinkCopy/i18n/nl.json +4 -0
  68. package/src/ALinkCopy/i18n/pl.json +4 -0
  69. package/src/ALoading/i18n/ALoadingI18n.js +4 -0
  70. package/src/ALoading/i18n/nl.json +3 -0
  71. package/src/ALoading/i18n/pl.json +3 -0
  72. package/src/AMenu/i18n/AMenu2I18n.js +4 -0
  73. package/src/AMenu/i18n/nl.json +14 -0
  74. package/src/AMenu/i18n/pl.json +14 -0
  75. package/src/AModal/compositionAPI/ZIndexAPI.js +48 -48
  76. package/src/AModal/i18n/AModalI18n.js +4 -0
  77. package/src/AModal/i18n/nl.json +7 -0
  78. package/src/AModal/i18n/pl.json +7 -0
  79. package/src/APagination/i18n/APaginationI18n.js +4 -0
  80. package/src/APagination/i18n/nl.json +12 -0
  81. package/src/APagination/i18n/pl.json +12 -0
  82. package/src/AProgress/AProgress.js +141 -141
  83. package/src/AProgressCircle/AProgressCircle.js +160 -160
  84. package/src/AShowMore/i18n/AShowMoreI18n.js +4 -0
  85. package/src/AShowMore/i18n/nl.json +6 -0
  86. package/src/AShowMore/i18n/pl.json +6 -0
  87. package/src/ASpinner/i18n/ASpinnerI18n.js +4 -0
  88. package/src/ASpinner/i18n/nl.json +3 -0
  89. package/src/ASpinner/i18n/pl.json +3 -0
  90. package/src/ATable/ATableHeaderTh/ATableHeaderTh.js +188 -188
  91. package/src/ATable/i18n/ATableI18n.js +4 -0
  92. package/src/ATable/i18n/nl.json +54 -0
  93. package/src/ATable/i18n/pl.json +54 -0
  94. package/src/ATableForm/i18n/ATableFormI18n.js +4 -0
  95. package/src/ATableForm/i18n/nl.json +18 -0
  96. package/src/ATableForm/i18n/pl.json +18 -0
  97. package/src/ATranslation/ATranslation.js +46 -0
  98. package/src/ATranslation/__tests__/ATranslation.test.js +121 -0
  99. package/src/ATranslation/compositionAPI/UtilsAPI.js +6 -1
  100. package/src/ATranslation/compositionAPI/__tests__/UtilsAPI.getTranslatedText.test.js +38 -0
  101. package/src/AVerticalScroll/i18n/AVerticalScrollI18n.js +4 -0
  102. package/src/AVerticalScroll/i18n/nl.json +4 -0
  103. package/src/AVerticalScroll/i18n/pl.json +4 -0
  104. package/src/AWizard/i18n/AWizardI18n.js +4 -0
  105. package/src/AWizard/i18n/nl.json +16 -0
  106. package/src/AWizard/i18n/pl.json +16 -0
  107. package/src/PVP/new.txt +39 -39
  108. package/src/PuxDatepicker/PuxDatepicker.js +670 -670
  109. package/src/PuxDatepicker/PuxDatepicker.pug +131 -131
  110. package/src/PuxDatepicker/PuxDatepicker.vue +2 -2
  111. package/src/PuxDatepicker/PuxDatepickerCalendarPanel/PuxDatepickerCalendarPanel.pug +136 -136
  112. package/src/PuxDatepicker/PuxDatepickerCalendarPanel/PuxDatepickerCalendarPanel.vue +2 -2
  113. package/src/PuxDatepicker/PuxDatepickerIcon/PuxDatepickerIcon.js +30 -30
  114. package/src/PuxDatepicker/PuxDatepickerIcon/PuxDatepickerIcon.pug +6 -6
  115. package/src/PuxDatepicker/PuxDatepickerIcon/PuxDatepickerIcon.vue +2 -2
  116. package/src/PuxDatepicker/locale/languages.js +174 -174
  117. package/src/PuxDatepicker/mixins/PanelMixin.js +76 -76
  118. package/src/PuxDatepicker/panel/PanelDate/PanelDate.pug +41 -41
  119. package/src/PuxDatepicker/panel/PanelDate/PanelDate.vue +2 -2
  120. package/src/PuxDatepicker/panel/PanelMonth/PanelMonth.pug +16 -16
  121. package/src/PuxDatepicker/panel/PanelMonth/PanelMonth.vue +2 -2
  122. package/src/PuxDatepicker/panel/PanelTime/PanelTime.pug +20 -20
  123. package/src/PuxDatepicker/panel/PanelTime/PanelTime.vue +2 -2
  124. package/src/PuxDatepicker/panel/PanelYear/PanelYear.pug +16 -16
  125. package/src/PuxDatepicker/panel/PanelYear/PanelYear.vue +2 -2
  126. package/src/PuxDatepicker/panel/PanelYearItem/PanelYearItem.js +55 -55
  127. package/src/PuxDatepicker/panel/PanelYearItem/PanelYearItem.pug +9 -9
  128. package/src/PuxDatepicker/panel/PanelYearItem/PanelYearItem.vue +2 -2
  129. package/src/PuxDatepicker/utils/keysCode.js +9 -9
  130. package/src/PuxDatepicker/utils/scroll-into-view.js +23 -23
  131. package/src/PuxDatepicker/utils/transform.js +23 -23
  132. package/src/filters/i18n/Filters18n.js +4 -0
  133. package/src/filters/i18n/nl.json +11 -0
  134. package/src/filters/i18n/pl.json +11 -0
  135. package/src/i18n/allLanguages.js +96 -0
  136. package/src/i18n/nl.json +4 -0
  137. package/src/i18n/pl.json +4 -0
  138. package/src/index.js +4 -0
  139. package/src/ui/ACheckbox/ACheckbox.js +5 -0
  140. package/src/ui/ACheckbox/i18n/ACheckboxI18n.js +4 -0
  141. package/src/ui/ACheckbox/i18n/nl.json +5 -0
  142. package/src/ui/ACheckbox/i18n/pl.json +5 -0
  143. package/src/ui/AColorPicker/AColorPicker.js +697 -0
  144. package/src/ui/AColorPicker/AColorPickerSaturation/AColorPickerSaturation.js +102 -0
  145. package/src/ui/AColorPicker/AColorPickerSaturation/compositionAPI/SaturationAPI.js +77 -0
  146. package/src/ui/AColorPicker/AColorPickerSlider/AColorPickerSlider.js +125 -0
  147. package/src/ui/AColorPicker/AColorPickerSlider/compositionAPI/SliderAPI.js +73 -0
  148. package/src/ui/AColorPicker/__tests__/AColorPicker.test.js +139 -0
  149. package/src/ui/AColorPicker/__tests__/colorUtils.test.js +92 -0
  150. package/src/ui/AColorPicker/compositionAPI/ColorStateAPI.js +108 -0
  151. package/src/ui/AColorPicker/compositionAPI/ConfirmAPI.js +36 -0
  152. package/src/ui/AColorPicker/compositionAPI/InputAPI.js +63 -0
  153. package/src/ui/AColorPicker/compositionAPI/KeyboardStepAPI.js +42 -0
  154. package/src/ui/AColorPicker/compositionAPI/PointerDragAPI.js +70 -0
  155. package/src/ui/AColorPicker/compositionAPI/PopoverAPI.js +179 -0
  156. package/src/ui/AColorPicker/compositionAPI/PredefineAPI.js +42 -0
  157. package/src/ui/AColorPicker/compositionAPI/ToggleClassAPI.js +24 -0
  158. package/src/ui/AColorPicker/i18n/AColorPickerI18n.js +25 -0
  159. package/src/ui/AColorPicker/i18n/ar.json +13 -0
  160. package/src/ui/AColorPicker/i18n/de.json +13 -0
  161. package/src/ui/AColorPicker/i18n/en.json +13 -0
  162. package/src/ui/AColorPicker/i18n/es.json +13 -0
  163. package/src/ui/AColorPicker/i18n/fr.json +13 -0
  164. package/src/ui/AColorPicker/i18n/hr.json +13 -0
  165. package/src/ui/AColorPicker/i18n/it.json +13 -0
  166. package/src/ui/AColorPicker/i18n/nl.json +13 -0
  167. package/src/ui/AColorPicker/i18n/pl.json +13 -0
  168. package/src/ui/AColorPicker/i18n/ru.json +13 -0
  169. package/src/ui/AColorPicker/i18n/uk.json +13 -0
  170. package/src/ui/AColorPicker/utils/colorUtils.js +281 -0
  171. package/src/ui/ADatepicker/ADatepickerCalendarPanel/ADatepickerCalendarPanel.js +68 -68
  172. package/src/ui/ADatepicker/i18n/ADatepickerI18n.js +4 -0
  173. package/src/ui/ADatepicker/i18n/nl.json +58 -0
  174. package/src/ui/ADatepicker/i18n/pl.json +58 -0
  175. package/src/ui/ADatepicker/panel/APanelTime/APanelTime.js +147 -147
  176. package/src/ui/ADatepicker/panel/APanelYear/APanelYear.js +123 -123
  177. package/src/ui/ADatepickerAlt/ADatepickerCalendarPanel/ADatepickerCalendarPanel.js +804 -804
  178. package/src/ui/ADatepickerAlt/panel/APanelDate/APanelDate.js +353 -353
  179. package/src/ui/ADatepickerAlt/panel/APanelMonth/APanelMonth.js +187 -187
  180. package/src/ui/ADatepickerAlt/panel/APanelTime/APanelTime.js +303 -303
  181. package/src/ui/ADatepickerAlt/panel/APanelYear/APanelYear.js +162 -162
  182. package/src/ui/ADatepickerRange/i18n/ADatepickerRangeI18n.js +4 -0
  183. package/src/ui/ADatepickerRange/i18n/nl.json +4 -0
  184. package/src/ui/ADatepickerRange/i18n/pl.json +4 -0
  185. package/src/ui/AErrors/i18n/AErrorsI18n.js +4 -0
  186. package/src/ui/AErrors/i18n/nl.json +3 -0
  187. package/src/ui/AErrors/i18n/pl.json +3 -0
  188. package/src/ui/AFieldset/__tests__/AFieldset.ClassColumn.test.js +1 -0
  189. package/src/ui/AFieldset/i18n/AFieldsetI18n.js +4 -0
  190. package/src/ui/AFieldset/i18n/nl.json +4 -0
  191. package/src/ui/AFieldset/i18n/pl.json +4 -0
  192. package/src/ui/AFormElementBtnClear/i18n/AFormElementBtnClearI18n.js +4 -0
  193. package/src/ui/AFormElementBtnClear/i18n/nl.json +3 -0
  194. package/src/ui/AFormElementBtnClear/i18n/pl.json +3 -0
  195. package/src/ui/AInput/i18n/AInputI18n.js +4 -0
  196. package/src/ui/AInput/i18n/nl.json +4 -0
  197. package/src/ui/AInput/i18n/pl.json +4 -0
  198. package/src/ui/AInputCurrency/i18n/AInputCurrencyI18n.js +4 -0
  199. package/src/ui/AInputCurrency/i18n/nl.json +4 -0
  200. package/src/ui/AInputCurrency/i18n/pl.json +4 -0
  201. package/src/ui/AInputNumber/i18n/AInputNumberI18n.js +4 -0
  202. package/src/ui/AInputNumber/i18n/nl.json +4 -0
  203. package/src/ui/AInputNumber/i18n/pl.json +4 -0
  204. package/src/ui/AInputNumberRange/i18n/AInputNumberRangeI18n.js +4 -0
  205. package/src/ui/AInputNumberRange/i18n/nl.json +4 -0
  206. package/src/ui/AInputNumberRange/i18n/pl.json +4 -0
  207. package/src/ui/AJson/i18n/AJsonI18n.js +4 -0
  208. package/src/ui/AJson/i18n/nl.json +8 -0
  209. package/src/ui/AJson/i18n/pl.json +8 -0
  210. package/src/ui/AMultiselectOrdered/i18n/AMultiselectOrderedI18n.js +4 -0
  211. package/src/ui/AMultiselectOrdered/i18n/nl.json +12 -0
  212. package/src/ui/AMultiselectOrdered/i18n/pl.json +12 -0
  213. package/src/ui/ARadio/i18n/ARadioI18n.js +4 -0
  214. package/src/ui/ARadio/i18n/nl.json +5 -0
  215. package/src/ui/ARadio/i18n/pl.json +5 -0
  216. package/src/ui/ARequired/i18n/ARequiredI18n.js +4 -0
  217. package/src/ui/ARequired/i18n/nl.json +3 -0
  218. package/src/ui/ARequired/i18n/pl.json +3 -0
  219. package/src/ui/ARouterLinkConfig/i18n/ARouterLinkConfigI18n.js +4 -0
  220. package/src/ui/ARouterLinkConfig/i18n/nl.json +14 -0
  221. package/src/ui/ARouterLinkConfig/i18n/pl.json +14 -0
  222. package/src/ui/ASelect/i18n/ASelectI18n.js +4 -0
  223. package/src/ui/ASelect/i18n/ar.json +5 -5
  224. package/src/ui/ASelect/i18n/de.json +4 -4
  225. package/src/ui/ASelect/i18n/en.json +5 -5
  226. package/src/ui/ASelect/i18n/es.json +5 -5
  227. package/src/ui/ASelect/i18n/fr.json +5 -5
  228. package/src/ui/ASelect/i18n/hr.json +5 -5
  229. package/src/ui/ASelect/i18n/it.json +5 -5
  230. package/src/ui/ASelect/i18n/nl.json +11 -0
  231. package/src/ui/ASelect/i18n/pl.json +11 -0
  232. package/src/ui/ASelect/i18n/ru.json +5 -5
  233. package/src/ui/ASelectStyle/i18n/ASelectStyleI18n.js +4 -0
  234. package/src/ui/ASelectStyle/i18n/nl.json +292 -0
  235. package/src/ui/ASelectStyle/i18n/pl.json +292 -0
  236. package/src/ui/ASlider/i18n/ASliderI18n.js +4 -0
  237. package/src/ui/ASlider/i18n/nl.json +5 -0
  238. package/src/ui/ASlider/i18n/pl.json +5 -0
  239. package/src/ui/ASwitch/i18n/ASwitchI18n.js +4 -0
  240. package/src/ui/ASwitch/i18n/nl.json +5 -0
  241. package/src/ui/ASwitch/i18n/pl.json +5 -0
  242. package/src/ui/AUiComponents.js +2 -0
  243. package/src/ui/AValidatedJson/i18n/AValidatedJsonI18n.js +4 -0
  244. package/src/ui/AValidatedJson/i18n/nl.json +25 -0
  245. package/src/ui/AValidatedJson/i18n/pl.json +25 -0
  246. package/src/ui/compositionApi/__tests__/UiStyleHideAPI.test.js +9 -4
@@ -1,804 +1,804 @@
1
- /* eslint vue/component-api-style: off */
2
- import {
3
- h,
4
- nextTick,
5
- } from "vue";
6
-
7
- import APanelDate from "../panel/APanelDate/APanelDate";
8
- import APanelMonth from "../panel/APanelMonth/APanelMonth";
9
- import APanelTime from "../panel/APanelTime/APanelTime";
10
- import APanelYear from "../panel/APanelYear/APanelYear";
11
-
12
- import AKeysCode from "../../../const/AKeysCode";
13
- import PanelMixin from "../mixins/PanelMixin";
14
- import scrollIntoView from "../utils/scroll-into-view";
15
- import {
16
- formatDate,
17
- isDateObject,
18
- isValidDate,
19
- } from "../utils";
20
- import {
21
- forEach,
22
- } from "lodash-es";
23
-
24
- // @vue/component
25
- export default {
26
- name: "ADatepickerCalendarPanel",
27
- components: {
28
- APanelDate,
29
- APanelMonth,
30
- APanelTime,
31
- APanelYear,
32
- },
33
- mixins: [
34
- PanelMixin,
35
- ],
36
- props: {
37
- id: {
38
- type: String,
39
- required: true,
40
- },
41
- value: {
42
- default: null,
43
- validator: function(val) {
44
- return val === null || isValidDate(val);
45
- },
46
- },
47
- startAt: {
48
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
49
- required: false,
50
- default: undefined,
51
- },
52
- endAt: {
53
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
54
- required: false,
55
- default: undefined,
56
- },
57
- visible: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- type: {
62
- type: String,
63
- default: "date", // ["date", "datetime"]
64
- },
65
- dateFormat: {
66
- type: String,
67
- default: "YYYY-MM-DD",
68
- },
69
- index: {
70
- type: Number,
71
- default: undefined,
72
- },
73
- defaultValue: {
74
- validator: function(val) {
75
- return isValidDate(val);
76
- },
77
- default: undefined,
78
- },
79
- firstDayOfWeek: {
80
- default: 7,
81
- type: Number,
82
- validator: val => val >= 1 && val <= 7,
83
- },
84
- notBefore: {
85
- default: null,
86
- validator: function(val) {
87
- return !val || isValidDate(val);
88
- },
89
- },
90
- notAfter: {
91
- default: null,
92
- validator: function(val) {
93
- return !val || isValidDate(val);
94
- },
95
- },
96
- disabledDays: {
97
- type: [Array, Function],
98
- default: function() {
99
- return [];
100
- },
101
- },
102
- minuteStep: {
103
- type: Number,
104
- default: 0,
105
- validator: val => val >= 0 && val <= 60,
106
- },
107
- currentLanguage: {
108
- type: Object,
109
- required: true,
110
- },
111
- },
112
- emits: [
113
- "closePopup",
114
- "selectDate",
115
- "selectTime",
116
- ],
117
- data() {
118
- const now = this.getNow(this.value);
119
- const calendarYear = now.getFullYear();
120
- const calendarMonth = now.getMonth();
121
- const firstYear = Math.floor(calendarYear / 10) * 10;
122
- return {
123
- panel: "NONE",
124
- dates: [],
125
- calendarMonth,
126
- calendarYear,
127
- firstYear,
128
- isFocusPanelChild: false,
129
- isWorkWithKeyboard: false,
130
- };
131
- },
132
- computed: {
133
- now: {
134
- get() {
135
- return new Date(this.calendarYear, this.calendarMonth).getTime();
136
- },
137
- set(val) {
138
- const now = new Date(val);
139
- this.calendarYear = now.getFullYear();
140
- this.calendarMonth = now.getMonth();
141
- },
142
- },
143
-
144
- timeType() {
145
- const h = /h+/.test(this.$parent.format) ? "12" : "24";
146
- const a = /A/.test(this.$parent.format) ? "A" : "a";
147
- return [h, a];
148
- },
149
-
150
- timeHeader() {
151
- if (this.type === "time") {
152
- return this.$parent.format;
153
- }
154
- return this.value && formatDate(this.value, this.dateFormat);
155
- },
156
-
157
- yearHeader() {
158
- const LAST_YEAR = this.firstYear + 9;
159
- return this.currentLanguage.headerYears(this.firstYear, LAST_YEAR);
160
- },
161
-
162
- months() {
163
- return this.currentLanguage.months;
164
- },
165
-
166
- notBeforeTime() {
167
- return this.getCriticalTime(this.notBefore);
168
- },
169
-
170
- notAfterTime() {
171
- return this.getCriticalTime(this.notAfter);
172
- },
173
-
174
- suffixForHeader() {
175
- if (this.panel === "TIME") {
176
- return this.currentLanguage.placeholder.regionTime;
177
- }
178
- return this.currentLanguage.placeholder.regionDate;
179
- },
180
-
181
- idForHeaderParent() {
182
- return `${ this.idForHeader }_parent`;
183
- },
184
-
185
- ariaLabelForButtonLastYear() {
186
- if (this.panel === "YEAR") {
187
- return this.currentLanguage.buttons.lastYears;
188
- }
189
- return this.currentLanguage.buttons.lastYear;
190
- },
191
-
192
- ariaLabelForButtonLastMonth() {
193
- return this.currentLanguage.buttons.lastMonth;
194
- },
195
-
196
- ariaLabelForButtonNextMonth() {
197
- return this.currentLanguage.buttons.nextMonth;
198
- },
199
-
200
- ariaLabelForButtonNextYear() {
201
- if (this.panel === "YEAR") {
202
- return this.currentLanguage.buttons.nextYears;
203
- }
204
- return this.currentLanguage.buttons.nextYear;
205
- },
206
-
207
- ariaLabelForButtonCurrentMonth() {
208
- return this.currentLanguage.buttons.toMonthsView;
209
- },
210
-
211
- ariaLabelForButtonCurrentYear() {
212
- return this.currentLanguage.buttons.toYearsView;
213
- },
214
-
215
- ariaLabelForButtonToDays() {
216
- return this.currentLanguage.buttons.toDaysView;
217
- },
218
- },
219
- watch: {
220
- value: {
221
- immediate: true,
222
- handler: "updateNow",
223
- },
224
- defaultValue: {
225
- handler: "updateNow",
226
- },
227
- visible: {
228
- immediate: true,
229
- handler: "init",
230
- },
231
- panel: {
232
- handler: "handelPanelChange",
233
- },
234
- },
235
- beforeUnmount() {
236
- this.destroyListenerForPressTabButton();
237
- this.destroyListenerForPressEscapeButton();
238
- },
239
- methods: {
240
- handelPanelChange(panel) {
241
- if (panel === "YEAR") {
242
- this.firstYear = Math.floor(this.calendarYear / 10) * 10;
243
- } else if (panel === "TIME") {
244
- nextTick().then(
245
- () => {
246
- const list = this.$el.querySelectorAll(".pux_datepicker__panel_time .pux_datepicker__time_list");
247
- for (let i = 0, len = list.length; i < len; i++) {
248
- const el = list[i];
249
- scrollIntoView(el, el.querySelector(".actived"));
250
- }
251
- },
252
- );
253
- }
254
- },
255
-
256
- init(val) {
257
- if (val) {
258
- const type = this.type;
259
- if (type === "month") {
260
- this.showPanelMonth();
261
- } else if (type === "year") {
262
- this.showPanelYear();
263
- } else if (type === "time") {
264
- this.showPanelTime();
265
- } else {
266
- this.showPanelDate();
267
- }
268
- this.setListenerForPressEscapeButton();
269
- } else {
270
- this.showPanelNone();
271
- this.updateNow(this.value);
272
- this.destroyListenerForPressEscapeButton();
273
- }
274
- this.emitEventBusDestroyAllListenerForPressButtonsForPanels();
275
- },
276
-
277
- getNow(value) {
278
- return value
279
- ? new Date(value)
280
- : this.defaultValue && isValidDate(this.defaultValue)
281
- ? new Date(this.defaultValue)
282
- : new Date();
283
- },
284
-
285
- updateNow(value) {
286
- this.now = this.getNow(value);
287
- },
288
-
289
- getCriticalTime(value) {
290
- if (!value) {
291
- return null;
292
- }
293
- const date = new Date(value);
294
- if (this.type === "year") {
295
- return new Date(date.getFullYear(), 0).getTime();
296
- } else if (this.type === "month") {
297
- return new Date(date.getFullYear(), date.getMonth()).getTime();
298
- } else if (this.type === "date") {
299
- return date.setHours(0, 0, 0, 0);
300
- }
301
- return date.getTime();
302
- },
303
-
304
- inBefore(time, startAt) {
305
- if (startAt === undefined) {
306
- startAt = this.startAt;
307
- }
308
- return (
309
- (this.notBeforeTime && time < this.notBeforeTime) ||
310
- (startAt && time < this.getCriticalTime(startAt))
311
- );
312
- },
313
-
314
- inAfter(time, endAt) {
315
- if (endAt === undefined) {
316
- endAt = this.endAt;
317
- }
318
- return (
319
- (this.notAfterTime && time > this.notAfterTime) ||
320
- (endAt && time > this.getCriticalTime(endAt))
321
- );
322
- },
323
-
324
- inDisabledDays(time) {
325
- if (Array.isArray(this.disabledDays)) {
326
- return this.disabledDays.some(v => this.getCriticalTime(v) === time);
327
- }
328
- if (typeof this.disabledDays === "function") {
329
- return this.disabledDays(new Date(time));
330
- }
331
- return false;
332
- },
333
-
334
- isDisabledYear(year) {
335
- const time = new Date(year, 0).getTime();
336
- const maxTime = new Date(year + 1, 0).getTime() - 1;
337
- return (
338
- this.inBefore(maxTime) ||
339
- this.inAfter(time) ||
340
- (this.type === "year" && this.inDisabledDays(time))
341
- );
342
- },
343
-
344
- isDisabledMonth(month) {
345
- const time = new Date(this.calendarYear, month).getTime();
346
- const maxTime = new Date(this.calendarYear, month + 1).getTime() - 1;
347
- return (
348
- this.inBefore(maxTime) ||
349
- this.inAfter(time) ||
350
- (this.type === "month" && this.inDisabledDays(time))
351
- );
352
- },
353
-
354
- isDisabledDate(date) {
355
- const time = new Date(date).getTime();
356
- const maxTime = new Date(date).setHours(23, 59, 59, 999);
357
- return (
358
- this.inBefore(maxTime) ||
359
- this.inAfter(time) ||
360
- this.inDisabledDays(time)
361
- );
362
- },
363
-
364
- isDisabledTime(date, startAt, endAt) {
365
- const time = new Date(date).getTime();
366
- return (
367
- this.inBefore(time, startAt) ||
368
- this.inAfter(time, endAt) ||
369
- this.inDisabledDays(time)
370
- );
371
- },
372
-
373
- selectDate(date) {
374
- if (this.type === "datetime") {
375
- let time = new Date(date);
376
- if (isDateObject(this.value)) {
377
- time.setHours(
378
- this.value.getHours(),
379
- this.value.getMinutes(),
380
- this.value.getSeconds(),
381
- );
382
- }
383
- if (this.isDisabledTime(time)) {
384
- time.setHours(0, 0, 0, 0);
385
- if (
386
- this.notBefore &&
387
- time.getTime() < new Date(this.notBefore).getTime()
388
- ) {
389
- time = new Date(this.notBefore);
390
- }
391
- if (
392
- this.startAt &&
393
- time.getTime() < new Date(this.startAt).getTime()
394
- ) {
395
- time = new Date(this.startAt);
396
- }
397
- }
398
- this.selectTime(time);
399
- this.showPanelTime();
400
- return;
401
- }
402
- this.$emit("selectDate", date);
403
- },
404
-
405
- selectYear({ year, isButtonClick }) {
406
- this.changeCalendarYear(year);
407
- if (this.type.toLowerCase() === "year") {
408
- return this.selectDate(new Date(this.now));
409
- }
410
- this.showPanelMonth();
411
- if (isButtonClick) {
412
- this.setFocusToActivePanel();
413
- }
414
- },
415
-
416
- selectMonth({ month, isButtonClick }) {
417
- this.changeCalendarMonth(month);
418
- if (this.type.toLowerCase() === "month") {
419
- return this.selectDate(new Date(this.now));
420
- }
421
- this.showPanelDate();
422
- if (isButtonClick) {
423
- this.setFocusToActivePanel();
424
- }
425
- },
426
-
427
- selectTime(time, statusClose = false) {
428
- this.$emit("selectTime", time, statusClose);
429
- },
430
-
431
- changeCalendarYear(year) {
432
- this.updateNow(new Date(year, this.calendarMonth));
433
- },
434
-
435
- changeCalendarMonth(month) {
436
- this.updateNow(new Date(this.calendarYear, month));
437
- },
438
-
439
- getSibling() {
440
- const PANELS = [
441
- this.$parent.$refs.calendarPanel,
442
- ];
443
- if (this.$parent.$refs.calendarPanel2) {
444
- PANELS.push(this.$parent.$refs.calendarPanel2);
445
- }
446
- const calendars = PANELS.filter(
447
- v => v.$options.name === this.$options.name,
448
- );
449
- const index = calendars.indexOf(this);
450
- /* eslint-disable-next-line no-bitwise */
451
- return calendars[index ^ 1];
452
- },
453
-
454
- handleIconMonth(flag) {
455
- const month = this.calendarMonth;
456
- this.changeCalendarMonth(month + flag);
457
- this.$parent.$emit("changeCalendarMonth", {
458
- month,
459
- flag,
460
- vm: this,
461
- sibling: this.getSibling(),
462
- });
463
- },
464
-
465
- handleIconYear(flag) {
466
- if (this.panel === "YEAR") {
467
- this.changePanelYears(flag);
468
- } else {
469
- const year = this.calendarYear;
470
- this.changeCalendarYear(year + flag);
471
- this.$parent.$emit("changeCalendarYear", {
472
- year,
473
- flag,
474
- vm: this,
475
- sibling: this.getSibling(),
476
- });
477
- }
478
- },
479
-
480
- handleBtnYear() {
481
- this.showPanelYear();
482
- if (this.isWorkWithKeyboard) {
483
- this.setFocusToActivePanel();
484
- }
485
- },
486
-
487
- handleBtnMonth() {
488
- this.showPanelMonth();
489
- if (this.isWorkWithKeyboard) {
490
- this.setFocusToActivePanel();
491
- }
492
- },
493
-
494
- handleTimeHeader() {
495
- if (this.type === "time") {
496
- return;
497
- }
498
- this.showPanelDate();
499
- if (this.isWorkWithKeyboard) {
500
- this.setFocusToActivePanel();
501
- }
502
- },
503
-
504
- changePanelYears(flag) {
505
- this.firstYear = this.firstYear + flag * 10;
506
- },
507
-
508
- showPanelNone() {
509
- this.panel = "NONE";
510
- this.isFocusPanelChild = false;
511
- this.destroyListenerForPressTabButton();
512
- this.emitEventBusDestroyAllListenerForPressButtonsForPanels();
513
- this.setWorkWithoutKeyboard();
514
- },
515
-
516
- showPanelTime() {
517
- this.panel = "TIME";
518
- },
519
-
520
- showPanelDate() {
521
- this.panel = "DATE";
522
- },
523
-
524
- showPanelYear() {
525
- this.panel = "YEAR";
526
- },
527
-
528
- showPanelMonth() {
529
- this.panel = "MONTH";
530
- },
531
-
532
- setFocusToActivePanelFromParent() {
533
- this.setWorkWithKeyboard();
534
- this.setFocusToActivePanel();
535
- this.setListenerForPressTabButton();
536
- },
537
-
538
- setFocusToActivePanel() {
539
- this.isFocusPanelChild = true;
540
- this.setFocusToActiveElementInChild();
541
- },
542
-
543
- removeFocusFromActivePanel() {
544
- if (this.isFocusPanelChild) {
545
- this.isFocusPanelChild = false;
546
- this.emitEventBusDestroyAllListenerForPressButtonsForPanels();
547
- }
548
- },
549
-
550
- setFocusToActiveElementInChild() {
551
- if (this.panel === "DATE") {
552
- this.$refs.panelDate.setFocusToActiveDay();
553
- } else if (this.panel === "TIME") {
554
- this.$refs.panelTime.setFocusToActiveTime();
555
- } else if (this.panel === "YEAR") {
556
- this.$refs.panelYear.setFocusToActiveYear();
557
- } else if (this.panel === "MONTH") {
558
- this.$refs.panelMonth.setFocusToActiveMonth();
559
- }
560
- },
561
-
562
- setListenerForPressTabButton() {
563
- document.addEventListener("keydown", this.pressTabButton);
564
- },
565
-
566
- destroyListenerForPressTabButton() {
567
- document.removeEventListener("keydown", this.pressTabButton);
568
- },
569
-
570
- pressTabButton($event) {
571
- const KEY_CODE = $event.keyCode;
572
- if (KEY_CODE === AKeysCode.tab) {
573
- this.trapFocus($event);
574
- this.stopCurrentEvent($event);
575
- }
576
- },
577
-
578
- trapFocus(EVENT) {
579
- const FOCUSABLE_ELEMENTS = this.$el.querySelectorAll(".pux_datepicker__calendar__tab");
580
- if (FOCUSABLE_ELEMENTS.length <= 1) {
581
- return;
582
- }
583
- let isFocused = false;
584
- let isFocusedPanel = false;
585
- forEach(FOCUSABLE_ELEMENTS, (element, elementIndex) => {
586
- if (document.activeElement === element) {
587
- if (EVENT.shiftKey) {
588
- if (elementIndex === 0) {
589
- FOCUSABLE_ELEMENTS[FOCUSABLE_ELEMENTS.length - 1].focus();
590
- isFocusedPanel = true;
591
- } else {
592
- FOCUSABLE_ELEMENTS[elementIndex - 1].focus();
593
- }
594
- } else {
595
- if (elementIndex === FOCUSABLE_ELEMENTS.length - 1) {
596
- FOCUSABLE_ELEMENTS[0].focus();
597
- } else {
598
- FOCUSABLE_ELEMENTS[elementIndex + 1].focus();
599
- }
600
- if (elementIndex === FOCUSABLE_ELEMENTS.length - 2) {
601
- isFocusedPanel = true;
602
- }
603
- }
604
- isFocused = true;
605
- return false;
606
- }
607
- });
608
- if (!isFocused) {
609
- if (EVENT.shiftKey) {
610
- FOCUSABLE_ELEMENTS[FOCUSABLE_ELEMENTS.length - 2].focus();
611
- } else {
612
- FOCUSABLE_ELEMENTS[0].focus();
613
- }
614
- }
615
- if (isFocusedPanel) {
616
- this.setFocusToActivePanel();
617
- } else {
618
- this.removeFocusFromActivePanel();
619
- }
620
- },
621
-
622
- setWorkWithKeyboard() {
623
- this.isWorkWithKeyboard = true;
624
- },
625
-
626
- setWorkWithoutKeyboard() {
627
- this.isWorkWithKeyboard = false;
628
- },
629
-
630
- setListenerForPressEscapeButton() {
631
- document.addEventListener("keydown", this.pressEscapeButton);
632
- },
633
-
634
- destroyListenerForPressEscapeButton() {
635
- document.removeEventListener("keydown", this.pressEscapeButton);
636
- },
637
-
638
- pressEscapeButton($event) {
639
- const KEY_CODE = $event.keyCode;
640
- if (KEY_CODE === AKeysCode.escape) {
641
- this.$emit("closePopup", true);
642
- }
643
- },
644
- },
645
- render() {
646
- return h("div", {
647
- class: ["pux_datepicker__calendar", `pux_datepicker__calendar_${ this.panel.toLowerCase() }`],
648
- role: "region",
649
- "aria-labelledby": this.idForHeaderParent,
650
- }, [
651
- h("div", {
652
- id: this.idForHeaderParent,
653
- class: "a_sr_only",
654
- role: "header",
655
- }, [
656
- h("div", {
657
- id: this.idForHeader,
658
- "aria-live": "polite",
659
- }, [
660
- this.panel === "DATE" && h("span", null, this.months[this.calendarMonth]),
661
- (this.panel === "DATE" || this.panel === "MONTH") && h("span", null, this.calendarYear),
662
- this.panel === "YEAR" && h("span", null, this.yearHeader),
663
- this.panel === "TIME" && h("span", null, this.timeHeader),
664
- ]),
665
- h("div", null, this.suffixForHeader),
666
- ]),
667
- h("div", {
668
- class: "pux_datepicker__calendar__header",
669
- }, [
670
- h("div", null, [
671
- this.panel !== "TIME" && h("button", {
672
- class: "pux_datepicker__icon_last_year pux_datepicker__calendar__tab",
673
- type: "button",
674
- ariaLabel: this.ariaLabelForButtonLastYear,
675
- innerHTML: "&laquo;",
676
- onClick: () => this.handleIconYear(-1),
677
- }),
678
- this.panel === "DATE" && h("button", {
679
- class: "pux_datepicker__icon_last_month pux_datepicker__calendar__tab",
680
- type: "button",
681
- ariaLabel: this.ariaLabelForButtonLastMonth,
682
- innerHTML: "&lsaquo;",
683
- onClick: () => this.handleIconMonth(-1),
684
- }),
685
- ]),
686
- h("div", null, [
687
- this.panel === "DATE" && h("button", {
688
- class: "pux_datepicker__current_month pux_datepicker__calendar__tab",
689
- type: "button",
690
- ariaLabel: this.ariaLabelForButtonCurrentMonth,
691
- onClick: this.handleBtnMonth,
692
- }, this.months[this.calendarMonth]),
693
- (this.panel === "DATE" || this.panel === "MONTH") && h("button", {
694
- class: "pux_datepicker__current_year pux_datepicker__calendar__tab",
695
- type: "button",
696
- ariaLabel: this.ariaLabelForButtonCurrentYear,
697
- onClick: this.handleBtnYear,
698
- }, this.calendarYear),
699
- this.panel === "YEAR" && h("span", {
700
- class: "pux_datepicker__current_year",
701
- }, this.yearHeader),
702
- this.panel === "TIME" && h("span", null, [
703
- this.type === "time" ?
704
- h("span", {
705
- class: "pux_datepicker__time_header",
706
- }, this.timeHeader) :
707
- h("button", {
708
- class: "pux_datepicker__time_header pux_datepicker__calendar__tab",
709
- type: "button",
710
- ariaLabel: this.ariaLabelForButtonToDays,
711
- onClick: this.handleTimeHeader,
712
- }, this.timeHeader),
713
- ]),
714
- ]),
715
- h("div", null, [
716
- this.panel === "DATE" && h("button", {
717
- class: "pux_datepicker__icon_next_month pux_datepicker__calendar__tab",
718
- type: "button",
719
- ariaLabel: this.ariaLabelForButtonNextMonth,
720
- innerHTML: "&rsaquo;",
721
- onClick: () => this.handleIconMonth(1),
722
- }),
723
- this.panel !== "TIME" && h("button", {
724
- class: "pux_datepicker__icon_next_year pux_datepicker__calendar__tab",
725
- type: "button",
726
- ariaLabel: this.ariaLabelForButtonNextYear,
727
- innerHTML: "&raquo;",
728
- onClick: () => this.handleIconYear(1),
729
- }),
730
- ]),
731
- ]),
732
- h("div", {
733
- class: "pux_datepicker__calendar__content",
734
- role: "application",
735
- }, [
736
- h(APanelDate, {
737
- ref: "panelDate",
738
- id: this.id,
739
- style: this.panel !== "DATE" ? "display: none;" : "",
740
- class: {
741
- pux_datepicker__panel_focus: this.isFocusPanelChild,
742
- pux_datepicker__calendar__tab: this.panel === "DATE",
743
- },
744
- tabindex: 0,
745
- value: this.value,
746
- dateFormat: this.dateFormat,
747
- calendarMonth: this.calendarMonth,
748
- calendarYear: this.calendarYear,
749
- startAt: this.startAt,
750
- endAt: this.endAt,
751
- firstDayOfWeek: this.firstDayOfWeek,
752
- disabledDate: this.isDisabledDate,
753
- currentLanguage: this.currentLanguage,
754
- onSelect: this.selectDate,
755
- onHandleIconMonth: this.handleIconMonth,
756
- }),
757
- h(APanelYear, {
758
- ref: "panelYear",
759
- id: this.id,
760
- style: this.panel !== "YEAR" ? "display: none;" : "",
761
- class: {
762
- pux_datepicker__panel_focus: this.isFocusPanelChild,
763
- pux_datepicker__calendar__tab: this.panel === "YEAR",
764
- },
765
- value: this.value,
766
- disabledYear: this.isDisabledYear,
767
- firstYear: this.firstYear,
768
- onSelect: this.selectYear,
769
- onHandleIconYear: this.handleIconYear,
770
- }),
771
- h(APanelMonth, {
772
- ref: "panelMonth",
773
- id: this.id,
774
- style: this.panel !== "MONTH" ? "display: none;" : "",
775
- class: {
776
- pux_datepicker__panel_focus: this.isFocusPanelChild,
777
- pux_datepicker__calendar__tab: this.panel === "MONTH",
778
- },
779
- value: this.value,
780
- disabledMonth: this.isDisabledMonth,
781
- calendarYear: this.calendarYear,
782
- currentLanguage: this.currentLanguage,
783
- onSelect: this.selectMonth,
784
- onHandleIconYear: this.handleIconYear,
785
- }),
786
- h(APanelTime, {
787
- ref: "panelTime",
788
- id: this.id,
789
- style: this.panel !== "TIME" ? "display: none;" : "",
790
- class: {
791
- pux_datepicker__panel_focus: this.isFocusPanelChild,
792
- pux_datepicker__calendar__tab: this.panel === "TIME",
793
- },
794
- minuteStep: this.minuteStep,
795
- value: this.value,
796
- disabledTime: this.isDisabledTime,
797
- timeType: this.timeType,
798
- currentLanguage: this.currentLanguage,
799
- onSelect: this.selectTime,
800
- }),
801
- ]),
802
- ]);
803
- },
804
- };
1
+ /* eslint vue/component-api-style: off */
2
+ import {
3
+ h,
4
+ nextTick,
5
+ } from "vue";
6
+
7
+ import APanelDate from "../panel/APanelDate/APanelDate";
8
+ import APanelMonth from "../panel/APanelMonth/APanelMonth";
9
+ import APanelTime from "../panel/APanelTime/APanelTime";
10
+ import APanelYear from "../panel/APanelYear/APanelYear";
11
+
12
+ import AKeysCode from "../../../const/AKeysCode";
13
+ import PanelMixin from "../mixins/PanelMixin";
14
+ import scrollIntoView from "../utils/scroll-into-view";
15
+ import {
16
+ formatDate,
17
+ isDateObject,
18
+ isValidDate,
19
+ } from "../utils";
20
+ import {
21
+ forEach,
22
+ } from "lodash-es";
23
+
24
+ // @vue/component
25
+ export default {
26
+ name: "ADatepickerCalendarPanel",
27
+ components: {
28
+ APanelDate,
29
+ APanelMonth,
30
+ APanelTime,
31
+ APanelYear,
32
+ },
33
+ mixins: [
34
+ PanelMixin,
35
+ ],
36
+ props: {
37
+ id: {
38
+ type: String,
39
+ required: true,
40
+ },
41
+ value: {
42
+ default: null,
43
+ validator: function(val) {
44
+ return val === null || isValidDate(val);
45
+ },
46
+ },
47
+ startAt: {
48
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
49
+ required: false,
50
+ default: undefined,
51
+ },
52
+ endAt: {
53
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
54
+ required: false,
55
+ default: undefined,
56
+ },
57
+ visible: {
58
+ type: Boolean,
59
+ default: false,
60
+ },
61
+ type: {
62
+ type: String,
63
+ default: "date", // ["date", "datetime"]
64
+ },
65
+ dateFormat: {
66
+ type: String,
67
+ default: "YYYY-MM-DD",
68
+ },
69
+ index: {
70
+ type: Number,
71
+ default: undefined,
72
+ },
73
+ defaultValue: {
74
+ validator: function(val) {
75
+ return isValidDate(val);
76
+ },
77
+ default: undefined,
78
+ },
79
+ firstDayOfWeek: {
80
+ default: 7,
81
+ type: Number,
82
+ validator: val => val >= 1 && val <= 7,
83
+ },
84
+ notBefore: {
85
+ default: null,
86
+ validator: function(val) {
87
+ return !val || isValidDate(val);
88
+ },
89
+ },
90
+ notAfter: {
91
+ default: null,
92
+ validator: function(val) {
93
+ return !val || isValidDate(val);
94
+ },
95
+ },
96
+ disabledDays: {
97
+ type: [Array, Function],
98
+ default: function() {
99
+ return [];
100
+ },
101
+ },
102
+ minuteStep: {
103
+ type: Number,
104
+ default: 0,
105
+ validator: val => val >= 0 && val <= 60,
106
+ },
107
+ currentLanguage: {
108
+ type: Object,
109
+ required: true,
110
+ },
111
+ },
112
+ emits: [
113
+ "closePopup",
114
+ "selectDate",
115
+ "selectTime",
116
+ ],
117
+ data() {
118
+ const now = this.getNow(this.value);
119
+ const calendarYear = now.getFullYear();
120
+ const calendarMonth = now.getMonth();
121
+ const firstYear = Math.floor(calendarYear / 10) * 10;
122
+ return {
123
+ panel: "NONE",
124
+ dates: [],
125
+ calendarMonth,
126
+ calendarYear,
127
+ firstYear,
128
+ isFocusPanelChild: false,
129
+ isWorkWithKeyboard: false,
130
+ };
131
+ },
132
+ computed: {
133
+ now: {
134
+ get() {
135
+ return new Date(this.calendarYear, this.calendarMonth).getTime();
136
+ },
137
+ set(val) {
138
+ const now = new Date(val);
139
+ this.calendarYear = now.getFullYear();
140
+ this.calendarMonth = now.getMonth();
141
+ },
142
+ },
143
+
144
+ timeType() {
145
+ const h = /h+/.test(this.$parent.format) ? "12" : "24";
146
+ const a = /A/.test(this.$parent.format) ? "A" : "a";
147
+ return [h, a];
148
+ },
149
+
150
+ timeHeader() {
151
+ if (this.type === "time") {
152
+ return this.$parent.format;
153
+ }
154
+ return this.value && formatDate(this.value, this.dateFormat);
155
+ },
156
+
157
+ yearHeader() {
158
+ const LAST_YEAR = this.firstYear + 9;
159
+ return this.currentLanguage.headerYears(this.firstYear, LAST_YEAR);
160
+ },
161
+
162
+ months() {
163
+ return this.currentLanguage.months;
164
+ },
165
+
166
+ notBeforeTime() {
167
+ return this.getCriticalTime(this.notBefore);
168
+ },
169
+
170
+ notAfterTime() {
171
+ return this.getCriticalTime(this.notAfter);
172
+ },
173
+
174
+ suffixForHeader() {
175
+ if (this.panel === "TIME") {
176
+ return this.currentLanguage.placeholder.regionTime;
177
+ }
178
+ return this.currentLanguage.placeholder.regionDate;
179
+ },
180
+
181
+ idForHeaderParent() {
182
+ return `${ this.idForHeader }_parent`;
183
+ },
184
+
185
+ ariaLabelForButtonLastYear() {
186
+ if (this.panel === "YEAR") {
187
+ return this.currentLanguage.buttons.lastYears;
188
+ }
189
+ return this.currentLanguage.buttons.lastYear;
190
+ },
191
+
192
+ ariaLabelForButtonLastMonth() {
193
+ return this.currentLanguage.buttons.lastMonth;
194
+ },
195
+
196
+ ariaLabelForButtonNextMonth() {
197
+ return this.currentLanguage.buttons.nextMonth;
198
+ },
199
+
200
+ ariaLabelForButtonNextYear() {
201
+ if (this.panel === "YEAR") {
202
+ return this.currentLanguage.buttons.nextYears;
203
+ }
204
+ return this.currentLanguage.buttons.nextYear;
205
+ },
206
+
207
+ ariaLabelForButtonCurrentMonth() {
208
+ return this.currentLanguage.buttons.toMonthsView;
209
+ },
210
+
211
+ ariaLabelForButtonCurrentYear() {
212
+ return this.currentLanguage.buttons.toYearsView;
213
+ },
214
+
215
+ ariaLabelForButtonToDays() {
216
+ return this.currentLanguage.buttons.toDaysView;
217
+ },
218
+ },
219
+ watch: {
220
+ value: {
221
+ immediate: true,
222
+ handler: "updateNow",
223
+ },
224
+ defaultValue: {
225
+ handler: "updateNow",
226
+ },
227
+ visible: {
228
+ immediate: true,
229
+ handler: "init",
230
+ },
231
+ panel: {
232
+ handler: "handelPanelChange",
233
+ },
234
+ },
235
+ beforeUnmount() {
236
+ this.destroyListenerForPressTabButton();
237
+ this.destroyListenerForPressEscapeButton();
238
+ },
239
+ methods: {
240
+ handelPanelChange(panel) {
241
+ if (panel === "YEAR") {
242
+ this.firstYear = Math.floor(this.calendarYear / 10) * 10;
243
+ } else if (panel === "TIME") {
244
+ nextTick().then(
245
+ () => {
246
+ const list = this.$el.querySelectorAll(".pux_datepicker__panel_time .pux_datepicker__time_list");
247
+ for (let i = 0, len = list.length; i < len; i++) {
248
+ const el = list[i];
249
+ scrollIntoView(el, el.querySelector(".actived"));
250
+ }
251
+ },
252
+ );
253
+ }
254
+ },
255
+
256
+ init(val) {
257
+ if (val) {
258
+ const type = this.type;
259
+ if (type === "month") {
260
+ this.showPanelMonth();
261
+ } else if (type === "year") {
262
+ this.showPanelYear();
263
+ } else if (type === "time") {
264
+ this.showPanelTime();
265
+ } else {
266
+ this.showPanelDate();
267
+ }
268
+ this.setListenerForPressEscapeButton();
269
+ } else {
270
+ this.showPanelNone();
271
+ this.updateNow(this.value);
272
+ this.destroyListenerForPressEscapeButton();
273
+ }
274
+ this.emitEventBusDestroyAllListenerForPressButtonsForPanels();
275
+ },
276
+
277
+ getNow(value) {
278
+ return value
279
+ ? new Date(value)
280
+ : this.defaultValue && isValidDate(this.defaultValue)
281
+ ? new Date(this.defaultValue)
282
+ : new Date();
283
+ },
284
+
285
+ updateNow(value) {
286
+ this.now = this.getNow(value);
287
+ },
288
+
289
+ getCriticalTime(value) {
290
+ if (!value) {
291
+ return null;
292
+ }
293
+ const date = new Date(value);
294
+ if (this.type === "year") {
295
+ return new Date(date.getFullYear(), 0).getTime();
296
+ } else if (this.type === "month") {
297
+ return new Date(date.getFullYear(), date.getMonth()).getTime();
298
+ } else if (this.type === "date") {
299
+ return date.setHours(0, 0, 0, 0);
300
+ }
301
+ return date.getTime();
302
+ },
303
+
304
+ inBefore(time, startAt) {
305
+ if (startAt === undefined) {
306
+ startAt = this.startAt;
307
+ }
308
+ return (
309
+ (this.notBeforeTime && time < this.notBeforeTime) ||
310
+ (startAt && time < this.getCriticalTime(startAt))
311
+ );
312
+ },
313
+
314
+ inAfter(time, endAt) {
315
+ if (endAt === undefined) {
316
+ endAt = this.endAt;
317
+ }
318
+ return (
319
+ (this.notAfterTime && time > this.notAfterTime) ||
320
+ (endAt && time > this.getCriticalTime(endAt))
321
+ );
322
+ },
323
+
324
+ inDisabledDays(time) {
325
+ if (Array.isArray(this.disabledDays)) {
326
+ return this.disabledDays.some(v => this.getCriticalTime(v) === time);
327
+ }
328
+ if (typeof this.disabledDays === "function") {
329
+ return this.disabledDays(new Date(time));
330
+ }
331
+ return false;
332
+ },
333
+
334
+ isDisabledYear(year) {
335
+ const time = new Date(year, 0).getTime();
336
+ const maxTime = new Date(year + 1, 0).getTime() - 1;
337
+ return (
338
+ this.inBefore(maxTime) ||
339
+ this.inAfter(time) ||
340
+ (this.type === "year" && this.inDisabledDays(time))
341
+ );
342
+ },
343
+
344
+ isDisabledMonth(month) {
345
+ const time = new Date(this.calendarYear, month).getTime();
346
+ const maxTime = new Date(this.calendarYear, month + 1).getTime() - 1;
347
+ return (
348
+ this.inBefore(maxTime) ||
349
+ this.inAfter(time) ||
350
+ (this.type === "month" && this.inDisabledDays(time))
351
+ );
352
+ },
353
+
354
+ isDisabledDate(date) {
355
+ const time = new Date(date).getTime();
356
+ const maxTime = new Date(date).setHours(23, 59, 59, 999);
357
+ return (
358
+ this.inBefore(maxTime) ||
359
+ this.inAfter(time) ||
360
+ this.inDisabledDays(time)
361
+ );
362
+ },
363
+
364
+ isDisabledTime(date, startAt, endAt) {
365
+ const time = new Date(date).getTime();
366
+ return (
367
+ this.inBefore(time, startAt) ||
368
+ this.inAfter(time, endAt) ||
369
+ this.inDisabledDays(time)
370
+ );
371
+ },
372
+
373
+ selectDate(date) {
374
+ if (this.type === "datetime") {
375
+ let time = new Date(date);
376
+ if (isDateObject(this.value)) {
377
+ time.setHours(
378
+ this.value.getHours(),
379
+ this.value.getMinutes(),
380
+ this.value.getSeconds(),
381
+ );
382
+ }
383
+ if (this.isDisabledTime(time)) {
384
+ time.setHours(0, 0, 0, 0);
385
+ if (
386
+ this.notBefore &&
387
+ time.getTime() < new Date(this.notBefore).getTime()
388
+ ) {
389
+ time = new Date(this.notBefore);
390
+ }
391
+ if (
392
+ this.startAt &&
393
+ time.getTime() < new Date(this.startAt).getTime()
394
+ ) {
395
+ time = new Date(this.startAt);
396
+ }
397
+ }
398
+ this.selectTime(time);
399
+ this.showPanelTime();
400
+ return;
401
+ }
402
+ this.$emit("selectDate", date);
403
+ },
404
+
405
+ selectYear({ year, isButtonClick }) {
406
+ this.changeCalendarYear(year);
407
+ if (this.type.toLowerCase() === "year") {
408
+ return this.selectDate(new Date(this.now));
409
+ }
410
+ this.showPanelMonth();
411
+ if (isButtonClick) {
412
+ this.setFocusToActivePanel();
413
+ }
414
+ },
415
+
416
+ selectMonth({ month, isButtonClick }) {
417
+ this.changeCalendarMonth(month);
418
+ if (this.type.toLowerCase() === "month") {
419
+ return this.selectDate(new Date(this.now));
420
+ }
421
+ this.showPanelDate();
422
+ if (isButtonClick) {
423
+ this.setFocusToActivePanel();
424
+ }
425
+ },
426
+
427
+ selectTime(time, statusClose = false) {
428
+ this.$emit("selectTime", time, statusClose);
429
+ },
430
+
431
+ changeCalendarYear(year) {
432
+ this.updateNow(new Date(year, this.calendarMonth));
433
+ },
434
+
435
+ changeCalendarMonth(month) {
436
+ this.updateNow(new Date(this.calendarYear, month));
437
+ },
438
+
439
+ getSibling() {
440
+ const PANELS = [
441
+ this.$parent.$refs.calendarPanel,
442
+ ];
443
+ if (this.$parent.$refs.calendarPanel2) {
444
+ PANELS.push(this.$parent.$refs.calendarPanel2);
445
+ }
446
+ const calendars = PANELS.filter(
447
+ v => v.$options.name === this.$options.name,
448
+ );
449
+ const index = calendars.indexOf(this);
450
+ /* eslint-disable-next-line no-bitwise */
451
+ return calendars[index ^ 1];
452
+ },
453
+
454
+ handleIconMonth(flag) {
455
+ const month = this.calendarMonth;
456
+ this.changeCalendarMonth(month + flag);
457
+ this.$parent.$emit("changeCalendarMonth", {
458
+ month,
459
+ flag,
460
+ vm: this,
461
+ sibling: this.getSibling(),
462
+ });
463
+ },
464
+
465
+ handleIconYear(flag) {
466
+ if (this.panel === "YEAR") {
467
+ this.changePanelYears(flag);
468
+ } else {
469
+ const year = this.calendarYear;
470
+ this.changeCalendarYear(year + flag);
471
+ this.$parent.$emit("changeCalendarYear", {
472
+ year,
473
+ flag,
474
+ vm: this,
475
+ sibling: this.getSibling(),
476
+ });
477
+ }
478
+ },
479
+
480
+ handleBtnYear() {
481
+ this.showPanelYear();
482
+ if (this.isWorkWithKeyboard) {
483
+ this.setFocusToActivePanel();
484
+ }
485
+ },
486
+
487
+ handleBtnMonth() {
488
+ this.showPanelMonth();
489
+ if (this.isWorkWithKeyboard) {
490
+ this.setFocusToActivePanel();
491
+ }
492
+ },
493
+
494
+ handleTimeHeader() {
495
+ if (this.type === "time") {
496
+ return;
497
+ }
498
+ this.showPanelDate();
499
+ if (this.isWorkWithKeyboard) {
500
+ this.setFocusToActivePanel();
501
+ }
502
+ },
503
+
504
+ changePanelYears(flag) {
505
+ this.firstYear = this.firstYear + flag * 10;
506
+ },
507
+
508
+ showPanelNone() {
509
+ this.panel = "NONE";
510
+ this.isFocusPanelChild = false;
511
+ this.destroyListenerForPressTabButton();
512
+ this.emitEventBusDestroyAllListenerForPressButtonsForPanels();
513
+ this.setWorkWithoutKeyboard();
514
+ },
515
+
516
+ showPanelTime() {
517
+ this.panel = "TIME";
518
+ },
519
+
520
+ showPanelDate() {
521
+ this.panel = "DATE";
522
+ },
523
+
524
+ showPanelYear() {
525
+ this.panel = "YEAR";
526
+ },
527
+
528
+ showPanelMonth() {
529
+ this.panel = "MONTH";
530
+ },
531
+
532
+ setFocusToActivePanelFromParent() {
533
+ this.setWorkWithKeyboard();
534
+ this.setFocusToActivePanel();
535
+ this.setListenerForPressTabButton();
536
+ },
537
+
538
+ setFocusToActivePanel() {
539
+ this.isFocusPanelChild = true;
540
+ this.setFocusToActiveElementInChild();
541
+ },
542
+
543
+ removeFocusFromActivePanel() {
544
+ if (this.isFocusPanelChild) {
545
+ this.isFocusPanelChild = false;
546
+ this.emitEventBusDestroyAllListenerForPressButtonsForPanels();
547
+ }
548
+ },
549
+
550
+ setFocusToActiveElementInChild() {
551
+ if (this.panel === "DATE") {
552
+ this.$refs.panelDate.setFocusToActiveDay();
553
+ } else if (this.panel === "TIME") {
554
+ this.$refs.panelTime.setFocusToActiveTime();
555
+ } else if (this.panel === "YEAR") {
556
+ this.$refs.panelYear.setFocusToActiveYear();
557
+ } else if (this.panel === "MONTH") {
558
+ this.$refs.panelMonth.setFocusToActiveMonth();
559
+ }
560
+ },
561
+
562
+ setListenerForPressTabButton() {
563
+ document.addEventListener("keydown", this.pressTabButton);
564
+ },
565
+
566
+ destroyListenerForPressTabButton() {
567
+ document.removeEventListener("keydown", this.pressTabButton);
568
+ },
569
+
570
+ pressTabButton($event) {
571
+ const KEY_CODE = $event.keyCode;
572
+ if (KEY_CODE === AKeysCode.tab) {
573
+ this.trapFocus($event);
574
+ this.stopCurrentEvent($event);
575
+ }
576
+ },
577
+
578
+ trapFocus(EVENT) {
579
+ const FOCUSABLE_ELEMENTS = this.$el.querySelectorAll(".pux_datepicker__calendar__tab");
580
+ if (FOCUSABLE_ELEMENTS.length <= 1) {
581
+ return;
582
+ }
583
+ let isFocused = false;
584
+ let isFocusedPanel = false;
585
+ forEach(FOCUSABLE_ELEMENTS, (element, elementIndex) => {
586
+ if (document.activeElement === element) {
587
+ if (EVENT.shiftKey) {
588
+ if (elementIndex === 0) {
589
+ FOCUSABLE_ELEMENTS[FOCUSABLE_ELEMENTS.length - 1].focus();
590
+ isFocusedPanel = true;
591
+ } else {
592
+ FOCUSABLE_ELEMENTS[elementIndex - 1].focus();
593
+ }
594
+ } else {
595
+ if (elementIndex === FOCUSABLE_ELEMENTS.length - 1) {
596
+ FOCUSABLE_ELEMENTS[0].focus();
597
+ } else {
598
+ FOCUSABLE_ELEMENTS[elementIndex + 1].focus();
599
+ }
600
+ if (elementIndex === FOCUSABLE_ELEMENTS.length - 2) {
601
+ isFocusedPanel = true;
602
+ }
603
+ }
604
+ isFocused = true;
605
+ return false;
606
+ }
607
+ });
608
+ if (!isFocused) {
609
+ if (EVENT.shiftKey) {
610
+ FOCUSABLE_ELEMENTS[FOCUSABLE_ELEMENTS.length - 2].focus();
611
+ } else {
612
+ FOCUSABLE_ELEMENTS[0].focus();
613
+ }
614
+ }
615
+ if (isFocusedPanel) {
616
+ this.setFocusToActivePanel();
617
+ } else {
618
+ this.removeFocusFromActivePanel();
619
+ }
620
+ },
621
+
622
+ setWorkWithKeyboard() {
623
+ this.isWorkWithKeyboard = true;
624
+ },
625
+
626
+ setWorkWithoutKeyboard() {
627
+ this.isWorkWithKeyboard = false;
628
+ },
629
+
630
+ setListenerForPressEscapeButton() {
631
+ document.addEventListener("keydown", this.pressEscapeButton);
632
+ },
633
+
634
+ destroyListenerForPressEscapeButton() {
635
+ document.removeEventListener("keydown", this.pressEscapeButton);
636
+ },
637
+
638
+ pressEscapeButton($event) {
639
+ const KEY_CODE = $event.keyCode;
640
+ if (KEY_CODE === AKeysCode.escape) {
641
+ this.$emit("closePopup", true);
642
+ }
643
+ },
644
+ },
645
+ render() {
646
+ return h("div", {
647
+ class: ["pux_datepicker__calendar", `pux_datepicker__calendar_${ this.panel.toLowerCase() }`],
648
+ role: "region",
649
+ "aria-labelledby": this.idForHeaderParent,
650
+ }, [
651
+ h("div", {
652
+ id: this.idForHeaderParent,
653
+ class: "a_sr_only",
654
+ role: "header",
655
+ }, [
656
+ h("div", {
657
+ id: this.idForHeader,
658
+ "aria-live": "polite",
659
+ }, [
660
+ this.panel === "DATE" && h("span", null, this.months[this.calendarMonth]),
661
+ (this.panel === "DATE" || this.panel === "MONTH") && h("span", null, this.calendarYear),
662
+ this.panel === "YEAR" && h("span", null, this.yearHeader),
663
+ this.panel === "TIME" && h("span", null, this.timeHeader),
664
+ ]),
665
+ h("div", null, this.suffixForHeader),
666
+ ]),
667
+ h("div", {
668
+ class: "pux_datepicker__calendar__header",
669
+ }, [
670
+ h("div", null, [
671
+ this.panel !== "TIME" && h("button", {
672
+ class: "pux_datepicker__icon_last_year pux_datepicker__calendar__tab",
673
+ type: "button",
674
+ ariaLabel: this.ariaLabelForButtonLastYear,
675
+ innerHTML: "&laquo;",
676
+ onClick: () => this.handleIconYear(-1),
677
+ }),
678
+ this.panel === "DATE" && h("button", {
679
+ class: "pux_datepicker__icon_last_month pux_datepicker__calendar__tab",
680
+ type: "button",
681
+ ariaLabel: this.ariaLabelForButtonLastMonth,
682
+ innerHTML: "&lsaquo;",
683
+ onClick: () => this.handleIconMonth(-1),
684
+ }),
685
+ ]),
686
+ h("div", null, [
687
+ this.panel === "DATE" && h("button", {
688
+ class: "pux_datepicker__current_month pux_datepicker__calendar__tab",
689
+ type: "button",
690
+ ariaLabel: this.ariaLabelForButtonCurrentMonth,
691
+ onClick: this.handleBtnMonth,
692
+ }, this.months[this.calendarMonth]),
693
+ (this.panel === "DATE" || this.panel === "MONTH") && h("button", {
694
+ class: "pux_datepicker__current_year pux_datepicker__calendar__tab",
695
+ type: "button",
696
+ ariaLabel: this.ariaLabelForButtonCurrentYear,
697
+ onClick: this.handleBtnYear,
698
+ }, this.calendarYear),
699
+ this.panel === "YEAR" && h("span", {
700
+ class: "pux_datepicker__current_year",
701
+ }, this.yearHeader),
702
+ this.panel === "TIME" && h("span", null, [
703
+ this.type === "time" ?
704
+ h("span", {
705
+ class: "pux_datepicker__time_header",
706
+ }, this.timeHeader) :
707
+ h("button", {
708
+ class: "pux_datepicker__time_header pux_datepicker__calendar__tab",
709
+ type: "button",
710
+ ariaLabel: this.ariaLabelForButtonToDays,
711
+ onClick: this.handleTimeHeader,
712
+ }, this.timeHeader),
713
+ ]),
714
+ ]),
715
+ h("div", null, [
716
+ this.panel === "DATE" && h("button", {
717
+ class: "pux_datepicker__icon_next_month pux_datepicker__calendar__tab",
718
+ type: "button",
719
+ ariaLabel: this.ariaLabelForButtonNextMonth,
720
+ innerHTML: "&rsaquo;",
721
+ onClick: () => this.handleIconMonth(1),
722
+ }),
723
+ this.panel !== "TIME" && h("button", {
724
+ class: "pux_datepicker__icon_next_year pux_datepicker__calendar__tab",
725
+ type: "button",
726
+ ariaLabel: this.ariaLabelForButtonNextYear,
727
+ innerHTML: "&raquo;",
728
+ onClick: () => this.handleIconYear(1),
729
+ }),
730
+ ]),
731
+ ]),
732
+ h("div", {
733
+ class: "pux_datepicker__calendar__content",
734
+ role: "application",
735
+ }, [
736
+ h(APanelDate, {
737
+ ref: "panelDate",
738
+ id: this.id,
739
+ style: this.panel !== "DATE" ? "display: none;" : "",
740
+ class: {
741
+ pux_datepicker__panel_focus: this.isFocusPanelChild,
742
+ pux_datepicker__calendar__tab: this.panel === "DATE",
743
+ },
744
+ tabindex: 0,
745
+ value: this.value,
746
+ dateFormat: this.dateFormat,
747
+ calendarMonth: this.calendarMonth,
748
+ calendarYear: this.calendarYear,
749
+ startAt: this.startAt,
750
+ endAt: this.endAt,
751
+ firstDayOfWeek: this.firstDayOfWeek,
752
+ disabledDate: this.isDisabledDate,
753
+ currentLanguage: this.currentLanguage,
754
+ onSelect: this.selectDate,
755
+ onHandleIconMonth: this.handleIconMonth,
756
+ }),
757
+ h(APanelYear, {
758
+ ref: "panelYear",
759
+ id: this.id,
760
+ style: this.panel !== "YEAR" ? "display: none;" : "",
761
+ class: {
762
+ pux_datepicker__panel_focus: this.isFocusPanelChild,
763
+ pux_datepicker__calendar__tab: this.panel === "YEAR",
764
+ },
765
+ value: this.value,
766
+ disabledYear: this.isDisabledYear,
767
+ firstYear: this.firstYear,
768
+ onSelect: this.selectYear,
769
+ onHandleIconYear: this.handleIconYear,
770
+ }),
771
+ h(APanelMonth, {
772
+ ref: "panelMonth",
773
+ id: this.id,
774
+ style: this.panel !== "MONTH" ? "display: none;" : "",
775
+ class: {
776
+ pux_datepicker__panel_focus: this.isFocusPanelChild,
777
+ pux_datepicker__calendar__tab: this.panel === "MONTH",
778
+ },
779
+ value: this.value,
780
+ disabledMonth: this.isDisabledMonth,
781
+ calendarYear: this.calendarYear,
782
+ currentLanguage: this.currentLanguage,
783
+ onSelect: this.selectMonth,
784
+ onHandleIconYear: this.handleIconYear,
785
+ }),
786
+ h(APanelTime, {
787
+ ref: "panelTime",
788
+ id: this.id,
789
+ style: this.panel !== "TIME" ? "display: none;" : "",
790
+ class: {
791
+ pux_datepicker__panel_focus: this.isFocusPanelChild,
792
+ pux_datepicker__calendar__tab: this.panel === "TIME",
793
+ },
794
+ minuteStep: this.minuteStep,
795
+ value: this.value,
796
+ disabledTime: this.isDisabledTime,
797
+ timeType: this.timeType,
798
+ currentLanguage: this.currentLanguage,
799
+ onSelect: this.selectTime,
800
+ }),
801
+ ]),
802
+ ]);
803
+ },
804
+ };