@kritzel/editor 0.4.31
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/LICENSE.md +50 -0
- package/README.md +5 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-B92VHWr4.js +1834 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/kritzel-active-users_46.cjs.entry.js +75271 -0
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +31 -0
- package/dist/cjs/kritzel-editor.cjs.js +25 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/collection/collection-manifest.json +65 -0
- package/dist/collection/components/kritzel-active-users/kritzel-active-users.css +65 -0
- package/dist/collection/components/kritzel-active-users/kritzel-active-users.js +134 -0
- package/dist/collection/components/kritzel-avatar/kritzel-avatar.css +58 -0
- package/dist/collection/components/kritzel-avatar/kritzel-avatar.js +207 -0
- package/dist/collection/components/kritzel-back-to-content/kritzel-back-to-content.css +42 -0
- package/dist/collection/components/kritzel-back-to-content/kritzel-back-to-content.js +95 -0
- package/dist/collection/components/kritzel-brush-style/kritzel-brush-style.css +43 -0
- package/dist/collection/components/kritzel-brush-style/kritzel-brush-style.js +97 -0
- package/dist/collection/components/kritzel-button/kritzel-button.css +73 -0
- package/dist/collection/components/kritzel-button/kritzel-button.js +118 -0
- package/dist/collection/components/kritzel-color/kritzel-color.css +25 -0
- package/dist/collection/components/kritzel-color/kritzel-color.js +149 -0
- package/dist/collection/components/kritzel-color-palette/kritzel-color-palette.css +46 -0
- package/dist/collection/components/kritzel-color-palette/kritzel-color-palette.js +225 -0
- package/dist/collection/components/kritzel-context-menu/kritzel-context-menu.css +112 -0
- package/dist/collection/components/kritzel-context-menu/kritzel-context-menu.js +368 -0
- package/dist/collection/components/kritzel-current-user/kritzel-current-user.css +11 -0
- package/dist/collection/components/kritzel-current-user/kritzel-current-user.js +109 -0
- package/dist/collection/components/kritzel-current-user-dialog/kritzel-current-user-dialog.css +39 -0
- package/dist/collection/components/kritzel-current-user-dialog/kritzel-current-user-dialog.js +169 -0
- package/dist/collection/components/kritzel-dialog/kritzel-dialog.css +209 -0
- package/dist/collection/components/kritzel-dialog/kritzel-dialog.js +787 -0
- package/dist/collection/components/kritzel-dropdown/kritzel-dropdown.css +190 -0
- package/dist/collection/components/kritzel-dropdown/kritzel-dropdown.js +418 -0
- package/dist/collection/components/kritzel-editor/kritzel-editor.css +161 -0
- package/dist/collection/components/kritzel-editor/kritzel-editor.js +4678 -0
- package/dist/collection/components/kritzel-export/kritzel-export.css +89 -0
- package/dist/collection/components/kritzel-export/kritzel-export.js +246 -0
- package/dist/collection/components/kritzel-font/kritzel-font.css +10 -0
- package/dist/collection/components/kritzel-font/kritzel-font.js +89 -0
- package/dist/collection/components/kritzel-font-family/kritzel-font-family.css +48 -0
- package/dist/collection/components/kritzel-font-family/kritzel-font-family.js +122 -0
- package/dist/collection/components/kritzel-font-size/kritzel-font-size.css +30 -0
- package/dist/collection/components/kritzel-font-size/kritzel-font-size.js +117 -0
- package/dist/collection/components/kritzel-input/kritzel-input.css +69 -0
- package/dist/collection/components/kritzel-input/kritzel-input.js +198 -0
- package/dist/collection/components/kritzel-line-endings/kritzel-line-endings.css +60 -0
- package/dist/collection/components/kritzel-line-endings/kritzel-line-endings.js +165 -0
- package/dist/collection/components/kritzel-loading-overlay/kritzel-loading-overlay.css +54 -0
- package/dist/collection/components/kritzel-loading-overlay/kritzel-loading-overlay.js +70 -0
- package/dist/collection/components/kritzel-login-dialog/kritzel-login-dialog.css +98 -0
- package/dist/collection/components/kritzel-login-dialog/kritzel-login-dialog.js +239 -0
- package/dist/collection/components/kritzel-master-detail/kritzel-master-detail.css +190 -0
- package/dist/collection/components/kritzel-master-detail/kritzel-master-detail.js +201 -0
- package/dist/collection/components/kritzel-menu/kritzel-menu.css +34 -0
- package/dist/collection/components/kritzel-menu/kritzel-menu.js +297 -0
- package/dist/collection/components/kritzel-menu-item/kritzel-menu-item.css +167 -0
- package/dist/collection/components/kritzel-menu-item/kritzel-menu-item.js +298 -0
- package/dist/collection/components/kritzel-more-menu/kritzel-more-menu.css +58 -0
- package/dist/collection/components/kritzel-more-menu/kritzel-more-menu.js +381 -0
- package/dist/collection/components/kritzel-notification-card/kritzel-notification-card.css +101 -0
- package/dist/collection/components/kritzel-notification-card/kritzel-notification-card.js +173 -0
- package/dist/collection/components/kritzel-numeric-input/kritzel-numeric-input.css +102 -0
- package/dist/collection/components/kritzel-numeric-input/kritzel-numeric-input.js +255 -0
- package/dist/collection/components/kritzel-opacity-slider/kritzel-opacity-slider.css +85 -0
- package/dist/collection/components/kritzel-opacity-slider/kritzel-opacity-slider.js +164 -0
- package/dist/collection/components/kritzel-pill-tabs/kritzel-pill-tabs.css +68 -0
- package/dist/collection/components/kritzel-pill-tabs/kritzel-pill-tabs.js +135 -0
- package/dist/collection/components/kritzel-portal/kritzel-portal.js +432 -0
- package/dist/collection/components/kritzel-settings/kritzel-settings.css +137 -0
- package/dist/collection/components/kritzel-settings/kritzel-settings.js +448 -0
- package/dist/collection/components/kritzel-shape-fill/kritzel-shape-fill.css +47 -0
- package/dist/collection/components/kritzel-shape-fill/kritzel-shape-fill.js +93 -0
- package/dist/collection/components/kritzel-share-dialog/kritzel-share-dialog.css +150 -0
- package/dist/collection/components/kritzel-share-dialog/kritzel-share-dialog.js +308 -0
- package/dist/collection/components/kritzel-slide-toggle/kritzel-slide-toggle.css +48 -0
- package/dist/collection/components/kritzel-slide-toggle/kritzel-slide-toggle.js +119 -0
- package/dist/collection/components/kritzel-split-button/kritzel-split-button.css +78 -0
- package/dist/collection/components/kritzel-split-button/kritzel-split-button.js +433 -0
- package/dist/collection/components/kritzel-stroke-size/kritzel-stroke-size.css +37 -0
- package/dist/collection/components/kritzel-stroke-size/kritzel-stroke-size.js +89 -0
- package/dist/collection/components/kritzel-tool-config/kritzel-tool-config.css +38 -0
- package/dist/collection/components/kritzel-tool-config/kritzel-tool-config.js +467 -0
- package/dist/collection/components/kritzel-toolbar/kritzel-toolbar.css +348 -0
- package/dist/collection/components/kritzel-toolbar/kritzel-toolbar.js +588 -0
- package/dist/collection/components/kritzel-tooltip/kritzel-tooltip.css +18 -0
- package/dist/collection/components/kritzel-tooltip/kritzel-tooltip.js +388 -0
- package/dist/collection/components/kritzel-utility-panel/kritzel-utility-panel.css +46 -0
- package/dist/collection/components/kritzel-utility-panel/kritzel-utility-panel.js +146 -0
- package/dist/collection/components/kritzel-workspace-manager/kritzel-workspace-manager.css +16 -0
- package/dist/collection/components/kritzel-workspace-manager/kritzel-workspace-manager.js +365 -0
- package/dist/collection/components/kritzel-zoom-panel/kritzel-zoom-panel.css +72 -0
- package/dist/collection/components/kritzel-zoom-panel/kritzel-zoom-panel.js +173 -0
- package/dist/collection/index.js +1 -0
- package/dist/components/index.d.ts +121 -0
- package/dist/components/index.js +48 -0
- package/dist/components/kritzel-active-users.d.ts +11 -0
- package/dist/components/kritzel-active-users.js +6 -0
- package/dist/components/kritzel-avatar.d.ts +11 -0
- package/dist/components/kritzel-avatar.js +6 -0
- package/dist/components/kritzel-awareness-cursors.js +6 -0
- package/dist/components/kritzel-back-to-content.d.ts +11 -0
- package/dist/components/kritzel-back-to-content.js +6 -0
- package/dist/components/kritzel-brush-style.d.ts +11 -0
- package/dist/components/kritzel-brush-style.js +64 -0
- package/dist/components/kritzel-button.d.ts +11 -0
- package/dist/components/kritzel-button.js +6 -0
- package/dist/components/kritzel-color-palette.d.ts +11 -0
- package/dist/components/kritzel-color-palette.js +6 -0
- package/dist/components/kritzel-color.d.ts +11 -0
- package/dist/components/kritzel-color.js +6 -0
- package/dist/components/kritzel-context-menu.d.ts +11 -0
- package/dist/components/kritzel-context-menu.js +6 -0
- package/dist/components/kritzel-current-user-dialog.d.ts +11 -0
- package/dist/components/kritzel-current-user-dialog.js +6 -0
- package/dist/components/kritzel-current-user.d.ts +11 -0
- package/dist/components/kritzel-current-user.js +6 -0
- package/dist/components/kritzel-cursor-trail.js +6 -0
- package/dist/components/kritzel-dialog.d.ts +11 -0
- package/dist/components/kritzel-dialog.js +6 -0
- package/dist/components/kritzel-dropdown.d.ts +11 -0
- package/dist/components/kritzel-dropdown.js +6 -0
- package/dist/components/kritzel-editor.d.ts +11 -0
- package/dist/components/kritzel-editor.js +1792 -0
- package/dist/components/kritzel-engine.js +6 -0
- package/dist/components/kritzel-export.d.ts +11 -0
- package/dist/components/kritzel-export.js +6 -0
- package/dist/components/kritzel-font-family.d.ts +11 -0
- package/dist/components/kritzel-font-family.js +6 -0
- package/dist/components/kritzel-font-size.d.ts +11 -0
- package/dist/components/kritzel-font-size.js +6 -0
- package/dist/components/kritzel-font.d.ts +11 -0
- package/dist/components/kritzel-font.js +6 -0
- package/dist/components/kritzel-icon.js +6 -0
- package/dist/components/kritzel-input.d.ts +11 -0
- package/dist/components/kritzel-input.js +6 -0
- package/dist/components/kritzel-line-endings.d.ts +11 -0
- package/dist/components/kritzel-line-endings.js +6 -0
- package/dist/components/kritzel-loading-overlay.d.ts +11 -0
- package/dist/components/kritzel-loading-overlay.js +6 -0
- package/dist/components/kritzel-login-dialog.d.ts +11 -0
- package/dist/components/kritzel-login-dialog.js +6 -0
- package/dist/components/kritzel-master-detail.d.ts +11 -0
- package/dist/components/kritzel-master-detail.js +6 -0
- package/dist/components/kritzel-menu-item.d.ts +11 -0
- package/dist/components/kritzel-menu-item.js +6 -0
- package/dist/components/kritzel-menu.d.ts +11 -0
- package/dist/components/kritzel-menu.js +6 -0
- package/dist/components/kritzel-more-menu.d.ts +11 -0
- package/dist/components/kritzel-more-menu.js +6 -0
- package/dist/components/kritzel-notification-card.d.ts +11 -0
- package/dist/components/kritzel-notification-card.js +6 -0
- package/dist/components/kritzel-numeric-input.d.ts +11 -0
- package/dist/components/kritzel-numeric-input.js +6 -0
- package/dist/components/kritzel-opacity-slider.d.ts +11 -0
- package/dist/components/kritzel-opacity-slider.js +6 -0
- package/dist/components/kritzel-pill-tabs.d.ts +11 -0
- package/dist/components/kritzel-pill-tabs.js +6 -0
- package/dist/components/kritzel-portal.d.ts +11 -0
- package/dist/components/kritzel-portal.js +6 -0
- package/dist/components/kritzel-settings.d.ts +11 -0
- package/dist/components/kritzel-settings.js +6 -0
- package/dist/components/kritzel-shape-fill.d.ts +11 -0
- package/dist/components/kritzel-shape-fill.js +6 -0
- package/dist/components/kritzel-share-dialog.d.ts +11 -0
- package/dist/components/kritzel-share-dialog.js +6 -0
- package/dist/components/kritzel-slide-toggle.d.ts +11 -0
- package/dist/components/kritzel-slide-toggle.js +6 -0
- package/dist/components/kritzel-split-button.d.ts +11 -0
- package/dist/components/kritzel-split-button.js +6 -0
- package/dist/components/kritzel-stroke-size.d.ts +11 -0
- package/dist/components/kritzel-stroke-size.js +6 -0
- package/dist/components/kritzel-tool-config.d.ts +11 -0
- package/dist/components/kritzel-tool-config.js +6 -0
- package/dist/components/kritzel-toolbar.d.ts +11 -0
- package/dist/components/kritzel-toolbar.js +6 -0
- package/dist/components/kritzel-tooltip.d.ts +11 -0
- package/dist/components/kritzel-tooltip.js +6 -0
- package/dist/components/kritzel-utility-panel.d.ts +11 -0
- package/dist/components/kritzel-utility-panel.js +6 -0
- package/dist/components/kritzel-watermark.js +6 -0
- package/dist/components/kritzel-workspace-manager.d.ts +11 -0
- package/dist/components/kritzel-workspace-manager.js +6 -0
- package/dist/components/kritzel-zoom-panel.d.ts +11 -0
- package/dist/components/kritzel-zoom-panel.js +6 -0
- package/dist/components/p-4-qLegHb.js +142 -0
- package/dist/components/p-5qkOM1RJ.js +1557 -0
- package/dist/components/p-B3Tqoyl9.js +43 -0
- package/dist/components/p-B5xYV1o3.js +77 -0
- package/dist/components/p-B6UJztrf.js +290 -0
- package/dist/components/p-BDjRSoAc.js +43 -0
- package/dist/components/p-BFTU3MAI.js +7 -0
- package/dist/components/p-BGmTmdLe.js +167 -0
- package/dist/components/p-BN8VWPlq.js +164 -0
- package/dist/components/p-BZ_KnHdR.js +222 -0
- package/dist/components/p-B_gT0lCn.js +94 -0
- package/dist/components/p-BfMlwIcG.js +62 -0
- package/dist/components/p-BjFrt1q0.js +62 -0
- package/dist/components/p-Blq9a1ni.js +3267 -0
- package/dist/components/p-BrGJIoGK.js +52 -0
- package/dist/components/p-BvG3JO85.js +56 -0
- package/dist/components/p-CS3YZVYE.js +319 -0
- package/dist/components/p-CVxGF4bJ.js +150 -0
- package/dist/components/p-Ckqh1tqY.js +468 -0
- package/dist/components/p-ClfOtiNp.js +84 -0
- package/dist/components/p-CmjXRLdr.js +220 -0
- package/dist/components/p-CoNexfpB.js +106 -0
- package/dist/components/p-Cp4e4oTE.js +122 -0
- package/dist/components/p-CrIEmItB.js +85 -0
- package/dist/components/p-CvaxFYS0.js +304 -0
- package/dist/components/p-CwBxnzYu.js +57 -0
- package/dist/components/p-Cy_cLtOP.js +3456 -0
- package/dist/components/p-CzUeIini.js +381 -0
- package/dist/components/p-D0tPTPkR.js +99 -0
- package/dist/components/p-DJxgPPfs.js +194 -0
- package/dist/components/p-DOJCDPVD.js +55 -0
- package/dist/components/p-DVv8ChhE.js +91 -0
- package/dist/components/p-DXZBWJBt.js +70 -0
- package/dist/components/p-DXuf225S.js +53 -0
- package/dist/components/p-DZsSiMnA.js +63037 -0
- package/dist/components/p-DqOC_Yck.js +112 -0
- package/dist/components/p-Ds0uNtwQ.js +97 -0
- package/dist/components/p-DyRJFg4w.js +57 -0
- package/dist/components/p-GbCxpbQ6.js +88 -0
- package/dist/components/p-McY5wZ0h.js +135 -0
- package/dist/components/p-QEue33R5.js +70 -0
- package/dist/components/p-R1D8Sr0l.js +299 -0
- package/dist/components/p-SLnqczCS.js +49 -0
- package/dist/components/p-hQwVRh0t.js +147 -0
- package/dist/components/p-h_uh_Njf.js +63 -0
- package/dist/components/p-kOINnzaR.js +161 -0
- package/dist/components/p-peZjvnkK.js +486 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-OjbYJz-P.js +1807 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/kritzel-active-users_46.entry.js +75224 -0
- package/dist/esm/kritzel-brush-style.entry.js +29 -0
- package/dist/esm/kritzel-editor.js +21 -0
- package/dist/esm/loader.js +11 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/kritzel-editor/index.esm.js +1 -0
- package/dist/kritzel-editor/kritzel-editor.esm.js +21 -0
- package/dist/kritzel-editor/p-501047d8.entry.js +29 -0
- package/dist/kritzel-editor/p-60319edb.entry.js +75224 -0
- package/dist/kritzel-editor/p-DQuL1Twl.js +3 -0
- package/dist/kritzel-editor/p-OjbYJz-P.js +1790 -0
- package/dist/types/components/kritzel-active-users/kritzel-active-users.d.ts +21 -0
- package/dist/types/components/kritzel-avatar/kritzel-avatar.d.ts +27 -0
- package/dist/types/components/kritzel-back-to-content/kritzel-back-to-content.d.ts +17 -0
- package/dist/types/components/kritzel-brush-style/kritzel-brush-style.d.ts +11 -0
- package/dist/types/components/kritzel-button/kritzel-button.d.ts +13 -0
- package/dist/types/components/kritzel-color/kritzel-color.d.ts +10 -0
- package/dist/types/components/kritzel-color-palette/kritzel-color-palette.d.ts +17 -0
- package/dist/types/components/kritzel-context-menu/kritzel-context-menu.d.ts +40 -0
- package/dist/types/components/kritzel-current-user/kritzel-current-user.d.ts +15 -0
- package/dist/types/components/kritzel-current-user-dialog/kritzel-current-user-dialog.d.ts +18 -0
- package/dist/types/components/kritzel-dialog/kritzel-dialog.d.ts +85 -0
- package/dist/types/components/kritzel-dropdown/kritzel-dropdown.d.ts +48 -0
- package/dist/types/components/kritzel-editor/kritzel-editor.d.ts +356 -0
- package/dist/types/components/kritzel-export/kritzel-export.d.ts +35 -0
- package/dist/types/components/kritzel-font/kritzel-font.d.ts +6 -0
- package/dist/types/components/kritzel-font-family/kritzel-font-family.d.ts +17 -0
- package/dist/types/components/kritzel-font-size/kritzel-font-size.d.ts +10 -0
- package/dist/types/components/kritzel-input/kritzel-input.d.ts +22 -0
- package/dist/types/components/kritzel-line-endings/kritzel-line-endings.d.ts +21 -0
- package/dist/types/components/kritzel-loading-overlay/kritzel-loading-overlay.d.ts +11 -0
- package/dist/types/components/kritzel-login-dialog/kritzel-login-dialog.d.ts +32 -0
- package/dist/types/components/kritzel-master-detail/kritzel-master-detail.d.ts +25 -0
- package/dist/types/components/kritzel-menu/kritzel-menu.d.ts +25 -0
- package/dist/types/components/kritzel-menu-item/kritzel-menu-item.d.ts +28 -0
- package/dist/types/components/kritzel-more-menu/kritzel-more-menu.d.ts +55 -0
- package/dist/types/components/kritzel-notification-card/kritzel-notification-card.d.ts +22 -0
- package/dist/types/components/kritzel-numeric-input/kritzel-numeric-input.d.ts +32 -0
- package/dist/types/components/kritzel-opacity-slider/kritzel-opacity-slider.d.ts +17 -0
- package/dist/types/components/kritzel-pill-tabs/kritzel-pill-tabs.d.ts +26 -0
- package/dist/types/components/kritzel-portal/kritzel-portal.d.ts +33 -0
- package/dist/types/components/kritzel-settings/kritzel-settings.d.ts +64 -0
- package/dist/types/components/kritzel-shape-fill/kritzel-shape-fill.d.ts +10 -0
- package/dist/types/components/kritzel-share-dialog/kritzel-share-dialog.d.ts +49 -0
- package/dist/types/components/kritzel-slide-toggle/kritzel-slide-toggle.d.ts +14 -0
- package/dist/types/components/kritzel-split-button/kritzel-split-button.d.ts +38 -0
- package/dist/types/components/kritzel-stroke-size/kritzel-stroke-size.d.ts +8 -0
- package/dist/types/components/kritzel-tool-config/kritzel-tool-config.d.ts +39 -0
- package/dist/types/components/kritzel-toolbar/kritzel-toolbar.d.ts +76 -0
- package/dist/types/components/kritzel-tooltip/kritzel-tooltip.d.ts +30 -0
- package/dist/types/components/kritzel-utility-panel/kritzel-utility-panel.d.ts +14 -0
- package/dist/types/components/kritzel-workspace-manager/kritzel-workspace-manager.d.ts +40 -0
- package/dist/types/components/kritzel-zoom-panel/kritzel-zoom-panel.d.ts +20 -0
- package/dist/types/components.d.ts +3166 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +1873 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +83 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h, d as Host, t as transformTag } from './p-5qkOM1RJ.js';
|
|
2
|
+
import { KritzelDevicesHelper } from '@kritzel/engine';
|
|
3
|
+
import { d as defineCustomElement$4 } from './p-BGmTmdLe.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './p-DqOC_Yck.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './p-BN8VWPlq.js';
|
|
6
|
+
import { d as defineCustomElement$1 } from './p-CS3YZVYE.js';
|
|
7
|
+
|
|
8
|
+
const kritzelSplitButtonCss = () => `:host{position:relative;display:flex;align-items:center;font-family:sans-serif;z-index:1;padding:var(--kritzel-split-button-padding, 4px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-split-button-border, 1px solid #ebebeb);gap:var(--kritzel-split-button-gap, 4px)}:host(.mobile){--kritzel-split-button-hover-background-color:transparent}button{border:none;background-color:transparent;padding:0;margin:0;font-family:inherit;font-size:inherit;color:var(--kritzel-split-button-color, #000000);-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:var(--kritzel-global-pointer-cursor, pointer);text-align:center;display:flex;align-items:center;justify-content:center;pointer-events:all;-webkit-tap-highlight-color:transparent}.split-main-button,.split-menu-button{height:auto;display:flex;align-items:center;padding:var(--kritzel-split-button-padding, 8px);background-color:var(--kritzel-split-button-background-color, #ffffff);border-radius:var(--kritzel-split-button-border-radius, 12px);font-size:var(--kritzel-split-button-font-size, 14px)}.split-main-button:hover,.split-menu-button:hover{background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button:focus,.split-menu-button:focus{background-color:var(--kritzel-split-button-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.split-main-button{gap:var(--kritzel-split-button-gap, 4px)}.split-menu-button{border-left:none;justify-content:center}.split-divider{width:var(--kritzel-split-button-divider-width, 1px);height:24px;background-color:var(--kritzel-split-button-divider-background-color, hsl(0, 0%, 0%, 4.3%))}:disabled{pointer-events:none;opacity:0.5}`;
|
|
9
|
+
|
|
10
|
+
const KritzelSplitButton = /*@__PURE__*/ proxyCustomElement(class KritzelSplitButton extends H {
|
|
11
|
+
constructor(registerHost) {
|
|
12
|
+
super();
|
|
13
|
+
if (registerHost !== false) {
|
|
14
|
+
this.__registerHost();
|
|
15
|
+
}
|
|
16
|
+
this.__attachShadow();
|
|
17
|
+
this.mainButtonClick = createEvent(this, "mainButtonClick");
|
|
18
|
+
this.itemSelect = createEvent(this, "itemSelect");
|
|
19
|
+
this.itemSave = createEvent(this, "itemSave");
|
|
20
|
+
this.itemCancel = createEvent(this, "itemCancel");
|
|
21
|
+
this.itemToggleChildMenu = createEvent(this, "itemToggleChildMenu");
|
|
22
|
+
this.itemCloseChildMenu = createEvent(this, "itemCloseChildMenu");
|
|
23
|
+
this.menuOpen = createEvent(this, "menuOpen");
|
|
24
|
+
this.menuClose = createEvent(this, "menuClose");
|
|
25
|
+
}
|
|
26
|
+
get host() { return this; }
|
|
27
|
+
buttonIcon = 'plus';
|
|
28
|
+
dropdownIcon = 'chevron-down';
|
|
29
|
+
items = [];
|
|
30
|
+
mainButtonDisabled = false;
|
|
31
|
+
menuButtonDisabled = false;
|
|
32
|
+
mainButtonClick;
|
|
33
|
+
itemSelect;
|
|
34
|
+
itemSave;
|
|
35
|
+
itemCancel;
|
|
36
|
+
itemToggleChildMenu;
|
|
37
|
+
itemCloseChildMenu;
|
|
38
|
+
menuOpen;
|
|
39
|
+
menuClose;
|
|
40
|
+
isMenuOpen = false;
|
|
41
|
+
isTouchDevice = KritzelDevicesHelper.isTouchDevice();
|
|
42
|
+
anchorElement;
|
|
43
|
+
menuScrollTop = 0;
|
|
44
|
+
splitMenuButtonRef;
|
|
45
|
+
menuRef;
|
|
46
|
+
async open() {
|
|
47
|
+
if (this.isMenuOpen)
|
|
48
|
+
return;
|
|
49
|
+
window.dispatchEvent(new CustomEvent('kritzel-dismiss-menus'));
|
|
50
|
+
this.isMenuOpen = true;
|
|
51
|
+
this.anchorElement = this.host;
|
|
52
|
+
this.menuOpen.emit();
|
|
53
|
+
}
|
|
54
|
+
async close() {
|
|
55
|
+
this.closeMenu();
|
|
56
|
+
}
|
|
57
|
+
async focusMenu() {
|
|
58
|
+
if (this.menuRef) {
|
|
59
|
+
await this.menuRef.setFocus();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
handleButtonClick = (event) => {
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
this.mainButtonClick.emit();
|
|
65
|
+
};
|
|
66
|
+
toggleMenu = (event) => {
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
if (this.isMenuOpen) {
|
|
69
|
+
this.closeMenu();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.openMenu(event);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
openMenu = (event) => {
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
window.dispatchEvent(new CustomEvent('kritzel-dismiss-menus'));
|
|
78
|
+
this.isMenuOpen = true;
|
|
79
|
+
this.anchorElement = this.host;
|
|
80
|
+
this.menuOpen.emit();
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
this.menuRef?.setScrollTop(this.menuScrollTop);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
closeMenu = () => {
|
|
86
|
+
this.isMenuOpen = false;
|
|
87
|
+
this.anchorElement = null;
|
|
88
|
+
this.splitMenuButtonRef?.blur();
|
|
89
|
+
this.menuClose.emit();
|
|
90
|
+
};
|
|
91
|
+
handleItemSelect = event => {
|
|
92
|
+
this.itemSelect.emit(event.detail);
|
|
93
|
+
};
|
|
94
|
+
handleItemSave = event => {
|
|
95
|
+
this.itemSave.emit(event.detail);
|
|
96
|
+
};
|
|
97
|
+
handleItemCancel = event => {
|
|
98
|
+
this.itemCancel.emit(event.detail);
|
|
99
|
+
};
|
|
100
|
+
handleItemToggleChildMenu = event => {
|
|
101
|
+
this.itemToggleChildMenu.emit(event.detail);
|
|
102
|
+
};
|
|
103
|
+
handleItemCloseChildMenu = event => {
|
|
104
|
+
this.itemCloseChildMenu.emit(event.detail);
|
|
105
|
+
};
|
|
106
|
+
handleScroll = event => {
|
|
107
|
+
this.menuScrollTop = event.target.scrollTop;
|
|
108
|
+
};
|
|
109
|
+
render() {
|
|
110
|
+
return (h(Host, { key: '80f3c3e9287618077ac2a617adf7d6a0de655e7a', class: { mobile: this.isTouchDevice } }, h("button", { key: '91b74d5411e4923f5dff8b664e3de1a8bcfd1889', class: "split-main-button", tabIndex: 0, onClick: this.handleButtonClick, disabled: this.mainButtonDisabled, "aria-label": "Main action" }, this.buttonIcon && h("kritzel-icon", { key: 'd089a83295928b61604e795db2d4696c463f00e2', name: this.buttonIcon })), h("div", { key: '7aa9f16c44edc37a1fce8ffdfddd78ae9b376024', class: "split-divider" }), h("button", { key: '45c8ee363f4d07c282b4a21381e1af80cf4a52f1', ref: el => (this.splitMenuButtonRef = el), class: "split-menu-button", tabIndex: 0, onClick: this.toggleMenu, disabled: this.menuButtonDisabled, "aria-label": "Open menu" }, h("kritzel-icon", { key: 'bab844ef65aa599a138522d94f1e067e8003ff67', name: this.dropdownIcon })), h("kritzel-portal", { key: '9f7241ef66f83e05c18613f36605dc3b6c41352a', anchor: this.anchorElement, offsetY: 4, onClose: this.closeMenu }, h("kritzel-menu", { key: '034c48192e15d56602b29a7e8d491e15cc01bd41', ref: el => (this.menuRef = el), items: this.items, onItemSelect: this.handleItemSelect, onItemSave: this.handleItemSave, onItemCancel: this.handleItemCancel, onItemToggleChildMenu: this.handleItemToggleChildMenu, onItemCloseChildMenu: this.handleItemCloseChildMenu, onClose: this.closeMenu, onScroll: this.handleScroll }))));
|
|
111
|
+
}
|
|
112
|
+
static get style() { return kritzelSplitButtonCss(); }
|
|
113
|
+
}, [513, "kritzel-split-button", {
|
|
114
|
+
"buttonIcon": [1, "button-icon"],
|
|
115
|
+
"dropdownIcon": [1, "dropdown-icon"],
|
|
116
|
+
"items": [16],
|
|
117
|
+
"mainButtonDisabled": [4, "main-button-disabled"],
|
|
118
|
+
"menuButtonDisabled": [4, "menu-button-disabled"],
|
|
119
|
+
"isMenuOpen": [32],
|
|
120
|
+
"isTouchDevice": [32],
|
|
121
|
+
"anchorElement": [32],
|
|
122
|
+
"menuScrollTop": [32],
|
|
123
|
+
"open": [64],
|
|
124
|
+
"close": [64],
|
|
125
|
+
"focusMenu": [64]
|
|
126
|
+
}]);
|
|
127
|
+
function defineCustomElement() {
|
|
128
|
+
if (typeof customElements === "undefined") {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const components = ["kritzel-split-button", "kritzel-icon", "kritzel-menu", "kritzel-menu-item", "kritzel-portal"];
|
|
132
|
+
components.forEach(tagName => { switch (tagName) {
|
|
133
|
+
case "kritzel-split-button":
|
|
134
|
+
if (!customElements.get(transformTag(tagName))) {
|
|
135
|
+
customElements.define(transformTag(tagName), KritzelSplitButton);
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case "kritzel-icon":
|
|
139
|
+
if (!customElements.get(transformTag(tagName))) {
|
|
140
|
+
defineCustomElement$4();
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case "kritzel-menu":
|
|
144
|
+
if (!customElements.get(transformTag(tagName))) {
|
|
145
|
+
defineCustomElement$3();
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
case "kritzel-menu-item":
|
|
149
|
+
if (!customElements.get(transformTag(tagName))) {
|
|
150
|
+
defineCustomElement$2();
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case "kritzel-portal":
|
|
154
|
+
if (!customElements.get(transformTag(tagName))) {
|
|
155
|
+
defineCustomElement$1();
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
} });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { KritzelSplitButton as K, defineCustomElement as d };
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h, d as Host, t as transformTag } from './p-5qkOM1RJ.js';
|
|
2
|
+
import { KritzelHTMLHelper } from '@kritzel/engine';
|
|
3
|
+
|
|
4
|
+
const kritzelDialogCss = () => `:host{display:contents}.dialog-content{text-align:start;line-height:normal}.backdrop{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10002;display:flex;align-items:center;justify-content:center;background-color:var(--kritzel-dialog-backdrop-color, rgba(0, 0, 0, 0.5));opacity:1;transition:opacity 150ms ease-out}.backdrop.is-animating{opacity:0}.dialog-content{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-dialog-background-color, #ffffff);border-radius:var(--kritzel-dialog-border-radius, 12px);box-shadow:var(--kritzel-dialog-box-shadow, 0 4px 20px rgba(0, 0, 0, 0.15));border:var(--kritzel-dialog-border, 1px solid #ebebeb);max-height:var(--kritzel-dialog-max-height, 90vh);max-width:var(--kritzel-dialog-max-width, 90vw);overflow:hidden;transform:scale(1);opacity:1;transition:transform 200ms ease-out, opacity 200ms ease-out;font-family:var(--kritzel-dialog-font-family, sans-serif)}.dialog-content.is-animating{transform:scale(0.95);opacity:0}.dialog-content.size-small{width:var(--kritzel-dialog-width-small, 320px);height:var(--kritzel-dialog-height-small, auto)}.dialog-content.size-medium{width:var(--kritzel-dialog-width-medium, 480px);height:var(--kritzel-dialog-height-medium, auto)}.dialog-content.size-large{width:var(--kritzel-dialog-width-large, 640px);height:var(--kritzel-dialog-height-large, auto)}.dialog-content.size-fullscreen{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}.backdrop.contained-fullscreen{background-color:transparent}.dialog-content.contained-fullscreen{border-radius:0}.dialog-content.contained-fullscreen .dialog-body{display:flex;flex-direction:column}.dialog-content.contained-fullscreen .dialog-body ::slotted(*){flex:1;min-height:0}@media (max-width: 576px), (max-height: 576px) and (orientation: landscape){.backdrop:has(.fullscreen-on-mobile){background-color:transparent}.dialog-content.fullscreen-on-mobile{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}.dialog-content.fullscreen-on-mobile .dialog-body{display:flex;flex-direction:column}.dialog-content.fullscreen-on-mobile .dialog-body ::slotted(*){flex:1;min-height:0}}.dialog-header{display:flex;align-items:center;justify-content:space-between;padding:var(--kritzel-dialog-header-padding, 16px 20px);border-bottom:var(--kritzel-dialog-header-border, 1px solid #ebebeb);gap:12px}.dialog-title{margin:0;font-size:var(--kritzel-dialog-title-font-size, 18px);font-weight:var(--kritzel-dialog-title-font-weight, 600);color:var(--kritzel-dialog-title-color, #1a1a1a);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.close-button{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:var(--kritzel-dialog-close-button-border-radius, 6px);background-color:var(--kritzel-dialog-close-button-background, transparent);color:var(--kritzel-dialog-close-button-color, #666666);cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 150ms ease, color 150ms ease;flex-shrink:0;-webkit-tap-highlight-color:transparent}.close-button:hover{background-color:var(--kritzel-dialog-close-button-hover-background, #f5f5f5);color:var(--kritzel-dialog-close-button-hover-color, #1a1a1a)}.close-button:active{background-color:var(--kritzel-dialog-close-button-active-background, #ebebeb)}.close-button:focus-visible{outline:revert;outline-offset:revert}.dialog-body{padding:var(--kritzel-dialog-body-padding, 20px);overflow-y:auto;flex:1;min-height:0;scrollbar-color:var(--kritzel-global-scrollbar-thumb-color, #ebebeb) transparent;scrollbar-width:thin}.dialog-footer{display:flex;align-items:center;justify-content:flex-end;gap:var(--kritzel-dialog-footer-gap, 8px);padding:var(--kritzel-dialog-footer-padding, 16px 20px);border-top:var(--kritzel-dialog-footer-border, 1px solid #ebebeb)}::slotted([slot='header']){flex:1}::slotted([slot='footer']){display:contents}`;
|
|
5
|
+
|
|
6
|
+
const KritzelDialog = /*@__PURE__*/ proxyCustomElement(class KritzelDialog extends H {
|
|
7
|
+
constructor(registerHost) {
|
|
8
|
+
super();
|
|
9
|
+
if (registerHost !== false) {
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
}
|
|
12
|
+
this.__attachShadow();
|
|
13
|
+
this.dialogOpen = createEvent(this, "dialogOpen");
|
|
14
|
+
this.dialogClose = createEvent(this, "dialogClose");
|
|
15
|
+
}
|
|
16
|
+
get host() { return this; }
|
|
17
|
+
/** Whether the dialog is open */
|
|
18
|
+
isOpen = false;
|
|
19
|
+
/** Optional title displayed in the header */
|
|
20
|
+
dialogTitle;
|
|
21
|
+
/** Whether to show the close button in the header */
|
|
22
|
+
closable = true;
|
|
23
|
+
/** Whether clicking the backdrop closes the dialog */
|
|
24
|
+
closeOnBackdrop = true;
|
|
25
|
+
/** Whether pressing Escape closes the dialog */
|
|
26
|
+
closeOnEscape = true;
|
|
27
|
+
/** Whether to auto-focus the first focusable element when opened */
|
|
28
|
+
autoFocus = true;
|
|
29
|
+
/** Whether to trap focus within the dialog */
|
|
30
|
+
trapFocus = true;
|
|
31
|
+
/** Size of the dialog */
|
|
32
|
+
size = 'medium';
|
|
33
|
+
/** Whether to automatically go fullscreen on mobile viewports */
|
|
34
|
+
fullscreenOnMobile = true;
|
|
35
|
+
/** Constrain the dialog to its nearest editor/container ancestor instead of the viewport. */
|
|
36
|
+
contained = false;
|
|
37
|
+
isAnimating = false;
|
|
38
|
+
mobileLockedHeight = null;
|
|
39
|
+
containerRect = null;
|
|
40
|
+
containerBorderRadius = null;
|
|
41
|
+
/** Emitted when the dialog opens */
|
|
42
|
+
dialogOpen;
|
|
43
|
+
/** Emitted when the dialog closes */
|
|
44
|
+
dialogClose;
|
|
45
|
+
previousOverflow = '';
|
|
46
|
+
previousActiveElement = null;
|
|
47
|
+
visualViewportListenersAttached = false;
|
|
48
|
+
containerElement = null;
|
|
49
|
+
containerResizeObserver = null;
|
|
50
|
+
containerTrackingFrame = null;
|
|
51
|
+
handleIsOpenChange(newValue) {
|
|
52
|
+
if (newValue) {
|
|
53
|
+
this.openDialog();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.closeDialog();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
handleKeyDown(event) {
|
|
60
|
+
if (!this.isOpen)
|
|
61
|
+
return;
|
|
62
|
+
if (event.key === 'Escape' && this.closeOnEscape) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
this.emitClose('escape');
|
|
66
|
+
}
|
|
67
|
+
if (event.key === 'Tab' && this.trapFocus) {
|
|
68
|
+
this.handleTabKey(event);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
handleWindowResize() {
|
|
72
|
+
if (!this.isOpen)
|
|
73
|
+
return;
|
|
74
|
+
this.lockMobileViewportHeight();
|
|
75
|
+
}
|
|
76
|
+
handleOrientationChange() {
|
|
77
|
+
if (!this.isOpen)
|
|
78
|
+
return;
|
|
79
|
+
// Let viewport metrics settle before recalculating after orientation flips.
|
|
80
|
+
requestAnimationFrame(() => this.lockMobileViewportHeight());
|
|
81
|
+
}
|
|
82
|
+
async open() {
|
|
83
|
+
if (!this.isOpen) {
|
|
84
|
+
this.isOpen = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async close(reason = 'programmatic') {
|
|
88
|
+
this.emitClose(reason);
|
|
89
|
+
}
|
|
90
|
+
async focusFirstElement() {
|
|
91
|
+
this.focusFirst();
|
|
92
|
+
}
|
|
93
|
+
componentDidLoad() {
|
|
94
|
+
if (this.isOpen) {
|
|
95
|
+
this.openDialog();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
disconnectedCallback() {
|
|
99
|
+
this.removeVisualViewportListeners();
|
|
100
|
+
this.stopContainerTracking();
|
|
101
|
+
this.restoreBodyScroll();
|
|
102
|
+
}
|
|
103
|
+
openDialog() {
|
|
104
|
+
this.isAnimating = true;
|
|
105
|
+
this.previousActiveElement = document.activeElement;
|
|
106
|
+
if (this.contained) {
|
|
107
|
+
this.startContainerTracking();
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.lockBodyScroll();
|
|
111
|
+
this.addVisualViewportListeners();
|
|
112
|
+
}
|
|
113
|
+
this.lockMobileViewportHeight();
|
|
114
|
+
this.dialogOpen.emit();
|
|
115
|
+
if (this.autoFocus) {
|
|
116
|
+
requestAnimationFrame(() => {
|
|
117
|
+
this.focusFirst();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
requestAnimationFrame(() => {
|
|
121
|
+
this.isAnimating = false;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
closeDialog() {
|
|
125
|
+
this.restoreBodyScroll();
|
|
126
|
+
this.removeVisualViewportListeners();
|
|
127
|
+
this.stopContainerTracking();
|
|
128
|
+
this.mobileLockedHeight = null;
|
|
129
|
+
this.returnFocusToPreviousElement();
|
|
130
|
+
}
|
|
131
|
+
findContainerElement() {
|
|
132
|
+
// Walk up the composed DOM (crossing shadow roots) and return the first
|
|
133
|
+
// ancestor that opts into containing dialogs. We accept either an explicit
|
|
134
|
+
// [data-kritzel-dialog-container] marker or the kritzel-editor host so any
|
|
135
|
+
// consumer can opt in without modifying the editor itself.
|
|
136
|
+
let node = this.host;
|
|
137
|
+
while (node) {
|
|
138
|
+
if (node instanceof H) {
|
|
139
|
+
if (node.hasAttribute('data-kritzel-dialog-container') || node.tagName === 'KRITZEL-EDITOR') {
|
|
140
|
+
return node;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const parent = node.parentNode;
|
|
144
|
+
if (parent) {
|
|
145
|
+
node = parent;
|
|
146
|
+
}
|
|
147
|
+
else if (node instanceof ShadowRoot) {
|
|
148
|
+
node = node.host;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
node = null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
startContainerTracking() {
|
|
157
|
+
this.containerElement = this.findContainerElement();
|
|
158
|
+
if (!this.containerElement) {
|
|
159
|
+
// No container found — fall back to viewport behavior.
|
|
160
|
+
this.containerRect = null;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.updateContainerRect();
|
|
164
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
165
|
+
this.containerResizeObserver = new ResizeObserver(() => this.updateContainerRect());
|
|
166
|
+
this.containerResizeObserver.observe(this.containerElement);
|
|
167
|
+
}
|
|
168
|
+
window.addEventListener('resize', this.handleContainerTrackingEvent, { passive: true });
|
|
169
|
+
window.addEventListener('scroll', this.handleContainerTrackingEvent, { capture: true, passive: true });
|
|
170
|
+
}
|
|
171
|
+
stopContainerTracking() {
|
|
172
|
+
if (this.containerResizeObserver) {
|
|
173
|
+
this.containerResizeObserver.disconnect();
|
|
174
|
+
this.containerResizeObserver = null;
|
|
175
|
+
}
|
|
176
|
+
window.removeEventListener('resize', this.handleContainerTrackingEvent);
|
|
177
|
+
window.removeEventListener('scroll', this.handleContainerTrackingEvent, { capture: true });
|
|
178
|
+
if (this.containerTrackingFrame !== null) {
|
|
179
|
+
cancelAnimationFrame(this.containerTrackingFrame);
|
|
180
|
+
this.containerTrackingFrame = null;
|
|
181
|
+
}
|
|
182
|
+
this.containerElement = null;
|
|
183
|
+
this.containerRect = null;
|
|
184
|
+
this.containerBorderRadius = null;
|
|
185
|
+
}
|
|
186
|
+
handleContainerTrackingEvent = () => {
|
|
187
|
+
if (this.containerTrackingFrame !== null)
|
|
188
|
+
return;
|
|
189
|
+
this.containerTrackingFrame = requestAnimationFrame(() => {
|
|
190
|
+
this.containerTrackingFrame = null;
|
|
191
|
+
this.updateContainerRect();
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
updateContainerRect() {
|
|
195
|
+
if (!this.containerElement)
|
|
196
|
+
return;
|
|
197
|
+
const rect = this.containerElement.getBoundingClientRect();
|
|
198
|
+
const next = { top: rect.top, left: rect.left, width: rect.width, height: rect.height };
|
|
199
|
+
const prev = this.containerRect;
|
|
200
|
+
if (!prev || prev.top !== next.top || prev.left !== next.left || prev.width !== next.width || prev.height !== next.height) {
|
|
201
|
+
this.containerRect = next;
|
|
202
|
+
}
|
|
203
|
+
// Look for the nearest visually-rounded ancestor (the container itself or
|
|
204
|
+
// any ancestor up to the document) so the backdrop matches wrappers that
|
|
205
|
+
// round their corners around the editor.
|
|
206
|
+
const radius = this.findVisualBorderRadius(this.containerElement);
|
|
207
|
+
if (this.containerBorderRadius !== radius) {
|
|
208
|
+
this.containerBorderRadius = radius;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
findVisualBorderRadius(start) {
|
|
212
|
+
let node = start;
|
|
213
|
+
while (node && node !== document.body && node !== document.documentElement) {
|
|
214
|
+
const computed = window.getComputedStyle(node);
|
|
215
|
+
const tl = computed.borderTopLeftRadius;
|
|
216
|
+
const tr = computed.borderTopRightRadius;
|
|
217
|
+
const br = computed.borderBottomRightRadius;
|
|
218
|
+
const bl = computed.borderBottomLeftRadius;
|
|
219
|
+
const isZero = (v) => !v || v === '0px' || v === '0%';
|
|
220
|
+
if (!(isZero(tl) && isZero(tr) && isZero(br) && isZero(bl))) {
|
|
221
|
+
return `${tl} ${tr} ${br} ${bl}`;
|
|
222
|
+
}
|
|
223
|
+
node = node.parentElement;
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
emitClose(reason) {
|
|
228
|
+
this.dialogClose.emit({ reason });
|
|
229
|
+
}
|
|
230
|
+
lockBodyScroll() {
|
|
231
|
+
this.previousOverflow = document.body.style.overflow;
|
|
232
|
+
document.body.style.overflow = 'hidden';
|
|
233
|
+
}
|
|
234
|
+
lockMobileViewportHeight() {
|
|
235
|
+
// Skip mobile viewport height locking when contained — the dialog is sized
|
|
236
|
+
// by its wrapper, not the viewport.
|
|
237
|
+
if (this.contained) {
|
|
238
|
+
this.mobileLockedHeight = null;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
// Only lock height on mobile when fullscreenOnMobile is enabled.
|
|
242
|
+
// Use the smaller dimension so landscape phones (wide but short) are also detected.
|
|
243
|
+
const viewportWidth = this.getViewportWidth();
|
|
244
|
+
const viewportHeight = this.getViewportHeight();
|
|
245
|
+
if (!this.fullscreenOnMobile || Math.min(viewportWidth, viewportHeight) > 576) {
|
|
246
|
+
this.mobileLockedHeight = null;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.mobileLockedHeight = `${viewportHeight}px`;
|
|
250
|
+
}
|
|
251
|
+
getViewportWidth() {
|
|
252
|
+
return Math.round(window.visualViewport?.width ?? window.innerWidth);
|
|
253
|
+
}
|
|
254
|
+
getViewportHeight() {
|
|
255
|
+
return Math.round(window.visualViewport?.height ?? window.innerHeight);
|
|
256
|
+
}
|
|
257
|
+
addVisualViewportListeners() {
|
|
258
|
+
const viewport = window.visualViewport;
|
|
259
|
+
if (!viewport || this.visualViewportListenersAttached)
|
|
260
|
+
return;
|
|
261
|
+
viewport.addEventListener('resize', this.handleVisualViewportChange);
|
|
262
|
+
viewport.addEventListener('scroll', this.handleVisualViewportChange);
|
|
263
|
+
this.visualViewportListenersAttached = true;
|
|
264
|
+
}
|
|
265
|
+
removeVisualViewportListeners() {
|
|
266
|
+
const viewport = window.visualViewport;
|
|
267
|
+
if (!viewport || !this.visualViewportListenersAttached)
|
|
268
|
+
return;
|
|
269
|
+
viewport.removeEventListener('resize', this.handleVisualViewportChange);
|
|
270
|
+
viewport.removeEventListener('scroll', this.handleVisualViewportChange);
|
|
271
|
+
this.visualViewportListenersAttached = false;
|
|
272
|
+
}
|
|
273
|
+
handleVisualViewportChange = () => {
|
|
274
|
+
if (!this.isOpen)
|
|
275
|
+
return;
|
|
276
|
+
this.lockMobileViewportHeight();
|
|
277
|
+
};
|
|
278
|
+
restoreBodyScroll() {
|
|
279
|
+
document.body.style.overflow = this.previousOverflow;
|
|
280
|
+
}
|
|
281
|
+
returnFocusToPreviousElement() {
|
|
282
|
+
if (this.previousActiveElement?.focus) {
|
|
283
|
+
this.previousActiveElement.focus();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
focusFirst() {
|
|
287
|
+
const dialogContent = this.host.shadowRoot?.querySelector('.dialog-content');
|
|
288
|
+
if (!dialogContent)
|
|
289
|
+
return;
|
|
290
|
+
const focusableElements = KritzelHTMLHelper.getFocusableElements(dialogContent);
|
|
291
|
+
const slotElements = this.getSlottedFocusableElements();
|
|
292
|
+
const allFocusable = [...focusableElements, ...slotElements];
|
|
293
|
+
if (allFocusable.length > 0) {
|
|
294
|
+
allFocusable[0].focus();
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
dialogContent.focus();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
getSlottedFocusableElements() {
|
|
301
|
+
const slots = this.host.shadowRoot?.querySelectorAll('slot') ?? [];
|
|
302
|
+
const focusable = [];
|
|
303
|
+
slots.forEach(slot => {
|
|
304
|
+
const assigned = slot.assignedElements({ flatten: true });
|
|
305
|
+
assigned.forEach(el => {
|
|
306
|
+
// Use KritzelHTMLHelper to find focusable elements including those in nested shadow DOMs
|
|
307
|
+
const elements = KritzelHTMLHelper.getFocusableElements(el);
|
|
308
|
+
focusable.push(...elements);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
return focusable;
|
|
312
|
+
}
|
|
313
|
+
handleTabKey(event) {
|
|
314
|
+
const focusableElements = this.getSlottedFocusableElements();
|
|
315
|
+
const closeButton = this.host.shadowRoot?.querySelector('.close-button');
|
|
316
|
+
if (closeButton && this.closable) {
|
|
317
|
+
focusableElements.unshift(closeButton);
|
|
318
|
+
}
|
|
319
|
+
if (focusableElements.length === 0)
|
|
320
|
+
return;
|
|
321
|
+
const firstFocusable = focusableElements[0];
|
|
322
|
+
const lastFocusable = focusableElements[focusableElements.length - 1];
|
|
323
|
+
const activeElement = this.getDeepActiveElement();
|
|
324
|
+
if (event.shiftKey) {
|
|
325
|
+
if (activeElement === firstFocusable) {
|
|
326
|
+
event.preventDefault();
|
|
327
|
+
lastFocusable.focus();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
if (activeElement === lastFocusable) {
|
|
332
|
+
event.preventDefault();
|
|
333
|
+
firstFocusable.focus();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
getDeepActiveElement() {
|
|
338
|
+
let activeEl = document.activeElement;
|
|
339
|
+
while (activeEl?.shadowRoot?.activeElement) {
|
|
340
|
+
activeEl = activeEl.shadowRoot.activeElement;
|
|
341
|
+
}
|
|
342
|
+
return activeEl;
|
|
343
|
+
}
|
|
344
|
+
handleBackdropClick = (event) => {
|
|
345
|
+
event.stopPropagation();
|
|
346
|
+
if (this.closeOnBackdrop) {
|
|
347
|
+
this.emitClose('backdrop');
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
handleCloseButtonClick = (event) => {
|
|
351
|
+
event.stopPropagation();
|
|
352
|
+
this.emitClose('close-button');
|
|
353
|
+
};
|
|
354
|
+
handleContentClick = (event) => {
|
|
355
|
+
event.stopPropagation();
|
|
356
|
+
};
|
|
357
|
+
renderCloseButton() {
|
|
358
|
+
if (!this.closable)
|
|
359
|
+
return null;
|
|
360
|
+
return (h("button", { class: "close-button", type: "button", "aria-label": "Close dialog", onClick: this.handleCloseButtonClick }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" }))));
|
|
361
|
+
}
|
|
362
|
+
renderHeader() {
|
|
363
|
+
const hasHeaderSlot = this.host.querySelector('[slot="header"]') !== null;
|
|
364
|
+
const hasTitle = !!this.dialogTitle;
|
|
365
|
+
if (!hasHeaderSlot && !hasTitle && !this.closable)
|
|
366
|
+
return null;
|
|
367
|
+
return (h("div", { class: "dialog-header" }, hasHeaderSlot ? (h("slot", { name: "header" })) : hasTitle ? (h("h2", { class: "dialog-title" }, this.dialogTitle)) : null, this.renderCloseButton()));
|
|
368
|
+
}
|
|
369
|
+
renderFooter() {
|
|
370
|
+
const hasFooterSlot = this.host.querySelector('[slot="footer"]') !== null;
|
|
371
|
+
if (!hasFooterSlot)
|
|
372
|
+
return null;
|
|
373
|
+
return (h("div", { class: "dialog-footer" }, h("slot", { name: "footer" })));
|
|
374
|
+
}
|
|
375
|
+
getBackdropStyle() {
|
|
376
|
+
if (!this.contained || !this.containerRect)
|
|
377
|
+
return undefined;
|
|
378
|
+
const { top, left, width, height } = this.containerRect;
|
|
379
|
+
const style = {
|
|
380
|
+
top: `${top}px`,
|
|
381
|
+
left: `${left}px`,
|
|
382
|
+
right: 'auto',
|
|
383
|
+
bottom: 'auto',
|
|
384
|
+
width: `${width}px`,
|
|
385
|
+
height: `${height}px`,
|
|
386
|
+
};
|
|
387
|
+
if (this.containerBorderRadius) {
|
|
388
|
+
style.borderRadius = this.containerBorderRadius;
|
|
389
|
+
// Ensure rounded corners actually clip the inner dialog content.
|
|
390
|
+
style.overflow = 'hidden';
|
|
391
|
+
}
|
|
392
|
+
return style;
|
|
393
|
+
}
|
|
394
|
+
getDialogContentStyle() {
|
|
395
|
+
const style = {};
|
|
396
|
+
// In contained mode, cap the dialog dimensions to the container so the
|
|
397
|
+
// declared widths/heights of size variants cannot overflow the wrapper.
|
|
398
|
+
if (this.contained && this.containerRect) {
|
|
399
|
+
const { width, height } = this.containerRect;
|
|
400
|
+
if (this.isContainerMobile()) {
|
|
401
|
+
// Mobile-sized container: behave like fullscreen-on-mobile but scoped
|
|
402
|
+
// to the container instead of the viewport (works in any orientation).
|
|
403
|
+
style.width = `${width}px`;
|
|
404
|
+
style.height = `${height}px`;
|
|
405
|
+
style.maxWidth = `${width}px`;
|
|
406
|
+
style.maxHeight = `${height}px`;
|
|
407
|
+
style.borderRadius = '0';
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
// Leave a small margin so the dialog visibly sits within the container.
|
|
411
|
+
const maxWidth = Math.max(0, width - 32);
|
|
412
|
+
const maxHeight = Math.max(0, height - 32);
|
|
413
|
+
style.maxWidth = `${maxWidth}px`;
|
|
414
|
+
style.maxHeight = `${maxHeight}px`;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (this.mobileLockedHeight) {
|
|
418
|
+
style.height = this.mobileLockedHeight;
|
|
419
|
+
style.maxHeight = this.mobileLockedHeight;
|
|
420
|
+
}
|
|
421
|
+
return Object.keys(style).length > 0 ? style : undefined;
|
|
422
|
+
}
|
|
423
|
+
isContainerMobile() {
|
|
424
|
+
if (!this.fullscreenOnMobile || !this.containerRect)
|
|
425
|
+
return false;
|
|
426
|
+
// Match the existing viewport media-query threshold: container is "mobile"
|
|
427
|
+
// when its smaller dimension is <= 576px. This handles both portrait and
|
|
428
|
+
// landscape wrappers symmetrically.
|
|
429
|
+
return Math.min(this.containerRect.width, this.containerRect.height) <= 576;
|
|
430
|
+
}
|
|
431
|
+
render() {
|
|
432
|
+
if (!this.isOpen)
|
|
433
|
+
return null;
|
|
434
|
+
const containerFullscreen = this.contained && this.isContainerMobile();
|
|
435
|
+
return (h(Host, null, h("div", { class: { backdrop: true, 'is-animating': this.isAnimating, 'contained-fullscreen': containerFullscreen }, style: this.getBackdropStyle(), onClick: this.handleBackdropClick }, h("div", { class: {
|
|
436
|
+
'dialog-content': true,
|
|
437
|
+
'is-animating': this.isAnimating,
|
|
438
|
+
[`size-${this.size}`]: true,
|
|
439
|
+
'fullscreen-on-mobile': this.fullscreenOnMobile,
|
|
440
|
+
'contained-fullscreen': containerFullscreen,
|
|
441
|
+
}, style: this.getDialogContentStyle(), role: "dialog", "aria-modal": "true", "aria-labelledby": this.dialogTitle ? 'dialog-title' : undefined, tabIndex: -1, onClick: this.handleContentClick }, this.renderHeader(), h("div", { class: "dialog-body" }, h("slot", null)), this.renderFooter()))));
|
|
442
|
+
}
|
|
443
|
+
static get watchers() { return {
|
|
444
|
+
"isOpen": [{
|
|
445
|
+
"handleIsOpenChange": 0
|
|
446
|
+
}]
|
|
447
|
+
}; }
|
|
448
|
+
static get style() { return kritzelDialogCss(); }
|
|
449
|
+
}, [769, "kritzel-dialog", {
|
|
450
|
+
"isOpen": [516, "is-open"],
|
|
451
|
+
"dialogTitle": [1, "dialog-title"],
|
|
452
|
+
"closable": [4],
|
|
453
|
+
"closeOnBackdrop": [4, "close-on-backdrop"],
|
|
454
|
+
"closeOnEscape": [4, "close-on-escape"],
|
|
455
|
+
"autoFocus": [4, "auto-focus"],
|
|
456
|
+
"trapFocus": [4, "trap-focus"],
|
|
457
|
+
"size": [1],
|
|
458
|
+
"fullscreenOnMobile": [4, "fullscreen-on-mobile"],
|
|
459
|
+
"contained": [516],
|
|
460
|
+
"isAnimating": [32],
|
|
461
|
+
"mobileLockedHeight": [32],
|
|
462
|
+
"containerRect": [32],
|
|
463
|
+
"containerBorderRadius": [32],
|
|
464
|
+
"open": [64],
|
|
465
|
+
"close": [64],
|
|
466
|
+
"focusFirstElement": [64]
|
|
467
|
+
}, [[8, "keydown", "handleKeyDown"], [9, "resize", "handleWindowResize"], [8, "orientationchange", "handleOrientationChange"]], {
|
|
468
|
+
"isOpen": [{
|
|
469
|
+
"handleIsOpenChange": 0
|
|
470
|
+
}]
|
|
471
|
+
}]);
|
|
472
|
+
function defineCustomElement() {
|
|
473
|
+
if (typeof customElements === "undefined") {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const components = ["kritzel-dialog"];
|
|
477
|
+
components.forEach(tagName => { switch (tagName) {
|
|
478
|
+
case "kritzel-dialog":
|
|
479
|
+
if (!customElements.get(transformTag(tagName))) {
|
|
480
|
+
customElements.define(transformTag(tagName), KritzelDialog);
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
} });
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export { KritzelDialog as K, defineCustomElement as d };
|