@m3e/web 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/all.js +2783 -354
- package/dist/all.js.map +1 -1
- package/dist/all.min.js +77 -41
- package/dist/all.min.js.map +1 -1
- package/dist/app-bar.js +14 -7
- package/dist/app-bar.js.map +1 -1
- package/dist/app-bar.min.js +1 -1
- package/dist/app-bar.min.js.map +1 -1
- package/dist/autocomplete.js +24 -26
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.min.js +1 -1
- package/dist/autocomplete.min.js.map +1 -1
- package/dist/bottom-sheet.js +8 -27
- package/dist/bottom-sheet.js.map +1 -1
- package/dist/bottom-sheet.min.js +1 -1
- package/dist/bottom-sheet.min.js.map +1 -1
- package/dist/calendar.js +1082 -0
- package/dist/calendar.js.map +1 -0
- package/dist/calendar.min.js +43 -0
- package/dist/calendar.min.js.map +1 -0
- package/dist/card.js +4 -2
- package/dist/card.js.map +1 -1
- package/dist/card.min.js +1 -1
- package/dist/card.min.js.map +1 -1
- package/dist/chips.js +2 -6
- package/dist/chips.js.map +1 -1
- package/dist/chips.min.js +1 -1
- package/dist/chips.min.js.map +1 -1
- package/dist/core-a11y.js +23 -9
- package/dist/core-a11y.js.map +1 -1
- package/dist/core-a11y.min.js +4 -4
- package/dist/core-a11y.min.js.map +1 -1
- package/dist/core-anchoring.js +135 -15
- package/dist/core-anchoring.js.map +1 -1
- package/dist/core-anchoring.min.js +1 -1
- package/dist/core-anchoring.min.js.map +1 -1
- package/dist/core.js +101 -1
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +1 -1
- package/dist/css-custom-data.json +962 -462
- package/dist/custom-elements.json +16838 -12546
- package/dist/datepicker.js +552 -0
- package/dist/datepicker.js.map +1 -0
- package/dist/datepicker.min.js +7 -0
- package/dist/datepicker.min.js.map +1 -0
- package/dist/fab-menu.js +1 -1
- package/dist/fab-menu.js.map +1 -1
- package/dist/fab-menu.min.js +1 -1
- package/dist/fab-menu.min.js.map +1 -1
- package/dist/form-field.js +2 -6
- package/dist/form-field.js.map +1 -1
- package/dist/form-field.min.js +3 -3
- package/dist/form-field.min.js.map +1 -1
- package/dist/html-custom-data.json +546 -180
- package/dist/menu.js +3 -7
- package/dist/menu.js.map +1 -1
- package/dist/menu.min.js +1 -1
- package/dist/menu.min.js.map +1 -1
- package/dist/nav-menu.js +3 -11
- package/dist/nav-menu.js.map +1 -1
- package/dist/nav-menu.min.js +1 -1
- package/dist/nav-menu.min.js.map +1 -1
- package/dist/nav-rail.js +2 -6
- package/dist/nav-rail.js.map +1 -1
- package/dist/nav-rail.min.js +1 -1
- package/dist/nav-rail.min.js.map +1 -1
- package/dist/option.js +5 -6
- package/dist/option.js.map +1 -1
- package/dist/option.min.js +1 -1
- package/dist/option.min.js.map +1 -1
- package/dist/paginator.js +2 -2
- package/dist/paginator.js.map +1 -1
- package/dist/paginator.min.js +1 -1
- package/dist/paginator.min.js.map +1 -1
- package/dist/search.js +805 -0
- package/dist/search.js.map +1 -0
- package/dist/search.min.js +7 -0
- package/dist/search.min.js.map +1 -0
- package/dist/select.js +5 -16
- package/dist/select.js.map +1 -1
- package/dist/select.min.js +1 -1
- package/dist/select.min.js.map +1 -1
- package/dist/snackbar.js +2 -6
- package/dist/snackbar.js.map +1 -1
- package/dist/snackbar.min.js +1 -1
- package/dist/snackbar.min.js.map +1 -1
- package/dist/src/all.d.ts +3 -0
- package/dist/src/all.d.ts.map +1 -1
- package/dist/src/app-bar/AppBarElement.d.ts +6 -4
- package/dist/src/app-bar/AppBarElement.d.ts.map +1 -1
- package/dist/src/autocomplete/AutocompleteElement.d.ts +2 -2
- package/dist/src/autocomplete/AutocompleteElement.d.ts.map +1 -1
- package/dist/src/autocomplete/AutocompleteQueryEventDetail.d.ts +12 -0
- package/dist/src/autocomplete/AutocompleteQueryEventDetail.d.ts.map +1 -0
- package/dist/src/autocomplete/QueryEventDetail.d.ts +3 -8
- package/dist/src/autocomplete/QueryEventDetail.d.ts.map +1 -1
- package/dist/src/autocomplete/index.d.ts +1 -0
- package/dist/src/autocomplete/index.d.ts.map +1 -1
- package/dist/src/bottom-sheet/BottomSheetElement.d.ts.map +1 -1
- package/dist/src/calendar/CalendarElement.d.ts +213 -0
- package/dist/src/calendar/CalendarElement.d.ts.map +1 -0
- package/dist/src/calendar/CalendarView.d.ts +3 -0
- package/dist/src/calendar/CalendarView.d.ts.map +1 -0
- package/dist/src/calendar/CalendarViewElementBase.d.ts +28 -0
- package/dist/src/calendar/CalendarViewElementBase.d.ts.map +1 -0
- package/dist/src/calendar/MonthViewElement.d.ts +36 -0
- package/dist/src/calendar/MonthViewElement.d.ts.map +1 -0
- package/dist/src/calendar/MultiYearViewElement.d.ts +27 -0
- package/dist/src/calendar/MultiYearViewElement.d.ts.map +1 -0
- package/dist/src/calendar/YearViewElement.d.ts +27 -0
- package/dist/src/calendar/YearViewElement.d.ts.map +1 -0
- package/dist/src/calendar/index.d.ts +7 -0
- package/dist/src/calendar/index.d.ts.map +1 -0
- package/dist/src/calendar/utils.d.ts +24 -0
- package/dist/src/calendar/utils.d.ts.map +1 -0
- package/dist/src/card/CardElement.d.ts.map +1 -1
- package/dist/src/chips/InputChipSetElement.d.ts.map +1 -1
- package/dist/src/core/a11y/FocusTrapElement.d.ts.map +1 -1
- package/dist/src/core/a11y/InteractivityChecker.d.ts.map +1 -1
- package/dist/src/core/anchoring/AnchorOptions.d.ts +1 -1
- package/dist/src/core/anchoring/AnchorOptions.d.ts.map +1 -1
- package/dist/src/core/anchoring/FloatingPanelElement.d.ts +18 -3
- package/dist/src/core/anchoring/FloatingPanelElement.d.ts.map +1 -1
- package/dist/src/core/anchoring/positionAnchor.d.ts.map +1 -1
- package/dist/src/core/shared/controllers/InertController.d.ts +19 -0
- package/dist/src/core/shared/controllers/InertController.d.ts.map +1 -0
- package/dist/src/core/shared/controllers/index.d.ts +1 -0
- package/dist/src/core/shared/controllers/index.d.ts.map +1 -1
- package/dist/src/core/shared/converters/dateConverter.d.ts +4 -0
- package/dist/src/core/shared/converters/dateConverter.d.ts.map +1 -0
- package/dist/src/core/shared/converters/index.d.ts +1 -0
- package/dist/src/core/shared/converters/index.d.ts.map +1 -1
- package/dist/src/core/shared/utils/index.d.ts +1 -0
- package/dist/src/core/shared/utils/index.d.ts.map +1 -1
- package/dist/src/core/shared/utils/registerStyleSheet.d.ts +7 -0
- package/dist/src/core/shared/utils/registerStyleSheet.d.ts.map +1 -0
- package/dist/src/datepicker/DatepickerElement.d.ts +237 -0
- package/dist/src/datepicker/DatepickerElement.d.ts.map +1 -0
- package/dist/src/datepicker/DatepickerToggleElement.d.ts +21 -0
- package/dist/src/datepicker/DatepickerToggleElement.d.ts.map +1 -0
- package/dist/src/datepicker/DatepickerVariant.d.ts +3 -0
- package/dist/src/datepicker/DatepickerVariant.d.ts.map +1 -0
- package/dist/src/datepicker/index.d.ts +4 -0
- package/dist/src/datepicker/index.d.ts.map +1 -0
- package/dist/src/form-field/FormFieldElement.d.ts.map +1 -1
- package/dist/src/menu/MenuElement.d.ts.map +1 -1
- package/dist/src/nav-menu/NavMenuElement.d.ts.map +1 -1
- package/dist/src/nav-menu/NavMenuItemElement.d.ts.map +1 -1
- package/dist/src/nav-rail/NavRailElement.d.ts.map +1 -1
- package/dist/src/option/OptionElement.d.ts.map +1 -1
- package/dist/src/option/OptionPanelElement.d.ts.map +1 -1
- package/dist/src/paginator/PageEventDetail.d.ts +6 -11
- package/dist/src/paginator/PageEventDetail.d.ts.map +1 -1
- package/dist/src/paginator/PaginatorElement.d.ts +3 -3
- package/dist/src/paginator/PaginatorElement.d.ts.map +1 -1
- package/dist/src/paginator/PaginatorPageEventDetail.d.ts +12 -0
- package/dist/src/paginator/PaginatorPageEventDetail.d.ts.map +1 -0
- package/dist/src/paginator/index.d.ts +1 -0
- package/dist/src/paginator/index.d.ts.map +1 -1
- package/dist/src/search/SearchBarElement.d.ts +92 -0
- package/dist/src/search/SearchBarElement.d.ts.map +1 -0
- package/dist/src/search/SearchViewElement.d.ts +146 -0
- package/dist/src/search/SearchViewElement.d.ts.map +1 -0
- package/dist/src/search/SearchViewMode.d.ts +3 -0
- package/dist/src/search/SearchViewMode.d.ts.map +1 -0
- package/dist/src/search/SearchViewQueryEventDetail.d.ts +12 -0
- package/dist/src/search/SearchViewQueryEventDetail.d.ts.map +1 -0
- package/dist/src/search/index.d.ts +5 -0
- package/dist/src/search/index.d.ts.map +1 -0
- package/dist/src/search/styles/SearchBarStyle.d.ts +12 -0
- package/dist/src/search/styles/SearchBarStyle.d.ts.map +1 -0
- package/dist/src/search/styles/SearchBarToken.d.ts +27 -0
- package/dist/src/search/styles/SearchBarToken.d.ts.map +1 -0
- package/dist/src/search/styles/SearchViewStyle.d.ts +12 -0
- package/dist/src/search/styles/SearchViewStyle.d.ts.map +1 -0
- package/dist/src/search/styles/SearchViewToken.d.ts +26 -0
- package/dist/src/search/styles/SearchViewToken.d.ts.map +1 -0
- package/dist/src/search/styles/index.d.ts +3 -0
- package/dist/src/search/styles/index.d.ts.map +1 -0
- package/dist/src/select/SelectElement.d.ts.map +1 -1
- package/dist/src/snackbar/SnackbarElement.d.ts.map +1 -1
- package/dist/src/stepper/StepperElement.d.ts.map +1 -1
- package/dist/stepper.js +2 -6
- package/dist/stepper.js.map +1 -1
- package/dist/stepper.min.js +1 -1
- package/dist/stepper.min.js.map +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.js.map +1 -1
- package/dist/tooltip.min.js +1 -1
- package/dist/tooltip.min.js.map +1 -1
- package/package.json +16 -1
package/dist/search.js
ADDED
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate } from 'tslib';
|
|
7
|
+
import { unsafeCSS, css, LitElement, html, nothing, svg } from 'lit';
|
|
8
|
+
import { property, state, query } from 'lit/decorators.js';
|
|
9
|
+
import { DesignToken, EventAttribute, AttachInternals, setCustomState, hasAssignedNodes, registerStyleSheet, customElement, ScrollLockController, InertController, FocusController, prefersReducedMotion, debounce } from '@m3e/web/core';
|
|
10
|
+
import '@m3e/web/icon-button';
|
|
11
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
|
+
import { positionAnchor } from '@m3e/web/core/anchoring';
|
|
13
|
+
import { M3eDirectionality } from '@m3e/web/core/bidi';
|
|
14
|
+
import { M3eBreakpointObserver, Breakpoint } from '@m3e/web/core/layout';
|
|
15
|
+
import '@m3e/web/core/a11y';
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
const SearchBarToken = {
|
|
19
|
+
containerColor: unsafeCSS(`var(--m3e-search-bar-container-color, ${DesignToken.color.surfaceContainerHigh})`),
|
|
20
|
+
leadingIconColor: unsafeCSS(`var(--m3e-search-bar-leading-icon-color, ${DesignToken.color.onSurface})`),
|
|
21
|
+
trailingIconColor: unsafeCSS(`var(--m3e-search-bar-trailing-icon-color, ${DesignToken.color.onSurfaceVariant})`),
|
|
22
|
+
containerHeight: unsafeCSS("var(--m3e-search-bar-container-height, 3.5rem)"),
|
|
23
|
+
containerShape: unsafeCSS(`var(--m3e-search-bar-container-shape, ${DesignToken.shape.corner.full})`),
|
|
24
|
+
iconSize: unsafeCSS("var(--m3e-search-bar-icon-size, 1.5rem)"),
|
|
25
|
+
supportingTextColor: unsafeCSS(`var(--m3e-search-bar-supporting-text-color, ${DesignToken.color.onSurfaceVariant})`),
|
|
26
|
+
supportingTextFontSize: unsafeCSS(`var(--m3e-search-bar-supporting-text-font-size, ${DesignToken.typescale.standard.body.large.fontSize})`),
|
|
27
|
+
supportingTextFontWeight: unsafeCSS(`var(--m3e-search-bar-supporting-text-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight})`),
|
|
28
|
+
supportingTextLineHeight: unsafeCSS(`var(--m3e-search-bar-supporting-text-line-height, ${DesignToken.typescale.standard.body.large.lineHeight})`),
|
|
29
|
+
supportingTextTracking: unsafeCSS(`var(--m3e-search-bar-supporting-text-tracking, ${DesignToken.typescale.standard.body.large.tracking})`),
|
|
30
|
+
inputColor: unsafeCSS(`var(--m3e-search-bar-input-color, ${DesignToken.color.onSurface})`),
|
|
31
|
+
inputTextFontSize: unsafeCSS(`var(--m3e-search-bar-input-text-font-size, ${DesignToken.typescale.standard.body.large.fontSize})`),
|
|
32
|
+
inputTextFontWeight: unsafeCSS(`var(--m3e-search-bar-input-text-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight})`),
|
|
33
|
+
inputTextLineHeight: unsafeCSS(`var(--m3e-search-bar-input-text-line-height, ${DesignToken.typescale.standard.body.large.lineHeight})`),
|
|
34
|
+
inputTextTracking: unsafeCSS(`var(--m3e-search-bar-input-text-tracking, ${DesignToken.typescale.standard.body.large.tracking})`),
|
|
35
|
+
leadingSpace: unsafeCSS("var(--m3e-search-bar-leading-space, 0.25rem)"),
|
|
36
|
+
trailingSpace: unsafeCSS("var(--m3e-search-bar-trailing-space, 0.25rem)"),
|
|
37
|
+
noActionsLeadingSpace: unsafeCSS("var(--m3e-search-bar-no-actions-leading-space, 1rem)"),
|
|
38
|
+
noActionsTrailingSpace: unsafeCSS("var(--m3e-search-bar-no-actions-trailing-space, 1rem)"),
|
|
39
|
+
leadingActionsTrailingSpace: unsafeCSS("var(--m3e-search-bar-leading-actions-trailing-space, 0.25rem)"),
|
|
40
|
+
trailingActionsLeadingSpace: unsafeCSS("var(--m3e-search-bar-trailing-actions-leading-space, 0.25rem)"),
|
|
41
|
+
actionsGap: unsafeCSS("var(--m3e-search-bar-actions-gap, 0px)")
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Light DOM styles for `M3eSearchBarElement`.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
const SearchBarLightDomStyle = css`m3e-search-bar input[slot="input"]::placeholder { user-select: none; color: ${SearchBarToken.supportingTextColor}; font-size: ${SearchBarToken.supportingTextFontSize}; font-weight: ${SearchBarToken.supportingTextFontWeight}; line-height: ${SearchBarToken.supportingTextLineHeight}; letter-spacing: ${SearchBarToken.supportingTextTracking}; }`;
|
|
49
|
+
/**
|
|
50
|
+
* Styles for `M3eSearchBarElement`.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
const SearchBarStyle = css`:host { display: block; height: ${SearchBarToken.containerHeight}; } .base { cursor: text; display: flex; align-items: center; box-sizing: border-box; width: 100%; height: 100%; border-radius: ${SearchBarToken.containerShape}; background-color: ${SearchBarToken.containerColor}; } .clear { display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 3rem; } :host(:not(:state(-clearable))) .clear { display: none; } :host(:state(-with-leading)) slot[name="leading"], :host(:state(-with-trailing)) slot[name="trailing"] { display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 3rem; padding-inline: 0.25rem; column-gap: calc(0.5rem + ${SearchBarToken.actionsGap}); } ::slotted([slot="input"]) { flex: 1 1 auto; outline: unset; border: unset; background-color: transparent; box-shadow: none; min-width: 0; padding: unset; color: ${SearchBarToken.inputColor}; font-size: ${SearchBarToken.inputTextFontSize}; font-weight: ${SearchBarToken.inputTextFontWeight}; line-height: ${SearchBarToken.inputTextLineHeight}; letter-spacing: ${SearchBarToken.inputTextTracking}; } :host(:state(-with-leading)) .base { padding-inline-start: ${SearchBarToken.leadingSpace}; } :host(:not(:state(-with-leading))) .base { padding-inline-start: ${SearchBarToken.noActionsLeadingSpace}; } :host(:is(:state(-with-trailing), :state(-clearable))) .base { padding-inline-end: ${SearchBarToken.trailingSpace}; } :host(:not(:is(:state(-with-trailing), :state(-clearable)))) .base { padding-inline-end: ${SearchBarToken.noActionsTrailingSpace}; } :host(:state(-with-leading)) ::slotted([slot="input"]) { margin-inline-start: ${SearchBarToken.leadingActionsTrailingSpace}; } :host(:is(:state(-with-trailing), :state(-clearable))) ::slotted([slot="input"]) { margin-inline-end: ${SearchBarToken.trailingActionsLeadingSpace}; } slot[name="leading"] { color: ${SearchBarToken.leadingIconColor}; --m3e-icon-color: ${SearchBarToken.leadingIconColor}; --m3e-icon-button-icon-color: ${SearchBarToken.leadingIconColor}; --m3e-icon-size: ${SearchBarToken.iconSize}; } slot[name="trailing"], .clear { color: ${SearchBarToken.trailingIconColor}; --m3e-icon-color: ${SearchBarToken.trailingIconColor}; --m3e-icon-button-icon-color: ${SearchBarToken.trailingIconColor}; --m3e-icon-size: ${SearchBarToken.iconSize}; } ::slotted(svg[slot="leading"]), ::slotted(svg[slot="trailing"]) { width: 1em; font-size: ${SearchBarToken.iconSize}; } ::slotted([slot="clear-icon"]), .clear-icon { width: 1em; font-size: ${SearchBarToken.iconSize} !important; } slot[name="clear-icon"] { --m3e-icon-size: ${SearchBarToken.iconSize}; } @media (forced-colors: active) { .base { border: 1px var(--_search-bar-forced-color-outline-style, solid) CanvasText; } }`;
|
|
54
|
+
|
|
55
|
+
/** @internal */
|
|
56
|
+
const SearchViewToken = {
|
|
57
|
+
containerColor: unsafeCSS(`var(--m3e-search-view-container-color, ${DesignToken.color.surfaceContainerHigh})`),
|
|
58
|
+
containedContainerColor: unsafeCSS(`var(--m3e-search-view-contained-container-color, ${DesignToken.color.surfaceContainerLow})`),
|
|
59
|
+
dividerColor: unsafeCSS(`var(--m3e-search-view-divider-color, ${DesignToken.color.outline})`),
|
|
60
|
+
dividerThickness: unsafeCSS(`var(--m3e-search-view-divider-thickness, 1px)`),
|
|
61
|
+
fullScreenContainerShape: unsafeCSS(`var(--m3e-search-view-full-screen-container-shape, ${DesignToken.shape.corner.none})`),
|
|
62
|
+
fullScreenHeaderContainerHeight: unsafeCSS("var(--m3e-search-view-full-screen-header-container-height, 4.5rem)"),
|
|
63
|
+
dockedContainerShape: unsafeCSS(`var(--m3e-search-view-docked-container-shape, ${DesignToken.shape.corner.extraLarge})`),
|
|
64
|
+
dockedHeaderContainerHeight: unsafeCSS("var(--m3e-search-view-docked-header-container-height, 3.5rem)"),
|
|
65
|
+
containedLeadingMargin: unsafeCSS("var(--m3e-search-view-contained-leading-margin, 1.5rem)"),
|
|
66
|
+
containedTrailingMargin: unsafeCSS("var(--m3e-search-view-contained-trailing-margin, 1.55rem)"),
|
|
67
|
+
containedFocusedLeadingMargin: unsafeCSS("var(--m3e-search-view-contained-focused-leading-margin, 0.75rem)"),
|
|
68
|
+
containedFocusedTrailingMargin: unsafeCSS("var(--m3e-search-view-contained-focused-trailing-margin, 0.75rem)"),
|
|
69
|
+
containedDockedBarResultsGap: unsafeCSS("var(--m3e-search-view-contained-docked-bar-results-gap, 2px)"),
|
|
70
|
+
containedDockedResultsShape: unsafeCSS(`var(--m3e-search-view-contained-docked-results-shape, ${DesignToken.shape.corner.medium})`),
|
|
71
|
+
containedDockedBarShape: unsafeCSS(`var(--m3e-search-view-contained-docked-bar-shape, ${DesignToken.shape.corner.full})`),
|
|
72
|
+
containedFullScreenBarContainerHeight: unsafeCSS("var(--m3e-search-view-contained-full-screen-bar-container-height, 3.5rem)"),
|
|
73
|
+
dockedContainerMinHeight: unsafeCSS("var(--m3e-search-view-docked-container-min-height, 240px)"),
|
|
74
|
+
dockedContainerMaxHeight: unsafeCSS("var(--m3e-search-view-docked-container-max-height, calc(100vh * 0.6667))"),
|
|
75
|
+
containedDockedResultsSpace: unsafeCSS("var(--m3e-search-view-contained-docked-results-space, 0.25rem)"),
|
|
76
|
+
dockedResultsBottomSpace: unsafeCSS("var(--m3e-search-view-docked-results-bottom-space, 1rem)"),
|
|
77
|
+
dockedScrimColor: unsafeCSS(`var(--m3e-search-view-docked-scrim-color, ${DesignToken.color.scrim})`),
|
|
78
|
+
dockedScrimOpacity: unsafeCSS("var(--m3e-search-view-docked-scrim-opacity, 32%)")
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Light DOM styles for `M3eSearchViewElement`.
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
const SearchViewLightDomStyle = css`m3e-search-view input[slot="input"]::placeholder { user-select: none; color: ${SearchBarToken.supportingTextColor}; font-size: ${SearchBarToken.supportingTextFontSize}; font-weight: ${SearchBarToken.supportingTextFontWeight}; line-height: ${SearchBarToken.supportingTextLineHeight}; letter-spacing: ${SearchBarToken.supportingTextTracking}; }`;
|
|
86
|
+
/**
|
|
87
|
+
* Styles for `M3eSearchViewElement`.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
const SearchViewStyle = css`:host { display: block; } .base { position: relative; width: 100%; } .anchor { position: absolute; width: 100%; visibility: hidden; } .view { display: flex; flex-direction: column; box-sizing: border-box; width: 100%; outline: none; padding: unset; margin: unset; border: unset; } .header { flex: none; display: flex; align-items: center; } .bar { flex: 1 1 auto; } :host(:state(-fullscreen)) .bar { transition: ${unsafeCSS(`margin ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard}`)}; } :host(:state(-fullscreen)[contained]:not([open])) .bar { margin-inline-start: ${SearchViewToken.containedLeadingMargin}; margin-inline-end: ${SearchViewToken.containedTrailingMargin}; } :host(:state(-fullscreen)[contained][open]) .bar, :host(:state(-fullscreen)[contained][open]) .results { margin-inline-start: ${SearchViewToken.containedFocusedLeadingMargin}; margin-inline-end: ${SearchViewToken.containedFocusedTrailingMargin}; } .icon { display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 3rem; } ::slotted([slot="search-icon"]), .search-icon, ::slotted([slot="close-icon"]), .close-icon { width: 1em; font-size: ${SearchBarToken.iconSize} !important; } .results { overflow: hidden; flex: 1 1 auto; display: flex; flex-direction: column; } .scroll-container { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; scrollbar-color: ${DesignToken.scrollbar.color}; } .view:not(:popover-open) .results, .view.closing .results { display: none; } :host(:not(:is(:state(-clearable), [open]))) .clear { display: none; } ::slotted([slot="clear-icon"]), .clear-icon { width: 1em; font-size: ${SearchBarToken.iconSize} !important; } slot[name="clear-icon"] { --m3e-icon-size: ${SearchBarToken.iconSize}; } :host(:state(-fullscreen)) .header { transition: height 150ms cubic-bezier(0.2, 0, 0, 1); } :host(:state(-fullscreen)) .view:popover-open:not(.closing) .header { height: ${SearchViewToken.fullScreenHeaderContainerHeight}; } :host(:state(-fullscreen):not([open])) .header, :host(:state(-fullscreen)[open]) .view.closing .header { height: ${SearchViewToken.containedFullScreenBarContainerHeight}; } :host(:state(-fullscreen)[open]) .bar { --m3e-search-bar-container-height: ${SearchViewToken.containedFullScreenBarContainerHeight}; } :host(:state(-fullscreen)) .anchor { height: ${SearchViewToken.containedFullScreenBarContainerHeight}; } :host(:state(-fullscreen)) .view:popover-open { border-radius: ${SearchViewToken.fullScreenContainerShape}; } :host(:state(-fullscreen)[contained]) .view:popover-open { background-color: ${SearchViewToken.containedContainerColor}; } :host(:state(-fullscreen):not([contained])) .view:popover-open { background-color: ${SearchViewToken.containerColor}; } :host(:state(-docked)[open]) .header, :host(:state(-docked)) .anchor { height: ${SearchViewToken.dockedHeaderContainerHeight}; } :host(:not([contained])[open]) .results { border-top-width: ${SearchViewToken.dividerThickness}; border-top-style: solid; border-top-color: ${SearchViewToken.dividerColor}; } :host(:state(-docked)[contained]) .results { margin-top: ${SearchViewToken.containedDockedBarResultsGap}; } :host(:state(-docked):not([contained])[open]) .view { background-color: ${SearchViewToken.containerColor}; --m3e-search-bar-container-color: ${SearchViewToken.containerColor}; } :host(:state(-docked)[contained]) .results { background-color: ${SearchViewToken.containerColor}; } :host(:state(-docked):not([contained])[open]) .view, :host(:state(-docked)[contained]) .results { border-radius: ${SearchViewToken.dockedContainerShape}; } :host(:state(-docked)) .results { min-height: calc(${SearchViewToken.dockedContainerMinHeight} - ${SearchViewToken.dockedHeaderContainerHeight}); max-height: calc(${SearchViewToken.dockedContainerMaxHeight} - ${SearchViewToken.dockedHeaderContainerHeight}); } :host(:state(-docked)) .scroll-container { scrollbar-width: ${DesignToken.scrollbar.thinWidth}; } :host(:state(-docked):not([contained])) .scroll-container { padding-bottom: ${SearchViewToken.dockedResultsBottomSpace}; } :host(:state(-docked)[contained]) .scroll-container { padding: ${SearchViewToken.containedDockedResultsSpace}; } :host(:state(-docked)) .results { transform-origin: top; transition: ${unsafeCSS(`transform ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard},
|
|
91
|
+
overlay ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
92
|
+
display ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host(:state(-docked):not([open])) .results { transform: scaleY(0.8); } :host(:state(-docked)[open]) .results { transform: scaleY(1); } @starting-style { :host(:state(-docked)[open]) .results { transform: scaleY(0.8); } } :host(:state(-docked)[contained]) .view { background-color: transparent; } :host(:state(-docked):not([open])) .view { transition: ${unsafeCSS(`border-radius ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard},
|
|
93
|
+
background-color ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard}`)}; } :host(:state(-docked):not([open])) .view::backdrop { transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
|
|
94
|
+
overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
95
|
+
visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host(:state(-docked)) .view::backdrop { background-color: color-mix(in srgb, ${SearchViewToken.dockedScrimColor} 0%, transparent); margin-inline-end: -20px; } :host(:state(-docked)[open]) .view::backdrop { background-color: color-mix( in srgb, ${SearchViewToken.dockedScrimColor} ${SearchViewToken.dockedScrimOpacity}, transparent ); transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard},
|
|
96
|
+
overlay ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
97
|
+
visibility ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard} allow-discrete`)}; } @starting-style { :host(:state(-docked)[open]) .view::backdrop { background-color: color-mix(in srgb, ${SearchViewToken.dockedScrimColor} 0%, transparent); } } :host(:state(-fullscreen)) .view:popover-open { width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; overflow: hidden; } @media (prefers-reduced-motion) { :host(:state(-fullscreen)) .bar, :host(:state(-fullscreen)) .header, :host(:state(-docked)) .results, :host(:state(-docked):not([open])) .view, :host(:state(-docked):not([open])) .view::backdrop, :host(:state(-docked)[open]) .view::backdrop { transition: none; } } @media (forced-colors: active) { :host(:not([contained])[open]) .bar { --_search-bar-forced-color-outline-style: none; } :host(:state(-docked):not([contained])[open]) .view, :host(:state(-docked)[contained]) .results { border: 1px solid CanvasText; } :host(:not([contained])[open]) .results { border-top-color: CanvasText; } }`;
|
|
98
|
+
|
|
99
|
+
var _M3eSearchBarElement_instances, _M3eSearchBarElement_input, _M3eSearchBarElement_inputInputHandler, _M3eSearchBarElement_renderClearButton, _M3eSearchBarElement_handleContainerClick, _M3eSearchBarElement_handleLeadingSlotChange, _M3eSearchBarElement_handleTrailingSlotChange, _M3eSearchBarElement_handleInputSlotChange, _M3eSearchBarElement_handleInputInput, _M3eSearchBarElement_handleClearClick;
|
|
100
|
+
/**
|
|
101
|
+
* A bar that provides a prominent entry point for search.
|
|
102
|
+
*
|
|
103
|
+
* @description
|
|
104
|
+
* The `m3e-search-bar` component provides a prominent entry point for search,
|
|
105
|
+
* capturing user input and emitting `query` and `clear` events as the text
|
|
106
|
+
* changes. It reflects focus and interaction states through customizable CSS
|
|
107
|
+
* properties for container, icons, and text styling.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* The following example illustrates typical usage with a leading icon and the
|
|
111
|
+
* ability to clear the current search text.
|
|
112
|
+
* ```html
|
|
113
|
+
* <m3e-search-bar clearable>
|
|
114
|
+
* <m3e-icon name="search" slot="leading"></m3e-icon>
|
|
115
|
+
* <input slot="input" placeholder="Search..." />
|
|
116
|
+
* </m3e-search-bar>
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @tag m3e-search-bar
|
|
120
|
+
*
|
|
121
|
+
* @attr clearable - Whether the bar presents a button used to clear the search term.
|
|
122
|
+
* @attr clear-label - The accessible label given to the button used to clear the search term.
|
|
123
|
+
*
|
|
124
|
+
* @slot leading - Renders content before the input of the bar.
|
|
125
|
+
* @slot input - Renders the input of the bar.
|
|
126
|
+
* @slot trailing - Renders content after the input of the bar.
|
|
127
|
+
*
|
|
128
|
+
* @fires clear - Dispatched when the search term is cleared.
|
|
129
|
+
*
|
|
130
|
+
* @cssprop --m3e-search-bar-container-color - Background color of the search bar container.
|
|
131
|
+
* @cssprop --m3e-search-bar-leading-icon-color - Color of the leading icon.
|
|
132
|
+
* @cssprop --m3e-search-bar-trailing-icon-color - Color of the trailing icon.
|
|
133
|
+
* @cssprop --m3e-search-bar-container-height - Height of the search bar container.
|
|
134
|
+
* @cssprop --m3e-search-bar-container-shape - Shape (border radius) of the search bar container.
|
|
135
|
+
* @cssprop --m3e-search-bar-icon-size - Size of icons inside the search bar.
|
|
136
|
+
* @cssprop --m3e-search-bar-supporting-text-color - Color of the supporting text.
|
|
137
|
+
* @cssprop --m3e-search-bar-supporting-text-font-size - Font size of the supporting text.
|
|
138
|
+
* @cssprop --m3e-search-bar-supporting-text-font-weight - Font weight of the supporting text.
|
|
139
|
+
* @cssprop --m3e-search-bar-supporting-text-line-height - Line height of the supporting text.
|
|
140
|
+
* @cssprop --m3e-search-bar-supporting-text-tracking - Letter spacing of the supporting text.
|
|
141
|
+
* @cssprop --m3e-search-bar-input-color - Color of the input text.
|
|
142
|
+
* @cssprop --m3e-search-bar-input-text-font-size - Font size of the input text.
|
|
143
|
+
* @cssprop --m3e-search-bar-input-text-font-weight - Font weight of the input text.
|
|
144
|
+
* @cssprop --m3e-search-bar-input-text-line-height - Line height of the input text.
|
|
145
|
+
* @cssprop --m3e-search-bar-input-text-tracking - Letter spacing of the input text.
|
|
146
|
+
* @cssprop --m3e-search-bar-leading-space - Space before the leading icon.
|
|
147
|
+
* @cssprop --m3e-search-bar-trailing-space - Space after the trailing icon.
|
|
148
|
+
* @cssprop --m3e-search-bar-no-actions-leading-space - Leading padding when no actions are present.
|
|
149
|
+
* @cssprop --m3e-search-bar-no-actions-trailing-space - Trailing padding when no actions are present.
|
|
150
|
+
* @cssprop --m3e-search-bar-leading-actions-trailing-space - Space between leading actions and the input.
|
|
151
|
+
* @cssprop --m3e-search-bar-trailing-actions-leading-space - Space between the input and trailing actions.
|
|
152
|
+
* @cssprop --m3e-search-bar-actions-gap - Gap between action icons.
|
|
153
|
+
*/
|
|
154
|
+
let M3eSearchBarElement = class M3eSearchBarElement extends EventAttribute(AttachInternals(LitElement), "clear") {
|
|
155
|
+
constructor() {
|
|
156
|
+
super(...arguments);
|
|
157
|
+
_M3eSearchBarElement_instances.add(this);
|
|
158
|
+
/** @private */
|
|
159
|
+
_M3eSearchBarElement_input.set(this, void 0);
|
|
160
|
+
/** @private */
|
|
161
|
+
_M3eSearchBarElement_inputInputHandler.set(this, () => __classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleInputInput).call(this));
|
|
162
|
+
/**
|
|
163
|
+
* Whether the bar presents a button used to clear the search term.
|
|
164
|
+
* @default false
|
|
165
|
+
*/
|
|
166
|
+
this.clearable = false;
|
|
167
|
+
/**
|
|
168
|
+
* The accessible label given to the button used to clear the search term.
|
|
169
|
+
* @default "Clear"
|
|
170
|
+
*/
|
|
171
|
+
this.clearLabel = "Clear";
|
|
172
|
+
}
|
|
173
|
+
/** Clears the search term. */
|
|
174
|
+
clear() {
|
|
175
|
+
if (!__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")) return;
|
|
176
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f").value = "";
|
|
177
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleInputInput).call(this);
|
|
178
|
+
this.dispatchEvent(new Event("clear", {
|
|
179
|
+
bubbles: true,
|
|
180
|
+
composed: true
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
/** @inheritdoc */
|
|
184
|
+
render() {
|
|
185
|
+
return html`<div class="base" @click="${__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleContainerClick)}"><slot name="leading" @slotchange="${__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleLeadingSlotChange)}"></slot><slot name="input" @slotchange="${__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleInputSlotChange)}"></slot>${__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_renderClearButton).call(this)}<slot name="trailing" @slotchange="${__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleTrailingSlotChange)}"></slot></div>`;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
_M3eSearchBarElement_input = new WeakMap();
|
|
189
|
+
_M3eSearchBarElement_inputInputHandler = new WeakMap();
|
|
190
|
+
_M3eSearchBarElement_instances = new WeakSet();
|
|
191
|
+
_M3eSearchBarElement_renderClearButton = function _M3eSearchBarElement_renderClearButton() {
|
|
192
|
+
return this.clearable ? html`<div class="clear"><m3e-icon-button aria-label="${this.clearLabel}" @click="${__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleClearClick)}"><slot name="clear-icon"><svg class="clear-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></slot></m3e-icon-button></div>` : nothing;
|
|
193
|
+
};
|
|
194
|
+
_M3eSearchBarElement_handleContainerClick = function _M3eSearchBarElement_handleContainerClick() {
|
|
195
|
+
if (!this.matches(":focus-within")) {
|
|
196
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")?.focus();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
_M3eSearchBarElement_handleLeadingSlotChange = function _M3eSearchBarElement_handleLeadingSlotChange(e) {
|
|
200
|
+
setCustomState(this, "-with-leading", hasAssignedNodes(e.target));
|
|
201
|
+
};
|
|
202
|
+
_M3eSearchBarElement_handleTrailingSlotChange = function _M3eSearchBarElement_handleTrailingSlotChange(e) {
|
|
203
|
+
setCustomState(this, "-with-trailing", hasAssignedNodes(e.target));
|
|
204
|
+
};
|
|
205
|
+
_M3eSearchBarElement_handleInputSlotChange = function _M3eSearchBarElement_handleInputSlotChange(e) {
|
|
206
|
+
const input = e.target.assignedElements({
|
|
207
|
+
flatten: true
|
|
208
|
+
}).find(x => x instanceof HTMLInputElement);
|
|
209
|
+
if (input != __classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")) {
|
|
210
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")?.removeEventListener("input", __classPrivateFieldGet(this, _M3eSearchBarElement_inputInputHandler, "f"));
|
|
211
|
+
__classPrivateFieldSet(this, _M3eSearchBarElement_input, input, "f");
|
|
212
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")?.addEventListener("input", __classPrivateFieldGet(this, _M3eSearchBarElement_inputInputHandler, "f"));
|
|
213
|
+
if (__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")) {
|
|
214
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f").role = __classPrivateFieldGet(this, _M3eSearchBarElement_input, "f").role || "searchbox";
|
|
215
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f").inputMode = __classPrivateFieldGet(this, _M3eSearchBarElement_input, "f").inputMode || "search";
|
|
216
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f").type = "text";
|
|
217
|
+
}
|
|
218
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_instances, "m", _M3eSearchBarElement_handleInputInput).call(this);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
_M3eSearchBarElement_handleInputInput = function _M3eSearchBarElement_handleInputInput() {
|
|
222
|
+
setCustomState(this, "-clearable", this.clearable && (__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")?.value ?? "").length > 0);
|
|
223
|
+
};
|
|
224
|
+
_M3eSearchBarElement_handleClearClick = function _M3eSearchBarElement_handleClearClick() {
|
|
225
|
+
this.clear();
|
|
226
|
+
__classPrivateFieldGet(this, _M3eSearchBarElement_input, "f")?.focus();
|
|
227
|
+
};
|
|
228
|
+
(() => {
|
|
229
|
+
registerStyleSheet(SearchBarLightDomStyle);
|
|
230
|
+
})();
|
|
231
|
+
/** The styles of the element. */
|
|
232
|
+
M3eSearchBarElement.styles = SearchBarStyle;
|
|
233
|
+
__decorate([property({
|
|
234
|
+
type: Boolean,
|
|
235
|
+
reflect: true
|
|
236
|
+
})], M3eSearchBarElement.prototype, "clearable", void 0);
|
|
237
|
+
__decorate([property({
|
|
238
|
+
attribute: "clear-label"
|
|
239
|
+
})], M3eSearchBarElement.prototype, "clearLabel", void 0);
|
|
240
|
+
M3eSearchBarElement = __decorate([customElement("m3e-search-bar")], M3eSearchBarElement);
|
|
241
|
+
|
|
242
|
+
var _M3eSearchViewElement_instances, _M3eSearchViewElement_input, _M3eSearchViewElement_closeOnInputFocus, _M3eSearchViewElement_inputInputHandler, _M3eSearchViewElement_inputFocusHandler, _M3eSearchViewElement_inputKeyDownHandler, _M3eSearchViewElement_inputPointerHandler, _M3eSearchViewElement_scrollLockController, _M3eSearchViewElement_inertController, _M3eSearchViewElement_openMode, _M3eSearchViewElement_anchorCleanup, _M3eSearchViewElement_breakpointUnobserve, _M3eSearchViewElement_renderIconOrBackButton, _M3eSearchViewElement_renderIcon, _M3eSearchViewElement_renderBackButton, _M3eSearchViewElement_renderClearButton, _M3eSearchViewElement_handleInputSlotChange, _M3eSearchViewElement_handleInputInput, _M3eSearchViewElement_updateMode, _M3eSearchViewElement_updateClearableState, _M3eSearchViewElement_handleInputFocus, _M3eSearchViewElement_handleCloseClick, _M3eSearchViewElement_handleClearClick, _M3eSearchViewElement_handleInputPointerDown, _M3eSearchViewElement_handleInputKeyDown, _M3eSearchViewElement_handleKeyDown, _M3eSearchViewElement_openDocked, _M3eSearchViewElement_closeDocked, _M3eSearchViewElement_hideDocked, _M3eSearchViewElement_openFullscreen, _M3eSearchViewElement_closeFullscreen;
|
|
243
|
+
/**
|
|
244
|
+
* A surface that presents suggestions and results for a search.
|
|
245
|
+
*
|
|
246
|
+
* @description
|
|
247
|
+
* The `m3e-search-view` component presents the surface for suggestions,
|
|
248
|
+
* history, and results, managing the open and close lifecycle around an
|
|
249
|
+
* embedded search bar. It emits `query`, `clear`, and `toggle`, events to
|
|
250
|
+
* support application driven search logic, and exposes CSS properties for
|
|
251
|
+
* container, shape, spacing, and layout across contained, docked, and full
|
|
252
|
+
* screen configurations.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* The following example shows a contained view in docked mode with a simple set of search results.
|
|
256
|
+
* ```html
|
|
257
|
+
* <m3e-search-view mode="docked" contained>
|
|
258
|
+
* <input slot="input" placeholder="Search..." />
|
|
259
|
+
* <m3e-list>
|
|
260
|
+
* <m3e-list-item>Result One</m3e-list-item>
|
|
261
|
+
* <m3e-list-item>Result Two</m3e-list-item>
|
|
262
|
+
* <m3e-list-item>Result Three</m3e-list-item>
|
|
263
|
+
* </m3e-list>
|
|
264
|
+
* </m3e-search-view>
|
|
265
|
+
* ```
|
|
266
|
+
*
|
|
267
|
+
* @tag m3e-search-view
|
|
268
|
+
*
|
|
269
|
+
* @attr contained - Whether the view features a persistent, filled search container.
|
|
270
|
+
* @attr mode - The behavior mode of the view.
|
|
271
|
+
* @attr open - Whether the view is expanded to show results.
|
|
272
|
+
* @attr clear-label - The accessible label given to the button used to clear the search term.
|
|
273
|
+
* @attr close-label - The accessible label given to the button used to collapse the view.
|
|
274
|
+
* @attr hide-search-icon - Whether to hide the search icon.
|
|
275
|
+
*
|
|
276
|
+
* @slot - When open, renders the results content of the view.
|
|
277
|
+
* @slot input - Renders the input of the view.
|
|
278
|
+
* @slot open-leading - When open, renders content before the input of the view.
|
|
279
|
+
* @slot open-trailing - When open, renders content after the input of the view.
|
|
280
|
+
* @slot closed-leading - When closed, renders content before the input of the view.
|
|
281
|
+
* @slot closed-trailing - When closed, renders content after the input of the view.
|
|
282
|
+
*
|
|
283
|
+
* @fires clear - Dispatched when the search term is cleared.
|
|
284
|
+
* @fires query - Dispatched when the view is opened or when the user modifies the search term.
|
|
285
|
+
* @fires beforetoggle - Dispatched before the toggle state changes.
|
|
286
|
+
* @fires toggle - Dispatched after the toggle state has changed.
|
|
287
|
+
*
|
|
288
|
+
* @cssprop --m3e-search-view-container-color - Background color of the view container.
|
|
289
|
+
* @cssprop --m3e-search-view-contained-container-color - Background color of the contained view container.
|
|
290
|
+
* @cssprop --m3e-search-view-divider-color - Color of the divider separating header and results.
|
|
291
|
+
* @cssprop --m3e-search-view-divider-thickness - Thickness of the divider separating header and results.
|
|
292
|
+
* @cssprop --m3e-search-view-full-screen-container-shape - Shape of the fullscreen view container.
|
|
293
|
+
* @cssprop --m3e-search-view-full-screen-header-container-height - Height of the header container in fullscreen mode.
|
|
294
|
+
* @cssprop --m3e-search-view-docked-container-shape - Shape of the docked view container.
|
|
295
|
+
* @cssprop --m3e-search-view-docked-header-container-height - Height of the header container in docked mode.
|
|
296
|
+
* @cssprop --m3e-search-view-contained-leading-margin - Leading margin for the contained view.
|
|
297
|
+
* @cssprop --m3e-search-view-contained-trailing-margin - Trailing margin for the contained view.
|
|
298
|
+
* @cssprop --m3e-search-view-contained-focused-leading-margin - Leading margin when the contained view is focused.
|
|
299
|
+
* @cssprop --m3e-search-view-contained-focused-trailing-margin - Trailing margin when the contained view is focused.
|
|
300
|
+
* @cssprop --m3e-search-view-contained-docked-bar-results-gap - Gap between the contained docked bar and results.
|
|
301
|
+
* @cssprop --m3e-search-view-contained-docked-results-shape - Shape of the results container in contained docked mode.
|
|
302
|
+
* @cssprop --m3e-search-view-contained-docked-bar-shape - Shape of the bar in contained docked mode.
|
|
303
|
+
* @cssprop --m3e-search-view-contained-full-screen-bar-container-height - Height of the bar container in contained fullscreen mode.
|
|
304
|
+
* @cssprop --m3e-search-view-docked-container-min-height - Minimum height of the docked view container.
|
|
305
|
+
* @cssprop --m3e-search-view-docked-container-max-height - Maximum height of the docked view container.
|
|
306
|
+
* @cssprop --m3e-search-view-contained-docked-results-space - Space above the results in contained docked mode.
|
|
307
|
+
* @cssprop --m3e-search-view-docked-results-bottom-space - Space below the results in docked mode.
|
|
308
|
+
* @cssprop --m3e-search-view-docked-scrim-color - Color of the scrim behind the docked view.
|
|
309
|
+
* @cssprop --m3e-search-view-docked-scrim-opacity - Opacity of the scrim behind the docked view.
|
|
310
|
+
*/
|
|
311
|
+
let M3eSearchViewElement = class M3eSearchViewElement extends EventAttribute(AttachInternals(LitElement), "clear", "query") {
|
|
312
|
+
constructor() {
|
|
313
|
+
super();
|
|
314
|
+
_M3eSearchViewElement_instances.add(this);
|
|
315
|
+
/** @private */
|
|
316
|
+
_M3eSearchViewElement_input.set(this, void 0);
|
|
317
|
+
/** @private */
|
|
318
|
+
_M3eSearchViewElement_closeOnInputFocus.set(this, false);
|
|
319
|
+
/** @private */
|
|
320
|
+
_M3eSearchViewElement_inputInputHandler.set(this, () => __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleInputInput).call(this));
|
|
321
|
+
/** @private */
|
|
322
|
+
_M3eSearchViewElement_inputFocusHandler.set(this, () => __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleInputFocus).call(this));
|
|
323
|
+
/** @private */
|
|
324
|
+
_M3eSearchViewElement_inputKeyDownHandler.set(this, e => __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleInputKeyDown).call(this, e));
|
|
325
|
+
/** @private */
|
|
326
|
+
_M3eSearchViewElement_inputPointerHandler.set(this, () => __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleInputPointerDown).call(this));
|
|
327
|
+
/** @private */
|
|
328
|
+
_M3eSearchViewElement_scrollLockController.set(this, new ScrollLockController(this));
|
|
329
|
+
/** @private */
|
|
330
|
+
_M3eSearchViewElement_inertController.set(this, new InertController(this));
|
|
331
|
+
/** @private */
|
|
332
|
+
this._clearable = false;
|
|
333
|
+
/** @private */
|
|
334
|
+
_M3eSearchViewElement_openMode.set(this, void 0);
|
|
335
|
+
/** @private */
|
|
336
|
+
_M3eSearchViewElement_anchorCleanup.set(this, void 0);
|
|
337
|
+
/** @private */
|
|
338
|
+
_M3eSearchViewElement_breakpointUnobserve.set(this, void 0);
|
|
339
|
+
/**
|
|
340
|
+
* Whether the view features a persistent, filled search container.
|
|
341
|
+
* @default false
|
|
342
|
+
*/
|
|
343
|
+
this.contained = false;
|
|
344
|
+
/**
|
|
345
|
+
* The behavior mode of the view.
|
|
346
|
+
* @default "docked"
|
|
347
|
+
*/
|
|
348
|
+
this.mode = "docked";
|
|
349
|
+
/**
|
|
350
|
+
* Whether the view is expanded to show results.
|
|
351
|
+
* @default false
|
|
352
|
+
*/
|
|
353
|
+
this.open = false;
|
|
354
|
+
/**
|
|
355
|
+
* The accessible label given to the button used to clear the search term.
|
|
356
|
+
* @default "Clear"
|
|
357
|
+
*/
|
|
358
|
+
this.clearLabel = "Clear";
|
|
359
|
+
/**
|
|
360
|
+
* The accessible label given to the button used to collapse the view.
|
|
361
|
+
* @default "Close"
|
|
362
|
+
*/
|
|
363
|
+
this.closeLabel = "Close";
|
|
364
|
+
/**
|
|
365
|
+
* Whether to hide the search icon.
|
|
366
|
+
* @default false;
|
|
367
|
+
*/
|
|
368
|
+
this.hideSearchIcon = false;
|
|
369
|
+
new FocusController(this, {
|
|
370
|
+
callback: focused => this._handleFocusChange(focused)
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/** The current mode applied to the view. */
|
|
374
|
+
get currentMode() {
|
|
375
|
+
return this._mode ?? (this.mode !== "fullscreen" ? "docked" : "fullscreen");
|
|
376
|
+
}
|
|
377
|
+
set currentMode(value) {
|
|
378
|
+
this._mode = value;
|
|
379
|
+
}
|
|
380
|
+
/** Clears the search term. */
|
|
381
|
+
clear() {
|
|
382
|
+
if (!__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")) return;
|
|
383
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").value = "";
|
|
384
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_updateClearableState).call(this);
|
|
385
|
+
this.dispatchEvent(new CustomEvent("query", {
|
|
386
|
+
detail: {
|
|
387
|
+
term: ""
|
|
388
|
+
},
|
|
389
|
+
bubbles: true,
|
|
390
|
+
composed: true
|
|
391
|
+
}));
|
|
392
|
+
this.dispatchEvent(new Event("clear", {
|
|
393
|
+
bubbles: true,
|
|
394
|
+
composed: true
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
/** @inheritdoc */
|
|
398
|
+
willUpdate(changedProperties) {
|
|
399
|
+
super.willUpdate(changedProperties);
|
|
400
|
+
if (changedProperties.has("mode")) {
|
|
401
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_breakpointUnobserve, "f")?.call(this);
|
|
402
|
+
const previousMode = changedProperties.get("mode");
|
|
403
|
+
if (previousMode && previousMode !== this.mode && this.open) {
|
|
404
|
+
this.open = false;
|
|
405
|
+
}
|
|
406
|
+
if (this.mode === "auto") {
|
|
407
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_breakpointUnobserve, M3eBreakpointObserver.observe([Breakpoint.XSmall], matches => {
|
|
408
|
+
const currentMode = this.currentMode;
|
|
409
|
+
this._mode = matches.get(Breakpoint.XSmall) ? "fullscreen" : "docked";
|
|
410
|
+
if (currentMode !== this._mode && this.open) {
|
|
411
|
+
this.open = false;
|
|
412
|
+
}
|
|
413
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_updateMode).call(this);
|
|
414
|
+
}), "f");
|
|
415
|
+
} else {
|
|
416
|
+
this._mode = undefined;
|
|
417
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_updateMode).call(this);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (changedProperties.has("_mode")) {
|
|
421
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_updateMode).call(this);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
/** @inheritdoc */
|
|
425
|
+
updated(_changedProperties) {
|
|
426
|
+
super.updated(_changedProperties);
|
|
427
|
+
if (_changedProperties.has("open")) {
|
|
428
|
+
if (!this.open) {
|
|
429
|
+
if ((__classPrivateFieldGet(this, _M3eSearchViewElement_openMode, "f") ?? this.currentMode) === "fullscreen") {
|
|
430
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_closeFullscreen).call(this);
|
|
431
|
+
} else {
|
|
432
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_closeDocked).call(this);
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
if (this.currentMode === "fullscreen") {
|
|
436
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_openFullscreen).call(this);
|
|
437
|
+
} else {
|
|
438
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_openDocked).call(this);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** @inheritdoc */
|
|
444
|
+
render() {
|
|
445
|
+
return html`<div class="base"><div class="anchor"></div><div role="${ifDefined(this.open ? "dialog" : undefined)}" aria-modal="${ifDefined(this.open ? "true" : undefined)}" aria-labelledby="${ifDefined(this.open ? "header" : undefined)}" class="view" tabindex="-1" @keydown="${__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleKeyDown)}"><m3e-focus-trap ?disabled="${!this.open}"><div class="header" id="header"><m3e-search-bar class="bar">${__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_renderIconOrBackButton).call(this)} ${this.open ? html`<slot name="open-leading" slot="leading"></slot>` : html`<slot name="closed-leading" slot="leading"></slot>`}<slot name="input" slot="input" @slotchange="${__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleInputSlotChange)}"></slot>${__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_renderClearButton).call(this)} ${this.open ? html`<slot name="open-trailing" slot="trailing"></slot>` : html`<slot name="closed-trailing" slot="trailing"></slot>`}</m3e-search-bar></div><div class="results"><div class="scroll-container"><slot></slot></div></div></m3e-focus-trap></div></div>`;
|
|
446
|
+
}
|
|
447
|
+
/** @private */
|
|
448
|
+
_handleFocusChange(focused) {
|
|
449
|
+
if (!focused && this.currentMode === "docked") {
|
|
450
|
+
this.clear();
|
|
451
|
+
this.open = false;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
_M3eSearchViewElement_input = new WeakMap();
|
|
456
|
+
_M3eSearchViewElement_closeOnInputFocus = new WeakMap();
|
|
457
|
+
_M3eSearchViewElement_inputInputHandler = new WeakMap();
|
|
458
|
+
_M3eSearchViewElement_inputFocusHandler = new WeakMap();
|
|
459
|
+
_M3eSearchViewElement_inputKeyDownHandler = new WeakMap();
|
|
460
|
+
_M3eSearchViewElement_inputPointerHandler = new WeakMap();
|
|
461
|
+
_M3eSearchViewElement_scrollLockController = new WeakMap();
|
|
462
|
+
_M3eSearchViewElement_inertController = new WeakMap();
|
|
463
|
+
_M3eSearchViewElement_openMode = new WeakMap();
|
|
464
|
+
_M3eSearchViewElement_anchorCleanup = new WeakMap();
|
|
465
|
+
_M3eSearchViewElement_breakpointUnobserve = new WeakMap();
|
|
466
|
+
_M3eSearchViewElement_instances = new WeakSet();
|
|
467
|
+
_M3eSearchViewElement_renderIconOrBackButton = function _M3eSearchViewElement_renderIconOrBackButton() {
|
|
468
|
+
if (!this.open && this.hideSearchIcon) return nothing;
|
|
469
|
+
return html`<div class="icon" slot="leading">${this.open ? __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_renderBackButton).call(this) : __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_renderIcon).call(this)}</div>`;
|
|
470
|
+
};
|
|
471
|
+
_M3eSearchViewElement_renderIcon = function _M3eSearchViewElement_renderIcon() {
|
|
472
|
+
return html`<slot name="search-icon"><svg class="search-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg></slot>`;
|
|
473
|
+
};
|
|
474
|
+
_M3eSearchViewElement_renderBackButton = function _M3eSearchViewElement_renderBackButton() {
|
|
475
|
+
return html`<m3e-icon-button class="close" slot="leading" aria-label="${this.closeLabel}" @click="${__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleCloseClick)}"><slot name="close-icon"><svg class="close-icon" viewBox="0 -960 960 960" fill="currentColor">${this.currentMode === "docked" ? svg`<path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"/>` : svg`<path d="M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"/>`}</svg></slot></m3e-icon-button>`;
|
|
476
|
+
};
|
|
477
|
+
_M3eSearchViewElement_renderClearButton = function _M3eSearchViewElement_renderClearButton() {
|
|
478
|
+
return html`<m3e-icon-button class="clear" slot="trailing" aria-label="${this.open && !this._clearable ? this.closeLabel : this.clearLabel}" @click="${__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleClearClick)}"><slot name="clear-icon"><svg class="clear-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></slot></m3e-icon-button>`;
|
|
479
|
+
};
|
|
480
|
+
_M3eSearchViewElement_handleInputSlotChange = function _M3eSearchViewElement_handleInputSlotChange(e) {
|
|
481
|
+
const input = e.target.assignedElements({
|
|
482
|
+
flatten: true
|
|
483
|
+
}).find(x => x instanceof HTMLInputElement);
|
|
484
|
+
if (input != __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")) {
|
|
485
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.removeEventListener("input", __classPrivateFieldGet(this, _M3eSearchViewElement_inputInputHandler, "f"));
|
|
486
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.removeEventListener("focus", __classPrivateFieldGet(this, _M3eSearchViewElement_inputFocusHandler, "f"));
|
|
487
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eSearchViewElement_inputKeyDownHandler, "f"));
|
|
488
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.removeEventListener("pointerdown", __classPrivateFieldGet(this, _M3eSearchViewElement_inputPointerHandler, "f"));
|
|
489
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_input, input, "f");
|
|
490
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.addEventListener("input", __classPrivateFieldGet(this, _M3eSearchViewElement_inputInputHandler, "f"));
|
|
491
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.addEventListener("focus", __classPrivateFieldGet(this, _M3eSearchViewElement_inputFocusHandler, "f"));
|
|
492
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.addEventListener("keydown", __classPrivateFieldGet(this, _M3eSearchViewElement_inputKeyDownHandler, "f"));
|
|
493
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.addEventListener("pointerdown", __classPrivateFieldGet(this, _M3eSearchViewElement_inputPointerHandler, "f"));
|
|
494
|
+
if (__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")) {
|
|
495
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").role = __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").role || "searchbox";
|
|
496
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").inputMode = __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").inputMode || "search";
|
|
497
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").type = "text";
|
|
498
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").ariaHasPopup = "dialog";
|
|
499
|
+
}
|
|
500
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_updateClearableState).call(this);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
_M3eSearchViewElement_handleInputInput = function _M3eSearchViewElement_handleInputInput() {
|
|
504
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_updateClearableState).call(this);
|
|
505
|
+
if (this.open) {
|
|
506
|
+
this.dispatchEvent(new CustomEvent("query", {
|
|
507
|
+
detail: {
|
|
508
|
+
term: __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.value ?? ""
|
|
509
|
+
},
|
|
510
|
+
bubbles: true,
|
|
511
|
+
composed: true
|
|
512
|
+
}));
|
|
513
|
+
} else {
|
|
514
|
+
this.open = true;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
_M3eSearchViewElement_updateMode = function _M3eSearchViewElement_updateMode() {
|
|
518
|
+
setCustomState(this, "-fullscreen", this.currentMode === "fullscreen");
|
|
519
|
+
setCustomState(this, "-docked", this.currentMode === "docked");
|
|
520
|
+
};
|
|
521
|
+
_M3eSearchViewElement_updateClearableState = function _M3eSearchViewElement_updateClearableState() {
|
|
522
|
+
this._clearable = (__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.value ?? "").length > 0;
|
|
523
|
+
setCustomState(this, "-clearable", this._clearable);
|
|
524
|
+
};
|
|
525
|
+
_M3eSearchViewElement_handleInputFocus = function _M3eSearchViewElement_handleInputFocus() {
|
|
526
|
+
this.open = !__classPrivateFieldGet(this, _M3eSearchViewElement_closeOnInputFocus, "f");
|
|
527
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_closeOnInputFocus, false, "f");
|
|
528
|
+
};
|
|
529
|
+
_M3eSearchViewElement_handleCloseClick = function _M3eSearchViewElement_handleCloseClick() {
|
|
530
|
+
if (!__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")) return;
|
|
531
|
+
if (__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").value) {
|
|
532
|
+
this.clear();
|
|
533
|
+
}
|
|
534
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_closeOnInputFocus, true, "f");
|
|
535
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.focus();
|
|
536
|
+
};
|
|
537
|
+
_M3eSearchViewElement_handleClearClick = function _M3eSearchViewElement_handleClearClick() {
|
|
538
|
+
if (!__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")) return;
|
|
539
|
+
if (__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f").value) {
|
|
540
|
+
this.clear();
|
|
541
|
+
} else {
|
|
542
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_closeOnInputFocus, true, "f");
|
|
543
|
+
}
|
|
544
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.focus();
|
|
545
|
+
};
|
|
546
|
+
_M3eSearchViewElement_handleInputPointerDown = function _M3eSearchViewElement_handleInputPointerDown() {
|
|
547
|
+
if (!this.open && __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.matches(":focus")) {
|
|
548
|
+
this.open = true;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
_M3eSearchViewElement_handleInputKeyDown = function _M3eSearchViewElement_handleInputKeyDown(e) {
|
|
552
|
+
if (this.open && e.key === "Escape" && !e.shiftKey && !e.ctrlKey) {
|
|
553
|
+
e.preventDefault();
|
|
554
|
+
const input = e.target;
|
|
555
|
+
if (input.value) {
|
|
556
|
+
this.clear();
|
|
557
|
+
}
|
|
558
|
+
this.open = false;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
_M3eSearchViewElement_handleKeyDown = function _M3eSearchViewElement_handleKeyDown(e) {
|
|
562
|
+
if (this.open && e.key === "Escape" && !e.shiftKey && !e.ctrlKey) {
|
|
563
|
+
e.preventDefault();
|
|
564
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_handleCloseClick).call(this);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
_M3eSearchViewElement_openDocked = /** @private */
|
|
568
|
+
async function _M3eSearchViewElement_openDocked() {
|
|
569
|
+
if (!this.dispatchEvent(new ToggleEvent("beforetoggle", {
|
|
570
|
+
oldState: "closed",
|
|
571
|
+
newState: "open",
|
|
572
|
+
bubbles: true,
|
|
573
|
+
composed: true,
|
|
574
|
+
cancelable: true
|
|
575
|
+
}))) {
|
|
576
|
+
this.open = false;
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_openMode, this.currentMode, "f");
|
|
580
|
+
const view = this._view;
|
|
581
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_anchorCleanup, "f")?.call(this);
|
|
582
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_anchorCleanup, await positionAnchor(view, this._anchor, {
|
|
583
|
+
position: "bottom"
|
|
584
|
+
}, (x, y) => {
|
|
585
|
+
const view = this._view;
|
|
586
|
+
view.style.top = `${y - this._anchor.clientHeight}px`;
|
|
587
|
+
view.style.width = `${this._anchor.clientWidth}px`;
|
|
588
|
+
if (M3eDirectionality.current === "rtl") {
|
|
589
|
+
view.style.right = `${window.innerWidth - x - this.clientWidth}px`;
|
|
590
|
+
view.style.left = "";
|
|
591
|
+
} else {
|
|
592
|
+
view.style.left = `${x}px`;
|
|
593
|
+
view.style.right = "";
|
|
594
|
+
}
|
|
595
|
+
}), "f");
|
|
596
|
+
this._anchor.style.position = "relative";
|
|
597
|
+
view.popover = "manual";
|
|
598
|
+
view.style.position = "absolute";
|
|
599
|
+
view.showPopover();
|
|
600
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_scrollLockController, "f").lock();
|
|
601
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_inertController, "f").lock();
|
|
602
|
+
this.dispatchEvent(new ToggleEvent("toggle", {
|
|
603
|
+
oldState: "closed",
|
|
604
|
+
newState: "open",
|
|
605
|
+
bubbles: true,
|
|
606
|
+
composed: true
|
|
607
|
+
}));
|
|
608
|
+
this.dispatchEvent(new CustomEvent("query", {
|
|
609
|
+
detail: {
|
|
610
|
+
term: __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.value ?? ""
|
|
611
|
+
},
|
|
612
|
+
bubbles: true,
|
|
613
|
+
composed: true
|
|
614
|
+
}));
|
|
615
|
+
};
|
|
616
|
+
_M3eSearchViewElement_closeDocked = function _M3eSearchViewElement_closeDocked() {
|
|
617
|
+
const view = this._view;
|
|
618
|
+
if (view.popover !== "manual") return;
|
|
619
|
+
if (!this.dispatchEvent(new ToggleEvent("beforetoggle", {
|
|
620
|
+
oldState: "open",
|
|
621
|
+
newState: "closed",
|
|
622
|
+
bubbles: true,
|
|
623
|
+
composed: true,
|
|
624
|
+
cancelable: true
|
|
625
|
+
}))) {
|
|
626
|
+
this.open = true;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_openMode, undefined, "f");
|
|
630
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_scrollLockController, "f").unlock();
|
|
631
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_inertController, "f").unlock();
|
|
632
|
+
if (prefersReducedMotion()) {
|
|
633
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_hideDocked).call(this);
|
|
634
|
+
} else {
|
|
635
|
+
view.classList.add("closing");
|
|
636
|
+
view.addEventListener("transitionend", () => __classPrivateFieldGet(this, _M3eSearchViewElement_instances, "m", _M3eSearchViewElement_hideDocked).call(this), {
|
|
637
|
+
once: true
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
_M3eSearchViewElement_hideDocked = function _M3eSearchViewElement_hideDocked() {
|
|
642
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_anchorCleanup, "f")?.call(this);
|
|
643
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_anchorCleanup, undefined, "f");
|
|
644
|
+
const view = this._view;
|
|
645
|
+
view.classList.remove("closing");
|
|
646
|
+
view.style.position = "";
|
|
647
|
+
view.style.width = "";
|
|
648
|
+
view.style.top = "";
|
|
649
|
+
view.style.left = "";
|
|
650
|
+
view.style.right = "";
|
|
651
|
+
view.hidePopover();
|
|
652
|
+
view.popover = null;
|
|
653
|
+
this._anchor.style.position = "";
|
|
654
|
+
this.dispatchEvent(new ToggleEvent("toggle", {
|
|
655
|
+
oldState: "open",
|
|
656
|
+
newState: "closed",
|
|
657
|
+
bubbles: true,
|
|
658
|
+
composed: true
|
|
659
|
+
}));
|
|
660
|
+
};
|
|
661
|
+
_M3eSearchViewElement_openFullscreen = /** @private */
|
|
662
|
+
async function _M3eSearchViewElement_openFullscreen() {
|
|
663
|
+
if (!this.dispatchEvent(new ToggleEvent("beforetoggle", {
|
|
664
|
+
oldState: "closed",
|
|
665
|
+
newState: "open",
|
|
666
|
+
bubbles: true,
|
|
667
|
+
composed: true,
|
|
668
|
+
cancelable: true
|
|
669
|
+
}))) {
|
|
670
|
+
this.open = false;
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_openMode, this.currentMode, "f");
|
|
674
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_scrollLockController, "f").lock();
|
|
675
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_inertController, "f").lock();
|
|
676
|
+
const view = this._view;
|
|
677
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_anchorCleanup, "f")?.call(this);
|
|
678
|
+
if (!prefersReducedMotion()) {
|
|
679
|
+
const rect = view.getBoundingClientRect();
|
|
680
|
+
const startInline = M3eDirectionality.current === "rtl" ? window.innerWidth - rect.right : rect.left;
|
|
681
|
+
view.style.position = "fixed";
|
|
682
|
+
view.popover = "manual";
|
|
683
|
+
view.showPopover();
|
|
684
|
+
this._anchor.style.position = "relative";
|
|
685
|
+
view.animate([{
|
|
686
|
+
transform: `translateX(${startInline}px)`,
|
|
687
|
+
width: `${rect.width}px`,
|
|
688
|
+
top: `${rect.top}px`,
|
|
689
|
+
height: `${rect.height}px`
|
|
690
|
+
}, {
|
|
691
|
+
transform: "translateX(0px)",
|
|
692
|
+
width: "100vw",
|
|
693
|
+
top: "0px",
|
|
694
|
+
height: "100vh"
|
|
695
|
+
}], {
|
|
696
|
+
duration: 150,
|
|
697
|
+
easing: "cubic-bezier(0.2, 0.0, 0, 1.0)"
|
|
698
|
+
});
|
|
699
|
+
} else {
|
|
700
|
+
view.style.position = "fixed";
|
|
701
|
+
view.popover = "manual";
|
|
702
|
+
view.showPopover();
|
|
703
|
+
this._anchor.style.position = "relative";
|
|
704
|
+
}
|
|
705
|
+
this.dispatchEvent(new ToggleEvent("toggle", {
|
|
706
|
+
oldState: "closed",
|
|
707
|
+
newState: "open",
|
|
708
|
+
bubbles: true,
|
|
709
|
+
composed: true
|
|
710
|
+
}));
|
|
711
|
+
this.dispatchEvent(new CustomEvent("query", {
|
|
712
|
+
detail: {
|
|
713
|
+
term: __classPrivateFieldGet(this, _M3eSearchViewElement_input, "f")?.value ?? ""
|
|
714
|
+
},
|
|
715
|
+
bubbles: true,
|
|
716
|
+
composed: true
|
|
717
|
+
}));
|
|
718
|
+
};
|
|
719
|
+
_M3eSearchViewElement_closeFullscreen = /** @private */
|
|
720
|
+
async function _M3eSearchViewElement_closeFullscreen() {
|
|
721
|
+
const view = this._view;
|
|
722
|
+
if (view.popover !== "manual") return;
|
|
723
|
+
if (!this.dispatchEvent(new ToggleEvent("beforetoggle", {
|
|
724
|
+
oldState: "open",
|
|
725
|
+
newState: "closed",
|
|
726
|
+
bubbles: true,
|
|
727
|
+
composed: true,
|
|
728
|
+
cancelable: true
|
|
729
|
+
}))) {
|
|
730
|
+
this.open = true;
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
__classPrivateFieldSet(this, _M3eSearchViewElement_openMode, undefined, "f");
|
|
734
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_scrollLockController, "f").unlock();
|
|
735
|
+
__classPrivateFieldGet(this, _M3eSearchViewElement_inertController, "f").unlock();
|
|
736
|
+
const anchor = this._anchor;
|
|
737
|
+
if (!prefersReducedMotion()) {
|
|
738
|
+
const start = view.getBoundingClientRect();
|
|
739
|
+
const end = anchor.getBoundingClientRect();
|
|
740
|
+
const startInline = M3eDirectionality.current === "rtl" ? window.innerWidth - start.right : start.left;
|
|
741
|
+
const endInline = M3eDirectionality.current === "rtl" ? window.innerWidth - end.right : end.left;
|
|
742
|
+
const dx = M3eDirectionality.current === "rtl" ? startInline - endInline : endInline - startInline;
|
|
743
|
+
view.classList.add("closing");
|
|
744
|
+
await view.animate([{
|
|
745
|
+
transform: `translateX(0px)`,
|
|
746
|
+
width: `${start.width}px`,
|
|
747
|
+
top: `${start.top}px`,
|
|
748
|
+
height: `${start.height}px`
|
|
749
|
+
}, {
|
|
750
|
+
transform: `translateX(${dx}px)`,
|
|
751
|
+
width: `${end.width}px`,
|
|
752
|
+
top: `${end.top}px`,
|
|
753
|
+
height: `${end.height}px`
|
|
754
|
+
}], {
|
|
755
|
+
duration: 150,
|
|
756
|
+
easing: "cubic-bezier(0.2, 0.0, 0, 1.0)"
|
|
757
|
+
}).finished;
|
|
758
|
+
}
|
|
759
|
+
view.hidePopover();
|
|
760
|
+
view.style.position = "";
|
|
761
|
+
view.popover = null;
|
|
762
|
+
view.classList.remove("closing");
|
|
763
|
+
anchor.style.position = "";
|
|
764
|
+
this.dispatchEvent(new ToggleEvent("toggle", {
|
|
765
|
+
oldState: "open",
|
|
766
|
+
newState: "closed",
|
|
767
|
+
bubbles: true,
|
|
768
|
+
composed: true
|
|
769
|
+
}));
|
|
770
|
+
};
|
|
771
|
+
(() => {
|
|
772
|
+
registerStyleSheet(SearchViewLightDomStyle);
|
|
773
|
+
})();
|
|
774
|
+
/** The styles of the element. */
|
|
775
|
+
M3eSearchViewElement.styles = SearchViewStyle;
|
|
776
|
+
__decorate([state()], M3eSearchViewElement.prototype, "_clearable", void 0);
|
|
777
|
+
__decorate([state()], M3eSearchViewElement.prototype, "_mode", void 0);
|
|
778
|
+
__decorate([query(".anchor")], M3eSearchViewElement.prototype, "_anchor", void 0);
|
|
779
|
+
__decorate([query(".view")], M3eSearchViewElement.prototype, "_view", void 0);
|
|
780
|
+
__decorate([property({
|
|
781
|
+
type: Boolean,
|
|
782
|
+
reflect: true
|
|
783
|
+
})], M3eSearchViewElement.prototype, "contained", void 0);
|
|
784
|
+
__decorate([property({
|
|
785
|
+
reflect: true
|
|
786
|
+
})], M3eSearchViewElement.prototype, "mode", void 0);
|
|
787
|
+
__decorate([property({
|
|
788
|
+
type: Boolean,
|
|
789
|
+
reflect: true
|
|
790
|
+
})], M3eSearchViewElement.prototype, "open", void 0);
|
|
791
|
+
__decorate([property({
|
|
792
|
+
attribute: "clear-label"
|
|
793
|
+
})], M3eSearchViewElement.prototype, "clearLabel", void 0);
|
|
794
|
+
__decorate([property({
|
|
795
|
+
attribute: "close-label"
|
|
796
|
+
})], M3eSearchViewElement.prototype, "closeLabel", void 0);
|
|
797
|
+
__decorate([property({
|
|
798
|
+
attribute: "hide-search-icon",
|
|
799
|
+
type: Boolean
|
|
800
|
+
})], M3eSearchViewElement.prototype, "hideSearchIcon", void 0);
|
|
801
|
+
__decorate([debounce(40)], M3eSearchViewElement.prototype, "_handleFocusChange", null);
|
|
802
|
+
M3eSearchViewElement = __decorate([customElement("m3e-search-view")], M3eSearchViewElement);
|
|
803
|
+
|
|
804
|
+
export { M3eSearchBarElement, M3eSearchViewElement };
|
|
805
|
+
//# sourceMappingURL=search.js.map
|