@eturnity/eturnity_reusable_components 1.1.35 → 1.1.38

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": "1.1.35",
3
+ "version": "1.1.38",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -3,11 +3,18 @@
3
3
  :colspan="colSpan"
4
4
  :isOpen="isOpen"
5
5
  @click="toggleOpen"
6
- ref="dropdownItem"
7
6
  :disabled="disabled"
8
7
  >
9
8
  <component-container :colSpan="colSpan - 1" class="table-dropdown">
10
- <component-item v-for="(item, index) in tableItems" :key="index">
9
+ <component-item
10
+ v-for="(item, index) in tableItems"
11
+ :key="index"
12
+ ref="dropdownItem"
13
+ :class="{
14
+ 'table-dropdown-item':
15
+ item.type !== 'no-template' && item.type !== 'input',
16
+ }"
17
+ >
11
18
  <template-button
12
19
  @click.stop="onTemplateClick(item.row)"
13
20
  v-if="item.type && item.type === 'template' && item.value === ''"
@@ -26,96 +33,106 @@
26
33
  />
27
34
  <div>{{ item.value }}</div>
28
35
  </template-link>
29
- <no-template v-else-if="item.type && item.type === 'no-template'">
36
+ <no-template v-if="item.type && item.type === 'no-template'">
30
37
  {{ $gettext("No main component template") }}
31
38
  </no-template>
32
39
  <input-container
33
- v-else-if="item.type === 'input'"
40
+ v-if="item.type === 'input'"
34
41
  @click.stop="onInputClick()"
35
42
  >
36
43
  <input-text
37
44
  class="inputField"
38
45
  :value="item.value"
39
46
  :noBorder="true"
47
+ :minWidth="item.value.length + 'ch'"
40
48
  :disabled="customInputDisabled"
41
49
  @input-change="onCustomInputChange($event)"
42
50
  />
43
51
  </input-container>
44
52
  <span v-else> {{ item.value }}</span>
45
53
  </component-item>
46
- <et-popover
47
- v-if="showArchived"
48
- style="position: absolute; left: 5px; top: 13px; z-index: 99"
49
- button-class="error"
50
- :text="$gettext(`Component has been archived and shouldn't be used`)"
51
- triggerType="hover"
52
- ></et-popover>
53
- <arrow-down
54
- v-if="!isOpen"
55
- class="arrow-dropdown"
56
- :src="require('../../assets/icons/collapse_arrow_icon.svg')"
57
- />
58
- <arrow-up
59
- v-else
60
- :src="require('../../assets/icons/collapse_arrow_icon.svg')"
61
- />
62
- </component-container>
63
- <options-container
64
- v-if="isOpen"
65
- :top="getItemLocation('top')"
66
- :width="getItemLocation('width')"
67
- ref="optionsContainer"
68
- >
69
- <options-wrapper @click.prevent.stop>
70
- <search-container @click.prevent.stop>
71
- <search-input
72
- :value="inputText"
73
- :placeholder="$gettext('Keyword') + '...'"
74
- @click.prevent.stop
75
- @on-change="onSearch($event)"
76
- ref="searchInput"
54
+ <arrow-container class="arrow-container">
55
+ <arrow-wrapper :showArchived="showArchived">
56
+ <et-popover
57
+ v-if="showArchived"
58
+ button-class="error"
59
+ :text="
60
+ $gettext(`Component has been archived and shouldn't be used`)
61
+ "
62
+ triggerType="hover"
63
+ ></et-popover>
64
+ <arrow-down
65
+ @click.native.stop="toggleOpen"
66
+ v-if="!isOpen"
67
+ class="arrow-dropdown"
68
+ :src="require('../../assets/icons/collapse_arrow_icon.svg')"
69
+ />
70
+ <arrow-up
71
+ @click.native.stop="toggleOpen"
72
+ v-else
73
+ :src="require('../../assets/icons/collapse_arrow_icon.svg')"
77
74
  />
78
- </search-container>
79
- <spinner v-if="optionsLoading" />
80
- <empty-text v-else-if="!optionsLoading && !optionItems.length">
81
- {{ emptyText ? emptyText : $gettext("No components found.") }}
82
- </empty-text>
83
- <options-item
84
- v-else
85
- :colSpan="colSpan"
86
- v-for="(item, index) in optionItems"
87
- :key="index"
88
- @click="onItemClick(item)"
89
- :tabindex="0"
90
- @keyup.enter.native="onItemClick(item)"
75
+ </arrow-wrapper>
76
+ <options-container
77
+ v-if="isOpen"
78
+ :top="getItemLocation('top')"
79
+ :left="getItemLocation('left')"
80
+ ref="optionsContainer"
91
81
  >
