pukaad-ui-lib 1.343.0 → 1.344.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.343.0",
4
+ "version": "1.344.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -16,11 +16,17 @@ export interface ContactChannel {
16
16
  channel_type: string;
17
17
  value: string;
18
18
  }
19
+ export interface SpecialDay {
20
+ date: string | Date;
21
+ isOpen: boolean;
22
+ timeSlots?: TimeSlot[];
23
+ }
19
24
  export interface PlaceDetailItem {
20
25
  description?: string;
21
26
  categories?: Category[];
22
27
  open_status?: string;
23
28
  opening_hours?: OpeningHour[];
29
+ special_days?: SpecialDay[];
24
30
  phone?: string;
25
31
  contact_channels?: ContactChannel[];
26
32
  }
@@ -34,11 +34,27 @@
34
34
  <div
35
35
  v-for="(hour, index) in businessHours"
36
36
  :key="index"
37
- class="flex items-center justify-between"
37
+ class="flex items-start justify-between"
38
38
  >
39
39
  <span>{{ hour.day }}</span>
40
- <span>{{ hour.time_range }}</span>
40
+ <div class="flex flex-col items-end">
41
+ <span v-for="(line, li) in hour.time_lines" :key="li">{{ line }}</span>
42
+ </div>
41
43
  </div>
44
+
45
+ <template v-if="upcomingSpecialDays.length">
46
+ <div class="font-body-large-prominent text-warning">วันทำการพิเศษ</div>
47
+ <div
48
+ v-for="(special, index) in upcomingSpecialDays"
49
+ :key="index"
50
+ class="flex items-start justify-between text-warning"
51
+ >
52
+ <span>{{ special.date_label }}</span>
53
+ <div class="flex flex-col items-end">
54
+ <span v-for="(line, li) in special.time_lines" :key="li">{{ line }}</span>
55
+ </div>
56
+ </div>
57
+ </template>
42
58
  </div>
43
59
  <div v-else class="text-cloud">ไม่มีข้อมูลเวลาทำการ</div>
44
60
  </div>
@@ -80,6 +96,7 @@
80
96
 
81
97
  <script setup>
82
98
  import { computed } from "vue";
99
+ import dayjs from "#pukaad-ui/runtime/utils/dayjs";
83
100
  const DAY_NAMES = [
84
101
  "\u0E27\u0E31\u0E19\u0E2D\u0E32\u0E17\u0E34\u0E15\u0E22\u0E4C",
85
102
  "\u0E27\u0E31\u0E19\u0E08\u0E31\u0E19\u0E17\u0E23\u0E4C",
@@ -96,10 +113,16 @@ const toArray = (value) => Array.isArray(value) ? value : [];
96
113
  const categoryText = computed(
97
114
  () => toArray(props.item.categories).filter((c) => c?.category_name).map((c) => c.category_name).join(", ")
98
115
  );
116
+ const getTimeLines = (isOpen, timeSlots, isAllDay) => {
117
+ if (!isOpen) return ["\u0E2B\u0E22\u0E38\u0E14\u0E17\u0E33\u0E01\u0E32\u0E23"];
118
+ const slots = toArray(timeSlots);
119
+ if (isAllDay || slots.length === 0) return ["\u0E40\u0E1B\u0E34\u0E14\u0E15\u0E25\u0E2D\u0E14 24 \u0E0A\u0E21."];
120
+ return slots.map((t) => `${t.start} - ${t.end} \u0E19.`);
121
+ };
99
122
  const businessHours = computed(
100
123
  () => toArray(props.item.opening_hours).filter((h) => !!h).map((h) => ({
101
124
  day: DAY_NAMES[h.day] ?? "",
102
- time_range: !h.isOpen ? "\u0E2B\u0E22\u0E38\u0E14\u0E17\u0E33\u0E01\u0E32\u0E23" : h.isAllDay ? "\u0E40\u0E1B\u0E34\u0E14\u0E15\u0E25\u0E2D\u0E14 24 \u0E0A\u0E21." : toArray(h.timeSlots).map((t) => `${t.start} - ${t.end}`).join(", ") || "\u0E40\u0E1B\u0E34\u0E14"
125
+ time_lines: getTimeLines(h.isOpen, h.timeSlots, h.isAllDay)
103
126
  }))
104
127
  );
105
128
  const socialLinks = computed(
@@ -108,6 +131,17 @@ const socialLinks = computed(
108
131
  link: ch.value
109
132
  }))
110
133
  );
