windly-ui 1.0.1 → 1.0.3

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.
Files changed (123) hide show
  1. package/dist/module.d.mts +3 -0
  2. package/dist/module.json +8 -0
  3. package/dist/module.mjs +26 -0
  4. package/dist/runtime/components/Accordion.d.vue.ts +39 -0
  5. package/{ui-library → dist/runtime}/components/Accordion.vue +44 -70
  6. package/dist/runtime/components/Accordion.vue.d.ts +39 -0
  7. package/dist/runtime/components/Avatar.d.vue.ts +141 -0
  8. package/dist/runtime/components/Avatar.vue +72 -0
  9. package/dist/runtime/components/Avatar.vue.d.ts +141 -0
  10. package/dist/runtime/components/Badge.d.vue.ts +133 -0
  11. package/dist/runtime/components/Badge.vue +99 -0
  12. package/dist/runtime/components/Badge.vue.d.ts +133 -0
  13. package/dist/runtime/components/Breadcrumbs.d.vue.ts +83 -0
  14. package/{ui-library → dist/runtime}/components/Breadcrumbs.vue +37 -59
  15. package/dist/runtime/components/Breadcrumbs.vue.d.ts +83 -0
  16. package/dist/runtime/components/Button.d.vue.ts +199 -0
  17. package/dist/runtime/components/Button.vue +125 -0
  18. package/dist/runtime/components/Button.vue.d.ts +199 -0
  19. package/dist/runtime/components/Card.d.vue.ts +83 -0
  20. package/{ui-library → dist/runtime}/components/Card.vue +26 -39
  21. package/dist/runtime/components/Card.vue.d.ts +83 -0
  22. package/dist/runtime/components/Checkbox.d.vue.ts +190 -0
  23. package/{ui-library → dist/runtime}/components/Checkbox.vue +45 -68
  24. package/dist/runtime/components/Checkbox.vue.d.ts +190 -0
  25. package/dist/runtime/components/CodeBlock.d.vue.ts +16 -0
  26. package/dist/runtime/components/CodeBlock.vue +75 -0
  27. package/dist/runtime/components/CodeBlock.vue.d.ts +16 -0
  28. package/dist/runtime/components/ColorPicker.d.vue.ts +91 -0
  29. package/dist/runtime/components/ColorPicker.vue +244 -0
  30. package/dist/runtime/components/ColorPicker.vue.d.ts +91 -0
  31. package/dist/runtime/components/Date.d.vue.ts +137 -0
  32. package/dist/runtime/components/Date.vue +201 -0
  33. package/dist/runtime/components/Date.vue.d.ts +137 -0
  34. package/dist/runtime/components/Dialog.d.vue.ts +103 -0
  35. package/{ui-library → dist/runtime}/components/Dialog.vue +30 -65
  36. package/dist/runtime/components/Dialog.vue.d.ts +103 -0
  37. package/dist/runtime/components/Divider.d.vue.ts +51 -0
  38. package/dist/runtime/components/Divider.vue +52 -0
  39. package/dist/runtime/components/Divider.vue.d.ts +51 -0
  40. package/dist/runtime/components/Drawer.d.vue.ts +30 -0
  41. package/dist/runtime/components/Drawer.vue +43 -0
  42. package/dist/runtime/components/Drawer.vue.d.ts +30 -0
  43. package/dist/runtime/components/Dropdown.d.vue.ts +34 -0
  44. package/dist/runtime/components/Dropdown.vue +127 -0
  45. package/dist/runtime/components/Dropdown.vue.d.ts +34 -0
  46. package/dist/runtime/components/FileUploader.d.vue.ts +58 -0
  47. package/dist/runtime/components/FileUploader.vue +202 -0
  48. package/dist/runtime/components/FileUploader.vue.d.ts +58 -0
  49. package/dist/runtime/components/Icon.d.vue.ts +41 -0
  50. package/dist/runtime/components/Icon.vue +66 -0
  51. package/dist/runtime/components/Icon.vue.d.ts +41 -0
  52. package/dist/runtime/components/Image.d.vue.ts +77 -0
  53. package/dist/runtime/components/Image.vue +61 -0
  54. package/dist/runtime/components/Image.vue.d.ts +77 -0
  55. package/dist/runtime/components/Input.d.vue.ts +66 -0
  56. package/dist/runtime/components/Input.vue +233 -0
  57. package/dist/runtime/components/Input.vue.d.ts +66 -0
  58. package/dist/runtime/components/Radio.d.vue.ts +41 -0
  59. package/dist/runtime/components/Radio.vue +222 -0
  60. package/dist/runtime/components/Radio.vue.d.ts +41 -0
  61. package/dist/runtime/components/ScrollArea.d.vue.ts +79 -0
  62. package/dist/runtime/components/ScrollArea.vue +36 -0
  63. package/dist/runtime/components/ScrollArea.vue.d.ts +79 -0
  64. package/dist/runtime/components/Select.d.vue.ts +43 -0
  65. package/dist/runtime/components/Select.vue +200 -0
  66. package/dist/runtime/components/Select.vue.d.ts +43 -0
  67. package/dist/runtime/components/Stepper.d.vue.ts +46 -0
  68. package/dist/runtime/components/Stepper.vue +218 -0
  69. package/dist/runtime/components/Stepper.vue.d.ts +46 -0
  70. package/dist/runtime/components/TabPanel.d.vue.ts +17 -0
  71. package/dist/runtime/components/TabPanel.vue +21 -0
  72. package/dist/runtime/components/TabPanel.vue.d.ts +17 -0
  73. package/dist/runtime/components/Table.d.vue.ts +40 -0
  74. package/dist/runtime/components/Table.vue +92 -0
  75. package/dist/runtime/components/Table.vue.d.ts +40 -0
  76. package/dist/runtime/components/Tabs.d.vue.ts +20 -0
  77. package/dist/runtime/components/Tabs.vue +62 -0
  78. package/dist/runtime/components/Tabs.vue.d.ts +20 -0
  79. package/dist/runtime/components/Textarea.d.vue.ts +208 -0
  80. package/dist/runtime/components/Textarea.vue +185 -0
  81. package/dist/runtime/components/Textarea.vue.d.ts +208 -0
  82. package/dist/runtime/components/Toggle.d.vue.ts +36 -0
  83. package/dist/runtime/components/Toggle.vue +173 -0
  84. package/dist/runtime/components/Toggle.vue.d.ts +36 -0
  85. package/dist/runtime/components/Tooltip.d.vue.ts +63 -0
  86. package/dist/runtime/components/Tooltip.vue +144 -0
  87. package/dist/runtime/components/Tooltip.vue.d.ts +63 -0
  88. package/dist/runtime/components/uiProps.d.ts +38 -0
  89. package/{ui-library/components/uiProps.ts → dist/runtime/components/uiProps.js} +2 -2
  90. package/dist/runtime/components/useUiClasses.d.ts +43 -0
  91. package/{ui-library/components/useUiClasses.ts → dist/runtime/components/useUiClasses.js} +25 -60
  92. package/dist/runtime/composables/plugin.d.ts +2 -0
  93. package/dist/runtime/composables/plugin.js +3 -0
  94. package/dist/runtime/tailwind-color.d.ts +2 -0
  95. package/dist/runtime/tailwind-color.js +5859 -0
  96. package/dist/types.d.mts +7 -0
  97. package/package.json +14 -16
  98. package/README.md +0 -208
  99. package/ui-library/components/Avatar.vue +0 -121
  100. package/ui-library/components/Badge.vue +0 -116
  101. package/ui-library/components/Button.vue +0 -154
  102. package/ui-library/components/CodeBlock.vue +0 -99
  103. package/ui-library/components/ColorPicker.vue +0 -302
  104. package/ui-library/components/Date.vue +0 -240
  105. package/ui-library/components/Divider.vue +0 -78
  106. package/ui-library/components/Drawer.vue +0 -67
  107. package/ui-library/components/Dropdown.vue +0 -248
  108. package/ui-library/components/FileUploader.vue +0 -330
  109. package/ui-library/components/Icon.vue +0 -82
  110. package/ui-library/components/Image.vue +0 -78
  111. package/ui-library/components/Input.vue +0 -531
  112. package/ui-library/components/Radio.vue +0 -356
  113. package/ui-library/components/ScrollArea.vue +0 -43
  114. package/ui-library/components/Select.vue +0 -309
  115. package/ui-library/components/Stepper.vue +0 -361
  116. package/ui-library/components/TabPanel.vue +0 -25
  117. package/ui-library/components/Table.vue +0 -152
  118. package/ui-library/components/Tabs.vue +0 -71
  119. package/ui-library/components/Textarea.vue +0 -233
  120. package/ui-library/components/Toggle.vue +0 -319
  121. package/ui-library/components/Tooltip.vue +0 -200
  122. package/ui-library/components/plugin.ts +0 -8
  123. package/ui-library/module.ts +0 -20
