Files
InvoiceShelf/resources/scripts/components/base/BaseTimePicker.vue
Darko Gjorgjijoski 71388ec6a5 Rename resources/scripts-v2 to resources/scripts and drop @v2 alias
Now that the legacy v1 frontend (commit 064bdf53) is gone, the v2 directory is the only frontend and the v2 suffix is just noise. Renames resources/scripts-v2 to resources/scripts via git mv (so git records the move as renames, preserving blame and log --follow), then bulk-rewrites the 152 files that imported via @v2/... to use @/scripts/... instead. The existing @ alias (resources/) covers the new path with no extra config needed.

Drops the now-unused @v2 alias from vite.config.js and points the laravel-vite-plugin entry at resources/scripts/main.ts. Updates the only blade reference (resources/views/app.blade.php) to match. The package.json test script (eslint ./resources/scripts) automatically targets the right place after the rename without any edit.

Verified: npm run build exits clean and the Vite warning lines now reference resources/scripts/plugins/i18n.ts, confirming every import resolved through the new path. git log --follow on any moved file walks back through its scripts-v2 history.
2026-04-07 12:50:16 +02:00

142 lines
3.3 KiB
Vue

<template>
<BaseContentPlaceholders v-if="contentLoading">
<BaseContentPlaceholdersBox
:rounded="true"
:class="`w-full ${computedContainerClass}`"
style="height: 38px"
/>
</BaseContentPlaceholders>
<div v-else :class="computedContainerClass" class="relative flex flex-row">
<svg
v-if="clockIcon && !hasIconSlot"
xmlns="http://www.w3.org/2000/svg"
class="
absolute
top-px
w-4
h-4
mx-2
my-2.5
text-sm
not-italic
font-black
text-subtle
cursor-pointer
"
viewBox="0 0 20 20"
fill="currentColor"
@click="onClickPicker"
>
<path
fill-rule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z"
clip-rule="evenodd"
/>
</svg>
<slot v-if="clockIcon && hasIconSlot" name="icon" />
<FlatPickr
ref="dpt"
v-model="time"
v-bind="$attrs"
:disabled="disabled"
:config="config"
:class="[defaultInputClass, inputInvalidClass, inputDisabledClass]"
/>
</div>
</template>
<script setup lang="ts">
import FlatPickr from 'vue-flatpickr-component'
import 'flatpickr/dist/flatpickr.css'
import { computed, reactive, useSlots, ref } from 'vue'
interface FlatPickrInstance {
fp: { open: () => void }
}
const dpt = ref<FlatPickrInstance | null>(null)
interface Props {
modelValue?: string | Date
contentLoading?: boolean
placeholder?: string | null
invalid?: boolean
disabled?: boolean
containerClass?: string
clockIcon?: boolean
defaultInputClass?: string
}
const props = withDefaults(defineProps<Props>(), {
modelValue: () => new Date(),
contentLoading: false,
placeholder: null,
invalid: false,
disabled: false,
containerClass: '',
clockIcon: true,
defaultInputClass:
'font-base pl-8 py-2 outline-hidden focus:ring-primary-400 focus:outline-hidden focus:border-primary-400 block w-full sm:text-sm border-line-strong rounded-md text-heading',
})
interface Emits {
(e: 'update:modelValue', value: string | Date): void
}
const emit = defineEmits<Emits>()
const slots = useSlots()
interface TimePickerConfig {
enableTime: boolean
noCalendar: boolean
dateFormat: string
time_24hr: boolean
}
const config = reactive<TimePickerConfig>({
enableTime: true,
noCalendar: true,
dateFormat: 'H:i',
time_24hr: true,
})
const time = computed<string | Date>({
get: () => props.modelValue,
set: (value: string | Date) => emit('update:modelValue', value),
})
const hasIconSlot = computed<boolean>(() => {
return !!slots.icon
})
function onClickPicker(): void {
dpt.value?.fp.open()
}
const computedContainerClass = computed<string>(() => {
const containerClass = `${props.containerClass} `
return containerClass
})
const inputInvalidClass = computed<string>(() => {
if (props.invalid) {
return 'border-red-400 ring-red-400 focus:ring-red-400 focus:border-red-400'
}
return ''
})
const inputDisabledClass = computed<string>(() => {
if (props.disabled) {
return 'border border-solid rounded-md outline-hidden input-field box-border-2 base-date-picker-input placeholder-subtle bg-surface-muted text-body border-line-strong'
}
return ''
})
</script>