@mozaic-ds/vue 0.20.0-beta.4 → 0.20.0-beta.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.
@@ -0,0 +1,200 @@
1
+ <template>
2
+ <div v-click-outside="onClickOutside" class="mc-listbox-options">
3
+ <button
4
+ type="button"
5
+ class="mc-listbox-options__trigger"
6
+ @click="isOpen = !isOpen"
7
+ >
8
+ <m-icon name="DisplayOptions24" />
9
+ <span class="mc-listbox-options__trigger-label">{{ triggerLabel }}</span>
10
+ </button>
11
+ <ul
12
+ v-if="items.length > 0"
13
+ ref="listbox"
14
+ role="listbox"
15
+ class="mc-listbox-options__list"
16
+ aria-labelledby="listbox"
17
+ :class="{ 'is-open': isOpen, 'align-right': position == 'right' }"
18
+ >
19
+ <li v-for="item in items" :key="item.id" class="mc-listbox-options__tile">
20
+ <m-icon
21
+ v-if="item.icon"
22
+ :name="item.icon"
23
+ class="mc-listbox-options__icon"
24
+ :color="item.danger ? '#C61112' : '#71706B'"
25
+ />
26
+ <component
27
+ :is="item.href ? 'a' : 'button'"
28
+ :href="item.href ? item.href : null"
29
+ :type="item.href ? null : 'button'"
30
+ class="mc-listbox-options__item"
31
+ :class="{ 'is-danger': item.danger }"
32
+ >
33
+ {{ item.text }}
34
+ </component>
35
+ </li>
36
+ </ul>
37
+ </div>
38
+ </template>
39
+
40
+ <script>
41
+ import MIcon from '../icon/MIcon.vue';
42
+
43
+ export default {
44
+ name: 'MListBoxOptions',
45
+
46
+ components: {
47
+ MIcon,
48
+ },
49
+
50
+ directives: {
51
+ 'click-outside': {
52
+ bind(el, binding, vnode) {
53
+ el.clickOutsideEvent = (event) => {
54
+ if (!(el === event.target || el.contains(event.target))) {
55
+ vnode.context[binding.expression](event);
56
+ }
57
+ };
58
+ document.body.addEventListener('click', el.clickOutsideEvent);
59
+ },
60
+ unbind(el) {
61
+ document.body.removeEventListener('click', el.clickOutsideEvent);
62
+ },
63
+ },
64
+ },
65
+
66
+ props: {
67
+ open: {
68
+ type: Boolean,
69
+ default: false,
70
+ },
71
+ position: {
72
+ type: String,
73
+ default: 'left',
74
+ },
75
+ items: {
76
+ type: Array,
77
+ default: () => [],
78
+ },
79
+ triggerLabel: {
80
+ type: String,
81
+ default: 'Display options',
82
+ },
83
+ },
84
+
85
+ data() {
86
+ return {
87
+ isOpen: this.open,
88
+ };
89
+ },
90
+
91
+ methods: {
92
+ onClickOutside() {
93
+ this.isOpen = false;
94
+ },
95
+ },
96
+ };
97
+ </script>
98
+
99
+ <style lang="scss">
100
+ @import 'settings-tools/all-settings';
101
+
102
+ .mc-listbox-options {
103
+ display: inline-block;
104
+ position: relative;
105
+
106
+ &__trigger {
107
+ align-items: center;
108
+ background: none;
109
+ border: none;
110
+ cursor: pointer;
111
+ display: flex;
112
+ height: $mu150;
113
+ justify-content: center;
114
+ padding: 0;
115
+ width: $mu150;
116
+
117
+ &-label {
118
+ @include visually-hidden();
119
+ }
120
+ }
121
+
122
+ &__list {
123
+ $parent: get-parent-selector(&);
124
+ @include unstyle-list();
125
+ background-color: $color-grey-000;
126
+ border: 1px solid $color-grey-600;
127
+ border-radius: 3px;
128
+ position: absolute;
129
+ overflow-y: auto;
130
+ margin-top: 5px;
131
+ margin-bottom: 0;
132
+ // max-height: 13.5rem;
133
+ min-width: $mu800;
134
+ opacity: 0;
135
+ visibility: hidden;
136
+
137
+ &.is-open {
138
+ opacity: 1;
139
+ visibility: visible;
140
+ z-index: 11;
141
+ }
142
+
143
+ &::-webkit-scrollbar {
144
+ background-color: $color-grey-100;
145
+ width: $mu025;
146
+
147
+ &-thumb {
148
+ background: $color-grey-600;
149
+ }
150
+ }
151
+
152
+ &.align-right {
153
+ transform: translateX(calc(-100% + #{$mu150}));
154
+ }
155
+ }
156
+
157
+ &__tile {
158
+ align-items: center;
159
+ color: #1e1e1c;
160
+ display: flex;
161
+ gap: $mu050;
162
+ min-height: $mu250;
163
+ padding-left: $mu075;
164
+ padding-right: $mu075;
165
+ position: relative;
166
+
167
+ &:hover {
168
+ background-color: #eeedea;
169
+ }
170
+ }
171
+
172
+ &__item {
173
+ @include set-font-scale('05', 'm');
174
+
175
+ background: none;
176
+ border: none;
177
+ color: currentColor;
178
+ cursor: pointer;
179
+ padding: 0;
180
+
181
+ &::after {
182
+ content: '';
183
+ position: absolute;
184
+ inset: 0;
185
+ z-index: 2;
186
+ }
187
+
188
+ &,
189
+ &:active,
190
+ &:hover,
191
+ &:focus {
192
+ text-decoration: none;
193
+ }
194
+
195
+ &.is-danger {
196
+ color: #c61112;
197
+ }
198
+ }
199
+ }
200
+ </style>
@@ -1,7 +1,12 @@
1
1
  import MListBox from './MListBox.vue';
2
+ import MListBoxOptions from './MListBoxOptions.vue';
2
3
 
3
4
  MListBox.install = function (Vue) {
4
5
  Vue.component(MListBox.name, MListBox);
5
6
  };
6
7
 
7
- export { MListBox };
8
+ MListBoxOptions.install = function (Vue) {
9
+ Vue.component(MListBoxOptions.name, MListBoxOptions);
10
+ };
11
+
12
+ export { MListBox, MListBoxOptions };
package/src/index.js CHANGED
@@ -37,7 +37,7 @@ export { MHero } from './components/hero';
37
37
  export { MIcon } from './components/icon';
38
38
  export { MLayer } from './components/layer';
39
39
  export { MLink } from './components/link';
40
- export { MListBox } from './components/listbox';
40
+ export { MListBox, MListBoxOptions } from './components/listbox';
41
41
  export { MLoader } from './components/loader';
42
42
  export { MModal } from './components/modal';
43
43
  export { MNotification } from './components/notification';
package/types/index.d.ts CHANGED
@@ -24,6 +24,7 @@ declare module '@mozaic-ds/vue' {
24
24
  const MLayer: VueConstructor;
25
25
  const MLink: VueConstructor;
26
26
  const MListBox: VueConstructor;
27
+ const MListBoxOptions: VueConstructor;
27
28
  const MLoader: VueConstructor;
28
29
  const MModal: VueConstructor;
29
30
  const MNotification: VueConstructor;
@@ -71,6 +72,7 @@ declare module '@mozaic-ds/vue' {
71
72
  MLayer,
72
73
  MLink,
73
74
  MListBox,
75
+ MListBoxOptions,
74
76
  MLoader,
75
77
  MModal,
76
78
  MNotification,