@nmorph/nmorph-ui-kit 2.2.17 → 2.2.19
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/navigation/nmorph-context-menu/NmorphContextMenu.css +1 -1
- package/dist/components/navigation/nmorph-context-menu/NmorphContextMenu.vue.js +71 -12
- package/dist/components/navigation/nmorph-context-menu/NmorphContextMenu.vue2.js +75 -34
- package/dist/components/navigation/nmorph-dropdown/NmorphDropdown.vue.js +5 -5
- package/dist/components/navigation/nmorph-dropdown/NmorphDropdown.vue2.js +6 -5
- package/dist/index.umd.js +14 -14
- package/dist/package.json.js +1 -1
- package/dist/src/components/navigation/index.d.ts +1 -0
- package/dist/src/components/navigation/nmorph-context-menu/NmorphContextMenu.vue.d.ts +7 -0
- package/dist/src/components/navigation/nmorph-context-menu/types.d.ts +12 -0
- package/dist/src/components/navigation/nmorph-dropdown/NmorphDropdown.vue.d.ts +2 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.nmorph-context-menu{display:inline-block;max-width:100%}
|
|
1
|
+
.nmorph-context-menu{display:inline-block;max-width:100%}.nmorph-context-menu__dropdown{text-align:left}.nmorph-context-menu__options{display:grid;gap:4px;padding:4px}.nmorph-context-menu__item{display:flex;gap:var(--indentation-02);justify-content:flex-start;align-items:center;box-sizing:border-box;width:100%;min-width:120px;padding:var(--indentation-02) var(--indentation-04);color:var(--nmorph-context-menu-item-color, var(--nmorph-text-color));font:inherit;line-height:var(--line-height-regular);text-align:left;background:transparent;border:0;border-radius:var(--default-border-radius);cursor:pointer}.nmorph-context-menu__item-label{color:var(--nmorph-context-menu-item-color, var(--nmorph-text-color));text-align:left}.nmorph-context-menu__item:not(:disabled):not(.nmorph-context-menu__item--disabled):hover{background:color-mix(in srgb,var(--nmorph-context-menu-item-color, var(--nmorph-text-color)) 12%,transparent)}.nmorph-context-menu__item:disabled,.nmorph-context-menu__item--disabled{cursor:default;opacity:.56;pointer-events:none}.nmorph-context-menu__dropdown .nmorph-button--transparent .nmorph-button__content{justify-content:flex-start;text-align:left}.nmorph-context-menu__dropdown .nmorph-button--transparent .nmorph-button__content span{text-align:left}.nmorph-context-menu__dropdown .nmorph-button--transparent .nmorph-button__content:not(:disabled,[loading=true]):hover{background:color-mix(in srgb,var(--nmorph-button-hover-color, var(--nmorph-button-color, var(--transparent-button-color, var(--nmorph-text-color)))) 12%,transparent)}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import './NmorphContextMenu.css';
|
|
2
|
-
import
|
|
3
|
-
import { openBlock as
|
|
2
|
+
import s from "./NmorphContextMenu.vue2.js";
|
|
3
|
+
import { openBlock as o, createElementBlock as l, renderSlot as i, createBlock as d, withCtx as p, Fragment as c, renderList as f, normalizeStyle as m, createElementVNode as h, toDisplayString as _, normalizeClass as y, resolveDynamicComponent as x, mergeProps as k, createCommentVNode as b } from "vue";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import w from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
6
|
+
const C = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "nmorph-context-menu__options"
|
|
9
|
+
}, v = ["disabled", "onClick"], O = { class: "nmorph-context-menu__item-label" }, g = ["tabindex", "aria-disabled", "onClick", "onKeydown"];
|
|
10
|
+
function H(a, u, z, e, E, K) {
|
|
11
|
+
return o(), l(
|
|
8
12
|
"div",
|
|
9
13
|
{
|
|
10
14
|
ref: "triggerDOMRef",
|
|
@@ -14,8 +18,8 @@ function m(o, p, f, e, s, h) {
|
|
|
14
18
|
onKeydown: e.keydownHandler
|
|
15
19
|
},
|
|
16
20
|
[
|
|
17
|
-
|
|
18
|
-
e.relativeElement ? (
|
|
21
|
+
i(a.$slots, "default"),
|
|
22
|
+
e.relativeElement ? (o(), d(e.NmorphDropdown, {
|
|
19
23
|
key: 0,
|
|
20
24
|
open: e.isOpen,
|
|
21
25
|
"relative-element": e.relativeElement,
|
|
@@ -31,21 +35,76 @@ function m(o, p, f, e, s, h) {
|
|
|
31
35
|
"trap-focus": e.props.trapFocus,
|
|
32
36
|
role: e.props.role,
|
|
33
37
|
"aria-label": e.props.ariaLabel,
|
|
38
|
+
"content-class": "nmorph-context-menu__dropdown",
|
|
34
39
|
onOnOutsideClick: e.outsideClickHandler,
|
|
35
40
|
onOnEscapeKeydown: e.escapeHandler
|
|
36
41
|
}, {
|
|
37
|
-
default:
|
|
38
|
-
|
|
42
|
+
default: p(() => [
|
|
43
|
+
e.hasOptions ? (o(), l("div", C, [
|
|
44
|
+
(o(!0), l(
|
|
45
|
+
c,
|
|
46
|
+
null,
|
|
47
|
+
f(e.normalizedOptions, (n, t) => (o(), l(
|
|
48
|
+
c,
|
|
49
|
+
{
|
|
50
|
+
key: n.key
|
|
51
|
+
},
|
|
52
|
+
[
|
|
53
|
+
n.component ? (o(), l("div", {
|
|
54
|
+
key: 1,
|
|
55
|
+
class: y(["nmorph-context-menu__item", { "nmorph-context-menu__item--disabled": n.disabled }]),
|
|
56
|
+
role: "menuitem",
|
|
57
|
+
tabindex: n.disabled ? -1 : 0,
|
|
58
|
+
"aria-disabled": n.disabled,
|
|
59
|
+
style: m(e.getOptionStyle(n)),
|
|
60
|
+
onClick: (r) => e.optionClickHandler(n, t),
|
|
61
|
+
onKeydown: (r) => e.optionKeydownHandler(r, n, t)
|
|
62
|
+
}, [
|
|
63
|
+
(o(), d(
|
|
64
|
+
x(n.component),
|
|
65
|
+
k({ ref_for: !0 }, n.componentProps),
|
|
66
|
+
null,
|
|
67
|
+
16
|
|
68
|
+
/* FULL_PROPS */
|
|
69
|
+
))
|
|
70
|
+
], 46, g)) : (o(), l("button", {
|
|
71
|
+
key: 0,
|
|
72
|
+
type: "button",
|
|
73
|
+
class: "nmorph-context-menu__item",
|
|
74
|
+
role: "menuitem",
|
|
75
|
+
disabled: n.disabled,
|
|
76
|
+
style: m(e.getOptionStyle(n)),
|
|
77
|
+
onClick: (r) => e.optionClickHandler(n, t)
|
|
78
|
+
}, [
|
|
79
|
+
h(
|
|
80
|
+
"span",
|
|
81
|
+
O,
|
|
82
|
+
_(n.label),
|
|
83
|
+
1
|
|
84
|
+
/* TEXT */
|
|
85
|
+
)
|
|
86
|
+
], 12, v))
|
|
87
|
+
],
|
|
88
|
+
64
|
|
89
|
+
/* STABLE_FRAGMENT */
|
|
90
|
+
))),
|
|
91
|
+
128
|
|
92
|
+
/* KEYED_FRAGMENT */
|
|
93
|
+
))
|
|
94
|
+
])) : i(a.$slots, "menu", {
|
|
95
|
+
key: 1,
|
|
96
|
+
close: e.close
|
|
97
|
+
})
|
|
39
98
|
]),
|
|
40
99
|
_: 3
|
|
41
100
|
/* FORWARDED */
|
|
42
|
-
}, 8, ["open", "relative-element", "placement", "width", "min-width", "max-width", "x-offset", "y-offset", "fill-width", "z-index", "close-on-escape", "trap-focus", "role", "aria-label"])) :
|
|
101
|
+
}, 8, ["open", "relative-element", "placement", "width", "min-width", "max-width", "x-offset", "y-offset", "fill-width", "z-index", "close-on-escape", "trap-focus", "role", "aria-label"])) : b("v-if", !0)
|
|
43
102
|
],
|
|
44
103
|
544
|
|
45
104
|
/* NEED_HYDRATION, NEED_PATCH */
|
|
46
105
|
);
|
|
47
106
|
}
|
|
48
|
-
const
|
|
107
|
+
const B = /* @__PURE__ */ w(s, [["render", H], ["__file", "/builds/ketjo/nmorph/library/src/components/navigation/nmorph-context-menu/NmorphContextMenu.vue"]]);
|
|
49
108
|
export {
|
|
50
|
-
|
|
109
|
+
B as default
|
|
51
110
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import './NmorphContextMenu.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
2
|
+
import { defineComponent as L, ref as i, computed as y, markRaw as M, toRaw as D, watch as h, onBeforeUnmount as V } from "vue";
|
|
3
|
+
import P from "../nmorph-dropdown/NmorphDropdown.vue.js";
|
|
4
|
+
const $ = /* @__PURE__ */ L({
|
|
5
5
|
__name: "NmorphContextMenu",
|
|
6
6
|
props: {
|
|
7
7
|
modelValue: { type: [Boolean, null], required: !1, default: null },
|
|
8
|
+
options: { type: Array, required: !1, default: () => [] },
|
|
8
9
|
trigger: { type: String, required: !1, default: "contextmenu" },
|
|
9
10
|
placement: { type: null, required: !1, default: "bottom-start" },
|
|
10
|
-
width: { type: [Number, String], required: !1, default:
|
|
11
|
+
width: { type: [Number, String], required: !1, default: "max-content" },
|
|
11
12
|
minWidth: { type: [Number, String], required: !1, default: void 0 },
|
|
12
13
|
maxWidth: { type: [Number, String], required: !1, default: void 0 },
|
|
13
14
|
xOffset: { type: Number, required: !1, default: 0 },
|
|
@@ -17,56 +18,96 @@ const H = /* @__PURE__ */ N({
|
|
|
17
18
|
closeOnEscape: { type: Boolean, required: !1, default: !0 },
|
|
18
19
|
trapFocus: { type: Boolean, required: !1, default: !1 },
|
|
19
20
|
disabled: { type: Boolean, required: !1, default: !1 },
|
|
21
|
+
closeOnScroll: { type: Boolean, required: !1, default: !0 },
|
|
20
22
|
role: { type: String, required: !1, default: "menu" },
|
|
21
23
|
ariaLabel: { type: String, required: !1, default: "" }
|
|
22
24
|
},
|
|
23
|
-
emits: ["update:model-value", "open", "close", "on-outside-click", "on-escape-keydown"],
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
emits: ["update:model-value", "open", "close", "select", "on-outside-click", "on-escape-keydown"],
|
|
26
|
+
setup(O, { expose: q, emit: v }) {
|
|
27
|
+
const l = O, r = v, d = i(null), c = i(null), o = i("point"), a = i(!!l.modelValue), f = y(() => typeof l.modelValue == "boolean" ? l.modelValue : a.value), S = y(() => l.options.length > 0), B = y(
|
|
28
|
+
() => l.options.map((e, t) => typeof e == "string" || typeof e == "number" ? {
|
|
29
|
+
key: `${e}-${t}`,
|
|
30
|
+
label: e,
|
|
31
|
+
value: e,
|
|
32
|
+
disabled: !1,
|
|
33
|
+
closeOnClick: !0,
|
|
34
|
+
raw: e
|
|
35
|
+
} : {
|
|
36
|
+
key: `${String(e.value ?? e.label ?? t)}-${t}`,
|
|
37
|
+
label: e.label,
|
|
38
|
+
value: e.value ?? e.label ?? t,
|
|
39
|
+
component: e.component ? M(D(e.component)) : void 0,
|
|
40
|
+
componentProps: e.componentProps,
|
|
41
|
+
disabled: !!e.disabled,
|
|
42
|
+
color: e.color,
|
|
43
|
+
closeOnClick: e.closeOnClick ?? !0,
|
|
44
|
+
raw: e
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
h(
|
|
48
|
+
() => l.modelValue,
|
|
28
49
|
(e) => {
|
|
29
|
-
typeof e == "boolean" && (
|
|
50
|
+
typeof e == "boolean" && (a.value = e);
|
|
30
51
|
}
|
|
31
52
|
);
|
|
32
|
-
const
|
|
53
|
+
const g = (e, t) => ({
|
|
33
54
|
clientWidth: 0,
|
|
34
55
|
getBoundingClientRect: () => ({
|
|
35
56
|
x: e,
|
|
36
|
-
y:
|
|
57
|
+
y: t,
|
|
37
58
|
width: 0,
|
|
38
59
|
height: 0,
|
|
39
|
-
top:
|
|
60
|
+
top: t,
|
|
40
61
|
left: e,
|
|
41
62
|
right: e,
|
|
42
|
-
bottom:
|
|
63
|
+
bottom: t,
|
|
43
64
|
toJSON: () => ({})
|
|
44
65
|
})
|
|
45
66
|
}), u = (e) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
},
|
|
67
|
+
const t = f.value;
|
|
68
|
+
a.value = e, r("update:model-value", e), t && !e && r("close");
|
|
69
|
+
}, n = () => {
|
|
49
70
|
u(!1);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
71
|
+
}, b = (e, t, m) => {
|
|
72
|
+
o.value = "point", c.value = g(e, t), u(!0), r("open", m);
|
|
73
|
+
}, p = (e, t) => {
|
|
74
|
+
o.value = "element", c.value = e, u(!0), r("open", t);
|
|
75
|
+
}, C = (e) => {
|
|
76
|
+
l.disabled || l.trigger !== "contextmenu" && l.trigger !== "both" || (e.preventDefault(), b(e.clientX, e.clientY, e));
|
|
77
|
+
}, E = (e) => {
|
|
78
|
+
if (l.disabled || l.trigger !== "click" && l.trigger !== "both" || e.button !== 0) return;
|
|
79
|
+
const t = e.currentTarget instanceof HTMLElement ? e.currentTarget : d.value;
|
|
80
|
+
t && p(t, e);
|
|
81
|
+
}, H = (e) => {
|
|
82
|
+
if (l.disabled || e.key !== "ContextMenu" && !(e.shiftKey && e.key === "F10")) return;
|
|
83
|
+
const t = e.target instanceof HTMLElement ? e.target : d.value;
|
|
84
|
+
t && (e.preventDefault(), p(t, e));
|
|
62
85
|
}, _ = () => {
|
|
63
|
-
|
|
86
|
+
r("on-outside-click"), n();
|
|
87
|
+
}, N = () => {
|
|
88
|
+
r("on-escape-keydown"), n();
|
|
89
|
+
}, w = (e, t) => {
|
|
90
|
+
e.disabled || (r("select", e.raw, t), e.closeOnClick && n());
|
|
91
|
+
}, x = (e, t, m) => {
|
|
92
|
+
e.key !== "Enter" && e.key !== " " || (e.preventDefault(), w(t, m));
|
|
93
|
+
}, T = (e) => ({
|
|
94
|
+
"--nmorph-context-menu-item-color": e.color
|
|
95
|
+
}), s = () => {
|
|
96
|
+
l.closeOnScroll && o.value === "point" && n();
|
|
64
97
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
h(
|
|
99
|
+
f,
|
|
100
|
+
(e) => {
|
|
101
|
+
typeof window > "u" || (e ? window.addEventListener("scroll", s, { passive: !0, capture: !0 }) : window.removeEventListener("scroll", s, !0));
|
|
102
|
+
},
|
|
103
|
+
{ immediate: !0 }
|
|
104
|
+
), V(() => {
|
|
105
|
+
typeof window < "u" && window.removeEventListener("scroll", s, !0);
|
|
106
|
+
}), q({ close: n });
|
|
107
|
+
const k = { props: l, emit: r, triggerDOMRef: d, relativeElement: c, anchorType: o, openState: a, isOpen: f, hasOptions: S, normalizedOptions: B, createPointElement: g, setOpen: u, close: n, openAt: b, openAtElement: p, contextMenuHandler: C, clickHandler: E, keydownHandler: H, outsideClickHandler: _, escapeHandler: N, optionClickHandler: w, optionKeydownHandler: x, getOptionStyle: T, scrollHandler: s, NmorphDropdown: P };
|
|
108
|
+
return Object.defineProperty(k, "__isScriptSetup", { enumerable: !1, value: !0 }), k;
|
|
68
109
|
}
|
|
69
110
|
});
|
|
70
111
|
export {
|
|
71
|
-
|
|
112
|
+
$ as default
|
|
72
113
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './NmorphDropdown.css';
|
|
2
2
|
import n from "./NmorphDropdown.vue2.js";
|
|
3
|
-
import { openBlock as r, createBlock as a, withCtx as l, createElementBlock as p, normalizeStyle as s, normalizeClass as
|
|
3
|
+
import { openBlock as r, createBlock as a, withCtx as l, createElementBlock as p, normalizeStyle as s, normalizeClass as c, renderSlot as i, createCommentVNode as d } from "vue";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import t from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
6
6
|
const m = ["role", "aria-label"];
|
|
@@ -18,19 +18,19 @@ function f(e, _, h, o, w, k) {
|
|
|
18
18
|
o.props.open ? (r(), p("div", {
|
|
19
19
|
key: 0,
|
|
20
20
|
ref: "dropdownDOMRef",
|
|
21
|
-
class:
|
|
21
|
+
class: c([o.modifiers, o.props.contentClass]),
|
|
22
22
|
style: s(o.dropdownStyle),
|
|
23
23
|
role: o.props.role || void 0,
|
|
24
24
|
"aria-label": o.props.ariaLabel || void 0
|
|
25
25
|
}, [
|
|
26
|
-
|
|
26
|
+
i(e.$slots, "default")
|
|
27
27
|
], 14, m)) : d("v-if", !0)
|
|
28
28
|
]),
|
|
29
29
|
_: 3
|
|
30
30
|
/* FORWARDED */
|
|
31
31
|
}, 8, ["show", "z-index", "close-on-escape", "trap-focus"]);
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const O = /* @__PURE__ */ t(n, [["render", f], ["__file", "/builds/ketjo/nmorph/library/src/components/navigation/nmorph-dropdown/NmorphDropdown.vue"]]);
|
|
34
34
|
export {
|
|
35
|
-
|
|
35
|
+
O as default
|
|
36
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './NmorphDropdown.css';
|
|
2
|
-
import { defineComponent as w, ref as b, toRef as r, computed as i, watch as
|
|
3
|
-
import { useModifiers as
|
|
2
|
+
import { defineComponent as w, ref as b, toRef as r, computed as i, watch as q } from "vue";
|
|
3
|
+
import { useModifiers as v } from "../../../utils/create-modifiers.js";
|
|
4
4
|
import { usePlacement as x } from "../../../hooks/use-placement.js";
|
|
5
5
|
import O from "../../others/nmorph-overlay/NmorphOverlay.vue.js";
|
|
6
6
|
const k = /* @__PURE__ */ w({
|
|
@@ -19,7 +19,8 @@ const k = /* @__PURE__ */ w({
|
|
|
19
19
|
closeOnEscape: { type: Boolean, required: !1, default: !0 },
|
|
20
20
|
trapFocus: { type: Boolean, required: !1, default: !1 },
|
|
21
21
|
role: { type: String, required: !1, default: "listbox" },
|
|
22
|
-
ariaLabel: { type: String, required: !1, default: "" }
|
|
22
|
+
ariaLabel: { type: String, required: !1, default: "" },
|
|
23
|
+
contentClass: { type: String, required: !1, default: "" }
|
|
23
24
|
},
|
|
24
25
|
emits: ["on-outside-click", "on-escape-keydown"],
|
|
25
26
|
setup(f, { expose: m, emit: c }) {
|
|
@@ -32,7 +33,7 @@ const k = /* @__PURE__ */ w({
|
|
|
32
33
|
xOffset: r(e, "xOffset"),
|
|
33
34
|
enabled: r(e, "open")
|
|
34
35
|
}), y = i(
|
|
35
|
-
() =>
|
|
36
|
+
() => v({
|
|
36
37
|
"nmorph-dropdown": [`${!e.open && "closed"}`]
|
|
37
38
|
})
|
|
38
39
|
), o = (t) => typeof t == "number" ? `${t}px` : t, p = i(
|
|
@@ -45,7 +46,7 @@ const k = /* @__PURE__ */ w({
|
|
|
45
46
|
top: l.value.y,
|
|
46
47
|
visibility: e.open && a.value ? "visible" : "hidden"
|
|
47
48
|
}));
|
|
48
|
-
|
|
49
|
+
q(
|
|
49
50
|
() => e.open,
|
|
50
51
|
(t) => {
|
|
51
52
|
t && s();
|