aloha-vue 2.74.0 → 2.75.1

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 (167) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +22 -21
  3. package/dist/aloha-vue.css +105 -105
  4. package/dist/aloha-vue.css.map +1 -1
  5. package/dist/aloha-vue.es.js +59267 -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/ADatepicker.js +6 -5
  100. package/src/ui/ADatepicker/compositionAPI/EventsAPI.js +297 -297
  101. package/src/ui/ADatepicker/utils/index.js +76 -76
  102. package/src/ui/ADatepickerAlt/ADatepicker.js +912 -912
  103. package/src/ui/ADatepickerAlt/utils/index.js +98 -98
  104. package/src/ui/AFieldset/__tests__/AFieldset.ClassColumn.test.js +113 -114
  105. package/src/ui/AFormElementBtnClear/AFormElementBtnClear.js +4 -1
  106. package/src/ui/AInputCurrency/AInputCurrency.js +20 -15
  107. package/src/ui/AInputCurrency/__tests__/AInputCurrency.ModelAPI.test.js +73 -73
  108. package/src/ui/AInputNumber/AInputNumber.js +17 -12
  109. package/src/ui/AJson/AJson.js +12 -3
  110. package/src/ui/AJson/compositionAPI/JsonAPI.js +116 -116
  111. package/src/ui/ALabel/__tests__/ALabel.IdAPI.test.js +42 -42
  112. package/src/ui/ALabel/__tests__/ALabel.LabelAPI.test.js +33 -33
  113. package/src/ui/ARadio/ARadio.js +80 -77
  114. package/src/ui/ASelect/ASelect.js +390 -383
  115. package/src/ui/ASelect/ASelectElement/ASelectElement.js +179 -176
  116. package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +143 -141
  117. package/src/ui/ASelect/__tests__/SelectedFirstAPI.test.js +101 -101
  118. package/src/ui/ASelect/__tests__/SelectedVisibleAPI.test.js +98 -98
  119. package/src/ui/ASlider/compositionAPI/SliderAPI.js +23 -23
  120. package/src/ui/AValidatedJson/AValidatedJson.js +4 -1
  121. package/src/ui/AValidatedJson/AValidatedJsonItem/AValidatedJsonItem.js +308 -298
  122. package/src/ui/compositionApi/UiCollapseAPI.js +68 -63
  123. package/src/ui/compositionApi/UiInputAutofillAPI.js +41 -41
  124. package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -106
  125. package/src/ui/compositionApi/__tests__/UIExcludeRenderAttributesAPI.test.js +39 -39
  126. package/src/ui/compositionApi/__tests__/UiDataWithKeyIdAndLabelAPI.test.js +128 -128
  127. package/src/ui/compositionApi/__tests__/UiSearchAPI.test.js +71 -71
  128. package/src/utils/EventBus.js +51 -8
  129. package/src/utils/__tests__/EventBus.test.js +138 -0
  130. package/src/utils/__tests__/utils.aOrderBy.test.js +1 -1
  131. package/src/utils/__tests__/utils.aSortBy.test.js +1 -1
  132. package/src/utils/__tests__/utils.getTotalNestedCount.test.js +56 -56
  133. package/src/utils/__tests__/utils.isArrayOfArrays.test.js +44 -44
  134. package/src/utils/__tests__/utils.isArrayOfStrings.test.js +36 -36
  135. package/src/utils/__tests__/utilsArray.aFirst.test.js +1 -1
  136. package/src/utils/__tests__/utilsArray.aLast.test.js +1 -1
  137. package/src/utils/__tests__/utilsLang.isArguments.test.js +1 -1
  138. package/src/utils/__tests__/utilsLang.isArray.test.js +1 -1
  139. package/src/utils/__tests__/utilsLang.isArrayBuffer.test.js +1 -1
  140. package/src/utils/__tests__/utilsLang.isBoolean.test.js +1 -1
  141. package/src/utils/__tests__/utilsLang.isBuffer.test.js +1 -1
  142. package/src/utils/__tests__/utilsLang.isDate.test.js +1 -1
  143. package/src/utils/__tests__/utilsLang.isElement.test.js +5 -3
  144. package/src/utils/__tests__/utilsLang.isError.test.js +1 -1
  145. package/src/utils/__tests__/utilsLang.isFinite.test.js +1 -1
  146. package/src/utils/__tests__/utilsLang.isFunction.test.js +1 -1
  147. package/src/utils/__tests__/utilsLang.isInteger.test.js +1 -1
  148. package/src/utils/__tests__/utilsLang.isMap.test.js +1 -1
  149. package/src/utils/__tests__/utilsLang.isNaN.test.js +1 -1
  150. package/src/utils/__tests__/utilsLang.isNil.test.js +1 -1
  151. package/src/utils/__tests__/utilsLang.isNull.test.js +1 -1
  152. package/src/utils/__tests__/utilsLang.isNumber.test.js +1 -1
  153. package/src/utils/__tests__/utilsLang.isObject.test.js +1 -1
  154. package/src/utils/__tests__/utilsLang.isObjectLike.test.js +5 -3
  155. package/src/utils/__tests__/utilsLang.isPlainObject.test.js +3 -2
  156. package/src/utils/__tests__/utilsLang.isPromise.test.js +5 -2
  157. package/src/utils/__tests__/utilsLang.isRegExp.test.js +1 -1
  158. package/src/utils/__tests__/utilsLang.isSet.test.js +1 -1
  159. package/src/utils/__tests__/utilsLang.isString.test.js +1 -1
  160. package/src/utils/__tests__/utilsLang.isSymbol.test.js +5 -3
  161. package/src/utils/__tests__/utilsLang.isUndefined.test.js +1 -1
  162. package/src/utils/__tests__/utilsLang.isWeakMap.test.js +1 -1
  163. package/src/utils/__tests__/utilsLang.isWeakSet.test.js +1 -1
  164. package/src/utils/__tests__/utilsMath.isEven.test.js +43 -43
  165. package/src/utils/__tests__/utilsMath.isOdd.test.js +43 -43
  166. package/src/utils/__tests__/utilsUi.isModelForFilterNotEmpty.test.js +65 -65
  167. package/src/utils/autosize.js +1 -1
