@maxax/ui 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/basic-button-group/components/ButtonGroupItem.vue.d.ts.map +1 -1
- package/dist/components/basic-edit-batch/components/EditBatchItem.vue.d.ts.map +1 -1
- package/dist/components/basic-form/components/FormItem.vue.d.ts.map +1 -1
- package/dist/components/basic-json-viewer/BasicJsonViewer.d.ts +331 -0
- package/dist/components/basic-json-viewer/BasicJsonViewer.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/components/Brackets.d.ts +24 -0
- package/dist/components/basic-json-viewer/components/Brackets.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/components/Carets.d.ts +24 -0
- package/dist/components/basic-json-viewer/components/Carets.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/components/CheckController.d.ts +34 -0
- package/dist/components/basic-json-viewer/components/CheckController.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/components/TreeNode.d.ts +362 -0
- package/dist/components/basic-json-viewer/components/TreeNode.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/context.d.ts +6 -0
- package/dist/components/basic-json-viewer/context.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/hooks/useClipboard.d.ts +4 -0
- package/dist/components/basic-json-viewer/hooks/useClipboard.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/hooks/useError.d.ts +8 -0
- package/dist/components/basic-json-viewer/hooks/useError.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/index.d.ts +7 -0
- package/dist/components/basic-json-viewer/index.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/interface.d.ts +377 -0
- package/dist/components/basic-json-viewer/interface.d.ts.map +1 -0
- package/dist/components/basic-json-viewer/utils/index.d.ts +8 -0
- package/dist/components/basic-json-viewer/utils/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +1124 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1151 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { camelize, isNumber, isString, removeClass, addClass, pascalCase, isClient as isClient$1, hasClass, withInstall, guid, isFunction, isElement, isObject as isObject$1, isUndefined, isBoolean, getSlot, isArray, deepMerge, cloneDeep as cloneDeep$
|
|
1
|
+
import { camelize, isNumber, isString, removeClass, addClass, pascalCase, isClient as isClient$1, hasClass, withInstall, guid, isFunction, isElement, isObject as isObject$1, isUndefined, isBoolean, getSlot, isArray, deepMerge, cloneDeep as cloneDeep$2, call, isNull, classNames, getValueKey, tryConstructArray, isNil, tryDeconstructArray, tryDeconstructObject, isEmpty, isPascalCase, mergeArray, getStyle as getStyle$1, kebabCase, findNodeAll, calculate, downloadFileStatic, downloadFileByResponseData, attrAccept as attrAccept$1 } from "@maxax/utils";
|
|
2
2
|
import { nextTick, Fragment, isVNode, Comment, Text, onMounted, watchEffect, onBeforeUnmount, inject, ref, computed, shallowRef, getCurrentInstance, unref, isRef, watch, onScopeDispose, toRaw, defineComponent, onUnmounted, h, useAttrs, createElementBlock, openBlock, mergeProps, createElementVNode, createBlock, createCommentVNode, normalizeClass, createVNode, createSlots, withCtx, renderSlot, provide, reactive, toRefs, resolveComponent, Transition, withDirectives, withModifiers, normalizeStyle, createTextVNode, toDisplayString, withKeys, resolveDynamicComponent, vShow, render as render$1, useSlots, renderList, toRef, normalizeProps, guardReactiveProps, shallowReadonly, getCurrentScope, toValue, vModelText, createApp, mergeDefaults, triggerRef, TransitionGroup, toHandlers, useTemplateRef } from "vue";
|
|
3
3
|
import { NButton, NInput, NCard, NCascader, NDatePicker, NTooltip, NDrawer, NDrawerContent, NSelect, NInputNumber, NUpload, NAutoComplete, NDynamicTags, NTreeSelect, NTimePicker, NSwitch, NCheckbox, NCheckboxGroup, NRadio, NRadioButton, NRadioGroup, NSlider, NTransfer, NDivider, NColorPicker, NRate, NCol, NFormItem, NForm, NRow, NPopover, NTabs, NTabPane, NScrollbar, NEmpty, NPagination, NSpin, NModal, NProgress } from "naive-ui";
|
|
4
|
-
import { merge, cloneDeep, uniqBy, get, omit, has, set, unset, isNumber as isNumber$1, isPlainObject, isBoolean as isBoolean$1, isFunction as isFunction$1, isArray as isArray$1, isString as isString$1, isEqual, concat, partition } from "lodash-es";
|
|
4
|
+
import { merge, cloneDeep as cloneDeep$1, uniqBy, get, omit, has, set, unset, isNumber as isNumber$1, isPlainObject, isBoolean as isBoolean$1, isFunction as isFunction$1, isArray as isArray$1, isString as isString$1, isEqual, concat, partition } from "lodash-es";
|
|
5
5
|
import { b as buildLocaleContext, z as zhCN } from "./utils-JnUSPc85.js";
|
|
6
6
|
import { useBoolean, useMergedState as useMergedState$1, useEventListener as useEventListener$1, useBreakpoint } from "@maxax/hooks";
|
|
7
7
|
import { format } from "date-fns";
|
|
@@ -3458,7 +3458,7 @@ function useButtonGroupClass(propsRef) {
|
|
|
3458
3458
|
}
|
|
3459
3459
|
function useButtonGroupEvents({ getSchema, schemaRef }) {
|
|
3460
3460
|
async function removeSchemaByField(fields) {
|
|
3461
|
-
const schemaList = cloneDeep(unref(getSchema));
|
|
3461
|
+
const schemaList = cloneDeep$1(unref(getSchema));
|
|
3462
3462
|
if (!fields) {
|
|
3463
3463
|
return;
|
|
3464
3464
|
}
|
|
@@ -3480,7 +3480,7 @@ function useButtonGroupEvents({ getSchema, schemaRef }) {
|
|
|
3480
3480
|
}
|
|
3481
3481
|
}
|
|
3482
3482
|
async function appendSchemaByField(schema, prefixField, first = false) {
|
|
3483
|
-
const schemaList = cloneDeep(unref(getSchema));
|
|
3483
|
+
const schemaList = cloneDeep$1(unref(getSchema));
|
|
3484
3484
|
const addSchemaIds = Array.isArray(schema) ? schema.map((item) => item.field) : [schema.field];
|
|
3485
3485
|
if (schemaList.find((item) => addSchemaIds.includes(item.field))) {
|
|
3486
3486
|
throw new Error("[error]:There are schemas that have already been added");
|
|
@@ -3545,7 +3545,7 @@ function useButtonGroupEvents({ getSchema, schemaRef }) {
|
|
|
3545
3545
|
}
|
|
3546
3546
|
function useButtonGroupSchema({ getProps, schemaRef }) {
|
|
3547
3547
|
const getSchema = computed(() => {
|
|
3548
|
-
const schemas = cloneDeep$
|
|
3548
|
+
const schemas = cloneDeep$2(unref(schemaRef) || unref(getProps).schemas || []);
|
|
3549
3549
|
return schemas;
|
|
3550
3550
|
});
|
|
3551
3551
|
return { getSchema };
|
|
@@ -6496,7 +6496,7 @@ function useEditBatchClass(propsRef) {
|
|
|
6496
6496
|
function useEditBatchEvents({ emit, getProps, getSchema, formModel, defaultValueRef, schemaRef, editBatchElRef, handleFormValues, fieldKey, schemaItemRef }) {
|
|
6497
6497
|
const getAllFields = () => unref(getSchema).map((item) => [...item.fields || [], item.field]).flat(1).filter(Boolean);
|
|
6498
6498
|
async function removeSchemaByField(fields) {
|
|
6499
|
-
const schemaList = cloneDeep(unref(getSchema));
|
|
6499
|
+
const schemaList = cloneDeep$1(unref(getSchema));
|
|
6500
6500
|
if (!fields) {
|
|
6501
6501
|
return;
|
|
6502
6502
|
}
|
|
@@ -6519,7 +6519,7 @@ function useEditBatchEvents({ emit, getProps, getSchema, formModel, defaultValue
|
|
|
6519
6519
|
}
|
|
6520
6520
|
}
|
|
6521
6521
|
async function appendSchemaByField(schema, prefixField, first = false) {
|
|
6522
|
-
const schemaList = cloneDeep(unref(getSchema));
|
|
6522
|
+
const schemaList = cloneDeep$1(unref(getSchema));
|
|
6523
6523
|
const addSchemaIds = Array.isArray(schema) ? schema.map((item) => item.field) : [schema.field];
|
|
6524
6524
|
if (schemaList.find((item) => addSchemaIds.includes(item.field))) {
|
|
6525
6525
|
throw new Error("[error]:There are schemas that have already been added");
|
|
@@ -6716,7 +6716,7 @@ function useEditBatchEvents({ emit, getProps, getSchema, formModel, defaultValue
|
|
|
6716
6716
|
};
|
|
6717
6717
|
}
|
|
6718
6718
|
function getDefaultValue$1(schema, defaultValueRef, key2) {
|
|
6719
|
-
let defaultValue = cloneDeep(defaultValueRef.value[key2]);
|
|
6719
|
+
let defaultValue = cloneDeep$1(defaultValueRef.value[key2]);
|
|
6720
6720
|
const isInput = checkIsInput$1(schema);
|
|
6721
6721
|
if (isInput) {
|
|
6722
6722
|
return !isNil(defaultValue) ? defaultValue : void 0;
|
|
@@ -6731,7 +6731,7 @@ function getDefaultValue$1(schema, defaultValueRef, key2) {
|
|
|
6731
6731
|
}
|
|
6732
6732
|
function useEditBatchSchema({ getProps, schemaRef, formModel }) {
|
|
6733
6733
|
const getSchema = computed(() => {
|
|
6734
|
-
const schemas = cloneDeep$
|
|
6734
|
+
const schemas = cloneDeep$2(unref(schemaRef) || unref(getProps).schemas || []);
|
|
6735
6735
|
for (const schema of schemas) {
|
|
6736
6736
|
const { defaultValue, component, componentProps = {}, isHandleDateDefaultValue = true, field, isHandleDefaultValue = true, valueFormat } = schema;
|
|
6737
6737
|
if (isHandleDateDefaultValue && defaultValue && component && itemIsDateComponent$1(component)) {
|
|
@@ -6868,7 +6868,7 @@ function useEditBatchValues({ getProps, defaultValueRef, getSchema, formModel })
|
|
|
6868
6868
|
}
|
|
6869
6869
|
}
|
|
6870
6870
|
});
|
|
6871
|
-
defaultValueRef.value = cloneDeep(obj);
|
|
6871
|
+
defaultValueRef.value = cloneDeep$1(obj);
|
|
6872
6872
|
}
|
|
6873
6873
|
return { handleFormValues, initDefault };
|
|
6874
6874
|
}
|
|
@@ -7567,7 +7567,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
7567
7567
|
if (isFunction(dynamicRules)) {
|
|
7568
7568
|
return dynamicRules(unref(getValues));
|
|
7569
7569
|
}
|
|
7570
|
-
let rules = cloneDeep$
|
|
7570
|
+
let rules = cloneDeep$2(defRules);
|
|
7571
7571
|
const {
|
|
7572
7572
|
rulesMessageJoinLabel: globalRulesMessageJoinLabel
|
|
7573
7573
|
} = props.formProps;
|
|
@@ -8011,7 +8011,7 @@ function useFormClass(propsRef) {
|
|
|
8011
8011
|
function useFormEvents({ emit, getProps, getSchema, formModel, defaultValueRef, formElRef, schemaRef, handleFormValues, initDefault }) {
|
|
8012
8012
|
const getAllFields = () => unref(getSchema).map((item) => [...item.fields || [], item.field]).flat(1).filter(Boolean);
|
|
8013
8013
|
async function removeSchemaByField(fields) {
|
|
8014
|
-
const schemaList = cloneDeep(unref(getSchema));
|
|
8014
|
+
const schemaList = cloneDeep$1(unref(getSchema));
|
|
8015
8015
|
if (!fields) {
|
|
8016
8016
|
return;
|
|
8017
8017
|
}
|
|
@@ -8035,7 +8035,7 @@ function useFormEvents({ emit, getProps, getSchema, formModel, defaultValueRef,
|
|
|
8035
8035
|
}
|
|
8036
8036
|
}
|
|
8037
8037
|
async function appendSchemaByField(schema, prefixField, first = false) {
|
|
8038
|
-
const schemaList = cloneDeep(unref(getSchema));
|
|
8038
|
+
const schemaList = cloneDeep$1(unref(getSchema));
|
|
8039
8039
|
const addSchemaIds = Array.isArray(schema) ? schema.map((item) => item.field) : [schema.field];
|
|
8040
8040
|
if (schemaList.find((item) => addSchemaIds.includes(item.field))) {
|
|
8041
8041
|
throw new Error("[error]:There are schemas that have already been added");
|
|
@@ -8226,7 +8226,7 @@ function useFormEvents({ emit, getProps, getSchema, formModel, defaultValueRef,
|
|
|
8226
8226
|
nameList.forEach((key2) => {
|
|
8227
8227
|
if (keys.includes(key2)) {
|
|
8228
8228
|
validKeys.push(key2);
|
|
8229
|
-
unref(formModel)[key2] = cloneDeep(unref(get(defaultValueRef.value, key2)));
|
|
8229
|
+
unref(formModel)[key2] = cloneDeep$1(unref(get(defaultValueRef.value, key2)));
|
|
8230
8230
|
}
|
|
8231
8231
|
});
|
|
8232
8232
|
validateFields(validKeys).catch((_) => {
|
|
@@ -8316,7 +8316,7 @@ function useFormEvents({ emit, getProps, getSchema, formModel, defaultValueRef,
|
|
|
8316
8316
|
};
|
|
8317
8317
|
}
|
|
8318
8318
|
function getDefaultValue(schema, defaultValueRef, key2) {
|
|
8319
|
-
let defaultValue = cloneDeep(defaultValueRef.value[key2]);
|
|
8319
|
+
let defaultValue = cloneDeep$1(defaultValueRef.value[key2]);
|
|
8320
8320
|
const isInput = checkIsInput(schema);
|
|
8321
8321
|
if (isInput) {
|
|
8322
8322
|
return !isNil(defaultValue) ? defaultValue : void 0;
|
|
@@ -8341,7 +8341,7 @@ function useFormGrid(propsRef) {
|
|
|
8341
8341
|
}
|
|
8342
8342
|
function useFormSchema({ getProps, schemaRef, formModel }) {
|
|
8343
8343
|
const getSchema = computed(() => {
|
|
8344
|
-
const schemas = cloneDeep$
|
|
8344
|
+
const schemas = cloneDeep$2(unref(schemaRef) || unref(getProps).schemas || []);
|
|
8345
8345
|
for (const schema of schemas) {
|
|
8346
8346
|
const { defaultValue, component, componentProps = {}, isHandleDateDefaultValue = true, field, isHandleDefaultValue = true, valueFormat, ifShow } = schema;
|
|
8347
8347
|
if (unref(getProps).showAdvancedButton) {
|
|
@@ -8481,7 +8481,7 @@ function useFormValues({ getProps, defaultValueRef, getSchema, formModel }) {
|
|
|
8481
8481
|
}
|
|
8482
8482
|
}
|
|
8483
8483
|
});
|
|
8484
|
-
defaultValueRef.value = cloneDeep(obj);
|
|
8484
|
+
defaultValueRef.value = cloneDeep$1(obj);
|
|
8485
8485
|
}
|
|
8486
8486
|
return { handleFormValues, initDefault };
|
|
8487
8487
|
}
|
|
@@ -12668,7 +12668,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
12668
12668
|
const mergedValueRef = useMergedState$1(controlledValueRef, uncontrolledValueRef);
|
|
12669
12669
|
const { t } = useLocale();
|
|
12670
12670
|
const iconList = ref(IconJson);
|
|
12671
|
-
const copyIconList = cloneDeep$
|
|
12671
|
+
const copyIconList = cloneDeep$2(iconList.value);
|
|
12672
12672
|
const totalPage = ref(0);
|
|
12673
12673
|
const pageSize = ref(35);
|
|
12674
12674
|
const currentPage = ref(1);
|
|
@@ -12881,6 +12881,1121 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
12881
12881
|
}
|
|
12882
12882
|
});
|
|
12883
12883
|
const XBasicIconPicker = withInstall(_sfc_main$o);
|
|
12884
|
+
function useClipboard() {
|
|
12885
|
+
const copied = ref(false);
|
|
12886
|
+
const copy = async (source) => {
|
|
12887
|
+
try {
|
|
12888
|
+
await navigator.clipboard.writeText(source);
|
|
12889
|
+
copied.value = true;
|
|
12890
|
+
setTimeout(() => {
|
|
12891
|
+
copied.value = false;
|
|
12892
|
+
}, 300);
|
|
12893
|
+
} catch (err) {
|
|
12894
|
+
console.error("[vue-json-pretty] Copy failed: ", err);
|
|
12895
|
+
}
|
|
12896
|
+
};
|
|
12897
|
+
return {
|
|
12898
|
+
copy
|
|
12899
|
+
};
|
|
12900
|
+
}
|
|
12901
|
+
const treeNodePropsPass$1 = {
|
|
12902
|
+
// JSONLike data.
|
|
12903
|
+
data: {
|
|
12904
|
+
type: [String, Number, Boolean, Array, Object],
|
|
12905
|
+
default: null
|
|
12906
|
+
},
|
|
12907
|
+
// Data root path.
|
|
12908
|
+
rootPath: {
|
|
12909
|
+
type: String,
|
|
12910
|
+
default: "root"
|
|
12911
|
+
},
|
|
12912
|
+
indent: {
|
|
12913
|
+
type: Number,
|
|
12914
|
+
default: 2
|
|
12915
|
+
},
|
|
12916
|
+
// Whether to display the length of (array|object).
|
|
12917
|
+
showLength: {
|
|
12918
|
+
type: Boolean,
|
|
12919
|
+
default: false
|
|
12920
|
+
},
|
|
12921
|
+
// Whether the key name uses double quotes.
|
|
12922
|
+
showDoubleQuotes: {
|
|
12923
|
+
type: Boolean,
|
|
12924
|
+
default: true
|
|
12925
|
+
},
|
|
12926
|
+
// Custom render for key.
|
|
12927
|
+
renderNodeKey: Function,
|
|
12928
|
+
// Custom render for value.
|
|
12929
|
+
renderNodeValue: Function,
|
|
12930
|
+
// Custom render for node actions.
|
|
12931
|
+
renderNodeActions: {
|
|
12932
|
+
type: [Boolean, Function],
|
|
12933
|
+
default: void 0
|
|
12934
|
+
},
|
|
12935
|
+
// Define the selection method supported by the data level, which is not available by default.
|
|
12936
|
+
selectableType: String,
|
|
12937
|
+
// Whether to display the selection control.
|
|
12938
|
+
showSelectController: {
|
|
12939
|
+
type: Boolean,
|
|
12940
|
+
default: false
|
|
12941
|
+
},
|
|
12942
|
+
// Whether to display the data level connection.
|
|
12943
|
+
showLine: {
|
|
12944
|
+
type: Boolean,
|
|
12945
|
+
default: true
|
|
12946
|
+
},
|
|
12947
|
+
showLineNumber: {
|
|
12948
|
+
type: Boolean,
|
|
12949
|
+
default: false
|
|
12950
|
+
},
|
|
12951
|
+
// Whether to trigger selection when clicking on the node.
|
|
12952
|
+
selectOnClickNode: {
|
|
12953
|
+
type: Boolean,
|
|
12954
|
+
default: true
|
|
12955
|
+
},
|
|
12956
|
+
// When using the selectableType, define whether current path/content is enabled.
|
|
12957
|
+
nodeSelectable: {
|
|
12958
|
+
type: Function,
|
|
12959
|
+
default: () => true
|
|
12960
|
+
},
|
|
12961
|
+
// Highlight current node when selected.
|
|
12962
|
+
highlightSelectedNode: {
|
|
12963
|
+
type: Boolean,
|
|
12964
|
+
default: true
|
|
12965
|
+
},
|
|
12966
|
+
showIcon: {
|
|
12967
|
+
type: Boolean,
|
|
12968
|
+
default: false
|
|
12969
|
+
},
|
|
12970
|
+
theme: {
|
|
12971
|
+
type: String,
|
|
12972
|
+
default: "light"
|
|
12973
|
+
},
|
|
12974
|
+
showKeyValueSpace: {
|
|
12975
|
+
type: Boolean,
|
|
12976
|
+
default: true
|
|
12977
|
+
},
|
|
12978
|
+
editable: {
|
|
12979
|
+
type: Boolean,
|
|
12980
|
+
default: false
|
|
12981
|
+
},
|
|
12982
|
+
editableTrigger: {
|
|
12983
|
+
type: String,
|
|
12984
|
+
default: "click"
|
|
12985
|
+
},
|
|
12986
|
+
onNodeClick: {
|
|
12987
|
+
type: Function
|
|
12988
|
+
},
|
|
12989
|
+
onNodeMouseover: {
|
|
12990
|
+
type: Function
|
|
12991
|
+
},
|
|
12992
|
+
onBracketsClick: {
|
|
12993
|
+
type: Function
|
|
12994
|
+
},
|
|
12995
|
+
onIconClick: {
|
|
12996
|
+
type: Function
|
|
12997
|
+
},
|
|
12998
|
+
onValueChange: {
|
|
12999
|
+
type: Function
|
|
13000
|
+
}
|
|
13001
|
+
};
|
|
13002
|
+
const treeNodeProps = {
|
|
13003
|
+
...treeNodePropsPass$1,
|
|
13004
|
+
// Current node data.
|
|
13005
|
+
node: {
|
|
13006
|
+
type: Object,
|
|
13007
|
+
required: true
|
|
13008
|
+
},
|
|
13009
|
+
// Whether the current node is collapsed.
|
|
13010
|
+
collapsed: Boolean,
|
|
13011
|
+
// Whether the current node is checked(When using the selection function).
|
|
13012
|
+
checked: Boolean,
|
|
13013
|
+
style: {
|
|
13014
|
+
type: Object,
|
|
13015
|
+
default: void 0
|
|
13016
|
+
},
|
|
13017
|
+
onSelectedChange: {
|
|
13018
|
+
type: Function,
|
|
13019
|
+
default: void 0
|
|
13020
|
+
}
|
|
13021
|
+
};
|
|
13022
|
+
const basicJsonViewerProps = {
|
|
13023
|
+
...treeNodePropsPass$1,
|
|
13024
|
+
collapsedNodeLength: {
|
|
13025
|
+
type: Number,
|
|
13026
|
+
default: Infinity
|
|
13027
|
+
},
|
|
13028
|
+
// Define the depth of the tree, nodes greater than this depth will not be expanded.
|
|
13029
|
+
deep: {
|
|
13030
|
+
type: Number,
|
|
13031
|
+
default: Infinity
|
|
13032
|
+
},
|
|
13033
|
+
pathCollapsible: {
|
|
13034
|
+
type: Function,
|
|
13035
|
+
default: () => false
|
|
13036
|
+
},
|
|
13037
|
+
// Whether to use virtual scroll, usually applied to big data.
|
|
13038
|
+
virtual: {
|
|
13039
|
+
type: Boolean,
|
|
13040
|
+
default: false
|
|
13041
|
+
},
|
|
13042
|
+
// When using virtual scroll, set the height of tree.
|
|
13043
|
+
height: {
|
|
13044
|
+
type: Number,
|
|
13045
|
+
default: 400
|
|
13046
|
+
},
|
|
13047
|
+
// When using virtual scroll without dynamicHeight, define the height of each row.
|
|
13048
|
+
itemHeight: {
|
|
13049
|
+
type: Number,
|
|
13050
|
+
default: 20
|
|
13051
|
+
},
|
|
13052
|
+
// Enable dynamic row heights for virtual scroll.
|
|
13053
|
+
dynamicHeight: {
|
|
13054
|
+
type: Boolean,
|
|
13055
|
+
default: true
|
|
13056
|
+
},
|
|
13057
|
+
// When there is a selection function, define the selected path.
|
|
13058
|
+
// For multiple selections, it is an array ['root.a','root.b'], for single selection, it is a string of 'root.a'.
|
|
13059
|
+
selectedValue: {
|
|
13060
|
+
type: [String, Array],
|
|
13061
|
+
default: () => ""
|
|
13062
|
+
},
|
|
13063
|
+
// Collapsed control.
|
|
13064
|
+
collapsedOnClickBrackets: {
|
|
13065
|
+
type: Boolean,
|
|
13066
|
+
default: true
|
|
13067
|
+
},
|
|
13068
|
+
style: {
|
|
13069
|
+
type: Object,
|
|
13070
|
+
default: void 0
|
|
13071
|
+
},
|
|
13072
|
+
onSelectedChange: {
|
|
13073
|
+
type: Function,
|
|
13074
|
+
default: void 0
|
|
13075
|
+
},
|
|
13076
|
+
theme: {
|
|
13077
|
+
type: String,
|
|
13078
|
+
default: "light"
|
|
13079
|
+
}
|
|
13080
|
+
};
|
|
13081
|
+
function emitError(message) {
|
|
13082
|
+
throw new Error(`[VueJSONPretty] ${message}`);
|
|
13083
|
+
}
|
|
13084
|
+
function getDataType(value) {
|
|
13085
|
+
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
13086
|
+
}
|
|
13087
|
+
function jsonFlatten(data, path = "root", level = 0, options) {
|
|
13088
|
+
const { key: key2, index: index2, type = "content", showComma = false, length = 1 } = options || {};
|
|
13089
|
+
const dataType = getDataType(data);
|
|
13090
|
+
if (dataType === "array") {
|
|
13091
|
+
const inner = arrFlat(
|
|
13092
|
+
data.map(
|
|
13093
|
+
(item, idx, arr) => jsonFlatten(item, `${path}[${idx}]`, level + 1, {
|
|
13094
|
+
index: idx,
|
|
13095
|
+
showComma: idx !== arr.length - 1,
|
|
13096
|
+
length,
|
|
13097
|
+
type
|
|
13098
|
+
})
|
|
13099
|
+
)
|
|
13100
|
+
);
|
|
13101
|
+
return [
|
|
13102
|
+
jsonFlatten("[", path, level, {
|
|
13103
|
+
showComma: false,
|
|
13104
|
+
key: key2,
|
|
13105
|
+
length: data.length,
|
|
13106
|
+
type: "arrayStart"
|
|
13107
|
+
})[0]
|
|
13108
|
+
].concat(
|
|
13109
|
+
inner,
|
|
13110
|
+
jsonFlatten("]", path, level, {
|
|
13111
|
+
showComma,
|
|
13112
|
+
length: data.length,
|
|
13113
|
+
type: "arrayEnd"
|
|
13114
|
+
})[0]
|
|
13115
|
+
);
|
|
13116
|
+
} else if (dataType === "object") {
|
|
13117
|
+
const keys = Object.keys(data);
|
|
13118
|
+
const inner = arrFlat(
|
|
13119
|
+
keys.map(
|
|
13120
|
+
(objKey, idx, arr) => jsonFlatten(data[objKey], /^[a-zA-Z_]\w*$/.test(objKey) ? `${path}.${objKey}` : `${path}["${objKey}"]`, level + 1, {
|
|
13121
|
+
key: objKey,
|
|
13122
|
+
showComma: idx !== arr.length - 1,
|
|
13123
|
+
length,
|
|
13124
|
+
type
|
|
13125
|
+
})
|
|
13126
|
+
)
|
|
13127
|
+
);
|
|
13128
|
+
return [
|
|
13129
|
+
jsonFlatten("{", path, level, {
|
|
13130
|
+
showComma: false,
|
|
13131
|
+
key: key2,
|
|
13132
|
+
index: index2,
|
|
13133
|
+
length: keys.length,
|
|
13134
|
+
type: "objectStart"
|
|
13135
|
+
})[0]
|
|
13136
|
+
].concat(inner, jsonFlatten("}", path, level, { showComma, length: keys.length, type: "objectEnd" })[0]);
|
|
13137
|
+
}
|
|
13138
|
+
return [
|
|
13139
|
+
{
|
|
13140
|
+
content: data,
|
|
13141
|
+
level,
|
|
13142
|
+
key: key2,
|
|
13143
|
+
index: index2,
|
|
13144
|
+
path,
|
|
13145
|
+
showComma,
|
|
13146
|
+
length,
|
|
13147
|
+
type
|
|
13148
|
+
}
|
|
13149
|
+
];
|
|
13150
|
+
}
|
|
13151
|
+
function arrFlat(arr) {
|
|
13152
|
+
if (typeof Array.prototype.flat === "function") {
|
|
13153
|
+
return arr.flat();
|
|
13154
|
+
}
|
|
13155
|
+
const stack = [...arr];
|
|
13156
|
+
const result = [];
|
|
13157
|
+
while (stack.length) {
|
|
13158
|
+
const first = stack.shift();
|
|
13159
|
+
if (Array.isArray(first)) {
|
|
13160
|
+
stack.unshift(...first);
|
|
13161
|
+
} else {
|
|
13162
|
+
result.push(first);
|
|
13163
|
+
}
|
|
13164
|
+
}
|
|
13165
|
+
return result;
|
|
13166
|
+
}
|
|
13167
|
+
function cloneDeep(source, hash = /* @__PURE__ */ new WeakMap()) {
|
|
13168
|
+
if (source === null || source === void 0) return source;
|
|
13169
|
+
if (source instanceof Date) return new Date(source);
|
|
13170
|
+
if (source instanceof RegExp) return new RegExp(source);
|
|
13171
|
+
if (typeof source !== "object") return source;
|
|
13172
|
+
if (hash.get(source)) return hash.get(source);
|
|
13173
|
+
if (Array.isArray(source)) {
|
|
13174
|
+
const output2 = source.map((item) => cloneDeep(item, hash));
|
|
13175
|
+
hash.set(source, output2);
|
|
13176
|
+
return output2;
|
|
13177
|
+
}
|
|
13178
|
+
const output = {};
|
|
13179
|
+
for (const key2 in source) {
|
|
13180
|
+
output[key2] = cloneDeep(source[key2], hash);
|
|
13181
|
+
}
|
|
13182
|
+
hash.set(source, output);
|
|
13183
|
+
return output;
|
|
13184
|
+
}
|
|
13185
|
+
function stringToAutoType(source) {
|
|
13186
|
+
let value;
|
|
13187
|
+
if (source === "null") value = null;
|
|
13188
|
+
else if (source === "undefined") value = void 0;
|
|
13189
|
+
else if (source === "true") value = true;
|
|
13190
|
+
else if (source === "false") value = false;
|
|
13191
|
+
else if (source[0] + source[source.length - 1] === '""' || source[0] + source[source.length - 1] === "''") {
|
|
13192
|
+
value = source.slice(1, -1);
|
|
13193
|
+
} else if (typeof Number(source) === "number" && !isNaN(Number(source)) || source === "NaN") {
|
|
13194
|
+
value = Number(source);
|
|
13195
|
+
} else {
|
|
13196
|
+
value = source;
|
|
13197
|
+
}
|
|
13198
|
+
return value;
|
|
13199
|
+
}
|
|
13200
|
+
const Brackets = /* @__PURE__ */ defineComponent({
|
|
13201
|
+
name: "JsonBrackets",
|
|
13202
|
+
props: {
|
|
13203
|
+
data: {
|
|
13204
|
+
required: true,
|
|
13205
|
+
type: String
|
|
13206
|
+
},
|
|
13207
|
+
onClick: {
|
|
13208
|
+
type: Function,
|
|
13209
|
+
default: void 0
|
|
13210
|
+
}
|
|
13211
|
+
},
|
|
13212
|
+
render() {
|
|
13213
|
+
const {
|
|
13214
|
+
data
|
|
13215
|
+
} = this;
|
|
13216
|
+
const {
|
|
13217
|
+
onClick
|
|
13218
|
+
} = this;
|
|
13219
|
+
return createVNode("span", {
|
|
13220
|
+
"class": "vjs-tree-brackets",
|
|
13221
|
+
"onClick": onClick
|
|
13222
|
+
}, [data]);
|
|
13223
|
+
}
|
|
13224
|
+
});
|
|
13225
|
+
const Carets = /* @__PURE__ */ defineComponent({
|
|
13226
|
+
name: "JsonCarets",
|
|
13227
|
+
props: {
|
|
13228
|
+
nodeType: {
|
|
13229
|
+
required: true,
|
|
13230
|
+
type: String
|
|
13231
|
+
},
|
|
13232
|
+
onClick: {
|
|
13233
|
+
type: Function,
|
|
13234
|
+
default: void 0
|
|
13235
|
+
}
|
|
13236
|
+
},
|
|
13237
|
+
render() {
|
|
13238
|
+
const {
|
|
13239
|
+
nodeType
|
|
13240
|
+
} = this;
|
|
13241
|
+
const {
|
|
13242
|
+
onClick
|
|
13243
|
+
} = this;
|
|
13244
|
+
const isOpen = nodeType === "objectStart" || nodeType === "arrayStart";
|
|
13245
|
+
const isClose = nodeType === "objectCollapsed" || nodeType === "arrayCollapsed";
|
|
13246
|
+
if (!isOpen && !isClose) return null;
|
|
13247
|
+
return createVNode("span", {
|
|
13248
|
+
"class": `vjs-carets vjs-carets-${isOpen ? "open" : "close"}`,
|
|
13249
|
+
"onClick": onClick
|
|
13250
|
+
}, [createVNode("svg", {
|
|
13251
|
+
"viewBox": "0 0 24 24",
|
|
13252
|
+
"width": "1em",
|
|
13253
|
+
"height": "1em",
|
|
13254
|
+
"fill": "currentColor",
|
|
13255
|
+
"aria-hidden": "true",
|
|
13256
|
+
"focusable": "false",
|
|
13257
|
+
"data-icon": "caret-down"
|
|
13258
|
+
}, [createVNode("path", {
|
|
13259
|
+
"fill": "currentColor",
|
|
13260
|
+
"d": "m12 13.171l4.95-4.95l1.414 1.415L12 16L5.636 9.636L7.05 8.222z"
|
|
13261
|
+
}, null)])]);
|
|
13262
|
+
}
|
|
13263
|
+
});
|
|
13264
|
+
const CheckController = /* @__PURE__ */ defineComponent({
|
|
13265
|
+
props: {
|
|
13266
|
+
checked: {
|
|
13267
|
+
type: Boolean,
|
|
13268
|
+
default: false
|
|
13269
|
+
},
|
|
13270
|
+
isMultiple: Boolean,
|
|
13271
|
+
onChange: {
|
|
13272
|
+
type: Function,
|
|
13273
|
+
default: void 0
|
|
13274
|
+
}
|
|
13275
|
+
},
|
|
13276
|
+
emits: ["change", "update:modelValue"],
|
|
13277
|
+
setup(props, {
|
|
13278
|
+
emit
|
|
13279
|
+
}) {
|
|
13280
|
+
const uiType = computed(() => props.isMultiple ? "checkbox" : "radio");
|
|
13281
|
+
const model = computed({
|
|
13282
|
+
get: () => props.checked,
|
|
13283
|
+
set: (val) => emit("update:modelValue", val)
|
|
13284
|
+
});
|
|
13285
|
+
return {
|
|
13286
|
+
uiType,
|
|
13287
|
+
model
|
|
13288
|
+
};
|
|
13289
|
+
},
|
|
13290
|
+
render() {
|
|
13291
|
+
const {
|
|
13292
|
+
uiType,
|
|
13293
|
+
model,
|
|
13294
|
+
$emit
|
|
13295
|
+
} = this;
|
|
13296
|
+
return createVNode("label", {
|
|
13297
|
+
"class": ["vjs-check-controller", model ? "is-checked" : ""],
|
|
13298
|
+
"onClick": (e) => e.stopPropagation()
|
|
13299
|
+
}, [createVNode("span", {
|
|
13300
|
+
"class": `vjs-check-controller-inner is-${uiType}`
|
|
13301
|
+
}, null), createVNode("input", {
|
|
13302
|
+
"checked": model,
|
|
13303
|
+
"class": `vjs-check-controller-original is-${uiType}`,
|
|
13304
|
+
"type": uiType,
|
|
13305
|
+
"onChange": () => $emit("change", model)
|
|
13306
|
+
}, null)]);
|
|
13307
|
+
}
|
|
13308
|
+
});
|
|
13309
|
+
const treeNodePropsPass = {
|
|
13310
|
+
// JSONLike data.
|
|
13311
|
+
data: {
|
|
13312
|
+
type: [String, Number, Boolean, Array, Object],
|
|
13313
|
+
default: null
|
|
13314
|
+
},
|
|
13315
|
+
// Data root path.
|
|
13316
|
+
rootPath: {
|
|
13317
|
+
type: String,
|
|
13318
|
+
default: "root"
|
|
13319
|
+
},
|
|
13320
|
+
indent: {
|
|
13321
|
+
type: Number,
|
|
13322
|
+
default: 2
|
|
13323
|
+
},
|
|
13324
|
+
// Whether to display the length of (array|object).
|
|
13325
|
+
showLength: {
|
|
13326
|
+
type: Boolean,
|
|
13327
|
+
default: false
|
|
13328
|
+
},
|
|
13329
|
+
// Whether the key name uses double quotes.
|
|
13330
|
+
showDoubleQuotes: {
|
|
13331
|
+
type: Boolean,
|
|
13332
|
+
default: true
|
|
13333
|
+
},
|
|
13334
|
+
// Custom render for key.
|
|
13335
|
+
renderNodeKey: Function,
|
|
13336
|
+
// Custom render for value.
|
|
13337
|
+
renderNodeValue: Function,
|
|
13338
|
+
// Custom render for node actions.
|
|
13339
|
+
renderNodeActions: {
|
|
13340
|
+
type: [Boolean, Function],
|
|
13341
|
+
default: void 0
|
|
13342
|
+
},
|
|
13343
|
+
// Define the selection method supported by the data level, which is not available by default.
|
|
13344
|
+
selectableType: String,
|
|
13345
|
+
// Whether to display the selection control.
|
|
13346
|
+
showSelectController: {
|
|
13347
|
+
type: Boolean,
|
|
13348
|
+
default: false
|
|
13349
|
+
},
|
|
13350
|
+
// Whether to display the data level connection.
|
|
13351
|
+
showLine: {
|
|
13352
|
+
type: Boolean,
|
|
13353
|
+
default: true
|
|
13354
|
+
},
|
|
13355
|
+
showLineNumber: {
|
|
13356
|
+
type: Boolean,
|
|
13357
|
+
default: false
|
|
13358
|
+
},
|
|
13359
|
+
// Whether to trigger selection when clicking on the node.
|
|
13360
|
+
selectOnClickNode: {
|
|
13361
|
+
type: Boolean,
|
|
13362
|
+
default: true
|
|
13363
|
+
},
|
|
13364
|
+
// When using the selectableType, define whether current path/content is enabled.
|
|
13365
|
+
nodeSelectable: {
|
|
13366
|
+
type: Function,
|
|
13367
|
+
default: () => true
|
|
13368
|
+
},
|
|
13369
|
+
// Highlight current node when selected.
|
|
13370
|
+
highlightSelectedNode: {
|
|
13371
|
+
type: Boolean,
|
|
13372
|
+
default: true
|
|
13373
|
+
},
|
|
13374
|
+
showIcon: {
|
|
13375
|
+
type: Boolean,
|
|
13376
|
+
default: false
|
|
13377
|
+
},
|
|
13378
|
+
theme: {
|
|
13379
|
+
type: String,
|
|
13380
|
+
default: "light"
|
|
13381
|
+
},
|
|
13382
|
+
showKeyValueSpace: {
|
|
13383
|
+
type: Boolean,
|
|
13384
|
+
default: true
|
|
13385
|
+
},
|
|
13386
|
+
editable: {
|
|
13387
|
+
type: Boolean,
|
|
13388
|
+
default: false
|
|
13389
|
+
},
|
|
13390
|
+
editableTrigger: {
|
|
13391
|
+
type: String,
|
|
13392
|
+
default: "click"
|
|
13393
|
+
},
|
|
13394
|
+
onNodeClick: {
|
|
13395
|
+
type: Function
|
|
13396
|
+
},
|
|
13397
|
+
onNodeMouseover: {
|
|
13398
|
+
type: Function
|
|
13399
|
+
},
|
|
13400
|
+
onBracketsClick: {
|
|
13401
|
+
type: Function
|
|
13402
|
+
},
|
|
13403
|
+
onIconClick: {
|
|
13404
|
+
type: Function
|
|
13405
|
+
},
|
|
13406
|
+
onValueChange: {
|
|
13407
|
+
type: Function
|
|
13408
|
+
}
|
|
13409
|
+
};
|
|
13410
|
+
const TreeNode$1 = /* @__PURE__ */ defineComponent({
|
|
13411
|
+
name: "TreeNode",
|
|
13412
|
+
props: treeNodeProps,
|
|
13413
|
+
emits: ["nodeClick", "nodeMouseover", "bracketsClick", "iconClick", "selectedChange", "valueChange"],
|
|
13414
|
+
setup(props, {
|
|
13415
|
+
emit
|
|
13416
|
+
}) {
|
|
13417
|
+
const dataType = computed(() => getDataType(props.node.content));
|
|
13418
|
+
const valueClass = computed(() => `vjs-value vjs-value-${dataType.value}`);
|
|
13419
|
+
const prettyKey = computed(() => props.showDoubleQuotes ? `"${props.node.key}"` : props.node.key);
|
|
13420
|
+
const renderKey = () => {
|
|
13421
|
+
const render2 = props.renderNodeKey;
|
|
13422
|
+
return render2 ? render2({
|
|
13423
|
+
node: props.node,
|
|
13424
|
+
defaultKey: prettyKey.value || ""
|
|
13425
|
+
}) : prettyKey.value;
|
|
13426
|
+
};
|
|
13427
|
+
const isMultiple = computed(() => props.selectableType === "multiple");
|
|
13428
|
+
const isSingle = computed(() => props.selectableType === "single");
|
|
13429
|
+
const selectable = computed(() => props.nodeSelectable(props.node) && (isMultiple.value || isSingle.value));
|
|
13430
|
+
const state = reactive({
|
|
13431
|
+
editing: false
|
|
13432
|
+
});
|
|
13433
|
+
const handleInputChange = (e) => {
|
|
13434
|
+
var _a;
|
|
13435
|
+
const source = (_a = e.target) == null ? void 0 : _a.value;
|
|
13436
|
+
const value = stringToAutoType(source);
|
|
13437
|
+
emit("valueChange", value, props.node.path);
|
|
13438
|
+
};
|
|
13439
|
+
const defaultValue = computed(() => {
|
|
13440
|
+
var _a;
|
|
13441
|
+
let value = (_a = props.node) == null ? void 0 : _a.content;
|
|
13442
|
+
if (value === null) {
|
|
13443
|
+
value = "null";
|
|
13444
|
+
} else if (value === void 0) {
|
|
13445
|
+
value = "undefined";
|
|
13446
|
+
}
|
|
13447
|
+
return dataType.value === "string" ? `"${value}"` : `${value}`;
|
|
13448
|
+
});
|
|
13449
|
+
const renderValue = () => {
|
|
13450
|
+
const render2 = props.renderNodeValue;
|
|
13451
|
+
return render2 ? render2({
|
|
13452
|
+
node: props.node,
|
|
13453
|
+
defaultValue: defaultValue.value
|
|
13454
|
+
}) : defaultValue.value;
|
|
13455
|
+
};
|
|
13456
|
+
const handleBracketsClick = () => {
|
|
13457
|
+
emit("bracketsClick", !props.collapsed, props.node);
|
|
13458
|
+
};
|
|
13459
|
+
const handleIconClick = () => {
|
|
13460
|
+
emit("iconClick", !props.collapsed, props.node);
|
|
13461
|
+
};
|
|
13462
|
+
const handleSelectedChange = () => {
|
|
13463
|
+
emit("selectedChange", props.node);
|
|
13464
|
+
};
|
|
13465
|
+
const handleNodeClick = () => {
|
|
13466
|
+
emit("nodeClick", props.node);
|
|
13467
|
+
if (selectable.value && props.selectOnClickNode) {
|
|
13468
|
+
emit("selectedChange", props.node);
|
|
13469
|
+
}
|
|
13470
|
+
};
|
|
13471
|
+
const handleNodeMouseover = () => {
|
|
13472
|
+
emit("nodeMouseover", props.node);
|
|
13473
|
+
};
|
|
13474
|
+
const handleValueEdit = (e) => {
|
|
13475
|
+
if (!props.editable) return;
|
|
13476
|
+
if (!state.editing) {
|
|
13477
|
+
state.editing = true;
|
|
13478
|
+
const handle = (innerE) => {
|
|
13479
|
+
var _a;
|
|
13480
|
+
if (innerE.target !== e.target && ((_a = innerE.target) == null ? void 0 : _a.parentElement) !== e.target) {
|
|
13481
|
+
state.editing = false;
|
|
13482
|
+
document.removeEventListener("click", handle);
|
|
13483
|
+
}
|
|
13484
|
+
};
|
|
13485
|
+
document.removeEventListener("click", handle);
|
|
13486
|
+
document.addEventListener("click", handle);
|
|
13487
|
+
}
|
|
13488
|
+
};
|
|
13489
|
+
const {
|
|
13490
|
+
copy
|
|
13491
|
+
} = useClipboard();
|
|
13492
|
+
const handleCopy = () => {
|
|
13493
|
+
const {
|
|
13494
|
+
key: key2,
|
|
13495
|
+
path
|
|
13496
|
+
} = props.node;
|
|
13497
|
+
const rootPath = props.rootPath;
|
|
13498
|
+
const content = new Function("data", `return data${path.slice(rootPath.length)}`)(props.data);
|
|
13499
|
+
const copiedData = JSON.stringify(key2 ? {
|
|
13500
|
+
[key2]: content
|
|
13501
|
+
} : content, null, 2);
|
|
13502
|
+
copy(copiedData);
|
|
13503
|
+
};
|
|
13504
|
+
const renderNodeActions = () => {
|
|
13505
|
+
const render2 = props.renderNodeActions;
|
|
13506
|
+
if (!render2) return null;
|
|
13507
|
+
const defaultActions = {
|
|
13508
|
+
copy: handleCopy
|
|
13509
|
+
};
|
|
13510
|
+
return typeof render2 === "function" ? render2({
|
|
13511
|
+
node: props.node,
|
|
13512
|
+
defaultActions
|
|
13513
|
+
}) : createVNode("span", {
|
|
13514
|
+
"onClick": handleCopy,
|
|
13515
|
+
"class": "vjs-tree-node-actions-item"
|
|
13516
|
+
}, [createTextVNode("copy")]);
|
|
13517
|
+
};
|
|
13518
|
+
return () => {
|
|
13519
|
+
const {
|
|
13520
|
+
node
|
|
13521
|
+
} = props;
|
|
13522
|
+
return createVNode("div", {
|
|
13523
|
+
"class": {
|
|
13524
|
+
"vjs-tree-node": true,
|
|
13525
|
+
"has-selector": props.showSelectController,
|
|
13526
|
+
"has-carets": props.showIcon,
|
|
13527
|
+
"is-highlight": props.highlightSelectedNode && props.checked,
|
|
13528
|
+
dark: props.theme === "dark"
|
|
13529
|
+
},
|
|
13530
|
+
"onClick": handleNodeClick,
|
|
13531
|
+
"onMouseover": handleNodeMouseover,
|
|
13532
|
+
"style": props.style
|
|
13533
|
+
}, [props.showLineNumber && createVNode("span", {
|
|
13534
|
+
"class": "vjs-node-index"
|
|
13535
|
+
}, [node.id + 1]), props.showSelectController && selectable.value && node.type !== "objectEnd" && node.type !== "arrayEnd" && createVNode(CheckController, {
|
|
13536
|
+
"isMultiple": isMultiple.value,
|
|
13537
|
+
"checked": props.checked,
|
|
13538
|
+
"onChange": handleSelectedChange
|
|
13539
|
+
}, null), createVNode("div", {
|
|
13540
|
+
"class": "vjs-indent"
|
|
13541
|
+
}, [Array.from(Array(node.level)).map((item, index2) => createVNode("div", {
|
|
13542
|
+
"key": index2,
|
|
13543
|
+
"class": {
|
|
13544
|
+
"vjs-indent-unit": true,
|
|
13545
|
+
"has-line": props.showLine
|
|
13546
|
+
}
|
|
13547
|
+
}, [Array.from(Array(props.indent)).map(() => createVNode(Fragment, null, [createTextVNode(" ")]))])), props.showIcon && createVNode(Carets, {
|
|
13548
|
+
"nodeType": node.type,
|
|
13549
|
+
"onClick": handleIconClick
|
|
13550
|
+
}, null)]), node.key && createVNode("span", {
|
|
13551
|
+
"class": "vjs-key"
|
|
13552
|
+
}, [renderKey(), createVNode("span", {
|
|
13553
|
+
"class": "vjs-colon"
|
|
13554
|
+
}, [`:${props.showKeyValueSpace ? " " : ""}`])]), createVNode("span", null, [node.type !== "content" && node.content ? createVNode(Brackets, {
|
|
13555
|
+
"data": node.content.toString(),
|
|
13556
|
+
"onClick": handleBracketsClick
|
|
13557
|
+
}, null) : createVNode("span", {
|
|
13558
|
+
"class": valueClass.value,
|
|
13559
|
+
"onClick": props.editable && (!props.editableTrigger || props.editableTrigger === "click") ? handleValueEdit : void 0,
|
|
13560
|
+
"onDblclick": props.editable && props.editableTrigger === "dblclick" ? handleValueEdit : void 0
|
|
13561
|
+
}, [props.editable && state.editing ? createVNode("input", {
|
|
13562
|
+
"value": defaultValue.value,
|
|
13563
|
+
"onChange": handleInputChange,
|
|
13564
|
+
"style": {
|
|
13565
|
+
padding: "3px 8px",
|
|
13566
|
+
border: "1px solid #eee",
|
|
13567
|
+
boxShadow: "none",
|
|
13568
|
+
boxSizing: "border-box",
|
|
13569
|
+
borderRadius: 5,
|
|
13570
|
+
fontFamily: "inherit"
|
|
13571
|
+
}
|
|
13572
|
+
}, null) : renderValue()]), node.showComma && createVNode("span", null, [","]), props.showLength && props.collapsed && createVNode("span", {
|
|
13573
|
+
"class": "vjs-comment"
|
|
13574
|
+
}, [createTextVNode(" // "), node.length, createTextVNode(" items ")])]), props.renderNodeActions && createVNode("span", {
|
|
13575
|
+
"class": "vjs-tree-node-actions"
|
|
13576
|
+
}, [renderNodeActions()])]);
|
|
13577
|
+
};
|
|
13578
|
+
}
|
|
13579
|
+
});
|
|
13580
|
+
const BasicJsonViewer = /* @__PURE__ */ defineComponent({
|
|
13581
|
+
name: "JsonTree",
|
|
13582
|
+
props: {
|
|
13583
|
+
...treeNodePropsPass,
|
|
13584
|
+
collapsedNodeLength: {
|
|
13585
|
+
type: Number,
|
|
13586
|
+
default: Infinity
|
|
13587
|
+
},
|
|
13588
|
+
// Define the depth of the tree, nodes greater than this depth will not be expanded.
|
|
13589
|
+
deep: {
|
|
13590
|
+
type: Number,
|
|
13591
|
+
default: Infinity
|
|
13592
|
+
},
|
|
13593
|
+
pathCollapsible: {
|
|
13594
|
+
type: Function,
|
|
13595
|
+
default: () => false
|
|
13596
|
+
},
|
|
13597
|
+
// Whether to use virtual scroll, usually applied to big data.
|
|
13598
|
+
virtual: {
|
|
13599
|
+
type: Boolean,
|
|
13600
|
+
default: false
|
|
13601
|
+
},
|
|
13602
|
+
// When using virtual scroll, set the height of tree.
|
|
13603
|
+
height: {
|
|
13604
|
+
type: Number,
|
|
13605
|
+
default: 400
|
|
13606
|
+
},
|
|
13607
|
+
// When using virtual scroll without dynamicHeight, define the height of each row.
|
|
13608
|
+
itemHeight: {
|
|
13609
|
+
type: Number,
|
|
13610
|
+
default: 20
|
|
13611
|
+
},
|
|
13612
|
+
// Enable dynamic row heights for virtual scroll.
|
|
13613
|
+
dynamicHeight: {
|
|
13614
|
+
type: Boolean,
|
|
13615
|
+
default: true
|
|
13616
|
+
},
|
|
13617
|
+
// When there is a selection function, define the selected path.
|
|
13618
|
+
// For multiple selections, it is an array ['root.a','root.b'], for single selection, it is a string of 'root.a'.
|
|
13619
|
+
selectedValue: {
|
|
13620
|
+
type: [String, Array],
|
|
13621
|
+
default: () => ""
|
|
13622
|
+
},
|
|
13623
|
+
// Collapsed control.
|
|
13624
|
+
collapsedOnClickBrackets: {
|
|
13625
|
+
type: Boolean,
|
|
13626
|
+
default: true
|
|
13627
|
+
},
|
|
13628
|
+
style: {
|
|
13629
|
+
type: Object,
|
|
13630
|
+
default: void 0
|
|
13631
|
+
},
|
|
13632
|
+
onSelectedChange: {
|
|
13633
|
+
type: Function,
|
|
13634
|
+
default: void 0
|
|
13635
|
+
},
|
|
13636
|
+
theme: {
|
|
13637
|
+
type: String,
|
|
13638
|
+
default: "light"
|
|
13639
|
+
}
|
|
13640
|
+
},
|
|
13641
|
+
emits: ["nodeClick", "nodeMouseover", "bracketsClick", "iconClick", "selectedChange", "update:selectedValue", "update:data"],
|
|
13642
|
+
setup(props, {
|
|
13643
|
+
emit,
|
|
13644
|
+
slots
|
|
13645
|
+
}) {
|
|
13646
|
+
const {
|
|
13647
|
+
b
|
|
13648
|
+
} = useNamespace("basic-json-viewer");
|
|
13649
|
+
const treeRef = ref();
|
|
13650
|
+
const originFlatData = computed(() => jsonFlatten(props.data, props.rootPath));
|
|
13651
|
+
const initHiddenPaths = (deep, collapsedNodeLength) => {
|
|
13652
|
+
return originFlatData.value.reduce((acc, item) => {
|
|
13653
|
+
var _a;
|
|
13654
|
+
const doCollapse = item.level >= deep || item.length >= collapsedNodeLength;
|
|
13655
|
+
const pathComparison = (_a = props.pathCollapsible) == null ? void 0 : _a.call(props, item);
|
|
13656
|
+
if ((item.type === "objectStart" || item.type === "arrayStart") && (doCollapse || pathComparison)) {
|
|
13657
|
+
return {
|
|
13658
|
+
...acc,
|
|
13659
|
+
[item.path]: 1
|
|
13660
|
+
};
|
|
13661
|
+
}
|
|
13662
|
+
return acc;
|
|
13663
|
+
}, {});
|
|
13664
|
+
};
|
|
13665
|
+
const state = reactive({
|
|
13666
|
+
translateY: 0,
|
|
13667
|
+
visibleData: null,
|
|
13668
|
+
hiddenPaths: initHiddenPaths(props.deep, props.collapsedNodeLength),
|
|
13669
|
+
startIndex: 0,
|
|
13670
|
+
endIndex: 0
|
|
13671
|
+
});
|
|
13672
|
+
let heights = [];
|
|
13673
|
+
let offsets = [];
|
|
13674
|
+
let totalHeight = 0;
|
|
13675
|
+
const rowRefs = {};
|
|
13676
|
+
const OVERSCAN_COUNT = 5;
|
|
13677
|
+
const initDynamicHeights = (length) => {
|
|
13678
|
+
heights = Array(length).fill(0).map(() => props.itemHeight || 20);
|
|
13679
|
+
offsets = new Array(length + 1);
|
|
13680
|
+
offsets[0] = 0;
|
|
13681
|
+
for (let i = 0; i < length; i++) {
|
|
13682
|
+
offsets[i + 1] = offsets[i] + heights[i];
|
|
13683
|
+
}
|
|
13684
|
+
totalHeight = offsets[length] || 0;
|
|
13685
|
+
};
|
|
13686
|
+
const recomputeOffsetsFrom = (start) => {
|
|
13687
|
+
const length = heights.length;
|
|
13688
|
+
if (start < 0) start = 0;
|
|
13689
|
+
if (start > length) start = length;
|
|
13690
|
+
for (let i = start; i < length; i++) {
|
|
13691
|
+
offsets[i + 1] = offsets[i] + heights[i];
|
|
13692
|
+
}
|
|
13693
|
+
totalHeight = offsets[length] || 0;
|
|
13694
|
+
};
|
|
13695
|
+
const setRowRef = (index2, el) => {
|
|
13696
|
+
if (el) {
|
|
13697
|
+
rowRefs[index2] = el;
|
|
13698
|
+
} else {
|
|
13699
|
+
delete rowRefs[index2];
|
|
13700
|
+
}
|
|
13701
|
+
};
|
|
13702
|
+
const lowerBound = (arr, target) => {
|
|
13703
|
+
let lo = 0;
|
|
13704
|
+
let hi = arr.length - 1;
|
|
13705
|
+
while (lo < hi) {
|
|
13706
|
+
const mid = lo + hi >>> 1;
|
|
13707
|
+
if (arr[mid] < target) lo = mid + 1;
|
|
13708
|
+
else hi = mid;
|
|
13709
|
+
}
|
|
13710
|
+
return lo;
|
|
13711
|
+
};
|
|
13712
|
+
const findStartIndexByScrollTop = (scrollTop) => {
|
|
13713
|
+
const i = lowerBound(offsets, scrollTop + 1e-4);
|
|
13714
|
+
return Math.max(0, Math.min(i - 1, heights.length - 1));
|
|
13715
|
+
};
|
|
13716
|
+
const findEndIndexByViewport = (scrollTop, viewportHeight) => {
|
|
13717
|
+
const target = scrollTop + viewportHeight;
|
|
13718
|
+
const i = lowerBound(offsets, target);
|
|
13719
|
+
return Math.max(0, Math.min(i + 1, heights.length));
|
|
13720
|
+
};
|
|
13721
|
+
const flatData = computed(() => {
|
|
13722
|
+
let startHiddenItem = null;
|
|
13723
|
+
const data = [];
|
|
13724
|
+
const length = originFlatData.value.length;
|
|
13725
|
+
for (let i = 0; i < length; i++) {
|
|
13726
|
+
const cur = originFlatData.value[i];
|
|
13727
|
+
const item = {
|
|
13728
|
+
...cur,
|
|
13729
|
+
id: i
|
|
13730
|
+
};
|
|
13731
|
+
const isHidden = state.hiddenPaths[item.path];
|
|
13732
|
+
if (startHiddenItem && startHiddenItem.path === item.path) {
|
|
13733
|
+
const isObject2 = startHiddenItem.type === "objectStart";
|
|
13734
|
+
const mergeItem = {
|
|
13735
|
+
...item,
|
|
13736
|
+
...startHiddenItem,
|
|
13737
|
+
showComma: item.showComma,
|
|
13738
|
+
content: isObject2 ? "{...}" : "[...]",
|
|
13739
|
+
type: isObject2 ? "objectCollapsed" : "arrayCollapsed"
|
|
13740
|
+
};
|
|
13741
|
+
startHiddenItem = null;
|
|
13742
|
+
data.push(mergeItem);
|
|
13743
|
+
} else if (isHidden && !startHiddenItem) {
|
|
13744
|
+
startHiddenItem = item;
|
|
13745
|
+
continue;
|
|
13746
|
+
} else {
|
|
13747
|
+
if (startHiddenItem) continue;
|
|
13748
|
+
else data.push(item);
|
|
13749
|
+
}
|
|
13750
|
+
}
|
|
13751
|
+
return data;
|
|
13752
|
+
});
|
|
13753
|
+
const selectedPaths = computed(() => {
|
|
13754
|
+
const value = props.selectedValue;
|
|
13755
|
+
if (value && props.selectableType === "multiple" && Array.isArray(value)) {
|
|
13756
|
+
return value;
|
|
13757
|
+
}
|
|
13758
|
+
return [value];
|
|
13759
|
+
});
|
|
13760
|
+
const propsErrorMessage = computed(() => {
|
|
13761
|
+
const error = props.selectableType && !props.selectOnClickNode && !props.showSelectController;
|
|
13762
|
+
return error ? "When selectableType is not null, selectOnClickNode and showSelectController cannot be false at the same time, because this will cause the selection to fail." : "";
|
|
13763
|
+
});
|
|
13764
|
+
const listHeight = computed(() => {
|
|
13765
|
+
if (props.dynamicHeight) {
|
|
13766
|
+
return totalHeight || 0;
|
|
13767
|
+
}
|
|
13768
|
+
return flatData.value.length * props.itemHeight;
|
|
13769
|
+
});
|
|
13770
|
+
const updateVisibleData = () => {
|
|
13771
|
+
var _a;
|
|
13772
|
+
const flatDataValue = flatData.value;
|
|
13773
|
+
if (!flatDataValue) return;
|
|
13774
|
+
if (props.virtual) {
|
|
13775
|
+
const scrollTop = ((_a = treeRef.value) == null ? void 0 : _a.scrollTop) || 0;
|
|
13776
|
+
if (props.dynamicHeight) {
|
|
13777
|
+
if (heights.length !== flatDataValue.length) {
|
|
13778
|
+
initDynamicHeights(flatDataValue.length);
|
|
13779
|
+
}
|
|
13780
|
+
const start = findStartIndexByScrollTop(scrollTop);
|
|
13781
|
+
const endNoOverscan = findEndIndexByViewport(scrollTop, props.height);
|
|
13782
|
+
const startWithOverscan = Math.max(0, start - OVERSCAN_COUNT);
|
|
13783
|
+
const endWithOverscan = Math.min(flatDataValue.length, endNoOverscan + OVERSCAN_COUNT);
|
|
13784
|
+
state.startIndex = startWithOverscan;
|
|
13785
|
+
state.endIndex = endWithOverscan;
|
|
13786
|
+
state.translateY = offsets[startWithOverscan] || 0;
|
|
13787
|
+
state.visibleData = flatDataValue.slice(startWithOverscan, endWithOverscan);
|
|
13788
|
+
nextTick().then(() => {
|
|
13789
|
+
let changed = false;
|
|
13790
|
+
for (let i = state.startIndex; i < state.endIndex; i++) {
|
|
13791
|
+
const el = rowRefs[i];
|
|
13792
|
+
if (!el) continue;
|
|
13793
|
+
const h2 = el.offsetHeight;
|
|
13794
|
+
if (h2 && heights[i] !== h2) {
|
|
13795
|
+
heights[i] = h2;
|
|
13796
|
+
offsets[i + 1] = offsets[i] + heights[i];
|
|
13797
|
+
recomputeOffsetsFrom(i + 1);
|
|
13798
|
+
changed = true;
|
|
13799
|
+
}
|
|
13800
|
+
}
|
|
13801
|
+
if (changed) {
|
|
13802
|
+
updateVisibleData();
|
|
13803
|
+
}
|
|
13804
|
+
});
|
|
13805
|
+
} else {
|
|
13806
|
+
const visibleCount = props.height / props.itemHeight;
|
|
13807
|
+
const scrollCount = Math.floor(scrollTop / props.itemHeight);
|
|
13808
|
+
let start = scrollCount < 0 ? 0 : scrollCount + visibleCount > flatDataValue.length ? flatDataValue.length - visibleCount : scrollCount;
|
|
13809
|
+
if (start < 0) {
|
|
13810
|
+
start = 0;
|
|
13811
|
+
}
|
|
13812
|
+
const end = start + visibleCount;
|
|
13813
|
+
state.translateY = start * props.itemHeight;
|
|
13814
|
+
state.startIndex = start;
|
|
13815
|
+
state.endIndex = end;
|
|
13816
|
+
state.visibleData = flatDataValue.slice(start, end);
|
|
13817
|
+
}
|
|
13818
|
+
} else {
|
|
13819
|
+
state.translateY = 0;
|
|
13820
|
+
state.startIndex = 0;
|
|
13821
|
+
state.endIndex = flatDataValue.length;
|
|
13822
|
+
state.visibleData = flatDataValue;
|
|
13823
|
+
}
|
|
13824
|
+
};
|
|
13825
|
+
let rafId = null;
|
|
13826
|
+
const handleTreeScroll = () => {
|
|
13827
|
+
if (rafId) {
|
|
13828
|
+
cancelAnimationFrame(rafId);
|
|
13829
|
+
}
|
|
13830
|
+
rafId = requestAnimationFrame(() => {
|
|
13831
|
+
updateVisibleData();
|
|
13832
|
+
});
|
|
13833
|
+
};
|
|
13834
|
+
const handleSelectedChange = ({
|
|
13835
|
+
path
|
|
13836
|
+
}) => {
|
|
13837
|
+
const type = props.selectableType;
|
|
13838
|
+
if (type === "multiple") {
|
|
13839
|
+
const index2 = selectedPaths.value.findIndex((item) => item === path);
|
|
13840
|
+
const newVal = [...selectedPaths.value];
|
|
13841
|
+
if (index2 !== -1) {
|
|
13842
|
+
newVal.splice(index2, 1);
|
|
13843
|
+
} else {
|
|
13844
|
+
newVal.push(path);
|
|
13845
|
+
}
|
|
13846
|
+
emit("update:selectedValue", newVal);
|
|
13847
|
+
emit("selectedChange", newVal, [...selectedPaths.value]);
|
|
13848
|
+
} else if (type === "single") {
|
|
13849
|
+
if (selectedPaths.value[0] !== path) {
|
|
13850
|
+
const [oldVal] = selectedPaths.value;
|
|
13851
|
+
const newVal = path;
|
|
13852
|
+
emit("update:selectedValue", newVal);
|
|
13853
|
+
emit("selectedChange", newVal, oldVal);
|
|
13854
|
+
}
|
|
13855
|
+
}
|
|
13856
|
+
};
|
|
13857
|
+
const handleNodeClick = (node) => {
|
|
13858
|
+
emit("nodeClick", node);
|
|
13859
|
+
};
|
|
13860
|
+
const handleNodeMouseover = (node) => {
|
|
13861
|
+
emit("nodeMouseover", node);
|
|
13862
|
+
};
|
|
13863
|
+
const updateCollapsedPaths = (collapsed, path) => {
|
|
13864
|
+
if (collapsed) {
|
|
13865
|
+
state.hiddenPaths = {
|
|
13866
|
+
...state.hiddenPaths,
|
|
13867
|
+
[path]: 1
|
|
13868
|
+
};
|
|
13869
|
+
} else {
|
|
13870
|
+
const newPaths = {
|
|
13871
|
+
...state.hiddenPaths
|
|
13872
|
+
};
|
|
13873
|
+
delete newPaths[path];
|
|
13874
|
+
state.hiddenPaths = newPaths;
|
|
13875
|
+
}
|
|
13876
|
+
};
|
|
13877
|
+
const handleBracketsClick = (collapsed, node) => {
|
|
13878
|
+
if (props.collapsedOnClickBrackets) {
|
|
13879
|
+
updateCollapsedPaths(collapsed, node.path);
|
|
13880
|
+
}
|
|
13881
|
+
emit("bracketsClick", collapsed, node);
|
|
13882
|
+
};
|
|
13883
|
+
const handleIconClick = (collapsed, node) => {
|
|
13884
|
+
updateCollapsedPaths(collapsed, node.path);
|
|
13885
|
+
emit("iconClick", collapsed, node);
|
|
13886
|
+
};
|
|
13887
|
+
const handleValueChange = (value, path) => {
|
|
13888
|
+
const newData = cloneDeep(props.data);
|
|
13889
|
+
const rootPath = props.rootPath;
|
|
13890
|
+
new Function("data", "val", `data${path.slice(rootPath.length)}=val`)(newData, value);
|
|
13891
|
+
emit("update:data", newData);
|
|
13892
|
+
};
|
|
13893
|
+
watchEffect(() => {
|
|
13894
|
+
if (propsErrorMessage.value) {
|
|
13895
|
+
emitError(propsErrorMessage.value);
|
|
13896
|
+
}
|
|
13897
|
+
});
|
|
13898
|
+
watchEffect(() => {
|
|
13899
|
+
if (flatData.value) {
|
|
13900
|
+
if (props.virtual && props.dynamicHeight) {
|
|
13901
|
+
if (heights.length !== flatData.value.length) {
|
|
13902
|
+
initDynamicHeights(flatData.value.length);
|
|
13903
|
+
}
|
|
13904
|
+
}
|
|
13905
|
+
updateVisibleData();
|
|
13906
|
+
}
|
|
13907
|
+
});
|
|
13908
|
+
watch(() => [props.dynamicHeight, props.itemHeight, originFlatData.value.length], () => {
|
|
13909
|
+
if (props.virtual && props.dynamicHeight) {
|
|
13910
|
+
initDynamicHeights(flatData.value.length);
|
|
13911
|
+
nextTick(updateVisibleData);
|
|
13912
|
+
}
|
|
13913
|
+
});
|
|
13914
|
+
watch(() => props.deep, (val) => {
|
|
13915
|
+
if (val) state.hiddenPaths = initHiddenPaths(val, props.collapsedNodeLength);
|
|
13916
|
+
});
|
|
13917
|
+
watch(() => props.collapsedNodeLength, (val) => {
|
|
13918
|
+
if (val) state.hiddenPaths = initHiddenPaths(props.deep, val);
|
|
13919
|
+
});
|
|
13920
|
+
return () => {
|
|
13921
|
+
var _a, _b, _c, _d, _e;
|
|
13922
|
+
const renderNodeKey = (_a = props.renderNodeKey) != null ? _a : slots.renderNodeKey;
|
|
13923
|
+
const renderNodeValue = (_b = props.renderNodeValue) != null ? _b : slots.renderNodeValue;
|
|
13924
|
+
const renderNodeActions = (_d = (_c = props.renderNodeActions) != null ? _c : slots.renderNodeActions) != null ? _d : false;
|
|
13925
|
+
const nodeContent = (_e = state.visibleData) == null ? void 0 : _e.map((item, localIndex) => {
|
|
13926
|
+
const globalIndex = state.startIndex + localIndex;
|
|
13927
|
+
return createVNode("div", {
|
|
13928
|
+
"key": item.id,
|
|
13929
|
+
"ref": (el) => setRowRef(globalIndex, el || null)
|
|
13930
|
+
}, [createVNode(TreeNode$1, {
|
|
13931
|
+
"data": props.data,
|
|
13932
|
+
"rootPath": props.rootPath,
|
|
13933
|
+
"indent": props.indent,
|
|
13934
|
+
"node": item,
|
|
13935
|
+
"collapsed": !!state.hiddenPaths[item.path],
|
|
13936
|
+
"theme": props.theme,
|
|
13937
|
+
"showDoubleQuotes": props.showDoubleQuotes,
|
|
13938
|
+
"showLength": props.showLength,
|
|
13939
|
+
"checked": selectedPaths.value.includes(item.path),
|
|
13940
|
+
"selectableType": props.selectableType,
|
|
13941
|
+
"showLine": props.showLine,
|
|
13942
|
+
"showLineNumber": props.showLineNumber,
|
|
13943
|
+
"showSelectController": props.showSelectController,
|
|
13944
|
+
"selectOnClickNode": props.selectOnClickNode,
|
|
13945
|
+
"nodeSelectable": props.nodeSelectable,
|
|
13946
|
+
"highlightSelectedNode": props.highlightSelectedNode,
|
|
13947
|
+
"editable": props.editable,
|
|
13948
|
+
"editableTrigger": props.editableTrigger,
|
|
13949
|
+
"showIcon": props.showIcon,
|
|
13950
|
+
"showKeyValueSpace": props.showKeyValueSpace,
|
|
13951
|
+
"renderNodeKey": renderNodeKey,
|
|
13952
|
+
"renderNodeValue": renderNodeValue,
|
|
13953
|
+
"renderNodeActions": renderNodeActions,
|
|
13954
|
+
"onNodeClick": handleNodeClick,
|
|
13955
|
+
"onNodeMouseover": handleNodeMouseover,
|
|
13956
|
+
"onBracketsClick": handleBracketsClick,
|
|
13957
|
+
"onIconClick": handleIconClick,
|
|
13958
|
+
"onSelectedChange": handleSelectedChange,
|
|
13959
|
+
"onValueChange": handleValueChange,
|
|
13960
|
+
"class": props.dynamicHeight ? "dynamic-height" : void 0,
|
|
13961
|
+
"style": props.dynamicHeight ? {} : props.itemHeight && props.itemHeight !== 20 ? {
|
|
13962
|
+
lineHeight: `${props.itemHeight}px`
|
|
13963
|
+
} : {}
|
|
13964
|
+
}, null)]);
|
|
13965
|
+
});
|
|
13966
|
+
return createVNode("div", {
|
|
13967
|
+
"ref": treeRef,
|
|
13968
|
+
"class": {
|
|
13969
|
+
[b()]: true,
|
|
13970
|
+
"vjs-tree": true,
|
|
13971
|
+
"is-virtual": props.virtual,
|
|
13972
|
+
dark: props.theme === "dark"
|
|
13973
|
+
},
|
|
13974
|
+
"onScroll": props.virtual ? handleTreeScroll : void 0,
|
|
13975
|
+
"style": props.showLineNumber ? {
|
|
13976
|
+
paddingLeft: `${Number(originFlatData.value.length.toString().length) * 12}px`,
|
|
13977
|
+
...props.style
|
|
13978
|
+
} : props.style
|
|
13979
|
+
}, [props.virtual ? createVNode("div", {
|
|
13980
|
+
"class": "vjs-tree-list",
|
|
13981
|
+
"style": {
|
|
13982
|
+
height: `${props.height}px`
|
|
13983
|
+
}
|
|
13984
|
+
}, [createVNode("div", {
|
|
13985
|
+
"class": "vjs-tree-list-holder",
|
|
13986
|
+
"style": {
|
|
13987
|
+
height: `${listHeight.value}px`
|
|
13988
|
+
}
|
|
13989
|
+
}, [createVNode("div", {
|
|
13990
|
+
"class": "vjs-tree-list-holder-inner",
|
|
13991
|
+
"style": {
|
|
13992
|
+
transform: `translateY(${state.translateY}px)`
|
|
13993
|
+
}
|
|
13994
|
+
}, [nodeContent])])]) : nodeContent]);
|
|
13995
|
+
};
|
|
13996
|
+
}
|
|
13997
|
+
});
|
|
13998
|
+
const XBasicJsonViewer = withInstall(BasicJsonViewer);
|
|
12884
13999
|
const ROW_KEY$1 = "_MAX_ROW_KEY";
|
|
12885
14000
|
const PAGE_SIZE_OPTIONS$1 = [10, 50, 80, 100];
|
|
12886
14001
|
const PAGE_SIZE$1 = 10;
|
|
@@ -12938,7 +14053,7 @@ function useDataSource$1(propsRef, { tableData, getPaginationInfo, setPagination
|
|
|
12938
14053
|
const lastItem = dataSource[dataSource.length - 1];
|
|
12939
14054
|
if (firstItem && lastItem) {
|
|
12940
14055
|
if (!firstItem[ROW_KEY$1] || !lastItem[ROW_KEY$1]) {
|
|
12941
|
-
const data = cloneDeep(unref(dataSourceRef));
|
|
14056
|
+
const data = cloneDeep$1(unref(dataSourceRef));
|
|
12942
14057
|
data.forEach((item) => {
|
|
12943
14058
|
if (!item[ROW_KEY$1]) {
|
|
12944
14059
|
item[ROW_KEY$1] = guid();
|
|
@@ -13005,7 +14120,7 @@ function useDataSource$1(propsRef, { tableData, getPaginationInfo, setPagination
|
|
|
13005
14120
|
return searchInfoRef.value;
|
|
13006
14121
|
}
|
|
13007
14122
|
function mergeListDataRecord(records, key2 = ROW_KEY$1) {
|
|
13008
|
-
const itemList = cloneDeep(getDataSource() || []);
|
|
14123
|
+
const itemList = cloneDeep$1(getDataSource() || []);
|
|
13009
14124
|
const items = mergeArray(itemList, records, key2);
|
|
13010
14125
|
setListData(items);
|
|
13011
14126
|
}
|
|
@@ -18316,7 +19431,7 @@ function useColumns(propsRef, getPaginationRef) {
|
|
|
18316
19431
|
const columnsRef = ref(unref(propsRef).columns);
|
|
18317
19432
|
let cacheColumns = unref(propsRef).columns || [];
|
|
18318
19433
|
const getColumnsRef = computed(() => {
|
|
18319
|
-
const columns = cloneDeep(unref(columnsRef));
|
|
19434
|
+
const columns = cloneDeep$1(unref(columnsRef));
|
|
18320
19435
|
handleFieldColumn(columns);
|
|
18321
19436
|
handleIndexColumn(propsRef, getPaginationRef, columns);
|
|
18322
19437
|
if (!columns) {
|
|
@@ -18337,7 +19452,7 @@ function useColumns(propsRef, getPaginationRef) {
|
|
|
18337
19452
|
}
|
|
18338
19453
|
const getViewColumns = computed(() => {
|
|
18339
19454
|
const viewColumns = filterDefaultHiddenColum(unref(getColumnsRef));
|
|
18340
|
-
const columns = cloneDeep(viewColumns);
|
|
19455
|
+
const columns = cloneDeep$1(viewColumns);
|
|
18341
19456
|
return columns.filter((column) => isIfShow(column));
|
|
18342
19457
|
});
|
|
18343
19458
|
watch(() => unref(propsRef).columns, (columns) => {
|
|
@@ -18356,7 +19471,7 @@ function useColumns(propsRef, getPaginationRef) {
|
|
|
18356
19471
|
});
|
|
18357
19472
|
}
|
|
18358
19473
|
function setColumns(columnList) {
|
|
18359
|
-
const columns = cloneDeep(columnList);
|
|
19474
|
+
const columns = cloneDeep$1(columnList);
|
|
18360
19475
|
if (!isArray$1(columns)) return;
|
|
18361
19476
|
if (columns.length <= 0) {
|
|
18362
19477
|
columnsRef.value = [];
|
|
@@ -18500,7 +19615,7 @@ function useDataSource(propsRef, { tableData, getPaginationInfo, setPagination,
|
|
|
18500
19615
|
const lastItem = dataSource[dataSource.length - 1];
|
|
18501
19616
|
if (firstItem && lastItem) {
|
|
18502
19617
|
if (!firstItem[ROW_KEY] || !lastItem[ROW_KEY]) {
|
|
18503
|
-
const data = cloneDeep(unref(dataSourceRef));
|
|
19618
|
+
const data = cloneDeep$1(unref(dataSourceRef));
|
|
18504
19619
|
data.forEach((item) => {
|
|
18505
19620
|
if (!item[ROW_KEY]) {
|
|
18506
19621
|
item[ROW_KEY] = guid();
|
|
@@ -18598,7 +19713,7 @@ function useDataSource(propsRef, { tableData, getPaginationInfo, setPagination,
|
|
|
18598
19713
|
return unref(getRowKey);
|
|
18599
19714
|
}
|
|
18600
19715
|
function mergeTableDataRecord(records, key2 = ROW_KEY) {
|
|
18601
|
-
const itemList = cloneDeep(getDataSource() || []);
|
|
19716
|
+
const itemList = cloneDeep$1(getDataSource() || []);
|
|
18602
19717
|
const items = mergeArray(itemList, records, key2);
|
|
18603
19718
|
setTableData(items);
|
|
18604
19719
|
}
|
|
@@ -18939,10 +20054,10 @@ function useRowSelection(propsRef, tableData, emit, tableElRef) {
|
|
|
18939
20054
|
setSelection();
|
|
18940
20055
|
}
|
|
18941
20056
|
function getSelectRowKeys() {
|
|
18942
|
-
return cloneDeep$
|
|
20057
|
+
return cloneDeep$2(unref(selectedRowKeysRef));
|
|
18943
20058
|
}
|
|
18944
20059
|
function getSelectRows() {
|
|
18945
|
-
return cloneDeep$
|
|
20060
|
+
return cloneDeep$2(unref(selectedRowRef));
|
|
18946
20061
|
}
|
|
18947
20062
|
function getRowSelection() {
|
|
18948
20063
|
return unref(getRowSelectionRef);
|
|
@@ -23717,7 +24832,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
23717
24832
|
});
|
|
23718
24833
|
useIframeResize(updateRender);
|
|
23719
24834
|
const treeNodePropKeys = ["titleField", "keyField", "checkable", "selectable", "unselectOnClick", "disableAll", "draggable", "droppable", "render", "nodeIndent", "showLine", "showLeftArrow", "showRightArrow"];
|
|
23720
|
-
const
|
|
24835
|
+
const treeNodeProps2 = reactive(pickReadonly(toRefs(props), ...treeNodePropKeys));
|
|
23721
24836
|
__expose({
|
|
23722
24837
|
setData,
|
|
23723
24838
|
setChecked,
|
|
@@ -23774,7 +24889,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
23774
24889
|
style: normalizeStyle({ height: `${unref(topSpaceHeight)}px` })
|
|
23775
24890
|
}, null, 4),
|
|
23776
24891
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(expandAnimation).ready.value ? unref(expandAnimation).topNodes.value : unref(renderNodes), (node) => {
|
|
23777
|
-
return openBlock(), createBlock(unref(XTreeNode), mergeProps({ ref_for: true },
|
|
24892
|
+
return openBlock(), createBlock(unref(XTreeNode), mergeProps({ ref_for: true }, treeNodeProps2, {
|
|
23778
24893
|
key: node[__props.keyField],
|
|
23779
24894
|
data: node,
|
|
23780
24895
|
"get-node": unref(getNode),
|
|
@@ -23809,7 +24924,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
23809
24924
|
class: normalizeClass(unref(transitionWrapperInnerCls))
|
|
23810
24925
|
}, [
|
|
23811
24926
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(expandAnimation).middleNodes.value, (node) => {
|
|
23812
|
-
return openBlock(), createBlock(unref(XTreeNode), mergeProps({ ref_for: true },
|
|
24927
|
+
return openBlock(), createBlock(unref(XTreeNode), mergeProps({ ref_for: true }, treeNodeProps2, {
|
|
23813
24928
|
key: node[__props.keyField],
|
|
23814
24929
|
data: node,
|
|
23815
24930
|
"get-node": unref(getNode),
|
|
@@ -23838,7 +24953,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
23838
24953
|
_: 3
|
|
23839
24954
|
}, 8, ["onAfterEnter", "onAfterLeave"]),
|
|
23840
24955
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(expandAnimation).bottomNodes.value, (node) => {
|
|
23841
|
-
return openBlock(), createBlock(unref(XTreeNode), mergeProps({ ref_for: true },
|
|
24956
|
+
return openBlock(), createBlock(unref(XTreeNode), mergeProps({ ref_for: true }, treeNodeProps2, {
|
|
23842
24957
|
key: node[__props.keyField],
|
|
23843
24958
|
data: node,
|
|
23844
24959
|
"get-node": unref(getNode),
|
|
@@ -24758,8 +25873,8 @@ const components = [
|
|
|
24758
25873
|
XBasicSubPanel,
|
|
24759
25874
|
XBasicRow,
|
|
24760
25875
|
XBasicCol,
|
|
25876
|
+
XBasicJsonViewer,
|
|
24761
25877
|
XTree,
|
|
24762
|
-
XTreeNode,
|
|
24763
25878
|
XTreeSearch,
|
|
24764
25879
|
XTreeDrop,
|
|
24765
25880
|
XBasicViewBar,
|
|
@@ -25436,6 +26551,7 @@ export {
|
|
|
25436
26551
|
XBasicHidden,
|
|
25437
26552
|
XBasicIconOnline,
|
|
25438
26553
|
XBasicIconPicker,
|
|
26554
|
+
XBasicJsonViewer,
|
|
25439
26555
|
XBasicListPage,
|
|
25440
26556
|
XBasicLoading,
|
|
25441
26557
|
vLoading as XBasicLoadingDirective,
|
|
@@ -25481,6 +26597,7 @@ export {
|
|
|
25481
26597
|
basicGradientTitleProps,
|
|
25482
26598
|
basicHelpProps,
|
|
25483
26599
|
basicIconOnlineProps,
|
|
26600
|
+
basicJsonViewerProps,
|
|
25484
26601
|
basicMessageBoxProps,
|
|
25485
26602
|
basicModalProps,
|
|
25486
26603
|
basicRadioGroupProps,
|
|
@@ -25503,6 +26620,8 @@ export {
|
|
|
25503
26620
|
responsiveArray,
|
|
25504
26621
|
setTableGlobalFormat,
|
|
25505
26622
|
setVxeTableTheme,
|
|
26623
|
+
treeNodeProps,
|
|
26624
|
+
treeNodePropsPass$1 as treeNodePropsPass,
|
|
25506
26625
|
useBasicDrawerModal,
|
|
25507
26626
|
useComponentRegister,
|
|
25508
26627
|
useConfigProvider,
|