x-prop-tree 0.8.31 → 0.8.33

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.
@@ -4,6 +4,11 @@ import { t as __exportAll } from "./rolldown-runtime.c6i0pdwe.js";
4
4
  var en_exports = /* @__PURE__ */ __exportAll({ default: () => en_default });
5
5
  var en_default = { "x-prop-tree": {
6
6
  copy: "Copy",
7
+ dlg: { saveChange: {
8
+ title: "Save Changes",
9
+ text: "Do you want to save the changes?"
10
+ } },
11
+ json: "JSON",
7
12
  jsonEditor: "JSON Editor",
8
13
  noAdaptSlot: "No Adapt Slot",
9
14
  noComp: "No Comp",
@@ -4,6 +4,11 @@ import { t as __exportAll } from "./rolldown-runtime.c6i0pdwe.js";
4
4
  var zhHans_exports = /* @__PURE__ */ __exportAll({ default: () => zhHans_default });
5
5
  var zhHans_default = { "x-prop-tree": {
6
6
  copy: "拷贝",
7
+ dlg: { saveChange: {
8
+ title: "保存变化",
9
+ text: "你想要保存变化吗?"
10
+ } },
11
+ json: "JSON",
7
12
  jsonEditor: "JSON编辑器",
8
13
  noAdaptSlot: "没有适配插槽",
9
14
  noComp: "没有组件",
@@ -12,7 +17,8 @@ var zhHans_default = { "x-prop-tree": {
12
17
  reset: "重置",
13
18
  selectAdaptSlot: "选择适配插槽",
14
19
  selectComp: "选择组件",
15
- selectSlot: "选择插槽"
20
+ selectSlot: "选择插槽",
21
+ structuredData: "结构化数据"
16
22
  } };
17
23
 
18
24
  //#endregion
package/dist/index.d.ts CHANGED
@@ -2,6 +2,13 @@
2
2
  export declare function loadLocaleMessagePropTree(locale: string): Promise<{
3
3
  'x-prop-tree': {
4
4
  copy: string;
5
+ dlg: {
6
+ saveChange: {
7
+ title: string;
8
+ text: string;
9
+ };
10
+ };
11
+ json: string;
5
12
  jsonEditor: string;
6
13
  noAdaptSlot: string;
7
14
  noComp: string;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function(){try{document.getElementById(`x-prop-tree`)?.remove();const e = document.createElement(`style`);e.setAttribute(`id`, `x-prop-tree`);const t = document.createTextNode(``);e.appendChild(t);document.head.appendChild(e);}catch(e){console.error('rolldown-plugin-inject-css', e);}})()
2
2
  import { n as isEqual, r as cloneDeep, t as omit } from "./vendor.mu9vrf3y.js";
3
3
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, h, inject, isRef, mergeModels, mergeProps, normalizeStyle, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, ref, renderList, renderSlot, resolveComponent, resolveDirective, toDisplayString, unref, useId, useModel, useTemplateRef, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
4
- import { eventBus, globalObjects, injectDark, injectLocale, openNumberDlg, openPromptDlg, useColor, useSystem, useViewStack } from "x-essential-lib";
4
+ import { eventBus, globalObjects, injectDark, injectLocale, openConfirmDlg, openNumberDlg, openPromptDlg, useColor, useSystem, useViewStack } from "x-essential-lib";
5
5
  import { getElement, getItems, getPropertyDefault, getPropertyDefaultArray, getTag, getTypes, isHexColor, isThemeColor, makeSlotId, parseNumberUnit, pkgs, rules, themeColors, unwrapSlotId } from "x-runtime-lib";
6
6
  import { getListEntry, setCollapse, tidyList } from "x-group-list";
7
7
  import { useI18n } from "vue-i18n";
@@ -1698,43 +1698,24 @@ var icon_default = index_vue_vue_type_script_setup_true_lang_default$11;
1698
1698
  //#region src/components/values/json/editor.vue?vue&type=script&setup=true&lang.ts
1699
1699
  var editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
1700
1700
  __name: "editor",
1701
- props: {
1702
- "modelValue": {
1703
- type: String,
1704
- required: true
1705
- },
1706
- "modelModifiers": {},
1707
- "lock": {
1708
- type: Boolean,
1709
- required: true
1710
- },
1711
- "lockModifiers": {},
1712
- "scale": {
1713
- type: Number,
1714
- required: true
1715
- },
1716
- "scaleModifiers": {}
1717
- },
1718
- emits: [
1719
- "update:modelValue",
1720
- "update:lock",
1721
- "update:scale"
1722
- ],
1701
+ props: { json: {
1702
+ type: String,
1703
+ required: true
1704
+ } },
1723
1705
  setup(__props, { expose: __expose }) {
1724
- const json = useModel(__props, "modelValue");
1725
- const lock = useModel(__props, "lock");
1726
- const scale = useModel(__props, "scale");
1727
1706
  const dark = injectDark();
1728
1707
  const locale = injectLocale();
1729
1708
  const version = injectVersion();
1709
+ const lock = ref(false);
1710
+ const scale = ref(1);
1730
1711
  const target = useTemplateRef("target");
1731
1712
  function onReady() {
1732
- const object = JSON.parse(json.value);
1713
+ const object = JSON.parse(__props.json);
1733
1714
  target.value?.load(object);
1734
1715
  }
1735
1716
  function save() {
1736
1717
  const object = target.value.save();
1737
- json.value = JSON.stringify(object, null, 2);
1718
+ return JSON.stringify(object, null, 2);
1738
1719
  }
1739
1720
  __expose({ save });
1740
1721
  return (_ctx, _cache) => {
@@ -1795,8 +1776,6 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1795
1776
  const { backgroundColor0, backgroundColor1, backgroundColor2 } = useColor();
1796
1777
  const json = useModel(__props, "modelValue");
1797
1778
  const emit = __emit;
1798
- const lock = ref(false);
1799
- const scale = ref(1);
1800
1779
  const contStyle = computed(() => {
1801
1780
  let h = 48;
1802
1781
  if (sysBarAvail.value) h += 24;
@@ -1806,17 +1785,21 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1806
1785
  height: `calc(100% - ${h}px)`
1807
1786
  };
1808
1787
  });
1809
- const title = computed(() => {
1810
- return t("x-prop-tree.jsonEditor");
1811
- });
1812
1788
  const { open } = useViewStack(`propTreejsonEditorDlg${useId()}`);
1813
- onUnmounted(() => {
1814
- open.value = false;
1815
- });
1816
1789
  const editor = useTemplateRef("editor");
1817
- watch(open, (val) => {
1818
- if (!val) editor.value?.save();
1819
- });
1790
+ async function onClose() {
1791
+ try {
1792
+ const newJson = editor.value.save();
1793
+ if (isEqual(newJson, json.value)) return;
1794
+ if (!await openConfirmDlg({
1795
+ title: t("x-prop-tree.dlg.saveChange.title"),
1796
+ text: t("x-prop-tree.dlg.saveChange.text")
1797
+ })) return;
1798
+ json.value = newJson;
1799
+ } finally {
1800
+ open.value = false;
1801
+ }
1802
+ }
1820
1803
  return (_ctx, _cache) => {
1821
1804
  const _component_v_btn = resolveComponent("v-btn");
1822
1805
  const _component_v_sheet = resolveComponent("v-sheet");
@@ -1824,20 +1807,20 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1824
1807
  const _component_v_dialog = resolveComponent("v-dialog");
1825
1808
  return openBlock(), createBlock(_component_v_dialog, {
1826
1809
  modelValue: unref(open),
1827
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => isRef(open) ? open.value = $event : null),
1810
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(open) ? open.value = $event : null),
1828
1811
  attach: "",
1829
1812
  fullscreen: "",
1830
1813
  "no-click-animation": "",
1831
1814
  persistent: "",
1832
1815
  transition: "dialog-bottom-transition",
1833
- onKeydown: _cache[6] || (_cache[6] = withKeys(withModifiers(($event) => open.value = false, ["stop", "prevent"]), ["esc"]))
1816
+ onKeydown: withKeys(withModifiers(onClose, ["stop", "prevent"]), ["esc"])
1834
1817
  }, {
1835
1818
  activator: withCtx(({ props: activatorProps }) => [createVNode(_component_v_btn, mergeProps(activatorProps, {
1836
1819
  block: "",
1837
1820
  density: "comfortable",
1838
1821
  readonly: __props.readonly
1839
1822
  }), {
1840
- default: withCtx(() => [createTextVNode(toDisplayString(title.value), 1)]),
1823
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(t)("x-prop-tree.json")), 1)]),
1841
1824
  _: 1
1842
1825
  }, 16, ["readonly"]), __props.hasDelete ? (openBlock(), createBlock(_component_v_btn, {
1843
1826
  key: 0,
@@ -1868,9 +1851,9 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1868
1851
  density: "comfortable",
1869
1852
  icon: "mdi-close",
1870
1853
  variant: "text",
1871
- onClick: _cache[1] || (_cache[1] = ($event) => open.value = false)
1854
+ onClick: onClose
1872
1855
  }),
1873
- createElementVNode("span", _hoisted_1$10, toDisplayString(title.value), 1),
1856
+ createElementVNode("span", _hoisted_1$10, toDisplayString(unref(t)("x-prop-tree.jsonEditor")), 1),
1874
1857
  createVNode(_component_v_spacer)
1875
1858
  ]),
1876
1859
  _: 1
@@ -1878,22 +1861,13 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1878
1861
  createElementVNode("div", { style: normalizeStyle(contStyle.value) }, [createVNode(editor_default, {
1879
1862
  ref_key: "editor",
1880
1863
  ref: editor,
1881
- modelValue: json.value,
1882
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => json.value = $event),
1883
- lock: lock.value,
1884
- "onUpdate:lock": _cache[3] || (_cache[3] = ($event) => lock.value = $event),
1885
- scale: scale.value,
1886
- "onUpdate:scale": _cache[4] || (_cache[4] = ($event) => scale.value = $event)
1887
- }, null, 8, [
1888
- "modelValue",
1889
- "lock",
1890
- "scale"
1891
- ])], 4)
1864
+ json: json.value
1865
+ }, null, 8, ["json"])], 4)
1892
1866
  ]),
