pukaad-ui-lib 1.70.0 → 1.72.0

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.70.0",
4
+ "version": "1.72.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,18 +1,19 @@
1
- import type { ChipProps, ChipColor, ChipSize } from "@/types/components/chip";
2
- declare var __VLS_1: {};
1
+ type ChipColor = "default" | "primary" | "success" | "warning" | "error" | "outline";
2
+ interface ChipProps {
3
+ color?: ChipColor;
4
+ closable?: boolean;
5
+ }
6
+ declare var __VLS_8: {};
3
7
  type __VLS_Slots = {} & {
4
- default?: (props: typeof __VLS_1) => any;
8
+ default?: (props: typeof __VLS_8) => any;
5
9
  };
6
10
  declare const __VLS_base: import("vue").DefineComponent<ChipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
11
  closable: () => any;
8
12
  }, string, import("vue").PublicProps, Readonly<ChipProps> & Readonly<{
9
13
  onClosable?: (() => any) | undefined;
10
14
  }>, {
11
- size: ChipSize;
12
- flat: boolean;
13
15
  color: ChipColor;
14
16
  closable: boolean;
15
- autoHeight: boolean;
16
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
18
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
18
19
  declare const _default: typeof __VLS_export;
@@ -1,13 +1,5 @@
1
1
  <template>
2
- <div
3
- :class="[
4
- 'rounded-full px-[8px] py-[4px] font-body-large inline-flex gap-[4px] justify-center items-center',
5
- !props.flat && 'border-[1px]',
6
- props.autoHeight ? 'break-all' : height,
7
- color,
8
- size
9
- ]"
10
- >
2
+ <Badge :variant="variant" class="gap-1">
11
3
  <slot name="default" />
12
4
  <div
13
5
  v-if="props.closable"
@@ -16,44 +8,26 @@
16
8
  >
17
9
  <Icon name="fa6-solid:xmark" size="16" />
18
10
  </div>
19
- </div>
11
+ </Badge>
20
12
  </template>
21
13
 
22
14
  <script setup>
23
15
  import { computed } from "vue";
16
+ import Badge from "@/runtime/components/ui/badge/Badge.vue";
24
17
  const emit = defineEmits(["closable"]);
25
18
  const props = defineProps({
26
19
  color: { type: String, required: false, default: "default" },
27
- flat: { type: Boolean, required: false, default: false },
28
- closable: { type: Boolean, required: false, default: false },
29
- autoHeight: { type: Boolean, required: false, default: false },
30
- size: { type: String, required: false, default: "medium" }
20
+ closable: { type: Boolean, required: false, default: false }
31
21
  });
