@ouestfrance/sipa-bms-ui 8.1.4 → 8.3.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/dist/components/form/BmsMultiSelect.vue.d.ts +29 -0
- package/dist/components/form/BmsSelect.vue.d.ts +15 -4
- package/dist/components/table/BmsServerTable.vue.d.ts +2 -2
- package/dist/components/table/UiBmsTable.vue.d.ts +8 -4
- package/dist/components/table/UiBmsTableRow.vue.d.ts +38 -0
- package/dist/composables/search.composable.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/mockServiceWorker.js +1 -1
- package/dist/models/table.model.d.ts +2 -1
- package/dist/sipa-bms-ui.css +116 -57
- package/dist/sipa-bms-ui.es.js +1677 -1451
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +1682 -1455
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +13 -13
- package/src/assets/scss/global-variables.scss +1 -1
- package/src/components/button/UiButton.stories.js +7 -0
- package/src/components/feedback/BmsBadge.stories.js +1 -2
- package/src/components/feedback/BmsTooltip.stories.js +1 -2
- package/src/components/feedback/UiTooltip.stories.js +6 -0
- package/src/components/form/BmsInputToggle.stories.js +1 -1
- package/src/components/form/BmsMultiSelect.stories.js +82 -0
- package/src/components/form/BmsMultiSelect.vue +140 -0
- package/src/components/form/BmsSelect.vue +30 -25
- package/src/components/form/UiBmsInputCheckbox.stories.js +1 -1
- package/src/components/form/UiBmsSwitch.stories.js +6 -1
- package/src/components/layout/BmsForm.stories.js +1 -1
- package/src/components/layout/BmsHeaderTitle.stories.js +1 -1
- package/src/components/navigation/BmsShortLinkMenu.stories.js +1 -1
- package/src/components/navigation/UiMenuItem.stories.js +6 -0
- package/src/components/navigation/UiMenuItemStatus.stories.js +6 -0
- package/src/components/navigation/UiTab.stories.js +7 -0
- package/src/components/navigation/UiTenantSwitcher.stories.js +6 -0
- package/src/components/table/BmsTable.stories.js +113 -0
- package/src/components/table/UiBmsTable.stories.js +49 -1
- package/src/components/table/UiBmsTable.vue +68 -70
- package/src/components/table/UiBmsTableRow.stories.js +143 -0
- package/src/components/table/UiBmsTableRow.vue +150 -0
- package/src/components/table/UiFilterButton.stories.js +6 -0
- package/src/components/utils/BmsProblem.stories.js +1 -1
- package/src/documentation/template_internal_component.mdx +19 -0
- package/src/index.ts +3 -0
- package/src/models/table.model.ts +2 -1
- package/src/showroom/pages/forms.vue +23 -1
- package/src/showroom/pages/table.vue +30 -5
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import BmsTable from '@/components/table/BmsTable.vue';
|
|
2
2
|
import BmsButton from '@/components/button/BmsButton.vue';
|
|
3
|
+
import BmsIconButton from '@/components/button/BmsIconButton.vue';
|
|
4
|
+
import { Save, Trash } from 'lucide-vue-next';
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
7
|
title: 'Composants/table/Table',
|
|
@@ -928,3 +930,114 @@ WithCustomActions.args = {
|
|
|
928
930
|
},
|
|
929
931
|
],
|
|
930
932
|
};
|
|
933
|
+
|
|
934
|
+
const TemplateActionColumn = (args) => ({
|
|
935
|
+
components: {
|
|
936
|
+
BmsTable,
|
|
937
|
+
BmsIconButton,
|
|
938
|
+
Save,
|
|
939
|
+
Trash,
|
|
940
|
+
},
|
|
941
|
+
setup() {
|
|
942
|
+
return { args };
|
|
943
|
+
},
|
|
944
|
+
template: `
|
|
945
|
+
<BmsTable v-bind="args">
|
|
946
|
+
<template #col3="{isChildElement}">
|
|
947
|
+
<template v-if="isChildElement">
|
|
948
|
+
disabled
|
|
949
|
+
</template>
|
|
950
|
+
<template v-else>
|
|
951
|
+
<BmsIconButton><Save/></BmsIconButton>
|
|
952
|
+
<BmsIconButton mode="danger"><Trash/></BmsIconButton>
|
|
953
|
+
</template>
|
|
954
|
+
</template>
|
|
955
|
+
</BmsTable>
|
|
956
|
+
`,
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
export const WithActionColumn = TemplateActionColumn.bind({});
|
|
960
|
+
WithActionColumn.args = {
|
|
961
|
+
headers: [
|
|
962
|
+
{
|
|
963
|
+
label: 'Column 1',
|
|
964
|
+
key: 'col1',
|
|
965
|
+
align: 'start',
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
label: 'Column 2',
|
|
969
|
+
key: 'col2',
|
|
970
|
+
align: 'center',
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
label: 'Column actions',
|
|
974
|
+
key: 'col3',
|
|
975
|
+
action: true,
|
|
976
|
+
},
|
|
977
|
+
],
|
|
978
|
+
items: [
|
|
979
|
+
{
|
|
980
|
+
col1: 'Value1',
|
|
981
|
+
col2: 'Value2',
|
|
982
|
+
col3: 'Value3',
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
col1: 'Value4',
|
|
986
|
+
col2: 'Value5',
|
|
987
|
+
col3: 'Value6',
|
|
988
|
+
},
|
|
989
|
+
],
|
|
990
|
+
selectedItems: [
|
|
991
|
+
{
|
|
992
|
+
col1: 'Value1',
|
|
993
|
+
col2: 'Value2',
|
|
994
|
+
col3: 'Value3',
|
|
995
|
+
},
|
|
996
|
+
],
|
|
997
|
+
selectable: true,
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
export const WithActionColumnAndChildElement = TemplateActionColumn.bind({});
|
|
1001
|
+
WithActionColumnAndChildElement.args = {
|
|
1002
|
+
headers: [
|
|
1003
|
+
{
|
|
1004
|
+
label: 'Column 1',
|
|
1005
|
+
key: 'col1',
|
|
1006
|
+
align: 'start',
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
label: 'Column 2',
|
|
1010
|
+
key: 'col2',
|
|
1011
|
+
align: 'center',
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
label: 'Column actions',
|
|
1015
|
+
key: 'col3',
|
|
1016
|
+
action: true,
|
|
1017
|
+
},
|
|
1018
|
+
],
|
|
1019
|
+
items: [
|
|
1020
|
+
{
|
|
1021
|
+
col1: 'Value1',
|
|
1022
|
+
col2: 'Value2',
|
|
1023
|
+
col3: 'Value3',
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
col1: 'Value4',
|
|
1027
|
+
col2: 'Value5',
|
|
1028
|
+
col3: 'Value6',
|
|
1029
|
+
childElement: {
|
|
1030
|
+
col1: 'child1',
|
|
1031
|
+
col2: 'child2',
|
|
1032
|
+
col3: 'child3',
|
|
1033
|
+
},
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
col1: 'Value10',
|
|
1037
|
+
col2: 'Value11',
|
|
1038
|
+
col3: 'Value12',
|
|
1039
|
+
},
|
|
1040
|
+
],
|
|
1041
|
+
selectedItems: [],
|
|
1042
|
+
selectable: true,
|
|
1043
|
+
};
|
|
@@ -2,8 +2,15 @@ import UiBmsTable from '@/components/table/UiBmsTable.vue';
|
|
|
2
2
|
import { Save, Trash } from 'lucide-vue-next';
|
|
3
3
|
import BmsIconButton from '@/components/button/BmsIconButton.vue';
|
|
4
4
|
|
|
5
|
+
import template from '@/documentation/template_internal_component.mdx';
|
|
6
|
+
|
|
5
7
|
export default {
|
|
6
|
-
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
page: template,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
title: 'Composants/table/UiBmsTable',
|
|
7
14
|
component: UiBmsTable,
|
|
8
15
|
};
|
|
9
16
|
|
|
@@ -561,3 +568,44 @@ AllSelected.args = {
|
|
|
561
568
|
selectable: true,
|
|
562
569
|
totalSize: 2,
|
|
563
570
|
};
|
|
571
|
+
|
|
572
|
+
export const WithChildElements = Template.bind({});
|
|
573
|
+
WithChildElements.args = {
|
|
574
|
+
headers: [
|
|
575
|
+
{
|
|
576
|
+
label: 'Column 1',
|
|
577
|
+
key: 'col1',
|
|
578
|
+
align: 'start',
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
label: 'Column 2',
|
|
582
|
+
key: 'col2',
|
|
583
|
+
align: 'center',
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
label: 'Column 3',
|
|
587
|
+
key: 'col3',
|
|
588
|
+
action: true,
|
|
589
|
+
// align: 'end',
|
|
590
|
+
},
|
|
591
|
+
],
|
|
592
|
+
items: [
|
|
593
|
+
{
|
|
594
|
+
col1: 'Value1',
|
|
595
|
+
col2: 'Value2',
|
|
596
|
+
col3: 'Value3',
|
|
597
|
+
childElement: {
|
|
598
|
+
col1: 'Child1',
|
|
599
|
+
col2: 'Child2',
|
|
600
|
+
col3: 'Child3',
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
col1: 'Value1',
|
|
605
|
+
col2: 'Value2',
|
|
606
|
+
col3: 'Value3',
|
|
607
|
+
},
|
|
608
|
+
],
|
|
609
|
+
hasFilters: true,
|
|
610
|
+
totalSize: 2,
|
|
611
|
+
};
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
SortValue,
|
|
6
6
|
StatusType,
|
|
7
7
|
type TableHeader,
|
|
8
|
-
TooltipDirection,
|
|
9
8
|
} from '@/models';
|
|
10
9
|
import _get from 'lodash/get';
|
|
11
10
|
import _isEqual from 'lodash/isEqual';
|
|
@@ -21,10 +20,9 @@ import {
|
|
|
21
20
|
import BmsLoader from '../feedback/BmsLoader.vue';
|
|
22
21
|
import { ChevronDown, ChevronsUpDown, ChevronUp } from 'lucide-vue-next';
|
|
23
22
|
import UiBmsInputCheckbox from '../form/UiBmsInputCheckbox.vue';
|
|
24
|
-
import { v4 as uuid } from 'uuid';
|
|
25
23
|
import BmsAlert from '../feedback/BmsAlert.vue';
|
|
26
|
-
import BmsTooltip from '../feedback/BmsTooltip.vue';
|
|
27
24
|
import { enforceActionsColumnHeader } from '@/helpers';
|
|
25
|
+
import UiBmsTableRow from './UiBmsTableRow.vue';
|
|
28
26
|
|
|
29
27
|
interface UiBmsTableProps {
|
|
30
28
|
headers: TableHeader[];
|
|
@@ -51,6 +49,7 @@ const props = withDefaults(defineProps<UiBmsTableProps>(), {
|
|
|
51
49
|
selectable: false,
|
|
52
50
|
selectableDisabled: false,
|
|
53
51
|
maxSelectedSize: Infinity,
|
|
52
|
+
selectMode: SelectMode.DEFAULT,
|
|
54
53
|
});
|
|
55
54
|
|
|
56
55
|
const selectedItems: ModelRef<unknown[]> = defineModel('selectedItems', {
|
|
@@ -323,7 +322,6 @@ onMounted(() => {
|
|
|
323
322
|
<th
|
|
324
323
|
v-for="header in filteredHeaders"
|
|
325
324
|
:style="{
|
|
326
|
-
// @ts-ignore
|
|
327
325
|
'--table-cell-width': header?.width || undefined,
|
|
328
326
|
}"
|
|
329
327
|
:class="getHeaderClasses(header)"
|
|
@@ -345,38 +343,44 @@ onMounted(() => {
|
|
|
345
343
|
<tbody class="bms-table__body">
|
|
346
344
|
<template v-if="items.length">
|
|
347
345
|
<template v-for="item in items" :key="item">
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
346
|
+
<UiBmsTableRow
|
|
347
|
+
:item="item"
|
|
348
|
+
:selected-items="selectedItems"
|
|
349
|
+
:selectable="selectable"
|
|
350
|
+
:headers="filteredHeaders"
|
|
351
|
+
:select-mode="selectMode"
|
|
352
|
+
:selectable-disabled="selectableDisabled"
|
|
353
|
+
:dense="mode === 'dense'"
|
|
354
|
+
@select="onItemSelect"
|
|
355
|
+
>
|
|
356
|
+
<template v-for="cell in headers" v-slot:[cell.key]="slotData">
|
|
357
|
+
<slot :name="cell.key" v-bind="slotData" />
|
|
358
|
+
</template>
|
|
359
|
+
<template #default="{ row }">
|
|
360
|
+
<slot name="default" :row="row"></slot>
|
|
361
|
+
</template>
|
|
362
|
+
</UiBmsTableRow>
|
|
363
|
+
<!-- FIXME typing -->
|
|
364
|
+
<template v-if="(item as any)?.childElement">
|
|
365
|
+
<slot name="child-element">
|
|
366
|
+
<UiBmsTableRow
|
|
367
|
+
is-child-element
|
|
368
|
+
:item="item"
|
|
369
|
+
:selected-items="selectedItems"
|
|
370
|
+
:selectable="selectable"
|
|
371
|
+
:headers="filteredHeaders"
|
|
372
|
+
:select-mode="selectMode"
|
|
373
|
+
:selectable-disabled="selectableDisabled"
|
|
370
374
|
>
|
|
371
|
-
<
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
</
|
|
377
|
-
</
|
|
375
|
+
<template
|
|
376
|
+
v-for="cell in headers"
|
|
377
|
+
v-slot:[cell.key]="slotData"
|
|
378
|
+
>
|
|
379
|
+
<slot :name="cell.key" v-bind="slotData" />
|
|
380
|
+
</template>
|
|
381
|
+
</UiBmsTableRow>
|
|
378
382
|
</slot>
|
|
379
|
-
</
|
|
383
|
+
</template>
|
|
380
384
|
</template>
|
|
381
385
|
</template>
|
|
382
386
|
<template v-else>
|
|
@@ -502,44 +506,44 @@ onMounted(() => {
|
|
|
502
506
|
td {
|
|
503
507
|
padding: var(--table-cell-padding);
|
|
504
508
|
}
|
|
509
|
+
}
|
|
505
510
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
511
|
+
th {
|
|
512
|
+
--header-content-sort-icon-color: var(--bms-grey-25);
|
|
513
|
+
--header-content-justify: start;
|
|
509
514
|
|
|
510
|
-
|
|
511
|
-
|
|
515
|
+
width: var(--table-cell-width, auto);
|
|
516
|
+
padding: var(--table-cell-padding);
|
|
512
517
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
518
|
+
&.sortable:hover {
|
|
519
|
+
--header-content-sort-icon-color: var(--bms-grey-100);
|
|
520
|
+
cursor: pointer;
|
|
521
|
+
}
|
|
517
522
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
523
|
+
&.u-text-align-start {
|
|
524
|
+
--header-content-justify: start;
|
|
525
|
+
}
|
|
521
526
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
527
|
+
&.u-text-align-center {
|
|
528
|
+
--header-content-justify: center;
|
|
529
|
+
}
|
|
525
530
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
531
|
+
&.u-text-align-end {
|
|
532
|
+
--header-content-justify: end;
|
|
533
|
+
}
|
|
529
534
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
535
|
+
&.sorted {
|
|
536
|
+
--header-content-sort-icon-color: var(--bms-grey-100);
|
|
537
|
+
}
|
|
533
538
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
+
.header-content {
|
|
540
|
+
display: flex;
|
|
541
|
+
align-items: center;
|
|
542
|
+
justify-content: var(--header-content-justify);
|
|
543
|
+
gap: 0.5em;
|
|
539
544
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
545
|
+
&-sort {
|
|
546
|
+
color: var(--header-content-sort-icon-color);
|
|
543
547
|
}
|
|
544
548
|
}
|
|
545
549
|
}
|
|
@@ -597,22 +601,16 @@ onMounted(() => {
|
|
|
597
601
|
border-bottom-right-radius: var(--table-cell-radius);
|
|
598
602
|
}
|
|
599
603
|
|
|
600
|
-
td,
|
|
601
604
|
th {
|
|
602
605
|
background-color: rgba(255, 255, 255, 1);
|
|
603
606
|
}
|
|
604
607
|
|
|
605
608
|
tbody {
|
|
606
609
|
overflow: hidden;
|
|
610
|
+
background: white;
|
|
607
611
|
|
|
608
612
|
tr {
|
|
609
613
|
position: relative;
|
|
610
|
-
|
|
611
|
-
&.selected {
|
|
612
|
-
td {
|
|
613
|
-
background-color: var(--bms-main-10);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
614
|
}
|
|
617
615
|
}
|
|
618
616
|
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import UiBmsTableRow from '@/components/table/UiBmsTableRow.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Composants/table/UiBmsTableRow',
|
|
5
|
+
component: UiBmsTableRow,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const Template = (args) => ({
|
|
9
|
+
components: {
|
|
10
|
+
UiBmsTableRow,
|
|
11
|
+
},
|
|
12
|
+
setup() {
|
|
13
|
+
return { args };
|
|
14
|
+
},
|
|
15
|
+
// And then the `args` are bound to your component with `v-bind="args"`
|
|
16
|
+
template: `
|
|
17
|
+
<table style="width:100%">
|
|
18
|
+
<UiBmsTableRow v-bind="args">
|
|
19
|
+
</UiBmsTableRow>
|
|
20
|
+
</table>
|
|
21
|
+
`,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Default = Template.bind({});
|
|
25
|
+
Default.args = {
|
|
26
|
+
headers: [
|
|
27
|
+
{
|
|
28
|
+
label: 'Column 1',
|
|
29
|
+
key: 'col1',
|
|
30
|
+
align: 'start',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: 'Column 2',
|
|
34
|
+
key: 'col2',
|
|
35
|
+
align: 'center',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Column 3',
|
|
39
|
+
key: 'col3',
|
|
40
|
+
align: 'end',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
selectedItems: [],
|
|
44
|
+
item: {
|
|
45
|
+
col1: 'Value1',
|
|
46
|
+
col2: 'Value2',
|
|
47
|
+
col3: 'Value3',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Dense = Template.bind({});
|
|
52
|
+
Dense.args = {
|
|
53
|
+
dense: true,
|
|
54
|
+
headers: [
|
|
55
|
+
{
|
|
56
|
+
label: 'Column 1',
|
|
57
|
+
key: 'col1',
|
|
58
|
+
align: 'start',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: 'Column 2',
|
|
62
|
+
key: 'col2',
|
|
63
|
+
align: 'center',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: 'Column 3',
|
|
67
|
+
key: 'col3',
|
|
68
|
+
align: 'end',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
selectedItems: [],
|
|
72
|
+
item: {
|
|
73
|
+
col1: 'Value1',
|
|
74
|
+
col2: 'Value2',
|
|
75
|
+
col3: 'Value3',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Selected = Template.bind({});
|
|
80
|
+
Selected.args = {
|
|
81
|
+
headers: [
|
|
82
|
+
{
|
|
83
|
+
label: 'Column 1',
|
|
84
|
+
key: 'col1',
|
|
85
|
+
align: 'start',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: 'Column 2',
|
|
89
|
+
key: 'col2',
|
|
90
|
+
align: 'center',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
label: 'Column 3',
|
|
94
|
+
key: 'col3',
|
|
95
|
+
align: 'end',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
selectedItems: [
|
|
99
|
+
{
|
|
100
|
+
col1: 'Value1',
|
|
101
|
+
col2: 'Value2',
|
|
102
|
+
col3: 'Value3',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
item: {
|
|
106
|
+
col1: 'Value1',
|
|
107
|
+
col2: 'Value2',
|
|
108
|
+
col3: 'Value3',
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const IsChildElement = Template.bind({});
|
|
113
|
+
IsChildElement.args = {
|
|
114
|
+
isChildElement: true,
|
|
115
|
+
headers: [
|
|
116
|
+
{
|
|
117
|
+
label: 'Column 1',
|
|
118
|
+
key: 'col1',
|
|
119
|
+
align: 'start',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: 'Column 2',
|
|
123
|
+
key: 'col2',
|
|
124
|
+
align: 'center',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
label: 'Column 3',
|
|
128
|
+
key: 'col3',
|
|
129
|
+
align: 'end',
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
selectedItems: [],
|
|
133
|
+
item: {
|
|
134
|
+
col1: 'Value1',
|
|
135
|
+
col2: 'Value2',
|
|
136
|
+
col3: 'Value3',
|
|
137
|
+
childElement: {
|
|
138
|
+
col1: 'child1',
|
|
139
|
+
col2: 'child2',
|
|
140
|
+
col3: 'child3',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tr
|
|
3
|
+
class="bms-table__row"
|
|
4
|
+
:class="{
|
|
5
|
+
'bms-table__row--selected': isItemSelected(item),
|
|
6
|
+
'bms-table__row--disabled': isChildElement,
|
|
7
|
+
'bms-table__row--dense': dense,
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
<td v-if="selectable" class="bms-table__row__cell__checkbox">
|
|
11
|
+
<BmsTooltip
|
|
12
|
+
:direction="TooltipDirection.Right"
|
|
13
|
+
tooltip-text="Vous ne pouvez pas désélectionner un élément unitairement si vous avez choisi de sélectionner la totalité des éléments"
|
|
14
|
+
:activated="selectMode === SelectMode.ALL"
|
|
15
|
+
>
|
|
16
|
+
<UiBmsInputCheckbox
|
|
17
|
+
:name="uuid()"
|
|
18
|
+
:disabled="selectMode === SelectMode.ALL || selectableDisabled"
|
|
19
|
+
:model-value="isItemSelected(item)"
|
|
20
|
+
@update:model-value="emits('select', item)"
|
|
21
|
+
/>
|
|
22
|
+
</BmsTooltip>
|
|
23
|
+
</td>
|
|
24
|
+
<slot name="default" :row="item">
|
|
25
|
+
<td
|
|
26
|
+
v-for="(cell, index) in headers"
|
|
27
|
+
:class="[getAlignClass(cell), 'bms-table__row__cell']"
|
|
28
|
+
:key="cell.key"
|
|
29
|
+
>
|
|
30
|
+
<div v-if="isChildElement" class="bms-table__row__cell--child-element">
|
|
31
|
+
<div class="bms-table__row__cell--child-element__icon">
|
|
32
|
+
<CornerDownRight v-if="index === 0" />
|
|
33
|
+
</div>
|
|
34
|
+
<slot
|
|
35
|
+
:name="cell.key"
|
|
36
|
+
:row="item.childElement"
|
|
37
|
+
:isChildElement="isChildElement"
|
|
38
|
+
>
|
|
39
|
+
{{ _get(item.childElement, cell.key) || '' }}
|
|
40
|
+
</slot>
|
|
41
|
+
</div>
|
|
42
|
+
<div v-else-if="cell?.action" class="bms-table__row__cell--action">
|
|
43
|
+
<slot
|
|
44
|
+
:name="cell.key"
|
|
45
|
+
:row="item"
|
|
46
|
+
:isChildElement="isChildElement"
|
|
47
|
+
></slot>
|
|
48
|
+
</div>
|
|
49
|
+
<slot
|
|
50
|
+
v-else
|
|
51
|
+
:name="cell.key"
|
|
52
|
+
:row="item"
|
|
53
|
+
:isChildElement="isChildElement"
|
|
54
|
+
>
|
|
55
|
+
{{ _get(item, cell.key) || '' }}
|
|
56
|
+
</slot>
|
|
57
|
+
</td>
|
|
58
|
+
</slot>
|
|
59
|
+
</tr>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { SelectMode, TableHeader, TooltipDirection } from '@/models';
|
|
64
|
+
import { v4 as uuid } from 'uuid';
|
|
65
|
+
import _isEqual from 'lodash/isEqual';
|
|
66
|
+
import _get from 'lodash/get';
|
|
67
|
+
import UiBmsInputCheckbox from '../form/UiBmsInputCheckbox.vue';
|
|
68
|
+
import BmsTooltip from '../feedback/BmsTooltip.vue';
|
|
69
|
+
import { CornerDownRight } from 'lucide-vue-next';
|
|
70
|
+
|
|
71
|
+
interface Props {
|
|
72
|
+
item: any;
|
|
73
|
+
selectedItems: any[];
|
|
74
|
+
selectable: boolean;
|
|
75
|
+
headers: TableHeader[];
|
|
76
|
+
selectMode: SelectMode;
|
|
77
|
+
selectableDisabled?: boolean;
|
|
78
|
+
dense?: boolean;
|
|
79
|
+
isChildElement?: boolean;
|
|
80
|
+
}
|
|
81
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
82
|
+
dense: false,
|
|
83
|
+
selectableDisabled: false,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const emits = defineEmits<{ select: [item: any] }>();
|
|
87
|
+
|
|
88
|
+
const isItemSelected = (item: unknown): boolean => {
|
|
89
|
+
return (
|
|
90
|
+
props.selectMode === SelectMode.ALL ||
|
|
91
|
+
!!props.selectedItems.find((it) => _isEqual(item, it))
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const getAlignClass = (header: TableHeader) => {
|
|
96
|
+
const align = !header.align ? 'start' : header.align;
|
|
97
|
+
return `u-text-align-${align}`;
|
|
98
|
+
};
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<style lang="scss" scoped>
|
|
102
|
+
.bms-table__row {
|
|
103
|
+
--table-cell-padding: 1em;
|
|
104
|
+
background-color: rgba(255, 255, 255, 1);
|
|
105
|
+
|
|
106
|
+
td {
|
|
107
|
+
padding: var(--table-cell-padding);
|
|
108
|
+
background-color: rgba(255, 255, 255, 1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&--dense {
|
|
112
|
+
--table-cell-padding: 0.5em 1em;
|
|
113
|
+
}
|
|
114
|
+
&--selected {
|
|
115
|
+
:deep(td) {
|
|
116
|
+
background-color: var(--bms-main-10);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&--disabled {
|
|
121
|
+
td {
|
|
122
|
+
color: var(--bms-grey-50);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&__cell {
|
|
127
|
+
&__checkbox {
|
|
128
|
+
width: 4em;
|
|
129
|
+
}
|
|
130
|
+
&--action {
|
|
131
|
+
display: flex;
|
|
132
|
+
justify-content: end;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&--empty {
|
|
136
|
+
height: 360px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&--child-element {
|
|
140
|
+
display: inline-flex;
|
|
141
|
+
align-items: flex-end;
|
|
142
|
+
&__icon {
|
|
143
|
+
display: flex;
|
|
144
|
+
min-width: 1em;
|
|
145
|
+
margin-right: 1em;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import UiFilterButton from '@/components/table/UiFilterButton.vue';
|
|
2
|
+
import template from '@/documentation/template_internal_component.mdx';
|
|
2
3
|
|
|
3
4
|
export default {
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {
|
|
7
|
+
page: template,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
4
10
|
title: 'Composants/table/FilterButton',
|
|
5
11
|
component: UiFilterButton,
|
|
6
12
|
argTypes: {},
|