@mozaic-ds/vue 0.38.0-beta.0 → 0.38.0

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": "@mozaic-ds/vue",
3
- "version": "0.38.0-beta.0",
3
+ "version": "0.38.0",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -50,7 +50,6 @@
50
50
  :items="localItems"
51
51
  :multiple="multiple"
52
52
  :empty-search-label="emptySearchLabel"
53
- :data-key-expr="dataKeyExpr"
54
53
  :data-text-expr="dataTextExpr"
55
54
  :data-value-expr="dataValueExpr"
56
55
  :max-width="maxWidth"
@@ -183,10 +182,6 @@ export default {
183
182
  type: String,
184
183
  default: 'No results found',
185
184
  },
186
- dataKeyExpr: {
187
- type: String,
188
- default: 'id',
189
- },
190
185
  dataTextExpr: {
191
186
  type: String,
192
187
  default: 'label',
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <fieldset class="mc-field mc-field--group">
3
- <legend class="mc-field__legend">
3
+ <legend v-if="legend" class="mc-field__legend">
4
4
  {{ legend }}
5
5
  <span
6
6
  v-if="requirementText"
@@ -63,7 +63,7 @@ export default {
63
63
  */
64
64
  legend: {
65
65
  type: String,
66
- required: true,
66
+ default: undefined,
67
67
  },
68
68
  /**
69
69
  * Property used to manage the values checked by v-model
@@ -164,6 +164,19 @@ export default {
164
164
  </script>
165
165
 
166
166
  <style lang="scss">
167
- @import 'settings-tools/_all-settings';
168
- @import 'components/_c.fields';
167
+ @import 'settings-tools/all-settings';
168
+ @import 'components/c.fields';
169
+
170
+ // TODO: temporary fix - should be put inside @mozaic-ds/styles
171
+ .mc-field--group {
172
+ .mc-field {
173
+ &__container {
174
+ margin-top: 0;
175
+ }
176
+
177
+ &__legend {
178
+ margin-bottom: 1rem;
179
+ }
180
+ }
181
+ }
169
182
  </style>
@@ -7,13 +7,6 @@
7
7
  <table aria-describedby="data" :class="getTableClasses">
8
8
  <thead>
9
9
  <tr v-if="!hideHeader">
10
- <th
11
- v-if="expandable"
12
- scope="col"
13
- class="mc-datatable__cell-button"
14
- >
15
- &nbsp;
16
- </th>
17
10
  <th
18
11
  v-for="(header, index) in getHeaders"
19
12
  :key="`header-${index}`"
@@ -47,68 +40,30 @@
47
40
  </tr>
48
41
  </thead>
49
42
  <tbody>
50
- <template v-for="(item, rowIndex) in getSource">
51
- <tr
52
- :key="item[dataKeyExpr]"
53
- :class="[rowClasses(item), parentRowClasses]"
43
+ <tr
44
+ v-for="(item, rowIndex) in getSource"
45
+ :key="item[dataKeyExpr]"
46
+ :class="rowClasses(item)"
47
+ >
48
+ <td
49
+ v-for="(header, index) in getHeaders"
50
+ :key="`${index}-${getItemValue(item, dataKeyExpr)}-${
51
+ header.dataFieldExpr
52
+ }`"
53
+ :class="header.cssClass"
54
+ @click="
55
+ allowRowClick && onRowClick({ event: $event, item: item })
56
+ "
54
57
  >
55
- <td v-if="expandable">
56
- <button
57
- v-if="expandableList?.includes(item.id) || !expandableList"
58
- type="button"
59
- class="mc-datatable__expand mc-datatable__btn"
60
- @click="onClickExpander($event, item, rowIndex)"
61
- >
62
- <span class="mc-datatable__btn-label">
63
- {{ expanderAccessibleLabel }}
64
- </span>
65
- <MIcon
66
- name="ControlCircleMore24"
67
- class="mc-datatable__btn-icon expand-more"
68
- />
69
- <MIcon
70
- name="ControlCircleLess24"
71
- class="mc-datatable__btn-icon expand-less"
72
- />
73
- </button>
74
- </td>
75
- <td
76
- v-for="(header, index) in getHeaders"
77
- :key="`${index}-${getItemValue(item, dataKeyExpr)}-${
78
- header.dataFieldExpr
79
- }`"
80
- :class="header.cssClass"
81
- @click="
82
- allowRowClick && onRowClick({ event: $event, item: item })
83
- "
58
+ <slot
59
+ :name="`item.${header.dataFieldExpr}`"
60
+ :item="item"
61
+ :index="rowIndex"
84
62
  >
85
- <slot
86
- :name="`item.${header.dataFieldExpr}`"
87
- :item="item"
88
- :index="rowIndex"
89
- >
90
- {{ getItemValue(item, header.dataFieldExpr) }}
91
- </slot>
92
- </td>
93
- </tr>
94
- <tr
95
- v-if="expandable"
96
- :key="'subrow' + item[dataKeyExpr]"
97
- class="mc-datatable__row-expandable"
98
- :class="expandableRowClasses"
99
- >
100
- <td :colspan="getHeaders.length + 1">
101
- <div class="mc-datatable__row-inner">
102
- <slot
103
- name="expandContent"
104
- :item="item"
105
- :row-index="rowIndex"
106
- >
107
- </slot>
108
- </div>
109
- </td>
110
- </tr>
111
- </template>
63
+ {{ getItemValue(item, header.dataFieldExpr) }}
64
+ </slot>
65
+ </td>
66
+ </tr>
112
67
  <tr v-if="getSource.length == 0">
113
68
  <td :colspan="getHeaders.length">
114
69
  <slot name="no-data" />
@@ -345,18 +300,6 @@ export default {
345
300
  type: [String, Function, Object],
346
301
  default: '',
347
302
  },
348
- expandable: {
349
- type: Boolean,
350
- default: false,
351
- },
352
- expandableList: {
353
- type: Array,
354
- default: undefined,
355
- },
356
- expanderAccessibleLabel: {
357
- type: String,
358
- default: 'Déplier la ligne',
359
- },
360
303
  },
361
304
 
362
305
  data() {
@@ -445,18 +388,6 @@ export default {
445
388
  const on = skip + take;
446
389
  return `${skip + 1} - ${on >= this.total ? this.total : on}`;
447
390
  },
448
-
449
- parentRowClasses() {
450
- return {
451
- 'mc-datatable__row-parent': this.expandable,
452
- };
453
- },
454
-
455
- expandableRowClasses() {
456
- return {
457
- 'mc-datatable__row-expandable--offset-1': this.expandable,
458
- };
459
- },
460
391
  },
461
392
 
462
393
  watch: {
@@ -660,30 +591,13 @@ export default {
660
591
  onRowClick(e) {
661
592
  this.$emit('row-click', e);
662
593
  },
663
-
664
- onClickExpander(e, rowData, rowIndex) {
665
- const button = e.currentTarget;
666
- const row = button.closest('tr');
667
-
668
- button.classList.toggle('is-expand');
669
- row.classList.toggle('mc-datatable__row-parent--expanded');
670
-
671
- const isExpanded = button.classList.contains('is-expand');
672
-
673
- const eventName = isExpanded ? 'expand-row' : 'retract-row';
674
- const eventArg = { data: rowData, index: rowIndex };
675
-
676
- this.$emit(eventName, eventArg);
677
- },
678
594
  },
679
595
  };
680
596
  </script>
681
597
 
682
598
  <style lang="scss">
683
599
  /* stylelint-disable */
684
- @import 'settings-tools/all-settings';
685
- @import 'components/c.datatable-tools';
686
- @import 'components/c.datatable-subtable';
600
+ @import 'settings-tools/_all-settings';
687
601
 
688
602
  .mc-data-table {
689
603
  @include set-font-family;
@@ -814,62 +728,6 @@ export default {
814
728
  vertical-align: middle;
815
729
  padding: 0 $mu100;
816
730
  }
817
-
818
- .mc-datatable__row {
819
- $datatable-row: &;
820
-
821
- &-parent:not(.mc-datatable__row-parent--expanded)
822
- + .mc-datatable__row-expandable {
823
- height: 0;
824
-
825
- .mc-datatable__row-inner {
826
- overflow: hidden;
827
- max-height: 0;
828
- }
829
- }
830
-
831
- &-parent.mc-datatable__row-parent--expanded
832
- + .mc-datatable__row-expandable {
833
- .mc-datatable__row-inner {
834
- max-height: 100%;
835
- }
836
- }
837
-
838
- &-expandable {
839
- height: auto;
840
-
841
- & > td {
842
- padding: 0;
843
- border-bottom: 0;
844
- }
845
-
846
- &--offset {
847
- &-1 {
848
- table {
849
- th:first-child,
850
- td:first-child {
851
- padding-left: $width-cell-checkbox + $mu100;
852
- }
853
- }
854
- }
855
-
856
- &-2 {
857
- table {
858
- th:first-child,
859
- td:first-child {
860
- padding-left: $width-cell-checkbox + $width-cell-button +
861
- $mu100;
862
- }
863
- }
864
- }
865
- }
866
- }
867
-
868
- &__inner,
869
- &-inner {
870
- background-color: $color-background-datatable-subtable;
871
- }
872
- }
873
731
  }
874
732
  }
875
733
 
@@ -907,6 +765,7 @@ export default {
907
765
  }
908
766
 
909
767
  // footer
768
+
910
769
  &__footer {
911
770
  @include set-box-shadow('s');
912
771
 
@@ -949,40 +808,6 @@ export default {
949
808
  background-color: $color-background-datatable-container;
950
809
  overflow: hidden;
951
810
  }
952
-
953
- &__cell {
954
- &-checkbox {
955
- width: $width-cell-checkbox;
956
- }
957
-
958
- &-button {
959
- width: $width-cell-button;
960
- }
961
-
962
- &-field {
963
- min-width: $width-cell-field;
964
- }
965
-
966
- &-number {
967
- @at-root td#{&} {
968
- text-align: right;
969
- }
970
- }
971
- }
972
-
973
- &__expand {
974
- &:not(.is-expand) {
975
- .expand-less {
976
- display: none;
977
- }
978
- }
979
-
980
- &.is-expand {
981
- .expand-more {
982
- display: none;
983
- }
984
- }
985
- }
986
811
  }
