@ouestfrance/sipa-bms-ui 8.9.0 → 8.9.2
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 +4 -4
- package/dist/sipa-bms-ui.css +17 -19
- package/dist/sipa-bms-ui.es.js +34 -20
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +34 -20
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/BmsMultiSelect.stories.js +6 -6
- package/src/components/form/BmsMultiSelect.vue +45 -20
- package/src/components/layout/BmsStepper.vue +0 -2
- package/src/showroom/pages/autocomplete.vue +12 -2
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ export const Default = Template.bind({});
|
|
|
30
30
|
Default.args = {
|
|
31
31
|
label: 'My label',
|
|
32
32
|
captions: ['Helping text'],
|
|
33
|
-
modelValue:
|
|
33
|
+
modelValue: null,
|
|
34
34
|
options: [
|
|
35
35
|
{ label: 'optionA', value: 'a' },
|
|
36
36
|
{ label: 'optionB', value: 'b' },
|
|
@@ -40,7 +40,7 @@ Default.args = {
|
|
|
40
40
|
export const WithValue = Template.bind({});
|
|
41
41
|
WithValue.args = {
|
|
42
42
|
label: 'My label',
|
|
43
|
-
modelValue: [
|
|
43
|
+
modelValue: ['a'],
|
|
44
44
|
options: [
|
|
45
45
|
{ label: 'optionA', value: 'a' },
|
|
46
46
|
{ label: 'optionB', value: 'b' },
|
|
@@ -50,7 +50,7 @@ WithValue.args = {
|
|
|
50
50
|
export const Disabled = Template.bind({});
|
|
51
51
|
Disabled.args = {
|
|
52
52
|
label: 'My label',
|
|
53
|
-
modelValue: [
|
|
53
|
+
modelValue: ['a'],
|
|
54
54
|
options: [
|
|
55
55
|
{ label: 'optionA', value: 'a' },
|
|
56
56
|
{ label: 'optionB', value: 'b' },
|
|
@@ -61,7 +61,7 @@ Disabled.args = {
|
|
|
61
61
|
export const Opened = Template.bind({});
|
|
62
62
|
Opened.args = {
|
|
63
63
|
label: 'My label',
|
|
64
|
-
modelValue:
|
|
64
|
+
modelValue: null,
|
|
65
65
|
options: [
|
|
66
66
|
{ label: 'optionA', value: 'a' },
|
|
67
67
|
{ label: 'optionB', value: 'b' },
|
|
@@ -72,7 +72,7 @@ Opened.args = {
|
|
|
72
72
|
export const WithErrors = Template.bind({});
|
|
73
73
|
WithErrors.args = {
|
|
74
74
|
label: 'My label',
|
|
75
|
-
modelValue:
|
|
75
|
+
modelValue: null,
|
|
76
76
|
options: [
|
|
77
77
|
{ label: 'optionA', value: 'a' },
|
|
78
78
|
{ label: 'optionB', value: 'b' },
|
|
@@ -83,7 +83,7 @@ WithErrors.args = {
|
|
|
83
83
|
export const WithIncorrectValue = Template.bind({});
|
|
84
84
|
WithIncorrectValue.args = {
|
|
85
85
|
label: 'My label',
|
|
86
|
-
modelValue: [
|
|
86
|
+
modelValue: ['a'],
|
|
87
87
|
options: [
|
|
88
88
|
{ label: 'optionB', value: 'b' },
|
|
89
89
|
{ label: 'optionC', value: 'c' },
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<RawSelect
|
|
3
3
|
v-bind="$props"
|
|
4
|
-
:options="
|
|
4
|
+
:options="filteredOptions"
|
|
5
5
|
:model-value="modelValue"
|
|
6
6
|
:open="isDatalistOpen"
|
|
7
7
|
@select="onSelect"
|
|
8
|
+
@click="setFocus"
|
|
8
9
|
>
|
|
9
10
|
<template #input>
|
|
10
11
|
<div class="tags">
|
|
11
12
|
<BmsTag
|
|
12
|
-
v-for="tag in
|
|
13
|
+
v-for="tag in selectedItems"
|
|
13
14
|
:small="small"
|
|
14
15
|
active
|
|
15
16
|
@dismiss="removeOption(tag.value)"
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
</div>
|
|
32
33
|
|
|
33
34
|
<span class="icon-container">
|
|
34
|
-
<template v-if="modelValue
|
|
35
|
+
<template v-if="modelValue && modelValue?.length">
|
|
35
36
|
<X class="icon icon-clear" @click.stop="clearInput" />
|
|
36
37
|
</template>
|
|
37
38
|
<template v-else>
|
|
@@ -65,9 +66,10 @@ import { InputOption } from '@/models';
|
|
|
65
66
|
import { searchString } from '@/helpers';
|
|
66
67
|
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
67
68
|
import RawSelect from './RawSelect.vue';
|
|
69
|
+
import { onClickOutside } from '@vueuse/core';
|
|
68
70
|
|
|
69
71
|
export interface Props extends FieldComponentProps {
|
|
70
|
-
options: InputOption[];
|
|
72
|
+
options: InputOption[] | string[];
|
|
71
73
|
placeholder?: string;
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -86,12 +88,19 @@ const openDatalist = () => (isDatalistOpen.value = true);
|
|
|
86
88
|
|
|
87
89
|
const searching = ref('');
|
|
88
90
|
|
|
89
|
-
const modelValue = defineModel<
|
|
90
|
-
|
|
91
|
+
const modelValue = defineModel<string[] | null>('modelValue', { default: [] });
|
|
92
|
+
|
|
93
|
+
onClickOutside(inputElement, closeDatalist, {
|
|
94
|
+
ignore: ['.datalist-option', '.icon-toggle-button'],
|
|
91
95
|
});
|
|
92
96
|
|
|
93
97
|
const onBackspace = () => {
|
|
94
|
-
|
|
98
|
+
if (
|
|
99
|
+
searching.value.length === 0 &&
|
|
100
|
+
modelValue.value &&
|
|
101
|
+
modelValue.value.length > 0
|
|
102
|
+
)
|
|
103
|
+
modelValue.value.splice(-1);
|
|
95
104
|
};
|
|
96
105
|
|
|
97
106
|
const setFocus = () => {
|
|
@@ -100,15 +109,20 @@ const setFocus = () => {
|
|
|
100
109
|
}
|
|
101
110
|
};
|
|
102
111
|
|
|
103
|
-
const onSelect = (option:
|
|
104
|
-
|
|
112
|
+
const onSelect = (option: InputOption | string) => {
|
|
113
|
+
if (typeof option === 'string') {
|
|
114
|
+
modelValue.value = (modelValue.value ?? []).concat(option);
|
|
115
|
+
} else if (option.value) {
|
|
116
|
+
modelValue.value = (modelValue.value ?? []).concat(option.value);
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
searching.value = '';
|
|
106
120
|
setFocus();
|
|
107
121
|
closeDatalist();
|
|
108
122
|
};
|
|
109
123
|
|
|
110
124
|
const removeOption = (value: string) => {
|
|
111
|
-
modelValue.value = modelValue.value.filter((o) => o
|
|
125
|
+
modelValue.value = (modelValue.value ?? []).filter((o) => o !== value);
|
|
112
126
|
};
|
|
113
127
|
|
|
114
128
|
const clearInput = () => {
|
|
@@ -116,18 +130,29 @@ const clearInput = () => {
|
|
|
116
130
|
searching.value = '';
|
|
117
131
|
};
|
|
118
132
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
const selectedItems = computed<InputOption[]>(() => {
|
|
134
|
+
if (!modelValue.value) return [];
|
|
135
|
+
|
|
136
|
+
const items: InputOption[] = [];
|
|
137
|
+
modelValue.value.forEach((selectedValue) => {
|
|
138
|
+
const item = optionsLabelValue.value.find(
|
|
139
|
+
(option) => option.value === selectedValue,
|
|
140
|
+
);
|
|
141
|
+
if (item) items.push(item);
|
|
142
|
+
});
|
|
143
|
+
return items;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const optionsLabelValue = computed(() =>
|
|
147
|
+
Array.isArray(props.options) &&
|
|
148
|
+
!!props.options.length &&
|
|
149
|
+
typeof props.options[0] === 'string'
|
|
150
|
+
? props.options.map((o) => ({ label: o, value: o }) as InputOption)
|
|
151
|
+
: (props.options as InputOption[]),
|
|
125
152
|
);
|
|
126
153
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
props.options.find((option) => option.value === o.value),
|
|
130
|
-
),
|
|
154
|
+
const filteredOptions = computed(() =>
|
|
155
|
+
optionsLabelValue.value.filter((o) => searchString(o.label, searching.value)),
|
|
131
156
|
);
|
|
132
157
|
</script>
|
|
133
158
|
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
v-model="inputText"
|
|
27
27
|
/>
|
|
28
28
|
|
|
29
|
+
Valeur: {{ select }}
|
|
29
30
|
<BmsSelect
|
|
30
31
|
label="Select"
|
|
31
32
|
@blur="console.log('blur')"
|
|
@@ -33,12 +34,20 @@
|
|
|
33
34
|
:options="optionsLabelValue"
|
|
34
35
|
/>
|
|
35
36
|
|
|
37
|
+
Valeur: {{ multiSelect }}
|
|
36
38
|
<BmsMultiSelect
|
|
37
39
|
label="Multi-select"
|
|
38
40
|
v-model="multiSelect"
|
|
39
41
|
:options="optionsLabelValue"
|
|
40
42
|
/>
|
|
41
43
|
<br />
|
|
44
|
+
Valeur: {{ multiSelectText }}
|
|
45
|
+
<BmsMultiSelect
|
|
46
|
+
label="Multi-select text"
|
|
47
|
+
v-model="multiSelectText"
|
|
48
|
+
:options="optionsText"
|
|
49
|
+
/>
|
|
50
|
+
<br />
|
|
42
51
|
Valeur: {{ autocompleteText }}
|
|
43
52
|
<BmsServerAutocomplete
|
|
44
53
|
label="Autocomplete avec un appel API"
|
|
@@ -55,10 +64,11 @@ import { ref } from 'vue';
|
|
|
55
64
|
import BmsButton from '@/components/button/BmsButton.vue';
|
|
56
65
|
import BmsSelect from '@/components/form/BmsSelect.vue';
|
|
57
66
|
import BmsMultiSelect from '@/components/form/BmsMultiSelect.vue';
|
|
67
|
+
import BmsServerAutocomplete from '@/components/form/BmsServerAutocomplete.vue';
|
|
58
68
|
|
|
59
69
|
const select = ref('');
|
|
60
|
-
const multiSelect = ref(
|
|
61
|
-
|
|
70
|
+
const multiSelect = ref(null);
|
|
71
|
+
const multiSelectText = ref(null);
|
|
62
72
|
|
|
63
73
|
const optionsLabelValue = ref(
|
|
64
74
|
range(0, 30).map((i) =>
|