@nmorph/nmorph-ui-kit 2.2.16 → 2.2.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/nuxt.mjs CHANGED
@@ -48,11 +48,15 @@ const mergeMessages = (base, overrides = {}) => {
48
48
  return result
49
49
  }
50
50
 
51
- export default defineNuxtPlugin((nuxtApp) => {
51
+ export default defineNuxtPlugin({
52
+ name: 'nmorph',
53
+ enforce: 'post',
54
+ setup(nuxtApp) {
52
55
  const pluginOptions = { ...options }
53
56
  const i18nOptions = { ...(pluginOptions.i18n || {}) }
54
57
  const messages = mergeMessages(libraryMessages, i18nOptions.messages)
55
- const i18n = nuxtApp.$i18n
58
+ const vueI18nGlobal = nuxtApp.vueApp.__VUE_I18N__?.global
59
+ const i18n = nuxtApp.$i18n?.mergeLocaleMessage ? nuxtApp.$i18n : vueI18nGlobal
56
60
 
57
61
  if (import.meta.server) {
58
62
  useHead({
@@ -85,6 +89,7 @@ export default defineNuxtPlugin((nuxtApp) => {
85
89
 
86
90
  pluginOptions.i18n = i18nOptions
87
91
  nuxtApp.vueApp.use(NmorphLibrary, pluginOptions)
92
+ }
88
93
  })
89
94
  `
90
95
  });
@@ -1,7 +1,7 @@
1
- import { ref as A, readonly as H } from "vue";
2
- import _ from "../package.json.js";
1
+ import { ref as H, readonly as _ } from "vue";
2
+ import w from "../package.json.js";
3
3
  import { nmorphLog as I } from "../outside-utils/index.js";
4
- import { camelToKebab as b } from "../utils/case-transformers.js";
4
+ import { camelToKebab as E } from "../utils/case-transformers.js";
5
5
  const $ = {
6
6
  info: "#d4e5edbb",
7
7
  infoText: "#506c80",
@@ -26,7 +26,7 @@ const $ = {
26
26
  placeholderText: "#c1c9cf",
27
27
  semiContrastText: "#8a9dc0",
28
28
  contrastText: "#b4c4de"
29
- }, w = {
29
+ }, F = {
30
30
  darkShade: "#0f1112",
31
31
  main: "#1c1f21",
32
32
  lightShade: "#292d30",
@@ -37,11 +37,11 @@ const $ = {
37
37
  placeholderText: "#575757",
38
38
  semiContrastText: "#9caab0",
39
39
  contrastText: "#c3cdd1"
40
- }, C = "nmorph-data-theme", R = "dark", S = {
40
+ }, T = "nmorph-data-theme", R = "dark", C = {
41
41
  themes: {
42
42
  common: $,
43
43
  light: V,
44
- dark: w
44
+ dark: F
45
45
  },
46
46
  defaultTheme: R,
47
47
  saveCurrentThemeToLS: !0,
@@ -51,143 +51,142 @@ const $ = {
51
51
  baseShadowWidth: "3.5px",
52
52
  baseShadowBlurCoefficient: "2"
53
53
  }
54
- }, F = (t) => /^#[0-9A-Fa-f]{6}$/.test(t), v = (t) => {
55
- if (!F(t)) throw new Error(`Invalid hex color: ${t}`);
56
- return t;
57
- }, L = (t, e) => {
54
+ }, U = (r) => /^#[0-9A-Fa-f]{6}$/.test(r), L = (r) => {
55
+ if (!U(r)) throw new Error(`Invalid hex color: ${r}`);
56
+ return r;
57
+ }, A = (r, e) => {
58
58
  const n = {};
59
- return t.forEach(({ name: o, color: s }) => {
60
- n[o] = s;
61
- }), e.forEach(({ name: o, color: s }) => {
62
- n[o] = s;
63
- }), Object.entries(n).map(([o, s]) => ({ name: o, color: s }));
64
- }, E = (t, e) => {
65
- let n = parseInt(t.substring(1, 3), 16), o = parseInt(t.substring(3, 5), 16), s = parseInt(t.substring(5, 7), 16);
66
- n = Math.round(n * (1 + e / 100)), o = Math.round(o * (1 + e / 100)), s = Math.round(s * (1 + e / 100)), n = Math.min(255, Math.max(0, n)), o = Math.min(255, Math.max(0, o)), s = Math.min(255, Math.max(0, s));
67
- const c = n.toString(16).padStart(2, "0"), i = o.toString(16).padStart(2, "0"), d = s.toString(16).padStart(2, "0");
68
- return `#${c}${i}${d}`;
69
- }, G = (t) => ({
70
- themes: t?.themes ?? S.themes,
71
- defaultTheme: t?.defaultTheme ?? S.defaultTheme,
72
- saveCurrentThemeToLS: t?.saveCurrentThemeToLS ?? S.saveCurrentThemeToLS,
73
- darkShadeGeneratorCoefficient: t?.darkShadeGeneratorCoefficient ?? S.darkShadeGeneratorCoefficient,
74
- lightShadeGeneratorCoefficient: t?.lightShadeGeneratorCoefficient ?? S.lightShadeGeneratorCoefficient,
75
- other: t?.other ?? S.other
76
- }), U = (t, e) => {
59
+ return r.forEach(({ name: a, color: s }) => {
60
+ n[a] = s;
61
+ }), e.forEach(({ name: a, color: s }) => {
62
+ n[a] = s;
63
+ }), Object.entries(n).map(([a, s]) => ({ name: a, color: s }));
64
+ }, y = (r, e) => {
65
+ let n = parseInt(r.substring(1, 3), 16), a = parseInt(r.substring(3, 5), 16), s = parseInt(r.substring(5, 7), 16);
66
+ n = Math.round(n * (1 + e / 100)), a = Math.round(a * (1 + e / 100)), s = Math.round(s * (1 + e / 100)), n = Math.min(255, Math.max(0, n)), a = Math.min(255, Math.max(0, a)), s = Math.min(255, Math.max(0, s));
67
+ const c = n.toString(16).padStart(2, "0"), i = a.toString(16).padStart(2, "0"), l = s.toString(16).padStart(2, "0");
68
+ return `#${c}${i}${l}`;
69
+ }, G = (r) => ({
70
+ themes: r?.themes ?? C.themes,
71
+ defaultTheme: r?.defaultTheme ?? C.defaultTheme,
72
+ saveCurrentThemeToLS: r?.saveCurrentThemeToLS ?? C.saveCurrentThemeToLS,
73
+ darkShadeGeneratorCoefficient: r?.darkShadeGeneratorCoefficient ?? C.darkShadeGeneratorCoefficient,
74
+ lightShadeGeneratorCoefficient: r?.lightShadeGeneratorCoefficient ?? C.lightShadeGeneratorCoefficient,
75
+ other: r?.other ?? C.other
76
+ }), N = (r, e) => {
77
77
  try {
78
- const n = v(e);
78
+ const n = L(e);
79
79
  return {
80
- darkShade: E(n, t.darkShadeGeneratorCoefficient),
81
- lightShade: E(n, t.lightShadeGeneratorCoefficient)
80
+ darkShade: y(n, r.darkShadeGeneratorCoefficient),
81
+ lightShade: y(n, r.lightShadeGeneratorCoefficient)
82
82
  };
83
83
  } catch (n) {
84
84
  return console.error(n instanceof Error ? n.message : n), {};
85
85
  }
86
- }, x = (t) => Object.entries(t).filter(([, e]) => typeof e == "string").map(([e, n]) => ({
87
- name: `--nmorph-${b(e)}-color`,
86
+ }, x = (r) => Object.entries(r).filter(([, e]) => typeof e == "string").map(([e, n]) => ({
87
+ name: `--nmorph-${E(e)}-color`,
88
88
  color: n
89
- })), N = (t, e) => {
90
- const n = (c) => c.map((i) => `${i.name}: ${i.color};`).join(" "), o = Object.entries(e).map(([c, i]) => `--${b(c)}: ${i};`).join(" "), s = [];
91
- return Object.entries(t).forEach(([c, i]) => {
92
- const d = x($);
93
- if (c === "common") s.push(n(L(d, i)));
89
+ })), P = (r, e) => {
90
+ const n = (c) => c.map((i) => `${i.name}: ${i.color};`).join(" "), a = Object.entries(e).map(([c, i]) => `--${E(c)}: ${i};`).join(" "), s = [];
91
+ return Object.entries(r).forEach(([c, i]) => {
92
+ const l = x($);
93
+ if (c === "common") s.push(n(A(l, i)));
94
94
  else {
95
- const T = `
96
- &[${C}='${c}'] {
95
+ const S = `
96
+ &[${T}='${c}'] {
97
97
  ${n(i)}
98
98
  }
99
99
  `;
100
- s.push(T);
100
+ s.push(S);
101
101
  }
102
102
  }), `
103
103
  :root {
104
104
  ${s.join(" ")}
105
- ${o}
105
+ ${a}
106
106
  }
107
107
  `;
108
- }, P = (t) => {
108
+ }, K = (r) => {
109
109
  const e = {};
110
- return Object.entries(t.themes).forEach(([n, o]) => {
110
+ return Object.entries(r.themes).forEach(([n, a]) => {
111
111
  e[n] = [];
112
- const s = !!o.darkShade, c = !!o.lightShade;
113
- !!o.main && !s && !c && o.main && (e[n] = x(U(t, o.main))), e[n] = [...e[n], ...x(o)];
112
+ const s = !!a.darkShade, c = !!a.lightShade;
113
+ !!a.main && !s && !c && a.main && (e[n] = x(N(r, a.main))), e[n] = [...e[n], ...x(a)];
114
114
  }), e;
115
- }, z = (t) => {
116
- const e = G(t);
117
- return N(P(e), e.other);
118
- }, J = (t) => {
119
- I("warn", `NMORPH(v${_.version})`);
120
- const e = G(t), n = (a) => {
115
+ }, J = (r) => {
116
+ const e = G(r);
117
+ return P(K(e), e.other);
118
+ }, Q = (r) => {
119
+ I("warn", `NMORPH(v${w.version})`);
120
+ const e = G(r), n = (o) => {
121
121
  try {
122
- const r = v(a);
122
+ const t = L(o);
123
123
  return {
124
- darkShade: E(r, e.darkShadeGeneratorCoefficient),
125
- lightShade: E(r, e.lightShadeGeneratorCoefficient)
124
+ darkShade: y(t, e.darkShadeGeneratorCoefficient),
125
+ lightShade: y(t, e.lightShadeGeneratorCoefficient)
126
126
  };
127
- } catch (r) {
128
- return console.error(r instanceof Error ? r.message : r), {};
127
+ } catch (t) {
128
+ return console.error(t instanceof Error ? t.message : t), {};
129
129
  }
130
- }, o = (a) => {
131
- const r = n(a);
132
- return s(r);
133
- }, s = (a) => Object.entries(a).filter(([, r]) => typeof r == "string").map(([r, h]) => ({
134
- name: `--nmorph-${b(r)}-color`,
130
+ }, a = (o) => {
131
+ const t = n(o);
132
+ return s(t);
133
+ }, s = (o) => Object.entries(o).filter(([, t]) => typeof t == "string").map(([t, h]) => ({
134
+ name: `--nmorph-${E(t)}-color`,
135
135
  color: h
136
- })), c = (a, r) => {
137
- const h = (f) => f.map((u) => `${u.name}: ${u.color};`).join(" "), l = Object.entries(r).map(([f, u]) => `--${b(f)}: ${u};`).join(" "), g = [];
138
- return Object.entries(a).forEach(([f, u]) => {
136
+ })), c = (o, t) => {
137
+ const h = (f) => f.map((u) => `${u.name}: ${u.color};`).join(" "), m = Object.entries(t).map(([f, u]) => `--${E(f)}: ${u};`).join(" "), b = [];
138
+ return Object.entries(o).forEach(([f, u]) => {
139
139
  const k = s($);
140
- if (f === "common") g.push(h(L(k, u)));
140
+ if (f === "common") b.push(h(A(k, u)));
141
141
  else {
142
142
  const B = `
143
- &[${C}='${f}'] {
143
+ &[${T}='${f}'] {
144
144
  ${h(u)}
145
145
  }
146
146
  `;
147
- g.push(B);
147
+ b.push(B);
148
148
  }
149
149
  }), `
150
150
  :root {
151
- ${g.join(" ")}
152
- ${l}
151
+ ${b.join(" ")}
152
+ ${m}
153
153
  }
154
154
  `;
155
- }, i = (a) => {
156
- const r = {};
157
- return Object.entries(a).forEach(([h, l]) => {
158
- r[h] = [];
159
- const g = !!l.darkShade, f = !!l.lightShade;
160
- !!l.main && !g && !f && l.main && (r[h] = o(l.main)), r[h] = [...r[h], ...s(l)];
161
- }), r;
162
- }, d = typeof document < "u", T = A(e.defaultTheme);
163
- let p = i(e.themes), m = null;
164
- d && (m = document.getElementById("nmorph-theme-styles"), m || (m = document.createElement("style"), m.id = "nmorph-theme-styles", m.type = "text/css", document.head.appendChild(m)), m.innerHTML = c(p, e.other));
155
+ }, i = (o) => {
156
+ const t = {};
157
+ return Object.entries(o).forEach(([h, m]) => {
158
+ t[h] = [];
159
+ const b = !!m.darkShade, f = !!m.lightShade;
160
+ !!m.main && !b && !f && m.main && (t[h] = a(m.main)), t[h] = [...t[h], ...s(m)];
161
+ }), t;
162
+ }, l = typeof document < "u", S = H(e.defaultTheme);
163
+ let g = i(e.themes), d = null;
164
+ l && (d = document.getElementById("nmorph-theme-styles"), d || (d = document.createElement("style"), d.id = "nmorph-theme-styles", d.type = "text/css", document.head.appendChild(d)), d.innerHTML = c(g, e.other));
165
165
  const D = () => {
166
- p = i(e.themes), m && (m.innerHTML = c(p, e.other));
167
- }, y = (a) => {
168
- T.value = a, d && (document.documentElement.setAttribute(C, T.value), !(typeof localStorage > "u") && (e.saveCurrentThemeToLS ? localStorage.setItem(C, a) : localStorage.removeItem(C)));
169
- }, M = (a, r) => {
170
- const h = r.main && !r.darkShade && !r.lightShade ? n(r.main) : {};
171
- e.themes[a] = { ...e.themes[a], ...r, ...h }, D();
172
- }, O = (a, r) => {
173
- r && M(a, r), y(a);
166
+ g = i(e.themes), d && (d.innerHTML = c(g, e.other));
167
+ }, p = (o) => {
168
+ S.value = o, l && (document.documentElement.setAttribute(T, S.value), !(typeof localStorage > "u") && (e.saveCurrentThemeToLS ? localStorage.setItem(T, o) : localStorage.removeItem(T)));
169
+ }, M = (o, t) => {
170
+ const h = t.main && !t.darkShade && !t.lightShade ? n(t.main) : {};
171
+ e.themes[o] = { ...e.themes[o], ...t, ...h }, D();
172
+ }, O = (o, t) => {
173
+ t && M(o, t), p(o);
174
+ }, v = () => {
175
+ const o = document.documentElement.getAttribute(T), t = typeof localStorage < "u" ? localStorage.getItem(T) : null, h = t ? g[t] : void 0, m = o ? g[o] : void 0;
176
+ return e.saveCurrentThemeToLS && t && h ? t : o && m ? o : S.value;
174
177
  };
175
- if (d && typeof localStorage < "u") {
176
- const a = localStorage.getItem(C), r = a ? p[a] : void 0;
177
- e.saveCurrentThemeToLS && r && (T.value = a);
178
- }
179
- y(T.value);
178
+ l ? document.documentElement.hasAttribute(T) ? window.requestAnimationFrame(() => p(v())) : p(v()) : p(S.value);
180
179
  const j = e;
181
180
  return {
182
- setTheme: y,
181
+ setTheme: p,
183
182
  setThemeColors: M,
184
183
  applyTheme: O,
185
- currentTheme: H(T),
184
+ currentTheme: _(S),
186
185
  data: j,
187
- getDynamicColorVariables: o
186
+ getDynamicColorVariables: a
188
187
  };
189
188
  };
190
189
  export {
191
- z as getNmorphThemeStyles,
192
- J as useNmorphTheme
190
+ J as getNmorphThemeStyles,
191
+ Q as useNmorphTheme
193
192
  };
@@ -1,4 +1,4 @@
1
- const a = "2.2.16", e = {
1
+ const a = "2.2.17", e = {
2
2
  version: a
3
3
  };
4
4
  export {
package/dist/plugin.js CHANGED
@@ -1,52 +1,52 @@
1
- import { default as C } from "./locales/ru.js";
2
- import { default as _ } from "./locales/zh.js";
3
- import { default as w } from "./locales/en.js";
4
- import { nmorphLog as M } from "./outside-utils/index.js";
1
+ import { default as L } from "./locales/ru.js";
2
+ import { default as M } from "./locales/zh.js";
3
+ import { default as z } from "./locales/en.js";
4
+ import { nmorphLog as D } from "./outside-utils/index.js";
5
5
  import { useNmorphTheme as h } from "./outside-hooks/use-nmorph-theme.js";
6
- import { getNmorphThemeStyles as E } from "./outside-hooks/use-nmorph-theme.js";
7
- import { useCommonStyles as i } from "./hooks/use-common-styles.js";
8
- import { getCommonStyles as O } from "./hooks/use-common-styles.js";
9
- import { AvatarShapeType as A, Locale as B, NmorphColor as F, NmorphComponentDirection as P, NmorphComponentHeight as R, NmorphComponentPosition as U, NmorphImageFit as Z, NmorphRadioStyleType as k, NmorphSelectionControlHeight as q, NmorphSelectionDateType as G, NmorphShadowType as J, NmorphSortOrder as K } from "./types/index.js";
6
+ import { getNmorphThemeStyles as H } from "./outside-hooks/use-nmorph-theme.js";
7
+ import { useCommonStyles as c } from "./hooks/use-common-styles.js";
8
+ import { getCommonStyles as j } from "./hooks/use-common-styles.js";
9
+ import { AvatarShapeType as F, Locale as G, NmorphColor as P, NmorphComponentDirection as R, NmorphComponentHeight as U, NmorphComponentPosition as Z, NmorphImageFit as k, NmorphRadioStyleType as q, NmorphSelectionControlHeight as J, NmorphSelectionDateType as K, NmorphShadowType as Q, NmorphSortOrder as W } from "./types/index.js";
10
10
  import { useNmorphTranslation as f } from "./hooks/use-nmorph-translation.js";
11
- import { useNmorphBrowser as c } from "./outside-hooks/use-nmorph-browser.js";
12
- import { useNmorphZIndex as N } from "./outside-hooks/use-nmorph-z-index.js";
13
- import { useNmorph as W } from "./outside-hooks/use-nmorph.js";
14
- import { useNmorphNotification as Y } from "./outside-hooks/use-nmorph-notification.js";
15
- const g = {
16
- install(e, r = {}) {
11
+ import { useNmorphBrowser as N } from "./outside-hooks/use-nmorph-browser.js";
12
+ import { useNmorphZIndex as g } from "./outside-hooks/use-nmorph-z-index.js";
13
+ import { useNmorph as Y } from "./outside-hooks/use-nmorph.js";
14
+ import { useNmorphNotification as V } from "./outside-hooks/use-nmorph-notification.js";
15
+ const u = {
16
+ install(o, r = {}) {
17
17
  if (!r?.i18n?.outsideMessagesMerge) {
18
- const o = f(r.i18n), m = e.__VUE_I18N__;
19
- m ? (o.global.messages.value && Object.entries(o.global.messages.value).forEach(([s, n]) => {
20
- m.global.mergeLocaleMessage(s, n);
21
- }), o.global.locale.value && (m.global.locale.value = o.global.locale.value)) : e.use(o);
18
+ const e = f(r.i18n), t = o.__VUE_I18N__?.global, s = !!(o.component("i18n-t") || o.component("I18nT") || o.directive("t"));
19
+ t?.mergeLocaleMessage ? (e.global.messages.value && Object.entries(e.global.messages.value).forEach(([p, i]) => {
20
+ t.mergeLocaleMessage?.(p, i);
21
+ }), t.locale && e.global.locale.value && (t.locale.value = e.global.locale.value)) : s || o.use(e);
22
22
  }
23
- i();
24
- const t = h(r.theme), a = c(), l = N(r.zIndex), p = { theme: t, browser: a, zIndex: l };
25
- return e.provide("nmorph", p), e;
23
+ c();
24
+ const m = h(r.theme), n = N(), a = g(r.zIndex), l = { theme: m, browser: n, zIndex: a };
25
+ return o.provide("nmorph", l), o;
26
26
  }
27
- }, S = g;
27
+ }, S = u;
28
28
  export {
29
- A as AvatarShapeType,
30
- B as Locale,
31
- F as NmorphColor,
32
- P as NmorphComponentDirection,
33
- R as NmorphComponentHeight,
34
- U as NmorphComponentPosition,
35
- Z as NmorphImageFit,
29
+ F as AvatarShapeType,
30
+ G as Locale,
31
+ P as NmorphColor,
32
+ R as NmorphComponentDirection,
33
+ U as NmorphComponentHeight,
34
+ Z as NmorphComponentPosition,
35
+ k as NmorphImageFit,
36
36
  S as NmorphLibrary,
37
- k as NmorphRadioStyleType,
38
- q as NmorphSelectionControlHeight,
39
- G as NmorphSelectionDateType,
40
- J as NmorphShadowType,
41
- K as NmorphSortOrder,
42
- w as en,
43
- O as getCommonStyles,
44
- E as getNmorphThemeStyles,
45
- M as nmorphLog,
46
- C as ru,
47
- W as useNmorph,
48
- c as useNmorphBrowser,
49
- Y as useNmorphNotification,
37
+ q as NmorphRadioStyleType,
38
+ J as NmorphSelectionControlHeight,
39
+ K as NmorphSelectionDateType,
40
+ Q as NmorphShadowType,
41
+ W as NmorphSortOrder,
42
+ z as en,
43
+ j as getCommonStyles,
44
+ H as getNmorphThemeStyles,
45
+ D as nmorphLog,
46
+ L as ru,
47
+ Y as useNmorph,
48
+ N as useNmorphBrowser,
49
+ V as useNmorphNotification,
50
50
  h as useNmorphTheme,
51
- _ as zh
51
+ M as zh
52
52
  };
@@ -1,7 +1,9 @@
1
1
  import { NmorphPlacementType } from '../../../types';
2
2
  import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ type NmorphContextMenuTrigger = 'contextmenu' | 'click' | 'both';
3
4
  interface INmorphProps {
4
- modelValue?: boolean;
5
+ modelValue?: boolean | null;
6
+ trigger?: NmorphContextMenuTrigger;
5
7
  placement?: NmorphPlacementType;
6
8
  width?: number | string;
7
9
  minWidth?: number | string;
@@ -33,6 +35,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<INmorphProps, {
33
35
  }>, {
34
36
  disabled: boolean;
35
37
  width: string | number;
38
+ modelValue: boolean;
36
39
  minWidth: string | number;
37
40
  zIndex: number;
38
41
  closeOnEscape: boolean;
@@ -44,6 +47,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<INmorphProps, {
44
47
  yOffset: number;
45
48
  fillWidth: boolean;
46
49
  ariaLabel: string;
50
+ trigger: NmorphContextMenuTrigger;
47
51
  }, {}, {}, {}, string, ComponentProvideOptions, true, {
48
52
  triggerDOMRef: HTMLDivElement;
49
53
  }, HTMLDivElement>, {