sprintify-ui 0.0.108 → 0.0.110
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/sprintify-ui.es.js +4203 -4192
- package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +10 -1
- package/dist/types/src/components/BaseField.vue.d.ts +1 -1
- package/dist/types/src/components/BaseFieldI18n.vue.d.ts +1 -1
- package/dist/types/src/components/BaseStatistic.vue.d.ts +1 -1
- package/dist/types/src/components/BaseTableColumn.vue.d.ts +1 -1
- package/dist/types/src/types/index.d.ts +7 -4
- package/package.json +1 -1
- package/src/components/BaseAutocomplete.stories.js +1 -1
- package/src/components/BaseAutocomplete.vue +17 -10
- package/src/components/BaseAutocompleteFetch.stories.js +1 -1
- package/src/components/BaseBelongsTo.stories.js +1 -1
- package/src/components/BaseDropdown.stories.js +1 -1
- package/src/components/BaseDropdown.vue +49 -20
- package/src/components/BaseDropdownAutocomplete.stories.js +9 -0
- package/src/components/BaseDropdownAutocomplete.vue +6 -1
- package/src/types/index.ts +8 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
|
-
import { Option } from '@/types';
|
|
2
|
+
import { Option, SelectConfiguration } from '@/types';
|
|
3
3
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
4
4
|
modelValue: {
|
|
5
5
|
type: PropType<Option | Option[] | null | undefined>;
|
|
@@ -45,6 +45,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
45
45
|
default: undefined;
|
|
46
46
|
type: NumberConstructor;
|
|
47
47
|
};
|
|
48
|
+
select: {
|
|
49
|
+
default: undefined;
|
|
50
|
+
type: PropType<SelectConfiguration | undefined>;
|
|
51
|
+
};
|
|
48
52
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "update:model-value")[], "close" | "update:model-value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
49
53
|
modelValue: {
|
|
50
54
|
type: PropType<Option | Option[] | null | undefined>;
|
|
@@ -90,11 +94,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
90
94
|
default: undefined;
|
|
91
95
|
type: NumberConstructor;
|
|
92
96
|
};
|
|
97
|
+
select: {
|
|
98
|
+
default: undefined;
|
|
99
|
+
type: PropType<SelectConfiguration | undefined>;
|
|
100
|
+
};
|
|
93
101
|
}>> & {
|
|
94
102
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
95
103
|
"onUpdate:model-value"?: ((...args: any[]) => any) | undefined;
|
|
96
104
|
}, {
|
|
97
105
|
required: boolean;
|
|
106
|
+
select: SelectConfiguration | undefined;
|
|
98
107
|
options: Option[] | undefined;
|
|
99
108
|
size: "base" | "xs" | "sm";
|
|
100
109
|
multiple: boolean;
|
|
@@ -42,9 +42,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
42
42
|
type: PropType<string | string[] | Record<string, boolean>>;
|
|
43
43
|
};
|
|
44
44
|
}>>, {
|
|
45
|
+
label: string;
|
|
45
46
|
required: boolean;
|
|
46
47
|
name: string;
|
|
47
|
-
label: string;
|
|
48
48
|
errorType: "default" | "alert";
|
|
49
49
|
labelClass: string | string[] | Record<string, boolean>;
|
|
50
50
|
}>, {
|
|
@@ -81,9 +81,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
81
81
|
}>> & {
|
|
82
82
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
83
83
|
}, {
|
|
84
|
+
label: string;
|
|
84
85
|
required: boolean;
|
|
85
86
|
name: string;
|
|
86
|
-
label: string;
|
|
87
87
|
defaultValue: string | number | boolean;
|
|
88
88
|
modelValue: {
|
|
89
89
|
[locale: string]: string | number | boolean;
|
|
@@ -48,8 +48,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
48
48
|
type: PropType<string | null>;
|
|
49
49
|
};
|
|
50
50
|
}>>, {
|
|
51
|
-
caption: string | null;
|
|
52
51
|
label: string | null;
|
|
52
|
+
caption: string | null;
|
|
53
53
|
secondaryValue: string | null;
|
|
54
54
|
trend: "up" | "down" | null;
|
|
55
55
|
}>;
|
|
@@ -152,8 +152,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
152
152
|
default: () => {};
|
|
153
153
|
};
|
|
154
154
|
}>>, {
|
|
155
|
-
meta: Record<string, any> | unknown[];
|
|
156
155
|
label: string;
|
|
156
|
+
meta: Record<string, any> | unknown[];
|
|
157
157
|
toggle: boolean;
|
|
158
158
|
width: number;
|
|
159
159
|
field: string;
|
|
@@ -163,9 +163,12 @@ export interface NotificationsConfig {
|
|
|
163
163
|
footerLabel?: string;
|
|
164
164
|
footerTo?: RouteLocationRaw;
|
|
165
165
|
}
|
|
166
|
+
export interface SelectConfigurationOption {
|
|
167
|
+
value: OptionValue;
|
|
168
|
+
label: string;
|
|
169
|
+
[key: string]: any;
|
|
170
|
+
}
|
|
166
171
|
export interface SelectConfiguration {
|
|
167
|
-
options:
|
|
168
|
-
|
|
169
|
-
labelKey: string;
|
|
170
|
-
onChange: (value: OptionValue) => void;
|
|
172
|
+
options: SelectConfigurationOption[];
|
|
173
|
+
onChange: (option: SelectConfigurationOption | null) => void;
|
|
171
174
|
}
|
package/package.json
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
>
|
|
16
16
|
<option
|
|
17
17
|
v-for="option in select.options"
|
|
18
|
-
:key="option
|
|
19
|
-
:value="option
|
|
18
|
+
:key="option.value + ''"
|
|
19
|
+
:value="option.value"
|
|
20
20
|
>
|
|
21
|
-
{{ option
|
|
21
|
+
{{ option.label }}
|
|
22
22
|
</option>
|
|
23
23
|
</select>
|
|
24
24
|
<div class="relative grow">
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
<script lang="ts" setup>
|
|
121
121
|
import { get } from 'lodash';
|
|
122
122
|
import { PropType, Ref, ComputedRef } from 'vue';
|
|
123
|
-
import { NormalizedOption, Option } from '@/types';
|
|
123
|
+
import { NormalizedOption, Option, OptionValue } from '@/types';
|
|
124
124
|
import { useHasOptions } from '@/composables/hasOptions';
|
|
125
125
|
import { useField } from '@/composables/field';
|
|
126
126
|
import { BaseIcon } from './index';
|
|
@@ -420,27 +420,34 @@ function highlight() {
|
|
|
420
420
|
inputElement.value?.select();
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
-
const selection = ref(null) as Ref<
|
|
423
|
+
const selection = ref(null) as Ref<OptionValue>;
|
|
424
424
|
|
|
425
425
|
watch(
|
|
426
426
|
() => props.select,
|
|
427
427
|
(select) => {
|
|
428
428
|
if (select && select.options.length > 0) {
|
|
429
|
-
selection.value = select.options[0]
|
|
429
|
+
selection.value = select.options[0].value;
|
|
430
430
|
}
|
|
431
431
|
},
|
|
432
432
|
{ immediate: true }
|
|
433
433
|
);
|
|
434
434
|
|
|
435
435
|
function onSelectChange(event: Event) {
|
|
436
|
-
focus();
|
|
437
|
-
open();
|
|
438
|
-
highlight();
|
|
439
436
|
const value = get(event, 'target.value', null);
|
|
437
|
+
const option = props.select?.options.find((option) => option.value == value);
|
|
438
|
+
|
|
440
439
|
if (props.select && props.select.onChange) {
|
|
441
|
-
props.select.onChange(
|
|
440
|
+
props.select.onChange(option ?? null);
|
|
442
441
|
}
|
|
442
|
+
|
|
443
443
|
emit('select', value);
|
|
444
|
+
|
|
445
|
+
// Let the emitted select event propagate before opening the dropdown
|
|
446
|
+
nextTick(() => {
|
|
447
|
+
focus();
|
|
448
|
+
open();
|
|
449
|
+
highlight();
|
|
450
|
+
});
|
|
444
451
|
}
|
|
445
452
|
|
|
446
453
|
const slotProps = {
|
|
@@ -67,16 +67,18 @@ const props = defineProps({
|
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
const emit = defineEmits(['close', 'open']);
|
|
71
|
+
|
|
70
72
|
const buttonX = ref(0);
|
|
71
73
|
const buttonY = ref(0);
|
|
72
74
|
const buttonWidth = ref(0);
|
|
73
75
|
const buttonHeight = ref(0);
|
|
74
76
|
|
|
77
|
+
const dropdownX = ref(0);
|
|
78
|
+
const dropdownY = ref(0);
|
|
75
79
|
const dropdownWidth = ref(0);
|
|
76
80
|
const dropdownHeight = ref(0);
|
|
77
81
|
|
|
78
|
-
const emit = defineEmits(['close', 'open']);
|
|
79
|
-
|
|
80
82
|
function setBoundingBoxes() {
|
|
81
83
|
if (button.value) {
|
|
82
84
|
const { y, x, height, width } = button.value.getBoundingClientRect();
|
|
@@ -87,7 +89,9 @@ function setBoundingBoxes() {
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
if (dropdown.value) {
|
|
90
|
-
const { height, width } = dropdown.value.getBoundingClientRect();
|
|
92
|
+
const { y, x, height, width } = dropdown.value.getBoundingClientRect();
|
|
93
|
+
dropdownX.value = x;
|
|
94
|
+
dropdownY.value = y;
|
|
91
95
|
dropdownWidth.value = width;
|
|
92
96
|
dropdownHeight.value = height;
|
|
93
97
|
}
|
|
@@ -163,25 +167,50 @@ useClickOutside(
|
|
|
163
167
|
);
|
|
164
168
|
|
|
165
169
|
const placementInternal = computed(() => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
window.innerHeight - buttonY.value - buttonHeight.value - props.padding
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
170
|
+
// vertical
|
|
171
|
+
const spaceTop = buttonY.value - props.padding;
|
|
172
|
+
const spaceBottom =
|
|
173
|
+
window.innerHeight - buttonY.value - buttonHeight.value - props.padding;
|
|
174
|
+
|
|
175
|
+
const tooTallForTop = spaceTop < dropdownHeight.value;
|
|
176
|
+
const tooTallForBottom = spaceBottom < dropdownHeight.value;
|
|
177
|
+
|
|
178
|
+
let verticalPreference = props.placement.split('-')[0];
|
|
179
|
+
|
|
180
|
+
if (tooTallForTop && !tooTallForBottom) {
|
|
181
|
+
verticalPreference = 'bottom';
|
|
182
|
+
} else if (!tooTallForTop && tooTallForBottom) {
|
|
183
|
+
verticalPreference = 'top';
|
|
184
|
+
} else if (tooTallForTop && tooTallForBottom) {
|
|
185
|
+
if (spaceTop > spaceBottom) {
|
|
186
|
+
verticalPreference = 'top';
|
|
187
|
+
} else {
|
|
188
|
+
verticalPreference = 'bottom';
|
|
189
|
+
}
|
|
180
190
|
}
|
|
181
|
-
|
|
182
|
-
|
|
191
|
+
|
|
192
|
+
// horizontal
|
|
193
|
+
const spaceStart = buttonX.value + buttonWidth.value;
|
|
194
|
+
const spaceEnd = window.innerWidth - buttonX.value;
|
|
195
|
+
|
|
196
|
+
const tooLargeForStart = spaceStart < dropdownWidth.value;
|
|
197
|
+
const tooLargeForEnd = spaceEnd < dropdownWidth.value;
|
|
198
|
+
|
|
199
|
+
let horizontalPreference = props.placement.split('-')[1];
|
|
200
|
+
|
|
201
|
+
if (tooLargeForStart && !tooLargeForEnd) {
|
|
202
|
+
horizontalPreference = 'start';
|
|
203
|
+
} else if (!tooLargeForStart && tooLargeForEnd) {
|
|
204
|
+
horizontalPreference = 'end';
|
|
205
|
+
} else if (tooLargeForStart && tooLargeForEnd) {
|
|
206
|
+
if (spaceStart > spaceEnd) {
|
|
207
|
+
horizontalPreference = 'end';
|
|
208
|
+
} else {
|
|
209
|
+
horizontalPreference = 'start';
|
|
210
|
+
}
|
|
183
211
|
}
|
|
184
|
-
|
|
212
|
+
|
|
213
|
+
return `${verticalPreference}-${horizontalPreference}`;
|
|
185
214
|
});
|
|
186
215
|
|
|
187
216
|
const dropdownStyles = computed((): StyleValue => {
|
|
@@ -57,6 +57,15 @@ Autocomplete.args = {
|
|
|
57
57
|
multiple: false,
|
|
58
58
|
labelKey: 'label',
|
|
59
59
|
valueKey: 'value',
|
|
60
|
+
select: {
|
|
61
|
+
options: [
|
|
62
|
+
{ label: 'Option 1', value: 'option-1' },
|
|
63
|
+
{ label: 'Option 2', value: 'option-2' },
|
|
64
|
+
{ label: 'Option 3', value: 'option-3' },
|
|
65
|
+
],
|
|
66
|
+
labelKey: 'label',
|
|
67
|
+
valueKey: 'value',
|
|
68
|
+
},
|
|
60
69
|
};
|
|
61
70
|
|
|
62
71
|
export const AutocompleteFetch = (args) => ({
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
:value-key="valueKey"
|
|
25
25
|
:inline="true"
|
|
26
26
|
:required="required"
|
|
27
|
+
:select="select"
|
|
27
28
|
dropdown-show="always"
|
|
28
29
|
@update:model-value="onUpdate($event, close)"
|
|
29
30
|
>
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
<script lang="ts" setup>
|
|
62
63
|
import { isArray } from 'lodash';
|
|
63
64
|
import { PropType, Ref } from 'vue';
|
|
64
|
-
import { Option } from '@/types';
|
|
65
|
+
import { Option, SelectConfiguration } from '@/types';
|
|
65
66
|
import BaseDropdown from './BaseDropdown.vue';
|
|
66
67
|
import BaseAutocomplete from './BaseAutocomplete.vue';
|
|
67
68
|
import BaseAutocompleteFetch from './BaseAutocompleteFetch.vue';
|
|
@@ -117,6 +118,10 @@ const props = defineProps({
|
|
|
117
118
|
default: undefined,
|
|
118
119
|
type: Number,
|
|
119
120
|
},
|
|
121
|
+
select: {
|
|
122
|
+
default: undefined,
|
|
123
|
+
type: [Object, undefined] as PropType<SelectConfiguration | undefined>,
|
|
124
|
+
},
|
|
120
125
|
});
|
|
121
126
|
|
|
122
127
|
const emit = defineEmits(['update:model-value', 'close']);
|
package/src/types/index.ts
CHANGED
|
@@ -198,9 +198,13 @@ export interface NotificationsConfig {
|
|
|
198
198
|
footerTo?: RouteLocationRaw;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
export interface SelectConfigurationOption {
|
|
202
|
+
value: OptionValue;
|
|
203
|
+
label: string;
|
|
204
|
+
[key: string]: any;
|
|
205
|
+
}
|
|
206
|
+
|
|
201
207
|
export interface SelectConfiguration {
|
|
202
|
-
options:
|
|
203
|
-
|
|
204
|
-
labelKey: string;
|
|
205
|
-
onChange: (value: OptionValue) => void;
|
|
208
|
+
options: SelectConfigurationOption[];
|
|
209
|
+
onChange: (option: SelectConfigurationOption | null) => void;
|
|
206
210
|
}
|