@@ -1,249 +1,254 @@
1
- import {
2
- computed,
3
- h,
4
- ref,
5
- toRefs,
6
- } from "vue";
7
-
8
- import AIcon from "../AIcon/AIcon";
9
- import ARateIcon from "./ARateIcon/ARateIcon";
10
- import ATranslation from "../ATranslation/ATranslation";
11
-
12
- import Star from "aloha-svg/dist/js/bootstrap/Star";
13
- import StarFill from "aloha-svg/dist/js/bootstrap/StarFill";
14
-
15
- export default {
16
- name: "ARate",
17
- components: {
18
- AIcon,
19
- ATranslation,
20
- ARateIcon,
21
- },
22
- props: {
23
- text: {
24
- type: String,
25
- default: null,
26
- },
27
- extra: {
28
- type: Object,
29
- required: false,
30
- },
31
- rating: {
32
- type: Number,
33
- default: 5,
34
- },
35
- icon: {
36
- type: String,
37
- default: Star,
38
- },
39
- iconFill: {
40
- type: String,
41
- default: StarFill,
42
- },
43
- readonly: {
44
- type: Boolean,
45
- default: false,
46
- },
47
- showScore: {
48
- type: Boolean,
49
- default: false,
50
- },
51
- modelValue: {
52
- type: Number,
53
- default: 0,
54
- },
55
- color: {
56
- type: String,
57
- default: "yellow",
58
- },
59
- hoveredColor: {
60
- type: String,
61
- default: "orange",
62
- },
63
- halfIcon: {
64
- type: Boolean,
65
- default: false,
66
- },
67
- size: {
68
- type: String,
69
- default: "medium",
70
- validator: value => ["small", "medium", "big"].includes(value),
71
- },
72
- },
73
- emits: ["update:modelValue"],
74
- setup(props, { emit }) {
75
- const {
76
- text,
77
- rating,
78
- modelValue,
79
- showScore,
80
- readonly,
81
- icon,
82
- extra,
83
- color,
84
- hoveredColor,
85
- halfIcon,
86
- size,
87
- } = toRefs(props);
88
-
89
- const localValue = ref(undefined);
90
- const hoveredValue = ref(undefined);
91
- const hoveredIndex = ref(-1);
92
-
93
- const initLocalVars = () => {
94
- localValue.value = modelValue.value;
95
- hoveredValue.value = modelValue.value;
96
- };
97
-
98
- const iconFillValue = computed(() => {
99
- return props.iconFill ? props.iconFill : `${ props.icon }Fill`;
100
- });
101
-
102
- const onDoubleClickIcon = () => {
103
- if (readonly.value) {
104
- return;
105
- }
106
-
107
- localValue.value = 0;
108
- emit("update:modelValue", localValue.value);
109
- };
110
-
111
- const onMouseEnterIcon = (event, index) => {
112
- if (readonly.value) {
113
- return;
114
- }
115
-
116
- hoveredIndex.value = index;
117
-
118
- let value = index + 1;
119
-
120
- if (halfIcon.value) {
121
- const rect = event.target.getBoundingClientRect();
122
- const isLeftHalf = event.clientX - rect.left < rect.width / 2;
123
-
124
- value = isLeftHalf ? index + 0.5 : index + 1;
125
- }
126
-
127
- hoveredValue.value = value;
128
- };
129
-
130
- const onMouseLeaveIcon = () => {
131
- if (readonly.value) {
132
- return;
133
- }
134
-
135
- hoveredIndex.value = -1;
136
- };
137
-
138
- const computedColor = computed(() => {
139
- return Array(rating.value).fill(null).map((_, index) => {
140
- if (index <= hoveredIndex.value) {
141
- return hoveredColor.value;
142
- }
143
- return index < localValue.value ? color.value : null;
144
- });
145
- });
146
-
147
- const onClickIcon = (event, index) => {
148
- if (readonly.value) {
149
- return;
150
- }
151
-
152
- let value = index + 1;
153
-
154
- if (halfIcon.value) {
155
- const rect = event.target.getBoundingClientRect();
156
- const isLeftHalf = event.clientX - rect.left < rect.width / 2;
157
-
158
- value = isLeftHalf ? index + 0.5 : index + 1;
159
- }
160
-
161
- emit("update:modelValue", value);
162
- localValue.value = value;
163
- };
164
-
165
- const computedIconValues = computed(() => {
166
- const value = hoveredIndex.value >= 0 ? hoveredValue.value : localValue.value;
167
- const wholePart = Math.floor(value);
168
- const fractionPart = value % 1;
169
-
170
- const iconsValues = Array(rating.value).fill(0);
171
-
172
- for (let i = 0; i < wholePart; i++) {
173
- iconsValues[i] = 100;
174
- }
175
-
176
- if (fractionPart !== 0 && wholePart < rating.value) {
177
- iconsValues[wholePart] = fractionPart * 100;
178
- }
179
-
180
- return iconsValues;
181
- });
182
-
183
- const onMouseMoveIcon = (event, index) => {
184
- if (readonly.value) {
185
- return;
186
- }
187
-
188
- let value = index + 1;
189
-
190
- if (halfIcon.value) {
191
- const rect = event.target.getBoundingClientRect();
192
- const isLeftHalf = event.clientX - rect.left < rect.width / 2;
193
-
194
- value = isLeftHalf ? index + 0.5 : index + 1;
195
- }
196
-
197
- if (hoveredValue.value !== value) {
198
- hoveredValue.value = value;
199
- hoveredIndex.value = index;
200
- }
201
- };
202
-
203
- initLocalVars();
204
-
205
- return {
206
- rating,
207
- showScore,
208
- readonly,
209
- icon,
210
- iconFill: iconFillValue,
211
- text,
212
- extra,
213
- color,
214
- size,
215
- onMouseEnterIcon,
216
- onMouseLeaveIcon,
217
- onClickIcon,
218
- onDoubleClickIcon,
219
- onMouseMoveIcon,
220
- modelValue: computed(() => localValue.value),
221
- iconValues: computedIconValues,
222
- computedColor,
223
- };
224
- },
225
- render() {
226
- return h("div", { class: "a_rate_container" }, [
227
- ...Array.from({ length: this.rating }, (_, index) => h(ARateIcon, {
228
- class: "a_rate_icon",
229
- icon: this.icon,
230
- iconFill: this.iconFill,
231
- value: this.iconValues[index],
232
- onClick: event => this.onClickIcon(event, index),
233
- onDblclick: this.onDoubleClickIcon,
234
- onMouseenter: event => this.onMouseEnterIcon(event, index),
235
- onMouseleave: this.onMouseLeaveIcon,
236
- onMousemove: event => this.onMouseMoveIcon(event, index),
237
- color: this.computedColor[index],
238
- size: this.size,
239
- key: index,
240
- })),
241
- this.showScore && h("span", { class: "a_rate_score" }, this.modelValue.toString()),
242
- h(ATranslation, {
243
- class: "a_rate_label",
244
- text: this.text,
245
- extra: this.extra,
246
- }),
247
- ]);
248
- },
249
- };
1
+ import {
2
+ computed,
3
+ h,
4
+ ref,
5
+ toRefs,
6
+ } from "vue";
7
+
8
+ import AIcon from "../AIcon/AIcon";
9
+ import ARateIcon from "./ARateIcon/ARateIcon";
10
+ import ATranslation from "../ATranslation/ATranslation";
11
+
12
+ const Star = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star" viewBox="0 0 16 16">
13
+ <path d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.56.56 0 0 0-.163-.505L1.71 6.745l4.052-.576a.53.53 0 0 0 .393-.288L8 2.223l1.847 3.658a.53.53 0 0 0 .393.288l4.052.575-2.906 2.77a.56.56 0 0 0-.163.506l.694 3.957-3.686-1.894a.5.5 0 0 0-.461 0z"/>
14
+ </svg>`;
15
+ const StarFill = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
16
+ <path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
17
+ </svg>`;
18
+
19
+
20
+ export default {
21
+ name: "ARate",
22
+ components: {
23
+ AIcon,
24
+ ATranslation,
25
+ ARateIcon,
26
+ },
27
+ props: {
28
+ text: {
29
+ type: String,
30
+ default: null,
31
+ },
32
+ extra: {
33
+ type: Object,
34
+ required: false,
35
+ },
36
+ rating: {
37
+ type: Number,
38
+ default: 5,
39
+ },
40
+ icon: {
41
+ type: String,
42
+ default: Star,
43
+ },
44
+ iconFill: {
45
+ type: String,
46
+ default: StarFill,
47
+ },
48
+ readonly: {
49
+ type: Boolean,
50
+ default: false,
51
+ },
52
+ showScore: {
53
+ type: Boolean,
54
+ default: false,
55
+ },
56
+ modelValue: {
57
+ type: Number,
58
+ default: 0,
59
+ },
60
+ color: {
61
+ type: String,
62
+ default: "yellow",
63
+ },
64
+ hoveredColor: {
65
+ type: String,
66
+ default: "orange",
67
+ },
68
+ halfIcon: {
69
+ type: Boolean,
70
+ default: false,
71
+ },
72
+ size: {
73
+ type: String,
74
+ default: "medium",
75
+ validator: value => ["small", "medium", "big"].includes(value),
76
+ },
77
+ },
78
+ emits: ["update:modelValue"],
79
+ setup(props, { emit }) {
80
+ const {
81
+ text,
82
+ rating,
83
+ modelValue,
84
+ showScore,
85
+ readonly,
86
+ icon,
87
+ extra,
88
+ color,
89
+ hoveredColor,
90
+ halfIcon,
91
+ size,
92
+ } = toRefs(props);
93
+
94
+ const localValue = ref(undefined);
95
+ const hoveredValue = ref(undefined);
96
+ const hoveredIndex = ref(-1);
97
+
98
+ const initLocalVars = () => {
99
+ localValue.value = modelValue.value;
100
+ hoveredValue.value = modelValue.value;
101
+ };
102
+
103
+ const iconFillValue = computed(() => {
104
+ return props.iconFill ? props.iconFill : `${ props.icon }Fill`;
105
+ });
106
+
107
+ const onDoubleClickIcon = () => {
108
+ if (readonly.value) {
109
+ return;
110
+ }
111
+
112
+ localValue.value = 0;
113
+ emit("update:modelValue", localValue.value);
114
+ };
115
+
116
+ const onMouseEnterIcon = (event, index) => {
117
+ if (readonly.value) {
118
+ return;
119
+ }
120
+
121
+ hoveredIndex.value = index;
122
+
123
+ let value = index + 1;
124
+
125
+ if (halfIcon.value) {
126
+ const rect = event.target.getBoundingClientRect();
127
+ const isLeftHalf = event.clientX - rect.left < rect.width / 2;
128
+
129
+ value = isLeftHalf ? index + 0.5 : index + 1;
130
+ }
131
+
132
+ hoveredValue.value = value;
133
+ };
134
+
135
+ const onMouseLeaveIcon = () => {
136
+ if (readonly.value) {
137
+ return;
138
+ }
139
+
140
+ hoveredIndex.value = -1;
141
+ };
142
+
143
+ const computedColor = computed(() => {
144
+ return Array(rating.value).fill(null).map((_, index) => {
145
+ if (index <= hoveredIndex.value) {
146
+ return hoveredColor.value;
147
+ }
148
+ return index < localValue.value ? color.value : null;
149
+ });
150
+ });
151
+
152
+ const onClickIcon = (event, index) => {
153
+ if (readonly.value) {
154
+ return;
155
+ }
156
+
157
+ let value = index + 1;
158
+
159
+ if (halfIcon.value) {
160
+ const rect = event.target.getBoundingClientRect();
161
+ const isLeftHalf = event.clientX - rect.left < rect.width / 2;
162
+
163
+ value = isLeftHalf ? index + 0.5 : index + 1;
164
+ }
165
+
166
+ emit("update:modelValue", value);
167
+ localValue.value = value;
168
+ };
169
+
170
+ const computedIconValues = computed(() => {
171
+ const value = hoveredIndex.value >= 0 ? hoveredValue.value : localValue.value;
172
+ const wholePart = Math.floor(value);
173
+ const fractionPart = value % 1;
174
+
175
+ const iconsValues = Array(rating.value).fill(0);
176
+
177
+ for (let i = 0; i < wholePart; i++) {
178
+ iconsValues[i] = 100;
179
+ }
180
+
181
+ if (fractionPart !== 0 && wholePart < rating.value) {
182
+ iconsValues[wholePart] = fractionPart * 100;
183
+ }
184
+
185
+ return iconsValues;
186
+ });
187
+
188
+ const onMouseMoveIcon = (event, index) => {
189
+ if (readonly.value) {
190
+ return;
191
+ }
192
+
193
+ let value = index + 1;
194
+
195
+ if (halfIcon.value) {
196
+ const rect = event.target.getBoundingClientRect();
197
+ const isLeftHalf = event.clientX - rect.left < rect.width / 2;
198
+
199
+ value = isLeftHalf ? index + 0.5 : index + 1;
200
+ }
201
+
202
+ if (hoveredValue.value !== value) {
203
+ hoveredValue.value = value;
204
+ hoveredIndex.value = index;
205
+ }
206
+ };
207
+
208
+ initLocalVars();
209
+
210
+ return {
211
+ rating,
212
+ showScore,
213
+ readonly,
214
+ icon,
215
+ iconFill: iconFillValue,
216
+ text,
217
+ extra,
218
+ color,
219
+ size,
220
+ onMouseEnterIcon,
221
+ onMouseLeaveIcon,
222
+ onClickIcon,
223
+ onDoubleClickIcon,
224
+ onMouseMoveIcon,
225
+ modelValue: computed(() => localValue.value),
226
+ iconValues: computedIconValues,
227
+ computedColor,
228
+ };
229
+ },
230
+ render() {
231
+ return h("div", { class: "a_rate_container" }, [
232
+ ...Array.from({ length: this.rating }, (_, index) => h(ARateIcon, {
233
+ class: "a_rate_icon",
234
+ icon: this.icon,
235
+ iconFill: this.iconFill,
236
+ value: this.iconValues[index],
237
+ onClick: event => this.onClickIcon(event, index),
238
+ onDblclick: this.onDoubleClickIcon,
239
+ onMouseenter: event => this.onMouseEnterIcon(event, index),
240
+ onMouseleave: this.onMouseLeaveIcon,
241
+ onMousemove: event => this.onMouseMoveIcon(event, index),
242
+ color: this.computedColor[index],
243
+ size: this.size,
244
+ key: index,
245
+ })),
246
+ this.showScore && h("span", { class: "a_rate_score" }, this.modelValue.toString()),
247
+ h(ATranslation, {
248
+ class: "a_rate_label",
249
+ text: this.text,
250
+ extra: this.extra,
251
+ }),
252
+ ]);
253
+ },
254
+ };
@@ -1,50 +1,53 @@
1
- import {
2
- h,
3
- } from "vue";
4
-
5
- import AIcon from "../../../AIcon/AIcon";
6
-
7
- import StarFill from "aloha-svg/dist/js/bootstrap/StarFill";
8
-
9
- export default {
10
- name: "ADecimalIcon",
11
- components: {
12
- AIcon,
13
- },
14
- props: {
15
- value: {
16
- type: Number,
17
- default: 50,
18
- },
19
- color: {
20
- type: String,
21
- default: "yellow",
22
- },
23
- icon: {
24
- type: String,
25
- default: StarFill,
26
- },
27
- size: {
28
- type: String,
29
- default: "medium",
30
- validator: value => ["small", "medium", "big"].includes(value),
31
- },
32
- },
33
- render() {
34
- const attrs = {
35
- class: "a_decimal_rate_icon a_rate_icon_decimal",
36
- style: {
37
- position: "absolute",
38
- overflow: "hidden",
39
- width: `${ this.value }%`,
40
- color: this.color,
41
- },
42
- };
43
- return h("i", attrs, [
44
- h(AIcon, {
45
- icon: this.icon,
46
- class: `a_decimal_rate_icon a_rate_icon_${ this.size }`,
47
- }),
48
- ]);
49
- },
50
- };
1
+ import {
2
+ h,
3
+ } from "vue";
4
+
5
+ import AIcon from "../../../AIcon/AIcon";
6
+
7
+ const StarFill = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
8
+ <path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
9
+ </svg>`;
10
+
11
+
12
+ export default {
13
+ name: "ADecimalIcon",
14
+ components: {
15
+ AIcon,
16
+ },
17
+ props: {
18
+ value: {
19
+ type: Number,
20
+ default: 50,
21
+ },
22
+ color: {
23
+ type: String,
24
+ default: "yellow",
25
+ },
26
+ icon: {
27
+ type: String,
28
+ default: StarFill,
29
+ },
30
+ size: {
31
+ type: String,
32
+ default: "medium",
33
+ validator: value => ["small", "medium", "big"].includes(value),
34
+ },
35
+ },
36
+ render() {
37
+ const attrs = {
38
+ class: "a_decimal_rate_icon a_rate_icon_decimal",
39
+ style: {
40
+ position: "absolute",
41
+ overflow: "hidden",
42
+ width: `${ this.value }%`,
43
+ color: this.color,
44
+ },
45
+ };
46
+ return h("i", attrs, [
47
+ h(AIcon, {
48
+ icon: this.icon,
49
+ class: `a_decimal_rate_icon a_rate_icon_${ this.size }`,
50
+ }),
51
+ ]);
52
+ },
53
+ };