@scalar/sidebar 0.2.1 → 0.3.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 +1 @@
1
- {"version":3,"file":"SidebarItem.vue.d.ts","sourceRoot":"","sources":["../../src/components/SidebarItem.vue"],"names":[],"mappings":"AA+MA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC9B,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC,OAAO,EACH;QACE,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;KACrD,GACD,SAAS,CAAA;CACd,CAAC;AASF,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAA;CAC3C,CAAC;AAmXF,QAAA,MAAM,eAAe;;;;;;kFAOnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"SidebarItem.vue.d.ts","sourceRoot":"","sources":["../../src/components/SidebarItem.vue"],"names":[],"mappings":"AAyMA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC9B,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAA;IACnC,OAAO,EACH;QACE,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;KACrD,GACD,SAAS,CAAA;CACd,CAAC;AASF,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAA;CAC3C,CAAC;AA6WF,QAAA,MAAM,eAAe;;;;;;kFAOnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,10 +1,10 @@
1
- import { defineComponent as G, resolveComponent as B, createBlock as n, openBlock as o, unref as r, withCtx as i, createTextVNode as s, toDisplayString as m, createElementBlock as p, Fragment as u, renderList as E, renderSlot as y, mergeProps as v, createSlots as I, createVNode as c, createCommentVNode as f } from "vue";
2
- import { ScalarSidebarSection as F, ScalarSidebarGroup as A, ScalarSidebarGroupToggle as N, ScalarSidebarItem as O } from "@scalar/components";
3
- import { Draggable as T } from "@scalar/draggable";
4
- import { ScalarIconFolder as V } from "@scalar/icons";
5
- import { formatSidebarLabel as h } from "../helpers/format-sidebar-label.js";
6
- import w from "./SidebarHttpBadge.vue.js";
7
- const z = /* @__PURE__ */ G({
1
+ import { defineComponent as B, resolveComponent as G, createBlock as n, openBlock as o, unref as r, withCtx as i, createTextVNode as s, toDisplayString as m, createElementBlock as p, Fragment as u, renderList as E, renderSlot as y, mergeProps as v, createSlots as I, createVNode as c, createCommentVNode as f } from "vue";
2
+ import { ScalarSidebarSection as F, ScalarSidebarGroup as N, ScalarSidebarGroupToggle as O, ScalarSidebarItem as T } from "@scalar/components";
3
+ import { Draggable as V } from "@scalar/draggable";
4
+ import { addWordBreaks as k } from "@scalar/helpers/string/add-word-breaks";
5
+ import { ScalarIconFolder as A } from "@scalar/icons";
6
+ import D from "./SidebarHttpBadge.vue.js";
7
+ const z = /* @__PURE__ */ B({
8
8
  __name: "SidebarItem",
9
9
  props: {
10
10
  item: {},
@@ -14,15 +14,15 @@ const z = /* @__PURE__ */ G({
14
14
  options: {}
15
15
  },
16
16
  emits: ["selectItem", "onDragEnd"],
17
- setup(D, { emit: C }) {
18
- const d = C, k = (e) => "children" in e && Array.isArray(e.children) && e.children.length > 0, $ = (e) => "isGroup" in e && e.isGroup, b = (e) => D.layout === "reference" ? e : e.filter(
19
- (t) => t.type === "webhook" || t.type === "operation" || t.type === "example" || t.type === "tag"
17
+ setup(w, { emit: $ }) {
18
+ const a = $, h = (e) => "children" in e && Array.isArray(e.children) && e.children.length > 0, C = (e) => "isGroup" in e && e.isGroup, g = (e) => w.layout === "reference" ? e : e.filter(
19
+ (t) => t.type === "operation" || t.type === "example" || t.type === "tag"
20
20
  ), S = (e, t) => {
21
- d("onDragEnd", e, t);
21
+ a("onDragEnd", e, t);
22
22
  };
23
23
  return (e, t) => {
24
- const g = B("SidebarItem", !0);
25
- return o(), n(r(T), {
24
+ const b = G("SidebarItem", !0);
25
+ return o(), n(r(V), {
26
26
  id: e.item.id,
27
27
  class: "flex flex-1 flex-col",
28
28
  isDraggable: e.layout === "client",
@@ -30,20 +30,20 @@ const z = /* @__PURE__ */ G({
30
30
  onOnDragEnd: S
31
31
  }, {
32
32
  default: i(() => [
33
- k(e.item) && $(e.item) ? (o(), n(r(F), { key: 0 }, {
33
+ h(e.item) && C(e.item) ? (o(), n(r(F), { key: 0 }, {
34
34
  items: i(() => [
35
- (o(!0), p(u, null, E(b(e.item.children), (l) => (o(), n(g, {
36
- key: l.id,
35
+ (o(!0), p(u, null, E(g(e.item.children), (d) => (o(), n(b, {
36
+ key: d.id,
37
37
  isExpanded: e.isExpanded,
38
38
  isSelected: e.isSelected,
39
- item: l,
39
+ item: d,
40
40
  layout: e.layout,
41
41
  options: e.options,
42
42
  onOnDragEnd: S,
43
- onSelectItem: t[0] || (t[0] = (a) => d("selectItem", a))
43
+ onSelectItem: t[0] || (t[0] = (l) => a("selectItem", l))
44
44
  }, {
45
- decorator: i((a) => [
46
- y(e.$slots, "decorator", v({ ref_for: !0 }, a))
45
+ decorator: i((l) => [
46
+ y(e.$slots, "decorator", v({ ref_for: !0 }, l))
47
47
  ]),
48
48
  _: 3
49
49
  }, 8, ["isExpanded", "isSelected", "item", "layout", "options"]))), 128))
@@ -52,27 +52,27 @@ const z = /* @__PURE__ */ G({
52
52
  s(m(e.item.title) + " ", 1)
53
53
  ]),
54
54
  _: 3
55
- })) : k(e.item) && (e.layout === "reference" && !(e.item.type === "operation" || e.item.type === "webhook") || e.layout === "client") ? (o(), n(r(A), {
55
+ })) : h(e.item) && (e.layout === "reference" && !(e.item.type === "operation" || e.item.type === "webhook") || e.layout === "client") ? (o(), n(r(N), {
56
56
  key: 1,
57
57
  active: e.isSelected(e.item.id),
58
58
  controlled: "",
59
59
  open: e.isExpanded(e.item.id),
60
- onClick: t[2] || (t[2] = () => d("selectItem", e.item.id))
60
+ onClick: t[2] || (t[2] = () => a("selectItem", e.item.id))
61
61
  }, I({
62
62
  items: i(() => [
63
- (o(!0), p(u, null, E(b(e.item.children), (l) => (o(), n(g, {
64
- key: l.id,
63
+ (o(!0), p(u, null, E(g(e.item.children), (d) => (o(), n(b, {
64
+ key: d.id,
65
65
  isExpanded: e.isExpanded,
66
66
  isSelected: e.isSelected,
67
- item: l,
67
+ item: d,
68
68
  layout: e.layout,
69
69
  options: e.options,
70
70
  parentIds: [],
71
71
  onOnDragEnd: S,
72
- onSelectItem: t[1] || (t[1] = (a) => d("selectItem", a))
72
+ onSelectItem: t[1] || (t[1] = (l) => a("selectItem", l))
73
73
  }, {
74
- decorator: i((a) => [
75
- y(e.$slots, "decorator", v({ ref_for: !0 }, a))
74
+ decorator: i((l) => [
75
+ y(e.$slots, "decorator", v({ ref_for: !0 }, l))
76
76
  ]),
77
77
  _: 3
78
78
  }, 8, ["isExpanded", "isSelected", "item", "layout", "options"]))), 128))
@@ -84,11 +84,11 @@ const z = /* @__PURE__ */ G({
84
84
  }, [
85
85
  e.item.type === "document" ? {
86
86
  name: "icon",
87
- fn: i(({ open: l }) => [
88
- c(r(V), { class: "text-c-3 block group-hover/group-button:hidden" }),
89
- c(r(N), {
87
+ fn: i(({ open: d }) => [
88
+ c(r(A), { class: "text-c-3 block group-hover/group-button:hidden" }),
89
+ c(r(O), {
90
90
  class: "text-c-3 hidden group-hover/group-button:block",
91
- open: l
91
+ open: d
92
92
  }, null, 8, ["open"])
93
93
  ]),
94
94
  key: "0"
@@ -100,7 +100,7 @@ const z = /* @__PURE__ */ G({
100
100
  key: 0,
101
101
  item: e.item
102
102
  }) : f("", !0),
103
- "method" in e.item ? (o(), n(w, {
103
+ "method" in e.item ? (o(), n(D, {
104
104
  key: 1,
105
105
  active: e.isSelected(e.item.id),
106
106
  class: "ml-2 h-4 self-start",
@@ -110,18 +110,18 @@ const z = /* @__PURE__ */ G({
110
110
  ]),
111
111
  key: "1"
112
112
  } : void 0
113
- ]), 1032, ["active", "open"])) : (o(), n(r(O), {
113
+ ]), 1032, ["active", "open"])) : (o(), n(r(T), {
114
114
  key: 2,
115
115
  is: "button",
116
116
  class: "text-left",
117
117
  selected: e.isSelected(e.item.id),
118
- onClick: t[3] || (t[3] = () => d("selectItem", e.item.id))
118
+ onClick: t[3] || (t[3] = () => a("selectItem", e.item.id))
119
119
  }, I({
120
120
  default: i(() => [
121
121
  e.item.type === "model" ? (o(), p(u, { key: 0 }, [
122
- s(m(r(h)(e.item.title, { wrapCharacters: /[\/\-\_A-Z\.]/g })), 1)
122
+ s(m(r(k)(e.item.title, { preset: "property" })), 1)
123
123
  ], 64)) : (o(), p(u, { key: 1 }, [
124
- s(m(e.options?.operationTitleSource === "path" && "path" in e.item ? r(h)(e.item.path) : r(h)(e.item.title)), 1)
124
+ s(m(e.options?.operationTitleSource === "path" && "path" in e.item ? r(k)(e.item.path) : r(k)(e.item.title)), 1)
125
125
  ], 64))
126
126
  ]),
127
127
  _: 2
@@ -133,7 +133,7 @@ const z = /* @__PURE__ */ G({
133
133
  key: 0,
134
134
  item: e.item
135
135
  }) : f("", !0),
136
- "method" in e.item ? (o(), n(w, {
136
+ "method" in e.item ? (o(), n(D, {
137
137
  key: 1,
138
138
  active: e.isSelected(e.item.id),
139
139
  class: "ml-2 h-4 self-start",
@@ -15,15 +15,15 @@ type SidebarStateOptions = Partial<{
15
15
  */
16
16
  onAfterExpand: (id: string) => void;
17
17
  /**
18
- * Called before an item is selected.
19
- * @param id - The ID of the item to select.
18
+ * Called just before a sidebar item selection changes.
19
+ * @param id - The ID of the item that is about to be selected, or null if deselecting.
20
20
  */
21
- onBeforeSelect: (id: string) => void;
21
+ onBeforeSelect: (id: string | null) => void;
22
22
  /**
23
- * Called after an item is selected.
24
- * @param id - The ID of the item that was selected.
23
+ * Called immediately after a sidebar item has been selected.
24
+ * @param id - The ID of the item that was selected, or null if selection was cleared.
25
25
  */
26
- onAfterSelect: (id: string) => void;
26
+ onAfterSelect: (id: string | null) => void;
27
27
  }>;
28
28
  }>;
29
29
  /**
@@ -73,7 +73,7 @@ export declare const createSidebarState: <T extends {
73
73
  }>>;
74
74
  selectedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
75
75
  expandedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
76
- setSelected: (id: string) => void;
76
+ setSelected: (id: string | null) => void;
77
77
  setExpanded: (id: string, value: boolean) => void;
78
78
  isExpanded: (id: string) => boolean;
79
79
  isSelected: (id: string) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"create-sidebar-state.d.ts","sourceRoot":"","sources":["../../src/helpers/create-sidebar-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,KAAK,CAAA;AAInE,KAAK,mBAAmB,GAAG,OAAO,CAAC;IACjC,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAA;IACX,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;QACb;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACpC;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACnC;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACpC;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;KACpC,CAAC,CAAA;CACH,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACzD,OAAO,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAC5B,UAAU,mBAAmB;;;;;;;sBAqBJ,MAAM;sBAiDN,MAAM,SAAS,OAAO;qBAkCvB,MAAM;qBAIN,MAAM;uBAIJ,MAAM;;;CAajC,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI,UAAU,CAAC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"create-sidebar-state.d.ts","sourceRoot":"","sources":["../../src/helpers/create-sidebar-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,KAAK,CAAA;AAInE,KAAK,mBAAmB,GAAG,OAAO,CAAC;IACjC,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAA;IACX,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;QACb;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACpC;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;QACnC;;;WAGG;QACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;QAC3C;;;WAGG;QACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;KAC3C,CAAC,CAAA;CACH,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACzD,OAAO,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAC5B,UAAU,mBAAmB;;;;;;;sBA0BJ,MAAM,GAAG,IAAI;sBAqDb,MAAM,SAAS,OAAO;qBAkCvB,MAAM;qBAIN,MAAM;uBAIJ,MAAM;;;CAajC,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI,UAAU,CAAC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA"}
@@ -1,22 +1,27 @@
1
1
  import { computed as c, toValue as u, ref as k } from "vue";
2
- import { generateReverseIndex as S } from "./generate-reverse-index.js";
2
+ import { generateReverseIndex as m } from "./generate-reverse-index.js";
3
3
  const E = (o, t) => {
4
- const n = c(() => S(u(o), t?.key ?? "children")), s = k({}), f = k({}), p = (e) => {
5
- const l = (r) => {
6
- r && (s.value[r.id] = !0, "parent" in r && r.parent && l(r.parent));
4
+ const n = c(
5
+ () => m({
6
+ items: u(o),
7
+ nestedKey: t?.key ?? "children"
8
+ })
9
+ ), s = k({}), l = k({}), p = (e) => {
10
+ const f = (r) => {
11
+ r && (s.value[r.id] = !0, "parent" in r && r.parent && f(r.parent));
7
12
  };
8
- t?.hooks?.onBeforeSelect && t.hooks.onBeforeSelect(e), s.value = {}, l(n.value.get(e)), t?.hooks?.onAfterSelect && t.hooks.onAfterSelect(e);
9
- }, v = (e, l) => {
13
+ t?.hooks?.onBeforeSelect && t.hooks.onBeforeSelect(e), s.value = {}, e !== null && f(n.value.get(e)), t?.hooks?.onAfterSelect && t.hooks.onAfterSelect(e);
14
+ }, v = (e, f) => {
10
15
  const r = (a) => {
11
- a && (f.value[a.id] = !0, "parent" in a && a.parent && r(a.parent));
16
+ a && (l.value[a.id] = !0, "parent" in a && a.parent && r(a.parent));
12
17
  };
13
- t?.hooks?.onBeforeExpand && t.hooks.onBeforeExpand(e), l === !1 ? f.value[e] = !1 : r(n.value.get(e)), t?.hooks?.onAfterExpand && t.hooks.onAfterExpand(e);
14
- }, x = (e) => f.value[e] ?? !1, d = (e) => s.value[e] ?? !1, h = (e) => n.value.get(e);
18
+ t?.hooks?.onBeforeExpand && t.hooks.onBeforeExpand(e), f === !1 ? l.value[e] = !1 : r(n.value.get(e)), t?.hooks?.onAfterExpand && t.hooks.onAfterExpand(e);
19
+ }, x = (e) => l.value[e] ?? !1, d = (e) => s.value[e] ?? !1, h = (e) => n.value.get(e);
15
20
  return {
16
21
  items: c(() => u(o)),
17
22
  index: n,
18
23
  selectedItems: s,
19
- expandedItems: f,
24
+ expandedItems: l,
20
25
  setSelected: p,
21
26
  setExpanded: v,
22
27
  isExpanded: x,
@@ -1,10 +1,14 @@
1
1
  /**
2
- * Generates a reverse index (Map) for fast lookups of entities by their IDs.
3
- * Also attaches a `parent` property to each node for easier upward traversal.
2
+ * Builds a reverse index for fast ID-based lookup and attaches a `parent` property to each node for upward traversal.
4
3
  *
5
- * @param items - The root array of entities to index.
6
- * @param nestedKey - The property name that contains child nodes (default: 'children').
7
- * @returns A Map where each key is an entity's `id` and the value is the entity (with optional `parent`).
4
+ * @template T - The node type (must include `id`).
5
+ * @template Key - The key pointing to nested children arrays (defaults to 'children').
6
+ *
7
+ * @param items - The root-level array of entities to index.
8
+ * @param nestedKey - The property name that contains child nodes within an entity (defaults to 'children').
9
+ * @param filter - Optional. A predicate to determine which nodes are included in the map (default: includes all).
10
+ * @param getId - Optional. A function to obtain the unique ID from a node (defaults to `node.id`).
11
+ * @returns A Map where each key is a node's ID and each value is the node, extended with an optional `parent` property.
8
12
  *
9
13
  * @example
10
14
  * const data = [
@@ -15,13 +19,18 @@
15
19
  * ]}
16
20
  * ]}
17
21
  * ];
18
- * const index = generateReverseIndex(data);
22
+ * const index = generateReverseIndex({ items: data });
19
23
  * // index.get('3') => { id: '3', name: 'Child 2', children: [...], parent: { id: '1', ... } }
20
24
  * // index.get('4') => { id: '4', name: 'Grandchild', parent: { id: '3', ... } }
21
25
  */
22
26
  export declare const generateReverseIndex: <T extends {
23
27
  id: string;
24
- } & Record<string, unknown>, Key extends string = "children">(items?: T[], nestedKey?: Key) => Map<string, T & {
28
+ } & Record<string, unknown>, Key extends string>({ items, nestedKey, filter, getId, }: {
29
+ items: T[];
30
+ nestedKey?: Key;
31
+ filter?: (node: T) => boolean;
32
+ getId?: (node: T) => string;
33
+ }) => Map<string, T & {
25
34
  parent?: T;
26
35
  }>;
27
36
  //# sourceMappingURL=generate-reverse-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-reverse-index.d.ts","sourceRoot":"","sources":["../../src/helpers/generate-reverse-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClD,GAAG,SAAS,MAAM,GAAG,UAAU,EAE/B,QAAO,CAAC,EAAO,EACf,YAAW,GAAuB;aAGa,CAAC;EAcjD,CAAA"}
1
+ {"version":3,"file":"generate-reverse-index.d.ts","sourceRoot":"","sources":["../../src/helpers/generate-reverse-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,SAAS,MAAM,EAAE,sCAK1G;IACD,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAA;IAC7B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAA;CAC5B;aAEgD,CAAC;EAgBjD,CAAA"}
@@ -1,9 +1,14 @@
1
- const s = (t = [], a = "children") => {
2
- const c = /* @__PURE__ */ new Map(), i = (r) => {
3
- c.set(r.id, r), a in r && Array.isArray(r[a]) && r[a]?.forEach((p) => i({ ...p, parent: r }));
1
+ const h = ({
2
+ items: c,
3
+ nestedKey: i = "children",
4
+ filter: f = () => !0,
5
+ getId: p = (a) => a.id
6
+ }) => {
7
+ const a = /* @__PURE__ */ new Map(), t = (r) => {
8
+ f(r) && a.set(p(r), r), i in r && Array.isArray(r[i]) && r[i]?.forEach((s) => t({ ...s, parent: r }));
4
9
  };
5
- return t.forEach(i), c;
10
+ return c.forEach(t), a;
6
11
  };
7
12
  export {
8
- s as generateReverseIndex
13
+ h as generateReverseIndex
9
14
  };
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/sidebar"
12
12
  },
13
- "version": "0.2.1",
13
+ "version": "0.3.0",
14
14
  "engines": {
15
15
  "node": ">=20"
16
16
  },
@@ -30,12 +30,12 @@
30
30
  "module": "./dist/index.js",
31
31
  "dependencies": {
32
32
  "vue": "^3.5.21",
33
- "@scalar/helpers": "0.0.13",
34
- "@scalar/components": "0.16.1",
33
+ "@scalar/components": "0.16.3",
35
34
  "@scalar/draggable": "0.3.0",
35
+ "@scalar/helpers": "0.1.1",
36
+ "@scalar/icons": "0.5.0",
36
37
  "@scalar/themes": "0.13.23",
37
- "@scalar/workspace-store": "0.18.1",
38
- "@scalar/icons": "0.5.0"
38
+ "@scalar/workspace-store": "0.20.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@tailwindcss/vite": "^4.1.7",
@@ -1,16 +0,0 @@
1
- /** Format options */
2
- type FormatOptions = {
3
- /**
4
- * The characters to allow wrapping on
5
- * @default /[\/-]/g - allow wrapping on "/" and "-"
6
- */
7
- wrapCharacters?: RegExp;
8
- };
9
- /**
10
- * Format the sidebar label
11
- *
12
- * Adds a zero-width space after the certain characters to allow improved * line wrapping in the sidebar. By default, it allows wrapping on "/" and * "-". To not add a zero-width space, pass an empty string for the * wrapCharacters option.
13
- */
14
- export declare const formatSidebarLabel: (label: string, opts?: FormatOptions) => string;
15
- export {};
16
- //# sourceMappingURL=format-sidebar-label.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-sidebar-label.d.ts","sourceRoot":"","sources":["../../src/helpers/format-sidebar-label.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,KAAK,aAAa,GAAG;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAcD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,EAAE,OAAM,aAAkB,KAAG,MAG5E,CAAA"}
@@ -1,9 +0,0 @@
1
- const e = {
2
- wrapCharacters: /[\/-]/g
3
- }, o = (r, a = {}) => {
4
- const { wrapCharacters: t } = { ...e, ...a };
5
- return r.replace(t, "​$&");
6
- };
7
- export {
8
- o as formatSidebarLabel
9
- };