@weni/unnnic-system 3.2.9-alpha.1 → 3.2.9-alpha.3
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/DateFilter/DateFilter.vue.d.ts +60 -93
- package/dist/components/Input/BaseInput.vue.d.ts +18 -0
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +60 -93
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +36 -0
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +60 -93
- package/dist/components/InputNext/InputNext.vue.d.ts +1 -1
- package/dist/components/Label/Label.vue.d.ts +2 -2
- package/dist/components/Label/Label.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +60 -93
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +36 -0
- package/dist/components/SelectTime/index.vue.d.ts +36 -0
- package/dist/components/index.d.ts +486 -750
- package/dist/components/index.d.ts.map +1 -1
- package/dist/{es-2735a8fb.js → es-6e7b12d4.js} +1 -1
- package/dist/{index-e012fa52.js → index-531ad3f6.js} +2715 -2696
- package/dist/locales/en.json.d.ts +2 -1
- package/dist/locales/es.json.d.ts +2 -1
- package/dist/locales/pt_br.json.d.ts +2 -1
- package/dist/{pt-br-f38a8b9c.js → pt-br-9c8a0c50.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.js +1 -1
- package/dist/unnnic.umd.cjs +32 -32
- package/package.json +1 -1
- package/src/components/Input/BaseInput.vue +12 -2
- package/src/components/Input/Input.scss +2 -1
- package/src/components/Input/Input.vue +17 -29
- package/src/components/Input/TextInput.vue +11 -1
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +2 -2
- package/src/components/Label/Label.vue +2 -2
- package/src/components/Popover/__tests__/Popover.spec.js +147 -0
- package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
- package/src/components/Popover/index.vue +146 -0
- package/src/components/Select/SelectOption.vue +57 -0
- package/src/components/Select/__tests__/Select.spec.js +412 -0
- package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
- package/src/components/Select/__tests__/SelectOption.spec.js +174 -0
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +93 -0
- package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
- package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
- package/src/components/Select/index.vue +187 -0
- package/src/locales/en.json +2 -1
- package/src/locales/es.json +2 -1
- package/src/locales/pt_br.json +2 -1
- package/src/stories/Popover.stories.js +39 -0
- package/src/stories/Select.stories.js +91 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="unnnic-select">
|
|
3
|
+
<UnnnicPopover
|
|
4
|
+
v-model="openPopover"
|
|
5
|
+
:popoverBalloonProps="{ maxHeight: calculatedMaxHeight }"
|
|
6
|
+
>
|
|
7
|
+
<template #trigger>
|
|
8
|
+
<UnnnicInput
|
|
9
|
+
:modelValue="inputValue"
|
|
10
|
+
class="unnnic-select__input"
|
|
11
|
+
readonly
|
|
12
|
+
:forceActiveStatus="openPopover"
|
|
13
|
+
:size="props.size"
|
|
14
|
+
:placeholder="props.placeholder"
|
|
15
|
+
:label="props.label"
|
|
16
|
+
:errors="props.errors"
|
|
17
|
+
:message="props.message"
|
|
18
|
+
:iconRight="openPopover ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"
|
|
19
|
+
:disabled="props.disabled"
|
|
20
|
+
/>
|
|
21
|
+
</template>
|
|
22
|
+
<template #content>
|
|
23
|
+
<div class="unnnic-select__content">
|
|
24
|
+
<UnnnicInput
|
|
25
|
+
v-if="props.enableSearch"
|
|
26
|
+
class="unnnic-select__input-search"
|
|
27
|
+
:modelValue="props.search"
|
|
28
|
+
:placeholder="$t('search')"
|
|
29
|
+
iconLeft="search"
|
|
30
|
+
@update:modelValue="handleSearch"
|
|
31
|
+
/>
|
|
32
|
+
<UnnnicSelectOption
|
|
33
|
+
v-for="option in filteredOptions"
|
|
34
|
+
:key="option[props.itemValue]"
|
|
35
|
+
:label="option[props.itemLabel]"
|
|
36
|
+
:active="
|
|
37
|
+
option[props.itemValue] === selectedItem?.[props.itemValue]
|
|
38
|
+
"
|
|
39
|
+
:disabled="option.disabled"
|
|
40
|
+
@click="handleSelectOption(option)"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
</UnnnicPopover>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script setup lang="ts">
|
|
49
|
+
import { computed, ref, watch } from 'vue';
|
|
50
|
+
import UnnnicInput from '../Input/Input.vue';
|
|
51
|
+
import UnnnicPopover from '../Popover/index.vue';
|
|
52
|
+
import UnnnicSelectOption from './SelectOption.vue';
|
|
53
|
+
import UnnnicI18n from '../../mixins/i18n';
|
|
54
|
+
|
|
55
|
+
defineOptions({
|
|
56
|
+
name: 'UnnnicSelect',
|
|
57
|
+
mixins: [UnnnicI18n],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
interface SelectProps {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
options: Array<{ [key: string]: any }>;
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
modelValue: any;
|
|
65
|
+
returnObject?: boolean;
|
|
66
|
+
itemLabel?: string;
|
|
67
|
+
itemValue?: string;
|
|
68
|
+
placeholder?: string;
|
|
69
|
+
label?: string;
|
|
70
|
+
type?: 'normal' | 'error';
|
|
71
|
+
errors?: string | Array<string>;
|
|
72
|
+
message?: string;
|
|
73
|
+
size?: 'sm' | 'md';
|
|
74
|
+
optionsLines?: number;
|
|
75
|
+
enableSearch?: boolean;
|
|
76
|
+
search?: string;
|
|
77
|
+
locale?: string;
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const props = withDefaults(defineProps<SelectProps>(), {
|
|
82
|
+
size: 'md',
|
|
83
|
+
type: 'normal',
|
|
84
|
+
placeholder: '',
|
|
85
|
+
optionsLines: 5,
|
|
86
|
+
returnObject: false,
|
|
87
|
+
itemLabel: 'label',
|
|
88
|
+
itemValue: 'value',
|
|
89
|
+
locale: 'en',
|
|
90
|
+
enableSearch: false,
|
|
91
|
+
disabled: false,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const emit = defineEmits<{
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
'update:modelValue': [value: any];
|
|
97
|
+
'update:search': [value: string];
|
|
98
|
+
}>();
|
|
99
|
+
|
|
100
|
+
const openPopover = ref(false);
|
|
101
|
+
|
|
102
|
+
watch(openPopover, () => {
|
|
103
|
+
if (!openPopover.value) {
|
|
104
|
+
handleSearch('');
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const calculatedMaxHeight = computed(() => {
|
|
109
|
+
if (!props.options || props.options.length === 0) return 'unset';
|
|
110
|
+
const fieldsHeight = 37 * props.optionsLines + 40;
|
|
111
|
+
return `${props.enableSearch ? fieldsHeight + 50 : fieldsHeight}px`;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const selectedItem = computed(() => {
|
|
115
|
+
if (props.returnObject) return props.modelValue;
|
|
116
|
+
|
|
117
|
+
return props.options.find(
|
|
118
|
+
(option) => option[props.itemValue] === props.modelValue,
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const inputValue = computed(() => {
|
|
123
|
+
return selectedItem.value?.[props.itemLabel];
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const handleSelectOption = (option) => {
|
|
127
|
+
if (
|
|
128
|
+
option[props.itemValue] === selectedItem.value?.[props.itemValue] ||
|
|
129
|
+
option.disabled
|
|
130
|
+
)
|
|
131
|
+
return;
|
|
132
|
+
|
|
133
|
+
emit(
|
|
134
|
+
'update:modelValue',
|
|
135
|
+
props.returnObject ? option : option[props.itemValue],
|
|
136
|
+
);
|
|
137
|
+
openPopover.value = false;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleSearch = (value: string) => {
|
|
141
|
+
emit('update:search', value);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const filteredOptions = computed(() => {
|
|
145
|
+
if (!props.enableSearch || !props.search) return props.options;
|
|
146
|
+
|
|
147
|
+
return props.options.filter(
|
|
148
|
+
(option) =>
|
|
149
|
+
option[props.itemLabel]
|
|
150
|
+
.toLowerCase()
|
|
151
|
+
.includes(props.search?.toLowerCase()) ||
|
|
152
|
+
option[props.itemValue]
|
|
153
|
+
.toLowerCase()
|
|
154
|
+
.includes(props.search?.toLowerCase()),
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
<style lang="scss" scoped>
|
|
160
|
+
@use '@/assets/scss/unnnic' as *;
|
|
161
|
+
|
|
162
|
+
:deep(.unnnic-select__input) {
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
:deep(.unnnic-select__input-search) {
|
|
167
|
+
> .icon-left {
|
|
168
|
+
color: $unnnic-color-fg-base;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:deep(.unnnic-select__input) {
|
|
173
|
+
> .icon-right {
|
|
174
|
+
color: $unnnic-color-fg-base;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.unnnic-select {
|
|
179
|
+
&__content {
|
|
180
|
+
display: flex;
|
|
181
|
+
flex-direction: column;
|
|
182
|
+
padding: 0;
|
|
183
|
+
margin: 0;
|
|
184
|
+
gap: $unnnic-space-1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
</style>
|
package/src/locales/en.json
CHANGED
package/src/locales/es.json
CHANGED
package/src/locales/pt_br.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import UnnnicPopover from '../components/Popover/index.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'example/Popover',
|
|
5
|
+
component: UnnnicPopover,
|
|
6
|
+
render: (args) => ({
|
|
7
|
+
components: { UnnnicPopover },
|
|
8
|
+
setup() {
|
|
9
|
+
return {
|
|
10
|
+
args,
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
template: `
|
|
14
|
+
<div>
|
|
15
|
+
<unnnic-popover v-bind="args">
|
|
16
|
+
<template #trigger>
|
|
17
|
+
<button>Click me</button>
|
|
18
|
+
</template>
|
|
19
|
+
<template #content>
|
|
20
|
+
<p>Hello</p>
|
|
21
|
+
</template>
|
|
22
|
+
</unnnic-popover>
|
|
23
|
+
<p>label label</p>
|
|
24
|
+
</div>
|
|
25
|
+
`,
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Default = {
|
|
30
|
+
args: {
|
|
31
|
+
modelValue: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const WithModelValue = {
|
|
36
|
+
args: {
|
|
37
|
+
modelValue: true,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import UnnnicSelect from '../components/Select/index.vue';
|
|
2
|
+
|
|
3
|
+
const options = [
|
|
4
|
+
{ label: 'Option 1', value: 'option1', altValue: 'alt_value_option1' },
|
|
5
|
+
{ label: 'Option 2', value: 'option2', altValue: 'alt_value_option2' },
|
|
6
|
+
{ label: 'Option 3', value: 'option3', altValue: 'alt_value_option3' },
|
|
7
|
+
{ label: 'Option 4', value: 'option4', altValue: 'alt_value_option4' },
|
|
8
|
+
{ label: 'Option 5', value: 'option5', altValue: 'alt_value_option5' },
|
|
9
|
+
{ label: 'Option 6', value: 'option6', altValue: 'alt_value_option6' },
|
|
10
|
+
{ label: 'Option 7', value: 'option7', altValue: 'alt_value_option7' },
|
|
11
|
+
{ label: 'Option 8', value: 'option8', altValue: 'alt_value_option8' },
|
|
12
|
+
{ label: 'Option 9', value: 'option9', altValue: 'alt_value_option9' },
|
|
13
|
+
{ label: 'Option 10', value: 'option10', disabled: true },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'Form/Select',
|
|
18
|
+
component: UnnnicSelect,
|
|
19
|
+
render: (args) => ({
|
|
20
|
+
components: { UnnnicSelect },
|
|
21
|
+
setup() {
|
|
22
|
+
const handleSearch = (value) => {
|
|
23
|
+
args.search = value;
|
|
24
|
+
};
|
|
25
|
+
return { args, handleSearch };
|
|
26
|
+
},
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
exampleValue: null,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
template: `
|
|
33
|
+
<p>modelValue: {{ exampleValue }}</p>
|
|
34
|
+
<unnnic-select v-model="exampleValue" v-bind="args" @update:search="handleSearch" />
|
|
35
|
+
`,
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Default = {
|
|
40
|
+
args: {
|
|
41
|
+
placeholder: 'Placeholder',
|
|
42
|
+
label: 'Label',
|
|
43
|
+
options,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const ReturnObject = {
|
|
48
|
+
args: {
|
|
49
|
+
returnObject: true,
|
|
50
|
+
placeholder: 'Placeholder',
|
|
51
|
+
label: 'Label',
|
|
52
|
+
options,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const AlternativeValueKey = {
|
|
57
|
+
args: {
|
|
58
|
+
itemValue: 'altValue',
|
|
59
|
+
placeholder: 'Placeholder',
|
|
60
|
+
label: 'Label',
|
|
61
|
+
options,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const AlternativeValueLabel = {
|
|
66
|
+
args: {
|
|
67
|
+
itemLabel: 'altValue',
|
|
68
|
+
placeholder: 'Placeholder',
|
|
69
|
+
label: 'Label',
|
|
70
|
+
options,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Disabled = {
|
|
75
|
+
args: {
|
|
76
|
+
placeholder: 'Placeholder',
|
|
77
|
+
label: 'Label',
|
|
78
|
+
options,
|
|
79
|
+
disabled: true,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const WithSearch = {
|
|
84
|
+
args: {
|
|
85
|
+
placeholder: 'Placeholder',
|
|
86
|
+
label: 'Label',
|
|
87
|
+
options,
|
|
88
|
+
enableSearch: true,
|
|
89
|
+
search: '',
|
|
90
|
+
},
|
|
91
|
+
};
|