iryx-ui 0.26.0 → 0.27.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.
@@ -1,14 +1,21 @@
1
1
  import { useIryxUiConfig as e } from "../config.js";
2
2
  import t from "./Icon.js";
3
- import { isSidebarGroup as n, toSidebarSections as r } from "../composables/sidebar.js";
4
- import { sidebarTheme as i } from "../theme/sidebar.js";
5
- import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createVNode as d, defineComponent as f, mergeModels as p, normalizeClass as m, openBlock as h, renderList as g, renderSlot as _, resolveDynamicComponent as v, toDisplayString as y, unref as b, useModel as x, withCtx as S } from "vue";
6
- import { ArrowRight01Icon as C } from "@hugeicons/core-free-icons";
7
- import { CollapsibleContent as w, CollapsibleRoot as T, CollapsibleTrigger as E, Primitive as D } from "reka-ui";
3
+ import { isSidebarGroup as n, sidebarPlacementKey as r, toSidebarSections as i } from "../composables/sidebar.js";
4
+ import a from "./Tooltip.js";
5
+ import o from "./DropdownMenu.js";
6
+ import { sidebarTheme as s } from "../theme/sidebar.js";
7
+ import { Fragment as c, computed as l, createBlock as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createTextVNode as m, createVNode as h, defineComponent as g, inject as _, mergeModels as v, normalizeClass as y, openBlock as b, ref as x, renderList as S, renderSlot as C, resolveDynamicComponent as w, toDisplayString as T, unref as E, useModel as D, withCtx as O } from "vue";
8
+ import { ArrowRight01Icon as k } from "@hugeicons/core-free-icons";
9
+ import { CollapsibleContent as A, CollapsibleRoot as j, CollapsibleTrigger as M, Primitive as N } from "reka-ui";
8
10
  //#region src/components/Sidebar.vue?vue&type=script&setup=true&lang.ts
