windly-ui 1.0.2 → 1.0.4

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 (103) hide show
  1. package/{ui-library/dist → dist}/module.json +2 -2
  2. package/dist/module.mjs +33 -0
  3. package/dist/runtime/components/Accordion.d.vue.ts +39 -0
  4. package/dist/runtime/components/Accordion.vue +96 -0
  5. package/dist/runtime/components/Accordion.vue.d.ts +39 -0
  6. package/dist/runtime/components/Alert.d.vue.ts +83 -0
  7. package/dist/runtime/components/Alert.vue +78 -0
  8. package/dist/runtime/components/Alert.vue.d.ts +83 -0
  9. package/dist/runtime/components/Avatar.d.vue.ts +141 -0
  10. package/dist/runtime/components/Avatar.vue +72 -0
  11. package/dist/runtime/components/Avatar.vue.d.ts +141 -0
  12. package/dist/runtime/components/Badge.d.vue.ts +133 -0
  13. package/dist/runtime/components/Badge.vue +99 -0
  14. package/dist/runtime/components/Badge.vue.d.ts +133 -0
  15. package/dist/runtime/components/Breadcrumbs.d.vue.ts +83 -0
  16. package/dist/runtime/components/Breadcrumbs.vue +116 -0
  17. package/dist/runtime/components/Breadcrumbs.vue.d.ts +83 -0
  18. package/dist/runtime/components/Button.d.vue.ts +208 -0
  19. package/dist/runtime/components/Button.vue +126 -0
  20. package/dist/runtime/components/Button.vue.d.ts +208 -0
  21. package/dist/runtime/components/Card.d.vue.ts +83 -0
  22. package/dist/runtime/components/Card.vue +71 -0
  23. package/dist/runtime/components/Card.vue.d.ts +83 -0
  24. package/dist/runtime/components/Checkbox.d.vue.ts +190 -0
  25. package/dist/runtime/components/Checkbox.vue +125 -0
  26. package/dist/runtime/components/Checkbox.vue.d.ts +190 -0
  27. package/dist/runtime/components/CodeBlock.d.vue.ts +16 -0
  28. package/dist/runtime/components/CodeBlock.vue +75 -0
  29. package/dist/runtime/components/CodeBlock.vue.d.ts +16 -0
  30. package/dist/runtime/components/ColorPicker.d.vue.ts +91 -0
  31. package/dist/runtime/components/ColorPicker.vue +244 -0
  32. package/dist/runtime/components/ColorPicker.vue.d.ts +91 -0
  33. package/dist/runtime/components/Date.d.vue.ts +137 -0
  34. package/dist/runtime/components/Date.vue +201 -0
  35. package/dist/runtime/components/Date.vue.d.ts +137 -0
  36. package/dist/runtime/components/Dialog.d.vue.ts +63 -0
  37. package/dist/runtime/components/Dialog.vue +85 -0
  38. package/dist/runtime/components/Dialog.vue.d.ts +63 -0
  39. package/dist/runtime/components/Divider.d.vue.ts +51 -0
  40. package/dist/runtime/components/Divider.vue +52 -0
  41. package/dist/runtime/components/Divider.vue.d.ts +51 -0
  42. package/dist/runtime/components/Drawer.d.vue.ts +30 -0
  43. package/dist/runtime/components/Drawer.vue +43 -0
  44. package/dist/runtime/components/Drawer.vue.d.ts +30 -0
  45. package/dist/runtime/components/Dropdown.d.vue.ts +34 -0
  46. package/dist/runtime/components/Dropdown.vue +127 -0
  47. package/dist/runtime/components/Dropdown.vue.d.ts +34 -0
  48. package/dist/runtime/components/FileUploader.d.vue.ts +65 -0
  49. package/dist/runtime/components/FileUploader.vue +358 -0
  50. package/dist/runtime/components/FileUploader.vue.d.ts +65 -0
  51. package/dist/runtime/components/Icon.d.vue.ts +41 -0
  52. package/dist/runtime/components/Icon.vue +66 -0
  53. package/dist/runtime/components/Icon.vue.d.ts +41 -0
  54. package/dist/runtime/components/Image.d.vue.ts +77 -0
  55. package/dist/runtime/components/Image.vue +61 -0
  56. package/dist/runtime/components/Image.vue.d.ts +77 -0
  57. package/dist/runtime/components/Input.d.vue.ts +68 -0
  58. package/dist/runtime/components/Input.vue +241 -0
  59. package/dist/runtime/components/Input.vue.d.ts +68 -0
  60. package/dist/runtime/components/Radio.d.vue.ts +41 -0
  61. package/dist/runtime/components/Radio.vue +222 -0
  62. package/dist/runtime/components/Radio.vue.d.ts +41 -0
  63. package/dist/runtime/components/ScrollArea.d.vue.ts +79 -0
  64. package/dist/runtime/components/ScrollArea.vue +36 -0
  65. package/dist/runtime/components/ScrollArea.vue.d.ts +79 -0
  66. package/dist/runtime/components/Select.d.vue.ts +51 -0
  67. package/dist/runtime/components/Select.vue +271 -0
  68. package/dist/runtime/components/Select.vue.d.ts +51 -0
  69. package/dist/runtime/components/Stepper.d.vue.ts +46 -0
  70. package/dist/runtime/components/Stepper.vue +218 -0
  71. package/dist/runtime/components/Stepper.vue.d.ts +46 -0
  72. package/dist/runtime/components/TabPanel.d.vue.ts +17 -0
  73. package/dist/runtime/components/TabPanel.vue +21 -0
  74. package/dist/runtime/components/TabPanel.vue.d.ts +17 -0
  75. package/dist/runtime/components/Table.d.vue.ts +40 -0
  76. package/dist/runtime/components/Table.vue +92 -0
  77. package/dist/runtime/components/Table.vue.d.ts +40 -0
  78. package/dist/runtime/components/Tabs.d.vue.ts +20 -0
  79. package/dist/runtime/components/Tabs.vue +62 -0
  80. package/dist/runtime/components/Tabs.vue.d.ts +20 -0
  81. package/dist/runtime/components/Textarea.d.vue.ts +208 -0
  82. package/dist/runtime/components/Textarea.vue +185 -0
  83. package/dist/runtime/components/Textarea.vue.d.ts +208 -0
  84. package/dist/runtime/components/Toggle.d.vue.ts +36 -0
  85. package/dist/runtime/components/Toggle.vue +173 -0
  86. package/dist/runtime/components/Toggle.vue.d.ts +36 -0
  87. package/dist/runtime/components/Tooltip.d.vue.ts +63 -0
  88. package/dist/runtime/components/Tooltip.vue +144 -0
  89. package/dist/runtime/components/Tooltip.vue.d.ts +63 -0
  90. package/dist/runtime/components/uiProps.d.ts +38 -0
  91. package/dist/runtime/components/uiProps.js +11 -0
  92. package/dist/runtime/components/useUiClasses.d.ts +43 -0
  93. package/dist/runtime/components/useUiClasses.js +124 -0
  94. package/dist/runtime/composables/plugin.d.ts +2 -0
  95. package/dist/runtime/composables/plugin.js +3 -0
  96. package/dist/runtime/tailwind-color.d.ts +2 -0
  97. package/dist/runtime/tailwind-color.js +5859 -0
  98. package/package.json +12 -46
  99. package/LICENSE +0 -21
  100. package/README.md +0 -232
  101. package/ui-library/dist/module.mjs +0 -22
  102. /package/{ui-library/dist → dist}/module.d.mts +0 -0
  103. /package/{ui-library/dist → dist}/types.d.mts +0 -0
