@mantine-vue/code-highlight 3.5.0 → 3.7.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.
package/cjs/index.cjs CHANGED
@@ -9,7 +9,7 @@ var plainTextAdapter = { getHighlighter: () => ({ code }) => ({
9
9
  }) };
10
10
  //#endregion
11
11
  //#region src/CodeHighlightProvider/CodeHighlightAdapterProvider.vue?vue&type=script&setup=true&lang.ts
12
- var _hoisted_1$1 = { style: { "display": "contents" } };
12
+ var _hoisted_1$3 = { style: { "display": "contents" } };
13
13
  //#endregion
14
14
  //#region src/CodeHighlightProvider/CodeHighlightAdapterProvider.vue
15
15
  var CodeHighlightAdapterProvider_default = /* @__PURE__ */ (0, vue.defineComponent)({
@@ -64,7 +64,7 @@ var CodeHighlightAdapterProvider_default = /* @__PURE__ */ (0, vue.defineCompone
64
64
  isLanguageLoaded: (language) => !language || !props.adapter.loadLanguage || loadedLanguages.value.includes(language)
65
65
  });
66
66
  return (_ctx, _cache) => {
67
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$1, [(0, vue.renderSlot)(_ctx.$slots, "default")]);
67
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$3, [(0, vue.renderSlot)(_ctx.$slots, "default")]);
68
68
  };
69
69
  }
70
70
  });
@@ -90,7 +90,7 @@ var CodeHighlightAdapterProvider = CodeHighlightAdapterProvider_default;
90
90
  //#region src/normalize-code.ts
91
91
  /** Removes blank leading lines and trailing whitespace before highlighting or copying code. */
92
92
  function normalizeCode(code, { withFirstLineIndentation } = {}) {
93
- return withFirstLineIndentation ? code.replace(/^(?:[^\S\r\n]*\r?\n)+|\s+$/g, "") : code.trim();
93
+ return withFirstLineIndentation ? code.replace(/^(?:[^\S\r\n]*\r?\n)+/, "").trimEnd() : code.trim();
94
94
  }
95
95
  //#endregion
96
96
  //#region src/CodeHighlight/CodeHighlight.context.ts
@@ -290,13 +290,13 @@ var CodeHighlight_module_default = {
290
290
  };
291
291
  //#endregion
292
292
  //#region src/CodeHighlight/CodeHighlight.vue?vue&type=script&setup=true&lang.ts
293
- var _hoisted_1 = ["data-with-border", "innerHTML"];
294
- var _hoisted_2 = ["data-with-border"];
295
- var _hoisted_3 = ["data-with-offset"];
296
- var _hoisted_4 = ["data-with-offset"];
297
- var _hoisted_5 = ["data-with-offset"];
298
- var _hoisted_6 = ["innerHTML"];
299
- var varsResolver$1 = (0, _mantine_vue_core.createVarsResolver)((theme, { maxCollapsedHeight, background, radius }) => ({ codeHighlight: {
293
+ var _hoisted_1$2 = ["data-with-border", "innerHTML"];
294
+ var _hoisted_2$2 = ["data-with-border"];
295
+ var _hoisted_3$1 = ["data-with-offset"];
296
+ var _hoisted_4$1 = ["data-with-offset"];
297
+ var _hoisted_5$1 = ["data-with-offset"];
298
+ var _hoisted_6$1 = ["innerHTML"];
299
+ var varsResolver$2 = (0, _mantine_vue_core.createVarsResolver)((theme, { maxCollapsedHeight, background, radius }) => ({ codeHighlight: {
300
300
  "--ch-max-height": (0, _mantine_vue_core.rem)(maxCollapsedHeight),
301
301
  "--ch-background": background ? (0, _mantine_vue_core.getThemeColor)(background, theme) : void 0,
302
302
  "--ch-radius": typeof radius !== "undefined" ? (0, _mantine_vue_core.getRadius)(radius) : void 0
@@ -372,13 +372,12 @@ var CodeHighlight_default = /* @__PURE__ */ (0, vue.defineComponent)({
372
372
  name: props.__staticSelector || "CodeHighlight",
373
373
  classes: CodeHighlight_module_default,
374
374
  props,
375
- className: attrs.class,
376
- style: attrs.style,
375
+ attrs,
377
376
  classNames: props.classNames,
378
377
  styles: props.styles,
379
378
  vars: props.vars,
380
379
  unstyled: props.unstyled,
381
- varsResolver: varsResolver$1,
380
+ varsResolver: varsResolver$2,
382
381
  rootSelector: "codeHighlight"
383
382
  });
384
383
  const [expanded, setExpanded] = (0, _mantine_vue_hooks.useUncontrolled)({
@@ -431,14 +430,14 @@ var CodeHighlight_default = /* @__PURE__ */ (0, vue.defineComponent)({
431
430
  }, {
432
431
  "data-with-border": (0, vue.unref)(props).withBorder || void 0,
433
432
  innerHTML: highlighted.value.highlightedCode
434
- }), null, 16, _hoisted_1)) : (0, vue.unref)(props).__inline ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("code", (0, vue.mergeProps)({ key: 1 }, {
433
+ }), null, 16, _hoisted_1$2)) : (0, vue.unref)(props).__inline ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("code", (0, vue.mergeProps)({ key: 1 }, {
435
434
  ...(0, vue.unref)(attrs),
436
435
  ...highlighted.value.codeElementProps,
437
436
  ...(0, vue.unref)(getStyles)("codeHighlight", {
438
437
  className: [highlighted.value.codeElementProps?.class, (0, vue.unref)(attrs).class],
439
438
  style: [highlighted.value.codeElementProps?.style, (0, vue.unref)(attrs).style]
440
439
  })
441
- }, { "data-with-border": (0, vue.unref)(props).withBorder || void 0 }), (0, vue.toDisplayString)(normalizedCode.value), 17, _hoisted_2)) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Box), (0, vue.mergeProps)({ key: 2 }, {
440
+ }, { "data-with-border": (0, vue.unref)(props).withBorder || void 0 }), (0, vue.toDisplayString)(normalizedCode.value), 17, _hoisted_2$2)) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Box), (0, vue.mergeProps)({ key: 2 }, {
442
441
  ...(0, vue.unref)(attrs),
443
442
  ...(0, vue.unref)(getStyles)("codeHighlight")
444
443
  }, {
@@ -471,7 +470,7 @@ var CodeHighlight_default = /* @__PURE__ */ (0, vue.defineComponent)({
471
470
  "copied-label",
472
471
  "copy-label"
473
472
  ])) : (0, vue.createCommentVNode)("", true)
474
- ], 16, _hoisted_3)) : (0, vue.createCommentVNode)("", true),
473
+ ], 16, _hoisted_3$1)) : (0, vue.createCommentVNode)("", true),
475
474
  (0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.ScrollArea), (0, vue.mergeProps)({
476
475
  type: "hover",
477
476
  "scrollbar-size": 4,
@@ -482,19 +481,19 @@ var CodeHighlight_default = /* @__PURE__ */ (0, vue.defineComponent)({
482
481
  }, (0, vue.unref)(getStyles)("scrollarea")), {
483
482
  default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", (0, vue.normalizeProps)((0, vue.guardReactiveProps)((0, vue.unref)(getStyles)("codeWrapper"))), [(0, vue.unref)(props).withLineNumbers ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({ key: 0 }, (0, vue.unref)(getStyles)("lineNumbers"), { "data-with-offset": (0, vue.unref)(props).__withOffset || void 0 }), [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(lineNumbers.value, (line) => {
484
483
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { key: line }, (0, vue.toDisplayString)(line), 1);
485
- }), 128))], 16, _hoisted_4)) : (0, vue.createCommentVNode)("", true), (0, vue.createElementVNode)("pre", (0, vue.mergeProps)((0, vue.unref)(getStyles)("pre"), { "data-with-offset": (0, vue.unref)(props).__withOffset || void 0 }), [highlighted.value.isHighlighted ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("code", (0, vue.mergeProps)({ key: 0 }, {
484
+ }), 128))], 16, _hoisted_4$1)) : (0, vue.createCommentVNode)("", true), (0, vue.createElementVNode)("pre", (0, vue.mergeProps)((0, vue.unref)(getStyles)("pre"), { "data-with-offset": (0, vue.unref)(props).__withOffset || void 0 }), [highlighted.value.isHighlighted ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("code", (0, vue.mergeProps)({ key: 0 }, {
486
485
  ...highlighted.value.codeElementProps,
487
486
  ...(0, vue.unref)(getStyles)("code", {
488
487
  className: highlighted.value.codeElementProps?.class,
489
488
  style: highlighted.value.codeElementProps?.style
490
489
  })
491
- }, { innerHTML: highlighted.value.highlightedCode }), null, 16, _hoisted_6)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("code", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, {
490
+ }, { innerHTML: highlighted.value.highlightedCode }), null, 16, _hoisted_6$1)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("code", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, {
492
491
  ...highlighted.value.codeElementProps,
493
492
  ...(0, vue.unref)(getStyles)("code", {
494
493
  className: highlighted.value.codeElementProps?.class,
495
494
  style: highlighted.value.codeElementProps?.style
496
495
  })
497
- })), (0, vue.toDisplayString)(normalizedCode.value), 17))], 16, _hoisted_5)], 16)]),
496
+ })), (0, vue.toDisplayString)(normalizedCode.value), 17))], 16, _hoisted_5$1)], 16)]),
498
497
  _: 1
