@studio-west/component-sw 0.12.24 → 0.13.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 +143 -30
- package/dist/{SwAlert-CU7nEnO-.js → SwAlert-CKJhS25j.js} +2 -2
- package/dist/SwButton-B-Z8Fhdv.js +61 -0
- package/dist/{SwDropdownItem-CKOTwhTf.js → SwDropdownItem-9Bq9fExK.js} +1 -1
- package/dist/SwFile-CfoiKvHJ.js +497 -0
- package/dist/{SwGide-Ie6XCPUn.js → SwGide-C62de-t6.js} +2 -2
- package/dist/{SwIcon-D6FCTrgR.js → SwIcon-CyVWEZkk.js} +1 -1
- package/dist/{SwInput-u7kS3lQn.js → SwInput-BED_o0wD.js} +1 -1
- package/dist/{SwMessage-DRjFGSK3.js → SwMessage-CA8jo3G7.js} +2 -2
- package/dist/{SwSkeleton-Byvq4bjt.js → SwSkeleton-BIj8PPM_.js} +1 -1
- package/dist/component-sw.css +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +21 -20
- package/package.json +2 -5
- package/types/components.d.ts +3 -0
- package/types/index.d.ts +19 -0
- package/dist/SwButton-Bvn3JLcT.js +0 -61
- package/src/Alert.ts +0 -70
- package/src/components/SwAlert.vue +0 -70
- package/src/components/SwButton.vue +0 -57
- package/src/components/SwButtonGroup.vue +0 -68
- package/src/components/SwCollapse.vue +0 -13
- package/src/components/SwDatePicker.vue +0 -375
- package/src/components/SwDropdown.vue +0 -195
- package/src/components/SwDropdownItem.vue +0 -26
- package/src/components/SwDropdownNew.vue +0 -175
- package/src/components/SwFormItem.vue +0 -21
- package/src/components/SwGide.vue +0 -128
- package/src/components/SwIcon.vue +0 -36
- package/src/components/SwInput.vue +0 -106
- package/src/components/SwMenu.vue +0 -217
- package/src/components/SwMessage.vue +0 -53
- package/src/components/SwSection.vue +0 -17
- package/src/components/SwSelect.vue +0 -153
- package/src/components/SwSkeleton.vue +0 -13
- package/src/components/SwSkeletonItem.vue +0 -27
- package/src/components/SwSlider.vue +0 -281
- package/src/components/SwSwitch.vue +0 -53
- package/src/components/SwTable.vue +0 -481
- package/src/components/SwTableColumn.vue +0 -88
- package/src/components/SwTabs.vue +0 -42
- package/src/components/SwTabsPane.vue +0 -44
- package/src/index.ts +0 -38
- package/src/utils/index.ts +0 -149
- /package/dist/{SwFormItem-DQJohClb.js → SwFormItem-rn5iuIUv.js} +0 -0
- /package/dist/{SwMenu-eQSh_MlP.js → SwMenu-Bh4BtVif.js} +0 -0
- /package/dist/{SwSection-BN1U3KaZ.js → SwSection-Bl3H3D2G.js} +0 -0
- /package/dist/{SwSelect-CMDZWWEI.js → SwSelect-DyArzImF.js} +0 -0
- /package/dist/{SwSkeletonItem-BnXZXE54.js → SwSkeletonItem-BKeBIWXT.js} +0 -0
- /package/dist/{SwSlider-DrIc0Xna.js → SwSlider-4S5KNn6o.js} +0 -0
- /package/dist/{SwSwitch-BVbje0T9.js → SwSwitch-BqAIQmG3.js} +0 -0
- /package/dist/{SwTable-4kHapbYy.js → SwTable-BjYEVovB.js} +0 -0
- /package/dist/{SwTableColumn-DCxVGb9d.js → SwTableColumn-CpNTUOVF.js} +0 -0
- /package/dist/{SwTabs-x2bXZwz1.js → SwTabs-jUzYPw9X.js} +0 -0
- /package/dist/{SwTabsPane-DpkTKQH8.js → SwTabsPane-Bhi49paR.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./SwAlert-
|
|
1
|
+
import { n as e } from "./SwAlert-CKJhS25j.js";
|
|
2
2
|
import { createApp as t, defineAsyncComponent as n, h as r } from "vue";
|
|
3
3
|
//#region src/Alert.ts
|
|
4
4
|
var i = null;
|
|
@@ -22,30 +22,31 @@ function a(n = {}) {
|
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/index.ts
|
|
24
24
|
var o = /* @__PURE__ */ Object.assign({
|
|
25
|
-
"./components/SwAlert.vue": () => import("./SwAlert-
|
|
26
|
-
"./components/SwButton.vue": () => import("./SwButton-
|
|
25
|
+
"./components/SwAlert.vue": () => import("./SwAlert-CKJhS25j.js").then((e) => e.t),
|
|
26
|
+
"./components/SwButton.vue": () => import("./SwButton-B-Z8Fhdv.js").then((e) => e.n),
|
|
27
27
|
"./components/SwButtonGroup.vue": () => import("./SwButtonGroup-Dmsbam44.js"),
|
|
28
28
|
"./components/SwCollapse.vue": () => import("./SwCollapse-Drz3qkNa.js"),
|
|
29
29
|
"./components/SwDatePicker.vue": () => import("./SwDatePicker-B3GrfMfB.js"),
|
|
30
30
|
"./components/SwDropdown.vue": () => import("./SwDropdown-DMkEn-su.js"),
|
|
31
|
-
"./components/SwDropdownItem.vue": () => import("./SwDropdownItem-
|
|
31
|
+
"./components/SwDropdownItem.vue": () => import("./SwDropdownItem-9Bq9fExK.js"),
|
|
32
32
|
"./components/SwDropdownNew.vue": () => import("./SwDropdownNew-TXu5V6xZ.js"),
|
|
33
|
-
"./components/
|
|
34
|
-
"./components/
|
|
35
|
-
"./components/
|
|
36
|
-
"./components/
|
|
37
|
-
"./components/
|
|
38
|
-
"./components/
|
|
39
|
-
"./components/
|
|
40
|
-
"./components/
|
|
41
|
-
"./components/
|
|
42
|
-
"./components/
|
|
43
|
-
"./components/
|
|
44
|
-
"./components/
|
|
45
|
-
"./components/
|
|
46
|
-
"./components/
|
|
47
|
-
"./components/
|
|
48
|
-
"./components/
|
|
33
|
+
"./components/SwFile.vue": () => import("./SwFile-CfoiKvHJ.js"),
|
|
34
|
+
"./components/SwFormItem.vue": () => import("./SwFormItem-rn5iuIUv.js"),
|
|
35
|
+
"./components/SwGide.vue": () => import("./SwGide-C62de-t6.js"),
|
|
36
|
+
"./components/SwIcon.vue": () => import("./SwIcon-CyVWEZkk.js").then((e) => e.t),
|
|
37
|
+
"./components/SwInput.vue": () => import("./SwInput-BED_o0wD.js"),
|
|
38
|
+
"./components/SwMenu.vue": () => import("./SwMenu-Bh4BtVif.js"),
|
|
39
|
+
"./components/SwMessage.vue": () => import("./SwMessage-CA8jo3G7.js"),
|
|
40
|
+
"./components/SwSection.vue": () => import("./SwSection-Bl3H3D2G.js"),
|
|
41
|
+
"./components/SwSelect.vue": () => import("./SwSelect-DyArzImF.js"),
|
|
42
|
+
"./components/SwSkeleton.vue": () => import("./SwSkeleton-BIj8PPM_.js"),
|
|
43
|
+
"./components/SwSkeletonItem.vue": () => import("./SwSkeletonItem-BKeBIWXT.js"),
|
|
44
|
+
"./components/SwSlider.vue": () => import("./SwSlider-4S5KNn6o.js"),
|
|
45
|
+
"./components/SwSwitch.vue": () => import("./SwSwitch-BqAIQmG3.js"),
|
|
46
|
+
"./components/SwTable.vue": () => import("./SwTable-BjYEVovB.js"),
|
|
47
|
+
"./components/SwTableColumn.vue": () => import("./SwTableColumn-CpNTUOVF.js"),
|
|
48
|
+
"./components/SwTabs.vue": () => import("./SwTabs-jUzYPw9X.js"),
|
|
49
|
+
"./components/SwTabsPane.vue": () => import("./SwTabsPane-Bhi49paR.js")
|
|
49
50
|
}), s = {};
|
|
50
51
|
for (let e in o) {
|
|
51
52
|
let t = e.split("/").pop().replace(".vue", "").replace(/-(\w)/g, (e, t) => t.toUpperCase());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studio-west/component-sw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Vue components of Component-SW collection.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -12,10 +12,7 @@
|
|
|
12
12
|
"homepage": "https://studiowest.ru/component-sw",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"types"
|
|
16
|
-
"src/**/*.d.ts",
|
|
17
|
-
"src/**/*.ts",
|
|
18
|
-
"src/**/*.vue"
|
|
15
|
+
"types"
|
|
19
16
|
],
|
|
20
17
|
"main": "./dist/index.cjs",
|
|
21
18
|
"module": "./dist/index.js",
|
package/types/components.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type SwInput = DefineComponent<import('./index').SwInputProps>
|
|
|
7
7
|
export type SwSwitch = DefineComponent<import('./index').SwSwitchProps>
|
|
8
8
|
export type SwSelect = DefineComponent<import('./index').SwSelectProps>
|
|
9
9
|
export type SwMenu = DefineComponent<import('./index').SwMenuProps>
|
|
10
|
+
export type SwFile = DefineComponent<import('./index').SwFileProps>
|
|
10
11
|
|
|
11
12
|
// Augment Vue's GlobalComponents interface
|
|
12
13
|
declare module 'vue' {
|
|
@@ -35,6 +36,7 @@ declare module 'vue' {
|
|
|
35
36
|
SwTabs: DefineComponent
|
|
36
37
|
SwTabsPane: DefineComponent
|
|
37
38
|
SwMenu: SwMenu
|
|
39
|
+
SwFile: SwFile
|
|
38
40
|
|
|
39
41
|
// kebab-case component names (alternative)
|
|
40
42
|
'sw-button': SwButton
|
|
@@ -60,6 +62,7 @@ declare module 'vue' {
|
|
|
60
62
|
'sw-tabs': DefineComponent
|
|
61
63
|
'sw-tabs-pane': DefineComponent
|
|
62
64
|
'sw-menu': SwMenu
|
|
65
|
+
'sw-file': SwFile
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
|
package/types/index.d.ts
CHANGED
|
@@ -75,12 +75,30 @@ export interface SwMenuProps {
|
|
|
75
75
|
class?: string
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export interface SwFileProps {
|
|
79
|
+
mode?: 'photo' | 'document'
|
|
80
|
+
disabled?: boolean
|
|
81
|
+
accept?: string
|
|
82
|
+
label?: string
|
|
83
|
+
class?: string
|
|
84
|
+
aspectRatio?: number | null
|
|
85
|
+
/** [empty, image, video] */
|
|
86
|
+
editorTitle?: [string, string, string] | string[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface SwFileItem {
|
|
90
|
+
id: string
|
|
91
|
+
file: File
|
|
92
|
+
previewUrl: string
|
|
93
|
+
}
|
|
94
|
+
|
|
78
95
|
// Export component constructor types
|
|
79
96
|
export type SwButton = DefineComponent<SwButtonProps>
|
|
80
97
|
export type SwInput = DefineComponent<SwInputProps>
|
|
81
98
|
export type SwSwitch = DefineComponent<SwSwitchProps>
|
|
82
99
|
export type SwSelect = DefineComponent<SwSelectProps>
|
|
83
100
|
export type SwMenu = DefineComponent<SwMenuProps>
|
|
101
|
+
export type SwFile = DefineComponent<SwFileProps>
|
|
84
102
|
|
|
85
103
|
// Global component registration
|
|
86
104
|
declare module 'vue' {
|
|
@@ -109,6 +127,7 @@ declare module 'vue' {
|
|
|
109
127
|
SwTabs: DefineComponent
|
|
110
128
|
SwTabsPane: DefineComponent
|
|
111
129
|
SwMenu: SwMenu
|
|
130
|
+
SwFile: DefineComponent
|
|
112
131
|
}
|
|
113
132
|
}
|
|
114
133
|
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { computed as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createTextVNode as i, defineComponent as a, normalizeClass as o, openBlock as s, renderSlot as c, resolveComponent as l, toDisplayString as u } from "vue";
|
|
2
|
-
//#endregion
|
|
3
|
-
//#region src/components/SwButton.vue
|
|
4
|
-
var d = /* @__PURE__ */ a({
|
|
5
|
-
__name: "SwButton",
|
|
6
|
-
props: {
|
|
7
|
-
class: { default: "" },
|
|
8
|
-
size: { default: "" },
|
|
9
|
-
type: { default: "" },
|
|
10
|
-
round: {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
default: !1
|
|
13
|
-
},
|
|
14
|
-
text: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: !1
|
|
17
|
-
},
|
|
18
|
-
link: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
default: !1
|
|
21
|
-
},
|
|
22
|
-
href: { default: "" },
|
|
23
|
-
disabled: {
|
|
24
|
-
type: Boolean,
|
|
25
|
-
default: !1
|
|
26
|
-
},
|
|
27
|
-
label: { default: "" },
|
|
28
|
-
prefix: { default: "" },
|
|
29
|
-
postfix: { default: "" }
|
|
30
|
-
},
|
|
31
|
-
setup(a) {
|
|
32
|
-
let d = a, f = () => {
|
|
33
|
-
if (d.href.length > 0) {
|
|
34
|
-
let e = document.createElement("a");
|
|
35
|
-
e.setAttribute("href", d.href), e.setAttribute("target", "_blank"), d.disabled || e.click();
|
|
36
|
-
}
|
|
37
|
-
}, p = e(() => {
|
|
38
|
-
let e = ["sw-button"];
|
|
39
|
-
return d.size.length > 0 && e.push("sw-" + d.size), d.type.length > 0 && e.push("sw-" + d.type), d.round && e.push("sw-round"), d.text && e.push("sw-text"), d.link && e.push("sw-link"), d.disabled && e.push("sw-disabled"), d.class.length > 0 && e.push(d.class), e;
|
|
40
|
-
});
|
|
41
|
-
return (e, d) => {
|
|
42
|
-
let m = l("sw-icon");
|
|
43
|
-
return s(), r("button", {
|
|
44
|
-
class: o(p.value),
|
|
45
|
-
onClick: f
|
|
46
|
-
}, [c(e.$slots, "default", {}, () => [
|
|
47
|
-
a.prefix ? (s(), t(m, {
|
|
48
|
-
key: 0,
|
|
49
|
-
iconClass: a.prefix
|
|
50
|
-
}, null, 8, ["iconClass"])) : n("", !0),
|
|
51
|
-
i(u(a.label), 1),
|
|
52
|
-
a.postfix ? (s(), t(m, {
|
|
53
|
-
key: 1,
|
|
54
|
-
iconClass: a.postfix
|
|
55
|
-
}, null, 8, ["iconClass"])) : n("", !0)
|
|
56
|
-
])], 2);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
//#endregion
|
|
61
|
-
export { d as default };
|
package/src/Alert.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createApp, h, type VNode } from 'vue'
|
|
2
|
-
import alert from './components/SwAlert.vue'
|
|
3
|
-
|
|
4
|
-
// Alert options interface
|
|
5
|
-
export interface AlertOptions {
|
|
6
|
-
title?: string
|
|
7
|
-
message?: string
|
|
8
|
-
type?: 'success' | 'warning' | 'error' | 'info'
|
|
9
|
-
duration?: number
|
|
10
|
-
showClose?: boolean
|
|
11
|
-
onClose?: () => void
|
|
12
|
-
prefix?: string | (() => VNode | VNode[])
|
|
13
|
-
suffix?: string | (() => VNode | VNode[])
|
|
14
|
-
footer?: string | (() => VNode | VNode[])
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
let container: HTMLDivElement | null = null
|
|
18
|
-
|
|
19
|
-
export function Alert(options: AlertOptions = {}): void {
|
|
20
|
-
if (typeof document === 'undefined') return
|
|
21
|
-
|
|
22
|
-
if (!container) {
|
|
23
|
-
container = document.querySelector("div.sw-alert-wrapper")
|
|
24
|
-
}
|
|
25
|
-
if (!container) {
|
|
26
|
-
container = document.createElement('div')
|
|
27
|
-
container.className = 'sw-alert-wrapper'
|
|
28
|
-
container.setAttribute('popover', 'manual')
|
|
29
|
-
document.body.appendChild(container)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
prefix,
|
|
34
|
-
suffix,
|
|
35
|
-
footer,
|
|
36
|
-
...props
|
|
37
|
-
} = options
|
|
38
|
-
|
|
39
|
-
const normalizeSlot = (slotContent: unknown): (() => VNode[] | null) | null => {
|
|
40
|
-
if (slotContent == null) return null
|
|
41
|
-
if (typeof slotContent === 'function') return slotContent as () => VNode[]
|
|
42
|
-
if (typeof slotContent === 'string') return () => [h('span', slotContent)]
|
|
43
|
-
if (Array.isArray(slotContent)) return () => slotContent as VNode[]
|
|
44
|
-
return () => [slotContent as VNode] // предполагаем, что это VNode
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const app = createApp({
|
|
48
|
-
setup() {
|
|
49
|
-
return () => h(alert, {
|
|
50
|
-
...props,
|
|
51
|
-
onClose: () => {
|
|
52
|
-
if (container && app._container) {
|
|
53
|
-
container.removeChild(app._container)
|
|
54
|
-
app.unmount()
|
|
55
|
-
}
|
|
56
|
-
if (options.onClose) options.onClose()
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
...(prefix != null && { prefix: normalizeSlot(prefix) }),
|
|
60
|
-
...(suffix != null && { suffix: normalizeSlot(suffix) }),
|
|
61
|
-
...(footer != null && { footer: normalizeSlot(footer) })
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const instance = app.mount(document.createElement('div'))
|
|
67
|
-
if (container && instance.$el) {
|
|
68
|
-
container.appendChild(instance.$el)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition name="fade">
|
|
3
|
-
<div v-if="visible" :class="style" @mouseenter="pauseTimer" @mouseleave="resumeTimer">
|
|
4
|
-
<sw-icon v-if="props.before.length > 0" :icon-class="props.before" />
|
|
5
|
-
<slot v-else name="prefix"></slot>
|
|
6
|
-
<slot>{{ props.message }}</slot>
|
|
7
|
-
<sw-icon v-if="props.after.length > 0" :icon-class="props.after" @click="close"/>
|
|
8
|
-
<slot v-else name="suffix"></slot>
|
|
9
|
-
<footer><slot name="footer"></slot></footer>
|
|
10
|
-
</div>
|
|
11
|
-
</transition>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script setup>
|
|
15
|
-
import { ref, computed, onMounted, onUnmounted } from "vue"
|
|
16
|
-
import SwIcon from "./SwIcon.vue"
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
message: {type: String, default: "Default message"},
|
|
19
|
-
before: {type: String, default: ''},
|
|
20
|
-
class: { type: String, default: ''},
|
|
21
|
-
after: {type: String, default: ''},
|
|
22
|
-
size: {type:String, default: ''},
|
|
23
|
-
duration: {type: Number, default: 6000},
|
|
24
|
-
type: {type:String, default: 'info', validator: (value) => ['success', 'warning', 'error', 'info'].includes(value)}
|
|
25
|
-
})
|
|
26
|
-
const emit = defineEmits(['closed'])
|
|
27
|
-
const visible = ref(false)
|
|
28
|
-
let timer = null
|
|
29
|
-
const show = () => {
|
|
30
|
-
document.querySelector('.sw-alert-wrapper').togglePopover()
|
|
31
|
-
visible.value = true
|
|
32
|
-
document.querySelector('.sw-alert-wrapper').showPopover()
|
|
33
|
-
startTimer()
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
const close = () => {
|
|
37
|
-
visible.value = false
|
|
38
|
-
emit("closed")
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const pauseTimer = () => {
|
|
42
|
-
if (timer) {
|
|
43
|
-
clearTimeout(timer)
|
|
44
|
-
timer = null
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const resumeTimer = () => {
|
|
49
|
-
startTimer()
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const startTimer = () => {
|
|
53
|
-
timer = setTimeout(close, props.duration)
|
|
54
|
-
};
|
|
55
|
-
onMounted(() => {
|
|
56
|
-
show()
|
|
57
|
-
})
|
|
58
|
-
onUnmounted(() => {
|
|
59
|
-
if (timer) {
|
|
60
|
-
clearTimeout(timer)
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
const style = computed(() =>{
|
|
64
|
-
const s = ['sw-alert']
|
|
65
|
-
if(props.size.length > 0) s.push(`sw-${props.size}`)
|
|
66
|
-
if(props.type.length > 0) s.push(`sw-${props.type}`)
|
|
67
|
-
if(props.class.length > 0) s.push(props.class)
|
|
68
|
-
return s
|
|
69
|
-
})
|
|
70
|
-
</script>
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<template>
|
|
3
|
-
<button :class="style" @click="isClick">
|
|
4
|
-
<slot><sw-icon v-if="prefix" :iconClass="prefix" />{{ label }}<sw-icon v-if="postfix" :iconClass="postfix" /></slot>
|
|
5
|
-
</button>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup lang="ts">
|
|
9
|
-
import { computed } from "vue"
|
|
10
|
-
|
|
11
|
-
// Define prop types
|
|
12
|
-
interface Props {
|
|
13
|
-
class?: string
|
|
14
|
-
size?: 'large' | 'small' | ''
|
|
15
|
-
type?: 'primary' | 'success' | 'info' | 'warning' | 'danger' | ''
|
|
16
|
-
round?: boolean
|
|
17
|
-
text?: boolean
|
|
18
|
-
link?: boolean
|
|
19
|
-
href?: string
|
|
20
|
-
disabled?: boolean
|
|
21
|
-
label?: string
|
|
22
|
-
prefix?: string
|
|
23
|
-
postfix?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
27
|
-
class: '',
|
|
28
|
-
size: '',
|
|
29
|
-
type: '',
|
|
30
|
-
round: false,
|
|
31
|
-
text: false,
|
|
32
|
-
link: false,
|
|
33
|
-
href: '',
|
|
34
|
-
disabled: false,
|
|
35
|
-
label: '',
|
|
36
|
-
prefix: '',
|
|
37
|
-
postfix: ''
|
|
38
|
-
})
|
|
39
|
-
const isClick = () =>{
|
|
40
|
-
if(props.href.length > 0){
|
|
41
|
-
const element = document.createElement('a')
|
|
42
|
-
element.setAttribute('href', props.href)
|
|
43
|
-
element.setAttribute('target', '_blank')
|
|
44
|
-
if(!props.disabled) element.click()
|
|
45
|
-
}}
|
|
46
|
-
const style = computed(() =>{
|
|
47
|
-
let s = ['sw-button']
|
|
48
|
-
if(props.size.length > 0) s.push('sw-' + props.size)
|
|
49
|
-
if(props.type.length > 0) s.push('sw-' + props.type)
|
|
50
|
-
if(props.round) s.push('sw-round')
|
|
51
|
-
if(props.text) s.push('sw-text')
|
|
52
|
-
if(props.link) s.push('sw-link')
|
|
53
|
-
if(props.disabled) s.push('sw-disabled')
|
|
54
|
-
if(props.class.length > 0) s.push(props.class)
|
|
55
|
-
return s
|
|
56
|
-
})
|
|
57
|
-
</script>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import {computed, onMounted, onUnmounted, ref, watch} from "vue"
|
|
3
|
-
|
|
4
|
-
const model = defineModel()
|
|
5
|
-
const buttons = ref([])
|
|
6
|
-
const buttonGroup = ref(null)
|
|
7
|
-
const observer = ref(null)
|
|
8
|
-
const props = defineProps({
|
|
9
|
-
class: {type:String, default: ''},
|
|
10
|
-
vertical: {type:Boolean, default: false},
|
|
11
|
-
radio: {type:Boolean, default: false},
|
|
12
|
-
round: {type:Boolean, default: false},
|
|
13
|
-
})
|
|
14
|
-
const style = computed(() =>{
|
|
15
|
-
let s = ['sw-button-group']
|
|
16
|
-
if(props.vertical) s.push('sw-vertical')
|
|
17
|
-
if(props.round) s.push('sw-round')
|
|
18
|
-
if(props.class.length > 0) s.push(props.class)
|
|
19
|
-
return s
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
onMounted(async () => {
|
|
23
|
-
await new Promise(resolve => setTimeout(resolve, 0))
|
|
24
|
-
if (props.radio) findSlotRootElements()
|
|
25
|
-
if (buttonGroup.value) {
|
|
26
|
-
observer.value = new MutationObserver(() => {
|
|
27
|
-
if (props.radio) findSlotRootElements()
|
|
28
|
-
})
|
|
29
|
-
observer.value.observe(buttonGroup.value, {
|
|
30
|
-
childList: true,
|
|
31
|
-
subtree: true
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
onUnmounted(() => {
|
|
37
|
-
if (observer.value) {
|
|
38
|
-
observer.value.disconnect()
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
watch(model,() => {
|
|
43
|
-
if (props.radio) {
|
|
44
|
-
[].forEach.call(buttons.value, (button, id) => {
|
|
45
|
-
if (id === model.value) button.classList.remove('sw-text')
|
|
46
|
-
else button.classList.add('sw-text')
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const findSlotRootElements = () => {
|
|
52
|
-
buttons.value = []
|
|
53
|
-
if (buttonGroup.value) buttons.value = buttonGroup.value.querySelectorAll('button, .sw-button')
|
|
54
|
-
if (props.radio) {
|
|
55
|
-
[].forEach.call(buttons.value, (button, id) => {
|
|
56
|
-
if (model.value !== id) button.classList.add('sw-text');
|
|
57
|
-
else button.classList.remove('sw-text');
|
|
58
|
-
button.addEventListener('click', () => model.value = id)
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
<template>
|
|
65
|
-
<div :class="style" ref="buttonGroup">
|
|
66
|
-
<slot />
|
|
67
|
-
</div>
|
|
68
|
-
</template>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sw-collapse" :class="{ 'is-open': props.visual }" >
|
|
3
|
-
<div class="sw-collapse__inner">
|
|
4
|
-
<slot></slot>
|
|
5
|
-
</div>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
<script setup>
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
visual: { type: Boolean, default: true }
|
|
11
|
-
})
|
|
12
|
-
</script>
|
|
13
|
-
|