@@ -0,0 +1,201 @@
1
+ <script setup>
2
+ import { ref, computed, watch } from "vue";
3
+ import { useUiClasses } from "./useUiClasses";
4
+ import { uiProps } from "./uiProps";
5
+ const props = defineProps({
6
+ modelValue: { type: [String, Array], default: "" },
7
+ multiDate: Boolean,
8
+ rangeDate: Boolean,
9
+ disabledDates: { type: Array, default: () => [] },
10
+ format: { type: String, default: "DD-MM-YYYY" },
11
+ showHeader: { type: Boolean, default: true },
12
+ backgroundColor: { type: String, default: "white" },
13
+ bordered: { type: Boolean, default: false },
14
+ borderRadius: { type: String, default: "rounded-md", acceptedValues: ["none", "sm", "md", "lg", "xl"] },
15
+ flat: { type: Boolean, default: false },
16
+ color: { type: String, default: "indigo" },
17
+ textColor: uiProps.textColor,
18
+ contentClass: uiProps.contentClass,
19
+ contentStyle: uiProps.contentStyle,
20
+ disable: uiProps.disable
21
+ });
22
+ const {
23
+ isHex
24
+ } = useUiClasses(props);
25
+ const emit = defineEmits(["update:modelValue", "change"]);
26
+ const today = /* @__PURE__ */ new Date();
27
+ const currentMonth = ref(today.getMonth());
28
+ const currentYear = ref(today.getFullYear());
29
+ const selectedDates = ref([]);
30
+ const rangeStart = ref(null);
31
+ const rangeEnd = ref(null);
32
+ const headerLabel = computed(() => {
33
+ const first = selectedDates.value[0];
34
+ if (!first) return "No date selected";
35
+ const date = new Date(first);
36
+ const dayName = date.toLocaleDateString("default", {
37
+ weekday: "long"
38
+ });
39
+ return dayName;
40
+ });
41
+ const daysInMonth = computed(() => {
42
+ return new Date(currentYear.value, currentMonth.value + 1, 0).getDate();
43
+ });
44
+ const blankDays = computed(() => {
45
+ return new Date(currentYear.value, currentMonth.value, 1).getDay();
46
+ });
47
+ const days = computed(
48
+ () => Array.from({ length: daysInMonth.value }, (_, i) => i + 1)
49
+ );
50
+ function formatDate(day) {
51
+ const d = new Date(currentYear.value, currentMonth.value, day);
52
+ const year = d.getFullYear();
53
+ const month = String(d.getMonth() + 1).padStart(2, "0");
54
+ const date = String(d.getDate()).padStart(2, "0");
55
+ return `${year}-${month}-${date}`;
56
+ }
57
+ function formatDateString(date, format) {
58
+ const map = {
59
+ YYYY: String(date.getFullYear()),
60
+ MM: String(date.getMonth() + 1).padStart(2, "0"),
61
+ DD: String(date.getDate()).padStart(2, "0"),
62
+ HH: String(date.getHours()).padStart(2, "0"),
63
+ mm: String(date.getMinutes()).padStart(2, "0"),
64
+ ss: String(date.getSeconds()).padStart(2, "0")
65
+ };
66
+ return format.replace(/YYYY|MM|DD|HH|mm|ss/g, (match) => {
67
+ return map[match];
68
+ });
69
+ }
70
+ function isDisabled(day) {
71
+ return props.disabledDates.includes(formatDate(day));
72
+ }
73
+ function isSelected(day) {
74
+ return selectedDates.value.includes(formatDate(day));
75
+ }
76
+ function isToday(day) {
77
+ const d = /* @__PURE__ */ new Date();
78
+ return day === d.getDate() && currentMonth.value === d.getMonth() && currentYear.value === d.getFullYear();
79
+ }
80
+ function isInRange(day) {
81
+ if (rangeStart.value === null || rangeEnd.value === null) return false;
82
+ const start = Math.min(rangeStart.value, rangeEnd.value);
83
+ const end = Math.max(rangeStart.value, rangeEnd.value);
84
+ return day >= start && day <= end;
85
+ }
86
+ function dayClasses(day) {
87
+ if (isDisabled(day)) return "text-gray-300 cursor-not-allowed";
88
+ if (isSelected(day))
89
+ return `bg-${props.color}-600 text-white font-medium`;
90
+ if (props.rangeDate && isInRange(day))
91
+ return `bg-${props.color}-100 text-${props.color}-700`;
92
+ if (isToday(day))
93
+ return `border border-${props.color}-500`;
94
+ return "hover:bg-gray-100";
95
+ }
96
+ function selectDate(day) {
97
+ if (isDisabled(day)) return;
98
+ const value = formatDate(day);
99
+ if (props.multiDate) {
100
+ if (selectedDates.value.includes(value)) {
101
+ selectedDates.value = selectedDates.value.filter((d) => d !== value);
102
+ } else {
103
+ selectedDates.value.push(value);
104
+ }
105
+ } else if (props.rangeDate) {
106
+ if (rangeStart.value === null) {
107
+ rangeStart.value = day;
108
+ rangeEnd.value = null;
109
+ } else {
110
+ rangeEnd.value = day;
111
+ selectedDates.value = buildRange();
112
+ }
113
+ } else {
114
+ selectedDates.value = [value];
115
+ }
116
+ emit("update:modelValue", selectedDates.value);
117
+ emit("change", selectedDates.value);
118
+ }
119
+ function buildRange() {
120
+ if (rangeStart.value === null || rangeEnd.value === null) return [];
121
+ const start = Math.min(rangeStart.value, rangeEnd.value);
122
+ const end = Math.max(rangeStart.value, rangeEnd.value);
123
+ const range = [];
124
+ for (let i = start; i <= end; i++) {
125
+ range.push(formatDate(i));
126
+ }
127
+ return range;
128
+ }
129
+ function nextMonth() {
130
+ if (currentMonth.value === 11) {
131
+ currentMonth.value = 0;
132
+ currentYear.value++;
133
+ } else currentMonth.value++;
134
+ }
135
+ function prevMonth() {
136
+ if (currentMonth.value === 0) {
137
+ currentMonth.value = 11;
138
+ currentYear.value--;
139
+ } else currentMonth.value--;
140
+ }
141
+ watch(
142
+ () => props.modelValue,
143
+ (val) => {
144
+ if (!val) return;
145
+ if (Array.isArray(val)) {
146
+ selectedDates.value = val;
147
+ } else {
148
+ selectedDates.value = [val];
149
+ }
150
+ },
151
+ { immediate: true }
152
+ );
153
+ </script>
154
+
155
+ <template>
156
+ <div class="w-80 min-w-80" :class="[
157
+ borderRadius ? `rounded-${borderRadius}` : '',
158
+ bordered ? 'border border-gray-200' : '',
159
+ flat ? '' : 'shadow-md',
160
+ textColor && !isHex(textColor) ? `text-${textColor}` : 'text-gray-800',
161
+ backgroundColor && !isHex(backgroundColor) ? `bg-${backgroundColor}` : ''
162
+ ]" :style="{
163
+ backgroundColor: isHex(backgroundColor) ? backgroundColor : '',
164
+ color: isHex(textColor) ? textColor : ''
165
+ }">
166
+ <div v-if="showHeader" class="px-4 py-3 flex justify-between items-center"
167
+ :class="bordered ? 'border-b border-gray-200' : ''">
168
+ <div class="text-sm font-semibold text-gray-700">
169
+ <div v-if="multiDate">{{ selectedDates.length }} selected</div>
170
+ <div v-else>
171
+ <div class="text-lg" :class="`text-${color}-600`">{{ headerLabel }}</div>
172
+ <div class="text-gray-700">
173
+ {{ selectedDates[0] ? formatDateString(new Date(selectedDates[0]), format) : "" }}
174
+ </div>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ <div class="flex items-center justify-between px-4 py-2">
179
+ <button @click="prevMonth" class="p-1 rounded hover:bg-gray-100">‹</button>
180
+ <div class="text-sm font-medium text-gray-800">
181
+ {{ new Date(currentYear, currentMonth).toLocaleString("default", { month: "long" }) }}
182
+ {{ currentYear }}
183
+ </div>
184
+ <button @click="nextMonth" class="p-1 rounded hover:bg-gray-100">›</button>
185
+ </div>
186
+ <div class="grid grid-cols-7 text-xs font-medium text-center text-gray-500 px-3 mb-1">
187
+ <div v-for="d in ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']" :key="d">
188
+ {{ d }}
189
+ </div>
190
+ </div>
191
+ <div class="grid grid-cols-7 gap-1 px-3 pb-3">
192
+ <div v-for="n in blankDays" :key="'b' + n"></div>
193
+ <div v-for="day in days" :key="day" @click="selectDate(day)"
194
+ class="h-10 flex items-center justify-center text-sm rounded-lg cursor-pointer transition-all duration-150"
195
+ :class="dayClasses(day)">
196
+ {{ day }}
197
+ </div>
198
+ </div>
199
+
200
+ </div>
201
+ </template>
@@ -0,0 +1,137 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ modelValue: {
3
+ type: (StringConstructor | ArrayConstructor)[];
4
+ default: string;
5
+ };
6
+ multiDate: BooleanConstructor;
7
+ rangeDate: BooleanConstructor;
8
+ disabledDates: {
9
+ type: () => string[];
10
+ default: () => never[];
11
+ };
12
+ format: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ showHeader: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
20
+ backgroundColor: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ bordered: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
28
+ borderRadius: {
29
+ type: StringConstructor;
30
+ default: string;
31
+ acceptedValues: string[];
32
+ };
33
+ flat: {
34
+ type: BooleanConstructor;
35
+ default: boolean;
36
+ };
37
+ color: {
38
+ type: StringConstructor;
39
+ default: string;
40
+ };
41
+ textColor: {
42
+ readonly type: StringConstructor;
43
+ readonly default: "";
44
+ };
45
+ contentClass: {
46
+ readonly type: StringConstructor;
47
+ readonly default: "";
48
+ };
49
+ contentStyle: {
50
+ readonly type: StringConstructor;
51
+ readonly default: "";
52
+ };
53
+ disable: {
54
+ readonly type: BooleanConstructor;
55
+ readonly default: false;
56
+ };
57
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
58
+ "update:modelValue": (...args: any[]) => void;
59
+ change: (...args: any[]) => void;
60
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
61
+ modelValue: {
62
+ type: (StringConstructor | ArrayConstructor)[];
63
+ default: string;
64
+ };
65
+ multiDate: BooleanConstructor;
66
+ rangeDate: BooleanConstructor;
67
+ disabledDates: {
68
+ type: () => string[];
69
+ default: () => never[];
70
+ };
71
+ format: {
72
+ type: StringConstructor;
73
+ default: string;
74
+ };
75
+ showHeader: {
76
+ type: BooleanConstructor;
77
+ default: boolean;
78
+ };
79
+ backgroundColor: {
80
+ type: StringConstructor;
81
+ default: string;
82
+ };
83
+ bordered: {
84
+ type: BooleanConstructor;
85
+ default: boolean;
86
+ };
87
+ borderRadius: {
88
+ type: StringConstructor;
89
+ default: string;
90
+ acceptedValues: string[];
91
+ };
92
+ flat: {
93
+ type: BooleanConstructor;
94
+ default: boolean;
95
+ };
96
+ color: {
97
+ type: StringConstructor;
98
+ default: string;
99
+ };
100
+ textColor: {
101
+ readonly type: StringConstructor;
102
+ readonly default: "";
103
+ };
104
+ contentClass: {
105
+ readonly type: StringConstructor;
106
+ readonly default: "";
107
+ };
108
+ contentStyle: {
109
+ readonly type: StringConstructor;
110
+ readonly default: "";
111
+ };
112
+ disable: {
113
+ readonly type: BooleanConstructor;
114
+ readonly default: false;
115
+ };
116
+ }>> & Readonly<{
117
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
118
+ onChange?: ((...args: any[]) => any) | undefined;
119
+ }>, {
120
+ modelValue: string | unknown[];
121
+ contentClass: string;
122
+ contentStyle: string;
123
+ textColor: string;
124
+ disable: boolean;
125
+ color: string;
126
+ backgroundColor: string;
127
+ flat: boolean;
128
+ bordered: boolean;
129
+ borderRadius: string;
130
+ multiDate: boolean;
131
+ rangeDate: boolean;
132
+ disabledDates: string[];
133
+ format: string;
134
+ showHeader: boolean;
135
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
136
+ declare const _default: typeof __VLS_export;
137
+ export default _default;
@@ -0,0 +1,103 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
+ type __VLS_WithSlots<T, S> = T & (new () => {
5
+ $slots: S;
6
+ });
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ isOpen: {
9
+ type: BooleanConstructor;
10
+ required: true;
11
+ };
12
+ title: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ message: {
17
+ type: StringConstructor;
18
+ default: string;
19
+ };
20
+ confirmBtnText: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ cancelBtnText: {
25
+ type: StringConstructor;
26
+ default: string;
27
+ };
28
+ showConfirmBtn: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ showCloseIcon: {
33
+ type: BooleanConstructor;
34
+ default: boolean;
35
+ };
36
+ persistent: {
37
+ type: BooleanConstructor;
38
+ default: boolean;
39
+ };
40
+ position: {
41
+ type: StringConstructor;
42
+ default: string;
43
+ validator: (val: unknown) => any;
44
+ };
45
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
46
+ "update:isOpen": (...args: any[]) => void;
47
+ confirm: (...args: any[]) => void;
48
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
49
+ isOpen: {
50
+ type: BooleanConstructor;
51
+ required: true;
52
+ };
53
+ title: {
54
+ type: StringConstructor;
55
+ default: string;
56
+ };
57
+ message: {
58
+ type: StringConstructor;
59
+ default: string;
60
+ };
61
+ confirmBtnText: {
62
+ type: StringConstructor;
63
+ default: string;
64
+ };
65
+ cancelBtnText: {
66
+ type: StringConstructor;
67
+ default: string;
68
+ };
69
+ showConfirmBtn: {
70
+ type: BooleanConstructor;
71
+ default: boolean;
72
+ };
73
+ showCloseIcon: {
74
+ type: BooleanConstructor;
75
+ default: boolean;
76
+ };
77
+ persistent: {
78
+ type: BooleanConstructor;
79
+ default: boolean;
80
+ };
81
+ position: {
82
+ type: StringConstructor;
83
+ default: string;
84
+ validator: (val: unknown) => any;
85
+ };
86
+ }>> & Readonly<{
87
+ "onUpdate:isOpen"?: ((...args: any[]) => any) | undefined;
88
+ onConfirm?: ((...args: any[]) => any) | undefined;
89
+ }>, {
90
+ title: string;
91
+ position: string;
92
+ message: string;
93
+ confirmBtnText: string;
94
+ cancelBtnText: string;
95
+ showConfirmBtn: boolean;
96
+ showCloseIcon: boolean;
97
+ persistent: boolean;
98
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
99
+ type __VLS_Slots = {
100
+ title?: ((props: {}) => any) | undefined;
101
+ } & {
102
+ message?: ((props: {}) => any) | undefined;
103
+ };
@@ -57,131 +57,96 @@
57
57
  </template>
58
58
 
59
59
  <script setup>
60
- import { computed, watch, onBeforeUnmount } from 'vue';
61
- import { useRouter } from 'vue-router';
62
-
60
+ import { computed, watch, onBeforeUnmount } from "vue";
61
+ import { useRouter } from "vue-router";
63
62
  const props = defineProps({
64
63
  isOpen: {
65
64
  type: Boolean,
66
- required: true,
65
+ required: true
67
66
  },
68
67
  title: {
69
68
  type: String,
70
- default: 'Modal Title',
69
+ default: "Modal Title"
71
70
  },
72
71
  message: {
73
72
  type: String,
74
- default: '',
73
+ default: ""
75
74
  },
76
75
  confirmBtnText: {
77
76
  type: String,
78
- default: 'Confirm',
77
+ default: "Confirm"
79
78
  },
80
79
  cancelBtnText: {
81
80
  type: String,
82
- default: 'Cancel',
81
+ default: "Cancel"
83
82
  },
84
83
  showConfirmBtn: {
85
84
  type: Boolean,
86
- default: false,
85
+ default: false
87
86
  },
88
87
  showCloseIcon: {
89
88
  type: Boolean,
90
- default: false,
89
+ default: false
91
90
  },
92
91
  persistent: {
93
92
  type: Boolean,
94
- default: false,
93
+ default: false
95
94
  },
96
95
  position: {
97
96
  type: String,
98
- default: 'center',
99
- validator: (val) =>
100
- ['center', 'top', 'bottom', 'left', 'right'].includes(val),
101
- },
97
+ default: "center",
98
+ validator: (val) => ["center", "top", "bottom", "left", "right"].includes(val)
99
+ }
102
100
  });
