x-prop-tree 0.8.32 → 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,10 @@ 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
+ } },
7
11
  json: "JSON",
8
12
  jsonEditor: "JSON Editor",
9
13
  noAdaptSlot: "No Adapt Slot",
@@ -4,6 +4,10 @@ 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
+ } },
7
11
  json: "JSON",
8
12
  jsonEditor: "JSON编辑器",
9
13
  noAdaptSlot: "没有适配插槽",
package/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@
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
+ };
5
11
  json: string;
6
12
  jsonEditor: string;
7
13
  noAdaptSlot: 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;
@@ -1807,13 +1786,20 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1807
1786
  };
1808
1787
  });
1809
1788
  const { open } = useViewStack(`propTreejsonEditorDlg${useId()}`);
1810
- onUnmounted(() => {
1811
- open.value = false;
1812
- });
1813
1789
  const editor = useTemplateRef("editor");
1814
- watch(open, (val) => {
1815
- if (!val) editor.value?.save();
1816
- });
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
+ }
1817
1803
  return (_ctx, _cache) => {
1818
1804
  const _component_v_btn = resolveComponent("v-btn");
1819
1805
  const _component_v_sheet = resolveComponent("v-sheet");
@@ -1821,13 +1807,13 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1821
1807
  const _component_v_dialog = resolveComponent("v-dialog");
1822
1808
  return openBlock(), createBlock(_component_v_dialog, {
1823
1809
  modelValue: unref(open),
1824
- "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),
1825
1811
  attach: "",
1826
1812
  fullscreen: "",
1827
1813
  "no-click-animation": "",
1828
1814
  persistent: "",
1829
1815
  transition: "dialog-bottom-transition",
1830
- onKeydown: _cache[6] || (_cache[6] = withKeys(withModifiers(($event) => open.value = false, ["stop", "prevent"]), ["esc"]))
1816
+ onKeydown: withKeys(withModifiers(onClose, ["stop", "prevent"]), ["esc"])
1831
1817
  }, {
1832
1818
  activator: withCtx(({ props: activatorProps }) => [createVNode(_component_v_btn, mergeProps(activatorProps, {
1833
1819
  block: "",
@@ -1865,7 +1851,7 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1865
1851
  density: "comfortable",
1866
1852
  icon: "mdi-close",
1867
1853
  variant: "text",
1868
- onClick: _cache[1] || (_cache[1] = ($event) => open.value = false)
1854
+ onClick: onClose
1869
1855
  }),
1870
1856
  createElementVNode("span", _hoisted_1$10, toDisplayString(unref(t)("x-prop-tree.jsonEditor")), 1),
1871
1857
  createVNode(_component_v_spacer)
@@ -1875,22 +1861,13 @@ var index_vue_vue_type_script_setup_true_lang_default$10 = /*@__PURE__*/ defineC
1875
1861
  createElementVNode("div", { style: normalizeStyle(contStyle.value) }, [createVNode(editor_default, {
1876
1862
  ref_key: "editor",
1877
1863
  ref: editor,
1878
- modelValue: json.value,
1879
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => json.value = $event),
1880
- lock: lock.value,
1881
- "onUpdate:lock": _cache[3] || (_cache[3] = ($event) => lock.value = $event),
1882
- scale: scale.value,
1883
- "onUpdate:scale": _cache[4] || (_cache[4] = ($event) => scale.value = $event)
1884
- }, null, 8, [
1885
- "modelValue",
1886
- "lock",
1887
- "scale"
1888
- ])], 4)
1864
+ json: json.value
1865
+ }, null, 8, ["json"])], 4)
1889
1866
  ]),
1890
1867
  _: 1
1891
1868
  }, 8, ["color"])]),
1892
1869
  _: 1
1893
- }, 8, ["modelValue"]);
1870
+ }, 8, ["modelValue", "onKeydown"]);
1894
1871
  };
1895
1872
  }
1896
1873
  });
@@ -3581,8 +3558,8 @@ const install = (app) => {
3581
3558
  //#endregion
3582
3559
  //#region src/i18n/index.ts
3583
3560
  async function loadLocaleMessagePropTree(locale) {
3584
- if (locale === "en") return (await import("./i18n-en.fevhb1gv.js").then((n) => n.t)).default;
3585
- else if (locale === "zhHans") return (await import("./i18n-zhHans.cro9uz6i.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;
3586
3563
  else throw new Error(`invalid locale=${locale}`);
3587
3564
  }
3588
3565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-prop-tree",
3
- "version": "0.8.32",
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.10",
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.4",
50
+ "x-runtime-lib": "^0.10.5",
51
51
  "x-state-lib": "^0.4.5"
52
52
  }
53
53
  }