@eturnity/eturnity_reusable_components 1.0.26 → 1.0.30

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.0.26",
3
+ "version": "1.0.30",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
package/src/App.vue CHANGED
@@ -8,6 +8,7 @@
8
8
  <th>Column 2</th>
9
9
  <th>Column 3</th>
10
10
  <th>Column 4</th>
11
+ <div />
11
12
  </tr>
12
13
  </thead>
13
14
  <tbody>
@@ -16,15 +17,12 @@
16
17
  <td class="text">Body 2</td>
17
18
  <td class="text">Body 3</td>
18
19
  <td class="text">Body 4</td>
20
+ <div class="icons-container">
21
+ <three-dots :options="listOptions" />
22
+ </div>
19
23
  </tr>
20
24
  </tbody>
21
25
  </main-table>
22
- <toggle
23
- @on-toggle-change="isChecked = $event"
24
- :isChecked="isChecked"
25
- label="My Label Text"
26
- size="small"
27
- />
28
26
  </page-container>
29
27
  </ThemeProvider>
30
28
  </template>
@@ -34,7 +32,7 @@ import { ThemeProvider } from "vue-styled-components"
34
32
  import theme from "./assets/theme"
35
33
  import styled from "vue-styled-components"
36
34
  import MainTable from "@/components/tables/mainTable"
37
- import Toggle from "@/components/inputs/toggle"
35
+ import ThreeDots from "@/components/threeDots"
38
36
 
39
37
  const PageContainer = styled.div`
40
38
  padding: 40px;
@@ -46,7 +44,7 @@ export default {
46
44
  ThemeProvider,
47
45
  PageContainer,
48
46
  MainTable,
49
- Toggle,
47
+ ThreeDots,
50
48
  },
51
49
  data() {
52
50
  return {
@@ -59,6 +57,52 @@ export default {
59
57
  unit_short_name: "cm",
60
58
  },
61
59
  isChecked: false,
60
+ listOptions: [
61
+ {
62
+ name: "Option 1",
63
+ value: "option_1",
64
+ children: [
65
+ {
66
+ name: "Option 1 Child",
67
+ value: "option_1_child",
68
+ },
69
+ {
70
+ name: "Option 2 Child",
71
+ value: "option_2_child",
72
+ },
73
+ {
74
+ name: "Option 3 Child",
75
+ value: "option_3_child",
76
+ },
77
+ ],
78
+ },
79
+ {
80
+ name: "Option 2",
81
+ value: "option_2",
82
+ },
83
+ {
84
+ name: "Option 3",
85
+ value: "option_3",
86
+ children: [
87
+ {
88
+ name: "Option 3 Child",
89
+ value: "option_3_child",
90
+ },
91
+ {
92
+ name: "Option 4 Child",
93
+ value: "option_4_child",
94
+ },
95
+ {
96
+ name: "Option 5 Child",
97
+ value: "option_5_child",
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ name: "Option 4",
103
+ value: "option_4",
104
+ },
105
+ ],
62
106
  }
63
107
  },
64
108
  methods: {
@@ -6,6 +6,7 @@
6
6
  :isError="isError"
7
7
  :rows="rowHeight"
8
8
  :value="value"
9
+ :disabled="isDisabled"
9
10
  @input="onChangeHandler"
10
11
  />
11
12
  </input-wrapper>
@@ -32,7 +33,7 @@ const Container = styled.div`
32
33
  margin-bottom: 20px;
33
34
  `
34
35
 
35
- const inputProps = { isError: Boolean }
36
+ const inputProps = { isError: Boolean, disabled: Boolean }
36
37
  const InputContainer = styled("textarea", inputProps)`
