aloha-vue 2.74.0 → 2.75.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 (166) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -21
  3. package/dist/aloha-vue.css +13594 -13594
  4. package/dist/aloha-vue.css.map +1 -1
  5. package/dist/aloha-vue.es.js +59266 -64918
  6. package/dist/aloha-vue.umd.js +338 -211
  7. package/package.json +27 -34
  8. package/scss/components/ATable.scss +2 -2
  9. package/scss/utils/button.scss +362 -362
  10. package/scss/utils/funktions.scss +162 -162
  11. package/src/AAccordion/AAccordionItem/AAccordionItem.js +235 -230
  12. package/src/ACarousel/ACarousel.js +7 -2
  13. package/src/ADropdown/ADropdown.js +4 -1
  14. package/src/AFilters/AFilterCenter/AFilterCenter.js +5 -1
  15. package/src/AFilters/AFilterCenter/AFilterCenterItem/AFilterCenterItem.js +7 -2
  16. package/src/AFilters/AFiltersHorizontal/AFiltersHorizontal.js +412 -396
  17. package/src/AFilters/AFiltersHorizontal/AFiltersHorizontalFilter/AFiltersHorizontalFilter.js +102 -99
  18. package/src/AFilters/AFiltersHorizontal/compositionAPI/FiltersSavedDeleteAPI.js +108 -108
  19. package/src/AFilters/AFiltersMain/AFiltersMain.js +114 -111
  20. package/src/AFilters/AFiltersSaveModal/compositionAPI/SaveAPI.js +65 -65
  21. package/src/ALinkCopy/ALinkCopy.js +98 -95
  22. package/src/ALinkCopy/compositionAPI/CopyAPI.js +48 -48
  23. package/src/AList/__tests__/AList.test.js +33 -33
  24. package/src/AList/compositionAPI/__tests__/TagAPI.test.js +43 -43
  25. package/src/AMenu/AMenu.js +4 -1
  26. package/src/AMenu/AMenuBreadcrumbs/AMenuBreadcrumbs.js +240 -237
  27. package/src/AMenu/AMenuPanelLink/AMenuPanelLink.js +4 -1
  28. package/src/AMenu/AMenuSearchPanelBreadcrumbs/AMenuSearchPanelBreadcrumbs.js +122 -119
  29. package/src/AModalWizard/AModalWizard.js +58 -53
  30. package/src/AModalWizard/compositionAPI/__tests__/ScrollAPI.test.js +46 -46
  31. package/src/APagination/APaginationPages/APaginationPages.js +15 -4
  32. package/src/ARate/ARate.js +254 -249
  33. package/src/ARate/ARateIcon/ADecimalIcon/ADecimalIcon.js +53 -50
  34. package/src/ARate/ARateIcon/ARateIcon.js +109 -104
  35. package/src/AResizer/AResizer.js +167 -162
  36. package/src/ATable/ATableHeaderTh/compositionAPI/SortAPI.js +172 -167
  37. package/src/ATable/ATableHeaderThAction/ATableHeaderThAction.js +14 -4
  38. package/src/ATable/ATableHeaderThAction/ATableHeaderThActionItem/ATableHeaderThActionItem.js +191 -184
  39. package/src/ATable/ATablePreviewDown/ATablePreviewDown.js +72 -69
  40. package/src/ATable/ATablePreviewRight/ATablePreviewRight.js +265 -258
  41. package/src/ATable/ATableSortingAdditional/ATableSortingAdditional.js +224 -219
  42. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.AttributesAPI.test.js +39 -39
  43. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ColumnsAPI.test.js +68 -68
  44. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.DropdownAPI.test.js +45 -45
  45. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.FormAPI.test.js +95 -95
  46. package/src/ATable/ATableSortingAdditional/__tests__/ATableSortingAdditional.ModelAPI.test.js +1 -1
  47. package/src/ATable/ATableTd/ATableTd.js +4 -1
  48. package/src/ATable/ATableTdAction/ATableTdAction.js +19 -12
  49. package/src/ATable/ATableTopPanel/ATableTopPanel.js +11 -3
  50. package/src/ATable/ATableTr/ATableTr.js +408 -405
  51. package/src/ATable/__tests__/ATable.HeaderSlot.test.js +102 -97
  52. package/src/ATable/__tests__/ATable.RowIdsAPI.test.js +66 -66
  53. package/src/ATableForm/ATableForm.js +88 -85
  54. package/src/ATableForm/ATableFormCellAction/ATableFormCellAction.js +14 -4
  55. package/src/ATableForm/ATableFormCellDnd/ATableFormCellDnd.js +196 -187
  56. package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +104 -104
  57. package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +200 -212
  58. package/src/ATableForm/__tests__/ATableForm.ListView.test.js +134 -174
  59. package/src/ATableForm/compositionAPI/IconsAPI.js +24 -21
  60. package/src/AVerticalScroll/AVerticalScroll.js +182 -177
  61. package/src/AWizard/AWizard.js +26 -21
  62. package/src/AWizard/AWizardStep/AWizardStep.js +275 -270
  63. package/src/AWizard/compositionAPI/__tests__/ChangeStepAPI.test.js +32 -32
  64. package/src/AWizard/compositionAPI/__tests__/LocalAPI.test.js +55 -55
  65. package/src/PuxDatepicker/PuxDatepickerCalendarPanel/PuxDatepickerCalendarPanel.js +646 -648
  66. package/src/PuxDatepicker/panel/PanelDate/PanelDate.js +300 -301
  67. package/src/PuxDatepicker/panel/PanelMonth/PanelMonth.js +148 -149
  68. package/src/PuxDatepicker/panel/PanelTime/PanelTime.js +256 -257
  69. package/src/PuxDatepicker/panel/PanelYear/PanelYear.js +136 -137
  70. package/src/PuxDatepicker/utils/index.js +100 -100
  71. package/src/compositionAPI/AHttpAPI.js +593 -593
  72. package/src/compositionAPI/__tests__/AHttpAPI.test.js +42 -42
  73. package/src/filters/__tests__/filterBoolean.test.js +38 -38
  74. package/src/filters/__tests__/filterCapitalize.test.js +38 -38
  75. package/src/filters/__tests__/filterCurrency.test.js +21 -21
  76. package/src/filters/__tests__/filterDate.test.js +42 -42
  77. package/src/filters/__tests__/filterDefaultForEmpty.test.js +24 -24
  78. package/src/filters/__tests__/filterEmail.test.js +42 -42
  79. package/src/filters/__tests__/filterEscapeHtml.test.js +45 -45
  80. package/src/filters/__tests__/filterFileSize.test.js +45 -45
  81. package/src/filters/__tests__/filterFloat.test.js +74 -74
  82. package/src/filters/__tests__/filterJson.test.js +74 -74
  83. package/src/filters/__tests__/filterKeyValue.test.js +50 -50
  84. package/src/filters/__tests__/filterLimitTo.test.js +39 -39
  85. package/src/filters/__tests__/filterLink.test.js +41 -41
  86. package/src/filters/__tests__/filterList.test.js +149 -149
  87. package/src/filters/__tests__/filterLowerCase.test.js +38 -38
  88. package/src/filters/__tests__/filterMask.test.js +80 -80
  89. package/src/filters/__tests__/filterPropertyByValue.test.js +27 -27
  90. package/src/filters/__tests__/filterSearchHighlight.test.js +129 -129
  91. package/src/filters/__tests__/filterUpperCase.test.js +38 -38
  92. package/src/filters/__tests__/filterValueByCondition.test.js +3 -3
  93. package/src/filters/filterJson.js +39 -39
  94. package/src/filters/filterValueByCondition.js +2 -2
  95. package/src/plugins/AAlertPlugin.js +16 -5
  96. package/src/plugins/AMultiselectOrderedPlugin.js +88 -81
  97. package/src/plugins/ASelectPlugin.js +12 -10
  98. package/src/ui/ACheckbox/ACheckbox.js +82 -79
  99. package/src/ui/ADatepicker/compositionAPI/EventsAPI.js +297 -297
  100. package/src/ui/ADatepicker/utils/index.js +76 -76
  101. package/src/ui/ADatepickerAlt/ADatepicker.js +912 -912
  102. package/src/ui/ADatepickerAlt/utils/index.js +98 -98
  103. package/src/ui/AFieldset/__tests__/AFieldset.ClassColumn.test.js +113 -114
  104. package/src/ui/AFormElementBtnClear/AFormElementBtnClear.js +4 -1
  105. package/src/ui/AInputCurrency/AInputCurrency.js +20 -15
  106. package/src/ui/AInputCurrency/__tests__/AInputCurrency.ModelAPI.test.js +73 -73
  107. package/src/ui/AInputNumber/AInputNumber.js +17 -12
  108. package/src/ui/AJson/AJson.js +12 -3
  109. package/src/ui/AJson/compositionAPI/JsonAPI.js +116 -116
  110. package/src/ui/ALabel/__tests__/ALabel.IdAPI.test.js +42 -42
  111. package/src/ui/ALabel/__tests__/ALabel.LabelAPI.test.js +33 -33
  112. package/src/ui/ARadio/ARadio.js +80 -77
  113. package/src/ui/ASelect/ASelect.js +390 -383
  114. package/src/ui/ASelect/ASelectElement/ASelectElement.js +179 -176
  115. package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +143 -141
  116. package/src/ui/ASelect/__tests__/SelectedFirstAPI.test.js +101 -101
  117. package/src/ui/ASelect/__tests__/SelectedVisibleAPI.test.js +98 -98
  118. package/src/ui/ASlider/compositionAPI/SliderAPI.js +23 -23
  119. package/src/ui/AValidatedJson/AValidatedJson.js +4 -1
  120. package/src/ui/AValidatedJson/AValidatedJsonItem/AValidatedJsonItem.js +308 -298
  121. package/src/ui/compositionApi/UiCollapseAPI.js +68 -63
  122. package/src/ui/compositionApi/UiInputAutofillAPI.js +41 -41
  123. package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -106
  124. package/src/ui/compositionApi/__tests__/UIExcludeRenderAttributesAPI.test.js +39 -39
  125. package/src/ui/compositionApi/__tests__/UiDataWithKeyIdAndLabelAPI.test.js +128 -128
  126. package/src/ui/compositionApi/__tests__/UiSearchAPI.test.js +71 -71
  127. package/src/utils/EventBus.js +51 -8
  128. package/src/utils/__tests__/EventBus.test.js +138 -0
  129. package/src/utils/__tests__/utils.aOrderBy.test.js +1 -1
  130. package/src/utils/__tests__/utils.aSortBy.test.js +1 -1
  131. package/src/utils/__tests__/utils.getTotalNestedCount.test.js +56 -56
  132. package/src/utils/__tests__/utils.isArrayOfArrays.test.js +44 -44
  133. package/src/utils/__tests__/utils.isArrayOfStrings.test.js +36 -36
  134. package/src/utils/__tests__/utilsArray.aFirst.test.js +1 -1
  135. package/src/utils/__tests__/utilsArray.aLast.test.js +1 -1
  136. package/src/utils/__tests__/utilsLang.isArguments.test.js +1 -1
  137. package/src/utils/__tests__/utilsLang.isArray.test.js +1 -1
  138. package/src/utils/__tests__/utilsLang.isArrayBuffer.test.js +1 -1
  139. package/src/utils/__tests__/utilsLang.isBoolean.test.js +1 -1
  140. package/src/utils/__tests__/utilsLang.isBuffer.test.js +1 -1
  141. package/src/utils/__tests__/utilsLang.isDate.test.js +1 -1
  142. package/src/utils/__tests__/utilsLang.isElement.test.js +5 -3
  143. package/src/utils/__tests__/utilsLang.isError.test.js +1 -1
  144. package/src/utils/__tests__/utilsLang.isFinite.test.js +1 -1
  145. package/src/utils/__tests__/utilsLang.isFunction.test.js +1 -1
  146. package/src/utils/__tests__/utilsLang.isInteger.test.js +1 -1
  147. package/src/utils/__tests__/utilsLang.isMap.test.js +1 -1
  148. package/src/utils/__tests__/utilsLang.isNaN.test.js +1 -1
  149. package/src/utils/__tests__/utilsLang.isNil.test.js +1 -1
  150. package/src/utils/__tests__/utilsLang.isNull.test.js +1 -1
  151. package/src/utils/__tests__/utilsLang.isNumber.test.js +1 -1
  152. package/src/utils/__tests__/utilsLang.isObject.test.js +1 -1
  153. package/src/utils/__tests__/utilsLang.isObjectLike.test.js +5 -3
  154. package/src/utils/__tests__/utilsLang.isPlainObject.test.js +3 -2
  155. package/src/utils/__tests__/utilsLang.isPromise.test.js +5 -2
  156. package/src/utils/__tests__/utilsLang.isRegExp.test.js +1 -1
  157. package/src/utils/__tests__/utilsLang.isSet.test.js +1 -1
  158. package/src/utils/__tests__/utilsLang.isString.test.js +1 -1
  159. package/src/utils/__tests__/utilsLang.isSymbol.test.js +5 -3
  160. package/src/utils/__tests__/utilsLang.isUndefined.test.js +1 -1
  161. package/src/utils/__tests__/utilsLang.isWeakMap.test.js +1 -1
  162. package/src/utils/__tests__/utilsLang.isWeakSet.test.js +1 -1
  163. package/src/utils/__tests__/utilsMath.isEven.test.js +43 -43
  164. package/src/utils/__tests__/utilsMath.isOdd.test.js +43 -43
  165. package/src/utils/__tests__/utilsUi.isModelForFilterNotEmpty.test.js +65 -65
  166. package/src/utils/autosize.js +1 -1
