@ouestfrance/sipa-bms-ui 8.3.0 → 8.5.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/BmsAutocomplete.vue.d.ts +3 -9
- package/dist/components/form/BmsInputBooleanCheckbox.vue.d.ts +3 -9
- package/dist/components/form/BmsInputCheckboxCaption.vue.d.ts +1 -1
- package/dist/components/form/BmsInputCheckboxGroup.vue.d.ts +4 -11
- package/dist/components/form/BmsInputCode.vue.d.ts +4 -11
- package/dist/components/form/BmsInputFile.vue.d.ts +2 -9
- package/dist/components/form/BmsInputRadioCaptionGroup.vue.d.ts +2 -9
- package/dist/components/form/BmsInputRadioGroup.vue.d.ts +2 -9
- package/dist/components/form/BmsInputText.vue.d.ts +10 -12
- package/dist/components/form/BmsInputToggle.vue.d.ts +5 -6
- package/dist/components/form/BmsMultiSelect.vue.d.ts +3 -9
- package/dist/components/form/BmsSearch.vue.d.ts +11 -5
- package/dist/components/form/BmsSelect.vue.d.ts +3 -8
- package/dist/components/form/BmsTag.vue.d.ts +1 -0
- package/dist/components/form/BmsTextArea.vue.d.ts +2 -9
- package/dist/components/form/RawAutocomplete.vue.d.ts +10 -11
- package/dist/components/form/RawInputText.vue.d.ts +3 -5
- package/dist/components/layout/BmsCard.vue.d.ts +3 -0
- package/dist/components/navigation/BmsFixedMenu.vue.d.ts +17 -0
- package/dist/components/navigation/UiTenantSwitcher.vue.d.ts +11 -5
- package/dist/components/table/BmsTableFilters.vue.d.ts +11 -5
- package/dist/index.d.ts +2 -1
- package/dist/mockServiceWorker.js +1 -1
- package/dist/plugins/field/FieldComponent.vue.d.ts +3 -11
- package/dist/plugins/field/FieldDatalist.vue.d.ts +2 -0
- package/dist/plugins/field/field-component.model.d.ts +11 -0
- package/dist/sipa-bms-ui.css +201 -147
- package/dist/sipa-bms-ui.es.js +4855 -3921
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +4861 -3926
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +20 -24
- package/src/components/form/BmsAutocomplete.stories.js +10 -0
- package/src/components/form/BmsAutocomplete.vue +4 -9
- package/src/components/form/BmsBetweenInput.vue +1 -10
- package/src/components/form/BmsFilePicker.stories.js +0 -7
- package/src/components/form/BmsInputBooleanCheckbox.stories.js +6 -0
- package/src/components/form/BmsInputBooleanCheckbox.vue +3 -16
- package/src/components/form/BmsInputCheckboxCaptionGroup.vue +1 -9
- package/src/components/form/BmsInputCheckboxGroup.vue +3 -18
- package/src/components/form/BmsInputCode.stories.js +2 -0
- package/src/components/form/BmsInputCode.vue +3 -18
- package/src/components/form/BmsInputDateTime.stories.js +2 -0
- package/src/components/form/BmsInputFile.stories.js +4 -1
- package/src/components/form/BmsInputFile.vue +5 -20
- package/src/components/form/BmsInputNumber.stories.js +5 -0
- package/src/components/form/BmsInputRadioCaptionGroup.vue +3 -18
- package/src/components/form/BmsInputRadioGroup.stories.js +12 -0
- package/src/components/form/BmsInputRadioGroup.vue +4 -19
- package/src/components/form/BmsInputText.spec.ts +1 -1
- package/src/components/form/BmsInputText.stories.js +5 -0
- package/src/components/form/BmsInputText.vue +5 -19
- package/src/components/form/BmsInputToggle.stories.js +3 -0
- package/src/components/form/BmsInputToggle.vue +13 -15
- package/src/components/form/BmsMultiSelect.stories.js +10 -1
- package/src/components/form/BmsMultiSelect.vue +5 -17
- package/src/components/form/BmsSearch.stories.js +2 -0
- package/src/components/form/BmsSelect.stories.js +4 -1
- package/src/components/form/BmsSelect.vue +7 -20
- package/src/components/form/BmsTag.stories.js +9 -0
- package/src/components/form/BmsTag.vue +9 -6
- package/src/components/form/BmsTextArea.stories.js +3 -2
- package/src/components/form/BmsTextArea.vue +12 -21
- package/src/components/form/RawAutocomplete.spec.ts +30 -10
- package/src/components/form/RawAutocomplete.vue +8 -18
- package/src/components/form/RawInputText.vue +11 -9
- package/src/components/form/UiBmsInputCheckbox.stories.js +10 -0
- package/src/components/layout/BmsCard.stories.js +14 -0
- package/src/components/layout/BmsCard.vue +14 -2
- package/src/components/navigation/BmsFixedMenu.stories.js +113 -0
- package/src/components/navigation/BmsFixedMenu.vue +70 -0
- package/src/components/navigation/BmsMenuNav.vue +5 -1
- package/src/components/table/UiBmsTableRow.vue +4 -4
- package/src/index.ts +3 -0
- package/src/plugins/field/FieldComponent.stories.js +8 -1
- package/src/plugins/field/FieldComponent.vue +29 -15
- package/src/plugins/field/FieldDatalist.stories.js +2 -0
- package/src/plugins/field/FieldDatalist.vue +12 -2
- package/src/plugins/field/field-component.model.ts +12 -0
- package/src/showroom/pages/autocomplete.vue +7 -4
- package/src/showroom/pages/forms.vue +28 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<field :disabled="disabled">
|
|
2
|
+
<field :disabled="disabled" :small="small">
|
|
3
3
|
<label class="input-toggle" :class="{ isOn: modelValue, disabled }">
|
|
4
4
|
<span class="input-switch-info">{{ label }}</span>
|
|
5
5
|
<UiBmsSwitch
|
|
@@ -16,21 +16,19 @@
|
|
|
16
16
|
|
|
17
17
|
<script lang="ts" setup>
|
|
18
18
|
import UiBmsSwitch from '@/components/form/UiBmsSwitch.vue';
|
|
19
|
+
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
modelValue: false,
|
|
30
|
-
},
|
|
31
|
-
);
|
|
21
|
+
interface Props extends FieldComponentProps {
|
|
22
|
+
name: string;
|
|
23
|
+
modelValue: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
withDefaults(defineProps<Props>(), {
|
|
27
|
+
disabled: false,
|
|
28
|
+
modelValue: false,
|
|
29
|
+
});
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
defineEmits<{
|
|
34
32
|
(e: 'update:modelValue', value: any): void;
|
|
35
33
|
}>();
|
|
36
34
|
</script>
|
|
@@ -40,7 +38,7 @@ const $emits = defineEmits<{
|
|
|
40
38
|
--label-color: var(--bms-grey-100);
|
|
41
39
|
--cursor: pointer;
|
|
42
40
|
|
|
43
|
-
font-weight:
|
|
41
|
+
font-weight: var(--field-label-font-weight);
|
|
44
42
|
display: flex;
|
|
45
43
|
align-items: center;
|
|
46
44
|
gap: 0.5em;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import BmsMultiSelect from '@/components/form/BmsMultiSelect.vue';
|
|
2
|
+
import template from '@/documentation/template_field_dependency.mdx';
|
|
2
3
|
|
|
3
4
|
export default {
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {
|
|
7
|
+
page: template,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
4
10
|
title: 'Composants/form/MultiSelect',
|
|
5
11
|
component: BmsMultiSelect,
|
|
6
12
|
};
|
|
@@ -13,7 +19,10 @@ const Template = (args) => ({
|
|
|
13
19
|
BmsMultiSelect,
|
|
14
20
|
},
|
|
15
21
|
template: `
|
|
16
|
-
<
|
|
22
|
+
<div style="display:flex;gap:1em;">
|
|
23
|
+
<BmsMultiSelect v-bind="args"/>
|
|
24
|
+
<BmsMultiSelect v-bind="{...args, small:true}"/>
|
|
25
|
+
</div>
|
|
17
26
|
`,
|
|
18
27
|
});
|
|
19
28
|
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<BmsSelect
|
|
3
3
|
v-model:open="open"
|
|
4
|
+
v-bind="$props"
|
|
4
5
|
:model-value="modelValue"
|
|
5
6
|
@update:model-value="onSelect"
|
|
6
|
-
:label="label"
|
|
7
|
-
:errors="errors"
|
|
8
|
-
:captions="captions"
|
|
9
|
-
:required="required"
|
|
10
|
-
:optional="optional"
|
|
11
|
-
:helperText="helperText"
|
|
12
|
-
:disabled="disabled"
|
|
13
|
-
:options="displayedOptions"
|
|
14
7
|
>
|
|
15
8
|
<template #input>
|
|
16
9
|
<div class="tags">
|
|
17
10
|
<BmsTag
|
|
18
11
|
v-for="tag in displayValues"
|
|
12
|
+
:small="small"
|
|
19
13
|
active
|
|
20
14
|
@dismiss="removeOption(tag.value)"
|
|
21
15
|
>
|
|
@@ -47,16 +41,10 @@ import BmsTag from './BmsTag.vue';
|
|
|
47
41
|
import { Caption, InputOption } from '@/models';
|
|
48
42
|
import _ from 'lodash';
|
|
49
43
|
import { searchString } from '@/helpers';
|
|
44
|
+
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
50
45
|
|
|
51
|
-
export interface Props {
|
|
46
|
+
export interface Props extends FieldComponentProps {
|
|
52
47
|
options: InputOption[];
|
|
53
|
-
label?: string;
|
|
54
|
-
errors?: string[] | Caption[];
|
|
55
|
-
captions?: string[] | Caption[];
|
|
56
|
-
required?: boolean;
|
|
57
|
-
optional?: boolean;
|
|
58
|
-
disabled?: boolean;
|
|
59
|
-
helperText?: string;
|
|
60
48
|
placeholder?: string;
|
|
61
49
|
}
|
|
62
50
|
|
|
@@ -110,7 +98,7 @@ const displayValues = computed<InputOption[]>(() =>
|
|
|
110
98
|
.tags {
|
|
111
99
|
display: flex;
|
|
112
100
|
gap: 0.5em;
|
|
113
|
-
padding:
|
|
101
|
+
padding: var(--field-margin);
|
|
114
102
|
flex-wrap: wrap;
|
|
115
103
|
width: 100%;
|
|
116
104
|
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<field
|
|
3
|
-
:label="label"
|
|
4
|
-
:errors="errors"
|
|
5
|
-
:captions="captions"
|
|
6
|
-
:required="required"
|
|
7
|
-
:optional="optional"
|
|
8
|
-
:helperText="helperText"
|
|
9
|
-
:disabled="disabled"
|
|
10
|
-
>
|
|
2
|
+
<field v-bind="$props">
|
|
11
3
|
<span class="select-wrapper" ref="selectWrapper" :class="classes">
|
|
12
4
|
<slot name="input">
|
|
13
5
|
<input
|
|
@@ -29,6 +21,7 @@
|
|
|
29
21
|
v-show="open"
|
|
30
22
|
:options="options"
|
|
31
23
|
:is-input-focused="open"
|
|
24
|
+
:small="small"
|
|
32
25
|
@select="(option: any) => selectItem(option)"
|
|
33
26
|
>
|
|
34
27
|
<template #option="{ option }: { option: any }">
|
|
@@ -44,18 +37,12 @@ import { ChevronDown } from 'lucide-vue-next';
|
|
|
44
37
|
import { Ref, computed, onMounted, ref, watch } from 'vue';
|
|
45
38
|
import _ from 'lodash';
|
|
46
39
|
import FieldDatalist from '@/plugins/field/FieldDatalist.vue';
|
|
47
|
-
import { Caption } from '@/models/caption.model';
|
|
48
40
|
import { InputOption } from '@/models';
|
|
41
|
+
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
49
42
|
|
|
50
|
-
export interface Props {
|
|
43
|
+
export interface Props extends FieldComponentProps {
|
|
51
44
|
options: InputOption[];
|
|
52
|
-
label?: string;
|
|
53
|
-
errors?: string[] | Caption[];
|
|
54
|
-
captions?: string[] | Caption[];
|
|
55
|
-
required?: boolean;
|
|
56
45
|
optional?: boolean;
|
|
57
|
-
disabled?: boolean;
|
|
58
|
-
helperText?: string;
|
|
59
46
|
placeholder?: string;
|
|
60
47
|
}
|
|
61
48
|
|
|
@@ -63,6 +50,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
63
50
|
label: '',
|
|
64
51
|
disabled: false,
|
|
65
52
|
required: false,
|
|
53
|
+
small: false,
|
|
66
54
|
});
|
|
67
55
|
const modelValue = defineModel<any>('modelValue', { required: true });
|
|
68
56
|
const open = defineModel<boolean>('open', { default: false });
|
|
@@ -119,11 +107,10 @@ defineExpose({
|
|
|
119
107
|
.select-wrapper {
|
|
120
108
|
width: 100%;
|
|
121
109
|
padding: 0 0 0 1em;
|
|
122
|
-
margin: 0.5em 0;
|
|
123
110
|
border-radius: var(--bms-border-radius);
|
|
124
111
|
border: 1px solid var(--field-border-color);
|
|
125
112
|
background-color: var(--input-background-color);
|
|
126
|
-
min-height:
|
|
113
|
+
min-height: var(--field-height);
|
|
127
114
|
|
|
128
115
|
display: flex;
|
|
129
116
|
align-items: center;
|
|
@@ -141,7 +128,7 @@ defineExpose({
|
|
|
141
128
|
}
|
|
142
129
|
&-button {
|
|
143
130
|
width: 1em;
|
|
144
|
-
margin: 0
|
|
131
|
+
margin: 0 var(--field-padding);
|
|
145
132
|
display: block;
|
|
146
133
|
}
|
|
147
134
|
}
|
|
@@ -31,6 +31,15 @@ const Template = (args) => ({
|
|
|
31
31
|
<Trash/>
|
|
32
32
|
</template>
|
|
33
33
|
</BmsTag>
|
|
34
|
+
<br/>
|
|
35
|
+
<BmsTag v-bind="{...args, small:true}">
|
|
36
|
+
<template #default>
|
|
37
|
+
<Activity/> message
|
|
38
|
+
</template>
|
|
39
|
+
<template v-if="args.templateIcon" #closeIcon>
|
|
40
|
+
<Trash/>
|
|
41
|
+
</template>
|
|
42
|
+
</BmsTag>
|
|
34
43
|
`,
|
|
35
44
|
});
|
|
36
45
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="tag"
|
|
4
|
-
:class="{ active: active, disabled: disabled }"
|
|
5
|
-
@click="emits('click')"
|
|
6
|
-
>
|
|
2
|
+
<div class="tag" :class="{ active, disabled, small }" @click="emits('click')">
|
|
7
3
|
<slot></slot>
|
|
8
4
|
<span class="dismiss-button">
|
|
9
5
|
<BmsIconButton @click.stop="emits('dismiss')" v-if="canBeDismissed">
|
|
@@ -21,8 +17,10 @@ interface Props {
|
|
|
21
17
|
active?: boolean;
|
|
22
18
|
disabled?: boolean;
|
|
23
19
|
canBeDismissed?: boolean;
|
|
20
|
+
small?: boolean;
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
|
|
23
|
+
withDefaults(defineProps<Props>(), {
|
|
26
24
|
active: false,
|
|
27
25
|
disabled: false,
|
|
28
26
|
canBeDismissed: true,
|
|
@@ -63,6 +61,11 @@ const emits = defineEmits(['dismiss', 'click']);
|
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
|
|
64
|
+
&.small {
|
|
65
|
+
padding: 2px 4px;
|
|
66
|
+
gap: 4px;
|
|
67
|
+
}
|
|
68
|
+
|
|
66
69
|
&:focus,
|
|
67
70
|
&:hover {
|
|
68
71
|
--tag-color: var(--bms-main-140);
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<field
|
|
3
|
-
:label="label"
|
|
4
|
-
:errors="errors"
|
|
5
|
-
:captions="captions"
|
|
6
|
-
:required="required"
|
|
7
|
-
:optional="optional"
|
|
8
|
-
:helperText="helperText"
|
|
9
|
-
:disabled="disabled"
|
|
10
|
-
>
|
|
2
|
+
<field v-bind="$props">
|
|
11
3
|
<textarea
|
|
12
4
|
ref="textArea"
|
|
13
5
|
:value="modelValue"
|
|
@@ -26,18 +18,11 @@
|
|
|
26
18
|
|
|
27
19
|
<script lang="ts" setup>
|
|
28
20
|
import { Ref, computed, ref } from 'vue';
|
|
29
|
-
import {
|
|
21
|
+
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
30
22
|
|
|
31
|
-
export interface Props {
|
|
23
|
+
export interface Props extends FieldComponentProps {
|
|
32
24
|
modelValue: string;
|
|
33
|
-
label?: string;
|
|
34
|
-
required?: boolean;
|
|
35
|
-
optional?: boolean;
|
|
36
|
-
disabled?: boolean;
|
|
37
|
-
helperText?: string;
|
|
38
25
|
placeholder?: string;
|
|
39
|
-
captions?: string[];
|
|
40
|
-
errors?: string[] | Caption[];
|
|
41
26
|
}
|
|
42
27
|
|
|
43
28
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -58,7 +43,11 @@ const onInput = (e: Event) => {
|
|
|
58
43
|
};
|
|
59
44
|
|
|
60
45
|
const classes = computed(() => {
|
|
61
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
'is-error': props.errors?.length,
|
|
48
|
+
'is-disabled': props.disabled,
|
|
49
|
+
'is-small': props.small,
|
|
50
|
+
};
|
|
62
51
|
});
|
|
63
52
|
|
|
64
53
|
const setFocus = () => {
|
|
@@ -79,8 +68,7 @@ defineExpose({
|
|
|
79
68
|
align-items: center;
|
|
80
69
|
|
|
81
70
|
width: 100%;
|
|
82
|
-
padding:
|
|
83
|
-
margin: 0.5em 0;
|
|
71
|
+
padding: var(--field-padding);
|
|
84
72
|
border-radius: var(--bms-border-radius);
|
|
85
73
|
border: 1px solid var(--field-border-color);
|
|
86
74
|
background-color: var(--textarea-background-color);
|
|
@@ -107,6 +95,9 @@ defineExpose({
|
|
|
107
95
|
--textarea-background-color: var(--bms-grey-25);
|
|
108
96
|
pointer-events: none;
|
|
109
97
|
}
|
|
98
|
+
&.is-small {
|
|
99
|
+
min-height: 56px;
|
|
100
|
+
}
|
|
110
101
|
}
|
|
111
102
|
}
|
|
112
103
|
</style>
|
|
@@ -27,10 +27,11 @@ const factory = (props?: PropsAndModel) => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const inputElement = wrapper.get('input');
|
|
30
|
-
|
|
30
|
+
const menu = wrapper.get('[data-testid="autocomplete-menu"]');
|
|
31
|
+
return { wrapper, inputElement, menu };
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
describe('
|
|
34
|
+
describe('RawAutocomplete', () => {
|
|
34
35
|
it('should mount component correctly', async () => {
|
|
35
36
|
const { wrapper } = factory();
|
|
36
37
|
|
|
@@ -40,8 +41,7 @@ describe('BmsAutocomplete', () => {
|
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
it('should show options on click', async () => {
|
|
43
|
-
const { wrapper, inputElement } = factory();
|
|
44
|
-
const menu = wrapper.get('[data-testid="autocomplete-menu"]');
|
|
44
|
+
const { wrapper, inputElement, menu } = factory();
|
|
45
45
|
|
|
46
46
|
expect(menu.isVisible()).toBeFalsy();
|
|
47
47
|
await inputElement.trigger('input');
|
|
@@ -58,8 +58,7 @@ describe('BmsAutocomplete', () => {
|
|
|
58
58
|
modelValue: 'i',
|
|
59
59
|
} as PropsAndModel);
|
|
60
60
|
expect(inputElement.element.value).toStrictEqual('titi');
|
|
61
|
-
wrapper.setProps({ modelValue: 'u' });
|
|
62
|
-
await nextTick();
|
|
61
|
+
await wrapper.setProps({ modelValue: 'u' });
|
|
63
62
|
expect(inputElement.element.value).toStrictEqual('tutu');
|
|
64
63
|
});
|
|
65
64
|
|
|
@@ -68,8 +67,7 @@ describe('BmsAutocomplete', () => {
|
|
|
68
67
|
modelValue: 'i',
|
|
69
68
|
} as PropsAndModel);
|
|
70
69
|
expect(inputElement.element.value).toStrictEqual('titi');
|
|
71
|
-
wrapper.setProps({ modelValue: 'not_found' });
|
|
72
|
-
await nextTick();
|
|
70
|
+
await wrapper.setProps({ modelValue: 'not_found' });
|
|
73
71
|
expect(inputElement.element.value).toStrictEqual('');
|
|
74
72
|
});
|
|
75
73
|
|
|
@@ -78,11 +76,33 @@ describe('BmsAutocomplete', () => {
|
|
|
78
76
|
modelValue: 'i',
|
|
79
77
|
} as PropsAndModel);
|
|
80
78
|
expect(inputElement.element.value).toStrictEqual('titi');
|
|
81
|
-
wrapper.setProps({ modelValue: undefined });
|
|
82
|
-
await nextTick();
|
|
79
|
+
await wrapper.setProps({ modelValue: undefined });
|
|
83
80
|
expect(inputElement.element.value).toStrictEqual('titi');
|
|
84
81
|
});
|
|
85
82
|
|
|
83
|
+
it('should emit modelValue if clicks on option', async () => {
|
|
84
|
+
const { wrapper, inputElement, menu } = factory({
|
|
85
|
+
modelValue: null,
|
|
86
|
+
} as PropsAndModel);
|
|
87
|
+
await inputElement.trigger('click');
|
|
88
|
+
await menu.find('[data-testid="i"]').trigger('click');
|
|
89
|
+
expect(wrapper.emitted()['select']).toStrictEqual([
|
|
90
|
+
[{ label: 'titi', value: 'i' }],
|
|
91
|
+
]);
|
|
92
|
+
expect(wrapper.emitted()['update:modelValue']).toStrictEqual([['i']]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should reset modelValue if user removes text input', async () => {
|
|
96
|
+
const { wrapper, inputElement } = factory({
|
|
97
|
+
modelValue: 'i',
|
|
98
|
+
} as PropsAndModel);
|
|
99
|
+
expect(inputElement.element.value).toStrictEqual('titi');
|
|
100
|
+
inputElement.element.value = '';
|
|
101
|
+
await inputElement.trigger('input');
|
|
102
|
+
expect(inputElement.element.value).toStrictEqual('');
|
|
103
|
+
expect(wrapper.emitted()['update:modelValue']).toStrictEqual([[null]]);
|
|
104
|
+
});
|
|
105
|
+
|
|
86
106
|
it('should emit event on option selection', async () => {
|
|
87
107
|
const { wrapper, inputElement } = factory();
|
|
88
108
|
const titi = wrapper.get('[data-testid="i"]');
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<field
|
|
3
|
-
:label="label"
|
|
4
|
-
:errors="errors"
|
|
5
|
-
:captions="captions"
|
|
6
|
-
:required="required"
|
|
7
|
-
:optional="optional"
|
|
8
|
-
:helperText="helperText"
|
|
9
|
-
:disabled="disabled"
|
|
10
|
-
>
|
|
2
|
+
<field v-bind="$props">
|
|
11
3
|
<RawInputText
|
|
12
4
|
ref="autocompleteInput"
|
|
13
5
|
v-model="inputText"
|
|
@@ -16,6 +8,7 @@
|
|
|
16
8
|
:class="classes"
|
|
17
9
|
:placeholder="placeholder"
|
|
18
10
|
:required="required"
|
|
11
|
+
:small="small"
|
|
19
12
|
@input="onInput"
|
|
20
13
|
v-model:focus="isInputFocused"
|
|
21
14
|
>
|
|
@@ -46,6 +39,7 @@
|
|
|
46
39
|
:can-add-new-option="canAddNewOption"
|
|
47
40
|
:new-option="inputText"
|
|
48
41
|
:options="filteredMenuItems"
|
|
42
|
+
:small="small"
|
|
49
43
|
@select="selectItem"
|
|
50
44
|
@add-new-option="(option: string) => emits('addNewOption', option)"
|
|
51
45
|
>
|
|
@@ -61,23 +55,16 @@
|
|
|
61
55
|
import { searchString } from '@/helpers/string.helper';
|
|
62
56
|
import FieldDatalist from '@/plugins/field/FieldDatalist.vue';
|
|
63
57
|
import { computed, ref, Ref, watch } from 'vue';
|
|
64
|
-
import { Caption } from '@/models/caption.model';
|
|
65
58
|
import RawInputText from '@/components/form/RawInputText.vue';
|
|
66
59
|
import { InputOption, InputType } from '@/models';
|
|
67
60
|
import { ChevronDown, ChevronUp, X } from 'lucide-vue-next';
|
|
61
|
+
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
68
62
|
|
|
69
|
-
export interface Props {
|
|
63
|
+
export interface Props extends FieldComponentProps {
|
|
70
64
|
options: InputOption[];
|
|
71
65
|
label?: string;
|
|
72
|
-
required?: boolean;
|
|
73
|
-
optional?: boolean;
|
|
74
|
-
disabled?: boolean;
|
|
75
|
-
helperText?: string;
|
|
76
66
|
placeholder?: string;
|
|
77
|
-
captions?: string[] | Caption[];
|
|
78
|
-
errors?: string[] | Caption[];
|
|
79
67
|
open?: boolean;
|
|
80
|
-
|
|
81
68
|
canAddNewOption?: boolean;
|
|
82
69
|
newOption?: string;
|
|
83
70
|
}
|
|
@@ -150,6 +137,9 @@ watch(
|
|
|
150
137
|
);
|
|
151
138
|
const onInput = () => {
|
|
152
139
|
isInputFocused.value = true;
|
|
140
|
+
if (inputText.value === '') {
|
|
141
|
+
clearInput();
|
|
142
|
+
}
|
|
153
143
|
};
|
|
154
144
|
|
|
155
145
|
const setFocus = () => {
|
|
@@ -28,20 +28,18 @@
|
|
|
28
28
|
|
|
29
29
|
<script lang="ts" setup>
|
|
30
30
|
import { computed, onMounted, Ref, ref } from 'vue';
|
|
31
|
-
import {
|
|
31
|
+
import { InputType } from '@/models';
|
|
32
|
+
import { FieldComponentProps } from '@/plugins/field/field-component.model';
|
|
32
33
|
|
|
33
|
-
export interface Props {
|
|
34
|
+
export interface Props extends FieldComponentProps {
|
|
34
35
|
modelValue: string | number;
|
|
35
|
-
required?: boolean;
|
|
36
36
|
placeholder?: string;
|
|
37
|
-
disabled?: boolean;
|
|
38
37
|
focus?: boolean;
|
|
39
38
|
type?:
|
|
40
39
|
| InputType.TEXT
|
|
41
40
|
| InputType.NUMBER
|
|
42
41
|
| InputType.DATE
|
|
43
42
|
| InputType.DATETIME;
|
|
44
|
-
errors?: string[] | Caption[];
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -88,7 +86,11 @@ const onInput = (e: Event) => {
|
|
|
88
86
|
};
|
|
89
87
|
|
|
90
88
|
const classes = computed(() => {
|
|
91
|
-
return {
|
|
89
|
+
return {
|
|
90
|
+
'is-error': props.errors?.length,
|
|
91
|
+
'is-disabled': props.disabled,
|
|
92
|
+
'is-small': props.small,
|
|
93
|
+
};
|
|
92
94
|
});
|
|
93
95
|
</script>
|
|
94
96
|
|
|
@@ -98,12 +100,12 @@ const classes = computed(() => {
|
|
|
98
100
|
align-items: center;
|
|
99
101
|
|
|
100
102
|
width: 100%;
|
|
101
|
-
padding: 1em;
|
|
102
|
-
margin: 0.5em 0;
|
|
103
103
|
border-radius: var(--bms-border-radius);
|
|
104
104
|
border: 1px solid var(--field-border-color);
|
|
105
105
|
background-color: var(--input-background-color);
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
padding: var(--field-padding);
|
|
108
|
+
height: var(--field-height);
|
|
107
109
|
|
|
108
110
|
&:hover {
|
|
109
111
|
--field-border-color: var(--bms-grey-100);
|
|
@@ -30,6 +30,16 @@ const Template = (args) => ({
|
|
|
30
30
|
</UiBmsInputCheckbox>
|
|
31
31
|
Valeur de mon champ : {{ curentValue }}
|
|
32
32
|
</div>
|
|
33
|
+
|
|
34
|
+
<br/>
|
|
35
|
+
<div>
|
|
36
|
+
<UiBmsInputCheckbox v-bind="{...args, small:true}" v-model="curentValue">
|
|
37
|
+
<template v-if="args.labelSlot" #label>
|
|
38
|
+
<span v-html='args.labelSlot'/>
|
|
39
|
+
</template>
|
|
40
|
+
</UiBmsInputCheckbox>
|
|
41
|
+
Valeur de mon champ : {{ curentValue }}
|
|
42
|
+
</div>
|
|
33
43
|
`,
|
|
34
44
|
});
|
|
35
45
|
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import BmsCard from '@/components/layout/BmsCard.vue';
|
|
2
|
+
import { vueRouter } from 'storybook-vue3-router';
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
title: 'Composants/layout/Card',
|
|
5
6
|
component: BmsCard,
|
|
7
|
+
decorators: [
|
|
8
|
+
vueRouter([
|
|
9
|
+
{
|
|
10
|
+
name: 'firstRoute',
|
|
11
|
+
path: '/toto',
|
|
12
|
+
},
|
|
13
|
+
]),
|
|
14
|
+
],
|
|
6
15
|
};
|
|
7
16
|
|
|
8
17
|
const Template = (args) => ({
|
|
@@ -21,6 +30,11 @@ const Template = (args) => ({
|
|
|
21
30
|
`,
|
|
22
31
|
});
|
|
23
32
|
|
|
33
|
+
export const WithLink = Template.bind({});
|
|
34
|
+
WithLink.args = {
|
|
35
|
+
to: '/toto',
|
|
36
|
+
};
|
|
37
|
+
|
|
24
38
|
export const Default = Template.bind({});
|
|
25
39
|
Default.args = {};
|
|
26
40
|
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
:class="{ animated, hasAction: !!$slots.action }"
|
|
8
8
|
>
|
|
9
9
|
<div class="card__body__content">
|
|
10
|
-
<
|
|
10
|
+
<BmsLink class="card__body__content__link" v-if="to" :to="to">
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</BmsLink>
|
|
13
|
+
<template v-else>
|
|
14
|
+
<slot></slot>
|
|
15
|
+
</template>
|
|
11
16
|
</div>
|
|
12
17
|
<div class="card__body__action" v-if="!!$slots.action">
|
|
13
18
|
<slot name="action"></slot>
|
|
@@ -19,11 +24,13 @@
|
|
|
19
24
|
<script lang="ts" setup>
|
|
20
25
|
import { StatusType } from '@/models';
|
|
21
26
|
import { ref } from 'vue';
|
|
27
|
+
import { RouteLocationRaw } from 'vue-router';
|
|
28
|
+
import BmsLink from '../navigation/BmsLink.vue';
|
|
22
29
|
|
|
23
30
|
const props = withDefaults(
|
|
24
31
|
defineProps<{
|
|
25
32
|
animated?: boolean;
|
|
26
|
-
|
|
33
|
+
to?: RouteLocationRaw;
|
|
27
34
|
type?: StatusType;
|
|
28
35
|
}>(),
|
|
29
36
|
{
|
|
@@ -105,6 +112,11 @@ window.addEventListener('mousemove', onMouseMove);
|
|
|
105
112
|
background-color: var(--summary-card-background-color);
|
|
106
113
|
backdrop-filter: blur(40px);
|
|
107
114
|
color: var(--summary-card-color);
|
|
115
|
+
|
|
116
|
+
&__link {
|
|
117
|
+
color: var(--summary-card-color);
|
|
118
|
+
text-decoration: none;
|
|
119
|
+
}
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
&__action {
|