ninemoon-ui 0.1.14 → 0.2.1
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/components/carousel/carousel.vue.d.ts +2 -0
- package/dist/components/date/datepicker.vue.d.ts +1 -1
- package/dist/components/date/datepickerRange.vue.d.ts +16 -0
- package/dist/components/form/formlabel.vue.d.ts +1 -3
- package/dist/components/pagination/pagination.vue.d.ts +8 -15
- package/dist/components/popover/popover.vue.d.ts +5 -0
- package/dist/components/switch/switch.vue.d.ts +10 -0
- package/dist/components/upload/upload.vue.d.ts +5 -0
- package/dist/index.d.ts +139 -61
- package/dist/index.es.js +21 -21
- package/dist/js/arrow/arrow.js +2 -2
- package/dist/js/badge/badge.js +1 -1
- package/dist/js/calendar/calendar.js +4 -4
- package/dist/js/carousel/carousel.js +59 -38
- package/dist/js/check/checkbox.js +4 -4
- package/dist/js/date/datepicker.js +20 -8
- package/dist/js/date/datepickerRange.js +104 -69
- package/dist/js/dateArrowplus/dateArrowplus.js +2 -2
- package/dist/js/delete/delete.js +2 -2
- package/dist/js/dialog/dialog.js +41 -29
- package/dist/js/form/formlabel.js +21 -89
- package/dist/js/image/image.js +17 -18
- package/dist/js/index/index.js +274 -253
- package/dist/js/input/input.js +8 -8
- package/dist/js/menu/menu.js +1 -1
- package/dist/js/numberInput/numberinput.js +8 -8
- package/dist/js/pagination/pagination.js +17 -14
- package/dist/js/popover/popover.js +3 -239
- package/dist/js/popover.vue_vue_type_script_setup_true_lang/popover.vue_vue_type_script_setup_true_lang.js +249 -0
- package/dist/js/radio/radiobox.js +4 -4
- package/dist/js/scrollBar/scrollBar.js +4 -4
- package/dist/js/select/select.js +5 -5
- package/dist/js/select/selectoption.js +3 -3
- package/dist/js/switch/switch.js +33 -7
- package/dist/js/table/table.js +107 -77
- package/dist/js/table/tableItem.js +2 -2
- package/dist/js/tabs/tabs.js +202 -21
- package/dist/js/upload/upload.js +57 -12
- package/dist/utils/tool.d.ts +5 -0
- package/package.json +5 -2
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { defineComponent, h, normalizeClass, normalizeStyle, ref, computed, nextTick, watch, getCurrentInstance, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, unref, createVNode, Transition, withCtx, withDirectives, resolveDynamicComponent, createCommentVNode, vShow } from "vue";
|
|
2
|
+
import { z as zIndexManager, u as usePotion, h as createScrollDirective, i as createBgClickDirective, c as createEscapeDirective, s as selector } from "../index/index.js";
|
|
3
|
+
const PLACEMENT_GROUPS = {
|
|
4
|
+
top: ["topleft", "topmiddle", "topright"],
|
|
5
|
+
bottom: ["bottomleft", "bottommiddle", "bottomright"],
|
|
6
|
+
center: ["centerleft", "centerright"]
|
|
7
|
+
};
|
|
8
|
+
const ARROW_CLASSES = {
|
|
9
|
+
base: 'absolute w-2.5 h-2.5 before:z-[-1] before:border before:border-gray-300 before:bg-white before:content-border before:rotate-45 before:content-[" "] before:w-2.5 before:h-2.5 before:absolute',
|
|
10
|
+
top: {
|
|
11
|
+
normal: "before:border-t-transparent before:border-l-transparent before:rounded-br",
|
|
12
|
+
exchange: "before:border-b-transparent before:border-r-transparent before:rounded-tl"
|
|
13
|
+
},
|
|
14
|
+
bottom: {
|
|
15
|
+
normal: "before:border-b-transparent before:border-r-transparent before:rounded-tl",
|
|
16
|
+
exchange: "before:border-t-transparent before:border-l-transparent before:rounded-br"
|
|
17
|
+
},
|
|
18
|
+
center: {
|
|
19
|
+
right: "before:border-r-transparent before:border-t-transparent before:rounded-bl",
|
|
20
|
+
left: "before:border-l-transparent before:border-b-transparent before:rounded-tr"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const arrowComponent = defineComponent({
|
|
24
|
+
name: "PopArrow",
|
|
25
|
+
props: {
|
|
26
|
+
arrowLeft: { type: Number, required: true },
|
|
27
|
+
arrowTop: { type: Number, required: true },
|
|
28
|
+
placement: { type: String, required: true },
|
|
29
|
+
exChange: { type: Boolean, required: true },
|
|
30
|
+
beforebgcolor: { type: String }
|
|
31
|
+
},
|
|
32
|
+
setup(props) {
|
|
33
|
+
const getArrowStyles = () => {
|
|
34
|
+
const { placement, exChange, arrowLeft, arrowTop } = props;
|
|
35
|
+
const isTopGroup = PLACEMENT_GROUPS.top.includes(placement);
|
|
36
|
+
const isBottomGroup = PLACEMENT_GROUPS.bottom.includes(placement);
|
|
37
|
+
const isCenterGroup = PLACEMENT_GROUPS.center.includes(placement);
|
|
38
|
+
return {
|
|
39
|
+
left: isTopGroup || isBottomGroup ? `${arrowLeft}px` : placement === "centerright" ? "-5px" : null,
|
|
40
|
+
right: placement === "centerleft" ? "-5px" : null,
|
|
41
|
+
top: isCenterGroup ? `${arrowTop}px` : isBottomGroup && !exChange || isTopGroup && exChange ? "-5px" : null,
|
|
42
|
+
bottom: isTopGroup && !exChange || isBottomGroup && exChange ? "-5px" : null
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const getArrowClasses = () => {
|
|
46
|
+
const { placement, exChange, beforebgcolor } = props;
|
|
47
|
+
const classes = [ARROW_CLASSES.base, beforebgcolor];
|
|
48
|
+
if (PLACEMENT_GROUPS.top.includes(placement)) {
|
|
49
|
+
classes.push(exChange ? ARROW_CLASSES.top.exchange : ARROW_CLASSES.top.normal);
|
|
50
|
+
}
|
|
51
|
+
if (PLACEMENT_GROUPS.bottom.includes(placement)) {
|
|
52
|
+
classes.push(exChange ? ARROW_CLASSES.bottom.exchange : ARROW_CLASSES.bottom.normal);
|
|
53
|
+
}
|
|
54
|
+
if (placement === "centerright") {
|
|
55
|
+
classes.push(ARROW_CLASSES.center.right);
|
|
56
|
+
}
|
|
57
|
+
if (placement === "centerleft") {
|
|
58
|
+
classes.push(ARROW_CLASSES.center.left);
|
|
59
|
+
}
|
|
60
|
+
return classes;
|
|
61
|
+
};
|
|
62
|
+
return () => h("span", {
|
|
63
|
+
class: normalizeClass(getArrowClasses()),
|
|
64
|
+
style: normalizeStyle(getArrowStyles())
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const defaultWidth = "200px";
|
|
69
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
70
|
+
__name: "popover",
|
|
71
|
+
props: {
|
|
72
|
+
trigger: { default: "click" },
|
|
73
|
+
width: {},
|
|
74
|
+
placement: { default: "topleft" },
|
|
75
|
+
insertClass: {},
|
|
76
|
+
beforeHidden: {},
|
|
77
|
+
modelValue: { type: Boolean },
|
|
78
|
+
beforebgcolor: {},
|
|
79
|
+
arrowshow: { type: Boolean, default: true },
|
|
80
|
+
renderType: { default: "show" }
|
|
81
|
+
},
|
|
82
|
+
emits: ["update:modelValue"],
|
|
83
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
84
|
+
const props = __props;
|
|
85
|
+
const base = ref();
|
|
86
|
+
const pop = ref();
|
|
87
|
+
const isLocalOpen = ref(false);
|
|
88
|
+
const currentZIndex = ref(zIndexManager.getCurrentZIndex());
|
|
89
|
+
const shouldShow = computed(() => {
|
|
90
|
+
if (isLocalOpen.value || props.trigger === "native" && props.modelValue) {
|
|
91
|
+
nextTick(setPosition);
|
|
92
|
+
}
|
|
93
|
+
if (props.trigger === "native") {
|
|
94
|
+
return props.modelValue;
|
|
95
|
+
} else {
|
|
96
|
+
return isLocalOpen.value;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
watch(shouldShow, (newVal) => {
|
|
100
|
+
if (newVal) {
|
|
101
|
+
currentZIndex.value = zIndexManager.getNextZIndex();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const emitAct = __emit;
|
|
105
|
+
const marginClass = computed(() => {
|
|
106
|
+
const marginMap = {
|
|
107
|
+
topleft: "-mt-3",
|
|
108
|
+
topmiddle: "-mt-3",
|
|
109
|
+
topright: "-mt-3",
|
|
110
|
+
bottomleft: "mt-3",
|
|
111
|
+
bottommiddle: "mt-3",
|
|
112
|
+
bottomright: "mt-3",
|
|
113
|
+
centerleft: "-ml-3",
|
|
114
|
+
centerright: "ml-3"
|
|
115
|
+
};
|
|
116
|
+
return marginMap[props.placement];
|
|
117
|
+
});
|
|
118
|
+
const showHandle = () => {
|
|
119
|
+
isLocalOpen.value = true;
|
|
120
|
+
};
|
|
121
|
+
const hovershowHandle = () => {
|
|
122
|
+
if (props.trigger === "hover") {
|
|
123
|
+
isLocalOpen.value = true;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const Left = ref(0);
|
|
127
|
+
const Top = ref(0);
|
|
128
|
+
const arrowLeft = ref(0);
|
|
129
|
+
const arrowTop = ref(0);
|
|
130
|
+
const exChange = ref(false);
|
|
131
|
+
const setPosition = () => {
|
|
132
|
+
const { top, bottom } = base.value.getBoundingClientRect();
|
|
133
|
+
if (top < 0 || bottom > window.innerHeight) {
|
|
134
|
+
hideHandle();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const position = usePotion(base.value, pop.value, {
|
|
138
|
+
position: props.placement
|
|
139
|
+
});
|
|
140
|
+
Top.value = position.Top;
|
|
141
|
+
Left.value = position.Left;
|
|
142
|
+
arrowTop.value = position.arrowTop;
|
|
143
|
+
arrowLeft.value = position.arrowLeft;
|
|
144
|
+
exChange.value = position.exChange;
|
|
145
|
+
};
|
|
146
|
+
const { proxy } = getCurrentInstance();
|
|
147
|
+
const vScroll = createScrollDirective({
|
|
148
|
+
onMove: () => {
|
|
149
|
+
setPosition();
|
|
150
|
+
},
|
|
151
|
+
scrollContainerId: (proxy == null ? void 0 : proxy.gloablScrollBar) ? proxy == null ? void 0 : proxy.gloablScrollBar : void 0
|
|
152
|
+
});
|
|
153
|
+
const vClickoutside = createBgClickDirective({
|
|
154
|
+
onCheckOut: (event, el) => {
|
|
155
|
+
if (el.contains(event.target)) {
|
|
156
|
+
return;
|
|
157
|
+
} else if (base.value.contains(event.target)) {
|
|
158
|
+
return;
|
|
159
|
+
} else {
|
|
160
|
+
closeCenter();
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
moveModel: props.trigger === "hover"
|
|
164
|
+
});
|
|
165
|
+
const vEsc = createEscapeDirective({
|
|
166
|
+
onEscape: () => {
|
|
167
|
+
hideHandle();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const closeCenter = () => {
|
|
171
|
+
if (props.beforeHidden) {
|
|
172
|
+
props.beforeHidden(hideHandle);
|
|
173
|
+
} else {
|
|
174
|
+
hideHandle();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const hideHandle = (disablecancelflag) => {
|
|
178
|
+
if (disablecancelflag === true) {
|
|
179
|
+
return;
|
|
180
|
+
} else {
|
|
181
|
+
if (props.trigger === "native") {
|
|
182
|
+
emitAct("update:modelValue", false);
|
|
183
|
+
} else {
|
|
184
|
+
isLocalOpen.value = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const widthNum = computed(() => {
|
|
189
|
+
if (!props.width)
|
|
190
|
+
return defaultWidth;
|
|
191
|
+
if (typeof props.width === "number") {
|
|
192
|
+
return `${props.width}px`;
|
|
193
|
+
} else if (typeof props.width === "string") {
|
|
194
|
+
const validUnit = /^(?:\d+(?:\.\d+)?)(?:px|%|em|rem|vw|vh)$/.test(
|
|
195
|
+
props.width
|
|
196
|
+
);
|
|
197
|
+
return validUnit ? props.width : `${props.width}px`;
|
|
198
|
+
}
|
|
199
|
+
return defaultWidth;
|
|
200
|
+
});
|
|
201
|
+
__expose({
|
|
202
|
+
hideHandle
|
|
203
|
+
});
|
|
204
|
+
return (_ctx, _cache) => {
|
|
205
|
+
return openBlock(), createElementBlock("div", {
|
|
206
|
+
class: "inline-block",
|
|
207
|
+
ref_key: "base",
|
|
208
|
+
ref: base,
|
|
209
|
+
onClick: showHandle,
|
|
210
|
+
onMouseenter: withModifiers(hovershowHandle, ["prevent"])
|
|
211
|
+
}, [
|
|
212
|
+
renderSlot(_ctx.$slots, "reference"),
|
|
213
|
+
(openBlock(), createBlock(Teleport, {
|
|
214
|
+
to: `#${unref(selector)}`
|
|
215
|
+
}, [
|
|
216
|
+
createVNode(Transition, { name: "opacity" }, {
|
|
217
|
+
default: withCtx(() => [
|
|
218
|
+
withDirectives((openBlock(), createElementBlock("div", {
|
|
219
|
+
ref_key: "pop",
|
|
220
|
+
ref: pop,
|
|
221
|
+
class: normalizeClass(["absolute rounded bg-white p-4 drop-shadow border border-gray-300 box-border", [marginClass.value, __props.insertClass]]),
|
|
222
|
+
style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px`, "z-index": currentZIndex.value })
|
|
223
|
+
}, [
|
|
224
|
+
renderSlot(_ctx.$slots, "default"),
|
|
225
|
+
__props.arrowshow ? (openBlock(), createBlock(resolveDynamicComponent(unref(arrowComponent)), {
|
|
226
|
+
key: 0,
|
|
227
|
+
arrowLeft: arrowLeft.value,
|
|
228
|
+
arrowTop: arrowTop.value,
|
|
229
|
+
exChange: exChange.value,
|
|
230
|
+
beforebgcolor: __props.beforebgcolor,
|
|
231
|
+
placement: __props.placement
|
|
232
|
+
}, null, 8, ["arrowLeft", "arrowTop", "exChange", "beforebgcolor", "placement"])) : createCommentVNode("", true)
|
|
233
|
+
], 6)), [
|
|
234
|
+
[vShow, shouldShow.value],
|
|
235
|
+
[unref(vClickoutside), shouldShow.value],
|
|
236
|
+
[unref(vEsc), shouldShow.value],
|
|
237
|
+
[unref(vScroll), shouldShow.value]
|
|
238
|
+
])
|
|
239
|
+
]),
|
|
240
|
+
_: 3
|
|
241
|
+
})
|
|
242
|
+
], 8, ["to"]))
|
|
243
|
+
], 544);
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
export {
|
|
248
|
+
_sfc_main as _
|
|
249
|
+
};
|
|
@@ -28,18 +28,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
28
28
|
const emit = __emit;
|
|
29
29
|
return (_ctx, _cache) => {
|
|
30
30
|
return openBlock(), createElementBlock("label", {
|
|
31
|
-
class: normalizeClass(["select-none text-sm inline-flex items-center cursor-pointer first:rounded-l-md last:rounded-r-md border-t border-b border-l last:border-r overflow-hidden", { "cursor-not-allowed":
|
|
31
|
+
class: normalizeClass(["select-none text-sm inline-flex items-center cursor-pointer first:rounded-l-md last:rounded-r-md border-t border-b border-l last:border-r overflow-hidden", { "cursor-not-allowed": __props.disabled }])
|
|
32
32
|
}, [
|
|
33
33
|
withDirectives(createElementVNode("input", {
|
|
34
34
|
type: "radio",
|
|
35
|
-
value:
|
|
35
|
+
value: __props.value,
|
|
36
36
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => checkedState.value = $event),
|
|
37
|
-
disabled:
|
|
37
|
+
disabled: __props.disabled,
|
|
38
38
|
class: "peer hidden disabled:cursor-not-allowed form-tick appearance-none h-4 w-4 rounded-full border border-gray-300 checked:border-transparent checked:bg-blue-600 focus:outline-none"
|
|
39
39
|
}, null, 8, _hoisted_1), [
|
|
40
40
|
[vModelRadio, checkedState.value]
|
|
41
41
|
]),
|
|
42
|
-
createElementVNode("div", _hoisted_2, toDisplayString(
|
|
42
|
+
createElementVNode("div", _hoisted_2, toDisplayString(__props.label), 1)
|
|
43
43
|
], 2);
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -113,13 +113,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
113
113
|
onMousedown: clickTrackHandler,
|
|
114
114
|
ref_key: "el",
|
|
115
115
|
ref: el,
|
|
116
|
-
class: normalizeClass(["absolute right-0.5 bottom-0.5 rounded transition-transform", [
|
|
116
|
+
class: normalizeClass(["absolute right-0.5 bottom-0.5 rounded transition-transform", [__props.vertical ? "top-0.5 w-1.5" : "left-0.5 h-1.5"]])
|
|
117
117
|
}, [
|
|
118
118
|
createElementVNode("div", {
|
|
119
119
|
onMousedown: clickThumbHandler,
|
|
120
120
|
ref_key: "thumb",
|
|
121
121
|
ref: thumb,
|
|
122
|
-
class: normalizeClass([
|
|
122
|
+
class: normalizeClass([__props.vertical ? "w-full" : "h-full", "bg-[#9092984d] cursor-pointer rounded"]),
|
|
123
123
|
style: normalizeStyle(renderThumbstyle())
|
|
124
124
|
}, null, 38)
|
|
125
125
|
], 34);
|
|
@@ -213,7 +213,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
213
213
|
setScrollLeft
|
|
214
214
|
});
|
|
215
215
|
return (_ctx, _cache) => {
|
|
216
|
-
return !
|
|
216
|
+
return !__props.native ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
217
217
|
createElementVNode("div", {
|
|
218
218
|
ref_key: "wrap",
|
|
219
219
|
ref: wrap,
|
|
@@ -222,7 +222,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
222
222
|
style: normalizeStyle(warpStyle.value),
|
|
223
223
|
onTouchstart: _cache[0] || (_cache[0] = ($event) => isTouching.value = true),
|
|
224
224
|
onTouchend: _cache[1] || (_cache[1] = ($event) => isTouching.value = false),
|
|
225
|
-
id:
|
|
225
|
+
id: __props.id
|
|
226
226
|
}, [
|
|
227
227
|
createElementVNode("div", {
|
|
228
228
|
ref_key: "contentBox",
|
package/dist/js/select/select.js
CHANGED
|
@@ -104,18 +104,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
104
104
|
ref_key: "inputbox",
|
|
105
105
|
ref: inputbox,
|
|
106
106
|
class: normalizeClass([{
|
|
107
|
-
"bg-gray-100 cursor-default":
|
|
108
|
-
"cursor-pointer": !
|
|
107
|
+
"bg-gray-100 cursor-default": __props.disabled,
|
|
108
|
+
"cursor-pointer": !__props.disabled
|
|
109
109
|
}, "relative flex h-full w-full items-center overflow-hidden rounded border border-solid"]),
|
|
110
110
|
onClick: showHandle
|
|
111
111
|
}, [
|
|
112
112
|
createElementVNode("input", {
|
|
113
113
|
value: inputLabel.value,
|
|
114
114
|
type: "text",
|
|
115
|
-
disabled:
|
|
116
|
-
readonly: !
|
|
115
|
+
disabled: __props.disabled,
|
|
116
|
+
readonly: !__props.filter,
|
|
117
117
|
class: normalizeClass(["w-full cursor-pointer appearance-none pl-2 text-sm outline-none disabled:cursor-default text-word3", heightClass.value]),
|
|
118
|
-
placeholder:
|
|
118
|
+
placeholder: __props.placeHolder
|
|
119
119
|
}, null, 10, _hoisted_1),
|
|
120
120
|
createVNode(ArrowIcon, {
|
|
121
121
|
class: normalizeClass(["w-3 h-3 fill-gray-300 inline-block transform transition-all mx-1", { "-rotate-90": showOption.value, "rotate-90": !showOption.value }])
|
|
@@ -42,12 +42,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
42
42
|
onMouseenter: moveIn,
|
|
43
43
|
class: normalizeClass(["px-1 py-2 cursor-pointer", {
|
|
44
44
|
"text-blue-light": isSelected.value,
|
|
45
|
-
"opacity-50 cursor-not-allowed":
|
|
46
|
-
"bg-gray-100": !
|
|
45
|
+
"opacity-50 cursor-not-allowed": __props.disabled,
|
|
46
|
+
"bg-gray-100": !__props.disabled && isHovered.value,
|
|
47
47
|
"bg-inherit": !isHovered.value
|
|
48
48
|
}])
|
|
49
49
|
}, [
|
|
50
|
-
!hasSlot.value ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(
|
|
50
|
+
!hasSlot.value ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(__props.label || __props.value), 1)) : renderSlot(_ctx.$slots, "default", { key: 1 })
|
|
51
51
|
], 34);
|
|
52
52
|
};
|
|
53
53
|
}
|
package/dist/js/switch/switch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, openBlock, createElementBlock, createElementVNode, normalizeStyle, normalizeClass, toDisplayString } from "vue";
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, normalizeStyle, normalizeClass, toDisplayString } from "vue";
|
|
2
2
|
const _hoisted_1 = { class: "inline-block cursor-pointer select-none text-xs relative" };
|
|
3
3
|
const _hoisted_2 = {
|
|
4
4
|
key: 0,
|
|
@@ -15,7 +15,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
15
15
|
uncheckedLabel: {},
|
|
16
16
|
checkedColor: { default: "#25b9e9" },
|
|
17
17
|
uncheckedColor: { default: "#666666" },
|
|
18
|
-
modelValue: { type: Boolean, default: false }
|
|
18
|
+
modelValue: { type: Boolean, default: false },
|
|
19
|
+
width: { default: "40px" },
|
|
20
|
+
height: { default: "20px" }
|
|
19
21
|
},
|
|
20
22
|
emits: ["update:modelValue", "switchChange"],
|
|
21
23
|
setup(__props, { emit: __emit }) {
|
|
@@ -25,6 +27,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
25
27
|
emit("update:modelValue", !props.modelValue);
|
|
26
28
|
emit("switchChange", !props.modelValue);
|
|
27
29
|
};
|
|
30
|
+
const containerStyle = computed(() => {
|
|
31
|
+
const width = typeof props.width === "number" ? props.width + "px" : props.width;
|
|
32
|
+
const height = typeof props.height === "number" ? props.height + "px" : props.height;
|
|
33
|
+
return {
|
|
34
|
+
backgroundColor: props.modelValue ? props.checkedColor : props.uncheckedColor,
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
minWidth: width,
|
|
38
|
+
borderRadius: typeof props.height === "number" ? props.height / 2 + "px" : `calc(${props.height} / 2)`
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const handleStyle = computed(() => {
|
|
42
|
+
const height = typeof props.height === "number" ? props.height + "px" : props.height;
|
|
43
|
+
return {
|
|
44
|
+
width: height,
|
|
45
|
+
height,
|
|
46
|
+
borderRadius: height
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
const handleClass = computed(() => {
|
|
50
|
+
const height = typeof props.height === "number" ? props.height + "px" : props.height;
|
|
51
|
+
return props.modelValue ? "left-[calc(100%-" + height + ")]" : "left-0";
|
|
52
|
+
});
|
|
28
53
|
return (_ctx, _cache) => {
|
|
29
54
|
return openBlock(), createElementBlock("label", _hoisted_1, [
|
|
30
55
|
createElementVNode("input", {
|
|
@@ -33,13 +58,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
33
58
|
onChange: togglehandle
|
|
34
59
|
}, null, 32),
|
|
35
60
|
createElementVNode("div", {
|
|
36
|
-
class: "relative box-border block
|
|
37
|
-
style: normalizeStyle(
|
|
61
|
+
class: "relative box-border block select-none overflow-hidden outline-0 ring-2 ring-gray-300",
|
|
62
|
+
style: normalizeStyle(containerStyle.value)
|
|
38
63
|
}, [
|
|
39
64
|
createElementVNode("div", {
|
|
40
|
-
class: normalizeClass(["absolute top-0 z-10 block
|
|
41
|
-
|
|
42
|
-
|
|
65
|
+
class: normalizeClass(["absolute top-0 z-10 block bg-slate-50 transition-all", handleClass.value]),
|
|
66
|
+
style: normalizeStyle(handleStyle.value)
|
|
67
|
+
}, null, 6),
|
|
68
|
+
__props.modelValue ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.checkedLabel), 1)) : (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(__props.uncheckedLabel), 1))
|
|
43
69
|
], 4)
|
|
44
70
|
]);
|
|
45
71
|
};
|