@@ -1,137 +1,136 @@
1
- import PanelYearItem from "../PanelYearItem/PanelYearItem.vue";
2
-
3
- import PanelMixin from "../../mixins/PanelMixin";
4
-
5
- import keysCode from "../../utils/keysCode";
6
- import {
7
- isUndefined,
8
- } from "lodash-es";
9
-
10
- // @vue/component
11
- export default {
12
- name: "PanelYear",
13
- components: {
14
- PanelYearItem,
15
- },
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
- firstYear: {
26
- type: Number,
27
- required: true,
28
- },
29
- disabledYear: {
30
- type: Function,
31
- required: false,
32
- default: undefined,
33
- },
34
- },
35
- emits: [
36
- "handleIconYear",
37
- "select",
38
- ],
39
- data() {
40
- return {
41
- yearIndexForFocus: undefined,
42
- };
43
- },
44
- computed: {
45
- firstYearLocal() {
46
- return Math.floor(this.firstYear / 10) * 10;
47
- },
48
-
49
- yearFromValue() {
50
- return this.value && new Date(this.value).getFullYear();
51
- },
52
-
53
- idForFocus() {
54
- if (!isUndefined(this.yearIndexForFocus)) {
55
- return this.getIdForYear(this.yearIndexForFocus);
56
- }
57
- return "";
58
- },
59
-
60
- yearIndexFromValueOrToday() {
61
- const DIFF_FIRST_AND_VALUE_YEAR = this.yearFromValueOrToday - this.firstYearLocal;
62
- if (DIFF_FIRST_AND_VALUE_YEAR <= 9 && DIFF_FIRST_AND_VALUE_YEAR >= 0) {
63
- return DIFF_FIRST_AND_VALUE_YEAR;
64
- }
65
- return 0;
66
- },
67
-
68
- yearFromValueOrToday() {
69
- return this.yearFromValue || new Date().getFullYear();
70
- },
71
-
72
- prefixForId() {
73
- return `${ this.id }_year_`;
74
- },
75
- },
76
- methods: {
77
- isDisabled(year) {
78
- return !!(typeof this.disabledYear === "function" && this.disabledYear(year));
79
- },
80
-
81
- selectYear({ year, isButtonClick }) {
82
- if (this.isDisabled(year)) {
83
- return;
84
- }
85
- this.$emit("select", ({ year, isButtonClick }));
86
- },
87
-
88
- getIdForYear(yearIndex) {
89
- return `${ this.prefixForId }${ yearIndex }`;
90
- },
91
-
92
- setFocusToActiveYear() {
93
- setTimeout(() => {
94
- this.setDefaultYearForFocus();
95
- document.getElementById(this.idForFocus).focus();
96
- this.setListenerForPressButtons();
97
- });
98
- },
99
-
100
- setDefaultYearForFocus() {
101
- this.yearIndexForFocus = this.yearIndexFromValueOrToday;
102
- },
103
-
104
- pressButton($event) {
105
- const KEY_CODE = $event.keyCode;
106
- if (KEY_CODE === keysCode.arrowUp || KEY_CODE === keysCode.arrowLeft) {
107
- this.setFocusToLastYear();
108
- this.stopCurrentEvent($event);
109
- } else if (KEY_CODE === keysCode.arrowDown || KEY_CODE === keysCode.arrowRight) {
110
- this.setFocusToNextYear();
111
- this.stopCurrentEvent($event);
112
- }
113
- },
114
-
115
- setFocusToLastYear() {
116
- const NEW_YEAR_FOR_FOCUS = this.yearIndexForFocus - 1;
117
- if (NEW_YEAR_FOR_FOCUS >= 0 && NEW_YEAR_FOR_FOCUS <= 9) {
118
- this.yearIndexForFocus = NEW_YEAR_FOR_FOCUS;
119
- } else {
120
- this.$emit("handleIconYear", -1);
121
- this.yearIndexForFocus = 9;
122
- }
123
- this.setFocusToElementWithTimeout(this.idForFocus);
124
- },
125
-
126
- setFocusToNextYear() {
127
- const NEW_YEAR_FOR_FOCUS = this.yearIndexForFocus + 1;
128
- if (NEW_YEAR_FOR_FOCUS <= 9 && NEW_YEAR_FOR_FOCUS >= 0) {
129
- this.yearIndexForFocus = NEW_YEAR_FOR_FOCUS;
130
- } else {
131
- this.$emit("handleIconYear", 1);
132
- this.yearIndexForFocus = 0;
133
- }
134
- this.setFocusToElementWithTimeout(this.idForFocus);
135
- },
136
- },
137
- };
1
+ import PanelYearItem from "../PanelYearItem/PanelYearItem.vue";
2
+
3
+ import PanelMixin from "../../mixins/PanelMixin";
4
+ import keysCode from "../../utils/keysCode";
5
+ import {
6
+ isUndefined,
7
+ } from "lodash-es";
8
+
9
+ // @vue/component
10
+ export default {
11
+ name: "PanelYear",
12
+ components: {
13
+ PanelYearItem,
14
+ },
15
+ mixins: [
16
+ PanelMixin,
17
+ ],
18
+ props: {
19
+ value: {
20
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
21
+ required: false,
22
+ default: undefined,
23
+ },
24
+ firstYear: {
25
+ type: Number,
26
+ required: true,
27
+ },
28
+ disabledYear: {
29
+ type: Function,
30
+ required: false,
31
+ default: undefined,
32
+ },
33
+ },
34
+ emits: [
35
+ "handleIconYear",
36
+ "select",
37
+ ],
38
+ data() {
39
+ return {
40
+ yearIndexForFocus: undefined,
41
+ };
42
+ },
43
+ computed: {
44
+ firstYearLocal() {
45
+ return Math.floor(this.firstYear / 10) * 10;
46
+ },
47
+
48
+ yearFromValue() {
49
+ return this.value && new Date(this.value).getFullYear();
50
+ },
51
+
52
+ idForFocus() {
53
+ if (!isUndefined(this.yearIndexForFocus)) {
54
+ return this.getIdForYear(this.yearIndexForFocus);
55
+ }
56
+ return "";
57
+ },
58
+
59
+ yearIndexFromValueOrToday() {
60
+ const DIFF_FIRST_AND_VALUE_YEAR = this.yearFromValueOrToday - this.firstYearLocal;
61
+ if (DIFF_FIRST_AND_VALUE_YEAR <= 9 && DIFF_FIRST_AND_VALUE_YEAR >= 0) {
62
+ return DIFF_FIRST_AND_VALUE_YEAR;
63
+ }
64
+ return 0;
65
+ },
66
+
67
+ yearFromValueOrToday() {
68
+ return this.yearFromValue || new Date().getFullYear();
69
+ },
70
+
71
+ prefixForId() {
72
+ return `${ this.id }_year_`;
73
+ },
74
+ },
75
+ methods: {
76
+ isDisabled(year) {
77
+ return !!(typeof this.disabledYear === "function" && this.disabledYear(year));
78
+ },
79
+
80
+ selectYear({ year, isButtonClick }) {
81
+ if (this.isDisabled(year)) {
82
+ return;
83
+ }
84
+ this.$emit("select", ({ year, isButtonClick }));
85
+ },
86
+
87
+ getIdForYear(yearIndex) {
88
+ return `${ this.prefixForId }${ yearIndex }`;
89
+ },
90
+
91
+ setFocusToActiveYear() {
92
+ setTimeout(() => {
93
+ this.setDefaultYearForFocus();
94
+ document.getElementById(this.idForFocus).focus();
95
+ this.setListenerForPressButtons();
96
+ });
97
+ },
98
+
99
+ setDefaultYearForFocus() {
100
+ this.yearIndexForFocus = this.yearIndexFromValueOrToday;
101
+ },
102
+
103
+ pressButton($event) {
104
+ const KEY_CODE = $event.keyCode;
105
+ if (KEY_CODE === keysCode.arrowUp || KEY_CODE === keysCode.arrowLeft) {
106
+ this.setFocusToLastYear();
107
+ this.stopCurrentEvent($event);
108
+ } else if (KEY_CODE === keysCode.arrowDown || KEY_CODE === keysCode.arrowRight) {
109
+ this.setFocusToNextYear();
110
+ this.stopCurrentEvent($event);
111
+ }
112
+ },
113
+
114
+ setFocusToLastYear() {
115
+ const NEW_YEAR_FOR_FOCUS = this.yearIndexForFocus - 1;
116
+ if (NEW_YEAR_FOR_FOCUS >= 0 && NEW_YEAR_FOR_FOCUS <= 9) {
117
+ this.yearIndexForFocus = NEW_YEAR_FOR_FOCUS;
118
+ } else {
119
+ this.$emit("handleIconYear", -1);
120
+ this.yearIndexForFocus = 9;
121
+ }
122
+ this.setFocusToElementWithTimeout(this.idForFocus);
123
+ },
124
+
125
+ setFocusToNextYear() {
126
+ const NEW_YEAR_FOR_FOCUS = this.yearIndexForFocus + 1;
127
+ if (NEW_YEAR_FOR_FOCUS <= 9 && NEW_YEAR_FOR_FOCUS >= 0) {
128
+ this.yearIndexForFocus = NEW_YEAR_FOR_FOCUS;
129
+ } else {
130
+ this.$emit("handleIconYear", 1);
131
+ this.yearIndexForFocus = 0;
132
+ }
133
+ this.setFocusToElementWithTimeout(this.idForFocus);
134
+ },
135
+ },
136
+ };
@@ -1,100 +1,100 @@
1
- import {
2
- format as fechaFormat,
3
- parse as fechaParse,
4
- } from "fecha";
5
-
6
-
7
- export function isPlainObject(obj) {
8
- return Object.prototype.toString.call(obj) === "[object Object]";
9
- }
10
-
11
- export function isDateObject(value) {
12
- return value instanceof Date;
13
- }
14
-
15
- export function isValidDate(date) {
16
- if (date === null || date === undefined) {
17
- return false;
18
- }
19
- return !isNaN(new Date(date).getTime());
20
- }
21
-
22
- export function isValidRangeDate(date) {
23
- return (
24
- Array.isArray(date) &&
25
- date.length === 2 &&
26
- isValidDate(date[0]) &&
27
- isValidDate(date[1]) &&
28
- (new Date(date[1]).getTime() >= new Date(date[0]).getTime())
29
- );
30
- }
31
-
32
- export function parseTime(time) {
33
- const VALUES = (time || "").split(":");
34
- if (VALUES.length >= 2) {
35
- const hours = parseInt(VALUES[0], 10);
36
- const minutes = parseInt(VALUES[1], 10);
37
- return {
38
- hours,
39
- minutes,
40
- };
41
- }
42
- return null;
43
- }
44
-
45
- export function formatTime(time, type = "24", a = "a") {
46
- let hours = time.hours;
47
- hours = (type === "24") ? hours : (hours % 12 || 12);
48
- hours = hours < 10 ? "0" + hours : hours;
49
- const minutes = time.minutes < 10 ? "0" + time.minutes : time.minutes;
50
- let result = hours + ":" + minutes;
51
- if (type === "12") {
52
- let suffix = time.hours >= 12 ? "pm" : "am";
53
- if (a === "A") {
54
- suffix = suffix.toUpperCase();
55
- }
56
- result = `${ result } ${ suffix }`;
57
- }
58
- return result;
59
- }
60
-
61
- export function formatDate(date, format) {
62
- if (!date) {
63
- return "";
64
- }
65
- try {
66
- return fechaFormat(new Date(date), format);
67
- } catch (e) {
68
- return "";
69
- }
70
- }
71
-
72
- export function parseDate(value, format) {
73
- try {
74
- return fechaParse(value, format) || null;
75
- } catch (e) {
76
- return null;
77
- }
78
- }
79
-
80
- export function throttle(action, delay) {
81
- let lastRun = 0;
82
- let timeout = null;
83
- return function() {
84
- if (timeout) {
85
- return;
86
- }
87
- const args = arguments;
88
- const elapsed = Date.now() - lastRun;
89
- const callBack = () => {
90
- lastRun = Date.now();
91
- timeout = null;
92
- action.apply(this, args);
93
- };
94
- if (elapsed >= delay) {
95
- callBack();
96
- } else {
97
- timeout = setTimeout(callBack, delay);
98
- }
99
- };
100
- }
1
+ import {
2
+ format as fechaFormat,
3
+ parse as fechaParse,
4
+ } from "fecha";
5
+
6
+
7
+ export function isPlainObject(obj) {
8
+ return Object.prototype.toString.call(obj) === "[object Object]";
9
+ }
10
+
11
+ export function isDateObject(value) {
12
+ return value instanceof Date;
13
+ }
14
+
15
+ export function isValidDate(date) {
16
+ if (date === null || date === undefined) {
17
+ return false;
18
+ }
19
+ return !isNaN(new Date(date).getTime());
20
+ }
21
+
22
+ export function isValidRangeDate(date) {
23
+ return (
24
+ Array.isArray(date) &&
25
+ date.length === 2 &&
26
+ isValidDate(date[0]) &&
27
+ isValidDate(date[1]) &&
28
+ (new Date(date[1]).getTime() >= new Date(date[0]).getTime())
29
+ );
30
+ }
31
+
32
+ export function parseTime(time) {
33
+ const VALUES = (time || "").split(":");
34
+ if (VALUES.length >= 2) {
35
+ const hours = parseInt(VALUES[0], 10);
36
+ const minutes = parseInt(VALUES[1], 10);
37
+ return {
38
+ hours,
39
+ minutes,
40
+ };
41
+ }
42
+ return null;
43
+ }
44
+
45
+ export function formatTime(time, type = "24", a = "a") {
46
+ let hours = time.hours;
47
+ hours = (type === "24") ? hours : (hours % 12 || 12);
48
+ hours = hours < 10 ? "0" + hours : hours;
49
+ const minutes = time.minutes < 10 ? "0" + time.minutes : time.minutes;
50
+ let result = hours + ":" + minutes;
51
+ if (type === "12") {
52
+ let suffix = time.hours >= 12 ? "pm" : "am";
53
+ if (a === "A") {
54
+ suffix = suffix.toUpperCase();
55
+ }
56
+ result = `${ result } ${ suffix }`;
57
+ }
58
+ return result;
59
+ }
60
+
61
+ export function formatDate(date, format) {
62
+ if (!date) {
63
+ return "";
64
+ }
65
+ try {
66
+ return fechaFormat(new Date(date), format);
67
+ } catch(e) {
68
+ return "";
69
+ }
70
+ }
71
+
72
+ export function parseDate(value, format) {
73
+ try {
74
+ return fechaParse(value, format) || null;
75
+ } catch(e) {
76
+ return null;
77
+ }
78
+ }
79
+
80
+ export function throttle(action, delay) {
81
+ let lastRun = 0;
82
+ let timeout = null;
83
+ return function() {
84
+ if (timeout) {
85
+ return;
86
+ }
87
+ const args = arguments;
88
+ const elapsed = Date.now() - lastRun;
89
+ const callBack = () => {
90
+ lastRun = Date.now();
91
+ timeout = null;
92
+ action.apply(this, args);
93
+ };
94
+ if (elapsed >= delay) {
95
+ callBack();
96
+ } else {
97
+ timeout = setTimeout(callBack, delay);
98
+ }
99
+ };
100
+ }