aloha-vue 1.2.170 → 1.2.172

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.
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.170",
17
+ "version": "1.2.172",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -1,125 +1,125 @@
1
- import {
2
- h,
3
- } from "vue";
4
-
5
- import AButton from "../../AButton/AButton";
6
- import AFilterCenterItem from "./AFilterCenterItem/AFilterCenterItem";
7
- import ASpinner from "../../ASpinner/ASpinner";
8
-
9
- import LoadingFiltersAPI from "./compositionAPI/LoadingFiltersAPI";
10
- import VisibleFiltersAPI from "./compositionAPI/VisibleFiltersAPI";
11
-
12
- export default {
13
- name: "AFilterCenter",
14
- props: {
15
- appliedModel: {
16
- type: Object,
17
- required: true,
18
- },
19
- closeAllFilters: {
20
- type: Function,
21
- required: true,
22
- },
23
- closeFilterValue: {
24
- type: Function,
25
- required: true,
26
- },
27
- dataKeyByKeyIdPerFilter: {
28
- type: Object,
29
- required: true,
30
- },
31
- disabled: {
32
- type: Boolean,
33
- required: false,
34
- },
35
- filtersGroup: {
36
- type: Object,
37
- required: true,
38
- default: () => ({
39
- alwaysVisible: [],
40
- filters: [],
41
- }),
42
- },
43
- filtersKeyById: {
44
- type: Object,
45
- required: true,
46
- },
47
- filtersVisibleAll: {
48
- type: Array,
49
- required: true,
50
- },
51
- id: {
52
- type: String,
53
- required: true,
54
- },
55
- },
56
- setup(props) {
57
- const {
58
- hasFilters,
59
- styleHide,
60
- updateVisibleChildFilters,
61
- } = VisibleFiltersAPI(props);
62
-
63
- const {
64
- isLeastOneChildFilterLoading,
65
- updateLoadingChildFilters,
66
- } = LoadingFiltersAPI(props);
67
-
68
- return {
69
- hasFilters,
70
- isLeastOneChildFilterLoading,
71
- styleHide,
72
- updateLoadingChildFilters,
73
- updateVisibleChildFilters,
74
- };
75
- },
76
- render() {
77
- if (!this.hasFilters) {
78
- return null;
79
- }
80
-
81
- return h("div", {
82
- class: "a_filters_center",
83
- }, [
84
- h("div", {
85
- class: "a_filters_center__item",
86
- }, [
87
- this.$slots.filtersHorizontal ?
88
- this.$slots.filtersHorizontal() :
89
- "",
90
- ]),
91
- this.filtersVisibleAll.map(filter => {
92
- return h(AFilterCenterItem, {
93
- key: filter.id,
94
- id: this.id,
95
- disabled: this.disabled,
96
- filter,
97
- closeFilterValue: this.closeFilterValue,
98
- dataKeyByKeyIdPerFilter: this.dataKeyByKeyIdPerFilter,
99
- model: this.appliedModel[filter.modelId || filter.id],
100
- onUpdateVisibleChildFilters: this.updateVisibleChildFilters,
101
- onUpdateLoadingChildFilters: this.updateLoadingChildFilters,
102
- }, this.$slots);
103
- }),
104
- this.isLeastOneChildFilterLoading ? h("div", {
105
- style: this.styleHide,
106
- class: "a_filters_center__item",
107
- }, [
108
- h(ASpinner, {
109
- class: "a_spinner_small",
110
- }),
111
- ]) : "",
112
- h("div", {
113
- class: "a_filters_center__item",
114
- style: this.styleHide,
115
- }, [
116
- h(AButton, {
117
- class: "a_btn a_btn_link a_btn_small",
118
- iconLeft: "Reset",
119
- text: "_A_FILTERS_DESELECT_ALL_",
120
- onClick: this.closeAllFilters,
121
- }),
122
- ]),
123
- ]);
124
- },
125
- };
1
+ import {
2
+ h,
3
+ } from "vue";
4
+
5
+ import AButton from "../../AButton/AButton";
6
+ import AFilterCenterItem from "./AFilterCenterItem/AFilterCenterItem";
7
+ import ASpinner from "../../ASpinner/ASpinner";
8
+
9
+ import LoadingFiltersAPI from "./compositionAPI/LoadingFiltersAPI";
10
+ import VisibleFiltersAPI from "./compositionAPI/VisibleFiltersAPI";
11
+
12
+ export default {
13
+ name: "AFilterCenter",
14
+ props: {
15
+ appliedModel: {
16
+ type: Object,
17
+ required: true,
18
+ },
19
+ closeAllFilters: {
20
+ type: Function,
21
+ required: true,
22
+ },
23
+ closeFilterValue: {
24
+ type: Function,
25
+ required: true,
26
+ },
27
+ dataKeyByKeyIdPerFilter: {
28
+ type: Object,
29
+ required: true,
30
+ },
31
+ disabled: {
32
+ type: Boolean,
33
+ required: false,
34
+ },
35
+ filtersGroup: {
36
+ type: Object,
37
+ required: true,
38
+ default: () => ({
39
+ alwaysVisible: [],
40
+ filters: [],
41
+ }),
42
+ },
43
+ filtersKeyById: {
44
+ type: Object,
45
+ required: true,
46
+ },
47
+ filtersVisibleAll: {
48
+ type: Array,
49
+ required: true,
50
+ },
51
+ id: {
52
+ type: String,
53
+ required: true,
54
+ },
55
+ },
56
+ setup(props) {
57
+ const {
58
+ hasFilters,
59
+ styleHide,
60
+ updateVisibleChildFilters,
61
+ } = VisibleFiltersAPI(props);
62
+
63
+ const {
64
+ isLeastOneChildFilterLoading,
65
+ updateLoadingChildFilters,
66
+ } = LoadingFiltersAPI(props);
67
+
68
+ return {
69
+ hasFilters,
70
+ isLeastOneChildFilterLoading,
71
+ styleHide,
72
+ updateLoadingChildFilters,
73
+ updateVisibleChildFilters,
74
+ };
75
+ },
76
+ render() {
77
+ if (!this.hasFilters) {
78
+ return null;
79
+ }
80
+
81
+ return h("div", {
82
+ class: "a_filters_center",
83
+ }, [
84
+ h("div", {
85
+ class: "a_filters_center__item",
86
+ }, [
87
+ this.$slots.filtersHorizontal ?
88
+ this.$slots.filtersHorizontal() :
89
+ "",
90
+ ]),
91
+ this.filtersVisibleAll.map(filter => {
92
+ return h(AFilterCenterItem, {
93
+ key: filter.modelId || filter.id,
94
+ id: this.id,
95
+ disabled: this.disabled,
96
+ filter,
97
+ closeFilterValue: this.closeFilterValue,
98
+ dataKeyByKeyIdPerFilter: this.dataKeyByKeyIdPerFilter,
99
+ model: this.appliedModel[filter.modelId || filter.id],
100
+ onUpdateVisibleChildFilters: this.updateVisibleChildFilters,
101
+ onUpdateLoadingChildFilters: this.updateLoadingChildFilters,
102
+ }, this.$slots);
103
+ }),
104
+ this.isLeastOneChildFilterLoading ? h("div", {
105
+ style: this.styleHide,
106
+ class: "a_filters_center__item",
107
+ }, [
108
+ h(ASpinner, {
109
+ class: "a_spinner_small",
110
+ }),
111
+ ]) : "",
112
+ h("div", {
113
+ class: "a_filters_center__item",
114
+ style: this.styleHide,
115
+ }, [
116
+ h(AButton, {
117
+ class: "a_btn a_btn_link a_btn_small",
118
+ iconLeft: "Reset",
119
+ text: "_A_FILTERS_DESELECT_ALL_",
120
+ onClick: this.closeAllFilters,
121
+ }),
122
+ ]),
123
+ ]);
124
+ },
125
+ };
@@ -1,42 +1,42 @@
1
- import {
2
- computed,
3
- toRef,
4
- } from "vue";
5
-
6
- import {
7
- typesWithData,
8
- } from "../../../../ui/const/AUiTypes";
9
- import {
10
- isEmpty,
11
- } from "lodash-es";
12
-
13
- export default function IsDataLoadingAPI(props, { emit }, {
14
- hasCurrentFilter = computed(() => false),
15
- }) {
16
- const dataKeyByKeyIdPerFilter = toRef(props, "dataKeyByKeyIdPerFilter");
17
- const filter = toRef(props, "filter");
18
-
19
- const isFilterLoading = computed(() => {
20
- if (!hasCurrentFilter.value) {
21
- return false;
22
- }
23
- if (typesWithData.value[filter.value.type]) {
24
- return isEmpty(dataKeyByKeyIdPerFilter.value[filter.value.id]);
25
- }
26
- return false;
27
- });
28
-
29
- const updateLoadingChildFilters = (newValue, altValue) => {
30
- if (newValue !== altValue) {
31
- emit("updateLoadingChildFilters", {
32
- id: filter.value.id,
33
- isLoading: isFilterLoading.value,
34
- });
35
- }
36
- };
37
-
38
- return {
39
- isFilterLoading,
40
- updateLoadingChildFilters,
41
- };
42
- }
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import {
7
+ typesWithData,
8
+ } from "../../../../ui/const/AUiTypes";
9
+ import {
10
+ isEmpty,
11
+ } from "lodash-es";
12
+
13
+ export default function IsDataLoadingAPI(props, { emit }, {
14
+ hasCurrentFilter = computed(() => false),
15
+ }) {
16
+ const dataKeyByKeyIdPerFilter = toRef(props, "dataKeyByKeyIdPerFilter");
17
+ const filter = toRef(props, "filter");
18
+
19
+ const isFilterLoading = computed(() => {
20
+ if (!hasCurrentFilter.value) {
21
+ return false;
22
+ }
23
+ if (typesWithData.value[filter.value.type]) {
24
+ return isEmpty(dataKeyByKeyIdPerFilter.value[filter.value.modelId || filter.value.id]);
25
+ }
26
+ return false;
27
+ });
28
+
29
+ const updateLoadingChildFilters = (newValue, altValue) => {
30
+ if (newValue !== altValue) {
31
+ emit("updateLoadingChildFilters", {
32
+ id: filter.value.modelId || filter.value.id,
33
+ isLoading: isFilterLoading.value,
34
+ });
35
+ }
36
+ };
37
+
38
+ return {
39
+ isFilterLoading,
40
+ updateLoadingChildFilters,
41
+ };
42
+ }
@@ -1,133 +1,151 @@
1
- import {
2
- computed,
3
- ref,
4
- toRef,
5
- } from "vue";
6
-
7
- import {
8
- typesContainer,
9
- } from "../../../ui/const/AUiTypes";
10
- import {
11
- isModelForFilterNotEmpty,
12
- } from "../../../utils/utilsUi";
13
- import {
14
- cloneDeep,
15
- forEach,
16
- } from "lodash-es";
17
-
18
- export default function FiltersAPI(props, { emit }) {
19
- const filters = toRef(props, "filters");
20
- const filterMain = toRef(props, "filterMain");
21
- const unappliedModel = toRef(props, "unappliedModel");
22
-
23
- const filtersDataKeyById = ref({});
24
- const filtersHorizontalRef = ref(undefined);
25
- const filtersVisibleIds = ref([]);
26
-
27
- const hasFilters = computed(() => {
28
- return !!(filters.value.length || filterMain.value);
29
- });
30
-
31
- const filtersKeyById = computed(() => {
32
- const FILTERS = {};
33
- forEach(cloneDeep(filters.value), filter => {
34
- FILTERS[filter.id] = filter;
35
- if (typesContainer.value[filter.type] &&
36
- filter.children &&
37
- filter.children.length) {
38
- forEach(filter.children, filterChild => {
39
- FILTERS[filterChild.id] = filterChild;
40
- });
41
- }
42
- });
43
- return FILTERS;
44
- });
45
-
46
- const filtersGroup = computed(() => {
47
- const FILTER_GROUP = {
48
- alwaysVisible: [],
49
- filters: [],
50
- };
51
- forEach(cloneDeep(filters.value), filter => {
52
- if (filter.alwaysVisible) {
53
- FILTER_GROUP.alwaysVisible.push(filter);
54
- } else {
55
- FILTER_GROUP.filters.push(filter);
56
- }
57
- });
58
-
59
- return FILTER_GROUP;
60
- });
61
-
62
- const filtersVisible = computed(() => {
63
- const FILTERS = [];
64
- forEach(filtersVisibleIds.value, filterId => {
65
- if (filtersKeyById.value[filterId]) {
66
- FILTERS.push(filtersKeyById.value[filterId]);
67
- }
68
- });
69
- return FILTERS;
70
- });
71
-
72
- const filtersVisibleAll = computed(() => {
73
- const FILTERS = [];
74
- FILTERS.push(...filters.value);
75
- const FILERS_NEW = [];
76
- forEach(FILTERS, filter => {
77
- FILERS_NEW.push(filter);
78
- if (typesContainer.value[filter.type] &&
79
- filter.children &&
80
- filter.children.length) {
81
- forEach(filter.children, filterChild => {
82
- FILERS_NEW.push(filterChild);
83
- });
84
- }
85
- });
86
- return FILERS_NEW;
87
- });
88
-
89
- const setFiltersVisibleIds = () => {
90
- const FILTERS_VISIBLE_IDS = [];
91
- forEach(filtersGroup.value.filters, filter => {
92
- if (isModelForFilterNotEmpty({
93
- filter, modelObj: unappliedModel.value,
94
- })) {
95
- FILTERS_VISIBLE_IDS.push(filter.id);
96
- }
97
- });
98
- filtersVisibleIds.value = FILTERS_VISIBLE_IDS;
99
- };
100
-
101
- const onUpdateModelFilters = ({ model, isUpdateFiltersVisible }) => {
102
- emit("update:unappliedModel", model);
103
-
104
- if (isUpdateFiltersVisible) {
105
- setTimeout(() => {
106
- setFiltersVisibleIds();
107
- });
108
- }
109
- };
110
-
111
- const updateAppliedModel = ({ model }) => {
112
- emit("update:appliedModel", model);
113
- };
114
-
115
- const updateMainModel = ({ model }) => {
116
- emit("update:mainModel", model);
117
- };
118
-
119
- return {
120
- filtersDataKeyById,
121
- filtersGroup,
122
- filtersHorizontalRef,
123
- filtersKeyById,
124
- filtersVisible,
125
- filtersVisibleAll,
126
- filtersVisibleIds,
127
- hasFilters,
128
- onUpdateModelFilters,
129
- setFiltersVisibleIds,
130
- updateAppliedModel,
131
- updateMainModel,
132
- };
133
- }
1
+ import {
2
+ computed,
3
+ ref,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import {
8
+ typesContainer,
9
+ } from "../../../ui/const/AUiTypes";
10
+ import {
11
+ isModelForFilterNotEmpty,
12
+ } from "../../../utils/utilsUi";
13
+ import {
14
+ cloneDeep,
15
+ forEach,
16
+ } from "lodash-es";
17
+
18
+ export default function FiltersAPI(props, { emit }) {
19
+ const filters = toRef(props, "filters");
20
+ const filterMain = toRef(props, "filterMain");
21
+ const unappliedModel = toRef(props, "unappliedModel");
22
+
23
+ const filtersDataKeyById = ref({});
24
+ const filtersHorizontalRef = ref(undefined);
25
+ const filtersVisibleIds = ref([]);
26
+
27
+ const hasFilters = computed(() => {
28
+ return !!(filters.value.length || filterMain.value);
29
+ });
30
+
31
+ const filtersKeyById = computed(() => {
32
+ const FILTERS = {};
33
+ forEach(cloneDeep(filters.value), filter => {
34
+ FILTERS[filter.modelId || filter.id] = {
35
+ ...filter,
36
+ id: filter.modelId || filter.id,
37
+ };
38
+ if (typesContainer.value[filter.type] &&
39
+ filter.children &&
40
+ filter.children.length) {
41
+ forEach(filter.children, filterChild => {
42
+ FILTERS[filter.modelId || filterChild.id] = {
43
+ ...filterChild,
44
+ id: filterChild.modelId || filterChild.id,
45
+ };
46
+ });
47
+ }
48
+ });
49
+ return FILTERS;
50
+ });
51
+
52
+ const filtersGroup = computed(() => {
53
+ const FILTER_GROUP = {
54
+ alwaysVisible: [],
55
+ filters: [],
56
+ };
57
+ forEach(cloneDeep(filters.value), filter => {
58
+ if (filter.alwaysVisible) {
59
+ FILTER_GROUP.alwaysVisible.push({
60
+ ...filter,
61
+ id: filter.modelId || filter.id,
62
+ });
63
+ } else {
64
+ FILTER_GROUP.filters.push({
65
+ ...filter,
66
+ id: filter.modelId || filter.id,
67
+ });
68
+ }
69
+ });
70
+
71
+ return FILTER_GROUP;
72
+ });
73
+
74
+ const filtersVisible = computed(() => {
75
+ const FILTERS = [];
76
+ forEach(filtersVisibleIds.value, filterId => {
77
+ if (filtersKeyById.value[filterId]) {
78
+ FILTERS.push(filtersKeyById.value[filterId]);
79
+ }
80
+ });
81
+ return FILTERS;
82
+ });
83
+
84
+ const filtersVisibleAll = computed(() => {
85
+ const FILTERS = [];
86
+ FILTERS.push(...filters.value);
87
+ const FILERS_NEW = [];
88
+ forEach(FILTERS, filter => {
89
+ FILERS_NEW.push({
90
+ ...filter,
91
+ id: filter.modelId || filter.id,
92
+ });
93
+ if (typesContainer.value[filter.type] &&
94
+ filter.children &&
95
+ filter.children.length) {
96
+ forEach(filter.children, filterChild => {
97
+ FILERS_NEW.push({
98
+ ...filterChild,
99
+ id: filterChild.modelId || filterChild.id,
100
+ });
101
+ });
102
+ }
103
+ });
104
+ return FILERS_NEW;
105
+ });
106
+
107
+ const setFiltersVisibleIds = () => {
108
+ const FILTERS_VISIBLE_IDS = [];
109
+ forEach(filtersGroup.value.filters, filter => {
110
+ if (isModelForFilterNotEmpty({
111
+ filter, modelObj: unappliedModel.value,
112
+ })) {
113
+ FILTERS_VISIBLE_IDS.push(filter.id);
114
+ }
115
+ });
116
+ filtersVisibleIds.value = FILTERS_VISIBLE_IDS;
117
+ };
118
+
119
+ const onUpdateModelFilters = ({ model, isUpdateFiltersVisible }) => {
120
+ emit("update:unappliedModel", model);
121
+
122
+ if (isUpdateFiltersVisible) {
123
+ setTimeout(() => {
124
+ setFiltersVisibleIds();
125
+ });
126
+ }
127
+ };
128
+
129
+ const updateAppliedModel = ({ model }) => {
130
+ emit("update:appliedModel", model);
131
+ };
132
+
133
+ const updateMainModel = ({ model }) => {
134
+ emit("update:mainModel", model);
135
+ };
136
+
137
+ return {
138
+ filtersDataKeyById,
139
+ filtersGroup,
140
+ filtersHorizontalRef,
141
+ filtersKeyById,
142
+ filtersVisible,
143
+ filtersVisibleAll,
144
+ filtersVisibleIds,
145
+ hasFilters,
146
+ onUpdateModelFilters,
147
+ setFiltersVisibleIds,
148
+ updateAppliedModel,
149
+ updateMainModel,
150
+ };
151
+ }