499
498
  }, 16, ["data-collapsed"]),
500
499
  (0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)((0, vue.unref)(getStyles)("showCodeButton"), {
@@ -515,12 +514,12 @@ var CodeHighlight_default = /* @__PURE__ */ (0, vue.defineComponent)({
515
514
  //#region src/CodeHighlight/CodeHighlight.ts
516
515
  var CodeHighlight = Object.assign(CodeHighlight_default, {
517
516
  classes: CodeHighlight_module_default,
518
- varsResolver: varsResolver$1,
517
+ varsResolver: varsResolver$2,
519
518
  Control: CodeHighlightControl_default
520
519
  });
521
520
  //#endregion
522
521
  //#region src/CodeHighlight/InlineCodeHighlight.vue?vue&type=script&setup=true&lang.ts
523
- var varsResolver = (0, _mantine_vue_core.createVarsResolver)((theme, { background, radius }) => ({ inlineCodeHighlight: {
522
+ var varsResolver$1 = (0, _mantine_vue_core.createVarsResolver)((theme, { background, radius }) => ({ inlineCodeHighlight: {
524
523
  "--ch-background": background ? (0, _mantine_vue_core.getThemeColor)(background, theme) : void 0,
525
524
  "--ch-radius": typeof radius !== "undefined" ? (0, _mantine_vue_core.getRadius)(radius) : void 0
526
525
  } }));
@@ -552,13 +551,12 @@ var InlineCodeHighlight = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)
552
551
  name: "InlineCodeHighlight",
553
552
  classes: CodeHighlight_module_default,
554
553
  props,
555
- className: attrs.class,
556
- style: attrs.style,
554
+ attrs,
557
555
  classNames: props.classNames,
558
556
  styles: props.styles,
559
557
  unstyled: props.unstyled,
560
558
  vars: props.vars,
561
- varsResolver,
559
+ varsResolver: varsResolver$1,
562
560
  rootSelector: "inlineCodeHighlight"
563
561
  });
564
562
  return (_ctx, _cache) => {
@@ -571,7 +569,7 @@ var InlineCodeHighlight = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)
571
569
  }
572
570
  }), {
573
571
  classes: CodeHighlight_module_default,
574
- varsResolver
572
+ varsResolver: varsResolver$1
575
573
  });
576
574
  //#endregion
577
575
  //#region src/CodeHighlightTabs/FileIcon.vue
@@ -669,8 +667,7 @@ var CodeHighlightTabs = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)({
669
667
  name: "CodeHighlightTabs",
670
668
  classes: CodeHighlight_module_default,
671
669
  props,
672
- className: attrs.class,
673
- style: attrs.style,
670
+ attrs,
674
671
  classNames: props.classNames,
675
672
  styles: props.styles,
676
673
  unstyled: props.unstyled,
@@ -791,6 +788,711 @@ var CodeHighlightTabs = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)({
791
788
  }
792
789
  }), { classes: CodeHighlight_module_default });
793
790
  //#endregion
