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,353 +1,353 @@
1
- /* eslint vue/component-api-style: off */
2
- import {
3
- h,
4
- } from "vue";
5
-
6
- import AKeysCode from "../../../../const/AKeysCode";
7
- import PanelMixin from "../../mixins/PanelMixin";
8
- import moment from "moment";
9
- import {
10
- formatDate,
11
- } from "../../utils";
12
-
13
- // @vue/component
14
- export default {
15
- name: "PanelDate",
16
- mixins: [
17
- PanelMixin,
18
- ],
19
- props: {
20
- value: {
21
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
22
- required: false,
23
- default: undefined,
24
- },
25
- startAt: {
26
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
27
- required: false,
28
- default: undefined,
29
- },
30
- endAt: {
31
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
32
- required: false,
33
- default: undefined,
34
- },
35
- dateFormat: {
36
- type: String,
37
- default: "YYYY-MM-DD",
38
- },
39
- calendarMonth: {
40
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
41
- default: new Date().getMonth(),
42
- },
43
- calendarYear: {
44
- type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
45
- default: new Date().getFullYear(),
46
- },
47
- firstDayOfWeek: {
48
- default: 7,
49
- type: Number,
50
- validator: val => val >= 1 && val <= 7,
51
- },
52
- disabledDate: {
53
- type: Function,
54
- default: () => {
55
- return false;
56
- },
57
- },
58
- currentLanguage: {
59
- type: Object,
60
- required: true,
61
- },
62
- },
63
- emits: [
64
- "handleIconMonth",
65
- "select",
66
- ],
67
- data() {
68
- return {
69
- dayForFocusButton: undefined,
70
- };
71
- },
72
- computed: {
73
- ths() {
74
- return this.getDays(this.firstDayOfWeek);
75
- },
76
-
77
- dates() {
78
- return this.getDates(this.calendarYear, this.calendarMonth, this.firstDayOfWeek);
79
- },
80
-
81
- trsWithTds() {
82
- const TRS_WITH_TDS = [];
83
- for (let i = 0; i < 6; i++) {
84
- const TDS = [];
85
- this.dates.slice(7 * i, 7 * i + 7).forEach(date => {
86
- const IS_TODAY = this.isCurrentDayToday(date);
87
- const CELL_TIME = this.getCellTime(date);
88
- const IS_DISABLED = this.disabledDate(CELL_TIME);
89
- TDS.push({
90
- class: this.getCellClasses({
91
- cellTime: CELL_TIME,
92
- isToday: IS_TODAY,
93
- month: date.month,
94
- }),
95
- id: this.getId({
96
- month: date.month,
97
- day: date.day,
98
- }),
99
- year: date.year,
100
- month: date.month,
101
- fullDate: this.getCellTitle(date),
102
- date: date,
103
- label: date.day,
104
- isToday: IS_TODAY,
105
- isDisabled: IS_DISABLED,
106
- isCurrentMonth: date.month === this.calendarMonth,
107
- });
108
- });
109
- TRS_WITH_TDS.push(TDS);
110
- }
111
- return TRS_WITH_TDS;
112
- },
113
-
114
- dayFromValueOrToday() {
115
- return this.dayFromValue || new Date().getDate();
116
- },
117
-
118
- dayFromValue() {
119
- if (this.value) {
120
- return new Date(this.value).getDate();
121
- }
122
- return "";
123
- },
124
-
125
- idForFocus() {
126
- if (this.dayForFocusButton) {
127
- return `${ this.id }_${ this.dayForFocusButton }`;
128
- }
129
- return "";
130
- },
131
-
132
- daysInMonth() {
133
- return moment(`${ this.calendarYear }_${ this.calendarMonth + 1 }`, "YYYY-MM").daysInMonth();
134
- },
135
-
136
- todayTranslate() {
137
- return this.currentLanguage.today;
138
- },
139
- },
140
- methods: {
141
- selectDate({ year, month, day }) {
142
- const date = new Date(year, month, day);
143
- if (this.disabledDate(date)) {
144
- return;
145
- }
146
- this.$emit("select", date);
147
- },
148
-
149
- getDays(firstDayOfWeek) {
150
- const days = this.currentLanguage.days;
151
- const firstday = parseInt(firstDayOfWeek, 10);
152
- return days.concat(days).slice(firstday, firstday + 7);
153
- },
154
-
155
- getDates(year, month, firstDayOfWeek) {
156
- const arr = [];
157
- const time = new Date(year, month);
158
-
159
- time.setDate(0);
160
- const lastMonthLength = (time.getDay() + 7 - firstDayOfWeek) % 7 + 1;
161
- const lastMonthfirst = time.getDate() - (lastMonthLength - 1);
162
- for (let i = 0; i < lastMonthLength; i++) {
163
- arr.push({ year, month: month - 1, day: lastMonthfirst + i });
164
- }
165
-
166
- time.setMonth(time.getMonth() + 2, 0);
167
- const curMonthLength = time.getDate();
168
- for (let i = 0; i < curMonthLength; i++) {
169
- arr.push({ year, month, day: 1 + i });
170
- }
171
-
172
- time.setMonth(time.getMonth() + 1, 1);
173
- const nextMonthLength = 42 - (lastMonthLength + curMonthLength);
174
- for (let i = 0; i < nextMonthLength; i++) {
175
- arr.push({ year, month: month + 1, day: 1 + i });
176
- }
177
-
178
- return arr;
179
- },
180
-
181
- isCurrentDayToday({ year, month, day }) {
182
- const CELL_TIME = this.getCellTime({ year, month, day });
183
- const TODAY = new Date().setHours(0, 0, 0, 0);
184
- return CELL_TIME === TODAY;
185
- },
186
-
187
- getCellClasses({ cellTime, isToday, month }) {
188
- const CLASSES = [];
189
- const CURRENT_TIME = this.value && new Date(this.value).setHours(0, 0, 0, 0);
190
- const START_TIME = this.startAt && new Date(this.startAt).setHours(0, 0, 0, 0);
191
- const END_TIME = this.endAt && new Date(this.endAt).setHours(0, 0, 0, 0);
192
-
193
- if (month < this.calendarMonth) {
194
- CLASSES.push("last-month");
195
- } else if (month > this.calendarMonth) {
196
- CLASSES.push("next-month");
197
- } else {
198
- CLASSES.push("cur-month");
199
- }
200
-
201
- if (isToday) {
202
- CLASSES.push("today");
203
- }
204
-
205
- if (this.disabledDate(cellTime)) {
206
- CLASSES.push("disabled");
207
- }
208
-
209
- if (CURRENT_TIME) {
210
- if (cellTime === CURRENT_TIME) {
211
- CLASSES.push("actived");
212
- } else if (START_TIME && cellTime <= CURRENT_TIME) {
213
- CLASSES.push("inrange");
214
- } else if (END_TIME && cellTime >= CURRENT_TIME) {
215
- CLASSES.push("inrange");
216
- }
217
- }
218
- return CLASSES.join(" ");
219
- },
220
-
221
- getCellTime({ year, month, day }) {
222
- return new Date(year, month, day).getTime();
223
- },
224
-
225
- getCellTitle({ year, month, day }) {
226
- return formatDate(new Date(year, month, day), this.dateFormat);
227
- },
228
-
229
- getId({ month, day }) {
230
- let id = `${ this.id }_${ day }`;
231
- if (month < this.calendarMonth) {
232
- id += "_last_month";
233
- } else if (month > this.calendarMonth) {
234
- id += "_next_month";
235
- }
236
- return id;
237
- },
238
-
239
- setFocusToActiveDay() {
240
- setTimeout(() => {
241
- this.setDefaultDayForFocusButton();
242
- document.getElementById(this.idForFocus).focus();
243
- this.setListenerForPressButtons();
244
- });
245
- },
246
-
247
- setDefaultDayForFocusButton() {
248
- this.dayForFocusButton = this.dayFromValueOrToday;
249
- },
250
-
251
- pressButton($event) {
252
- const KEY_CODE = $event.keyCode;
253
- if (KEY_CODE === AKeysCode.arrowUp) {
254
- this.setFocusToPast(7);
255
- this.stopCurrentEvent($event);
256
- } else if (KEY_CODE === AKeysCode.arrowDown) {
257
- this.setFocusToFuture(7);
258
- this.stopCurrentEvent($event);
259
- } else if (KEY_CODE === AKeysCode.arrowLeft) {
260
- this.setFocusToPast(1);
261
- this.stopCurrentEvent($event);
262
- } else if (KEY_CODE === AKeysCode.arrowRight) {
263
- this.setFocusToFuture(1);
264
- this.stopCurrentEvent($event);
265
- }
266
- },
267
-
268
- setFocusToPast(minusDays) {
269
- const NEW_DAY_FOR_BUTTON = this.dayForFocusButton - minusDays;
270
- if (NEW_DAY_FOR_BUTTON > 0) {
271
- this.dayForFocusButton = NEW_DAY_FOR_BUTTON;
272
- } else {
273
- this.$emit("handleIconMonth", -1);
274
- setTimeout(() => {
275
- this.dayForFocusButton = this.daysInMonth - Math.abs(NEW_DAY_FOR_BUTTON);
276
- });
277
- }
278
- this.setFocusToElementWithTimeout(this.idForFocus);
279
- },
280
-
281
- setFocusToFuture(plusDays) {
282
- const NEW_DAY_FOR_BUTTON = this.dayForFocusButton + plusDays;
283
- if (NEW_DAY_FOR_BUTTON <= this.daysInMonth) {
284
- this.dayForFocusButton = NEW_DAY_FOR_BUTTON;
285
- } else {
286
- const ALT_DAY_IN_MONTH = this.daysInMonth;
287
- this.$emit("handleIconMonth", 1);
288
- this.dayForFocusButton = NEW_DAY_FOR_BUTTON - ALT_DAY_IN_MONTH;
289
- }
290
- this.setFocusToElementWithTimeout(this.idForFocus);
291
- },
292
-
293
- destroyListenerForPressButtonsCallback() {
294
- this.dayForFocusButton = undefined;
295
- },
296
- },
297
- render() {
298
- return h("table", {
299
- class: "pux_datepicker__panel pux_datepicker__panel_date",
300
- role: "grid",
301
- ariaReadonly: true,
302
- "aria-labelledby": this.idForHeader,
303
- ...this.attributesForMainElement,
304
- }, [
305
- h("thead", null, [
306
- h("tr", null, [
307
- this.ths.map((thData, thIndex) => {
308
- return h("th", {
309
- key: thIndex,
310
- ariaLabel: thData.longName,
311
- }, thData.shortName);
312
- }),
313
- ]),
314
- ]),
315
- h("tbody", null, [
316
- this.trsWithTds.map((tdList, tdListIndex) => {
317
- return h("tr", {
318
- key: tdListIndex,
319
- }, [
320
- tdList.map((tdData, tdDataIndex) => {
321
- return h("td", {
322
- key: tdDataIndex,
323
- class: ["cell", tdData.class, {
324
- pux_datepicker__panel__cell_focus: tdData.id === this.idForFocus,
325
- }],
326
- }, [
327
- h("button", {
328
- id: tdData.id,
329
- class: "pux_datepicker__panel__button",
330
- type: "button",
331
- tabindex: -1,
332
- ariaHidden: true,
333
- ariaSelected: !!(tdData.isCurrentMonth && tdData.label === this.dayFromValue),
334
- onClick: () => this.selectDate(tdData.date),
335
- }, [
336
- h("span", {
337
- ariaHidden: true,
338
- }, tdData.label),
339
- h("span", {
340
- class: "a_sr_only",
341
- }, tdData.fullDate),
342
- tdData.isToday && h("span", {
343
- class: "a_sr_only",
344
- }, this.todayTranslate),
345
- ]),
346
- ]);
347
- }),
348
- ]);
349
- }),
350
- ]),
351
- ]);
352
- },
353
- };
1
+ /* eslint vue/component-api-style: off */
2
+ import {
3
+ h,
4
+ } from "vue";
5
+
6
+ import AKeysCode from "../../../../const/AKeysCode";
7
+ import PanelMixin from "../../mixins/PanelMixin";
8
+ import moment from "moment";
9
+ import {
10
+ formatDate,
11
+ } from "../../utils";
12
+
13
+ // @vue/component
14
+ export default {
15
+ name: "PanelDate",
16
+ mixins: [
17
+ PanelMixin,
18
+ ],
19
+ props: {
20
+ value: {
21
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
22
+ required: false,
23
+ default: undefined,
24
+ },
25
+ startAt: {
26
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
27
+ required: false,
28
+ default: undefined,
29
+ },
30
+ endAt: {
31
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
32
+ required: false,
33
+ default: undefined,
34
+ },
35
+ dateFormat: {
36
+ type: String,
37
+ default: "YYYY-MM-DD",
38
+ },
39
+ calendarMonth: {
40
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
41
+ default: new Date().getMonth(),
42
+ },
43
+ calendarYear: {
44
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
45
+ default: new Date().getFullYear(),
46
+ },
47
+ firstDayOfWeek: {
48
+ default: 7,
49
+ type: Number,
50
+ validator: val => val >= 1 && val <= 7,
51
+ },
52
+ disabledDate: {
53
+ type: Function,
54
+ default: () => {
55
+ return false;
56
+ },
57
+ },
58
+ currentLanguage: {
59
+ type: Object,
60
+ required: true,
61
+ },
62
+ },
63
+ emits: [
64
+ "handleIconMonth",
65
+ "select",
66
+ ],
67
+ data() {
68
+ return {
69
+ dayForFocusButton: undefined,
70
+ };
71
+ },
72
+ computed: {
73
+ ths() {
74
+ return this.getDays(this.firstDayOfWeek);
75
+ },
76
+
77
+ dates() {
78
+ return this.getDates(this.calendarYear, this.calendarMonth, this.firstDayOfWeek);
79
+ },
80
+
81
+ trsWithTds() {
82
+ const TRS_WITH_TDS = [];
83
+ for (let i = 0; i < 6; i++) {
84
+ const TDS = [];
85
+ this.dates.slice(7 * i, 7 * i + 7).forEach(date => {
86
+ const IS_TODAY = this.isCurrentDayToday(date);
87
+ const CELL_TIME = this.getCellTime(date);
88
+ const IS_DISABLED = this.disabledDate(CELL_TIME);
89
+ TDS.push({
90
+ class: this.getCellClasses({
91
+ cellTime: CELL_TIME,
92
+ isToday: IS_TODAY,
93
+ month: date.month,
94
+ }),
95
+ id: this.getId({
96
+ month: date.month,
97
+ day: date.day,
98
+ }),
99
+ year: date.year,
100
+ month: date.month,
101
+ fullDate: this.getCellTitle(date),
102
+ date: date,
103
+ label: date.day,
104
+ isToday: IS_TODAY,
105
+ isDisabled: IS_DISABLED,
106
+ isCurrentMonth: date.month === this.calendarMonth,
107
+ });
108
+ });
109
+ TRS_WITH_TDS.push(TDS);
110
+ }
111
+ return TRS_WITH_TDS;
112
+ },
113
+
114
+ dayFromValueOrToday() {
115
+ return this.dayFromValue || new Date().getDate();
116
+ },
117
+
118
+ dayFromValue() {
119
+ if (this.value) {
120
+ return new Date(this.value).getDate();
121
+ }
122
+ return "";
123
+ },
124
+
125
+ idForFocus() {
126
+ if (this.dayForFocusButton) {
127
+ return `${ this.id }_${ this.dayForFocusButton }`;
128
+ }
129
+ return "";
130
+ },
131
+
132
+ daysInMonth() {
133
+ return moment(`${ this.calendarYear }_${ this.calendarMonth + 1 }`, "YYYY-MM").daysInMonth();
134
+ },
135
+
136
+ todayTranslate() {
137
+ return this.currentLanguage.today;
138
+ },
139
+ },
140
+ methods: {
141
+ selectDate({ year, month, day }) {
142
+ const date = new Date(year, month, day);
143
+ if (this.disabledDate(date)) {
144
+ return;
145
+ }
146
+ this.$emit("select", date);
147
+ },
148
+
149
+ getDays(firstDayOfWeek) {
150
+ const days = this.currentLanguage.days;
151
+ const firstday = parseInt(firstDayOfWeek, 10);
152
+ return days.concat(days).slice(firstday, firstday + 7);
153
+ },
154
+
155
+ getDates(year, month, firstDayOfWeek) {
156
+ const arr = [];
157
+ const time = new Date(year, month);
158
+
159
+ time.setDate(0);
160
+ const lastMonthLength = (time.getDay() + 7 - firstDayOfWeek) % 7 + 1;
161
+ const lastMonthfirst = time.getDate() - (lastMonthLength - 1);
162
+ for (let i = 0; i < lastMonthLength; i++) {
163
+ arr.push({ year, month: month - 1, day: lastMonthfirst + i });
164
+ }
165
+
166
+ time.setMonth(time.getMonth() + 2, 0);
167
+ const curMonthLength = time.getDate();
168
+ for (let i = 0; i < curMonthLength; i++) {
169
+ arr.push({ year, month, day: 1 + i });
170
+ }
171
+
172
+ time.setMonth(time.getMonth() + 1, 1);
173
+ const nextMonthLength = 42 - (lastMonthLength + curMonthLength);
174
+ for (let i = 0; i < nextMonthLength; i++) {
175
+ arr.push({ year, month: month + 1, day: 1 + i });
176
+ }
177
+
178
+ return arr;
179
+ },
180
+
181
+ isCurrentDayToday({ year, month, day }) {
182
+ const CELL_TIME = this.getCellTime({ year, month, day });
183
+ const TODAY = new Date().setHours(0, 0, 0, 0);
184
+ return CELL_TIME === TODAY;
185
+ },
186
+
187
+ getCellClasses({ cellTime, isToday, month }) {
188
+ const CLASSES = [];
189
+ const CURRENT_TIME = this.value && new Date(this.value).setHours(0, 0, 0, 0);
190
+ const START_TIME = this.startAt && new Date(this.startAt).setHours(0, 0, 0, 0);
191
+ const END_TIME = this.endAt && new Date(this.endAt).setHours(0, 0, 0, 0);
192
+
193
+ if (month < this.calendarMonth) {
194
+ CLASSES.push("last-month");
195
+ } else if (month > this.calendarMonth) {
196
+ CLASSES.push("next-month");
197
+ } else {
198
+ CLASSES.push("cur-month");
199
+ }
200
+
201
+ if (isToday) {
202
+ CLASSES.push("today");
203
+ }
204
+
205
+ if (this.disabledDate(cellTime)) {
206
+ CLASSES.push("disabled");
207
+ }
208
+
209
+ if (CURRENT_TIME) {
210
+ if (cellTime === CURRENT_TIME) {
211
+ CLASSES.push("actived");
212
+ } else if (START_TIME && cellTime <= CURRENT_TIME) {
213
+ CLASSES.push("inrange");
214
+ } else if (END_TIME && cellTime >= CURRENT_TIME) {
215
+ CLASSES.push("inrange");
216
+ }
217
+ }
218
+ return CLASSES.join(" ");
219
+ },
220
+
221
+ getCellTime({ year, month, day }) {
222
+ return new Date(year, month, day).getTime();
223
+ },
224
+
225
+ getCellTitle({ year, month, day }) {
226
+ return formatDate(new Date(year, month, day), this.dateFormat);
227
+ },
228
+
229
+ getId({ month, day }) {
230
+ let id = `${ this.id }_${ day }`;
231
+ if (month < this.calendarMonth) {
232
+ id += "_last_month";
233
+ } else if (month > this.calendarMonth) {
234
+ id += "_next_month";
235
+ }
236
+ return id;
237
+ },
238
+
239
+ setFocusToActiveDay() {
240
+ setTimeout(() => {
241
+ this.setDefaultDayForFocusButton();
242
+ document.getElementById(this.idForFocus).focus();
243
+ this.setListenerForPressButtons();
244
+ });
245
+ },
246
+
247
+ setDefaultDayForFocusButton() {
248
+ this.dayForFocusButton = this.dayFromValueOrToday;
249
+ },
250
+
251
+ pressButton($event) {
252
+ const KEY_CODE = $event.keyCode;
253
+ if (KEY_CODE === AKeysCode.arrowUp) {
254
+ this.setFocusToPast(7);
255
+ this.stopCurrentEvent($event);
256
+ } else if (KEY_CODE === AKeysCode.arrowDown) {
257
+ this.setFocusToFuture(7);
258
+ this.stopCurrentEvent($event);
259
+ } else if (KEY_CODE === AKeysCode.arrowLeft) {
260
+ this.setFocusToPast(1);
261
+ this.stopCurrentEvent($event);
262
+ } else if (KEY_CODE === AKeysCode.arrowRight) {
263
+ this.setFocusToFuture(1);
264
+ this.stopCurrentEvent($event);
265
+ }
266
+ },
267
+
268
+ setFocusToPast(minusDays) {
269
+ const NEW_DAY_FOR_BUTTON = this.dayForFocusButton - minusDays;
270
+ if (NEW_DAY_FOR_BUTTON > 0) {
271
+ this.dayForFocusButton = NEW_DAY_FOR_BUTTON;
272
+ } else {
273
+ this.$emit("handleIconMonth", -1);
274
+ setTimeout(() => {
275
+ this.dayForFocusButton = this.daysInMonth - Math.abs(NEW_DAY_FOR_BUTTON);
276
+ });
277
+ }
278
+ this.setFocusToElementWithTimeout(this.idForFocus);
279
+ },
280
+
281
+ setFocusToFuture(plusDays) {
282
+ const NEW_DAY_FOR_BUTTON = this.dayForFocusButton + plusDays;
283
+ if (NEW_DAY_FOR_BUTTON <= this.daysInMonth) {
284
+ this.dayForFocusButton = NEW_DAY_FOR_BUTTON;
285
+ } else {
286
+ const ALT_DAY_IN_MONTH = this.daysInMonth;
287
+ this.$emit("handleIconMonth", 1);
288
+ this.dayForFocusButton = NEW_DAY_FOR_BUTTON - ALT_DAY_IN_MONTH;
289
+ }
290
+ this.setFocusToElementWithTimeout(this.idForFocus);
291
+ },
292
+
293
+ destroyListenerForPressButtonsCallback() {
294
+ this.dayForFocusButton = undefined;
295
+ },
296
+ },
297
+ render() {
298
+ return h("table", {
299
+ class: "pux_datepicker__panel pux_datepicker__panel_date",
300
+ role: "grid",
301
+ ariaReadonly: true,
302
+ "aria-labelledby": this.idForHeader,
303
+ ...this.attributesForMainElement,
304
+ }, [
305
+ h("thead", null, [
306
+ h("tr", null, [
307
+ this.ths.map((thData, thIndex) => {
308
+ return h("th", {
309
+ key: thIndex,
310
+ ariaLabel: thData.longName,
311
+ }, thData.shortName);
312
+ }),
313
+ ]),
314
+ ]),
315
+ h("tbody", null, [
316
+ this.trsWithTds.map((tdList, tdListIndex) => {
317
+ return h("tr", {
318
+ key: tdListIndex,
319
+ }, [
320
+ tdList.map((tdData, tdDataIndex) => {
321
+ return h("td", {
322
+ key: tdDataIndex,
323
+ class: ["cell", tdData.class, {
324
+ pux_datepicker__panel__cell_focus: tdData.id === this.idForFocus,
325
+ }],
326
+ }, [
327
+ h("button", {
328
+ id: tdData.id,
329
+ class: "pux_datepicker__panel__button",
330
+ type: "button",
331
+ tabindex: -1,
332
+ ariaHidden: true,
333
+ ariaSelected: !!(tdData.isCurrentMonth && tdData.label === this.dayFromValue),
334
+ onClick: () => this.selectDate(tdData.date),
335
+ }, [
336
+ h("span", {
337
+ ariaHidden: true,
338
+ }, tdData.label),
339
+ h("span", {
340
+ class: "a_sr_only",
341
+ }, tdData.fullDate),
342
+ tdData.isToday && h("span", {
343
+ class: "a_sr_only",
344
+ }, this.todayTranslate),
345
+ ]),
346
+ ]);
347
+ }),
348
+ ]);
349
+ }),
350
+ ]),
351
+ ]);
352
+ },
353
+ };