@m3ui-vue/m3ui-vue 1.10.2 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/dist/API.md +195 -56
- package/dist/MButton-gWoOzFWf.js +284 -0
- package/dist/MButton-gWoOzFWf.js.map +1 -0
- package/dist/MColorPickerModal-CJYMvlgK.js +466 -0
- package/dist/MColorPickerModal-CJYMvlgK.js.map +1 -0
- package/dist/MDialog-CU8EYgCC.js +226 -0
- package/dist/MDialog-CU8EYgCC.js.map +1 -0
- package/dist/{MIcon-BSsJZhK7.js → MIcon-CkUc9kuQ.js} +10 -4
- package/dist/MIcon-CkUc9kuQ.js.map +1 -0
- package/dist/MIconButton-DTFOfsTy.js +317 -0
- package/dist/MIconButton-DTFOfsTy.js.map +1 -0
- package/dist/MListItem-Cdw2FqCT.js +1306 -0
- package/dist/MListItem-Cdw2FqCT.js.map +1 -0
- package/dist/MLoadingIndicator-BxAy2x7P.js +115 -0
- package/dist/MLoadingIndicator-BxAy2x7P.js.map +1 -0
- package/dist/{MMenuItem-US0Zbglq.js → MMenuItem-CEIKYvaX.js} +216 -214
- package/dist/MMenuItem-CEIKYvaX.js.map +1 -0
- package/dist/{MPdfViewer-DL9mRsd2.js → MPdfViewer-CEfyXGq2.js} +674 -671
- package/dist/MPdfViewer-CEfyXGq2.js.map +1 -0
- package/dist/MProgressBar-BzZMxq7M.js.map +1 -1
- package/dist/MSeekBar-B3_D-PwH.js +435 -0
- package/dist/MSeekBar-B3_D-PwH.js.map +1 -0
- package/dist/{MSegmentedButton-DMou-8sG.js → MSegmentedButton-Dg07j-4r.js} +4 -4
- package/dist/{MSegmentedButton-DMou-8sG.js.map → MSegmentedButton-Dg07j-4r.js.map} +1 -1
- package/dist/{MSignaturePad-WuvE_Cyl.js → MSignaturePad-3nddtLKI.js} +2 -2
- package/dist/{MSignaturePad-WuvE_Cyl.js.map → MSignaturePad-3nddtLKI.js.map} +1 -1
- package/dist/{MSlider-7TzhFHKS.js → MSlider-BrpLbqwt.js} +4 -4
- package/dist/{MSlider-7TzhFHKS.js.map → MSlider-BrpLbqwt.js.map} +1 -1
- package/dist/{MSpinner-CkIVBuGE.js → MSpinner-CLwzDH33.js} +2 -2
- package/dist/{MSpinner-CkIVBuGE.js.map → MSpinner-CLwzDH33.js.map} +1 -1
- package/dist/{MTextField-B6_iOczK.js → MTextField-CZRizAwA.js} +136 -134
- package/dist/MTextField-CZRizAwA.js.map +1 -0
- package/dist/{_useFieldValidation-COBJ1tWr.js → _useFieldValidation-DVcqyy9g.js} +2 -2
- package/dist/{_useFieldValidation-COBJ1tWr.js.map → _useFieldValidation-DVcqyy9g.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/chart.js +1 -1
- package/dist/code-editor.js +3 -3
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAlert.vue.d.ts +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +3 -3
- package/dist/components/MAvatar.vue.d.ts +19 -1
- package/dist/components/MButton.vue.d.ts +2 -1
- package/dist/components/MChatBubble.vue.d.ts +2 -0
- package/dist/components/MCheckbox.vue.d.ts +2 -0
- package/dist/components/MDataTable.vue.d.ts +31 -3
- package/dist/components/MFlow.vue.d.ts +1 -1
- package/dist/components/MHotkeys.vue.d.ts +1 -0
- package/dist/components/MIcon.vue.d.ts +6 -0
- package/dist/components/MIconButton.vue.d.ts +5 -0
- package/dist/components/MKanban.vue.d.ts +1 -1
- package/dist/components/MLink.vue.d.ts +59 -0
- package/dist/components/MListItem.vue.d.ts +3 -1
- package/dist/components/MMapControl.vue.d.ts +1 -1
- package/dist/components/MNotificationCenter.vue.d.ts +1 -1
- package/dist/components/MNumberField.vue.d.ts +1 -1
- package/dist/components/MPagination.vue.d.ts +14 -1
- package/dist/components/MPdfSigner.vue.d.ts +2 -2
- package/dist/components/MRadio.vue.d.ts +2 -0
- package/dist/components/MRadioGroup.vue.d.ts +2 -0
- package/dist/components/MStatCard.vue.d.ts +2 -2
- package/dist/components/MSwitch.vue.d.ts +2 -0
- package/dist/components/MText.vue.d.ts +4 -2
- package/dist/components/MTextField.vue.d.ts +2 -0
- package/dist/components/_MDrawerItemList.vue.d.ts +6 -0
- package/dist/composables/_menuGroups.d.ts +10 -1
- package/dist/composables/_splitAttrs.d.ts +6 -0
- package/dist/composables/_springAnimation.d.ts +2 -2
- package/dist/composables/_useFocusTrap.d.ts +15 -0
- package/dist/composables/_usePaneResize.d.ts +1 -1
- package/dist/composables/_useSpring.d.ts +4 -4
- package/dist/composables/dynamicColor.d.ts +9 -1
- package/dist/composables/motion.d.ts +63 -0
- package/dist/composables/useConfirm.d.ts +28 -0
- package/dist/composables/useDevice.d.ts +8 -1
- package/dist/composables/useLocale.d.ts +14 -0
- package/dist/composables/useScrollReveal.d.ts +1 -1
- package/dist/composables/useTheme.d.ts +1 -0
- package/dist/composables/useToast.d.ts +7 -0
- package/dist/draw.js +556 -556
- package/dist/draw.js.map +1 -1
- package/dist/flow.js +854 -851
- package/dist/flow.js.map +1 -1
- package/dist/gantt.js +1118 -1096
- package/dist/gantt.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/locales/index.d.ts +1 -0
- package/dist/locales/index.js +833 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/locales/pl.d.ts +2 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +10327 -9796
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +860 -860
- package/dist/map.js.map +1 -1
- package/dist/{material-color-utilities-CEFytLsr.js → material-color-utilities-BZsBNIhi.js} +276 -217
- package/dist/material-color-utilities-BZsBNIhi.js.map +1 -0
- package/dist/media.js +7 -7
- package/dist/{motion-BcejVTeX.js → motion-BqYcqcim.js} +15 -5
- package/dist/motion-BqYcqcim.js.map +1 -0
- package/dist/pdf-sign.js +140 -137
- package/dist/pdf-sign.js.map +1 -1
- package/dist/pdf.js +1 -1
- package/dist/plugin.d.ts +11 -0
- package/dist/rich-text-editor.js +7 -7
- package/dist/styles/theme.css +40 -0
- package/dist/styles.css +1 -1
- package/dist/terminal.js +1 -1
- package/dist/{useLocale-YRaOT12S.js → useLocale-BjcYauXr.js} +60 -4
- package/dist/useLocale-BjcYauXr.js.map +1 -0
- package/dist/{useThemeTokens-DyAdPQB0.js → useThemeTokens-D5nr5KHf.js} +28 -27
- package/dist/useThemeTokens-D5nr5KHf.js.map +1 -0
- package/package.json +17 -2
- package/src/__tests__/MAvatarImage.test.ts +37 -0
- package/src/__tests__/MDataTableControlled.test.ts +68 -0
- package/src/__tests__/MHotkeysSequence.test.ts +53 -0
- package/src/__tests__/MIconAxes.test.ts +16 -0
- package/src/__tests__/MIconButtonWidth.test.ts +22 -0
- package/src/__tests__/MLink.test.ts +46 -0
- package/src/__tests__/MPaginationPages.test.ts +43 -0
- package/src/__tests__/MTextEmphasized.test.ts +14 -0
- package/src/__tests__/controlDescription.test.ts +34 -0
- package/src/__tests__/customColor.test.ts +27 -0
- package/src/__tests__/dynamicColor.test.ts +3 -2
- package/src/__tests__/focusTrap.test.ts +124 -0
- package/src/__tests__/formatMessage.test.ts +20 -0
- package/src/__tests__/inputAttrs.test.ts +103 -0
- package/src/__tests__/localePresets.test.ts +2 -0
- package/src/__tests__/menuGroupsRemount.test.ts +40 -0
- package/src/__tests__/menuHydration.test.ts +41 -0
- package/src/__tests__/motionPrefs.test.ts +28 -0
- package/src/__tests__/ssr.test.ts +11 -0
- package/src/__tests__/ssrToast.test.ts +20 -0
- package/src/__tests__/toastDetails.test.ts +39 -0
- package/src/__tests__/useConfirm.test.ts +47 -0
- package/src/__tests__/useTheme.test.ts +14 -0
- package/src/__tests__/warningRole.test.ts +22 -0
- package/src/components/MAlert.vue +2 -2
- package/src/components/MAnimatedNumber.vue +9 -3
- package/src/components/MAutocomplete.vue +16 -4
- package/src/components/MAvailabilityCalendar.vue +3 -3
- package/src/components/MAvatar.vue +32 -5
- package/src/components/MAvatarGroup.vue +7 -2
- package/src/components/MBottomSheet.vue +18 -2
- package/src/components/MButton.vue +18 -5
- package/src/components/MCarousel.vue +3 -3
- package/src/components/MChatBubble.vue +14 -1
- package/src/components/MCheckbox.vue +21 -4
- package/src/components/MChip.vue +4 -2
- package/src/components/MCollapse.vue +7 -1
- package/src/components/MCommandPalette.vue +6 -2
- package/src/components/MContextMenu.vue +4 -4
- package/src/components/MCreditCardInput.vue +5 -0
- package/src/components/MDashboardGrid.vue +2 -1
- package/src/components/MDataTable.vue +63 -16
- package/src/components/MDialog.vue +21 -3
- package/src/components/MDiffViewer.vue +3 -3
- package/src/components/MDrawLayers.vue +3 -3
- package/src/components/MFabMenu.vue +7 -0
- package/src/components/MFloorPlan.vue +3 -3
- package/src/components/MFloorPlanInspector.vue +3 -3
- package/src/components/MFlow.vue +9 -5
- package/src/components/MFlowControls.vue +6 -0
- package/src/components/MFormBuilder.vue +1 -1
- package/src/components/MGantt.vue +10 -10
- package/src/components/MHotkeys.vue +61 -16
- package/src/components/MIcon.vue +17 -1
- package/src/components/MIconButton.vue +29 -6
- package/src/components/MImageCropper.vue +1 -1
- package/src/components/MKanban.vue +2 -1
- package/src/components/MLightbox.vue +5 -4
- package/src/components/MLink.vue +136 -0
- package/src/components/MListDetail.vue +7 -0
- package/src/components/MListItem.vue +7 -4
- package/src/components/MLoadingIndicator.vue +2 -1
- package/src/components/MMap.vue +3 -0
- package/src/components/MMapCluster.vue +2 -2
- package/src/components/MMapControl.vue +2 -2
- package/src/components/MMapMeasure.vue +1 -1
- package/src/components/MMaskField.vue +16 -3
- package/src/components/MMenu.vue +4 -4
- package/src/components/MMenuItem.vue +2 -2
- package/src/components/MMeterGroup.vue +3 -2
- package/src/components/MMortgageCalculator.vue +3 -3
- package/src/components/MMultiAutocomplete.vue +19 -7
- package/src/components/MMultiSelect.vue +19 -7
- package/src/components/MNavigationDrawer.vue +10 -3
- package/src/components/MNavigationRail.vue +5 -1
- package/src/components/MNotificationCenter.vue +2 -1
- package/src/components/MNotificationHost.vue +3 -3
- package/src/components/MNumberField.vue +23 -6
- package/src/components/MOdontogram.vue +4 -4
- package/src/components/MOrderBook.vue +4 -0
- package/src/components/MPagination.vue +91 -12
- package/src/components/MPdfSigner.vue +3 -3
- package/src/components/MPdfViewer.vue +7 -7
- package/src/components/MPhoneInput.vue +17 -4
- package/src/components/MProductConfigurator.vue +4 -4
- package/src/components/MProgressBar.vue +5 -0
- package/src/components/MQuiz.vue +8 -5
- package/src/components/MRadio.vue +24 -5
- package/src/components/MRadioGroup.vue +3 -0
- package/src/components/MReactions.vue +2 -2
- package/src/components/MResourceTimeline.vue +3 -3
- package/src/components/MResult.vue +1 -1
- package/src/components/MScrollField.vue +1 -1
- package/src/components/MSearchField.vue +6 -5
- package/src/components/MSeatMap.vue +5 -0
- package/src/components/MSeekBar.vue +3 -2
- package/src/components/MSelect.vue +16 -4
- package/src/components/MSideSheet.vue +25 -3
- package/src/components/MSimpleCarousel.vue +2 -2
- package/src/components/MSnackbar.vue +16 -13
- package/src/components/MSparkline.vue +2 -1
- package/src/components/MSpinner.vue +8 -0
- package/src/components/MSplitter.vue +1 -1
- package/src/components/MSpotlightSearch.vue +6 -2
- package/src/components/MSpreadsheet.vue +1 -1
- package/src/components/MStatCard.vue +2 -1
- package/src/components/MSwitch.vue +21 -4
- package/src/components/MTabs.vue +2 -1
- package/src/components/MTagInput.vue +19 -6
- package/src/components/MText.vue +23 -4
- package/src/components/MTextField.vue +25 -6
- package/src/components/MTimeline.vue +5 -5
- package/src/components/MToolbar.vue +2 -2
- package/src/components/MTour.vue +3 -0
- package/src/components/MTrackingTimeline.vue +6 -0
- package/src/components/MTypewriter.vue +7 -1
- package/src/components/MWindow.vue +10 -1
- package/src/components/_MColorPanel.vue +4 -4
- package/src/components/_MComment.vue +3 -2
- package/src/components/_MFlowNodeShell.vue +1 -1
- package/src/components/_MPdfPage.vue +1 -1
- package/src/components/_MTransferPane.vue +10 -0
- package/src/composables/_effectCanvas.ts +2 -1
- package/src/composables/_menuGroups.ts +10 -1
- package/src/composables/_splitAttrs.ts +29 -0
- package/src/composables/_springAnimation.ts +3 -3
- package/src/composables/_themeTransition.ts +3 -2
- package/src/composables/_useFocusTrap.ts +142 -0
- package/src/composables/_useMenuNav.ts +3 -3
- package/src/composables/_usePaneResize.ts +2 -1
- package/src/composables/_useSheetMotion.ts +3 -4
- package/src/composables/_useSpring.ts +16 -10
- package/src/composables/cron.ts +7 -6
- package/src/composables/dynamicColor.ts +21 -2
- package/src/composables/motion.ts +27 -0
- package/src/composables/useConfirm.ts +116 -0
- package/src/composables/useDevice.ts +23 -3
- package/src/composables/useFieldBg.ts +4 -0
- package/src/composables/useLocale.ts +74 -0
- package/src/composables/useNotification.ts +3 -0
- package/src/composables/useScrollReveal.ts +3 -3
- package/src/composables/useTheme.ts +8 -2
- package/src/composables/useToast.ts +27 -4
- package/src/directives/vSparkle.ts +2 -1
- package/src/index.ts +8 -5
- package/src/locales/ar.ts +7 -0
- package/src/locales/de.ts +7 -0
- package/src/locales/es.ts +7 -0
- package/src/locales/fr.ts +7 -0
- package/src/locales/index.ts +1 -0
- package/src/locales/ja.ts +7 -0
- package/src/locales/ko.ts +7 -0
- package/src/locales/pl.ts +807 -0
- package/src/locales/pt.ts +7 -0
- package/src/locales/zh.ts +7 -0
- package/src/plugin.ts +16 -0
- package/src/styles/theme.css +40 -0
- package/dist/MButton-B9RCM06i.js +0 -171
- package/dist/MButton-B9RCM06i.js.map +0 -1
- package/dist/MColorPickerModal-ChRtcZOo.js +0 -577
- package/dist/MColorPickerModal-ChRtcZOo.js.map +0 -1
- package/dist/MDialog-dk07tify.js +0 -167
- package/dist/MDialog-dk07tify.js.map +0 -1
- package/dist/MIcon-BSsJZhK7.js.map +0 -1
- package/dist/MIconButton-CrBPZidd.js +0 -288
- package/dist/MIconButton-CrBPZidd.js.map +0 -1
- package/dist/MListItem-h9H223vx.js +0 -1239
- package/dist/MListItem-h9H223vx.js.map +0 -1
- package/dist/MLoadingIndicator-YTV1Ov5w.js +0 -114
- package/dist/MLoadingIndicator-YTV1Ov5w.js.map +0 -1
- package/dist/MMenuItem-US0Zbglq.js.map +0 -1
- package/dist/MPdfViewer-DL9mRsd2.js.map +0 -1
- package/dist/MSeekBar-JFZcoJ8y.js +0 -434
- package/dist/MSeekBar-JFZcoJ8y.js.map +0 -1
- package/dist/MTextField-B6_iOczK.js.map +0 -1
- package/dist/material-color-utilities-CEFytLsr.js.map +0 -1
- package/dist/motion-BcejVTeX.js.map +0 -1
- package/dist/useLocale-YRaOT12S.js.map +0 -1
- package/dist/useThemeTokens-DyAdPQB0.js.map +0 -1
package/dist/draw.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "./MIconButton-
|
|
3
|
-
import { n, t as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import { Fragment as
|
|
1
|
+
import { a as e, i as t } from "./useLocale-BjcYauXr.js";
|
|
2
|
+
import { t as n } from "./MIconButton-DTFOfsTy.js";
|
|
3
|
+
import { n as r, t as i } from "./MMenuItem-CEIKYvaX.js";
|
|
4
|
+
import { t as a } from "./MTooltip-Cn_DYm9M.js";
|
|
5
|
+
import { t as o } from "./MColorPickerModal-CJYMvlgK.js";
|
|
6
|
+
import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createTextVNode as p, createVNode as m, defineComponent as h, inject as ee, mergeModels as g, mergeProps as _, nextTick as v, normalizeClass as y, normalizeStyle as b, onBeforeUnmount as te, onMounted as ne, openBlock as x, provide as re, ref as S, renderList as C, renderSlot as w, shallowRef as T, toDisplayString as ie, unref as E, useId as D, useModel as O, vModelText as k, watch as ae, withCtx as A, withDirectives as oe, withKeys as j, withModifiers as se } from "vue";
|
|
7
7
|
// src/composables/drawGeometry.ts
|
|
8
|
-
var
|
|
8
|
+
var ce = 0, le = () => `d${Date.now().toString(36)}${(ce++).toString(36)}`, ue = {
|
|
9
9
|
pen: {
|
|
10
10
|
thinning: .6,
|
|
11
11
|
taper: .4,
|
|
@@ -26,8 +26,8 @@ var N = 0, oe = () => `d${Date.now().toString(36)}${(N++).toString(36)}`, se = {
|
|
|
26
26
|
taper: 0,
|
|
27
27
|
opacity: .35
|
|
28
28
|
}
|
|
29
|
-
},
|
|
30
|
-
function
|
|
29
|
+
}, M = (e) => Math.round(e * 100) / 100;
|
|
30
|
+
function de(e, t = .5, n = 4) {
|
|
31
31
|
if (e.length < 2) return e.slice();
|
|
32
32
|
let r = 1 - Math.min(.9, Math.max(0, t) * .85), i = Math.max(.5, n * .1), a = [e[0]], [o, s] = e[0];
|
|
33
33
|
for (let t = 1; t < e.length; t++) {
|
|
@@ -47,7 +47,7 @@ function ce(e, t = .5, n = 4) {
|
|
|
47
47
|
c[2]
|
|
48
48
|
], a;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function fe(e, t) {
|
|
51
51
|
let n = .5;
|
|
52
52
|
return e.map((r, i) => {
|
|
53
53
|
if (!i) return [
|
|
@@ -63,8 +63,8 @@ function le(e, t) {
|
|
|
63
63
|
];
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
let { thinning: r, taper: i } =
|
|
66
|
+
function N(e, t, n) {
|
|
67
|
+
let { thinning: r, taper: i } = ue[n], a = [0];
|
|
68
68
|
for (let t = 1; t < e.length; t++) a.push(a[t - 1] + Math.hypot(e[t][0] - e[t - 1][0], e[t][1] - e[t - 1][1]));
|
|
69
69
|
let o = a[a.length - 1], s = Math.min(o / 3, t * 3 * i);
|
|
70
70
|
return e.map((e, n) => {
|
|
@@ -76,13 +76,13 @@ function ue(e, t, n) {
|
|
|
76
76
|
return Math.max(.25, i);
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function pe(e) {
|
|
80
80
|
let t = e.points;
|
|
81
81
|
if (!t.length) return "";
|
|
82
|
-
let n =
|
|
82
|
+
let n = N(t, e.size, e.pen);
|
|
83
83
|
if (t.length === 1 || t.every((e) => Math.hypot(e[0] - t[0][0], e[1] - t[0][1]) < .5)) {
|
|
84
|
-
let [e, r] = t[0], i =
|
|
85
|
-
return `M${
|
|
84
|
+
let [e, r] = t[0], i = M(Math.max(...n));
|
|
85
|
+
return `M${M(e - i)} ${M(r)}a${i} ${i} 0 1 0 ${i * 2} 0a${i} ${i} 0 1 0 ${-i * 2} 0Z`;
|
|
86
86
|
}
|
|
87
87
|
let r = [], i = [];
|
|
88
88
|
for (let e = 0; e < t.length; e++) {
|
|
@@ -95,35 +95,35 @@ function de(e) {
|
|
|
95
95
|
let t = "";
|
|
96
96
|
for (let n = 1; n < e.length - 1; n++) {
|
|
97
97
|
let [r, i] = e[n], [a, o] = e[n + 1];
|
|
98
|
-
t += `Q${
|
|
98
|
+
t += `Q${M(r)} ${M(i)} ${M((r + a) / 2)} ${M((i + o) / 2)}`;
|
|
99
99
|
}
|
|
100
100
|
let n = e[e.length - 1];
|
|
101
|
-
return `${t}L${
|
|
102
|
-
}, o =
|
|
103
|
-
return `M${
|
|
101
|
+
return `${t}L${M(n[0])} ${M(n[1])}`;
|
|
102
|
+
}, o = M(n[n.length - 1]), s = M(n[0]), c = i.slice().reverse();
|
|
103
|
+
return `M${M(r[0][0])} ${M(r[0][1])}${a(r)}A${o} ${o} 0 0 1 ${M(c[0][0])} ${M(c[0][1])}${a(c)}A${s} ${s} 0 0 1 ${M(r[0][0])} ${M(r[0][1])}Z`;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function me(e) {
|
|
106
106
|
let [t, n] = e.from, [r, i] = e.to;
|
|
107
107
|
switch (e.shape) {
|
|
108
108
|
case "rect": {
|
|
109
109
|
let e = Math.min(t, r), a = Math.min(n, i);
|
|
110
|
-
return { d: `M${
|
|
110
|
+
return { d: `M${M(e)} ${M(a)}h${M(Math.abs(r - t))}v${M(Math.abs(i - n))}h${M(-Math.abs(r - t))}Z` };
|
|
111
111
|
}
|
|
112
112
|
case "ellipse": {
|
|
113
113
|
let e = Math.abs(r - t) / 2, a = Math.abs(i - n) / 2, o = (t + r) / 2, s = (n + i) / 2;
|
|
114
|
-
return { d: `M${
|
|
114
|
+
return { d: `M${M(o - e)} ${M(s)}a${M(e)} ${M(a)} 0 1 0 ${M(e * 2)} 0a${M(e)} ${M(a)} 0 1 0 ${M(-e * 2)} 0Z` };
|
|
115
115
|
}
|
|
116
116
|
case "arrow": {
|
|
117
117
|
let a = Math.hypot(r - t, i - n) || 1, o = (r - t) / a, s = (i - n) / a, c = Math.min(a * .6, Math.max(10, e.size * 4)), l = c * .55, u = r - o * c, d = i - s * c;
|
|
118
118
|
return {
|
|
119
|
-
d: `M${
|
|
120
|
-
head: `M${
|
|
119
|
+
d: `M${M(t)} ${M(n)}L${M(u + o * .5)} ${M(d + s * .5)}`,
|
|
120
|
+
head: `M${M(r)} ${M(i)}L${M(u - s * l)} ${M(d + o * l)}L${M(u + s * l)} ${M(d - o * l)}Z`
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
default: return { d: `M${
|
|
123
|
+
default: return { d: `M${M(t)} ${M(n)}L${M(r)} ${M(i)}` };
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function he(e, t, n) {
|
|
127
127
|
let r = n[0] - t[0], i = n[1] - t[1];
|
|
128
128
|
if (e === "rect" || e === "ellipse") {
|
|
129
129
|
let e = Math.max(Math.abs(r), Math.abs(i));
|
|
@@ -132,18 +132,18 @@ function pe(e, t, n) {
|
|
|
132
132
|
let a = Math.round(Math.atan2(i, r) / (Math.PI / 4)) * (Math.PI / 4), o = Math.hypot(r, i);
|
|
133
133
|
return [t[0] + Math.cos(a) * o, t[1] + Math.sin(a) * o];
|
|
134
134
|
}
|
|
135
|
-
var
|
|
136
|
-
function
|
|
135
|
+
var ge = 1.25;
|
|
136
|
+
function _e(e) {
|
|
137
137
|
let t = e.text.split("\n");
|
|
138
138
|
return {
|
|
139
139
|
x: e.at[0],
|
|
140
140
|
y: e.at[1],
|
|
141
141
|
width: Math.max(e.size, ...t.map((t) => t.length * e.size * .56)),
|
|
142
|
-
height: t.length * e.size *
|
|
142
|
+
height: t.length * e.size * ge
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
if (e.type === "text") return
|
|
145
|
+
function ve(e) {
|
|
146
|
+
if (e.type === "text") return _e(e);
|
|
147
147
|
let t = e.type === "stroke" ? e.points.map((e) => [e[0], e[1]]) : [e.from, e.to], n = e.size / 2, r = Infinity, i = Infinity, a = -Infinity, o = -Infinity;
|
|
148
148
|
for (let [e, n] of t) r = Math.min(r, e), i = Math.min(i, n), a = Math.max(a, e), o = Math.max(o, n);
|
|
149
149
|
return {
|
|
@@ -153,7 +153,7 @@ function he(e) {
|
|
|
153
153
|
height: o - i + n * 2
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function ye(e) {
|
|
157
157
|
if (!e.length) return null;
|
|
158
158
|
let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x + e.width)), i = Math.max(...e.map((e) => e.y + e.height));
|
|
159
159
|
return {
|
|
@@ -163,11 +163,11 @@ function ge(e) {
|
|
|
163
163
|
height: i - n
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function P(e, t, n, r, i, a) {
|
|
167
167
|
let o = i - n, s = a - r, c = o * o + s * s, l = c ? Math.max(0, Math.min(1, ((e - n) * o + (t - r) * s) / c)) : 0;
|
|
168
168
|
return Math.hypot(n + l * o - e, r + l * s - t);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function F(e) {
|
|
171
171
|
let [t, n] = e.from, [r, i] = e.to;
|
|
172
172
|
if (e.shape === "rect") return [
|
|
173
173
|
[t, n],
|
|
@@ -182,39 +182,39 @@ function I(e) {
|
|
|
182
182
|
}
|
|
183
183
|
return [e.from, e.to];
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function be(e, t, n, r = 4) {
|
|
186
186
|
if (e.type === "text") {
|
|
187
|
-
let i =
|
|
187
|
+
let i = _e(e);
|
|
188
188
|
return t >= i.x - r && t <= i.x + i.width + r && n >= i.y - r && n <= i.y + i.height + r;
|
|
189
189
|
}
|
|
190
190
|
if (e.type === "shape" && e.fill && (e.shape === "rect" || e.shape === "ellipse")) {
|
|
191
|
-
let r =
|
|
191
|
+
let r = ve(e);
|
|
192
192
|
if (t >= r.x && t <= r.x + r.width && n >= r.y && n <= r.y + r.height) {
|
|
193
193
|
if (e.shape === "rect") return !0;
|
|
194
194
|
let i = r.width / 2, a = r.height / 2;
|
|
195
195
|
if (((t - r.x - i) / i) ** 2 + ((n - r.y - a) / a) ** 2 <= 1) return !0;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
let i = e.type === "stroke" ? e.points.map((e) => [e[0], e[1]]) :
|
|
198
|
+
let i = e.type === "stroke" ? e.points.map((e) => [e[0], e[1]]) : F(e), a = e.size / 2 + r;
|
|
199
199
|
if (i.length === 1) return Math.hypot(i[0][0] - t, i[0][1] - n) <= a;
|
|
200
|
-
for (let e = 1; e < i.length; e++) if (
|
|
200
|
+
for (let e = 1; e < i.length; e++) if (P(t, n, i[e - 1][0], i[e - 1][1], i[e][0], i[e][1]) <= a) return !0;
|
|
201
201
|
return !1;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
if (e.type !== "stroke") return
|
|
203
|
+
function xe(e, t, n, r) {
|
|
204
|
+
if (e.type !== "stroke") return be(e, t, n, r) ? [] : [e];
|
|
205
205
|
let i = r + e.size / 2, a = e.points;
|
|
206
206
|
if (a.length === 1) return Math.hypot(a[0][0] - t, a[0][1] - n) <= i ? [] : [e];
|
|
207
207
|
let o = !1, s = [], c = [];
|
|
208
208
|
return a.forEach((e, r) => {
|
|
209
|
-
let l = a[r - 1], u = Math.hypot(e[0] - t, e[1] - n) <= i, d = !!l && c.length > 0 &&
|
|
209
|
+
let l = a[r - 1], u = Math.hypot(e[0] - t, e[1] - n) <= i, d = !!l && c.length > 0 && P(t, n, l[0], l[1], e[0], e[1]) <= i;
|
|
210
210
|
u || d ? (o = !0, c.length > 1 && s.push(c), c = u ? [] : [e]) : c.push(e);
|
|
211
211
|
}), c.length > 1 && s.push(c), o ? s.map((t, n) => ({
|
|
212
212
|
...e,
|
|
213
|
-
id: n ?
|
|
213
|
+
id: n ? le() : e.id,
|
|
214
214
|
points: t
|
|
215
215
|
})) : [e];
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function I(e, t, n) {
|
|
218
218
|
let r = !1;
|
|
219
219
|
for (let i = 0, a = n.length - 1; i < n.length; a = i++) {
|
|
220
220
|
let [o, s] = n[i], [c, l] = n[a];
|
|
@@ -222,13 +222,13 @@ function L(e, t, n) {
|
|
|
222
222
|
}
|
|
223
223
|
return r;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function Se(e, t) {
|
|
226
226
|
if (t.length < 3) return !1;
|
|
227
227
|
let n;
|
|
228
228
|
if (e.type === "stroke") n = e.points.map((e) => [e[0], e[1]]);
|
|
229
|
-
else if (e.type === "shape") n =
|
|
229
|
+
else if (e.type === "shape") n = F(e);
|
|
230
230
|
else {
|
|
231
|
-
let t =
|
|
231
|
+
let t = _e(e);
|
|
232
232
|
n = [
|
|
233
233
|
[t.x, t.y],
|
|
234
234
|
[t.x + t.width, t.y],
|
|
@@ -236,9 +236,9 @@ function be(e, t) {
|
|
|
236
236
|
[t.x + t.width, t.y + t.height]
|
|
237
237
|
];
|
|
238
238
|
}
|
|
239
|
-
return n.filter(([e, n]) =>
|
|
239
|
+
return n.filter(([e, n]) => I(e, n, t)).length >= Math.max(1, n.length * .5);
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Ce(e, t) {
|
|
242
242
|
let { dx: n = 0, dy: r = 0, sx: i = 1, sy: a = 1, ox: o = 0, oy: s = 0 } = t, c = (e) => o + (e - o) * i + n, l = (e) => s + (e - s) * a + r, u = Math.sqrt(Math.abs(i * a));
|
|
243
243
|
return e.type === "stroke" ? {
|
|
244
244
|
...e,
|
|
@@ -259,26 +259,26 @@ function xe(e, t) {
|
|
|
259
259
|
at: [c(e.at[0]), l(e.at[1])]
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
|
-
var
|
|
263
|
-
function
|
|
262
|
+
var L = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
263
|
+
function R(e, t = "sans-serif") {
|
|
264
264
|
if (e.type === "stroke") {
|
|
265
|
-
let t =
|
|
266
|
-
return `<path d="${
|
|
265
|
+
let t = ue[e.pen].opacity;
|
|
266
|
+
return `<path d="${pe(e)}" fill="${L(e.color)}"${t < 1 ? ` fill-opacity="${t}"` : ""}/>`;
|
|
267
267
|
}
|
|
268
268
|
if (e.type === "shape") {
|
|
269
|
-
let { d: t, head: n } =
|
|
270
|
-
return `<path d="${t}" fill="${e.fill && (e.shape === "rect" || e.shape === "ellipse") ?
|
|
269
|
+
let { d: t, head: n } = me(e);
|
|
270
|
+
return `<path d="${t}" fill="${e.fill && (e.shape === "rect" || e.shape === "ellipse") ? L(e.fill) : "none"}" stroke="${L(e.color)}" stroke-width="${e.size}" stroke-linecap="round" stroke-linejoin="round"/>${n ? `<path d="${n}" fill="${L(e.color)}"/>` : ""}`;
|
|
271
271
|
}
|
|
272
272
|
let n = e.text.split("\n");
|
|
273
|
-
return `<text x="${e.at[0]}" y="${e.at[1]}" font-size="${e.size}" font-family="${
|
|
273
|
+
return `<text x="${e.at[0]}" y="${e.at[1]}" font-size="${e.size}" font-family="${L(t)}" fill="${L(e.color)}">${n.map((t, n) => `<tspan x="${e.at[0]}" dy="${n ? e.size * ge : e.size * .95}">${L(t) || " "}</tspan>`).join("")}</text>`;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function we(e, t) {
|
|
276
276
|
if (!t?.length) return e;
|
|
277
277
|
let n = (e) => e.layer === void 0 ? 0 : Math.max(0, t.indexOf(e.layer));
|
|
278
278
|
return e.map((e, t) => [e, t]).sort((e, t) => n(e[0]) - n(t[0]) || e[1] - t[1]).map(([e]) => e);
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
let n =
|
|
280
|
+
function Te(e, t = {}) {
|
|
281
|
+
let n = we(e, t.layers).filter((e) => (t.page === void 0 || (e.page ?? 0) === t.page) && !t.hiddenLayers?.includes(e.layer ?? "")), r = t.padding ?? 16, i = t.box ?? ye(n.map(ve)) ?? {
|
|
282
282
|
x: 0,
|
|
283
283
|
y: 0,
|
|
284
284
|
width: 1,
|
|
@@ -288,10 +288,10 @@ function Ce(e, t = {}) {
|
|
|
288
288
|
y: i.y - r,
|
|
289
289
|
width: i.width + r * 2,
|
|
290
290
|
height: i.height + r * 2
|
|
291
|
-
}, o = t.background ? `<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" fill="${
|
|
292
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${
|
|
291
|
+
}, o = t.background ? `<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" fill="${L(t.background)}"/>` : "";
|
|
292
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${M(a.x)} ${M(a.y)} ${M(a.width)} ${M(a.height)}" width="${Math.ceil(a.width)}" height="${Math.ceil(a.height)}">${o}${n.map((e) => R(e, t.fontFamily)).join("")}</svg>`;
|
|
293
293
|
}
|
|
294
|
-
async function
|
|
294
|
+
async function Ee(e, t = 2) {
|
|
295
295
|
let n = URL.createObjectURL(new Blob([e], { type: "image/svg+xml" }));
|
|
296
296
|
try {
|
|
297
297
|
let e = new Image();
|
|
@@ -303,83 +303,83 @@ async function we(e, t = 2) {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
// src/composables/useDrawing.ts
|
|
306
|
-
var
|
|
307
|
-
function
|
|
308
|
-
let e =
|
|
306
|
+
var De = Symbol("m3-draw");
|
|
307
|
+
function Oe() {
|
|
308
|
+
let e = ee(De, null);
|
|
309
309
|
if (!e) throw Error("useDrawing() must be called inside <MDrawCanvas>");
|
|
310
310
|
return e;
|
|
311
311
|
}
|
|
312
312
|
// src/components/MDrawCanvas.vue?vue&type=script&setup=true&lang.ts
|
|
313
|
-
var
|
|
313
|
+
var ke = ["aria-label"], Ae = [
|
|
314
314
|
"id",
|
|
315
315
|
"width",
|
|
316
316
|
"height"
|
|
317
|
-
],
|
|
317
|
+
], je = ["d", "stroke-width"], Me = [
|
|
318
318
|
"id",
|
|
319
319
|
"width",
|
|
320
320
|
"height"
|
|
321
|
-
],
|
|
321
|
+
], Ne = [
|
|
322
322
|
"cx",
|
|
323
323
|
"cy",
|
|
324
324
|
"r"
|
|
325
|
-
],
|
|
325
|
+
], Pe = [
|
|
326
326
|
"id",
|
|
327
327
|
"width",
|
|
328
328
|
"height"
|
|
329
|
-
],
|
|
329
|
+
], Fe = ["d", "stroke-width"], Ie = ["id"], Le = ["width", "height"], Re = ["transform"], ze = ["fill"], Be = ["href"], Ve = ["fill"], He = ["transform"], Ue = [
|
|
330
330
|
"width",
|
|
331
331
|
"height",
|
|
332
332
|
"fill"
|
|
333
|
-
],
|
|
333
|
+
], We = [
|
|
334
334
|
"href",
|
|
335
335
|
"width",
|
|
336
336
|
"height"
|
|
337
|
-
],
|
|
337
|
+
], Ge = [
|
|
338
338
|
"width",
|
|
339
339
|
"height",
|
|
340
340
|
"fill"
|
|
341
|
-
],
|
|
341
|
+
], Ke = ["clip-path"], qe = [
|
|
342
342
|
"d",
|
|
343
343
|
"fill",
|
|
344
344
|
"fill-opacity"
|
|
345
|
-
],
|
|
345
|
+
], Je = [
|
|
346
346
|
"d",
|
|
347
347
|
"fill",
|
|
348
348
|
"stroke",
|
|
349
349
|
"stroke-width"
|
|
350
|
-
],
|
|
350
|
+
], Ye = ["d", "fill"], Xe = [
|
|
351
351
|
"x",
|
|
352
352
|
"y",
|
|
353
353
|
"font-size",
|
|
354
354
|
"fill"
|
|
355
|
-
],
|
|
355
|
+
], Ze = ["x", "dy"], Qe = [
|
|
356
356
|
"d",
|
|
357
357
|
"fill",
|
|
358
358
|
"fill-opacity"
|
|
359
|
-
],
|
|
359
|
+
], $e = [
|
|
360
360
|
"d",
|
|
361
361
|
"fill",
|
|
362
362
|
"stroke",
|
|
363
363
|
"stroke-width"
|
|
364
|
-
],
|
|
364
|
+
], et = ["d", "fill"], tt = [
|
|
365
365
|
"points",
|
|
366
366
|
"stroke-width",
|
|
367
367
|
"stroke-dasharray"
|
|
368
|
-
],
|
|
368
|
+
], nt = [
|
|
369
369
|
"x",
|
|
370
370
|
"y",
|
|
371
371
|
"width",
|
|
372
372
|
"height",
|
|
373
373
|
"stroke-width",
|
|
374
374
|
"stroke-dasharray"
|
|
375
|
-
],
|
|
375
|
+
], rt = [
|
|
376
376
|
"x",
|
|
377
377
|
"y",
|
|
378
378
|
"width",
|
|
379
379
|
"height",
|
|
380
380
|
"rx",
|
|
381
381
|
"stroke-width"
|
|
382
|
-
],
|
|
382
|
+
], it = ["aria-label", "onKeydown"], at = 24, ot = 10, st = /* @__PURE__ */ h({
|
|
383
383
|
__name: "MDrawCanvas",
|
|
384
384
|
props: /*@__PURE__*/ g({
|
|
385
385
|
mode: { default: "infinite" },
|
|
@@ -456,81 +456,81 @@ var De = ["aria-label"], Oe = [
|
|
|
456
456
|
"update:viewport"
|
|
457
457
|
]),
|
|
458
458
|
setup(t, { expose: n, emit: r }) {
|
|
459
|
-
let i = t, a =
|
|
459
|
+
let i = t, a = O(t, "modelValue"), o = O(t, "tool"), l = O(t, "color"), p = O(t, "size"), m = O(t, "fill"), h = O(t, "layers"), ee = O(t, "layer"), g = O(t, "pages"), y = O(t, "selection"), A = O(t, "viewport"), ce = r, M = e(), N = S(), _e = S(), P = S({
|
|
460
460
|
width: 0,
|
|
461
461
|
height: 0
|
|
462
|
-
}),
|
|
463
|
-
function
|
|
464
|
-
i.history && (
|
|
465
|
-
}
|
|
466
|
-
function ut() {
|
|
467
|
-
V.value.length && (H.value = [a.value, ...H.value], a.value = V.value[V.value.length - 1], V.value = V.value.slice(0, -1), A.value = A.value.filter((e) => a.value.some((t) => t.id === e)), P("change", a.value));
|
|
462
|
+
}), F = (e) => e * (i.pageSize.height + at), I = c(() => i.mode === "pages"), L = T(null), R = c(() => L.value ?? a.value), Oe = c(() => h.value.map((e) => e.id)), st = c(() => ee.value ?? h.value[h.value.length - 1]?.id), ct = (e) => h.value.find((t) => t.id === (e.layer ?? h.value[0]?.id)), lt = (e) => ct(e)?.visible !== !1, z = (e) => lt(e) && !ct(e)?.locked, ut = c(() => we(R.value, Oe.value).filter(lt)), B = T([]), V = T([]);
|
|
463
|
+
function H(e) {
|
|
464
|
+
i.history && (B.value = [...B.value, a.value].slice(-i.historySize), V.value = []), a.value = e, ce("change", e);
|
|
468
465
|
}
|
|
469
466
|
function dt() {
|
|
470
|
-
|
|
467
|
+
B.value.length && (V.value = [a.value, ...V.value], a.value = B.value[B.value.length - 1], B.value = B.value.slice(0, -1), y.value = y.value.filter((e) => a.value.some((t) => t.id === e)), ce("change", a.value));
|
|
471
468
|
}
|
|
472
469
|
function ft() {
|
|
473
|
-
|
|
470
|
+
V.value.length && (B.value = [...B.value, a.value], a.value = V.value[0], V.value = V.value.slice(1), ce("change", a.value));
|
|
474
471
|
}
|
|
475
472
|
function pt() {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
473
|
+
a.value.length && H(a.value.filter((e) => !z(e))), y.value = [];
|
|
474
|
+
}
|
|
475
|
+
function mt() {
|
|
476
|
+
if (!y.value.length) return;
|
|
477
|
+
let e = new Set(y.value);
|
|
478
|
+
H(a.value.filter((t) => !e.has(t.id))), y.value = [];
|
|
479
479
|
}
|
|
480
|
-
let
|
|
481
|
-
function
|
|
482
|
-
let t =
|
|
480
|
+
let U = c(() => A.value);
|
|
481
|
+
function W(e) {
|
|
482
|
+
let t = N.value.getBoundingClientRect();
|
|
483
483
|
return {
|
|
484
|
-
x: (e.clientX - t.left -
|
|
485
|
-
y: (e.clientY - t.top -
|
|
484
|
+
x: (e.clientX - t.left - U.value.x) / U.value.zoom,
|
|
485
|
+
y: (e.clientY - t.top - U.value.y) / U.value.zoom
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
|
-
function
|
|
489
|
-
if (!
|
|
490
|
-
let t = Math.floor(e / (i.pageSize.height +
|
|
491
|
-
return Math.max(0, Math.min(
|
|
488
|
+
function ht(e) {
|
|
489
|
+
if (!I.value) return;
|
|
490
|
+
let t = Math.floor(e / (i.pageSize.height + at));
|
|
491
|
+
return Math.max(0, Math.min(g.value - 1, t));
|
|
492
492
|
}
|
|
493
|
-
let
|
|
493
|
+
let gt = (e, t) => ({
|
|
494
494
|
x: e.x,
|
|
495
|
-
y: t === void 0 ? e.y : e.y -
|
|
496
|
-
}),
|
|
497
|
-
function
|
|
498
|
-
let r =
|
|
499
|
-
|
|
495
|
+
y: t === void 0 ? e.y : e.y - F(t)
|
|
496
|
+
}), _t = (e) => I.value ? F(e.page ?? 0) : 0, vt = (e) => Math.min(i.maxZoom, Math.max(i.minZoom, e));
|
|
497
|
+
function yt(e, t, n) {
|
|
498
|
+
let r = U.value, i = vt(e);
|
|
499
|
+
A.value = {
|
|
500
500
|
zoom: i,
|
|
501
501
|
x: t - (t - r.x) / r.zoom * i,
|
|
502
502
|
y: n - (n - r.y) / r.zoom * i
|
|
503
503
|
};
|
|
504
504
|
}
|
|
505
|
-
let
|
|
506
|
-
function
|
|
507
|
-
let { width: e, height: t } =
|
|
505
|
+
let bt = (e) => yt(U.value.zoom * e, P.value.width / 2, P.value.height / 2);
|
|
506
|
+
function xt() {
|
|
507
|
+
let { width: e, height: t } = P.value;
|
|
508
508
|
if (!e || !t) return;
|
|
509
|
-
let n =
|
|
509
|
+
let n = I.value ? {
|
|
510
510
|
x: 0,
|
|
511
511
|
y: 0,
|
|
512
512
|
width: i.pageSize.width,
|
|
513
|
-
height:
|
|
514
|
-
} :
|
|
513
|
+
height: F(g.value - 1) + i.pageSize.height
|
|
514
|
+
} : ye([...ut.value.map((e) => ve(e)), ...i.backgroundImage && i.backgroundImageBox ? [i.backgroundImageBox] : []]);
|
|
515
515
|
if (!n) {
|
|
516
|
-
|
|
516
|
+
A.value = {
|
|
517
517
|
x: e / 2,
|
|
518
518
|
y: t / 2,
|
|
519
519
|
zoom: 1
|
|
520
520
|
};
|
|
521
521
|
return;
|
|
522
522
|
}
|
|
523
|
-
let r =
|
|
524
|
-
|
|
523
|
+
let r = vt(I.value ? Math.min((e - 48) / n.width, 1.5) : Math.min((e - 48) / n.width, (t - 48) / n.height, 2));
|
|
524
|
+
A.value = {
|
|
525
525
|
zoom: r,
|
|
526
526
|
x: (e - n.width * r) / 2 - n.x * r,
|
|
527
|
-
y:
|
|
527
|
+
y: I.value ? 24 : (t - n.height * r) / 2 - n.y * r
|
|
528
528
|
};
|
|
529
529
|
}
|
|
530
|
-
let
|
|
530
|
+
let G = T(null), K = /* @__PURE__ */ new Map(), q = null, St = S(!1), Ct = S(!1), wt = c(() => i.penOnly === !0 || i.penOnly === "auto" && St.value), J = T(null), Y = T(null), Tt = (e) => e === "pen" || e === "brush" || e === "marker" || e === "highlighter", Et = (e) => e === "line" || e === "arrow" || e === "rect" || e === "ellipse", Dt = (e) => i.pressure && e.pointerType === "pen" && e.pressure > 0 ? e.pressure : .5;
|
|
531
531
|
function Ot(e) {
|
|
532
|
-
let t =
|
|
533
|
-
return !(e.pen && i.pressure) &&
|
|
532
|
+
let t = o.value, n = e.points;
|
|
533
|
+
return !(e.pen && i.pressure) && ue[t].thinning > 0 && (n = fe(n, p.value)), n = de(n, i.smoothing, p.value).map(([e, t, n]) => [
|
|
534
534
|
Math.round(e * 100) / 100,
|
|
535
535
|
Math.round(t * 100) / 100,
|
|
536
536
|
Math.round(n * 100) / 100
|
|
@@ -538,96 +538,96 @@ var De = ["aria-label"], Oe = [
|
|
|
538
538
|
id: "live",
|
|
539
539
|
type: "stroke",
|
|
540
540
|
pen: t,
|
|
541
|
-
color:
|
|
541
|
+
color: l.value,
|
|
542
542
|
size: p.value,
|
|
543
543
|
points: n,
|
|
544
|
-
layer:
|
|
544
|
+
layer: st.value,
|
|
545
545
|
page: e.page
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
548
|
function kt() {
|
|
549
|
-
let [e, t] = [...
|
|
549
|
+
let [e, t] = [...K.values()];
|
|
550
550
|
if (!e || !t) return;
|
|
551
|
-
let n =
|
|
552
|
-
|
|
551
|
+
let n = N.value.getBoundingClientRect();
|
|
552
|
+
q = {
|
|
553
553
|
d: Math.hypot(e.x - t.x, e.y - t.y) || 1,
|
|
554
554
|
mx: (e.x + t.x) / 2 - n.left,
|
|
555
555
|
my: (e.y + t.y) / 2 - n.top,
|
|
556
|
-
vp: { ...
|
|
557
|
-
},
|
|
556
|
+
vp: { ...U.value }
|
|
557
|
+
}, G.value = {
|
|
558
558
|
kind: "pinch",
|
|
559
|
-
ids: [...
|
|
559
|
+
ids: [...K.keys()].slice(0, 2)
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
|
-
let At = (e) => e.target ===
|
|
562
|
+
let At = (e) => e.target === N.value || !!_e.value?.contains(e.target);
|
|
563
563
|
function jt(e) {
|
|
564
564
|
if (!At(e)) return;
|
|
565
|
-
|
|
565
|
+
N.value.focus({ preventScroll: !0 }), e.pointerType === "touch" && K.set(e.pointerId, {
|
|
566
566
|
x: e.clientX,
|
|
567
567
|
y: e.clientY
|
|
568
|
-
}), e.pointerType === "pen" && (
|
|
569
|
-
let t =
|
|
570
|
-
if (e.pointerType === "touch" &&
|
|
571
|
-
t?.kind === "erase" && (
|
|
568
|
+
}), e.pointerType === "pen" && (St.value = !0);
|
|
569
|
+
let t = G.value;
|
|
570
|
+
if (e.pointerType === "touch" && K.size === 2 && (!t || t.kind === "pan" || t.kind === "draw" && t.touch || t.kind === "lasso" || t.kind === "shape" || t.kind === "erase")) {
|
|
571
|
+
t?.kind === "erase" && (L.value = null), J.value = null, Y.value = null, kt();
|
|
572
572
|
return;
|
|
573
573
|
}
|
|
574
574
|
if (t) return;
|
|
575
575
|
try {
|
|
576
|
-
|
|
576
|
+
N.value.setPointerCapture(e.pointerId);
|
|
577
577
|
} catch {}
|
|
578
|
-
let n =
|
|
579
|
-
if (e.button === 1 ||
|
|
580
|
-
|
|
578
|
+
let n = W(e);
|
|
579
|
+
if (e.button === 1 || Ct.value || o.value === "pan" || i.readonly || e.pointerType === "touch" && wt.value) {
|
|
580
|
+
G.value = {
|
|
581
581
|
kind: "pan",
|
|
582
582
|
id: e.pointerId,
|
|
583
583
|
sx: e.clientX,
|
|
584
584
|
sy: e.clientY,
|
|
585
|
-
vx:
|
|
586
|
-
vy:
|
|
585
|
+
vx: U.value.x,
|
|
586
|
+
vy: U.value.y
|
|
587
587
|
};
|
|
588
588
|
return;
|
|
589
589
|
}
|
|
590
590
|
if (e.button !== 0 && (e.pointerType !== "pen" || e.button !== 5)) return;
|
|
591
|
-
let r = e.pointerType === "pen" && (e.button === 5 || e.buttons & 32) ? "eraser" :
|
|
591
|
+
let r = e.pointerType === "pen" && (e.button === 5 || e.buttons & 32) ? "eraser" : o.value;
|
|
592
592
|
if (r === "eraser" || r === "stroke-eraser") {
|
|
593
|
-
|
|
593
|
+
G.value = {
|
|
594
594
|
kind: "erase",
|
|
595
595
|
id: e.pointerId,
|
|
596
596
|
whole: r === "stroke-eraser",
|
|
597
597
|
last: n
|
|
598
|
-
},
|
|
598
|
+
}, L.value = a.value, Pt(n);
|
|
599
599
|
return;
|
|
600
600
|
}
|
|
601
|
-
let
|
|
602
|
-
if (Tt(r))
|
|
601
|
+
let s = ht(n.y), c = gt(n, s);
|
|
602
|
+
if (Tt(r)) G.value = {
|
|
603
603
|
kind: "draw",
|
|
604
604
|
id: e.pointerId,
|
|
605
|
-
page:
|
|
605
|
+
page: s,
|
|
606
606
|
points: [[
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
c.x,
|
|
608
|
+
c.y,
|
|
609
609
|
Dt(e)
|
|
610
610
|
]],
|
|
611
611
|
pen: e.pointerType === "pen",
|
|
612
612
|
touch: e.pointerType === "touch",
|
|
613
613
|
started: performance.now()
|
|
614
|
-
},
|
|
615
|
-
else if (Et(r))
|
|
614
|
+
}, J.value = Ot(G.value);
|
|
615
|
+
else if (Et(r)) G.value = {
|
|
616
616
|
kind: "shape",
|
|
617
617
|
id: e.pointerId,
|
|
618
|
-
page:
|
|
618
|
+
page: s,
|
|
619
619
|
shape: r,
|
|
620
|
-
from: [
|
|
621
|
-
to: [
|
|
620
|
+
from: [c.x, c.y],
|
|
621
|
+
to: [c.x, c.y]
|
|
622
622
|
};
|
|
623
623
|
else if (r === "text") {
|
|
624
624
|
let t = Ft(n, (e) => e.type === "text");
|
|
625
|
-
t ? Ut(t) : Ht(
|
|
625
|
+
t ? Ut(t) : Ht(c, s), e.preventDefault();
|
|
626
626
|
} else if (r === "select") {
|
|
627
627
|
let t = Bt(n);
|
|
628
628
|
if (t) {
|
|
629
629
|
let r = X.value, i = t.includes("l") ? r.x + r.width : r.x, o = t.includes("t") ? r.y + r.height : r.y;
|
|
630
|
-
|
|
630
|
+
G.value = {
|
|
631
631
|
kind: "scale",
|
|
632
632
|
id: e.pointerId,
|
|
633
633
|
origin: {
|
|
@@ -635,39 +635,39 @@ var De = ["aria-label"], Oe = [
|
|
|
635
635
|
y: o
|
|
636
636
|
},
|
|
637
637
|
from: n
|
|
638
|
-
},
|
|
638
|
+
}, L.value = a.value;
|
|
639
639
|
return;
|
|
640
640
|
}
|
|
641
641
|
let r = Ft(n), i = X.value && n.x >= X.value.x && n.x <= X.value.x + X.value.width && n.y >= X.value.y && n.y <= X.value.y + X.value.height;
|
|
642
|
-
if (r && !
|
|
643
|
-
|
|
642
|
+
if (r && !y.value.includes(r.id) && !i && (y.value = e.shiftKey ? [...y.value, r.id] : [r.id]), r || i) {
|
|
643
|
+
G.value = {
|
|
644
644
|
kind: "move",
|
|
645
645
|
id: e.pointerId,
|
|
646
646
|
from: n,
|
|
647
647
|
moved: !1
|
|
648
|
-
},
|
|
648
|
+
}, L.value = a.value;
|
|
649
649
|
return;
|
|
650
650
|
}
|
|
651
|
-
|
|
651
|
+
G.value = {
|
|
652
652
|
kind: "lasso",
|
|
653
653
|
id: e.pointerId,
|
|
654
654
|
points: [[n.x, n.y]],
|
|
655
655
|
add: e.shiftKey
|
|
656
|
-
},
|
|
656
|
+
}, Y.value = [[n.x, n.y]];
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
function Mt(e) {
|
|
660
|
-
e.pointerType === "touch" &&
|
|
660
|
+
e.pointerType === "touch" && K.has(e.pointerId) && K.set(e.pointerId, {
|
|
661
661
|
x: e.clientX,
|
|
662
662
|
y: e.clientY
|
|
663
663
|
});
|
|
664
|
-
let t =
|
|
664
|
+
let t = G.value;
|
|
665
665
|
if (!t) return;
|
|
666
666
|
if (t.kind === "pinch") {
|
|
667
|
-
let [e, n] = t.ids.map((e) =>
|
|
668
|
-
if (!e || !n || !
|
|
669
|
-
let r =
|
|
670
|
-
|
|
667
|
+
let [e, n] = t.ids.map((e) => K.get(e));
|
|
668
|
+
if (!e || !n || !q) return;
|
|
669
|
+
let r = N.value.getBoundingClientRect(), i = Math.hypot(e.x - n.x, e.y - n.y), a = (e.x + n.x) / 2 - r.left, o = (e.y + n.y) / 2 - r.top, s = vt(q.vp.zoom * (i / q.d)), c = (q.mx - q.vp.x) / q.vp.zoom, l = (q.my - q.vp.y) / q.vp.zoom;
|
|
670
|
+
A.value = {
|
|
671
671
|
zoom: s,
|
|
672
672
|
x: a - c * s,
|
|
673
673
|
y: o - l * s
|
|
@@ -676,8 +676,8 @@ var De = ["aria-label"], Oe = [
|
|
|
676
676
|
}
|
|
677
677
|
if ("id" in t && t.id !== e.pointerId) return;
|
|
678
678
|
if (t.kind === "pan") {
|
|
679
|
-
|
|
680
|
-
...
|
|
679
|
+
A.value = {
|
|
680
|
+
...U.value,
|
|
681
681
|
x: t.vx + e.clientX - t.sx,
|
|
682
682
|
y: t.vy + e.clientY - t.sy
|
|
683
683
|
};
|
|
@@ -686,21 +686,21 @@ var De = ["aria-label"], Oe = [
|
|
|
686
686
|
let n = (e.getCoalescedEvents?.() ?? []).length ? e.getCoalescedEvents() : [e];
|
|
687
687
|
if (t.kind === "draw") {
|
|
688
688
|
for (let e of n) {
|
|
689
|
-
let n =
|
|
689
|
+
let n = gt(W(e), t.page);
|
|
690
690
|
t.points.push([
|
|
691
691
|
n.x,
|
|
692
692
|
n.y,
|
|
693
693
|
Dt(e)
|
|
694
694
|
]);
|
|
695
695
|
}
|
|
696
|
-
|
|
696
|
+
J.value = Ot(t);
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
|
-
let r =
|
|
699
|
+
let r = W(e);
|
|
700
700
|
if (t.kind === "erase") {
|
|
701
|
-
let e = i.eraserSize /
|
|
701
|
+
let e = i.eraserSize / U.value.zoom / 2;
|
|
702
702
|
for (let r of n) {
|
|
703
|
-
let n =
|
|
703
|
+
let n = W(r), i = Math.max(1, Math.ceil(Math.hypot(n.x - t.last.x, n.y - t.last.y) / e));
|
|
704
704
|
for (let e = 1; e <= i; e++) Pt({
|
|
705
705
|
x: t.last.x + (n.x - t.last.x) * e / i,
|
|
706
706
|
y: t.last.y + (n.y - t.last.y) * e / i
|
|
@@ -708,144 +708,144 @@ var De = ["aria-label"], Oe = [
|
|
|
708
708
|
t.last = n;
|
|
709
709
|
}
|
|
710
710
|
} else if (t.kind === "shape") {
|
|
711
|
-
let n =
|
|
712
|
-
t.to = e.shiftKey ?
|
|
711
|
+
let n = gt(r, t.page);
|
|
712
|
+
t.to = e.shiftKey ? he(t.shape, t.from, [n.x, n.y]) : [n.x, n.y], J.value = {
|
|
713
713
|
id: "live",
|
|
714
714
|
type: "shape",
|
|
715
715
|
shape: t.shape,
|
|
716
716
|
from: t.from,
|
|
717
717
|
to: t.to,
|
|
718
|
-
color:
|
|
718
|
+
color: l.value,
|
|
719
719
|
size: p.value,
|
|
720
|
-
fill: m.value ?
|
|
721
|
-
layer:
|
|
720
|
+
fill: m.value ? l.value : null,
|
|
721
|
+
layer: st.value,
|
|
722
722
|
page: t.page
|
|
723
723
|
};
|
|
724
|
-
} else if (t.kind === "lasso") t.points.push([r.x, r.y]),
|
|
724
|
+
} else if (t.kind === "lasso") t.points.push([r.x, r.y]), Y.value = t.points.slice();
|
|
725
725
|
else if (t.kind === "move") {
|
|
726
726
|
let e = r.x - t.from.x, n = r.y - t.from.y;
|
|
727
|
-
if (!t.moved && Math.hypot(e, n) *
|
|
727
|
+
if (!t.moved && Math.hypot(e, n) * U.value.zoom < 3) return;
|
|
728
728
|
t.moved = !0;
|
|
729
|
-
let i = new Set(
|
|
730
|
-
|
|
729
|
+
let i = new Set(y.value);
|
|
730
|
+
L.value = a.value.map((t) => i.has(t.id) ? Ce(t, {
|
|
731
731
|
dx: e,
|
|
732
732
|
dy: n
|
|
733
733
|
}) : t);
|
|
734
734
|
} else if (t.kind === "scale") {
|
|
735
|
-
let e = Math.hypot(t.from.x - t.origin.x, t.from.y - t.origin.y) || 1, n = Math.max(.05, Math.hypot(r.x - t.origin.x, r.y - t.origin.y) / e), i = new Set(
|
|
736
|
-
|
|
735
|
+
let e = Math.hypot(t.from.x - t.origin.x, t.from.y - t.origin.y) || 1, n = Math.max(.05, Math.hypot(r.x - t.origin.x, r.y - t.origin.y) / e), i = new Set(y.value);
|
|
736
|
+
L.value = a.value.map((e) => i.has(e.id) ? Ce(e, {
|
|
737
737
|
sx: n,
|
|
738
738
|
sy: n,
|
|
739
739
|
ox: t.origin.x,
|
|
740
|
-
oy: t.origin.y -
|
|
740
|
+
oy: t.origin.y - _t(e)
|
|
741
741
|
}) : e);
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
function Nt(e) {
|
|
745
|
-
|
|
746
|
-
let t =
|
|
745
|
+
K.delete(e.pointerId);
|
|
746
|
+
let t = G.value;
|
|
747
747
|
if (!t) return;
|
|
748
748
|
if (t.kind === "pinch") {
|
|
749
749
|
if (!t.ids.includes(e.pointerId)) return;
|
|
750
|
-
|
|
751
|
-
let [n, r] = [...
|
|
752
|
-
n !== void 0 && r && (
|
|
750
|
+
G.value = null, q = null;
|
|
751
|
+
let [n, r] = [...K.entries()][0] ?? [];
|
|
752
|
+
n !== void 0 && r && (G.value = {
|
|
753
753
|
kind: "pan",
|
|
754
754
|
id: n,
|
|
755
755
|
sx: r.x,
|
|
756
756
|
sy: r.y,
|
|
757
|
-
vx:
|
|
758
|
-
vy:
|
|
757
|
+
vx: U.value.x,
|
|
758
|
+
vy: U.value.y
|
|
759
759
|
});
|
|
760
760
|
return;
|
|
761
761
|
}
|
|
762
762
|
if (t.id !== e.pointerId) return;
|
|
763
|
-
|
|
763
|
+
G.value = null;
|
|
764
764
|
let n = e.type === "pointercancel";
|
|
765
765
|
if (t.kind === "draw") {
|
|
766
766
|
let e = Ot(t);
|
|
767
|
-
|
|
767
|
+
J.value = null, n || H([...a.value, {
|
|
768
768
|
...e,
|
|
769
|
-
id:
|
|
769
|
+
id: le()
|
|
770
770
|
}]);
|
|
771
771
|
} else if (t.kind === "shape") {
|
|
772
|
-
let e =
|
|
773
|
-
|
|
772
|
+
let e = J.value;
|
|
773
|
+
J.value = null, e && !n && Math.hypot(t.to[0] - t.from[0], t.to[1] - t.from[1]) > 2 && H([...a.value, {
|
|
774
774
|
...e,
|
|
775
|
-
id:
|
|
775
|
+
id: le()
|
|
776
776
|
}]);
|
|
777
777
|
} else if (t.kind === "erase" || t.kind === "move" || t.kind === "scale") {
|
|
778
|
-
let r =
|
|
779
|
-
if (
|
|
780
|
-
let t = Ft(
|
|
781
|
-
|
|
778
|
+
let r = L.value;
|
|
779
|
+
if (L.value = null, r && r !== a.value && !n && (t.kind !== "move" || t.moved) && H(r), t.kind === "move" && !t.moved && !e.shiftKey) {
|
|
780
|
+
let t = Ft(W(e));
|
|
781
|
+
y.value = t ? [t.id] : [];
|
|
782
782
|
}
|
|
783
783
|
} else if (t.kind === "lasso") {
|
|
784
784
|
let e = t.points;
|
|
785
|
-
if (
|
|
786
|
-
t.add || (
|
|
785
|
+
if (Y.value = null, e.length < 3) {
|
|
786
|
+
t.add || (y.value = []);
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
|
-
let n =
|
|
790
|
-
|
|
789
|
+
let n = R.value.filter((t) => z(t) && Se(t, e.map(([e, n]) => [e, n - _t(t)]))).map((e) => e.id);
|
|
790
|
+
y.value = t.add ? [.../* @__PURE__ */ new Set([...y.value, ...n])] : n;
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
793
|
function Pt(e) {
|
|
794
|
-
let t = i.eraserSize /
|
|
795
|
-
for (let n of
|
|
796
|
-
if (!
|
|
794
|
+
let t = i.eraserSize / U.value.zoom, n = G.value, r = n?.kind === "erase" && n.whole, o = !1, s = [];
|
|
795
|
+
for (let n of L.value ?? a.value) {
|
|
796
|
+
if (!z(n)) {
|
|
797
797
|
s.push(n);
|
|
798
798
|
continue;
|
|
799
799
|
}
|
|
800
|
-
let i = e.x, a = e.y -
|
|
800
|
+
let i = e.x, a = e.y - _t(n);
|
|
801
801
|
if (r) {
|
|
802
|
-
|
|
802
|
+
be(n, i, a, t) ? o = !0 : s.push(n);
|
|
803
803
|
continue;
|
|
804
804
|
}
|
|
805
|
-
let c =
|
|
805
|
+
let c = xe(n, i, a, t);
|
|
806
806
|
(c.length !== 1 || c[0] !== n) && (o = !0), s.push(...c);
|
|
807
807
|
}
|
|
808
|
-
o && (
|
|
808
|
+
o && (L.value = s);
|
|
809
809
|
}
|
|
810
810
|
function Ft(e, t = () => !0) {
|
|
811
|
-
let n = 6 /
|
|
811
|
+
let n = 6 / U.value.zoom, r = ut.value;
|
|
812
812
|
for (let i = r.length - 1; i >= 0; i--) {
|
|
813
813
|
let a = r[i];
|
|
814
|
-
if (
|
|
814
|
+
if (z(a) && t(a) && be(a, e.x, e.y - _t(a), n)) return a;
|
|
815
815
|
}
|
|
816
816
|
return null;
|
|
817
817
|
}
|
|
818
818
|
function It(e) {
|
|
819
819
|
if (!At(e)) return;
|
|
820
820
|
e.preventDefault();
|
|
821
|
-
let t =
|
|
822
|
-
if (e.ctrlKey || e.metaKey)
|
|
821
|
+
let t = N.value.getBoundingClientRect();
|
|
822
|
+
if (e.ctrlKey || e.metaKey) yt(U.value.zoom * Math.exp(-e.deltaY * (e.deltaMode ? .05 : .01)), e.clientX - t.left, e.clientY - t.top);
|
|
823
823
|
else {
|
|
824
824
|
let t = e.deltaMode ? 16 : 1, n = e.shiftKey && !e.deltaX ? e.deltaY : e.deltaX, r = e.shiftKey && !e.deltaX ? 0 : e.deltaY;
|
|
825
|
-
|
|
826
|
-
...
|
|
827
|
-
x:
|
|
828
|
-
y:
|
|
825
|
+
A.value = {
|
|
826
|
+
...U.value,
|
|
827
|
+
x: U.value.x - n * t,
|
|
828
|
+
y: U.value.y - r * t
|
|
829
829
|
};
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
function Lt(e) {
|
|
833
833
|
if (!At(e)) return;
|
|
834
834
|
let t = e.ctrlKey || e.metaKey;
|
|
835
|
-
t && e.key.toLowerCase() === "z" ? (e.preventDefault(), e.shiftKey ?
|
|
835
|
+
t && e.key.toLowerCase() === "z" ? (e.preventDefault(), e.shiftKey ? ft() : dt()) : t && e.key.toLowerCase() === "y" ? (e.preventDefault(), ft()) : t && e.key.toLowerCase() === "a" && !i.readonly ? (e.preventDefault(), o.value = "select", y.value = R.value.filter(z).map((e) => e.id)) : (e.key === "Delete" || e.key === "Backspace") && y.value.length ? (e.preventDefault(), mt()) : e.key === "Escape" ? y.value = [] : e.key === " " && !e.repeat && (e.preventDefault(), Ct.value = !0);
|
|
836
836
|
}
|
|
837
|
-
let Rt = (e) => e.key === " " && (
|
|
838
|
-
let e = new Set(
|
|
839
|
-
return
|
|
840
|
-
let t =
|
|
837
|
+
let Rt = (e) => e.key === " " && (Ct.value = !1), X = c(() => {
|
|
838
|
+
let e = new Set(y.value);
|
|
839
|
+
return ye(R.value.filter((t) => e.has(t.id)).map((e) => {
|
|
840
|
+
let t = ve(e);
|
|
841
841
|
return {
|
|
842
842
|
...t,
|
|
843
|
-
y: t.y +
|
|
843
|
+
y: t.y + _t(e)
|
|
844
844
|
};
|
|
845
845
|
}));
|
|
846
|
-
}), zt =
|
|
846
|
+
}), zt = c(() => {
|
|
847
847
|
let e = X.value;
|
|
848
|
-
return !e ||
|
|
848
|
+
return !e || o.value !== "select" ? [] : [
|
|
849
849
|
{
|
|
850
850
|
id: "tl",
|
|
851
851
|
x: e.x,
|
|
@@ -873,11 +873,11 @@ var De = ["aria-label"], Oe = [
|
|
|
873
873
|
];
|
|
874
874
|
});
|
|
875
875
|
function Bt(e) {
|
|
876
|
-
let t =
|
|
876
|
+
let t = ot * 1.2 / U.value.zoom;
|
|
877
877
|
return zt.value.find((n) => Math.abs(n.x - e.x) <= t && Math.abs(n.y - e.y) <= t)?.id;
|
|
878
878
|
}
|
|
879
|
-
|
|
880
|
-
let Z =
|
|
879
|
+
ae(o, (e) => e !== "select" && (y.value = []));
|
|
880
|
+
let Z = S(null), Vt = S();
|
|
881
881
|
function Ht(e, t) {
|
|
882
882
|
if (Z.value) return Wt();
|
|
883
883
|
let n = Math.max(12, p.value * 4);
|
|
@@ -887,7 +887,7 @@ var De = ["aria-label"], Oe = [
|
|
|
887
887
|
page: t,
|
|
888
888
|
text: "",
|
|
889
889
|
size: n,
|
|
890
|
-
color:
|
|
890
|
+
color: l.value
|
|
891
891
|
}, v(() => Vt.value?.focus());
|
|
892
892
|
}
|
|
893
893
|
function Ut(e) {
|
|
@@ -910,129 +910,129 @@ var De = ["aria-label"], Oe = [
|
|
|
910
910
|
if (e.id) {
|
|
911
911
|
let n = a.value.find((t) => t.id === e.id);
|
|
912
912
|
if (!n) return;
|
|
913
|
-
t ? n.type === "text" && n.text !== t &&
|
|
913
|
+
t ? n.type === "text" && n.text !== t && H(a.value.map((n) => n.id === e.id ? {
|
|
914
914
|
...n,
|
|
915
915
|
text: t
|
|
916
|
-
} : n)) :
|
|
917
|
-
} else t &&
|
|
918
|
-
id:
|
|
916
|
+
} : n)) : H(a.value.filter((t) => t.id !== e.id));
|
|
917
|
+
} else t && H([...a.value, {
|
|
918
|
+
id: le(),
|
|
919
919
|
type: "text",
|
|
920
920
|
at: e.at,
|
|
921
921
|
text: t,
|
|
922
922
|
size: e.size,
|
|
923
923
|
color: e.color,
|
|
924
|
-
layer:
|
|
924
|
+
layer: st.value,
|
|
925
925
|
page: e.page
|
|
926
926
|
}]);
|
|
927
927
|
}
|
|
928
|
-
let Gt =
|
|
928
|
+
let Gt = c(() => {
|
|
929
929
|
let e = Z.value;
|
|
930
930
|
if (!e) return {};
|
|
931
|
-
let t =
|
|
931
|
+
let t = U.value.zoom, n = e.page === void 0 ? 0 : F(e.page), r = e.text.split("\n");
|
|
932
932
|
return {
|
|
933
|
-
left: `${e.at[0] * t +
|
|
934
|
-
top: `${(e.at[1] + n) * t +
|
|
933
|
+
left: `${e.at[0] * t + U.value.x}px`,
|
|
934
|
+
top: `${(e.at[1] + n) * t + U.value.y}px`,
|
|
935
935
|
fontSize: `${e.size * t}px`,
|
|
936
|
-
lineHeight: String(
|
|
936
|
+
lineHeight: String(ge),
|
|
937
937
|
color: e.color,
|
|
938
938
|
width: `${Math.max(4, ...r.map((e) => e.length + 1)) * .6}em`,
|
|
939
|
-
height: `${r.length *
|
|
939
|
+
height: `${r.length * ge}em`
|
|
940
940
|
};
|
|
941
941
|
});
|
|
942
942
|
function Kt(e) {
|
|
943
|
-
if (
|
|
944
|
-
let t = Ft(
|
|
943
|
+
if (o.value !== "select" || i.readonly) return;
|
|
944
|
+
let t = Ft(W(e), (e) => e.type === "text");
|
|
945
945
|
t && Ut(t);
|
|
946
946
|
}
|
|
947
947
|
let qt = /* @__PURE__ */ new WeakMap();
|
|
948
948
|
function Jt(e) {
|
|
949
949
|
let t = qt.get(e);
|
|
950
|
-
return t || (t = e.type === "stroke" ? { d:
|
|
950
|
+
return t || (t = e.type === "stroke" ? { d: pe(e) } : e.type === "shape" ? me(e) : { d: "" }, qt.set(e, t)), t;
|
|
951
951
|
}
|
|
952
|
-
let Yt =
|
|
953
|
-
let e =
|
|
952
|
+
let Yt = c(() => Z.value?.id), Xt = c(() => I.value ? Array.from({ length: Math.max(1, g.value) }, (e, t) => t) : [void 0]), Zt = (e) => ut.value.filter((t) => (e === void 0 || (t.page ?? 0) === e) && t.id !== Yt.value), Qt = c(() => {
|
|
953
|
+
let e = U.value.zoom;
|
|
954
954
|
return {
|
|
955
|
-
x: -
|
|
956
|
-
y: -
|
|
957
|
-
width:
|
|
958
|
-
height:
|
|
955
|
+
x: -U.value.x / e,
|
|
956
|
+
y: -U.value.y / e,
|
|
957
|
+
width: P.value.width / e,
|
|
958
|
+
height: P.value.height / e
|
|
959
959
|
};
|
|
960
|
-
}), Q = `m3d${
|
|
960
|
+
}), Q = `m3d${D().replace(/[^a-zA-Z0-9-]/g, "")}`, $ = c(() => i.backgroundSize), $t = c(() => G.value?.kind === "pan" || G.value?.kind === "pinch" ? "grabbing" : Ct.value || o.value === "pan" || i.readonly ? "grab" : o.value === "text" ? "text" : o.value === "select" ? "default" : "crosshair"), en = c(() => h.value.filter((e) => e.visible === !1).map((e) => e.id));
|
|
961
961
|
function tn(e = {}) {
|
|
962
|
-
let t =
|
|
963
|
-
return
|
|
962
|
+
let t = N.value ? getComputedStyle(N.value).fontFamily : "sans-serif", n = I.value ? e.page ?? 0 : void 0;
|
|
963
|
+
return Te(a.value, {
|
|
964
964
|
page: n,
|
|
965
|
-
box:
|
|
965
|
+
box: I.value ? {
|
|
966
966
|
x: 0,
|
|
967
967
|
y: 0,
|
|
968
968
|
...i.pageSize
|
|
969
969
|
} : void 0,
|
|
970
970
|
background: e.background === !1 ? void 0 : i.paper,
|
|
971
971
|
hiddenLayers: en.value,
|
|
972
|
-
layers:
|
|
972
|
+
layers: Oe.value,
|
|
973
973
|
fontFamily: t
|
|
974
974
|
});
|
|
975
975
|
}
|
|
976
|
-
let nn = (e = {}) =>
|
|
977
|
-
return
|
|
978
|
-
let e =
|
|
976
|
+
let nn = (e = {}) => Ee(tn(e), e.scale ?? 2), rn = null;
|
|
977
|
+
return ne(() => {
|
|
978
|
+
let e = N.value;
|
|
979
979
|
e.addEventListener("wheel", It, { passive: !1 });
|
|
980
|
-
let t = () =>
|
|
980
|
+
let t = () => P.value = {
|
|
981
981
|
width: e.clientWidth,
|
|
982
982
|
height: e.clientHeight
|
|
983
983
|
};
|
|
984
984
|
t(), rn = new ResizeObserver(t), rn.observe(e);
|
|
985
|
-
let n =
|
|
986
|
-
n.x === 0 && n.y === 0 && n.zoom === 1 &&
|
|
987
|
-
}),
|
|
988
|
-
rn?.disconnect(),
|
|
989
|
-
}),
|
|
990
|
-
tool:
|
|
991
|
-
color:
|
|
985
|
+
let n = A.value;
|
|
986
|
+
n.x === 0 && n.y === 0 && n.zoom === 1 && xt();
|
|
987
|
+
}), te(() => {
|
|
988
|
+
rn?.disconnect(), N.value?.removeEventListener("wheel", It);
|
|
989
|
+
}), re(De, {
|
|
990
|
+
tool: o,
|
|
991
|
+
color: l,
|
|
992
992
|
size: p,
|
|
993
993
|
fill: m,
|
|
994
|
-
items:
|
|
995
|
-
selection:
|
|
996
|
-
layers:
|
|
994
|
+
items: c(() => a.value),
|
|
995
|
+
selection: y,
|
|
996
|
+
layers: c(() => h.value),
|
|
997
997
|
setLayers: (e) => h.value = e,
|
|
998
|
-
layer:
|
|
999
|
-
get: () =>
|
|
1000
|
-
set: (e) =>
|
|
998
|
+
layer: c({
|
|
999
|
+
get: () => st.value,
|
|
1000
|
+
set: (e) => ee.value = e
|
|
1001
1001
|
}),
|
|
1002
|
-
mode:
|
|
1003
|
-
pages:
|
|
1004
|
-
addPage: () =>
|
|
1005
|
-
zoom:
|
|
1006
|
-
zoomIn: () =>
|
|
1007
|
-
zoomOut: () =>
|
|
1008
|
-
fitView:
|
|
1009
|
-
canUndo:
|
|
1010
|
-
canRedo:
|
|
1011
|
-
undo:
|
|
1012
|
-
redo:
|
|
1013
|
-
clear:
|
|
1014
|
-
deleteSelection:
|
|
1002
|
+
mode: c(() => i.mode),
|
|
1003
|
+
pages: g,
|
|
1004
|
+
addPage: () => g.value += 1,
|
|
1005
|
+
zoom: c(() => U.value.zoom),
|
|
1006
|
+
zoomIn: () => bt(1.25),
|
|
1007
|
+
zoomOut: () => bt(.8),
|
|
1008
|
+
fitView: xt,
|
|
1009
|
+
canUndo: c(() => B.value.length > 0),
|
|
1010
|
+
canRedo: c(() => V.value.length > 0),
|
|
1011
|
+
undo: dt,
|
|
1012
|
+
redo: ft,
|
|
1013
|
+
clear: pt,
|
|
1014
|
+
deleteSelection: mt,
|
|
1015
1015
|
exportSvg: tn,
|
|
1016
1016
|
exportPng: nn
|
|
1017
1017
|
}), n({
|
|
1018
|
-
undo:
|
|
1019
|
-
redo:
|
|
1020
|
-
clear:
|
|
1021
|
-
deleteSelection:
|
|
1022
|
-
fitView:
|
|
1023
|
-
zoomIn: () =>
|
|
1024
|
-
zoomOut: () =>
|
|
1018
|
+
undo: dt,
|
|
1019
|
+
redo: ft,
|
|
1020
|
+
clear: pt,
|
|
1021
|
+
deleteSelection: mt,
|
|
1022
|
+
fitView: xt,
|
|
1023
|
+
zoomIn: () => bt(1.25),
|
|
1024
|
+
zoomOut: () => bt(.8),
|
|
1025
1025
|
exportSvg: tn,
|
|
1026
1026
|
exportPng: nn,
|
|
1027
|
-
toContent:
|
|
1028
|
-
}), (e, n) => (
|
|
1027
|
+
toContent: W
|
|
1028
|
+
}), (e, n) => (x(), d("div", {
|
|
1029
1029
|
ref_key: "root",
|
|
1030
|
-
ref:
|
|
1030
|
+
ref: N,
|
|
1031
1031
|
class: "m3-draw-canvas outline-none select-none [touch-action:none]",
|
|
1032
1032
|
style: b({ cursor: $t.value }),
|
|
1033
1033
|
tabindex: "0",
|
|
1034
1034
|
role: "application",
|
|
1035
|
-
"aria-label": t.label ??
|
|
1035
|
+
"aria-label": t.label ?? E(M).drawCanvas,
|
|
1036
1036
|
onPointerdown: jt,
|
|
1037
1037
|
onPointermove: Mt,
|
|
1038
1038
|
onPointerup: Nt,
|
|
@@ -1041,81 +1041,81 @@ var De = ["aria-label"], Oe = [
|
|
|
1041
1041
|
onDblclick: Kt,
|
|
1042
1042
|
onKeydown: Lt,
|
|
1043
1043
|
onKeyup: Rt,
|
|
1044
|
-
onContextmenu: n[2] ||=
|
|
1044
|
+
onContextmenu: n[2] ||= se(() => {}, ["prevent"])
|
|
1045
1045
|
}, [
|
|
1046
|
-
(
|
|
1046
|
+
(x(), d("svg", {
|
|
1047
1047
|
ref_key: "svgEl",
|
|
1048
1048
|
ref: _e,
|
|
1049
1049
|
class: "absolute inset-0 size-full",
|
|
1050
1050
|
"aria-hidden": "true"
|
|
1051
|
-
}, [
|
|
1052
|
-
|
|
1051
|
+
}, [f("defs", null, [
|
|
1052
|
+
f("pattern", {
|
|
1053
1053
|
id: `${Q}-grid`,
|
|
1054
1054
|
width: $.value,
|
|
1055
1055
|
height: $.value,
|
|
1056
1056
|
patternUnits: "userSpaceOnUse"
|
|
1057
|
-
}, [
|
|
1057
|
+
}, [f("path", {
|
|
1058
1058
|
d: `M${$.value} 0H0V${$.value}`,
|
|
1059
1059
|
fill: "none",
|
|
1060
1060
|
stroke: "rgba(0,0,0,.12)",
|
|
1061
|
-
"stroke-width": 1 /
|
|
1062
|
-
}, null, 8,
|
|
1063
|
-
|
|
1061
|
+
"stroke-width": 1 / U.value.zoom
|
|
1062
|
+
}, null, 8, je)], 8, Ae),
|
|
1063
|
+
f("pattern", {
|
|
1064
1064
|
id: `${Q}-dots`,
|
|
1065
1065
|
width: $.value,
|
|
1066
1066
|
height: $.value,
|
|
1067
1067
|
patternUnits: "userSpaceOnUse"
|
|
1068
|
-
}, [
|
|
1068
|
+
}, [f("circle", {
|
|
1069
1069
|
cx: $.value / 2,
|
|
1070
1070
|
cy: $.value / 2,
|
|
1071
|
-
r: Math.max(.8, 1.2 /
|
|
1071
|
+
r: Math.max(.8, 1.2 / U.value.zoom),
|
|
1072
1072
|
fill: "rgba(0,0,0,.22)"
|
|
1073
|
-
}, null, 8,
|
|
1074
|
-
|
|
1073
|
+
}, null, 8, Ne)], 8, Me),
|
|
1074
|
+
f("pattern", {
|
|
1075
1075
|
id: `${Q}-lines`,
|
|
1076
1076
|
width: $.value * 4,
|
|
1077
1077
|
height: $.value * 1.25,
|
|
1078
1078
|
patternUnits: "userSpaceOnUse"
|
|
1079
|
-
}, [
|
|
1079
|
+
}, [f("path", {
|
|
1080
1080
|
d: `M0 ${$.value * 1.25 - .5}H${$.value * 4}`,
|
|
1081
1081
|
fill: "none",
|
|
1082
1082
|
stroke: "rgba(30,90,200,.22)",
|
|
1083
|
-
"stroke-width": 1 /
|
|
1084
|
-
}, null, 8,
|
|
1085
|
-
(
|
|
1083
|
+
"stroke-width": 1 / U.value.zoom
|
|
1084
|
+
}, null, 8, Fe)], 8, Pe),
|
|
1085
|
+
(x(!0), d(s, null, C(I.value ? Xt.value : [], (e) => (x(), d("clipPath", {
|
|
1086
1086
|
id: `${Q}-page${e}`,
|
|
1087
1087
|
key: e ?? "x"
|
|
1088
|
-
}, [
|
|
1088
|
+
}, [f("rect", {
|
|
1089
1089
|
x: "0",
|
|
1090
1090
|
y: "0",
|
|
1091
1091
|
width: t.pageSize.width,
|
|
1092
1092
|
height: t.pageSize.height
|
|
1093
|
-
}, null, 8,
|
|
1094
|
-
]),
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
t.backgroundImage ? (
|
|
1093
|
+
}, null, 8, Le)], 8, Ie))), 128))
|
|
1094
|
+
]), f("g", { transform: `translate(${U.value.x} ${U.value.y}) scale(${U.value.zoom})` }, [
|
|
1095
|
+
I.value ? u("", !0) : (x(), d(s, { key: 0 }, [
|
|
1096
|
+
f("rect", _(Qt.value, { fill: t.paper }), null, 16, ze),
|
|
1097
|
+
t.backgroundImage ? (x(), d("image", _({
|
|
1098
1098
|
key: 0,
|
|
1099
1099
|
href: t.backgroundImage
|
|
1100
1100
|
}, t.backgroundImageBox ?? {
|
|
1101
1101
|
x: 0,
|
|
1102
1102
|
y: 0
|
|
1103
|
-
}, { preserveAspectRatio: "xMidYMid slice" }), null, 16,
|
|
1104
|
-
t.background === "none" ?
|
|
1103
|
+
}, { preserveAspectRatio: "xMidYMid slice" }), null, 16, Be)) : u("", !0),
|
|
1104
|
+
t.background === "none" ? u("", !0) : (x(), d("rect", _({ key: 1 }, Qt.value, { fill: `url(#${Q}-${t.background})` }), null, 16, Ve))
|
|
1105
1105
|
], 64)),
|
|
1106
|
-
(
|
|
1106
|
+
(x(!0), d(s, null, C(Xt.value, (e) => (x(), d("g", {
|
|
1107
1107
|
key: e ?? "all",
|
|
1108
|
-
transform: e === void 0 ? void 0 : `translate(0 ${
|
|
1109
|
-
}, [e === void 0 ?
|
|
1110
|
-
|
|
1108
|
+
transform: e === void 0 ? void 0 : `translate(0 ${F(e)})`
|
|
1109
|
+
}, [e === void 0 ? u("", !0) : (x(), d(s, { key: 0 }, [
|
|
1110
|
+
f("rect", {
|
|
1111
1111
|
x: "0",
|
|
1112
1112
|
y: "0",
|
|
1113
1113
|
width: t.pageSize.width,
|
|
1114
1114
|
height: t.pageSize.height,
|
|
1115
1115
|
fill: t.paper,
|
|
1116
1116
|
class: "m3-draw-page"
|
|
1117
|
-
}, null, 8,
|
|
1118
|
-
t.backgroundImage ? (
|
|
1117
|
+
}, null, 8, Ue),
|
|
1118
|
+
t.backgroundImage ? (x(), d("image", {
|
|
1119
1119
|
key: 0,
|
|
1120
1120
|
href: t.backgroundImage,
|
|
1121
1121
|
x: "0",
|
|
@@ -1123,88 +1123,88 @@ var De = ["aria-label"], Oe = [
|
|
|
1123
1123
|
width: t.pageSize.width,
|
|
1124
1124
|
height: t.pageSize.height,
|
|
1125
1125
|
preserveAspectRatio: "xMidYMid meet"
|
|
1126
|
-
}, null, 8,
|
|
1127
|
-
t.background === "none" ?
|
|
1126
|
+
}, null, 8, We)) : u("", !0),
|
|
1127
|
+
t.background === "none" ? u("", !0) : (x(), d("rect", {
|
|
1128
1128
|
key: 1,
|
|
1129
1129
|
x: "0",
|
|
1130
1130
|
y: "0",
|
|
1131
1131
|
width: t.pageSize.width,
|
|
1132
1132
|
height: t.pageSize.height,
|
|
1133
1133
|
fill: `url(#${Q}-${t.background})`
|
|
1134
|
-
}, null, 8,
|
|
1135
|
-
], 64)),
|
|
1134
|
+
}, null, 8, Ge))
|
|
1135
|
+
], 64)), f("g", { "clip-path": e === void 0 ? void 0 : `url(#${Q}-page${e})` }, [(x(!0), d(s, null, C(Zt(e), (e) => (x(), d(s, { key: e.id }, [e.type === "stroke" ? (x(), d("path", {
|
|
1136
1136
|
key: 0,
|
|
1137
1137
|
d: Jt(e).d,
|
|
1138
1138
|
fill: e.color,
|
|
1139
|
-
"fill-opacity":
|
|
1140
|
-
}, null, 8,
|
|
1139
|
+
"fill-opacity": E(ue)[e.pen].opacity
|
|
1140
|
+
}, null, 8, qe)) : e.type === "shape" ? (x(), d(s, { key: 1 }, [f("path", {
|
|
1141
1141
|
d: Jt(e).d,
|
|
1142
1142
|
fill: e.fill && (e.shape === "rect" || e.shape === "ellipse") ? e.fill : "none",
|
|
1143
1143
|
stroke: e.color,
|
|
1144
1144
|
"stroke-width": e.size,
|
|
1145
1145
|
"stroke-linecap": "round",
|
|
1146
1146
|
"stroke-linejoin": "round"
|
|
1147
|
-
}, null, 8,
|
|
1147
|
+
}, null, 8, Je), Jt(e).head ? (x(), d("path", {
|
|
1148
1148
|
key: 0,
|
|
1149
1149
|
d: Jt(e).head,
|
|
1150
1150
|
fill: e.color
|
|
1151
|
-
}, null, 8,
|
|
1151
|
+
}, null, 8, Ye)) : u("", !0)], 64)) : (x(), d("text", {
|
|
1152
1152
|
key: 2,
|
|
1153
1153
|
x: e.at[0],
|
|
1154
1154
|
y: e.at[1],
|
|
1155
1155
|
"font-size": e.size,
|
|
1156
1156
|
fill: e.color,
|
|
1157
1157
|
class: "m3-draw-text"
|
|
1158
|
-
}, [(
|
|
1158
|
+
}, [(x(!0), d(s, null, C(e.text.split("\n"), (t, n) => (x(), d("tspan", {
|
|
1159
1159
|
key: n,
|
|
1160
1160
|
x: e.at[0],
|
|
1161
|
-
dy: n ? e.size *
|
|
1162
|
-
},
|
|
1161
|
+
dy: n ? e.size * E(ge) : e.size * .95
|
|
1162
|
+
}, ie(t || " "), 9, Ze))), 128))], 8, Xe))], 64))), 128)), J.value && (e === void 0 || J.value.page === e) ? (x(), d(s, { key: 0 }, [J.value.type === "stroke" ? (x(), d("path", {
|
|
1163
1163
|
key: 0,
|
|
1164
|
-
d:
|
|
1165
|
-
fill:
|
|
1166
|
-
"fill-opacity":
|
|
1167
|
-
}, null, 8,
|
|
1168
|
-
d:
|
|
1169
|
-
fill:
|
|
1170
|
-
stroke:
|
|
1171
|
-
"stroke-width":
|
|
1164
|
+
d: E(pe)(J.value),
|
|
1165
|
+
fill: J.value.color,
|
|
1166
|
+
"fill-opacity": E(ue)[J.value.pen].opacity
|
|
1167
|
+
}, null, 8, Qe)) : J.value.type === "shape" ? (x(), d(s, { key: 1 }, [f("path", {
|
|
1168
|
+
d: E(me)(J.value).d,
|
|
1169
|
+
fill: J.value.fill && (J.value.shape === "rect" || J.value.shape === "ellipse") ? J.value.fill : "none",
|
|
1170
|
+
stroke: J.value.color,
|
|
1171
|
+
"stroke-width": J.value.size,
|
|
1172
1172
|
"stroke-linecap": "round",
|
|
1173
1173
|
"stroke-linejoin": "round"
|
|
1174
|
-
}, null, 8,
|
|
1174
|
+
}, null, 8, $e), E(me)(J.value).head ? (x(), d("path", {
|
|
1175
1175
|
key: 0,
|
|
1176
|
-
d:
|
|
1177
|
-
fill:
|
|
1178
|
-
}, null, 8,
|
|
1179
|
-
|
|
1176
|
+
d: E(me)(J.value).head,
|
|
1177
|
+
fill: J.value.color
|
|
1178
|
+
}, null, 8, et)) : u("", !0)], 64)) : u("", !0)], 64)) : u("", !0)], 8, Ke)], 8, He))), 128)),
|
|
1179
|
+
Y.value ? (x(), d("polygon", {
|
|
1180
1180
|
key: 1,
|
|
1181
|
-
points:
|
|
1181
|
+
points: Y.value.map((e) => e.join(",")).join(" "),
|
|
1182
1182
|
class: "fill-primary/8 stroke-primary",
|
|
1183
|
-
"stroke-width": 1.5 /
|
|
1184
|
-
"stroke-dasharray": `${4 /
|
|
1185
|
-
}, null, 8,
|
|
1186
|
-
X.value &&
|
|
1187
|
-
x: X.value.x - 4 /
|
|
1188
|
-
y: X.value.y - 4 /
|
|
1189
|
-
width: X.value.width + 8 /
|
|
1190
|
-
height: X.value.height + 8 /
|
|
1183
|
+
"stroke-width": 1.5 / U.value.zoom,
|
|
1184
|
+
"stroke-dasharray": `${4 / U.value.zoom} ${3 / U.value.zoom}`
|
|
1185
|
+
}, null, 8, tt)) : u("", !0),
|
|
1186
|
+
X.value && o.value === "select" ? (x(), d(s, { key: 2 }, [f("rect", {
|
|
1187
|
+
x: X.value.x - 4 / U.value.zoom,
|
|
1188
|
+
y: X.value.y - 4 / U.value.zoom,
|
|
1189
|
+
width: X.value.width + 8 / U.value.zoom,
|
|
1190
|
+
height: X.value.height + 8 / U.value.zoom,
|
|
1191
1191
|
fill: "none",
|
|
1192
1192
|
class: "stroke-primary",
|
|
1193
|
-
"stroke-width": 1.5 /
|
|
1194
|
-
"stroke-dasharray": `${5 /
|
|
1195
|
-
}, null, 8,
|
|
1193
|
+
"stroke-width": 1.5 / U.value.zoom,
|
|
1194
|
+
"stroke-dasharray": `${5 / U.value.zoom} ${4 / U.value.zoom}`
|
|
1195
|
+
}, null, 8, nt), (x(!0), d(s, null, C(zt.value, (e) => (x(), d("rect", {
|
|
1196
1196
|
key: e.id,
|
|
1197
|
-
x: e.x -
|
|
1198
|
-
y: e.y -
|
|
1199
|
-
width:
|
|
1200
|
-
height:
|
|
1201
|
-
rx: 2 /
|
|
1197
|
+
x: e.x - ot / 2 / U.value.zoom,
|
|
1198
|
+
y: e.y - ot / 2 / U.value.zoom,
|
|
1199
|
+
width: ot / U.value.zoom,
|
|
1200
|
+
height: ot / U.value.zoom,
|
|
1201
|
+
rx: 2 / U.value.zoom,
|
|
1202
1202
|
class: "fill-surface stroke-primary",
|
|
1203
|
-
"stroke-width": 1.5 /
|
|
1203
|
+
"stroke-width": 1.5 / U.value.zoom,
|
|
1204
1204
|
style: b({ cursor: e.cursor })
|
|
1205
|
-
}, null, 12,
|
|
1206
|
-
], 8,
|
|
1207
|
-
Z.value ?
|
|
1205
|
+
}, null, 12, rt))), 128))], 64)) : u("", !0)
|
|
1206
|
+
], 8, Re)], 512)),
|
|
1207
|
+
Z.value ? oe((x(), d("textarea", {
|
|
1208
1208
|
key: 0,
|
|
1209
1209
|
ref_key: "textarea",
|
|
1210
1210
|
ref: Vt,
|
|
@@ -1212,22 +1212,22 @@ var De = ["aria-label"], Oe = [
|
|
|
1212
1212
|
"data-draw-overlay": "",
|
|
1213
1213
|
class: "m3-draw-text absolute resize-none overflow-hidden border-0 bg-transparent p-0 whitespace-pre outline-1 outline-primary outline-dashed",
|
|
1214
1214
|
style: b(Gt.value),
|
|
1215
|
-
"aria-label":
|
|
1215
|
+
"aria-label": E(M).drawText,
|
|
1216
1216
|
spellcheck: "false",
|
|
1217
1217
|
onBlur: Wt,
|
|
1218
|
-
onKeydown: [
|
|
1219
|
-
}, null, 44,
|
|
1220
|
-
|
|
1221
|
-
], 44,
|
|
1218
|
+
onKeydown: [j(se(Wt, ["prevent"]), ["esc"]), n[1] ||= se(() => {}, ["stop"])]
|
|
1219
|
+
}, null, 44, it)), [[k, Z.value.text]]) : u("", !0),
|
|
1220
|
+
w(e.$slots, "default")
|
|
1221
|
+
], 44, ke));
|
|
1222
1222
|
}
|
|
1223
|
-
}),
|
|
1223
|
+
}), ct = ["aria-label"], lt = {
|
|
1224
1224
|
key: 1,
|
|
1225
1225
|
class: "flex items-center"
|
|
1226
|
-
},
|
|
1226
|
+
}, z = ["aria-label"], ut = [
|
|
1227
1227
|
"aria-label",
|
|
1228
1228
|
"aria-pressed",
|
|
1229
1229
|
"onClick"
|
|
1230
|
-
],
|
|
1230
|
+
], B = ["aria-label", "aria-pressed"], V = {
|
|
1231
1231
|
key: 0,
|
|
1232
1232
|
class: "material-symbols-outlined text-[16px] text-white drop-shadow",
|
|
1233
1233
|
"aria-hidden": "true"
|
|
@@ -1235,7 +1235,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1235
1235
|
"aria-label",
|
|
1236
1236
|
"aria-pressed",
|
|
1237
1237
|
"onClick"
|
|
1238
|
-
],
|
|
1238
|
+
], dt = /* @__PURE__ */ h({
|
|
1239
1239
|
__name: "MDrawToolbar",
|
|
1240
1240
|
props: {
|
|
1241
1241
|
tools: { default: () => [
|
|
@@ -1278,10 +1278,10 @@ var De = ["aria-label"], Oe = [
|
|
|
1278
1278
|
default: !0
|
|
1279
1279
|
}
|
|
1280
1280
|
},
|
|
1281
|
-
setup(
|
|
1282
|
-
let
|
|
1283
|
-
if (!
|
|
1284
|
-
let
|
|
1281
|
+
setup(t) {
|
|
1282
|
+
let h = t, g = ee(De, null);
|
|
1283
|
+
if (!g) throw Error("MDrawToolbar must be inside <MDrawCanvas>");
|
|
1284
|
+
let _ = g, v = e(), te = {
|
|
1285
1285
|
select: {
|
|
1286
1286
|
icon: "arrow_selector_tool",
|
|
1287
1287
|
key: "drawSelect"
|
|
@@ -1334,7 +1334,7 @@ var De = ["aria-label"], Oe = [
|
|
|
1334
1334
|
icon: "text_fields",
|
|
1335
1335
|
key: "drawText"
|
|
1336
1336
|
}
|
|
1337
|
-
},
|
|
1337
|
+
}, ne = [
|
|
1338
1338
|
["select"],
|
|
1339
1339
|
["pan"],
|
|
1340
1340
|
[
|
|
@@ -1351,32 +1351,32 @@ var De = ["aria-label"], Oe = [
|
|
|
1351
1351
|
"ellipse"
|
|
1352
1352
|
],
|
|
1353
1353
|
["text"]
|
|
1354
|
-
],
|
|
1355
|
-
|
|
1356
|
-
let t =
|
|
1357
|
-
t >= 0 && (
|
|
1358
|
-
...
|
|
1354
|
+
], re = c(() => ne.map((e) => e.filter((e) => h.tools.includes(e))).filter((e) => e.length)), T = S({}), D = (e, t) => e.includes(_.tool.value) ? _.tool.value : T.value[t] ?? e[0];
|
|
1355
|
+
ae(_.tool, (e) => {
|
|
1356
|
+
let t = re.value.findIndex((t) => t.includes(e));
|
|
1357
|
+
t >= 0 && (T.value = {
|
|
1358
|
+
...T.value,
|
|
1359
1359
|
[t]: e
|
|
1360
1360
|
});
|
|
1361
1361
|
}, { immediate: !0 });
|
|
1362
|
-
let
|
|
1363
|
-
return (e,
|
|
1362
|
+
let O = c(() => ["rect", "ellipse"].includes(_.tool.value)), k = (e) => v[te[e].key], oe = S(!1), j = c(() => !h.colors.some((e) => e.toLowerCase() === _.color.value.toLowerCase()));
|
|
1363
|
+
return (e, c) => (x(), d("div", {
|
|
1364
1364
|
class: "m3-draw-toolbar flex max-w-[calc(100%-16px)] items-center gap-0.5 overflow-x-auto rounded-full bg-surface-container px-2 py-1 text-on-surface shadow-elevation-3 [scrollbar-width:none]",
|
|
1365
1365
|
role: "toolbar",
|
|
1366
|
-
"aria-label":
|
|
1366
|
+
"aria-label": E(v).drawTools
|
|
1367
1367
|
}, [
|
|
1368
|
-
|
|
1369
|
-
(
|
|
1368
|
+
w(e.$slots, "default"),
|
|
1369
|
+
(x(!0), d(s, null, C(re.value, (e, t) => (x(), d(s, { key: t }, [e.length === 1 ? (x(), l(a, {
|
|
1370
1370
|
key: 0,
|
|
1371
|
-
text:
|
|
1371
|
+
text: k(e[0]),
|
|
1372
1372
|
placement: "top"
|
|
1373
1373
|
}, {
|
|
1374
|
-
default: A(() => [
|
|
1375
|
-
icon:
|
|
1376
|
-
label:
|
|
1377
|
-
variant:
|
|
1378
|
-
"aria-pressed":
|
|
1379
|
-
onClick: (t) =>
|
|
1374
|
+
default: A(() => [m(n, {
|
|
1375
|
+
icon: te[e[0]].icon,
|
|
1376
|
+
label: k(e[0]),
|
|
1377
|
+
variant: E(_).tool.value === e[0] ? "filled" : "standard",
|
|
1378
|
+
"aria-pressed": E(_).tool.value === e[0],
|
|
1379
|
+
onClick: (t) => E(_).tool.value = e[0]
|
|
1380
1380
|
}, null, 8, [
|
|
1381
1381
|
"icon",
|
|
1382
1382
|
"label",
|
|
@@ -1385,16 +1385,16 @@ var De = ["aria-label"], Oe = [
|
|
|
1385
1385
|
"onClick"
|
|
1386
1386
|
])]),
|
|
1387
1387
|
_: 2
|
|
1388
|
-
}, 1032, ["text"])) : (
|
|
1389
|
-
text:
|
|
1388
|
+
}, 1032, ["text"])) : (x(), d("div", lt, [m(a, {
|
|
1389
|
+
text: k(D(e, t)),
|
|
1390
1390
|
placement: "top"
|
|
1391
1391
|
}, {
|
|
1392
|
-
default: A(() => [
|
|
1393
|
-
icon:
|
|
1394
|
-
label:
|
|
1395
|
-
variant: e.includes(
|
|
1396
|
-
"aria-pressed": e.includes(
|
|
1397
|
-
onClick: (
|
|
1392
|
+
default: A(() => [m(n, {
|
|
1393
|
+
icon: te[D(e, t)].icon,
|
|
1394
|
+
label: k(D(e, t)),
|
|
1395
|
+
variant: e.includes(E(_).tool.value) ? "filled" : "standard",
|
|
1396
|
+
"aria-pressed": e.includes(E(_).tool.value),
|
|
1397
|
+
onClick: (n) => E(_).tool.value = D(e, t)
|
|
1398
1398
|
}, null, 8, [
|
|
1399
1399
|
"icon",
|
|
1400
1400
|
"label",
|
|
@@ -1403,22 +1403,22 @@ var De = ["aria-label"], Oe = [
|
|
|
1403
1403
|
"onClick"
|
|
1404
1404
|
])]),
|
|
1405
1405
|
_: 2
|
|
1406
|
-
}, 1032, ["text"]),
|
|
1407
|
-
trigger: A(() => [
|
|
1406
|
+
}, 1032, ["text"]), m(r, null, {
|
|
1407
|
+
trigger: A(() => [f("button", {
|
|
1408
1408
|
type: "button",
|
|
1409
1409
|
class: "flex h-10 w-4 items-center justify-center rounded-full text-on-surface-variant hover:bg-on-surface/8",
|
|
1410
|
-
"aria-label":
|
|
1411
|
-
}, [...
|
|
1410
|
+
"aria-label": E(v).drawMore
|
|
1411
|
+
}, [...c[7] ||= [f("span", {
|
|
1412
1412
|
class: "material-symbols-outlined text-[18px]",
|
|
1413
1413
|
"aria-hidden": "true"
|
|
1414
|
-
}, "arrow_drop_down", -1)]], 8,
|
|
1415
|
-
default: A(() => [(
|
|
1414
|
+
}, "arrow_drop_down", -1)]], 8, z)]),
|
|
1415
|
+
default: A(() => [(x(!0), d(s, null, C(e, (e) => (x(), l(i, {
|
|
1416
1416
|
key: e,
|
|
1417
|
-
icon:
|
|
1418
|
-
selected:
|
|
1419
|
-
onClick: (t) =>
|
|
1417
|
+
icon: te[e].icon,
|
|
1418
|
+
selected: E(_).tool.value === e,
|
|
1419
|
+
onClick: (t) => E(_).tool.value = e
|
|
1420
1420
|
}, {
|
|
1421
|
-
default: A(() => [
|
|
1421
|
+
default: A(() => [p(ie(k(e)), 1)]),
|
|
1422
1422
|
_: 2
|
|
1423
1423
|
}, 1032, [
|
|
1424
1424
|
"icon",
|
|
@@ -1427,114 +1427,114 @@ var De = ["aria-label"], Oe = [
|
|
|
1427
1427
|
]))), 128))]),
|
|
1428
1428
|
_: 2
|
|
1429
1429
|
}, 1024)]))], 64))), 128)),
|
|
1430
|
-
|
|
1430
|
+
O.value ? (x(), l(a, {
|
|
1431
1431
|
key: 0,
|
|
1432
|
-
text:
|
|
1432
|
+
text: E(v).drawFill,
|
|
1433
1433
|
placement: "top"
|
|
1434
1434
|
}, {
|
|
1435
|
-
default: A(() => [
|
|
1435
|
+
default: A(() => [m(n, {
|
|
1436
1436
|
icon: "format_color_fill",
|
|
1437
|
-
label:
|
|
1438
|
-
variant:
|
|
1439
|
-
"aria-pressed":
|
|
1440
|
-
onClick:
|
|
1437
|
+
label: E(v).drawFill,
|
|
1438
|
+
variant: E(_).fill.value ? "tonal" : "standard",
|
|
1439
|
+
"aria-pressed": E(_).fill.value,
|
|
1440
|
+
onClick: c[0] ||= (e) => E(_).fill.value = !E(_).fill.value
|
|
1441
1441
|
}, null, 8, [
|
|
1442
1442
|
"label",
|
|
1443
1443
|
"variant",
|
|
1444
1444
|
"aria-pressed"
|
|
1445
1445
|
])]),
|
|
1446
1446
|
_: 1
|
|
1447
|
-
}, 8, ["text"])) :
|
|
1448
|
-
|
|
1449
|
-
(
|
|
1447
|
+
}, 8, ["text"])) : u("", !0),
|
|
1448
|
+
c[9] ||= f("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1),
|
|
1449
|
+
(x(!0), d(s, null, C(t.colors, (e) => (x(), d("button", {
|
|
1450
1450
|
key: e,
|
|
1451
1451
|
type: "button",
|
|
1452
|
-
class: y(["m-0.5 size-7 shrink-0 rounded-full border border-outline-variant outline-offset-2 transition-[outline-color] duration-150",
|
|
1452
|
+
class: y(["m-0.5 size-7 shrink-0 rounded-full border border-outline-variant outline-offset-2 transition-[outline-color] duration-150", E(_).color.value.toLowerCase() === e.toLowerCase() ? "outline-2 outline-primary" : "outline-2 outline-transparent"]),
|
|
1453
1453
|
style: b({ background: e }),
|
|
1454
|
-
"aria-label": `${
|
|
1455
|
-
"aria-pressed":
|
|
1456
|
-
onClick: (t) =>
|
|
1457
|
-
}, null, 14,
|
|
1458
|
-
|
|
1454
|
+
"aria-label": `${E(v).drawColor} ${e}`,
|
|
1455
|
+
"aria-pressed": E(_).color.value.toLowerCase() === e.toLowerCase(),
|
|
1456
|
+
onClick: (t) => E(_).color.value = e
|
|
1457
|
+
}, null, 14, ut))), 128)),
|
|
1458
|
+
t.customColor ? (x(), l(a, {
|
|
1459
1459
|
key: 1,
|
|
1460
|
-
text:
|
|
1460
|
+
text: E(v).drawCustomColor,
|
|
1461
1461
|
placement: "top"
|
|
1462
1462
|
}, {
|
|
1463
|
-
default: A(() => [
|
|
1463
|
+
default: A(() => [f("button", {
|
|
1464
1464
|
type: "button",
|
|
1465
|
-
class: y(["m-0.5 flex size-7 shrink-0 items-center justify-center rounded-full outline-offset-2 transition-[outline-color] duration-150",
|
|
1466
|
-
style: b({ background:
|
|
1467
|
-
"aria-label":
|
|
1468
|
-
"aria-pressed":
|
|
1469
|
-
onClick:
|
|
1470
|
-
}, [
|
|
1465
|
+
class: y(["m-0.5 flex size-7 shrink-0 items-center justify-center rounded-full outline-offset-2 transition-[outline-color] duration-150", j.value ? "outline-2 outline-primary" : "outline-2 outline-transparent"]),
|
|
1466
|
+
style: b({ background: j.value ? E(_).color.value : "conic-gradient(#f44336, #ffeb3b, #4caf50, #00bcd4, #3f51b5, #e91e63, #f44336)" }),
|
|
1467
|
+
"aria-label": E(v).drawCustomColor,
|
|
1468
|
+
"aria-pressed": j.value,
|
|
1469
|
+
onClick: c[1] ||= (e) => oe.value = !0
|
|
1470
|
+
}, [j.value ? u("", !0) : (x(), d("span", V, "add"))], 14, B)]),
|
|
1471
1471
|
_: 1
|
|
1472
|
-
}, 8, ["text"])) :
|
|
1473
|
-
|
|
1472
|
+
}, 8, ["text"])) : u("", !0),
|
|
1473
|
+
t.customColor ? (x(), l(o, {
|
|
1474
1474
|
key: 2,
|
|
1475
|
-
modelValue:
|
|
1476
|
-
"onUpdate:modelValue":
|
|
1477
|
-
show:
|
|
1478
|
-
"onUpdate:show":
|
|
1479
|
-
}, null, 8, ["modelValue", "show"])) :
|
|
1480
|
-
|
|
1481
|
-
(
|
|
1475
|
+
modelValue: E(_).color.value,
|
|
1476
|
+
"onUpdate:modelValue": c[2] ||= (e) => E(_).color.value = e,
|
|
1477
|
+
show: oe.value,
|
|
1478
|
+
"onUpdate:show": c[3] ||= (e) => oe.value = e
|
|
1479
|
+
}, null, 8, ["modelValue", "show"])) : u("", !0),
|
|
1480
|
+
c[10] ||= f("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1),
|
|
1481
|
+
(x(!0), d(s, null, C(t.sizes, (e) => (x(), d("button", {
|
|
1482
1482
|
key: e,
|
|
1483
1483
|
type: "button",
|
|
1484
|
-
class: y(["flex size-9 shrink-0 items-center justify-center rounded-full transition-colors",
|
|
1485
|
-
"aria-label": `${
|
|
1486
|
-
"aria-pressed":
|
|
1487
|
-
onClick: (t) =>
|
|
1488
|
-
}, [
|
|
1484
|
+
class: y(["flex size-9 shrink-0 items-center justify-center rounded-full transition-colors", E(_).size.value === e ? "bg-secondary-container" : "hover:bg-on-surface/8"]),
|
|
1485
|
+
"aria-label": `${E(v).drawSize} ${e}`,
|
|
1486
|
+
"aria-pressed": E(_).size.value === e,
|
|
1487
|
+
onClick: (t) => E(_).size.value = e
|
|
1488
|
+
}, [f("span", {
|
|
1489
1489
|
class: "rounded-full bg-on-surface",
|
|
1490
1490
|
style: b({
|
|
1491
1491
|
width: `${Math.min(20, Math.max(3, e * 1.2))}px`,
|
|
1492
1492
|
height: `${Math.min(20, Math.max(3, e * 1.2))}px`
|
|
1493
1493
|
})
|
|
1494
1494
|
}, null, 4)], 10, H))), 128)),
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
text:
|
|
1495
|
+
t.history ? (x(), d(s, { key: 3 }, [
|
|
1496
|
+
c[8] ||= f("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1),
|
|
1497
|
+
m(a, {
|
|
1498
|
+
text: E(v).drawUndo,
|
|
1499
1499
|
placement: "top"
|
|
1500
1500
|
}, {
|
|
1501
|
-
default: A(() => [
|
|
1501
|
+
default: A(() => [m(n, {
|
|
1502
1502
|
icon: "undo",
|
|
1503
|
-
label:
|
|
1504
|
-
disabled: !
|
|
1505
|
-
onClick:
|
|
1503
|
+
label: E(v).drawUndo,
|
|
1504
|
+
disabled: !E(_).canUndo.value,
|
|
1505
|
+
onClick: c[4] ||= (e) => E(_).undo()
|
|
1506
1506
|
}, null, 8, ["label", "disabled"])]),
|
|
1507
1507
|
_: 1
|
|
1508
1508
|
}, 8, ["text"]),
|
|
1509
|
-
|
|
1510
|
-
text:
|
|
1509
|
+
m(a, {
|
|
1510
|
+
text: E(v).drawRedo,
|
|
1511
1511
|
placement: "top"
|
|
1512
1512
|
}, {
|
|
1513
|
-
default: A(() => [
|
|
1513
|
+
default: A(() => [m(n, {
|
|
1514
1514
|
icon: "redo",
|
|
1515
|
-
label:
|
|
1516
|
-
disabled: !
|
|
1517
|
-
onClick:
|
|
1515
|
+
label: E(v).drawRedo,
|
|
1516
|
+
disabled: !E(_).canRedo.value,
|
|
1517
|
+
onClick: c[5] ||= (e) => E(_).redo()
|
|
1518
1518
|
}, null, 8, ["label", "disabled"])]),
|
|
1519
1519
|
_: 1
|
|
1520
1520
|
}, 8, ["text"])
|
|
1521
|
-
], 64)) :
|
|
1522
|
-
|
|
1521
|
+
], 64)) : u("", !0),
|
|
1522
|
+
E(_).selection.value.length ? (x(), l(a, {
|
|
1523
1523
|
key: 4,
|
|
1524
|
-
text:
|
|
1524
|
+
text: E(v).drawDelete,
|
|
1525
1525
|
placement: "top"
|
|
1526
1526
|
}, {
|
|
1527
|
-
default: A(() => [
|
|
1527
|
+
default: A(() => [m(n, {
|
|
1528
1528
|
icon: "delete",
|
|
1529
|
-
label:
|
|
1530
|
-
onClick:
|
|
1529
|
+
label: E(v).drawDelete,
|
|
1530
|
+
onClick: c[6] ||= (e) => E(_).deleteSelection()
|
|
1531
1531
|
}, null, 8, ["label"])]),
|
|
1532
1532
|
_: 1
|
|
1533
|
-
}, 8, ["text"])) :
|
|
1534
|
-
|
|
1535
|
-
], 8,
|
|
1533
|
+
}, 8, ["text"])) : u("", !0),
|
|
1534
|
+
w(e.$slots, "end")
|
|
1535
|
+
], 8, ct));
|
|
1536
1536
|
}
|
|
1537
|
-
}),
|
|
1537
|
+
}), ft = ["aria-label"], pt = { class: "flex items-center pb-1 pl-2" }, mt = { class: "flex-1 text-title-small" }, U = [
|
|
1538
1538
|
"value",
|
|
1539
1539
|
"aria-label",
|
|
1540
1540
|
"onKeydown",
|
|
@@ -1543,90 +1543,90 @@ var De = ["aria-label"], Oe = [
|
|
|
1543
1543
|
"aria-pressed",
|
|
1544
1544
|
"onClick",
|
|
1545
1545
|
"onDblclick"
|
|
1546
|
-
],
|
|
1546
|
+
], ht = { class: "hidden flex-col group-hover:flex group-focus-within:flex" }, gt = ["aria-label", "onClick"], _t = ["aria-label", "onClick"], vt = /* @__PURE__ */ h({
|
|
1547
1547
|
__name: "MDrawLayers",
|
|
1548
|
-
setup(
|
|
1549
|
-
let
|
|
1550
|
-
if (!
|
|
1551
|
-
let
|
|
1548
|
+
setup(r) {
|
|
1549
|
+
let i = ee(De, null);
|
|
1550
|
+
if (!i) throw Error("MDrawLayers must be inside <MDrawCanvas>");
|
|
1551
|
+
let o = i, p = e(), h = c(() => o.layers.value.length ? o.layers.value : [{
|
|
1552
1552
|
id: "layer-1",
|
|
1553
|
-
name:
|
|
1554
|
-
}]), g =
|
|
1553
|
+
name: t(p.drawLayer, { n: "1" }, p.lang)
|
|
1554
|
+
}]), g = c(() => h.value.slice().reverse()), _ = (e) => o.setLayers(e), b = (e, t) => _(h.value.map((n) => n.id === e ? {
|
|
1555
1555
|
...n,
|
|
1556
1556
|
...t
|
|
1557
1557
|
} : n));
|
|
1558
|
-
function
|
|
1558
|
+
function te() {
|
|
1559
1559
|
let e = {
|
|
1560
|
-
id:
|
|
1561
|
-
name:
|
|
1560
|
+
id: le(),
|
|
1561
|
+
name: t(p.drawLayer, { n: String(h.value.length + 1) }, p.lang)
|
|
1562
1562
|
};
|
|
1563
|
-
_([...
|
|
1563
|
+
_([...h.value, e]), o.layer.value = e.id;
|
|
1564
1564
|
}
|
|
1565
|
-
function
|
|
1566
|
-
if (
|
|
1567
|
-
let t =
|
|
1568
|
-
n.length && (
|
|
1569
|
-
let r =
|
|
1570
|
-
_(r),
|
|
1565
|
+
function ne(e) {
|
|
1566
|
+
if (h.value.length < 2) return;
|
|
1567
|
+
let t = h.value[0].id, n = o.items.value.filter((n) => (n.layer ?? t) === e).map((e) => e.id);
|
|
1568
|
+
n.length && (o.selection.value = n, o.deleteSelection());
|
|
1569
|
+
let r = h.value.filter((t) => t.id !== e);
|
|
1570
|
+
_(r), o.layer.value === e && (o.layer.value = r[r.length - 1].id);
|
|
1571
1571
|
}
|
|
1572
|
-
function
|
|
1573
|
-
let n =
|
|
1574
|
-
if (r < 0 || r >=
|
|
1575
|
-
let i =
|
|
1572
|
+
function re(e, t) {
|
|
1573
|
+
let n = h.value.findIndex((t) => t.id === e), r = n + t;
|
|
1574
|
+
if (r < 0 || r >= h.value.length) return;
|
|
1575
|
+
let i = h.value.slice();
|
|
1576
1576
|
[i[n], i[r]] = [i[r], i[n]], _(i);
|
|
1577
1577
|
}
|
|
1578
|
-
let
|
|
1579
|
-
function
|
|
1580
|
-
|
|
1578
|
+
let w = S(""), T = S();
|
|
1579
|
+
function D(e) {
|
|
1580
|
+
w.value = e, v(() => T.value?.[0]?.select());
|
|
1581
1581
|
}
|
|
1582
|
-
function
|
|
1583
|
-
|
|
1582
|
+
function O(e, t) {
|
|
1583
|
+
w.value === e && (w.value = "", t.trim() && b(e, { name: t.trim() }));
|
|
1584
1584
|
}
|
|
1585
|
-
return (e,
|
|
1585
|
+
return (e, t) => (x(), d("div", {
|
|
1586
1586
|
class: "m3-draw-layers flex w-64 flex-col rounded-xl bg-surface-container p-2 text-on-surface shadow-elevation-2",
|
|
1587
1587
|
role: "group",
|
|
1588
|
-
"aria-label":
|
|
1589
|
-
}, [
|
|
1590
|
-
text:
|
|
1588
|
+
"aria-label": E(p).drawLayers
|
|
1589
|
+
}, [f("div", pt, [f("span", mt, ie(E(p).drawLayers), 1), m(a, {
|
|
1590
|
+
text: E(p).drawAddLayer,
|
|
1591
1591
|
placement: "left"
|
|
1592
1592
|
}, {
|
|
1593
|
-
default: A(() => [
|
|
1593
|
+
default: A(() => [m(n, {
|
|
1594
1594
|
icon: "add",
|
|
1595
1595
|
size: "xs",
|
|
1596
|
-
label:
|
|
1597
|
-
onClick:
|
|
1596
|
+
label: E(p).drawAddLayer,
|
|
1597
|
+
onClick: te
|
|
1598
1598
|
}, null, 8, ["label"])]),
|
|
1599
1599
|
_: 1
|
|
1600
|
-
}, 8, ["text"])]), (
|
|
1600
|
+
}, 8, ["text"])]), (x(!0), d(s, null, C(g.value, (e) => (x(), d("div", {
|
|
1601
1601
|
key: e.id,
|
|
1602
|
-
class: y(["group flex h-10 items-center gap-1 rounded-full pr-1 pl-3 text-body-medium",
|
|
1602
|
+
class: y(["group flex h-10 items-center gap-1 rounded-full pr-1 pl-3 text-body-medium", E(o).layer.value === e.id ? "bg-secondary-container text-on-secondary-container" : "hover:bg-on-surface/8"])
|
|
1603
1603
|
}, [
|
|
1604
|
-
|
|
1604
|
+
w.value === e.id ? (x(), d("input", {
|
|
1605
1605
|
key: 0,
|
|
1606
1606
|
ref_for: !0,
|
|
1607
1607
|
ref_key: "input",
|
|
1608
|
-
ref:
|
|
1608
|
+
ref: T,
|
|
1609
1609
|
value: e.name,
|
|
1610
|
-
"aria-label":
|
|
1610
|
+
"aria-label": E(p).drawLayerName,
|
|
1611
1611
|
class: "h-7 min-w-0 flex-1 rounded-xs bg-surface px-1 ring-1 ring-primary outline-none",
|
|
1612
|
-
onKeydown: [
|
|
1613
|
-
onBlur: (t) =>
|
|
1614
|
-
}, null, 40,
|
|
1612
|
+
onKeydown: [j((t) => O(e.id, t.target.value), ["enter"]), t[0] ||= j((e) => w.value = "", ["esc"])],
|
|
1613
|
+
onBlur: (t) => O(e.id, t.target.value)
|
|
1614
|
+
}, null, 40, U)) : (x(), d("button", {
|
|
1615
1615
|
key: 1,
|
|
1616
1616
|
type: "button",
|
|
1617
1617
|
class: y(["min-w-0 flex-1 truncate text-left outline-none", e.visible === !1 && "opacity-50"]),
|
|
1618
|
-
"aria-pressed":
|
|
1619
|
-
onClick: (t) =>
|
|
1620
|
-
onDblclick: (t) =>
|
|
1621
|
-
},
|
|
1622
|
-
|
|
1623
|
-
text: e.visible === !1 ?
|
|
1618
|
+
"aria-pressed": E(o).layer.value === e.id,
|
|
1619
|
+
onClick: (t) => E(o).layer.value = e.id,
|
|
1620
|
+
onDblclick: (t) => D(e.id)
|
|
1621
|
+
}, ie(e.name), 43, W)),
|
|
1622
|
+
m(a, {
|
|
1623
|
+
text: e.visible === !1 ? E(p).drawShowLayer : E(p).drawHideLayer,
|
|
1624
1624
|
placement: "left"
|
|
1625
1625
|
}, {
|
|
1626
|
-
default: A(() => [
|
|
1626
|
+
default: A(() => [m(n, {
|
|
1627
1627
|
icon: e.visible === !1 ? "visibility_off" : "visibility",
|
|
1628
1628
|
size: "xs",
|
|
1629
|
-
label: e.visible === !1 ?
|
|
1629
|
+
label: e.visible === !1 ? E(p).drawShowLayer : E(p).drawHideLayer,
|
|
1630
1630
|
onClick: (t) => b(e.id, { visible: e.visible === !1 })
|
|
1631
1631
|
}, null, 8, [
|
|
1632
1632
|
"icon",
|
|
@@ -1635,14 +1635,14 @@ var De = ["aria-label"], Oe = [
|
|
|
1635
1635
|
])]),
|
|
1636
1636
|
_: 2
|
|
1637
1637
|
}, 1032, ["text"]),
|
|
1638
|
-
|
|
1639
|
-
text: e.locked ?
|
|
1638
|
+
m(a, {
|
|
1639
|
+
text: e.locked ? E(p).drawUnlockLayer : E(p).drawLockLayer,
|
|
1640
1640
|
placement: "left"
|
|
1641
1641
|
}, {
|
|
1642
|
-
default: A(() => [
|
|
1642
|
+
default: A(() => [m(n, {
|
|
1643
1643
|
icon: e.locked ? "lock" : "lock_open",
|
|
1644
1644
|
size: "xs",
|
|
1645
|
-
label: e.locked ?
|
|
1645
|
+
label: e.locked ? E(p).drawUnlockLayer : E(p).drawLockLayer,
|
|
1646
1646
|
onClick: (t) => b(e.id, { locked: !e.locked })
|
|
1647
1647
|
}, null, 8, [
|
|
1648
1648
|
"icon",
|
|
@@ -1651,33 +1651,33 @@ var De = ["aria-label"], Oe = [
|
|
|
1651
1651
|
])]),
|
|
1652
1652
|
_: 2
|
|
1653
1653
|
}, 1032, ["text"]),
|
|
1654
|
-
|
|
1654
|
+
f("div", ht, [f("button", {
|
|
1655
1655
|
type: "button",
|
|
1656
1656
|
class: "h-4 leading-none text-on-surface-variant",
|
|
1657
|
-
"aria-label":
|
|
1658
|
-
onClick: (t) =>
|
|
1659
|
-
}, [...
|
|
1657
|
+
"aria-label": E(p).drawLayerUp,
|
|
1658
|
+
onClick: (t) => re(e.id, 1)
|
|
1659
|
+
}, [...t[1] ||= [f("span", {
|
|
1660
1660
|
class: "material-symbols-outlined text-[16px]",
|
|
1661
1661
|
"aria-hidden": "true"
|
|
1662
|
-
}, "arrow_drop_up", -1)]], 8,
|
|
1662
|
+
}, "arrow_drop_up", -1)]], 8, gt), f("button", {
|
|
1663
1663
|
type: "button",
|
|
1664
1664
|
class: "h-4 leading-none text-on-surface-variant",
|
|
1665
|
-
"aria-label":
|
|
1666
|
-
onClick: (t) =>
|
|
1667
|
-
}, [...
|
|
1665
|
+
"aria-label": E(p).drawLayerDown,
|
|
1666
|
+
onClick: (t) => re(e.id, -1)
|
|
1667
|
+
}, [...t[2] ||= [f("span", {
|
|
1668
1668
|
class: "material-symbols-outlined text-[16px]",
|
|
1669
1669
|
"aria-hidden": "true"
|
|
1670
|
-
}, "arrow_drop_down", -1)]], 8,
|
|
1671
|
-
|
|
1670
|
+
}, "arrow_drop_down", -1)]], 8, _t)]),
|
|
1671
|
+
h.value.length > 1 ? (x(), l(n, {
|
|
1672
1672
|
key: 2,
|
|
1673
1673
|
icon: "delete",
|
|
1674
1674
|
size: "xs",
|
|
1675
|
-
label:
|
|
1676
|
-
onClick: (t) =>
|
|
1677
|
-
}, null, 8, ["label", "onClick"])) :
|
|
1678
|
-
], 2))), 128))], 8,
|
|
1675
|
+
label: E(p).drawDeleteLayer,
|
|
1676
|
+
onClick: (t) => ne(e.id)
|
|
1677
|
+
}, null, 8, ["label", "onClick"])) : u("", !0)
|
|
1678
|
+
], 2))), 128))], 8, ft));
|
|
1679
1679
|
}
|
|
1680
1680
|
});
|
|
1681
|
-
export {
|
|
1681
|
+
export { st as MDrawCanvas, vt as MDrawLayers, dt as MDrawToolbar, he as constrain, le as drawId, xe as eraseAt, be as hitItem, Se as inLasso, ve as itemBox, R as itemSvg, me as shapePath, fe as simulatePressure, de as smoothPoints, we as sortByLayer, pe as strokePath, Ee as svgToPng, _e as textBox, Te as toDrawSvg, Ce as transformItem, ye as unionBox, Oe as useDrawing };
|
|
1682
1682
|
|
|
1683
1683
|
//# sourceMappingURL=draw.js.map
|