791
+ //#region src/JsonViewer/json-viewer-utils.ts
792
+ var PATH_SEPARATOR = "\0";
793
+ var serializePath = (segments) => segments.join("\0");
794
+ function getArrayChunks(length, groupArraysAfterLength) {
795
+ if (groupArraysAfterLength === false) return null;
796
+ const size = Math.floor(groupArraysAfterLength);
797
+ if (!(size >= 1) || length <= groupArraysAfterLength) return null;
798
+ const chunks = [];
799
+ for (let start = 0; start < length; start += size) chunks.push({
800
+ start,
801
+ end: Math.min(start + size, length) - 1
802
+ });
803
+ return chunks;
804
+ }
805
+ var getChunkSegment = (chunk) => `[${chunk.start}...${chunk.end}]`;
806
+ function resolveDisplayValue(value) {
807
+ if (value !== null && typeof value === "object" && typeof value.toJSON === "function") try {
808
+ return value.toJSON();
809
+ } catch {
810
+ return value;
811
+ }
812
+ return value;
813
+ }
814
+ var isExpandableValue = (value) => value !== null && typeof value === "object";
815
+ var getEntries = (value) => Array.isArray(value) ? value.map((item, index) => [String(index), item]) : Object.entries(value);
816
+ function getExpandablePaths(value, { depth = Infinity, groupArraysAfterLength = false } = {}) {
817
+ const paths = [];
818
+ const ancestors = /* @__PURE__ */ new WeakSet();
819
+ const visit = (node, path, level) => {
820
+ const resolved = resolveDisplayValue(node);
821
+ if (!isExpandableValue(resolved) || ancestors.has(resolved) || level > depth) return;
822
+ const entries = getEntries(resolved);
823
+ if (!entries.length) return;
824
+ if (path.length) paths.push(serializePath(path));
825
+ ancestors.add(resolved);
826
+ const chunks = Array.isArray(resolved) ? getArrayChunks(entries.length, groupArraysAfterLength) : null;
827
+ if (chunks && level + 1 <= depth) for (const chunk of chunks) {
828
+ paths.push(serializePath([...path, getChunkSegment(chunk)]));
829
+ entries.slice(chunk.start, chunk.end + 1).forEach(([key, child]) => visit(child, [...path, key], level + 2));
830
+ }
831
+ else entries.forEach(([key, child]) => visit(child, [...path, key], level + 1));
832
+ ancestors.delete(resolved);
833
+ };
834
+ visit(value, [], 1);
835
+ return paths;
836
+ }
837
+ function getValueType(value) {
838
+ return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
839
+ }
840
+ function getTypeLabel(value) {
841
+ const type = getValueType(value);
842
+ return type === "number" ? Number.isInteger(value) ? "int" : "float" : type === "boolean" ? "bool" : type;
843
+ }
844
+ function formatValue(value, withQuotes, collapseStringsAfterLength) {
845
+ if (value === null) return {
846
+ display: "null",
847
+ collapsed: false
848
+ };
849
+ if (value === void 0) return {
850
+ display: "undefined",
851
+ collapsed: false
852
+ };
853
+ if (typeof value !== "string") return {
854
+ display: String(value),
855
+ collapsed: false
856
+ };
857
+ if (collapseStringsAfterLength !== false && value.length > collapseStringsAfterLength) {
858
+ const splitsPair = /^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(value.slice(collapseStringsAfterLength - 1));
859
+ const truncated = value.slice(0, collapseStringsAfterLength - (splitsPair ? 1 : 0));
860
+ return {
861
+ display: withQuotes ? `${JSON.stringify(truncated).slice(0, -1)}..."` : `${truncated}...`,
862
+ collapsed: true
863
+ };
864
+ }
865
+ return {
866
+ display: withQuotes ? JSON.stringify(value) : value,
867
+ collapsed: false
868
+ };
869
+ }
870
+ function safeStringify(value) {
871
+ const ancestors = [];
872
+ try {
873
+ return JSON.stringify(value, function(_key, item) {
874
+ if (typeof item === "bigint") return item.toString();
875
+ if (typeof item !== "object" || item === null) return item;
876
+ while (ancestors.length && ancestors.at(-1) !== this) ancestors.pop();
877
+ if (ancestors.includes(item)) return "[Circular]";
878
+ ancestors.push(item);
879
+ return item;
880
+ }, 2) ?? String(value);
881
+ } catch {
882
+ return String(value);
883
+ }
884
+ }
885
+ //#endregion
886
+ //#region src/JsonViewer/JsonViewerNode.vue?vue&type=script&setup=true&lang.ts
887
+ var _hoisted_1$1 = ["data-type", "data-highlight"];
888
+ var _hoisted_2$1 = [
889
+ "aria-expanded",
890
+ "aria-level",
891
+ "data-root",
892
+ "tabindex"
893
+ ];
894
+ var _hoisted_3 = ["data-expanded"];
895
+ var _hoisted_4 = ["data-value-type"];
896
+ var _hoisted_5 = {
897
+ key: 0,
898
+ viewBox: "0 0 16 16",
899
+ width: "14",
900
+ height: "14",
901
+ fill: "currentColor"
902
+ };
903
+ var _hoisted_6 = {
904
+ key: 1,
905
+ viewBox: "0 0 16 16",
906
+ width: "14",
907
+ height: "14",
908
+ fill: "currentColor"
909
+ };
910
+ var _hoisted_7 = {
911
+ role: "group",
912
+ style: { paddingLeft: "var(--jv-indent)" }
913
+ };
914
+ var _hoisted_8 = ["data-type", "data-highlight"];
915
+ var _hoisted_9 = [
916
+ "aria-level",
917
+ "data-root",
918
+ "tabindex"
919
+ ];
920
+ var _hoisted_10 = ["data-value-type", "data-wrap"];
921
+ var _hoisted_11 = ["data-value-type"];
922
+ var _hoisted_12 = {
923
+ key: 0,
924
+ viewBox: "0 0 16 16",
925
+ width: "14",
926
+ height: "14",
927
+ fill: "currentColor"
928
+ };
929
+ var _hoisted_13 = {
930
+ key: 1,
931
+ viewBox: "0 0 16 16",
932
+ width: "14",
933
+ height: "14",
934
+ fill: "currentColor"
935
+ };
936
+ //#endregion
937
+ //#region src/JsonViewer/JsonViewerNode.vue
938
+ var JsonViewerNode_default = /* @__PURE__ */ (0, vue.defineComponent)({
939
+ name: "JsonViewerNode",
940
+ __name: "JsonViewerNode",
941
+ props: {
942
+ value: {},
943
+ path: {},
944
+ nodeKey: {},
945
+ level: {},
946
+ ancestors: {},
947
+ expandedPaths: {},
948
+ togglePath: { type: Function },
949
+ getStyles: {},
950
+ maxDisplayLength: {},
951
+ withTypes: { type: Boolean },
952
+ withSize: { type: Boolean },
953
+ withCopy: { type: Boolean },
954
+ withQuotes: { type: Boolean },
955
+ withKeyQuotes: { type: Boolean },
956
+ collapseStringsAfterLength: { type: [Number, Boolean] },
957
+ sortKeys: { type: [Boolean, Function] },
958
+ groupArraysAfterLength: { type: [Number, Boolean] },
959
+ copyLabel: {},
960
+ copiedLabel: {},
961
+ onValueSelect: { type: Function },
962
+ highlightItems: {},
963
+ allExpanded: { type: Boolean },
964
+ withChevrons: { type: Boolean },
965
+ isRoot: { type: Boolean },
966
+ chunk: {},
967
+ chunkEntries: {}
968
+ },
969
+ setup(__props) {
970
+ const props = __props;
971
+ const { copy: copyToClipboard, copied } = (0, _mantine_vue_hooks.useClipboard)({ timeout: 1e3 });
972
+ const stringExpanded = (0, vue.ref)(false);
973
+ const resolved = (0, vue.computed)(() => props.chunk ? props.chunkEntries : resolveDisplayValue(props.value));
974
+ const circular = (0, vue.computed)(() => !props.chunk && isExpandableValue(resolved.value) && props.ancestors.includes(resolved.value));
975
+ const expandable = (0, vue.computed)(() => props.chunk || !circular.value && isExpandableValue(resolved.value));
976
+ const array = (0, vue.computed)(() => props.chunk || Array.isArray(resolved.value));
977
+ const pathString = (0, vue.computed)(() => serializePath(props.path));
978
+ const entries = (0, vue.computed)(() => {
979
+ if (props.chunk) return props.chunkEntries ?? [];
980
+ if (!expandable.value) return [];
981
+ const result = getEntries(resolved.value);
982
+ if (!array.value && props.sortKeys) {
983
+ const compare = typeof props.sortKeys === "function" ? props.sortKeys : (a, b) => a.localeCompare(b);
984
+ result.sort((a, b) => compare(a[0], b[0]));
985
+ }
986
+ return result;
987
+ });
988
+ const empty = (0, vue.computed)(() => expandable.value && entries.value.length === 0);
989
+ const expanded = (0, vue.computed)(() => !empty.value && (props.isRoot || props.allExpanded || props.expandedPaths.includes(pathString.value)));
990
+ const canCollapse = (0, vue.computed)(() => !empty.value && !props.isRoot && !props.allExpanded);
991
+ const chunks = (0, vue.computed)(() => !props.chunk && array.value ? getArrayChunks(entries.value.length, props.groupArraysAfterLength) : null);
992
+ const shownEntries = (0, vue.computed)(() => chunks.value ? entries.value : entries.value.slice(0, props.maxDisplayLength));
993
+ const primitiveType = (0, vue.computed)(() => circular.value ? "circular" : getValueType(resolved.value));
994
+ const shouldCollapseString = (0, vue.computed)(() => typeof resolved.value === "string" && props.collapseStringsAfterLength !== false && resolved.value.length > props.collapseStringsAfterLength);
995
+ const formatted = (0, vue.computed)(() => circular.value ? {
996
+ display: "[Circular]",
997
+ collapsed: false
998
+ } : formatValue(resolved.value, props.withQuotes, stringExpanded.value ? false : props.collapseStringsAfterLength));
999
+ const openBracket = (0, vue.computed)(() => array.value ? "[" : "{");
1000
+ const closeBracket = (0, vue.computed)(() => array.value ? "]" : "}");
1001
+ const childAncestors = (0, vue.computed)(() => props.chunk ? props.ancestors : [...props.ancestors, resolved.value]);
1002
+ function toggle() {
1003
+ if (canCollapse.value) props.togglePath(pathString.value);
1004
+ }
1005
+ function copy(event) {
1006
+ event.stopPropagation();
1007
+ copyToClipboard(safeStringify(resolved.value));
1008
+ }
1009
+ function select(event) {
1010
+ event?.stopPropagation();
1011
+ props.onValueSelect?.(props.path, resolved.value);
1012
+ }
1013
+ function stopCopyKeydown(event) {
1014
+ if (event.key === "Enter" || event.key === " ") event.stopPropagation();
1015
+ }
1016
+ function focusSibling(row, direction) {
1017
+ const root = row.closest("[data-jv-root]");
1018
+ const rows = Array.from(root?.querySelectorAll("[data-jv-node]") ?? []);
1019
+ rows[rows.indexOf(row) + direction]?.focus();
1020
+ }
1021
+ function onKeydown(event) {
1022
+ const row = event.currentTarget;
1023
+ if ((event.ctrlKey || event.metaKey) && event.code === "KeyC" && !window.getSelection()?.toString()) {
1024
+ event.preventDefault();
1025
+ row.querySelector("[data-jv-copy]")?.click();
1026
+ return;
1027
+ }
1028
+ if (event.key === "Enter" || event.key === " ") {
1029
+ if (event.target !== row) return;
1030
+ event.preventDefault();
1031
+ if (expandable.value) toggle();
1032
+ else select();
1033
+ return;
1034
+ }
1035
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1036
+ event.preventDefault();
1037
+ focusSibling(row, event.key === "ArrowDown" ? 1 : -1);
1038
+ return;
1039
+ }
1040
+ if (event.key === "ArrowRight") {
1041
+ event.preventDefault();
1042
+ if (expanded.value) row.parentElement?.querySelector(":scope > [role=\"group\"] [data-jv-node]")?.focus();
1043
+ else toggle();
1044
+ return;
1045
+ }
1046
+ if (event.key === "ArrowLeft") {
1047
+ event.preventDefault();
1048
+ if (expanded.value && canCollapse.value) toggle();
1049
+ else row.parentElement?.parentElement?.closest("[data-jv-node-wrapper]")?.querySelector(":scope > [data-jv-node]")?.focus();
1050
+ }
1051
+ }
1052
+ return (_ctx, _cache) => {
1053
+ const _component_JsonViewerNode = (0, vue.resolveComponent)("JsonViewerNode", true);
1054
+ return expandable.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({ key: 0 }, props.getStyles("node"), {
1055
+ "data-jv-node-wrapper": "",
1056
+ "data-type": array.value ? "array" : "object",
1057
+ "data-highlight": props.highlightItems?.[pathString.value]
1058
+ }), [(0, vue.createElementVNode)("div", (0, vue.mergeProps)(props.getStyles("row"), {
1059
+ role: "treeitem",
1060
+ "aria-expanded": empty.value ? void 0 : expanded.value,
1061
+ "aria-level": props.level,
1062
+ "data-jv-node": "",
1063
+ "data-jv-row": "",
1064
+ "data-hoverable": "",
1065
+ "data-root": props.isRoot || void 0,
1066
+ tabindex: props.isRoot ? 0 : -1,
1067
+ onClick: (0, vue.withModifiers)(toggle, ["stop"]),
1068
+ onKeydown
1069
+ }), [
1070
+ canCollapse.value && props.withChevrons ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.mergeProps)({ key: 0 }, props.getStyles("toggle"), { "data-expanded": expanded.value || void 0 }), [..._cache[1] || (_cache[1] = [(0, vue.createElementVNode)("svg", {
1071
+ viewBox: "0 0 16 16",
1072
+ width: "12",
1073
+ height: "12",
1074
+ fill: "currentColor"
1075
+ }, [(0, vue.createElementVNode)("path", { d: "M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z" })], -1)])], 16, _hoisted_3)) : (0, vue.createCommentVNode)("", true),
1076
+ props.nodeKey !== void 0 || props.chunk ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.mergeProps)({ key: 1 }, props.getStyles("key"), { "data-key": "" }), [(0, vue.createTextVNode)((0, vue.toDisplayString)(props.chunk ? (0, vue.unref)(getChunkSegment)(props.chunk) : props.withKeyQuotes ? JSON.stringify(props.nodeKey) : props.nodeKey), 1), !props.chunk ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [(0, vue.createTextVNode)(": ")], 64)) : (0, vue.createCommentVNode)("", true)], 16)) : (0, vue.createCommentVNode)("", true),
1077
+ (0, vue.createElementVNode)("span", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(props.getStyles("bracket"))), (0, vue.toDisplayString)(openBracket.value), 17),
1078
+ !empty.value && !expanded.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 2 }, props.getStyles("ellipsis"))), "...", 16)) : (0, vue.createCommentVNode)("", true),
1079
+ empty.value || !expanded.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 3 }, props.getStyles("bracket"))), (0, vue.toDisplayString)(closeBracket.value), 17)) : (0, vue.createCommentVNode)("", true),
1080
+ props.withTypes ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.mergeProps)({ key: 4 }, props.getStyles("type"), { "data-value-type": array.value ? "array" : "object" }), (0, vue.toDisplayString)(array.value ? "array" : "object"), 17, _hoisted_4)) : (0, vue.createCommentVNode)("", true),
1081
+ props.withSize ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 5 }, props.getStyles("size"))), (0, vue.toDisplayString)(entries.value.length) + " " + (0, vue.toDisplayString)(array.value ? "items" : "keys"), 17)) : (0, vue.createCommentVNode)("", true),
1082
+ props.withCopy && !props.chunk ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Tooltip), {
1083
+ key: 6,
1084
+ label: (0, vue.unref)(copied) ? props.copiedLabel : props.copyLabel,
1085
+ position: "top",
1086
+ fz: "xs"
1087
+ }, {
1088
+ default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)({
1089
+ tabindex: "-1",
1090
+ "data-jv-copy": ""
1091
+ }, props.getStyles("copyButton"), {
1092
+ "aria-label": (0, vue.unref)(copied) ? props.copiedLabel : props.copyLabel,
1093
+ onClick: copy,
1094
+ onKeydown: stopCopyKeydown
1095
+ }), {
1096
+ default: (0, vue.withCtx)(() => [(0, vue.unref)(copied) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", _hoisted_5, [..._cache[2] || (_cache[2] = [(0, vue.createElementVNode)("path", { d: "M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" }, null, -1)])])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", _hoisted_6, [..._cache[3] || (_cache[3] = [(0, vue.createElementVNode)("path", { d: "M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" }, null, -1), (0, vue.createElementVNode)("path", { d: "M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" }, null, -1)])]))]),
1097
+ _: 1
1098
+ }, 16, ["aria-label"])]),
1099
+ _: 1
1100
+ }, 8, ["label"])) : (0, vue.createCommentVNode)("", true)
1101
+ ], 16, _hoisted_2$1), expanded.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [(0, vue.createElementVNode)("div", _hoisted_7, [
1102
+ ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(chunks.value, (chunkItem) => {
1103
+ return (0, vue.openBlock)(), (0, vue.createBlock)(_component_JsonViewerNode, (0, vue.mergeProps)({ key: chunkItem.start }, { ref_for: true }, props, {
1104
+ path: [...props.path, (0, vue.unref)(getChunkSegment)(chunkItem)],
1105
+ level: props.level + 1,
1106
+ ancestors: childAncestors.value,
1107
+ chunk: chunkItem,
1108
+ "chunk-entries": entries.value.slice(chunkItem.start, chunkItem.end + 1),
1109
+ "is-root": false
1110
+ }), null, 16, [
1111
+ "path",
1112
+ "level",
1113
+ "ancestors",
1114
+ "chunk",
1115
+ "chunk-entries"
1116
+ ]);
1117
+ }), 128)),
1118
+ ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(chunks.value ? [] : shownEntries.value, ([key, item]) => {
1119
+ return (0, vue.openBlock)(), (0, vue.createBlock)(_component_JsonViewerNode, (0, vue.mergeProps)({ key }, { ref_for: true }, props, {
1120
+ value: item,
1121
+ path: props.chunk ? [...props.path.slice(0, -1), key] : [...props.path, key],
1122
+ "node-key": array.value ? void 0 : key,
1123
+ level: props.level + 1,
1124
+ ancestors: childAncestors.value,
1125
+ chunk: void 0,
1126
+ "chunk-entries": void 0,
1127
+ "is-root": false
1128
+ }), null, 16, [
1129
+ "value",
1130
+ "path",
1131
+ "node-key",
1132
+ "level",
1133
+ "ancestors"
1134
+ ]);
1135
+ }), 128)),
1136
+ !chunks.value && entries.value.length > props.maxDisplayLength ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({ key: 0 }, props.getStyles("row"), { "data-jv-row": "" }), [(0, vue.createElementVNode)("span", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(props.getStyles("size"))), "... " + (0, vue.toDisplayString)(entries.value.length - props.maxDisplayLength) + " more " + (0, vue.toDisplayString)(array.value ? "items" : "keys"), 17)], 16)) : (0, vue.createCommentVNode)("", true)
1137
+ ]), (0, vue.createElementVNode)("div", (0, vue.mergeProps)(props.getStyles("row"), {
1138
+ "data-jv-row": "",
1139
+ "aria-hidden": "true"
1140
+ }), [(0, vue.createElementVNode)("span", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(props.getStyles("bracket"))), (0, vue.toDisplayString)(closeBracket.value), 17)], 16)], 64)) : (0, vue.createCommentVNode)("", true)], 16, _hoisted_1$1)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({ key: 1 }, props.getStyles("node"), {
1141
+ "data-jv-node-wrapper": "",
1142
+ "data-type": primitiveType.value,
1143
+ "data-highlight": props.highlightItems?.[pathString.value]
1144
+ }), [(0, vue.createElementVNode)("div", (0, vue.mergeProps)(props.getStyles("row"), {
1145
+ role: "treeitem",
1146
+ "aria-level": props.level,
1147
+ "data-jv-node": "",
1148
+ "data-jv-row": "",
1149
+ "data-hoverable": "",
1150
+ "data-root": props.isRoot || void 0,
1151
+ tabindex: props.isRoot ? 0 : -1,
1152
+ onClick: select,
1153
+ onKeydown
1154
+ }), [
1155
+ props.nodeKey !== void 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 0 }, props.getStyles("key"))), (0, vue.toDisplayString)(props.withKeyQuotes ? JSON.stringify(props.nodeKey) : props.nodeKey) + ": ", 17)) : (0, vue.createCommentVNode)("", true),
1156
+ (0, vue.createElementVNode)("span", (0, vue.mergeProps)(props.getStyles("value"), {
1157
+ "data-value-type": primitiveType.value,
1158
+ "data-wrap": primitiveType.value === "string" && formatted.value.display.length > 20 ? true : void 0
1159
+ }), (0, vue.toDisplayString)(formatted.value.display), 17, _hoisted_10),
1160
+ shouldCollapseString.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)({ key: 1 }, props.getStyles("ellipsis"), {
1161
+ "aria-expanded": stringExpanded.value,
1162
+ "data-clickable": "",
1163
+ onClick: _cache[0] || (_cache[0] = (0, vue.withModifiers)(($event) => stringExpanded.value = !stringExpanded.value, ["stop"]))
1164
+ }), {
1165
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)(stringExpanded.value ? "show less" : "show more"), 1)]),
1166
+ _: 1
1167
+ }, 16, ["aria-expanded"])) : (0, vue.createCommentVNode)("", true),
1168
+ props.withTypes ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", (0, vue.mergeProps)({ key: 2 }, props.getStyles("type"), { "data-value-type": primitiveType.value }), (0, vue.toDisplayString)(circular.value ? "circular" : (0, vue.unref)(getTypeLabel)(resolved.value)), 17, _hoisted_11)) : (0, vue.createCommentVNode)("", true),
1169
+ props.withCopy ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Tooltip), {
1170
+ key: 3,
1171
+ label: (0, vue.unref)(copied) ? props.copiedLabel : props.copyLabel,
1172
+ position: "top",
1173
+ fz: "xs"
1174
+ }, {
1175
+ default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)({
1176
+ tabindex: "-1",
1177
+ "data-jv-copy": ""
1178
+ }, props.getStyles("copyButton"), {
1179
+ "aria-label": (0, vue.unref)(copied) ? props.copiedLabel : props.copyLabel,
1180
+ onClick: copy,
1181
+ onKeydown: stopCopyKeydown
1182
+ }), {
1183
+ default: (0, vue.withCtx)(() => [(0, vue.unref)(copied) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", _hoisted_12, [..._cache[4] || (_cache[4] = [(0, vue.createElementVNode)("path", { d: "M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" }, null, -1)])])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", _hoisted_13, [..._cache[5] || (_cache[5] = [(0, vue.createElementVNode)("path", { d: "M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" }, null, -1), (0, vue.createElementVNode)("path", { d: "M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" }, null, -1)])]))]),
1184
+ _: 1
1185
+ }, 16, ["aria-label"])]),
1186
+ _: 1
1187
+ }, 8, ["label"])) : (0, vue.createCommentVNode)("", true)
1188
+ ], 16, _hoisted_9)], 16, _hoisted_8));
1189
+ };
1190
+ }
1191
+ });
1192
+ var JsonViewer_module_default = {
1193
+ root: "_root_z2quo_1",
1194
+ controls: "_controls_z2quo_34",
1195
+ copyAllButton: "_copyAllButton_z2quo_41",
1196
+ control: "_control_z2quo_34",
1197
+ scrollarea: "_scrollarea_z2quo_81",
1198
+ content: "_content_z2quo_85",
1199
+ wrapper: "_wrapper_z2quo_89",
1200
+ lineNumbers: "_lineNumbers_z2quo_95",
1201
+ node: "_node_z2quo_132",
1202
+ row: "_row_z2quo_135",
1203
+ toggle: "_toggle_z2quo_142",
1204
+ copyButton: "_copyButton_z2quo_197",
1205
+ key: "_key_z2quo_253",
1206
+ value: "_value_z2quo_266",
1207
+ bracket: "_bracket_z2quo_340",
1208
+ type: "_type_z2quo_350",
1209
+ size: "_size_z2quo_445",
1210
+ ellipsis: "_ellipsis_z2quo_460"
1211
+ };
1212
+ //#endregion
1213
+ //#region src/JsonViewer/JsonViewer.vue?vue&type=script&setup=true&lang.ts
1214
+ var _hoisted_1 = {
1215
+ xmlns: "http://www.w3.org/2000/svg",
1216
+ viewBox: "0 0 24 24",
1217
+ "stroke-width": "2",
1218
+ stroke: "currentColor",
1219
+ fill: "none",
1220
+ "stroke-linecap": "round",
1221
+ "stroke-linejoin": "round",
1222
+ width: "16",
1223
+ height: "16"
1224
+ };
1225
+ var _hoisted_2 = ["aria-label"];
1226
+ var varsResolver = (0, _mantine_vue_core.createVarsResolver)((_, { radius, fontSize, indentWidth }) => ({ root: {
1227
+ "--jv-radius": radius !== void 0 ? (0, _mantine_vue_core.getRadius)(radius) : void 0,
1228
+ "--jv-fz": fontSize !== void 0 ? (0, _mantine_vue_core.getFontSize)(fontSize) : void 0,
1229
+ "--jv-indent": indentWidth !== void 0 ? (0, _mantine_vue_core.rem)(indentWidth) : void 0
1230
+ } }));
1231
+ //#endregion
1232
+ //#region src/JsonViewer/JsonViewer.vue
1233
+ var JsonViewer_default = /* @__PURE__ */ (0, vue.defineComponent)({
1234
+ name: "JsonViewer",
1235
+ inheritAttrs: false,
1236
+ __name: "JsonViewer",
1237
+ props: {
1238
+ classNames: {},
1239
+ styles: {},
1240
+ vars: {},
1241
+ unstyled: {
1242
+ type: Boolean,
1243
+ default: false
1244
+ },
1245
+ value: {},
1246
+ rootName: {
1247
+ type: [String, Boolean],
1248
+ default: false
1249
+ },
1250
+ defaultExpandDepth: { default: 1 },
1251
+ expandedPaths: { default: void 0 },
1252
+ maxDisplayLength: { default: 100 },
1253
+ withTypes: {
1254
+ type: Boolean,
1255
+ default: false
1256
+ },
1257
+ withSize: {
1258
+ type: Boolean,
1259
+ default: false
1260
+ },
1261
+ withCopy: {
1262
+ type: Boolean,
1263
+ default: false
1264
+ },
1265
+ withCopyButton: {
1266
+ type: Boolean,
1267
+ default: false
1268
+ },
1269
+ withQuotes: {
1270
+ type: Boolean,
1271
+ default: true
1272
+ },
1273
+ withKeyQuotes: {
1274
+ type: Boolean,
1275
+ default: false
1276
+ },
1277
+ collapseStringsAfterLength: {
1278
+ type: [Number, Boolean],
1279
+ default: false
1280
+ },
1281
+ sortKeys: {
1282
+ type: [Boolean, Function],
1283
+ default: false
1284
+ },
1285
+ groupArraysAfterLength: {
1286
+ type: [Number, Boolean],
1287
+ default: false
1288
+ },
1289
+ radius: {},
1290
+ fontSize: {},
1291
+ indentWidth: { default: 16 },
1292
+ withBorder: {
1293
+ type: Boolean,
1294
+ default: false
1295
+ },
1296
+ copyLabel: { default: "Copy" },
1297
+ copiedLabel: { default: "Copied" },
1298
+ expandAllLabel: { default: "Expand all" },
1299
+ collapseAllLabel: { default: "Collapse all" },
1300
+ withControls: {
1301
+ type: Boolean,
1302
+ default: false
1303
+ },
1304
+ highlightItems: {},
1305
+ allExpanded: {
1306
+ type: Boolean,
1307
+ default: false
1308
+ },
1309
+ withLineNumbers: {
1310
+ type: Boolean,
1311
+ default: false
1312
+ },
1313
+ withChevrons: {
1314
+ type: Boolean,
1315
+ default: false
1316
+ }
1317
+ },
1318
+ emits: [
1319
+ "update:expandedPaths",
1320
+ "expandedPathsChange",
1321
+ "valueSelect"
1322
+ ],
1323
+ setup(__props, { emit: __emit }) {
1324
+ const rawProps = __props;
1325
+ const emit = __emit;
1326
+ const attrs = (0, vue.useAttrs)();
1327
+ const props = (0, _mantine_vue_core.useProps)("JsonViewer", null, rawProps);
1328
+ const [expanded, setExpanded] = (0, _mantine_vue_hooks.useUncontrolled)({
1329
+ value: () => props.expandedPaths,
1330
+ defaultValue: getExpandablePaths(props.value, {
1331
+ depth: props.defaultExpandDepth,
1332
+ groupArraysAfterLength: props.groupArraysAfterLength
1333
+ }),
1334
+ finalValue: [],
1335
+ onChange: (paths) => {
1336
+ emit("update:expandedPaths", paths);
1337
+ emit("expandedPathsChange", paths);
1338
+ }
1339
+ });
1340
+ function togglePath(path) {
1341
+ if (!props.allExpanded) setExpanded(expanded.value.includes(path) ? expanded.value.filter((item) => item !== path) : [...expanded.value, path]);
1342
+ }
1343
+ function expandAll() {
1344
+ setExpanded(getExpandablePaths(props.value, { groupArraysAfterLength: props.groupArraysAfterLength }));
1345
+ }
1346
+ function collapseAll() {
1347
+ setExpanded([]);
1348
+ }
1349
+ const getStyles = (0, _mantine_vue_core.useStyles)({
1350
+ name: "JsonViewer",
1351
+ classes: JsonViewer_module_default,
1352
+ props,
1353
+ attrs,
1354
+ classNames: props.classNames,
1355
+ styles: props.styles,
1356
+ vars: props.vars,
1357
+ unstyled: props.unstyled,
1358
+ varsResolver
1359
+ });
1360
+ const { copy: copyToClipboard, copied } = (0, _mantine_vue_hooks.useClipboard)();
1361
+ const content = (0, vue.ref)(null);
1362
+ const lineHeights = (0, vue.ref)([]);
1363
+ let observer;
1364
+ function syncLines() {
1365
+ lineHeights.value = props.withLineNumbers && content.value ? Array.from(content.value.querySelectorAll(":scope [data-jv-row]")).map((row) => row.getBoundingClientRect().height) : [];
1366
+ }
1367
+ (0, vue.watch)([
1368
+ expanded,
1369
+ () => props.allExpanded,
1370
+ () => props.value
1371
+ ], () => (0, vue.nextTick)(syncLines), { deep: true });
1372
+ (0, vue.onMounted)(() => {
1373
+ syncLines();
1374
+ if (content.value && typeof ResizeObserver !== "undefined") {
1375
+ observer = new ResizeObserver(syncLines);
1376
+ observer.observe(content.value);
1377
+ }
1378
+ });
1379
+ (0, vue.onBeforeUnmount)(() => observer?.disconnect());
1380
+ return (_ctx, _cache) => {
1381
+ return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Box), (0, vue.mergeProps)({
1382
+ ...(0, vue.unref)(attrs),
1383
+ ...(0, vue.unref)(getStyles)("root")
1384
+ }, {
1385
+ "data-with-border": (0, vue.unref)(props).withBorder || void 0,
1386
+ "data-jv-root": ""
1387
+ }), {
1388
+ default: (0, vue.withCtx)(() => [
1389
+ (0, vue.unref)(props).withCopyButton ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Tooltip), {
1390
+ key: 0,
1391
+ label: (0, vue.unref)(copied) ? (0, vue.unref)(props).copiedLabel : (0, vue.unref)(props).copyLabel,
1392
+ position: "left",
1393
+ fz: "xs"
1394
+ }, {
1395
+ default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)((0, vue.unref)(getStyles)("copyAllButton"), {
1396
+ "aria-label": (0, vue.unref)(copied) ? (0, vue.unref)(props).copiedLabel : `${(0, vue.unref)(props).copyLabel} JSON`,
1397
+ onClick: _cache[0] || (_cache[0] = ($event) => (0, vue.unref)(copyToClipboard)((0, vue.unref)(safeStringify)((0, vue.unref)(props).value)))
1398
+ }), {
1399
+ default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", _hoisted_1, [(0, vue.unref)(copied) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 0 }, [_cache[1] || (_cache[1] = (0, vue.createElementVNode)("path", {
1400
+ stroke: "none",
1401
+ d: "M0 0h24v24H0z",
1402
+ fill: "none"
1403
+ }, null, -1)), _cache[2] || (_cache[2] = (0, vue.createElementVNode)("path", { d: "M5 12l5 5l10 -10" }, null, -1))], 64)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [
1404
+ _cache[3] || (_cache[3] = (0, vue.createElementVNode)("path", {
1405
+ stroke: "none",
1406
+ d: "M0 0h24v24H0z",
1407
+ fill: "none"
1408
+ }, null, -1)),
1409
+ _cache[4] || (_cache[4] = (0, vue.createElementVNode)("path", { d: "M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z" }, null, -1)),
1410
+ _cache[5] || (_cache[5] = (0, vue.createElementVNode)("path", { d: "M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" }, null, -1))
1411
+ ], 64))]))]),
1412
+ _: 1
1413
+ }, 16, ["aria-label"])]),
1414
+ _: 1
1415
+ }, 8, ["label"])) : (0, vue.createCommentVNode)("", true),
1416
+ (0, vue.unref)(props).withControls && !(0, vue.unref)(props).allExpanded ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, (0, vue.unref)(getStyles)("controls"))), [(0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)((0, vue.unref)(getStyles)("control"), { onClick: expandAll }), {
1417
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(props).expandAllLabel), 1)]),
1418
+ _: 1
1419
+ }, 16), (0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.UnstyledButton), (0, vue.mergeProps)((0, vue.unref)(getStyles)("control"), { onClick: collapseAll }), {
1420
+ default: (0, vue.withCtx)(() => [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(props).collapseAllLabel), 1)]),
1421
+ _: 1
1422
+ }, 16)], 16)) : (0, vue.createCommentVNode)("", true),
1423
+ (0, vue.createVNode)((0, vue.unref)(_mantine_vue_core.ScrollArea), (0, vue.mergeProps)({
1424
+ type: "hover",
1425
+ "scrollbar-size": 4
1426
+ }, (0, vue.unref)(getStyles)("scrollarea")), {
1427
+ default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", (0, vue.normalizeProps)((0, vue.guardReactiveProps)((0, vue.unref)(getStyles)("wrapper"))), [(0, vue.unref)(props).withLineNumbers ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({ key: 0 }, (0, vue.unref)(getStyles)("lineNumbers"), { "aria-hidden": "true" }), [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(lineHeights.value, (height, index) => {
1428
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
1429
+ key: index,
1430
+ style: (0, vue.normalizeStyle)({ height: `${height}px` })
1431
+ }, (0, vue.toDisplayString)(index + 1), 5);
1432
+ }), 128))], 16)) : (0, vue.createCommentVNode)("", true), (0, vue.createElementVNode)("div", (0, vue.mergeProps)({ ref: (node) => content.value = node }, (0, vue.unref)(getStyles)("content"), {
1433
+ role: "tree",
1434
+ "aria-label": (0, vue.unref)(props).rootName || "JSON"
1435
+ }), [(0, vue.createVNode)(JsonViewerNode_default, {
1436
+ value: (0, vue.unref)(props).value,
1437
+ path: [],
1438
+ "node-key": (0, vue.unref)(props).rootName || void 0,
1439
+ level: 1,
1440
+ ancestors: [],
1441
+ "expanded-paths": (0, vue.unref)(expanded),
1442
+ "toggle-path": togglePath,
1443
+ "get-styles": (0, vue.unref)(getStyles),
1444
+ "max-display-length": (0, vue.unref)(props).maxDisplayLength,
1445
+ "with-types": (0, vue.unref)(props).withTypes,
1446
+ "with-size": (0, vue.unref)(props).withSize,
1447
+ "with-copy": (0, vue.unref)(props).withCopy,
1448
+ "with-quotes": (0, vue.unref)(props).withQuotes,
1449
+ "with-key-quotes": (0, vue.unref)(props).withKeyQuotes,
1450
+ "collapse-strings-after-length": (0, vue.unref)(props).collapseStringsAfterLength,
1451
+ "sort-keys": (0, vue.unref)(props).sortKeys,
1452
+ "group-arrays-after-length": (0, vue.unref)(props).groupArraysAfterLength,
1453
+ "copy-label": (0, vue.unref)(props).copyLabel,
1454
+ "copied-label": (0, vue.unref)(props).copiedLabel,
1455
+ "on-value-select": (path, value) => emit("valueSelect", path, value),
1456
+ "highlight-items": (0, vue.unref)(props).highlightItems,
1457
+ "all-expanded": (0, vue.unref)(props).allExpanded,
1458
+ "with-chevrons": (0, vue.unref)(props).withChevrons,
1459
+ "is-root": ""
1460
+ }, null, 8, [
1461
+ "value",
1462
+ "node-key",
1463
+ "expanded-paths",
1464
+ "get-styles",
1465
+ "max-display-length",
1466
+ "with-types",
1467
+ "with-size",
1468
+ "with-copy",
1469
+ "with-quotes",
1470
+ "with-key-quotes",
1471
+ "collapse-strings-after-length",
1472
+ "sort-keys",
1473
+ "group-arrays-after-length",
1474
+ "copy-label",
1475
+ "copied-label",
1476
+ "on-value-select",
1477
+ "highlight-items",
1478
+ "all-expanded",
1479
+ "with-chevrons"
1480
+ ])], 16, _hoisted_2)], 16)]),
1481
+ _: 1
1482
+ }, 16)
1483
+ ]),
1484
+ _: 1
1485
+ }, 16, ["data-with-border"]);
1486
+ };
1487
+ }
1488
+ });
1489
+ //#endregion
1490
+ //#region src/JsonViewer/JsonViewer.ts
1491
+ var JsonViewer = (0, _mantine_vue_core.factory)(JsonViewer_default, {
1492
+ classes: JsonViewer_module_default,
1493
+ varsResolver
1494
+ });
1495
+ //#endregion
794
1496
  //#region src/CodeHighlightProvider/adapters/highlight-js-adapter.ts
