Skip to content

Commit d5b6a91

Browse files
authored
Merge pull request #18793 from craftcms/bugfix/settings-timezone
[6.x] Bugfix/settings timezone
2 parents 79c2458 + 1e6d3da commit d5b6a91

9 files changed

Lines changed: 192 additions & 288 deletions

File tree

resources/js/components/Combobox.vue

Lines changed: 0 additions & 101 deletions
This file was deleted.

resources/js/components/form/CraftCombobox.vue

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22
import {t} from '@craftcms/cp';
33
import InputCombobox from '@/components/form/InputCombobox.vue';
44
import type {SelectItem} from '@/types';
5-
import {computed} from 'vue';
5+
import {computed, useSlots} from 'vue';
66
7-
const emit = defineEmits<{
8-
(e: 'update:modelValue', value: string): void;
9-
}>();
7+
const modelValue = defineModel<string | number | boolean>();
108
const props = defineProps<{
11-
modelValue: string;
129
label: string;
1310
id?: string;
1411
name?: string;
1512
disabled?: boolean;
1613
options?: Array<SelectItem>;
1714
callouts?: Array<string>;
1815
error?: string;
16+
requireOptionMatch?: boolean;
1917
}>();
2018
21-
const valueProxy = computed({
22-
get() {
23-
return props.modelValue;
24-
},
25-
set(newValue) {
26-
emit('update:modelValue', newValue);
27-
},
19+
const slots = useSlots();
20+
const forwardedSlots = computed(() => {
21+
const {default: _, ...rest} = slots;
22+
return rest;
2823
});
2924
</script>
3025

@@ -35,14 +30,20 @@
3530
:name="name"
3631
:disabled="disabled"
3732
:has-feedback-for="error ? 'error' : ''"
33+
:require-options-match="requireOptionMatch"
3834
v-bind="$attrs"
3935
>
4036
<InputCombobox
4137
slot="input"
42-
v-model="valueProxy"
38+
v-model="modelValue"
4339
:options="options"
4440
:label="label"
45-
/>
41+
>
42+
<!-- Forward all other slots -->
43+
<template v-for="(_, name) in forwardedSlots" #[name]="slotData">
44+
<slot :name="name" v-bind="slotData || {}"></slot>
45+
</template>
46+
</InputCombobox>
4647

4748
<div slot="after">
4849
<slot name="after">

resources/js/components/form/InputCombobox.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import InputComboboxOption from '@/components/form/InputComboboxOption.vue';
1919
2020
const emit = defineEmits<{
21-
(e: 'update:modelValue', value: string): void;
21+
(e: 'update:modelValue', value: string | number): void;
2222
}>();
2323
const props = withDefaults(
2424
defineProps<{
2525
label?: string;
2626
options?: Array<SelectItem>;
27-
modelValue?: string;
27+
modelValue?: string | number | boolean;
2828
requireOptionMatch?: boolean;
2929
transformModelValue?: (newValue: SelectOption | null) => string;
3030
class?: HTMLAttributes['class'];
@@ -60,7 +60,7 @@
6060
6161
if (!selectedItem && !props.requireOptionMatch) {
6262
selectedItem = {
63-
label: props.modelValue,
63+
label: String(props.modelValue),
6464
value: props.modelValue,
6565
};
6666
}
@@ -76,7 +76,7 @@
7676
});
7777
7878
const reference = useTemplateRef<HTMLElement | null>('reference');
79-
const query = ref(props.modelValue ?? '');
79+
const query = ref(String(props.modelValue ?? ''));
8080
8181
const referenceCoordinates = computed(() => {
8282
const coordinates = reference.value?.getBoundingClientRect();
@@ -88,12 +88,12 @@
8888
});
8989
9090
function matchesQuery(query: MaybeRef<string>, item: MaybeRef<SelectOption>) {
91-
const lowerQuery = unref(query).toLowerCase();
91+
const lowerQuery = String(unref(query)).toLowerCase();
9292
const option = unref(item);
9393
9494
return (
9595
option.label.toLowerCase().includes(lowerQuery) ||
96-
option.value.toLowerCase().includes(lowerQuery) ||
96+
option.value.toString().toLowerCase().includes(lowerQuery) ||
9797
(option.data?.keywords?.toLowerCase().includes(lowerQuery) ?? false)
9898
);
9999
}

resources/js/components/form/InputComboboxOption.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515
:checked="selected"
1616
:hint="option.data?.hint"
1717
>
18-
<template
19-
v-if="option.label.startsWith('$') || option.label.startsWith('@')"
20-
>
21-
<code>
18+
<div class="flex gap-2 items-center">
19+
<template v-if="option.data?.indicator">
20+
<craft-indicator v-bind="option.data.indicator"></craft-indicator>
21+
</template>
22+
<template
23+
v-if="option.label.startsWith('$') || option.label.startsWith('@')"
24+
>
25+
<code>
26+
{{ option.label }}
27+
</code>
28+
</template>
29+
<template v-else>
2230
{{ option.label }}
23-
</code>
24-
</template>
25-
<template v-else>
26-
{{ option.label }}
27-
</template>
31+
</template>
32+
</div>
2833
</craft-option>
2934
</slot>
3035
</ComboboxOption>

0 commit comments

Comments
 (0)