pukaad-ui-lib 1.33.0 → 1.34.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.33.0",
4
+ "version": "1.34.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -37,8 +37,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
37
37
  name: string;
38
38
  placeholder: string;
39
39
  description: string;
40
- limit: number;
41
40
  options: AutocompleteOption[] | string[] | number[];
41
+ limit: number;
42
42
  disabledErrorMessage: boolean;
43
43
  disabledBorder: boolean;
44
44
  showCounter: boolean;
@@ -37,8 +37,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
37
37
  name: string;
38
38
  placeholder: string;
39
39
  description: string;
40
- limit: number;
41
40
  options: AutocompleteOption[] | string[] | number[];
41
+ limit: number;
42
42
  disabledErrorMessage: boolean;
43
43
  disabledBorder: boolean;
44
44
  showCounter: boolean;
@@ -0,0 +1,42 @@
1
+ import type { HTMLAttributes } from "vue";
2
+ import type { LayoutTypes } from "@/runtime/components/ui/calendar";
3
+ export interface InputBirthDateProps {
4
+ id?: string;
5
+ name?: string;
6
+ disabled?: boolean;
7
+ label?: string;
8
+ placeholder?: string;
9
+ description?: string;
10
+ disabledErrorMessage?: boolean;
11
+ required?: boolean;
12
+ dateFormat?: string;
13
+ locale?: string;
14
+ layout?: LayoutTypes;
15
+ class?: HTMLAttributes["class"];
16
+ minAge?: number;
17
+ maxYearsBack?: number;
18
+ }
19
+ type __VLS_Props = InputBirthDateProps;
20
+ type __VLS_ModelProps = {
21
+ modelValue?: Date | undefined;
22
+ };
23
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
24
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ "update:modelValue": (value: Date | undefined) => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
27
+ "onUpdate:modelValue"?: ((value: Date | undefined) => any) | undefined;
28
+ }>, {
29
+ required: boolean;
30
+ id: string;
31
+ name: string;
32
+ placeholder: string;
33
+ disabled: boolean;
34
+ disabledErrorMessage: boolean;
35
+ locale: string;
36
+ layout: "month-and-year" | "month-only" | "year-only";
37
+ dateFormat: string;
38
+ minAge: number;
39
+ maxYearsBack: number;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
41
+ declare const _default: typeof __VLS_export;
42
+ export default _default;
@@ -0,0 +1,74 @@
1
+ <template>
2
+ <InputDatePicker
3
+ v-model="modelValue"
4
+ :id="props.id"
5
+ :name="props.name"
6
+ :label="props.label"
7
+ :placeholder="props.placeholder"
8
+ :disabled="props.disabled"
9
+ :required="props.required"
10
+ :description="props.description"
11
+ :disabled-error-message="props.disabledErrorMessage"
12
+ :date-format="props.dateFormat"
13
+ :locale="props.locale"
14
+ :layout="props.layout"
15
+ :max-value="today"
16
+ :min-value="minDate"
17
+ :rules="birthDateRules"
18
+ :class="props.class"
19
+ />
20
+ </template>
21
+
22
+ <script setup>
23
+ import { computed } from "vue";
24
+ const props = defineProps({
25
+ id: { type: String, required: false, default: "input-birth-date" },
26
+ name: { type: String, required: false, default: "input-birth-date" },
27
+ disabled: { type: Boolean, required: false, default: false },
28
+ label: { type: String, required: false },
29
+ placeholder: { type: String, required: false, default: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E27\u0E31\u0E19\u0E40\u0E01\u0E34\u0E14" },
30
+ description: { type: String, required: false },
31
+ disabledErrorMessage: { type: Boolean, required: false, default: false },
32
+ required: { type: Boolean, required: false, default: false },
33
+ dateFormat: { type: String, required: false, default: "D MMMM BBBB" },
34
+ locale: { type: String, required: false, default: "th" },
35
+ layout: { type: null, required: false, default: "month-and-year" },
36
+ class: { type: null, required: false },
37
+ minAge: { type: Number, required: false, default: 13 },
38
+ maxYearsBack: { type: Number, required: false, default: 100 }
39
+ });
40
+ const modelValue = defineModel({ type: null, ...{ default: void 0 } });
41
+ const today = computed(() => /* @__PURE__ */ new Date());
42
+ const minDate = computed(() => {
43
+ const date = /* @__PURE__ */ new Date();
44
+ date.setFullYear(date.getFullYear() - props.maxYearsBack);
45
+ return date;
46
+ });
47
+ const birthDateRules = (v) => {
48
+ if (!v && props.required) {
49
+ return `\u0E01\u0E23\u0E38\u0E13\u0E32\u0E40\u0E25\u0E37\u0E2D\u0E01${props.label || "\u0E27\u0E31\u0E19\u0E40\u0E01\u0E34\u0E14"}`;
50
+ }
51
+ if (v) {
52
+ const now = /* @__PURE__ */ new Date();
53
+ if (v > now) {
54
+ return "\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
55
+ }
56
+ const minAllowedDate = /* @__PURE__ */ new Date();
57
+ minAllowedDate.setFullYear(
58
+ minAllowedDate.getFullYear() - props.maxYearsBack
59
+ );
60
+ if (v < minAllowedDate) {
61
+ return "\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
62
+ }
63
+ const ageDate = new Date(
64
+ now.getFullYear() - props.minAge,
65
+ now.getMonth(),
66
+ now.getDate()
67
+ );
68
+ if (v > ageDate) {
69
+ return `\u0E1C\u0E39\u0E49\u0E43\u0E0A\u0E49\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35\u0E2D\u0E32\u0E22\u0E38\u0E44\u0E21\u0E48\u0E15\u0E48\u0E33\u0E01\u0E27\u0E48\u0E32 ${props.minAge} \u0E1B\u0E35`;
70
+ }
71
+ }
72
+ return true;
73
+ };
74
+ </script>
@@ -0,0 +1,42 @@
1
+ import type { HTMLAttributes } from "vue";
2
+ import type { LayoutTypes } from "@/runtime/components/ui/calendar";
3
+ export interface InputBirthDateProps {
4
+ id?: string;
5
+ name?: string;
6
+ disabled?: boolean;
7
+ label?: string;
8
+ placeholder?: string;
9
+ description?: string;
10
+ disabledErrorMessage?: boolean;
11
+ required?: boolean;
12
+ dateFormat?: string;
13
+ locale?: string;
14
+ layout?: LayoutTypes;
15
+ class?: HTMLAttributes["class"];
16
+ minAge?: number;
17
+ maxYearsBack?: number;
18
+ }
19
+ type __VLS_Props = InputBirthDateProps;
20
+ type __VLS_ModelProps = {
21
+ modelValue?: Date | undefined;
22
+ };
23
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
24
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ "update:modelValue": (value: Date | undefined) => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
27
+ "onUpdate:modelValue"?: ((value: Date | undefined) => any) | undefined;
28
+ }>, {
29
+ required: boolean;
30
+ id: string;
31
+ name: string;
32
+ placeholder: string;
33
+ disabled: boolean;
34
+ disabledErrorMessage: boolean;
35
+ locale: string;
36
+ layout: "month-and-year" | "month-only" | "year-only";
37
+ dateFormat: string;
38
+ minAge: number;
39
+ maxYearsBack: number;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
41
+ declare const _default: typeof __VLS_export;
42
+ export default _default;
@@ -1,3 +1,4 @@
1
+ import type { DateValue } from "reka-ui";
1
2
  import type { HTMLAttributes } from "vue";
2
3
  import type { LayoutTypes } from "@/runtime/components/ui/calendar";
3
4
  export interface InputDatePickerProps {
@@ -15,6 +16,9 @@ export interface InputDatePickerProps {
15
16
  layout?: LayoutTypes;
16
17
  showTime?: boolean;
17
18
  class?: HTMLAttributes["class"];
19
+ maxValue?: Date;
20
+ minValue?: Date;
21
+ isDateDisabled?: (date: DateValue) => boolean;
18
22
  }
19
23
  type __VLS_Props = InputDatePickerProps;
20
24
  type __VLS_ModelProps = {
@@ -27,7 +27,7 @@
27
27
  cn(
28
28
  'w-full flex items-center justify-between gap-2 font-body-large',
29
29
  !modelValue && 'text-muted-foreground',
30
- errorMessage && 'border-destructive',
30
+ errorMessage && 'border-destructive hover:border-destructive',
31
31
  props.class
32
32
  )
33
33
  "
@@ -44,6 +44,9 @@
44
44
  initial-focus
45
45
  :locale="locale"
46
46
  :layout="layout"
47
+ :max-value="maxCalendarValue"
48
+ :min-value="minCalendarValue"
49
+ :is-date-disabled="props.isDateDisabled"
47
50
  />
48
51
  <!-- Time Picker -->
49
52
  <div
@@ -126,7 +129,26 @@ const props = defineProps({
126
129
  locale: { type: String, required: false, default: "th" },
127
130
  layout: { type: null, required: false, default: "month-and-year" },
128
131
  showTime: { type: Boolean, required: false, default: false },
129
- class: { type: null, required: false }
132
+ class: { type: null, required: false },
133
+ maxValue: { type: Date, required: false },
134
+ minValue: { type: Date, required: false },
135
+ isDateDisabled: { type: Function, required: false }
136
+ });
137
+ const maxCalendarValue = computed(() => {
138
+ if (!props.maxValue) return void 0;
139
+ return new CalendarDate(
140
+ props.maxValue.getFullYear(),
141
+ props.maxValue.getMonth() + 1,
142
+ props.maxValue.getDate()
143
+ );
144
+ });
145
+ const minCalendarValue = computed(() => {
146
+ if (!props.minValue) return void 0;
147
+ return new CalendarDate(
148
+ props.minValue.getFullYear(),
149
+ props.minValue.getMonth() + 1,
150
+ props.minValue.getDate()
151
+ );
130
152
  });
131
153
  const modelValue = defineModel({ type: null, ...{ default: void 0 } });
132
154
  const fieldRef = ref();
@@ -1,3 +1,4 @@
1
+ import type { DateValue } from "reka-ui";
1
2
  import type { HTMLAttributes } from "vue";
2
3
  import type { LayoutTypes } from "@/runtime/components/ui/calendar";
3
4
  export interface InputDatePickerProps {
@@ -15,6 +16,9 @@ export interface InputDatePickerProps {
15
16
  layout?: LayoutTypes;
16
17
  showTime?: boolean;
17
18
  class?: HTMLAttributes["class"];
19
+ maxValue?: Date;
20
+ minValue?: Date;
21
+ isDateDisabled?: (date: DateValue) => boolean;
18
22
  }
19
23
  type __VLS_Props = InputDatePickerProps;
20
24
  type __VLS_ModelProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.33.0",
3
+ "version": "1.34.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",