windly-ui 1.0.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/README.md +208 -0
- package/app/app.vue +10 -0
- package/app/assets/css/tailwind.css +3 -0
- package/app/components/doc/component.vue +34 -0
- package/app/components/doc/megaSection.vue +56 -0
- package/app/components/doc/section.vue +56 -0
- package/app/pages/_docs.vue +2420 -0
- package/app/pages/index.vue +137 -0
- package/nuxt.config.ts +19 -0
- package/package.json +21 -0
- package/public/doc/avatar.avif +0 -0
- package/public/favicon.ico +0 -0
- package/public/robots.txt +2 -0
- package/tailwind.config.ts +28 -0
- package/tsconfig.json +18 -0
- package/ui-library/components/Accordion.vue +118 -0
- package/ui-library/components/Avatar.vue +121 -0
- package/ui-library/components/Badge.vue +116 -0
- package/ui-library/components/Breadcrumbs.vue +138 -0
- package/ui-library/components/Button.vue +154 -0
- package/ui-library/components/Card.vue +84 -0
- package/ui-library/components/Checkbox.vue +148 -0
- package/ui-library/components/CodeBlock.vue +99 -0
- package/ui-library/components/ColorPicker.vue +302 -0
- package/ui-library/components/Date.vue +240 -0
- package/ui-library/components/Dialog.vue +187 -0
- package/ui-library/components/Divider.vue +78 -0
- package/ui-library/components/Drawer.vue +67 -0
- package/ui-library/components/Dropdown.vue +248 -0
- package/ui-library/components/FileUploader.vue +330 -0
- package/ui-library/components/Icon.vue +82 -0
- package/ui-library/components/Image.vue +78 -0
- package/ui-library/components/Input.vue +531 -0
- package/ui-library/components/Radio.vue +356 -0
- package/ui-library/components/ScrollArea.vue +43 -0
- package/ui-library/components/Select.vue +309 -0
- package/ui-library/components/Stepper.vue +361 -0
- package/ui-library/components/TabPanel.vue +25 -0
- package/ui-library/components/Table.vue +152 -0
- package/ui-library/components/Tabs.vue +71 -0
- package/ui-library/components/Textarea.vue +233 -0
- package/ui-library/components/Toggle.vue +319 -0
- package/ui-library/components/Tooltip.vue +200 -0
- package/ui-library/components/plugin.ts +8 -0
- package/ui-library/components/uiProps.ts +11 -0
- package/ui-library/components/useUiClasses.ts +159 -0
- package/ui-library/module.ts +20 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({
|
|
3
|
+
inheritAttrs: false,
|
|
4
|
+
})
|
|
5
|
+
|
|
6
|
+
import { computed, ref, watch, nextTick } from 'vue'
|
|
7
|
+
import { useUiClasses } from './useUiClasses'
|
|
8
|
+
import { uiProps } from './uiProps'
|
|
9
|
+
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: '',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
label: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: '',
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
placeholder: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: '',
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
rows: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 3,
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
maxRows: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 10,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
autoGrow: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
readonly: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
error: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
errorMessage: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: '',
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
hint: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: '',
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
showWordCount: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
showCharCount: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false,
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
maxlength: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: undefined,
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
...uiProps,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const emit = defineEmits([
|
|
80
|
+
'update:modelValue',
|
|
81
|
+
])
|
|
82
|
+
|
|
83
|
+
const textareaRef = ref<HTMLTextAreaElement>()
|
|
84
|
+
|
|
85
|
+
const {
|
|
86
|
+
contentClass,
|
|
87
|
+
contentStyle,
|
|
88
|
+
|
|
89
|
+
color,
|
|
90
|
+
textColor,
|
|
91
|
+
|
|
92
|
+
rounded,
|
|
93
|
+
size,
|
|
94
|
+
|
|
95
|
+
disable,
|
|
96
|
+
|
|
97
|
+
roundedClass,
|
|
98
|
+
sizeClass,
|
|
99
|
+
|
|
100
|
+
computedContentClass,
|
|
101
|
+
|
|
102
|
+
isHex,
|
|
103
|
+
} = useUiClasses(props)
|
|
104
|
+
|
|
105
|
+
const paddingClass = {
|
|
106
|
+
sm: 'px-3 py-2',
|
|
107
|
+
md: 'px-4 py-3',
|
|
108
|
+
lg: 'px-5 py-4',
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const textareaStyle = computed(() => {
|
|
112
|
+
const style: Record<string, any> = {
|
|
113
|
+
...(typeof contentStyle.value === 'object' && contentStyle.value !== null ? contentStyle.value : {}),
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (isHex(color.value)) {
|
|
117
|
+
style.borderColor = color.value
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (isHex(textColor.value)) {
|
|
121
|
+
style.color = textColor.value
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return style
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const textareaClass = computed(() => {
|
|
128
|
+
// cast keys to the exact key types for the maps so TS can validate indexing
|
|
129
|
+
const rKey = rounded.value as keyof typeof roundedClass
|
|
130
|
+
const sKey = size.value as keyof typeof sizeClass
|
|
131
|
+
const pKey = size.value as keyof typeof paddingClass
|
|
132
|
+
|
|
133
|
+
const rClass = roundedClass[rKey] ?? ''
|
|
134
|
+
const sClass = sizeClass[sKey] ?? ''
|
|
135
|
+
const pClass = paddingClass[pKey] ?? ''
|
|
136
|
+
|
|
137
|
+
let cls = `
|
|
138
|
+
w-full
|
|
139
|
+
border
|
|
140
|
+
transition-all
|
|
141
|
+
duration-300
|
|
142
|
+
focus:outline-none
|
|
143
|
+
focus:ring-2
|
|
144
|
+
${rClass}
|
|
145
|
+
${sClass}
|
|
146
|
+
${pClass}
|
|
147
|
+
`
|
|
148
|
+
|
|
149
|
+
if (disable.value) {
|
|
150
|
+
cls += ' opacity-50 cursor-not-allowed'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (props.error) {
|
|
154
|
+
cls += ' border-red-500'
|
|
155
|
+
} else if (!isHex(color.value)) {
|
|
156
|
+
cls += ` border-${color.value}`
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (textColor.value && !isHex(textColor.value)) {
|
|
160
|
+
cls += ` text-${textColor.value}`
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
cls += ` ${computedContentClass.value}`
|
|
164
|
+
cls += ` ${contentClass.value || ''}`
|
|
165
|
+
|
|
166
|
+
return cls
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const wordCount = computed(() => {
|
|
170
|
+
return props.modelValue
|
|
171
|
+
.trim()
|
|
172
|
+
.split(/\s+/)
|
|
173
|
+
.filter(Boolean)
|
|
174
|
+
.length
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const charCount = computed(() => {
|
|
178
|
+
return props.modelValue.length
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
function updateValue(event: Event) {
|
|
182
|
+
emit(
|
|
183
|
+
'update:modelValue',
|
|
184
|
+
(event.target as HTMLTextAreaElement).value
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function resizeTextarea() {
|
|
189
|
+
if (!props.autoGrow) return
|
|
190
|
+
if (!textareaRef.value) return
|
|
191
|
+
|
|
192
|
+
textareaRef.value.style.height = 'auto'
|
|
193
|
+
textareaRef.value.style.height =
|
|
194
|
+
textareaRef.value.scrollHeight + 'px'
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
watch(
|
|
198
|
+
() => props.modelValue,
|
|
199
|
+
async () => {
|
|
200
|
+
await nextTick()
|
|
201
|
+
resizeTextarea()
|
|
202
|
+
},
|
|
203
|
+
{ immediate: true }
|
|
204
|
+
)
|
|
205
|
+
</script>
|
|
206
|
+
<template>
|
|
207
|
+
<div class="flex flex-col gap-1">
|
|
208
|
+
<label v-if="label" class="font-medium">
|
|
209
|
+
{{ label }}
|
|
210
|
+
</label>
|
|
211
|
+
|
|
212
|
+
<textarea ref="textareaRef" :value="modelValue" :rows="rows" :placeholder="placeholder" :disabled="disable"
|
|
213
|
+
:readonly="readonly" :maxlength="maxlength" :class="textareaClass" :style="textareaStyle"
|
|
214
|
+
@input="updateValue" v-bind="$attrs" />
|
|
215
|
+
<div class="flex justify-between text-xs text-gray-500">
|
|
216
|
+
<span>
|
|
217
|
+
{{ error ? errorMessage : hint }}
|
|
218
|
+
</span>
|
|
219
|
+
<span class="flex gap-3">
|
|
220
|
+
<span v-if="showWordCount">
|
|
221
|
+
{{ wordCount }} words
|
|
222
|
+
</span>
|
|
223
|
+
|
|
224
|
+
<span v-if="showCharCount">
|
|
225
|
+
{{ charCount }}
|
|
226
|
+
<template v-if="maxlength">
|
|
227
|
+
/ {{ maxlength }}
|
|
228
|
+
</template>
|
|
229
|
+
</span>
|
|
230
|
+
</span>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
</template>
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineOptions({
|
|
5
|
+
name: 'UIToggle',
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
type LabelPosition =
|
|
9
|
+
| 'top'
|
|
10
|
+
| 'bottom'
|
|
11
|
+
| 'left'
|
|
12
|
+
| 'right'
|
|
13
|
+
|
|
14
|
+
type ToggleSize =
|
|
15
|
+
| 'small'
|
|
16
|
+
| 'medium'
|
|
17
|
+
| 'large'
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(
|
|
20
|
+
defineProps<{
|
|
21
|
+
modelValue?: boolean | string | number
|
|
22
|
+
|
|
23
|
+
label?: string
|
|
24
|
+
|
|
25
|
+
labelPosition?: LabelPosition
|
|
26
|
+
|
|
27
|
+
customClasses?: string
|
|
28
|
+
|
|
29
|
+
trueColor?: string
|
|
30
|
+
|
|
31
|
+
falseColor?: string
|
|
32
|
+
|
|
33
|
+
size?: ToggleSize
|
|
34
|
+
|
|
35
|
+
activeValue?: string | number | boolean
|
|
36
|
+
|
|
37
|
+
inactiveValue?: string | number | boolean
|
|
38
|
+
|
|
39
|
+
activeIcon?: string
|
|
40
|
+
|
|
41
|
+
inactiveIcon?: string
|
|
42
|
+
|
|
43
|
+
disable?: boolean
|
|
44
|
+
}>(),
|
|
45
|
+
{
|
|
46
|
+
modelValue: false,
|
|
47
|
+
|
|
48
|
+
label: '',
|
|
49
|
+
|
|
50
|
+
labelPosition: 'right',
|
|
51
|
+
|
|
52
|
+
customClasses: '',
|
|
53
|
+
|
|
54
|
+
trueColor: 'blue-500',
|
|
55
|
+
|
|
56
|
+
falseColor: 'gray-300',
|
|
57
|
+
|
|
58
|
+
size: 'medium',
|
|
59
|
+
|
|
60
|
+
activeValue: true,
|
|
61
|
+
|
|
62
|
+
inactiveValue: false,
|
|
63
|
+
|
|
64
|
+
activeIcon: '',
|
|
65
|
+
|
|
66
|
+
inactiveIcon: '',
|
|
67
|
+
|
|
68
|
+
disable: false,
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
const emit = defineEmits<{
|
|
73
|
+
(
|
|
74
|
+
e: 'update:modelValue',
|
|
75
|
+
value:
|
|
76
|
+
| boolean
|
|
77
|
+
| string
|
|
78
|
+
| number,
|
|
79
|
+
): void
|
|
80
|
+
}>()
|
|
81
|
+
|
|
82
|
+
const isHex = (val: string) => {
|
|
83
|
+
return (
|
|
84
|
+
val.startsWith('#') ||
|
|
85
|
+
val.startsWith('rgb') ||
|
|
86
|
+
val.startsWith('hsl')
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const isActive = computed(
|
|
91
|
+
() =>
|
|
92
|
+
props.modelValue ===
|
|
93
|
+
props.activeValue,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const toggleSize = computed(() => {
|
|
97
|
+
switch (props.size) {
|
|
98
|
+
case 'small':
|
|
99
|
+
return {
|
|
100
|
+
bg: 'w-10 h-5',
|
|
101
|
+
|
|
102
|
+
dot: 'w-4 h-4 top-0.5 left-0.5',
|
|
103
|
+
|
|
104
|
+
translate:
|
|
105
|
+
'translate-x-5',
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
case 'large':
|
|
109
|
+
return {
|
|
110
|
+
bg: 'w-16 h-9',
|
|
111
|
+
|
|
112
|
+
dot: 'w-7 h-7 top-1 left-1',
|
|
113
|
+
|
|
114
|
+
translate:
|
|
115
|
+
'translate-x-7',
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'medium':
|
|
119
|
+
default:
|
|
120
|
+
return {
|
|
121
|
+
bg: 'w-14 h-8',
|
|
122
|
+
|
|
123
|
+
dot: 'w-6 h-6 top-1 left-1',
|
|
124
|
+
|
|
125
|
+
translate:
|
|
126
|
+
'translate-x-6',
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const toggleBgClasses = computed(
|
|
132
|
+
() => [
|
|
133
|
+
!isHex(props.trueColor) &&
|
|
134
|
+
isActive.value
|
|
135
|
+
? `bg-${props.trueColor}`
|
|
136
|
+
: '',
|
|
137
|
+
|
|
138
|
+
!isHex(props.falseColor) &&
|
|
139
|
+
!isActive.value
|
|
140
|
+
? `bg-${props.falseColor}`
|
|
141
|
+
: '',
|
|
142
|
+
],
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
const toggleBgStyle = computed(
|
|
146
|
+
() => {
|
|
147
|
+
const style: Record<
|
|
148
|
+
string,
|
|
149
|
+
string
|
|
150
|
+
> = {}
|
|
151
|
+
|
|
152
|
+
if (
|
|
153
|
+
isActive.value &&
|
|
154
|
+
isHex(props.trueColor)
|
|
155
|
+
) {
|
|
156
|
+
style.backgroundColor =
|
|
157
|
+
props.trueColor
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (
|
|
161
|
+
!isActive.value &&
|
|
162
|
+
isHex(props.falseColor)
|
|
163
|
+
) {
|
|
164
|
+
style.backgroundColor =
|
|
165
|
+
props.falseColor
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return style
|
|
169
|
+
},
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
const toggle = () => {
|
|
173
|
+
if (props.disable)
|
|
174
|
+
return
|
|
175
|
+
|
|
176
|
+
const newValue =
|
|
177
|
+
isActive.value
|
|
178
|
+
? props.inactiveValue
|
|
179
|
+
: props.activeValue
|
|
180
|
+
|
|
181
|
+
emit(
|
|
182
|
+
'update:modelValue',
|
|
183
|
+
newValue,
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<template>
|
|
189
|
+
<div
|
|
190
|
+
:class="[
|
|
191
|
+
'toggle-container flex items-center',
|
|
192
|
+
customClasses,
|
|
193
|
+
]"
|
|
194
|
+
:style="{
|
|
195
|
+
flexDirection:
|
|
196
|
+
labelPosition ===
|
|
197
|
+
'top' ||
|
|
198
|
+
labelPosition ===
|
|
199
|
+
'bottom'
|
|
200
|
+
? 'column'
|
|
201
|
+
: 'row',
|
|
202
|
+
}"
|
|
203
|
+
>
|
|
204
|
+
<!-- Top Label -->
|
|
205
|
+
<span
|
|
206
|
+
v-if="
|
|
207
|
+
label &&
|
|
208
|
+
labelPosition ===
|
|
209
|
+
'top'
|
|
210
|
+
"
|
|
211
|
+
class="mb-2 font-medium text-gray-700 dark:text-gray-300"
|
|
212
|
+
>
|
|
213
|
+
{{ label }}
|
|
214
|
+
</span>
|
|
215
|
+
|
|
216
|
+
<!-- Left Label -->
|
|
217
|
+
<span
|
|
218
|
+
v-if="
|
|
219
|
+
label &&
|
|
220
|
+
labelPosition ===
|
|
221
|
+
'left'
|
|
222
|
+
"
|
|
223
|
+
class="mr-3 font-medium text-gray-700 dark:text-gray-300"
|
|
224
|
+
>
|
|
225
|
+
{{ label }}
|
|
226
|
+
</span>
|
|
227
|
+
|
|
228
|
+
<!-- Toggle -->
|
|
229
|
+
<div
|
|
230
|
+
:class="[
|
|
231
|
+
'relative inline-flex items-center cursor-pointer',
|
|
232
|
+
{
|
|
233
|
+
'opacity-50 pointer-events-none':
|
|
234
|
+
disable,
|
|
235
|
+
},
|
|
236
|
+
]"
|
|
237
|
+
@click="toggle"
|
|
238
|
+
>
|
|
239
|
+
<!-- Background -->
|
|
240
|
+
<span
|
|
241
|
+
:class="[
|
|
242
|
+
'block rounded-full transition-colors duration-300 ease-in-out',
|
|
243
|
+
toggleSize.bg,
|
|
244
|
+
toggleBgClasses,
|
|
245
|
+
]"
|
|
246
|
+
:style="toggleBgStyle"
|
|
247
|
+
/>
|
|
248
|
+
|
|
249
|
+
<!-- Dot -->
|
|
250
|
+
<span
|
|
251
|
+
:class="[
|
|
252
|
+
'toggle-dot absolute rounded-full bg-white transition-transform duration-300 ease-in-out shadow-md hover:glow-effect flex items-center justify-center',
|
|
253
|
+
|
|
254
|
+
toggleSize.dot,
|
|
255
|
+
|
|
256
|
+
{
|
|
257
|
+
[toggleSize.translate]:
|
|
258
|
+
isActive,
|
|
259
|
+
},
|
|
260
|
+
]"
|
|
261
|
+
>
|
|
262
|
+
<span
|
|
263
|
+
class="material-icons text-sm"
|
|
264
|
+
>
|
|
265
|
+
{{
|
|
266
|
+
isActive
|
|
267
|
+
? activeIcon
|
|
268
|
+
: inactiveIcon
|
|
269
|
+
}}
|
|
270
|
+
</span>
|
|
271
|
+
</span>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<!-- Bottom Label -->
|
|
275
|
+
<span
|
|
276
|
+
v-if="
|
|
277
|
+
label &&
|
|
278
|
+
labelPosition ===
|
|
279
|
+
'bottom'
|
|
280
|
+
"
|
|
281
|
+
class="mt-2 font-medium text-gray-700 dark:text-gray-300"
|
|
282
|
+
>
|
|
283
|
+
{{ label }}
|
|
284
|
+
</span>
|
|
285
|
+
|
|
286
|
+
<!-- Right Label -->
|
|
287
|
+
<span
|
|
288
|
+
v-if="
|
|
289
|
+
label &&
|
|
290
|
+
labelPosition ===
|
|
291
|
+
'right'
|
|
292
|
+
"
|
|
293
|
+
class="ml-3 font-medium text-gray-700 dark:text-gray-300"
|
|
294
|
+
>
|
|
295
|
+
{{ label }}
|
|
296
|
+
</span>
|
|
297
|
+
</div>
|
|
298
|
+
</template>
|
|
299
|
+
|
|
300
|
+
<style scoped>
|
|
301
|
+
.toggle-container {
|
|
302
|
+
user-select: none;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.glow-effect {
|
|
306
|
+
transition:
|
|
307
|
+
box-shadow 0.3s ease-in-out;
|
|
308
|
+
box-shadow:
|
|
309
|
+
0 0 10px
|
|
310
|
+
rgba(0, 0, 0, 0.15),
|
|
311
|
+
0 0 10px
|
|
312
|
+
rgba(0, 0, 255, 0.3);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.material-icons {
|
|
316
|
+
font-size: 1rem;
|
|
317
|
+
color: currentColor;
|
|
318
|
+
}
|
|
319
|
+
</style>
|