pukaad-ui-lib 1.79.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.79.0",
4
+ "version": "1.80.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -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 = {
@@ -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 { NativeSelect, NativeSelectOption } from "@/runtime/components/ui/native-select";
9
- import { CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNextButton, CalendarPrevButton } from ".";
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 class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none">
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="(e) => {
69
- placeholder = placeholder.set({
70
- month: Number(e?.target?.value)
71
- });
72
- }"
92
+ @change="
93
+ (e) => {
94
+ placeholder = placeholder.set({
95
+ month: Number(e?.target?.value)
96
+ });
97
+ }
98
+ "
73
99
  >
74
- <NativeSelectOption v-for="(month) in createYear({ dateObj: date })" :key="month.toString()" :value="month.month" :selected="date.month === month.month">
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 class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none">
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="(e) => {
91
- placeholder = placeholder.set({
92
- year: Number(e?.target?.value)
93
- });
94
- }"
126
+ @change="
127
+ (e) => {
128
+ placeholder = placeholder.set({
129
+ year: Number(e?.target?.value)
130
+ });
131
+ }
132
+ "
95
133
  >
96
- <NativeSelectOption v-for="(year) in yearRange" :key="year.toString()" :value="year.year" :selected="date.year === year.year">
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 class="flex items-center gap-1 absolute top-0 inset-x-0 justify-between">
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 name="calendar-heading" :date="date" :month="ReuseMonthTemplate" :year="ReuseYearTemplate">
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 v-for="(weekDates, index) in month.rows" :key="`weekDate-${index}`" class="mt-2 w-full">
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.79.0",
3
+ "version": "1.80.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",