987
812
  /* stylelint-enable */
988
813
  </style>
@@ -25,7 +25,7 @@
25
25
  :disabled="disabled"
26
26
  @click="openState = !openState"
27
27
  >
28
- {{ getButtonLabel }}
28
+ {{ buttonValue }}
29
29
  </button>
30
30
  <button
31
31
  v-if="isClearable"
@@ -43,7 +43,6 @@
43
43
  :items="localItems"
44
44
  :multiple="multiple"
45
45
  :empty-search-label="emptySearchLabel"
46
- :data-key-expr="dataKeyExpr"
47
46
  :data-text-expr="dataTextExpr"
48
47
  :data-value-expr="dataValueExpr"
49
48
  :max-width="maxWidth"
@@ -141,10 +140,6 @@ export default {
141
140
  type: String,
142
141
  default: 'No results found',
143
142
  },
144
- dataKeyExpr: {
145
- type: String,
146
- default: 'id',
147
- },
148
143
  dataTextExpr: {
149
144
  type: String,
150
145
  default: 'label',
@@ -179,6 +174,7 @@ export default {
179
174
  openState: this.open,
180
175
  tagWidth: '0px',
181
176
  tagValue: null,
177
+ buttonValue: this.placeholder,
182
178
  localItems: null,
183
179
  sortedListItems: null,
184
180
  listboxValue: null,
@@ -214,25 +210,6 @@ export default {
214
210
  'mc-select--s': this.size === 's',
215
211
  };
216
212
  },
217
- getButtonLabel() {
218
- let label = this.placeholder;
219
-
220
- if (this.modelValue && !this.items.length) {
221
- return label;
222
- }
223
-
224
- const value = this.listboxValue;
225
- const selectedItems = this.getSelectedItems(value);
226
- const selectedLabels = selectedItems.map(
227
- (item) => item[this.dataTextExpr]
228
- );
229
-
230
- label =
231
- ((!value || value.length === 0) && this.placeholder) ||
232
- selectedLabels.join(', ');
233
-
234
- return label;
235
- },
236
213
  },