9
- var O = /*@__PURE__*/ f({
11
+ var P = [
12
+ "aria-label",
13
+ "disabled",
14
+ "data-active",
15
+ "data-disabled"
16
+ ], F = /*@__PURE__*/ g({
10
17
  __name: "Sidebar",
11
- props: /*@__PURE__*/ p({
18
+ props: /*@__PURE__*/ v({
12
19
  items: {},
13
20
  side: { default: "left" },
14
21
  label: { default: "Sidebar" },
@@ -31,61 +38,113 @@ var O = /*@__PURE__*/ f({
31
38
  collapsedModifiers: {}
32
39
  }),
33
40
  emits: ["update:collapsed"],
34
- setup(f) {
35
- let p = f, O = x(f, "collapsed"), k = e(), A = o(() => p.unstyled ?? k.unstyled), j = o(() => r(p.items)), M = o(() => i({
36
- side: p.side,
37
- collapsed: O.value
41
+ setup(g) {
42
+ let v = g, F = D(g, "collapsed"), I = _(r, void 0), L = l(() => F.value && I !== "drawer"), R = e(), z = l(() => v.unstyled ?? R.unstyled), B = l(() => i(v.items)), V = l(() => s({
43
+ side: v.side,
44
+ collapsed: L.value,
45
+ inShell: I !== void 0
38
46
  }));
39
- function N(e) {
40
- let t = p.ui?.[e];
41
- return A.value ? t : M.value[e]({ class: t });
47
+ function H(e) {
48
+ let t = v.ui?.[e];
49
+ return z.value ? t : V.value[e]({ class: t });
42
50
  }
43
- let P = (e) => e.href ? "a" : "button";
44
- function F(e, t) {
51
+ let U = l(() => v.side === "right" ? "left" : "right"), W = x({}), G = (e, t) => `${e}:${t.label}`, K = (e) => e.href ? "a" : "button", q = (e) => [...e.label][0], J = (e) => e.badge === void 0 ? e.label : `${e.label} (${e.badge})`;
52
+ function Y(e) {
53
+ return (e.items ?? []).map((e) => ({
54
+ label: e.label,
55
+ icon: e.icon,
56
+ disabled: e.disabled,
57
+ href: e.href,
58
+ onSelect: e.onSelect
59
+ }));
60
+ }
61
+ function X(e, t) {
45
62
  if (e.disabled) {
46
63
  t.preventDefault();
47
64
  return;
48
65
  }
49
66
  e.onSelect?.();
50
67
  }
51
- let I = (e) => e.label;
52
- return (e, r) => (h(), s(b(D), {
68
+ let Z = (e) => e.label;
69
+ return (e, r) => (b(), u(E(N), {
53
70
  as: "nav",
54
- "aria-label": p.label,
55
- "data-collapsed": O.value ? "" : void 0,
56
- class: m(A.value ? [p.ui?.root, p.class] : M.value.root({ class: [p.ui?.root, p.class] }))
71
+ "aria-label": v.label,
72
+ "data-collapsed": L.value ? "" : void 0,
73
+ class: y(z.value ? [v.ui?.root, v.class] : V.value.root({ class: [v.ui?.root, v.class] }))
57
74
  }, {
58
- default: S(() => [
59
- e.$slots.header ? (h(), l("div", {
75
+ default: O(() => [
76
+ e.$slots.header ? (b(), f("div", {
60
77
  key: 0,
61
- class: m(N("header"))
62
- }, [_(e.$slots, "header", { collapsed: O.value })], 2)) : c("", !0),
63
- u("div", { class: m(N("nav")) }, [_(e.$slots, "default", { collapsed: O.value }, () => [(h(!0), l(a, null, g(j.value, (r, i) => (h(), l("div", {
78
+ class: y(H("header"))
79
+ }, [C(e.$slots, "header", { collapsed: L.value })], 2)) : d("", !0),
80
+ p("div", { class: y(H("nav")) }, [C(e.$slots, "default", { collapsed: L.value }, () => [(b(!0), f(c, null, S(B.value, (r, i) => (b(), f("div", {
64
81
  key: r.section || i,
65
- class: m(N("section"))
66
- }, [r.section ? (h(), l("p", {
82
+ class: y(H("section"))
83
+ }, [r.section ? (b(), f("p", {
67
84
  key: 0,
68
- class: m(N("sectionLabel"))
69
- }, y(r.section), 3)) : c("", !0), (h(!0), l(a, null, g(r.items, (r) => (h(), l(a, { key: r.label }, [b(n)(r) ? (h(), s(b(T), {
85
+ class: y(H("sectionLabel"))
86
+ }, T(r.section), 3)) : d("", !0), (b(!0), f(c, null, S(r.items, (r) => (b(), f(c, { key: r.label }, [E(n)(r) && L.value ? (b(), u(a, {
70
87
  key: 0,
71
- "default-open": r.defaultOpen,
72
- disabled: r.disabled
88
+ text: J(r),
89
+ side: U.value,
90
+ unstyled: z.value
91
+ }, {
92
+ trigger: O(() => [h(o, {
93
+ items: Y(r),
94
+ side: U.value,
95
+ unstyled: z.value
96
+ }, {
97
+ trigger: O(() => [p("button", {
98
+ type: "button",
99
+ "aria-label": Z(r),
100
+ disabled: r.disabled,
101
+ "data-active": r.active ? "" : void 0,
102
+ "data-disabled": r.disabled ? "" : void 0,
103
+ class: y(H("link"))
104
+ }, [C(e.$slots, "link", {
105
+ link: r,
106
+ collapsed: L.value
107
+ }, () => [r.icon ? (b(), u(t, {
108
+ key: 0,
109
+ icon: r.icon
110
+ }, null, 8, ["icon"])) : (b(), f("span", {
111
+ key: 1,
112
+ "aria-hidden": "true",
113
+ class: y(H("linkInitial"))
114
+ }, T(q(r)), 3))])], 10, P)]),
115
+ header: O(() => [m(T(r.label), 1)]),
116
+ _: 2
117
+ }, 1032, [
118
+ "items",
119
+ "side",
120
+ "unstyled"
121
+ ])]),
122
+ _: 2
123
+ }, 1032, [
124
+ "text",
125
+ "side",
126
+ "unstyled"
127
+ ])) : E(n)(r) ? (b(), u(E(j), {
128
+ key: 1,
129
+ open: W.value[G(i, r)] ?? r.defaultOpen ?? !1,
130
+ disabled: r.disabled,
131
+ "onUpdate:open": (e) => W.value[G(i, r)] = e
73
132
  }, {
74
- default: S(() => [d(b(E), {
75
- "aria-label": I(r),
133
+ default: O(() => [h(E(M), {
134
+ "aria-label": Z(r),
76
135
  "data-active": r.active ? "" : void 0,
77
136
  "data-disabled": r.disabled ? "" : void 0,
78
- class: m(N("link"))
137
+ class: y(H("link"))
79
138
  }, {
80
- default: S(() => [
81
- r.icon ? (h(), s(t, {
139
+ default: O(() => [
140
+ r.icon ? (b(), u(t, {
82
141
  key: 0,
83
142
  icon: r.icon
84
- }, null, 8, ["icon"])) : c("", !0),
85
- u("span", { class: m(N("linkLabel")) }, y(r.label), 3),
86
- d(t, {
87
- icon: b(C),
88
- class: m(N("groupIcon"))
143
+ }, null, 8, ["icon"])) : d("", !0),
144
+ p("span", { class: y(H("linkLabel")) }, T(r.label), 3),
145
+ h(t, {
146
+ icon: E(k),
147
+ class: y(H("groupIcon"))
89
148
  }, null, 8, ["icon", "class"])
90
149
  ]),
91
150
  _: 2
@@ -94,29 +153,29 @@ var O = /*@__PURE__*/ f({
94
153
  "data-active",
95
154
  "data-disabled",
96
155
  "class"
97
- ]), d(b(w), { class: m(N("groupContent")) }, {
98
- default: S(() => [u("div", { class: m(N("groupInner")) }, [(h(!0), l(a, null, g(r.items, (e) => (h(), s(v(P(e)), {
156
+ ]), h(E(A), { class: y(H("groupContent")) }, {
157
+ default: O(() => [p("div", { class: y(H("groupInner")) }, [(b(!0), f(c, null, S(r.items, (e) => (b(), u(w(K(e)), {
99
158
  key: e.label,
100
159
  href: e.href,
101
160
  type: e.href ? void 0 : "button",
102
- "aria-label": I(e),
161
+ "aria-label": Z(e),
103
162
  "aria-current": e.active ? "page" : void 0,
104
163
  "aria-disabled": e.disabled || void 0,
105
164
  "data-active": e.active ? "" : void 0,
106
165
  "data-disabled": e.disabled ? "" : void 0,
107
- class: m(N("link")),
108
- onClick: (t) => F(e, t)
166
+ class: y(H("link")),
167
+ onClick: (t) => X(e, t)
109
168
  }, {
110
- default: S(() => [
111
- e.icon ? (h(), s(t, {
169
+ default: O(() => [
170
+ e.icon ? (b(), u(t, {
112
171
  key: 0,
113
172
  icon: e.icon
114
- }, null, 8, ["icon"])) : c("", !0),
115
- u("span", { class: m(N("linkLabel")) }, y(e.label), 3),
116
- e.badge === void 0 ? c("", !0) : (h(), l("span", {
173
+ }, null, 8, ["icon"])) : d("", !0),
174
+ p("span", { class: y(H("linkLabel")) }, T(e.label), 3),
175
+ e.badge === void 0 ? d("", !0) : (b(), f("span", {
117
176
  key: 1,
118
- class: m(N("linkBadge"))
119
- }, y(e.badge), 3))
177
+ class: y(H("linkBadge"))
178
+ }, T(e.badge), 3))
120
179
  ]),
121
180
  _: 2
122
181
  }, 1032, [
@@ -133,48 +192,69 @@ var O = /*@__PURE__*/ f({
133
192
  _: 2
134
193
  }, 1032, ["class"])]),
135
194
  _: 2
136
- }, 1032, ["default-open", "disabled"])) : (h(), s(v(P(r)), {
137
- key: 1,
138
- href: r.href,
139
- type: r.href ? void 0 : "button",
140
- "aria-label": I(r),
141
- "aria-current": r.active ? "page" : void 0,
142
- "aria-disabled": r.disabled || void 0,
143
- "data-active": r.active ? "" : void 0,
144
- "data-disabled": r.disabled ? "" : void 0,
145
- class: m(N("link")),
146
- onClick: (e) => F(r, e)
195
+ }, 1032, [
196
+ "open",
197
+ "disabled",
198
+ "onUpdate:open"
199
+ ])) : (b(), u(a, {
200
+ key: 2,
201
+ text: J(r),
202
+ side: U.value,
203
+ disabled: !L.value,
204
+ unstyled: z.value
147
205
  }, {
148
- default: S(() => [_(e.$slots, "link", {
149
- link: r,
150
- collapsed: O.value
151
- }, () => [
152
- r.icon ? (h(), s(t, {
153
- key: 0,
154
- icon: r.icon
155
- }, null, 8, ["icon"])) : c("", !0),
156
- u("span", { class: m(N("linkLabel")) }, y(r.label), 3),
157
- r.badge === void 0 ? c("", !0) : (h(), l("span", {
158
- key: 1,
159
- class: m(N("linkBadge"))
160
- }, y(r.badge), 3))
161
- ])]),
206
+ trigger: O(() => [(b(), u(w(K(r)), {
207
+ href: r.href,
208
+ type: r.href ? void 0 : "button",
209
+ "aria-label": Z(r),
210
+ "aria-current": r.active ? "page" : void 0,
211
+ "aria-disabled": r.disabled || void 0,
212
+ "data-active": r.active ? "" : void 0,
213
+ "data-disabled": r.disabled ? "" : void 0,
214
+ class: y(H("link")),
215
+ onClick: (e) => X(r, e)
216
+ }, {
217
+ default: O(() => [C(e.$slots, "link", {
218
+ link: r,
219
+ collapsed: L.value
220
+ }, () => [
221
+ r.icon ? (b(), u(t, {
222
+ key: 0,
223
+ icon: r.icon
224
+ }, null, 8, ["icon"])) : L.value ? (b(), f("span", {
225
+ key: 1,
226
+ "aria-hidden": "true",
227
+ class: y(H("linkInitial"))
228
+ }, T(q(r)), 3)) : d("", !0),
229
+ p("span", { class: y(H("linkLabel")) }, T(r.label), 3),
230
+ r.badge === void 0 ? d("", !0) : (b(), f("span", {
231
+ key: 2,
232
+ class: y(H("linkBadge"))
233
+ }, T(r.badge), 3))
234
+ ])]),
235
+ _: 2
236
+ }, 1032, [
237
+ "href",
238
+ "type",
239
+ "aria-label",
240
+ "aria-current",
241
+ "aria-disabled",
242
+ "data-active",
243
+ "data-disabled",
244
+ "class",
245
+ "onClick"
246
+ ]))]),
162
247
  _: 2
163
248
  }, 1032, [
164
- "href",
165
- "type",
166
- "aria-label",
167
- "aria-current",
168
- "aria-disabled",
169
- "data-active",
170
- "data-disabled",
171
- "class",
172
- "onClick"
249
+ "text",
250
+ "side",
251
+ "disabled",
252
+ "unstyled"
173
253
  ]))], 64))), 128))], 2))), 128))])], 2),
174
- e.$slots.footer ? (h(), l("div", {
254
+ e.$slots.footer ? (b(), f("div", {
175
255
  key: 1,
176
- class: m(N("footer"))
177
- }, [_(e.$slots, "footer", { collapsed: O.value })], 2)) : c("", !0)
256
+ class: y(H("footer"))
257
+ }, [C(e.$slots, "footer", { collapsed: L.value })], 2)) : d("", !0)
178
258
  ]),
179
259
  _: 3
180
260
  }, 8, [
@@ -185,4 +265,4 @@ var O = /*@__PURE__*/ f({
185
265
  }
186
266
  });
187
267
  //#endregion
188
- export { O as default };
268
+ export { F as default };
@@ -6,6 +6,8 @@ export interface DropdownMenuItemOption {
6
6
  disabled?: boolean;
7
7
  /** Style the item as destructive. */
8
8
  danger?: boolean;
9
+ /** Renders the item as a link. */
10
+ href?: string;
9
11
  /** Run when the item is chosen. Omit on an entry that opens a submenu. */
10
12
  onSelect?: () => void;
11
13
  /** Nested entries. Turns this item into a submenu trigger. */
@@ -15,7 +17,7 @@ export interface DropdownMenuItemOption {
15
17
  * One row of a menu.
16
18
  *
17
19
  * `'-'` renders a separator. An option with `items` opens a submenu, and one
18
- * with neither `items` nor `onSelect` is a non-interactive group label.
20
+ * with none of `items`, `href` or `onSelect` is a non-interactive group label.
19
21
  */
20
22
  export type DropdownMenuEntry = DropdownMenuItemOption | '-';
21
23
  export declare function isSeparator(entry: DropdownMenuEntry): entry is '-';
@@ -1,3 +1,4 @@
1
+ import type { InjectionKey } from 'vue';
1
2
  import type { IconLike } from './icon';
2
3
  export interface SidebarLink {
3
4
  label: string;
@@ -29,6 +30,8 @@ export interface SidebarSection {
29
30
  items: SidebarLink[];
30
31
  }
31
32
  export type SidebarItems = (SidebarLink | SidebarSection)[];
33
+ /** Provided by `IAppShell` around each copy of its sidebar slot. */
34
+ export declare const sidebarPlacementKey: InjectionKey<'column' | 'drawer'>;
32
35
  export declare function isSidebarSection(item: SidebarLink | SidebarSection): item is SidebarSection;
33
36
  /** Normalise to sections, so the template has a single path to render. */
34
37
  export declare function toSidebarSections(items: SidebarItems | undefined): SidebarSection[];
@@ -1,11 +1,12 @@
1
1
  //#region src/composables/sidebar.ts
2
- function e(e) {
2
+ var e = Symbol.for("iryx-ui:sidebar-placement");
3
+ function t(e) {
3
4
  return typeof e.section == "string";
4
5
  }
5
- function t(t) {
6
+ function n(e) {
6
7
  let n = [], r;
7
- for (let i of t ?? []) {
8
- if (e(i)) {
8
+ for (let i of e ?? []) {
9
+ if (t(i)) {
9
10
  n.push(i), r = void 0;
10
11
  continue;
11
12
  }
@@ -16,8 +17,8 @@ function t(t) {
16
17
  }
17
18
  return n;
18
19
  }
19
- function n(e) {
20
+ function r(e) {
20
21
  return Array.isArray(e.items) && e.items.length > 0;
21
22
  }
22
23
  //#endregion
23
- export { n as isSidebarGroup, e as isSidebarSection, t as toSidebarSections };
24
+ export { r as isSidebarGroup, t as isSidebarSection, e as sidebarPlacementKey, n as toSidebarSections };