795
1497
  function createHighlightJsAdapter(hljs) {
796
1498
  return { getHighlighter: () => ({ code, language }) => {
@@ -2018,10 +2720,16 @@ exports.CodeHighlightAdapterProvider = CodeHighlightAdapterProvider;
2018
2720
  exports.CodeHighlightControl = CodeHighlightControl_default;
2019
2721
  exports.CodeHighlightTabs = CodeHighlightTabs;
2020
2722
  exports.InlineCodeHighlight = InlineCodeHighlight;
2723
+ exports.JsonViewer = JsonViewer;
2724
+ exports.PATH_SEPARATOR = PATH_SEPARATOR;
2021
2725
  exports.createHighlightJsAdapter = createHighlightJsAdapter;
2022
2726
  exports.createShikiAdapter = createShikiAdapter;
2727
+ exports.getExpandablePaths = getExpandablePaths;
2023
2728
  exports.normalizeCode = normalizeCode;
2024
2729
  exports.plainTextAdapter = plainTextAdapter;
2730
+ exports.safeStringify = safeStringify;
2731
+ exports.serializeJsonViewerPath = serializePath;
2732
+ exports.serializePath = serializePath;
2025
2733
  exports.stripShikiCodeBlocks = stripShikiCodeBlocks;
2026
2734
  exports.useCodeHighlightContext = useCodeHighlightContext;
2027
2735
  exports.useHighlight = useHighlight;