@simsustech/quasar-components 0.5.6 → 0.6.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/CHANGELOG.md +12 -0
- package/dist/authentication.js +2 -2
- package/dist/form.js +131 -26
- package/dist/{nl-CBxnt0JS.js → nl-D4kRrjEa.js} +1 -1
- package/dist/{nl-BjtwxTCz.js → nl-DF7uv7-9.js} +1 -0
- package/dist/types/ui/form/FilteredModelSelect.vue.d.ts +97 -0
- package/dist/types/ui/form/FormInput.vue.d.ts +1 -1
- package/dist/types/ui/form/index.d.ts +1 -0
- package/dist/types/ui/form/lang/en-US.d.ts +1 -1
- package/dist/types/ui/form/lang/index.d.ts +2 -0
- package/dist/types/ui/form/lang/nl.d.ts +1 -1
- package/dist/vite-plugin.js +3 -0
- package/package.json +1 -1
- package/src/ui/authentication/lang/en-US.ts +1 -1
- package/src/ui/authentication/lang/nl.ts +1 -1
- package/src/ui/form/FilteredModelSelect.vue +125 -0
- package/src/ui/form/FormInput.vue +8 -1
- package/src/ui/form/index.ts +1 -0
- package/src/ui/form/lang/en-US.ts +2 -1
- package/src/ui/form/lang/index.ts +1 -0
- package/src/ui/form/lang/nl.ts +2 -1
- package/src/vite-plugin.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @simsustech/quasar-components
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2d54c9b: feat(components): add FilteredModelSelect component
|
|
8
|
+
|
|
9
|
+
## 0.5.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ba791dc: fix(components): change OTP email label
|
|
14
|
+
|
|
3
15
|
## 0.5.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/authentication.js
CHANGED
|
@@ -27,7 +27,7 @@ const lang$1 = {
|
|
|
27
27
|
},
|
|
28
28
|
otp: {
|
|
29
29
|
fields: {
|
|
30
|
-
email: "
|
|
30
|
+
email: "Your (current) email address"
|
|
31
31
|
},
|
|
32
32
|
validations: {
|
|
33
33
|
fieldRequired: "Field is required.",
|
|
@@ -98,7 +98,7 @@ var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: f
|
|
|
98
98
|
const lang = ref(lang$1);
|
|
99
99
|
const locales = /* @__PURE__ */ Object.assign({
|
|
100
100
|
"./en-US.ts": () => Promise.resolve().then(() => enUS),
|
|
101
|
-
"./nl.ts": () => import("./nl-
|
|
101
|
+
"./nl.ts": () => import("./nl-D4kRrjEa.js")
|
|
102
102
|
});
|
|
103
103
|
const useLang = () => {
|
|
104
104
|
return lang;
|
package/dist/form.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ref, defineComponent, useAttrs, withAsyncContext, watch, openBlock, createBlock, unref, mergeProps, normalizeProps, guardReactiveProps, withCtx, createVNode, createTextVNode, toDisplayString, computed, useSlots, renderSlot, createCommentVNode, toRefs, resolveDirective, createElementBlock, Fragment, renderList, resolveDynamicComponent, createElementVNode, withDirectives } from "vue";
|
|
1
|
+
import { ref, defineComponent, useAttrs, withAsyncContext, watch, openBlock, createBlock, unref, mergeProps, normalizeProps, guardReactiveProps, withCtx, createVNode, createTextVNode, toDisplayString, computed, useSlots, renderSlot, createCommentVNode, toRefs, resolveDirective, createElementBlock, Fragment, renderList, resolveDynamicComponent, createElementVNode, withDirectives, createSlots } from "vue";
|
|
2
2
|
import { useQuasar, QSelect, QItem, QItemSection, QItemLabel, QInput, QDate, QIcon, QTooltip, QBtn, QPopupProxy, QField, QEditor } from "quasar";
|
|
3
3
|
const lang$1 = {
|
|
4
4
|
isoName: "en-US",
|
|
5
5
|
yes: "Yes",
|
|
6
6
|
no: "No",
|
|
7
|
+
selectMultiple: "Select one or multiple",
|
|
7
8
|
buttons: {
|
|
8
9
|
close: "Close"
|
|
9
10
|
},
|
|
@@ -52,7 +53,7 @@ var define_import_meta_env_default = { BASE_URL: "/", MODE: "production", DEV: f
|
|
|
52
53
|
const lang = ref(lang$1);
|
|
53
54
|
const locales = /* @__PURE__ */ Object.assign({
|
|
54
55
|
"./en-US.ts": () => Promise.resolve().then(() => enUS),
|
|
55
|
-
"./nl.ts": () => import("./nl-
|
|
56
|
+
"./nl.ts": () => import("./nl-DF7uv7-9.js")
|
|
56
57
|
});
|
|
57
58
|
const useLang = () => {
|
|
58
59
|
return lang;
|
|
@@ -76,7 +77,7 @@ const loadLang = async (isoName) => {
|
|
|
76
77
|
loadingLanguage = false;
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
|
-
const _sfc_main$
|
|
80
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
80
81
|
__name: "GenderSelect",
|
|
81
82
|
props: {
|
|
82
83
|
modelValue: {},
|
|
@@ -129,7 +130,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
|
-
const _sfc_main$
|
|
133
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
133
134
|
__name: "GenderItem",
|
|
134
135
|
props: {
|
|
135
136
|
modelValue: {}
|
|
@@ -169,7 +170,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
169
170
|
};
|
|
170
171
|
}
|
|
171
172
|
});
|
|
172
|
-
const _sfc_main$
|
|
173
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
173
174
|
__name: "PostalCodeInput",
|
|
174
175
|
props: {
|
|
175
176
|
modelValue: {},
|
|
@@ -207,7 +208,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
207
208
|
};
|
|
208
209
|
}
|
|
209
210
|
});
|
|
210
|
-
const _sfc_main$
|
|
211
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
211
212
|
__name: "FormItem",
|
|
212
213
|
props: {
|
|
213
214
|
modelValue: {},
|
|
@@ -268,7 +269,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
268
269
|
};
|
|
269
270
|
}
|
|
270
271
|
});
|
|
271
|
-
const _sfc_main$
|
|
272
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
272
273
|
__name: "FormInput",
|
|
273
274
|
props: {
|
|
274
275
|
modelValue: {},
|
|
@@ -301,7 +302,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
301
302
|
};
|
|
302
303
|
}
|
|
303
304
|
});
|
|
304
|
-
const _sfc_main$
|
|
305
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
305
306
|
__name: "TelephoneNumberInput",
|
|
306
307
|
props: {
|
|
307
308
|
modelValue: {},
|
|
@@ -332,7 +333,7 @@ const _hoisted_1 = {
|
|
|
332
333
|
style: { "margin-left": "-0.5em", "margin-top": "0.75em" }
|
|
333
334
|
};
|
|
334
335
|
const _hoisted_2 = { class: "row items-center justify-end" };
|
|
335
|
-
const _sfc_main$
|
|
336
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
336
337
|
__name: "DateInput",
|
|
337
338
|
props: {
|
|
338
339
|
modelValue: {},
|
|
@@ -550,7 +551,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
550
551
|
};
|
|
551
552
|
}
|
|
552
553
|
});
|
|
553
|
-
const _sfc_main$
|
|
554
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
554
555
|
__name: "BooleanSelect",
|
|
555
556
|
props: {
|
|
556
557
|
modelValue: { type: [Boolean, null] },
|
|
@@ -596,7 +597,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
596
597
|
};
|
|
597
598
|
}
|
|
598
599
|
});
|
|
599
|
-
const _sfc_main$
|
|
600
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
600
601
|
__name: "BooleanItem",
|
|
601
602
|
props: {
|
|
602
603
|
modelValue: { type: [Boolean, null] },
|
|
@@ -637,11 +638,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
637
638
|
};
|
|
638
639
|
}
|
|
639
640
|
});
|
|
640
|
-
const __default__ = {
|
|
641
|
+
const __default__$1 = {
|
|
641
642
|
name: "EmailInput"
|
|
642
643
|
};
|
|
643
|
-
const _sfc_main$
|
|
644
|
-
...__default__,
|
|
644
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
645
|
+
...__default__$1,
|
|
645
646
|
props: {
|
|
646
647
|
subject: {},
|
|
647
648
|
body: {}
|
|
@@ -677,7 +678,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
677
678
|
};
|
|
678
679
|
}
|
|
679
680
|
});
|
|
680
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
681
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
681
682
|
__name: "DatePicker",
|
|
682
683
|
props: {
|
|
683
684
|
modelValue: {},
|
|
@@ -743,18 +744,122 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
743
744
|
};
|
|
744
745
|
}
|
|
745
746
|
});
|
|
747
|
+
const __default__ = {
|
|
748
|
+
name: "FilteredModelSelect"
|
|
749
|
+
};
|
|
750
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
751
|
+
...__default__,
|
|
752
|
+
props: {
|
|
753
|
+
modelValue: {},
|
|
754
|
+
labelKey: {},
|
|
755
|
+
valueKey: {},
|
|
756
|
+
filteredOptions: {},
|
|
757
|
+
required: { type: Boolean },
|
|
758
|
+
onFilter: {},
|
|
759
|
+
multiple: { type: Boolean },
|
|
760
|
+
label: {},
|
|
761
|
+
hint: {}
|
|
762
|
+
},
|
|
763
|
+
emits: ["update:model-value", "filter"],
|
|
764
|
+
setup(__props, { emit: __emit }) {
|
|
765
|
+
const props = __props;
|
|
766
|
+
const attrs = useAttrs();
|
|
767
|
+
const emit = __emit;
|
|
768
|
+
const lang2 = useLang();
|
|
769
|
+
const { modelValue, onFilter, filteredOptions, labelKey, valueKey } = toRefs(props);
|
|
770
|
+
const options = computed(() => {
|
|
771
|
+
var _a;
|
|
772
|
+
if (filteredOptions.value.length) {
|
|
773
|
+
return (_a = filteredOptions.value) == null ? void 0 : _a.map((option) => ({
|
|
774
|
+
label: option[labelKey.value],
|
|
775
|
+
value: option[valueKey.value || "id"]
|
|
776
|
+
}));
|
|
777
|
+
}
|
|
778
|
+
return [];
|
|
779
|
+
});
|
|
780
|
+
const requiredValidation = ref(
|
|
781
|
+
(val) => (Array.isArray(val) ? !!val.length : !!val) || lang2.value.validations.fieldRequired
|
|
782
|
+
);
|
|
783
|
+
const selectedIds = computed(() => {
|
|
784
|
+
if (Array.isArray(modelValue.value)) {
|
|
785
|
+
return [...modelValue.value];
|
|
786
|
+
} else if (modelValue.value) {
|
|
787
|
+
return [modelValue.value];
|
|
788
|
+
}
|
|
789
|
+
return [];
|
|
790
|
+
});
|
|
791
|
+
const filterFn = (val, update, abort) => {
|
|
792
|
+
if (!onFilter.value)
|
|
793
|
+
update(() => {
|
|
794
|
+
});
|
|
795
|
+
emit("filter", {
|
|
796
|
+
ids: selectedIds.value,
|
|
797
|
+
searchPhrase: val.toLowerCase(),
|
|
798
|
+
done: () => update(() => {
|
|
799
|
+
})
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
const selectRef = ref();
|
|
803
|
+
watch(modelValue, () => {
|
|
804
|
+
if (!options.value.length)
|
|
805
|
+
emit("filter", {
|
|
806
|
+
ids: selectedIds.value,
|
|
807
|
+
searchPhrase: "",
|
|
808
|
+
done: () => {
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
return (_ctx, _cache) => {
|
|
813
|
+
return openBlock(), createBlock(unref(QSelect), mergeProps({
|
|
814
|
+
ref_key: "selectRef",
|
|
815
|
+
ref: selectRef
|
|
816
|
+
}, unref(attrs), {
|
|
817
|
+
"model-value": unref(modelValue),
|
|
818
|
+
options: options.value,
|
|
819
|
+
label: `${_ctx.label}${_ctx.required ? "*" : ""}`,
|
|
820
|
+
hint: _ctx.multiple ? unref(lang2).selectMultiple : void 0,
|
|
821
|
+
"emit-value": "",
|
|
822
|
+
"map-options": "",
|
|
823
|
+
"fill-input": !_ctx.multiple,
|
|
824
|
+
"use-input": !!unref(onFilter),
|
|
825
|
+
"hide-selected": !_ctx.multiple && !!unref(onFilter) || Number.isNaN(unref(modelValue)),
|
|
826
|
+
multiple: _ctx.multiple,
|
|
827
|
+
"bottom-slots": !!_ctx.hint,
|
|
828
|
+
"input-debounce": "500",
|
|
829
|
+
rules: _ctx.required ? [requiredValidation.value] : [],
|
|
830
|
+
onFilter: filterFn,
|
|
831
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:model-value", $event))
|
|
832
|
+
}), createSlots({
|
|
833
|
+
hint: withCtx(() => [
|
|
834
|
+
createTextVNode(toDisplayString(_ctx.hint), 1)
|
|
835
|
+
]),
|
|
836
|
+
_: 2
|
|
837
|
+
}, [
|
|
838
|
+
renderList(Object.keys(_ctx.$slots), (slot, index) => {
|
|
839
|
+
return {
|
|
840
|
+
name: slot,
|
|
841
|
+
fn: withCtx((scope) => [
|
|
842
|
+
renderSlot(_ctx.$slots, slot, { scope })
|
|
843
|
+
])
|
|
844
|
+
};
|
|
845
|
+
})
|
|
846
|
+
]), 1040, ["model-value", "options", "label", "hint", "fill-input", "use-input", "hide-selected", "multiple", "bottom-slots", "rules"]);
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
});
|
|
746
850
|
export {
|
|
747
|
-
_sfc_main$
|
|
748
|
-
_sfc_main$
|
|
749
|
-
_sfc_main$
|
|
750
|
-
_sfc_main as DatePicker,
|
|
751
|
-
_sfc_main$
|
|
752
|
-
_sfc_main
|
|
753
|
-
_sfc_main$7 as
|
|
754
|
-
_sfc_main$
|
|
755
|
-
_sfc_main$a as
|
|
756
|
-
_sfc_main$
|
|
757
|
-
_sfc_main$
|
|
851
|
+
_sfc_main$3 as BooleanItem,
|
|
852
|
+
_sfc_main$4 as BooleanSelect,
|
|
853
|
+
_sfc_main$5 as DateInput,
|
|
854
|
+
_sfc_main$1 as DatePicker,
|
|
855
|
+
_sfc_main$2 as EmailInput,
|
|
856
|
+
_sfc_main as FilteredModelSelect,
|
|
857
|
+
_sfc_main$7 as FormInput,
|
|
858
|
+
_sfc_main$8 as FormItem,
|
|
859
|
+
_sfc_main$a as GenderItem,
|
|
860
|
+
_sfc_main$b as GenderSelect,
|
|
861
|
+
_sfc_main$9 as PostalCodeInput,
|
|
862
|
+
_sfc_main$6 as TelephoneNumberInput,
|
|
758
863
|
loadLang,
|
|
759
864
|
useLang
|
|
760
865
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
declare const _default: <T extends {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
id: number;
|
|
4
|
+
}>(__VLS_props: {
|
|
5
|
+
required?: boolean | undefined;
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
modelValue?: number | number[] | null | undefined;
|
|
8
|
+
hint?: string | undefined;
|
|
9
|
+
multiple?: boolean | undefined;
|
|
10
|
+
onFilter?: ((args_0: {
|
|
11
|
+
ids: number[];
|
|
12
|
+
searchPhrase: string;
|
|
13
|
+
done: (success?: boolean) => void;
|
|
14
|
+
}) => any) | undefined;
|
|
15
|
+
"onUpdate:model-value"?: ((id: number) => any) | undefined;
|
|
16
|
+
labelKey: string;
|
|
17
|
+
valueKey?: string | undefined;
|
|
18
|
+
filteredOptions: T[];
|
|
19
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, __VLS_ctx?: {
|
|
20
|
+
attrs: any;
|
|
21
|
+
slots: Partial<Record<string, (_: {
|
|
22
|
+
scope: any;
|
|
23
|
+
}) => any>>;
|
|
24
|
+
emit: {
|
|
25
|
+
(e: 'update:model-value', id: number): void;
|
|
26
|
+
(e: 'filter', { ids, searchPhrase, done }: {
|
|
27
|
+
ids: number[];
|
|
28
|
+
searchPhrase: string;
|
|
29
|
+
done: (success?: boolean) => void;
|
|
30
|
+
}): void;
|
|
31
|
+
};
|
|
32
|
+
} | undefined, __VLS_expose?: ((exposed: import('vue').ShallowUnwrapRef<{}>) => void) | undefined, __VLS_setup?: Promise<{
|
|
33
|
+
props: {
|
|
34
|
+
required?: boolean | undefined;
|
|
35
|
+
label?: string | undefined;
|
|
36
|
+
modelValue?: number | number[] | null | undefined;
|
|
37
|
+
hint?: string | undefined;
|
|
38
|
+
multiple?: boolean | undefined;
|
|
39
|
+
onFilter?: ((args_0: {
|
|
40
|
+
ids: number[];
|
|
41
|
+
searchPhrase: string;
|
|
42
|
+
done: (success?: boolean) => void;
|
|
43
|
+
}) => any) | undefined;
|
|
44
|
+
"onUpdate:model-value"?: ((id: number) => any) | undefined;
|
|
45
|
+
labelKey: string;
|
|
46
|
+
valueKey?: string | undefined;
|
|
47
|
+
filteredOptions: T[];
|
|
48
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
49
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
50
|
+
attrs: any;
|
|
51
|
+
slots: Partial<Record<string, (_: {
|
|
52
|
+
scope: any;
|
|
53
|
+
}) => any>>;
|
|
54
|
+
emit: {
|
|
55
|
+
(e: 'update:model-value', id: number): void;
|
|
56
|
+
(e: 'filter', { ids, searchPhrase, done }: {
|
|
57
|
+
ids: number[];
|
|
58
|
+
searchPhrase: string;
|
|
59
|
+
done: (success?: boolean) => void;
|
|
60
|
+
}): void;
|
|
61
|
+
};
|
|
62
|
+
}>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
}> & {
|
|
65
|
+
__ctx?: {
|
|
66
|
+
props: {
|
|
67
|
+
required?: boolean | undefined;
|
|
68
|
+
label?: string | undefined;
|
|
69
|
+
modelValue?: number | number[] | null | undefined;
|
|
70
|
+
hint?: string | undefined;
|
|
71
|
+
multiple?: boolean | undefined;
|
|
72
|
+
onFilter?: ((args_0: {
|
|
73
|
+
ids: number[];
|
|
74
|
+
searchPhrase: string;
|
|
75
|
+
done: (success?: boolean) => void;
|
|
76
|
+
}) => any) | undefined;
|
|
77
|
+
"onUpdate:model-value"?: ((id: number) => any) | undefined;
|
|
78
|
+
labelKey: string;
|
|
79
|
+
valueKey?: string | undefined;
|
|
80
|
+
filteredOptions: T[];
|
|
81
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
82
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
83
|
+
attrs: any;
|
|
84
|
+
slots: Partial<Record<string, (_: {
|
|
85
|
+
scope: any;
|
|
86
|
+
}) => any>>;
|
|
87
|
+
emit: {
|
|
88
|
+
(e: 'update:model-value', id: number): void;
|
|
89
|
+
(e: 'filter', { ids, searchPhrase, done }: {
|
|
90
|
+
ids: number[];
|
|
91
|
+
searchPhrase: string;
|
|
92
|
+
done: (success?: boolean) => void;
|
|
93
|
+
}): void;
|
|
94
|
+
};
|
|
95
|
+
} | undefined;
|
|
96
|
+
};
|
|
97
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type FormItems = 'name' | 'firstName' | 'lastName' | 'address' | 'city';
|
|
1
|
+
export type FormItems = 'name' | 'firstName' | 'lastName' | 'address' | 'city' | 'postalCode' | 'telephoneNumber';
|
|
2
2
|
export interface Props {
|
|
3
3
|
modelValue?: string | null;
|
|
4
4
|
field?: FormItems;
|
|
@@ -9,4 +9,5 @@ export { default as BooleanSelect } from './BooleanSelect.vue';
|
|
|
9
9
|
export { default as BooleanItem } from './BooleanItem.vue';
|
|
10
10
|
export { default as EmailInput } from './EmailInput.vue';
|
|
11
11
|
export { default as DatePicker } from './DatePicker.vue';
|
|
12
|
+
export { default as FilteredModelSelect } from './FilteredModelSelect.vue';
|
|
12
13
|
export { useLang, loadLang } from './lang/index.js';
|
|
@@ -2,6 +2,7 @@ export interface Language {
|
|
|
2
2
|
isoName: string;
|
|
3
3
|
yes: string;
|
|
4
4
|
no: string;
|
|
5
|
+
selectMultiple: string;
|
|
5
6
|
buttons: {
|
|
6
7
|
close: string;
|
|
7
8
|
};
|
|
@@ -47,6 +48,7 @@ export declare const lang: Ref<{
|
|
|
47
48
|
isoName: string;
|
|
48
49
|
yes: string;
|
|
49
50
|
no: string;
|
|
51
|
+
selectMultiple: string;
|
|
50
52
|
buttons: {
|
|
51
53
|
close: string;
|
|
52
54
|
};
|
package/dist/vite-plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<q-select
|
|
3
|
+
ref="selectRef"
|
|
4
|
+
v-bind="attrs"
|
|
5
|
+
:model-value="modelValue"
|
|
6
|
+
:options="options"
|
|
7
|
+
:label="`${label}${required ? '*' : ''}`"
|
|
8
|
+
:hint="multiple ? lang.selectMultiple : undefined"
|
|
9
|
+
emit-value
|
|
10
|
+
map-options
|
|
11
|
+
:fill-input="!multiple"
|
|
12
|
+
:use-input="!!onFilter"
|
|
13
|
+
:hide-selected="(!multiple && !!onFilter) || Number.isNaN(modelValue)"
|
|
14
|
+
:multiple="multiple"
|
|
15
|
+
:bottom-slots="!!hint"
|
|
16
|
+
input-debounce="500"
|
|
17
|
+
:rules="required ? [requiredValidation] : []"
|
|
18
|
+
@filter="filterFn"
|
|
19
|
+
@update:model-value="$emit('update:model-value', $event)"
|
|
20
|
+
>
|
|
21
|
+
<template #hint> {{ hint }} </template>
|
|
22
|
+
<template
|
|
23
|
+
v-for="(slot, index) of Object.keys($slots)"
|
|
24
|
+
:key="index"
|
|
25
|
+
#[slot]="scope"
|
|
26
|
+
>
|
|
27
|
+
<slot :scope="scope" :name="slot"></slot>
|
|
28
|
+
</template>
|
|
29
|
+
</q-select>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
export default {
|
|
34
|
+
name: 'FilteredModelSelect'
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<script
|
|
39
|
+
setup
|
|
40
|
+
lang="ts"
|
|
41
|
+
generic="T extends { id: number; [key: string]: unknown }"
|
|
42
|
+
>
|
|
43
|
+
import { QSelect } from 'quasar'
|
|
44
|
+
import { computed, ref, toRefs, useAttrs, watch } from 'vue'
|
|
45
|
+
import { useLang } from './lang/index.js'
|
|
46
|
+
|
|
47
|
+
interface Props {
|
|
48
|
+
modelValue?: number | number[] | null
|
|
49
|
+
labelKey: string
|
|
50
|
+
valueKey?: string
|
|
51
|
+
filteredOptions: T[]
|
|
52
|
+
required?: boolean
|
|
53
|
+
onFilter?: unknown
|
|
54
|
+
multiple?: boolean
|
|
55
|
+
label?: string
|
|
56
|
+
hint?: string
|
|
57
|
+
}
|
|
58
|
+
const props = defineProps<Props>()
|
|
59
|
+
const attrs = useAttrs()
|
|
60
|
+
|
|
61
|
+
const emit = defineEmits<{
|
|
62
|
+
(e: 'update:model-value', id: number): void
|
|
63
|
+
(
|
|
64
|
+
e: 'filter',
|
|
65
|
+
{
|
|
66
|
+
ids,
|
|
67
|
+
searchPhrase,
|
|
68
|
+
done
|
|
69
|
+
}: {
|
|
70
|
+
ids: number[]
|
|
71
|
+
searchPhrase: string
|
|
72
|
+
done: (success?: boolean) => void
|
|
73
|
+
}
|
|
74
|
+
): void
|
|
75
|
+
}>()
|
|
76
|
+
|
|
77
|
+
const lang = useLang()
|
|
78
|
+
|
|
79
|
+
const { modelValue, onFilter, filteredOptions, labelKey, valueKey } =
|
|
80
|
+
toRefs(props)
|
|
81
|
+
const options = computed(() => {
|
|
82
|
+
if (filteredOptions.value.length) {
|
|
83
|
+
return filteredOptions.value?.map((option) => ({
|
|
84
|
+
label: option[labelKey.value],
|
|
85
|
+
value: option[valueKey.value || 'id']
|
|
86
|
+
}))
|
|
87
|
+
}
|
|
88
|
+
return []
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const requiredValidation = ref(
|
|
92
|
+
(val: unknown) =>
|
|
93
|
+
(Array.isArray(val) ? !!val.length : !!val) ||
|
|
94
|
+
lang.value.validations.fieldRequired
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
const selectedIds = computed(() => {
|
|
98
|
+
if (Array.isArray(modelValue.value)) {
|
|
99
|
+
return [...modelValue.value]
|
|
100
|
+
} else if (modelValue.value) {
|
|
101
|
+
return [modelValue.value]
|
|
102
|
+
}
|
|
103
|
+
return []
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const filterFn: QSelect['$props']['onFilter'] = (val, update, abort) => {
|
|
107
|
+
if (!onFilter.value) update(() => {})
|
|
108
|
+
emit('filter', {
|
|
109
|
+
ids: selectedIds.value,
|
|
110
|
+
searchPhrase: val.toLowerCase(),
|
|
111
|
+
done: () => update(() => {})
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const selectRef = ref<QSelect>()
|
|
116
|
+
|
|
117
|
+
watch(modelValue, () => {
|
|
118
|
+
if (!options.value.length)
|
|
119
|
+
emit('filter', {
|
|
120
|
+
ids: selectedIds.value,
|
|
121
|
+
searchPhrase: '',
|
|
122
|
+
done: () => {}
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
</script>
|
|
@@ -15,7 +15,14 @@ import { ref, watch, useAttrs } from 'vue'
|
|
|
15
15
|
import { QInput, useQuasar, ValidationRule } from 'quasar'
|
|
16
16
|
import { useLang, loadLang } from './lang'
|
|
17
17
|
|
|
18
|
-
export type FormItems =
|
|
18
|
+
export type FormItems =
|
|
19
|
+
| 'name'
|
|
20
|
+
| 'firstName'
|
|
21
|
+
| 'lastName'
|
|
22
|
+
| 'address'
|
|
23
|
+
| 'city'
|
|
24
|
+
| 'postalCode'
|
|
25
|
+
| 'telephoneNumber'
|
|
19
26
|
|
|
20
27
|
export interface Props {
|
|
21
28
|
modelValue?: string | null
|
package/src/ui/form/index.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { default as BooleanSelect } from './BooleanSelect.vue'
|
|
|
9
9
|
export { default as BooleanItem } from './BooleanItem.vue'
|
|
10
10
|
export { default as EmailInput } from './EmailInput.vue'
|
|
11
11
|
export { default as DatePicker } from './DatePicker.vue'
|
|
12
|
+
export { default as FilteredModelSelect } from './FilteredModelSelect.vue'
|
|
12
13
|
export { useLang, loadLang } from './lang/index.js'
|
package/src/ui/form/lang/nl.ts
CHANGED