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.
- package/dist/module.d.mts +3 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +26 -0
- package/dist/runtime/components/Accordion.d.vue.ts +39 -0
- package/{ui-library → dist/runtime}/components/Accordion.vue +44 -70
- package/dist/runtime/components/Accordion.vue.d.ts +39 -0
- package/dist/runtime/components/Avatar.d.vue.ts +141 -0
- package/dist/runtime/components/Avatar.vue +72 -0
- package/dist/runtime/components/Avatar.vue.d.ts +141 -0
- package/dist/runtime/components/Badge.d.vue.ts +133 -0
- package/dist/runtime/components/Badge.vue +99 -0
- package/dist/runtime/components/Badge.vue.d.ts +133 -0
- package/dist/runtime/components/Breadcrumbs.d.vue.ts +83 -0
- package/{ui-library → dist/runtime}/components/Breadcrumbs.vue +37 -59
- package/dist/runtime/components/Breadcrumbs.vue.d.ts +83 -0
- package/dist/runtime/components/Button.d.vue.ts +199 -0
- package/dist/runtime/components/Button.vue +125 -0
- package/dist/runtime/components/Button.vue.d.ts +199 -0
- package/dist/runtime/components/Card.d.vue.ts +83 -0
- package/{ui-library → dist/runtime}/components/Card.vue +26 -39
- package/dist/runtime/components/Card.vue.d.ts +83 -0
- package/dist/runtime/components/Checkbox.d.vue.ts +190 -0
- package/{ui-library → dist/runtime}/components/Checkbox.vue +45 -68
- package/dist/runtime/components/Checkbox.vue.d.ts +190 -0
- package/dist/runtime/components/CodeBlock.d.vue.ts +16 -0
- package/dist/runtime/components/CodeBlock.vue +75 -0
- package/dist/runtime/components/CodeBlock.vue.d.ts +16 -0
- package/dist/runtime/components/ColorPicker.d.vue.ts +91 -0
- package/dist/runtime/components/ColorPicker.vue +244 -0
- package/dist/runtime/components/ColorPicker.vue.d.ts +91 -0
- package/dist/runtime/components/Date.d.vue.ts +137 -0
- package/dist/runtime/components/Date.vue +201 -0
- package/dist/runtime/components/Date.vue.d.ts +137 -0
- package/dist/runtime/components/Dialog.d.vue.ts +103 -0
- package/{ui-library → dist/runtime}/components/Dialog.vue +30 -65
- package/dist/runtime/components/Dialog.vue.d.ts +103 -0
- package/dist/runtime/components/Divider.d.vue.ts +51 -0
- package/dist/runtime/components/Divider.vue +52 -0
- package/dist/runtime/components/Divider.vue.d.ts +51 -0
- package/dist/runtime/components/Drawer.d.vue.ts +30 -0
- package/dist/runtime/components/Drawer.vue +43 -0
- package/dist/runtime/components/Drawer.vue.d.ts +30 -0
- package/dist/runtime/components/Dropdown.d.vue.ts +34 -0
- package/dist/runtime/components/Dropdown.vue +127 -0
- package/dist/runtime/components/Dropdown.vue.d.ts +34 -0
- package/dist/runtime/components/FileUploader.d.vue.ts +58 -0
- package/dist/runtime/components/FileUploader.vue +202 -0
- package/dist/runtime/components/FileUploader.vue.d.ts +58 -0
- package/dist/runtime/components/Icon.d.vue.ts +41 -0
- package/dist/runtime/components/Icon.vue +66 -0
- package/dist/runtime/components/Icon.vue.d.ts +41 -0
- package/dist/runtime/components/Image.d.vue.ts +77 -0
- package/dist/runtime/components/Image.vue +61 -0
- package/dist/runtime/components/Image.vue.d.ts +77 -0
- package/dist/runtime/components/Input.d.vue.ts +66 -0
- package/dist/runtime/components/Input.vue +233 -0
- package/dist/runtime/components/Input.vue.d.ts +66 -0
- package/dist/runtime/components/Radio.d.vue.ts +41 -0
- package/dist/runtime/components/Radio.vue +222 -0
- package/dist/runtime/components/Radio.vue.d.ts +41 -0
- package/dist/runtime/components/ScrollArea.d.vue.ts +79 -0
- package/dist/runtime/components/ScrollArea.vue +36 -0
- package/dist/runtime/components/ScrollArea.vue.d.ts +79 -0
- package/dist/runtime/components/Select.d.vue.ts +43 -0
- package/dist/runtime/components/Select.vue +200 -0
- package/dist/runtime/components/Select.vue.d.ts +43 -0
- package/dist/runtime/components/Stepper.d.vue.ts +46 -0
- package/dist/runtime/components/Stepper.vue +218 -0
- package/dist/runtime/components/Stepper.vue.d.ts +46 -0
- package/dist/runtime/components/TabPanel.d.vue.ts +17 -0
- package/dist/runtime/components/TabPanel.vue +21 -0
- package/dist/runtime/components/TabPanel.vue.d.ts +17 -0
- package/dist/runtime/components/Table.d.vue.ts +40 -0
- package/dist/runtime/components/Table.vue +92 -0
- package/dist/runtime/components/Table.vue.d.ts +40 -0
- package/dist/runtime/components/Tabs.d.vue.ts +20 -0
- package/dist/runtime/components/Tabs.vue +62 -0
- package/dist/runtime/components/Tabs.vue.d.ts +20 -0
- package/dist/runtime/components/Textarea.d.vue.ts +208 -0
- package/dist/runtime/components/Textarea.vue +185 -0
- package/dist/runtime/components/Textarea.vue.d.ts +208 -0
- package/dist/runtime/components/Toggle.d.vue.ts +36 -0
- package/dist/runtime/components/Toggle.vue +173 -0
- package/dist/runtime/components/Toggle.vue.d.ts +36 -0
- package/dist/runtime/components/Tooltip.d.vue.ts +63 -0
- package/dist/runtime/components/Tooltip.vue +144 -0
- package/dist/runtime/components/Tooltip.vue.d.ts +63 -0
- package/dist/runtime/components/uiProps.d.ts +38 -0
- package/{ui-library/components/uiProps.ts → dist/runtime/components/uiProps.js} +2 -2
- package/dist/runtime/components/useUiClasses.d.ts +43 -0
- package/{ui-library/components/useUiClasses.ts → dist/runtime/components/useUiClasses.js} +25 -60
- package/dist/runtime/composables/plugin.d.ts +2 -0
- package/dist/runtime/composables/plugin.js +3 -0
- package/dist/runtime/tailwind-color.d.ts +2 -0
- package/dist/runtime/tailwind-color.js +5859 -0
- package/dist/types.d.mts +7 -0
- package/package.json +14 -16
- package/README.md +0 -208
- package/ui-library/components/Avatar.vue +0 -121
- package/ui-library/components/Badge.vue +0 -116
- package/ui-library/components/Button.vue +0 -154
- package/ui-library/components/CodeBlock.vue +0 -99
- package/ui-library/components/ColorPicker.vue +0 -302
- package/ui-library/components/Date.vue +0 -240
- package/ui-library/components/Divider.vue +0 -78
- package/ui-library/components/Drawer.vue +0 -67
- package/ui-library/components/Dropdown.vue +0 -248
- package/ui-library/components/FileUploader.vue +0 -330
- package/ui-library/components/Icon.vue +0 -82
- package/ui-library/components/Image.vue +0 -78
- package/ui-library/components/Input.vue +0 -531
- package/ui-library/components/Radio.vue +0 -356
- package/ui-library/components/ScrollArea.vue +0 -43
- package/ui-library/components/Select.vue +0 -309
- package/ui-library/components/Stepper.vue +0 -361
- package/ui-library/components/TabPanel.vue +0 -25
- package/ui-library/components/Table.vue +0 -152
- package/ui-library/components/Tabs.vue +0 -71
- package/ui-library/components/Textarea.vue +0 -233
- package/ui-library/components/Toggle.vue +0 -319
- package/ui-library/components/Tooltip.vue +0 -200
- package/ui-library/components/plugin.ts +0 -8
- package/ui-library/module.ts +0 -20
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
modelValue: { type: [String, Number], required: true, default: "" },
|
|
5
|
+
label: { type: String, required: true },
|
|
6
|
+
hint: { type: String, required: false, default: "" },
|
|
7
|
+
placeholder: { type: String, required: false, default: "" },
|
|
8
|
+
case: { type: [String, null], required: false, default: null },
|
|
9
|
+
size: { type: String, required: false, default: "md" },
|
|
10
|
+
color: { type: String, required: false, default: "primary" },
|
|
11
|
+
rounded: { type: String, required: false, default: "md" },
|
|
12
|
+
dense: { type: Boolean, required: false, default: false },
|
|
13
|
+
outlined: { type: Boolean, required: false, default: false },
|
|
14
|
+
borderless: { type: Boolean, required: false, default: false },
|
|
15
|
+
flat: { type: Boolean, required: false, default: false },
|
|
16
|
+
type: { type: String, required: false, default: "text" },
|
|
17
|
+
allow: { type: Array, required: false, default: () => [] },
|
|
18
|
+
deny: { type: Array, required: false, default: () => [] },
|
|
19
|
+
supportedValues: { type: Array, required: false, default: () => [] },
|
|
20
|
+
unsupportedValues: { type: Array, required: false, default: () => [] },
|
|
21
|
+
required: { type: Boolean, required: false, default: false },
|
|
22
|
+
regex: { type: null, required: false, default: "" },
|
|
23
|
+
minLength: { type: Number, required: false, default: void 0 },
|
|
24
|
+
maxLength: { type: Number, required: false, default: void 0 },
|
|
25
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
26
|
+
readonly: { type: Boolean, required: false, default: false },
|
|
27
|
+
autocomplete: { type: String, required: false, default: "off" },
|
|
28
|
+
validateOn: { type: String, required: false, default: "input" }
|
|
29
|
+
});
|
|
30
|
+
const emit = defineEmits(["update:modelValue", "valid", "invalid"]);
|
|
31
|
+
const validationError = ref("");
|
|
32
|
+
const NATIVE_PATTERNS = {
|
|
33
|
+
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
34
|
+
url: /^(https?:\/\/)?([\w-]+\.)+[\w-]{2,}(\/\S*)?$/i,
|
|
35
|
+
tel: /^\+?[1-9]\d{6,14}$/
|
|
36
|
+
};
|
|
37
|
+
const RULE_PATTERNS = {
|
|
38
|
+
alphabets: /^[A-Za-z]+$/,
|
|
39
|
+
numbers: /^[0-9]+$/,
|
|
40
|
+
spaces: /\s/,
|
|
41
|
+
name: /^[A-Za-z.'-\s]+$/,
|
|
42
|
+
punctuation: /[.,!?;:'"()-]/,
|
|
43
|
+
integer: /^-?\d+$/,
|
|
44
|
+
positive: /^\d+$/,
|
|
45
|
+
negative: /^-\d+$/,
|
|
46
|
+
decimal: /^-?\d*\.?\d+$/,
|
|
47
|
+
scientific: /^-?\d+(\.\d+)?e[-+]?\d+$/i,
|
|
48
|
+
uppercase: /^[A-Z]+$/,
|
|
49
|
+
lowercase: /^[a-z]+$/
|
|
50
|
+
};
|
|
51
|
+
function validate(value) {
|
|
52
|
+
validationError.value = "";
|
|
53
|
+
if (props.required && !value.trim()) {
|
|
54
|
+
validationError.value = "This field is required.";
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (props.minLength !== void 0 && value.length < props.minLength) {
|
|
58
|
+
validationError.value = `Minimum ${props.minLength} characters required.`;
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (props.maxLength !== void 0 && value.length > props.maxLength) {
|
|
62
|
+
validationError.value = `Maximum ${props.maxLength} characters allowed.`;
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if (props.supportedValues.length && !props.supportedValues.includes(value)) {
|
|
66
|
+
validationError.value = "Value is not allowed.";
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (props.unsupportedValues.includes(value)) {
|
|
70
|
+
validationError.value = "Value is not permitted.";
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const nativePattern = NATIVE_PATTERNS[props.type];
|
|
74
|
+
if (nativePattern && value && !nativePattern.test(value)) {
|
|
75
|
+
validationError.value = `Invalid ${props.type} format.`;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
for (const rule of props.allow) {
|
|
79
|
+
const regex = RULE_PATTERNS[rule];
|
|
80
|
+
if (regex && value && !regex.test(value)) {
|
|
81
|
+
validationError.value = `Failed validation: ${rule}`;
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const rule of props.deny) {
|
|
86
|
+
const regex = RULE_PATTERNS[rule];
|
|
87
|
+
if (regex && regex.test(value)) {
|
|
88
|
+
validationError.value = `Contains unsupported value: ${rule}`;
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (props.regex) {
|
|
93
|
+
const regex = props.regex instanceof RegExp ? props.regex : new RegExp(props.regex);
|
|
94
|
+
if (!regex.test(value)) {
|
|
95
|
+
validationError.value = "Custom validation failed.";
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
function runValidation(value) {
|
|
102
|
+
const isValid = validate(value);
|
|
103
|
+
if (isValid) {
|
|
104
|
+
emit("valid");
|
|
105
|
+
} else {
|
|
106
|
+
emit("invalid", validationError.value);
|
|
107
|
+
}
|
|
108
|
+
return isValid;
|
|
109
|
+
}
|
|
110
|
+
function handleInput(event) {
|
|
111
|
+
const target = event.target;
|
|
112
|
+
let value = target.value;
|
|
113
|
+
if (props.maxLength !== void 0 && value.length > props.maxLength) {
|
|
114
|
+
value = value.slice(0, props.maxLength);
|
|
115
|
+
}
|
|
116
|
+
emit("update:modelValue", value);
|
|
117
|
+
if (props.validateOn === "input") {
|
|
118
|
+
runValidation(value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function handleBlur(event) {
|
|
122
|
+
if (props.validateOn !== "blur") return;
|
|
123
|
+
const target = event.target;
|
|
124
|
+
runValidation(target.value);
|
|
125
|
+
}
|
|
126
|
+
const isHex = (val) => val.startsWith("#");
|
|
127
|
+
const roundedMap = {
|
|
128
|
+
none: "rounded-none",
|
|
129
|
+
sm: "rounded-sm",
|
|
130
|
+
md: "rounded-md",
|
|
131
|
+
lg: "rounded-lg",
|
|
132
|
+
xl: "rounded-xl",
|
|
133
|
+
full: "rounded-full"
|
|
134
|
+
};
|
|
135
|
+
const computedClass = computed(() => {
|
|
136
|
+
let classes = "input block w-full transition-all duration-300";
|
|
137
|
+
if (props.borderless) {
|
|
138
|
+
classes += " border-none bg-transparent";
|
|
139
|
+
} else if (props.outlined) {
|
|
140
|
+
classes += " border";
|
|
141
|
+
} else {
|
|
142
|
+
classes += " border-0 border-b";
|
|
143
|
+
}
|
|
144
|
+
classes += ` ${roundedMap[props.rounded] ?? roundedMap.md}`;
|
|
145
|
+
if (!props.flat) {
|
|
146
|
+
classes += " shadow-sm";
|
|
147
|
+
}
|
|
148
|
+
if (props.disabled) {
|
|
149
|
+
classes += " opacity-50 cursor-not-allowed";
|
|
150
|
+
}
|
|
151
|
+
if (props.size === "sm") {
|
|
152
|
+
classes += " text-sm";
|
|
153
|
+
} else if (props.size === "lg") {
|
|
154
|
+
classes += " text-lg";
|
|
155
|
+
} else {
|
|
156
|
+
classes += " text-base";
|
|
157
|
+
}
|
|
158
|
+
if (props.case === "upper") {
|
|
159
|
+
classes += " uppercase";
|
|
160
|
+
} else if (props.case === "lower") {
|
|
161
|
+
classes += " lowercase";
|
|
162
|
+
} else if (props.case === "capitalize") {
|
|
163
|
+
classes += " capitalize";
|
|
164
|
+
}
|
|
165
|
+
if (validationError.value) {
|
|
166
|
+
classes += " border-red-500";
|
|
167
|
+
} else {
|
|
168
|
+
classes += ` ${props.color && !isHex(props.color) ? `border-${props.color} focus:ring-${props.color} text-${props.color} ` : ""}`;
|
|
169
|
+
}
|
|
170
|
+
if (props.modelValue !== null && props.modelValue !== "" && props.modelValue !== void 0)
|
|
171
|
+
classes += " has-value";
|
|
172
|
+
return classes;
|
|
173
|
+
});
|
|
174
|
+
const computedStyle = computed(() => {
|
|
175
|
+
let styles = {};
|
|
176
|
+
if (props.color && isHex(props.color)) {
|
|
177
|
+
styles["--tw-ring-color"] = props.color;
|
|
178
|
+
styles["border-color"] = props.color;
|
|
179
|
+
}
|
|
180
|
+
return styles;
|
|
181
|
+
});
|
|
182
|
+
const visibility = ref(false);
|
|
183
|
+
const inputType = computed(() => props.type === "password" ? visibility.value ? "text" : "password" : props.type);
|
|
184
|
+
const inputAttrs = computed(() => {
|
|
185
|
+
let inputAttrs2 = {};
|
|
186
|
+
if (props.type) inputAttrs2 = { ...inputAttrs2, type: props.type === "password" ? inputType.value : props.type };
|
|
187
|
+
if (props.placeholder) inputAttrs2 = { ...inputAttrs2, placeholder: props.placeholder };
|
|
188
|
+
if (props.disabled) inputAttrs2 = { ...inputAttrs2, disabled: props.disabled };
|
|
189
|
+
if (props.readonly) inputAttrs2 = { ...inputAttrs2, readonly: props.readonly };
|
|
190
|
+
if (props.autocomplete) inputAttrs2 = { ...inputAttrs2, autocomplete: props.autocomplete };
|
|
191
|
+
if (props.required) inputAttrs2 = { ...inputAttrs2, required: props.required };
|
|
192
|
+
if (props.maxLength) inputAttrs2 = { ...inputAttrs2, maxlength: props.maxLength };
|
|
193
|
+
return inputAttrs2;
|
|
194
|
+
});
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<template>
|
|
198
|
+
<div class="input-container" :class="{ dense: !outlined || dense, [`input-${size}`]: size }">
|
|
199
|
+
<input
|
|
200
|
+
:value="modelValue"
|
|
201
|
+
:class="computedClass"
|
|
202
|
+
:style="computedStyle"
|
|
203
|
+
@input="handleInput"
|
|
204
|
+
@blur="handleBlur"
|
|
205
|
+
v-bind="inputAttrs"
|
|
206
|
+
/>
|
|
207
|
+
|
|
208
|
+
<label class="label" :class="!isHex(color) ? `text-${color}` : ''" :style="isHex(color) ? { color } : {}">
|
|
209
|
+
{{ label }}
|
|
210
|
+
</label>
|
|
211
|
+
|
|
212
|
+
<div class="absolute right-0 top-1/2 transform -translate-y-1/2">
|
|
213
|
+
<UIButton v-if="type === 'password'" :icon="visibility ? 'visibility_off' : 'visibility'" flat dense color="gray-400" @click="visibility = !visibility" />
|
|
214
|
+
</div>
|
|
215
|
+
<p
|
|
216
|
+
v-if="hint && !validationError"
|
|
217
|
+
class="hint-text"
|
|
218
|
+
>
|
|
219
|
+
{{ hint }}
|
|
220
|
+
</p>
|
|
221
|
+
|
|
222
|
+
<p
|
|
223
|
+
v-if="validationError"
|
|
224
|
+
class="error-text"
|
|
225
|
+
>
|
|
226
|
+
{{ validationError }}
|
|
227
|
+
</p>
|
|
228
|
+
</div>
|
|
229
|
+
</template>
|
|
230
|
+
|
|
231
|
+
<style scoped>
|
|
232
|
+
.input-container{margin:20px 0 10px;position:relative}.input-container.dense{margin:10px 0}.input-container .input{padding:10px}.input-container.dense .input{padding:6px 10px}.input:focus{outline:none}.label{color:#9ca3af;left:10px;padding:0 5px;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%);transition:top .2s ease,font-size .2s ease,color .2s ease,transform .2s ease}.input-container:has(input[type=date]) .label,.input-container:has(input[type=datetime-local]) .label,.input-container:has(input[type=month]) .label,.input-container:has(input[type=time]) .label,.input-container:has(input[type=week]) .label{color:gray;left:5px;top:-20%;transform:none;z-index:1}.input-container.input-lg.dense .input:-moz-placeholder+.label,.input:-moz-placeholder+.label{color:gray;left:5px;top:-20px;transform:none;z-index:1}.input-container.input-lg.dense .input.has-value+.label,.input-container.input-lg.dense .input:focus+.label,.input-container.input-lg.dense .input:placeholder-shown+.label,.input.has-value+.label,.input:focus+.label,.input:placeholder-shown+.label{color:gray;left:5px;top:-20px;transform:none;z-index:1}.input-container.dense .input:-moz-placeholder+.label{top:-10px}.input-container.dense .input.has-value+.label,.input-container.dense .input:focus+.label,.input-container.dense .input:placeholder-shown+.label{top:-10px}.input-container.input-lg .input:-moz-placeholder+.label{top:-24px}.input-container.input-lg .input.has-value+.label,.input-container.input-lg .input:focus+.label,.input-container.input-lg .input:placeholder-shown+.label{top:-24px}.input-container.input-sm .label{font-size:14px}.input-container.input-md .label{font-size:16px}.input-container.input-lg .label{font-size:18px}.input-container.input-sm .input:-moz-placeholder+.label{font-size:12px}.input-container.input-sm .input.has-value+.label,.input-container.input-sm .input:focus+.label,.input-container.input-sm .input:placeholder-shown+.label{font-size:12px}.input-container.input-md .input:-moz-placeholder+.label{font-size:14px}.input-container.input-md .input.has-value+.label,.input-container.input-md .input:focus+.label,.input-container.input-md .input:placeholder-shown+.label{font-size:14px}.input-container.input-lg .input:-moz-placeholder+.label{font-size:16px}.input-container.input-lg .input.has-value+.label,.input-container.input-lg .input:focus+.label,.input-container.input-lg .input:placeholder-shown+.label{font-size:16px}.hint-text{color:#6b7280;font-size:12px;margin-left:5px}.char-count{color:#6b7280}.char-count,.error-text{font-size:.875rem;margin-top:4px}.error-text{color:#ef4444}
|
|
233
|
+
</style>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
type SupportedInputType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search' | 'date' | 'datetime-local' | 'month' | 'week' | 'time';
|
|
2
|
+
type ValidationRule = "alphabets" | "numbers" | "spaces" | "name" | "punctuation" | "integer" | "positive" | "negative" | "decimal" | "scientific" | "uppercase" | "lowercase";
|
|
3
|
+
type ValidateOn = "input" | "blur";
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
modelValue: string | number;
|
|
6
|
+
label: string;
|
|
7
|
+
hint?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
case?: "upper" | "lower" | "capitalize" | "normal" | null;
|
|
10
|
+
size?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
rounded?: string;
|
|
13
|
+
dense?: boolean;
|
|
14
|
+
outlined?: boolean;
|
|
15
|
+
borderless?: boolean;
|
|
16
|
+
flat?: boolean;
|
|
17
|
+
type?: SupportedInputType;
|
|
18
|
+
allow?: ValidationRule[];
|
|
19
|
+
deny?: ValidationRule[];
|
|
20
|
+
supportedValues?: Array<string | number>;
|
|
21
|
+
unsupportedValues?: Array<string | number>;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
regex?: string | RegExp;
|
|
24
|
+
minLength?: number;
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
readonly?: boolean;
|
|
28
|
+
autocomplete?: string;
|
|
29
|
+
validateOn?: ValidateOn;
|
|
30
|
+
};
|
|
31
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
32
|
+
"update:modelValue": (value: string) => any;
|
|
33
|
+
invalid: (error: string) => any;
|
|
34
|
+
valid: () => any;
|
|
35
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
36
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
37
|
+
onInvalid?: ((error: string) => any) | undefined;
|
|
38
|
+
onValid?: (() => any) | undefined;
|
|
39
|
+
}>, {
|
|
40
|
+
modelValue: string | number;
|
|
41
|
+
disabled: boolean;
|
|
42
|
+
dense: boolean;
|
|
43
|
+
type: SupportedInputType;
|
|
44
|
+
color: string;
|
|
45
|
+
rounded: string;
|
|
46
|
+
size: string;
|
|
47
|
+
required: boolean;
|
|
48
|
+
flat: boolean;
|
|
49
|
+
placeholder: string;
|
|
50
|
+
readonly: boolean;
|
|
51
|
+
hint: string;
|
|
52
|
+
case: "upper" | "lower" | "capitalize" | "normal" | null;
|
|
53
|
+
outlined: boolean;
|
|
54
|
+
borderless: boolean;
|
|
55
|
+
allow: ValidationRule[];
|
|
56
|
+
deny: ValidationRule[];
|
|
57
|
+
supportedValues: Array<string | number>;
|
|
58
|
+
unsupportedValues: Array<string | number>;
|
|
59
|
+
regex: string | RegExp;
|
|
60
|
+
minLength: number;
|
|
61
|
+
maxLength: number;
|
|
62
|
+
autocomplete: string;
|
|
63
|
+
validateOn: ValidateOn;
|
|
64
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
65
|
+
declare const _default: typeof __VLS_export;
|
|
66
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type LabelPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
2
|
+
type RadioSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
type Rounded = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
modelValue?: string | number | boolean;
|
|
6
|
+
value: string | number | boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
disable?: boolean;
|
|
13
|
+
color?: string;
|
|
14
|
+
size?: RadioSize;
|
|
15
|
+
rounded?: Rounded;
|
|
16
|
+
flat?: boolean;
|
|
17
|
+
bordered?: boolean;
|
|
18
|
+
borderColor?: string;
|
|
19
|
+
labelPosition?: LabelPosition;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
22
|
+
"update:modelValue": (value: string | number | boolean) => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
"onUpdate:modelValue"?: ((value: string | number | boolean) => any) | undefined;
|
|
25
|
+
}>, {
|
|
26
|
+
modelValue: string | number | boolean;
|
|
27
|
+
name: string;
|
|
28
|
+
disable: boolean;
|
|
29
|
+
color: string;
|
|
30
|
+
rounded: Rounded;
|
|
31
|
+
size: RadioSize;
|
|
32
|
+
borderColor: string;
|
|
33
|
+
icon: string;
|
|
34
|
+
flat: boolean;
|
|
35
|
+
id: string;
|
|
36
|
+
bordered: boolean;
|
|
37
|
+
hint: string;
|
|
38
|
+
labelPosition: LabelPosition;
|
|
39
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineOptions({
|
|
3
|
+
name: "UIRadio"
|
|
4
|
+
});
|
|
5
|
+
import { computed } from "vue";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
modelValue: { type: [String, Number, Boolean], required: false, default: "" },
|
|
8
|
+
value: { type: [String, Number, Boolean], required: true },
|
|
9
|
+
label: { type: String, required: true },
|
|
10
|
+
id: { type: String, required: false, default: void 0 },
|
|
11
|
+
name: { type: String, required: false, default: "" },
|
|
12
|
+
hint: { type: String, required: false, default: "" },
|
|
13
|
+
icon: { type: String, required: false, default: "" },
|
|
14
|
+
disable: { type: Boolean, required: false, default: false },
|
|
15
|
+
color: { type: String, required: false, default: "blue-500" },
|
|
16
|
+
size: { type: String, required: false, default: "md" },
|
|
17
|
+
rounded: { type: String, required: false, default: "full" },
|
|
18
|
+
flat: { type: Boolean, required: false, default: false },
|
|
19
|
+
bordered: { type: Boolean, required: false, default: true },
|
|
20
|
+
borderColor: { type: String, required: false, default: "gray-300" },
|
|
21
|
+
labelPosition: { type: String, required: false, default: "right" }
|
|
22
|
+
});
|
|
23
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
24
|
+
const isHex = (val) => {
|
|
25
|
+
return val.startsWith("#") || val.startsWith("rgb") || val.startsWith("hsl");
|
|
26
|
+
};
|
|
27
|
+
const isChecked = computed(
|
|
28
|
+
() => props.modelValue === props.value
|
|
29
|
+
);
|
|
30
|
+
const sizeClasses = computed(
|
|
31
|
+
() => {
|
|
32
|
+
switch (props.size) {
|
|
33
|
+
case "sm":
|
|
34
|
+
return {
|
|
35
|
+
radio: "w-4 h-4",
|
|
36
|
+
icon: "text-sm"
|
|
37
|
+
};
|
|
38
|
+
case "lg":
|
|
39
|
+
return {
|
|
40
|
+
radio: "w-6 h-6",
|
|
41
|
+
icon: "text-lg"
|
|
42
|
+
};
|
|
43
|
+
case "md":
|
|
44
|
+
default:
|
|
45
|
+
return {
|
|
46
|
+
radio: "w-5 h-5",
|
|
47
|
+
icon: "text-base"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
const roundedClass = computed(
|
|
53
|
+
() => {
|
|
54
|
+
const map = {
|
|
55
|
+
none: "rounded-none",
|
|
56
|
+
sm: "rounded-sm",
|
|
57
|
+
md: "rounded-md",
|
|
58
|
+
lg: "rounded-lg",
|
|
59
|
+
full: "rounded-full"
|
|
60
|
+
};
|
|
61
|
+
return map[props.rounded];
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
const labelPositionClass = computed(() => {
|
|
65
|
+
const map = {
|
|
66
|
+
top: "flex-col-reverse",
|
|
67
|
+
bottom: "flex-col",
|
|
68
|
+
left: "flex-row-reverse",
|
|
69
|
+
right: "flex-row"
|
|
70
|
+
};
|
|
71
|
+
return map[props.labelPosition];
|
|
72
|
+
});
|
|
73
|
+
const radioClasses = computed(
|
|
74
|
+
() => [
|
|
75
|
+
"inline-flex items-center justify-center border-2 transition-all duration-200 bg-white dark:bg-gray-900",
|
|
76
|
+
sizeClasses.value.radio,
|
|
77
|
+
roundedClass.value,
|
|
78
|
+
props.flat ? "shadow-none" : "shadow-sm",
|
|
79
|
+
props.disable ? "opacity-50" : "",
|
|
80
|
+
props.bordered && !isHex(
|
|
81
|
+
props.borderColor
|
|
82
|
+
) ? `border-${props.borderColor}` : "",
|
|
83
|
+
isChecked.value && !isHex(props.color) ? `border-${props.color} text-${props.color}` : "",
|
|
84
|
+
!isChecked.value ? "border-gray-300" : ""
|
|
85
|
+
]
|
|
86
|
+
);
|
|
87
|
+
const radioStyle = computed(
|
|
88
|
+
() => {
|
|
89
|
+
const style = {};
|
|
90
|
+
if (props.bordered && isHex(
|
|
91
|
+
props.borderColor
|
|
92
|
+
)) {
|
|
93
|
+
style.borderColor = props.borderColor;
|
|
94
|
+
}
|
|
95
|
+
if (isChecked.value && isHex(props.color)) {
|
|
96
|
+
style.borderColor = props.color;
|
|
97
|
+
style.color = props.color;
|
|
98
|
+
}
|
|
99
|
+
return style;
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
const iconClasses = computed(
|
|
103
|
+
() => [
|
|
104
|
+
"material-icons transition-opacity duration-200",
|
|
105
|
+
sizeClasses.value.icon,
|
|
106
|
+
isChecked.value ? "opacity-100" : "opacity-0",
|
|
107
|
+
!isHex(props.color) ? `text-${props.color}` : ""
|
|
108
|
+
]
|
|
109
|
+
);
|
|
110
|
+
const iconStyle = computed(
|
|
111
|
+
() => {
|
|
112
|
+
const style = {};
|
|
113
|
+
if (isHex(props.color)) {
|
|
114
|
+
style.color = props.color;
|
|
115
|
+
}
|
|
116
|
+
return style;
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
const toggle = () => {
|
|
120
|
+
if (props.disable)
|
|
121
|
+
return;
|
|
122
|
+
emit(
|
|
123
|
+
"update:modelValue",
|
|
124
|
+
props.value
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<template>
|
|
130
|
+
<div
|
|
131
|
+
class="radio-container flex items-center"
|
|
132
|
+
>
|
|
133
|
+
<input
|
|
134
|
+
:id="id"
|
|
135
|
+
type="radio"
|
|
136
|
+
:name="name"
|
|
137
|
+
:value="value"
|
|
138
|
+
:checked="
|
|
139
|
+
isChecked
|
|
140
|
+
"
|
|
141
|
+
:disabled="
|
|
142
|
+
disable
|
|
143
|
+
"
|
|
144
|
+
class="sr-only"
|
|
145
|
+
@change="toggle"
|
|
146
|
+
>
|
|
147
|
+
|
|
148
|
+
<label
|
|
149
|
+
:for="id"
|
|
150
|
+
tabindex="0"
|
|
151
|
+
role="radio"
|
|
152
|
+
:aria-checked="
|
|
153
|
+
isChecked
|
|
154
|
+
"
|
|
155
|
+
:aria-disabled="
|
|
156
|
+
disable
|
|
157
|
+
"
|
|
158
|
+
:class="[
|
|
159
|
+
'flex items-center cursor-pointer select-none',
|
|
160
|
+
labelPositionClass,
|
|
161
|
+
{
|
|
162
|
+
'opacity-50 pointer-events-none': disable
|
|
163
|
+
}
|
|
164
|
+
]"
|
|
165
|
+
@click.prevent="
|
|
166
|
+
toggle
|
|
167
|
+
"
|
|
168
|
+
@keydown.enter.prevent="
|
|
169
|
+
toggle
|
|
170
|
+
"
|
|
171
|
+
@keydown.space.prevent="
|
|
172
|
+
toggle
|
|
173
|
+
"
|
|
174
|
+
>
|
|
175
|
+
<!-- Radio -->
|
|
176
|
+
<span
|
|
177
|
+
:class="
|
|
178
|
+
radioClasses
|
|
179
|
+
"
|
|
180
|
+
:style="
|
|
181
|
+
radioStyle
|
|
182
|
+
"
|
|
183
|
+
>
|
|
184
|
+
<i
|
|
185
|
+
v-if="
|
|
186
|
+
icon && isChecked
|
|
187
|
+
"
|
|
188
|
+
:class="
|
|
189
|
+
iconClasses
|
|
190
|
+
"
|
|
191
|
+
:style="
|
|
192
|
+
iconStyle
|
|
193
|
+
"
|
|
194
|
+
>
|
|
195
|
+
{{ icon }}
|
|
196
|
+
</i>
|
|
197
|
+
<span
|
|
198
|
+
v-else
|
|
199
|
+
class="block m-auto rounded-full"
|
|
200
|
+
:class="
|
|
201
|
+
[
|
|
202
|
+
!isHex(props.color) && isChecked ? `bg-${props.color}` : '',
|
|
203
|
+
size === 'sm' ? 'w-2 h-2' : size === 'lg' ? 'w-3 h-3' : 'w-2.5 h-2.5'
|
|
204
|
+
]
|
|
205
|
+
"
|
|
206
|
+
:style="isHex(props.color) ? { backgroundColor: props.color } : {}"
|
|
207
|
+
/>
|
|
208
|
+
</span>
|
|
209
|
+
|
|
210
|
+
<!-- Label -->
|
|
211
|
+
<span
|
|
212
|
+
class="mx-2 font-medium text-gray-700 dark:text-gray-300"
|
|
213
|
+
>
|
|
214
|
+
{{ label }}
|
|
215
|
+
</span>
|
|
216
|
+
</label>
|
|
217
|
+
</div>
|
|
218
|
+
</template>
|
|
219
|
+
|
|
220
|
+
<style scoped>
|
|
221
|
+
.radio-container{-webkit-user-select:none;-moz-user-select:none;user-select:none}
|
|
222
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type LabelPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
2
|
+
type RadioSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
type Rounded = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
modelValue?: string | number | boolean;
|
|
6
|
+
value: string | number | boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
hint?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
disable?: boolean;
|
|
13
|
+
color?: string;
|
|
14
|
+
size?: RadioSize;
|
|
15
|
+
rounded?: Rounded;
|
|
16
|
+
flat?: boolean;
|
|
17
|
+
bordered?: boolean;
|
|
18
|
+
borderColor?: string;
|
|
19
|
+
labelPosition?: LabelPosition;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
22
|
+
"update:modelValue": (value: string | number | boolean) => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
"onUpdate:modelValue"?: ((value: string | number | boolean) => any) | undefined;
|
|
25
|
+
}>, {
|
|
26
|
+
modelValue: string | number | boolean;
|
|
27
|
+
name: string;
|
|
28
|
+
disable: boolean;
|
|
29
|
+
color: string;
|
|
30
|
+
rounded: Rounded;
|
|
31
|
+
size: RadioSize;
|
|
32
|
+
borderColor: string;
|
|
33
|
+
icon: string;
|
|
34
|
+
flat: boolean;
|
|
35
|
+
id: string;
|
|
36
|
+
bordered: boolean;
|
|
37
|
+
hint: string;
|
|
38
|
+
labelPosition: LabelPosition;
|
|
39
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
|
+
declare const _default: typeof __VLS_export;
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
width: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: string;
|
|
9
|
+
};
|
|
10
|
+
height: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
maxWidth: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
default: string;
|
|
17
|
+
};
|
|
18
|
+
maxHeight: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
horizontal: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
vertical: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
hideScrollbar: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
35
|
+
width: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
height: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
maxWidth: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
maxHeight: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
horizontal: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
vertical: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
hideScrollbar: {
|
|
60
|
+
type: BooleanConstructor;
|
|
61
|
+
default: boolean;
|
|
62
|
+
};
|
|
63
|
+
}>> & Readonly<{}>, {
|
|
64
|
+
horizontal: boolean;
|
|
65
|
+
vertical: boolean;
|
|
66
|
+
width: string;
|
|
67
|
+
maxWidth: string;
|
|
68
|
+
height: string;
|
|
69
|
+
maxHeight: string;
|
|
70
|
+
hideScrollbar: boolean;
|
|
71
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
72
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
73
|
+
declare const _default: typeof __VLS_export;
|
|
74
|
+
export default _default;
|
|
75
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
76
|
+
new (): {
|
|
77
|
+
$slots: S;
|
|
78
|
+
};
|
|
79
|
+
};
|