32
- const color = computed(() => {
33
- const colors = {
34
- default: props.flat ? "border-gray bg-mercury" : "border-gray bg-white",
35
- primary: "border-primary bg-info text-primary",
36
- success: "border-success bg-green-light text-success",
37
- warning: "border-warning bg-yellow-light text-warning",
38
- error: "border-error bg-red-light text-error"
22
+ const variant = computed(() => {
23
+ const colorToVariant = {
24
+ default: "default",
25
+ primary: "primary",
26
+ success: "success",
27
+ warning: "warning",
28
+ error: "destructive",
29
+ outline: "outline"
39
30
  };
40
- return colors[props.color];
41
- });
42
- const height = computed(() => {
43
- const sizes = {
44
- tiny: "h-[24px]",
45
- small: "h-[32px]",
46
- medium: "h-[40px]",
47
- large: "h-[48px]",
48
- "x-large": "h-[52px]"
49
- };
50
- return sizes[props.size];
51
- });
52
- const size = computed(() => {
53
- if (props.size === "tiny") {
54
- return "font-body-small";
55
- } else {
56
- return "font-body-large";
57
- }
31
+ return colorToVariant[props.color];
58
32
  });
59
33
  </script>
@@ -1,18 +1,19 @@
1
- import type { ChipProps, ChipColor, ChipSize } from "@/types/components/chip";
2
- declare var __VLS_1: {};
1
+ type ChipColor = "default" | "primary" | "success" | "warning" | "error" | "outline";
2
+ interface ChipProps {
3
+ color?: ChipColor;
4
+ closable?: boolean;
5
+ }
6
+ declare var __VLS_8: {};
3
7
  type __VLS_Slots = {} & {
4
- default?: (props: typeof __VLS_1) => any;
8
+ default?: (props: typeof __VLS_8) => any;
5
9
  };
6
10
  declare const __VLS_base: import("vue").DefineComponent<ChipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
11
  closable: () => any;
8
12
  }, string, import("vue").PublicProps, Readonly<ChipProps> & Readonly<{
9
13
  onClosable?: (() => any) | undefined;
10
14
  }>, {
11
- size: ChipSize;
12
- flat: boolean;
13
15
  color: ChipColor;
14
16
  closable: boolean;
15
- autoHeight: boolean;
16
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
18
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
18
19
  declare const _default: typeof __VLS_export;
@@ -38,7 +38,7 @@
38
38
  </div>
39
39
  <template #footer="{ meta }">
40
40
  <div class="flex justify-end gap-[16px] items-center">
41
- <Button type="outline" @click="onClose"> ยกเลิก </Button>
41
+ <Button variant="outline" @click="onClose"> ยกเลิก </Button>
42
42
  <Button type="submit" color="primary" :disabled="!meta.valid">
43
43
  ยืนยัน
44
44
  </Button>
@@ -82,14 +82,7 @@ watch(isDrawerOpen, (newVal) => {
82
82
  const onClose = async () => {
83
83
  const isModified = JSON.stringify(form.value) !== JSON.stringify(props.item);
84
84
  if (isModified) {
85
- const { isConfirmed } = await $alert.show({
86
- type: "warning",
87
- title: "\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E2D\u0E2D\u0E01\u0E08\u0E32\u0E01\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48 ?",
88
- description: "\u0E01\u0E32\u0E23\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01 \u0E04\u0E38\u0E13\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E25\u0E30\u0E17\u0E34\u0E49\u0E07\u0E01\u0E32\u0E23\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48 ?",
89
- confirmText: "\u0E25\u0E30\u0E17\u0E34\u0E49\u0E07",
90
- cancelText: "\u0E41\u0E01\u0E49\u0E44\u0E02\u0E15\u0E48\u0E2D",
91
- showCancelBtn: true
92
- });
85
+ const isConfirmed = await $alert.confirmUnsavedChanges();
93
86
  if (isConfirmed) {
94
87
  isDrawerOpen.value = false;
95
88
  }
@@ -48,8 +48,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
48
48
  label: string;
49
49
  required: boolean;
50
50
  name: string;
51
- placeholder: string;
52
51
  gap: string;
52
+ placeholder: string;
53
53
  labelDetail: string;
54
54
  placeholderDetail: string;
55
55
  requiredDetail: boolean;
@@ -48,8 +48,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
48
48
  label: string;
49
49
  required: boolean;
50
50
  name: string;
51
- placeholder: string;
52
51
  gap: string;
52
+ placeholder: string;
53
53
  labelDetail: string;
54
54
  placeholderDetail: string;
55
55
  requiredDetail: boolean;
@@ -35,9 +35,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
35
35
  required: boolean;
36
36
  id: string;
37
37
  name: string;
38
- placeholder: string;
39
38
  description: string;
40
39
  options: AutocompleteOption[] | string[] | number[];
40
+ placeholder: string;
41
41
  limit: number;
42
42
  disabledErrorMessage: boolean;
43
43
  disabledBorder: boolean;
@@ -35,9 +35,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
35
35
  required: boolean;
36
36
  id: string;
37
37
  name: string;
38
- placeholder: string;
39
38
  description: string;
40
39
  options: AutocompleteOption[] | string[] | number[];
40
+ placeholder: string;
41
41
  limit: number;
42
42
  disabledErrorMessage: boolean;
43
43
  disabledBorder: boolean;
@@ -29,8 +29,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
29
29
  required: boolean;
30
30
  id: string;
31
31
  name: string;
32
- placeholder: string;
33
32
  disabled: boolean;
33
+ placeholder: string;
34
34
  disabledErrorMessage: boolean;
35
35
  locale: string;
36
36
  layout: "month-and-year" | "month-only" | "year-only";
@@ -29,8 +29,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
29
29
  required: boolean;
30
30
  id: string;
31
31
  name: string;
32
- placeholder: string;
33
32
  disabled: boolean;
33
+ placeholder: string;
34
34
  disabledErrorMessage: boolean;
35
35
  locale: string;
36
36
  layout: "month-and-year" | "month-only" | "year-only";
@@ -39,8 +39,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
39
39
  required: boolean;
40
40
  id: string;
41
41
  name: string;
42
- placeholder: string;
43
42
  disabled: boolean;
43
+ placeholder: string;
44
44
  disabledErrorMessage: boolean;
45
45
  locale: string;
46
46
  layout: "month-and-year" | "month-only" | "year-only";
@@ -39,8 +39,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
39
39
  required: boolean;
40
40
  id: string;
41
41
  name: string;
42
- placeholder: string;
43
42
  disabled: boolean;
43
+ placeholder: string;
44
44
  disabledErrorMessage: boolean;
45
45
  locale: string;
46
46
  layout: "month-and-year" | "month-only" | "year-only";
@@ -0,0 +1,20 @@
1
+ import type { PrimitiveProps } from "reka-ui";
2
+ import type { HTMLAttributes } from "vue";
3
+ import type { BadgeVariants } from ".";
4
+ type __VLS_Props = PrimitiveProps & {
5
+ variant?: BadgeVariants["variant"];
6
+ class?: HTMLAttributes["class"];
7
+ };
8
+ declare var __VLS_8: {};
9
+ type __VLS_Slots = {} & {
10
+ default?: (props: typeof __VLS_8) => any;
11
+ };
12
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
16
+ type __VLS_WithSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import { reactiveOmit } from "@vueuse/core";
3
+ import { Primitive } from "reka-ui";
4
+ import { cn } from "@/runtime/plugins/shadcn";
5
+ import { badgeVariants } from ".";
6
+ const props = defineProps({
7
+ asChild: { type: Boolean, required: false },
8
+ as: { type: null, required: false },
9
+ variant: { type: null, required: false },
10
+ class: { type: null, required: false }
11
+ });
12
+ const delegatedProps = reactiveOmit(props, "class");
13
+ </script>
14
+
15
+ <template>
16
+ <Primitive
17
+ data-slot="badge"
18
+ :class="cn(badgeVariants({ variant }), props.class)"
19
+ v-bind="delegatedProps"
20
+ >
21
+ <slot />
22
+ </Primitive>
23
+ </template>
@@ -0,0 +1,20 @@
1
+ import type { PrimitiveProps } from "reka-ui";
2
+ import type { HTMLAttributes } from "vue";
3
+ import type { BadgeVariants } from ".";
4
+ type __VLS_Props = PrimitiveProps & {
5
+ variant?: BadgeVariants["variant"];
6
+ class?: HTMLAttributes["class"];
7
+ };
8
+ declare var __VLS_8: {};
9
+ type __VLS_Slots = {} & {
10
+ default?: (props: typeof __VLS_8) => any;
11
+ };
12
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
16
+ type __VLS_WithSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,6 @@
1
+ import type { VariantProps } from "class-variance-authority";
2
+ export { default as Badge } from "./Badge.vue.js";
3
+ export declare const badgeVariants: (props?: ({
4
+ variant?: "default" | "outline" | "primary" | "secondary" | "destructive" | "success" | "warning" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ export type BadgeVariants = VariantProps<typeof badgeVariants>;
@@ -0,0 +1,21 @@
1
+ import { cva } from "class-variance-authority";
2
+ export { default as Badge } from "./Badge.vue";
3
+ export const badgeVariants = cva(
4
+ "inline-flex items-center justify-center rounded-full border px-[12px] py-[6px] font-body-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
5
+ {
6
+ variants: {
7
+ variant: {
8
+ default: "border-transparent bg-white [a&]:hover:bg-white/90",
9
+ primary: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
10
+ secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
11
+ destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
12
+ success: "border-success bg-green-light text-success [a&]:hover:bg-green-light/80",
13
+ warning: "border-warning bg-yellow-light text-warning [a&]:hover:bg-yellow-light/80",
14
+ outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground "
15
+ }
16
+ },
17
+ defaultVariants: {
18
+ variant: "default"
19
+ }
20
+ }
21
+ );
@@ -1,12 +1,12 @@
1
1
  import type { PinInputRootProps } from "reka-ui";
2
2
  import type { HTMLAttributes } from "vue";
3
3
  declare const __VLS_export: <Type extends "text" | "number" = "text">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
- props: __VLS_PrettifyLocal<(PinInputRootProps<Type> & {
4
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(PinInputRootProps<Type> & {
5
5
  class?: HTMLAttributes["class"];
6
6
  }) & {
7
7
  "onUpdate:modelValue"?: ((value: [Type] extends ["number"] ? number[] : string[]) => any) | undefined;
8
8
  onComplete?: ((value: [Type] extends ["number"] ? number[] : string[]) => any) | undefined;
9
- }> & import("vue").PublicProps & (typeof globalThis extends {
9
+ }> & (typeof globalThis extends {
10
10
  __VLS_PROPS_FALLBACK: infer P;
11
11
  } ? P : {});
12
12
  expose: (exposed: {}) => void;
@@ -1,12 +1,12 @@
1
1
  import type { PinInputRootProps } from "reka-ui";
2
2
  import type { HTMLAttributes } from "vue";
3
3
  declare const __VLS_export: <Type extends "text" | "number" = "text">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
- props: __VLS_PrettifyLocal<(PinInputRootProps<Type> & {
4
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(PinInputRootProps<Type> & {
5
5
  class?: HTMLAttributes["class"];
6
6
  }) & {
7
7
  "onUpdate:modelValue"?: ((value: [Type] extends ["number"] ? number[] : string[]) => any) | undefined;
8
8
  onComplete?: ((value: [Type] extends ["number"] ? number[] : string[]) => any) | undefined;
9
- }> & import("vue").PublicProps & (typeof globalThis extends {
9
+ }> & (typeof globalThis extends {
10
10
  __VLS_PROPS_FALLBACK: infer P;
11
11
  } ? P : {});
12
12
  expose: (exposed: {}) => void;
@@ -34,6 +34,7 @@ const props = defineProps({
34
34
  reference: { type: null, required: false },
35
35
  asChild: { type: Boolean, required: false },
36
36
  as: { type: null, required: false },
37
+ disableOutsidePointerEvents: { type: Boolean, required: false },
37
38
  class: { type: null, required: false }
38
39
  });
39
40
  const emits = defineEmits(["closeAutoFocus", "escapeKeyDown", "pointerDownOutside"]);
@@ -13,6 +13,11 @@ export interface AlertResponse {
13
13
  }
14
14
  export declare class Alert {
15
15
  show(options?: AlertOptions): Promise<AlertResponse>;
16
+ /**
17
+ * แสดง alert ยืนยันการออกจากหน้าที่มีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก
18
+ * @returns Promise<boolean> - true ถ้าผู้ใช้กด "ละทิ้ง", false ถ้ากด "แก้ไขต่อ"
19
+ */
20
+ confirmUnsavedChanges(): Promise<boolean>;
16
21
  }
17
22
  declare const _default: import("nuxt/app").Plugin<{
18
23
  alert: Alert;
@@ -106,6 +106,21 @@ export class Alert {
106
106
  app.mount(div);
107
107
  });
108
108
  }
109
+ /**
110
+ * แสดง alert ยืนยันการออกจากหน้าที่มีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก
111
+ * @returns Promise<boolean> - true ถ้าผู้ใช้กด "ละทิ้ง", false ถ้ากด "แก้ไขต่อ"
112
+ */
113
+ async confirmUnsavedChanges() {
114
+ const result = await this.show({
115
+ type: "warning",
116
+ title: "\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E2D\u0E2D\u0E01\u0E08\u0E32\u0E01\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48 ?",
117
+ description: "\u0E01\u0E32\u0E23\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01 \u0E04\u0E38\u0E13\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E25\u0E30\u0E17\u0E34\u0E49\u0E07\u0E01\u0E32\u0E23\u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E41\u0E1B\u0E25\u0E07\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48 ?",
118
+ confirmText: "\u0E25\u0E30\u0E17\u0E34\u0E49\u0E07",
119
+ cancelText: "\u0E41\u0E01\u0E49\u0E44\u0E02\u0E15\u0E48\u0E2D",
120
+ showCancelBtn: true
121
+ });
122
+ return result.isConfirmed;
123
+ }
109
124
  }
110
125
  export default defineNuxtPlugin(() => {
111
126
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.70.0",
3
+ "version": "1.72.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,7 +57,7 @@
57
57
  "pinia-plugin-persistedstate": "^4.4.1",
58
58
  "quill": "^2.0.3",
59
59
  "quill-delta-to-html": "^0.12.1",
60
- "reka-ui": "^2.6.1",
60
+ "reka-ui": "^2.7.0",
61
61
  "shadcn-nuxt": "^2.3.3",
62
62
  "shadcn-vue": "^2.3.2",
63
63
  "tailwind-merge": "^3.4.0",
@@ -88,4 +88,4 @@
88
88
  "@types/vue-cropperjs": "^4.1.6",
89
89
  "@vue/compiler-sfc": "^3.5.24"
90
90
  }
91
- }
91
+ }