37
38
  border: ${(props) =>
38
39
  props.isError
@@ -46,6 +47,7 @@ const InputContainer = styled("textarea", inputProps)`
46
47
  width: 100%;
47
48
  max-width: 100%;
48
49
  box-sizing: border-box; // to allow width of 100% with padding
50
+ cursor: ${(props) => (props.disabled ? "not-allowed" : "inherit")};
49
51
 
50
52
  &::placeholder {
51
53
  color: ${(props) =>
@@ -96,6 +98,10 @@ export default {
96
98
  errorText: {
97
99
  required: false,
98
100
  },
101
+ isDisabled: {
102
+ required: false,
103
+ default: false,
104
+ },
99
105
  },
100
106
  methods: {
101
107
  onChangeHandler($event) {
@@ -154,8 +154,8 @@ const TableContainer = styled.table`
154
154
  }
155
155
 
156
156
  .icons-container {
157
- width: 100%;
158
- display: inline-flex;
157
+ width: auto;
158
+ display: table-cell;
159
159
  flex-wrap: nowrap;
160
160
  background-color: #fff;
161
161
  vertical-align: middle;
@@ -7,13 +7,36 @@
7
7
  </button-container>
8
8
  <options-container v-if="isOpen">
9
9
  <option-item
10
- v-for="item in options"
10
+ v-for="(item, index) in options"
11
11
  :key="item.value"
12
12
  tabindex="0"
13
- @click="onSelect(item.value)"
14
- @keyup.enter="onSelect(item.value)"
13
+ @click="onSelect({ value: item.value, hasChildren: hasChildren(item) })"
14
+ @keyup.enter="
15
+ onSelect({ value: item.value, hasChildren: hasChildren(item) })
16
+ "
17
+ @mouseover="onItemHover(index)"
15
18
  >
16
- {{ item.name }}
19
+ <arrow-left :hasChildren="hasChildren(item)" />
20
+ <span>
21
+ {{ item.name }}
22
+ </span>
23
+ <children-container
24
+ class="child"
25
+ v-if="hasChildren(item) && hoverItem === index"
26
+ >
27
+ <option-child
28
+ v-for="child in item.children"
29
+ :key="child.value"
30
+ @click.stop="
31
+ onSelect({ value: child.value, hasChildren: hasChildren(child) })
32
+ "
33
+ @keyup.enter.stop="
34
+ onSelect({ value: child.value, hasChildren: hasChildren(child) })
35
+ "
36
+ >
37
+ {{ child.name }}
38
+ </option-child>
39
+ </children-container>
17
40
  </option-item>
18
41
  </options-container>
19
42
  </page-container>
@@ -28,23 +51,51 @@
28
51
  // />
29
52
  // options to pass:
30
53
  // listOptions: [
31
- // {
32
- // name: "Option 1",
33
- // value: "option_1",
34
- // },
35
- // {
36
- // name: "Option 2",
37
- // value: "option_2",
38
- // },
39
- // {
40
- // name: "Option 3",
41
- // value: "option_3",
42
- // },
43
- // {
44
- // name: "Option 4",
45
- // value: "option_4",
46
- // }
47
- // ],
54
+ // {
55
+ // name: "Option 1",
56
+ // value: "option_1",
57
+ // children: [
58
+ // {
59
+ // name: "Option 1 Child",
60
+ // value: "option_1_child",
61
+ // },
62
+ // {
63
+ // name: "Option 2 Child",
64
+ // value: "option_2_child",
65
+ // },
66
+ // {
67
+ // name: "Option 3 Child",
68
+ // value: "option_3_child",
69
+ // },
70
+ // ],
71
+ // },
72
+ // {
73
+ // name: "Option 2",
74
+ // value: "option_2",
75
+ // },
76
+ // {
77
+ // name: "Option 3",
78
+ // value: "option_3",
79
+ // children: [
80
+ // {
81
+ // name: "Option 3 Child",
82
+ // value: "option_3_child",
83
+ // },
84
+ // {
85
+ // name: "Option 4 Child",
86
+ // value: "option_4_child",
87
+ // },
88
+ // {
89
+ // name: "Option 5 Child",
90
+ // value: "option_5_child",
91
+ // },
92
+ // ],
93
+ // },
94
+ // {
95
+ // name: "Option 4",
96
+ // value: "option_4",
97
+ // },
98
+ // ],
48
99
 
49
100
  import styled from "vue-styled-components"
50
101
 
@@ -82,11 +133,9 @@ const DotItem = styled.div`
82
133
 
83
134
  const OptionsContainer = styled.div`
84
135
  z-index: 99;
85
- position: absolute;
86
- right: 0;
87
- border: 1px solid
88
- ${(props) =>
89
- props.buttonColor ? props.buttonColor : props.theme.colors.grey3};
136
+ position: fixed;
137
+ right: 60px;
138
+ border: 1px solid ${(props) => props.theme.colors.grey3};
90
139
  display: grid;
91
140
  grid-template-columns: 1fr;
92
141
  min-width: 200px;
@@ -102,6 +151,22 @@ const OptionItem = styled.div`
102
151
  padding: 12px;
103
152
  cursor: pointer;
104
153
  font-size: 13px;
154
+ position: relative;
155
+
156
+ &:hover {
157
+ background-color: #ebeef4;
158
+ }
159
+
160
+ &:focus-visible {
161
+ outline: none;
162
+ background-color: #ebeef4;
163
+ }
164
+ `
165
+ const OptionChild = styled.div`
166
+ padding: 12px;
167
+ cursor: pointer;
168
+ font-size: 13px;
169
+ position: relative;
105
170
 
106
171
  &:hover {
107
172
  background-color: #ebeef4;
@@ -113,6 +178,34 @@ const OptionItem = styled.div`
113
178
  }