1893
1867
  _: 1
1894
1868
  }, 8, ["color"])]),
1895
1869
  _: 1
1896
- }, 8, ["modelValue"]);
1870
+ }, 8, ["modelValue", "onKeydown"]);
1897
1871
  };
1898
1872
  }
1899
1873
  });
@@ -3584,8 +3558,8 @@ const install = (app) => {
3584
3558
  //#endregion
3585
3559
  //#region src/i18n/index.ts
3586
3560
  async function loadLocaleMessagePropTree(locale) {
3587
- if (locale === "en") return (await import("./i18n-en.iiploulp.js").then((n) => n.t)).default;
3588
- else if (locale === "zhHans") return (await import("./i18n-zhHans.bb5g1fpp.js").then((n) => n.t)).default;
3561
+ if (locale === "en") return (await import("./i18n-en.l2rmrsld.js").then((n) => n.t)).default;
3562
+ else if (locale === "zhHans") return (await import("./i18n-zhHans.mlbij4hp.js").then((n) => n.t)).default;
3589
3563
  else throw new Error(`invalid locale=${locale}`);
3590
3564
  }
3591
3565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-prop-tree",
3
- "version": "0.8.31",
3
+ "version": "0.8.33",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -43,11 +43,11 @@
43
43
  "vue": "^3.5.42",
44
44
  "vue-i18n": "^11.4.10",
45
45
  "vuetify": "^4.2.1",
46
- "x-block-lib": "^0.11.7",
46
+ "x-block-lib": "^0.11.11",
47
47
  "x-error-lib": "^0.6.5",
48
48
  "x-essential-lib": "^0.10.40",
49
49
  "x-group-list": "^0.4.19",
50
- "x-runtime-lib": "^0.10.3",
50
+ "x-runtime-lib": "^0.10.5",
51
51
  "x-state-lib": "^0.4.5"
52
52
  }
53
53
  }