134
+ const sortedSpecialDays = computed(() => {
135
+ const today = dayjs().startOf("day");
136
+ const maxDate = today.add(30, "day").endOf("day");
137
+ return toArray(props.item.special_days).filter((s) => !!s?.date).map((s) => ({ ...s, date: dayjs(s.date) })).filter((s) => s.date.isValid()).filter((s) => !s.date.isBefore(today) && !s.date.isAfter(maxDate)).sort((a, b) => a.date.valueOf() - b.date.valueOf());
138
+ });
139
+ const upcomingSpecialDays = computed(
140
+ () => sortedSpecialDays.value.map((s) => ({
141
+ date_label: s.date.locale("th").format("D MMMM BBBB"),
142
+ time_lines: getTimeLines(s.isOpen, s.timeSlots)
143
+ }))
144
+ );
111
145
  const onClickLink = (link) => {
112
146
  window.open(link, "_blank");
113
147
  };
@@ -16,11 +16,17 @@ export interface ContactChannel {
16
16
  channel_type: string;
17
17
  value: string;
18
18
  }
19
+ export interface SpecialDay {
20
+ date: string | Date;
21
+ isOpen: boolean;
22
+ timeSlots?: TimeSlot[];
23
+ }
19
24
  export interface PlaceDetailItem {
20
25
  description?: string;
21
26
  categories?: Category[];
22
27
  open_status?: string;
23
28
  opening_hours?: OpeningHour[];
29
+ special_days?: SpecialDay[];
24
30
  phone?: string;
25
31
  contact_channels?: ContactChannel[];
26
32
  }