114
179
  `
115
180
 
181
+ const arrowAttrs = { hasChildren: Boolean }
182
+ const ArrowLeft = styled("span", arrowAttrs)`
183
+ border: solid #9f9f9f;
184
+ border-width: 0 1.5px 1.5px 0;
185
+ display: inline-block;
186
+ padding: 3px;
187
+ margin-bottom: 1px;
188
+ transform: rotate(135deg);
189
+ margin-right: 3px;
190
+ visibility: ${(props) => (props.hasChildren ? "visible" : "hidden")};
191
+ `
192
+
193
+ const ChildrenContainer = styled.div`
194
+ position: fixed;
195
+ right: 262px;
196
+ border: 1px solid ${(props) => props.theme.colors.grey3};
197
+ display: grid;
198
+ grid-template-columns: 1fr;
199
+ min-width: 200px;
200
+ width: max-content;
201
+ border-radius: 4px;
202
+ background-color: #fff;
203
+ margin-top: -28px;
204
+ margin-right: -1px;
205
+ max-height: 220px;
206
+ overflow: auto;
207
+ `
208
+
116
209
  export default {
117
210
  name: "three-dots",
118
211
  components: {
@@ -121,6 +214,9 @@ export default {
121
214
  DotItem,
122
215
  OptionsContainer,
123
216
  OptionItem,
217
+ ChildrenContainer,
218
+ OptionChild,
219
+ ArrowLeft,
124
220
  },
125
221
  props: {
126
222
  options: {
@@ -130,6 +226,7 @@ export default {
130
226
  data() {
131
227
  return {
132
228
  isOpen: false,
229
+ hoverItem: null,
133
230
  }
134
231
  },
135
232
  methods: {
@@ -142,7 +239,16 @@ export default {
142
239
  document.removeEventListener("click", this.clickOutside)
143
240
  }
144
241
  },
145
- onSelect(value) {
242
+ hasChildren(item) {
243
+ return !!item.children && !!item.children.length
244
+ },
245
+ onItemHover(index) {
246
+ this.hoverItem = index
247
+ },
248
+ onSelect({ value, hasChildren }) {
249
+ if (hasChildren) {
250
+ return
251
+ }
146
252
  this.$emit("on-select", value)
147
253
  this.isOpen = false
148
254
  },