103
-
104
- const emit = defineEmits(['update:isOpen', 'confirm']);
101
+ const emit = defineEmits(["update:isOpen", "confirm"]);
105
102
  const router = useRouter();
106
-
107
- const close = () => emit('update:isOpen', false);
108
-
103
+ const close = () => emit("update:isOpen", false);
109
104
  const handleConfirm = () => {
110
- emit('confirm');
105
+ emit("confirm");
111
106
  close();
112
107
  };
113
-
114
108
  const handleOutsideClick = () => {
115
109
  if (!props.persistent) close();
116
110
  };
117
-
118
111
  const handleEscKey = (event) => {
119
- if (event.key === 'Escape' && !props.persistent) {
112
+ if (event.key === "Escape" && !props.persistent) {
120
113
  close();
121
114
  }
122
115
  };
123
-
124
116
  const positionClasses = computed(() => {
125
117
  switch (props.position) {
126
- case 'top':
127
- return 'items-start justify-center p-6';
128
- case 'bottom':
129
- return 'items-end justify-center p-6';
130
- case 'left':
131
- return 'items-center justify-start p-6';
132
- case 'right':
133
- return 'items-center justify-end p-6';
118
+ case "top":
119
+ return "items-start justify-center p-6";
120
+ case "bottom":
121
+ return "items-end justify-center p-6";
122
+ case "left":
123
+ return "items-center justify-start p-6";
124
+ case "right":
125
+ return "items-center justify-end p-6";
134
126
  default:
135
- return 'items-center justify-center p-6';
127
+ return "items-center justify-center p-6";
136
128
  }
137
129
  });
138
-
139
- /* Handle ESC key */
140
130
  watch(
141
131
  () => props.isOpen,
142
132
  (open) => {
143
133
  if (open) {
144
- document.addEventListener('keydown', handleEscKey);
134
+ document.addEventListener("keydown", handleEscKey);
145
135
  } else {
146
- document.removeEventListener('keydown', handleEscKey);
136
+ document.removeEventListener("keydown", handleEscKey);
147
137
  }
148
138
  }
149
139
  );
150
-
151
- /* Close modal on route change */
152
140
  const removeGuard = router.beforeEach((to, from, next) => {
153
141
  if (props.isOpen && !props.persistent) close();
154
142
  next();
155
143
  });
156
-
157
144
  onBeforeUnmount(() => {
158
- document.removeEventListener('keydown', handleEscKey);
145
+ document.removeEventListener("keydown", handleEscKey);
159
146
  removeGuard?.();
160
147
  });
161
148
  </script>
162
149
 
163
150
  <style scoped>
164
- .fade-enter-active {
165
- animation: fadeInScale 0.3s ease forwards;
166
- }
167
-
168
- .fade-leave-active {
169
- transition: opacity 0.3s ease, transform 0.3s ease;
170
- }
171
-
172
- @keyframes fadeInScale {
173
- from {
174
- opacity: 0;
175
- transform: scale(0.9);
176
- }
177
- to {
178
- opacity: 1;
179
- transform: scale(1);
180
- }
181
- }
182
-
183
- .fade-leave-to {
184
- opacity: 0;
185
- transform: scale(0.9);
186
- }
151
+ .fade-enter-active{animation:fadeInScale .3s ease forwards}.fade-leave-active{transition:opacity .3s ease,transform .3s ease}@keyframes fadeInScale{0%{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}.fade-leave-to{opacity:0;transform:scale(.9)}
187
152
  </style>
@@ -0,0 +1,103 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
+ type __VLS_WithSlots<T, S> = T & (new () => {
5
+ $slots: S;
6
+ });
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ isOpen: {
9
+ type: BooleanConstructor;
10
+ required: true;
11
+ };
12
+ title: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ message: {
17
+ type: StringConstructor;
18
+ default: string;
19
+ };
20
+ confirmBtnText: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ cancelBtnText: {
25
+ type: StringConstructor;
26
+ default: string;
27
+ };
28
+ showConfirmBtn: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ showCloseIcon: {
33
+ type: BooleanConstructor;
34
+ default: boolean;
35
+ };
36
+ persistent: {
37
+ type: BooleanConstructor;
38
+ default: boolean;
39
+ };
40
+ position: {
41
+ type: StringConstructor;
42
+ default: string;
43
+ validator: (val: unknown) => any;
44
+ };
45
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
46
+ "update:isOpen": (...args: any[]) => void;
47
+ confirm: (...args: any[]) => void;
48
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
49
+ isOpen: {
50
+ type: BooleanConstructor;
51
+ required: true;
52
+ };
53
+ title: {
54
+ type: StringConstructor;
55
+ default: string;
56
+ };
57
+ message: {
58
+ type: StringConstructor;
59
+ default: string;
60
+ };
61
+ confirmBtnText: {
62
+ type: StringConstructor;
63
+ default: string;
64
+ };
65
+ cancelBtnText: {
66
+ type: StringConstructor;
67
+ default: string;
68
+ };
69
+ showConfirmBtn: {
70
+ type: BooleanConstructor;
71
+ default: boolean;
72
+ };
73
+ showCloseIcon: {
74
+ type: BooleanConstructor;
75
+ default: boolean;
76
+ };
77
+ persistent: {
78
+ type: BooleanConstructor;
79
+ default: boolean;
80
+ };
81
+ position: {
82
+ type: StringConstructor;
83
+ default: string;
84
+ validator: (val: unknown) => any;
85
+ };
86
+ }>> & Readonly<{
87
+ "onUpdate:isOpen"?: ((...args: any[]) => any) | undefined;
88
+ onConfirm?: ((...args: any[]) => any) | undefined;
89
+ }>, {
90
+ title: string;
91
+ position: string;
92
+ message: string;
93
+ confirmBtnText: string;
94
+ cancelBtnText: string;
95
+ showConfirmBtn: boolean;
96
+ showCloseIcon: boolean;
97
+ persistent: boolean;
98
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
99
+ type __VLS_Slots = {
100
+ title?: ((props: {}) => any) | undefined;
101
+ } & {
102
+ message?: ((props: {}) => any) | undefined;
103
+ };