@worm-print-platform/canvas 1.5.3 → 1.6.1
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/README.md +12 -4
- package/dist/browser-bundle.d.ts +1 -1
- package/dist/canvas.css +6 -1
- package/dist/canvas.js +1173 -119
- package/dist/core/default-template.d.ts +1 -1
- package/dist/core/element-definitions.d.ts +1 -1
- package/dist/core/format.d.ts +1 -1
- package/dist/core/h.d.ts +3 -17
- package/dist/core/icons.d.ts +1 -1
- package/dist/core/plugin.d.ts +4 -3
- package/dist/core/store.d.ts +3 -2
- package/dist/host-contract.d.ts +16 -3
- package/dist/index.cjs +1043 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6225 -4961
- package/dist/print-designer.d.ts +22 -3
- package/dist/shell/binding.d.ts +2 -2
- package/dist/shell/canvas.d.ts +2 -2
- package/dist/shell/code.d.ts +3 -3
- package/dist/shell/color-picker.d.ts +3 -39
- package/dist/shell/controls.d.ts +29 -11
- package/dist/shell/crop-anchor.d.ts +2 -2
- package/dist/shell/elements.d.ts +2 -2
- package/dist/shell/expression-editor.d.ts +3 -28
- package/dist/shell/flow-list.d.ts +2 -4
- package/dist/shell/font-select.d.ts +1 -1
- package/dist/shell/format-bar.d.ts +2 -2
- package/dist/shell/help-content/{advanced-settings.d.ts → en-US/advanced-settings.d.ts} +1 -1
- package/dist/shell/help-content/{changelog.d.ts → en-US/changelog.d.ts} +1 -1
- package/dist/shell/help-content/{faq.d.ts → en-US/faq.d.ts} +1 -1
- package/dist/shell/help-content/{features.d.ts → en-US/features.d.ts} +1 -1
- package/dist/shell/help-content/{getting-started.d.ts → en-US/getting-started.d.ts} +1 -1
- package/dist/shell/help-content/{shortcuts.d.ts → en-US/shortcuts.d.ts} +1 -1
- package/dist/shell/help-content/index.d.ts +4 -1
- package/dist/shell/help-content/th-TH/advanced-settings.d.ts +12 -0
- package/dist/shell/help-content/th-TH/changelog.d.ts +12 -0
- package/dist/shell/help-content/th-TH/faq.d.ts +12 -0
- package/dist/shell/help-content/th-TH/features.d.ts +12 -0
- package/dist/shell/help-content/th-TH/getting-started.d.ts +12 -0
- package/dist/shell/help-content/th-TH/shortcuts.d.ts +12 -0
- package/dist/shell/help-content/zh-CN/advanced-settings.d.ts +12 -0
- package/dist/shell/help-content/zh-CN/changelog.d.ts +12 -0
- package/dist/shell/help-content/zh-CN/faq.d.ts +12 -0
- package/dist/shell/help-content/zh-CN/features.d.ts +12 -0
- package/dist/shell/help-content/zh-CN/getting-started.d.ts +12 -0
- package/dist/shell/help-content/zh-CN/shortcuts.d.ts +12 -0
- package/dist/shell/help-modal.d.ts +6 -1
- package/dist/shell/page-extras.d.ts +1 -1
- package/dist/shell/panels.d.ts +4 -4
- package/dist/shell/plugin-ui.d.ts +1 -1
- package/dist/shell/prop-group.d.ts +1 -1
- package/dist/shell/property-panel.d.ts +1 -1
- package/dist/shell/property-search.d.ts +1 -1
- package/dist/shell/ruler.d.ts +1 -1
- package/dist/shell/table-props.d.ts +1 -1
- package/dist/shell/table.d.ts +1 -1
- package/dist/shell/toolbar-overflow.d.ts +4 -4
- package/dist/shell/toolbar.d.ts +2 -2
- package/dist/shell/watermark.d.ts +1 -1
- package/dist/test-setup.d.ts +7 -0
- package/dist/theme-tokens.d.ts +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/vue3/PrintDesigner.d.ts +24 -1
- package/dist/vue3/PrintHtmlPreview.d.ts +1 -1
- package/dist/vue3/index.cjs +2 -2
- package/dist/vue3/index.d.ts +1 -1
- package/dist/vue3/index.js +85 -75
- package/dist/vue3/previewStyle.d.ts +1 -1
- package/dist/vue3/toolbarOverflow.d.ts +1 -1
- package/package.json +3 -3
package/dist/shell/panels.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/canvas v1.
|
|
2
|
+
* @worm-print-platform/canvas v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
@@ -15,6 +15,6 @@ export declare const ELEMENT_TYPES: {
|
|
|
15
15
|
label: string;
|
|
16
16
|
icon: string;
|
|
17
17
|
}[];
|
|
18
|
-
export declare function renderLeftPanel(ctx: ShellCtx): import("
|
|
19
|
-
export declare function renderPageTabs(ctx: ShellCtx): import("
|
|
20
|
-
export declare function renderStatusBar(ctx: ShellCtx): import("
|
|
18
|
+
export declare function renderLeftPanel(ctx: ShellCtx): import("@worm-print-platform/plugin-kit/dom").El;
|
|
19
|
+
export declare function renderPageTabs(ctx: ShellCtx): import("@worm-print-platform/plugin-kit/dom").El;
|
|
20
|
+
export declare function renderStatusBar(ctx: ShellCtx): import("@worm-print-platform/plugin-kit/dom").El;
|
package/dist/shell/ruler.d.ts
CHANGED
package/dist/shell/table.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/canvas v1.
|
|
2
|
+
* @worm-print-platform/canvas v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
@@ -12,8 +12,8 @@ export interface ToolbarUnitDef {
|
|
|
12
12
|
id: string;
|
|
13
13
|
/** 数值小者先被收进「更多」 */
|
|
14
14
|
order: number;
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/** 面板内分组标题的语言包 key:渲染时按实例 locale 取词,避免模块级常量冻结语言 */
|
|
16
|
+
labelKey: string;
|
|
17
17
|
}
|
|
18
18
|
/** 收纳优先级链:与 Vue 3 轨的 DesignerToolbar / FormatToolbar 声明逐条对应 */
|
|
19
19
|
export declare const TOOLBAR_UNITS: ToolbarUnitDef[];
|
|
@@ -21,7 +21,7 @@ export declare const TOOLBAR_UNITS: ToolbarUnitDef[];
|
|
|
21
21
|
* 「更多」分组节点:触发钮 + 常驻面板(收起时 .is-hidden,不能用条件渲染,
|
|
22
22
|
* 否则落位槽不存在,被收纳的单元会退回行内显示)。
|
|
23
23
|
*/
|
|
24
|
-
export declare function renderMoreGroup(ctx: ShellCtx): import("
|
|
24
|
+
export declare function renderMoreGroup(ctx: ShellCtx): import("@worm-print-platform/plugin-kit/dom").El;
|
|
25
25
|
export declare function applyToolbarOverflow(scope: ParentNode): {
|
|
26
26
|
movedIds: string[];
|
|
27
27
|
overflowRemains: boolean;
|
package/dist/shell/toolbar.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/canvas v1.
|
|
2
|
+
* @worm-print-platform/canvas v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
import type { ShellCtx } from './controls';
|
|
8
|
-
export declare function renderToolbar(ctx: ShellCtx, formatSection: unknown): import("
|
|
8
|
+
export declare function renderToolbar(ctx: ShellCtx, formatSection: unknown): import("@worm-print-platform/plugin-kit/dom").El;
|
package/dist/theme-tokens.d.ts
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/canvas v1.
|
|
2
|
+
* @worm-print-platform/canvas v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
/** 设计器(@worm-print-platform/canvas)当前版本,用于状态栏等 UI 展示 */
|
|
8
|
-
export declare const CANVAS_VERSION = "1.
|
|
8
|
+
export declare const CANVAS_VERSION = "1.6.1";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/canvas v1.
|
|
2
|
+
* @worm-print-platform/canvas v1.6.1
|
|
3
3
|
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
4
|
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
*/
|
|
7
7
|
import type { PropType } from 'vue';
|
|
8
8
|
import type { PrintFontDeclaration } from '@worm-print-platform/core';
|
|
9
|
+
import type { CustomLocaleMessages } from '@worm-print-platform/core/i18n';
|
|
9
10
|
import type { MultiPageTemplateData, PrintBusinessField, RuntimeElement, TemplateData, UploadDesignBackgroundFn, UploadImageFn } from '@worm-print-platform/core/designer';
|
|
10
11
|
import type { PrintDesignerElement } from '../print-designer';
|
|
11
12
|
import type { PrintDesignerThemeConfig, PrintDesignerThemeMode } from '../host-contract';
|
|
@@ -77,6 +78,16 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
77
78
|
type: PropType<PrintDesignerThemeConfig>;
|
|
78
79
|
default: undefined;
|
|
79
80
|
};
|
|
81
|
+
/** 界面语言(BCP47,如 en-US);未传时跟随全局 locale */
|
|
82
|
+
lang: {
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
/** 自定义语言包(对象注入),覆盖内置与插件译文 */
|
|
87
|
+
messages: {
|
|
88
|
+
type: PropType<CustomLocaleMessages>;
|
|
89
|
+
default: undefined;
|
|
90
|
+
};
|
|
80
91
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
81
92
|
[key: string]: any;
|
|
82
93
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -144,6 +155,16 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
144
155
|
type: PropType<PrintDesignerThemeConfig>;
|
|
145
156
|
default: undefined;
|
|
146
157
|
};
|
|
158
|
+
/** 界面语言(BCP47,如 en-US);未传时跟随全局 locale */
|
|
159
|
+
lang: {
|
|
160
|
+
type: StringConstructor;
|
|
161
|
+
default: undefined;
|
|
162
|
+
};
|
|
163
|
+
/** 自定义语言包(对象注入),覆盖内置与插件译文 */
|
|
164
|
+
messages: {
|
|
165
|
+
type: PropType<CustomLocaleMessages>;
|
|
166
|
+
default: undefined;
|
|
167
|
+
};
|
|
147
168
|
}>> & Readonly<{
|
|
148
169
|
onSave?: ((json: string) => any) | undefined;
|
|
149
170
|
onPreview?: (() => any) | undefined;
|
|
@@ -152,6 +173,7 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
152
173
|
fonts: readonly PrintFontDeclaration[];
|
|
153
174
|
designData: Record<string, unknown> | readonly Record<string, unknown>[];
|
|
154
175
|
theme: PrintDesignerThemeMode;
|
|
176
|
+
lang: string;
|
|
155
177
|
isEdit: boolean;
|
|
156
178
|
showHelp: boolean;
|
|
157
179
|
showPreview: boolean;
|
|
@@ -159,6 +181,7 @@ declare const component: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
159
181
|
themeConfig: PrintDesignerThemeConfig;
|
|
160
182
|
uploadImage: UploadImageFn;
|
|
161
183
|
uploadDesignBackground: UploadDesignBackgroundFn;
|
|
184
|
+
messages: CustomLocaleMessages;
|
|
162
185
|
initialTemplate: TemplateData | MultiPageTemplateData;
|
|
163
186
|
initialElements: RuntimeElement[];
|
|
164
187
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/vue3/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue"),U=require("@worm-print-platform/canvas"),C=require("@worm-print-platform/core"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue"),U=require("@worm-print-platform/canvas"),C=require("@worm-print-platform/core"),k=require("@worm-print-platform/core/browser"),g=require("@worm-print-platform/core/designer"),j=require("@worm-print-platform/plugin-kit");function H(e,l){const v=l.map(u=>({...u,options:{...u.options},printElementType:{...u.printElementType}})),o=e.pages;return Array.isArray(o)?{...e,pages:o.map((u,a)=>a===0?{...u,elements:v}:u)}:{...e,elements:v}}const M=n.defineComponent({name:"PrintDesigner",props:{initialTemplate:{type:Object,default:void 0},initialElements:{type:Array,default:void 0},fields:{type:Array,default:void 0},isEdit:{type:Boolean,default:void 0},uploadImage:{type:Function,default:void 0},uploadDesignBackground:{type:Function,default:void 0},showHelp:{type:Boolean,default:void 0},showPreview:{type:Boolean,default:void 0},showSave:{type:Boolean,default:void 0},fonts:{type:Array,default:void 0},designData:{type:[Object,Array],default:void 0},theme:{type:String,default:void 0},themeConfig:{type:Object,default:void 0},lang:{type:String,default:void 0},messages:{type:Object,default:void 0}},emits:{preview:()=>!0,save:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const o=n.ref(null);let u=null,a=null;typeof customElements<"u"&&U.definePrintDesigner();function f(t){if(e.initialTemplate!==void 0){t.template=e.initialTemplate;return}if(e.initialElements===void 0)return;const i=t.getTemplateJson(),m=JSON.parse(i);t.template=H(m,e.initialElements)}function y(){const t=o.value;t&&(f(t),e.fields!==void 0&&(t.fields=e.fields),e.fonts!==void 0&&(t.fonts=e.fonts),e.designData!==void 0&&(t.designData=e.designData),t.uploadImage=e.uploadImage,t.uploadDesignBackground=e.uploadDesignBackground,e.isEdit!==void 0&&(t.isEdit=e.isEdit),e.showHelp!==void 0&&(t.showHelp=e.showHelp),e.showPreview!==void 0&&(t.showPreview=e.showPreview),e.showSave!==void 0&&(t.showSave=e.showSave),e.theme!==void 0&&(t.theme=e.theme),e.themeConfig!==void 0&&(t.themeConfig=e.themeConfig),e.lang!==void 0&&(t.lang=e.lang),e.messages!==void 0&&(t.messages=e.messages))}return n.onMounted(()=>{const t=o.value;t&&(u=i=>l("save",i.detail),a=()=>l("preview"),t.addEventListener("save",u),t.addEventListener("preview",a),y())}),n.onBeforeUnmount(()=>{const t=o.value;u&&t?.removeEventListener("save",u),a&&t?.removeEventListener("preview",a),u=null,a=null}),n.watch(()=>e.initialTemplate,()=>{const t=o.value;t&&f(t)}),n.watch(()=>e.initialElements,()=>{const t=o.value;t&&f(t)}),n.watch(()=>e.fields,t=>{const i=o.value;i&&(i.fields=t??[])}),n.watch(()=>e.fonts,t=>{const i=o.value;i&&(i.fonts=t)}),n.watch(()=>e.designData,t=>{const i=o.value;i&&(i.designData=t)}),n.watch(()=>e.uploadImage,t=>{const i=o.value;i&&(i.uploadImage=t)}),n.watch(()=>e.uploadDesignBackground,t=>{const i=o.value;i&&(i.uploadDesignBackground=t)}),n.watch(()=>e.isEdit,t=>{const i=o.value;i&&t!==void 0&&(i.isEdit=t)}),n.watch(()=>e.showHelp,t=>{const i=o.value;i&&t!==void 0&&(i.showHelp=t)}),n.watch(()=>e.showPreview,t=>{const i=o.value;i&&t!==void 0&&(i.showPreview=t)}),n.watch(()=>e.showSave,t=>{const i=o.value;i&&t!==void 0&&(i.showSave=t)}),n.watch(()=>e.theme,t=>{const i=o.value;i&&t!==void 0&&(i.theme=t)}),n.watch(()=>e.themeConfig,t=>{const i=o.value;i&&t!==void 0&&(i.themeConfig=t)}),n.watch(()=>e.lang,t=>{const i=o.value;i&&t!==void 0&&(i.lang=t)}),n.watch(()=>e.messages,t=>{const i=o.value;i&&t!==void 0&&(i.messages=t)}),v({getTemplateJson(){const t=o.value?.getTemplateJson();return t?JSON.parse(t):void 0},validateTemplate(){return o.value?.validateTemplate()??[]},getGeometryWarnings(){return o.value?.getGeometryWarnings()??[]}}),()=>n.h("print-designer",{ref:o})}}),_=M,I="worm-print-canvas-vue3-preview",F=`
|
|
2
2
|
.pcv3-preview.print-html-preview {
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|
|
@@ -79,4 +79,4 @@
|
|
|
79
79
|
color: #b88230;
|
|
80
80
|
font-size: 11px;
|
|
81
81
|
}
|
|
82
|
-
`;function J(){if(typeof document>"u"||document.getElementById(I))return;const e=document.createElement("style");e.id=I,e.textContent=F,document.head.appendChild(e)}const q=n.defineComponent({name:"PrintHtmlPreview",props:{templateJson:{type:Object,default:void 0},printData:{type:[Object,Array],default:void 0},baseUrl:{type:String,default:void 0},fontBaseUrl:{type:String,default:void 0},renderers:{type:Object,default:void 0}},emits:{rendered:(e,l)=>typeof e=="number"&&typeof l=="number",error:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const
|
|
82
|
+
`;function J(){if(typeof document>"u"||document.getElementById(I))return;const e=document.createElement("style");e.id=I,e.textContent=F,document.head.appendChild(e)}const q=n.defineComponent({name:"PrintHtmlPreview",props:{templateJson:{type:Object,default:void 0},printData:{type:[Object,Array],default:void 0},baseUrl:{type:String,default:void 0},fontBaseUrl:{type:String,default:void 0},renderers:{type:Object,default:void 0}},emits:{rendered:(e,l)=>typeof e=="number"&&typeof l=="number",error:e=>typeof e=="string"},setup(e,{emit:l,expose:v}){const o=n.ref(),u=n.ref(),a=n.ref(!1),f=n.ref(""),y=n.ref([]);let O=0;const t=n.computed(()=>g.resolvePrinterDpi(e.templateJson)),i=n.ref(0),m=n.computed(()=>g.zoomPresets(t.value,i.value,g.paperWidthPx(e.templateJson))),p=n.ref(g.defaultZoomKey(t.value)),z=n.computed(()=>g.zoomValueOf(m.value,p.value)),T=n.computed(()=>g.viewZoomHint(t.value,p.value));function x(){i.value=u.value?.clientWidth??0}function R(){p.value=g.resolveZoomKey(m.value,p.value,t.value)}function D(){g.applyPreviewViewZoom(o.value?.contentWindow?.document,z.value)}function S(){x(),D()}async function r(){if(!e.templateJson){f.value="",a.value=!1;return}const s=++O;a.value=!0,f.value="",y.value=[];try{const{html:d,pageCount:b,copies:c,pageLayouts:P}=await k.renderHtmlPages(e.templateJson,e.printData,e.baseUrl,k.browserCodeRenderer,{fontBaseUrl:e.fontBaseUrl,renderers:e.renderers});if(s!==O)return;y.value=C.collectLayoutWarnings(P??[]);const h=o.value?.contentWindow?.document;h&&(h.open(),h.write(d),h.close()),x(),R(),D(),l("rendered",b,c)}catch(d){if(s!==O)return;f.value=d instanceof Error?d.message:"未知错误",l("error",f.value)}finally{s===O&&(a.value=!1)}}function w(){const s=o.value?.contentWindow;s&&(s.focus(),s.print())}function E(s){m.value.some(d=>d.key===s)&&(p.value=s)}return n.watch(()=>[e.templateJson,e.printData,e.baseUrl,e.fontBaseUrl,e.renderers],()=>{r()},{deep:!0}),n.watch(z,()=>D()),n.onMounted(()=>{J(),x(),R(),window.addEventListener("resize",S),r()}),n.onBeforeUnmount(()=>{O++,window.removeEventListener("resize",S)}),v({print:w,rerender:r,setViewZoom:E,zoomKey:p,presets:m,viewHint:T}),()=>{const s=a.value||!!f.value,d=[];if(f.value?d.push(n.h("div",{key:"error",class:"print-html-preview-error"},[n.h("span",null,`预览渲染失败:${f.value}`)])):a.value&&d.push(n.h("div",{key:"loading",class:"print-html-preview-loading"},"预览渲染中…")),d.push(n.h("iframe",{key:"iframe",ref:o,class:"print-html-preview-iframe",title:"打印预览",style:{display:s?"none":""}})),y.value.length&&!s&&d.push(n.h("div",{key:"warn",class:"print-html-preview-warn",role:"status"},[n.h("span",null,`出纸提示:${y.value.join(";")}`)])),e.templateJson&&!s){const b=m.value.map(c=>n.h("button",{key:c.key,type:"button",class:{"print-html-preview-zoom-btn":!0,active:c.key===p.value},title:c.tip,onClick:()=>{p.value=c.key}},c.label));T.value&&b.push(n.h("span",{class:"print-html-preview-zoom-hint"},T.value)),b.push(n.h("span",{class:"print-html-preview-zoom-note"},"仅屏幕缩放,打印不受影响")),d.push(n.h("div",{key:"zoom",class:"print-html-preview-zoom"},b))}return n.h("div",{ref:u,class:"print-html-preview pcv3-preview"},d)}}}),V=q;function Z(e){return`tb-more-slot-${e}`}const B=j.TOOLBAR_OVERFLOW_KEY,A=2,K=74;function L(){const e=n.shallowRef(null),l=new Map,v=n.reactive(new Map),o=new Map;let u=0;const a=n.ref(new Set),f=n.ref(!1),y=n.computed(()=>[...v.values()].sort((r,w)=>r.order-w.order)),O=n.computed(()=>a.value.size>0);function t(){for(const[r,w]of l){const E=w.offsetWidth;E>0&&o.set(r,E)}}function i(r){const w=getComputedStyle(r),E=Number.parseFloat(w.gap)||A,s=Number.parseFloat(w.paddingLeft)||0,d=Number.parseFloat(w.paddingRight)||0;let b=0;for(const c of Array.from(r.children)){if(c.hasAttribute("data-overflow-more")||c.hasAttribute("data-overflow-spacer"))continue;const P=Math.max(c.offsetWidth,c.scrollWidth);P<=0||(b+=P+E)}return{available:r.clientWidth-s-d,natural:b}}function m(){const r=e.value;if(!r)return;const{available:w,natural:E}=i(r),s=a.value.size>0;s||(u=E,t());const d=y.value.map(h=>({id:h.id,order:h.order,width:o.get(h.id)??0})),b=d.reduce((h,W)=>h-W.width-A,u),c=g.resolveToolbarOverflow({available:w,pinned:b,moreTriggerWidth:K,gap:A,units:d});c.movedIds.length===a.value.size&&c.movedIds.every(h=>a.value.has(h))||(a.value=new Set(c.movedIds)),f.value=c.overflowRemains,s&&a.value.size===0&&n.nextTick(m)}let p=null;function z(r){r!==e.value&&(p?.disconnect(),e.value=r,r&&typeof ResizeObserver<"u"&&(p=new ResizeObserver(()=>m()),p.observe(r)),n.nextTick(m))}function T(r,w){v.set(r.id,r),l.set(r.id,w),n.nextTick(m)}function x(r){l.delete(r),v.delete(r),o.delete(r),n.nextTick(m)}const R=document.createElement("div");function D(r){return a.value.has(r)}function S(r){return a.value,e.value?.querySelector(`[data-overflow-slot="${r}"]`)??R}return n.onUnmounted(()=>p?.disconnect()),{attachRoot:z,registerUnit:T,unregisterUnit:x,refresh:m,movedIds:a,overflowRemains:f,hasMoved:O,chain:y,moved:D,slotEl:S}}function G(){const e=L();return n.provide(B,e),e}function N(){return n.inject(B,null)}function $(){const e=n.ref(new Set),l=document.createElement("div");return{attachRoot:()=>{},registerUnit:()=>{},unregisterUnit:()=>{},refresh:()=>{},movedIds:e,overflowRemains:n.ref(!1),hasMoved:n.computed(()=>!1),chain:n.computed(()=>[]),moved:()=>!1,slotEl:()=>l}}function Y(e){return{mounted(l,v){l.dataset.unit=v.value.id,e.registerUnit(v.value,l)},unmounted(l,v){e.unregisterUnit(v.value.id)}}}Object.defineProperty(exports,"createDefaultTemplate",{enumerable:!0,get:()=>U.createDefaultTemplate});Object.defineProperty(exports,"toRuntimePool",{enumerable:!0,get:()=>U.toRuntimePool});Object.defineProperty(exports,"browserCodeRenderer",{enumerable:!0,get:()=>k.browserCodeRenderer});Object.defineProperty(exports,"renderHtmlPages",{enumerable:!0,get:()=>k.renderHtmlPages});Object.defineProperty(exports,"DEFAULT_DEMO_DATA",{enumerable:!0,get:()=>g.DEFAULT_DEMO_DATA});Object.defineProperty(exports,"getDemoData",{enumerable:!0,get:()=>g.getDemoData});exports.PrintDesigner=_;exports.PrintHtmlPreview=V;exports.TOOLBAR_OVERFLOW=B;exports.createOverflowUnitDirective=Y;exports.createToolbarOverflow=L;exports.emptyToolbarOverflow=$;exports.moreSlotId=Z;exports.provideToolbarOverflow=G;exports.useToolbarOverflow=N;
|
package/dist/vue3/index.d.ts
CHANGED