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