windly-ui 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/Alert.d.vue.ts +18 -0
- package/dist/runtime/components/Alert.vue +21 -3
- package/dist/runtime/components/Alert.vue.d.ts +18 -0
- package/dist/runtime/components/Avatar.d.vue.ts +5 -5
- package/dist/runtime/components/Avatar.vue.d.ts +5 -5
- package/dist/runtime/components/Badge.d.vue.ts +5 -5
- package/dist/runtime/components/Badge.vue.d.ts +5 -5
- package/dist/runtime/components/Breadcrumbs.vue +2 -2
- package/dist/runtime/components/Button.d.vue.ts +5 -5
- package/dist/runtime/components/Button.vue +5 -5
- package/dist/runtime/components/Button.vue.d.ts +5 -5
- package/dist/runtime/components/Card.d.vue.ts +27 -0
- package/dist/runtime/components/Card.vue +12 -8
- package/dist/runtime/components/Card.vue.d.ts +27 -0
- package/dist/runtime/components/Checkbox.d.vue.ts +14 -5
- package/dist/runtime/components/Checkbox.vue +11 -4
- package/dist/runtime/components/Checkbox.vue.d.ts +14 -5
- package/dist/runtime/components/Chip.d.vue.ts +5 -5
- package/dist/runtime/components/Chip.vue.d.ts +5 -5
- package/dist/runtime/components/CodeBlock.vue +50 -8
- package/dist/runtime/components/Date.d.vue.ts +22 -4
- package/dist/runtime/components/Date.vue +39 -15
- package/dist/runtime/components/Date.vue.d.ts +22 -4
- package/dist/runtime/components/Dialog.d.vue.ts +7 -9
- package/dist/runtime/components/Dialog.vue +23 -4
- package/dist/runtime/components/Dialog.vue.d.ts +7 -9
- package/dist/runtime/components/Divider.vue +1 -1
- package/dist/runtime/components/Dropdown.d.vue.ts +2 -2
- package/dist/runtime/components/Dropdown.vue +71 -23
- package/dist/runtime/components/Dropdown.vue.d.ts +2 -2
- package/dist/runtime/components/FileUploader.d.vue.ts +1 -1
- package/dist/runtime/components/FileUploader.vue +11 -9
- package/dist/runtime/components/FileUploader.vue.d.ts +1 -1
- package/dist/runtime/components/Image.d.vue.ts +11 -1
- package/dist/runtime/components/Image.vue +15 -0
- package/dist/runtime/components/Image.vue.d.ts +11 -1
- package/dist/runtime/components/Input.d.vue.ts +5 -1
- package/dist/runtime/components/Input.vue +53 -14
- package/dist/runtime/components/Input.vue.d.ts +5 -1
- package/dist/runtime/components/Radio.d.vue.ts +2 -2
- package/dist/runtime/components/Radio.vue +9 -7
- package/dist/runtime/components/Radio.vue.d.ts +2 -2
- package/dist/runtime/components/ScrollArea.vue +4 -0
- package/dist/runtime/components/Select.d.vue.ts +1 -1
- package/dist/runtime/components/Select.vue +11 -9
- package/dist/runtime/components/Select.vue.d.ts +1 -1
- package/dist/runtime/components/Tabs.d.vue.ts +8 -1
- package/dist/runtime/components/Tabs.vue +21 -6
- package/dist/runtime/components/Tabs.vue.d.ts +8 -1
- package/dist/runtime/components/Textarea.d.vue.ts +39 -185
- package/dist/runtime/components/Textarea.vue +94 -71
- package/dist/runtime/components/Textarea.vue.d.ts +39 -185
- package/dist/runtime/components/Toggle.d.vue.ts +9 -3
- package/dist/runtime/components/Toggle.vue +70 -122
- package/dist/runtime/components/Toggle.vue.d.ts +9 -3
- package/dist/runtime/components/Tooltip.vue +3 -0
- package/dist/runtime/components/uiProps.d.ts +2 -2
- package/dist/runtime/components/uiProps.js +2 -2
- package/dist/runtime/components/useUiClasses.d.ts +3 -1
- package/dist/runtime/components/useUiClasses.js +7 -5
- package/dist/runtime/docs/index.vue +163 -72
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
11
11
|
readonly type: StringConstructor;
|
|
12
12
|
readonly default: "";
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
disabled: {
|
|
15
15
|
readonly type: BooleanConstructor;
|
|
16
16
|
readonly default: false;
|
|
17
17
|
};
|
|
@@ -21,7 +21,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
21
21
|
};
|
|
22
22
|
color: {
|
|
23
23
|
readonly type: StringConstructor;
|
|
24
|
-
readonly default: "
|
|
24
|
+
readonly default: "indigo-400";
|
|
25
25
|
};
|
|
26
26
|
rounded: {
|
|
27
27
|
readonly type: StringConstructor;
|
|
@@ -46,6 +46,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
46
46
|
type: StringConstructor;
|
|
47
47
|
default: null;
|
|
48
48
|
};
|
|
49
|
+
hint: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: null;
|
|
52
|
+
};
|
|
49
53
|
trueValue: {
|
|
50
54
|
default: boolean;
|
|
51
55
|
};
|
|
@@ -94,7 +98,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
94
98
|
readonly type: StringConstructor;
|
|
95
99
|
readonly default: "";
|
|
96
100
|
};
|
|
97
|
-
|
|
101
|
+
disabled: {
|
|
98
102
|
readonly type: BooleanConstructor;
|
|
99
103
|
readonly default: false;
|
|
100
104
|
};
|
|
@@ -104,7 +108,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
104
108
|
};
|
|
105
109
|
color: {
|
|
106
110
|
readonly type: StringConstructor;
|
|
107
|
-
readonly default: "
|
|
111
|
+
readonly default: "indigo-400";
|
|
108
112
|
};
|
|
109
113
|
rounded: {
|
|
110
114
|
readonly type: StringConstructor;
|
|
@@ -129,6 +133,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
129
133
|
type: StringConstructor;
|
|
130
134
|
default: null;
|
|
131
135
|
};
|
|
136
|
+
hint: {
|
|
137
|
+
type: StringConstructor;
|
|
138
|
+
default: null;
|
|
139
|
+
};
|
|
132
140
|
trueValue: {
|
|
133
141
|
default: boolean;
|
|
134
142
|
};
|
|
@@ -165,6 +173,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
165
173
|
}>> & Readonly<{
|
|
166
174
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
167
175
|
}>, {
|
|
176
|
+
disabled: boolean;
|
|
168
177
|
dense: boolean;
|
|
169
178
|
label: string;
|
|
170
179
|
name: string;
|
|
@@ -173,10 +182,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
173
182
|
contentClass: string;
|
|
174
183
|
contentStyle: string;
|
|
175
184
|
textColor: string;
|
|
176
|
-
disable: boolean;
|
|
177
185
|
loading: boolean;
|
|
178
186
|
rounded: string;
|
|
179
187
|
iconSize: string;
|
|
188
|
+
hint: string;
|
|
180
189
|
trueValue: boolean;
|
|
181
190
|
falseValue: boolean;
|
|
182
191
|
intermediateValue: null;
|
|
@@ -8,6 +8,7 @@ const props = defineProps({
|
|
|
8
8
|
modelValue: { required: true },
|
|
9
9
|
name: { type: String, default: null },
|
|
10
10
|
label: { type: String, default: null },
|
|
11
|
+
hint: { type: String, default: null },
|
|
11
12
|
trueValue: { default: true },
|
|
12
13
|
falseValue: { default: false },
|
|
13
14
|
intermediateValue: { default: null },
|
|
@@ -20,7 +21,7 @@ const props = defineProps({
|
|
|
20
21
|
...uiProps
|
|
21
22
|
});
|
|
22
23
|
const {
|
|
23
|
-
|
|
24
|
+
disabled,
|
|
24
25
|
color,
|
|
25
26
|
size,
|
|
26
27
|
rounded,
|
|
@@ -60,11 +61,11 @@ const boxColorClass = computed(() => {
|
|
|
60
61
|
const containerClass = computed(
|
|
61
62
|
() => `
|
|
62
63
|
inline-flex items-center gap-2
|
|
63
|
-
${
|
|
64
|
+
${disabled.value ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
|
|
64
65
|
`
|
|
65
66
|
);
|
|
66
67
|
function toggle() {
|
|
67
|
-
if (
|
|
68
|
+
if (disabled.value) return;
|
|
68
69
|
if (isChecked.value || isIntermediate.value) {
|
|
69
70
|
emit("update:modelValue", props.falseValue);
|
|
70
71
|
} else {
|
|
@@ -77,13 +78,18 @@ function toggle() {
|
|
|
77
78
|
<label
|
|
78
79
|
:class="containerClass"
|
|
79
80
|
role="checkbox"
|
|
81
|
+
:tabindex="disabled ? -1 : 0"
|
|
80
82
|
:aria-checked="isIntermediate ? 'mixed' : isChecked"
|
|
83
|
+
:aria-disabled="disabled"
|
|
84
|
+
@keydown.enter.prevent="toggle"
|
|
85
|
+
@keydown.space.prevent="toggle"
|
|
81
86
|
>
|
|
82
87
|
<input
|
|
83
88
|
type="checkbox"
|
|
84
89
|
class="hidden"
|
|
85
90
|
:name="name"
|
|
86
|
-
:disabled="
|
|
91
|
+
:disabled="disabled"
|
|
92
|
+
tabindex="-1"
|
|
87
93
|
@change="toggle"
|
|
88
94
|
/>
|
|
89
95
|
|
|
@@ -121,5 +127,6 @@ function toggle() {
|
|
|
121
127
|
<span v-if="label" class="select-none" :class="labelSizeClass">
|
|
122
128
|
{{ label }}
|
|
123
129
|
</span>
|
|
130
|
+
<span v-if="hint" class="text-xs text-gray-400 dark:text-gray-500">{{ hint }}</span>
|
|
124
131
|
</label>
|
|
125
132
|
</template>
|
|
@@ -11,7 +11,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
11
11
|
readonly type: StringConstructor;
|
|
12
12
|
readonly default: "";
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
disabled: {
|
|
15
15
|
readonly type: BooleanConstructor;
|
|
16
16
|
readonly default: false;
|
|
17
17
|
};
|
|
@@ -21,7 +21,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
21
21
|
};
|
|
22
22
|
color: {
|
|
23
23
|
readonly type: StringConstructor;
|
|
24
|
-
readonly default: "
|
|
24
|
+
readonly default: "indigo-400";
|
|
25
25
|
};
|
|
26
26
|
rounded: {
|
|
27
27
|
readonly type: StringConstructor;
|
|
@@ -46,6 +46,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
46
46
|
type: StringConstructor;
|
|
47
47
|
default: null;
|
|
48
48
|
};
|
|
49
|
+
hint: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: null;
|
|
52
|
+
};
|
|
49
53
|
trueValue: {
|
|
50
54
|
default: boolean;
|
|
51
55
|
};
|
|
@@ -94,7 +98,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
94
98
|
readonly type: StringConstructor;
|
|
95
99
|
readonly default: "";
|
|
96
100
|
};
|
|
97
|
-
|
|
101
|
+
disabled: {
|
|
98
102
|
readonly type: BooleanConstructor;
|
|
99
103
|
readonly default: false;
|
|
100
104
|
};
|
|
@@ -104,7 +108,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
104
108
|
};
|
|
105
109
|
color: {
|
|
106
110
|
readonly type: StringConstructor;
|
|
107
|
-
readonly default: "
|
|
111
|
+
readonly default: "indigo-400";
|
|
108
112
|
};
|
|
109
113
|
rounded: {
|
|
110
114
|
readonly type: StringConstructor;
|
|
@@ -129,6 +133,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
129
133
|
type: StringConstructor;
|
|
130
134
|
default: null;
|
|
131
135
|
};
|
|
136
|
+
hint: {
|
|
137
|
+
type: StringConstructor;
|
|
138
|
+
default: null;
|
|
139
|
+
};
|
|
132
140
|
trueValue: {
|
|
133
141
|
default: boolean;
|
|
134
142
|
};
|
|
@@ -165,6 +173,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
165
173
|
}>> & Readonly<{
|
|
166
174
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
167
175
|
}>, {
|
|
176
|
+
disabled: boolean;
|
|
168
177
|
dense: boolean;
|
|
169
178
|
label: string;
|
|
170
179
|
name: string;
|
|
@@ -173,10 +182,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
173
182
|
contentClass: string;
|
|
174
183
|
contentStyle: string;
|
|
175
184
|
textColor: string;
|
|
176
|
-
disable: boolean;
|
|
177
185
|
loading: boolean;
|
|
178
186
|
rounded: string;
|
|
179
187
|
iconSize: string;
|
|
188
|
+
hint: string;
|
|
180
189
|
trueValue: boolean;
|
|
181
190
|
falseValue: boolean;
|
|
182
191
|
intermediateValue: null;
|
|
@@ -15,7 +15,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
15
15
|
readonly type: StringConstructor;
|
|
16
16
|
readonly default: "";
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
disabled: {
|
|
19
19
|
readonly type: BooleanConstructor;
|
|
20
20
|
readonly default: false;
|
|
21
21
|
};
|
|
@@ -25,7 +25,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
25
25
|
};
|
|
26
26
|
color: {
|
|
27
27
|
readonly type: StringConstructor;
|
|
28
|
-
readonly default: "
|
|
28
|
+
readonly default: "indigo-400";
|
|
29
29
|
};
|
|
30
30
|
rounded: {
|
|
31
31
|
readonly type: StringConstructor;
|
|
@@ -68,7 +68,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
68
68
|
readonly type: StringConstructor;
|
|
69
69
|
readonly default: "";
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
disabled: {
|
|
72
72
|
readonly type: BooleanConstructor;
|
|
73
73
|
readonly default: false;
|
|
74
74
|
};
|
|
@@ -78,7 +78,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
78
78
|
};
|
|
79
79
|
color: {
|
|
80
80
|
readonly type: StringConstructor;
|
|
81
|
-
readonly default: "
|
|
81
|
+
readonly default: "indigo-400";
|
|
82
82
|
};
|
|
83
83
|
rounded: {
|
|
84
84
|
readonly type: StringConstructor;
|
|
@@ -109,6 +109,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
109
109
|
default: boolean;
|
|
110
110
|
};
|
|
111
111
|
}>> & Readonly<{}>, {
|
|
112
|
+
disabled: boolean;
|
|
112
113
|
color: string;
|
|
113
114
|
content: string;
|
|
114
115
|
size: string;
|
|
@@ -118,7 +119,6 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
118
119
|
contentClass: string;
|
|
119
120
|
contentStyle: string;
|
|
120
121
|
textColor: string;
|
|
121
|
-
disable: boolean;
|
|
122
122
|
loading: boolean;
|
|
123
123
|
rounded: string;
|
|
124
124
|
iconSize: string;
|
|
@@ -15,7 +15,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
15
15
|
readonly type: StringConstructor;
|
|
16
16
|
readonly default: "";
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
disabled: {
|
|
19
19
|
readonly type: BooleanConstructor;
|
|
20
20
|
readonly default: false;
|
|
21
21
|
};
|
|
@@ -25,7 +25,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
25
25
|
};
|
|
26
26
|
color: {
|
|
27
27
|
readonly type: StringConstructor;
|
|
28
|
-
readonly default: "
|
|
28
|
+
readonly default: "indigo-400";
|
|
29
29
|
};
|
|
30
30
|
rounded: {
|
|
31
31
|
readonly type: StringConstructor;
|
|
@@ -68,7 +68,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
68
68
|
readonly type: StringConstructor;
|
|
69
69
|
readonly default: "";
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
disabled: {
|
|
72
72
|
readonly type: BooleanConstructor;
|
|
73
73
|
readonly default: false;
|
|
74
74
|
};
|
|
@@ -78,7 +78,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
78
78
|
};
|
|
79
79
|
color: {
|
|
80
80
|
readonly type: StringConstructor;
|
|
81
|
-
readonly default: "
|
|
81
|
+
readonly default: "indigo-400";
|
|
82
82
|
};
|
|
83
83
|
rounded: {
|
|
84
84
|
readonly type: StringConstructor;
|
|
@@ -109,6 +109,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
109
109
|
default: boolean;
|
|
110
110
|
};
|
|
111
111
|
}>> & Readonly<{}>, {
|
|
112
|
+
disabled: boolean;
|
|
112
113
|
color: string;
|
|
113
114
|
content: string;
|
|
114
115
|
size: string;
|
|
@@ -118,7 +119,6 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
118
119
|
contentClass: string;
|
|
119
120
|
contentStyle: string;
|
|
120
121
|
textColor: string;
|
|
121
|
-
disable: boolean;
|
|
122
122
|
loading: boolean;
|
|
123
123
|
rounded: string;
|
|
124
124
|
iconSize: string;
|
|
@@ -15,28 +15,66 @@ function stringifyProps(props) {
|
|
|
15
15
|
return `${key}="${String(value)}"`;
|
|
16
16
|
}).filter(Boolean).join(" ");
|
|
17
17
|
}
|
|
18
|
-
function renderVNode(vnode) {
|
|
18
|
+
function renderVNode(vnode, depth = 0) {
|
|
19
|
+
const indent = " ".repeat(depth);
|
|
19
20
|
if (typeof vnode.children === "string") {
|
|
20
|
-
return vnode.children
|
|
21
|
+
return `${indent}${vnode.children}`;
|
|
21
22
|
}
|
|
22
23
|
if (vnode.type === /* @__PURE__ */ Symbol.for("v-fgt")) {
|
|
23
|
-
return vnode.children.map(renderVNode).join("");
|
|
24
|
+
return vnode.children.map((child) => renderVNode(child, depth)).filter(Boolean).join("\n");
|
|
24
25
|
}
|
|
25
26
|
if (typeof vnode.type === "object") {
|
|
26
27
|
const typeAny = vnode.type;
|
|
27
28
|
const name = typeAny.__name || typeAny.name || typeAny.displayName || "Component";
|
|
28
29
|
const props = stringifyProps(vnode.props);
|
|
29
|
-
return
|
|
30
|
+
return `${indent}<${name}${props ? " " + props : ""} />`;
|
|
30
31
|
}
|
|
31
32
|
if (typeof vnode.type === "string") {
|
|
32
|
-
const
|
|
33
|
-
|
|
33
|
+
const propsStr = stringifyProps(vnode.props);
|
|
34
|
+
const openTag = `<${vnode.type}${propsStr ? " " + propsStr : ""}>`;
|
|
35
|
+
const closeTag = `</${vnode.type}>`;
|
|
36
|
+
const children = Array.isArray(vnode.children) ? vnode.children : [];
|
|
37
|
+
const inlineText = typeof vnode.children === "string" ? vnode.children : "";
|
|
38
|
+
if (inlineText) {
|
|
39
|
+
return `${indent}${openTag}${inlineText}${closeTag}`;
|
|
40
|
+
}
|
|
41
|
+
if (!children.length) {
|
|
42
|
+
return `${indent}${openTag}${closeTag}`;
|
|
43
|
+
}
|
|
44
|
+
const hasElementChild = children.some(isVNode);
|
|
45
|
+
if (!hasElementChild) {
|
|
46
|
+
const flatText = children.filter((child) => typeof child === "string").join("");
|
|
47
|
+
return `${indent}${openTag}${flatText}${closeTag}`;
|
|
48
|
+
}
|
|
49
|
+
const childLines = children.map((child) => {
|
|
50
|
+
if (isVNode(child)) return renderVNode(child, depth + 1);
|
|
51
|
+
if (typeof child === "string" && child.trim()) return `${" ".repeat(depth + 1)}${child.trim()}`;
|
|
52
|
+
return "";
|
|
53
|
+
}).filter(Boolean).join("\n");
|
|
54
|
+
return `${indent}${openTag}
|
|
55
|
+
${childLines}
|
|
56
|
+
${indent}${closeTag}`;
|
|
34
57
|
}
|
|
35
58
|
return "";
|
|
36
59
|
}
|
|
37
60
|
const slotCode = computed(() => {
|
|
38
61
|
const vnodes = slots.default?.() || [];
|
|
39
|
-
return vnodes.map(renderVNode).join("");
|
|
62
|
+
return vnodes.map((vnode) => renderVNode(vnode, 0)).filter(Boolean).join("\n");
|
|
63
|
+
});
|
|
64
|
+
function escapeHtml(str) {
|
|
65
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
66
|
+
}
|
|
67
|
+
const highlightedCode = computed(() => {
|
|
68
|
+
let html = escapeHtml(slotCode.value);
|
|
69
|
+
html = html.replace(
|
|
70
|
+
/([\w-]+)="([^"]*)"/g,
|
|
71
|
+
'<span class="cb-attr">$1</span>=<span class="cb-string">"$2"</span>'
|
|
72
|
+
);
|
|
73
|
+
html = html.replace(
|
|
74
|
+
/(<\/?)([\w-]+)/g,
|
|
75
|
+
'$1<span class="cb-tag">$2</span>'
|
|
76
|
+
);
|
|
77
|
+
return html;
|
|
40
78
|
});
|
|
41
79
|
const buttonIcon = ref("content_copy");
|
|
42
80
|
const copyCode = async () => {
|
|
@@ -68,8 +106,12 @@ const copyCode = async () => {
|
|
|
68
106
|
</UITabPanel>
|
|
69
107
|
|
|
70
108
|
<UITabPanel name="code" label="Code">
|
|
71
|
-
<pre class="p-4 bg-gray-900 text-gray-100 text-sm overflow-x-auto"><code
|
|
109
|
+
<pre class="p-4 bg-gray-900 text-gray-100 text-sm overflow-x-auto overflow-y-auto max-h-96"><code v-html="highlightedCode" /></pre>
|
|
72
110
|
</UITabPanel>
|
|
73
111
|
</UITabs>
|
|
74
112
|
</div>
|
|
75
113
|
</template>
|
|
114
|
+
|
|
115
|
+
<style scoped>
|
|
116
|
+
:deep(.cb-tag){color:#7dd3fc}:deep(.cb-attr){color:#fbbf24}:deep(.cb-string){color:#86efac}
|
|
117
|
+
</style>
|
|
@@ -50,10 +50,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
50
50
|
readonly type: StringConstructor;
|
|
51
51
|
readonly default: "";
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
disabled: {
|
|
54
54
|
readonly type: BooleanConstructor;
|
|
55
55
|
readonly default: false;
|
|
56
56
|
};
|
|
57
|
+
events: {
|
|
58
|
+
type: () => {
|
|
59
|
+
date: string;
|
|
60
|
+
color?: string;
|
|
61
|
+
}[];
|
|
62
|
+
default: () => never[];
|
|
63
|
+
};
|
|
57
64
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
58
65
|
"update:modelValue": (...args: any[]) => void;
|
|
59
66
|
change: (...args: any[]) => void;
|
|
@@ -109,29 +116,40 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
109
116
|
readonly type: StringConstructor;
|
|
110
117
|
readonly default: "";
|
|
111
118
|
};
|
|
112
|
-
|
|
119
|
+
disabled: {
|
|
113
120
|
readonly type: BooleanConstructor;
|
|
114
121
|
readonly default: false;
|
|
115
122
|
};
|
|
123
|
+
events: {
|
|
124
|
+
type: () => {
|
|
125
|
+
date: string;
|
|
126
|
+
color?: string;
|
|
127
|
+
}[];
|
|
128
|
+
default: () => never[];
|
|
129
|
+
};
|
|
116
130
|
}>> & Readonly<{
|
|
117
131
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
118
132
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
119
133
|
}>, {
|
|
120
134
|
modelValue: string | unknown[];
|
|
135
|
+
disabled: boolean;
|
|
136
|
+
backgroundColor: string;
|
|
121
137
|
color: string;
|
|
122
138
|
flat: boolean;
|
|
123
|
-
backgroundColor: string;
|
|
124
139
|
borderRadius: string;
|
|
125
140
|
contentClass: string;
|
|
126
141
|
contentStyle: string;
|
|
127
142
|
textColor: string;
|
|
128
|
-
disable: boolean;
|
|
129
143
|
bordered: boolean;
|
|
130
144
|
multiDate: boolean;
|
|
131
145
|
rangeDate: boolean;
|
|
132
146
|
disabledDates: string[];
|
|
133
147
|
format: string;
|
|
134
148
|
showHeader: boolean;
|
|
149
|
+
events: {
|
|
150
|
+
date: string;
|
|
151
|
+
color?: string;
|
|
152
|
+
}[];
|
|
135
153
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
136
154
|
declare const _default: typeof __VLS_export;
|
|
137
155
|
export default _default;
|
|
@@ -17,7 +17,8 @@ const props = defineProps({
|
|
|
17
17
|
textColor: uiProps.textColor,
|
|
18
18
|
contentClass: uiProps.contentClass,
|
|
19
19
|
contentStyle: uiProps.contentStyle,
|
|
20
|
-
|
|
20
|
+
disabled: uiProps.disabled,
|
|
21
|
+
events: { type: Array, default: () => [] }
|
|
21
22
|
});
|
|
22
23
|
const {
|
|
23
24
|
isHex
|
|
@@ -29,10 +30,14 @@ const currentYear = ref(today.getFullYear());
|
|
|
29
30
|
const selectedDates = ref([]);
|
|
30
31
|
const rangeStart = ref(null);
|
|
31
32
|
const rangeEnd = ref(null);
|
|
33
|
+
function parseISO(value) {
|
|
34
|
+
const [year, month, day] = value.split("-").map(Number);
|
|
35
|
+
return new Date(year, month - 1, day);
|
|
36
|
+
}
|
|
32
37
|
const headerLabel = computed(() => {
|
|
33
38
|
const first = selectedDates.value[0];
|
|
34
39
|
if (!first) return "No date selected";
|
|
35
|
-
const date =
|
|
40
|
+
const date = parseISO(first);
|
|
36
41
|
const dayName = date.toLocaleDateString("default", {
|
|
37
42
|
weekday: "long"
|
|
38
43
|
});
|
|
@@ -73,15 +78,20 @@ function isDisabled(day) {
|
|
|
73
78
|
function isSelected(day) {
|
|
74
79
|
return selectedDates.value.includes(formatDate(day));
|
|
75
80
|
}
|
|
81
|
+
function eventFor(day) {
|
|
82
|
+
const value = formatDate(day);
|
|
83
|
+
return props.events.find((e) => e.date === value);
|
|
84
|
+
}
|
|
76
85
|
function isToday(day) {
|
|
77
86
|
const d = /* @__PURE__ */ new Date();
|
|
78
87
|
return day === d.getDate() && currentMonth.value === d.getMonth() && currentYear.value === d.getFullYear();
|
|
79
88
|
}
|
|
80
89
|
function isInRange(day) {
|
|
81
90
|
if (rangeStart.value === null || rangeEnd.value === null) return false;
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
91
|
+
const value = formatDate(day);
|
|
92
|
+
const start = rangeStart.value < rangeEnd.value ? rangeStart.value : rangeEnd.value;
|
|
93
|
+
const end = rangeStart.value < rangeEnd.value ? rangeEnd.value : rangeStart.value;
|
|
94
|
+
return value >= start && value <= end;
|
|
85
95
|
}
|
|
86
96
|
function dayClasses(day) {
|
|
87
97
|
if (isDisabled(day)) return "text-gray-300 cursor-not-allowed";
|
|
@@ -94,6 +104,7 @@ function dayClasses(day) {
|
|
|
94
104
|
return "hover:bg-gray-100";
|
|
95
105
|
}
|
|
96
106
|
function selectDate(day) {
|
|
107
|
+
if (props.disabled) return;
|
|
97
108
|
if (isDisabled(day)) return;
|
|
98
109
|
const value = formatDate(day);
|
|
99
110
|
if (props.multiDate) {
|
|
@@ -103,11 +114,13 @@ function selectDate(day) {
|
|
|
103
114
|
selectedDates.value.push(value);
|
|
104
115
|
}
|
|
105
116
|
} else if (props.rangeDate) {
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
const rangeIsComplete = rangeStart.value !== null && rangeEnd.value !== null;
|
|
118
|
+
if (rangeStart.value === null || rangeIsComplete) {
|
|
119
|
+
rangeStart.value = value;
|
|
108
120
|
rangeEnd.value = null;
|
|
121
|
+
selectedDates.value = [value];
|
|
109
122
|
} else {
|
|
110
|
-
rangeEnd.value =
|
|
123
|
+
rangeEnd.value = value;
|
|
111
124
|
selectedDates.value = buildRange();
|
|
112
125
|
}
|
|
113
126
|
} else {
|
|
@@ -118,21 +131,29 @@ function selectDate(day) {
|
|
|
118
131
|
}
|
|
119
132
|
function buildRange() {
|
|
120
133
|
if (rangeStart.value === null || rangeEnd.value === null) return [];
|
|
121
|
-
const
|
|
122
|
-
const
|
|
134
|
+
const startDate = parseISO(rangeStart.value);
|
|
135
|
+
const endDate = parseISO(rangeEnd.value);
|
|
136
|
+
const [from, to] = startDate <= endDate ? [startDate, endDate] : [endDate, startDate];
|
|
123
137
|
const range = [];
|
|
124
|
-
|
|
125
|
-
|
|
138
|
+
const cursor = new Date(from);
|
|
139
|
+
while (cursor <= to) {
|
|
140
|
+
const year = cursor.getFullYear();
|
|
141
|
+
const month = String(cursor.getMonth() + 1).padStart(2, "0");
|
|
142
|
+
const date = String(cursor.getDate()).padStart(2, "0");
|
|
143
|
+
range.push(`${year}-${month}-${date}`);
|
|
144
|
+
cursor.setDate(cursor.getDate() + 1);
|
|
126
145
|
}
|
|
127
146
|
return range;
|
|
128
147
|
}
|
|
129
148
|
function nextMonth() {
|
|
149
|
+
if (props.disabled) return;
|
|
130
150
|
if (currentMonth.value === 11) {
|
|
131
151
|
currentMonth.value = 0;
|
|
132
152
|
currentYear.value++;
|
|
133
153
|
} else currentMonth.value++;
|
|
134
154
|
}
|
|
135
155
|
function prevMonth() {
|
|
156
|
+
if (props.disabled) return;
|
|
136
157
|
if (currentMonth.value === 0) {
|
|
137
158
|
currentMonth.value = 11;
|
|
138
159
|
currentYear.value--;
|
|
@@ -157,9 +178,10 @@ watch(
|
|
|
157
178
|
borderRadius ? `rounded-${borderRadius}` : '',
|
|
158
179
|
bordered ? 'border border-gray-200' : '',
|
|
159
180
|
flat ? '' : 'shadow-md',
|
|
181
|
+
disabled ? 'opacity-50 pointer-events-none' : '',
|
|
160
182
|
textColor && !isHex(textColor) ? `text-${textColor}` : 'text-gray-800',
|
|
161
183
|
backgroundColor && !isHex(backgroundColor) ? `bg-${backgroundColor}` : ''
|
|
162
|
-
]" :style="{
|
|
184
|
+
]" :aria-disabled="disabled" :style="{
|
|
163
185
|
backgroundColor: isHex(backgroundColor) ? backgroundColor : '',
|
|
164
186
|
color: isHex(textColor) ? textColor : ''
|
|
165
187
|
}">
|
|
@@ -170,7 +192,7 @@ watch(
|
|
|
170
192
|
<div v-else>
|
|
171
193
|
<div class="text-lg" :class="`text-${color}-600`">{{ headerLabel }}</div>
|
|
172
194
|
<div class="text-gray-700">
|
|
173
|
-
{{ selectedDates[0] ? formatDateString(
|
|
195
|
+
{{ selectedDates[0] ? formatDateString(parseISO(selectedDates[0]), format) : "" }}
|
|
174
196
|
</div>
|
|
175
197
|
</div>
|
|
176
198
|
</div>
|
|
@@ -191,9 +213,11 @@ watch(
|
|
|
191
213
|
<div class="grid grid-cols-7 gap-1 px-3 pb-3">
|
|
192
214
|
<div v-for="n in blankDays" :key="'b' + n"></div>
|
|
193
215
|
<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"
|
|
216
|
+
class="relative h-10 flex items-center justify-center text-sm rounded-lg cursor-pointer transition-all duration-150"
|
|
195
217
|
:class="dayClasses(day)">
|
|
196
218
|
{{ day }}
|
|
219
|
+
<span v-if="eventFor(day)" class="absolute bottom-0.5 w-1.5 h-1.5 rounded-full"
|
|
220
|
+
:class="`bg-${eventFor(day).color || 'blue-500'}`" />
|
|
197
221
|
</div>
|
|
198
222
|
</div>
|
|
199
223
|
|
|
@@ -50,10 +50,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
50
50
|
readonly type: StringConstructor;
|
|
51
51
|
readonly default: "";
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
disabled: {
|
|
54
54
|
readonly type: BooleanConstructor;
|
|
55
55
|
readonly default: false;
|
|
56
56
|
};
|
|
57
|
+
events: {
|
|
58
|
+
type: () => {
|
|
59
|
+
date: string;
|
|
60
|
+
color?: string;
|
|
61
|
+
}[];
|
|
62
|
+
default: () => never[];
|
|
63
|
+
};
|
|
57
64
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
58
65
|
"update:modelValue": (...args: any[]) => void;
|
|
59
66
|
change: (...args: any[]) => void;
|
|
@@ -109,29 +116,40 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
109
116
|
readonly type: StringConstructor;
|
|
110
117
|
readonly default: "";
|
|
111
118
|
};
|
|
112
|
-
|
|
119
|
+
disabled: {
|
|
113
120
|
readonly type: BooleanConstructor;
|
|
114
121
|
readonly default: false;
|
|
115
122
|
};
|
|
123
|
+
events: {
|
|
124
|
+
type: () => {
|
|
125
|
+
date: string;
|
|
126
|
+
color?: string;
|
|
127
|
+
}[];
|
|
128
|
+
default: () => never[];
|
|
129
|
+
};
|
|
116
130
|
}>> & Readonly<{
|
|
117
131
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
118
132
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
119
133
|
}>, {
|
|
120
134
|
modelValue: string | unknown[];
|
|
135
|
+
disabled: boolean;
|
|
136
|
+
backgroundColor: string;
|
|
121
137
|
color: string;
|
|
122
138
|
flat: boolean;
|
|
123
|
-
backgroundColor: string;
|
|
124
139
|
borderRadius: string;
|
|
125
140
|
contentClass: string;
|
|
126
141
|
contentStyle: string;
|
|
127
142
|
textColor: string;
|
|
128
|
-
disable: boolean;
|
|
129
143
|
bordered: boolean;
|
|
130
144
|
multiDate: boolean;
|
|
131
145
|
rangeDate: boolean;
|
|
132
146
|
disabledDates: string[];
|
|
133
147
|
format: string;
|
|
134
148
|
showHeader: boolean;
|
|
149
|
+
events: {
|
|
150
|
+
date: string;
|
|
151
|
+
color?: string;
|
|
152
|
+
}[];
|
|
135
153
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
136
154
|
declare const _default: typeof __VLS_export;
|
|
137
155
|
export default _default;
|