pukaad-ui-lib 1.78.0 → 1.80.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 +1 -1
- package/dist/runtime/components/input/input-birth-date.vue +11 -0
- package/dist/runtime/components/input/input-date-picker.d.vue.ts +2 -0
- package/dist/runtime/components/input/input-date-picker.vue +5 -1
- package/dist/runtime/components/input/input-date-picker.vue.d.ts +2 -0
- package/dist/runtime/components/input/input-email.vue +1 -0
- package/dist/runtime/components/input/input-password.vue +1 -0
- package/dist/runtime/components/input/input-phone.vue +18 -2
- package/dist/runtime/components/input/input-text-field.d.vue.ts +1 -0
- package/dist/runtime/components/input/input-text-field.vue +2 -0
- package/dist/runtime/components/input/input-text-field.vue.d.ts +1 -0
- package/dist/runtime/components/ui/calendar/Calendar.d.vue.ts +2 -0
- package/dist/runtime/components/ui/calendar/Calendar.vue +77 -27
- package/dist/runtime/components/ui/calendar/Calendar.vue.d.ts +2 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
:max-value="today"
|
|
16
16
|
:min-value="minDate"
|
|
17
17
|
:rules="birthDateRules"
|
|
18
|
+
:default-placeholder="defaultPlaceholder"
|
|
19
|
+
:reverse-years="true"
|
|
18
20
|
:class="props.class"
|
|
19
21
|
/>
|
|
20
22
|
</template>
|
|
21
23
|
|
|
22
24
|
<script setup>
|
|
23
25
|
import { computed } from "vue";
|
|
26
|
+
import { CalendarDate } from "@internationalized/date";
|
|
24
27
|
const props = defineProps({
|
|
25
28
|
id: { type: String, required: false, default: "input-birth-date" },
|
|
26
29
|
name: { type: String, required: false, default: "input-birth-date" },
|
|
@@ -44,6 +47,14 @@ const minDate = computed(() => {
|
|
|
44
47
|
date.setFullYear(date.getFullYear() - props.maxYearsBack);
|
|
45
48
|
return date;
|
|
46
49
|
});
|
|
50
|
+
const defaultPlaceholder = computed(() => {
|
|
51
|
+
const date = /* @__PURE__ */ new Date();
|
|
52
|
+
return new CalendarDate(
|
|
53
|
+
date.getFullYear() - props.minAge,
|
|
54
|
+
date.getMonth() + 1,
|
|
55
|
+
date.getDate()
|
|
56
|
+
);
|
|
57
|
+
});
|
|
47
58
|
const birthDateRules = (v) => {
|
|
48
59
|
if (!v && props.required) {
|
|
49
60
|
return `\u0E01\u0E23\u0E38\u0E13\u0E32\u0E40\u0E25\u0E37\u0E2D\u0E01${props.label || "\u0E27\u0E31\u0E19\u0E40\u0E01\u0E34\u0E14"}`;
|
|
@@ -19,6 +19,8 @@ export interface InputDatePickerProps {
|
|
|
19
19
|
maxValue?: Date;
|
|
20
20
|
minValue?: Date;
|
|
21
21
|
isDateDisabled?: (date: DateValue) => boolean;
|
|
22
|
+
defaultPlaceholder?: DateValue;
|
|
23
|
+
reverseYears?: boolean;
|
|
22
24
|
}
|
|
23
25
|
type __VLS_Props = InputDatePickerProps;
|
|
24
26
|
type __VLS_ModelProps = {
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
:max-value="maxCalendarValue"
|
|
47
47
|
:min-value="minCalendarValue"
|
|
48
48
|
:is-date-disabled="props.isDateDisabled"
|
|
49
|
+
:default-placeholder="props.defaultPlaceholder"
|
|
50
|
+
:reverse-years="props.reverseYears"
|
|
49
51
|
/>
|
|
50
52
|
<!-- Time Picker -->
|
|
51
53
|
<div
|
|
@@ -131,7 +133,9 @@ const props = defineProps({
|
|
|
131
133
|
class: { type: null, required: false },
|
|
132
134
|
maxValue: { type: Date, required: false },
|
|
133
135
|
minValue: { type: Date, required: false },
|
|
134
|
-
isDateDisabled: { type: Function, required: false }
|
|
136
|
+
isDateDisabled: { type: Function, required: false },
|
|
137
|
+
defaultPlaceholder: { type: null, required: false },
|
|
138
|
+
reverseYears: { type: Boolean, required: false }
|
|
135
139
|
});
|
|
136
140
|
const maxCalendarValue = computed(() => {
|
|
137
141
|
if (!props.maxValue) return void 0;
|
|
@@ -19,6 +19,8 @@ export interface InputDatePickerProps {
|
|
|
19
19
|
maxValue?: Date;
|
|
20
20
|
minValue?: Date;
|
|
21
21
|
isDateDisabled?: (date: DateValue) => boolean;
|
|
22
|
+
defaultPlaceholder?: DateValue;
|
|
23
|
+
reverseYears?: boolean;
|
|
22
24
|
}
|
|
23
25
|
type __VLS_Props = InputDatePickerProps;
|
|
24
26
|
type __VLS_ModelProps = {
|
|
@@ -32,6 +32,7 @@ const props = defineProps({
|
|
|
32
32
|
iconAppend: { type: String, required: false },
|
|
33
33
|
showCounter: { type: Boolean, required: false },
|
|
34
34
|
limit: { type: Number, required: false },
|
|
35
|
+
maxLength: { type: Number, required: false },
|
|
35
36
|
defaultValue: { type: [String, Number], required: false },
|
|
36
37
|
modelValue: { type: [String, Number], required: false },
|
|
37
38
|
class: { type: null, required: false }
|
|
@@ -64,6 +64,7 @@ const props = defineProps({
|
|
|
64
64
|
iconAppend: { type: String, required: false },
|
|
65
65
|
showCounter: { type: Boolean, required: false },
|
|
66
66
|
limit: { type: Number, required: false },
|
|
67
|
+
maxLength: { type: Number, required: false },
|
|
67
68
|
defaultValue: { type: [String, Number], required: false },
|
|
68
69
|
modelValue: { type: [String, Number], required: false },
|
|
69
70
|
class: { type: null, required: false }
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
ref="phoneRef"
|
|
4
4
|
v-bind="$props"
|
|
5
5
|
:rules="defaultRules || props.rules"
|
|
6
|
+
:max-length="computedMaxLength"
|
|
6
7
|
v-model="phoneCode"
|
|
7
8
|
>
|
|
8
9
|
<template #append v-if="props.showIconStatus && validationState !== 'none'">
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
</template>
|
|
13
14
|
|
|
14
15
|
<script setup>
|
|
15
|
-
import { ref, watch, computed } from "vue";
|
|
16
|
+
import { ref, watch, computed, nextTick } from "vue";
|
|
16
17
|
import {
|
|
17
18
|
formatPhone,
|
|
18
19
|
reverseFormatPhone,
|
|
@@ -36,6 +37,7 @@ const props = defineProps({
|
|
|
36
37
|
iconAppend: { type: String, required: false },
|
|
37
38
|
showCounter: { type: Boolean, required: false },
|
|
38
39
|
limit: { type: Number, required: false },
|
|
40
|
+
maxLength: { type: Number, required: false },
|
|
39
41
|
defaultValue: { type: [String, Number], required: false },
|
|
40
42
|
modelValue: { type: [String, Number], required: false },
|
|
41
43
|
class: { type: null, required: false }
|
|
@@ -43,6 +45,7 @@ const props = defineProps({
|
|
|
43
45
|
const phoneRef = ref();
|
|
44
46
|
const phoneCode = ref("");
|
|
45
47
|
const validationState = ref("none");
|
|
48
|
+
const previousFormatted = ref("");
|
|
46
49
|
const modelValue = defineModel({ type: String, ...{
|
|
47
50
|
default: ""
|
|
48
51
|
} });
|
|
@@ -52,6 +55,12 @@ const validationIcon = computed(() => {
|
|
|
52
55
|
const validationIconClass = computed(() => {
|
|
53
56
|
return validationState.value === "success" ? "text-success" : "text-destructive";
|
|
54
57
|
});
|
|
58
|
+
const computedMaxLength = computed(() => {
|
|
59
|
+
if (previousFormatted.value && phoneCode.value.includes("+66")) {
|
|
60
|
+
return previousFormatted.value.length;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
});
|
|
55
64
|
const defaultRules = (v) => {
|
|
56
65
|
if (!v) return "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E01\u0E23\u0E2D\u0E01\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C";
|
|
57
66
|
if (!checkPattern(v)) return "\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
|
|
@@ -62,6 +71,7 @@ watch(
|
|
|
62
71
|
(v) => {
|
|
63
72
|
if (!v) {
|
|
64
73
|
validationState.value = "none";
|
|
74
|
+
previousFormatted.value = "";
|
|
65
75
|
return;
|
|
66
76
|
}
|
|
67
77
|
const isValidPattern = checkPattern(v);
|
|
@@ -72,11 +82,17 @@ watch(
|
|
|
72
82
|
}
|
|
73
83
|
modelValue.value = reverseFormatPhone(newNumber || v);
|
|
74
84
|
validationState.value = "success";
|
|
85
|
+
previousFormatted.value = newNumber || v;
|
|
86
|
+
nextTick(() => {
|
|
87
|
+
const inputEl = document.getElementById(props.id);
|
|
88
|
+
inputEl?.blur();
|
|
89
|
+
});
|
|
75
90
|
} else {
|
|
76
|
-
if (v.includes("+66")) {
|
|
91
|
+
if (previousFormatted.value && v.includes("+66")) {
|
|
77
92
|
phoneCode.value = "";
|
|
78
93
|
modelValue.value = "";
|
|
79
94
|
validationState.value = "none";
|
|
95
|
+
previousFormatted.value = "";
|
|
80
96
|
} else {
|
|
81
97
|
validationState.value = "error";
|
|
82
98
|
}
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
:disabled="props.disabled"
|
|
48
48
|
:placeholder="props.placeholder"
|
|
49
49
|
:type="props.type"
|
|
50
|
+
:maxlength="props.maxLength"
|
|
50
51
|
@click="emits('click', $event)"
|
|
51
52
|
@keydown="emits('keydown', $event)"
|
|
52
53
|
>
|
|
@@ -115,6 +116,7 @@ const props = defineProps({
|
|
|
115
116
|
iconAppend: { type: String, required: false },
|
|
116
117
|
showCounter: { type: Boolean, required: false, default: false },
|
|
117
118
|
limit: { type: Number, required: false, default: 0 },
|
|
119
|
+
maxLength: { type: Number, required: false },
|
|
118
120
|
defaultValue: { type: [String, Number], required: false },
|
|
119
121
|
modelValue: { type: [String, Number], required: false },
|
|
120
122
|
class: { type: null, required: false }
|
|
@@ -5,6 +5,7 @@ type __VLS_Props = CalendarRootProps & {
|
|
|
5
5
|
class?: HTMLAttributes["class"];
|
|
6
6
|
layout?: LayoutTypes;
|
|
7
7
|
yearRange?: DateValue[];
|
|
8
|
+
reverseYears?: boolean;
|
|
8
9
|
};
|
|
9
10
|
declare var __VLS_59: {}, __VLS_67: {}, __VLS_69: {
|
|
10
11
|
date: DateValue;
|
|
@@ -31,6 +32,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
31
32
|
}>, {
|
|
32
33
|
modelValue: DateValue | DateValue[];
|
|
33
34
|
layout: "month-and-year" | "month-only" | "year-only";
|
|
35
|
+
reverseYears: boolean;
|
|
34
36
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
37
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
38
|
declare const _default: typeof __VLS_export;
|
|
@@ -5,8 +5,23 @@ import { CalendarRoot, useDateFormatter, useForwardPropsEmits } from "reka-ui";
|
|
|
5
5
|
import { createYear, createYearRange, toDate } from "reka-ui/date";
|
|
6
6
|
import { computed, toRaw } from "vue";
|
|
7
7
|
import { cn } from "@/runtime/plugins/shadcn";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
NativeSelect,
|
|
10
|
+
NativeSelectOption
|
|
11
|
+
} from "@/runtime/components/ui/native-select";
|
|
12
|
+
import {
|
|
13
|
+
CalendarCell,
|
|
14
|
+
CalendarCellTrigger,
|
|
15
|
+
CalendarGrid,
|
|
16
|
+
CalendarGridBody,
|
|
17
|
+
CalendarGridHead,
|
|
18
|
+
CalendarGridRow,
|
|
19
|
+
CalendarHeadCell,
|
|
20
|
+
CalendarHeader,
|
|
21
|
+
CalendarHeading,
|
|
22
|
+
CalendarNextButton,
|
|
23
|
+
CalendarPrevButton
|
|
24
|
+
} from ".";
|
|
10
25
|
const props = defineProps({
|
|
11
26
|
defaultValue: { type: null, required: false },
|
|
12
27
|
defaultPlaceholder: { type: null, required: false },
|
|
@@ -36,7 +51,8 @@ const props = defineProps({
|
|
|
36
51
|
as: { type: null, required: false },
|
|
37
52
|
class: { type: null, required: false },
|
|
38
53
|
layout: { type: null, required: false, default: void 0 },
|
|
39
|
-
yearRange: { type: Array, required: false }
|
|
54
|
+
yearRange: { type: Array, required: false },
|
|
55
|
+
reverseYears: { type: Boolean, required: false, default: false }
|
|
40
56
|
});
|
|
41
57
|
const emits = defineEmits(["update:modelValue", "update:placeholder"]);
|
|
42
58
|
const delegatedProps = reactiveOmit(props, "class", "layout", "placeholder");
|
|
@@ -51,6 +67,12 @@ const yearRange = computed(() => {
|
|
|
51
67
|
end: props?.maxValue ?? (toRaw(props.placeholder) ?? props.defaultPlaceholder ?? today(getLocalTimeZone())).cycle("year", 10)
|
|
52
68
|
});
|
|
53
69
|
});
|
|
70
|
+
const displayYearRange = computed(() => {
|
|
71
|
+
if (props.reverseYears) {
|
|
72
|
+
return [...yearRange.value].reverse();
|
|
73
|
+
}
|
|
74
|
+
return yearRange.value;
|
|
75
|
+
});
|
|
54
76
|
const [DefineMonthTemplate, ReuseMonthTemplate] = createReusableTemplate();
|
|
55
77
|
const [DefineYearTemplate, ReuseYearTemplate] = createReusableTemplate();
|
|
56
78
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
@@ -60,18 +82,30 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
60
82
|
<DefineMonthTemplate v-slot="{ date }">
|
|
61
83
|
<div class="**:data-[slot=native-select-icon]:right-1">
|
|
62
84
|
<div class="relative">
|
|
63
|
-
<div
|
|
85
|
+
<div
|
|
86
|
+
class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none"
|
|
87
|
+
>
|
|
64
88
|
{{ formatter.custom(toDate(date), { month: "short" }) }}
|
|
65
89
|
</div>
|
|
66
90
|
<NativeSelect
|
|
67
91
|
class="text-xs h-8 pr-6 pl-2 text-transparent relative"
|
|
68
|
-
@change="
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
92
|
+
@change="
|
|
93
|
+
(e) => {
|
|
94
|
+
placeholder = placeholder.set({
|
|
95
|
+
month: Number(e?.target?.value)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
"
|
|
73
99
|
>
|
|
74
|
-
<NativeSelectOption
|
|
100
|
+
<NativeSelectOption
|
|
101
|
+
v-for="month in createYear({ dateObj: date })"
|
|
102
|
+
:key="month.toString()"
|
|
103
|
+
:value="month.month"
|
|
104
|
+
:selected="date.month === month.month"
|
|
105
|
+
:class="
|
|
106
|
+
date.month === month.month ? 'text-primary font-medium' : ''
|
|
107
|
+
"
|
|
108
|
+
>
|
|
75
109
|
{{ formatter.custom(toDate(month), { month: "short" }) }}
|
|
76
110
|
</NativeSelectOption>
|
|
77
111
|
</NativeSelect>
|
|
@@ -82,18 +116,28 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
82
116
|
<DefineYearTemplate v-slot="{ date }">
|
|
83
117
|
<div class="**:data-[slot=native-select-icon]:right-1">
|
|
84
118
|
<div class="relative">
|
|
85
|
-
<div
|
|
119
|
+
<div
|
|
120
|
+
class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none"
|
|
121
|
+
>
|
|
86
122
|
{{ formatter.custom(toDate(date), { year: "numeric" }) }}
|
|
87
123
|
</div>
|
|
88
124
|
<NativeSelect
|
|
89
125
|
class="text-xs h-8 pr-6 pl-2 text-transparent relative"
|
|
90
|
-
@change="
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
126
|
+
@change="
|
|
127
|
+
(e) => {
|
|
128
|
+
placeholder = placeholder.set({
|
|
129
|
+
year: Number(e?.target?.value)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
"
|
|
95
133
|
>
|
|
96
|
-
<NativeSelectOption
|
|
134
|
+
<NativeSelectOption
|
|
135
|
+
v-for="year in displayYearRange"
|
|
136
|
+
:key="year.toString()"
|
|
137
|
+
:value="year.year"
|
|
138
|
+
:selected="date.year === year.year"
|
|
139
|
+
:class="date.year === year.year ? 'text-primary font-medium' : ''"
|
|
140
|
+
>
|
|
97
141
|
{{ formatter.custom(toDate(year), { year: "numeric" }) }}
|
|
98
142
|
</NativeSelectOption>
|
|
99
143
|
</NativeSelect>
|
|
@@ -109,7 +153,9 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
109
153
|
:class="cn('p-3', props.class)"
|
|
110
154
|
>
|
|
111
155
|
<CalendarHeader class="pt-0">
|
|
112
|
-
<nav
|
|
156
|
+
<nav
|
|
157
|
+
class="flex items-center gap-1 absolute top-0 inset-x-0 justify-between"
|
|
158
|
+
>
|
|
113
159
|
<CalendarPrevButton>
|
|
114
160
|
<slot name="calendar-prev-icon" />
|
|
115
161
|
</CalendarPrevButton>
|
|
@@ -118,7 +164,12 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
118
164
|
</CalendarNextButton>
|
|
119
165
|
</nav>
|
|
120
166
|
|
|
121
|
-
<slot
|
|
167
|
+
<slot
|
|
168
|
+
name="calendar-heading"
|
|
169
|
+
:date="date"
|
|
170
|
+
:month="ReuseMonthTemplate"
|
|
171
|
+
:year="ReuseYearTemplate"
|
|
172
|
+
>
|
|
122
173
|
<template v-if="layout === 'month-and-year'">
|
|
123
174
|
<div class="flex items-center justify-center gap-1">
|
|
124
175
|
<ReuseMonthTemplate :date="date" />
|
|
@@ -147,24 +198,23 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
147
198
|
<CalendarGrid v-for="month in grid" :key="month.value.toString()">
|
|
148
199
|
<CalendarGridHead>
|
|
149
200
|
<CalendarGridRow>
|
|
150
|
-
<CalendarHeadCell
|
|
151
|
-
v-for="day in weekDays" :key="day"
|
|
152
|
-
>
|
|
201
|
+
<CalendarHeadCell v-for="day in weekDays" :key="day">
|
|
153
202
|
{{ day }}
|
|
154
203
|
</CalendarHeadCell>
|
|
155
204
|
</CalendarGridRow>
|
|
156
205
|
</CalendarGridHead>
|
|
157
206
|
<CalendarGridBody>
|
|
158
|
-
<CalendarGridRow
|
|
207
|
+
<CalendarGridRow
|
|
208
|
+
v-for="(weekDates, index) in month.rows"
|
|
209
|
+
:key="`weekDate-${index}`"
|
|
210
|
+
class="mt-2 w-full"
|
|
211
|
+
>
|
|
159
212
|
<CalendarCell
|
|
160
213
|
v-for="weekDate in weekDates"
|
|
161
214
|
:key="weekDate.toString()"
|
|
162
215
|
:date="weekDate"
|
|
163
216
|
>
|
|
164
|
-
<CalendarCellTrigger
|
|
165
|
-
:day="weekDate"
|
|
166
|
-
:month="month.value"
|
|
167
|
-
/>
|
|
217
|
+
<CalendarCellTrigger :day="weekDate" :month="month.value" />
|
|
168
218
|
</CalendarCell>
|
|
169
219
|
</CalendarGridRow>
|
|
170
220
|
</CalendarGridBody>
|
|
@@ -5,6 +5,7 @@ type __VLS_Props = CalendarRootProps & {
|
|
|
5
5
|
class?: HTMLAttributes["class"];
|
|
6
6
|
layout?: LayoutTypes;
|
|
7
7
|
yearRange?: DateValue[];
|
|
8
|
+
reverseYears?: boolean;
|
|
8
9
|
};
|
|
9
10
|
declare var __VLS_59: {}, __VLS_67: {}, __VLS_69: {
|
|
10
11
|
date: DateValue;
|
|
@@ -31,6 +32,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
31
32
|
}>, {
|
|
32
33
|
modelValue: DateValue | DateValue[];
|
|
33
34
|
layout: "month-and-year" | "month-only" | "year-only";
|
|
35
|
+
reverseYears: boolean;
|
|
34
36
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
37
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
36
38
|
declare const _default: typeof __VLS_export;
|