@studio-west/component-sw 1.0.1 → 1.0.2

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 CHANGED
@@ -1792,6 +1792,10 @@ const star = 'https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline/st
1792
1792
 
1793
1793
  ## Изменения / Changelog
1794
1794
 
1795
+ ### 1.1.0
1796
+
1797
+ - **SwDadata** — запрос к DaData через native `fetch` (зависимость `axios` удалена)
1798
+
1795
1799
  ### 1.0.1
1796
1800
 
1797
1801
  - README: правки формулировок (SwAffix, SwMenu, SwSlider)
@@ -1,4 +1,4 @@
1
- import { t as e } from "./SwButton-yBtJyLyA.js";
1
+ import { t as e } from "./SwButton-XAFVTlsb.js";
2
2
  import { createBlock as t, createTextVNode as n, defineComponent as r, normalizeClass as i, normalizeStyle as a, onMounted as o, onUnmounted as s, openBlock as c, ref as l, vShow as u, withCtx as d, withDirectives as f } from "vue";
3
3
  //#endregion
4
4
  //#region src/components/SwBackTop.vue
@@ -1,4 +1,4 @@
1
- import { t as e } from "./SwDadata-DqTWDCFW.js";
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
2
  import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createTextVNode as a, defineComponent as o, normalizeClass as s, openBlock as c, renderSlot as l, resolveComponent as u, toDisplayString as d } from "vue";
3
3
  //#region src/components/SwButton.vue?vue&type=script&setup=true&lang.ts
