@studio-west/component-sw 0.13.11 → 0.13.17

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { n as e } from "./SwIcon-C4RHAbK1.js";
2
- import { Transition as t, computed as n, createApp as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, defineAsyncComponent as l, h as u, normalizeClass as d, onMounted as f, onUnmounted as p, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, withCtx as v } from "vue";
1
+ import { n as e } from "./SwIcon-B-HHyuxu.js";
2
+ import { Transition as t, computed as n, createApp as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, defineAsyncComponent as l, h as u, normalizeClass as d, onMounted as f, onUnmounted as p, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, unref as v, useSlots as y, withCtx as b } from "vue";
3
3
  //#region src/components/SwAlert.vue
4
- var y = {
4
+ var x = { class: "body" }, S = { class: "text" }, C = { key: 0 }, w = {
5
5
  __name: "SwAlert",
6
6
  props: {
7
7
  message: {
@@ -35,108 +35,135 @@ var y = {
35
35
  "success",
36
36
  "warning",
37
37
  "error",
38
- "info"
38
+ "danger",
39
+ "info",
40
+ "primary"
39
41
  ].includes(e)
40
42
  }
41
43
  },
42
44
  emits: ["closed"],
43
45
  setup(r, { emit: l }) {
44
- let u = r, y = l, b = h(!1), x = null, S = () => {
45
- document.querySelector(".sw-alert-wrapper").togglePopover(), b.value = !0, document.querySelector(".sw-alert-wrapper").showPopover(), E();
46
- }, C = () => {
47
- b.value = !1, y("closed");
48
- }, w = () => {
49
- x &&= (clearTimeout(x), null);
50
- }, T = () => {
51
- E();
52
- }, E = () => {
53
- x = setTimeout(C, u.duration);
46
+ let u = y(), w = r, T = l, E = h(!1), D = null, O = () => {
47
+ E.value = !0, M();
48
+ }, k = () => {
49
+ E.value = !1, T("closed");
50
+ }, A = () => {
51
+ D &&= (clearTimeout(D), null);
52
+ }, j = () => {
53
+ M();
54
+ }, M = () => {
55
+ D = setTimeout(k, w.duration);
54
56
  };
55
57
  f(() => {
56
- S();
58
+ O();
57
59
  }), p(() => {
58
- x && clearTimeout(x);
60
+ D && clearTimeout(D);
59
61
  });
60
- let D = n(() => {
62
+ let N = n(() => {
61
63
  let e = ["sw-alert"];
62
- return u.size.length > 0 && e.push(`sw-${u.size}`), u.type.length > 0 && e.push(`sw-${u.type}`), u.class.length > 0 && e.push(u.class), e;
64
+ if (w.size.length > 0 && e.push(`sw-${w.size}`), w.type.length > 0) {
65
+ let t = w.type === "error" ? "danger" : w.type;
66
+ e.push(`sw-${t}`);
67
+ }
68
+ return w.class.length > 0 && e.push(w.class), e;
63
69
  });
64
70
  return (n, r) => (m(), i(t, { name: "fade" }, {
65
- default: v(() => [b.value ? (m(), o("div", {
71
+ default: b(() => [E.value ? (m(), o("div", {
66
72
  key: 0,
67
- class: d(D.value),
68
- onMouseenter: w,
69
- onMouseleave: T
70
- }, [
71
- u.before.length > 0 ? (m(), i(e, {
73
+ class: d(N.value),
74
+ onMouseenter: A,
75
+ onMouseleave: j
76
+ }, [s("div", x, [
77
+ w.before.length > 0 ? (m(), i(e, {
72
78
  key: 0,
73
- "icon-class": u.before
79
+ "icon-class": w.before
74
80
  }, null, 8, ["icon-class"])) : g(n.$slots, "prefix", {}, void 0, void 0, 1),
75
- g(n.$slots, "default", {}, () => [c(_(u.message), 1)]),
76
- u.after.length > 0 ? (m(), i(e, {
81
+ s("span", S, [g(n.$slots, "default", {}, () => [c(_(w.message), 1)])]),
82
+ w.after.length > 0 ? (m(), i(e, {
77
83
  key: 2,
78
- "icon-class": u.after,
79
- onClick: C
80
- }, null, 8, ["icon-class"])) : g(n.$slots, "suffix", {}, void 0, void 0, 3),
81
- s("footer", null, [g(n.$slots, "footer")])
82
- ], 34)) : a("", !0)]),
84
+ class: "close",
85
+ "icon-class": w.after,
86
+ onClick: k
87
+ }, null, 8, ["icon-class"])) : g(n.$slots, "suffix", {}, void 0, void 0, 3)
88
+ ]), v(u).footer ? (m(), o("footer", C, [g(n.$slots, "footer")])) : a("", !0)], 34)) : a("", !0)]),
83
89
  _: 3
84
90
  }));
85
91
  }
86
- }, b = null;
87
- function x(e = {}) {
92
+ }, T = /* @__PURE__ */ new Map(), E = "center", D = "top";
93
+ function O(e, t) {
94
+ return `${e}-${t}`;
95
+ }
96
+ function k(e, t) {
97
+ let n = O(e, t), r = T.get(n) ?? null;
98
+ return r ||= document.querySelector(`div.sw-alert-wrapper[data-place="${n}"]`), r || (r = document.createElement("div"), r.className = `sw-alert-wrapper place-${e} align-${t}`, r.dataset.place = n, r.setAttribute("popover", "manual"), document.body.appendChild(r), T.set(n, r)), r;
99
+ }
100
+ function A(e) {
101
+ if (typeof e.showPopover == "function") try {
102
+ e.matches(":popover-open") || e.showPopover();
103
+ } catch {}
104
+ }
105
+ function j(e) {
106
+ if (e.childElementCount > 0) return;
107
+ if (typeof e.hidePopover == "function") try {
108
+ e.matches(":popover-open") && e.hidePopover();
109
+ } catch {}
110
+ let t = e.dataset.place;
111
+ t && T.delete(t), e.remove();
112
+ }
113
+ function M(e = {}) {
88
114
  if (typeof document > "u") return;
89
- b ||= document.querySelector("div.sw-alert-wrapper"), b || (b = document.createElement("div"), b.className = "sw-alert-wrapper", b.setAttribute("popover", "manual"), document.body.appendChild(b));
90
- let { prefix: t, suffix: n, footer: i, ...a } = e, o = (e) => e == null ? null : typeof e == "function" ? e : typeof e == "string" ? () => [u("span", e)] : Array.isArray(e) ? () => e : () => [e], s = r({ setup() {
91
- return () => u(y, {
92
- ...a,
93
- onClose: () => {
94
- b && s._container && (b.removeChild(s._container), s.unmount()), e.onClose && e.onClose();
115
+ let t = e.placement ?? D, n = k(t, e.align ?? E), { prefix: i, suffix: a, footer: o, placement: s, align: c, ...l } = e, d = (e) => e == null ? null : typeof e == "function" ? e : typeof e == "string" ? () => [u("span", e)] : Array.isArray(e) ? () => e : () => [e], f = r({ setup() {
116
+ return () => u(w, {
117
+ ...l,
118
+ onClosed: () => {
119
+ f.unmount(), p.parentNode === n && n.removeChild(p), j(n), e.onClose && e.onClose();
95
120
  }
96
121
  }, {
97
- ...t != null && { prefix: o(t) },
98
- ...n != null && { suffix: o(n) },
99
- ...i != null && { footer: o(i) }
122
+ ...i != null && { prefix: d(i) },
123
+ ...a != null && { suffix: d(a) },
124
+ ...o != null && { footer: d(o) }
100
125
  });
101
- } }), c = s.mount(document.createElement("div"));
102
- b && c.$el && b.appendChild(c.$el);
126
+ } }), p = document.createElement("div");
127
+ p.className = "sw-alert-host", f.mount(p), t === "bottom" && n.firstChild ? n.insertBefore(p, n.firstChild) : n.appendChild(p), A(n);
103
128
  }
104
129
  //#endregion
105
130
  //#region src/index.ts
106
- var S = /* #__PURE__ */ Object.assign({
107
- "./components/SwButton.vue": () => import("./SwButton-BfG2InPf.js").then((e) => e.n),
131
+ var N = /* #__PURE__ */ Object.assign({
132
+ "./components/SwBadge.vue": () => import("./SwBadge-BOqWsTgl.js"),
133
+ "./components/SwButton.vue": () => import("./SwButton-DpOGpsBS.js").then((e) => e.n),
108
134
  "./components/SwButtonGroup.vue": () => import("./SwButtonGroup-Ck8aedFL.js"),
109
135
  "./components/SwCollapse.vue": () => import("./SwCollapse-DrCfi6Ly.js"),
110
- "./components/SwDatePicker.vue": () => import("./SwDatePicker-BfuFsZeg.js"),
111
- "./components/SwDropdown.vue": () => import("./SwDropdown-BTADCvrN.js"),
112
- "./components/SwDropdownItem.vue": () => import("./SwDropdownItem-BBDMECgR.js"),
113
- "./components/SwDropdownNew.vue": () => import("./SwDropdownNew-BuCIN-iv.js"),
114
- "./components/SwFile.vue": () => import("./SwFile-D8wkf69j.js"),
115
- "./components/SwFormItem.vue": () => import("./SwFormItem-DgFaNwe9.js"),
116
- "./components/SwGide.vue": () => import("./SwGide-Da6Nv8Dd.js"),
117
- "./components/SwIcon.vue": () => import("./SwIcon-C4RHAbK1.js").then((e) => e.t),
118
- "./components/SwInput.vue": () => import("./SwInput-0Eph7P-m.js"),
136
+ "./components/SwDatePicker.vue": () => import("./SwDatePicker-BwgaZLnR.js"),
137
+ "./components/SwDropdown.vue": () => import("./SwDropdown-DpedC6Bn.js"),
138
+ "./components/SwDropdownItem.vue": () => import("./SwDropdownItem-DthBPUxn.js"),
139
+ "./components/SwFile.vue": () => import("./SwFile-DfeOYJQc.js"),
140
+ "./components/SwFormItem.vue": () => import("./SwFormItem-SuqNvXBQ.js"),
141
+ "./components/SwGide.vue": () => import("./SwGide-BjQbQiBI.js"),
142
+ "./components/SwIcon.vue": () => import("./SwIcon-B-HHyuxu.js").then((e) => e.t),
143
+ "./components/SwInput.vue": () => import("./SwInput-BQXnoovf.js"),
119
144
  "./components/SwMenu.vue": () => import("./SwMenu-Dohv0z9N.js"),
120
- "./components/SwMessage.vue": () => import("./SwMessage-WHO6knac.js"),
145
+ "./components/SwMessage.vue": () => import("./SwMessage-BghpMRWc.js"),
146
+ "./components/SwPagination.vue": () => import("./SwPagination-jTW9BD5P.js"),
121
147
  "./components/SwSection.vue": () => import("./SwSection-Ck1GYU_A.js"),
122
- "./components/SwSelect.vue": () => import("./SwSelect-DwxIlRFI.js"),
148
+ "./components/SwSelect.vue": () => import("./SwSelect-DDNh3p6B.js"),
123
149
  "./components/SwSkeleton.vue": () => import("./SwSkeleton-DsjPQpL2.js"),
124
150
  "./components/SwSkeletonItem.vue": () => import("./SwSkeletonItem-DOBVXQbh.js"),
125
- "./components/SwSlider.vue": () => import("./SwSlider-DkgJH6Bh.js"),
151
+ "./components/SwSlider.vue": () => import("./SwSlider-Cl9pwY6h.js"),
126
152
  "./components/SwSwitch.vue": () => import("./SwSwitch-Cxk-eNTf.js"),
127
153
  "./components/SwTable.vue": () => import("./SwTable-DE3cDsvN.js"),
128
154
  "./components/SwTableColumn.vue": () => import("./SwTableColumn-DQT28erv.js"),
129
155
  "./components/SwTabs.vue": () => import("./SwTabs-A6JIa-Kl.js"),
130
- "./components/SwTabsPane.vue": () => import("./SwTabsPane-CDBFh3D3.js")
131
- }), C = { SwAlert: y };
132
- for (let e in S) {
156
+ "./components/SwTabsPane.vue": () => import("./SwTabsPane-CDBFh3D3.js"),
157
+ "./components/SwTag.vue": () => import("./SwTag-DjZlthUS.js")
158
+ }), P = { SwAlert: w };
159
+ for (let e in N) {
133
160
  let t = e.split("/").pop().replace(".vue", "").replace(/-(\w)/g, (e, t) => t.toUpperCase());
134
- C[t] = l(() => S[e]());
161
+ P[t] = l(() => N[e]());
135
162
  }
136
- var w = { install(e) {
137
- Object.keys(C).forEach((t) => {
138
- e.component(t, C[t]);
139
- }), e.config.globalProperties.$Alert = x, e.provide("Alert", x);
163
+ var F = { install(e) {
164
+ Object.keys(P).forEach((t) => {
165
+ e.component(t, P[t]);
166
+ }), e.config.globalProperties.$Alert = M, e.provide("Alert", M);
140
167
  } };
141
168
  //#endregion
142
- export { x as Alert, w as Library, C as components };
169
+ export { M as Alert, F as Library, P as components };
@@ -36,7 +36,22 @@ function r(e, t) {
36
36
  let s = n.slice(0, e.length).replace(/_+/g, (e) => `\\d{1,${e.length}}`).replace(/[+()]/g, "\\$&"), c = RegExp(`^${s}$`);
37
37
  return o = o.replace(/[-—]$|(\) )$/g, ""), !c.test(e) || e.length < 5 ? o : e;
38
38
  }
39
- function i(e, t = !1) {
39
+ function i(e) {
40
+ if (typeof document > "u" || !document.body) return 0;
41
+ let t = 0, n = document.body.querySelectorAll("*");
42
+ for (let r = 0; r < n.length; r++) {
43
+ let i = n[r];
44
+ if (e && (i === e || e.contains(i)) || i.closest(".sw-alert-wrapper, .sw-dropdown-popup.gide")) continue;
45
+ let a = getComputedStyle(i);
46
+ if (a.position === "static") continue;
47
+ let o = a.zIndex;
48
+ if (o === "auto") continue;
49
+ let s = Number.parseInt(o, 10);
50
+ !Number.isNaN(s) && s > t && (t = s);
51
+ }
52
+ return t;
53
+ }
54
+ function a(e, t = !1) {
40
55
  let n = e.getBoundingClientRect();
41
56
  return t ? n.left > 50 ? {
42
57
  right: "100%",
@@ -50,4 +65,4 @@ function i(e, t = !1) {
50
65
  };
51
66
  }
52
67
  //#endregion
53
- export { t as a, n as i, r as n, e as r, i as t };
68
+ export { n as a, i, r as n, t as o, e as r, a as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studio-west/component-sw",
3
- "version": "0.13.11",
3
+ "version": "0.13.17",
4
4
  "description": "Vue components of Component-SW collection.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -52,6 +52,9 @@
52
52
  },
53
53
  "author": "Alexander Efimov",
54
54
  "license": "MIT",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
55
58
  "engines": {
56
59
  "node": ">=20.19.0 || >=22.12.0"
57
60
  }
@@ -22,7 +22,6 @@ declare module 'vue' {
22
22
  SwCollapse: DefineComponent
23
23
  SwDropdown: DefineComponent
24
24
  SwDropdownItem: DefineComponent
25
- SwDropdownNew: DefineComponent
26
25
  SwFormItem: DefineComponent
27
26
  SwGide: DefineComponent
28
27
  SwIcon: DefineComponent
@@ -48,7 +47,6 @@ declare module 'vue' {
48
47
  'sw-collapse': DefineComponent
49
48
  'sw-dropdown': DefineComponent
50
49
  'sw-dropdown-item': DefineComponent
51
- 'sw-dropdown-new': DefineComponent
52
50
  'sw-form-item': DefineComponent
53
51
  'sw-gide': DefineComponent
54
52
  'sw-icon': DefineComponent
package/types/index.d.ts CHANGED
@@ -7,14 +7,21 @@ export interface LibraryPlugin extends Plugin {
7
7
 
8
8
  declare const Library: LibraryPlugin
9
9
 
10
+ export type AlertAlign = 'left' | 'center' | 'right'
11
+ export type AlertPlacement = 'top' | 'bottom'
12
+
10
13
  // Alert options interface
11
14
  export interface AlertOptions {
12
15
  title?: string
13
16
  message?: string
14
- type?: 'success' | 'warning' | 'error' | 'info'
17
+ type?: 'success' | 'warning' | 'error' | 'danger' | 'info' | 'primary'
15
18
  duration?: number
16
19
  showClose?: boolean
17
20
  onClose?: () => void
21
+ /** Горизонталь: слева, по центру, справа */
22
+ align?: AlertAlign
23
+ /** Вертикаль: top — старые сверху; bottom — свежие сверху */
24
+ placement?: AlertPlacement
18
25
  before?: string
19
26
  after?: string
20
27
  /** Слот #prefix (для иконки — `before`) */
@@ -62,6 +69,8 @@ export interface SwInputProps {
62
69
  minlength?: number
63
70
  inputSize?: number
64
71
  autofocus?: boolean
72
+ clearable?: boolean
73
+ rows?: number
65
74
  }
66
75
 
67
76
  export interface SwSwitchProps {
@@ -81,6 +90,40 @@ export interface SwSelectProps {
81
90
  token?: string
82
91
  }
83
92
 
93
+ export interface SwTagProps {
94
+ class?: string
95
+ size?: 'large' | 'small' | ''
96
+ type?: 'primary' | 'success' | 'info' | 'warning' | 'danger' | ''
97
+ label?: string
98
+ before?: string
99
+ closable?: boolean
100
+ round?: boolean
101
+ disabled?: boolean
102
+ }
103
+
104
+ export interface SwBadgeProps {
105
+ class?: string
106
+ type?: 'primary' | 'success' | 'info' | 'warning' | 'danger' | ''
107
+ value?: number | string
108
+ max?: number
109
+ isDot?: boolean
110
+ showZero?: boolean
111
+ hidden?: boolean
112
+ }
113
+
114
+ export interface SwPaginationProps {
115
+ class?: string
116
+ size?: 'large' | 'small' | ''
117
+ total?: number
118
+ pageSize?: number
119
+ pagerCount?: number
120
+ disabled?: boolean
121
+ showTotal?: boolean
122
+ showSize?: boolean
123
+ pageSizes?: number[]
124
+ modelValue?: number
125
+ }
126
+
84
127
  export interface SwMenuProps {
85
128
  menuItems: Record<string, any> | Array<{ [componentName: string]: any }>
86
129
  class?: string
@@ -108,6 +151,9 @@ export type SwButton = DefineComponent<SwButtonProps>
108
151
  export type SwInput = DefineComponent<SwInputProps>
109
152
  export type SwSwitch = DefineComponent<SwSwitchProps>
110
153
  export type SwSelect = DefineComponent<SwSelectProps>
154
+ export type SwTag = DefineComponent<SwTagProps>
155
+ export type SwBadge = DefineComponent<SwBadgeProps>
156
+ export type SwPagination = DefineComponent<SwPaginationProps>
111
157
  export type SwMenu = DefineComponent<SwMenuProps>
112
158
  export type SwFile = DefineComponent<SwFileProps>
113
159
 
@@ -118,13 +164,15 @@ declare module 'vue' {
118
164
  SwInput: SwInput
119
165
  SwSwitch: SwSwitch
120
166
  SwSelect: SwSelect
167
+ SwTag: SwTag
168
+ SwBadge: SwBadge
169
+ SwPagination: SwPagination
121
170
  // Add other components as needed
122
171
  SwAlert: DefineComponent
123
172
  SwButtonGroup: DefineComponent
124
173
  SwCollapse: DefineComponent
125
174
  SwDropdown: DefineComponent
126
175
  SwDropdownItem: DefineComponent
127
- SwDropdownNew: DefineComponent
128
176
  SwFormItem: DefineComponent
129
177
  SwGide: DefineComponent
130
178
  SwIcon: DefineComponent
@@ -1,114 +0,0 @@
1
- import { Teleport as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, mergeModels as a, normalizeClass as o, normalizeStyle as s, onMounted as c, onUnmounted as l, openBlock as u, ref as d, renderSlot as f, unref as p, useModel as m, watchEffect as h, withModifiers as g } from "vue";
2
- //#region src/components/SwDropdown.vue
3
- var _ = ["id"], v = {
4
- __name: "SwDropdown",
5
- props: /*@__PURE__*/ a({
6
- class: {
7
- type: String,
8
- default: ""
9
- },
10
- size: {
11
- type: String,
12
- default: ""
13
- },
14
- type: {
15
- type: String,
16
- default: ""
17
- },
18
- trigger: {
19
- type: String,
20
- default: "click"
21
- },
22
- placement: {
23
- type: String,
24
- default: "bottom-left"
25
- },
26
- maxWidth: {
27
- type: Number,
28
- default: 0
29
- }
30
- }, {
31
- modelValue: {},
32
- modelModifiers: {}
33
- }),
34
- emits: ["update:modelValue"],
35
- setup(a, { expose: v }) {
36
- let y = a, b = m(a, "modelValue"), x = d(null), S = d(null), C = d({}), w = Math.ceil(Math.random() * 1e3), T = d(0), E = t(() => {
37
- let e = ["sw-dropdown"];
38
- return y.size.length > 0 && e.push("sw-" + y.size), y.type.length > 0 && e.push("sw-" + y.type), e;
39
- }), D = new ResizeObserver(() => {
40
- b.value && T.value++, T.value > 99 && (T.value = 1);
41
- });
42
- h(() => {
43
- if (!b.value || !S.value || !x.value) return;
44
- T.value < 2 && D.observe(S.value);
45
- let e = window.pageYOffset || document.documentElement.scrollTop, t = window.pageXOffset || document.documentElement.scrollLeft;
46
- document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = `-${t}px`, document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.documentElement.scrollTop = e, document.documentElement.scrollLeft = t;
47
- let n = x.value.getBoundingClientRect(), r = window.innerWidth, i = window.innerHeight, a = S.value.offsetHeight, o = S.value.offsetWidth, s = n.left + n.width / 2 + t, c = n.top + n.height / 2 + e, l = n.height / 2 + 8, [u, d] = y.placement.split("-", 2);
48
- switch (u) {
49
- case "bottom":
50
- c = e + i - a - l - 8 < c ? c - l - a : c + l, d === void 0 && (s -= o / 2);
51
- break;
52
- case "top":
53
- c = e + a + l + 8 > c ? c + l : c - l - a, d === void 0 && (s -= o / 2);
54
- break;
55
- case "left":
56
- s - o - n.width / 2 - 8 < 0 ? s + n.width / 2 + 8 + o < r ? (s = s + n.width / 2 + 8, c -= a / 2) : (c = e + a + l + 8 > c ? c + l : c - l - a, s = s + n.width / 2 < r ? s + n.width / 2 - o : s - o / 2) : (s = s - o - n.width / 2 - 8, c -= a / 2);
57
- break;
58
- case "right":
59
- s + n.width / 2 + 8 + o > r ? s - o - n.width / 2 - 8 > 0 ? (s = s - o - n.width / 2 - 8, c -= a / 2) : (c = e + a + l + 8 > c ? c + l : c - l - a, s -= n.width / 2) : (s = s + n.width / 2 + 8, c -= a / 2);
60
- break;
61
- }
62
- switch (d) {
63
- case "left":
64
- s = t + r - 8 > s - n.width / 2 + o ? s - n.width / 2 : s - o + n.width / 2;
65
- break;
66
- case "right":
67
- s = 8 < s + n.width / 2 - o ? s - o + n.width / 2 : s - n.width / 2;
68
- break;
69
- }
70
- s < 0 && (s = 0), c < 0 && (c = 0), C.value = {
71
- position: "absolute",
72
- top: `${c}px`,
73
- left: `${s}px`,
74
- maxWidth: y.maxWidth > 0 ? `${y.maxWidth}px` : ""
75
- };
76
- }, { flush: "post" });
77
- let O = () => {
78
- y.trigger === "click" && (b.value = !b.value);
79
- }, k = () => {
80
- y.trigger === "hover" && (b.value = !b.value);
81
- }, A = () => {
82
- y.trigger === "context" && (b.value = !b.value);
83
- }, j = () => {
84
- b.value && T.value++, T.value > 99 && (T.value = 1);
85
- };
86
- v({ handleResize: j });
87
- let M = (e) => {
88
- y.trigger !== "none" && !e.target.closest(`[id="${w}"]`) && x.value && !x.value.contains(e.target) && (b.value = !1);
89
- };
90
- return c(() => {
91
- window.addEventListener("resize", j), document.documentElement.ontouchstart === void 0 ? document.documentElement.addEventListener("click", M, !0) : document.documentElement.addEventListener("touchstart", M, !0), window.onscrollend === void 0 ? window.addEventListener("scroll", j) : window.addEventListener("scrollend", j);
92
- }), l(() => {
93
- D.disconnect(), window.removeEventListener("resize", j), document.documentElement.ontouchstart === void 0 ? document.documentElement.removeEventListener("click", M) : document.documentElement.removeEventListener("touchstart", M), window.onscrollend === void 0 ? window.removeEventListener("scroll", j) : window.removeEventListener("scrollend", j);
94
- }), (t, a) => (u(), i("div", {
95
- class: o(E.value),
96
- onClick: a[0] ||= (e) => O(),
97
- onMouseover: a[1] ||= g((e) => k(), ["stop"]),
98
- onMouseleave: a[2] ||= g((e) => k(), ["stop"]),
99
- onContextmenu: a[3] ||= g((e) => A(), ["stop"]),
100
- ref_key: "dropdownRef",
101
- ref: x
102
- }, [f(t.$slots, "default"), (u(), n(e, { to: "body" }, [b.value ? (u(), i("ul", {
103
- key: 0,
104
- ref_key: "popupRef",
105
- ref: S,
106
- id: p(w),
107
- class: o(["sw-dropdown-popup", y.class]),
108
- style: s(C.value),
109
- tabindex: "-1"
110
- }, [f(t.$slots, "dropdown")], 14, _)) : r("", !0)]))], 34));
111
- }
112
- };
113
- //#endregion
114
- export { v as default };
@@ -1,40 +0,0 @@
1
- import { n as e } from "./SwIcon-C4RHAbK1.js";
2
- import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, normalizeClass as a, openBlock as o, renderSlot as s } from "vue";
3
- //#region src/components/SwDropdownItem.vue
4
- var c = {
5
- __name: "SwDropdownItem",
6
- props: {
7
- class: {
8
- type: String,
9
- default: ""
10
- },
11
- size: {
12
- type: String,
13
- default: ""
14
- },
15
- type: {
16
- type: String,
17
- default: ""
18
- },
19
- before: {
20
- type: String,
21
- default: ""
22
- },
23
- iconBefore: {
24
- type: String,
25
- default: ""
26
- }
27
- },
28
- setup(c) {
29
- let l = c, u = t(() => l.before || l.iconBefore), d = t(() => {
30
- let e = ["sw-dropdown-item"];
31
- return l.size.length > 0 && e.push("sw-" + l.size), l.type.length > 0 && e.push("sw-" + l.type), l.class.length > 0 && e.push(l.class), e;
32
- });
33
- return (t, c) => (o(), i("li", { class: a(d.value) }, [u.value.length > 0 ? (o(), n(e, {
34
- key: 0,
35
- "icon-class": u.value
36
- }, null, 8, ["icon-class"])) : r("", !0), s(t.$slots, "default")], 2));
37
- }
38
- };
39
- //#endregion
40
- export { c as default };
@@ -1,107 +0,0 @@
1
- import { Teleport as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, mergeModels as a, normalizeClass as o, normalizeStyle as s, onMounted as c, onUnmounted as l, openBlock as u, ref as d, renderSlot as f, unref as p, useModel as m, watchEffect as h, withModifiers as g } from "vue";
2
- //#region src/components/SwDropdownNew.vue
3
- var _ = ["id"], v = {
4
- __name: "SwDropdownNew",
5
- props: /*@__PURE__*/ a({
6
- class: {
7
- type: String,
8
- default: ""
9
- },
10
- type: {
11
- type: String,
12
- default: ""
13
- },
14
- trigger: {
15
- type: String,
16
- default: "click"
17
- },
18
- placement: {
19
- type: String,
20
- default: "bottom-left"
21
- },
22
- maxWidth: {
23
- type: Number,
24
- default: 0
25
- }
26
- }, {
27
- modelValue: {},
28
- modelModifiers: {}
29
- }),
30
- emits: ["update:modelValue"],
31
- setup(a, { expose: v }) {
32
- let y = a, b = m(a, "modelValue"), x = d(null), S = d(null), C = d({}), w = Math.ceil(Math.random() * 1e3), T = d(0), E = t(() => {
33
- let e = ["sw-dropdown"];
34
- return y.type.length > 0 && e.push("sw-" + y.type), e;
35
- }), D = new ResizeObserver(() => {
36
- b.value && T.value++, T.value > 99 && (T.value = 1);
37
- });
38
- h(() => {
39
- if (!b.value || !S.value || !x.value) return;
40
- T.value < 2 && D.observe(S.value);
41
- let e = window.pageYOffset || document.documentElement.scrollTop, t = window.pageXOffset || document.documentElement.scrollLeft;
42
- document.body.style.position = "fixed", document.body.style.top = `-${e}px`, document.body.style.left = `-${t}px`, document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.documentElement.scrollTop = e, document.documentElement.scrollLeft = t;
43
- let n = x.value.getBoundingClientRect(), r = window.innerWidth, i = window.innerHeight, a = S.value.offsetHeight, o = S.value.offsetWidth, s = n.left + n.width / 2 + t, c = n.top + n.height / 2 + e, l = n.height / 2 + 8, [u, d] = y.placement.split("-", 2);
44
- switch (u) {
45
- case "bottom":
46
- c = e + i - a - l - 8 < c ? c - l - a : c + l, d === void 0 && (s -= o / 2);
47
- break;
48
- case "top":
49
- c = e + a + l + 8 > c ? c + l : c - l - a, d === void 0 && (s -= o / 2);
50
- break;
51
- case "left":
52
- s - o - n.width / 2 - 8 < 0 ? s + n.width / 2 + 8 + o < r ? (s = s + n.width / 2 + 8, c -= a / 2) : (c = e + a + l + 8 > c ? c + l : c - l - a, s = s + n.width / 2 < r ? s + n.width / 2 - o : s - o / 2) : (s = s - o - n.width / 2 - 8, c -= a / 2);
53
- break;
54
- case "right":
55
- s + n.width / 2 + 8 + o > r ? s - o - n.width / 2 - 8 > 0 ? (s = s - o - n.width / 2 - 8, c -= a / 2) : (c = e + a + l + 8 > c ? c + l : c - l - a, s -= n.width / 2) : (s = s + n.width / 2 + 8, c -= a / 2);
56
- break;
57
- }
58
- switch (d) {
59
- case "left":
60
- s = t + r - 8 > s - n.width / 2 + o ? s - n.width / 2 : s - o + n.width / 2;
61
- break;
62
- case "right":
63
- s = 8 < s + n.width / 2 - o ? s - o + n.width / 2 : s - n.width / 2;
64
- break;
65
- }
66
- s < 0 && (s = 0), c < 0 && (c = 0), C.value = {
67
- position: "absolute",
68
- top: `${c}px`,
69
- left: `${s}px`,
70
- maxWidth: y.maxWidth > 0 ? `${y.maxWidth}px` : ""
71
- };
72
- }, { flush: "post" });
73
- let O = () => {
74
- y.trigger === "click" && (b.value = !b.value);
75
- }, k = () => {
76
- y.trigger === "hover" && (b.value = !b.value);
77
- }, A = () => {
78
- y.trigger === "context" && (b.value = !b.value);
79
- }, j = () => {
80
- b.value && T.value++, T.value > 99 && (T.value = 1);
81
- };
82
- return v({ handleResize: j }), c(() => {
83
- window.addEventListener("resize", j), window.onscrollend === void 0 ? window.addEventListener("scroll", j) : window.addEventListener("scrollend", j);
84
- }), l(() => {
85
- D.disconnect(), window.removeEventListener("resize", j), window.onscrollend === void 0 ? window.removeEventListener("scroll", j) : window.removeEventListener("scrollend", j);
86
- }), (t, a) => (u(), i("div", {
87
- class: o(E.value),
88
- onClick: a[0] ||= (e) => O(),
89
- onMouseover: a[1] ||= g((e) => k(), ["stop"]),
90
- onMouseleave: a[2] ||= g((e) => k(), ["stop"]),
91
- onContextmenu: a[3] ||= g((e) => A(), ["stop"]),
92
- ref_key: "dropdownRef",
93
- ref: x
94
- }, [f(t.$slots, "default"), (u(), n(e, { to: "body" }, [b.value ? (u(), i("ul", {
95
- key: 0,
96
- popover: "",
97
- ref_key: "popupRef",
98
- ref: S,
99
- id: p(w),
100
- class: o(["sw-dropdown-popup", y.class]),
101
- style: s(C.value),
102
- tabindex: "-1"
103
- }, [f(t.$slots, "dropdown")], 14, _)) : r("", !0)]))], 34));
104
- }
105
- };
106
- //#endregion
107
- export { v as default };