92
- <template v-for="(option, idx) in optionsDisplay">
93
- <span v-if="option !== 'template'" :key="idx">
94
- {{ item[option] }}
95
- </span>
96
- <template-button
97
- @click.stop="onTemplateClick(item)"
98
- v-else-if="option === 'template' && item.has_template"
99
- :key="idx"
100
- >{{ $gettext("Use template...") }}</template-button
82
+ <options-wrapper @click.prevent.stop>
83
+ <search-container @click.prevent.stop>
84
+ <search-input
85
+ :value="inputText"
86
+ :placeholder="$gettext('Keyword') + '...'"
87
+ @click.prevent.stop
88
+ @on-change="onSearch($event)"
89
+ ref="searchInput"
90
+ />
91
+ </search-container>
92
+ <spinner v-if="optionsLoading" />
93
+ <empty-text v-else-if="!optionsLoading && !optionItems.length">
94
+ {{ emptyText ? emptyText : $gettext("No components found.") }}
95
+ </empty-text>
96
+ <options-item
97
+ v-else
98
+ :colSpan="colSpan - 1"
99
+ v-for="(item, index) in optionItems"
100
+ :key="index"
101
+ @click="onItemClick(item)"
102
+ :tabindex="0"
103
+ @keyup.enter.native="onItemClick(item)"
101
104
  >
102
- <no-template
103
- v-else-if="option === 'template' && !item.has_template"
104
- :key="idx"
105
+ <template v-for="(option, idx) in optionsDisplay">
106
+ <span v-if="option !== 'template'" :key="idx">
107
+ {{ item[option] }}
108
+ </span>
109
+ <template-button
110
+ @click.stop="onTemplateClick(item)"
111
+ v-else-if="option === 'template' && item.has_template"
112
+ :key="idx"
113
+ >{{ $gettext("Use template...") }}</template-button
114
+ >
115
+ <no-template
116
+ v-else-if="option === 'template' && !item.has_template"
117
+ :key="idx"
118
+ >
119
+ {{ $gettext("No main component template") }}
120
+ </no-template>
121
+ </template>
122
+ </options-item>
123
+ </options-wrapper>
124
+ <custom-container
125
+ v-if="inputText.length && allowFreeInputs"
126
+ @click="onCustomNameClick()"
127
+ >
128
+ <custom-name>{{ getCustomName }}</custom-name>
129
+ <custom-subtext
130
+ >({{ $gettext("custom_component") }})</custom-subtext
105
131
  >
106
- {{ $gettext("No main component template") }}
107
- </no-template>
108
- </template>
109
- </options-item>
110
- </options-wrapper>
111
- <custom-container
112
- v-if="inputText.length && allowFreeInputs"
113
- @click="onCustomNameClick()"
114
- >
115
- <custom-name>{{ getCustomName }}</custom-name>
116
- <custom-subtext>({{ $gettext("custom_component") }})</custom-subtext>
117
- </custom-container>
118
- </options-container>
132
+ </custom-container>
133
+ </options-container>
134
+ </arrow-container>
135
+ </component-container>
119
136
  </dropdown-row>
120
137
  </template>
121
138
 
@@ -145,24 +162,33 @@ import SearchInput from "@eturnity/eturnity_reusable_components/src/components/i
145
162
  import InputText from "@eturnity/eturnity_reusable_components/src/components/inputs/inputText"
146
163
 
147
164
  const rowAttrs = { disabled: Boolean, isOpen: Boolean }
148
- const DropdownRow = styled("td", rowAttrs)`
165
+ const DropdownRow = styled("div", rowAttrs)`
149
166
  cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
167
+ display: contents;
150
168
 
151
169
  input {
152
170
  cursor: ${(props) => (!props.isOpen ? "pointer !important" : "inherit")};
153
171
  }
154
172
  `
155
173
 
156
- const ComponentItem = styled.div`
174
+ const ComponentItem = styled.td`
157
175
  overflow: hidden;
158
176
  text-overflow: ellipsis;
177
+ padding-right: 0 !important;
178
+
179
+ &.table-dropdown-item {
180
+ background-clip: content-box;
181
+ padding: 8px 0 7px 0 !important;
182
+
183
+ span {
184
+ padding-left: 15px;
185
+ }
186
+ }
159
187
  `