237
214
 
238
215
  watch: {
@@ -254,6 +231,15 @@ export default {
254
231
  },
255
232
  listboxValue: {
256
233
  handler: function (val) {
234
+ const selectedItems = this.getSelectedItems(val);
235
+ const seletedLabels = selectedItems.map(
236
+ (item) => item[this.dataTextExpr]
237
+ );
238
+
239
+ this.buttonValue =
240
+ ((!val || val.length === 0) && this.placeholder) ||
241
+ seletedLabels.join(', ');
242
+
257
243
  if (this.multiple) {
258
244
  this.tagValue = val;
259
245
  }
@@ -272,6 +258,7 @@ export default {
272
258
  this.$emit('update:open', val);
273
259
  },
274
260
  },
261
+
275
262
  methods: {
276
263
  setTagWidth() {
277
264
  this.$nextTick(() => {
@@ -151,7 +151,7 @@ export default {
151
151
  /** The size of title (l, s, m, or xl).*/
152
152
  size: {
153
153
  type: String,
154
- default: 'l',
154
+ default: 'm',
155
155
  validator: (value) => ['s', 'm', 'l', 'xl'].includes(value),
156
156
  },
157
157
  /** Label of the back button. Useful for accessibilty reason */
@@ -238,6 +238,16 @@ export default {
238
238
  @import 'settings-tools/all-settings';
239
239
  @import 'components/c.divider';
240
240
 
241
+ @mixin set-container-padding() {
242
+ padding-left: $mu200;
243
+ padding-right: $mu200;
244
+
245
+ @media (min-width: $screen-l) and (max-width: ($screen-xl - 1)) {
246
+ padding-left: $mu300;
247
+ padding-right: $mu300;
248
+ }
249
+ }
250
+
241
251
  .mc-header {
242
252
  @include set-font-face();
243
253
 
@@ -245,13 +255,11 @@ export default {
245
255
  z-index: 5;
246
256
 
247
257
  &__container {
248
- display: grid;
249
- padding: $mu050 $mu150 $mu100;
258
+ @include set-container-padding();
250
259
 
251
- @include set-from-screen('l') {
252
- padding-left: $mu200;
253
- padding-right: $mu200;
254
- }
260
+ display: grid;
261
+ padding-top: $mu050;
262
+ padding-bottom: $mu100;
255
263
  }
256
264
 
257
265
  &__breadcrumb {
@@ -318,6 +326,7 @@ export default {
318
326
  }
319
327
 
320
328
  &__title {
329
+ @include set-font-scale('08', 'm'); // 28px / 36px
321
330
  @include set-font-weight('semi-bold');
322
331
 
323
332
  margin-top: 0;
@@ -327,10 +336,6 @@ export default {
327
336
  @include set-font-scale('07', 'm'); // 23px / 32px
328
337
  }
329
338
 
330
- &--m {
331
- @include set-font-scale('08', 'm'); // 28px / 36px
332
- }
333
-
334
339
  &--l {
335
340
  @include set-font-scale('09', 'm'); // 34px / 44px
336
341
  }
@@ -376,8 +381,7 @@ export default {
376
381
  }
377
382
 
378
383
  &__tabs {
379
- padding-left: $mu200;
380
- padding-right: $mu200;
384
+ @include set-container-padding();
381
385
  }
382
386
 
383
387
  // Modifiers
@@ -63,10 +63,6 @@ export default {
63
63
  type: Boolean,
64
64
  default: false,
65
65
  },
66
- dataKeyExpr: {
67
- type: String,
68
- default: 'id',
69
- },
70
66
  dataTextExpr: {
71
67
  type: String,
72
68
  default: 'label',
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <fieldset class="mc-field mc-field--group">
3
- <legend class="mc-field__legend">
3
+ <legend v-if="legend" class="mc-field__legend">
4
4
  {{ legend }}
5
5
  <span
6
6
  v-if="requirementText"
@@ -48,7 +48,7 @@ export default {
48
48
  props: {
49
49
  legend: {
50
50
  type: String,
51
- required: true,
51
+ default: null,
52
52
  },
53
53
  requirementText: {
54
54
  type: String,
@@ -106,6 +106,19 @@ export default {
106
106
  </script>
107
107
 
108
108
  <style lang="scss">
109
- @import 'settings-tools/_all-settings';
110
- @import 'components/_c.fields';
109
+ @import 'settings-tools/all-settings';
110
+ @import 'components/c.fields';
111
+
112
+ // TODO: temporary fix - should be put inside @mozaic-ds/styles
113
+ .mc-field--group {
114
+ .mc-field {
115
+ &__container {
116
+ margin-top: 0;
117
+ }
118
+
119
+ &__legend {
120
+ margin-bottom: 1rem;
121
+ }
122
+ }
123
+ }
111
124
  </style>