@mouseless/baked 1.2.2 → 1.2.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/module.json
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
:options="data"
|
|
14
14
|
:placeholder="l(label)"
|
|
15
15
|
:show-clear
|
|
16
|
-
|
|
16
|
+
:filter
|
|
17
|
+
class="w-full"
|
|
17
18
|
>
|
|
18
19
|
<template #value="slotProps">
|
|
19
20
|
<span>
|
|
@@ -42,11 +43,11 @@ const { schema, data } = defineProps({
|
|
|
42
43
|
data: { type: null, required: true }
|
|
43
44
|
});
|
|
44
45
|
const model = defineModel({ type: null, required: true });
|
|
45
|
-
const { label, localizeLabel, optionLabel, optionValue, showClear, stateful } = schema;
|
|
46
|
+
const { filter, label, localizeLabel, optionLabel, optionValue, showClear, stateful, targetProp } = schema;
|
|
46
47
|
const path = context.injectPath();
|
|
47
48
|
const selected = ref();
|
|
48
49
|
watch(
|
|
49
|
-
[() => data,
|
|
50
|
+
[() => data, getModel],
|
|
50
51
|
([_data, _model]) => {
|
|
51
52
|
if (!_data) {
|
|
52
53
|
return;
|
|
@@ -65,12 +66,15 @@ function getValueLabel(slotProps) {
|
|
|
65
66
|
const result = slotProps.value?.[optionLabel] ?? slotProps.value ?? label;
|
|
66
67
|
return localizeLabel ? l(result) : result;
|
|
67
68
|
}
|
|
69
|
+
function getModel() {
|
|
70
|
+
return targetProp ? model.value?.[targetProp] : model.value;
|
|
71
|
+
}
|
|
68
72
|
function setModel(selected2) {
|
|
69
73
|
const selectedValue = optionValue ? selected2?.[optionValue] : selected2;
|
|
70
|
-
model.value = selectedValue;
|
|
71
74
|
if (stateful) {
|
|
72
75
|
selectStates[path] = selectedValue;
|
|
73
76
|
}
|
|
77
|
+
model.value = selectedValue ? targetProp ? { [targetProp]: selectedValue } : selectedValue : void 0;
|
|
74
78
|
}
|
|
75
79
|
function setSelected(value) {
|
|
76
80
|
if (!data) {
|
|
@@ -79,7 +83,7 @@ function setSelected(value) {
|
|
|
79
83
|
selected.value = optionValue ? data.filter((o) => o[optionValue] === value)[0] : value;
|
|
80
84
|
if (stateful) {
|
|
81
85
|
const selectedValue = optionValue ? selected.value?.[optionValue] : selected.value;
|
|
82
|
-
if (
|
|
86
|
+
if (getModel() !== selectedValue) {
|
|
83
87
|
setModel(selected.value);
|
|
84
88
|
}
|
|
85
89
|
}
|
|
@@ -87,15 +91,5 @@ function setSelected(value) {
|
|
|
87
91
|
</script>
|
|
88
92
|
|
|
89
93
|
<style>
|
|
90
|
-
|
|
91
|
-
placeholder gives select the initial width, but it overlaps with label so it is
|
|
92
|
-
hidden
|
|
93
|
-
*/
|
|
94
|
-
.hide-placeholder .p-placeholder {
|
|
95
|
-
visibility: hidden;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.p-select-label {
|
|
99
|
-
font-size: inherit;
|
|
100
|
-
}
|
|
94
|
+
.b-component--Select .p-placeholder{visibility:hidden}.b-component--Select .p-select-label{font-size:inherit}
|
|
101
95
|
</style>
|
|
@@ -34,11 +34,11 @@ const { schema, data } = defineProps({
|
|
|
34
34
|
data: { type: null, required: true }
|
|
35
35
|
});
|
|
36
36
|
const model = defineModel({ type: null, required: true });
|
|
37
|
-
const { allowEmpty = false, localizeLabel, optionLabel, optionValue, stateful } = schema;
|
|
37
|
+
const { allowEmpty = false, localizeLabel, optionLabel, optionValue, stateful, targetProp } = schema;
|
|
38
38
|
const path = context.injectPath();
|
|
39
39
|
const selected = ref();
|
|
40
40
|
watch(
|
|
41
|
-
[() => data,
|
|
41
|
+
[() => data, getModel],
|
|
42
42
|
([_data, _model]) => {
|
|
43
43
|
if (!_data) {
|
|
44
44
|
return;
|
|
@@ -53,12 +53,15 @@ function getOptionLabel(slotProps) {
|
|
|
53
53
|
const result = slotProps.option[optionLabel] ?? slotProps.option;
|
|
54
54
|
return localizeLabel ? l(result) : result;
|
|
55
55
|
}
|
|
56
|
+
function getModel() {
|
|
57
|
+
return targetProp ? model.value?.[targetProp] : model.value;
|
|
58
|
+
}
|
|
56
59
|
function setModel(selected2) {
|
|
57
60
|
const selectedValue = optionValue ? selected2?.[optionValue] : selected2;
|
|
58
|
-
model.value = selectedValue;
|
|
59
61
|
if (stateful) {
|
|
60
62
|
selectButtonStates[path] = selectedValue;
|
|
61
63
|
}
|
|
64
|
+
model.value = selectedValue ? targetProp ? { [targetProp]: selectedValue } : selectedValue : void 0;
|
|
62
65
|
}
|
|
63
66
|
function setSelected(value) {
|
|
64
67
|
if (!data) {
|
|
@@ -67,7 +70,7 @@ function setSelected(value) {
|
|
|
67
70
|
selected.value = optionValue ? data.filter((o) => o[optionValue] === value)[0] : value;
|
|
68
71
|
if (stateful) {
|
|
69
72
|
const selectedValue = optionValue ? selected.value?.[optionValue] : selected.value;
|
|
70
|
-
if (
|
|
73
|
+
if (getModel() !== selectedValue) {
|
|
71
74
|
setModel(selected.value);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -75,5 +78,5 @@ function setSelected(value) {
|
|
|
75
78
|
</script>
|
|
76
79
|
|
|
77
80
|
<style>
|
|
78
|
-
.p-popover-content .p-selectbutton{@apply max-sm:flex-col}.p-popover-content .p-selectbutton .p-togglebutton:first-child{@apply max-sm:rounded-t-lg max-sm:rounded-es-none}.p-popover-content .p-selectbutton .p-togglebutton:last-child{@apply max-sm:rounded-b-lg max-sm:rounded-se-none}
|
|
81
|
+
.p-popover-content .b-component--SelectButton.p-selectbutton{@apply max-sm:flex-col}.p-popover-content .b-component--SelectButton.p-selectbutton .p-togglebutton:first-child{@apply max-sm:rounded-t-lg max-sm:rounded-es-none}.p-popover-content .b-component--SelectButton.p-selectbutton .p-togglebutton:last-child{@apply max-sm:rounded-b-lg max-sm:rounded-se-none}
|
|
79
82
|
</style>
|