@@ -0,0 +1,208 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ contentClass: {
3
+ readonly type: StringConstructor;
4
+ readonly default: "";
5
+ };
6
+ contentStyle: {
7
+ readonly type: StringConstructor;
8
+ readonly default: "";
9
+ };
10
+ textColor: {
11
+ readonly type: StringConstructor;
12
+ readonly default: "";
13
+ };
14
+ disable: {
15
+ readonly type: BooleanConstructor;
16
+ readonly default: false;
17
+ };
18
+ loading: {
19
+ readonly type: BooleanConstructor;
20
+ readonly default: false;
21
+ };
22
+ color: {
23
+ readonly type: StringConstructor;
24
+ readonly default: "blue-900";
25
+ };
26
+ rounded: {
27
+ readonly type: StringConstructor;
28
+ readonly default: "md";
29
+ };
30
+ size: {
31
+ readonly type: StringConstructor;
32
+ readonly default: "md";
33
+ };
34
+ iconSize: {
35
+ readonly type: StringConstructor;
36
+ readonly default: "lg";
37
+ };
38
+ modelValue: {
39
+ type: StringConstructor;
40
+ default: string;
41
+ };
42
+ label: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ placeholder: {
47
+ type: StringConstructor;
48
+ default: string;
49
+ };
50
+ rows: {
51
+ type: NumberConstructor;
52
+ default: number;
53
+ };
54
+ maxRows: {
55
+ type: NumberConstructor;
56
+ default: number;
57
+ };
58
+ autoGrow: {
59
+ type: BooleanConstructor;
60
+ default: boolean;
61
+ };
62
+ readonly: {
63
+ type: BooleanConstructor;
64
+ default: boolean;
65
+ };
66
+ error: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
70
+ errorMessage: {
71
+ type: StringConstructor;
72
+ default: string;
73
+ };
74
+ hint: {
75
+ type: StringConstructor;
76
+ default: string;
77
+ };
78
+ showWordCount: {
79
+ type: BooleanConstructor;
80
+ default: boolean;
81
+ };
82
+ showCharCount: {
83
+ type: BooleanConstructor;
84
+ default: boolean;
85
+ };
86
+ maxlength: {
87
+ type: NumberConstructor;
88
+ default: undefined;
89
+ };
90
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
91
+ "update:modelValue": (...args: any[]) => void;
92
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
93
+ contentClass: {
94
+ readonly type: StringConstructor;
95
+ readonly default: "";
96
+ };
97
+ contentStyle: {
98
+ readonly type: StringConstructor;
99
+ readonly default: "";
100
+ };
101
+ textColor: {
102
+ readonly type: StringConstructor;
103
+ readonly default: "";
104
+ };
105
+ disable: {
106
+ readonly type: BooleanConstructor;
107
+ readonly default: false;
108
+ };
109
+ loading: {
110
+ readonly type: BooleanConstructor;
111
+ readonly default: false;
112
+ };
113
+ color: {
114
+ readonly type: StringConstructor;
115
+ readonly default: "blue-900";
116
+ };
117
+ rounded: {
118
+ readonly type: StringConstructor;
119
+ readonly default: "md";
120
+ };
121
+ size: {
122
+ readonly type: StringConstructor;
123
+ readonly default: "md";
124
+ };
125
+ iconSize: {
126
+ readonly type: StringConstructor;
127
+ readonly default: "lg";
128
+ };
129
+ modelValue: {
130
+ type: StringConstructor;
131
+ default: string;
132
+ };
133
+ label: {
134
+ type: StringConstructor;
135
+ default: string;
136
+ };
137
+ placeholder: {
138
+ type: StringConstructor;
139
+ default: string;
140
+ };
141
+ rows: {
142
+ type: NumberConstructor;
143
+ default: number;
144
+ };
145
+ maxRows: {
146
+ type: NumberConstructor;
147
+ default: number;
148
+ };
149
+ autoGrow: {
150
+ type: BooleanConstructor;
151
+ default: boolean;
152
+ };
153
+ readonly: {
154
+ type: BooleanConstructor;
155
+ default: boolean;
156
+ };
157
+ error: {
158
+ type: BooleanConstructor;
159
+ default: boolean;
160
+ };
161
+ errorMessage: {
162
+ type: StringConstructor;
163
+ default: string;
164
+ };
165
+ hint: {
166
+ type: StringConstructor;
167
+ default: string;
168
+ };
169
+ showWordCount: {
170
+ type: BooleanConstructor;
171
+ default: boolean;
172
+ };
173
+ showCharCount: {
174
+ type: BooleanConstructor;
175
+ default: boolean;
176
+ };
177
+ maxlength: {
178
+ type: NumberConstructor;
179
+ default: undefined;
180
+ };
181
+ }>> & Readonly<{
182
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
183
+ }>, {
184
+ modelValue: string;
185
+ label: string;
186
+ contentClass: string;
187
+ contentStyle: string;
188
+ textColor: string;
189
+ disable: boolean;
190
+ loading: boolean;
191
+ color: string;
192
+ rounded: string;
193
+ size: string;
194
+ iconSize: string;
195
+ placeholder: string;
196
+ readonly: boolean;
197
+ error: boolean;
198
+ hint: string;
199
+ errorMessage: string;
200
+ maxlength: number;
201
+ rows: number;
202
+ maxRows: number;
203
+ autoGrow: boolean;
204
+ showWordCount: boolean;
205
+ showCharCount: boolean;
206
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
207
+ declare const _default: typeof __VLS_export;
208
+ export default _default;
@@ -0,0 +1,36 @@
1
+ type LabelPosition = 'top' | 'bottom' | 'left' | 'right';
2
+ type ToggleSize = 'small' | 'medium' | 'large';
3
+ type __VLS_Props = {
4
+ modelValue?: boolean | string | number;
5
+ label?: string;
6
+ labelPosition?: LabelPosition;
7
+ customClasses?: string;
8
+ trueColor?: string;
9
+ falseColor?: string;
10
+ size?: ToggleSize;
11
+ activeValue?: string | number | boolean;
12
+ inactiveValue?: string | number | boolean;
13
+ activeIcon?: string;
14
+ inactiveIcon?: string;
15
+ disable?: boolean;
16
+ };
17
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
18
+ "update:modelValue": (value: string | number | boolean) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
+ "onUpdate:modelValue"?: ((value: string | number | boolean) => any) | undefined;
21
+ }>, {
22
+ modelValue: boolean | string | number;
23
+ label: string;
24
+ disable: boolean;
25
+ size: ToggleSize;
26
+ labelPosition: LabelPosition;
27
+ customClasses: string;
28
+ trueColor: string;
29
+ falseColor: string;
30
+ activeValue: string | number | boolean;
31
+ inactiveValue: string | number | boolean;
32
+ activeIcon: string;
33
+ inactiveIcon: string;
34
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
+ declare const _default: typeof __VLS_export;
36
+ export default _default;
@@ -0,0 +1,173 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ defineOptions({
4
+ name: "UIToggle"
5
+ });
6
+ const props = defineProps({
7
+ modelValue: { type: [Boolean, String, Number], required: false, default: false },
8
+ label: { type: String, required: false, default: "" },
9
+ labelPosition: { type: String, required: false, default: "right" },
10
+ customClasses: { type: String, required: false, default: "" },
11
+ trueColor: { type: String, required: false, default: "blue-500" },
12
+ falseColor: { type: String, required: false, default: "gray-300" },
13
+ size: { type: String, required: false, default: "medium" },
14
+ activeValue: { type: [String, Number, Boolean], required: false, default: true },
15
+ inactiveValue: { type: [String, Number, Boolean], required: false, default: false },
16
+ activeIcon: { type: String, required: false, default: "" },
17
+ inactiveIcon: { type: String, required: false, default: "" },
18
+ disable: { type: Boolean, required: false, default: false }
19
+ });
20
+ const emit = defineEmits(["update:modelValue"]);
21
+ const isHex = (val) => {
22
+ return val.startsWith("#") || val.startsWith("rgb") || val.startsWith("hsl");
23
+ };
24
+ const isActive = computed(
25
+ () => props.modelValue === props.activeValue
26
+ );
27
+ const toggleSize = computed(() => {
28
+ switch (props.size) {
29
+ case "small":
30
+ return {
31
+ bg: "w-10 h-5",
32
+ dot: "w-4 h-4 top-0.5 left-0.5",
33
+ translate: "translate-x-5"
34
+ };
35
+ case "large":
36
+ return {
37
+ bg: "w-16 h-9",
38
+ dot: "w-7 h-7 top-1 left-1",
39
+ translate: "translate-x-7"
40
+ };
41
+ case "medium":
42
+ default:
43
+ return {
44
+ bg: "w-14 h-8",
45
+ dot: "w-6 h-6 top-1 left-1",
46
+ translate: "translate-x-6"
47
+ };
48
+ }
49
+ });
50
+ const toggleBgClasses = computed(
51
+ () => [
52
+ !isHex(props.trueColor) && isActive.value ? `bg-${props.trueColor}` : "",
53
+ !isHex(props.falseColor) && !isActive.value ? `bg-${props.falseColor}` : ""
54
+ ]
55
+ );
56
+ const toggleBgStyle = computed(
57
+ () => {
58
+ const style = {};
59
+ if (isActive.value && isHex(props.trueColor)) {
60
+ style.backgroundColor = props.trueColor;
61
+ }
62
+ if (!isActive.value && isHex(props.falseColor)) {
63
+ style.backgroundColor = props.falseColor;
64
+ }
65
+ return style;
66
+ }
67
+ );
68
+ const toggle = () => {
69
+ if (props.disable)
70
+ return;
71
+ const newValue = isActive.value ? props.inactiveValue : props.activeValue;
72
+ emit(
73
+ "update:modelValue",
74
+ newValue
75
+ );
76
+ };
77
+ </script>
78
+
79
+ <template>
80
+ <div
81
+ :class="[
82
+ 'toggle-container flex items-center',
83
+ customClasses
84
+ ]"
85
+ :style="{
86
+ flexDirection: labelPosition === 'top' || labelPosition === 'bottom' ? 'column' : 'row'
87
+ }"
88
+ >
89
+ <!-- Top Label -->
90
+ <span
91
+ v-if="
92
+ label && labelPosition === 'top'
93
+ "
94
+ class="mb-2 font-medium text-gray-700 dark:text-gray-300"
95
+ >
96
+ {{ label }}
97
+ </span>
98
+
99
+ <!-- Left Label -->
100
+ <span
101
+ v-if="
102
+ label && labelPosition === 'left'
103
+ "
104
+ class="mr-3 font-medium text-gray-700 dark:text-gray-300"
105
+ >
106
+ {{ label }}
107
+ </span>
108
+
109
+ <!-- Toggle -->
110
+ <div
111
+ :class="[
112
+ 'relative inline-flex items-center cursor-pointer',
113
+ {
114
+ 'opacity-50 pointer-events-none': disable
115
+ }
116
+ ]"
117
+ @click="toggle"
118
+ >
119
+ <!-- Background -->
120
+ <span
121
+ :class="[
122
+ 'block rounded-full transition-colors duration-300 ease-in-out',
123
+ toggleSize.bg,
124
+ toggleBgClasses
125
+ ]"
126
+ :style="toggleBgStyle"
127
+ />
128
+
129
+ <!-- Dot -->
130
+ <span
131
+ :class="[
132
+ 'toggle-dot absolute rounded-full bg-white transition-transform duration-300 ease-in-out shadow-md hover:glow-effect flex items-center justify-center',
133
+ toggleSize.dot,
134
+ {
135
+ [toggleSize.translate]: isActive
136
+ }
137
+ ]"
138
+ >
139
+ <span
140
+ class="material-icons text-sm"
141
+ >
142
+ {{
143
+ isActive ? activeIcon : inactiveIcon
144
+ }}
145
+ </span>
146
+ </span>
147
+ </div>
148
+
149
+ <!-- Bottom Label -->
150
+ <span
151
+ v-if="
152
+ label && labelPosition === 'bottom'
153
+ "
154
+ class="mt-2 font-medium text-gray-700 dark:text-gray-300"
155
+ >
156
+ {{ label }}
157
+ </span>
158
+
159
+ <!-- Right Label -->
160
+ <span
161
+ v-if="
162
+ label && labelPosition === 'right'
163
+ "
164
+ class="ml-3 font-medium text-gray-700 dark:text-gray-300"
165
+ >
166
+ {{ label }}
167
+ </span>
168
+ </div>
169
+ </template>
170
+
171
+ <style scoped>
172
+ .toggle-container{-webkit-user-select:none;-moz-user-select:none;user-select:none}.glow-effect{box-shadow:0 0 10px rgba(0,0,0,.15),0 0 10px rgba(0,0,255,.3);transition:box-shadow .3s ease-in-out}.material-icons{color:currentColor;font-size:1rem}
173
+ </style>
@@ -0,0 +1,36 @@
1
+ type LabelPosition = 'top' | 'bottom' | 'left' | 'right';
2
+ type ToggleSize = 'small' | 'medium' | 'large';
3
+ type __VLS_Props = {
4
+ modelValue?: boolean | string | number;
5
+ label?: string;
6
+ labelPosition?: LabelPosition;
7
+ customClasses?: string;
8
+ trueColor?: string;
9
+ falseColor?: string;
10
+ size?: ToggleSize;
11
+ activeValue?: string | number | boolean;
12
+ inactiveValue?: string | number | boolean;
13
+ activeIcon?: string;
14
+ inactiveIcon?: string;
15
+ disable?: boolean;
16
+ };
17
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
18
+ "update:modelValue": (value: string | number | boolean) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
+ "onUpdate:modelValue"?: ((value: string | number | boolean) => any) | undefined;
21
+ }>, {
22
+ modelValue: boolean | string | number;
23
+ label: string;
24
+ disable: boolean;
25
+ size: ToggleSize;
26
+ labelPosition: LabelPosition;
27
+ customClasses: string;
28
+ trueColor: string;
29
+ falseColor: string;
30
+ activeValue: string | number | boolean;
31
+ inactiveValue: string | number | boolean;
32
+ activeIcon: string;
33
+ inactiveIcon: string;
34
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
+ declare const _default: typeof __VLS_export;
36
+ export default _default;
@@ -0,0 +1,63 @@
1
+ type TooltipPlacement = 'top' | 'right' | 'bottom' | 'left';
2
+ declare var __VLS_1: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_1) => any;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
+ text: {
8
+ type: StringConstructor;
9
+ required: true;
10
+ };
11
+ placement: {
12
+ type: () => TooltipPlacement;
13
+ default: string;
14
+ validator: (v: string) => any;
15
+ };
16
+ arrow: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
20
+ color: {
21
+ type: StringConstructor;
22
+ default: string;
23
+ };
24
+ textColor: {
25
+ type: StringConstructor;
26
+ default: string;
27
+ };
28
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
29
+ text: {
30
+ type: StringConstructor;
31
+ required: true;
32
+ };
33
+ placement: {
34
+ type: () => TooltipPlacement;
35
+ default: string;
36
+ validator: (v: string) => any;
37
+ };
38
+ arrow: {
39
+ type: BooleanConstructor;
40
+ default: boolean;
41
+ };
42
+ color: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ textColor: {
47
+ type: StringConstructor;
48
+ default: string;
49
+ };
50
+ }>> & Readonly<{}>, {
51
+ textColor: string;
52
+ color: string;
53
+ placement: TooltipPlacement;
54
+ arrow: boolean;
55
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
56
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
57
+ declare const _default: typeof __VLS_export;
58
+ export default _default;
59
+ type __VLS_WithSlots<T, S> = T & {
60
+ new (): {
61
+ $slots: S;
62
+ };
63
+ };
@@ -0,0 +1,144 @@
1
+ <script setup>
2
+ defineOptions({
3
+ name: "UITooltip",
4
+ inheritAttrs: false
5
+ });
6
+ import { computed, ref } from "vue";
7
+ const props = defineProps({
8
+ text: {
9
+ type: String,
10
+ required: true
11
+ },
12
+ placement: {
13
+ type: String,
14
+ default: "top",
15
+ validator: (v) => ["top", "right", "bottom", "left"].includes(v)
16
+ },
17
+ arrow: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ color: {
22
+ type: String,
23
+ default: "gray-800"
24
+ },
25
+ textColor: {
26
+ type: String,
27
+ default: "white"
28
+ }
29
+ });
30
+ const baseClasses = computed(() => "px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap");
31
+ const visible = ref(false);
32
+ const isHex = (val) => val.startsWith("#");
33
+ const showTooltip = () => {
34
+ visible.value = true;
35
+ };
36
+ const hideTooltip = () => {
37
+ visible.value = false;
38
+ };
39
+ const tooltipStyle = computed(() => {
40
+ const style = {};
41
+ if (isHex(props.color)) {
42
+ style.backgroundColor = props.color;
43
+ }
44
+ if (isHex(props.textColor)) {
45
+ style.color = props.textColor;
46
+ }
47
+ return style;
48
+ });
49
+ const tooltipClasses = computed(() => [
50
+ baseClasses.value,
51
+ !isHex(props.color) ? `bg-${props.color}` : "",
52
+ !isHex(props.textColor) ? `text-${props.textColor}` : ""
53
+ ]);
54
+ const placementClasses = computed(() => {
55
+ switch (props.placement) {
56
+ case "top":
57
+ return "bottom-full left-1/2 -translate-x-1/2 mb-3";
58
+ case "right":
59
+ return "left-full top-1/2 -translate-y-1/2 ml-3";
60
+ case "bottom":
61
+ return "top-full left-1/2 -translate-x-1/2 mt-3";
62
+ case "left":
63
+ return "right-full top-1/2 -translate-y-1/2 mr-3";
64
+ default:
65
+ return "";
66
+ }
67
+ });
68
+ const arrowClasses = computed(() => {
69
+ switch (props.placement) {
70
+ case "top":
71
+ return "left-1/2 -translate-x-1/2 bottom-0 -mb-3.5";
72
+ case "right":
73
+ return "top-1/2 -translate-y-1/2 left-0 -ml-3.5";
74
+ case "bottom":
75
+ return "left-1/2 -translate-x-1/2 top-0 -mt-3.5";
76
+ case "left":
77
+ return "top-1/2 -translate-y-1/2 right-0 -mr-3.5";
78
+ default:
79
+ return "";
80
+ }
81
+ });
82
+ const arrowIcon = computed(() => {
83
+ switch (props.placement) {
84
+ case "top":
85
+ return "arrow_drop_down";
86
+ case "right":
87
+ return "arrow_left";
88
+ case "bottom":
89
+ return "arrow_drop_up";
90
+ case "left":
91
+ return "arrow_right";
92
+ default:
93
+ return "";
94
+ }
95
+ });
96
+ const arrowStyle = computed(() => {
97
+ const style = {};
98
+ if (isHex(props.color))
99
+ style.color = props.color;
100
+ return style;
101
+ });
102
+ </script>
103
+
104
+ <template>
105
+ <div
106
+ class="relative inline-block"
107
+ tabindex="0"
108
+ @mouseenter="showTooltip"
109
+ @mouseleave="hideTooltip"
110
+ @focus="showTooltip"
111
+ @blur="hideTooltip"
112
+ >
113
+ <!-- Trigger -->
114
+ <slot />
115
+
116
+ <!-- Tooltip -->
117
+ <transition name="fade">
118
+ <div
119
+ v-if="visible"
120
+ role="tooltip"
121
+ class="absolute z-50"
122
+ :class="[tooltipClasses, placementClasses]"
123
+ :style="tooltipStyle"
124
+ v-bind="$attrs"
125
+ >
126
+ <!-- Arrow -->
127
+ <i
128
+ v-if="arrow"
129
+ class="material-icons tooltip-arrow"
130
+ :class="[arrowClasses, !isHex(props.color) ? `text-${props.color}` : '']"
131
+ :style="arrowStyle"
132
+ >
133
+ {{ arrowIcon }}
134
+ </i>
135
+
136
+ {{ text }}
137
+ </div>
138
+ </transition>
139
+ </div>
140
+ </template>
141
+
142
+ <style scoped>
143
+ .fade-enter-active,.fade-leave-active{transition:opacity .2s ease}.fade-enter-from,.fade-leave-to{opacity:0}.tooltip-arrow{font-size:1.5rem;line-height:1;position:absolute}
144
+ </style>