160
188
 
161
189
  const containerAttrs = { colSpan: Number }
162
190
  const ComponentContainer = styled("div", containerAttrs)`
163
- display: grid;
164
- grid-template-columns: 1fr repeat(${(props) => props.colSpan}, auto) auto;
165
- grid-gap: 12px;
191
+ display: contents;
166
192
  align-items: center;
167
193
  background-color: ${(props) => props.theme.colors.white};
168
194
  border-radius: 4px;
@@ -181,13 +207,35 @@ const ArrowUp = styled.img`
181
207
  transition: transform 150ms ease;
182
208
  `
183
209
 
184
- const optionsAttrs = { top: Number, width: Number }
210
+ const ArrowContainer = styled.td`
211
+ border-bottom: 1px solid ${(props) => props.theme.colors.grey4};
212
+ background-clip: content-box;
213
+ padding: 8px 0 7px 0 !important;
214
+ border-radius: 0 4px 4px 0;
215
+
216
+ .arrow-dropdown {
217
+ vertical-align: middle;
218
+ margin-left: 11px;
219
+ }
220
+ `
221
+
222
+ const arrowAttrs = { showArchived: Boolean }
223
+ const ArrowWrapper = styled("div", arrowAttrs)`
224
+ display: grid;
225
+ grid-template-columns: ${(props) =>
226
+ props.showArchived ? "auto auto" : "auto"};
227
+ align-items: center;
228
+ justify-items: center;
229
+ `
230
+
231
+ const optionsAttrs = { top: Number, left: Number }
185
232
  const OptionsContainer = styled("div", optionsAttrs)`
186
233
  position: absolute;
187
234
  display: grid;
188
235
  grid-template-rows: 1fr auto;
189
236
  top: ${(props) => props.top + "px"};
190
- width: ${(props) => props.width + "px"};
237
+ left: ${(props) => props.left + "px"};
238
+ width: auto;
191
239
  max-height: 360px;
192
240
  min-height: 200px;
193
241
  overflow: auto;
@@ -213,14 +261,19 @@ const OptionsWrapper = styled.div`
213
261
  font-size: 14px;
214
262
  grid-template-rows: max-content;
215
263
  height: max-content;
264
+ min-width: 400px; // kind of an arbitrary number until we know all use cases
216
265
  `
217
266
 
218
267
  const OptionsItem = styled("div", containerAttrs)`
219
268
  display: grid;
220
- grid-template-columns: 1fr repeat(${(props) => props.colSpan}, auto);
221
- grid-gap: 12px;
269
+ grid-template-columns: 1fr repeat(
270
+ ${(props) => props.colSpan},
271
+ minmax(50px, auto)
272
+ );
273
+ grid-gap: 30px;
222
274
  padding: 10px;
223
275
  height: max-content;
276
+ justify-items: flex-start;
224
277
 
225
278
  span {
226
279
  overflow: hidden;
@@ -267,15 +320,7 @@ const TemplateLink = styled.div`
267
320
 
268
321
  const InputContainer = styled.div`
269
322
  .inputField input {
270
- padding: 0;
271
-
272
- &:focus {
273
- padding: 5px 0px;
274
- }
275
-
276
- &:hover {
277
- padding: 0px 0 !important;
278
- }
323
+ border-radius: 4px 0 0 4px;
279
324
  }
280
325
  `
281
326
 
@@ -312,6 +357,7 @@ export default {
312
357
  Spinner,
313
358
  EmptyText,
314
359
  SearchInput,
360
+ ArrowWrapper,
315
361
  OptionsWrapper,
316
362
  OptionsItem,
317
363
  SearchContainer,
@@ -323,6 +369,7 @@ export default {
323
369
  CustomContainer,
324
370
  CustomName,
325
371
  CustomSubtext,
372
+ ArrowContainer,
326
373
  },
327
374
  props: {
328
375
  colSpan: {
@@ -426,7 +473,7 @@ export default {
426
473
  this.$emit("dropdown-search", value)
427
474
  },
428
475
  getItemLocation(value) {
429
- let ref = this.$refs.dropdownItem
476
+ let ref = this.$refs.dropdownItem[0]
430
477
  let location = ref.$el.getBoundingClientRect()[value]
431
478
  if (value === "top") {
432
479
  location = location + window.scrollY + 40