@webority/ui-elements 0.171.2 → 0.172.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/dist/WuiCarousel-CFKmFVzc.js +1 -0
- package/dist/{WuiCodeBlock-Du-JZO3A.js → WuiCodeBlock-fBc3Uwsw.js} +1 -1
- package/dist/{WuiCommandPalette-BKW0e-ho.js → WuiCommandPalette-BQCy0bon.js} +2 -2
- package/dist/WuiCommentThread-jy4rMc9Q.js +1 -0
- package/dist/WuiConsentBanner-DlAE3DTf.js +1 -0
- package/dist/WuiContextMenu-hLeCs0qw.js +1 -0
- package/dist/WuiDataTable-B-JaTsrI.js +1 -0
- package/dist/WuiDatePicker-4tdWakGX.js +1 -0
- package/dist/WuiDateRange-D7LJuY2F.js +1 -0
- package/dist/WuiDateTime-BSJfyZ0q.js +1 -0
- package/dist/{WuiDock-d5abaLkL.js → WuiDock-2LGlbEFx.js} +1 -1
- package/dist/{WuiDrawer-BMkPnEFz.js → WuiDrawer-D-XfW1kl.js} +1 -1
- package/dist/{WuiDropdown-B9WeT-gH.js → WuiDropdown-5-6E5Q9d.js} +1 -1
- package/dist/{WuiEntryGrid-Bm5_MizA.js → WuiEntryGrid-DkW0tIDy.js} +1 -1
- package/dist/WuiGantt-XMvgsZsn.js +1 -0
- package/dist/{WuiHoverCard-D6JBAqdW.js → WuiHoverCard-DhJcIIM1.js} +1 -1
- package/dist/WuiImageCrop-CIAjHOGk.js +1 -0
- package/dist/WuiInlineEdit-C9FxCWCk.js +1 -0
- package/dist/WuiLeadPopup-KyguGV-q.js +345 -0
- package/dist/WuiLightbox-CBiqJmGE.js +1 -0
- package/dist/WuiMarkdown-DsN4YbiZ.js +4 -0
- package/dist/WuiMentionInput-CktKQjQc.js +1 -0
- package/dist/{WuiModal-DMGgOCBU.js → WuiModal-DQbVJGUo.js} +1 -1
- package/dist/WuiNavigationMenu-KdW7yuLn.js +1 -0
- package/dist/{WuiNotificationCenter-DgcJYPV3.js → WuiNotificationCenter-DZariS2K.js} +1 -1
- package/dist/WuiOrgTree-CFxoY9Vr.js +1 -0
- package/dist/WuiOtp-Cc0formv.js +1 -0
- package/dist/{WuiOverflow-MzrZwzud.js → WuiOverflow-CXYk2ubC.js} +1 -1
- package/dist/WuiPhone-BI438y4S.js +1 -0
- package/dist/{WuiPopover-BYO_H-fk.js → WuiPopover-BvWKRNQY.js} +1 -1
- package/dist/{WuiRating-DLVduJZ_.js → WuiRating-DIQfif9x.js} +1 -1
- package/dist/{WuiRecordPager-Dye7AfCS.js → WuiRecordPager-DAyoD650.js} +1 -1
- package/dist/{WuiRelativeTime-CujAFS_w.js → WuiRelativeTime-CPzs4tjM.js} +1 -1
- package/dist/WuiSavedViews-BAqHgVj2.js +1 -0
- package/dist/WuiSelect-htggZB0v.js +1 -0
- package/dist/{WuiShortcuts-Crj8lFVz.js → WuiShortcuts-DWzmRKEG.js} +1 -1
- package/dist/{WuiShowMore-CGhWrlmK.js → WuiShowMore-DyfGnrob.js} +1 -1
- package/dist/WuiSlider-LE2wquOo.js +1 -0
- package/dist/WuiSortable-DxwYjicc.js +1 -0
- package/dist/WuiTimePicker-xrPYytjq.js +1 -0
- package/dist/WuiTour-D-H5sMJS.js +1 -0
- package/dist/WuiTree-BnlK9fYL.js +1 -0
- package/dist/WuiTreePicker-Bx9nvRrC.js +1 -0
- package/dist/{WuiWhatsNew-DjnQWqlF.js → WuiWhatsNew-Dm4Yl68x.js} +1 -1
- package/dist/WuiWizardStep-n8Ge5GDI.js +1 -0
- package/dist/anchorOverlay-daGdh_91.js +1 -0
- package/dist/avatarNode-BaEvz5Xr.js +1 -0
- package/dist/{calendarMath-DIoh4HjR.js → calendarMath-rI1aBVRd.js} +1 -1
- package/dist/chips-DrTvHdbb.js +2 -0
- package/dist/{dataTable-oR_YiFJc.js → dataTable-Bz6HxUx0.js} +1 -1
- package/dist/dataTable.g-DazoWWps.js +1 -0
- package/dist/datePicker.g-sGQE8c3n.js +1 -0
- package/dist/dom-DMQu--xV.js +1 -0
- package/dist/drawerDiscard-B33Oc_Sv.js +1 -0
- package/dist/elements/carousel.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command-palette.js +1 -1
- package/dist/elements/comment-thread.js +1 -1
- package/dist/elements/consent-banner.js +1 -1
- package/dist/elements/context-menu.js +1 -1
- package/dist/elements/data-table.js +1 -1
- package/dist/elements/date-range.js +1 -1
- package/dist/elements/date-time.js +1 -0
- package/dist/elements/datepicker.js +1 -1
- package/dist/elements/dock.js +1 -1
- package/dist/elements/drawer.js +1 -1
- package/dist/elements/dropdown.js +1 -1
- package/dist/elements/entry-grid.js +1 -1
- package/dist/elements/filter-popover.js +1 -1
- package/dist/elements/gantt.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/image-crop.js +1 -1
- package/dist/elements/inline-edit.js +1 -1
- package/dist/elements/kanban.js +1 -1
- package/dist/elements/lead-popup.js +1 -1
- package/dist/elements/lightbox.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/mention-input.js +1 -1
- package/dist/elements/modal.js +1 -1
- package/dist/elements/navigation-menu.js +1 -1
- package/dist/elements/notification-center.js +1 -1
- package/dist/elements/org-tree.js +1 -1
- package/dist/elements/otp.js +1 -1
- package/dist/elements/overflow.js +1 -1
- package/dist/elements/phone.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/rating.js +1 -1
- package/dist/elements/record-pager.js +1 -1
- package/dist/elements/relative-time.js +1 -1
- package/dist/elements/saved-views.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/shortcuts.js +1 -1
- package/dist/elements/show-more.js +1 -1
- package/dist/elements/slider.js +1 -1
- package/dist/elements/sortable.js +1 -1
- package/dist/elements/status-icon.js +1 -1
- package/dist/elements/timepicker.js +1 -1
- package/dist/elements/tour.js +1 -1
- package/dist/elements/tree-picker.js +1 -1
- package/dist/elements/tree.js +1 -1
- package/dist/elements/whats-new.js +1 -1
- package/dist/elements/wizard.js +1 -1
- package/dist/fileViewer.g-B6N9K2xi.js +1 -0
- package/dist/{fileViewerImage-uL9m83k1.js → fileViewerImage-ItX9j9U9.js} +2 -2
- package/dist/fileViewerMedia-BCqp2Z96.js +1 -0
- package/dist/{fileViewerPdf-BsSc-9fL.js → fileViewerPdf-aaI2R2nB.js} +2 -2
- package/dist/{filterPopover-C_oDfQBg.js → filterPopover-D7LGrhnO.js} +1 -1
- package/dist/formatters-DikbTYA4.js +1 -0
- package/dist/helpers.js +1 -1
- package/dist/iconGlyphs.g-P04RJkSE.js +1 -0
- package/dist/{inlineEditText-CGaAKZhR.js → inlineEditText-C6g6qhye.js} +1 -1
- package/dist/kanban-CX6DyApZ.js +1 -0
- package/dist/{kanbanModel-sAwpMCpn.js → kanbanModel-CuMgMnSc.js} +1 -1
- package/dist/loader-B3lirubB.js +1 -0
- package/dist/{nativeOverlay-DGady-wN.js → nativeOverlay-BHD2QV02.js} +1 -1
- package/dist/{notificationDays-DQlrEZ3z.js → notificationDays-grsj1DtM.js} +1 -1
- package/dist/optionLabel-CmrOSHbD.js +1 -0
- package/dist/{relativeTime-CQuwuwZ-.js → relativeTime-vdCXtfKg.js} +1 -1
- package/dist/rtl-g7G8Bsib.js +1 -0
- package/dist/{search-w5M6FzD9.js → search-DwboX91o.js} +1 -1
- package/dist/server.js +1 -1
- package/dist/serverHtml-BC6tAyAl.js +1 -0
- package/dist/{shortcutKeys-DmPiY4T7.js → shortcutKeys-6iLc6oDR.js} +1 -1
- package/dist/statusIcons-Cd3GJcBR.js +1 -0
- package/dist/svgNodes-CyPS2oFH.js +1 -0
- package/dist/tableExport-D1OdFVQj.js +2 -0
- package/dist/tableSelect.g-Bmd-ExRE.js +1 -0
- package/dist/text/en.json +14 -2
- package/dist/text.js +1 -1
- package/dist/{themeTransition-CA1qzCZk.js → themeTransition-D7HJ4A4m.js} +1 -1
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-chart.global.js +15 -15
- package/dist/ui-chart.js +10 -10
- package/dist/ui-consent-banner.global.js +1 -1
- package/dist/ui-elements/carousel.global.js +1 -1
- package/dist/ui-elements/code-block.global.js +1 -1
- package/dist/ui-elements/command-palette.global.js +2 -2
- package/dist/ui-elements/comment-thread.global.js +1 -1
- package/dist/ui-elements/consent-banner.global.js +1 -1
- package/dist/ui-elements/context-menu.global.js +1 -1
- package/dist/ui-elements/date-range.global.js +1 -25
- package/dist/ui-elements/date-time.global.js +1 -0
- package/dist/ui-elements/datepicker.global.js +1 -0
- package/dist/ui-elements/drawer.global.js +1 -1
- package/dist/ui-elements/dropdown.global.js +1 -1
- package/dist/ui-elements/entry-grid.global.js +1 -1
- package/dist/ui-elements/gantt.global.js +1 -1
- package/dist/ui-elements/glyphs.global.js +1 -1
- package/dist/ui-elements/image-crop.global.js +1 -17
- package/dist/ui-elements/inline-edit.global.js +1 -1
- package/dist/ui-elements/kanban.global.js +1 -1
- package/dist/ui-elements/lead-popup.global.js +40 -77
- package/dist/ui-elements/lightbox.global.js +1 -1
- package/dist/ui-elements/markdown.global.js +3 -3
- package/dist/ui-elements/org-tree.global.js +1 -1
- package/dist/ui-elements/phone.global.js +1 -16
- package/dist/ui-elements/popover.global.js +1 -1
- package/dist/ui-elements/saved-views.global.js +1 -1
- package/dist/ui-elements/select-chips.global.js +2 -2
- package/dist/ui-elements/select-recents.global.js +1 -1
- package/dist/ui-elements/select-search.global.js +1 -1
- package/dist/ui-elements/select-window.global.js +1 -1
- package/dist/ui-elements/slider.global.js +1 -51
- package/dist/ui-elements/sortable.global.js +1 -1
- package/dist/ui-elements/status-icon.global.js +1 -10
- package/dist/ui-elements/table-export.global.js +2 -0
- package/dist/ui-elements/timepicker.global.js +1 -9
- package/dist/ui-elements/tour.global.js +1 -1
- package/dist/ui-elements/tree-picker.global.js +1 -1
- package/dist/ui-elements/tree.global.js +1 -1
- package/dist/ui-elements/wizard.global.js +1 -1
- package/dist/ui-elements.global.js +1 -55
- package/dist/ui-elements.js +1 -1
- package/dist/ui-file-viewer.global.js +11 -11
- package/dist/ui-file-viewer.js +1 -1
- package/dist/ui-lead-popup.global.js +1 -1
- package/dist/ui-rich-text.global.js +53 -63
- package/dist/ui-rich-text.js +53 -63
- package/dist/ui-tour.global.js +1 -1
- package/dist/wuiHttp-BWf9dDsZ.js +1 -0
- package/dist/zone-BR02ZkHF.js +1 -0
- package/package.json +10 -6
- package/types/WuiCommandPalette.d.ts +0 -60
- package/types/WuiDataTable.d.ts +2 -0
- package/types/WuiDatePicker.d.ts +6 -4
- package/types/WuiDateRange.d.ts +2 -2
- package/types/WuiDateTime.d.ts +26 -0
- package/types/WuiInlineEdit.d.ts +1 -1
- package/types/WuiLeadPopup.d.ts +1 -1
- package/types/WuiMarkdown.d.ts +4 -4
- package/types/WuiNavigationMenu.d.ts +30 -0
- package/types/WuiOrgTree.d.ts +12 -0
- package/types/WuiTimePicker.d.ts +1 -1
- package/types/WuiTree.d.ts +58 -0
- package/types/WuiTreePicker.d.ts +38 -0
- package/types/WuiWizard.d.ts +3 -3
- package/types/anchorOverlay.d.ts +3 -1
- package/types/{avatarHtml.d.ts → avatarNode.d.ts} +3 -3
- package/types/chartSpec.d.ts +10 -1
- package/types/dom.d.ts +7 -0
- package/types/elements/date-time.d.ts +2 -0
- package/types/global/core.d.ts +2 -3
- package/types/global/glyphs.d.ts +5 -4
- package/types/global/parts/table-export.d.ts +1 -0
- package/types/global/shared.d.ts +12 -2
- package/types/global/tableExport.d.ts +6 -0
- package/types/globals.d.ts +3 -1
- package/types/helpers.d.ts +3 -2
- package/types/iconGlyphs.g.d.ts +5 -4
- package/types/iconGlyphsCore.g.d.ts +2 -1
- package/types/iconGlyphsLazy.g.d.ts +2 -1
- package/types/index.d.ts +2 -1
- package/types/optionLabel.d.ts +9 -15
- package/types/razor-js/modules/shared.d.ts +1 -1
- package/types/razor-js/webority-ui.d.ts +1 -0
- package/types/richTextIcons.d.ts +14 -1
- package/types/rtl.d.ts +2 -0
- package/types/select/list.d.ts +9 -4
- package/types/server/index.d.ts +2 -1
- package/types/server/serverHtml.d.ts +6 -0
- package/types/server/serverTable.d.ts +1 -1
- package/types/server/wuiHttp.d.ts +8 -1
- package/types/svgNodes.d.ts +7 -0
- package/types/tableExport.d.ts +9 -0
- package/types/tableExportLoader.d.ts +4 -0
- package/types/text/web/chart.g.d.ts +1 -0
- package/types/text/web/confirmDialog.g.d.ts +1 -0
- package/types/text/web/dataTable.g.d.ts +7 -0
- package/types/text/web/datePicker.g.d.ts +2 -0
- package/types/text/web/modal.g.d.ts +1 -0
- package/types/toastTypes.d.ts +2 -1
- package/types/tooltips.d.ts +3 -3
- package/dist/WuiCarousel-CRx2-eKV.js +0 -1
- package/dist/WuiCommentThread-DZEYOHsk.js +0 -1
- package/dist/WuiConsentBanner-CWvXnwBH.js +0 -1
- package/dist/WuiContextMenu-DvYwIicr.js +0 -1
- package/dist/WuiDataTable-BSMhRQ1i.js +0 -1
- package/dist/WuiDatePicker-DxPethoe.js +0 -34
- package/dist/WuiDateRange-zPmNewOW.js +0 -25
- package/dist/WuiGantt-DaEgtdOU.js +0 -1
- package/dist/WuiImageCrop-BTY59Qsm.js +0 -17
- package/dist/WuiInlineEdit-BlsGNQSC.js +0 -1
- package/dist/WuiLeadPopup-L9UCTVA5.js +0 -382
- package/dist/WuiLightbox-BnLEEkj1.js +0 -1
- package/dist/WuiMarkdown-B7nfQ6tW.js +0 -4
- package/dist/WuiMentionInput-DvKw8MXS.js +0 -1
- package/dist/WuiNavigationMenu-CfD0FWvt.js +0 -1
- package/dist/WuiOrgTree-5v0vqPVk.js +0 -1
- package/dist/WuiOtp-DonxSwVn.js +0 -14
- package/dist/WuiPhone-BFb_LjJa.js +0 -16
- package/dist/WuiSavedViews-BsAyuOzX.js +0 -1
- package/dist/WuiSelect-iE3EVUWK.js +0 -9
- package/dist/WuiSlider-J9YPWu9e.js +0 -51
- package/dist/WuiSortable-BfOm57Mj.js +0 -1
- package/dist/WuiTimePicker-BsnPOYNw.js +0 -9
- package/dist/WuiTour-C2CRQvS7.js +0 -1
- package/dist/WuiTree-DGZSXgBh.js +0 -1
- package/dist/WuiTreePicker-CkTfNUQx.js +0 -1
- package/dist/WuiWizardStep-CryQ5BlK.js +0 -1
- package/dist/anchorOverlay-DSzkGQPi.js +0 -1
- package/dist/avatarHtml-BWlA0cm-.js +0 -1
- package/dist/chips-B4ZNRO-h.js +0 -2
- package/dist/dataTable.g-BVxhub_d.js +0 -1
- package/dist/datePicker.g-VdBlhA2G.js +0 -1
- package/dist/dom-Do1pAA12.js +0 -1
- package/dist/drawerDiscard-B4OcoR8S.js +0 -1
- package/dist/fileViewer.g-D5lbrn8g.js +0 -1
- package/dist/fileViewerMedia-cfmycjzl.js +0 -1
- package/dist/formatters-CMTSYlW9.js +0 -1
- package/dist/iconGlyphs.g-BUF97bUu.js +0 -1
- package/dist/kanban-CRRLqNn_.js +0 -1
- package/dist/loader-Cf_ozcXz.js +0 -1
- package/dist/optionLabel-CWMhBkdO.js +0 -1
- package/dist/statusIcons-CRtqA_1C.js +0 -10
- package/dist/tableSelect.g-DKZqXQT_.js +0 -1
- package/dist/wuiHttp-DGbD7Fra.js +0 -1
|
@@ -2,11 +2,16 @@ export type DataTableText = {
|
|
|
2
2
|
readonly actionFailedMessage: string;
|
|
3
3
|
readonly actionForbiddenMessage: string;
|
|
4
4
|
readonly collapseRowLabel: string;
|
|
5
|
+
readonly densityComfortableLabel: string;
|
|
6
|
+
readonly densityCompactLabel: string;
|
|
7
|
+
readonly densityLabel: string;
|
|
5
8
|
readonly empty: string;
|
|
6
9
|
readonly emptyLabel: string;
|
|
7
10
|
readonly errorText: string;
|
|
8
11
|
readonly expandLabel: string;
|
|
9
12
|
readonly expandRowLabel: string;
|
|
13
|
+
readonly exportCsvLabel: string;
|
|
14
|
+
readonly exportExcelLabel: string;
|
|
10
15
|
readonly forbiddenMessage: string;
|
|
11
16
|
readonly groupRowsOne: string;
|
|
12
17
|
readonly groupRowsOther: string;
|
|
@@ -15,6 +20,7 @@ export type DataTableText = {
|
|
|
15
20
|
readonly networkMessage: string;
|
|
16
21
|
readonly pageTextOne: string;
|
|
17
22
|
readonly pageTextOther: string;
|
|
23
|
+
readonly pageTextPending: string;
|
|
18
24
|
readonly resizeColumnLabel: string;
|
|
19
25
|
readonly resizeColumnText: string;
|
|
20
26
|
readonly resizeText: string;
|
|
@@ -26,6 +32,7 @@ export type DataTableText = {
|
|
|
26
32
|
readonly savedText: string;
|
|
27
33
|
readonly selectAllRowsLabel: string;
|
|
28
34
|
readonly selectRowLabel: string;
|
|
35
|
+
readonly timeoutMessage: string;
|
|
29
36
|
readonly wasNotSavedText: string;
|
|
30
37
|
};
|
|
31
38
|
export declare const DATA_TABLE_TEXT: DataTableText;
|
|
@@ -2,6 +2,7 @@ export type DatePickerText = {
|
|
|
2
2
|
readonly chooseMonthYearLabel: string;
|
|
3
3
|
readonly chooseYearLabel: string;
|
|
4
4
|
readonly clearLabel: string;
|
|
5
|
+
readonly dateTimeLabel: string;
|
|
5
6
|
readonly helpLabel: string;
|
|
6
7
|
readonly monthPlaceholder: string;
|
|
7
8
|
readonly nextDecadeLabel: string;
|
|
@@ -14,5 +15,6 @@ export type DatePickerText = {
|
|
|
14
15
|
readonly previousYearLabel: string;
|
|
15
16
|
readonly todayLabel: string;
|
|
16
17
|
readonly yearPlaceholder: string;
|
|
18
|
+
readonly zoneNote: string;
|
|
17
19
|
};
|
|
18
20
|
export declare const DATE_PICKER_TEXT: DatePickerText;
|
package/types/toastTypes.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export interface ToastOptions {
|
|
|
12
12
|
onClick?: () => void;
|
|
13
13
|
};
|
|
14
14
|
id?: string;
|
|
15
|
-
|
|
15
|
+
/** Nodes drawn as the message, instead of `message` text. */
|
|
16
|
+
content?: Node;
|
|
16
17
|
animation?: ToastAnimation | null;
|
|
17
18
|
shape?: ToastShape | null;
|
|
18
19
|
surface?: ToastSurface | null;
|
package/types/tooltips.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export declare const TOOLTIP_ATTRIBUTE = "data-wui-tooltip";
|
|
2
2
|
export declare const TOOLTIP_PLACEMENT_ATTRIBUTE = "data-wui-tooltip-placement";
|
|
3
3
|
export declare const TOOLTIP_CLASS_ATTRIBUTE = "data-wui-tooltip-class";
|
|
4
|
-
export declare const TOOLTIP_HTML_ATTRIBUTE = "data-wui-tooltip-html";
|
|
5
4
|
export declare const TOOLTIP_ID_ATTRIBUTE = "data-wui-tooltip-id";
|
|
6
5
|
export declare const TOOLTIP_OPEN_ATTRIBUTE = "data-wui-tooltip-open";
|
|
6
|
+
export declare const TOOLTIP_SHORTCUT_ATTRIBUTE = "data-wui-tooltip-shortcut";
|
|
7
7
|
/**
|
|
8
|
-
* One set of delegated listeners per document for every tooltip trigger. A trigger carries TOOLTIP_ATTRIBUTE (text
|
|
9
|
-
*
|
|
8
|
+
* One set of delegated listeners per document for every tooltip trigger. A trigger carries TOOLTIP_ATTRIBUTE (text, with an
|
|
9
|
+
* optional TOOLTIP_SHORTCUT_ATTRIBUTE key drawn beside it) or TOOLTIP_ID_ATTRIBUTE (the id of a bubble the caller rendered).
|
|
10
10
|
* Shows on hover and on keyboard focus (:focus-visible), hides on leave, blur, a click on the trigger and Escape.
|
|
11
11
|
* The bubble is a popover="manual" element inside overlayRoot():
|
|
12
12
|
* <div class="tooltip wui-tooltip bs-tooltip-{placement} {class}" role="tooltip" popover="manual">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{r as t,t as n}from"./textStore-opIEM4lu.js";import{t as r}from"./carousel.g-Bw_pFDzc.js";var i=()=>t(`carousel`,r),a=120,o=class extends e{_page;_pages;_perView;_paused;_hover;_focus;_timer;_settleTimer;_status;_ready;_motion;_mutations;_resizer;_doc;_track;_onClick;_onKeyDown;_onScroll;_onEnter;_onLeave;_onFocusIn;_onFocusOut;_onVisibility;_onMotion;_tick;static get observedAttributes(){return[`autoplay`]}constructor(){super(),this._page=0,this._pages=1,this._perView=1,this._paused=!1,this._hover=!1,this._focus=!1,this._timer=null,this._settleTimer=null,this._status=``,this._ready=!1,this._motion=null,this._mutations=null,this._resizer=null,this._doc=null,this._track=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),a)},this._onEnter=()=>this._hold({hover:!0}),this._onLeave=()=>this._hold({hover:!1}),this._onFocusIn=()=>this._hold({focus:!0}),this._onFocusOut=e=>this._hold({focus:e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)}),this._onVisibility=()=>this._sync(),this._onMotion=()=>this._sync(),this._tick=()=>{this._timer=null,this._go(this._page+1<this._pages?this._page+1:0)}}connectedCallback(){let e=this.querySelector(`.wui-carousel-track`);if(this._track=e instanceof HTMLElement?e:null,!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let t=this.getAttribute(`data-wui-style`);if(t){for(let e of t.split(`;`)){let t=e.indexOf(`:`);t>0&&this.style.setProperty(e.slice(0,t).trim(),e.slice(t+1).trim())}this.removeAttribute(`data-wui-style`)}this._motion=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-reduced-motion: reduce)`):null,this._motion?.addEventListener(`change`,this._onMotion),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseenter`,this._onEnter),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._track.addEventListener(`keydown`,this._onKeyDown),this._track.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._doc.addEventListener(`visibilitychange`,this._onVisibility),typeof MutationObserver<`u`&&(this._mutations=new MutationObserver(()=>this._refresh()),this._mutations.observe(this._track,{childList:!0})),typeof ResizeObserver<`u`&&(this._resizer=new ResizeObserver(()=>this._refresh()),this._resizer.observe(this._track)),this._ready=!0,this._refresh()}disconnectedCallback(){this._ready=!1,this._timer!==null&&clearTimeout(this._timer),this._settleTimer!==null&&clearTimeout(this._settleTimer),this._timer=null,this._motion?.removeEventListener(`change`,this._onMotion),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseenter`,this._onEnter),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._track?.removeEventListener(`keydown`,this._onKeyDown),this._track?.removeEventListener(`scroll`,this._onScroll),this._doc?.removeEventListener(`visibilitychange`,this._onVisibility),this._mutations?.disconnect(),this._resizer?.disconnect(),this._mutations=this._resizer=this._motion=this._doc=null}attributeChangedCallback(){this._ready&&this._sync()}get paused(){return this._paused}set paused(e){this._paused=!!e,this._ready&&this._sync()}next(){this._page+1<this._pages?this._go(this._page+1):this.hasAttribute(`loop`)&&this._go(0)}prev(){this._page>0?this._go(this._page-1):this.hasAttribute(`loop`)&&this._go(this._pages-1)}goTo(e){this._go(Number(e))}_interval(){let e=Number.parseInt(this.getAttribute(`autoplay`)??``,10);return Math.max(e||0,0)}_slides(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(`wui-carousel-slide`))}_playing(){return this._interval()>0&&this._pages>1&&!this._paused&&!this._hover&&!this._focus&&!this._motion?.matches&&!this._doc?.hidden}_hold({hover:e=this._hover,focus:t=this._focus}){this._hover=e,this._focus=t,this._sync()}_click(e){let t=(e.target instanceof Element?e.target:null)?.closest(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`),n=t instanceof HTMLElement?t:null;if(!n||!this.contains(n))return;let r=this._track;if(!r)throw Error(`WuiCarousel used before it was connected`);r.contains(n)||(n.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):n.getAttribute(`aria-disabled`)===`true`?e.preventDefault():n.classList.contains(`wui-carousel-prev`)?this.prev():n.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(n.dataset.page)))}_key(e){if(e.target!==this._track||e.altKey||e.ctrlKey||e.metaKey)return;let t={ArrowRight:()=>this.next(),ArrowLeft:()=>this.prev(),Home:()=>this._go(0),End:()=>this._go(this._pages-1)}[e.key];t&&(e.preventDefault(),t())}_perViewNow(){let e=``;if(typeof window<`u`){let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);e=window.getComputedStyle(t).getPropertyValue(`--wui-carousel-view`)}return Math.max(Number.parseInt(e,10)||0,1)}_start(e){return Math.min(e*this._perView,Math.max(0,this._slides().length-this._perView))}_label(){let e=this._slides();return e.forEach((t,r)=>{let a=n(i().slideText,{n:r+1,total:e.length});t.getAttribute(`aria-label`)!==a&&t.setAttribute(`aria-label`,a)}),e.length}_refresh(){let e=this._label();this._perView=this._perViewNow();let t=Math.max(1,Math.ceil(e/this._perView)),n=this.querySelector(`.wui-carousel-dots`);if(n&&n.children.length!==t){let e=this.getAttribute(`dot-label`)||i().dotLabel;n.replaceChildren(...Array.from({length:t},(t,n)=>{let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=`wui-carousel-dot`,r.dataset.page=String(n),r.setAttribute(`aria-label`,`${e} ${this._start(n)+1}`),r}))}this._pages=t,this._page=Math.min(this._page,t-1),this.toggleAttribute(`data-single`,t<=1),this._render(!1),this._sync()}_settle(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);let t=this._slides();if(!t.length)return;let n;if(e.scrollWidth>e.clientWidth&&e.scrollLeft+e.clientWidth>=e.scrollWidth-2)n=this._pages-1;else{let r=0,i=1/0;t.forEach((t,n)=>{let a=Math.abs(t.offsetLeft-e.scrollLeft);a<i&&(i=a,r=n)}),n=Math.min(this._pages-1,Math.round(r/this._perView))}n!==this._page&&(this._page=n,this._render(!0),this._sync())}_go(e){if(!Number.isInteger(e))return;this._page=Math.max(0,Math.min(this._pages-1,e));let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);let n=this._slides()[this._start(this._page)];if(n){let e=this._motion?.matches?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({left:n.offsetLeft,behavior:e}):t.scrollLeft=n.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))e instanceof HTMLElement&&(Number(e.dataset.page)===this._page?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`));this.querySelector(`.wui-carousel-prev`)?.setAttribute(`aria-disabled`,String(!t&&this._page===0)),this.querySelector(`.wui-carousel-next`)?.setAttribute(`aria-disabled`,String(!t&&this._page===this._pages-1));let r=this._slides().length,a=this._start(this._page)+1,o=Math.min(r,a+this._perView-1),s=a===o?n(i().statusTextOne,{first:a,total:r}):n(i().statusTextOther,{first:a,last:o,total:r});if(s===this._status||(this._status=s,!e))return;let c=this.querySelector(`[data-wui-status]`);c&&!this._playing()&&(c.textContent=s),this.dispatchEvent(new CustomEvent(`wui:carousel:change`,{bubbles:!0,detail:{page:this._page,pages:this._pages}}))}_sync(){this._timer!==null&&clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t instanceof HTMLElement){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||i().playLabel:this.getAttribute(`pause-label`)||i().pauseLabel,r=t.querySelector(`.wui-carousel-pause-text`);r&&r.textContent!==n&&(r.textContent=n),this.toggleAttribute(`data-paused`,this._paused)}this._playing()&&(this._timer=setTimeout(this._tick,e))}};export{o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{n}from"./commentText-NWsssKvj.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{a as i,l as a,s as o}from"./nativeOverlay-DGady-wN.js";import{l as s}from"./wuiHttp-DGbD7Fra.js";import{r as c,t as l}from"./textStore-opIEM4lu.js";import{n as u,t as d}from"./httpFailure.g-DBKzEpAf.js";import{r as f}from"./WuiMentionInput-DvKw8MXS.js";var p=`[data-wui-items]`,m=`[data-wui-picker]`,h=`[data-wui-composer]`,g=`[data-wui-comment]`,_=`[data-wui-live]`,v=()=>c(`commentThread`,u),y=e=>({forbidden:v().forbiddenMessage,client:v().failedClientMessage,validation:v().validationMessage,server:v().failedServerMessage,network:c(`httpFailure`,d).networkText})[e],b=e=>({post:v().donePostText,reply:v().doneReplyText,edit:v().doneEditText,delete:v().doneDeleteText,react:``})[e],x=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:v().failedServerMessage},S=e=>e instanceof Element?e:null,C=e=>`disabled`in e&&e.disabled===!0,w=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},T=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},E=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},D=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],O=class extends r{_wired;_busy;_peopleProp;_pickerFor;_openers;constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=T(this,`${h} wui-mention-input`,f);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:D(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:n}_onClick(e){let t=E(S(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!C(t)){let e=t.closest(m),n=e?this._pickerFor?.comment:t.closest(g);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=E(S(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||C(n))return;let r=n.closest(g);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=w(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(E(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=T(this,m,HTMLElement),n=S(e.target);if(this._pickerFor&&t?.contains(n)){let r=D(t,`[data-wui-emoji]`,HTMLElement),i=n instanceof HTMLElement?r.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),r[(i+(e.key===`ArrowRight`?1:-1)+r.length)%r.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let r=E(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(r&&this.contains(r)){e.preventDefault(),e.stopPropagation(),this._closeSlot(r,!0);return}let i=E(n,`[data-wui-confirm]`,HTMLElement);i&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(i.closest(g),!0))}_onSubmitKey(e){let t=T(E(S(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!C(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=T(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:l(v().replyToText,{author:r}),placeholder:v().replyPlaceholder,value:``,send:v().replyLabel,opener:t})}_openEditor(e,t){let n=T(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=T(w(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:v().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:v().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,v().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(n,r,i,a,o){let s=this.ownerDocument.createElement(`button`);return s.type=`button`,s.className=e(n,r,i),s.dataset.wui=t,s.setAttribute(`data-wui-action`,a),s.textContent=o,s}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=T(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=T(e,`:scope > .wui-comment-row`,HTMLElement),n=T(t,`[data-wui-confirm]`,HTMLElement),r=T(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),T(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=T(e,`:scope > .wui-comment-row`,HTMLElement),r=T(n,`[data-wui-confirm]`,HTMLElement),i=T(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&T(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=T(this,m,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),a(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),T(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=T(this,m,HTMLElement);n&&i(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=T(this,m,HTMLElement),t=this._pickerFor;!t||e&&o(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=E(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,v().emptyBodyMessage),n?.focus();return}let i=t.closest(g);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:w(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:w(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??T(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),b(e)&&this._announce(b(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:x(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:v().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await s(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||y(r.kind)||v().failedServerMessage}}_swapItems(e){let t=T(this,p,HTMLElement);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=T(n.content,p,HTMLElement);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!C(i))return;let a=e=>e?D(this,g,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>T(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=T(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=T(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=D(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??T(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=T(this,`${h} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=T(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=T(this,`:scope > ${_}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};export{O as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{n}from"./devWarn-DXdRWZs3.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i}from"./textStore-opIEM4lu.js";import{t as a}from"./consentBanner.g-CZAb1BLJ.js";import{t as o}from"./tourOpenMark-nPeAJFSo.js";var s={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},c=e=>`var(${e}, ${s[e]})`,l=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${c(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${c(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${c(`--color-surface`)}; border: 1px solid ${c(`--color-border`)}; border-radius: ${c(`--wui-radius-lg`)}; box-shadow: ${c(`--wui-shadow-modal`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${c(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${c(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${c(`--color-primary-text`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${c(`--color-border`)}; border-bottom: 1px solid ${c(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${c(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${c(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${c(`--color-primary`)}; background: ${c(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${c(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${c(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${c(`--color-primary`)}; border-color: ${c(`--color-primary`)}; color: ${c(`--color-on-primary`)}; } .btn-primary:hover { background: ${c(`--color-primary-hover`)}; border-color: ${c(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${c(`--color-text-muted`)}; color: ${c(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${c(`--color-bg-muted`)}; color: ${c(`--color-text`)}; } .btn-link { font-weight: 400; color: ${c(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${c(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } /* The actions are small buttons, which fall under the 44px touch target on touch screens. This sheet's .btn is inline-block, so it centres the label itself. */ @media (max-width: 575.98px), (pointer: coarse) { .wui-consent-banner-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } `,u=`wui-consent-save`,d=`[data-consent-settings]`,f=`tour-open`,p=`--wui-consent-banner-block`,m=`--wui-consent-banner-inline`,h=()=>i(`consentBanner`,a),g=[`analytics`,`functional`,`marketing`],_={analytics:{label:`analyticsLabel`,description:`analyticsDescription`},functional:{label:`functionalLabel`,description:`functionalDescription`},marketing:{label:`marketingLabel`,description:`marketingDescription`}};function v(e){return g.some(t=>t===e)}var y=/* @__PURE__ */ new Set;function b(e){y.has(e)||(y.add(e),n(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${g.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var x=0,S=null;function C(e){S||(S=new CSSStyleSheet,S.replaceSync(l)),e.adoptedStyleSheets=[S]}var w=class extends r{_uid;_preferences;_settings;_onDocumentClick;_tourWatch;_roomObserver;_onWindowResize;_rendered;static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),x+=1,this._uid=`wui-consent-${x}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(d)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||h().heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||h().description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||h().policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||h().analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||h().functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||h().marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...g];let t=e.split(/\s+/).filter(Boolean);for(let e of t)v(e)||b(e);let n=g.filter(e=>t.includes(e));return n.length?n:[...g]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(g.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[o]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(f,document.documentElement.hasAttribute(o))}attributeChangedCallback(){this._rendered&&this.render()}render(){let n=this.isOpen,r=this._uid,i=this.policyHref?` <a class="wui-consent-banner-policy" href="${D(this.policyHref)}">${E(this.policyLabel)}</a>`:``,a=this._root();a instanceof ShadowRoot&&C(a),a.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${r}-heading" aria-describedby="${r}-description" hidden> <h2 class="wui-consent-banner-heading" id="${r}-heading">${E(this.heading)}</h2> <p class="wui-consent-banner-description" id="${r}-description">${E(this.description)}${i}</p> <div class="wui-consent-banner-settings" hidden> ${T(r,`essential`,h().essentialLabel,h().essentialDescription,!0)} ${this.categories.map(e=>T(r,e,h()[_[e].label],this[_[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${E(h().settingsLabel)}</button> <button type="button" class="${e(`neutral`,`outline`,`sm`)} wui-consent-banner-reject" data-wui="${t}">${E(h().rejectLabel)}</button> <button type="button" class="${e(`primary`,`solid`,`sm`)} wui-consent-banner-accept" data-wui="${t}">${E(h().acceptLabel)}</button> <button type="button" class="${e(`primary`,`solid`,`sm`)} wui-consent-banner-save" hidden data-wui="${t}">${E(h().saveLabel)}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),n&&(this._requirePanel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){if(this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._requirePanel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t){let t=e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`);t instanceof HTMLElement&&t.focus()}}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(p),document.documentElement.style.removeProperty(m)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(p,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(m,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){let e=this._root().querySelector(`.wui-consent-banner-panel`);return e instanceof HTMLElement?e:null}_requirePanel(){let e=this._panel();if(!e)throw Error(`consent banner panel is missing`);return e}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return{analytics:e&&t.includes(`analytics`),functional:e&&t.includes(`functional`),marketing:e&&t.includes(`marketing`)}}_switchValues(){let e={analytics:!1,functional:!1,marketing:!1};for(let t of g){let n=this._root().querySelector(`input[data-category="${t}"]`);e[t]=n instanceof HTMLInputElement&&n.checked}return e}_applyPreferences(){for(let e of g){let t=this._root().querySelector(`input[data-category="${e}"]`);t instanceof HTMLInputElement&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!(n instanceof HTMLElement))return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r instanceof HTMLElement&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r instanceof HTMLElement&&(r.hidden=e)}}};function T(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${E(n)}</label> </div> <p class="wui-consent-banner-category-description">${E(r)}</p> </div>`}var E=e=>String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),D=e=>String(e??``).replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);export{w as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{t}from"./imeSafeEnter-DPs9qL3S.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{t as r}from"./menuKeyNav-CstMzU08.js";import{a as i,l as a,s as o}from"./nativeOverlay-DGady-wN.js";var s=`[role="menuitem"]`,c=`.wui-context-menu-sub`,l=`input.wui-context-menu-search`,u=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,d=500,f=10,p=400,m=null,h=null,g=0;function _(e,t,n){let r=document.createElement(`span`);return r.setAttribute(`aria-hidden`,`true`),r.style.cssText=n?`position:absolute;left:${e+window.scrollX}px;top:${t+window.scrollY}px;width:0;height:0;`:`position:fixed;left:${e}px;top:${t}px;width:0;height:0;`,document.body.append(r),r}var v=/* @__PURE__ */ new WeakMap;function y(e,t,n){let r=v.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return v.set(e,{region:t,cancel:n}),!0}var b=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,x=e=>`focus`in e,S=e=>[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE||e instanceof Element&&!e.matches(`.wui-context-menu-hint, .wui-context-menu-tick`)).map(e=>e.textContent).join(``),C=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),w=e=>[...e.children].filter(e=>e instanceof HTMLElement),T=(e,t)=>{let n=e.children[t];if(!(n instanceof HTMLElement))throw Error(`a submenu holds its opener and then its panel`);return n},E=e=>T(e,0),D=e=>T(e,1),O=(e,t)=>{let n=e?.closest(t);return n instanceof HTMLElement?n:null},k=class extends e{_region;_origin;_returnFocus;_press;_swallowClick;_unbindKeys;_anchor;_closingByKey;_onContextMenu;_onContextMenuCapture;_onDocKeyDown;_onDocClick;_onPointerDown;_onPressMove;_onPressEnd;_onClickCapture;_onKeyDown;_onClick;_onInput;_onMouseMove;_onDismiss;_onPointerDownCapture;static get observedAttributes(){return[`disabled`,`open`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._unbindKeys=null,this._anchor=null,this._closingByKey=!1,this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onDocClick=e=>this._handleDocClick(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>f&&this._cancelPress()},this._onPressEnd=()=>this._cancelPress(),this._onClickCapture=e=>{if(this._swallowClick&&this._region){if(!(e.target instanceof Node))throw Error(`a click target is always a node`);this._region.contains(e.target)&&(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())}},this._onKeyDown=e=>{if(this.isOpen&&this._inPanel(e.target)){if(e.key===`Escape`){if(e.stopPropagation(),this.hasAttribute(`open`)&&O(b(e.target),`[role="menu"]`)===this._panel()){e.preventDefault(),this.close(!0);return}this._closingByKey=!0}this._handleMenuKey(e)}},this._onClick=e=>this._handleClick(e),this._onInput=e=>this._handleInput(e),this._onMouseMove=e=>{let t=O(b(e.target),s);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{this.hasAttribute(`open`)||e.type===`scroll`&&this._inPanel(e.target)||this.close()},this._onPointerDownCapture=()=>{this._swallowClick=!1}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),document.addEventListener(`click`,this._onDocClick),window.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`input`,this._onInput),this.addEventListener(`mousemove`,this._onMouseMove),this._syncOpen()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){e===`open`?this.isConnected&&this._syncOpen():this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){let e=this._panel();return!!e&&o(e)}open(e,t,{region:n=this,origin:i=n,trigger:s=null,keyboard:c=!1}={}){let l=this._panel();if(!l)return!1;let u=new CustomEvent(`wui-context-menu:beforeopen`,{bubbles:!0,cancelable:!0,detail:{region:n,origin:i,trigger:s}});if(this.dispatchEvent(u),u.defaultPrevented)return!1;if(this._decorate(l),m&&m!==this&&m.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)&&x(e)?e:null}this._region=n,this._origin=i,h=null,m=this,this._unbindKeys?.(),this._unbindKeys=r(l,{items:()=>this._menuRows()}),this._anchor?.remove();let d=this.hasAttribute(`open`);return this._anchor=_(e,t,d),a(this._anchor,l,{mode:d?`manual`:`auto`,keepOffscreen:d,clampHeight:!0,onClosed:()=>this._onPanelClosed()}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),queueMicrotask(()=>{o(l)&&((c?this._rowsOf(l)[0]:null)??l).focus({preventScroll:!0})}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:n,origin:i,x:e,y:t}})),!0}_syncOpen(){if(!this.hasAttribute(`open`)){this.close(this._inPanel(document.activeElement));return}let e=this.target?document.querySelector(this.target):this,t=e&&this._regionRect(e);e&&t&&this.open(t.left,t.top,{region:e,origin:e})}_regionRect(e){if(e!==this)return e.getBoundingClientRect();let t=[...this.children].filter(e=>e!==this._panel()).map(e=>e.getBoundingClientRect());return t.length?{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top))}:null}close(e=!1){let t=this._panel();t&&o(t)&&(e&&(this._closingByKey=!0),i(t))}_finish(e){let t=this._panel();if(t)for(let e of C(t,c))this._setSub(e,!1);m===this&&(m=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._unbindKeys?.(),this._unbindKeys=null,this._anchor?.remove(),this._anchor=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_onPanelClosed(){let e=this._panel();if(!e||o(e))return;let t=this._closingByKey;this._closingByKey=!1,this._finish(t)}_menuRows(){let e=b(document.activeElement);if(!e||e.matches(l))return[];let t=O(e,`[role="menu"]`);return t?this._rowsOf(t):[]}_panel(){return w(this).find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return e instanceof Node&&!!this._panel()?.contains(e)}_rowsOf(e){return e?C(e,s).filter(t=>t.closest(`[role="menu"]`)===e&&!this._isDisabled(t)&&n(t)):[]}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=b(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(u))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_triggerFor(e){let t=b(e),n=this.getAttribute(`trigger`);if(!t||!n||this._inPanel(t))return null;let r=O(t,n),i=r&&this._regionFor(r);return r&&i?{trigger:r,region:i}:null}_isKeyEcho(){return h?.menu===this&&this.isOpen&&performance.now()-h.at<p}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!v.has(e))return;let t=this._regionFor(e.target);t&&(this._isKeyEcho()?e.preventDefault():e.shiftKey||y(e,t,()=>this.close(!0))&&this.open(e.clientX,e.clientY,{region:t,origin:b(e.target)})&&e.preventDefault())}_handleDocKeyDown(e){if(e.defaultPrevented&&!v.has(e))return;if(t(e)){let t=this._triggerFor(e.target);if(!t||!y(e,t.region,()=>this.close(!0)))return;e.preventDefault(),t.trigger.click();return}if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let n=this._regionFor(e.target);if(!n||!y(e,n,()=>this.close(!0)))return;let r=b(e.target);if(!r)return;let i=r.getBoundingClientRect();this.open(i.left+Math.min(16,i.width/2),i.bottom,{region:n,origin:r,keyboard:!0})&&(e.preventDefault(),h={menu:this,at:performance.now()})}_handleDocClick(e){let t=this._triggerFor(e.target);if(!t||!y(e,t.region,()=>this.close(!0)))return;let n=t.trigger.getBoundingClientRect();this.open(n.left,n.bottom,{region:t.region,origin:t.trigger,trigger:t.trigger,keyboard:e.detail===0})}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!y(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=b(e.target);this._press={x:n,y:r,timer:setTimeout(()=>{this._cancelPress(),this.open(n,r,{region:t,origin:i})&&(this._swallowClick=!0)},d)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(!this.isOpen)return;let n=b(e.target);if(!n)return;if(n.matches(l)){this._handleSearchKey(e,n);return}let r=O(n,`[role="menu"]`);if(!r)return;let i=O(n,s),a=r.matches(`.wui-context-menu-subpanel`)?r.parentElement:null;if(e.key===`Tab`)this.close(!0);else if(e.key===`ArrowRight`){let t=i&&this._subOf(i);if(!t)return;e.preventDefault(),this._openSub(t,!0)}else if(e.key===`ArrowLeft`){if(!a)return;e.preventDefault(),this._closeSubByKey(a)}else(t(e)||e.key===` `)&&(e.preventDefault(),i?.click())}_handleSearchKey(e,t){let n=O(t,c);if(!n)return;let r=this._rowsOf(D(n));e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closeSubByKey(n)):e.key===`ArrowDown`?(e.preventDefault(),r[0]?.focus({preventScroll:!0})):e.key===`ArrowUp`?(e.preventDefault(),r[r.length-1]?.focus({preventScroll:!0})):e.key===`Tab`&&this.close(!0)}_subOf(e){return e.hasAttribute(`aria-haspopup`)&&e.parentElement?.matches(c)?e.parentElement:null}_openSub(e,t){let n=e.parentElement;if(!n)throw Error(`a submenu is always inside its menu panel`);for(let t of w(n))t!==e&&t.matches(c)&&this._closeSub(t);this._setSub(e,!0);let r=D(e).querySelector(`:scope > ${l}`),i=e.hasAttribute(`data-searchable`)&&r instanceof HTMLInputElement?r:null;i?(i.value=``,this._filter(e,``),i.focus({preventScroll:!0})):t&&this._rowsOf(D(e))[0]?.focus({preventScroll:!0})}_closeSub(e){for(let t of C(D(e),c))this._setSub(t,!1);this._setSub(e,!1)}_closeSubByKey(e){this._closeSub(e),E(e).focus({preventScroll:!0})}_setSub(e,t){let n=D(e);t?(a(E(e),n,{mode:`auto`,beside:!0,onClosed:()=>this._onSubClosed(e)}),E(e).setAttribute(`aria-expanded`,String(o(n)))):o(n)?i(n):this._onSubClosed(e)}_onSubClosed(e){let t=D(e);if(o(t))return;let n=E(e);n.setAttribute(`aria-expanded`,`false`),t.removeAttribute(`data-side`);let r=this._closingByKey;this._closingByKey=!1,r&&n.focus({preventScroll:!0})}_filter(e,t){let n=t.trim().toLowerCase();for(let t of w(D(e)))t.tagName===`HR`?t.hidden=n!==``:t.matches(s)?t.hidden=n!==``&&!S(t).toLowerCase().includes(n):t.matches(c)&&(t.hidden=n!==``&&!S(E(t)).toLowerCase().includes(n))}_handleInput(e){let t=b(e.target)?.closest(l);if(!(t instanceof HTMLInputElement))return;let n=O(t,c);n?.hasAttribute(`data-searchable`)&&this._inPanel(n)&&this._filter(n,t.value)}_decorate(e){for(let t of C(e,s)){let e=t.getAttribute(`aria-checked`)===`true`,n=t.querySelector(`:scope > .wui-context-menu-tick`);if(e&&!n){let e=document.createElement(`span`);e.className=`wui-context-menu-tick`,e.setAttribute(`aria-hidden`,`true`),t.prepend(e)}else!e&&n&&n.remove();let r=t.querySelector(`:scope > .wui-context-menu-hint`),i=t.dataset.hint;if(i){let e=r??document.createElement(`span`);r||(e.className=`wui-context-menu-hint`,e.id=`wui-context-menu-hint-${++g}`,t.append(e)),e.textContent=i,t.setAttribute(`aria-describedby`,e.id)}else r&&(r.remove(),t.removeAttribute(`aria-describedby`))}}_handleClick(e){let t=O(b(e.target),s);if(!t||!this._inPanel(t))return;if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}let n=this._subOf(t);n?(e.preventDefault(),this._openSub(n,e.detail===0)):(this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}})))}_teardown(){let e=this._panel();if(this._closingByKey=!1,e){for(let t of[...C(e,c)].reverse())i(D(t));i(e)}this._anchor&&this._finish(!1),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),document.removeEventListener(`click`,this._onDocClick),window.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`input`,this._onInput),this.removeEventListener(`mousemove`,this._onMouseMove)}};export{k as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,F as r,I as i,P as a,_ as o,g as s,h as c,m as l,r as u,s as d,t as f,w as p,x as m}from"./dataTable-oR_YiFJc.js";import{t as h}from"./dom-Do1pAA12.js";import{t as g}from"./elementBase-Cxeyx0tU.js";import{t as _}from"./imeSafeEnter-DPs9qL3S.js";var v=`.wui-col-resize`,y=`.wui-group-row, .wui-virtual-spacer`,b=`.wui-select-cell, .wui-expand-cell`,x=`<svg class="wui-icon" data-icon="chevron-down" data-wui="AppIcon" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="1.5" d="M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95"></path></svg>`;function S(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function C(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var w=e=>{let t=h(e,v);return t instanceof HTMLElement?t:null},T=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),E=class extends g{_frame;_headDirty;_rowsDirty;_frozenSig;_natural;_widths;_collapsed;_groupOrder;_items;_range;_drag;_userSized;_swallowClick;_mo;_ro;_fonts;_onPointerDown;_onKeyDown;_onClick;_onDblClick;_onScroll;_onFonts;_top=null;_bottom=null;_rowHeight=0;constructor(){super(),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=/* @__PURE__ */ new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=w(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=n(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._schedule()}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(t,n){let r=this._headCells(t),i=r.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(b)?`lead`:null});if(!i.some(e=>e===`start`||e===`end`))return;let a=p(i);a.forEach((e,t)=>{e&&this._ro?.observe(S(r[t]))});let o=e=>S(r[e]).getBoundingClientRect().width,s=0;a.forEach((n,r)=>{n?.side===`start`&&(this._setVar(t,e(`start`,n.ordinal),s),s+=o(r))}),s=0;for(let n=a.length-1;n>=0;n--){let r=a[n];r?.side===`end`&&(this._setVar(t,e(`end`,r.ordinal),s),s+=o(n))}if(n)for(let e of t.rows)e.matches(`${y}, .wui-row-expanded`)||e.cells.length!==r.length||a.forEach((t,n)=>{if(!t)return;let r=S(e.cells[n]);r.classList.contains(`wui-pin-${t.side}`)||r.classList.add(`wui-pin-${t.side}`),t.edge&&!r.classList.contains(`wui-pin-${t.side}-edge`)&&r.classList.add(`wui-pin-${t.side}-edge`);let i=m(t.side,t.ordinal);r.style.getPropertyValue(`--wui-pin-at`)!==i&&r.style.setProperty(u,i)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(b))}_handles(e){let n=this._headCells(e),r=this._resizable(n);n.forEach((e,n)=>{if(!r[n]||e.querySelector(v))return;let i=e.ownerDocument.createElement(`span`);i.className=`wui-col-resize`,i.setAttribute(`role`,`separator`),i.setAttribute(`aria-orientation`,`vertical`),i.setAttribute(`aria-valuemin`,`48`),i.setAttribute(`aria-valuemax`,String(f)),i.setAttribute(`tabindex`,`0`);let a=(e.textContent??``).trim();i.setAttribute(`aria-label`,t(a)),a&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,a),e.classList.add(`wui-col-resizable`),e.appendChild(i)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(y)&&!T(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let n=t.querySelector(v);n&&this._handleValue(n,l(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(b))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let n=l(t);e.style.width=`${n}px`,e.setAttribute(`data-wui-width`,``);let r=e.querySelector(v);return r&&this._handleValue(r,n),n}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,r(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(S(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},i(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let n=this._ensureFrozen(t);this._userSized=!0;let r=e.dataset.key;if(r&&r in this._widths){let{[r]:e,...t}=this._widths;this._widths=t,i(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[n.indexOf(e)]||0),this._fitTable(t,n),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=w(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=w(e.target);if(!t||!this.contains(t))return;let n=t.closest(`th`);if(_(e)||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(n);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let r=this._table;if(!r)return;this._ensureFrozen(r);let i=S(n),a=e.shiftKey?50:10,o=e.key===`ArrowRight`!==this._rtl(),s=Number.parseFloat(i.style.width)||i.getBoundingClientRect().width;this._resizeTo(i,s+(o?a:-a),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(v)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}if(!this.hasAttribute(`group-by`))return;let n=h(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(n instanceof HTMLTableRowElement)||!this.contains(n))return;let r=n.dataset.groupKey;this._collapsed.has(r)?this._collapsed.delete(r):this._collapsed.add(r),this._showGroup(n,!this._collapsed.has(r));let i=this._table;i&&this.hasAttribute(`virtual`)&&(this._virtual(i,!0),this._mo?.takeRecords())}_group(e){let t=this.getAttribute(`group-by`),n=this._headCells(e),r=n.findIndex(e=>e.dataset.key===t);if(r<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let i=e.tBodies[0];if(!i)return;let a=[...i.rows].filter(e=>!e.matches(y));if(a.some(T))return;let l=this.ownerDocument,u=/* @__PURE__ */ new Map;for(let e of i.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&u.set(e.dataset.groupKey,e);let d=this.closest(`[data-wui-server]`)?[]:this._groupOrder,f=s(a,e=>e.dataset.group??e.cells[r]?.textContent?.trim()??``,d);this._groupOrder=f.map(e=>e.key);let p=l.createDocumentFragment(),m=f.map(e=>{let t=u.get(e.key)??this._groupRow(l,e.key);return u.delete(e.key),C(t.querySelector(`.wui-group-cell`),HTMLTableCellElement).colSpan=n.length,C(t.querySelector(`.wui-group-count`),HTMLElement).textContent=c(e.items.length),C(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${o(e.items.length)}`,p.append(t,...e.items),[t,e.key]});for(let e of u.values())e.remove();i.insertBefore(p,this._bottom?.parentNode===i?this._bottom:null);for(let[e,t]of m)this._showGroup(e,!this._collapsed.has(t))}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.innerHTML=x;let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(y);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let n=e.tBodies[0];if(!n)return;if(t){this._top=this._spacer(n,this._top),this._bottom=this._spacer(n,this._bottom),n.firstElementChild!==this._top&&n.insertBefore(this._top,n.firstChild),n.lastElementChild!==this._bottom&&n.append(this._bottom);let t=Math.max(1,this._headCells(e).length);S(this._top.cells[0]).colSpan=t,S(this._bottom.cells[0]).colSpan=t,this._items=[...n.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let r=e.tHead?.getBoundingClientRect().height||0,i=a({scrollTop:this.scrollTop-r,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),o=this._range;if(o&&o.start===i.start&&o.end===i.end)return;let s=o?Math.min(o.start,i.start):0,c=o?Math.max(o.end,i.end):this._items.length;for(let e=s;e<c;e++){let t=e<i.start||e>=i.end,n=S(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=i;let l=S(this._top),u=S(this._bottom);l.hidden=i.before===0,u.hidden=i.after===0,S(l.cells[0]).style.height=`${i.before}px`,S(u.cells[0]).style.height=`${i.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?d.compact:e.classList.contains(`wui-table-cozy`)?d.cozy:d.comfortable}};export{E as t};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./calendarMath-DIoh4HjR.js";import{r as f}from"./dom-Do1pAA12.js";import{t as p}from"./elementBase-Cxeyx0tU.js";import{r as m,t as h}from"./fieldState-D-zQcXUS.js";import{_ as g,b as _,g as v}from"./formatters-CMTSYlW9.js";import{t as y}from"./formMirror-9IpSgeZb.js";import{t as b}from"./iconGlyphs.g-BUF97bUu.js";import{a as x,l as S,s as C}from"./nativeOverlay-DGady-wN.js";import{n as w}from"./optionLabel-CWMhBkdO.js";import{r as T}from"./textStore-opIEM4lu.js";import{t as E}from"./datePicker.g-VdBlhA2G.js";var D=()=>T(`datePicker`,E),O=e=>e-(e%10+10)%10-1,k=class extends p{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}_internals;_value;_defaultValue;_rendered;_viewY;_viewM;_mode;_focus;_gridFocus;_slide;_viewNavigated;_openFn;_closeFn;_onKeyBound;_closingQuietly;get _open(){return f(this._openFn,`open missing`)}get _close(){return f(this._closeFn,`close missing`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&C(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,y(this,this._value),this._syncTrigger()}_firstDay(){return c(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_parts(e){if(this._yearOnly()){let t=a(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return l(e);let n=t(e);return n?{y:n.y,m:n.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?D().yearPlaceholder:this._monthOnly()?D().monthPlaceholder:D().placeholder)}_label(t){let n=this.getAttribute(`display-format`);return this._yearOnly()?s(t,n):this._monthOnly()?e(t,n):i(t,n)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,i=this.getAttribute(`aria-label`),a=this.getAttribute(`aria-describedby`);this.innerHTML=`
|
|
2
|
-
<div class="datepicker">
|
|
3
|
-
<button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${i?` aria-label="${w(i)}"`:``}${a?` aria-describedby="${w(a)}"`:``}>
|
|
4
|
-
<span data-trigger-label class="${t?``:`wui-select-placeholder`}">${w(t?this._label(this._value):e)}</span>
|
|
5
|
-
${b(`calendar-dots`)}
|
|
6
|
-
</button>
|
|
7
|
-
<div class="datepicker-pop" role="dialog" popover="auto"></div>
|
|
8
|
-
</div>`,this._rendered=!0,m(this,this.querySelector(`.datepicker-trigger`)),y(this,this._value),this._wire()}_syncFormValue(){y(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),m(this,e)}_limits(){if(this._yearOnly()){let e=a(this.getAttribute(`min`)),t=a(this.getAttribute(`max`)),n=e?e.y:-1/0,r=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<n||e>r}}if(this._monthOnly()){let e=t(this.getAttribute(`min`)),n=t(this.getAttribute(`max`)),r=e?e.y*12+e.m:-1/0,i=n?n.y*12+n.m:1/0,a=e?e.y:-1/0,o=n?n.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=l(this.getAttribute(`min`)),n=l(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=n?new Date(n.y,n.m,n.d).getTime():1/0,s=/* @__PURE__ */ new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&s.add(Number(t))}return{dayDisabled:(e,t,n)=>{let a=new Date(e,t,n),o=a.getTime();return o<r||o>i||s.has(a.getDay())},monthDisabled:(e,t)=>{let n=new Date(e,t,1).getTime();return new Date(e,t,o(e,t)).getTime()<r||n>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{x(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(e.innerHTML=this._mode===`months`?this._monthsHtml():this._mode===`years`?this._yearsHtml():this._daysHtml(),this._focusActive())}_daysHtml(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,n=o(this._viewY,this._viewM),r=l(this._value),i=/* @__PURE__ */ new Date,{dayDisabled:a}=this._limits(),s=this._focus||r||{y:this._viewY,m:this._viewM,d:1},c=(e,t,n,o)=>{let c=d(e,t,n),l=r&&r.y===e&&r.m===t&&r.d===n,u=i.getFullYear()===e&&i.getMonth()===t&&i.getDate()===n,f=s.y===e&&s.m===t&&s.d===n,p=a(e,t,n);return`<button type="button" class="${[`datepicker-day`,o?`is-outside`:``,u?`is-today`:``,l?`is-selected`:``].filter(Boolean).join(` `)}" data-iso="${c}" role="gridcell" tabindex="${f&&!p?`0`:`-1`}"${l?` aria-selected="true"`:``}${p?` disabled aria-disabled="true"`:``}>${n}</button>`},f=``,p=u(this._viewY,this._viewM-1),m=o(p.y,p.m);for(let e=t-1;e>=0;e--)f+=c(p.y,p.m,m-e,!0);for(let e=1;e<=n;e++)f+=c(this._viewY,this._viewM,e,!1);let v=u(this._viewY,this._viewM+1),y=(7-(t+n)%7)%7;for(let e=1;e<=y;e++)f+=c(v.y,v.m,e,!0);let x=a(i.getFullYear(),i.getMonth(),i.getDate()),S=h(this)?``:`<button type="button" class="datepicker-link" data-clear>${w(D().clearLabel)}</button>`,C=Array.from({length:7},(t,n)=>_((n+e)%7,`min`)).map(e=>`<span>${e}</span>`).join(``);return`
|
|
9
|
-
<div class="datepicker-head">
|
|
10
|
-
<button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="${w(D().previousMonth)}">${b(`chevron-left`)}</button>
|
|
11
|
-
<button type="button" class="datepicker-month" data-view="months" aria-label="${w(D().chooseMonthYearLabel)}">${g(this._viewM)} ${this._viewY}</button>
|
|
12
|
-
<button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="${w(D().nextMonth)}">${b(`chevron-right`)}</button>
|
|
13
|
-
</div>
|
|
14
|
-
<div class="datepicker-weekdays">${C}</div>
|
|
15
|
-
<div class="datepicker-grid${this._slide?` ${this._slide}`:``}" role="grid">${f}</div>
|
|
16
|
-
<div class="datepicker-foot">
|
|
17
|
-
<button type="button" class="datepicker-link" data-today${x?` disabled`:``}>${w(D().todayLabel)}</button>
|
|
18
|
-
${S}
|
|
19
|
-
</div>`}_clearFoot(e){return!e||h(this)?``:`
|
|
20
|
-
<div class="datepicker-foot">
|
|
21
|
-
<button type="button" class="datepicker-link" data-clear>${w(D().clearLabel)}</button>
|
|
22
|
-
</div>`}_monthsHtml(){let e=this._parts(this._value),t=/* @__PURE__ */ new Date,{monthDisabled:n}=this._limits(),r=``;for(let i=0;i<12;i++){let a=e&&e.y===this._viewY&&e.m===i,o=t.getFullYear()===this._viewY&&t.getMonth()===i,s=n(this._viewY,i),c=[`datepicker-cell`,o?`is-today`:``,a?`is-selected`:``].filter(Boolean).join(` `),l=this._monthOnly()?` tabindex="${this._viewY*12+i===this._gridFocus&&!s?0:-1}"`:``;r+=`<button type="button" class="${c}" data-month="${i}"${l}${s?` disabled`:``}>${v(i)}</button>`}return`
|
|
23
|
-
<div class="datepicker-head">
|
|
24
|
-
<button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="${w(D().previousYearLabel)}">${b(`chevron-left`)}</button>
|
|
25
|
-
<button type="button" class="datepicker-month" data-view="years" aria-label="${w(D().chooseYearLabel)}">${this._viewY}</button>
|
|
26
|
-
<button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="${w(D().nextYearLabel)}">${b(`chevron-right`)}</button>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="datepicker-cells">${r}</div>${this._clearFoot(this._monthOnly())}`}_yearsHtml(){let e=this._parts(this._value),t=(/* @__PURE__ */ new Date()).getFullYear(),{yearDisabled:n}=this._limits(),r=O(this._viewY),i=``;for(let a=0;a<12;a++){let o=r+a,s=e&&e.y===o,c=t===o,l=n(o),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `),d=this._yearOnly()?` tabindex="${o===this._gridFocus&&!l?0:-1}"`:``;i+=`<button type="button" class="${u}" data-year="${o}"${d}${l?` disabled`:``}>${o}</button>`}return`
|
|
29
|
-
<div class="datepicker-head">
|
|
30
|
-
<button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="${w(D().previousDecadeLabel)}">${b(`chevron-left`)}</button>
|
|
31
|
-
<span class="datepicker-month">${r+1} to ${r+10}</span>
|
|
32
|
-
<button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="${w(D().nextDecadeLabel)}">${b(`chevron-right`)}</button>
|
|
33
|
-
</div>
|
|
34
|
-
<div class="datepicker-cells">${i}</div>${this._clearFoot(this._yearOnly())}`}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>n(Math.floor(e/12),t(e))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:O,unit:e=>e,cell:e=>e,disabled:e,iso:r}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=/* @__PURE__ */ new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,n,r){let{y:i,m:a}=u(e,t);this._focus={y:i,m:a,d:n};let o=i!==this._viewY||a!==this._viewM;this._viewY=i,this._viewM=a,this._slide=o&&r||``,this._renderView(),this._slide=``;let s=this.querySelector(`.datepicker-day[data-iso="${d(i,a,n)}"]`);s instanceof HTMLButtonElement&&s.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch(e.key){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let n=this._focus||l(this._value)||{y:this._viewY,m:this._viewM,d:1},r=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},i=(t,i,a=t<0?-1:1)=>{e.preventDefault(),r(n.y,n.m,n.d+t,a,i)};switch(e.key){case`ArrowLeft`:i(-1,`slide-prev`);break;case`ArrowRight`:i(1,`slide-next`);break;case`ArrowUp`:i(-7,`slide-prev`);break;case`ArrowDown`:i(7,`slide-next`);break;case`Home`:i(-((new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:i(6-(new Date(n.y,n.m,n.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=u(n.y,n.m-(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=u(n.y,n.m+(e.shiftKey?12:1));r(t.y,t.m,Math.min(n.d,o(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(n.y,n.m,n.d)||(this.value=d(n.y,n.m,n.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),i=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>C(t),o=()=>{i?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if(h(this))return;let n=/* @__PURE__ */ new Date,r=this._parts(this._value),s=this._gridKind();if(s)this._viewY=r?r.y:n.getFullYear(),this._mode=s.view,this._focus=null,this._gridFocus=this._gridFocusCell(s);else{(r||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=r&&r.y===this._viewY&&r.m===this._viewM;if(this._focus=t?r:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),S(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!a())return;i?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let c=t.querySelector(`[tabindex="0"]`);c instanceof HTMLElement&&c.focus()},this._closeFn=()=>{x(t)},e.addEventListener(`click`,()=>a()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let i=t.closest(`[data-nav]`);if(i instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(i.dataset.nav)<0?`slide-prev`:`slide-next`;let e=u(this._viewY,this._viewM+Number(i.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let a=t.closest(`[data-nav-year]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navYear),this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-nav-decade]`);if(o instanceof HTMLElement){this._viewY+=Number(o.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let s=t.closest(`[data-view]`);if(s instanceof HTMLElement){this._mode=s.dataset.view,this._renderView();return}let c=t.closest(`[data-month]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._monthOnly()){this.value=n(this._viewY,Number(c.dataset.month)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(c.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let l=t.closest(`[data-year]`);if(l instanceof HTMLButtonElement&&!l.disabled){if(this._yearOnly()){this.value=r(Number(l.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(l.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=/* @__PURE__ */ new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=d(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let f=t.closest(`.datepicker-day[data-iso]`);f instanceof HTMLButtonElement&&!f.disabled&&(this.value=f.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{a()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};export{k as t};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,s as r,t as i,u as a}from"./calendarMath-DIoh4HjR.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{r as s,t as c}from"./textStore-opIEM4lu.js";import{t as l}from"./dateRangePicker.g-Pnc37vgX.js";import{C as u,S as d,_ as f,b as p,x as m}from"./formatters-CMTSYlW9.js";import{t as h}from"./elementBase-Cxeyx0tU.js";import{r as g,t as _}from"./fieldState-D-zQcXUS.js";import{t as v}from"./iconGlyphs.g-BUF97bUu.js";import{a as y,l as b,s as x}from"./nativeOverlay-DGady-wN.js";import{n as S}from"./optionLabel-CWMhBkdO.js";var C=4,w=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],T={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},E=e=>String(e).padStart(2,`0`),D=e=>`${e.getUTCFullYear()}-${E(e.getUTCMonth()+1)}-${E(e.getUTCDate())}`;function O(e){return w.includes(e)}function k(e,t=/* @__PURE__ */ new Date,{timeZone:n=m,financialYearStart:i=C}={}){if(!O(e))return null;let a=r(u(n,t));if(!a)throw Error(`today missing`);let{y:o,m:c,d}=a,f=(e,t,n)=>D(new Date(Date.UTC(e,t,n))),p=s(`dateRangePicker`,l)[T[e]];switch(e){case`today`:return{label:p,start:f(o,c,d),end:f(o,c,d)};case`yesterday`:return{label:p,start:f(o,c,d-1),end:f(o,c,d-1)};case`last7Days`:return{label:p,start:f(o,c,d-6),end:f(o,c,d)};case`last30Days`:return{label:p,start:f(o,c,d-29),end:f(o,c,d)};case`thisMonth`:return{label:p,start:f(o,c,1),end:f(o,c+1,0)};case`lastMonth`:return{label:p,start:f(o,c-1,1),end:f(o,c,0)};case`thisFinancialYear`:{let e=i-1,t=c>=e?o:o-1;return{label:p,start:f(t,e,1),end:f(t+1,e,0)}}default:return null}}function A(e){o(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function j(e){return typeof e==`object`&&!!e}function M(e,t=/* @__PURE__ */ new Date,n={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return A(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let r=k(e,t,n);r?o.push(r):A(`"${e}" is not one of ${w.join(`, `)}`)}else j(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&r(e.start)&&r(e.end)?o.push({label:e.label,start:e.start,end:e.end}):A(`an item needs a label and ISO start and end dates, or a preset name`);return o}var N=()=>s(`dateRangePicker`,l);function P(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function F(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var I=class extends h{static formAssociated=!0;_internals;_start;_end;_hover;_viewY;_viewM;get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!_(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return n(this)}_label(){let t=this.getAttribute(`placeholder`)||N().placeholder;return!this._start&&!this._end?{text:t,empty:!0}:{text:c(N().rangeText,{start:e(this._start)||N().startLabel,end:e(this._end)||N().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=r(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),o=this.getAttribute(`aria-label`),s=this.getAttribute(`aria-describedby`);this.innerHTML=`
|
|
2
|
-
<div class="daterange">
|
|
3
|
-
<button type="button" class="input daterange-trigger${n}${a?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${o?` aria-label="${S(o)}"`:``}${s?` aria-describedby="${S(s)}"`:``}>
|
|
4
|
-
<span data-range-label class="${a?`wui-select-placeholder`:``}">${S(i)}</span>
|
|
5
|
-
${v(`calendar`)}
|
|
6
|
-
</button>
|
|
7
|
-
<div class="daterange-pop" role="dialog" popover="auto"></div>
|
|
8
|
-
</div>`,g(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r)}_syncMirrors(){let e=this.getAttribute(`start-name`)||this.getAttribute(`name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){let e=r(this.getAttribute(`min`)),t=r(this.getAttribute(`max`)),n=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0;return(e,t,r)=>{let a=new Date(e,t,r).getTime();return a<n||a>i}}_monthHtml(e,n){let r=this._firstDay(),o=(new Date(e,n,1).getDay()-r+7)%7,s=t(e,n),c=this._limits(),l=Array.from({length:7},(e,t)=>p((t+r)%7,`min`)).map(e=>`<span>${e}</span>`).join(``),u=(e,t,n,r)=>{let i=a(e,t,n),o=c(e,t,n);return`<button type="button" class="${[`datepicker-day`,r?`is-outside`:``].filter(Boolean).join(` `)}" data-iso="${i}"${o?` disabled`:``}>${n}</button>`},d=``,m=i(e,n-1),h=t(m.y,m.m);for(let e=o-1;e>=0;e--)d+=u(m.y,m.m,h-e,!0);for(let t=1;t<=s;t++)d+=u(e,n,t,!1);let g=i(e,n+1),_=(7-(o+s)%7)%7;for(let e=1;e<=_;e++)d+=u(g.y,g.m,e,!0);return`
|
|
9
|
-
<div class="daterange-cal">
|
|
10
|
-
<div class="datepicker-month-label">${f(n)} ${e}</div>
|
|
11
|
-
<div class="datepicker-weekdays">${l}</div>
|
|
12
|
-
<div class="datepicker-grid" role="grid">${d}</div>
|
|
13
|
-
</div>`}_presetOptions(){let e=this.getAttribute(`time-zone`),t=m;e!==null&&(d(e)?t=e:o(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),r=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?r=e:o(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:r}}_presetsHtml(){if(!this._presetList?.length)return``;let e=this._limits(),t=t=>{let n=r(t);if(!n)throw Error(`Expected a preset date, found "${t}".`);return e(n.y,n.m,n.d)},n=this._presetList.map((e,n)=>`<button type="button" class="wui-daterange-preset" data-preset="${n}"${t(e.start)||t(e.end)?` disabled`:``}>${S(e.label)}</button>`).join(``);return`<div class="wui-daterange-presets" role="group" aria-label="${S(N().quickRangesLabel)}">${n}</div>`}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=i(this._viewY,this._viewM+1),n=this._presetsHtml(),r=`
|
|
14
|
-
<div class="daterange-head">
|
|
15
|
-
<button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="${S(N().previousMonthLabel)}">${v(`chevron-left`)}</button>
|
|
16
|
-
<button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="${S(N().nextMonthLabel)}">${v(`chevron-right`)}</button>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="daterange-cals">
|
|
19
|
-
${this._monthHtml(this._viewY,this._viewM)}
|
|
20
|
-
${this._monthHtml(t.y,t.m)}
|
|
21
|
-
</div>
|
|
22
|
-
<div class="datepicker-foot">
|
|
23
|
-
<span class="daterange-hint" data-range-hint></span>
|
|
24
|
-
<button type="button" class="datepicker-link" data-clear>${S(N().clearLabel)}</button>
|
|
25
|
-
</div>`;e.classList.toggle(`wui-daterange-pop--presets`,n!==``),e.innerHTML=n?`${n}<div class="wui-daterange-main">${r}</div>`:r,this._paint()}_paint(){let t=this.querySelector(`.daterange-pop`);if(!t)return;let n=this._start?new Date(this._start).getTime():null,r=this._end;n&&!this._end&&this._hover&&new Date(this._hover).getTime()>=n&&(r=this._hover);let i=r?new Date(r).getTime():null;for(let e of F(t,`.datepicker-day[data-iso]`)){let t=new Date(e.dataset.iso??``).getTime(),r=n!=null&&t===n,a=i!=null&&t===i,o=n!=null&&i!=null&&t>n&&t<i;e.classList.toggle(`is-range-start`,r),e.classList.toggle(`is-range-end`,a),e.classList.toggle(`in-range`,o)}F(t,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let a=t.querySelector(`[data-range-hint]`);a&&(a.textContent=this._start?this._end?c(N().rangeText,{start:e(this._start),end:e(this._end)}):N().pickEndDateLabel:N().pickStartDateLabel)}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&y(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),n=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let a=()=>x(t),o=()=>{this._hover=``,n?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let i=r(this._start);if(i)this._viewY=i.y,this._viewM=i.m;else{let e=/* @__PURE__ */ new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=M(this.getAttribute(`presets`),/* @__PURE__ */ new Date,this._presetOptions()),this._renderView(),b(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),a()&&(n?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{y(t)},e.addEventListener(`click`,()=>{a()?this._close():_(this)||this._open()}),t.addEventListener(`click`,e=>{let t=P(e),n=t.closest(`[data-nav]`);if(n instanceof HTMLElement){let e=i(this._viewY,this._viewM+Number(n.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=t.closest(`[data-preset]`);if(r instanceof HTMLButtonElement&&!r.disabled){let e=this._presetList?.[Number(r.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=P(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};export{I as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./buttonClass-GtEi8hAY.js";import{t}from"./devWarn-DXdRWZs3.js";import{r as n}from"./dom-Do1pAA12.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{a as i,c as a,d as o,f as s,i as c,l,m as u,n as d,o as f,p,s as m,t as h,u as g}from"./initials-Qb6ITcri.js";import{t as _}from"./avatarHtml-BWlA0cm-.js";import{t as v}from"./iconGlyphs.g-BUF97bUu.js";import{n as y,r as b,t as x}from"./textStore-opIEM4lu.js";import{a as S,l as C}from"./nativeOverlay-DGady-wN.js";import{t as w}from"./gantt.g-TdTxeruW.js";var T=`data-wui-gantt-pick`,E=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r},D=e=>`${e}px`,O=(e,t,n)=>{let r=E(`div`,`wui-gantt-table-cell`,n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function k(e){let t=e.text,n=E(`div`,`wui-gantt-table`);n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=E(`div`);r.setAttribute(`role`,`rowgroup`);let i=E(`div`,`wui-gantt-table-row`);i.dataset.kind=`head`,i.setAttribute(`role`,`row`),i.style.height=D(e.headHeight),i.append(O(`name`,`columnheader`,t.tableName),O(`owner`,`columnheader`,t.detailsOwner),O(`start`,`columnheader`,t.tableStart),O(`end`,`columnheader`,t.tableEnd),O(`done`,`columnheader`,t.detailsDone)),r.append(i);let a=E(`div`);a.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let r=n.row;if(n.kind===`group`){let r=n.group;if(!r)continue;let i=E(`div`,`wui-gantt-table-row`);i.dataset.kind=`group`,i.dataset.wuiGanttGroup=r.name,i.setAttribute(`role`,`row`),i.style.height=D(n.height);let o=E(`div`,`wui-gantt-table-cell wui-gantt-table-group`);o.setAttribute(`role`,`rowheader`);let s=E(`button`,`wui-gantt-group-toggle`);s.type=`button`,s.setAttribute(`aria-expanded`,String(!r.folded)),s.setAttribute(`aria-label`,x(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),s.setAttribute(e.focusAttr,`group:${r.name}`),s.innerHTML=v(r.folded?`chevron-right`:`chevron-down`,{size:16}),o.append(s,E(`span`,null,r.name),E(`span`,null,y(t,`groupSummary`,r.count,{percent:r.percent}))),i.append(o),a.append(i);continue}let i=E(`div`,`wui-gantt-table-row`);i.dataset.kind=r.end===void 0?`milestone`:`bar`,i.dataset.wuiGanttKey=r.key,i.dataset.wuiGanttPick=r.key,r.key===e.selected&&(i.dataset.selected=`true`),i.setAttribute(`role`,`row`),i.style.height=D(n.height);let o=O(`name`,`rowheader`,r.name);o.title=r.name;let s=O(`owner`,`cell`,``);r.owner&&(s.title=r.owner,s.innerHTML=_({initials:h(r.owner)},`avatar-xs`),s.append(E(`span`,`visually-hidden`,r.owner)));let c=O(`start`,`cell`,r.start===void 0?``:f(l(r.start))),u=O(`end`,`cell`,r.end===void 0?``:f(l(r.end))),d=O(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);i.append(o,s,c,u,d),a.append(i)}let o=e.skeleton;for(let e=0;o&&e<o.rows;e+=1){let e=E(`div`,`wui-gantt-table-row`);e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=D(o.rowHeight);let t=E(`span`,`wui-gantt-skeleton`);t.style.height=D(o.barHeight),e.append(t),a.append(e)}return n.append(r,a),n}var A=()=>b(`gantt`,w),j=`wui-gantt:zoom-change`,M=`wui-gantt:from-change`,N=`wui-gantt:fold-change`,P=`wui-gantt:select`,F=`wui-gantt:add-task`,I=`wui-gantt:retry`,L=`data-wui-gantt-focus`,R=`bar:`,z=`http://www.w3.org/2000/svg`,B=[`day`,`week`,`month`],V=3,H=16,U=300,W=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],G=0,K=(e,t,n)=>{let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r},q=e=>`${e}px`;function J(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function Y(e){let t=A();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var X=e=>e.progress??0,Z=e=>e.status??`notStarted`,Q=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),$=class extends r{uid;_spec=null;_prev=null;_zoom=`week`;_fromMs=null;_folded=/* @__PURE__ */ new Set;_selected=null;_controlled=!1;_awaitingSpec=!1;_connected=!1;_focusAfter=null;_resolved=null;_specRows=[];_card=null;_onClick;_onKeyDown;_onChange;constructor(){super(),G+=1,this.uid=`wui-gantt-${G}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if(Object.hasOwn(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=(S(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return t(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?l(e.from):null),n(!Q(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(j,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:o(e,this._fromMs),this._draw())}_setFrom(e){this._emit(M,{from:m(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(N,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(P,{key:e}),this._focusAfter=`${R}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=B.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${L}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(L)??``,n);return}let r=t.closest(`[${T}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(R)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(F):e===`retry`?this._emit(I):n&&e===`nav:earlier`?this._setFrom(g(n.zoom,n.fromMs,-1)):n&&e===`nav:later`?this._setFrom(g(n.zoom,n.fromMs,1)):n&&e===`nav:today`?this._setFrom(u(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${L}^="${R}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!W.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(L)?.startsWith(R))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),e.key){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n.at(-1));break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(L)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(L):null}_draw(){if(this._card&&=(S(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let r;try{r=this._compose()}catch(e){t(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),r=[this._stateBlock(`error`,A().errorText)]}if(this.replaceChildren(...r),this._card){let e=n(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),C(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let i=[...this.querySelectorAll(`[${L}]`)].find(t=>t.getAttribute(L)===e);i instanceof HTMLElement&&(e.startsWith(R)?this._focusBar(i):i.focus())}_compose(){let e=this._spec;if(!J(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),p(e);let t=e.layout??`table`,n=c[t],r=A(),f=l(e.today??s()),m=this._zoom,h=o(m,this._fromMs??u(m,f)),g={layout:t,zoom:m,fromMs:h,todayMs:f};this._resolved=g,this._specRows=e.rows;let _=e.rows.some(e=>e.start!==void 0),v=(e.state??`ready`)===`ready`&&!_?`empty`:e.state??`ready`;this.dataset.state=v,this.dataset.zoom=m,this.dataset.layout=t,v===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let y=v===`ready`?a({...e,folded:[...this._folded],selected:this._selected},g):null,b=y?.axis??i(t,m,h),x=K(`div`,`wui-gantt-lane`);x.style.width=q(b.width),y?this._fillLane(x,e,y):v===`loading`&&(x.style.height=q(V*n.rowH));let S=[];v===`loading`&&S.push(this._fillSkeleton(x,e,n)),v===`empty`&&S.push(this._emptyBlock(e)),v===`error`&&S.push(this._stateBlock(`error`,e.errorText||r.errorText));let C=this._head(b),w=K(`div`,`wui-gantt-plot`);w.append(C,x);let T=K(`div`,`wui-gantt-scroller`);if(t===`table`){let t=k({title:e.title,rows:y?.rows??[],headHeight:2*d.tierH,selected:this._selected,text:r,focusAttr:L,skeleton:v===`loading`?{rows:V,rowHeight:n.rowH,barHeight:n.barH}:void 0});T.append(t,w)}else T.append(w);return[this._toolbar(e,v===`ready`),T,...S,this._legend(t)]}_toolbar(e,t){let n=K(`div`,`wui-gantt-toolbar`);return t&&n.append(K(`p`,`wui-gantt-count`,this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=A(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,l(e.start??``)),a=Math.max(a,l(e.end??e.start??``));return[y(t,`summaryTasks`,n.length-r),y(t,`summaryMilestones`,r),x(t.summaryRange,{from:f(i),to:f(a)})].join(`, `)}_scale(){let e=A(),t=K(`div`,`segmented segmented-sm wui-gantt-scale`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign(K(`span`,`segmented-thumb`),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of B){let r=K(`label`,`segmented-option`),i=K(`input`,`segmented-input`);i.type=`radio`,i.name=`${this.uid}-scale`,i.value=e,i.checked=e===this._zoom,i.setAttribute(L,`zoom:${e}`),r.append(i,n[e]),t.append(r)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=q(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let t=A(),n=K(`div`,`wui-gantt-nav`),r=(t,n,r)=>{let i=K(`button`,e(`neutral`,`soft`,`sm`));return i.type=`button`,i.setAttribute(`aria-label`,n),i.setAttribute(L,t),i.innerHTML=v(r,{size:16}),i},i=K(`button`,e(`neutral`,`soft`,`sm`),t.todayLabel);return i.type=`button`,i.setAttribute(L,`nav:today`),n.append(r(`nav:earlier`,t.earlierLabel,`chevron-left`),r(`nav:later`,t.laterLabel,`chevron-right`),i),n}_head(e){let t=K(`div`,`wui-gantt-head`);t.style.width=q(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=K(`div`,`wui-gantt-tier ${t}`);for(let t of e){let e=K(`div`,t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`);e.style.left=q(t.x),e.style.width=q(t.w),t.sub&&e.append(K(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=A(),n=K(`div`,`wui-gantt-legend`);n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=K(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=K(`span`,`wui-gantt-swatch`);t.dataset.status=e,r(t,Y(e))}let i=K(`span`,`wui-gantt-swatch`);if(i.dataset.kind=`milestone`,r(i,t.milestoneLabel),e===`table`){let e=K(`span`,`wui-gantt-legend-note`,t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(t,n){let r=A(),i=K(`div`,`wui-gantt-state`);if(t===`error`){i.setAttribute(`role`,`alert`),i.append(K(`p`,null,n));let t=K(`button`,e(`neutral`,`soft`,`sm`),r.retryLabel);t.type=`button`,t.setAttribute(L,`retry`),i.append(t)}else i.append(K(`p`,null,n));return i}_emptyBlock(t){let n=A(),r=K(`div`,`wui-gantt-state`);if(r.append(K(`p`,`fw-semibold`,n.emptyTitle),K(`p`,null,t.emptyText||n.emptyText)),t.addTask){let t=K(`button`,e(`primary`,`solid`,`sm`),n.addTaskLabel);t.type=`button`,t.setAttribute(L,`add`),r.append(t)}return r}_fillSkeleton(e,t,n){let r=K(`div`,`visually-hidden`,t.loadingText||A().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<V;t+=1){let r=K(`div`,`wui-gantt-skeleton`);r.style.top=q(t*n.rowH+n.barTop),r.style.left=q(40+t*60),r.style.width=q(240),r.style.height=q(n.barH),r.setAttribute(`aria-hidden`,`true`),e.append(r)}return r}_fillLane(e,t,n){let r=A(),{axis:i}=n,a=n.layout===`table`;e.style.height=q(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let o=K(`p`,`visually-hidden`,a?r.helpTextTable:r.helpText);o.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,o.id);let s=(e,t,n,r,i)=>{let a=K(`div`,e);return a.setAttribute(`aria-hidden`,`true`),a.style.left=q(t),a.style.top=q(n),a.style.width=q(r),a.style.height=q(i),a},c=[o];for(let e of n.rows){if(e.height===0)continue;let t=s(`wui-gantt-row`,0,e.top,i.width,e.height);a&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),c.push(t)}for(let e of i.weekendX)c.push(s(`wui-gantt-weekend`,e,0,i.ppd,n.height));for(let e of i.gridX)c.push(s(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){c.push(s(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=K(`div`,`wui-gantt-today-flag rounded-pill`,r.todayLabel);e.style.left=q(n.today.x),c.push(e)}let l=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let t=K(`div`,`wui-gantt-item`);t.setAttribute(`role`,`listitem`),t.style.display=`contents`,e.kind===`group`?this._drawGroup(t,e,n):e.kind===`milestone`?this._drawMilestone(t,e,l,n):this._drawBar(t,e,l,n),c.push(t)}c.push(this._deps(n)),this._card=a?null:this._details(n,l),e.append(...c);let u=e.querySelector(`[${L}^="${R}"]`);u instanceof HTMLElement&&(u.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=A(),r=this._names(e,t);if(e.end===void 0){let t=f(l(e.start??``));return r?x(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=x(n.barLabel,{name:e.name,start:f(l(e.start??``)),end:f(l(e.end)),percent:X(e),status:Y(Z(e)).toLowerCase()});return r?x(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,r){let i=K(`button`,t);i.type=`button`;let a=this._barSentence(e,n);return i.setAttribute(`aria-label`,a),i.title=a,i.tabIndex=-1,i.dataset.status=Z(e),i.dataset.wuiGanttKey=e.key,i.setAttribute(L,`${R}${e.key}`),r?i.setAttribute(`aria-pressed`,String(this._selected===e.key)):i.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(i.dataset.selected=`true`),i}_afterLabel(e,t,n,r){let i=K(`span`,`wui-gantt-label wui-gantt-label-surface`,e);return i.style.left=q(t),i.style.top=q(n),i.style.height=q(r),i}_drawBar(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=this._focusable(i,`wui-gantt-bar rounded-2`,n,o),c=t.top+a.barTop;s.style.left=q(t.x),s.style.width=q(t.w),s.style.top=q(c),s.style.height=q(a.barH);let l=X(i),u=K(`span`,`wui-gantt-bar-progress`);if(u.style.width=`${l}%`,s.append(u),e.append(s),o)return;let d=`${i.name} ${l}%`;t.place===`inside`?s.append(K(`span`,`wui-gantt-bar-label`,d)):e.append(this._afterLabel(d,t.x+t.w+H,c,a.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=d.milestone/2,c=t.top+(a.rowH-d.milestone)/2,u=this._focusable(i,`wui-gantt-milestone`,n,o);if(u.style.left=q(t.x-s),u.style.top=q(c),u.style.width=q(d.milestone),u.style.height=q(d.milestone),e.append(u),o)return;let p=this._afterLabel(`${i.name}, ${f(l(i.start??``))}`,t.x+d.milestone,t.top+a.barTop,a.barH);t.flip&&(p.style.left=``,p.style.right=q(r.axis.width-(t.x-d.milestone))),e.append(p)}_drawGroup(e,t,n){let r=A(),i=t.group;if(!i)return;if(n.layout===`lanes`){let n=K(`div`,`wui-gantt-group wui-gantt-label wui-gantt-label-surface`);n.dataset.wuiGanttGroup=i.name,n.style.left=q(8),n.style.top=q(t.top+6);let a=K(`button`,`wui-gantt-group-toggle`);a.type=`button`,a.setAttribute(`aria-expanded`,String(!i.folded)),a.setAttribute(`aria-label`,x(i.folded?r.unfoldLabel:r.foldLabel,{group:i.name})),a.setAttribute(L,`group:${i.name}`),a.innerHTML=v(i.folded?`chevron-right`:`chevron-down`,{size:16}),n.append(a,K(`span`,null,i.name),K(`span`,null,y(r,`groupSummary`,i.count,{percent:i.percent}))),e.append(n)}let a=K(`div`,`wui-gantt-group-summary`);a.dataset.wuiGanttGroup=i.name,a.style.left=q(t.x),a.style.width=q(t.w),a.style.top=q(t.top+n.geometry.groupBarTop),a.style.height=q(d.groupBarH),e.append(a)}_deps(e){let t=document.createElementNS(z,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(z,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(z,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(t,n){let r=this._selected,i=r===null?void 0:t.rows.find(e=>e.row.key===r&&e.kind!==`group`&&!e.hidden);if(!i)return null;let a=A(),{row:o}=i,s=K(`div`,`wui-gantt-details`);s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,o.name),s.style.width=q(U);let c=K(`dl`),u=(e,t)=>{c.append(K(`dt`,null,e),K(`dd`,null,t))},d=f(l(o.start??``));o.owner&&u(a.detailsOwner,o.owner),u(a.detailsDates,o.end===void 0?d:x(a.detailsRange,{start:d,end:f(l(o.end))})),o.end!==void 0&&u(a.detailsDone,`${X(o)}%, ${Y(Z(o))}`);let p=this._names(o,n);p&&u(a.detailsStartsAfter,p);let m=K(`button`,e(`neutral`,`ghost`,`sm`),a.detailsCloseLabel);return m.type=`button`,m.setAttribute(L,`close`),s.append(K(`h3`,`h6`,o.name),c,m),s}};export{$ as t};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./elementBase-Cxeyx0tU.js";import{r as t,t as n}from"./textStore-opIEM4lu.js";import{t as r}from"./imageCrop.g-BnbAeH2Q.js";var i=4096,a=[.92,.8,.65,.5],o=.8,s=8;function c(e){if(e==null||e===``||e===`free`)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)&&t>0?t:null}function l(e,t,n){if(!n)return{x:0,y:0,w:e,h:t};let r=e,i=r/n;return i>t&&(i=t,r=i*n),{x:(e-r)/2,y:(t-i)/2,w:r,h:i}}function u(e,t,n){return{...e,x:Math.min(Math.max(e.x,0),Math.max(t-e.w,0)),y:Math.min(Math.max(e.y,0),Math.max(n-e.h,0))}}function d(e,t,n,r,i){return u({...e,x:e.x+t,y:e.y+n},r,i)}function f(e,t){return Math.min(32,e,t)}function p(e,t){return t.w/e.w}function m(e,t){return Math.max(4,p(e,t))}function h(e,t,n,r,i){let a=Math.min(Math.max(n,1),m(e,t)),o=e.h/e.w,s=Math.min(r,i/o),c=Math.min(Math.max(f(r,i),f(r,i)/o),s),l=Math.min(Math.max(t.w/a,c),s),d=l*o,p=e.x+e.w/2,h=e.y+e.h/2;return u({x:p-l/2,y:h-d/2,w:l,h:d},r,i)}var g=[`nw`,`ne`,`sw`,`se`];function _(e,t,n,r,i,a){let o=f(i,a),s=t.endsWith(`w`),c=t.startsWith(`n`),l=s?e.x+e.w:e.x,u=c?e.y+e.h:e.y,d=Math.min(Math.max(n,0),i),p=Math.min(Math.max(r,0),a);return d=s?Math.min(d,l-o):Math.max(d,l+o),p=c?Math.min(p,u-o):Math.max(p,u+o),{x:Math.min(d,l),y:Math.min(p,u),w:Math.abs(d-l),h:Math.abs(p-u)}}function v(e,t=i){let n=Math.min(1,t/Math.max(e.w,e.h));return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function y(e,t){let n=t/Math.max(e.w,e.h);return{width:Math.max(1,Math.round(e.w*n)),height:Math.max(1,Math.round(e.h*n))}}function b(e,t,n){return n%180==0?{w:e,h:t}:{w:t,h:e}}function x(e,t,n){return u({x:n-(e.y+e.h),y:e.x,w:e.h,h:e.w},n,t)}function S(e){return String(e||``).split(/[\s,]+/).map(Number).filter(e=>Number.isInteger(e)&&e>0)}var C=[`image/png`,`image/jpeg`,`image/webp`],w={"image/png":`.png`,"image/jpeg":`.jpg`,"image/webp":`.webp`};function T(e){let t=String(e||``).toLowerCase();return C.includes(t)?t:`image/png`}function E(e,t){let n=String(e||`image`),r=w[t];if(r===void 0)throw Error(`No file extension for ${t}`);return(t===`image/jpeg`?/\.jpe?g$/i.test(n):n.toLowerCase().endsWith(r))?n:`${n.replace(/\.[^./\\]+$/,``)||`image`}${r}`}async function D(e,{width:t,height:n,type:r,maxBytes:i}){let c=r,l=t,u=n,d=null;for(let t=0;t<=s;t++){let n=c===`image/png`?[void 0]:t===0?a:[a[1]];for(let t of n){if(d=await e(l,u,c,t),!d||(d.type&&d.type!==c&&(c=d.type),!(i>0)||d.size<=i))return d;if(c===`image/png`)break}l=Math.max(1,Math.round(l*o)),u=Math.max(1,Math.round(u*o))}return d}var O=.05,k=.2,A={w:320,h:240},j={nw:`topLeftLabel`,ne:`topRightLabel`,sw:`bottomLeftLabel`,se:`bottomRightLabel`},M=()=>t(`imageCrop`,r),N=e=>{let t=j[e];return t?M()[t]:e};function P(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var F=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14"/></svg>`,I=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M5 12h14M12 5v14"/></svg>`,L=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>`,R=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>`,z=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function B(e){let[t,n]=[...e.values()];if(!t||!n)throw Error(`two pointers missing`);return[t,n]}function V(e,t){if(e===null)throw Error(`${t} missing`);return e}function H(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`${t} missing`);return r}function U(e){if(e===null)throw Error(`event target missing`);if(!(e instanceof Element))return null;let t=e.closest(`.wui-crop-handle`);return t instanceof HTMLElement?t:null}var W=class extends e{_rect;_base;_natural;_source;_rotation;_drag;_pointers;_pinch;_previewPending;_resizeObserver;_rendered;_stageEl;_imgEl;_frameEl;_sliderEl;_toolsEl;_previewBoxEl;_liveEl;static get observedAttributes(){return[`src`,`aspect`,`round`,`rotatable`,`previews`]}constructor(){super(),this._rect=null,this._base=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pointers=/* @__PURE__ */ new Map,this._pinch=null,this._previewPending=!1,this._resizeObserver=null,this._stageEl=null,this._imgEl=null,this._frameEl=null,this._sliderEl=null,this._toolsEl=null,this._previewBoxEl=null,this._liveEl=null}get _stage(){return V(this._stageEl,`stage`)}get _img(){return V(this._imgEl,`image`)}get _frame(){return V(this._frameEl,`frame`)}get _slider(){return V(this._sliderEl,`zoom slider`)}get _tools(){return V(this._toolsEl,`tools`)}get _previewBox(){return V(this._previewBoxEl,`previews`)}get _live(){return V(this._liveEl,`live region`)}get src(){return this.getAttribute(`src`)||``}set src(e){e==null||e===``?this.removeAttribute(`src`):this.setAttribute(`src`,String(e))}get aspect(){return c(this.getAttribute(`aspect`))}set aspect(e){e==null||e===``?this.removeAttribute(`aspect`):this.setAttribute(`aspect`,String(e))}get round(){return this.hasAttribute(`round`)}set round(e){this.toggleAttribute(`round`,!!e)}get rotatable(){return this.hasAttribute(`rotatable`)}set rotatable(e){this.toggleAttribute(`rotatable`,!!e)}get previews(){return this.getAttribute(`previews`)||``}set previews(e){e==null||e===``?this.removeAttribute(`previews`):this.setAttribute(`previews`,Array.isArray(e)?e.join(` `):String(e))}get rect(){return this._rect?{...this._rect}:null}get rotation(){return this._rotation}set rotation(e){if(!this._rect)return;let t=(Math.round(Number(e)/90)*90%360+360)%360;if(!Number.isNaN(t))for(;this._rotation!==t;)this.rotate()}get zoom(){return this._rect?p(this._rect,V(this._base,`base frame`)):1}set zoom(e){if(!this._rect)return;let t=V(this._natural,`natural size`);this._rect=h(this._rect,V(this._base,`base frame`),Number(e)||1,t.w,t.h),this._paint(),this._announce()}connectedCallback(){this._rendered?this._observe():this.render()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}attributeChangedCallback(e){this._rendered&&(e===`src`?this._loadImage():e===`aspect`?(this._rebuildHandles(),this._resetRect()):e===`rotatable`?this._tools.hidden=!this.rotatable:e===`previews`?this._renderPreviews():this._applyRound())}render(){this.innerHTML=`<div>
|
|
2
|
-
<div class="wui-crop-stage" tabindex="0" role="group" aria-label="${P(M().cropAreaText)}">
|
|
3
|
-
<img class="wui-crop-img" alt="" draggable="false">
|
|
4
|
-
<div class="wui-crop-frame"></div>
|
|
5
|
-
</div>
|
|
6
|
-
<div class="wui-crop-controls">
|
|
7
|
-
<button type="button" class="wui-crop-zoombtn" data-zoom="out" aria-label="${P(M().zoomOutLabel)}">${F}</button>
|
|
8
|
-
<input type="range" class="form-range wui-crop-zoom" min="1" max="4" step="0.01" value="1" aria-label="${P(M().zoomLabel)}">
|
|
9
|
-
<button type="button" class="wui-crop-zoombtn" data-zoom="in" aria-label="${P(M().zoomInLabel)}">${I}</button>
|
|
10
|
-
</div>
|
|
11
|
-
<div class="wui-crop-tools" hidden>
|
|
12
|
-
<button type="button" class="wui-crop-toolbtn" data-crop-action="rotate" aria-label="${P(M().rotateClockwiseLabel)}">${L}<span>${P(M().rotateLabel)}</span></button>
|
|
13
|
-
<button type="button" class="wui-crop-toolbtn" data-crop-action="reset" aria-label="${P(M().resetCropLabel)}">${R}<span>${P(M().resetLabel)}</span></button>
|
|
14
|
-
</div>
|
|
15
|
-
<div class="wui-crop-previews" aria-hidden="true" hidden></div>
|
|
16
|
-
<div class="visually-hidden" data-wui-crop-live aria-live="polite"></div>
|
|
17
|
-
</div>`,this._stageEl=H(this,`.wui-crop-stage`,HTMLElement),this._imgEl=H(this,`.wui-crop-img`,HTMLImageElement),this._frameEl=H(this,`.wui-crop-frame`,HTMLElement),this._sliderEl=H(this,`.wui-crop-zoom`,HTMLInputElement),this._toolsEl=H(this,`.wui-crop-tools`,HTMLElement),this._previewBoxEl=H(this,`.wui-crop-previews`,HTMLElement),this._liveEl=H(this,`[data-wui-crop-live]`,HTMLElement),this._rendered=!0,this._tools.hidden=!this.rotatable,this._applyRound(),this._rebuildHandles(),this._renderPreviews(),this._wire(),this._observe(),this._loadImage()}_applyRound(){this._frame.classList.toggle(`wui-crop-frame--round`,this.round),this._previewBox.classList.toggle(`wui-crop-previews--round`,this.round)}_rebuildHandles(){for(let e of this._frame.querySelectorAll(`.wui-crop-handle`))e.remove();if(!this.aspect)for(let e of g){let t=document.createElement(`button`);t.type=`button`,t.className=`wui-crop-handle wui-crop-handle--${e}`,t.dataset.handle=e,t.setAttribute(`aria-label`,n(M().resizeCornerText,{corner:N(e)})),this._frame.appendChild(t)}}_renderPreviews(){let e=S(this.previews);this._previewBox.replaceChildren(),this._previewBox.hidden=e.length===0;for(let t of e){let e=document.createElement(`canvas`);e.className=`wui-crop-preview`,e.dataset.size=String(t),e.style.width=`${t}px`,e.style.height=`${t}px`,this._previewBox.appendChild(e)}this._schedulePreviews()}_loadImage(){this._rect=null,this._natural=null,this._source=null,this._rotation=0,this._drag=null,this._pinch=null,this._pointers.clear();let e=this.src;this._img.hidden=!e,this._frame.hidden=!0,e&&(this._img.onload=()=>{this._source={w:this._img.naturalWidth,h:this._img.naturalHeight},this._natural={...this._source},this._resetRect(),this.dispatchEvent(new Event(`load`))},this._img.onerror=()=>{this._frame.hidden=!0,this.dispatchEvent(new Event(`error`))},this._img.src=e)}_resetRect(){this._natural&&(this._base=l(this._natural.w,this._natural.h,this.aspect),this._rect={...this._base},this._frame.hidden=!1,this._paint())}_observe(){typeof ResizeObserver>`u`||this._resizeObserver||(this._resizeObserver=new ResizeObserver(()=>this._paint()),this._resizeObserver.observe(this._stage))}_view(){let e=V(this._natural,`natural size`),t=this._stage.clientWidth||A.w,n=this._stage.clientHeight||A.h,r=Math.min(t/e.w,n/e.h),i=e.w*r,a=e.h*r;return{scale:r,left:(t-i)/2,top:(n-a)/2,iw:i,ih:a}}_paint(){if(!this._rect)return;let e=this._view(),t=this._rotation%180!=0,n=t?e.ih:e.iw,r=t?e.iw:e.ih;Object.assign(this._img.style,{left:`${e.left+(e.iw-n)/2}px`,top:`${e.top+(e.ih-r)/2}px`,width:`${n}px`,height:`${r}px`,transform:this._rotation?`rotate(${this._rotation}deg)`:``});let i=this._rect;Object.assign(this._frame.style,{left:`${e.left+i.x*e.scale}px`,top:`${e.top+i.y*e.scale}px`,width:`${i.w*e.scale}px`,height:`${i.h*e.scale}px`});let a=V(this._base,`base frame`),o=p(i,a),s=m(i,a);this._slider.max=String(s),this._slider.value=String(Math.min(Math.max(o,1),s)),this._slider.setAttribute(`aria-valuetext`,`${Math.round(o*100)}%`),this._schedulePreviews()}_schedulePreviews(){if(!this._rect||this._previewBox.hidden||this._previewPending)return;this._previewPending=!0;let e=()=>{this._previewPending=!1,this._drawPreviews()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):e()}_drawPreviews(){if(!this._rect)return;let e=V(this._natural,`natural size`),t=u(this._rect,e.w,e.h),n=typeof window<`u`&&window.devicePixelRatio||1;for(let e of this._previewBox.children){if(!(e instanceof HTMLCanvasElement))throw Error(`Preview box holds a non-canvas child`);let r=e,i=Number(r.dataset.size),a=Math.max(1,Math.round(i*t.h/t.w));r.style.width=`${i}px`,r.style.height=`${a}px`,r.width=Math.round(i*n),r.height=Math.round(a*n);let o=r.getContext(`2d`);o&&this._drawCrop(o,t,r.width,r.height)}}_drawCrop(e,t,n,r){if(!this._rotation){e.drawImage(this._img,t.x,t.y,t.w,t.h,0,0,n,r);return}let i=V(this._source,`source size`),a=V(this._natural,`natural size`);e.save(),e.scale(n/t.w,r/t.h),e.translate(-t.x,-t.y),e.translate(a.w/2,a.h/2),e.rotate(this._rotation*Math.PI/180),e.drawImage(this._img,-i.w/2,-i.h/2,i.w,i.h),e.restore()}_announce(){this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:this.rect}))}_say(){let e=V(this._rect,`frame`),t=this._rotation?n(M().turnedText,{rotation:this._rotation}):``,r=n(M().frameText,{width:Math.round(e.w),height:Math.round(e.h),left:Math.round(e.x),top:Math.round(e.y),zoom:Math.round(p(e,V(this._base,`base frame`))*100),turned:t});this._live.textContent=r===this._live.textContent?`${r} `:r}rotate(){if(!this._rect)return;let e=V(this._natural,`natural size`),t=x(this._rect,e.w,e.h);this._rotation=(this._rotation+90)%360;let n=V(this._source,`source size`);this._natural=b(n.w,n.h,this._rotation),this._base=l(this._natural.w,this._natural.h,this.aspect);let r=this.aspect;this._rect=r&&r!==1?{...this._base}:t,this._paint(),this._announce()}reset(){this._source&&(this._rotation=0,this._natural={...this._source},this._resetRect(),this._announce())}_wire(){let e=this._stage;e.addEventListener(`pointerdown`,t=>{if(!this._rect||t.button>0)return;if(this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),e.setPointerCapture?.(t.pointerId),this._pointers.size===2){let[e,n]=B(this._pointers);this._drag=null,this._pinch={distance:z(e,n)||1,zoom:this.zoom,done:!1},t.preventDefault();return}if(this._pinch)return;let n=U(t.target);this._drag={id:t.pointerId,corner:n?n.dataset.handle:null,x:t.clientX,y:t.clientY,start:{...this._rect}},n||e.focus(),t.preventDefault()}),e.addEventListener(`pointermove`,t=>{if(this._pointers.has(t.pointerId)&&this._pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this._pinch){if(this._pinch.done||this._pointers.size<2||!this._pointers.has(t.pointerId))return;let[e,n]=B(this._pointers),r=this._pinch.zoom*z(e,n)/this._pinch.distance,i=V(this._natural,`natural size`);this._rect=h(V(this._rect,`frame`),V(this._base,`base frame`),r,i.w,i.h),this._paint();return}let n=this._drag;if(!n||n.id!==t.pointerId)return;let r=this._view(),{w:i,h:a}=V(this._natural,`natural size`);if(n.corner){let o=e.getBoundingClientRect(),s=(t.clientX-o.left-e.clientLeft-r.left)/r.scale,c=(t.clientY-o.top-e.clientTop-r.top)/r.scale;this._rect=_(V(this._rect,`frame`),n.corner,s,c,i,a)}else this._rect=d(n.start,(t.clientX-n.x)/r.scale,(t.clientY-n.y)/r.scale,i,a);this._paint()});let t=t=>{if(this._pointers.delete(t.pointerId)&&e.releasePointerCapture?.(t.pointerId),this._pinch){!this._pinch.done&&this._pointers.size<2&&(this._pinch.done=!0,this._announce()),this._pointers.size===0&&(this._pinch=null);return}let n=this._drag;n&&n.id===t.pointerId&&(this._drag=null,this._announce())};e.addEventListener(`pointerup`,t),e.addEventListener(`pointercancel`,t),e.addEventListener(`keydown`,e=>this._onKey(e)),e.addEventListener(`wheel`,e=>{this._rect&&this.contains(document.activeElement)&&(e.preventDefault(),this.zoom*=e.deltaY<0?1.1:1/1.1)},{passive:!1});for(let e of[`input`,`change`])this._slider.addEventListener(e,e=>e.stopPropagation());this._slider.addEventListener(`input`,()=>{this.zoom=Number(this._slider.value)});for(let e of this.querySelectorAll(`.wui-crop-zoombtn`)){if(!(e instanceof HTMLButtonElement))throw Error(`zoom button missing`);e.addEventListener(`click`,()=>{this.zoom*=e.dataset.zoom===`in`?1.25:.8})}H(this,`[data-crop-action="rotate"]`,HTMLButtonElement).addEventListener(`click`,()=>this.rotate()),H(this,`[data-crop-action="reset"]`,HTMLButtonElement).addEventListener(`click`,()=>this.reset())}_onKey(e){if(!this._rect||e.altKey||e.ctrlKey||e.metaKey)return;let{w:t,h:n}=V(this._natural,`natural size`);if(e.key===`+`||e.key===`=`)this.zoom*=1.25,this._say();else if(e.key===`-`||e.key===`_`)this.zoom*=.8,this._say();else if((e.key===`r`||e.key===`R`)&&this.rotatable)this.rotate(),this._say();else if(e.key.startsWith(`Arrow`)){let r=e.shiftKey?k:O,i=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0,a=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,o=U(e.target)?.dataset.handle;if(o){let e=this._rect,s=(o.endsWith(`w`)?e.x:e.x+e.w)+i*r*e.w,c=(o.startsWith(`n`)?e.y:e.y+e.h)+a*r*e.h;this._rect=_(e,o,s,c,t,n)}else this._rect=d(this._rect,i*r*this._rect.w,a*r*this._rect.h,t,n);this._paint(),this._announce(),this._say()}else return;e.preventDefault()}async toBlob({type:e,maxBytes:t=0,size:n=0}={}){if(!this._rect)return null;let r=T(e),i=V(this._natural,`natural size`),a=u(this._rect,i.w,i.h),{width:o,height:s}=n>0?y(a,n):v(a);return D((e,t,n,r)=>new Promise(i=>{let o=document.createElement(`canvas`);o.width=e,o.height=t;let s=o.getContext(`2d`);s?(n===`image/jpeg`&&(s.fillStyle=`#fff`,s.fillRect(0,0,e,t)),this._drawCrop(s,a,e,t),o.toBlob(i,n,r)):i(null)}),{width:o,height:s,type:r,maxBytes:t})}async toFile({name:e,type:t,maxBytes:n=0,size:r=0}={}){let i=await this.toBlob({type:t,maxBytes:n,size:r});return i?new File([i],E(e,i.type),{type:i.type}):null}};export{W as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./calendarMath-DIoh4HjR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-CMTSYlW9.js";import{t as o}from"./imeSafeEnter-DPs9qL3S.js";import{n as s,t as c}from"./inlineEditText-CGaAKZhR.js";import{l}from"./wuiHttp-DGbD7Fra.js";import{r as u,t as d}from"./textStore-opIEM4lu.js";import{t as f}from"./inlineEdit.g-ZxRNYq0t.js";var p=()=>u(`inlineEdit`,f),m=e=>s.some(t=>t===e),h=`[data-wui-display]`,g=`[data-wui-value]`,_=`[data-wui-editor]`,v=`[data-wui-control]`,y=`[data-wui-error]`,b=`[data-wui-live]`,x=`[aria-expanded="true"]`,S=/* @__PURE__ */ new Set([`select`,`date`]),C=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:p().serverMessage},w=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,T=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},E=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=T(this,h),t=T(this,_),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(h)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(_)?.querySelector(x))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||S.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!S.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(d(p().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(d(p().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:C(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await l(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.html.trim()};let a={forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().validationMessage,server:p().serverMessage,network:p().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||p().serverMessage}}_close(){let e=T(this,h),t=T(this,_),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),T(t,x)?.click(),n&&e?.focus()}_focusControl(e){if(!S.has(this._type())){e.focus(),e.select?.();return}let t=T(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(g);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(g);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(g);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=T(this,y),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(b);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(v);return w(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return m(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{E as t};
|