4
4
  var f = /*@__PURE__*/ o({
@@ -0,0 +1,91 @@
1
+ import { Fragment as e, createElementBlock as t, createElementVNode as n, createVNode as r, defineComponent as i, mergeModels as a, nextTick as o, normalizeClass as s, openBlock as c, ref as l, renderList as u, resolveComponent as d, toDisplayString as f, useModel as p, vShow as m, watch as h, withDirectives as g } from "vue";
2
+ //#region src/components/SwDadata.vue?vue&type=script&setup=true&lang.ts
3
+ var _ = { class: "sw-dadata-popup" }, v = [
4
+ "aria-selected",
5
+ "onClick",
6
+ "onMouseenter"
7
+ ], y = /* @__PURE__ */ i({
8
+ __name: "SwDadata",
9
+ props: /*@__PURE__*/ a({
10
+ class: { default: "" },
11
+ size: { default: "large" },
12
+ placeholder: { default: "" },
13
+ token: { default: "" }
14
+ }, {
15
+ modelValue: {},
16
+ modelModifiers: {}
17
+ }),
18
+ emits: ["update:modelValue"],
19
+ setup(i) {
20
+ let a = l({ fullText: "" }), y = l(!1), b = l([]), x = l(-1), S = l(null), C = p(i, "modelValue"), w = i;
21
+ h(() => C.value?.text, (e) => {
22
+ e && e.length > 3 && (a.value.fullText = e);
23
+ }), h(() => a.value.fullText, (e, t) => {
24
+ y.value = e.length > 3 && e.length > (t?.length ?? 0), x.value = -1, e.length > 3 && T();
25
+ });
26
+ let T = () => {
27
+ w.token && fetch("https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address", {
28
+ method: "POST",
29
+ headers: {
30
+ "Content-Type": "application/json",
31
+ Accept: "application/json",
32
+ Authorization: "Token " + w.token
33
+ },
34
+ body: JSON.stringify({ query: a.value.fullText })
35
+ }).then((e) => {
36
+ if (!e.ok) throw Error(String(e.status));
37
+ return e.json();
38
+ }).then((e) => {
39
+ b.value = e.suggestions || [], b.value.length === 1 && E(b.value[0]);
40
+ }).catch(() => {
41
+ b.value = [];
42
+ });
43
+ }, E = (e) => {
44
+ a.value.fullText = e.value, y.value = !1, x.value = -1, C.value = {
45
+ text: e.value,
46
+ coords: [Number(e.data.geo_lat), Number(e.data.geo_lon)],
47
+ suggestion: e.data
48
+ };
49
+ }, D = (e) => {
50
+ if (!y.value || !b.value.length) return;
51
+ let t = b.value.length;
52
+ e.key === "ArrowDown" ? (e.preventDefault(), x.value = (x.value + 1) % t, O()) : e.key === "ArrowUp" ? (e.preventDefault(), x.value = x.value <= 0 ? t - 1 : x.value - 1, O()) : e.key === "Enter" && x.value >= 0 ? (e.preventDefault(), E(b.value[x.value])) : e.key === "Escape" && (y.value = !1, x.value = -1);
53
+ }, O = () => {
54
+ o(() => {
55
+ (S.value?.querySelector(".is-active"))?.scrollIntoView({ block: "nearest" });
56
+ });
57
+ };
58
+ return (i, o) => {
59
+ let l = d("sw-input");
60
+ return c(), t("div", {
61
+ class: s(["sw-dadata", w.class]),
62
+ onKeydown: D
63
+ }, [r(l, {
64
+ name: "address",
65
+ size: w.size,
66
+ modelValue: a.value.fullText,
67
+ "onUpdate:modelValue": o[0] ||= (e) => a.value.fullText = e,
68
+ placeholder: w.placeholder,
69
+ clearable: ""
70
+ }, null, 8, [
71
+ "size",
72
+ "modelValue",
73
+ "placeholder"
74
+ ]), g(n("div", _, [n("ul", {
75
+ ref_key: "listRef",
76
+ ref: S,
77
+ class: "sw-dadata-list",
78
+ role: "listbox"
79
+ }, [(c(!0), t(e, null, u(b.value, (e, n) => (c(), t("li", {
80
+ key: n,
81
+ role: "option",
82
+ class: s({ "is-active": n === x.value }),
83
+ "aria-selected": n === x.value,
84
+ onClick: (t) => E(e),
85
+ onMouseenter: (e) => x.value = n
86
+ }, f(e.value), 43, v))), 128))], 512)], 512), [[m, y.value && b.value.length]])], 34);
87
+ };
88
+ }
89
+ });
90
+ //#endregion
91
+ export { y as default };
@@ -1,5 +1,5 @@
1
- import { n as e } from "./SwIcon-Bjw7BuaO.js";
2
- import { t } from "./SwButton-yBtJyLyA.js";
1
+ import { n as e } from "./SwIcon-BbL8Tu2z.js";
2
+ import { t } from "./SwButton-XAFVTlsb.js";
3
3
  import { Teleport as n, Transition as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, mergeModels as f, nextTick as p, normalizeClass as m, normalizeStyle as h, onUnmounted as g, openBlock as _, ref as v, renderSlot as y, toDisplayString as b, unref as x, useModel as S, useSlots as C, watch as w, withCtx as T, withModifiers as E } from "vue";
4
4
  //#region src/components/SwDrawer.vue?vue&type=script&setup=true&lang.ts
5
5
  var D = { key: 0 }, O = { class: "sw-drawer-body" }, k = { key: 1 }, A = 250, j = /* @__PURE__ */ d({
@@ -1,4 +1,4 @@
1
- import { n as e } from "./SwIcon-Bjw7BuaO.js";
1
+ import { n as e } from "./SwIcon-BbL8Tu2z.js";
2
2
  import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, normalizeClass as o, openBlock as s, renderSlot as c } from "vue";
3
3
  //#region src/components/SwDropdownItem.vue
4
4
  var l = {
@@ -1,5 +1,5 @@
1
- import { n as e } from "./SwIcon-Bjw7BuaO.js";
2
- import { t } from "./SwButton-yBtJyLyA.js";
1
+ import { n as e } from "./SwIcon-BbL8Tu2z.js";
2
+ import { t } from "./SwButton-XAFVTlsb.js";
3
3
  import { Fragment as n, computed as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onUnmounted as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, useModel as ee, watch as te, withCtx as b, withModifiers as ne } from "vue";
4
4
  //#region src/utils/mediaCrop.ts
5
5
  function re(e, t, n, r) {
@@ -1,6 +1,6 @@
1
1
  import { i as e } from "./utils-B970mUhr.js";
2
- import { n as t } from "./SwIcon-Bjw7BuaO.js";
3
- import { t as n } from "./SwButton-yBtJyLyA.js";
2
+ import { n as t } from "./SwIcon-BbL8Tu2z.js";
3
+ import { t as n } from "./SwButton-XAFVTlsb.js";
4
4
  import r from "./SwDropdown-DpedC6Bn.js";
5
5
  import { computed as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, mergeModels as l, normalizeClass as u, onMounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, useModel as g, watchEffect as _, withCtx as v } from "vue";
6
6
  //#region src/components/SwGuide.vue
@@ -1,8 +1,8 @@
1
- import { r as e } from "./utils-B970mUhr.js";
2
- import { t } from "./SwDadata-DqTWDCFW.js";
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { r as t } from "./utils-B970mUhr.js";
3
3
  import { computed as n, createElementBlock as r, createElementVNode as i, mergeProps as a, openBlock as o, unref as s } from "vue";
4
4
  //#region src/components/SwIcon.vue
5
- var c = /* @__PURE__ */ t({ default: () => u }), l = ["href"], u = /*@__PURE__*/ Object.assign({ inheritAttrs: !1 }, {
5
+ var c = /* @__PURE__ */ e({ default: () => u }), l = ["href"], u = /*@__PURE__*/ Object.assign({ inheritAttrs: !1 }, {
6
6
  __name: "SwIcon",
7
7
  props: {
8
8
  prefix: {
@@ -18,8 +18,8 @@ var c = /* @__PURE__ */ t({ default: () => u }), l = ["href"], u = /*@__PURE__*/
18
18
  default: ""
19
19
  }
20
20
  },
21
- setup(t) {
22
- let c = t, u = e(c.iconClass), d = n(() => {
21
+ setup(e) {
22
+ let c = e, u = t(c.iconClass), d = n(() => {
23
23
  let e = `url("${c.iconClass.replace(/"/g, "\\\"")}")`;
24
24
  return {
25
25
  WebkitMaskImage: e,
@@ -1,5 +1,5 @@
1
1
  import { n as e } from "./utils-B970mUhr.js";
2
- import { n as t } from "./SwIcon-Bjw7BuaO.js";
2
+ import { n as t } from "./SwIcon-BbL8Tu2z.js";
3
3
  import { computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createTextVNode as o, defineComponent as s, mergeModels as c, mergeProps as l, nextTick as u, normalizeClass as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, useModel as g, vModelDynamic as _, vModelText as v, watch as y, withDirectives as b, withModifiers as x } from "vue";
4
4
  //#region src/components/SwInput.vue?vue&type=script&setup=true&lang.ts
5
5
  var S = ["for"], C = {
@@ -1,5 +1,5 @@
1
- import { n as e } from "./SwIcon-Bjw7BuaO.js";
2
- import { t } from "./SwButton-yBtJyLyA.js";
1
+ import { n as e } from "./SwIcon-BbL8Tu2z.js";
2
+ import { t } from "./SwButton-XAFVTlsb.js";
3
3
  import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, mergeModels as c, nextTick as l, normalizeClass as u, onUnmounted as d, openBlock as f, ref as p, renderSlot as m, toDisplayString as h, unref as g, useModel as _, useSlots as v, watch as y, withCtx as b } from "vue";
4
4
  //#region src/components/SwMessage.vue
5
5
  var x = { key: 0 }, S = {
@@ -1,4 +1,4 @@
1
- import { t as e } from "./SwTag-snjqhsXj.js";
1
+ import { t as e } from "./SwTag-BEoATwwG.js";
2
2
  import { Fragment as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, onMounted as f, onUnmounted as p, openBlock as m, ref as h, renderList as g, toDisplayString as _, useModel as v, vShow as y, watch as b, withDirectives as x } from "vue";
3
3
  //#region src/components/SwSelect.vue?vue&type=script&setup=true&lang.ts
4
4
  var S = ["aria-expanded"], C = { class: "sw-select-values" }, w = {
@@ -1,5 +1,5 @@
1
- import { n as e } from "./SwIcon-Bjw7BuaO.js";
2
- import { t } from "./SwDadata-DqTWDCFW.js";
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { n as t } from "./SwIcon-BbL8Tu2z.js";
3
3
  import { computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, normalizeClass as u, openBlock as d, renderSlot as f, toDisplayString as p } from "vue";
4
4
  //#region src/components/SwTag.vue?vue&type=script&setup=true&lang.ts
5
5
  var m = { class: "text" }, h = ["disabled"], g = "https://cdn.jsdelivr.net/npm/@tabler/icons@3.19.0/icons/outline", _ = /*@__PURE__*/ l({
@@ -24,19 +24,19 @@ var m = { class: "text" }, h = ["disabled"], g = "https://cdn.jsdelivr.net/npm/@
24
24
  }
25
25
  },
26
26
  emits: ["close"],
27
- setup(t, { emit: l }) {
28
- let _ = `${g}/x.svg`, v = t, y = l, b = n(() => {
27
+ setup(e, { emit: l }) {
28
+ let _ = `${g}/x.svg`, v = e, y = l, b = n(() => {
29
29
  let e = ["sw-tag"];
30
30
  return v.size && e.push("sw-" + v.size), v.type && e.push("sw-" + v.type), v.round && e.push("sw-round"), v.disabled && e.push("sw-disabled"), v.class && e.push(v.class), e;
31
31
  }), x = (e) => {
32
32
  e.stopPropagation(), v.disabled || y("close");
33
33
  };
34
- return (t, n) => (d(), a("span", { class: u(b.value) }, [
35
- v.before ? (d(), r(e, {
34
+ return (e, n) => (d(), a("span", { class: u(b.value) }, [
35
+ v.before ? (d(), r(t, {
36
36
  key: 0,
37
37
  "icon-class": v.before
38
38
  }, null, 8, ["icon-class"])) : i("", !0),
39
- o("span", m, [f(t.$slots, "default", {}, () => [s(p(v.label), 1)])]),
39
+ o("span", m, [f(e.$slots, "default", {}, () => [s(p(v.label), 1)])]),
40
40
  v.closable ? (d(), a("button", {
41
41
  key: 1,
42
42
  type: "button",
@@ -44,9 +44,9 @@ var m = { class: "text" }, h = ["disabled"], g = "https://cdn.jsdelivr.net/npm/@
44
44
  "aria-label": "close",
45
45
  disabled: v.disabled,
46
46
  onClick: x
47
- }, [c(e, { "icon-class": _ })], 8, h)) : i("", !0)
47
+ }, [c(t, { "icon-class": _ })], 8, h)) : i("", !0)
48
48
  ], 2));
49
49
  }
50
- }), v = /* @__PURE__ */ t({ default: () => y }), y = _;
50
+ }), v = /* @__PURE__ */ e({ default: () => y }), y = _;
51
51
  //#endregion
52
52
  export { v as n, y as t };