@eturnity/eturnity_reusable_components 8.16.2--EPDM-14330.3 → 8.16.2--EPDM-14330.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "8.16.2--EPDM-14330.3",
3
+ "version": "8.16.2--EPDM-14330.5",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -0,0 +1,317 @@
1
+ <template>
2
+ <PageContainer>
3
+ <ButtonIcon
4
+ class="button-icon"
5
+ icon-name="sorting"
6
+ :text="$gettext('sort')"
7
+ type="filter"
8
+ @click="toggleOptions"
9
+ />
10
+ <ButtonWrapper v-if="isOptionsVisible">
11
+ <BoxContainer class="box-container">
12
+ <BoxTitle>{{ $gettext('sort') }}</BoxTitle>
13
+ <SortOptionsContainer>
14
+ <template v-if="selectedSort.length > 0">
15
+ <SortDropdownContainer
16
+ v-for="(item, index) in selectedSort"
17
+ :key="index"
18
+ >
19
+ <SelectComponent
20
+ ref="selectSortDropdown"
21
+ align-items="vertical"
22
+ class="sort-dropdown"
23
+ :dropdown-auto-close="false"
24
+ select-height="40px"
25
+ @input-change="
26
+ onSelectSort({
27
+ type: 'column',
28
+ value: $event,
29
+ index: index,
30
+ })
31
+ "
32
+ >
33
+ <template #selector>
34
+ <SelectedText>{{
35
+ getSelectedLabel({ type: 'column', value: item.column }) ||
36
+ $gettext('category')
37
+ }}</SelectedText>
38
+ </template>
39
+ <template #dropdown>
40
+ <SelectOption
41
+ v-for="(item, index) in sortOptions"
42
+ :key="item.value"
43
+ :value="item.value"
44
+ >
45
+ {{ item.label }}
46
+ </SelectOption>
47
+ </template>
48
+ </SelectComponent>
49
+ <SelectComponent
50
+ ref="selectSortDropdown"
51
+ align-items="vertical"
52
+ class="sort-dropdown"
53
+ :dropdown-auto-close="false"
54
+ select-height="40px"
55
+ @input-change="
56
+ onSelectSort({
57
+ type: 'direction',
58
+ value: $event,
59
+ index: index,
60
+ })
61
+ "
62
+ >
63
+ <template #selector>
64
+ <SelectedText>{{
65
+ getSelectedLabel({
66
+ type: 'direction',
67
+ value: item.direction,
68
+ }) || $gettext('constraint')
69
+ }}</SelectedText>
70
+ </template>
71
+ <template #dropdown>
72
+ <SelectOption
73
+ v-for="(item, index) in directionOptions"
74
+ :key="item.value"
75
+ :value="item.value"
76
+ >
77
+ {{ item.label }}
78
+ </SelectOption>
79
+ </template>
80
+ </SelectComponent>
81
+ <IconContainer>
82
+ <RCIcon
83
+ :color="theme.semanticColors.teal[800]"
84
+ cursor="pointer"
85
+ name="close"
86
+ size="14px"
87
+ @click.stop="removeItem(index)"
88
+ />
89
+ </IconContainer>
90
+ </SortDropdownContainer>
91
+ </template>
92
+ <template v-else>
93
+ <SortDropdownContainer>
94
+ <SelectComponent
95
+ ref="selectSortDropdown"
96
+ align-items="vertical"
97
+ class="sort-dropdown"
98
+ :dropdown-auto-close="false"
99
+ select-height="40px"
100
+ @input-change="
101
+ onSelectSort({
102
+ type: 'column',
103
+ value: $event,
104
+ index: 0,
105
+ })
106
+ "
107
+ >
108
+ <template #selector>
109
+ <SelectedText>{{ $gettext('category') }}</SelectedText>
110
+ </template>
111
+ <template #dropdown>
112
+ <SelectOption
113
+ v-for="(item, index) in sortOptions"
114
+ :key="item.value"
115
+ :value="item.value"
116
+ >
117
+ {{ item.label }}
118
+ </SelectOption>
119
+ </template>
120
+ </SelectComponent>
121
+ <SelectComponent
122
+ ref="selectSortDropdown"
123
+ align-items="vertical"
124
+ class="sort-dropdown"
125
+ :dropdown-auto-close="false"
126
+ select-height="40px"
127
+ @input-change="
128
+ onSelectSort({
129
+ type: 'direction',
130
+ value: $event,
131
+ index: 0,
132
+ })
133
+ "
134
+ >
135
+ <template #selector>
136
+ <SelectedText>{{ $gettext('constraint') }}</SelectedText>
137
+ </template>
138
+ <template #dropdown>
139
+ <SelectOption
140
+ v-for="(item, index) in directionOptions"
141
+ :key="item.value"
142
+ :value="item.value"
143
+ >
144
+ {{ item.label }}
145
+ </SelectOption>
146
+ </template>
147
+ </SelectComponent>
148
+ </SortDropdownContainer>
149
+ </template>
150
+ </SortOptionsContainer>
151
+ </BoxContainer>
152
+ </ButtonWrapper>
153
+ </PageContainer>
154
+ </template>
155
+
156
+ <script>
157
+ import styled from 'vue3-styled-components'
158
+ import ButtonIcon from '../buttons/buttonIcon/index.vue'
159
+ import SelectComponent from '../inputs/select/index.vue'
160
+ import SelectOption from '../inputs/select/option/index.vue'
161
+ import RCIcon from '../icon'
162
+ import theme from '../../assets/theme'
163
+
164
+ const PageContainer = styled.div``
165
+
166
+ const ButtonWrapper = styled.div`
167
+ position: relative;
168
+ `
169
+
170
+ const BoxContainer = styled.div`
171
+ position: absolute;
172
+ z-index: 99;
173
+ top: 8px;
174
+ right: 0;
175
+ width: max-content;
176
+ max-width: 500px;
177
+ background-color: ${(props) => props.theme.colors.white};
178
+ border: 1px solid ${(props) => props.theme.semanticColors.grey[300]};
179
+ border-radius: 4px;
180
+ padding: 24px;
181
+ `
182
+
183
+ const BoxTitle = styled.div`
184
+ font-size: 14px;
185
+ font-weight: 500;
186
+ color: ${(props) => props.theme.semanticColors.teal[800]};
187
+ margin-bottom: 16px;
188
+ `
189
+
190
+ const SortOptionsContainer = styled.div`
191
+ display: flex;
192
+ flex-direction: column;
193
+ gap: 16px;
194
+ white-space: nowrap;
195
+ `
196
+
197
+ const SortDropdownContainer = styled.div`
198
+ display: flex;
199
+ flex-direction: row;
200
+ gap: 8px;
201
+ align-items: center;
202
+ `
203
+
204
+ const SelectedText = styled.div`
205
+ font-size: 14px;
206
+ font-weight: 400;
207
+ color: ${(props) => props.theme.semanticColors.grey[800]};
208
+ `
209
+
210
+ const IconContainer = styled.div`
211
+ margin-left: 12px;
212
+ `
213
+
214
+ export default {
215
+ name: 'ViewSettings',
216
+ components: {
217
+ PageContainer,
218
+ ButtonIcon,
219
+ ButtonWrapper,
220
+ BoxContainer,
221
+ BoxTitle,
222
+ SortOptionsContainer,
223
+ SortDropdownContainer,
224
+ SelectComponent,
225
+ SelectOption,
226
+ SelectedText,
227
+ RCIcon,
228
+ IconContainer,
229
+ },
230
+ props: {
231
+ sortOptions: {
232
+ type: Array,
233
+ required: true,
234
+ },
235
+ selectedSort: {
236
+ type: Array,
237
+ required: true,
238
+ },
239
+ },
240
+ data() {
241
+ return {
242
+ isOptionsVisible: false,
243
+ }
244
+ },
245
+ computed: {
246
+ directionOptions() {
247
+ return [
248
+ {
249
+ value: 'ascending',
250
+ label: this.$gettext('ascending'),
251
+ },
252
+ {
253
+ value: 'descending',
254
+ label: this.$gettext('descending'),
255
+ },
256
+ ]
257
+ },
258
+ theme() {
259
+ return theme
260
+ },
261
+ },
262
+ mounted() {},
263
+ beforeUnmount() {
264
+ document.removeEventListener('click', this.handleClickOutside)
265
+ },
266
+ methods: {
267
+ handleClickOutside(event) {
268
+ const buttonIcon = this.$el.querySelector('.button-icon')
269
+ const boxContainer = this.$el.querySelector('.box-container')
270
+ const isClickInDropdown = event.target.closest('.sort-dropdown')
271
+
272
+ if (
273
+ !buttonIcon.contains(event.target) &&
274
+ !boxContainer.contains(event.target) &&
275
+ !isClickInDropdown
276
+ ) {
277
+ this.isOptionsVisible = false
278
+ document.removeEventListener('click', this.handleClickOutside)
279
+ }
280
+ },
281
+ toggleOptions() {
282
+ this.isOptionsVisible = !this.isOptionsVisible
283
+ if (this.isOptionsVisible) {
284
+ document.addEventListener('click', this.handleClickOutside)
285
+ } else {
286
+ document.removeEventListener('click', this.handleClickOutside)
287
+ }
288
+ },
289
+ getSelectedLabel({ type, value }) {
290
+ // debugger
291
+ if (!value) return
292
+ if (type === 'column') {
293
+ return this.sortOptions.find((option) => option.value === value).label
294
+ } else if (type === 'direction') {
295
+ return this.directionOptions.find((option) => option.value === value)
296
+ .label
297
+ }
298
+ },
299
+ onSelectSort({ type, value, index }) {
300
+ console.log(type, value, index)
301
+
302
+ this.$emit('on-sort-change', {
303
+ type,
304
+ value,
305
+ index,
306
+ })
307
+ this.isOptionsVisible = true
308
+ },
309
+ removeItem(index) {
310
+ this.$emit('on-sort-change', {
311
+ type: 'remove',
312
+ index,
313
+ })
314
+ },
315
+ },
316
+ }
317
+ </script>
@@ -171,6 +171,7 @@
171
171
  :no-relative="noRelative"
172
172
  :option-width="getOptionWidth"
173
173
  :selected-value="selectedValue"
174
+ @click.stop
174
175
  @mouseleave="optionLeave"
175
176
  @option-hovered="optionHovered"
176
177
  @option-selected="optionSelected"