From 1cbde57cf955ae8665e4649c6d5b4a4c0b68c830 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Sun, 16 Nov 2025 00:44:53 +0700 Subject: [PATCH] dev: hotfix comps/pub/myui + updated data/types + updated data-table + updated nav-header + added toggle comps/pub/ui + updated button + updated toggle --- .../pub/my-ui/data-table/data-table.vue | 4 +-- app/components/pub/my-ui/data/types.ts | 3 +- app/components/pub/my-ui/nav-header/prep.vue | 15 ++++++-- .../pub/my-ui/toggle/provided-toggle.vue | 34 +++++++++++++++++++ app/components/pub/ui/button/index.ts | 2 +- app/components/pub/ui/toggle/index.ts | 6 ++-- 6 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 app/components/pub/my-ui/toggle/provided-toggle.vue diff --git a/app/components/pub/my-ui/data-table/data-table.vue b/app/components/pub/my-ui/data-table/data-table.vue index f3e2ef43..431df276 100644 --- a/app/components/pub/my-ui/data-table/data-table.vue +++ b/app/components/pub/my-ui/data-table/data-table.vue @@ -22,7 +22,7 @@ const selected = ref([]) function toggleSelection(row: any, event?: Event) { if (event) event.stopPropagation() // cegah event bubble ke TableRow - const isMultiple = props.selectMode === 'multi' || props.selectMode === 'multiple' + const isMultiple = props.selectMode === 'multiple' // props.selectMode === 'multi' || // gunakan pembanding berdasarkan id atau stringify data const findIndex = selected.value.findIndex((r) => JSON.stringify(r) === JSON.stringify(row)) @@ -128,7 +128,7 @@ function handleActionCellClick(event: Event, _cellRef: string) { 'bg-green-50': props.selectMode === 'single' && selected.some((r) => JSON.stringify(r) === JSON.stringify(row)), 'bg-blue-50': - (props.selectMode === 'multi' || props.selectMode === 'multiple') && + (props.selectMode === 'multiple') && // props.selectMode === 'multi' || selected.some((r) => JSON.stringify(r) === JSON.stringify(row)), }" @click="toggleSelection(row)" diff --git a/app/components/pub/my-ui/data/types.ts b/app/components/pub/my-ui/data/types.ts index c0d283de..a9b2586b 100644 --- a/app/components/pub/my-ui/data/types.ts +++ b/app/components/pub/my-ui/data/types.ts @@ -8,6 +8,7 @@ export interface ListItemDto { } export type ComponentType = Component +export type ComponentWithProps = { component: Component, props: Record } export interface ButtonNav { variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' @@ -45,13 +46,13 @@ export interface RefSearchNav { export interface HeaderPrep { title?: string icon?: string + components?: ComponentWithProps[] refSearchNav?: RefSearchNav quickSearchNav?: QuickSearchNav filterNav?: ButtonNav addNav?: ButtonNav printNav?: ButtonNav } - export interface KeyLabel { key: string label: string diff --git a/app/components/pub/my-ui/nav-header/prep.vue b/app/components/pub/my-ui/nav-header/prep.vue index 63535847..7aa5e4f2 100644 --- a/app/components/pub/my-ui/nav-header/prep.vue +++ b/app/components/pub/my-ui/nav-header/prep.vue @@ -30,15 +30,24 @@ function btnClick() {
- {{ props.prep.title }} + {{ prep.title }}
+
+ +
+import { ref, inject } from "vue" +// import Toggle from '~/components/pub/ui/toggle/Toggle.vue' + +const props = defineProps<{ + label: string, + providedKey?: string, + variant?: 'default' | 'outline' | null | undefined +}>() + +const model = defineModel() +const provideKey = props.providedKey || 'toggle-provide' +const { updateProvidedVal } = inject(provideKey) + +watch(model, (newVal) => { + updateProvidedVal(newVal) +}) + + + diff --git a/app/components/pub/ui/button/index.ts b/app/components/pub/ui/button/index.ts index c4063089..43c75876 100644 --- a/app/components/pub/ui/button/index.ts +++ b/app/components/pub/ui/button/index.ts @@ -19,7 +19,7 @@ export const buttonVariants = cva( link: 'text-primary underline-offset-4 hover:underline', }, size: { - default: 'md:h8 2xl:h-9 px-4 py-2', + default: 'md:h-8 2xl:h-9 px-4 py-2', xs: 'h-7 rounded px-2', sm: 'h-8 rounded-md px-3 text-xs', lg: 'h-10 rounded-md px-8', diff --git a/app/components/pub/ui/toggle/index.ts b/app/components/pub/ui/toggle/index.ts index 07acae50..9486e903 100644 --- a/app/components/pub/ui/toggle/index.ts +++ b/app/components/pub/ui/toggle/index.ts @@ -4,16 +4,16 @@ import { cva } from 'class-variance-authority' export { default as Toggle } from './Toggle.vue' export const toggleVariants = cva( - 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground', + 'inline-flex items-center justify-center rounded-md text-xs 2xl:text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground', { variants: { variant: { default: 'bg-transparent', outline: - 'border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground', + 'border border-slate-300 bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground', }, size: { - default: 'h-9 px-3', + default: 'md:h-8 2xl:h-9 px-3', sm: 'h-8 px-2', lg: 'h-10 px-3', },