sprintify-ui 0.0.102 → 0.0.104
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 +9541 -9273
- package/dist/style.css +1 -1
- package/dist/types/src/components/BaseAutocomplete.vue.d.ts +23 -3
- package/dist/types/src/components/BaseAutocompleteFetch.vue.d.ts +26 -8
- package/dist/types/src/components/BaseBelongsTo.vue.d.ts +26 -8
- package/dist/types/src/components/BaseDropdown.vue.d.ts +9 -0
- package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +123 -0
- package/dist/types/src/components/BaseHasMany.vue.d.ts +5 -5
- package/dist/types/src/components/BaseTable.vue.d.ts +2 -2
- package/dist/types/src/components/BaseTagAutocompleteFetch.vue.d.ts +5 -5
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/BaseAutocomplete.stories.js +6 -0
- package/src/components/BaseAutocomplete.vue +65 -15
- package/src/components/BaseAutocompleteDropdown.vue +2 -2
- package/src/components/BaseAutocompleteFetch.stories.js +6 -0
- package/src/components/BaseAutocompleteFetch.vue +34 -8
- package/src/components/BaseBelongsTo.stories.js +6 -0
- package/src/components/BaseBelongsTo.vue +17 -7
- package/src/components/BaseButtonGroup.vue +1 -1
- package/src/components/BaseColor.vue +3 -3
- package/src/components/BaseDropdown.stories.js +1 -1
- package/src/components/BaseDropdown.vue +15 -9
- package/src/components/BaseDropdownAutocomplete.stories.js +178 -0
- package/src/components/BaseDropdownAutocomplete.vue +225 -0
- package/src/components/BaseHasMany.vue +6 -5
- package/src/components/BaseRadioGroup.vue +4 -1
- package/src/components/BaseTable.vue +1 -1
- package/src/components/BaseTagAutocomplete.vue +4 -4
- package/src/components/BaseTagAutocompleteFetch.vue +5 -5
- package/src/components/index.ts +2 -0
- package/src/types/index.ts +1 -1
- package/dist/types/src/components/BaseFormField.d.ts +0 -81
- package/dist/types/src/components/BaseLocaleForm.vue.d.ts +0 -439
- package/dist/types/src/components/BaseNumberForm.vue.d.ts +0 -401
- package/dist/types/src/components/BasePasswordForm.vue.d.ts +0 -384
- package/dist/types/src/components/BaseTextareaForm.vue.d.ts +0 -413
- package/src/components/BaseFormField.ts +0 -117
- package/src/components/BaseLocaleForm.vue +0 -142
- package/src/components/BaseNumberForm.vue +0 -67
- package/src/components/BasePasswordForm.vue +0 -59
- package/src/components/BaseTextareaForm.vue +0 -101
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<BaseDropdown
|
|
3
|
+
:animated="true"
|
|
4
|
+
:keep-alive="false"
|
|
5
|
+
:placement="placement"
|
|
6
|
+
:padding="padding"
|
|
7
|
+
@open="onOpen"
|
|
8
|
+
@close="onClose"
|
|
9
|
+
>
|
|
10
|
+
<template #button="buttonProps">
|
|
11
|
+
<slot name="button" v-bind="buttonProps" :new-value="newValue"></slot>
|
|
12
|
+
</template>
|
|
13
|
+
<template #dropdown="{ close }">
|
|
14
|
+
<div
|
|
15
|
+
class="inline-block w-[320px] overflow-hidden rounded-md border border-slate-300 bg-white px-1 pt-1 shadow-lg"
|
|
16
|
+
>
|
|
17
|
+
<component
|
|
18
|
+
:is="componentName"
|
|
19
|
+
ref="autocomplete"
|
|
20
|
+
:model-value="newValue"
|
|
21
|
+
:size="size"
|
|
22
|
+
v-bind="autocompleteProps"
|
|
23
|
+
:label-key="labelKey"
|
|
24
|
+
:value-key="valueKey"
|
|
25
|
+
:inline="true"
|
|
26
|
+
:required="required"
|
|
27
|
+
dropdown-show="always"
|
|
28
|
+
@update:model-value="onUpdate($event, close)"
|
|
29
|
+
>
|
|
30
|
+
<template #option="optionProps">
|
|
31
|
+
<div
|
|
32
|
+
:class="[optionProps.active ? 'bg-slate-100' : 'bg-white']"
|
|
33
|
+
class="mb-px flex items-center rounded py-1 px-1"
|
|
34
|
+
>
|
|
35
|
+
<div class="flex grow items-center">
|
|
36
|
+
<slot
|
|
37
|
+
name="option"
|
|
38
|
+
:option="optionProps.option"
|
|
39
|
+
:active="optionProps.active"
|
|
40
|
+
:size="size"
|
|
41
|
+
></slot>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="shrink-0">
|
|
44
|
+
<BaseIcon
|
|
45
|
+
v-if="
|
|
46
|
+
(optionProps.selected ?? false) ||
|
|
47
|
+
(optionProps.option[valueKey] == null && newValue == null)
|
|
48
|
+
"
|
|
49
|
+
icon="mdi:check-bold"
|
|
50
|
+
class="h-4 w-4 text-slate-500"
|
|
51
|
+
></BaseIcon>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
</component>
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
</BaseDropdown>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script lang="ts" setup>
|
|
62
|
+
import { isArray } from 'lodash';
|
|
63
|
+
import { PropType, Ref } from 'vue';
|
|
64
|
+
import { Option } from '@/types';
|
|
65
|
+
import BaseDropdown from './BaseDropdown.vue';
|
|
66
|
+
import BaseAutocomplete from './BaseAutocomplete.vue';
|
|
67
|
+
import BaseAutocompleteFetch from './BaseAutocompleteFetch.vue';
|
|
68
|
+
import BaseTagAutocomplete from './BaseTagAutocomplete.vue';
|
|
69
|
+
import BaseTagAutocompleteFetch from './BaseTagAutocompleteFetch.vue';
|
|
70
|
+
|
|
71
|
+
const props = defineProps({
|
|
72
|
+
modelValue: {
|
|
73
|
+
type: [Array, Object, null, undefined] as PropType<
|
|
74
|
+
Option[] | Option | null | undefined
|
|
75
|
+
>,
|
|
76
|
+
default: undefined,
|
|
77
|
+
},
|
|
78
|
+
multiple: {
|
|
79
|
+
type: Boolean as PropType<boolean>,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
url: {
|
|
83
|
+
type: String as PropType<string>,
|
|
84
|
+
default: undefined,
|
|
85
|
+
},
|
|
86
|
+
options: {
|
|
87
|
+
type: Array as PropType<Option[] | undefined>,
|
|
88
|
+
default: undefined,
|
|
89
|
+
},
|
|
90
|
+
labelKey: {
|
|
91
|
+
default: 'name',
|
|
92
|
+
type: String,
|
|
93
|
+
},
|
|
94
|
+
valueKey: {
|
|
95
|
+
default: 'id',
|
|
96
|
+
type: String,
|
|
97
|
+
},
|
|
98
|
+
size: {
|
|
99
|
+
type: String as PropType<'xs' | 'sm' | 'base'>,
|
|
100
|
+
default: 'sm',
|
|
101
|
+
},
|
|
102
|
+
required: {
|
|
103
|
+
type: Boolean as PropType<boolean>,
|
|
104
|
+
default: false,
|
|
105
|
+
},
|
|
106
|
+
emptyOptionLabel: {
|
|
107
|
+
default: undefined,
|
|
108
|
+
type: String,
|
|
109
|
+
},
|
|
110
|
+
placement: {
|
|
111
|
+
type: String as PropType<
|
|
112
|
+
'bottom-start' | 'bottom-end' | 'top-start' | 'top-end'
|
|
113
|
+
>,
|
|
114
|
+
default: undefined,
|
|
115
|
+
},
|
|
116
|
+
padding: {
|
|
117
|
+
default: undefined,
|
|
118
|
+
type: Number,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const emit = defineEmits(['update:model-value', 'close']);
|
|
123
|
+
|
|
124
|
+
const componentName = computed(() => {
|
|
125
|
+
if (props.multiple) {
|
|
126
|
+
if (props.url) {
|
|
127
|
+
return BaseTagAutocompleteFetch;
|
|
128
|
+
}
|
|
129
|
+
if (props.options) {
|
|
130
|
+
return BaseTagAutocomplete;
|
|
131
|
+
}
|
|
132
|
+
console.error('BaseDropdownAutocomplete: options or url is required');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (props.url) {
|
|
137
|
+
return BaseAutocompleteFetch;
|
|
138
|
+
}
|
|
139
|
+
if (props.options) {
|
|
140
|
+
return BaseAutocomplete;
|
|
141
|
+
}
|
|
142
|
+
console.error('BaseDropdownAutocomplete: options or url is required');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const autocomplete = ref(null) as Ref<any>;
|
|
146
|
+
|
|
147
|
+
const newValue = ref(null) as Ref<any>;
|
|
148
|
+
|
|
149
|
+
const autocompleteProps = computed(() => {
|
|
150
|
+
const newProps = {} as any;
|
|
151
|
+
|
|
152
|
+
if (props.url) {
|
|
153
|
+
newProps.url = props.url;
|
|
154
|
+
} else {
|
|
155
|
+
newProps.options = props.options ?? [];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!props.multiple) {
|
|
159
|
+
newProps.showModelValue = false;
|
|
160
|
+
newProps.showEmptyOption = true;
|
|
161
|
+
newProps.emptyOptionLabel = props.emptyOptionLabel;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return newProps;
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
watch(
|
|
168
|
+
() => props.modelValue,
|
|
169
|
+
(modelValue) => {
|
|
170
|
+
newValue.value = modelValue ?? null;
|
|
171
|
+
},
|
|
172
|
+
{ immediate: true, deep: true }
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
function onOpen() {
|
|
176
|
+
nextTick(() => {
|
|
177
|
+
setTimeout(() => {
|
|
178
|
+
autocomplete.value?.open();
|
|
179
|
+
}, 1);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function onClose() {
|
|
184
|
+
nextTick(() => {
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
autocomplete.value?.setKeywords('');
|
|
187
|
+
}, 1);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
emit('close');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function onUpdate(
|
|
194
|
+
value: Option | Option[] | null | undefined,
|
|
195
|
+
close: () => void
|
|
196
|
+
) {
|
|
197
|
+
newValue.value = getNewValue(value);
|
|
198
|
+
|
|
199
|
+
update();
|
|
200
|
+
|
|
201
|
+
if (!props.multiple) {
|
|
202
|
+
close();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function getNewValue(value: Option | Option[] | null | undefined) {
|
|
207
|
+
if (isArray(value)) {
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (value == null) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (value[props.valueKey] ?? null) {
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function update() {
|
|
223
|
+
emit('update:model-value', newValue.value);
|
|
224
|
+
}
|
|
225
|
+
</script>
|
|
@@ -104,10 +104,11 @@ function onUpdate(newModels: Option[]) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
defineExpose({
|
|
107
|
-
focus: tagAutocompleteFetch.value?.focus,
|
|
108
|
-
blur: tagAutocompleteFetch.value?.blur,
|
|
109
|
-
open: tagAutocompleteFetch.value?.open,
|
|
110
|
-
close: tagAutocompleteFetch.value?.close,
|
|
111
|
-
setKeywords:
|
|
107
|
+
focus: () => tagAutocompleteFetch.value?.focus(),
|
|
108
|
+
blur: () => tagAutocompleteFetch.value?.blur(),
|
|
109
|
+
open: () => tagAutocompleteFetch.value?.open(),
|
|
110
|
+
close: () => tagAutocompleteFetch.value?.close(),
|
|
111
|
+
setKeywords: (input: string) =>
|
|
112
|
+
tagAutocompleteFetch.value?.setKeywords(input),
|
|
112
113
|
});
|
|
113
114
|
</script>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<ul class="space-y-3">
|
|
4
|
-
<li
|
|
4
|
+
<li
|
|
5
|
+
v-for="option in normalizedOptions"
|
|
6
|
+
:key="option.value ? option.value : 'null'"
|
|
7
|
+
>
|
|
5
8
|
<label
|
|
6
9
|
:for="name + '-' + option.value"
|
|
7
10
|
class="cursor-pointer"
|
|
@@ -305,7 +305,7 @@ const props = defineProps({
|
|
|
305
305
|
default: false,
|
|
306
306
|
type: Boolean,
|
|
307
307
|
},
|
|
308
|
-
/** Rows can be checked (multiple)
|
|
308
|
+
/** Rows can be checked (multiple) */
|
|
309
309
|
checkable: {
|
|
310
310
|
default: false,
|
|
311
311
|
type: Boolean,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="autocomplete">
|
|
3
3
|
<div
|
|
4
|
-
class="rounded border bg-white p-1"
|
|
4
|
+
class="relative z-[1] rounded border bg-white p-1"
|
|
5
5
|
:class="[
|
|
6
6
|
hasErrorInternal ? 'border-red-600' : 'border-slate-300',
|
|
7
7
|
wrapperClass,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<div class="-m-0.5 flex flex-wrap">
|
|
11
11
|
<div
|
|
12
12
|
v-for="selection in normalizedModelValue"
|
|
13
|
-
:key="selection.value"
|
|
13
|
+
:key="selection.value ? selection.value : 'null'"
|
|
14
14
|
class="p-0.5"
|
|
15
15
|
>
|
|
16
16
|
<div
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
v-if="opened || dropdownShow == 'always'"
|
|
57
57
|
:class="[
|
|
58
58
|
inline
|
|
59
|
-
? 'relative
|
|
59
|
+
? 'relative'
|
|
60
60
|
: 'absolute top-1 z-menu min-h-[110px] w-full overflow-hidden rounded border border-slate-300 bg-white shadow-md',
|
|
61
61
|
]"
|
|
62
62
|
>
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
:size="size"
|
|
68
68
|
:loading="loading"
|
|
69
69
|
:loading-bottom="loadingBottom"
|
|
70
|
-
:dropdown-class="inline ? '' : 'p-1'"
|
|
70
|
+
:dropdown-class="inline ? 'pt-1' : 'p-1'"
|
|
71
71
|
:keywords="keywords"
|
|
72
72
|
@select="onSelect"
|
|
73
73
|
@scroll-bottom="emit('scrollBottom')"
|
|
@@ -174,10 +174,10 @@ const debouncedSearch = debounce(() => {
|
|
|
174
174
|
}, 300);
|
|
175
175
|
|
|
176
176
|
defineExpose({
|
|
177
|
-
focus: tagAutocomplete.value?.focus,
|
|
178
|
-
blur: tagAutocomplete.value?.blur,
|
|
179
|
-
open: tagAutocomplete.value?.open,
|
|
180
|
-
close: tagAutocomplete.value?.close,
|
|
181
|
-
setKeywords: tagAutocomplete.value?.setKeywords,
|
|
177
|
+
focus: () => tagAutocomplete.value?.focus(),
|
|
178
|
+
blur: () => tagAutocomplete.value?.blur(),
|
|
179
|
+
open: () => tagAutocomplete.value?.open(),
|
|
180
|
+
close: () => tagAutocomplete.value?.close(),
|
|
181
|
+
setKeywords: (input: string) => tagAutocomplete.value?.setKeywords(input),
|
|
182
182
|
});
|
|
183
183
|
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ import BaseDescriptionList from './BaseDescriptionList.vue';
|
|
|
28
28
|
import BaseDescriptionListItem from './BaseDescriptionListItem.vue';
|
|
29
29
|
import BaseDialog from './BaseDialog.vue';
|
|
30
30
|
import BaseDropdown from './BaseDropdown.vue';
|
|
31
|
+
import BaseDropdownAutocomplete from './BaseDropdownAutocomplete.vue';
|
|
31
32
|
import BaseField from './BaseField.vue';
|
|
32
33
|
import BaseFieldI18n from './BaseFieldI18n.vue';
|
|
33
34
|
import BaseFilePicker from './BaseFilePicker.vue';
|
|
@@ -110,6 +111,7 @@ export {
|
|
|
110
111
|
BaseDescriptionListItem,
|
|
111
112
|
BaseDialog,
|
|
112
113
|
BaseDropdown,
|
|
114
|
+
BaseDropdownAutocomplete,
|
|
113
115
|
BaseField,
|
|
114
116
|
BaseFieldI18n,
|
|
115
117
|
BaseFilePicker,
|
package/src/types/index.ts
CHANGED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import BaseForm from './BaseForm.vue';
|
|
2
|
-
declare const _default: import("vue").DefineComponent<{
|
|
3
|
-
name: {
|
|
4
|
-
required: true;
|
|
5
|
-
type: StringConstructor;
|
|
6
|
-
};
|
|
7
|
-
placeholder: {
|
|
8
|
-
default: string;
|
|
9
|
-
type: StringConstructor;
|
|
10
|
-
};
|
|
11
|
-
label: {
|
|
12
|
-
default: string;
|
|
13
|
-
type: StringConstructor;
|
|
14
|
-
};
|
|
15
|
-
disabled: {
|
|
16
|
-
type: BooleanConstructor;
|
|
17
|
-
default: boolean;
|
|
18
|
-
};
|
|
19
|
-
required: {
|
|
20
|
-
default: boolean;
|
|
21
|
-
type: BooleanConstructor;
|
|
22
|
-
};
|
|
23
|
-
autofocus: {
|
|
24
|
-
default: boolean;
|
|
25
|
-
type: BooleanConstructor;
|
|
26
|
-
};
|
|
27
|
-
preventSubmit: {
|
|
28
|
-
default: boolean;
|
|
29
|
-
type: BooleanConstructor;
|
|
30
|
-
};
|
|
31
|
-
}, unknown, unknown, {
|
|
32
|
-
form(): typeof BaseForm | null;
|
|
33
|
-
errors(): any;
|
|
34
|
-
labelValue(): string;
|
|
35
|
-
}, {
|
|
36
|
-
inputListener(payload: any): void;
|
|
37
|
-
errorMessage(name?: string | null): any;
|
|
38
|
-
hasError(name?: string | null): boolean;
|
|
39
|
-
clearErrors(name?: string | null): void;
|
|
40
|
-
disableForm(): void;
|
|
41
|
-
enableForm(): void;
|
|
42
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
43
|
-
name: {
|
|
44
|
-
required: true;
|
|
45
|
-
type: StringConstructor;
|
|
46
|
-
};
|
|
47
|
-
placeholder: {
|
|
48
|
-
default: string;
|
|
49
|
-
type: StringConstructor;
|
|
50
|
-
};
|
|
51
|
-
label: {
|
|
52
|
-
default: string;
|
|
53
|
-
type: StringConstructor;
|
|
54
|
-
};
|
|
55
|
-
disabled: {
|
|
56
|
-
type: BooleanConstructor;
|
|
57
|
-
default: boolean;
|
|
58
|
-
};
|
|
59
|
-
required: {
|
|
60
|
-
default: boolean;
|
|
61
|
-
type: BooleanConstructor;
|
|
62
|
-
};
|
|
63
|
-
autofocus: {
|
|
64
|
-
default: boolean;
|
|
65
|
-
type: BooleanConstructor;
|
|
66
|
-
};
|
|
67
|
-
preventSubmit: {
|
|
68
|
-
default: boolean;
|
|
69
|
-
type: BooleanConstructor;
|
|
70
|
-
};
|
|
71
|
-
}>> & {
|
|
72
|
-
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
73
|
-
}, {
|
|
74
|
-
required: boolean;
|
|
75
|
-
label: string;
|
|
76
|
-
disabled: boolean;
|
|
77
|
-
placeholder: string;
|
|
78
|
-
preventSubmit: boolean;
|
|
79
|
-
autofocus: boolean;
|
|
80
|
-
}>;
|
|
81
|
-
export default _default;
|