@mozaic-ds/vue 0.19.1 → 1.0.0-rc.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.19.1",
3
+ "version": "1.0.0-rc.0",
4
4
  "description": "Vue.js implementation of Mozaic Design System",
5
5
  "author": "Adeo - Mozaic Design System",
6
6
  "scripts": {
@@ -23,9 +23,9 @@
23
23
  "postinstall.js"
24
24
  ],
25
25
  "dependencies": {
26
- "@mozaic-ds/css-dev-tools": "1.29.1",
26
+ "@mozaic-ds/css-dev-tools": "2.0.0-rc.1",
27
27
  "@mozaic-ds/icons": "1.34.0",
28
- "@mozaic-ds/styles": "1.33.0",
28
+ "@mozaic-ds/styles": "2.0.0-rc.4",
29
29
  "@mozaic-ds/web-fonts": "1.22.0",
30
30
  "core-js": "^3.18.3",
31
31
  "libphonenumber-js": "1.9.50",
@@ -1,118 +1,146 @@
1
1
  <template>
2
- <div class="mc-data-table" :class="getClasses">
2
+ <div class="mc-datatable" :class="[getClasses, `mc-datatable--${size}`]">
3
+ <MDataTableTop v-if="$slots.edition || $slots.actions || $slots.filters">
4
+ <template #edition>
5
+ <slot name="edition" />
6
+ </template>
7
+ <template #actions>
8
+ <slot name="actions" />
9
+ </template>
10
+ <template #filters>
11
+ <slot name="filters" />
12
+ </template>
13
+ </MDataTableTop>
14
+
3
15
  <slot />
4
- <div class="mc-data-table__body">
5
- <table aria-describedby="data" :class="getTableClasses">
6
- <thead>
7
- <tr v-if="!hideHeader">
8
- <th
9
- v-for="(header, index) in getHeaders"
10
- :key="`header-${index}`"
11
- :class="header.cssClass"
12
- scope="col"
13
- >
14
- <div class="header">
15
- <slot :name="`header.${header.dataFieldExpr}`" :header="header">
16
- {{ header.caption }}
17
- </slot>
18
- <div
16
+
17
+ <div class="mc-datatable__container">
18
+ <!-- MAIN -->
19
+ <div class="mc-datatable__main" :style="tableStyle">
20
+ <table class="mc-datatable__table" :class="getTableClasses">
21
+ <thead v-if="!hideHeader">
22
+ <tr>
23
+ <th
24
+ v-for="(header, index) in getHeaders"
25
+ :key="`header-${index}`"
26
+ :class="header.cssClass"
27
+ scope="col"
28
+ >
29
+ <button
19
30
  v-if="sorting.mode !== 'none' && header.allowSorting"
20
- class="header__sort"
31
+ type="button"
32
+ class="mc-datatable__sort mc-datatable__btn"
33
+ :class="header.sortOrder"
21
34
  @click="!loading && onSortClick({ e: $event, header })"
22
35
  >
23
- <m-icon
24
- :name="'ArrowArrowTop16'"
25
- :class="{ active: header.sortOrder === 'asc' }"
26
- />
27
- <m-icon
28
- :name="'ArrowArrowBottom16'"
29
- :class="{ active: header.sortOrder === 'desc' }"
30
- />
31
- </div>
32
- </div>
33
- </th>
34
- </tr>
35
- </thead>
36
- <tbody>
37
- <tr
38
- v-for="(item, rowIndex) in getSource"
39
- :key="item[dataKeyExpr]"
40
- :class="rowClasses(item)"
41
- >
42
- <td
43
- v-for="(header, index) in getHeaders"
44
- :key="`${index}-${getItemValue(item, dataKeyExpr)}-${
45
- header.dataFieldExpr
46
- }`"
47
- :class="header.cssClass"
48
- @click="
49
- allowRowClick && onRowClick({ event: $event, item: item })
50
- "
36
+ <span class="mc-datatable__sort-label">
37
+ <span class="visually-hidden">Trier par</span>
38
+ {{ header.caption }}
39
+ </span>
40
+
41
+ <span class="mc-datatable__sort-arrow"></span>
42
+ </button>
43
+
44
+ <slot
45
+ v-else
46
+ :name="`header.${header.dataFieldExpr}`"
47
+ :header="header"
48
+ >
49
+ {{ header.caption }}
50
+ </slot>
51
+ </th>
52
+ </tr>
53
+ </thead>
54
+ <tbody>
55
+ <tr
56
+ v-for="(item, rowIndex) in getSource"
57
+ :key="item[dataKeyExpr]"
58
+ :class="rowClasses(item)"
51
59
  >
52
- <slot
53
- :name="`item.${header.dataFieldExpr}`"
54
- :item="item"
55
- :index="rowIndex"
60
+ <td
61
+ v-for="(header, index) in getHeaders"
62
+ :key="`${index}-${getItemValue(item, dataKeyExpr)}-${
63
+ header.dataFieldExpr
64
+ }`"
65
+ :class="header.cssClass"
66
+ @click="
67
+ allowRowClick && onRowClick({ event: $event, item: item })
68
+ "
56
69
  >
57
- {{ getItemValue(item, header.dataFieldExpr) }}
58
- </slot>
59
- </td>
60
- </tr>
61
- <tr v-if="getSource.length == 0">
62
- <td :colspan="getHeaders.length">
63
- <slot name="no-data" />
64
- </td>
65
- </tr>
66
- </tbody>
67
- </table>
68
- </div>
69
- <div
70
- v-if="pagingOptions.enabled && total != null"
71
- class="mc-data-table__footer"
72
- >
73
- <div class="mc-data-table__footer__item-per-page">
74
- <m-select
75
- :id="'itemPerPage'"
76
- :disabled="loading"
77
- :options="getPageSizes"
78
- :value="getPageValue"
79
- @change="onPageSizeChanged"
80
- >
81
- <template #text="{ option }">
82
- <slot name="pager.text" :pager="option">
83
- {{ option.text }}
84
- </slot>
85
- </template>
86
- </m-select>
70
+ <slot
71
+ :name="`item.${header.dataFieldExpr}`"
72
+ :item="item"
73
+ :index="rowIndex"
74
+ >
75
+ {{ getItemValue(item, header.dataFieldExpr) }}
76
+ </slot>
77
+ </td>
78
+ </tr>
79
+ <!-- NO-DATA -->
80
+ <tr v-if="getSource.length === 0">
81
+ <td :colspan="getHeaders.length">
82
+ <slot name="no-data" />
83
+ </td>
84
+ </tr>
85
+ </tbody>
86
+ </table>
87
87
  </div>
88
+
89
+ <!-- FOOTER -->
88
90
  <div
89
- v-if="pagingOptions.displayTotal"
90
- class="mc-data-table__footer__display-total-item"
91
+ v-if="pagingOptions.enabled && total != null"
92
+ class="mc-datatable__footer"
91
93
  >
92
- <span class="strong">{{ getTotalStringCurrentCount }}</span> /
93
- <span class="strong">{{ total }}</span>
94
- </div>
95
- <div class="mc-data-table__footer__pagination">
96
- <m-pagination
97
- :disabled="loading"
98
- :length="getPagingSize"
99
- :page-label="pagingOptions.pageLabel"
100
- :value="pagingOptions.index"
101
- @on-update-page="onUpdatePage"
102
- >
103
- <template #text="{ option }">
104
- <slot name="paging.text" :paging="option">
105
- {{ option.text }}
106
- </slot>
107
- </template>
108
- </m-pagination>
94
+ <!-- select -->
95
+ <div class="mc-datatable__select">
96
+ <label for="itemPerPage" class="mc-datatable__select-label">
97
+ Rows per page
98
+ </label>
99
+ <m-select
100
+ :id="'itemPerPage'"
101
+ size="s"
102
+ :disabled="loading"
103
+ :options="getPageSizes"
104
+ :value="getPageValue"
105
+ @change="onPageSizeChanged"
106
+ >
107
+ <template #text="{ option }">
108
+ <slot name="pager.text" :pager="option">
109
+ {{ option.text }}
110
+ </slot>
111
+ </template>
112
+ </m-select>
113
+ </div>
114
+
115
+ <!-- count -->
116
+ <div v-if="pagingOptions.displayTotal" class="mc-datatable__count">
117
+ <strong>{{ getTotalStringCurrentCount }}</strong> of
118
+ <strong>{{ total }}</strong>
119
+ </div>
120
+
121
+ <!-- pagination -->
122
+ <div class="mc-datatable__pagination">
123
+ <m-pagination
124
+ :disabled="loading"
125
+ :length="getPagingSize"
126
+ :page-label="pagingOptions.pageLabel"
127
+ :value="pagingOptions.index"
128
+ @on-update-page="onUpdatePage"
129
+ >
130
+ <template #text="{ option }">
131
+ <slot name="paging.text" :paging="option">
132
+ {{ option.text }}
133
+ </slot>
134
+ </template>
135
+ </m-pagination>
136
+ </div>
109
137
  </div>
110
138
  </div>
111
139
  </div>
112
140
  </template>
113
141
 
114
142
  <script>
115
- import MIcon from '../icon/MIcon.vue';
143
+ import MDataTableTop from './MDataTableTop.vue';
116
144
  import MPagination from '../pagination/MPagination.vue';
117
145
  import MSelect from '../select/MSelect.vue';
118
146
 
@@ -158,7 +186,7 @@ function buildOptions(
158
186
  const columnSorters = sortedColmuns.reduce(
159
187
  (acc, header) => ({
160
188
  ...acc,
161
- [header.sortFieldExpr ?? header.dataFieldExpr]: header.sortOrder,
189
+ [header.dataFieldExpr]: header.sortOrder,
162
190
  }),
163
191
  {}
164
192
  );
@@ -209,7 +237,7 @@ const Sorting = {
209
237
  export default {
210
238
  name: 'MDataTable',
211
239
 
212
- components: { MIcon, MSelect, MPagination },
240
+ components: { MDataTableTop, MSelect, MPagination },
213
241
 
214
242
  props: {
215
243
  /** Get or set the name of identity. */
@@ -221,7 +249,7 @@ export default {
221
249
 
222
250
  /**
223
251
  * Get or set the headers informations.
224
- * @type {{ caption: string, dataFieldExpr: string, sortFieldExpr: string, allowSorting: boolean, sortOrder: 'asc' | 'desc' | null }[] }
252
+ * @example {{ caption: string, dataFieldExpr: string, sortFieldExpr: string, allowSorting: boolean, sortOrder: 'asc' | 'desc' | null }[] }
225
253
  */
226
254
  headers: {
227
255
  type: Array,
@@ -282,7 +310,10 @@ export default {
282
310
  default: () => ({}),
283
311
  },
284
312
 
285
- /** Get or set if the headers are hide. */
313
+ /**
314
+ * Defines whether headers are hidden
315
+ * @values false, true
316
+ */
286
317
  hideHeader: {
287
318
  type: Boolean,
288
319
  default: false,
@@ -292,6 +323,20 @@ export default {
292
323
  type: [String, Function, Object],
293
324
  default: '',
294
325
  },
326
+
327
+ size: {
328
+ type: String,
329
+ default: 'm',
330
+ validator: (value) => ['s', 'm', 'l'].includes(value),
331
+ },
332
+
333
+ /**
334
+ * Defines custom styles on .mc-datatable__main element
335
+ */
336
+ tableStyle: {
337
+ type: Object,
338
+ default: null,
339
+ },
295
340
  },
296
341
 
297
342
  data() {
@@ -323,7 +368,7 @@ export default {
323
368
 
324
369
  getClasses() {
325
370
  return {
326
- 'mc-data-table--fixed-header': this.fixedHeader,
371
+ 'mc-datatable--sticky-header': this.fixedHeader,
327
372
  };
328
373
  },
329
374
 
@@ -469,7 +514,7 @@ export default {
469
514
  const getClasses = parseClasses(this.itemClasses, item);
470
515
 
471
516
  return {
472
- 'mc-data-table__body__row--clickable': this.allowRowClick,
517
+ 'mc-datatable__row-clickable': this.allowRowClick,
473
518
  ...getClasses,
474
519
  };
475
520
  },
@@ -586,194 +631,21 @@ export default {
586
631
  </script>
587
632
 
588
633
  <style lang="scss">
589
- /* stylelint-disable */
590
- $local-config: (
591
- font-path: '~@mozaic-ds/web-fonts',
592
- );
593
-
594
- @import 'settings-tools/_all-settings';
595
-
596
- .mc-data-table {
597
- @include set-font-face();
598
-
599
- position: relative;
600
- background-color: $color-grey-000;
601
- padding: 2px 0;
602
- background-clip: padding-box;
603
- display: flex;
604
- flex-direction: column;
605
-
606
- @include set-border-radius('m');
607
-
608
- &__body {
609
- overflow-x: scroll;
610
- height: 100%;
611
-
612
- & table {
613
- border-collapse: collapse;
614
- width: 100%;
615
-
616
- &.no-data {
617
- height: 100%;
618
- & tr {
619
- & td {
620
- text-align: center;
621
- }
622
- }
623
- }
624
-
625
- & thead {
626
- & tr {
627
- & th {
628
- height: 46px;
629
- background-color: $color-grey-000;
630
- padding: 0 1rem;
631
- font-style: normal;
632
- font-weight: 600;
633
- font-size: 14px;
634
- line-height: 18px;
635
- text-align: left;
636
- box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
637
- white-space: nowrap;
638
- text-overflow: ellipsis;
639
-
640
- & .header {
641
- display: flex;
642
- align-items: center;
643
-
644
- &__sort {
645
- margin-left: 5px;
646
- position: relative;
647
- width: 24px;
648
-
649
- & svg {
650
- margin-top: -50%;
651
- opacity: 0.1;
652
- position: absolute;
653
- cursor: pointer;
654
-
655
- &.active {
656
- opacity: 1;
657
- }
658
-
659
- &:last-child {
660
- top: 9px;
661
- }
662
- }
663
- }
664
- }
665
- }
666
- }
667
- }
668
-
669
- & tbody {
670
- & tr {
671
- &:not(:last-child) {
672
- border-bottom: 1px solid $color-grey-300;
673
- }
674
-
675
- &.mc-data-table__body__row--clickable {
676
- cursor: pointer;
677
-
678
- &:hover {
679
- background-color: $color-grey-100;
680
- opacity: 0.8;
681
- }
682
-
683
- &:active {
684
- background-color: $color-grey-200;
685
- opacity: 0.8;
686
- }
687
- }
688
-
689
- & td {
690
- font-style: normal;
691
- font-weight: normal;
692
- font-size: 13px;
693
- line-height: 18px;
694
- height: 40px;
695
- padding: 0 1rem;
696
- white-space: nowrap;
697
- text-overflow: ellipsis;
698
- }
699
- }
700
- }
701
- }
634
+ @import 'settings-tools/all-settings';
635
+ @import 'components/c.datatable';
636
+ @import 'components/c.datatable-tools';
637
+ @import 'components/c.datatable-footer';
638
+ // @import 'components/c.datatable-subtable';
639
+
640
+ .mc-datatable {
641
+ &__main {
642
+ overflow-y: auto;
702
643
  }
703
644
 
704
- &__footer {
705
- border-top: 1px solid $color-grey-300;
706
- height: 70px;
707
- display: flex;
708
- align-items: center;
709
- padding: 0 1rem;
710
-
711
- @include set-border-radius('m', 'bottom');
712
-
713
- &__item-per-page {
714
- & select {
715
- width: auto;
716
- font-size: 0.875rem;
717
- line-height: 1.1428571;
718
- padding: calc(0.5rem - 1px) 2.25rem calc(0.5rem - 1px)
719
- calc(0.5rem - 1px);
720
- }
721
- }
722
-
723
- &__display-total-item {
724
- width: auto;
725
- min-width: 150px;
726
- padding: 0.5rem 2.25rem;
727
- font-size: 0.875rem;
728
- .strong {
729
- font-weight: bold;
730
- }
731
- }
732
-
733
- &__pagination {
734
- text-align: right;
735
- width: 100%;
736
- display: flex;
737
- justify-content: flex-end;
738
-
739
- & .mc-pagination {
740
- .mc-pagination__button {
741
- min-width: 2rem;
742
- min-height: 2rem;
743
-
744
- .mc-pagination__button-icon {
745
- height: 1rem;
746
- width: 1rem;
747
- }
748
- }
749
-
750
- .mc-select {
751
- font-size: 0.875rem;
752
- line-height: 1.1428571;
753
- padding: calc(0.5rem - 1px) 2.25rem calc(0.5rem - 1px)
754
- calc(0.5rem - 1px);
755
- }
756
- }
757
- }
758
- }
759
-
760
- &.mc-data-table--fixed-header & {
761
- &__body {
762
- & table {
763
- overflow-y: auto;
764
-
765
- & thead {
766
- & tr {
767
- & th {
768
- position: sticky;
769
- top: 0;
770
- z-index: 1;
771
- }
772
- }
773
- }
774
- }
645
+ &__row {
646
+ &-clickable {
647
+ cursor: pointer;
775
648
  }
776
649
  }
777
650
  }
778
- /* stylelint-enable */
779
651
  </style>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <div
3
+ v-if="$slots.edition || $slots.actions || $slots.filters"
4
+ class="mc-datatable__header"
5
+ >
6
+ <div class="mc-datatable__topbar">
7
+ <div v-if="$slots.edition" class="mc-datatable__topbar-edition">
8
+ <slot name="edition" />
9
+ </div>
10
+ <div v-if="$slots.actions" class="mc-datatable__topbar-actions">
11
+ <slot name="actions" />
12
+ </div>
13
+ </div>
14
+ <div v-if="$slots.filters" class="mc-datatable__filters">
15
+ <slot name="filters" />
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ export default {
22
+ name: 'MDataTableTop',
23
+ };
24
+ </script>
25
+
26
+ <style lang="scss">
27
+ @import 'settings-tools/all-settings';
28
+ @import 'components/c.datatable-header';
29
+
30
+ .mc-datatable {
31
+ &__topbar-actions {
32
+ margin-left: auto;
33
+ }
34
+ }
35
+ </style>