@robot-admin/naive-ui-components 0.36.0 → 0.37.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/CHANGELOG.md +15 -0
- package/README.md +2 -1
- package/README_EN.md +16 -15
- package/dist/BPMN.cjs +1 -0
- package/dist/BPMN.js +1 -0
- package/dist/C_ActionBar.css +68 -55
- package/dist/C_ActionBar2.cjs +1 -1
- package/dist/C_ActionBar2.js +1 -1
- package/dist/C_AntV.cjs +1 -1
- package/dist/C_AntV.css +156 -153
- package/dist/C_AntV.js +1 -1
- package/dist/C_AntV2.cjs +1 -4
- package/dist/C_AntV2.js +1 -4
- package/dist/C_AudioPlayer.css +74 -61
- package/dist/C_AudioPlayer2.cjs +1 -1
- package/dist/C_AudioPlayer2.js +1 -1
- package/dist/C_AutoComplete.css +3 -3
- package/dist/C_AutoComplete2.cjs +1 -1
- package/dist/C_AutoComplete2.js +1 -1
- package/dist/C_AvatarGroup.css +38 -38
- package/dist/C_AvatarGroup2.cjs +1 -1
- package/dist/C_AvatarGroup2.js +1 -1
- package/dist/C_Barcode.css +9 -9
- package/dist/C_Barcode2.cjs +1 -1
- package/dist/C_Barcode2.js +1 -1
- package/dist/C_Breadcrumb.css +73 -60
- package/dist/C_Breadcrumb2.cjs +1 -1
- package/dist/C_Breadcrumb2.js +1 -1
- package/dist/C_Captcha.css +74 -40
- package/dist/C_Captcha.d.ts +2 -2
- package/dist/C_Captcha2.cjs +1 -1
- package/dist/C_Captcha2.js +1 -1
- package/dist/C_Cascade.css +4 -4
- package/dist/C_Cascade2.cjs +1 -1
- package/dist/C_Cascade2.js +1 -1
- package/dist/C_Chat.css +136 -115
- package/dist/C_Chat2.cjs +1 -1
- package/dist/C_Chat2.js +1 -1
- package/dist/C_City.css +57 -56
- package/dist/C_City2.cjs +1 -1
- package/dist/C_City2.js +1 -1
- package/dist/C_Code.cjs +1 -1
- package/dist/C_Code.css +110 -45
- package/dist/C_Code.js +1 -1
- package/dist/C_Code2.cjs +2 -1
- package/dist/C_Code2.js +2 -1
- package/dist/C_CollapsePanel.css +67 -54
- package/dist/C_CollapsePanel2.cjs +1 -1
- package/dist/C_CollapsePanel2.js +1 -1
- package/dist/C_ContextMenu.css +36 -23
- package/dist/C_ContextMenu2.cjs +1 -1
- package/dist/C_ContextMenu2.js +1 -1
- package/dist/C_Cron.css +144 -131
- package/dist/C_Cron2.cjs +1 -1
- package/dist/C_Cron2.js +1 -1
- package/dist/C_DataPicker.css +84 -84
- package/dist/C_DataPicker.d.ts +2 -2
- package/dist/C_DataPicker2.cjs +1 -1
- package/dist/C_DataPicker2.js +1 -1
- package/dist/C_Date.css +5 -5
- package/dist/C_Date2.cjs +1 -1
- package/dist/C_Date2.js +1 -1
- package/dist/C_Density2.cjs +1 -1
- package/dist/C_Density2.js +1 -1
- package/dist/C_Draggable.css +71 -71
- package/dist/C_Draggable2.cjs +1 -1
- package/dist/C_Draggable2.js +1 -1
- package/dist/C_Editor.css +51 -76
- package/dist/C_Editor2.cjs +1 -1
- package/dist/C_Editor2.js +1 -1
- package/dist/C_FilePreview.css +109 -109
- package/dist/C_FilePreview2.cjs +1 -1
- package/dist/C_FilePreview2.js +1 -1
- package/dist/C_Form.base.css +64 -74
- package/dist/C_Form.cjs +1 -1
- package/dist/C_Form.css +64 -74
- package/dist/C_Form.d.cts +1 -2
- package/dist/C_Form.d.ts +1 -2
- package/dist/C_Form.js +1 -1
- package/dist/C_FormModal.css +69 -56
- package/dist/C_FormModal.d.ts +1 -1
- package/dist/C_FormModal2.cjs +1 -1
- package/dist/C_FormModal2.js +1 -1
- package/dist/C_FormSearch.css +99 -99
- package/dist/C_FormSearch.d.ts +2 -2
- package/dist/C_FormulaEditor.css +171 -150
- package/dist/C_FullCalendar.css +35 -11
- package/dist/C_FullCalendar2.cjs +1 -1
- package/dist/C_FullCalendar2.js +1 -1
- package/dist/C_GlobalSearch.css +221 -200
- package/dist/C_GlobalSearch2.cjs +1 -1
- package/dist/C_GlobalSearch2.js +1 -1
- package/dist/C_Guide.css +37 -24
- package/dist/C_Guide2.cjs +1 -1
- package/dist/C_Guide2.js +1 -1
- package/dist/C_Icon.css +13 -0
- package/dist/C_Icon2.cjs +1 -1
- package/dist/C_Icon2.js +1 -1
- package/dist/C_ImageCropper.css +41 -40
- package/dist/C_ImageCropper2.cjs +1 -1
- package/dist/C_ImageCropper2.js +1 -1
- package/dist/C_Language.css +15 -2
- package/dist/C_Language2.cjs +1 -1
- package/dist/C_Language2.js +1 -1
- package/dist/C_Loading.css +18 -18
- package/dist/C_Loading2.cjs +1 -1
- package/dist/C_Loading2.js +1 -1
- package/dist/C_Login.css +88 -54
- package/dist/C_Login.d.ts +2 -2
- package/dist/C_Login2.cjs +1 -1
- package/dist/C_Login2.js +1 -1
- package/dist/C_Map.css +13 -13
- package/dist/C_Map2.cjs +1 -1
- package/dist/C_Map2.js +1 -1
- package/dist/C_Markdown.css +69 -60
- package/dist/C_Markdown2.cjs +1 -1
- package/dist/C_Markdown2.js +1 -1
- package/dist/C_NotificationCenter.css +173 -199
- package/dist/C_NotificationCenter2.cjs +1 -1
- package/dist/C_NotificationCenter2.js +1 -1
- package/dist/C_OrgChart.css +16 -16
- package/dist/C_OrgChart2.cjs +1 -1
- package/dist/C_OrgChart2.js +1 -1
- package/dist/C_PageLoading.css +33 -33
- package/dist/C_QRCode.css +14 -14
- package/dist/C_QRCode2.cjs +1 -1
- package/dist/C_QRCode2.js +1 -1
- package/dist/C_Select.css +4 -4
- package/dist/C_Select2.cjs +1 -1
- package/dist/C_Select2.js +1 -1
- package/dist/C_Signature.css +25 -25
- package/dist/C_Signature2.cjs +1 -1
- package/dist/C_Signature2.js +1 -1
- package/dist/C_Skeleton.css +28 -16
- package/dist/C_Skeleton2.cjs +1 -1
- package/dist/C_Skeleton2.js +1 -1
- package/dist/C_SplitPane.css +82 -70
- package/dist/C_SplitPane2.cjs +1 -1
- package/dist/C_SplitPane2.js +1 -1
- package/dist/C_Steps.css +48 -48
- package/dist/C_Steps2.cjs +1 -1
- package/dist/C_Steps2.js +1 -1
- package/dist/C_Table.base.css +302 -299
- package/dist/C_Table.css +238 -225
- package/dist/C_Table.d.ts +3 -2
- package/dist/C_Table2.cjs +4 -4
- package/dist/C_Table2.js +4 -4
- package/dist/C_Tabs.css +11 -51
- package/dist/C_TagsView.css +91 -84
- package/dist/C_TagsView2.cjs +1 -1
- package/dist/C_TagsView2.js +1 -1
- package/dist/C_Theme.css +13 -0
- package/dist/C_Time.css +5 -5
- package/dist/C_Time2.cjs +1 -1
- package/dist/C_Time2.js +1 -1
- package/dist/C_Timeline.css +112 -71
- package/dist/C_Timeline2.cjs +1 -1
- package/dist/C_Timeline2.js +1 -1
- package/dist/C_Transfer.css +69 -60
- package/dist/C_Transfer2.cjs +1 -1
- package/dist/C_Transfer2.js +1 -1
- package/dist/C_Tree.css +30 -30
- package/dist/C_Tree.d.ts +3 -2
- package/dist/C_Tree2.cjs +1 -1
- package/dist/C_Tree2.js +1 -1
- package/dist/C_Upload.css +113 -116
- package/dist/C_Upload2.cjs +1 -1
- package/dist/C_Upload2.js +1 -1
- package/dist/C_UserPicker.css +2 -2
- package/dist/C_UserPicker.d.ts +2 -2
- package/dist/C_VideoPlayer.cjs +1 -1
- package/dist/C_VideoPlayer.css +138 -119
- package/dist/C_VideoPlayer.js +1 -1
- package/dist/C_VideoPlayer2.cjs +3 -3
- package/dist/C_VideoPlayer2.js +3 -3
- package/dist/C_VtableGantt.css +37 -40
- package/dist/C_WaterFall.css +55 -46
- package/dist/C_WaterFall2.cjs +1 -1
- package/dist/C_WaterFall2.js +1 -1
- package/dist/C_WorkFlow.css +456 -520
- package/dist/C_WorkFlow.d.ts +2 -2
- package/dist/C_WorkFlow2.cjs +1 -1
- package/dist/C_WorkFlow2.js +1 -1
- package/dist/Card.cjs +1 -1
- package/dist/Card.js +1 -1
- package/dist/Dynamic.cjs +1 -1
- package/dist/Dynamic.js +1 -1
- package/dist/ER.cjs +1 -0
- package/dist/ER.js +1 -0
- package/dist/NodeConfigModal.cjs +1 -1
- package/dist/NodeConfigModal.js +1 -1
- package/dist/SearchFieldSettings.cjs +1 -1
- package/dist/SearchFieldSettings.js +1 -1
- package/dist/Steps.cjs +1 -1
- package/dist/Steps.js +1 -1
- package/dist/Tabs.cjs +1 -1
- package/dist/Tabs.js +1 -1
- package/dist/UML.cjs +4 -0
- package/dist/UML.js +4 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -10
- package/dist/config.d.ts +3 -10
- package/dist/config.js +1 -1
- package/dist/constants.d.cts +2 -2
- package/dist/constants.d.ts +2 -2
- package/dist/constants2.d.cts +2 -2
- package/dist/constants2.d.ts +2 -2
- package/dist/constants4.d.cts +4 -4
- package/dist/constants4.d.ts +4 -4
- package/dist/constants5.d.cts +2 -2
- package/dist/constants5.d.ts +2 -2
- package/dist/context.cjs +1 -0
- package/dist/{useFormConfig.d.cts → context.d.cts} +8 -2
- package/dist/{useFormConfig.d.ts → context.d.ts} +8 -2
- package/dist/context.js +1 -0
- package/dist/createPageLoading.cjs +1 -1
- package/dist/createPageLoading.js +1 -1
- package/dist/data2.d.cts +8 -8
- package/dist/data2.d.ts +8 -8
- package/dist/data3.cjs +1 -1
- package/dist/data3.js +1 -1
- package/dist/dateRange.d.ts +1 -1
- package/dist/editors.d.cts +2 -2
- package/dist/editors.d.ts +2 -2
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.js +1 -1
- package/dist/fieldRenderers.cjs +1 -1
- package/dist/fieldRenderers.js +1 -1
- package/dist/graphics.cjs +1 -1
- package/dist/graphics.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +6 -6
- package/dist/index.vue.d.ts +6 -6
- package/dist/index10.vue.d.cts +5 -2
- package/dist/index10.vue.d.ts +4 -4
- package/dist/index11.vue.d.cts +4 -4
- package/dist/index11.vue.d.ts +4 -4
- package/dist/index12.vue.d.cts +4 -4
- package/dist/index13.vue.d.ts +4 -5
- package/dist/index14.vue.d.cts +4 -5
- package/dist/index15.vue.d.ts +1 -1
- package/dist/index16.vue.d.cts +1 -1
- package/dist/index16.vue.d.ts +3 -3
- package/dist/index17.vue.d.cts +3 -3
- package/dist/index17.vue.d.ts +9 -9
- package/dist/index18.vue.d.cts +9 -9
- package/dist/index18.vue.d.ts +2 -2
- package/dist/index19.vue.d.cts +2 -2
- package/dist/index20.vue.d.ts +1 -1
- package/dist/index21.vue.d.cts +1 -1
- package/dist/index21.vue.d.ts +4 -4
- package/dist/index22.vue.d.cts +4 -4
- package/dist/index24.vue.d.cts +1 -1
- package/dist/index24.vue.d.ts +1 -1
- package/dist/index27.vue.d.cts +1 -1
- package/dist/index27.vue.d.ts +1 -1
- package/dist/index28.vue.d.cts +1 -1
- package/dist/index28.vue.d.ts +1 -1
- package/dist/index3.vue.d.cts +2 -2
- package/dist/index3.vue.d.ts +2 -2
- package/dist/index31.vue.d.cts +2 -2
- package/dist/index31.vue.d.ts +2 -2
- package/dist/index32.vue.d.cts +2 -2
- package/dist/index32.vue.d.ts +2 -2
- package/dist/index4.vue.d.cts +5 -5
- package/dist/index4.vue.d.ts +5 -5
- package/dist/index7.vue.d.ts +4 -2
- package/dist/index8.vue.d.cts +4 -2
- package/dist/index9.vue.d.ts +5 -2
- package/dist/mapUtils.d.cts +1 -1
- package/dist/mapUtils.d.ts +1 -1
- package/dist/readonlyGraph.cjs +1 -0
- package/dist/readonlyGraph.js +1 -0
- package/dist/serializeSearch.cjs +1 -1
- package/dist/serializeSearch.js +1 -1
- package/dist/shared-tokens.css +1 -1
- package/dist/source.cjs +1 -1
- package/dist/source.js +1 -1
- package/dist/style.css +3601 -3554
- package/dist/theme.cjs +1 -0
- package/dist/theme.d.cts +73 -0
- package/dist/theme.d.ts +73 -0
- package/dist/theme.js +1 -0
- package/dist/theme2.cjs +1 -0
- package/dist/theme2.js +1 -0
- package/dist/useCollapsePanel.d.cts +2 -2
- package/dist/useCollapsePanel.d.ts +2 -2
- package/dist/useComponentDensity.cjs +1 -0
- package/dist/useComponentDensity.js +1 -0
- package/dist/useComponentLocale.cjs +1 -1
- package/dist/useComponentLocale.js +1 -1
- package/dist/useComponentTheme.cjs +1 -0
- package/dist/useComponentTheme.js +1 -0
- package/dist/useCropperCore.d.cts +4 -4
- package/dist/useCropperCore.d.ts +4 -4
- package/dist/useDynamicFormState.d.cts +1 -1
- package/dist/useDynamicFormState.d.ts +1 -1
- package/dist/useEdgeInteraction.cjs +1 -0
- package/dist/useEdgeInteraction.d.cts +22 -5
- package/dist/useEdgeInteraction.d.ts +22 -5
- package/dist/useEdgeInteraction.js +1 -0
- package/dist/useFormConfig.cjs +1 -1
- package/dist/useFormConfig.js +1 -1
- package/dist/useFormRenderer.d.cts +1 -1
- package/dist/useFormRenderer.d.ts +1 -1
- package/dist/useFormulaEvaluator.cjs +2 -2
- package/dist/useFormulaEvaluator.js +2 -2
- package/dist/useFullscreen.d.cts +2 -2
- package/dist/useFullscreen.d.ts +2 -2
- package/dist/useGlobalSearch.d.cts +1 -1
- package/dist/useGlobalSearch.d.ts +1 -1
- package/dist/useGraphExport.cjs +1 -0
- package/dist/useGraphExport.js +1 -0
- package/dist/useInfiniteScroll.d.cts +5 -5
- package/dist/useInfiniteScroll.d.ts +5 -5
- package/dist/useQRCode.d.cts +3 -3
- package/dist/useQRCode.d.ts +3 -3
- package/dist/useSignatureHistory.d.cts +5 -5
- package/dist/useSignatureHistory.d.ts +5 -5
- package/dist/useSplitResize.d.cts +4 -4
- package/dist/useSplitResize.d.ts +4 -4
- package/dist/useWorkflowValidation.d.cts +104 -104
- package/dist/useWorkflowValidation.d.ts +104 -104
- package/dist/verification.d.cts +4 -5
- package/dist/verification.d.ts +4 -5
- package/docs/guides/theme.md +81 -0
- package/package.json +1 -1
- /package/dist/{config2.d.ts → component-config.d.ts} +0 -0
|
@@ -264,11 +264,10 @@ declare const __VLS_export: vue.DefineComponent<Props, {
|
|
|
264
264
|
onReady?: ((graph: Graph) => any) | undefined;
|
|
265
265
|
"onData-change"?: ((data: DiagramData) => any) | undefined;
|
|
266
266
|
}>, {
|
|
267
|
-
readonly: boolean;
|
|
268
|
-
theme: "light" | "dark";
|
|
269
|
-
showToolbar: boolean;
|
|
270
|
-
height: string | number;
|
|
271
267
|
width: string | number;
|
|
268
|
+
height: string | number;
|
|
269
|
+
showToolbar: boolean;
|
|
270
|
+
readonly: boolean;
|
|
272
271
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
273
272
|
declare const _default: typeof __VLS_export;
|
|
274
273
|
//#endregion
|
|
@@ -286,7 +285,25 @@ declare function useGraphBase(containerRef: Ref<HTMLElement | undefined>, isDark
|
|
|
286
285
|
scheduleZoomToFit: (delay?: number, padding?: number) => void;
|
|
287
286
|
zoom: (factor: number) => void;
|
|
288
287
|
resizeGraph: () => void;
|
|
289
|
-
updateTheme: (
|
|
288
|
+
updateTheme: () => void;
|
|
289
|
+
themeOptions: ComputedRef<{
|
|
290
|
+
background: {
|
|
291
|
+
color: string;
|
|
292
|
+
};
|
|
293
|
+
grid: {
|
|
294
|
+
visible: boolean;
|
|
295
|
+
type: string;
|
|
296
|
+
args: ({
|
|
297
|
+
color: string;
|
|
298
|
+
thickness: number;
|
|
299
|
+
factor?: undefined;
|
|
300
|
+
} | {
|
|
301
|
+
color: string;
|
|
302
|
+
thickness: number;
|
|
303
|
+
factor: number;
|
|
304
|
+
})[];
|
|
305
|
+
};
|
|
306
|
+
}>;
|
|
290
307
|
};
|
|
291
308
|
//#endregion
|
|
292
309
|
//#region src/components/C_AntV/composables/useGraphExport.d.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={defaultColor:`#A2B1C3`,highlightColor:`#ff4d4f`,strokeWidth:2,highlightStrokeWidth:3,portPositions:[],onDataChange:()=>{},isReadonly:()=>!1};function t(t,n={}){let r={...e,...n},i=()=>{t.value?.getEdges().forEach(e=>{e.attr(`line/stroke`,r.defaultColor),e.attr(`line/strokeWidth`,r.strokeWidth)})},a=e=>{i(),e.attr(`line/stroke`,r.highlightColor),e.attr(`line/strokeWidth`,r.highlightStrokeWidth)},o=(e,t)=>{r.portPositions.forEach(n=>e.attr(`port-${n}/style/opacity`,t))};return{resetEdgeStyles:i,highlightEdge:a,togglePorts:o,bindInteractions:()=>{let e=t.value;e&&(e.on(`edge:click`,({edge:e})=>a(e)),e.on(`edge:dblclick`,({edge:e})=>{r.isReadonly()||(e.remove(),r.onDataChange())}),e.on(`blank:click`,i),e.on(`node:click`,i),e.on(`edge:connected`,()=>{r.isReadonly()||r.onDataChange()}),r.portPositions.length>0&&(e.on(`node:mouseenter`,({node:e})=>o(e,1)),e.on(`node:mouseleave`,({node:e})=>o(e,0))))}}}export{t};
|
package/dist/useFormConfig.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./chunk.cjs`);const e=require(`./density.cjs`),t=require(`./
|
|
1
|
+
require(`./chunk.cjs`);const e=require(`./density.cjs`),t=require(`./context.cjs`);let n=require(`vue`);function r(){return(0,n.getCurrentInstance)()?(0,n.inject)(t.i,{}):{}}function i(e,t){let n=e??{},r=(e,t)=>e||t?{...e,...t}:void 0;return{...t,...n,grid:r(t.grid,n.grid),inline:r(t.inline,n.inline),card:r(t.card,n.card),tabs:r(t.tabs,n.tabs),steps:r(t.steps,n.steps),dynamic:r(t.dynamic,n.dynamic),custom:r(t.custom,n.custom)}}const a={layout:`default`,labelPlacement:`left`,labelWidth:`auto`,size:`medium`,density:`default`,disabled:!1,readonly:!1,showActions:!0,validateOnChange:!1,preserveRemovedFields:!1,submitText:``,resetText:``,submitSuccessText:``,resetSuccessText:``,mode:`create`},o=[`steps`,`custom`];function s(t){return{...a,...t,size:t?.size??e.t(t?.density).size}}function c(e){return!(e.showActions===!1||o.includes(e.layout))}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
package/dist/useFormConfig.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./density.js";import{
|
|
1
|
+
import{t as e}from"./density.js";import{i as t}from"./context.js";import{getCurrentInstance as n,inject as r}from"vue";function i(){return n()?r(t,{}):{}}function a(e,t){let n=e??{},r=(e,t)=>e||t?{...e,...t}:void 0;return{...t,...n,grid:r(t.grid,n.grid),inline:r(t.inline,n.inline),card:r(t.card,n.card),tabs:r(t.tabs,n.tabs),steps:r(t.steps,n.steps),dynamic:r(t.dynamic,n.dynamic),custom:r(t.custom,n.custom)}}const o={layout:`default`,labelPlacement:`left`,labelWidth:`auto`,size:`medium`,density:`default`,disabled:!1,readonly:!1,showActions:!0,validateOnChange:!1,preserveRemovedFields:!1,submitText:``,resetText:``,submitSuccessText:``,resetSuccessText:``,mode:`create`},s=[`steps`,`custom`];function c(t){return{...o,...t,size:t?.size??e(t?.density).size}}function l(e){return!(e.showActions===!1||s.includes(e.layout))}export{l as a,c as i,s as n,i as o,a as r,o as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as OptionItem, D as FormModel, O as FormOption, c as ResolvedFormConfig } from "./context.cjs";
|
|
2
2
|
import * as vue from "vue";
|
|
3
3
|
import { Component, ComputedRef, InjectionKey, Ref, Slots, VNode } from "vue";
|
|
4
4
|
import { FormItemInst } from "naive-ui";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as OptionItem, D as FormModel, O as FormOption, c as ResolvedFormConfig } from "./context.js";
|
|
2
2
|
import * as vue from "vue";
|
|
3
3
|
import { Component, ComputedRef, InjectionKey, Ref, Slots, VNode } from "vue";
|
|
4
4
|
import { FormItemInst } from "naive-ui";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`./chunk.cjs`);const e=require(`./
|
|
2
|
-
`,r:`\r`,t:` `}[t]??t}else o+=t;n+=1}if(!s)throw Error(`第 ${a+1} 个字符处的字符串未闭合`);r({type:`string`,value:o,position:a});continue}let o=e.slice(n,n+2);if([`>=`,`<=`,`==`,`!=`].includes(o)){r({type:`operator`,value:o,position:n}),n+=2;continue}if(`+-*/%><?:`.includes(t)){r({type:`operator`,value:t,position:n}),n+=1;continue}if(`(),`.includes(t)){r({type:`punctuation`,value:t,position:n}),n+=1;continue}let s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(i);if(s){let e=s[0],t=e.toUpperCase();r({type:[`AND`,`OR`,`NOT`].includes(t)?`operator`:`identifier`,value:[`AND`,`OR`,`NOT`].includes(t)?t:e,position:n}),n+=e.length;continue}throw Error(`第 ${n+1} 个字符“${t}”不受支持`)}return t.push({type:`eof`,value:``,position:n}),t}var h=class{cursor=0;nestingDepth=0;constructor(e){this.tokens=e}parse(){let e=this.parseConditional();return this.expect(`eof`),e}current(){return this.tokens[this.cursor]}advance(){return this.tokens[this.cursor++]}consume(e){return this.current().value===e?(this.advance(),!0):!1}expect(e,t){let n=this.current();if(n.type!==e||t!==void 0&&n.value!==t)throw Error(`第 ${n.position+1} 个字符处应为 ${t??e}`);return this.advance()}parseConditional(){if(++this.nestingDepth>100)throw Error(`公式嵌套不能超过 100 层`);try{let e=this.parseOr();if(!this.consume(`?`))return e;let t=this.parseConditional();return this.expect(`operator`,`:`),{kind:`conditional`,condition:e,truthy:t,falsy:this.parseConditional()}}finally{this.nestingDepth--}}parseBinary(e,t){let n=e();for(;t.includes(this.current().value);)n={kind:`binary`,operator:this.advance().value,left:n,right:e()};return n}parseOr(){return this.parseBinary(()=>this.parseAnd(),[`OR`])}parseAnd(){return this.parseBinary(()=>this.parseEquality(),[`AND`])}parseEquality(){return this.parseBinary(()=>this.parseComparison(),[`==`,`!=`])}parseComparison(){return this.parseBinary(()=>this.parseAdditive(),[`>`,`>=`,`<`,`<=`])}parseAdditive(){return this.parseBinary(()=>this.parseMultiplicative(),[`+`,`-`])}parseMultiplicative(){return this.parseBinary(()=>this.parseUnary(),[`*`,`/`,`%`])}parseUnary(){let e=[];for(;[`-`,`+`,`NOT`].includes(this.current().value)&&!(this.current().value===`NOT`&&this.tokens[this.cursor+1]?.value===`(`);)if(e.push(this.advance().value),e.length>100)throw Error(`一元运算不能超过 100 层`);let t=this.parsePrimary();for(let n of e.reverse())t={kind:`unary`,operator:n,value:t};return t}parsePrimary(){let e=this.current();if(e.type===`number`||e.type===`string`)return this.advance(),{kind:`literal`,value:e.type===`number`?Number(e.value):e.value};if(e.type===`variable`)return this.advance(),{kind:`variable`,name:e.value};if(e.type===`identifier`||e.type===`operator`&&[`AND`,`OR`,`NOT`].includes(e.value)){this.advance();let t=e.value.toUpperCase();if(t===`TRUE`||t===`FALSE`)return{kind:`literal`,value:t===`TRUE`};if(this.consume(`(`))return this.parseFunction(t,e);if(t===`NOT`)return{kind:`unary`,operator:`NOT`,value:this.parseUnary()};if(e.type===`identifier`)return{kind:`identifier`,name:e.value}}if(this.consume(`(`)){let e=this.parseConditional();return this.expect(`punctuation`,`)`),e}throw Error(`第 ${e.position+1} 个字符处缺少有效值`)}parseFunction(e,t){if(!Object.prototype.hasOwnProperty.call(f,e))throw Error(`第 ${t.position+1} 个字符处:未知函数“${t.value}”`);let n=[];if(!this.consume(`)`)){do n.push(this.parseConditional());while(this.consume(`,`));this.expect(`punctuation`,`)`)}let[r,i]=e===`IF`?[3,3]:e===`ROUND`?[1,2]:[`AND`,`OR`,`SUM`,`AVG`,`MAX`,`MIN`].includes(e)?[1,1/0]:[1,1];if(n.length<r||n.length>i)throw Error(`第 ${t.position+1} 个字符处:${e} 需要 ${r===i?r:`${r}–${i===1/0?`多个`:i}`} 个参数`);return{kind:`call`,name:e,args:n}}};function g(e,t){if(!Object.prototype.hasOwnProperty.call(t,e)||t[e]==null)throw Error(`变量“${e}”缺少样例数据`);let n=t[e];if(![`number`,`string`,`boolean`].includes(typeof n)||typeof n==`number`&&!Number.isFinite(n))throw Error(`变量“${e}”的数据类型不受支持`);return n}function _(e,t,n){switch(e){case`==`:return t===n;case`!=`:return t!==n;case`+`:return p(t)+p(n);case`-`:return p(t)-p(n);case`*`:return p(t)*p(n);case`/`:return p(t)/p(n);case`%`:return p(t)%p(n);default:if(typeof t==`boolean`||typeof n==`boolean`)throw Error(`运算符 ${e} 不支持布尔值`);return e===`>`?t>n:e===`>=`?t>=n:e===`<`?t<n:t<=n}}function v(e,t,n,r=0){if(r>200)throw Error(`公式计算层数超过安全限制`);let i=e=>v(e,t,n,r+1);switch(e.kind){case`literal`:return e.value;case`variable`:{let r=t.get(e.name);if(!r)throw Error(`未知变量“${e.name}”`);return g(r,n)}case`identifier`:return g(e.name,n);case`conditional`:return i(e.condition)?i(e.truthy):i(e.falsy);case`unary`:{let t=i(e.value);return e.operator===`NOT`?!t:e.operator===`-`?-p(t):p(t)}case`binary`:{let t=i(e.left);return e.operator===`AND`?!!t&&!!i(e.right):e.operator===`OR`?!!t||!!i(e.right):_(e.operator,t,i(e.right))}case`call`:return e.name===`IF`?i(e.args[0])?i(e.args[1]):i(e.args[2]):e.name===`AND`?e.args.every(e=>!!i(e)):e.name===`OR`?e.args.some(e=>!!i(e)):f[e.name](...e.args.map(i))}}function y(e){let t=m(e),n=new h(t).parse();return{tokens:t,evaluate(e,t){let r=v(n,e,t);if(typeof r==`number`&&!Number.isFinite(r))throw Error(`公式计算结果必须是有限数值`);return r}}}function b(e){return m(e)}function x(e,t){let r=(0,n.computed)(()=>new Set(e.value.map(e=>e.name))),i=(0,n.computed)(()=>new Set(e.value.map(e=>e.field))),a=(0,n.computed)(()=>new Set(t.value.map(e=>e.name.toUpperCase()))),o=null;function s(e){try{let t=b(e),n=[],r=0;return t.forEach((i,a)=>{if(i.type===`eof`)return;i.position>r&&n.push({type:`space`,value:e.slice(r,i.position),start:r,end:i.position});let o=e.slice(i.position,t[a+1]?.position??e.length).trimEnd();r=i.position+o.length;let s=t[a+1],c=i.type===`variable`?`variable`:i.type===`number`?`number`:s?.value===`(`&&(i.type===`identifier`||[`AND`,`OR`,`NOT`].includes(i.value))?`function`:i.type===`operator`?`operator`:i.type===`punctuation`?i.value===`,`?`comma`:`paren`:`text`;n.push({type:c,value:c===`variable`?i.value:o,start:i.position,end:r})}),r<e.length&&n.push({type:`space`,value:e.slice(r),start:r,end:e.length}),n}catch{return e?[{type:`text`,value:e,start:0,end:e.length}]:[]}}function c(e){let t=r.value,n=i.value,c=a.value;if(o?.formula===e&&o.names===t&&o.fields===n&&o.functions===c)return o.analysis;let l={tokens:s(e),validation:{valid:!0,message:e.trim()?`语法校验通过`:`尚未输入公式`},compiled:null};if(e.trim())try{l.compiled=y(e);for(let e of l.tokens){if(e.type===`variable`&&!t.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知变量「${e.value}」`);if(e.type===`function`&&!c.has(e.value.toUpperCase()))throw Error(`第 ${e.start+1} 个字符处:未知函数「${e.value}」`);if(e.type===`text`&&/^[A-Za-z_]\w*$/.test(e.value)&&![`TRUE`,`FALSE`].includes(e.value.toUpperCase())&&!n.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知字段「${e.value}」`)}}catch(e){let t=e instanceof Error?e.message:String(e),n=/第 (\d+) 个字符/.exec(t);l.validation={valid:!1,message:t,...n?{position:Number(n[1])-1}:{}},l.compiled=null}return o={formula:e,names:t,fields:n,functions:c,analysis:l},l}function l(e){return c(e).validation}function u(e,t){let n=0,r=``;for(let i of s(e).filter(e=>e.type===`variable`))r+=e.slice(n,i.start)+(t.get(i.value)??`__unknown_${i.value}__`),n=i.end;return r+e.slice(n)}return{tokenize:s,analyze:c,validate:l,toEvalExpression:u,variableNames:r,functionNames:a}}function ee(e){let t=(0,n.computed)(()=>({variables:e.config?.variables??e.variables??[],functions:e.config?.functions??e.functions??s,sampleData:e.config?.sampleData??e.sampleData??{},disabled:e.config?.disabled??e.disabled??!1,placeholder:e.config?.placeholder??e.placeholder??`例如:[完成值] / [目标值] * 100`,height:e.config?.height??e.height??`auto`,showPreview:e.config?.showPreview??e.showPreview??!0,showKeyboard:e.config?.showKeyboard??e.showKeyboard??!0,showVariablePanel:e.config?.showVariablePanel??e.showVariablePanel??!0,editableSampleData:e.config?.editableSampleData??e.editableSampleData??!0,templates:e.config?.templates??e.templates??[]})),r=e.modelValue??``,i=(0,n.ref)(r),a=(0,n.ref)({}),o=x((0,n.computed)(()=>t.value.variables),(0,n.computed)(()=>t.value.functions)),c=(0,n.computed)(()=>o.analyze(i.value)),l=(0,n.computed)(()=>{let e=new Map(Object.entries(t.value.sampleData));for(let[t,n]of Object.entries(a.value))n===null?e.delete(t):e.set(t,n);return Object.fromEntries(e)}),u=(0,n.computed)(()=>new Map(t.value.variables.map(e=>[e.name,e.field]))),d=(0,n.computed)(()=>{let e=c.value.tokens.filter(e=>e.type===`variable`).map(e=>e.value),n=c.value.tokens.filter(e=>e.type===`text`).map(e=>e.value);return t.value.variables.filter(t=>e.includes(t.name)||n.includes(t.field)).map(e=>({...e,value:l.value[e.field]}))}),f=(0,n.computed)(()=>{if(!c.value.validation.valid)return{success:!1,result:void 0,error:c.value.validation.message};if(!c.value.compiled)return{success:!0,result:void 0};try{return{success:!0,result:c.value.compiled.evaluate(u.value,l.value)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}});function p(e,n){!t.value.disabled&&t.value.editableSampleData&&(a.value={...a.value,[e]:n})}function m(){i.value=r,a.value={}}return(0,n.watch)(()=>e.modelValue,e=>{e!==void 0&&e!==i.value&&(i.value=e)}),(0,n.watch)(()=>t.value.sampleData,()=>{a.value={}}),{options:t,formula:i,analysis:c,evalResult:f,usedVariables:d,updateSample:p,reset:m}}const S={class:`formula-input__header`},C=[`readonly`,`aria-invalid`,`placeholder`],w={key:0,class:`formula-input__tokens`,"aria-label":`公式结构预览`},T=(0,n.defineComponent)({name:`FormulaInput`,__name:`FormulaInput`,props:{formula:{},tokens:{},validation:{},variableNames:{},disabled:{type:Boolean,default:!1},placeholder:{default:`例如:[完成值] / [目标值] * 100`}},emits:[`update:formula`],setup(e,{expose:t,emit:r}){let i=e,a=r,o=(0,n.ref)(),s=(0,n.ref)(i.formula),c=`formula-feedback-${(0,n.useId)()}`,l=s.value.length,u=l;(0,n.watch)(s,e=>a(`update:formula`,e),{flush:`sync`}),(0,n.watch)(()=>i.formula,e=>{e!==s.value&&(s.value=e,l=u=e.length)});function d(){o.value&&(l=o.value.selectionStart,u=o.value.selectionEnd)}function f(e,t=l,r=u){if(i.disabled)return;let a=Math.max(0,Math.min(t,s.value.length));s.value=s.value.slice(0,a)+e+s.value.slice(Math.max(a,r)),l=u=a+e.length,(0,n.nextTick)(()=>{o.value?.focus({preventScroll:!0}),o.value?.setSelectionRange(l,u)})}function p(e){f(e)}function m(){if(l!==u){f(``);return}if(l===0)return;let e=i.tokens.find(e=>e.type===`variable`&&e.end===l),t=Array.from(s.value.slice(0,l)).pop()?.length??1;f(``,e?.start??l-t,u)}function h(){f(``,0,s.value.length)}function g(){l=u=s.value.length,o.value?.setSelectionRange(l,u)}function _(){o.value?.focus({preventScroll:!0}),g()}function v(){let e=i.validation.position??0;o.value?.focus({preventScroll:!0}),o.value?.setSelectionRange(e,Math.min(e+1,s.value.length)),d()}return t({insertAtCursor:p,backspace:m,clear:h,focus:_,moveCursorToEnd:g}),(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{class:(0,n.normalizeClass)([`formula-input`,{"formula-input--disabled":e.disabled,"formula-input--error":!e.validation.valid&&e.formula.trim()}])},[(0,n.createElementVNode)(`div`,S,[r[1]||=(0,n.createElementVNode)(`span`,{class:`formula-input__label`},`01 / 编辑公式`,-1),e.formula.trim()&&!e.disabled?((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:0,type:`button`,class:`formula-input__clear`,onClick:h},`清空公式`)):(0,n.createCommentVNode)(`v-if`,!0)]),(0,n.withDirectives)((0,n.createElementVNode)(`textarea`,{ref_key:`editorRef`,ref:o,"onUpdate:modelValue":r[0]||=e=>s.value=e,class:`formula-input__editor`,readonly:e.disabled,"aria-label":`公式输入`,"aria-invalid":!e.validation.valid&&!!e.formula.trim(),"aria-describedby":c,placeholder:e.placeholder,spellcheck:`false`,onSelect:d,onClick:d,onKeyup:d,onBlur:d},null,40,C),[[n.vModelText,s.value]]),e.tokens.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,w,[r[2]||=(0,n.createElementVNode)(`span`,{class:`formula-input__tokens-label`},`结构预览`,-1),((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.tokens,(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`span`,{key:t,class:(0,n.normalizeClass)(`formula-token formula-token--${e.type}`)},(0,n.toDisplayString)(e.type===`variable`?`[${e.value}]`:e.value),3))),128))])):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`div`,{id:c,class:`formula-input__validation`,role:`status`},[(0,n.createElementVNode)(`span`,{class:(0,n.normalizeClass)(e.formula.trim()?e.validation.valid?`formula-input__validation-success`:`formula-input__validation-error`:`formula-input__validation-hint`)},(0,n.toDisplayString)(e.formula.trim()?e.validation.valid?`语法校验通过,可在右侧调整数据试算。`:e.validation.message:`点击左侧变量开始,也可以直接输入 [变量名]。`),3),e.validation.position===void 0?(0,n.createCommentVNode)(`v-if`,!0):((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:0,type:`button`,class:`formula-input__locate`,onClick:v},`定位错误`))])],2))}});var E=t.t(T,[[`__scopeId`,`data-v-5b2f30eb`]]);const D={class:`variable-panel`},O={class:`variable-panel__tabs`},k=[`aria-pressed`],A=[`aria-pressed`],j={class:`variable-panel__search`},M=[`aria-expanded`,`onClick`],N={class:`variable-panel__items`},P=[`disabled`,`onClick`],F={key:0},I=[`disabled`,`onClick`],L={class:`variable-panel__func-name`},R={class:`variable-panel__func-desc`},z={class:`variable-panel__func-sig`},B=(0,n.defineComponent)({__name:`VariablePanel`,props:{variables:{},functions:{},disabled:{type:Boolean}},emits:[`select-variable`,`select-function`],setup(t){let i=t,a=(0,n.ref)(`variable`),o=(0,n.ref)(``),s=(0,n.ref)(new Set),c=(0,n.computed)(()=>{let e=o.value.toLowerCase(),t=e?i.variables.filter(t=>t.name.toLowerCase().includes(e)||t.field.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)):i.variables,n=new Map;for(let e of t){let t=e.group??`其他`,r=n.get(t);r?r.push(e):n.set(t,[e])}return Array.from(n,([e,t])=>({name:e,items:t}))});(0,n.watch)(c,e=>{for(let t of e)s.value.add(t.name)},{immediate:!0});function l(e){s.value.has(e)?s.value.delete(e):s.value.add(e)}let u=(0,n.computed)(()=>{let e=o.value.toLowerCase();return e?i.functions.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)):i.functions});function d(e){switch(e){case`number`:return`mdi:numeric`;case`text`:return`mdi:format-text`;case`boolean`:return`mdi:toggle-switch-outline`;default:return`mdi:variable`}}return(i,f)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,D,[(0,n.createCommentVNode)(` 切换 Tab:变量 / 函数 `),(0,n.createElementVNode)(`div`,O,[(0,n.createElementVNode)(`button`,{type:`button`,class:(0,n.normalizeClass)([`variable-panel__tab`,{"variable-panel__tab--active":a.value===`variable`}]),"aria-pressed":a.value===`variable`,onClick:f[0]||=e=>a.value=`variable`},` 可用变量 `,10,k),(0,n.createElementVNode)(`button`,{type:`button`,class:(0,n.normalizeClass)([`variable-panel__tab`,{"variable-panel__tab--active":a.value===`function`}]),"aria-pressed":a.value===`function`,onClick:f[1]||=e=>a.value=`function`},` 常用函数 `,10,A)]),(0,n.createCommentVNode)(` 搜索框 `),(0,n.createElementVNode)(`div`,j,[(0,n.createVNode)((0,n.unref)(r.NInput),{value:o.value,"onUpdate:value":f[2]||=e=>o.value=e,size:`small`,placeholder:`搜索变量或函数`,"input-props":{"aria-label":`搜索变量或函数`},clearable:``},{prefix:(0,n.withCtx)(()=>[(0,n.createVNode)(e.t,{name:`mdi:magnify`,size:16})]),_:1},8,[`value`])]),(0,n.createCommentVNode)(` 变量列表 `),a.value===`variable`?((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(r.NScrollbar),{key:0,class:`variable-panel__list`},{default:(0,n.withCtx)(()=>[c.value.length>0?((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,{key:0},(0,n.renderList)(c.value,r=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:r.name,class:`variable-panel__group`},[(0,n.createElementVNode)(`button`,{type:`button`,class:`variable-panel__group-title`,"aria-expanded":s.value.has(r.name),onClick:e=>l(r.name)},[(0,n.createVNode)(e.t,{name:s.value.has(r.name)?`mdi:chevron-down`:`mdi:chevron-right`,size:16},null,8,[`name`]),(0,n.createTextVNode)(` `+(0,n.toDisplayString)(r.name),1)],8,M),(0,n.withDirectives)((0,n.createElementVNode)(`div`,N,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(r.items,r=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:r.field,type:`button`,class:`variable-panel__item`,disabled:t.disabled,onClick:e=>i.$emit(`select-variable`,r)},[(0,n.createVNode)(e.t,{name:d(r.type),size:15,class:`variable-panel__item-icon`},null,8,[`name`]),(0,n.createElementVNode)(`span`,null,[(0,n.createTextVNode)((0,n.toDisplayString)(r.name),1),r.description?((0,n.openBlock)(),(0,n.createElementBlock)(`small`,F,(0,n.toDisplayString)(r.description),1)):(0,n.createCommentVNode)(`v-if`,!0)])],8,P))),128))],512),[[n.vShow,s.value.has(r.name)]])]))),128)):((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(r.NEmpty),{key:1,size:`small`,description:`无匹配变量`}))]),_:1})):((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:1},[(0,n.createCommentVNode)(` 函数列表 `),(0,n.createVNode)((0,n.unref)(r.NScrollbar),{class:`variable-panel__list`},{default:(0,n.withCtx)(()=>[u.value.length>0?((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,{key:0},(0,n.renderList)(u.value,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:e.name,type:`button`,class:`variable-panel__func`,disabled:t.disabled,onClick:t=>i.$emit(`select-function`,e)},[(0,n.createElementVNode)(`div`,L,[f[3]||=(0,n.createElementVNode)(`span`,{class:`variable-panel__func-badge`},`ƒ`,-1),(0,n.createTextVNode)(` `+(0,n.toDisplayString)(e.name),1)]),(0,n.createElementVNode)(`div`,R,(0,n.toDisplayString)(e.description),1),(0,n.createElementVNode)(`div`,z,(0,n.toDisplayString)(e.signature),1)],8,I))),128)):((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(r.NEmpty),{key:1,size:`small`,description:`无匹配函数`}))]),_:1})],2112))]))}});var V=t.t(B,[[`__scopeId`,`data-v-2d73fec7`]]);const H={class:`virtual-keyboard`,role:`group`,"aria-label":`公式键盘`},U={key:0,class:`virtual-keyboard__functions`},W={class:`virtual-keyboard__function-grid`},G=[`disabled`,`title`,`aria-label`,`onClick`],K={class:`virtual-keyboard__body`},q={class:`virtual-keyboard__operators`},J={class:`virtual-keyboard__label`},Y=[`disabled`,`aria-label`,`onClick`],te={class:`virtual-keyboard__numbers`},X={class:`virtual-keyboard__keys virtual-keyboard__keys--numbers`},Z=[`disabled`,`aria-label`,`onClick`],Q={class:`virtual-keyboard__footer`},ne={class:`virtual-keyboard__actions`},re=[`disabled`,`aria-label`,`onClick`],ie=(0,n.defineComponent)({name:`VirtualKeyboard`,__name:`VirtualKeyboard`,props:{disabled:{type:Boolean,default:!1},functions:{default:()=>[]}},emits:[`key-press`,`insert-function`,`action`],setup(t){let r=a.filter(e=>e.type===`number`),s=o.map(e=>({...e,label:e.value===`BACKSPACE`?`退格`:e.label,icon:e.value===`BACKSPACE`?`M9 4h12v16H9L2 12zM9.9 6 4.6 12l5.3 6H19V6zM11 8l6 6-1.4 1.4-6-6zM15.6 8 17 9.4l-6 6-1.4-1.4z`:`M5 5h14v2H5zM9 2h6v2H9zM7 8h2v11h6V8h2v13H7zM10 8h1v9h-1zM13 8h1v9h-1z`})),c=[{name:`arithmetic`,label:`四则与取余`,keys:[...a,...i].filter(e=>e.type===`operator`)},{name:`compare`,label:`比较判断`,keys:i.filter(e=>e.type===`compare`)},{name:`logic`,label:`括号与条件`,keys:i.filter(e=>e.type===`paren`||e.type===`logic`)}];return(i,a)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,H,[t.functions.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,U,[a[1]||=(0,n.createElementVNode)(`span`,{class:`virtual-keyboard__label`},`函数快捷输入`,-1),(0,n.createElementVNode)(`div`,W,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(t.functions,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:e.name,type:`button`,class:`virtual-keyboard__function`,disabled:t.disabled,title:`${e.signature} · ${e.description}`,"aria-label":`插入函数 ${e.name}`,onClick:t=>i.$emit(`insert-function`,e)},[(0,n.createTextVNode)((0,n.toDisplayString)(e.name),1),a[0]||=(0,n.createElementVNode)(`span`,null,`( )`,-1)],8,G))),128))])])):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`div`,K,[(0,n.createElementVNode)(`div`,q,[((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(c,e=>(0,n.createElementVNode)(`section`,{key:e.label,class:`virtual-keyboard__group`},[(0,n.createElementVNode)(`h3`,J,(0,n.toDisplayString)(e.label),1),(0,n.createElementVNode)(`div`,{class:(0,n.normalizeClass)([`virtual-keyboard__keys`,`virtual-keyboard__keys--${e.name}`])},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.keys,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:e.value,type:`button`,class:(0,n.normalizeClass)([`virtual-keyboard__key`,e.color&&`virtual-keyboard__key--${e.color}`]),disabled:t.disabled,"aria-label":`插入 ${e.label}`,onClick:t=>i.$emit(`key-press`,e)},(0,n.toDisplayString)(e.label),11,Y))),128))],2)])),64))]),(0,n.createElementVNode)(`section`,te,[a[2]||=(0,n.createElementVNode)(`h3`,{class:`virtual-keyboard__label`},`数字输入`,-1),(0,n.createElementVNode)(`div`,X,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(r),e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:e.value,type:`button`,class:(0,n.normalizeClass)([`virtual-keyboard__key`,{"virtual-keyboard__key--zero":e.value===`0`}]),disabled:t.disabled,"aria-label":`输入 ${e.label}`,onClick:t=>i.$emit(`key-press`,e)},(0,n.toDisplayString)(e.label),11,Z))),128))])])]),(0,n.createElementVNode)(`footer`,Q,[a[3]||=(0,n.createElementVNode)(`span`,null,`按键会插入到光标处,选中文字可直接替换。`,-1),(0,n.createElementVNode)(`div`,ne,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(s),r=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:r.value,type:`button`,class:(0,n.normalizeClass)([`virtual-keyboard__action`,{"virtual-keyboard__action--clear":r.value===`CLEAR`}]),disabled:t.disabled,"aria-label":r.label,onClick:e=>i.$emit(`action`,r.value)},[(0,n.createVNode)(e.t,{type:`svg`,"svg-path":r.icon,size:16},null,8,[`svg-path`]),(0,n.createTextVNode)((0,n.toDisplayString)(r.label),1)],10,re))),128))])])]))}});var ae=t.t(ie,[[`__scopeId`,`data-v-05f0982d`]]);const oe={class:`formula-preview`,"aria-label":`公式试算`},se={class:`formula-preview__result-label`},ce={key:0,class:`formula-preview__result-value`},le={key:1,class:`formula-preview__result-empty`},ue={class:`formula-preview__vars`},de={class:`formula-preview__vars-title`},fe={class:`formula-preview__var-heading`},pe=[`for`],me={key:3,class:`formula-preview__var-value`},he={key:4},ge={key:0,class:`formula-preview__empty`},_e=(0,n.defineComponent)({name:`FormulaPreview`,__name:`FormulaPreview`,props:{formula:{},evalResult:{},usedVariables:{},editable:{type:Boolean}},emits:[`update-value`],setup(e,{emit:t}){let i=t,a=`formula-sample-${(0,n.useId)()}`;function o(e){return typeof e==`number`?new Intl.NumberFormat(void 0,{maximumFractionDigits:6}).format(e):typeof e==`boolean`?e?`真 · true`:`假 · false`:String(e)}return(t,s)=>((0,n.openBlock)(),(0,n.createElementBlock)(`aside`,oe,[s[1]||=(0,n.createElementVNode)(`header`,null,[(0,n.createElementVNode)(`span`,{class:`formula-preview__step`},`02`),(0,n.createElementVNode)(`div`,null,[(0,n.createElementVNode)(`h3`,null,`验证计算结果`),(0,n.createElementVNode)(`p`,null,`调整试算值,观察规则是否符合预期。`)])],-1),(0,n.createElementVNode)(`div`,{class:(0,n.normalizeClass)([`formula-preview__result`,{"formula-preview__result--error":!!e.evalResult.error}]),role:`status`,"aria-live":`polite`},[(0,n.createElementVNode)(`span`,se,(0,n.toDisplayString)(e.evalResult.error?`暂时无法计算`:`试算结果`),1),e.evalResult.success&&e.evalResult.result!==void 0?((0,n.openBlock)(),(0,n.createElementBlock)(`output`,ce,(0,n.toDisplayString)(o(e.evalResult.result)),1)):((0,n.openBlock)(),(0,n.createElementBlock)(`span`,le,(0,n.toDisplayString)(e.formula.trim()?e.evalResult.error||`等待数据`:`输入公式后展示结果`),1))],2),(0,n.createElementVNode)(`div`,ue,[(0,n.createElementVNode)(`div`,de,[s[0]||=(0,n.createTextVNode)(`本次使用的试算值 `,-1),(0,n.createElementVNode)(`span`,null,(0,n.toDisplayString)(e.usedVariables.length)+` 项`,1)]),((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(e.usedVariables,t=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:t.field,class:`formula-preview__var-row`},[(0,n.createElementVNode)(`div`,fe,[(0,n.createElementVNode)(`label`,{for:`${a}-${t.field}`},(0,n.toDisplayString)(t.name),9,pe),(0,n.createElementVNode)(`code`,null,(0,n.toDisplayString)(t.field),1)]),e.editable&&t.type===`number`?((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(r.NInputNumber),{key:0,value:typeof t.value==`number`?t.value:null,"input-props":{id:`${a}-${t.field}`,"aria-label":`试算值:${t.name}`},placeholder:`请输入数值`,"onUpdate:value":e=>i(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):e.editable&&t.type===`boolean`?((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(r.NSwitch),{key:1,value:t.value===!0,"aria-label":`试算值:${t.name}`,"onUpdate:value":e=>i(`update-value`,t.field,e)},null,8,[`value`,`aria-label`,`onUpdate:value`])):e.editable&&t.type===`text`?((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(r.NInput),{key:2,value:typeof t.value==`string`?t.value:``,"input-props":{id:`${a}-${t.field}`,"aria-label":`试算值:${t.name}`},"onUpdate:value":e=>i(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):((0,n.openBlock)(),(0,n.createElementBlock)(`span`,me,(0,n.toDisplayString)(t.value??`未提供`),1)),t.description?((0,n.openBlock)(),(0,n.createElementBlock)(`p`,he,(0,n.toDisplayString)(t.description),1)):(0,n.createCommentVNode)(`v-if`,!0)]))),128)),e.usedVariables.length?(0,n.createCommentVNode)(`v-if`,!0):((0,n.openBlock)(),(0,n.createElementBlock)(`p`,ge,(0,n.toDisplayString)(e.formula.trim()?`当前公式没有引用变量。`:`引用变量后,对应数据会出现在这里。`),1))]),s[2]||=(0,n.createElementVNode)(`p`,{class:`formula-preview__note`},`试算值仅用于本次验证,修改不会写入业务数据。`,-1)]))}});var ve=t.t(_e,[[`__scopeId`,`data-v-b2656900`]]);const ye={class:`c-formula__title-row`},be={class:`c-formula__actions`},$={key:0,class:`c-formula__templates`,"aria-label":`公式模板`},xe=[`disabled`,`aria-pressed`,`onClick`],Se={key:0,class:`c-formula__sidebar`},Ce={class:`c-formula__main`},we={key:0,class:`c-formula__keyboard`,open:``},Te={class:`c-formula__guide`},Ee=(0,n.defineComponent)({name:`C_FormulaEditor`,__name:`index`,props:{modelValue:{},config:{},variables:{},functions:{},sampleData:{},disabled:{type:Boolean,default:!1},placeholder:{},height:{},showPreview:{type:Boolean,default:!0},showKeyboard:{type:Boolean,default:!0},showVariablePanel:{type:Boolean,default:!0},editableSampleData:{type:Boolean,default:!0},templates:{}},emits:[`update:modelValue`,`change`,`validation-change`],setup(t,{expose:i,emit:a}){let o=t,s=a,{options:c,formula:l,analysis:u,evalResult:d,usedVariables:f,updateSample:p,reset:m}=ee(o),h=(0,n.ref)();(0,n.watch)(l,e=>{s(`update:modelValue`,e),s(`change`,e)}),(0,n.watch)(()=>u.value.validation,e=>s(`validation-change`,e),{immediate:!0});function g(e){c.value.disabled||(l.value=e)}function _(e){c.value.disabled||h.value?.insertAtCursor(e)}function v(e){c.value.disabled||(e===`BACKSPACE`&&h.value?.backspace(),e===`CLEAR`&&h.value?.clear())}return i({getValue:()=>l.value,setValue:e=>{l.value=e},reset:m,validate:()=>u.value.validation,insertAtCursor:_,focus:()=>h.value?.focus()}),(t,i)=>((0,n.openBlock)(),(0,n.createElementBlock)(`section`,{class:`c-formula`,style:(0,n.normalizeStyle)({height:typeof(0,n.unref)(c).height==`number`?`${(0,n.unref)(c).height}px`:(0,n.unref)(c).height}),"aria-label":`公式编辑器`},[(0,n.createElementVNode)(`header`,ye,[i[5]||=(0,n.createElementVNode)(`div`,null,[(0,n.createElementVNode)(`span`,{class:`c-formula__eyebrow`},`FORMULA WORKBENCH`),(0,n.createElementVNode)(`h2`,null,`规则与试算`),(0,n.createElementVNode)(`p`,null,`插入变量、编辑公式,再用试算值验证结果。`)],-1),(0,n.createElementVNode)(`div`,be,[(0,n.createVNode)((0,n.unref)(r.NTag),{type:(0,n.unref)(l).trim()?(0,n.unref)(u).validation.valid?`success`:`error`:`default`,size:`small`},{default:(0,n.withCtx)(()=>[(0,n.createTextVNode)((0,n.toDisplayString)((0,n.unref)(l).trim()?(0,n.unref)(u).validation.valid?`语法有效`:`需要修正`:`等待输入`),1)]),_:1},8,[`type`]),(0,n.createVNode)((0,n.unref)(r.NButton),{size:`small`,disabled:(0,n.unref)(c).disabled,onClick:(0,n.unref)(m)},{default:(0,n.withCtx)(()=>[...i[4]||=[(0,n.createTextVNode)(`重置`,-1)]]),_:1},8,[`disabled`,`onClick`])])]),(0,n.unref)(c).templates.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,$,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(c).templates,e=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{key:e.value,type:`button`,disabled:(0,n.unref)(c).disabled,"aria-pressed":(0,n.unref)(l)===e.value,onClick:t=>l.value=e.value},[(0,n.createElementVNode)(`strong`,null,(0,n.toDisplayString)(e.label),1),(0,n.createElementVNode)(`span`,null,(0,n.toDisplayString)(e.description),1)],8,xe))),128))])):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`div`,{class:(0,n.normalizeClass)([`c-formula__body`,{"c-formula__body--no-sidebar":!(0,n.unref)(c).showVariablePanel,"c-formula__body--no-preview":!(0,n.unref)(c).showPreview}])},[(0,n.unref)(c).showVariablePanel?((0,n.openBlock)(),(0,n.createElementBlock)(`aside`,Se,[(0,n.createVNode)(V,{variables:(0,n.unref)(c).variables,functions:(0,n.unref)(c).functions,disabled:(0,n.unref)(c).disabled,onSelectVariable:i[0]||=e=>_(`[${e.name}]`),onSelectFunction:i[1]||=e=>_(`${e.name}(`)},null,8,[`variables`,`functions`,`disabled`])])):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`div`,Ce,[(0,n.createVNode)(E,{ref_key:`formulaInputRef`,ref:h,formula:(0,n.unref)(l),tokens:(0,n.unref)(u).tokens,validation:(0,n.unref)(u).validation,disabled:(0,n.unref)(c).disabled,placeholder:(0,n.unref)(c).placeholder,"onUpdate:formula":g},null,8,[`formula`,`tokens`,`validation`,`disabled`,`placeholder`]),(0,n.unref)(c).showKeyboard?((0,n.openBlock)(),(0,n.createElementBlock)(`details`,we,[(0,n.createElementVNode)(`summary`,null,[(0,n.createVNode)(e.t,{type:`svg`,"svg-path":`M4 5h16v14H4zM6 7v10h12V7zM7 8h2v2H7zM10 8h2v2h-2zM13 8h2v2h-2zM16 8h1v2h-1zM7 11h2v2H7zM10 11h2v2h-2zM13 11h2v2h-2zM16 11h1v2h-1zM8 14h8v2H8z`,size:18}),i[6]||=(0,n.createElementVNode)(`span`,{class:`c-formula__keyboard-title`},[(0,n.createTextVNode)(`公式键盘`),(0,n.createElementVNode)(`small`,null,`数字、运算与函数 · 点击插入`)],-1),(0,n.createVNode)(e.t,{class:`c-formula__keyboard-chevron`,type:`svg`,"svg-path":`M6 8l6 6 6-6 1.4 1.4L12 16.8 4.6 9.4z`,size:18})]),(0,n.createVNode)(ae,{disabled:(0,n.unref)(c).disabled,functions:(0,n.unref)(c).functions,onKeyPress:i[2]||=e=>_(e.value),onInsertFunction:i[3]||=e=>_(`${e.name}(`),onAction:v},null,8,[`disabled`,`functions`])])):(0,n.createCommentVNode)(`v-if`,!0),(0,n.createElementVNode)(`div`,Te,[(0,n.createVNode)(e.t,{name:`mdi:information-outline`,size:16}),i[7]||=(0,n.createElementVNode)(`p`,null,[(0,n.createTextVNode)(`变量使用 `),(0,n.createElementVNode)(`code`,null,`[变量名]`),(0,n.createTextVNode)(`,支持括号、比较和条件函数。右侧结果是当前数据的本地试算。`)],-1)])]),(0,n.unref)(c).showPreview?((0,n.openBlock)(),(0,n.createBlock)(ve,{key:1,formula:(0,n.unref)(l),"eval-result":(0,n.unref)(d),"used-variables":(0,n.unref)(f),editable:(0,n.unref)(c).editableSampleData&&!(0,n.unref)(c).disabled,onUpdateValue:(0,n.unref)(p)},null,8,[`formula`,`eval-result`,`used-variables`,`editable`,`onUpdateValue`])):(0,n.createCommentVNode)(`v-if`,!0)],2)],4))}});var De=t.t(Ee,[[`__scopeId`,`data-v-b006a294`]]);function Oe(e){let t=(0,n.computed)(()=>{let t=new Map;for(let n of e.value)t.set(n.name,n.field);return t}),r,i;function a(e,n){if(!e.trim())return{success:!0,result:void 0};try{return(!i||r!==e)&&(i=y(e),r=e),{success:!0,result:i.evaluate(t.value,n)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}}function o(e){try{return[...new Set(b(e).filter(e=>e.type===`variable`).map(e=>e.value))]}catch{return[]}}return{evaluate:a,extractVariableNames:o,variableMap:t}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Oe}});
|
|
1
|
+
require(`./chunk.cjs`);const e=require(`./useComponentTheme.cjs`),t=require(`./export-helper.cjs`),n=require(`./C_Icon2.cjs`);let r=require(`vue`),i=require(`naive-ui`);const a=[{label:`?`,value:` ? `,type:`logic`,color:`warning`},{label:`:`,value:` : `,type:`logic`,color:`warning`},{label:`and`,value:` AND `,type:`logic`,color:`warning`},{label:`or`,value:` OR `,type:`logic`,color:`warning`},{label:`(`,value:`(`,type:`paren`},{label:`)`,value:`)`,type:`paren`},{label:`,`,value:`, `,type:`paren`},{label:`==`,value:` == `,type:`compare`},{label:`>`,value:` > `,type:`compare`},{label:`<`,value:` < `,type:`compare`},{label:`≥`,value:` >= `,type:`compare`},{label:`≤`,value:` <= `,type:`compare`},{label:`≠`,value:` != `,type:`compare`},{label:`%`,value:` % `,type:`operator`}],o=[{label:`1`,value:`1`,type:`number`},{label:`2`,value:`2`,type:`number`},{label:`3`,value:`3`,type:`number`},{label:`+`,value:` + `,type:`operator`,color:`primary`},{label:`−`,value:` - `,type:`operator`,color:`primary`},{label:`4`,value:`4`,type:`number`},{label:`5`,value:`5`,type:`number`},{label:`6`,value:`6`,type:`number`},{label:`×`,value:` * `,type:`operator`,color:`primary`},{label:`÷`,value:` / `,type:`operator`,color:`primary`},{label:`7`,value:`7`,type:`number`},{label:`8`,value:`8`,type:`number`},{label:`9`,value:`9`,type:`number`},{label:`0`,value:`0`,type:`number`},{label:`.`,value:`.`,type:`number`}],s=[{label:`⌫`,value:`BACKSPACE`,type:`action`,isAction:!0},{label:`清空`,value:`CLEAR`,type:`action`,isAction:!0}],c=[{name:`IF`,signature:`IF(条件, 真值, 假值)`,description:`根据条件返回不同的值`,category:`逻辑`},{name:`AND`,signature:`AND(条件1, 条件2)`,description:`全部条件为真时返回真`,category:`逻辑`},{name:`OR`,signature:`OR(条件1, 条件2)`,description:`任一条件为真时返回真`,category:`逻辑`},{name:`NOT`,signature:`NOT(条件)`,description:`对条件取反`,category:`逻辑`},{name:`SUM`,signature:`SUM(值1, 值2, ...)`,description:`计算所有值的总和`,category:`数学`},{name:`AVG`,signature:`AVG(值1, 值2, ...)`,description:`计算所有值的平均值`,category:`数学`},{name:`MAX`,signature:`MAX(值1, 值2, ...)`,description:`返回最大值`,category:`数学`},{name:`MIN`,signature:`MIN(值1, 值2, ...)`,description:`返回最小值`,category:`数学`},{name:`ABS`,signature:`ABS(数值)`,description:`返回绝对值`,category:`数学`},{name:`ROUND`,signature:`ROUND(数值, 小数位)`,description:`四舍五入到指定小数位`,category:`数学`},{name:`CEIL`,signature:`CEIL(数值)`,description:`向上取整`,category:`数学`},{name:`FLOOR`,signature:`FLOOR(数值)`,description:`向下取整`,category:`数学`}],l=new Set([`+`,`-`,`*`,`/`,`%`,`>`,`<`,`>=`,`<=`,`==`,`!=`,`?`,`:`,`AND`,`OR`,`NOT`]),u=new Set([`+`,`-`,`*`,`/`,`%`,`>`,`<`,`>=`,`<=`,`==`,`!=`,`?`,`:`,`AND`,`OR`]),d=1e4,f=5e3,p=Object.freeze({IF:(e,t,n)=>e?t:n,AND:(...e)=>e.every(Boolean),OR:(...e)=>e.some(Boolean),NOT:e=>!e,SUM:(...e)=>e.reduce((e,t)=>e+m(t),0),AVG:(...e)=>e.length?e.reduce((e,t)=>e+m(t),0)/e.length:0,MAX:(...e)=>Math.max(...e.map(m)),MIN:(...e)=>Math.min(...e.map(m)),ABS:e=>Math.abs(m(e)),ROUND:(e,t=0)=>{let n=10**Math.min(100,Math.max(0,Math.trunc(m(t))));return Math.round(m(e)*n)/n},CEIL:e=>Math.ceil(m(e)),FLOOR:e=>Math.floor(m(e))});function m(e){let t=Number(e);if(!Number.isFinite(t))throw Error(`无法将“${String(e)}”转换为有限数值`);return t}function h(e){if(e.length>d)throw Error(`公式长度不能超过 ${d} 个字符`);let t=[],n=0,r=e=>{if(t.push(e),t.length>f)throw Error(`公式不能超过 ${f} 个词元`)};for(;n<e.length;){let t=e[n];if(/\s/.test(t)){n+=1;continue}let i=e.slice(n),a=/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i.exec(i);if(a){r({type:`number`,value:a[0],position:n}),n+=a[0].length;continue}if(t===`[`){let t=e.indexOf(`]`,n+1);if(t===-1)throw Error(`第 ${n+1} 个字符处缺少 ]`);let i=e.slice(n+1,t).trim();if(!i)throw Error(`第 ${n+1} 个字符处的变量名不能为空`);r({type:`variable`,value:i,position:n}),n=t+1;continue}if(t===`"`||t===`'`){let i=t,a=n,o=``,s=!1;for(n+=1;n<e.length;){let t=e[n];if(t===i){s=!0,n+=1;break}if(t===`\\`){if(n+=1,n>=e.length)break;let t=e[n];o+={n:`
|
|
2
|
+
`,r:`\r`,t:` `}[t]??t}else o+=t;n+=1}if(!s)throw Error(`第 ${a+1} 个字符处的字符串未闭合`);r({type:`string`,value:o,position:a});continue}let o=e.slice(n,n+2);if([`>=`,`<=`,`==`,`!=`].includes(o)){r({type:`operator`,value:o,position:n}),n+=2;continue}if(`+-*/%><?:`.includes(t)){r({type:`operator`,value:t,position:n}),n+=1;continue}if(`(),`.includes(t)){r({type:`punctuation`,value:t,position:n}),n+=1;continue}let s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(i);if(s){let e=s[0],t=e.toUpperCase();r({type:[`AND`,`OR`,`NOT`].includes(t)?`operator`:`identifier`,value:[`AND`,`OR`,`NOT`].includes(t)?t:e,position:n}),n+=e.length;continue}throw Error(`第 ${n+1} 个字符“${t}”不受支持`)}return t.push({type:`eof`,value:``,position:n}),t}var g=class{cursor=0;nestingDepth=0;constructor(e){this.tokens=e}parse(){let e=this.parseConditional();return this.expect(`eof`),e}current(){return this.tokens[this.cursor]}advance(){return this.tokens[this.cursor++]}consume(e){return this.current().value===e?(this.advance(),!0):!1}expect(e,t){let n=this.current();if(n.type!==e||t!==void 0&&n.value!==t)throw Error(`第 ${n.position+1} 个字符处应为 ${t??e}`);return this.advance()}parseConditional(){if(++this.nestingDepth>100)throw Error(`公式嵌套不能超过 100 层`);try{let e=this.parseOr();if(!this.consume(`?`))return e;let t=this.parseConditional();return this.expect(`operator`,`:`),{kind:`conditional`,condition:e,truthy:t,falsy:this.parseConditional()}}finally{this.nestingDepth--}}parseBinary(e,t){let n=e();for(;t.includes(this.current().value);)n={kind:`binary`,operator:this.advance().value,left:n,right:e()};return n}parseOr(){return this.parseBinary(()=>this.parseAnd(),[`OR`])}parseAnd(){return this.parseBinary(()=>this.parseEquality(),[`AND`])}parseEquality(){return this.parseBinary(()=>this.parseComparison(),[`==`,`!=`])}parseComparison(){return this.parseBinary(()=>this.parseAdditive(),[`>`,`>=`,`<`,`<=`])}parseAdditive(){return this.parseBinary(()=>this.parseMultiplicative(),[`+`,`-`])}parseMultiplicative(){return this.parseBinary(()=>this.parseUnary(),[`*`,`/`,`%`])}parseUnary(){let e=[];for(;[`-`,`+`,`NOT`].includes(this.current().value)&&!(this.current().value===`NOT`&&this.tokens[this.cursor+1]?.value===`(`);)if(e.push(this.advance().value),e.length>100)throw Error(`一元运算不能超过 100 层`);let t=this.parsePrimary();for(let n of e.reverse())t={kind:`unary`,operator:n,value:t};return t}parsePrimary(){let e=this.current();if(e.type===`number`||e.type===`string`)return this.advance(),{kind:`literal`,value:e.type===`number`?Number(e.value):e.value};if(e.type===`variable`)return this.advance(),{kind:`variable`,name:e.value};if(e.type===`identifier`||e.type===`operator`&&[`AND`,`OR`,`NOT`].includes(e.value)){this.advance();let t=e.value.toUpperCase();if(t===`TRUE`||t===`FALSE`)return{kind:`literal`,value:t===`TRUE`};if(this.consume(`(`))return this.parseFunction(t,e);if(t===`NOT`)return{kind:`unary`,operator:`NOT`,value:this.parseUnary()};if(e.type===`identifier`)return{kind:`identifier`,name:e.value}}if(this.consume(`(`)){let e=this.parseConditional();return this.expect(`punctuation`,`)`),e}throw Error(`第 ${e.position+1} 个字符处缺少有效值`)}parseFunction(e,t){if(!Object.prototype.hasOwnProperty.call(p,e))throw Error(`第 ${t.position+1} 个字符处:未知函数“${t.value}”`);let n=[];if(!this.consume(`)`)){do n.push(this.parseConditional());while(this.consume(`,`));this.expect(`punctuation`,`)`)}let[r,i]=e===`IF`?[3,3]:e===`ROUND`?[1,2]:[`AND`,`OR`,`SUM`,`AVG`,`MAX`,`MIN`].includes(e)?[1,1/0]:[1,1];if(n.length<r||n.length>i)throw Error(`第 ${t.position+1} 个字符处:${e} 需要 ${r===i?r:`${r}–${i===1/0?`多个`:i}`} 个参数`);return{kind:`call`,name:e,args:n}}};function _(e,t){if(!Object.prototype.hasOwnProperty.call(t,e)||t[e]==null)throw Error(`变量“${e}”缺少样例数据`);let n=t[e];if(![`number`,`string`,`boolean`].includes(typeof n)||typeof n==`number`&&!Number.isFinite(n))throw Error(`变量“${e}”的数据类型不受支持`);return n}function v(e,t,n){switch(e){case`==`:return t===n;case`!=`:return t!==n;case`+`:return m(t)+m(n);case`-`:return m(t)-m(n);case`*`:return m(t)*m(n);case`/`:return m(t)/m(n);case`%`:return m(t)%m(n);default:if(typeof t==`boolean`||typeof n==`boolean`)throw Error(`运算符 ${e} 不支持布尔值`);return e===`>`?t>n:e===`>=`?t>=n:e===`<`?t<n:t<=n}}function y(e,t,n,r=0){if(r>200)throw Error(`公式计算层数超过安全限制`);let i=e=>y(e,t,n,r+1);switch(e.kind){case`literal`:return e.value;case`variable`:{let r=t.get(e.name);if(!r)throw Error(`未知变量“${e.name}”`);return _(r,n)}case`identifier`:return _(e.name,n);case`conditional`:return i(e.condition)?i(e.truthy):i(e.falsy);case`unary`:{let t=i(e.value);return e.operator===`NOT`?!t:e.operator===`-`?-m(t):m(t)}case`binary`:{let t=i(e.left);return e.operator===`AND`?!!t&&!!i(e.right):e.operator===`OR`?!!t||!!i(e.right):v(e.operator,t,i(e.right))}case`call`:return e.name===`IF`?i(e.args[0])?i(e.args[1]):i(e.args[2]):e.name===`AND`?e.args.every(e=>!!i(e)):e.name===`OR`?e.args.some(e=>!!i(e)):p[e.name](...e.args.map(i))}}function b(e){let t=h(e),n=new g(t).parse();return{tokens:t,evaluate(e,t){let r=y(n,e,t);if(typeof r==`number`&&!Number.isFinite(r))throw Error(`公式计算结果必须是有限数值`);return r}}}function x(e){return h(e)}function S(e,t){let n=(0,r.computed)(()=>new Set(e.value.map(e=>e.name))),i=(0,r.computed)(()=>new Set(e.value.map(e=>e.field))),a=(0,r.computed)(()=>new Set(t.value.map(e=>e.name.toUpperCase()))),o=null;function s(e){try{let t=x(e),n=[],r=0;return t.forEach((i,a)=>{if(i.type===`eof`)return;i.position>r&&n.push({type:`space`,value:e.slice(r,i.position),start:r,end:i.position});let o=e.slice(i.position,t[a+1]?.position??e.length).trimEnd();r=i.position+o.length;let s=t[a+1],c=i.type===`variable`?`variable`:i.type===`number`?`number`:s?.value===`(`&&(i.type===`identifier`||[`AND`,`OR`,`NOT`].includes(i.value))?`function`:i.type===`operator`?`operator`:i.type===`punctuation`?i.value===`,`?`comma`:`paren`:`text`;n.push({type:c,value:c===`variable`?i.value:o,start:i.position,end:r})}),r<e.length&&n.push({type:`space`,value:e.slice(r),start:r,end:e.length}),n}catch{return e?[{type:`text`,value:e,start:0,end:e.length}]:[]}}function c(e){let t=n.value,r=i.value,c=a.value;if(o?.formula===e&&o.names===t&&o.fields===r&&o.functions===c)return o.analysis;let l={tokens:s(e),validation:{valid:!0,message:e.trim()?`语法校验通过`:`尚未输入公式`},compiled:null};if(e.trim())try{l.compiled=b(e);for(let e of l.tokens){if(e.type===`variable`&&!t.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知变量「${e.value}」`);if(e.type===`function`&&!c.has(e.value.toUpperCase()))throw Error(`第 ${e.start+1} 个字符处:未知函数「${e.value}」`);if(e.type===`text`&&/^[A-Za-z_]\w*$/.test(e.value)&&![`TRUE`,`FALSE`].includes(e.value.toUpperCase())&&!r.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知字段「${e.value}」`)}}catch(e){let t=e instanceof Error?e.message:String(e),n=/第 (\d+) 个字符/.exec(t);l.validation={valid:!1,message:t,...n?{position:Number(n[1])-1}:{}},l.compiled=null}return o={formula:e,names:t,fields:r,functions:c,analysis:l},l}function l(e){return c(e).validation}function u(e,t){let n=0,r=``;for(let i of s(e).filter(e=>e.type===`variable`))r+=e.slice(n,i.start)+(t.get(i.value)??`__unknown_${i.value}__`),n=i.end;return r+e.slice(n)}return{tokenize:s,analyze:c,validate:l,toEvalExpression:u,variableNames:n,functionNames:a}}function ee(e){let t=(0,r.computed)(()=>({variables:e.config?.variables??e.variables??[],functions:e.config?.functions??e.functions??c,sampleData:e.config?.sampleData??e.sampleData??{},disabled:e.config?.disabled??e.disabled??!1,placeholder:e.config?.placeholder??e.placeholder??`例如:[完成值] / [目标值] * 100`,height:e.config?.height??e.height??`auto`,showPreview:e.config?.showPreview??e.showPreview??!0,showKeyboard:e.config?.showKeyboard??e.showKeyboard??!0,showVariablePanel:e.config?.showVariablePanel??e.showVariablePanel??!0,editableSampleData:e.config?.editableSampleData??e.editableSampleData??!0,templates:e.config?.templates??e.templates??[]})),n=e.modelValue??``,i=(0,r.ref)(n),a=(0,r.ref)({}),o=S((0,r.computed)(()=>t.value.variables),(0,r.computed)(()=>t.value.functions)),s=(0,r.computed)(()=>o.analyze(i.value)),l=(0,r.computed)(()=>{let e=new Map(Object.entries(t.value.sampleData));for(let[t,n]of Object.entries(a.value))n===null?e.delete(t):e.set(t,n);return Object.fromEntries(e)}),u=(0,r.computed)(()=>new Map(t.value.variables.map(e=>[e.name,e.field]))),d=(0,r.computed)(()=>{let e=s.value.tokens.filter(e=>e.type===`variable`).map(e=>e.value),n=s.value.tokens.filter(e=>e.type===`text`).map(e=>e.value);return t.value.variables.filter(t=>e.includes(t.name)||n.includes(t.field)).map(e=>({...e,value:l.value[e.field]}))}),f=(0,r.computed)(()=>{if(!s.value.validation.valid)return{success:!1,result:void 0,error:s.value.validation.message};if(!s.value.compiled)return{success:!0,result:void 0};try{return{success:!0,result:s.value.compiled.evaluate(u.value,l.value)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}});function p(e,n){!t.value.disabled&&t.value.editableSampleData&&(a.value={...a.value,[e]:n})}function m(){i.value=n,a.value={}}return(0,r.watch)(()=>e.modelValue,e=>{e!==void 0&&e!==i.value&&(i.value=e)}),(0,r.watch)(()=>t.value.sampleData,()=>{a.value={}}),{options:t,formula:i,analysis:s,evalResult:f,usedVariables:d,updateSample:p,reset:m}}const C={class:`formula-input__header`},w=[`readonly`,`aria-invalid`,`placeholder`],T={key:0,class:`formula-input__tokens`,"aria-label":`公式结构预览`},E=(0,r.defineComponent)({name:`FormulaInput`,__name:`FormulaInput`,props:{formula:{},tokens:{},validation:{},variableNames:{},disabled:{type:Boolean,default:!1},placeholder:{default:`例如:[完成值] / [目标值] * 100`}},emits:[`update:formula`],setup(e,{expose:t,emit:n}){let i=e,a=n,o=(0,r.ref)(),s=(0,r.ref)(i.formula),c=`formula-feedback-${(0,r.useId)()}`,l=s.value.length,u=l;(0,r.watch)(s,e=>a(`update:formula`,e),{flush:`sync`}),(0,r.watch)(()=>i.formula,e=>{e!==s.value&&(s.value=e,l=u=e.length)});function d(){o.value&&(l=o.value.selectionStart,u=o.value.selectionEnd)}function f(e,t=l,n=u){if(i.disabled)return;let a=Math.max(0,Math.min(t,s.value.length));s.value=s.value.slice(0,a)+e+s.value.slice(Math.max(a,n)),l=u=a+e.length,(0,r.nextTick)(()=>{o.value?.focus({preventScroll:!0}),o.value?.setSelectionRange(l,u)})}function p(e){f(e)}function m(){if(l!==u){f(``);return}if(l===0)return;let e=i.tokens.find(e=>e.type===`variable`&&e.end===l),t=Array.from(s.value.slice(0,l)).pop()?.length??1;f(``,e?.start??l-t,u)}function h(){f(``,0,s.value.length)}function g(){l=u=s.value.length,o.value?.setSelectionRange(l,u)}function _(){o.value?.focus({preventScroll:!0}),g()}function v(){let e=i.validation.position??0;o.value?.focus({preventScroll:!0}),o.value?.setSelectionRange(e,Math.min(e+1,s.value.length)),d()}return t({insertAtCursor:p,backspace:m,clear:h,focus:_,moveCursorToEnd:g}),(t,n)=>((0,r.openBlock)(),(0,r.createElementBlock)(`div`,{class:(0,r.normalizeClass)([`formula-input`,{"formula-input--disabled":e.disabled,"formula-input--error":!e.validation.valid&&e.formula.trim()}])},[(0,r.createElementVNode)(`div`,C,[n[1]||=(0,r.createElementVNode)(`span`,{class:`formula-input__label`},`01 / 编辑公式`,-1),e.formula.trim()&&!e.disabled?((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:0,type:`button`,class:`formula-input__clear`,onClick:h},`清空公式`)):(0,r.createCommentVNode)(`v-if`,!0)]),(0,r.withDirectives)((0,r.createElementVNode)(`textarea`,{ref_key:`editorRef`,ref:o,"onUpdate:modelValue":n[0]||=e=>s.value=e,class:`formula-input__editor`,readonly:e.disabled,"aria-label":`公式输入`,"aria-invalid":!e.validation.valid&&!!e.formula.trim(),"aria-describedby":c,placeholder:e.placeholder,spellcheck:`false`,onSelect:d,onClick:d,onKeyup:d,onBlur:d},null,40,w),[[r.vModelText,s.value]]),e.tokens.length?((0,r.openBlock)(),(0,r.createElementBlock)(`div`,T,[n[2]||=(0,r.createElementVNode)(`span`,{class:`formula-input__tokens-label`},`结构预览`,-1),((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(e.tokens,(e,t)=>((0,r.openBlock)(),(0,r.createElementBlock)(`span`,{key:t,class:(0,r.normalizeClass)(`formula-token formula-token--${e.type}`)},(0,r.toDisplayString)(e.type===`variable`?`[${e.value}]`:e.value),3))),128))])):(0,r.createCommentVNode)(`v-if`,!0),(0,r.createElementVNode)(`div`,{id:c,class:`formula-input__validation`,role:`status`},[(0,r.createElementVNode)(`span`,{class:(0,r.normalizeClass)(e.formula.trim()?e.validation.valid?`formula-input__validation-success`:`formula-input__validation-error`:`formula-input__validation-hint`)},(0,r.toDisplayString)(e.formula.trim()?e.validation.valid?`语法校验通过,可在右侧调整数据试算。`:e.validation.message:`点击左侧变量开始,也可以直接输入 [变量名]。`),3),e.validation.position===void 0?(0,r.createCommentVNode)(`v-if`,!0):((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:0,type:`button`,class:`formula-input__locate`,onClick:v},`定位错误`))])],2))}});var D=t.t(E,[[`__scopeId`,`data-v-5b2f30eb`]]);const O={class:`variable-panel`},k={class:`variable-panel__tabs`},A=[`aria-pressed`],j=[`aria-pressed`],M={class:`variable-panel__search`},N=[`aria-expanded`,`onClick`],P={class:`variable-panel__items`},F=[`disabled`,`onClick`],I={key:0},L=[`disabled`,`onClick`],R={class:`variable-panel__func-name`},z={class:`variable-panel__func-desc`},B={class:`variable-panel__func-sig`},V=(0,r.defineComponent)({__name:`VariablePanel`,props:{variables:{},functions:{},disabled:{type:Boolean}},emits:[`select-variable`,`select-function`],setup(e){let t=e,a=(0,r.ref)(`variable`),o=(0,r.ref)(``),s=(0,r.ref)(new Set),c=(0,r.computed)(()=>{let e=o.value.toLowerCase(),n=e?t.variables.filter(t=>t.name.toLowerCase().includes(e)||t.field.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)):t.variables,r=new Map;for(let e of n){let t=e.group??`其他`,n=r.get(t);n?n.push(e):r.set(t,[e])}return Array.from(r,([e,t])=>({name:e,items:t}))});(0,r.watch)(c,e=>{for(let t of e)s.value.add(t.name)},{immediate:!0});function l(e){s.value.has(e)?s.value.delete(e):s.value.add(e)}let u=(0,r.computed)(()=>{let e=o.value.toLowerCase();return e?t.functions.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)):t.functions});function d(e){switch(e){case`number`:return`mdi:numeric`;case`text`:return`mdi:format-text`;case`boolean`:return`mdi:toggle-switch-outline`;default:return`mdi:variable`}}return(t,f)=>((0,r.openBlock)(),(0,r.createElementBlock)(`div`,O,[(0,r.createCommentVNode)(` 切换 Tab:变量 / 函数 `),(0,r.createElementVNode)(`div`,k,[(0,r.createElementVNode)(`button`,{type:`button`,class:(0,r.normalizeClass)([`variable-panel__tab`,{"variable-panel__tab--active":a.value===`variable`}]),"aria-pressed":a.value===`variable`,onClick:f[0]||=e=>a.value=`variable`},` 可用变量 `,10,A),(0,r.createElementVNode)(`button`,{type:`button`,class:(0,r.normalizeClass)([`variable-panel__tab`,{"variable-panel__tab--active":a.value===`function`}]),"aria-pressed":a.value===`function`,onClick:f[1]||=e=>a.value=`function`},` 常用函数 `,10,j)]),(0,r.createCommentVNode)(` 搜索框 `),(0,r.createElementVNode)(`div`,M,[(0,r.createVNode)((0,r.unref)(i.NInput),{value:o.value,"onUpdate:value":f[2]||=e=>o.value=e,size:`small`,placeholder:`搜索变量或函数`,"input-props":{"aria-label":`搜索变量或函数`},clearable:``},{prefix:(0,r.withCtx)(()=>[(0,r.createVNode)(n.t,{name:`mdi:magnify`,size:16})]),_:1},8,[`value`])]),(0,r.createCommentVNode)(` 变量列表 `),a.value===`variable`?((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(i.NScrollbar),{key:0,class:`variable-panel__list`},{default:(0,r.withCtx)(()=>[c.value.length>0?((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,{key:0},(0,r.renderList)(c.value,i=>((0,r.openBlock)(),(0,r.createElementBlock)(`div`,{key:i.name,class:`variable-panel__group`},[(0,r.createElementVNode)(`button`,{type:`button`,class:`variable-panel__group-title`,"aria-expanded":s.value.has(i.name),onClick:e=>l(i.name)},[(0,r.createVNode)(n.t,{name:s.value.has(i.name)?`mdi:chevron-down`:`mdi:chevron-right`,size:16},null,8,[`name`]),(0,r.createTextVNode)(` `+(0,r.toDisplayString)(i.name),1)],8,N),(0,r.withDirectives)((0,r.createElementVNode)(`div`,P,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(i.items,i=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:i.field,type:`button`,class:`variable-panel__item`,disabled:e.disabled,onClick:e=>t.$emit(`select-variable`,i)},[(0,r.createVNode)(n.t,{name:d(i.type),size:15,class:`variable-panel__item-icon`},null,8,[`name`]),(0,r.createElementVNode)(`span`,null,[(0,r.createTextVNode)((0,r.toDisplayString)(i.name),1),i.description?((0,r.openBlock)(),(0,r.createElementBlock)(`small`,I,(0,r.toDisplayString)(i.description),1)):(0,r.createCommentVNode)(`v-if`,!0)])],8,F))),128))],512),[[r.vShow,s.value.has(i.name)]])]))),128)):((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(i.NEmpty),{key:1,size:`small`,description:`无匹配变量`}))]),_:1})):((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:1},[(0,r.createCommentVNode)(` 函数列表 `),(0,r.createVNode)((0,r.unref)(i.NScrollbar),{class:`variable-panel__list`},{default:(0,r.withCtx)(()=>[u.value.length>0?((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,{key:0},(0,r.renderList)(u.value,n=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:n.name,type:`button`,class:`variable-panel__func`,disabled:e.disabled,onClick:e=>t.$emit(`select-function`,n)},[(0,r.createElementVNode)(`div`,R,[f[3]||=(0,r.createElementVNode)(`span`,{class:`variable-panel__func-badge`},`ƒ`,-1),(0,r.createTextVNode)(` `+(0,r.toDisplayString)(n.name),1)]),(0,r.createElementVNode)(`div`,z,(0,r.toDisplayString)(n.description),1),(0,r.createElementVNode)(`div`,B,(0,r.toDisplayString)(n.signature),1)],8,L))),128)):((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(i.NEmpty),{key:1,size:`small`,description:`无匹配函数`}))]),_:1})],2112))]))}});var H=t.t(V,[[`__scopeId`,`data-v-2d73fec7`]]);const U={class:`virtual-keyboard`,role:`group`,"aria-label":`公式键盘`},W={key:0,class:`virtual-keyboard__functions`},G={class:`virtual-keyboard__function-grid`},K=[`disabled`,`title`,`aria-label`,`onClick`],q={class:`virtual-keyboard__body`},J={class:`virtual-keyboard__operators`},Y={class:`virtual-keyboard__label`},X=[`disabled`,`aria-label`,`onClick`],te={class:`virtual-keyboard__numbers`},Z={class:`virtual-keyboard__keys virtual-keyboard__keys--numbers`},Q=[`disabled`,`aria-label`,`onClick`],ne={class:`virtual-keyboard__footer`},re={class:`virtual-keyboard__actions`},ie=[`disabled`,`aria-label`,`onClick`],ae=(0,r.defineComponent)({name:`VirtualKeyboard`,__name:`VirtualKeyboard`,props:{disabled:{type:Boolean,default:!1},functions:{default:()=>[]}},emits:[`key-press`,`insert-function`,`action`],setup(e){let t=o.filter(e=>e.type===`number`),i=s.map(e=>({...e,label:e.value===`BACKSPACE`?`退格`:e.label,icon:e.value===`BACKSPACE`?`M9 4h12v16H9L2 12zM9.9 6 4.6 12l5.3 6H19V6zM11 8l6 6-1.4 1.4-6-6zM15.6 8 17 9.4l-6 6-1.4-1.4z`:`M5 5h14v2H5zM9 2h6v2H9zM7 8h2v11h6V8h2v13H7zM10 8h1v9h-1zM13 8h1v9h-1z`})),c=[{name:`arithmetic`,label:`四则与取余`,keys:[...o,...a].filter(e=>e.type===`operator`)},{name:`compare`,label:`比较判断`,keys:a.filter(e=>e.type===`compare`)},{name:`logic`,label:`括号与条件`,keys:a.filter(e=>e.type===`paren`||e.type===`logic`)}];return(a,o)=>((0,r.openBlock)(),(0,r.createElementBlock)(`div`,U,[e.functions.length?((0,r.openBlock)(),(0,r.createElementBlock)(`div`,W,[o[1]||=(0,r.createElementVNode)(`span`,{class:`virtual-keyboard__label`},`函数快捷输入`,-1),(0,r.createElementVNode)(`div`,G,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(e.functions,t=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:t.name,type:`button`,class:`virtual-keyboard__function`,disabled:e.disabled,title:`${t.signature} · ${t.description}`,"aria-label":`插入函数 ${t.name}`,onClick:e=>a.$emit(`insert-function`,t)},[(0,r.createTextVNode)((0,r.toDisplayString)(t.name),1),o[0]||=(0,r.createElementVNode)(`span`,null,`( )`,-1)],8,K))),128))])])):(0,r.createCommentVNode)(`v-if`,!0),(0,r.createElementVNode)(`div`,q,[(0,r.createElementVNode)(`div`,J,[((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(c,t=>(0,r.createElementVNode)(`section`,{key:t.label,class:`virtual-keyboard__group`},[(0,r.createElementVNode)(`h3`,Y,(0,r.toDisplayString)(t.label),1),(0,r.createElementVNode)(`div`,{class:(0,r.normalizeClass)([`virtual-keyboard__keys`,`virtual-keyboard__keys--${t.name}`])},[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(t.keys,t=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:t.value,type:`button`,class:(0,r.normalizeClass)([`virtual-keyboard__key`,t.color&&`virtual-keyboard__key--${t.color}`]),disabled:e.disabled,"aria-label":`插入 ${t.label}`,onClick:e=>a.$emit(`key-press`,t)},(0,r.toDisplayString)(t.label),11,X))),128))],2)])),64))]),(0,r.createElementVNode)(`section`,te,[o[2]||=(0,r.createElementVNode)(`h3`,{class:`virtual-keyboard__label`},`数字输入`,-1),(0,r.createElementVNode)(`div`,Z,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)((0,r.unref)(t),t=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:t.value,type:`button`,class:(0,r.normalizeClass)([`virtual-keyboard__key`,{"virtual-keyboard__key--zero":t.value===`0`}]),disabled:e.disabled,"aria-label":`输入 ${t.label}`,onClick:e=>a.$emit(`key-press`,t)},(0,r.toDisplayString)(t.label),11,Q))),128))])])]),(0,r.createElementVNode)(`footer`,ne,[o[3]||=(0,r.createElementVNode)(`span`,null,`按键会插入到光标处,选中文字可直接替换。`,-1),(0,r.createElementVNode)(`div`,re,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)((0,r.unref)(i),t=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:t.value,type:`button`,class:(0,r.normalizeClass)([`virtual-keyboard__action`,{"virtual-keyboard__action--clear":t.value===`CLEAR`}]),disabled:e.disabled,"aria-label":t.label,onClick:e=>a.$emit(`action`,t.value)},[(0,r.createVNode)(n.t,{type:`svg`,"svg-path":t.icon,size:16},null,8,[`svg-path`]),(0,r.createTextVNode)((0,r.toDisplayString)(t.label),1)],10,ie))),128))])])]))}});var oe=t.t(ae,[[`__scopeId`,`data-v-05f0982d`]]);const se={class:`formula-preview`,"aria-label":`公式试算`},ce={class:`formula-preview__result-label`},le={key:0,class:`formula-preview__result-value`},ue={key:1,class:`formula-preview__result-empty`},de={class:`formula-preview__vars`},fe={class:`formula-preview__vars-title`},pe={class:`formula-preview__var-heading`},me=[`for`],he={key:3,class:`formula-preview__var-value`},ge={key:4},_e={key:0,class:`formula-preview__empty`},ve=(0,r.defineComponent)({name:`FormulaPreview`,__name:`FormulaPreview`,props:{formula:{},evalResult:{},usedVariables:{},editable:{type:Boolean}},emits:[`update-value`],setup(e,{emit:t}){let n=t,a=`formula-sample-${(0,r.useId)()}`;function o(e){return typeof e==`number`?new Intl.NumberFormat(void 0,{maximumFractionDigits:6}).format(e):typeof e==`boolean`?e?`真 · true`:`假 · false`:String(e)}return(t,s)=>((0,r.openBlock)(),(0,r.createElementBlock)(`aside`,se,[s[1]||=(0,r.createElementVNode)(`header`,null,[(0,r.createElementVNode)(`span`,{class:`formula-preview__step`},`02`),(0,r.createElementVNode)(`div`,null,[(0,r.createElementVNode)(`h3`,null,`验证计算结果`),(0,r.createElementVNode)(`p`,null,`调整试算值,观察规则是否符合预期。`)])],-1),(0,r.createElementVNode)(`div`,{class:(0,r.normalizeClass)([`formula-preview__result`,{"formula-preview__result--error":!!e.evalResult.error}]),role:`status`,"aria-live":`polite`},[(0,r.createElementVNode)(`span`,ce,(0,r.toDisplayString)(e.evalResult.error?`暂时无法计算`:`试算结果`),1),e.evalResult.success&&e.evalResult.result!==void 0?((0,r.openBlock)(),(0,r.createElementBlock)(`output`,le,(0,r.toDisplayString)(o(e.evalResult.result)),1)):((0,r.openBlock)(),(0,r.createElementBlock)(`span`,ue,(0,r.toDisplayString)(e.formula.trim()?e.evalResult.error||`等待数据`:`输入公式后展示结果`),1))],2),(0,r.createElementVNode)(`div`,de,[(0,r.createElementVNode)(`div`,fe,[s[0]||=(0,r.createTextVNode)(`本次使用的试算值 `,-1),(0,r.createElementVNode)(`span`,null,(0,r.toDisplayString)(e.usedVariables.length)+` 项`,1)]),((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(e.usedVariables,t=>((0,r.openBlock)(),(0,r.createElementBlock)(`div`,{key:t.field,class:`formula-preview__var-row`},[(0,r.createElementVNode)(`div`,pe,[(0,r.createElementVNode)(`label`,{for:`${a}-${t.field}`},(0,r.toDisplayString)(t.name),9,me),(0,r.createElementVNode)(`code`,null,(0,r.toDisplayString)(t.field),1)]),e.editable&&t.type===`number`?((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(i.NInputNumber),{key:0,value:typeof t.value==`number`?t.value:null,"input-props":{id:`${a}-${t.field}`,"aria-label":`试算值:${t.name}`},placeholder:`请输入数值`,"onUpdate:value":e=>n(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):e.editable&&t.type===`boolean`?((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(i.NSwitch),{key:1,value:t.value===!0,"aria-label":`试算值:${t.name}`,"onUpdate:value":e=>n(`update-value`,t.field,e)},null,8,[`value`,`aria-label`,`onUpdate:value`])):e.editable&&t.type===`text`?((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(i.NInput),{key:2,value:typeof t.value==`string`?t.value:``,"input-props":{id:`${a}-${t.field}`,"aria-label":`试算值:${t.name}`},"onUpdate:value":e=>n(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):((0,r.openBlock)(),(0,r.createElementBlock)(`span`,he,(0,r.toDisplayString)(t.value??`未提供`),1)),t.description?((0,r.openBlock)(),(0,r.createElementBlock)(`p`,ge,(0,r.toDisplayString)(t.description),1)):(0,r.createCommentVNode)(`v-if`,!0)]))),128)),e.usedVariables.length?(0,r.createCommentVNode)(`v-if`,!0):((0,r.openBlock)(),(0,r.createElementBlock)(`p`,_e,(0,r.toDisplayString)(e.formula.trim()?`当前公式没有引用变量。`:`引用变量后,对应数据会出现在这里。`),1))]),s[2]||=(0,r.createElementVNode)(`p`,{class:`formula-preview__note`},`试算值仅用于本次验证,修改不会写入业务数据。`,-1)]))}});var ye=t.t(ve,[[`__scopeId`,`data-v-b2656900`]]);const be={class:`c-formula__title-row`},$={class:`c-formula__actions`},xe={key:0,class:`c-formula__templates`,"aria-label":`公式模板`},Se=[`disabled`,`aria-pressed`,`onClick`],Ce={key:0,class:`c-formula__sidebar`},we={class:`c-formula__main`},Te={key:0,class:`c-formula__keyboard`,open:``},Ee={class:`c-formula__guide`},De=(0,r.defineComponent)({name:`C_FormulaEditor`,__name:`index`,props:{modelValue:{},config:{},variables:{},functions:{},sampleData:{},disabled:{type:Boolean,default:!1},placeholder:{},height:{},showPreview:{type:Boolean,default:!0},showKeyboard:{type:Boolean,default:!0},showVariablePanel:{type:Boolean,default:!0},editableSampleData:{type:Boolean,default:!0},templates:{}},emits:[`update:modelValue`,`change`,`validation-change`],setup(t,{expose:a,emit:o}){let s=e.n(),c=t,l=o,{options:u,formula:d,analysis:f,evalResult:p,usedVariables:m,updateSample:h,reset:g}=ee(c),_=(0,r.ref)();(0,r.watch)(d,e=>{l(`update:modelValue`,e),l(`change`,e)}),(0,r.watch)(()=>f.value.validation,e=>l(`validation-change`,e),{immediate:!0});function v(e){u.value.disabled||(d.value=e)}function y(e){u.value.disabled||_.value?.insertAtCursor(e)}function b(e){u.value.disabled||(e===`BACKSPACE`&&_.value?.backspace(),e===`CLEAR`&&_.value?.clear())}return a({getValue:()=>d.value,setValue:e=>{d.value=e},reset:g,validate:()=>f.value.validation,insertAtCursor:y,focus:()=>_.value?.focus()}),(e,t)=>((0,r.openBlock)(),(0,r.createElementBlock)(`section`,{class:`c-formula`,style:(0,r.normalizeStyle)({...(0,r.unref)(s),height:typeof(0,r.unref)(u).height==`number`?`${(0,r.unref)(u).height}px`:(0,r.unref)(u).height}),"aria-label":`公式编辑器`},[(0,r.createElementVNode)(`header`,be,[t[5]||=(0,r.createElementVNode)(`div`,null,[(0,r.createElementVNode)(`span`,{class:`c-formula__eyebrow`},`FORMULA WORKBENCH`),(0,r.createElementVNode)(`h2`,null,`规则与试算`),(0,r.createElementVNode)(`p`,null,`插入变量、编辑公式,再用试算值验证结果。`)],-1),(0,r.createElementVNode)(`div`,$,[(0,r.createVNode)((0,r.unref)(i.NTag),{type:(0,r.unref)(d).trim()?(0,r.unref)(f).validation.valid?`success`:`error`:`default`,size:`small`},{default:(0,r.withCtx)(()=>[(0,r.createTextVNode)((0,r.toDisplayString)((0,r.unref)(d).trim()?(0,r.unref)(f).validation.valid?`语法有效`:`需要修正`:`等待输入`),1)]),_:1},8,[`type`]),(0,r.createVNode)((0,r.unref)(i.NButton),{size:`small`,disabled:(0,r.unref)(u).disabled,onClick:(0,r.unref)(g)},{default:(0,r.withCtx)(()=>[...t[4]||=[(0,r.createTextVNode)(`重置`,-1)]]),_:1},8,[`disabled`,`onClick`])])]),(0,r.unref)(u).templates.length?((0,r.openBlock)(),(0,r.createElementBlock)(`div`,xe,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)((0,r.unref)(u).templates,e=>((0,r.openBlock)(),(0,r.createElementBlock)(`button`,{key:e.value,type:`button`,disabled:(0,r.unref)(u).disabled,"aria-pressed":(0,r.unref)(d)===e.value,onClick:t=>d.value=e.value},[(0,r.createElementVNode)(`strong`,null,(0,r.toDisplayString)(e.label),1),(0,r.createElementVNode)(`span`,null,(0,r.toDisplayString)(e.description),1)],8,Se))),128))])):(0,r.createCommentVNode)(`v-if`,!0),(0,r.createElementVNode)(`div`,{class:(0,r.normalizeClass)([`c-formula__body`,{"c-formula__body--no-sidebar":!(0,r.unref)(u).showVariablePanel,"c-formula__body--no-preview":!(0,r.unref)(u).showPreview}])},[(0,r.unref)(u).showVariablePanel?((0,r.openBlock)(),(0,r.createElementBlock)(`aside`,Ce,[(0,r.createVNode)(H,{variables:(0,r.unref)(u).variables,functions:(0,r.unref)(u).functions,disabled:(0,r.unref)(u).disabled,onSelectVariable:t[0]||=e=>y(`[${e.name}]`),onSelectFunction:t[1]||=e=>y(`${e.name}(`)},null,8,[`variables`,`functions`,`disabled`])])):(0,r.createCommentVNode)(`v-if`,!0),(0,r.createElementVNode)(`div`,we,[(0,r.createVNode)(D,{ref_key:`formulaInputRef`,ref:_,formula:(0,r.unref)(d),tokens:(0,r.unref)(f).tokens,validation:(0,r.unref)(f).validation,disabled:(0,r.unref)(u).disabled,placeholder:(0,r.unref)(u).placeholder,"onUpdate:formula":v},null,8,[`formula`,`tokens`,`validation`,`disabled`,`placeholder`]),(0,r.unref)(u).showKeyboard?((0,r.openBlock)(),(0,r.createElementBlock)(`details`,Te,[(0,r.createElementVNode)(`summary`,null,[(0,r.createVNode)(n.t,{type:`svg`,"svg-path":`M4 5h16v14H4zM6 7v10h12V7zM7 8h2v2H7zM10 8h2v2h-2zM13 8h2v2h-2zM16 8h1v2h-1zM7 11h2v2H7zM10 11h2v2h-2zM13 11h2v2h-2zM16 11h1v2h-1zM8 14h8v2H8z`,size:18}),t[6]||=(0,r.createElementVNode)(`span`,{class:`c-formula__keyboard-title`},[(0,r.createTextVNode)(`公式键盘`),(0,r.createElementVNode)(`small`,null,`数字、运算与函数 · 点击插入`)],-1),(0,r.createVNode)(n.t,{class:`c-formula__keyboard-chevron`,type:`svg`,"svg-path":`M6 8l6 6 6-6 1.4 1.4L12 16.8 4.6 9.4z`,size:18})]),(0,r.createVNode)(oe,{disabled:(0,r.unref)(u).disabled,functions:(0,r.unref)(u).functions,onKeyPress:t[2]||=e=>y(e.value),onInsertFunction:t[3]||=e=>y(`${e.name}(`),onAction:b},null,8,[`disabled`,`functions`])])):(0,r.createCommentVNode)(`v-if`,!0),(0,r.createElementVNode)(`div`,Ee,[(0,r.createVNode)(n.t,{name:`mdi:information-outline`,size:16}),t[7]||=(0,r.createElementVNode)(`p`,null,[(0,r.createTextVNode)(`变量使用 `),(0,r.createElementVNode)(`code`,null,`[变量名]`),(0,r.createTextVNode)(`,支持括号、比较和条件函数。右侧结果是当前数据的本地试算。`)],-1)])]),(0,r.unref)(u).showPreview?((0,r.openBlock)(),(0,r.createBlock)(ye,{key:1,formula:(0,r.unref)(d),"eval-result":(0,r.unref)(p),"used-variables":(0,r.unref)(m),editable:(0,r.unref)(u).editableSampleData&&!(0,r.unref)(u).disabled,onUpdateValue:(0,r.unref)(h)},null,8,[`formula`,`eval-result`,`used-variables`,`editable`,`onUpdateValue`])):(0,r.createCommentVNode)(`v-if`,!0)],2)],4))}});var Oe=t.t(De,[[`__scopeId`,`data-v-78a3bd4f`]]);function ke(e){let t=(0,r.computed)(()=>{let t=new Map;for(let n of e.value)t.set(n.name,n.field);return t}),n,i;function a(e,r){if(!e.trim())return{success:!0,result:void 0};try{return(!i||n!==e)&&(i=b(e),n=e),{success:!0,result:i.evaluate(t.value,r)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}}function o(e){try{return[...new Set(x(e).filter(e=>e.type===`variable`).map(e=>e.value))]}catch{return[]}}return{evaluate:a,extractVariableNames:o,variableMap:t}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return ke}});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,r:`\r`,t:` `}[t]??t}else o+=t;n+=1}if(!s)throw Error(`第 ${a+1} 个字符处的字符串未闭合`);r({type:`string`,value:o,position:a});continue}let o=e.slice(n,n+2);if([`>=`,`<=`,`==`,`!=`].includes(o)){r({type:`operator`,value:o,position:n}),n+=2;continue}if(`+-*/%><?:`.includes(t)){r({type:`operator`,value:t,position:n}),n+=1;continue}if(`(),`.includes(t)){r({type:`punctuation`,value:t,position:n}),n+=1;continue}let s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(i);if(s){let e=s[0],t=e.toUpperCase();r({type:[`AND`,`OR`,`NOT`].includes(t)?`operator`:`identifier`,value:[`AND`,`OR`,`NOT`].includes(t)?t:e,position:n}),n+=e.length;continue}throw Error(`第 ${n+1} 个字符“${t}”不受支持`)}return t.push({type:`eof`,value:``,position:n}),t}var te=class{cursor=0;nestingDepth=0;constructor(e){this.tokens=e}parse(){let e=this.parseConditional();return this.expect(`eof`),e}current(){return this.tokens[this.cursor]}advance(){return this.tokens[this.cursor++]}consume(e){return this.current().value===e?(this.advance(),!0):!1}expect(e,t){let n=this.current();if(n.type!==e||t!==void 0&&n.value!==t)throw Error(`第 ${n.position+1} 个字符处应为 ${t??e}`);return this.advance()}parseConditional(){if(++this.nestingDepth>100)throw Error(`公式嵌套不能超过 100 层`);try{let e=this.parseOr();if(!this.consume(`?`))return e;let t=this.parseConditional();return this.expect(`operator`,`:`),{kind:`conditional`,condition:e,truthy:t,falsy:this.parseConditional()}}finally{this.nestingDepth--}}parseBinary(e,t){let n=e();for(;t.includes(this.current().value);)n={kind:`binary`,operator:this.advance().value,left:n,right:e()};return n}parseOr(){return this.parseBinary(()=>this.parseAnd(),[`OR`])}parseAnd(){return this.parseBinary(()=>this.parseEquality(),[`AND`])}parseEquality(){return this.parseBinary(()=>this.parseComparison(),[`==`,`!=`])}parseComparison(){return this.parseBinary(()=>this.parseAdditive(),[`>`,`>=`,`<`,`<=`])}parseAdditive(){return this.parseBinary(()=>this.parseMultiplicative(),[`+`,`-`])}parseMultiplicative(){return this.parseBinary(()=>this.parseUnary(),[`*`,`/`,`%`])}parseUnary(){let e=[];for(;[`-`,`+`,`NOT`].includes(this.current().value)&&!(this.current().value===`NOT`&&this.tokens[this.cursor+1]?.value===`(`);)if(e.push(this.advance().value),e.length>100)throw Error(`一元运算不能超过 100 层`);let t=this.parsePrimary();for(let n of e.reverse())t={kind:`unary`,operator:n,value:t};return t}parsePrimary(){let e=this.current();if(e.type===`number`||e.type===`string`)return this.advance(),{kind:`literal`,value:e.type===`number`?Number(e.value):e.value};if(e.type===`variable`)return this.advance(),{kind:`variable`,name:e.value};if(e.type===`identifier`||e.type===`operator`&&[`AND`,`OR`,`NOT`].includes(e.value)){this.advance();let t=e.value.toUpperCase();if(t===`TRUE`||t===`FALSE`)return{kind:`literal`,value:t===`TRUE`};if(this.consume(`(`))return this.parseFunction(t,e);if(t===`NOT`)return{kind:`unary`,operator:`NOT`,value:this.parseUnary()};if(e.type===`identifier`)return{kind:`identifier`,name:e.value}}if(this.consume(`(`)){let e=this.parseConditional();return this.expect(`punctuation`,`)`),e}throw Error(`第 ${e.position+1} 个字符处缺少有效值`)}parseFunction(e,t){if(!Object.prototype.hasOwnProperty.call(z,e))throw Error(`第 ${t.position+1} 个字符处:未知函数“${t.value}”`);let n=[];if(!this.consume(`)`)){do n.push(this.parseConditional());while(this.consume(`,`));this.expect(`punctuation`,`)`)}let[r,i]=e===`IF`?[3,3]:e===`ROUND`?[1,2]:[`AND`,`OR`,`SUM`,`AVG`,`MAX`,`MIN`].includes(e)?[1,1/0]:[1,1];if(n.length<r||n.length>i)throw Error(`第 ${t.position+1} 个字符处:${e} 需要 ${r===i?r:`${r}–${i===1/0?`多个`:i}`} 个参数`);return{kind:`call`,name:e,args:n}}};function H(e,t){if(!Object.prototype.hasOwnProperty.call(t,e)||t[e]==null)throw Error(`变量“${e}”缺少样例数据`);let n=t[e];if(![`number`,`string`,`boolean`].includes(typeof n)||typeof n==`number`&&!Number.isFinite(n))throw Error(`变量“${e}”的数据类型不受支持`);return n}function U(e,t,n){switch(e){case`==`:return t===n;case`!=`:return t!==n;case`+`:return B(t)+B(n);case`-`:return B(t)-B(n);case`*`:return B(t)*B(n);case`/`:return B(t)/B(n);case`%`:return B(t)%B(n);default:if(typeof t==`boolean`||typeof n==`boolean`)throw Error(`运算符 ${e} 不支持布尔值`);return e===`>`?t>n:e===`>=`?t>=n:e===`<`?t<n:t<=n}}function W(e,t,n,r=0){if(r>200)throw Error(`公式计算层数超过安全限制`);let i=e=>W(e,t,n,r+1);switch(e.kind){case`literal`:return e.value;case`variable`:{let r=t.get(e.name);if(!r)throw Error(`未知变量“${e.name}”`);return H(r,n)}case`identifier`:return H(e.name,n);case`conditional`:return i(e.condition)?i(e.truthy):i(e.falsy);case`unary`:{let t=i(e.value);return e.operator===`NOT`?!t:e.operator===`-`?-B(t):B(t)}case`binary`:{let t=i(e.left);return e.operator===`AND`?!!t&&!!i(e.right):e.operator===`OR`?!!t||!!i(e.right):U(e.operator,t,i(e.right))}case`call`:return e.name===`IF`?i(e.args[0])?i(e.args[1]):i(e.args[2]):e.name===`AND`?e.args.every(e=>!!i(e)):e.name===`OR`?e.args.some(e=>!!i(e)):z[e.name](...e.args.map(i))}}function G(e){let t=V(e),n=new te(t).parse();return{tokens:t,evaluate(e,t){let r=W(n,e,t);if(typeof r==`number`&&!Number.isFinite(r))throw Error(`公式计算结果必须是有限数值`);return r}}}function K(e){return V(e)}function q(e,t){let n=r(()=>new Set(e.value.map(e=>e.name))),i=r(()=>new Set(e.value.map(e=>e.field))),a=r(()=>new Set(t.value.map(e=>e.name.toUpperCase()))),o=null;function s(e){try{let t=K(e),n=[],r=0;return t.forEach((i,a)=>{if(i.type===`eof`)return;i.position>r&&n.push({type:`space`,value:e.slice(r,i.position),start:r,end:i.position});let o=e.slice(i.position,t[a+1]?.position??e.length).trimEnd();r=i.position+o.length;let s=t[a+1],c=i.type===`variable`?`variable`:i.type===`number`?`number`:s?.value===`(`&&(i.type===`identifier`||[`AND`,`OR`,`NOT`].includes(i.value))?`function`:i.type===`operator`?`operator`:i.type===`punctuation`?i.value===`,`?`comma`:`paren`:`text`;n.push({type:c,value:c===`variable`?i.value:o,start:i.position,end:r})}),r<e.length&&n.push({type:`space`,value:e.slice(r),start:r,end:e.length}),n}catch{return e?[{type:`text`,value:e,start:0,end:e.length}]:[]}}function c(e){let t=n.value,r=i.value,c=a.value;if(o?.formula===e&&o.names===t&&o.fields===r&&o.functions===c)return o.analysis;let l={tokens:s(e),validation:{valid:!0,message:e.trim()?`语法校验通过`:`尚未输入公式`},compiled:null};if(e.trim())try{l.compiled=G(e);for(let e of l.tokens){if(e.type===`variable`&&!t.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知变量「${e.value}」`);if(e.type===`function`&&!c.has(e.value.toUpperCase()))throw Error(`第 ${e.start+1} 个字符处:未知函数「${e.value}」`);if(e.type===`text`&&/^[A-Za-z_]\w*$/.test(e.value)&&![`TRUE`,`FALSE`].includes(e.value.toUpperCase())&&!r.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知字段「${e.value}」`)}}catch(e){let t=e instanceof Error?e.message:String(e),n=/第 (\d+) 个字符/.exec(t);l.validation={valid:!1,message:t,...n?{position:Number(n[1])-1}:{}},l.compiled=null}return o={formula:e,names:t,fields:r,functions:c,analysis:l},l}function l(e){return c(e).validation}function u(e,t){let n=0,r=``;for(let i of s(e).filter(e=>e.type===`variable`))r+=e.slice(n,i.start)+(t.get(i.value)??`__unknown_${i.value}__`),n=i.end;return r+e.slice(n)}return{tokenize:s,analyze:c,validate:l,toEvalExpression:u,variableNames:n,functionNames:a}}function J(e){let t=r(()=>({variables:e.config?.variables??e.variables??[],functions:e.config?.functions??e.functions??F,sampleData:e.config?.sampleData??e.sampleData??{},disabled:e.config?.disabled??e.disabled??!1,placeholder:e.config?.placeholder??e.placeholder??`例如:[完成值] / [目标值] * 100`,height:e.config?.height??e.height??`auto`,showPreview:e.config?.showPreview??e.showPreview??!0,showKeyboard:e.config?.showKeyboard??e.showKeyboard??!0,showVariablePanel:e.config?.showVariablePanel??e.showVariablePanel??!0,editableSampleData:e.config?.editableSampleData??e.editableSampleData??!0,templates:e.config?.templates??e.templates??[]})),n=e.modelValue??``,i=h(n),a=h({}),o=q(r(()=>t.value.variables),r(()=>t.value.functions)),s=r(()=>o.analyze(i.value)),c=r(()=>{let e=new Map(Object.entries(t.value.sampleData));for(let[t,n]of Object.entries(a.value))n===null?e.delete(t):e.set(t,n);return Object.fromEntries(e)}),l=r(()=>new Map(t.value.variables.map(e=>[e.name,e.field]))),u=r(()=>{let e=s.value.tokens.filter(e=>e.type===`variable`).map(e=>e.value),n=s.value.tokens.filter(e=>e.type===`text`).map(e=>e.value);return t.value.variables.filter(t=>e.includes(t.name)||n.includes(t.field)).map(e=>({...e,value:c.value[e.field]}))}),d=r(()=>{if(!s.value.validation.valid)return{success:!1,result:void 0,error:s.value.validation.message};if(!s.value.compiled)return{success:!0,result:void 0};try{return{success:!0,result:s.value.compiled.evaluate(l.value,c.value)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}});function f(e,n){!t.value.disabled&&t.value.editableSampleData&&(a.value={...a.value,[e]:n})}function p(){i.value=n,a.value={}}return S(()=>e.modelValue,e=>{e!==void 0&&e!==i.value&&(i.value=e)}),S(()=>t.value.sampleData,()=>{a.value={}}),{options:t,formula:i,analysis:s,evalResult:d,usedVariables:u,updateSample:f,reset:p}}const Y={class:`formula-input__header`},X=[`readonly`,`aria-invalid`,`placeholder`],Z={key:0,class:`formula-input__tokens`,"aria-label":`公式结构预览`};var Q=t(u({name:`FormulaInput`,__name:`FormulaInput`,props:{formula:{},tokens:{},validation:{},variableNames:{},disabled:{type:Boolean,default:!1},placeholder:{default:`例如:[完成值] / [目标值] * 100`}},emits:[`update:formula`],setup(e,{expose:t,emit:r}){let i=e,c=r,l=h(),u=h(i.formula),p=`formula-feedback-${y()}`,v=u.value.length,x=v;S(u,e=>c(`update:formula`,e),{flush:`sync`}),S(()=>i.formula,e=>{e!==u.value&&(u.value=e,v=x=e.length)});function C(){l.value&&(v=l.value.selectionStart,x=l.value.selectionEnd)}function T(e,t=v,n=x){if(i.disabled)return;let r=Math.max(0,Math.min(t,u.value.length));u.value=u.value.slice(0,r)+e+u.value.slice(Math.max(r,n)),v=x=r+e.length,d(()=>{l.value?.focus({preventScroll:!0}),l.value?.setSelectionRange(v,x)})}function E(e){T(e)}function D(){if(v!==x){T(``);return}if(v===0)return;let e=i.tokens.find(e=>e.type===`variable`&&e.end===v),t=Array.from(u.value.slice(0,v)).pop()?.length??1;T(``,e?.start??v-t,x)}function O(){T(``,0,u.value.length)}function k(){v=x=u.value.length,l.value?.setSelectionRange(v,x)}function A(){l.value?.focus({preventScroll:!0}),k()}function j(){let e=i.validation.position??0;l.value?.focus({preventScroll:!0}),l.value?.setSelectionRange(e,Math.min(e+1,u.value.length)),C()}return t({insertAtCursor:E,backspace:D,clear:O,focus:A,moveCursorToEnd:k}),(t,r)=>(m(),o(`div`,{class:f([`formula-input`,{"formula-input--disabled":e.disabled,"formula-input--error":!e.validation.valid&&e.formula.trim()}])},[s(`div`,Y,[r[1]||=s(`span`,{class:`formula-input__label`},`01 / 编辑公式`,-1),e.formula.trim()&&!e.disabled?(m(),o(`button`,{key:0,type:`button`,class:`formula-input__clear`,onClick:O},`清空公式`)):a(`v-if`,!0)]),w(s(`textarea`,{ref_key:`editorRef`,ref:l,"onUpdate:modelValue":r[0]||=e=>u.value=e,class:`formula-input__editor`,readonly:e.disabled,"aria-label":`公式输入`,"aria-invalid":!e.validation.valid&&!!e.formula.trim(),"aria-describedby":p,placeholder:e.placeholder,spellcheck:`false`,onSelect:C,onClick:C,onKeyup:C,onBlur:C},null,40,X),[[b,u.value]]),e.tokens.length?(m(),o(`div`,Z,[r[2]||=s(`span`,{class:`formula-input__tokens-label`},`结构预览`,-1),(m(!0),o(n,null,g(e.tokens,(e,t)=>(m(),o(`span`,{key:t,class:f(`formula-token formula-token--${e.type}`)},_(e.type===`variable`?`[${e.value}]`:e.value),3))),128))])):a(`v-if`,!0),s(`div`,{id:p,class:`formula-input__validation`,role:`status`},[s(`span`,{class:f(e.formula.trim()?e.validation.valid?`formula-input__validation-success`:`formula-input__validation-error`:`formula-input__validation-hint`)},_(e.formula.trim()?e.validation.valid?`语法校验通过,可在右侧调整数据试算。`:e.validation.message:`点击左侧变量开始,也可以直接输入 [变量名]。`),3),e.validation.position===void 0?a(`v-if`,!0):(m(),o(`button`,{key:0,type:`button`,class:`formula-input__locate`,onClick:j},`定位错误`))])],2))}}),[[`__scopeId`,`data-v-5b2f30eb`]]);const ne={class:`variable-panel`},re={class:`variable-panel__tabs`},ie=[`aria-pressed`],ae=[`aria-pressed`],oe={class:`variable-panel__search`},se=[`aria-expanded`,`onClick`],ce={class:`variable-panel__items`},le=[`disabled`,`onClick`],ue={key:0},de=[`disabled`,`onClick`],fe={class:`variable-panel__func-name`},pe={class:`variable-panel__func-desc`},me={class:`variable-panel__func-sig`};var he=t(u({__name:`VariablePanel`,props:{variables:{},functions:{},disabled:{type:Boolean}},emits:[`select-variable`,`select-function`],setup(t){let u=t,d=h(`variable`),p=h(``),y=h(new Set),b=r(()=>{let e=p.value.toLowerCase(),t=e?u.variables.filter(t=>t.name.toLowerCase().includes(e)||t.field.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)):u.variables,n=new Map;for(let e of t){let t=e.group??`其他`,r=n.get(t);r?r.push(e):n.set(t,[e])}return Array.from(n,([e,t])=>({name:e,items:t}))});S(b,e=>{for(let t of e)y.value.add(t.name)},{immediate:!0});function T(e){y.value.has(e)?y.value.delete(e):y.value.add(e)}let O=r(()=>{let e=p.value.toLowerCase();return e?u.functions.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)):u.functions});function A(e){switch(e){case`number`:return`mdi:numeric`;case`text`:return`mdi:format-text`;case`boolean`:return`mdi:toggle-switch-outline`;default:return`mdi:variable`}}return(r,u)=>(m(),o(`div`,ne,[a(` 切换 Tab:变量 / 函数 `),s(`div`,re,[s(`button`,{type:`button`,class:f([`variable-panel__tab`,{"variable-panel__tab--active":d.value===`variable`}]),"aria-pressed":d.value===`variable`,onClick:u[0]||=e=>d.value=`variable`},` 可用变量 `,10,ie),s(`button`,{type:`button`,class:f([`variable-panel__tab`,{"variable-panel__tab--active":d.value===`function`}]),"aria-pressed":d.value===`function`,onClick:u[1]||=e=>d.value=`function`},` 常用函数 `,10,ae)]),a(` 搜索框 `),s(`div`,oe,[l(v(D),{value:p.value,"onUpdate:value":u[2]||=e=>p.value=e,size:`small`,placeholder:`搜索变量或函数`,"input-props":{"aria-label":`搜索变量或函数`},clearable:``},{prefix:C(()=>[l(e,{name:`mdi:magnify`,size:16})]),_:1},8,[`value`])]),a(` 变量列表 `),d.value===`variable`?(m(),i(v(k),{key:0,class:`variable-panel__list`},{default:C(()=>[b.value.length>0?(m(!0),o(n,{key:0},g(b.value,i=>(m(),o(`div`,{key:i.name,class:`variable-panel__group`},[s(`button`,{type:`button`,class:`variable-panel__group-title`,"aria-expanded":y.value.has(i.name),onClick:e=>T(i.name)},[l(e,{name:y.value.has(i.name)?`mdi:chevron-down`:`mdi:chevron-right`,size:16},null,8,[`name`]),c(` `+_(i.name),1)],8,se),w(s(`div`,ce,[(m(!0),o(n,null,g(i.items,n=>(m(),o(`button`,{key:n.field,type:`button`,class:`variable-panel__item`,disabled:t.disabled,onClick:e=>r.$emit(`select-variable`,n)},[l(e,{name:A(n.type),size:15,class:`variable-panel__item-icon`},null,8,[`name`]),s(`span`,null,[c(_(n.name),1),n.description?(m(),o(`small`,ue,_(n.description),1)):a(`v-if`,!0)])],8,le))),128))],512),[[x,y.value.has(i.name)]])]))),128)):(m(),i(v(E),{key:1,size:`small`,description:`无匹配变量`}))]),_:1})):(m(),o(n,{key:1},[a(` 函数列表 `),l(v(k),{class:`variable-panel__list`},{default:C(()=>[O.value.length>0?(m(!0),o(n,{key:0},g(O.value,e=>(m(),o(`button`,{key:e.name,type:`button`,class:`variable-panel__func`,disabled:t.disabled,onClick:t=>r.$emit(`select-function`,e)},[s(`div`,fe,[u[3]||=s(`span`,{class:`variable-panel__func-badge`},`ƒ`,-1),c(` `+_(e.name),1)]),s(`div`,pe,_(e.description),1),s(`div`,me,_(e.signature),1)],8,de))),128)):(m(),i(v(E),{key:1,size:`small`,description:`无匹配函数`}))]),_:1})],2112))]))}}),[[`__scopeId`,`data-v-2d73fec7`]]);const ge={class:`virtual-keyboard`,role:`group`,"aria-label":`公式键盘`},_e={key:0,class:`virtual-keyboard__functions`},ve={class:`virtual-keyboard__function-grid`},ye=[`disabled`,`title`,`aria-label`,`onClick`],be={class:`virtual-keyboard__body`},xe={class:`virtual-keyboard__operators`},Se={class:`virtual-keyboard__label`},Ce=[`disabled`,`aria-label`,`onClick`],we={class:`virtual-keyboard__numbers`},Te={class:`virtual-keyboard__keys virtual-keyboard__keys--numbers`},Ee=[`disabled`,`aria-label`,`onClick`],De={class:`virtual-keyboard__footer`},Oe={class:`virtual-keyboard__actions`},ke=[`disabled`,`aria-label`,`onClick`];var Ae=t(u({name:`VirtualKeyboard`,__name:`VirtualKeyboard`,props:{disabled:{type:Boolean,default:!1},functions:{default:()=>[]}},emits:[`key-press`,`insert-function`,`action`],setup(t){let r=N.filter(e=>e.type===`number`),i=P.map(e=>({...e,label:e.value===`BACKSPACE`?`退格`:e.label,icon:e.value===`BACKSPACE`?`M9 4h12v16H9L2 12zM9.9 6 4.6 12l5.3 6H19V6zM11 8l6 6-1.4 1.4-6-6zM15.6 8 17 9.4l-6 6-1.4-1.4z`:`M5 5h14v2H5zM9 2h6v2H9zM7 8h2v11h6V8h2v13H7zM10 8h1v9h-1zM13 8h1v9h-1z`})),u=[{name:`arithmetic`,label:`四则与取余`,keys:[...N,...M].filter(e=>e.type===`operator`)},{name:`compare`,label:`比较判断`,keys:M.filter(e=>e.type===`compare`)},{name:`logic`,label:`括号与条件`,keys:M.filter(e=>e.type===`paren`||e.type===`logic`)}];return(d,p)=>(m(),o(`div`,ge,[t.functions.length?(m(),o(`div`,_e,[p[1]||=s(`span`,{class:`virtual-keyboard__label`},`函数快捷输入`,-1),s(`div`,ve,[(m(!0),o(n,null,g(t.functions,e=>(m(),o(`button`,{key:e.name,type:`button`,class:`virtual-keyboard__function`,disabled:t.disabled,title:`${e.signature} · ${e.description}`,"aria-label":`插入函数 ${e.name}`,onClick:t=>d.$emit(`insert-function`,e)},[c(_(e.name),1),p[0]||=s(`span`,null,`( )`,-1)],8,ye))),128))])])):a(`v-if`,!0),s(`div`,be,[s(`div`,xe,[(m(),o(n,null,g(u,e=>s(`section`,{key:e.label,class:`virtual-keyboard__group`},[s(`h3`,Se,_(e.label),1),s(`div`,{class:f([`virtual-keyboard__keys`,`virtual-keyboard__keys--${e.name}`])},[(m(!0),o(n,null,g(e.keys,e=>(m(),o(`button`,{key:e.value,type:`button`,class:f([`virtual-keyboard__key`,e.color&&`virtual-keyboard__key--${e.color}`]),disabled:t.disabled,"aria-label":`插入 ${e.label}`,onClick:t=>d.$emit(`key-press`,e)},_(e.label),11,Ce))),128))],2)])),64))]),s(`section`,we,[p[2]||=s(`h3`,{class:`virtual-keyboard__label`},`数字输入`,-1),s(`div`,Te,[(m(!0),o(n,null,g(v(r),e=>(m(),o(`button`,{key:e.value,type:`button`,class:f([`virtual-keyboard__key`,{"virtual-keyboard__key--zero":e.value===`0`}]),disabled:t.disabled,"aria-label":`输入 ${e.label}`,onClick:t=>d.$emit(`key-press`,e)},_(e.label),11,Ee))),128))])])]),s(`footer`,De,[p[3]||=s(`span`,null,`按键会插入到光标处,选中文字可直接替换。`,-1),s(`div`,Oe,[(m(!0),o(n,null,g(v(i),n=>(m(),o(`button`,{key:n.value,type:`button`,class:f([`virtual-keyboard__action`,{"virtual-keyboard__action--clear":n.value===`CLEAR`}]),disabled:t.disabled,"aria-label":n.label,onClick:e=>d.$emit(`action`,n.value)},[l(e,{type:`svg`,"svg-path":n.icon,size:16},null,8,[`svg-path`]),c(_(n.label),1)],10,ke))),128))])])]))}}),[[`__scopeId`,`data-v-05f0982d`]]);const je={class:`formula-preview`,"aria-label":`公式试算`},Me={class:`formula-preview__result-label`},Ne={key:0,class:`formula-preview__result-value`},Pe={key:1,class:`formula-preview__result-empty`},Fe={class:`formula-preview__vars`},Ie={class:`formula-preview__vars-title`},Le={class:`formula-preview__var-heading`},Re=[`for`],ze={key:3,class:`formula-preview__var-value`},Be={key:4},Ve={key:0,class:`formula-preview__empty`};var $=t(u({name:`FormulaPreview`,__name:`FormulaPreview`,props:{formula:{},evalResult:{},usedVariables:{},editable:{type:Boolean}},emits:[`update-value`],setup(e,{emit:t}){let r=t,l=`formula-sample-${y()}`;function u(e){return typeof e==`number`?new Intl.NumberFormat(void 0,{maximumFractionDigits:6}).format(e):typeof e==`boolean`?e?`真 · true`:`假 · false`:String(e)}return(t,d)=>(m(),o(`aside`,je,[d[1]||=s(`header`,null,[s(`span`,{class:`formula-preview__step`},`02`),s(`div`,null,[s(`h3`,null,`验证计算结果`),s(`p`,null,`调整试算值,观察规则是否符合预期。`)])],-1),s(`div`,{class:f([`formula-preview__result`,{"formula-preview__result--error":!!e.evalResult.error}]),role:`status`,"aria-live":`polite`},[s(`span`,Me,_(e.evalResult.error?`暂时无法计算`:`试算结果`),1),e.evalResult.success&&e.evalResult.result!==void 0?(m(),o(`output`,Ne,_(u(e.evalResult.result)),1)):(m(),o(`span`,Pe,_(e.formula.trim()?e.evalResult.error||`等待数据`:`输入公式后展示结果`),1))],2),s(`div`,Fe,[s(`div`,Ie,[d[0]||=c(`本次使用的试算值 `,-1),s(`span`,null,_(e.usedVariables.length)+` 项`,1)]),(m(!0),o(n,null,g(e.usedVariables,t=>(m(),o(`div`,{key:t.field,class:`formula-preview__var-row`},[s(`div`,Le,[s(`label`,{for:`${l}-${t.field}`},_(t.name),9,Re),s(`code`,null,_(t.field),1)]),e.editable&&t.type===`number`?(m(),i(v(O),{key:0,value:typeof t.value==`number`?t.value:null,"input-props":{id:`${l}-${t.field}`,"aria-label":`试算值:${t.name}`},placeholder:`请输入数值`,"onUpdate:value":e=>r(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):e.editable&&t.type===`boolean`?(m(),i(v(A),{key:1,value:t.value===!0,"aria-label":`试算值:${t.name}`,"onUpdate:value":e=>r(`update-value`,t.field,e)},null,8,[`value`,`aria-label`,`onUpdate:value`])):e.editable&&t.type===`text`?(m(),i(v(D),{key:2,value:typeof t.value==`string`?t.value:``,"input-props":{id:`${l}-${t.field}`,"aria-label":`试算值:${t.name}`},"onUpdate:value":e=>r(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):(m(),o(`span`,ze,_(t.value??`未提供`),1)),t.description?(m(),o(`p`,Be,_(t.description),1)):a(`v-if`,!0)]))),128)),e.usedVariables.length?a(`v-if`,!0):(m(),o(`p`,Ve,_(e.formula.trim()?`当前公式没有引用变量。`:`引用变量后,对应数据会出现在这里。`),1))]),d[2]||=s(`p`,{class:`formula-preview__note`},`试算值仅用于本次验证,修改不会写入业务数据。`,-1)]))}}),[[`__scopeId`,`data-v-b2656900`]]);const He={class:`c-formula__title-row`},Ue={class:`c-formula__actions`},We={key:0,class:`c-formula__templates`,"aria-label":`公式模板`},Ge=[`disabled`,`aria-pressed`,`onClick`],Ke={key:0,class:`c-formula__sidebar`},qe={class:`c-formula__main`},Je={key:0,class:`c-formula__keyboard`,open:``},Ye={class:`c-formula__guide`};var Xe=t(u({name:`C_FormulaEditor`,__name:`index`,props:{modelValue:{},config:{},variables:{},functions:{},sampleData:{},disabled:{type:Boolean,default:!1},placeholder:{},height:{},showPreview:{type:Boolean,default:!0},showKeyboard:{type:Boolean,default:!0},showVariablePanel:{type:Boolean,default:!0},editableSampleData:{type:Boolean,default:!0},templates:{}},emits:[`update:modelValue`,`change`,`validation-change`],setup(t,{expose:r,emit:u}){let d=t,y=u,{options:b,formula:x,analysis:w,evalResult:E,usedVariables:D,updateSample:O,reset:k}=J(d),A=h();S(x,e=>{y(`update:modelValue`,e),y(`change`,e)}),S(()=>w.value.validation,e=>y(`validation-change`,e),{immediate:!0});function M(e){b.value.disabled||(x.value=e)}function N(e){b.value.disabled||A.value?.insertAtCursor(e)}function P(e){b.value.disabled||(e===`BACKSPACE`&&A.value?.backspace(),e===`CLEAR`&&A.value?.clear())}return r({getValue:()=>x.value,setValue:e=>{x.value=e},reset:k,validate:()=>w.value.validation,insertAtCursor:N,focus:()=>A.value?.focus()}),(t,r)=>(m(),o(`section`,{class:`c-formula`,style:p({height:typeof v(b).height==`number`?`${v(b).height}px`:v(b).height}),"aria-label":`公式编辑器`},[s(`header`,He,[r[5]||=s(`div`,null,[s(`span`,{class:`c-formula__eyebrow`},`FORMULA WORKBENCH`),s(`h2`,null,`规则与试算`),s(`p`,null,`插入变量、编辑公式,再用试算值验证结果。`)],-1),s(`div`,Ue,[l(v(j),{type:v(x).trim()?v(w).validation.valid?`success`:`error`:`default`,size:`small`},{default:C(()=>[c(_(v(x).trim()?v(w).validation.valid?`语法有效`:`需要修正`:`等待输入`),1)]),_:1},8,[`type`]),l(v(T),{size:`small`,disabled:v(b).disabled,onClick:v(k)},{default:C(()=>[...r[4]||=[c(`重置`,-1)]]),_:1},8,[`disabled`,`onClick`])])]),v(b).templates.length?(m(),o(`div`,We,[(m(!0),o(n,null,g(v(b).templates,e=>(m(),o(`button`,{key:e.value,type:`button`,disabled:v(b).disabled,"aria-pressed":v(x)===e.value,onClick:t=>x.value=e.value},[s(`strong`,null,_(e.label),1),s(`span`,null,_(e.description),1)],8,Ge))),128))])):a(`v-if`,!0),s(`div`,{class:f([`c-formula__body`,{"c-formula__body--no-sidebar":!v(b).showVariablePanel,"c-formula__body--no-preview":!v(b).showPreview}])},[v(b).showVariablePanel?(m(),o(`aside`,Ke,[l(he,{variables:v(b).variables,functions:v(b).functions,disabled:v(b).disabled,onSelectVariable:r[0]||=e=>N(`[${e.name}]`),onSelectFunction:r[1]||=e=>N(`${e.name}(`)},null,8,[`variables`,`functions`,`disabled`])])):a(`v-if`,!0),s(`div`,qe,[l(Q,{ref_key:`formulaInputRef`,ref:A,formula:v(x),tokens:v(w).tokens,validation:v(w).validation,disabled:v(b).disabled,placeholder:v(b).placeholder,"onUpdate:formula":M},null,8,[`formula`,`tokens`,`validation`,`disabled`,`placeholder`]),v(b).showKeyboard?(m(),o(`details`,Je,[s(`summary`,null,[l(e,{type:`svg`,"svg-path":`M4 5h16v14H4zM6 7v10h12V7zM7 8h2v2H7zM10 8h2v2h-2zM13 8h2v2h-2zM16 8h1v2h-1zM7 11h2v2H7zM10 11h2v2h-2zM13 11h2v2h-2zM16 11h1v2h-1zM8 14h8v2H8z`,size:18}),r[6]||=s(`span`,{class:`c-formula__keyboard-title`},[c(`公式键盘`),s(`small`,null,`数字、运算与函数 · 点击插入`)],-1),l(e,{class:`c-formula__keyboard-chevron`,type:`svg`,"svg-path":`M6 8l6 6 6-6 1.4 1.4L12 16.8 4.6 9.4z`,size:18})]),l(Ae,{disabled:v(b).disabled,functions:v(b).functions,onKeyPress:r[2]||=e=>N(e.value),onInsertFunction:r[3]||=e=>N(`${e.name}(`),onAction:P},null,8,[`disabled`,`functions`])])):a(`v-if`,!0),s(`div`,Ye,[l(e,{name:`mdi:information-outline`,size:16}),r[7]||=s(`p`,null,[c(`变量使用 `),s(`code`,null,`[变量名]`),c(`,支持括号、比较和条件函数。右侧结果是当前数据的本地试算。`)],-1)])]),v(b).showPreview?(m(),i($,{key:1,formula:v(x),"eval-result":v(E),"used-variables":v(D),editable:v(b).editableSampleData&&!v(b).disabled,onUpdateValue:v(O)},null,8,[`formula`,`eval-result`,`used-variables`,`editable`,`onUpdateValue`])):a(`v-if`,!0)],2)],4))}}),[[`__scopeId`,`data-v-b006a294`]]);function Ze(e){let t=r(()=>{let t=new Map;for(let n of e.value)t.set(n.name,n.field);return t}),n,i;function a(e,r){if(!e.trim())return{success:!0,result:void 0};try{return(!i||n!==e)&&(i=G(e),n=e),{success:!0,result:i.evaluate(t.value,r)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}}function o(e){try{return[...new Set(K(e).filter(e=>e.type===`variable`).map(e=>e.value))]}catch{return[]}}return{evaluate:a,extractVariableNames:o,variableMap:t}}export{F as a,M as c,P as i,I as l,Xe as n,N as o,q as r,ee as s,Ze as t};
|
|
1
|
+
import{n as e}from"./useComponentTheme.js";import{t}from"./export-helper.js";import{t as n}from"./C_Icon2.js";import{Fragment as r,computed as i,createBlock as a,createCommentVNode as o,createElementBlock as s,createElementVNode as c,createTextVNode as l,createVNode as u,defineComponent as d,nextTick as f,normalizeClass as p,normalizeStyle as m,openBlock as h,ref as g,renderList as _,toDisplayString as v,unref as y,useId as b,vModelText as x,vShow as S,watch as C,withCtx as w,withDirectives as T}from"vue";import{NButton as E,NEmpty as D,NInput as O,NInputNumber as k,NScrollbar as A,NSwitch as j,NTag as ee}from"naive-ui";const M=[{label:`?`,value:` ? `,type:`logic`,color:`warning`},{label:`:`,value:` : `,type:`logic`,color:`warning`},{label:`and`,value:` AND `,type:`logic`,color:`warning`},{label:`or`,value:` OR `,type:`logic`,color:`warning`},{label:`(`,value:`(`,type:`paren`},{label:`)`,value:`)`,type:`paren`},{label:`,`,value:`, `,type:`paren`},{label:`==`,value:` == `,type:`compare`},{label:`>`,value:` > `,type:`compare`},{label:`<`,value:` < `,type:`compare`},{label:`≥`,value:` >= `,type:`compare`},{label:`≤`,value:` <= `,type:`compare`},{label:`≠`,value:` != `,type:`compare`},{label:`%`,value:` % `,type:`operator`}],N=[{label:`1`,value:`1`,type:`number`},{label:`2`,value:`2`,type:`number`},{label:`3`,value:`3`,type:`number`},{label:`+`,value:` + `,type:`operator`,color:`primary`},{label:`−`,value:` - `,type:`operator`,color:`primary`},{label:`4`,value:`4`,type:`number`},{label:`5`,value:`5`,type:`number`},{label:`6`,value:`6`,type:`number`},{label:`×`,value:` * `,type:`operator`,color:`primary`},{label:`÷`,value:` / `,type:`operator`,color:`primary`},{label:`7`,value:`7`,type:`number`},{label:`8`,value:`8`,type:`number`},{label:`9`,value:`9`,type:`number`},{label:`0`,value:`0`,type:`number`},{label:`.`,value:`.`,type:`number`}],P=[{label:`⌫`,value:`BACKSPACE`,type:`action`,isAction:!0},{label:`清空`,value:`CLEAR`,type:`action`,isAction:!0}],F=[{name:`IF`,signature:`IF(条件, 真值, 假值)`,description:`根据条件返回不同的值`,category:`逻辑`},{name:`AND`,signature:`AND(条件1, 条件2)`,description:`全部条件为真时返回真`,category:`逻辑`},{name:`OR`,signature:`OR(条件1, 条件2)`,description:`任一条件为真时返回真`,category:`逻辑`},{name:`NOT`,signature:`NOT(条件)`,description:`对条件取反`,category:`逻辑`},{name:`SUM`,signature:`SUM(值1, 值2, ...)`,description:`计算所有值的总和`,category:`数学`},{name:`AVG`,signature:`AVG(值1, 值2, ...)`,description:`计算所有值的平均值`,category:`数学`},{name:`MAX`,signature:`MAX(值1, 值2, ...)`,description:`返回最大值`,category:`数学`},{name:`MIN`,signature:`MIN(值1, 值2, ...)`,description:`返回最小值`,category:`数学`},{name:`ABS`,signature:`ABS(数值)`,description:`返回绝对值`,category:`数学`},{name:`ROUND`,signature:`ROUND(数值, 小数位)`,description:`四舍五入到指定小数位`,category:`数学`},{name:`CEIL`,signature:`CEIL(数值)`,description:`向上取整`,category:`数学`},{name:`FLOOR`,signature:`FLOOR(数值)`,description:`向下取整`,category:`数学`}],I=new Set([`+`,`-`,`*`,`/`,`%`,`>`,`<`,`>=`,`<=`,`==`,`!=`,`?`,`:`,`AND`,`OR`,`NOT`]),L=new Set([`+`,`-`,`*`,`/`,`%`,`>`,`<`,`>=`,`<=`,`==`,`!=`,`?`,`:`,`AND`,`OR`]),R=1e4,z=5e3,B=Object.freeze({IF:(e,t,n)=>e?t:n,AND:(...e)=>e.every(Boolean),OR:(...e)=>e.some(Boolean),NOT:e=>!e,SUM:(...e)=>e.reduce((e,t)=>e+V(t),0),AVG:(...e)=>e.length?e.reduce((e,t)=>e+V(t),0)/e.length:0,MAX:(...e)=>Math.max(...e.map(V)),MIN:(...e)=>Math.min(...e.map(V)),ABS:e=>Math.abs(V(e)),ROUND:(e,t=0)=>{let n=10**Math.min(100,Math.max(0,Math.trunc(V(t))));return Math.round(V(e)*n)/n},CEIL:e=>Math.ceil(V(e)),FLOOR:e=>Math.floor(V(e))});function V(e){let t=Number(e);if(!Number.isFinite(t))throw Error(`无法将“${String(e)}”转换为有限数值`);return t}function H(e){if(e.length>R)throw Error(`公式长度不能超过 ${R} 个字符`);let t=[],n=0,r=e=>{if(t.push(e),t.length>z)throw Error(`公式不能超过 ${z} 个词元`)};for(;n<e.length;){let t=e[n];if(/\s/.test(t)){n+=1;continue}let i=e.slice(n),a=/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i.exec(i);if(a){r({type:`number`,value:a[0],position:n}),n+=a[0].length;continue}if(t===`[`){let t=e.indexOf(`]`,n+1);if(t===-1)throw Error(`第 ${n+1} 个字符处缺少 ]`);let i=e.slice(n+1,t).trim();if(!i)throw Error(`第 ${n+1} 个字符处的变量名不能为空`);r({type:`variable`,value:i,position:n}),n=t+1;continue}if(t===`"`||t===`'`){let i=t,a=n,o=``,s=!1;for(n+=1;n<e.length;){let t=e[n];if(t===i){s=!0,n+=1;break}if(t===`\\`){if(n+=1,n>=e.length)break;let t=e[n];o+={n:`
|
|
2
|
+
`,r:`\r`,t:` `}[t]??t}else o+=t;n+=1}if(!s)throw Error(`第 ${a+1} 个字符处的字符串未闭合`);r({type:`string`,value:o,position:a});continue}let o=e.slice(n,n+2);if([`>=`,`<=`,`==`,`!=`].includes(o)){r({type:`operator`,value:o,position:n}),n+=2;continue}if(`+-*/%><?:`.includes(t)){r({type:`operator`,value:t,position:n}),n+=1;continue}if(`(),`.includes(t)){r({type:`punctuation`,value:t,position:n}),n+=1;continue}let s=/^[A-Za-z_][A-Za-z0-9_]*/.exec(i);if(s){let e=s[0],t=e.toUpperCase();r({type:[`AND`,`OR`,`NOT`].includes(t)?`operator`:`identifier`,value:[`AND`,`OR`,`NOT`].includes(t)?t:e,position:n}),n+=e.length;continue}throw Error(`第 ${n+1} 个字符“${t}”不受支持`)}return t.push({type:`eof`,value:``,position:n}),t}var U=class{cursor=0;nestingDepth=0;constructor(e){this.tokens=e}parse(){let e=this.parseConditional();return this.expect(`eof`),e}current(){return this.tokens[this.cursor]}advance(){return this.tokens[this.cursor++]}consume(e){return this.current().value===e?(this.advance(),!0):!1}expect(e,t){let n=this.current();if(n.type!==e||t!==void 0&&n.value!==t)throw Error(`第 ${n.position+1} 个字符处应为 ${t??e}`);return this.advance()}parseConditional(){if(++this.nestingDepth>100)throw Error(`公式嵌套不能超过 100 层`);try{let e=this.parseOr();if(!this.consume(`?`))return e;let t=this.parseConditional();return this.expect(`operator`,`:`),{kind:`conditional`,condition:e,truthy:t,falsy:this.parseConditional()}}finally{this.nestingDepth--}}parseBinary(e,t){let n=e();for(;t.includes(this.current().value);)n={kind:`binary`,operator:this.advance().value,left:n,right:e()};return n}parseOr(){return this.parseBinary(()=>this.parseAnd(),[`OR`])}parseAnd(){return this.parseBinary(()=>this.parseEquality(),[`AND`])}parseEquality(){return this.parseBinary(()=>this.parseComparison(),[`==`,`!=`])}parseComparison(){return this.parseBinary(()=>this.parseAdditive(),[`>`,`>=`,`<`,`<=`])}parseAdditive(){return this.parseBinary(()=>this.parseMultiplicative(),[`+`,`-`])}parseMultiplicative(){return this.parseBinary(()=>this.parseUnary(),[`*`,`/`,`%`])}parseUnary(){let e=[];for(;[`-`,`+`,`NOT`].includes(this.current().value)&&!(this.current().value===`NOT`&&this.tokens[this.cursor+1]?.value===`(`);)if(e.push(this.advance().value),e.length>100)throw Error(`一元运算不能超过 100 层`);let t=this.parsePrimary();for(let n of e.reverse())t={kind:`unary`,operator:n,value:t};return t}parsePrimary(){let e=this.current();if(e.type===`number`||e.type===`string`)return this.advance(),{kind:`literal`,value:e.type===`number`?Number(e.value):e.value};if(e.type===`variable`)return this.advance(),{kind:`variable`,name:e.value};if(e.type===`identifier`||e.type===`operator`&&[`AND`,`OR`,`NOT`].includes(e.value)){this.advance();let t=e.value.toUpperCase();if(t===`TRUE`||t===`FALSE`)return{kind:`literal`,value:t===`TRUE`};if(this.consume(`(`))return this.parseFunction(t,e);if(t===`NOT`)return{kind:`unary`,operator:`NOT`,value:this.parseUnary()};if(e.type===`identifier`)return{kind:`identifier`,name:e.value}}if(this.consume(`(`)){let e=this.parseConditional();return this.expect(`punctuation`,`)`),e}throw Error(`第 ${e.position+1} 个字符处缺少有效值`)}parseFunction(e,t){if(!Object.prototype.hasOwnProperty.call(B,e))throw Error(`第 ${t.position+1} 个字符处:未知函数“${t.value}”`);let n=[];if(!this.consume(`)`)){do n.push(this.parseConditional());while(this.consume(`,`));this.expect(`punctuation`,`)`)}let[r,i]=e===`IF`?[3,3]:e===`ROUND`?[1,2]:[`AND`,`OR`,`SUM`,`AVG`,`MAX`,`MIN`].includes(e)?[1,1/0]:[1,1];if(n.length<r||n.length>i)throw Error(`第 ${t.position+1} 个字符处:${e} 需要 ${r===i?r:`${r}–${i===1/0?`多个`:i}`} 个参数`);return{kind:`call`,name:e,args:n}}};function W(e,t){if(!Object.prototype.hasOwnProperty.call(t,e)||t[e]==null)throw Error(`变量“${e}”缺少样例数据`);let n=t[e];if(![`number`,`string`,`boolean`].includes(typeof n)||typeof n==`number`&&!Number.isFinite(n))throw Error(`变量“${e}”的数据类型不受支持`);return n}function te(e,t,n){switch(e){case`==`:return t===n;case`!=`:return t!==n;case`+`:return V(t)+V(n);case`-`:return V(t)-V(n);case`*`:return V(t)*V(n);case`/`:return V(t)/V(n);case`%`:return V(t)%V(n);default:if(typeof t==`boolean`||typeof n==`boolean`)throw Error(`运算符 ${e} 不支持布尔值`);return e===`>`?t>n:e===`>=`?t>=n:e===`<`?t<n:t<=n}}function G(e,t,n,r=0){if(r>200)throw Error(`公式计算层数超过安全限制`);let i=e=>G(e,t,n,r+1);switch(e.kind){case`literal`:return e.value;case`variable`:{let r=t.get(e.name);if(!r)throw Error(`未知变量“${e.name}”`);return W(r,n)}case`identifier`:return W(e.name,n);case`conditional`:return i(e.condition)?i(e.truthy):i(e.falsy);case`unary`:{let t=i(e.value);return e.operator===`NOT`?!t:e.operator===`-`?-V(t):V(t)}case`binary`:{let t=i(e.left);return e.operator===`AND`?!!t&&!!i(e.right):e.operator===`OR`?!!t||!!i(e.right):te(e.operator,t,i(e.right))}case`call`:return e.name===`IF`?i(e.args[0])?i(e.args[1]):i(e.args[2]):e.name===`AND`?e.args.every(e=>!!i(e)):e.name===`OR`?e.args.some(e=>!!i(e)):B[e.name](...e.args.map(i))}}function K(e){let t=H(e),n=new U(t).parse();return{tokens:t,evaluate(e,t){let r=G(n,e,t);if(typeof r==`number`&&!Number.isFinite(r))throw Error(`公式计算结果必须是有限数值`);return r}}}function q(e){return H(e)}function J(e,t){let n=i(()=>new Set(e.value.map(e=>e.name))),r=i(()=>new Set(e.value.map(e=>e.field))),a=i(()=>new Set(t.value.map(e=>e.name.toUpperCase()))),o=null;function s(e){try{let t=q(e),n=[],r=0;return t.forEach((i,a)=>{if(i.type===`eof`)return;i.position>r&&n.push({type:`space`,value:e.slice(r,i.position),start:r,end:i.position});let o=e.slice(i.position,t[a+1]?.position??e.length).trimEnd();r=i.position+o.length;let s=t[a+1],c=i.type===`variable`?`variable`:i.type===`number`?`number`:s?.value===`(`&&(i.type===`identifier`||[`AND`,`OR`,`NOT`].includes(i.value))?`function`:i.type===`operator`?`operator`:i.type===`punctuation`?i.value===`,`?`comma`:`paren`:`text`;n.push({type:c,value:c===`variable`?i.value:o,start:i.position,end:r})}),r<e.length&&n.push({type:`space`,value:e.slice(r),start:r,end:e.length}),n}catch{return e?[{type:`text`,value:e,start:0,end:e.length}]:[]}}function c(e){let t=n.value,i=r.value,c=a.value;if(o?.formula===e&&o.names===t&&o.fields===i&&o.functions===c)return o.analysis;let l={tokens:s(e),validation:{valid:!0,message:e.trim()?`语法校验通过`:`尚未输入公式`},compiled:null};if(e.trim())try{l.compiled=K(e);for(let e of l.tokens){if(e.type===`variable`&&!t.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知变量「${e.value}」`);if(e.type===`function`&&!c.has(e.value.toUpperCase()))throw Error(`第 ${e.start+1} 个字符处:未知函数「${e.value}」`);if(e.type===`text`&&/^[A-Za-z_]\w*$/.test(e.value)&&![`TRUE`,`FALSE`].includes(e.value.toUpperCase())&&!i.has(e.value))throw Error(`第 ${e.start+1} 个字符处:未知字段「${e.value}」`)}}catch(e){let t=e instanceof Error?e.message:String(e),n=/第 (\d+) 个字符/.exec(t);l.validation={valid:!1,message:t,...n?{position:Number(n[1])-1}:{}},l.compiled=null}return o={formula:e,names:t,fields:i,functions:c,analysis:l},l}function l(e){return c(e).validation}function u(e,t){let n=0,r=``;for(let i of s(e).filter(e=>e.type===`variable`))r+=e.slice(n,i.start)+(t.get(i.value)??`__unknown_${i.value}__`),n=i.end;return r+e.slice(n)}return{tokenize:s,analyze:c,validate:l,toEvalExpression:u,variableNames:n,functionNames:a}}function Y(e){let t=i(()=>({variables:e.config?.variables??e.variables??[],functions:e.config?.functions??e.functions??F,sampleData:e.config?.sampleData??e.sampleData??{},disabled:e.config?.disabled??e.disabled??!1,placeholder:e.config?.placeholder??e.placeholder??`例如:[完成值] / [目标值] * 100`,height:e.config?.height??e.height??`auto`,showPreview:e.config?.showPreview??e.showPreview??!0,showKeyboard:e.config?.showKeyboard??e.showKeyboard??!0,showVariablePanel:e.config?.showVariablePanel??e.showVariablePanel??!0,editableSampleData:e.config?.editableSampleData??e.editableSampleData??!0,templates:e.config?.templates??e.templates??[]})),n=e.modelValue??``,r=g(n),a=g({}),o=J(i(()=>t.value.variables),i(()=>t.value.functions)),s=i(()=>o.analyze(r.value)),c=i(()=>{let e=new Map(Object.entries(t.value.sampleData));for(let[t,n]of Object.entries(a.value))n===null?e.delete(t):e.set(t,n);return Object.fromEntries(e)}),l=i(()=>new Map(t.value.variables.map(e=>[e.name,e.field]))),u=i(()=>{let e=s.value.tokens.filter(e=>e.type===`variable`).map(e=>e.value),n=s.value.tokens.filter(e=>e.type===`text`).map(e=>e.value);return t.value.variables.filter(t=>e.includes(t.name)||n.includes(t.field)).map(e=>({...e,value:c.value[e.field]}))}),d=i(()=>{if(!s.value.validation.valid)return{success:!1,result:void 0,error:s.value.validation.message};if(!s.value.compiled)return{success:!0,result:void 0};try{return{success:!0,result:s.value.compiled.evaluate(l.value,c.value)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}});function f(e,n){!t.value.disabled&&t.value.editableSampleData&&(a.value={...a.value,[e]:n})}function p(){r.value=n,a.value={}}return C(()=>e.modelValue,e=>{e!==void 0&&e!==r.value&&(r.value=e)}),C(()=>t.value.sampleData,()=>{a.value={}}),{options:t,formula:r,analysis:s,evalResult:d,usedVariables:u,updateSample:f,reset:p}}const X={class:`formula-input__header`},Z=[`readonly`,`aria-invalid`,`placeholder`],Q={key:0,class:`formula-input__tokens`,"aria-label":`公式结构预览`};var ne=t(d({name:`FormulaInput`,__name:`FormulaInput`,props:{formula:{},tokens:{},validation:{},variableNames:{},disabled:{type:Boolean,default:!1},placeholder:{default:`例如:[完成值] / [目标值] * 100`}},emits:[`update:formula`],setup(e,{expose:t,emit:n}){let i=e,a=n,l=g(),u=g(i.formula),d=`formula-feedback-${b()}`,m=u.value.length,y=m;C(u,e=>a(`update:formula`,e),{flush:`sync`}),C(()=>i.formula,e=>{e!==u.value&&(u.value=e,m=y=e.length)});function S(){l.value&&(m=l.value.selectionStart,y=l.value.selectionEnd)}function w(e,t=m,n=y){if(i.disabled)return;let r=Math.max(0,Math.min(t,u.value.length));u.value=u.value.slice(0,r)+e+u.value.slice(Math.max(r,n)),m=y=r+e.length,f(()=>{l.value?.focus({preventScroll:!0}),l.value?.setSelectionRange(m,y)})}function E(e){w(e)}function D(){if(m!==y){w(``);return}if(m===0)return;let e=i.tokens.find(e=>e.type===`variable`&&e.end===m),t=Array.from(u.value.slice(0,m)).pop()?.length??1;w(``,e?.start??m-t,y)}function O(){w(``,0,u.value.length)}function k(){m=y=u.value.length,l.value?.setSelectionRange(m,y)}function A(){l.value?.focus({preventScroll:!0}),k()}function j(){let e=i.validation.position??0;l.value?.focus({preventScroll:!0}),l.value?.setSelectionRange(e,Math.min(e+1,u.value.length)),S()}return t({insertAtCursor:E,backspace:D,clear:O,focus:A,moveCursorToEnd:k}),(t,n)=>(h(),s(`div`,{class:p([`formula-input`,{"formula-input--disabled":e.disabled,"formula-input--error":!e.validation.valid&&e.formula.trim()}])},[c(`div`,X,[n[1]||=c(`span`,{class:`formula-input__label`},`01 / 编辑公式`,-1),e.formula.trim()&&!e.disabled?(h(),s(`button`,{key:0,type:`button`,class:`formula-input__clear`,onClick:O},`清空公式`)):o(`v-if`,!0)]),T(c(`textarea`,{ref_key:`editorRef`,ref:l,"onUpdate:modelValue":n[0]||=e=>u.value=e,class:`formula-input__editor`,readonly:e.disabled,"aria-label":`公式输入`,"aria-invalid":!e.validation.valid&&!!e.formula.trim(),"aria-describedby":d,placeholder:e.placeholder,spellcheck:`false`,onSelect:S,onClick:S,onKeyup:S,onBlur:S},null,40,Z),[[x,u.value]]),e.tokens.length?(h(),s(`div`,Q,[n[2]||=c(`span`,{class:`formula-input__tokens-label`},`结构预览`,-1),(h(!0),s(r,null,_(e.tokens,(e,t)=>(h(),s(`span`,{key:t,class:p(`formula-token formula-token--${e.type}`)},v(e.type===`variable`?`[${e.value}]`:e.value),3))),128))])):o(`v-if`,!0),c(`div`,{id:d,class:`formula-input__validation`,role:`status`},[c(`span`,{class:p(e.formula.trim()?e.validation.valid?`formula-input__validation-success`:`formula-input__validation-error`:`formula-input__validation-hint`)},v(e.formula.trim()?e.validation.valid?`语法校验通过,可在右侧调整数据试算。`:e.validation.message:`点击左侧变量开始,也可以直接输入 [变量名]。`),3),e.validation.position===void 0?o(`v-if`,!0):(h(),s(`button`,{key:0,type:`button`,class:`formula-input__locate`,onClick:j},`定位错误`))])],2))}}),[[`__scopeId`,`data-v-5b2f30eb`]]);const re={class:`variable-panel`},ie={class:`variable-panel__tabs`},ae=[`aria-pressed`],oe=[`aria-pressed`],se={class:`variable-panel__search`},ce=[`aria-expanded`,`onClick`],le={class:`variable-panel__items`},ue=[`disabled`,`onClick`],de={key:0},fe=[`disabled`,`onClick`],pe={class:`variable-panel__func-name`},me={class:`variable-panel__func-desc`},he={class:`variable-panel__func-sig`};var ge=t(d({__name:`VariablePanel`,props:{variables:{},functions:{},disabled:{type:Boolean}},emits:[`select-variable`,`select-function`],setup(e){let t=e,d=g(`variable`),f=g(``),m=g(new Set),b=i(()=>{let e=f.value.toLowerCase(),n=e?t.variables.filter(t=>t.name.toLowerCase().includes(e)||t.field.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)):t.variables,r=new Map;for(let e of n){let t=e.group??`其他`,n=r.get(t);n?n.push(e):r.set(t,[e])}return Array.from(r,([e,t])=>({name:e,items:t}))});C(b,e=>{for(let t of e)m.value.add(t.name)},{immediate:!0});function x(e){m.value.has(e)?m.value.delete(e):m.value.add(e)}let E=i(()=>{let e=f.value.toLowerCase();return e?t.functions.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)):t.functions});function k(e){switch(e){case`number`:return`mdi:numeric`;case`text`:return`mdi:format-text`;case`boolean`:return`mdi:toggle-switch-outline`;default:return`mdi:variable`}}return(t,i)=>(h(),s(`div`,re,[o(` 切换 Tab:变量 / 函数 `),c(`div`,ie,[c(`button`,{type:`button`,class:p([`variable-panel__tab`,{"variable-panel__tab--active":d.value===`variable`}]),"aria-pressed":d.value===`variable`,onClick:i[0]||=e=>d.value=`variable`},` 可用变量 `,10,ae),c(`button`,{type:`button`,class:p([`variable-panel__tab`,{"variable-panel__tab--active":d.value===`function`}]),"aria-pressed":d.value===`function`,onClick:i[1]||=e=>d.value=`function`},` 常用函数 `,10,oe)]),o(` 搜索框 `),c(`div`,se,[u(y(O),{value:f.value,"onUpdate:value":i[2]||=e=>f.value=e,size:`small`,placeholder:`搜索变量或函数`,"input-props":{"aria-label":`搜索变量或函数`},clearable:``},{prefix:w(()=>[u(n,{name:`mdi:magnify`,size:16})]),_:1},8,[`value`])]),o(` 变量列表 `),d.value===`variable`?(h(),a(y(A),{key:0,class:`variable-panel__list`},{default:w(()=>[b.value.length>0?(h(!0),s(r,{key:0},_(b.value,i=>(h(),s(`div`,{key:i.name,class:`variable-panel__group`},[c(`button`,{type:`button`,class:`variable-panel__group-title`,"aria-expanded":m.value.has(i.name),onClick:e=>x(i.name)},[u(n,{name:m.value.has(i.name)?`mdi:chevron-down`:`mdi:chevron-right`,size:16},null,8,[`name`]),l(` `+v(i.name),1)],8,ce),T(c(`div`,le,[(h(!0),s(r,null,_(i.items,r=>(h(),s(`button`,{key:r.field,type:`button`,class:`variable-panel__item`,disabled:e.disabled,onClick:e=>t.$emit(`select-variable`,r)},[u(n,{name:k(r.type),size:15,class:`variable-panel__item-icon`},null,8,[`name`]),c(`span`,null,[l(v(r.name),1),r.description?(h(),s(`small`,de,v(r.description),1)):o(`v-if`,!0)])],8,ue))),128))],512),[[S,m.value.has(i.name)]])]))),128)):(h(),a(y(D),{key:1,size:`small`,description:`无匹配变量`}))]),_:1})):(h(),s(r,{key:1},[o(` 函数列表 `),u(y(A),{class:`variable-panel__list`},{default:w(()=>[E.value.length>0?(h(!0),s(r,{key:0},_(E.value,n=>(h(),s(`button`,{key:n.name,type:`button`,class:`variable-panel__func`,disabled:e.disabled,onClick:e=>t.$emit(`select-function`,n)},[c(`div`,pe,[i[3]||=c(`span`,{class:`variable-panel__func-badge`},`ƒ`,-1),l(` `+v(n.name),1)]),c(`div`,me,v(n.description),1),c(`div`,he,v(n.signature),1)],8,fe))),128)):(h(),a(y(D),{key:1,size:`small`,description:`无匹配函数`}))]),_:1})],2112))]))}}),[[`__scopeId`,`data-v-2d73fec7`]]);const _e={class:`virtual-keyboard`,role:`group`,"aria-label":`公式键盘`},ve={key:0,class:`virtual-keyboard__functions`},ye={class:`virtual-keyboard__function-grid`},be=[`disabled`,`title`,`aria-label`,`onClick`],xe={class:`virtual-keyboard__body`},Se={class:`virtual-keyboard__operators`},Ce={class:`virtual-keyboard__label`},we=[`disabled`,`aria-label`,`onClick`],Te={class:`virtual-keyboard__numbers`},Ee={class:`virtual-keyboard__keys virtual-keyboard__keys--numbers`},De=[`disabled`,`aria-label`,`onClick`],Oe={class:`virtual-keyboard__footer`},ke={class:`virtual-keyboard__actions`},Ae=[`disabled`,`aria-label`,`onClick`];var je=t(d({name:`VirtualKeyboard`,__name:`VirtualKeyboard`,props:{disabled:{type:Boolean,default:!1},functions:{default:()=>[]}},emits:[`key-press`,`insert-function`,`action`],setup(e){let t=N.filter(e=>e.type===`number`),i=P.map(e=>({...e,label:e.value===`BACKSPACE`?`退格`:e.label,icon:e.value===`BACKSPACE`?`M9 4h12v16H9L2 12zM9.9 6 4.6 12l5.3 6H19V6zM11 8l6 6-1.4 1.4-6-6zM15.6 8 17 9.4l-6 6-1.4-1.4z`:`M5 5h14v2H5zM9 2h6v2H9zM7 8h2v11h6V8h2v13H7zM10 8h1v9h-1zM13 8h1v9h-1z`})),a=[{name:`arithmetic`,label:`四则与取余`,keys:[...N,...M].filter(e=>e.type===`operator`)},{name:`compare`,label:`比较判断`,keys:M.filter(e=>e.type===`compare`)},{name:`logic`,label:`括号与条件`,keys:M.filter(e=>e.type===`paren`||e.type===`logic`)}];return(d,f)=>(h(),s(`div`,_e,[e.functions.length?(h(),s(`div`,ve,[f[1]||=c(`span`,{class:`virtual-keyboard__label`},`函数快捷输入`,-1),c(`div`,ye,[(h(!0),s(r,null,_(e.functions,t=>(h(),s(`button`,{key:t.name,type:`button`,class:`virtual-keyboard__function`,disabled:e.disabled,title:`${t.signature} · ${t.description}`,"aria-label":`插入函数 ${t.name}`,onClick:e=>d.$emit(`insert-function`,t)},[l(v(t.name),1),f[0]||=c(`span`,null,`( )`,-1)],8,be))),128))])])):o(`v-if`,!0),c(`div`,xe,[c(`div`,Se,[(h(),s(r,null,_(a,t=>c(`section`,{key:t.label,class:`virtual-keyboard__group`},[c(`h3`,Ce,v(t.label),1),c(`div`,{class:p([`virtual-keyboard__keys`,`virtual-keyboard__keys--${t.name}`])},[(h(!0),s(r,null,_(t.keys,t=>(h(),s(`button`,{key:t.value,type:`button`,class:p([`virtual-keyboard__key`,t.color&&`virtual-keyboard__key--${t.color}`]),disabled:e.disabled,"aria-label":`插入 ${t.label}`,onClick:e=>d.$emit(`key-press`,t)},v(t.label),11,we))),128))],2)])),64))]),c(`section`,Te,[f[2]||=c(`h3`,{class:`virtual-keyboard__label`},`数字输入`,-1),c(`div`,Ee,[(h(!0),s(r,null,_(y(t),t=>(h(),s(`button`,{key:t.value,type:`button`,class:p([`virtual-keyboard__key`,{"virtual-keyboard__key--zero":t.value===`0`}]),disabled:e.disabled,"aria-label":`输入 ${t.label}`,onClick:e=>d.$emit(`key-press`,t)},v(t.label),11,De))),128))])])]),c(`footer`,Oe,[f[3]||=c(`span`,null,`按键会插入到光标处,选中文字可直接替换。`,-1),c(`div`,ke,[(h(!0),s(r,null,_(y(i),t=>(h(),s(`button`,{key:t.value,type:`button`,class:p([`virtual-keyboard__action`,{"virtual-keyboard__action--clear":t.value===`CLEAR`}]),disabled:e.disabled,"aria-label":t.label,onClick:e=>d.$emit(`action`,t.value)},[u(n,{type:`svg`,"svg-path":t.icon,size:16},null,8,[`svg-path`]),l(v(t.label),1)],10,Ae))),128))])])]))}}),[[`__scopeId`,`data-v-05f0982d`]]);const Me={class:`formula-preview`,"aria-label":`公式试算`},Ne={class:`formula-preview__result-label`},Pe={key:0,class:`formula-preview__result-value`},Fe={key:1,class:`formula-preview__result-empty`},Ie={class:`formula-preview__vars`},Le={class:`formula-preview__vars-title`},Re={class:`formula-preview__var-heading`},ze=[`for`],Be={key:3,class:`formula-preview__var-value`},Ve={key:4},$={key:0,class:`formula-preview__empty`};var He=t(d({name:`FormulaPreview`,__name:`FormulaPreview`,props:{formula:{},evalResult:{},usedVariables:{},editable:{type:Boolean}},emits:[`update-value`],setup(e,{emit:t}){let n=t,i=`formula-sample-${b()}`;function u(e){return typeof e==`number`?new Intl.NumberFormat(void 0,{maximumFractionDigits:6}).format(e):typeof e==`boolean`?e?`真 · true`:`假 · false`:String(e)}return(t,d)=>(h(),s(`aside`,Me,[d[1]||=c(`header`,null,[c(`span`,{class:`formula-preview__step`},`02`),c(`div`,null,[c(`h3`,null,`验证计算结果`),c(`p`,null,`调整试算值,观察规则是否符合预期。`)])],-1),c(`div`,{class:p([`formula-preview__result`,{"formula-preview__result--error":!!e.evalResult.error}]),role:`status`,"aria-live":`polite`},[c(`span`,Ne,v(e.evalResult.error?`暂时无法计算`:`试算结果`),1),e.evalResult.success&&e.evalResult.result!==void 0?(h(),s(`output`,Pe,v(u(e.evalResult.result)),1)):(h(),s(`span`,Fe,v(e.formula.trim()?e.evalResult.error||`等待数据`:`输入公式后展示结果`),1))],2),c(`div`,Ie,[c(`div`,Le,[d[0]||=l(`本次使用的试算值 `,-1),c(`span`,null,v(e.usedVariables.length)+` 项`,1)]),(h(!0),s(r,null,_(e.usedVariables,t=>(h(),s(`div`,{key:t.field,class:`formula-preview__var-row`},[c(`div`,Re,[c(`label`,{for:`${i}-${t.field}`},v(t.name),9,ze),c(`code`,null,v(t.field),1)]),e.editable&&t.type===`number`?(h(),a(y(k),{key:0,value:typeof t.value==`number`?t.value:null,"input-props":{id:`${i}-${t.field}`,"aria-label":`试算值:${t.name}`},placeholder:`请输入数值`,"onUpdate:value":e=>n(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):e.editable&&t.type===`boolean`?(h(),a(y(j),{key:1,value:t.value===!0,"aria-label":`试算值:${t.name}`,"onUpdate:value":e=>n(`update-value`,t.field,e)},null,8,[`value`,`aria-label`,`onUpdate:value`])):e.editable&&t.type===`text`?(h(),a(y(O),{key:2,value:typeof t.value==`string`?t.value:``,"input-props":{id:`${i}-${t.field}`,"aria-label":`试算值:${t.name}`},"onUpdate:value":e=>n(`update-value`,t.field,e)},null,8,[`value`,`input-props`,`onUpdate:value`])):(h(),s(`span`,Be,v(t.value??`未提供`),1)),t.description?(h(),s(`p`,Ve,v(t.description),1)):o(`v-if`,!0)]))),128)),e.usedVariables.length?o(`v-if`,!0):(h(),s(`p`,$,v(e.formula.trim()?`当前公式没有引用变量。`:`引用变量后,对应数据会出现在这里。`),1))]),d[2]||=c(`p`,{class:`formula-preview__note`},`试算值仅用于本次验证,修改不会写入业务数据。`,-1)]))}}),[[`__scopeId`,`data-v-b2656900`]]);const Ue={class:`c-formula__title-row`},We={class:`c-formula__actions`},Ge={key:0,class:`c-formula__templates`,"aria-label":`公式模板`},Ke=[`disabled`,`aria-pressed`,`onClick`],qe={key:0,class:`c-formula__sidebar`},Je={class:`c-formula__main`},Ye={key:0,class:`c-formula__keyboard`,open:``},Xe={class:`c-formula__guide`};var Ze=t(d({name:`C_FormulaEditor`,__name:`index`,props:{modelValue:{},config:{},variables:{},functions:{},sampleData:{},disabled:{type:Boolean,default:!1},placeholder:{},height:{},showPreview:{type:Boolean,default:!0},showKeyboard:{type:Boolean,default:!0},showVariablePanel:{type:Boolean,default:!0},editableSampleData:{type:Boolean,default:!0},templates:{}},emits:[`update:modelValue`,`change`,`validation-change`],setup(t,{expose:i,emit:d}){let f=e(),b=t,x=d,{options:S,formula:T,analysis:D,evalResult:O,usedVariables:k,updateSample:A,reset:j}=Y(b),M=g();C(T,e=>{x(`update:modelValue`,e),x(`change`,e)}),C(()=>D.value.validation,e=>x(`validation-change`,e),{immediate:!0});function N(e){S.value.disabled||(T.value=e)}function P(e){S.value.disabled||M.value?.insertAtCursor(e)}function F(e){S.value.disabled||(e===`BACKSPACE`&&M.value?.backspace(),e===`CLEAR`&&M.value?.clear())}return i({getValue:()=>T.value,setValue:e=>{T.value=e},reset:j,validate:()=>D.value.validation,insertAtCursor:P,focus:()=>M.value?.focus()}),(e,t)=>(h(),s(`section`,{class:`c-formula`,style:m({...y(f),height:typeof y(S).height==`number`?`${y(S).height}px`:y(S).height}),"aria-label":`公式编辑器`},[c(`header`,Ue,[t[5]||=c(`div`,null,[c(`span`,{class:`c-formula__eyebrow`},`FORMULA WORKBENCH`),c(`h2`,null,`规则与试算`),c(`p`,null,`插入变量、编辑公式,再用试算值验证结果。`)],-1),c(`div`,We,[u(y(ee),{type:y(T).trim()?y(D).validation.valid?`success`:`error`:`default`,size:`small`},{default:w(()=>[l(v(y(T).trim()?y(D).validation.valid?`语法有效`:`需要修正`:`等待输入`),1)]),_:1},8,[`type`]),u(y(E),{size:`small`,disabled:y(S).disabled,onClick:y(j)},{default:w(()=>[...t[4]||=[l(`重置`,-1)]]),_:1},8,[`disabled`,`onClick`])])]),y(S).templates.length?(h(),s(`div`,Ge,[(h(!0),s(r,null,_(y(S).templates,e=>(h(),s(`button`,{key:e.value,type:`button`,disabled:y(S).disabled,"aria-pressed":y(T)===e.value,onClick:t=>T.value=e.value},[c(`strong`,null,v(e.label),1),c(`span`,null,v(e.description),1)],8,Ke))),128))])):o(`v-if`,!0),c(`div`,{class:p([`c-formula__body`,{"c-formula__body--no-sidebar":!y(S).showVariablePanel,"c-formula__body--no-preview":!y(S).showPreview}])},[y(S).showVariablePanel?(h(),s(`aside`,qe,[u(ge,{variables:y(S).variables,functions:y(S).functions,disabled:y(S).disabled,onSelectVariable:t[0]||=e=>P(`[${e.name}]`),onSelectFunction:t[1]||=e=>P(`${e.name}(`)},null,8,[`variables`,`functions`,`disabled`])])):o(`v-if`,!0),c(`div`,Je,[u(ne,{ref_key:`formulaInputRef`,ref:M,formula:y(T),tokens:y(D).tokens,validation:y(D).validation,disabled:y(S).disabled,placeholder:y(S).placeholder,"onUpdate:formula":N},null,8,[`formula`,`tokens`,`validation`,`disabled`,`placeholder`]),y(S).showKeyboard?(h(),s(`details`,Ye,[c(`summary`,null,[u(n,{type:`svg`,"svg-path":`M4 5h16v14H4zM6 7v10h12V7zM7 8h2v2H7zM10 8h2v2h-2zM13 8h2v2h-2zM16 8h1v2h-1zM7 11h2v2H7zM10 11h2v2h-2zM13 11h2v2h-2zM16 11h1v2h-1zM8 14h8v2H8z`,size:18}),t[6]||=c(`span`,{class:`c-formula__keyboard-title`},[l(`公式键盘`),c(`small`,null,`数字、运算与函数 · 点击插入`)],-1),u(n,{class:`c-formula__keyboard-chevron`,type:`svg`,"svg-path":`M6 8l6 6 6-6 1.4 1.4L12 16.8 4.6 9.4z`,size:18})]),u(je,{disabled:y(S).disabled,functions:y(S).functions,onKeyPress:t[2]||=e=>P(e.value),onInsertFunction:t[3]||=e=>P(`${e.name}(`),onAction:F},null,8,[`disabled`,`functions`])])):o(`v-if`,!0),c(`div`,Xe,[u(n,{name:`mdi:information-outline`,size:16}),t[7]||=c(`p`,null,[l(`变量使用 `),c(`code`,null,`[变量名]`),l(`,支持括号、比较和条件函数。右侧结果是当前数据的本地试算。`)],-1)])]),y(S).showPreview?(h(),a(He,{key:1,formula:y(T),"eval-result":y(O),"used-variables":y(k),editable:y(S).editableSampleData&&!y(S).disabled,onUpdateValue:y(A)},null,8,[`formula`,`eval-result`,`used-variables`,`editable`,`onUpdateValue`])):o(`v-if`,!0)],2)],4))}}),[[`__scopeId`,`data-v-78a3bd4f`]]);function Qe(e){let t=i(()=>{let t=new Map;for(let n of e.value)t.set(n.name,n.field);return t}),n,r;function a(e,i){if(!e.trim())return{success:!0,result:void 0};try{return(!r||n!==e)&&(r=K(e),n=e),{success:!0,result:r.evaluate(t.value,i)}}catch(e){return{success:!1,result:void 0,error:e instanceof Error?e.message:String(e)}}}function o(e){try{return[...new Set(q(e).filter(e=>e.type===`variable`).map(e=>e.value))]}catch{return[]}}return{evaluate:a,extractVariableNames:o,variableMap:t}}export{F as a,M as c,P as i,L as l,Ze as n,N as o,J as r,I as s,Qe as t};
|
package/dist/useFullscreen.d.cts
CHANGED
|
@@ -96,12 +96,12 @@ interface ExcelLoadResult {
|
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/components/C_FilePreview/index.vue.d.ts
|
|
98
98
|
declare const __VLS_export: vue.DefineComponent<FilePreviewProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
99
|
-
download: (file: string | File) => any;
|
|
100
99
|
preview: (file: string | File) => any;
|
|
100
|
+
download: (file: string | File) => any;
|
|
101
101
|
"update:show": (show: boolean) => any;
|
|
102
102
|
}, string, vue.PublicProps, Readonly<FilePreviewProps> & Readonly<{
|
|
103
|
-
onDownload?: ((file: string | File) => any) | undefined;
|
|
104
103
|
onPreview?: ((file: string | File) => any) | undefined;
|
|
104
|
+
onDownload?: ((file: string | File) => any) | undefined;
|
|
105
105
|
"onUpdate:show"?: ((show: boolean) => any) | undefined;
|
|
106
106
|
}>, {
|
|
107
107
|
show: boolean;
|
package/dist/useFullscreen.d.ts
CHANGED
|
@@ -96,12 +96,12 @@ interface ExcelLoadResult {
|
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/components/C_FilePreview/index.vue.d.ts
|
|
98
98
|
declare const __VLS_export: vue.DefineComponent<FilePreviewProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
99
|
-
download: (file: string | File) => any;
|
|
100
99
|
preview: (file: string | File) => any;
|
|
100
|
+
download: (file: string | File) => any;
|
|
101
101
|
"update:show": (show: boolean) => any;
|
|
102
102
|
}, string, vue.PublicProps, Readonly<FilePreviewProps> & Readonly<{
|
|
103
|
-
onDownload?: ((file: string | File) => any) | undefined;
|
|
104
103
|
onPreview?: ((file: string | File) => any) | undefined;
|
|
104
|
+
onDownload?: ((file: string | File) => any) | undefined;
|
|
105
105
|
"onUpdate:show"?: ((show: boolean) => any) | undefined;
|
|
106
106
|
}>, {
|
|
107
107
|
show: boolean;
|
|
@@ -60,8 +60,8 @@ declare const __VLS_export: vue.DefineComponent<Props, {
|
|
|
60
60
|
openDialog: () => Promise<void>;
|
|
61
61
|
closeDialog: () => void;
|
|
62
62
|
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
63
|
-
placeholder: string;
|
|
64
63
|
emptyText: string;
|
|
64
|
+
placeholder: string;
|
|
65
65
|
resultGroupTitle: string;
|
|
66
66
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
67
67
|
declare const _default: typeof __VLS_export;
|
|
@@ -60,8 +60,8 @@ declare const __VLS_export: vue.DefineComponent<Props, {
|
|
|
60
60
|
openDialog: () => Promise<void>;
|
|
61
61
|
closeDialog: () => void;
|
|
62
62
|
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
63
|
-
placeholder: string;
|
|
64
63
|
emptyText: string;
|
|
64
|
+
placeholder: string;
|
|
65
65
|
resultGroupTitle: string;
|
|
66
66
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
67
67
|
declare const _default: typeof __VLS_export;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./chunk.cjs`),t=require(`./feedback.cjs`),n=require(`./useComponentTheme.cjs`);let r=require(`vue`),i=require(`@antv/x6`),a=require(`html2canvas`);a=e.n(a);function o(e,t){let n=t&&getComputedStyle(t),r=t=>String(n?.getPropertyValue(`--c-${t}`).trim()||e[`--c-${t}`]||e[`--c-theme-${t}`]);return{background:r(`bg-body`),gridPrimary:r(`border`),gridSecondary:r(`bg-muted`)}}function s(e){return{background:{color:e.background},grid:{visible:!0,type:`doubleMesh`,args:[{color:e.gridPrimary,thickness:1},{color:e.gridSecondary,thickness:1,factor:4}]},mousewheel:{enabled:!0,zoomAtMousePosition:!0,modifiers:`ctrl`,minScale:.5,maxScale:2},selecting:{enabled:!0,rubberband:!0,movable:!0,showNodeSelectionBox:!0},resizing:!0,rotating:!0,snapline:!0,keyboard:!0,clipboard:!0}}function c(e){return e?{width:e.clientWidth||e.offsetWidth||800,height:e.clientHeight||e.offsetHeight||600}:{width:0,height:0}}function l(e,t){let a=n.n(()=>t===void 0?void 0:t.value?`dark`:`light`),l=(0,r.computed)(()=>o(a.value,e.value)),u=(0,r.computed)(()=>{let{background:e,grid:t}=s(l.value);return{background:e,grid:t}}),d=0,f,p=!1,m=(0,r.shallowRef)(null),h=(0,r.ref)(!1),g=t=>{if(!p){h.value=!0;try{if(!e.value)return;m.value&&=(m.value.dispose(),null);let{width:n,height:r}=c(e.value),a=s(l.value);m.value=new i.Graph({container:e.value,width:n,height:r,...a,...t,background:t.background??a.background,grid:t.grid??a.grid})}catch{}finally{h.value=!1}}},_=async(e={})=>{let t=++d;await(0,r.nextTick)(),t===d&&g(e)};function v(){if(!m.value)return;let e=l.value;m.value.drawBackground?.({color:e.background}),m.value.drawGrid?.({type:`doubleMesh`,args:[{color:e.gridPrimary,thickness:1},{color:e.gridSecondary,thickness:1,factor:4}]})}(0,r.watch)(l,v,{flush:`post`});function y(){if(d++,clearTimeout(f),f=void 0,m.value){let e=m.value;m.value=null,e.dispose()}}function b(){m.value?.centerContent()}function x(){m.value?.zoomToFit({padding:20,maxScale:1})}function S(e=200,t=20){clearTimeout(f);let n=m.value;n&&(f=setTimeout(()=>{!p&&m.value===n&&n.zoomToFit({padding:t,maxScale:1})},e))}function C(e){m.value?.zoom(e)}function w(){if(m.value&&e.value){let{width:t,height:n}=c(e.value);m.value.resize(t,n)}}return(0,r.onUnmounted)(()=>{p=!0,y()}),{graph:m,loading:h,initGraph:_,destroyGraph:y,centerContent:b,zoomToFit:x,scheduleZoomToFit:S,zoom:C,resizeGraph:w,updateTheme:v,themeOptions:u}}function u(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.style.display=`none`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function d(e,t=`diagram.json`){let n=JSON.stringify(e,null,2);u(new Blob([n],{type:`application/json`}),t)}async function f(e,t=`diagram.png`,n={}){let{backgroundColor:r=`#ffffff`,scale:i=2}=n,{container:o}=e;u(await m(await(0,a.default)(o,{backgroundColor:r,scale:i,useCORS:!0,logging:!1}),`image/png`),t)}function p(e,t=`diagram.svg`){let n=e.container.querySelector(`svg`);if(!n)throw Error(`SVG导出失败: 未找到图表 SVG 元素`);let r=n.cloneNode(!0),i=new Set([...n.outerHTML.matchAll(/var\((--[\w-]+)/g)].map(e=>e[1])),a=getComputedStyle(n);for(let e of i){let t=a.getPropertyValue(e).trim();t&&r.style.setProperty(e,t)}r.getAttribute(`xmlns`)||r.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),r.getAttribute(`xmlns:xlink`)||r.setAttribute(`xmlns:xlink`,`http://www.w3.org/1999/xlink`);let o=new XMLSerializer().serializeToString(r);u(new Blob([o],{type:`image/svg+xml;charset=utf-8`}),t)}function m(e,t,n=1){return new Promise((r,i)=>{e.toBlob(e=>{e?r(e):i(Error(`Canvas 转 Blob 失败`))},t,n)})}const h=[{label:`导出PNG`,key:`png`},{label:`导出SVG`,key:`svg`},{label:`导出JSON`,key:`json`}];function g(e,n=`diagram`){let r=t.t();return{exportOptions:h,handleExport:async(t,i)=>{if(e.value)try{switch(t){case`png`:await f(e.value,`${n}.png`);break;case`svg`:p(e.value,`${n}.svg`);break;case`json`:i&&d(i(),`${n}.json`);break}}catch(e){r.error(`导出${t.toUpperCase()}失败,请重试`,e)}}}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return g}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./feedback.js";import{n as t}from"./useComponentTheme.js";import{computed as n,nextTick as r,onUnmounted as i,ref as a,shallowRef as o,watch as s}from"vue";import{Graph as c}from"@antv/x6";import l from"html2canvas";function u(e,t){let n=t&&getComputedStyle(t),r=t=>String(n?.getPropertyValue(`--c-${t}`).trim()||e[`--c-${t}`]||e[`--c-theme-${t}`]);return{background:r(`bg-body`),gridPrimary:r(`border`),gridSecondary:r(`bg-muted`)}}function d(e){return{background:{color:e.background},grid:{visible:!0,type:`doubleMesh`,args:[{color:e.gridPrimary,thickness:1},{color:e.gridSecondary,thickness:1,factor:4}]},mousewheel:{enabled:!0,zoomAtMousePosition:!0,modifiers:`ctrl`,minScale:.5,maxScale:2},selecting:{enabled:!0,rubberband:!0,movable:!0,showNodeSelectionBox:!0},resizing:!0,rotating:!0,snapline:!0,keyboard:!0,clipboard:!0}}function f(e){return e?{width:e.clientWidth||e.offsetWidth||800,height:e.clientHeight||e.offsetHeight||600}:{width:0,height:0}}function p(e,l){let p=t(()=>l===void 0?void 0:l.value?`dark`:`light`),m=n(()=>u(p.value,e.value)),h=n(()=>{let{background:e,grid:t}=d(m.value);return{background:e,grid:t}}),g=0,_,v=!1,y=o(null),b=a(!1),x=t=>{if(!v){b.value=!0;try{if(!e.value)return;y.value&&=(y.value.dispose(),null);let{width:n,height:r}=f(e.value),i=d(m.value);y.value=new c({container:e.value,width:n,height:r,...i,...t,background:t.background??i.background,grid:t.grid??i.grid})}catch{}finally{b.value=!1}}},S=async(e={})=>{let t=++g;await r(),t===g&&x(e)};function C(){if(!y.value)return;let e=m.value;y.value.drawBackground?.({color:e.background}),y.value.drawGrid?.({type:`doubleMesh`,args:[{color:e.gridPrimary,thickness:1},{color:e.gridSecondary,thickness:1,factor:4}]})}s(m,C,{flush:`post`});function w(){if(g++,clearTimeout(_),_=void 0,y.value){let e=y.value;y.value=null,e.dispose()}}function T(){y.value?.centerContent()}function E(){y.value?.zoomToFit({padding:20,maxScale:1})}function D(e=200,t=20){clearTimeout(_);let n=y.value;n&&(_=setTimeout(()=>{!v&&y.value===n&&n.zoomToFit({padding:t,maxScale:1})},e))}function O(e){y.value?.zoom(e)}function k(){if(y.value&&e.value){let{width:t,height:n}=f(e.value);y.value.resize(t,n)}}return i(()=>{v=!0,w()}),{graph:y,loading:b,initGraph:S,destroyGraph:w,centerContent:T,zoomToFit:E,scheduleZoomToFit:D,zoom:O,resizeGraph:k,updateTheme:C,themeOptions:h}}function m(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.style.display=`none`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function h(e,t=`diagram.json`){let n=JSON.stringify(e,null,2);m(new Blob([n],{type:`application/json`}),t)}async function g(e,t=`diagram.png`,n={}){let{backgroundColor:r=`#ffffff`,scale:i=2}=n,{container:a}=e;m(await v(await l(a,{backgroundColor:r,scale:i,useCORS:!0,logging:!1}),`image/png`),t)}function _(e,t=`diagram.svg`){let n=e.container.querySelector(`svg`);if(!n)throw Error(`SVG导出失败: 未找到图表 SVG 元素`);let r=n.cloneNode(!0),i=new Set([...n.outerHTML.matchAll(/var\((--[\w-]+)/g)].map(e=>e[1])),a=getComputedStyle(n);for(let e of i){let t=a.getPropertyValue(e).trim();t&&r.style.setProperty(e,t)}r.getAttribute(`xmlns`)||r.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),r.getAttribute(`xmlns:xlink`)||r.setAttribute(`xmlns:xlink`,`http://www.w3.org/1999/xlink`);let o=new XMLSerializer().serializeToString(r);m(new Blob([o],{type:`image/svg+xml;charset=utf-8`}),t)}function v(e,t,n=1){return new Promise((r,i)=>{e.toBlob(e=>{e?r(e):i(Error(`Canvas 转 Blob 失败`))},t,n)})}const y=[{label:`导出PNG`,key:`png`},{label:`导出SVG`,key:`svg`},{label:`导出JSON`,key:`json`}];function b(t,n=`diagram`){let r=e();return{exportOptions:y,handleExport:async(e,i)=>{if(t.value)try{switch(e){case`png`:await g(t.value,`${n}.png`);break;case`svg`:_(t.value,`${n}.svg`);break;case`json`:i&&h(i(),`${n}.json`);break}}catch(t){r.error(`导出${e.toUpperCase()}失败,请重试`,t)}}}}export{p as n,b as t};
|
|
@@ -77,26 +77,26 @@ type __VLS_Slots = {} & {
|
|
|
77
77
|
footer?: (props: typeof __VLS_5) => any;
|
|
78
78
|
};
|
|
79
79
|
declare const __VLS_base: vue.DefineComponent<WaterFallProps, WaterFallExpose, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
80
|
-
"item-click": (item: WaterFallItem, index: number) => any;
|
|
81
80
|
"load-more": () => any;
|
|
81
|
+
"item-click": (item: WaterFallItem, index: number) => any;
|
|
82
82
|
"image-loaded": (item: WaterFallItem) => any;
|
|
83
83
|
"image-error": (item: WaterFallItem) => any;
|
|
84
84
|
}, string, vue.PublicProps, Readonly<WaterFallProps> & Readonly<{
|
|
85
|
-
"onItem-click"?: ((item: WaterFallItem, index: number) => any) | undefined;
|
|
86
85
|
"onLoad-more"?: (() => any) | undefined;
|
|
86
|
+
"onItem-click"?: ((item: WaterFallItem, index: number) => any) | undefined;
|
|
87
87
|
"onImage-loaded"?: ((item: WaterFallItem) => any) | undefined;
|
|
88
88
|
"onImage-error"?: ((item: WaterFallItem) => any) | undefined;
|
|
89
89
|
}>, {
|
|
90
|
+
loading: boolean;
|
|
91
|
+
gap: number;
|
|
92
|
+
infinite: boolean;
|
|
90
93
|
virtualScroll: boolean;
|
|
91
94
|
columns: number;
|
|
92
|
-
gap: number;
|
|
93
95
|
lazy: boolean;
|
|
94
|
-
infinite: boolean;
|
|
95
96
|
skeleton: boolean;
|
|
96
97
|
skeletonCount: number;
|
|
97
98
|
animationDuration: number;
|
|
98
99
|
breakpoints: WaterFallBreakpoint[];
|
|
99
|
-
loading: boolean;
|
|
100
100
|
noMore: boolean;
|
|
101
101
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
102
102
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -77,26 +77,26 @@ type __VLS_Slots = {} & {
|
|
|
77
77
|
footer?: (props: typeof __VLS_5) => any;
|
|
78
78
|
};
|
|
79
79
|
declare const __VLS_base: vue.DefineComponent<WaterFallProps, WaterFallExpose, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
80
|
-
"item-click": (item: WaterFallItem, index: number) => any;
|
|
81
80
|
"load-more": () => any;
|
|
81
|
+
"item-click": (item: WaterFallItem, index: number) => any;
|
|
82
82
|
"image-loaded": (item: WaterFallItem) => any;
|
|
83
83
|
"image-error": (item: WaterFallItem) => any;
|
|
84
84
|
}, string, vue.PublicProps, Readonly<WaterFallProps> & Readonly<{
|
|
85
|
-
"onItem-click"?: ((item: WaterFallItem, index: number) => any) | undefined;
|
|
86
85
|
"onLoad-more"?: (() => any) | undefined;
|
|
86
|
+
"onItem-click"?: ((item: WaterFallItem, index: number) => any) | undefined;
|
|
87
87
|
"onImage-loaded"?: ((item: WaterFallItem) => any) | undefined;
|
|
88
88
|
"onImage-error"?: ((item: WaterFallItem) => any) | undefined;
|
|
89
89
|
}>, {
|
|
90
|
+
loading: boolean;
|
|
91
|
+
gap: number;
|
|
92
|
+
infinite: boolean;
|
|
90
93
|
virtualScroll: boolean;
|
|
91
94
|
columns: number;
|
|
92
|
-
gap: number;
|
|
93
95
|
lazy: boolean;
|
|
94
|
-
infinite: boolean;
|
|
95
96
|
skeleton: boolean;
|
|
96
97
|
skeletonCount: number;
|
|
97
98
|
animationDuration: number;
|
|
98
99
|
breakpoints: WaterFallBreakpoint[];
|
|
99
|
-
loading: boolean;
|
|
100
100
|
noMore: boolean;
|
|
101
101
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
102
102
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
package/dist/useQRCode.d.cts
CHANGED
|
@@ -51,15 +51,15 @@ declare const __VLS_export: vue.DefineComponent<Props, QRCodeExpose, {}, {}, {},
|
|
|
51
51
|
onError?: ((error: Error) => any) | undefined;
|
|
52
52
|
}>, {
|
|
53
53
|
size: number;
|
|
54
|
-
|
|
54
|
+
label: string;
|
|
55
55
|
color: string;
|
|
56
56
|
showBorder: boolean;
|
|
57
|
-
|
|
57
|
+
showLabel: boolean;
|
|
58
|
+
mode: RenderMode;
|
|
58
59
|
margin: number;
|
|
59
60
|
bgColor: string;
|
|
60
61
|
errorCorrectionLevel: ErrorCorrectionLevel;
|
|
61
62
|
logo: LogoOptions;
|
|
62
|
-
showLabel: boolean;
|
|
63
63
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
//#endregion
|
package/dist/useQRCode.d.ts
CHANGED
|
@@ -51,15 +51,15 @@ declare const __VLS_export: vue.DefineComponent<Props, QRCodeExpose, {}, {}, {},
|
|
|
51
51
|
onError?: ((error: Error) => any) | undefined;
|
|
52
52
|
}>, {
|
|
53
53
|
size: number;
|
|
54
|
-
|
|
54
|
+
label: string;
|
|
55
55
|
color: string;
|
|
56
56
|
showBorder: boolean;
|
|
57
|
-
|
|
57
|
+
showLabel: boolean;
|
|
58
|
+
mode: RenderMode;
|
|
58
59
|
margin: number;
|
|
59
60
|
bgColor: string;
|
|
60
61
|
errorCorrectionLevel: ErrorCorrectionLevel;
|
|
61
62
|
logo: LogoOptions;
|
|
62
|
-
showLabel: boolean;
|
|
63
63
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
//#endregion
|