@@ -228,6 +228,7 @@ const onSubmit = async () => {
228
228
  extra_phones: d.extraPhones ?? [],
229
229
  contact_channels: d.contactChannels ?? [],
230
230
  opening_hours: d.openingHours ?? null,
231
+ special_days: d.specialDays ?? null,
231
232
  categories: categoryIds,
232
233
  is_review: d.isReview ?? false,
233
234
  rating: d.rating ?? 0,
@@ -1,5 +1,6 @@
1
1
  import type { InputAddressValue } from "#pukaad-ui/runtime/components/input/input-address.vue";
2
2
  import type { LocalizedNameItem } from "#pukaad-ui/types/components/input/input-localized-name";
3
+ import type { SpecialDaySchedule } from "#pukaad-ui/runtime/components/input/input-date-opening-special.vue";
3
4
  interface FileItem {
4
5
  file?: File;
5
6
  url: string;
@@ -23,6 +24,7 @@ export interface SuggestPlaceData {
23
24
  }[];
24
25
  description?: string;
25
26
  openingHours?: Record<string, unknown>;
27
+ specialDays?: SpecialDaySchedule[];
26
28
  phone?: string;
27
29
  extraPhones?: string[];
28
30
  isReview?: boolean;
@@ -51,6 +51,11 @@
51
51
  name="openingHours"
52
52
  v-model="modelValue.openingHours"
53
53
  />
54
+ <InputDateOpeningSpecial
55
+ v-if="props.state === 'business' && isOpeningHoursCompleted"
56
+ name="specialDays"
57
+ v-model="modelValue.specialDays"
58
+ />
54
59
  <div class="flex flex-col gap-[8px]">
55
60
  <InputTextField
56
61
  name="phone"
@@ -189,6 +194,10 @@ const isAddressCompleted = computed(() => {
189
194
  const v = modelValue.address || {};
190
195
  return !!(v.province_id && v.amphur_id && v.tambon_id && v.zipcode);
191
196
  });
197
+ const isOpeningHoursCompleted = computed(() => {
198
+ const hours = modelValue.openingHours;
199
+ return Array.isArray(hours) && hours.some((s) => s?.isOpen);
200
+ });
192
201
  watch(
193
202
  () => modelValue.isReview,
194
203
  (newVal) => {
@@ -1,5 +1,6 @@
1
1
  import type { InputAddressValue } from "#pukaad-ui/runtime/components/input/input-address.vue";
2
2
  import type { LocalizedNameItem } from "#pukaad-ui/types/components/input/input-localized-name";
3
+ import type { SpecialDaySchedule } from "#pukaad-ui/runtime/components/input/input-date-opening-special.vue";
3
4
  interface FileItem {
4
5
  file?: File;
5
6
  url: string;
@@ -23,6 +24,7 @@ export interface SuggestPlaceData {
23
24
  }[];
24
25
  description?: string;
25
26
  openingHours?: Record<string, unknown>;
27
+ specialDays?: SpecialDaySchedule[];
26
28
  phone?: string;
27
29
  extraPhones?: string[];
28
30
  isReview?: boolean;
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
64
64
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
65
65
  src: string;
66
66
  center: boolean;
67
+ background: boolean;
68
+ modal: boolean;
67
69
  responsive: boolean;
68
70
  restore: boolean;
69
71
  checkCrossOrigin: boolean;
70
72
  checkOrientation: boolean;
71
73
  crossorigin: "" | "anonymous" | "use-credentials";
72
- modal: boolean;
73
74
  guides: boolean;
74
75
  highlight: boolean;
75
- background: boolean;
76
76
  autoCrop: boolean;
77
77
  movable: boolean;
78
78
  rotatable: boolean;
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
64
64
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
65
65
  src: string;
66
66
  center: boolean;
67
+ background: boolean;
68
+ modal: boolean;
67
69
  responsive: boolean;
68
70
  restore: boolean;
69
71
  checkCrossOrigin: boolean;
70
72
  checkOrientation: boolean;
71
73
  crossorigin: "" | "anonymous" | "use-credentials";
72
- modal: boolean;
73
74
  guides: boolean;
74
75
  highlight: boolean;
75
- background: boolean;
76
76
  autoCrop: boolean;
77
77
  movable: boolean;
78
78
  rotatable: boolean;
@@ -0,0 +1,32 @@
1
+ export interface SpecialDayTimeSlot {
2
+ start: string;
3
+ end: string;
4
+ }
5
+ export interface SpecialDaySchedule {
6
+ date: Date | undefined;
7
+ isOpen: boolean;
8
+ timeSlots: SpecialDayTimeSlot[];
9
+ }
10
+ export interface InputDateOpeningSpecialProps {
11
+ name?: string;
12
+ label?: string;
13
+ placeholder?: string;
14
+ required?: boolean;
15
+ }
16
+ type __VLS_Props = InputDateOpeningSpecialProps;
17
+ type __VLS_ModelProps = {
18
+ modelValue?: SpecialDaySchedule[];
19
+ };
20
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
21
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ "update:modelValue": (value: SpecialDaySchedule[]) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
+ "onUpdate:modelValue"?: ((value: SpecialDaySchedule[]) => any) | undefined;
25
+ }>, {
26
+ label: string;
27
+ name: string;
28
+ required: boolean;
29
+ placeholder: string;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const _default: typeof __VLS_export;
32
+ export default _default;
@@ -0,0 +1,246 @@
1
+ <template>
2
+ <div class="flex flex-col gap-[4px]">
3
+ <label v-if="props.label" class="font-body-large-prominent text-gray">
4
+ {{ props.label }}
5
+ <span v-if="props.required" class="text-destructive">*</span>
6
+ </label>
7
+ <div
8
+ class="border-input relative flex w-full rounded-md border-[1px] bg-white px-[12px] py-[5px] gap-2 cursor-pointer"
9
+ @click="openModal"
10
+ >
11
+ <span
12
+ v-if="!isConfirmed"
13
+ class="flex-1 text-muted-foreground font-body-large"
14
+ >
15
+ {{ props.placeholder }}
16
+ </span>
17
+ <div v-else class="flex-1 flex flex-col gap-[4px]">
18
+ <div
19
+ v-for="(item, i) in modelValue"
20
+ :key="i"
21
+ class="flex justify-between font-body-large"
22
+ >
23
+ <span>{{ formatDate(item.date) }}</span>
24
+ <div class="text-right flex flex-col items-end gap-1">
25
+ <span v-if="!item.isOpen">หยุดทำการ</span>
26
+ <span v-else-if="item.timeSlots.length === 0">เปิดตลอด 24 ชม.</span>
27
+ <div v-else class="flex flex-col gap-1">
28
+ <span v-for="(slot, i) in item.timeSlots" :key="i"
29
+ >{{ slot.start }} - {{ slot.end }} น.</span
30
+ >
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <Icon
36
+ name="lucide:chevron-right"
37
+ :size="16"
38
+ class="shrink-0 self-center"
39
+ />
40
+ </div>
41
+ </div>
42
+
43
+ <Modal
44
+ v-model="isOpenModal"
45
+ title="วันทำการพิเศษ"
46
+ @close="closeModal"
47
+ class="w-[512px]"
48
+ :content-max-height="450"
49
+ >
50
+ <div class="flex flex-col gap-[24px]">
51
+ <div
52
+ v-for="(day, dayIndex) in workingDays"
53
+ :key="day.id"
54
+ class="flex flex-col gap-[16px]"
55
+ >
56
+ <InputDatePicker
57
+ :name="`special-date-${day.id}`"
58
+ v-model="day.date"
59
+ label="วันที่"
60
+ placeholder="เลือกวันที่"
61
+ :min-value="today"
62
+ />
63
+
64
+ <div class="flex gap-6">
65
+ <InputCheckbox
66
+ label="เปิดตลอด 24 ชม."
67
+ :model-value="day.isAllDay"
68
+ @update:model-value="(v) => setAllDay(day, v)"
69
+ />
70
+ <InputCheckbox
71
+ label="หยุดทำการ"
72
+ :model-value="day.isClosed"
73
+ @update:model-value="(v) => setClosed(day, v)"
74
+ />
75
+ </div>
76
+
77
+ <div
78
+ v-if="!day.isClosed && !day.isAllDay"
79
+ class="flex flex-col gap-[8px]"
80
+ >
81
+ <div
82
+ v-for="(timeSlot, slotIndex) in day.timeSlots"
83
+ :key="timeSlot.id"
84
+ class="flex items-end justify-between gap-2"
85
+ >
86
+ <InputSelect
87
+ :name="`special-time-start-${timeSlot.id}`"
88
+ v-model="timeSlot.start"
89
+ label="เวลาเปิด"
90
+ :options="timeOptions"
91
+ placeholder="00:00"
92
+ />
93
+ <InputSelect
94
+ :name="`special-time-end-${timeSlot.id}`"
95
+ v-model="timeSlot.end"
96
+ label="เวลาปิด"
97
+ :options="timeOptions"
98
+ placeholder="00:00"
99
+ />
100
+
101
+ <PickerOptionMenu
102
+ :items="getTimeSlotMenuItems(dayIndex, slotIndex)"
103
+ />
104
+ </div>
105
+ </div>
106
+ </div>
107
+
108
+ <Button
109
+ variant="text"
110
+ color="primary"
111
+ size="sm"
112
+ class="justify-start"
113
+ @click="addDay"
114
+ >
115
+ <Icon name="lucide:plus" :size="16" />
116
+ เพิ่มวันที่
117
+ </Button>
118
+ </div>
119
+
120
+ <template #footer>
121
+ <div class="flex w-full justify-end">
122
+ <Button color="primary" :disabled="!isScheduleValid" @click="saveDays"
123
+ >บันทึก</Button
124
+ >
125
+ </div>
126
+ </template>
127
+ </Modal>
128
+ </template>
129
+
130
+ <script setup>
131
+ import { ref, computed } from "vue";
132
+ import dayjs from "#pukaad-ui/runtime/utils/dayjs";
133
+ const props = defineProps({
134
+ name: { type: String, required: false, default: "date-opening-special" },
135
+ label: { type: String, required: false, default: "\u0E27\u0E31\u0E19\u0E17\u0E33\u0E01\u0E32\u0E23\u0E1E\u0E34\u0E40\u0E28\u0E29" },
136
+ placeholder: { type: String, required: false, default: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E27\u0E31\u0E19 \u0E40\u0E27\u0E25\u0E32\u0E17\u0E33\u0E01\u0E32\u0E23" },
137
+ required: { type: Boolean, required: false, default: false }
138
+ });
139
+ const modelValue = defineModel({ type: Array, ...{ default: () => [] } });
140
+ let idCounter = 0;
141
+ const isOpenModal = ref(false);
142
+ const workingDays = ref([]);
143
+ const today = dayjs().startOf("day").toDate();
144
+ const isConfirmed = computed(() => modelValue.value.length > 0);
145
+ const isScheduleValid = computed(() => {
146
+ if (workingDays.value.length === 0) return false;
147
+ const validDays = workingDays.value.filter((d) => {
148
+ if (!d.date) return false;
149
+ if (d.isClosed || d.isAllDay) return true;
150
+ return d.timeSlots.some((slot) => slot.start && slot.end);
151
+ });
152
+ if (validDays.length === 0) return false;
153
+ return workingDays.value.every((d) => {
154
+ if (!d.date) return true;
155
+ if (d.isClosed || d.isAllDay) return true;
156
+ return d.timeSlots.some((slot) => slot.start && slot.end);
157
+ });
158
+ });
159
+ function formatDate(date) {
160
+ if (!date) return "";
161
+ return dayjs(date).locale("th").format("D MMMM BBBB");
162
+ }
163
+ function createEmptyDay() {
164
+ return {
165
+ id: idCounter++,
166
+ date: void 0,
167
+ isClosed: false,
168
+ isAllDay: false,
169
+ timeSlots: [{ id: idCounter++, start: "", end: "" }]
170
+ };
171
+ }
172
+ function openModal() {
173
+ workingDays.value = modelValue.value.length > 0 ? modelValue.value.map((d) => {
174
+ const slots = d.timeSlots ?? [];
175
+ return {
176
+ id: idCounter++,
177
+ date: d.date,
178
+ isClosed: !d.isOpen,
179
+ isAllDay: d.isOpen && slots.length === 0,
180
+ timeSlots: slots.length > 0 ? slots.map((slot) => ({ id: idCounter++, ...slot })) : [{ id: idCounter++, start: "", end: "" }]
181
+ };
182
+ }) : [createEmptyDay()];
183
+ isOpenModal.value = true;
184
+ }
185
+ function closeModal() {
186
+ isOpenModal.value = false;
187
+ }
188
+ function addDay() {
189
+ workingDays.value.push(createEmptyDay());
190
+ }
191
+ function setAllDay(day, value) {
192
+ day.isAllDay = value;
193
+ if (value) day.isClosed = false;
194
+ }
195
+ function setClosed(day, value) {
196
+ day.isClosed = value;
197
+ if (value) day.isAllDay = false;
198
+ }
199
+ function addTimeSlot(dayIndex) {
200
+ workingDays.value[dayIndex].timeSlots.push({
201
+ id: idCounter++,
202
+ start: "",
203
+ end: ""
204
+ });
205
+ }
206
+ function removeTimeSlot(dayIndex, slotIndex) {
207
+ const day = workingDays.value[dayIndex];
208
+ if (day.timeSlots.length === 1) {
209
+ workingDays.value.splice(dayIndex, 1);
210
+ } else {
211
+ day.timeSlots.splice(slotIndex, 1);
212
+ }
213
+ }
214
+ function getTimeSlotMenuItems(dayIndex, slotIndex) {
215
+ return [
216
+ {
217
+ label: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E27\u0E25\u0E32\u0E17\u0E33\u0E01\u0E32\u0E23",
218
+ name: "add",
219
+ icon: "lucide:plus",
220
+ action: () => addTimeSlot(dayIndex)
221
+ },
222
+ {
223
+ label: "\u0E25\u0E1A\u0E40\u0E27\u0E25\u0E32",
224
+ name: "delete",
225
+ icon: "lucide:trash-2",
226
+ action: () => removeTimeSlot(dayIndex, slotIndex)
227
+ }
228
+ ];
229
+ }
230
+ function saveDays() {
231
+ modelValue.value = workingDays.value.filter((d) => {
232
+ if (!d.date) return false;
233
+ if (d.isClosed || d.isAllDay) return true;
234
+ return d.timeSlots.some((slot) => slot.start && slot.end);
235
+ }).map((d) => ({
236
+ date: d.date,
237
+ isOpen: !d.isClosed,
238
+ timeSlots: d.isClosed || d.isAllDay ? [] : d.timeSlots.filter((slot) => slot.start && slot.end).map((slot) => ({ start: slot.start, end: slot.end }))
239
+ }));
240
+ isOpenModal.value = false;
241
+ }
242
+ const timeOptions = Array.from({ length: 48 }, (_, i) => {
243
+ const t = dayjs().startOf("day").add(i * 30, "minute").format("HH:mm");
244
+ return { label: t, value: t };
245
+ });
246
+ </script>
@@ -0,0 +1,32 @@
1
+ export interface SpecialDayTimeSlot {
2
+ start: string;
3
+ end: string;
4
+ }
5
+ export interface SpecialDaySchedule {
6
+ date: Date | undefined;
7
+ isOpen: boolean;
8
+ timeSlots: SpecialDayTimeSlot[];
9
+ }
10
+ export interface InputDateOpeningSpecialProps {
11
+ name?: string;
12
+ label?: string;
13
+ placeholder?: string;
14
+ required?: boolean;
15
+ }
16
+ type __VLS_Props = InputDateOpeningSpecialProps;
17
+ type __VLS_ModelProps = {
18
+ modelValue?: SpecialDaySchedule[];
19
+ };
20
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
21
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
+ "update:modelValue": (value: SpecialDaySchedule[]) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
+ "onUpdate:modelValue"?: ((value: SpecialDaySchedule[]) => any) | undefined;
25
+ }>, {
26
+ label: string;
27
+ name: string;
28
+ required: boolean;
29
+ placeholder: string;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const _default: typeof __VLS_export;
32
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.343.0",
3
+ "version": "1.344.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",