@weni/unnnic-system 3.2.9-alpha.1 → 3.2.9-alpha.10
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/CHANGELOG.md +18 -0
- package/dist/components/Chip/Chip.vue.d.ts.map +1 -1
- package/dist/components/DataTable/index.vue.d.ts +7 -0
- package/dist/components/DataTable/index.vue.d.ts.map +1 -1
- package/dist/components/DateFilter/DateFilter.vue.d.ts +87 -95
- package/dist/components/Input/BaseInput.vue.d.ts +22 -0
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +87 -95
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +52 -1
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +87 -95
- 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 +87 -95
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +52 -1
- package/dist/components/SelectTime/index.vue.d.ts +52 -1
- package/dist/components/Tab/Tab.vue.d.ts +11 -0
- package/dist/components/index.d.ts +895 -937
- package/dist/components/index.d.ts.map +1 -1
- package/dist/{es-2735a8fb.js → es-3cbe331a.js} +1 -1
- package/dist/{index-e012fa52.js → index-2241773d.js} +4242 -4189
- 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-9ddee0e9.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.js +1 -1
- package/dist/unnnic.umd.cjs +39 -39
- package/package.json +1 -1
- package/src/assets/scss/scheme-colors.scss +115 -238
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +11 -7
- package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +2 -2
- package/src/components/Chip/Chip.vue +3 -2
- package/src/components/DataTable/index.vue +25 -10
- package/src/components/Input/BaseInput.vue +21 -2
- package/src/components/Input/Input.scss +2 -1
- package/src/components/Input/Input.vue +26 -30
- package/src/components/Input/TextInput.vue +59 -22
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +7 -3
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
- 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 +65 -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 +97 -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 +245 -0
- package/src/components/Tab/Tab.vue +37 -23
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
- 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/DataTable.stories.js +60 -0
- package/src/stories/Input.stories.js +6 -0
- package/src/stories/Popover.stories.js +39 -0
- package/src/stories/Select.stories.js +91 -0
- package/src/stories/Tab.stories.js +11 -4
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="unnnic-select"
|
|
4
|
+
@keydown="handleKeyDown"
|
|
5
|
+
>
|
|
6
|
+
<UnnnicPopover
|
|
7
|
+
v-model="openPopover"
|
|
8
|
+
:popoverBalloonProps="{ maxHeight: calculatedMaxHeight }"
|
|
9
|
+
>
|
|
10
|
+
<template #trigger>
|
|
11
|
+
<UnnnicInput
|
|
12
|
+
:modelValue="inputValue"
|
|
13
|
+
class="unnnic-select__input"
|
|
14
|
+
readonly
|
|
15
|
+
:forceActiveStatus="openPopover"
|
|
16
|
+
:size="props.size"
|
|
17
|
+
:placeholder="props.placeholder"
|
|
18
|
+
:label="props.label"
|
|
19
|
+
:errors="props.errors"
|
|
20
|
+
:message="props.message"
|
|
21
|
+
:iconRight="openPopover ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"
|
|
22
|
+
:disabled="props.disabled"
|
|
23
|
+
showClear
|
|
24
|
+
@clear="emit('update:modelValue', '')"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
<template #content>
|
|
28
|
+
<div class="unnnic-select__content">
|
|
29
|
+
<UnnnicInput
|
|
30
|
+
v-if="props.enableSearch"
|
|
31
|
+
class="unnnic-select__input-search"
|
|
32
|
+
:modelValue="props.search"
|
|
33
|
+
:placeholder="$t('search')"
|
|
34
|
+
iconLeft="search"
|
|
35
|
+
@update:modelValue="handleSearch"
|
|
36
|
+
/>
|
|
37
|
+
<UnnnicSelectOption
|
|
38
|
+
v-for="(option, index) in filteredOptions"
|
|
39
|
+
:key="option[props.itemValue]"
|
|
40
|
+
:data-option-index="index"
|
|
41
|
+
:label="option[props.itemLabel]"
|
|
42
|
+
:active="
|
|
43
|
+
option[props.itemValue] === selectedItem?.[props.itemValue]
|
|
44
|
+
"
|
|
45
|
+
:focused="focusedOptionIndex === index"
|
|
46
|
+
:disabled="option.disabled"
|
|
47
|
+
@click="handleSelectOption(option)"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
</UnnnicPopover>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { computed, ref, watch, nextTick } from 'vue';
|
|
57
|
+
import UnnnicInput from '../Input/Input.vue';
|
|
58
|
+
import UnnnicPopover from '../Popover/index.vue';
|
|
59
|
+
import UnnnicSelectOption from './SelectOption.vue';
|
|
60
|
+
import UnnnicI18n from '../../mixins/i18n';
|
|
61
|
+
|
|
62
|
+
defineOptions({
|
|
63
|
+
name: 'UnnnicSelect',
|
|
64
|
+
mixins: [UnnnicI18n],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
interface SelectProps {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
options: Array<{ [key: string]: any }>;
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
modelValue: any;
|
|
72
|
+
returnObject?: boolean;
|
|
73
|
+
itemLabel?: string;
|
|
74
|
+
itemValue?: string;
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
label?: string;
|
|
77
|
+
type?: 'normal' | 'error';
|
|
78
|
+
errors?: string | Array<string>;
|
|
79
|
+
message?: string;
|
|
80
|
+
size?: 'sm' | 'md';
|
|
81
|
+
optionsLines?: number;
|
|
82
|
+
enableSearch?: boolean;
|
|
83
|
+
search?: string;
|
|
84
|
+
locale?: string;
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const props = withDefaults(defineProps<SelectProps>(), {
|
|
89
|
+
size: 'md',
|
|
90
|
+
type: 'normal',
|
|
91
|
+
placeholder: '',
|
|
92
|
+
optionsLines: 5,
|
|
93
|
+
returnObject: false,
|
|
94
|
+
itemLabel: 'label',
|
|
95
|
+
itemValue: 'value',
|
|
96
|
+
locale: 'en',
|
|
97
|
+
enableSearch: false,
|
|
98
|
+
disabled: false,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const emit = defineEmits<{
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
'update:modelValue': [value: any];
|
|
104
|
+
'update:search': [value: string];
|
|
105
|
+
}>();
|
|
106
|
+
|
|
107
|
+
const openPopover = ref(false);
|
|
108
|
+
|
|
109
|
+
watch(openPopover, () => {
|
|
110
|
+
if (!openPopover.value) {
|
|
111
|
+
handleSearch('');
|
|
112
|
+
} else {
|
|
113
|
+
focusedOptionIndex.value = -1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (openPopover.value && props.modelValue) {
|
|
117
|
+
const selectedOptionIndex = props.options.findIndex(
|
|
118
|
+
(option) =>
|
|
119
|
+
option[props.itemValue] === selectedItem.value[props.itemValue],
|
|
120
|
+
);
|
|
121
|
+
scrollToOption(selectedOptionIndex, 'instant', 'center');
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const handleKeyDown = (event) => {
|
|
126
|
+
const { key } = event;
|
|
127
|
+
const validKeys = ['ArrowUp', 'ArrowDown', 'Enter'];
|
|
128
|
+
if (validKeys.includes(key)) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
if (key === 'ArrowUp') {
|
|
131
|
+
if (focusedOptionIndex.value === 0) return;
|
|
132
|
+
focusedOptionIndex.value--;
|
|
133
|
+
scrollToOption(focusedOptionIndex.value);
|
|
134
|
+
}
|
|
135
|
+
if (key === 'ArrowDown') {
|
|
136
|
+
if (focusedOptionIndex.value === filteredOptions.value.length - 1) return;
|
|
137
|
+
focusedOptionIndex.value++;
|
|
138
|
+
scrollToOption(focusedOptionIndex.value);
|
|
139
|
+
}
|
|
140
|
+
if (key === 'Enter') {
|
|
141
|
+
handleSelectOption(filteredOptions.value[focusedOptionIndex.value]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const focusedOptionIndex = ref<number>(-1);
|
|
147
|
+
|
|
148
|
+
const scrollToOption = (
|
|
149
|
+
index: number,
|
|
150
|
+
behavior: 'smooth' | 'instant' = 'smooth',
|
|
151
|
+
block: 'center' | 'start' | 'end' | 'nearest' = 'center',
|
|
152
|
+
) => {
|
|
153
|
+
nextTick(() => {
|
|
154
|
+
const option = document.querySelector(`[data-option-index="${index}"]`);
|
|
155
|
+
if (option) {
|
|
156
|
+
option.scrollIntoView({ behavior, block });
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const calculatedMaxHeight = computed(() => {
|
|
162
|
+
if (!props.options || props.options.length === 0) return 'unset';
|
|
163
|
+
const popoverPadding = 32;
|
|
164
|
+
const popoverGap = 4;
|
|
165
|
+
// 37 = 21px (height) + 16px (padding)
|
|
166
|
+
const fieldsHeight = 37 * props.optionsLines;
|
|
167
|
+
const size =
|
|
168
|
+
fieldsHeight + popoverPadding + (popoverGap * props.optionsLines - 2);
|
|
169
|
+
return `${props.enableSearch ? size + 54 : size}px`;
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const selectedItem = computed(() => {
|
|
173
|
+
if (props.returnObject) return props.modelValue;
|
|
174
|
+
|
|
175
|
+
return props.options.find(
|
|
176
|
+
(option) => option[props.itemValue] === props.modelValue,
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const inputValue = computed(() => {
|
|
181
|
+
return selectedItem.value?.[props.itemLabel];
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const handleSelectOption = (option) => {
|
|
185
|
+
if (
|
|
186
|
+
option[props.itemValue] === selectedItem.value?.[props.itemValue] ||
|
|
187
|
+
option.disabled
|
|
188
|
+
)
|
|
189
|
+
return;
|
|
190
|
+
|
|
191
|
+
emit(
|
|
192
|
+
'update:modelValue',
|
|
193
|
+
props.returnObject ? option : option[props.itemValue],
|
|
194
|
+
);
|
|
195
|
+
openPopover.value = false;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const handleSearch = (value: string) => {
|
|
199
|
+
emit('update:search', value);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const filteredOptions = computed(() => {
|
|
203
|
+
if (!props.enableSearch || !props.search) return props.options;
|
|
204
|
+
|
|
205
|
+
return props.options.filter(
|
|
206
|
+
(option) =>
|
|
207
|
+
option[props.itemLabel]
|
|
208
|
+
.toLowerCase()
|
|
209
|
+
.includes(props.search?.toLowerCase()) ||
|
|
210
|
+
option[props.itemValue]
|
|
211
|
+
.toLowerCase()
|
|
212
|
+
.includes(props.search?.toLowerCase()),
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<style lang="scss" scoped>
|
|
218
|
+
@use '@/assets/scss/unnnic' as *;
|
|
219
|
+
|
|
220
|
+
:deep(.unnnic-select__input) {
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
:deep(.unnnic-select__input-search) {
|
|
225
|
+
> .icon-left {
|
|
226
|
+
color: $unnnic-color-fg-base;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
:deep(.unnnic-select__input) {
|
|
231
|
+
> .icon-right {
|
|
232
|
+
color: $unnnic-color-fg-base;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.unnnic-select {
|
|
237
|
+
&__content {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
padding: 0;
|
|
241
|
+
margin: 0;
|
|
242
|
+
gap: $unnnic-space-1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
</style>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
class="tab-head"
|
|
10
10
|
:class="{
|
|
11
11
|
'tab-head--active': localValue === tab,
|
|
12
|
+
'tab-head--disabled': disabledTabs?.includes(tab),
|
|
12
13
|
}"
|
|
13
14
|
@click="change(tab)"
|
|
14
15
|
>
|
|
@@ -20,10 +21,9 @@
|
|
|
20
21
|
side="bottom"
|
|
21
22
|
>
|
|
22
23
|
<UnnnicIcon
|
|
23
|
-
icon="
|
|
24
|
+
icon="help"
|
|
24
25
|
:size="size === 'sm' ? 'xs' : 'sm'"
|
|
25
|
-
|
|
26
|
-
scheme="neutral-cleanest"
|
|
26
|
+
scheme="fg-base"
|
|
27
27
|
/>
|
|
28
28
|
</UnnnicToolTip>
|
|
29
29
|
</li>
|
|
@@ -65,6 +65,13 @@ export default {
|
|
|
65
65
|
tabs: {
|
|
66
66
|
type: Array,
|
|
67
67
|
default: null,
|
|
68
|
+
validator: (tabs) => {
|
|
69
|
+
return tabs.every((tab) => typeof tab === 'string') && tabs.length <= 5;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
disabledTabs: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: null,
|
|
68
75
|
},
|
|
69
76
|
},
|
|
70
77
|
emits: ['change'],
|
|
@@ -105,6 +112,10 @@ export default {
|
|
|
105
112
|
return '';
|
|
106
113
|
},
|
|
107
114
|
change(value) {
|
|
115
|
+
if (this.disabledTabs?.includes(value)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
this.localValue = value;
|
|
109
120
|
this.$emit('change', this.localValue);
|
|
110
121
|
},
|
|
@@ -119,18 +130,15 @@ export default {
|
|
|
119
130
|
display: flex;
|
|
120
131
|
align-items: flex-start;
|
|
121
132
|
justify-content: space-between;
|
|
122
|
-
color: $unnnic-color-
|
|
123
|
-
font
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
|
|
127
|
-
margin-bottom: $unnnic-inset-sm;
|
|
128
|
-
border-bottom: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
|
|
133
|
+
color: $unnnic-color-fg-base;
|
|
134
|
+
font: $unnnic-font-action;
|
|
135
|
+
margin-bottom: $unnnic-space-4;
|
|
136
|
+
border-bottom: $unnnic-border-width-thinner solid $unnnic-color-border-base;
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
.tab-content {
|
|
132
140
|
display: flex;
|
|
133
|
-
gap: $unnnic-
|
|
141
|
+
gap: $unnnic-space-6;
|
|
134
142
|
|
|
135
143
|
margin: 0;
|
|
136
144
|
padding: 0;
|
|
@@ -139,27 +147,24 @@ export default {
|
|
|
139
147
|
|
|
140
148
|
.tab-head {
|
|
141
149
|
display: flex;
|
|
142
|
-
gap: $unnnic-
|
|
150
|
+
gap: $unnnic-space-2;
|
|
143
151
|
align-items: center;
|
|
144
152
|
|
|
145
153
|
cursor: pointer;
|
|
146
|
-
|
|
154
|
+
padding: $unnnic-space-2 $unnnic-space-4;
|
|
147
155
|
|
|
148
156
|
.unnnic-tooltip {
|
|
149
157
|
display: flex;
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
&:hover {
|
|
153
|
-
color: $unnnic-color-
|
|
161
|
+
color: $unnnic-color-fg-emphasized;
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
.tab-head--active {
|
|
158
|
-
|
|
159
|
-
font
|
|
160
|
-
color: $unnnic-color-neutral-black;
|
|
161
|
-
font-size: $unnnic-font-size-body-lg;
|
|
162
|
-
line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
|
|
166
|
+
color: $unnnic-color-fg-emphasized;
|
|
167
|
+
font: $unnnic-font-action;
|
|
163
168
|
transition: 0.4s;
|
|
164
169
|
|
|
165
170
|
position: relative;
|
|
@@ -168,14 +173,23 @@ export default {
|
|
|
168
173
|
content: '';
|
|
169
174
|
|
|
170
175
|
position: absolute;
|
|
171
|
-
bottom:
|
|
172
|
-
left:
|
|
176
|
+
bottom: 0;
|
|
177
|
+
left: 0;
|
|
173
178
|
|
|
174
179
|
display: block;
|
|
175
180
|
|
|
176
|
-
width:
|
|
181
|
+
width: 100%;
|
|
177
182
|
|
|
178
|
-
border-bottom: $unnnic-border-width-thin solid $unnnic-color-
|
|
183
|
+
border-bottom: $unnnic-border-width-thin solid $unnnic-color-border-active;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.tab-head--disabled {
|
|
188
|
+
color: $unnnic-color-fg-muted;
|
|
189
|
+
cursor: default;
|
|
190
|
+
|
|
191
|
+
&:hover {
|
|
192
|
+
color: $unnnic-color-fg-muted;
|
|
179
193
|
}
|
|
180
194
|
}
|
|
181
195
|
|
|
@@ -4,7 +4,7 @@ exports[`Tab.vue > matches the snapshot 1`] = `
|
|
|
4
4
|
"<div data-v-b4e39fac="" class="tab size-md">
|
|
5
5
|
<header data-v-b4e39fac="" class="tab-header">
|
|
6
6
|
<ul data-v-b4e39fac="" class="tab-content">
|
|
7
|
-
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--
|
|
7
|
+
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--sm" data-testid="material-icon" translate="no">help</span><span data-v-bf0cf546="" class="unnnic-tooltip-label unnnic-tooltip-label-bottom" data-testid="tooltip-label" style="left: 0px; top: 8px;">Tooltip text <br data-v-bf0cf546=""><!--v-if--></span></div>
|
|
8
8
|
</li>
|
|
9
9
|
<li data-v-b4e39fac="" class="tab-head tab-head--active">tab2
|
|
10
10
|
<!--v-if-->
|
package/src/locales/en.json
CHANGED
package/src/locales/es.json
CHANGED
package/src/locales/pt_br.json
CHANGED
|
@@ -330,3 +330,63 @@ export const Loading = {
|
|
|
330
330
|
isLoading: true,
|
|
331
331
|
},
|
|
332
332
|
};
|
|
333
|
+
|
|
334
|
+
export const ControlledSort = {
|
|
335
|
+
args: { headers, items },
|
|
336
|
+
render: (args) => ({
|
|
337
|
+
components: {
|
|
338
|
+
UnnnicDataTable,
|
|
339
|
+
},
|
|
340
|
+
setup() {
|
|
341
|
+
let sortState = {
|
|
342
|
+
header: 'ID',
|
|
343
|
+
itemKey: 'id',
|
|
344
|
+
order: 'asc',
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
const handleSort = ({ order, header, itemKey }) => {
|
|
348
|
+
action('update:sort')({ order, header, itemKey });
|
|
349
|
+
sortState = { header, itemKey, order };
|
|
350
|
+
|
|
351
|
+
if (order === 'asc') {
|
|
352
|
+
args.items = [...args.items].sort((a, b) => {
|
|
353
|
+
if (itemKey === 'id') return a.id - b.id;
|
|
354
|
+
return a[itemKey] > b[itemKey] ? 1 : -1;
|
|
355
|
+
});
|
|
356
|
+
} else if (order === 'desc') {
|
|
357
|
+
args.items = [...args.items].sort((a, b) => {
|
|
358
|
+
if (itemKey === 'id') return b.id - a.id;
|
|
359
|
+
return a[itemKey] < b[itemKey] ? 1 : -1;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const updatePage = (page) => {
|
|
365
|
+
action('update:page')(page);
|
|
366
|
+
args.page = page;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const itemClick = (item) => {
|
|
370
|
+
action('itemClick')(item);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
return { args, sortState, handleSort, updatePage, itemClick };
|
|
374
|
+
},
|
|
375
|
+
template: `
|
|
376
|
+
<div>
|
|
377
|
+
<UnnnicDataTable
|
|
378
|
+
v-bind="args"
|
|
379
|
+
:headers="args.headers"
|
|
380
|
+
:items="args.items"
|
|
381
|
+
:pageTotal="125"
|
|
382
|
+
:pageInterval="5"
|
|
383
|
+
v-model:sort="sortState"
|
|
384
|
+
@update:sort="handleSort"
|
|
385
|
+
@update:page="updatePage"
|
|
386
|
+
@itemClick="itemClick"
|
|
387
|
+
>
|
|
388
|
+
</UnnnicDataTable>
|
|
389
|
+
</div>
|
|
390
|
+
`,
|
|
391
|
+
}),
|
|
392
|
+
};
|
|
@@ -94,6 +94,11 @@ export const Normal = {
|
|
|
94
94
|
args: {
|
|
95
95
|
type: 'normal',
|
|
96
96
|
placeholder: 'Placeholder',
|
|
97
|
+
showClear: true,
|
|
98
|
+
iconLeft: 'expand-8-1',
|
|
99
|
+
iconRight: 'messaging-we-chat-3',
|
|
100
|
+
iconLeftClickable: true,
|
|
101
|
+
iconRightClickable: false,
|
|
97
102
|
},
|
|
98
103
|
};
|
|
99
104
|
|
|
@@ -102,6 +107,7 @@ export const NormalSm = {
|
|
|
102
107
|
size: 'sm',
|
|
103
108
|
type: 'normal',
|
|
104
109
|
placeholder: 'Placeholder',
|
|
110
|
+
showClear: true,
|
|
105
111
|
},
|
|
106
112
|
};
|
|
107
113
|
|
|
@@ -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
|
+
};
|
|
@@ -3,9 +3,6 @@ import unnnicTab from '../components/Tab/Tab.vue';
|
|
|
3
3
|
export default {
|
|
4
4
|
title: 'tabs/Tab',
|
|
5
5
|
component: unnnicTab,
|
|
6
|
-
argTypes: {
|
|
7
|
-
size: { control: { type: 'select', options: ['md', 'sm'] } },
|
|
8
|
-
},
|
|
9
6
|
render: (args) => ({
|
|
10
7
|
components: {
|
|
11
8
|
unnnicTab,
|
|
@@ -36,6 +33,15 @@ export default {
|
|
|
36
33
|
Second description
|
|
37
34
|
</p>
|
|
38
35
|
</template>
|
|
36
|
+
<template #tab-head-third>
|
|
37
|
+
Third
|
|
38
|
+
</template>
|
|
39
|
+
<template #tab-panel-third>
|
|
40
|
+
<h2 class="title">Third Content</h2>
|
|
41
|
+
<p class="description">
|
|
42
|
+
Third description
|
|
43
|
+
</p>
|
|
44
|
+
</template>
|
|
39
45
|
</unnnic-tab>
|
|
40
46
|
`,
|
|
41
47
|
}),
|
|
@@ -44,6 +50,7 @@ export default {
|
|
|
44
50
|
export const Default = {
|
|
45
51
|
args: {
|
|
46
52
|
initialTab: 'first',
|
|
47
|
-
tabs: ['first', 'second'],
|
|
53
|
+
tabs: ['first', 'second', 'third'],
|
|
54
|
+
disabledTabs: ['third'],
|
|
48
55
|
},
|
|
49
56
|
};
|