dev: hotfix, moved combobox and datepicker

This commit is contained in:
2025-10-10 23:58:44 +07:00
parent f94b6d273a
commit 1a3edd5a1e
25 changed files with 58 additions and 33 deletions
@@ -1,16 +1,11 @@
<script setup lang="ts">
import { cn } from '~/lib/utils'
interface Item {
value: string | number
label: string
code?: string
priority?: number
}
import { type Item } from './index'
const props = defineProps<{
id: string
modelValue?: string | number
id?: string
modelValue?: string
items: Item[]
placeholder?: string
searchPlaceholder?: string
@@ -20,7 +15,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{
'update:modelValue': [value: string | number]
'update:modelValue': [value: string]
}>()
const open = ref(false)
@@ -28,12 +23,17 @@ const open = ref(false)
const selectedItem = computed(() => props.items.find((item) => item.value === props.modelValue))
const displayText = computed(() => {
console.log(selectedItem);
if (selectedItem.value?.label) {
return selectedItem.value.label
}
return props.placeholder || 'Pilih item'
})
watch(props, () => {
console.log(props.modelValue);
})
const searchableItems = computed(() => {
const itemsWithSearch = props.items.map((item) => ({
...item,
@@ -0,0 +1,25 @@
export interface Item {
value: string
label: string
code?: string
priority?: number
}
export function recStrToItem(input: Record<string, string>): Item[] {
console.log(input)
const items: Item[] = []
let idx = 0;
for (const key in input) {
if (input.hasOwnProperty(key)) {
const value = input[key]
items.push({
value: key || ('unknown-' + idx),
label: input[key] || ('unknown-' + idx),
})
}
idx++
}
return items
}
export { default as Combobox } from './combobox.vue'