@m3e/core 1.0.0-rc.1 → 1.0.0-rc.3
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 +1 -2
- package/dist/a11y.js +6 -18
- package/dist/a11y.js.map +1 -1
- package/dist/a11y.min.js +5 -5
- package/dist/a11y.min.js.map +1 -1
- package/dist/css-custom-data.json +20 -0
- package/dist/custom-elements.json +3605 -3375
- package/dist/html-custom-data.json +36 -6
- package/dist/index.js +417 -33
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +95 -84
- package/dist/index.min.js.map +1 -1
- package/dist/src/a11y/FocusTrapElement.d.ts +1 -1
- package/dist/src/a11y/FocusTrapElement.d.ts.map +1 -1
- package/dist/src/shared/controllers/PressedController.d.ts +2 -0
- package/dist/src/shared/controllers/PressedController.d.ts.map +1 -1
- package/dist/src/shared/mixins/AttachInternals.d.ts.map +1 -1
- package/dist/src/shared/mixins/Checked.d.ts.map +1 -1
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts.map +1 -1
- package/dist/src/shared/mixins/ConstraintValidation.d.ts.map +1 -1
- package/dist/src/shared/mixins/Dirty.d.ts.map +1 -1
- package/dist/src/shared/mixins/Disabled.d.ts.map +1 -1
- package/dist/src/shared/mixins/DisabledInteractive.d.ts.map +1 -1
- package/dist/src/shared/mixins/EventAttribute.d.ts.map +1 -1
- package/dist/src/shared/mixins/Focusable.d.ts.map +1 -1
- package/dist/src/shared/mixins/FormAssociated.d.ts.map +1 -1
- package/dist/src/shared/mixins/FormSubmitter.d.ts +4 -1
- package/dist/src/shared/mixins/FormSubmitter.d.ts.map +1 -1
- package/dist/src/shared/mixins/HtmlFor.d.ts.map +1 -1
- package/dist/src/shared/mixins/KeyboardClick.d.ts.map +1 -1
- package/dist/src/shared/mixins/Labelled.d.ts.map +1 -1
- package/dist/src/shared/mixins/LinkButton.d.ts +13 -3
- package/dist/src/shared/mixins/LinkButton.d.ts.map +1 -1
- package/dist/src/shared/mixins/ReadOnly.d.ts.map +1 -1
- package/dist/src/shared/mixins/Required.d.ts.map +1 -1
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts.map +1 -1
- package/dist/src/shared/mixins/Role.d.ts.map +1 -1
- package/dist/src/shared/mixins/Selected.d.ts.map +1 -1
- package/dist/src/shared/mixins/Touched.d.ts.map +1 -1
- package/dist/src/shared/mixins/Vertical.d.ts.map +1 -1
- package/dist/src/shared/primitives/CollapsibleElement.d.ts +1 -1
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/ElevationElement.d.ts +0 -1
- package/dist/src/shared/primitives/ElevationElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/FocusRingElement.d.ts +0 -1
- package/dist/src/shared/primitives/FocusRingElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts +0 -1
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts +0 -1
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/RippleElement.d.ts +0 -1
- package/dist/src/shared/primitives/RippleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts +1 -4
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/SlideElement.d.ts +1 -3
- package/dist/src/shared/primitives/SlideElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/StateLayerElement.d.ts +0 -1
- package/dist/src/shared/primitives/StateLayerElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/TextHighlightElement.d.ts +81 -0
- package/dist/src/shared/primitives/TextHighlightElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/TextOverflowElement.d.ts +0 -1
- package/dist/src/shared/primitives/TextOverflowElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/index.d.ts +1 -0
- package/dist/src/shared/primitives/index.d.ts.map +1 -1
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts +2 -2
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts.map +1 -1
- package/package.json +1 -1
- package/cem.config.mjs +0 -16
- package/demo/index.html +0 -58
- package/eslint.config.mjs +0 -21
- package/rollup.config.js +0 -132
- package/src/a11y/AriaDescriber.ts +0 -130
- package/src/a11y/FocusTrapElement.ts +0 -136
- package/src/a11y/InteractivityChecker.ts +0 -62
- package/src/a11y/LiveAnnouncer.ts +0 -143
- package/src/a11y/aria-reference.ts +0 -51
- package/src/a11y/index.ts +0 -8
- package/src/a11y/keycodes/KeyCode.ts +0 -128
- package/src/a11y/keycodes/ModifierKeys.ts +0 -5
- package/src/a11y/keycodes/getKeyCode.ts +0 -8
- package/src/a11y/keycodes/hasModifierKey.ts +0 -11
- package/src/a11y/keycodes/index.ts +0 -5
- package/src/a11y/keycodes/isModifierAllowed.ts +0 -12
- package/src/a11y/list-key/FocusKeyManager.ts +0 -25
- package/src/a11y/list-key/ListKeyManager.ts +0 -350
- package/src/a11y/list-key/ListManager.ts +0 -66
- package/src/a11y/list-key/RadioKeyManager.ts +0 -49
- package/src/a11y/list-key/RovingTabIndexManager.ts +0 -56
- package/src/a11y/list-key/SelectionManager.ts +0 -132
- package/src/a11y/list-key/Typeahead.ts +0 -131
- package/src/a11y/list-key/index.ts +0 -7
- package/src/a11y/visuallyHide.ts +0 -18
- package/src/anchoring/AnchorOptions.ts +0 -19
- package/src/anchoring/AnchorPosition.ts +0 -14
- package/src/anchoring/index.ts +0 -3
- package/src/anchoring/positionAnchor.ts +0 -53
- package/src/bidi/Directionality.ts +0 -85
- package/src/bidi/index.ts +0 -1
- package/src/index.ts +0 -1
- package/src/layout/Breakpoint.ts +0 -26
- package/src/layout/BreakpointObserver.ts +0 -44
- package/src/layout/index.ts +0 -2
- package/src/platform/Platform.ts +0 -67
- package/src/platform/index.ts +0 -1
- package/src/shared/controllers/FocusController.ts +0 -60
- package/src/shared/controllers/HoverController.ts +0 -140
- package/src/shared/controllers/IntersectionController.ts +0 -81
- package/src/shared/controllers/LongPressController.ts +0 -87
- package/src/shared/controllers/MonitorControllerBase.ts +0 -99
- package/src/shared/controllers/MutationController.ts +0 -89
- package/src/shared/controllers/PressedController.ts +0 -137
- package/src/shared/controllers/ResizeController.ts +0 -83
- package/src/shared/controllers/ScrollController.ts +0 -100
- package/src/shared/controllers/index.ts +0 -8
- package/src/shared/decorators/debounce.ts +0 -19
- package/src/shared/decorators/index.ts +0 -1
- package/src/shared/directives/index.ts +0 -1
- package/src/shared/directives/safeStyleMap.ts +0 -108
- package/src/shared/index.ts +0 -7
- package/src/shared/mixins/AttachInternals.ts +0 -48
- package/src/shared/mixins/Checked.ts +0 -50
- package/src/shared/mixins/CheckedIndeterminate.ts +0 -47
- package/src/shared/mixins/CheckedOrSelected.ts +0 -36
- package/src/shared/mixins/ConstraintValidation.ts +0 -213
- package/src/shared/mixins/Constructor.ts +0 -2
- package/src/shared/mixins/Dirty.ts +0 -71
- package/src/shared/mixins/Disabled.ts +0 -49
- package/src/shared/mixins/DisabledInteractive.ts +0 -78
- package/src/shared/mixins/EventAttribute.ts +0 -25
- package/src/shared/mixins/Focusable.ts +0 -52
- package/src/shared/mixins/FormAssociated.ts +0 -152
- package/src/shared/mixins/FormSubmitter.ts +0 -123
- package/src/shared/mixins/HtmlFor.ts +0 -89
- package/src/shared/mixins/KeyboardClick.ts +0 -46
- package/src/shared/mixins/Labelled.ts +0 -88
- package/src/shared/mixins/LinkButton.ts +0 -169
- package/src/shared/mixins/ReadOnly.ts +0 -48
- package/src/shared/mixins/Required.ts +0 -50
- package/src/shared/mixins/RequiredConstraintValidation.ts +0 -45
- package/src/shared/mixins/Role.ts +0 -134
- package/src/shared/mixins/Selected.ts +0 -50
- package/src/shared/mixins/Touched.ts +0 -71
- package/src/shared/mixins/Vertical.ts +0 -44
- package/src/shared/mixins/hasKeys.ts +0 -10
- package/src/shared/mixins/index.ts +0 -24
- package/src/shared/primitives/CollapsibleElement.ts +0 -227
- package/src/shared/primitives/ElevationElement.ts +0 -254
- package/src/shared/primitives/ElevationLevel.ts +0 -2
- package/src/shared/primitives/ElevationToken.ts +0 -18
- package/src/shared/primitives/FocusRingElement.ts +0 -199
- package/src/shared/primitives/FocusRingToken.ts +0 -24
- package/src/shared/primitives/PseudoCheckboxElement.ts +0 -116
- package/src/shared/primitives/PseudoRadioElement.ts +0 -83
- package/src/shared/primitives/RippleElement.ts +0 -289
- package/src/shared/primitives/RippleToken.ts +0 -15
- package/src/shared/primitives/ScrollContainerElement.ts +0 -151
- package/src/shared/primitives/ScrollDividers.ts +0 -2
- package/src/shared/primitives/SlideElement.ts +0 -128
- package/src/shared/primitives/StateLayerElement.ts +0 -191
- package/src/shared/primitives/StateLayerToken.ts +0 -16
- package/src/shared/primitives/TextOverflowElement.ts +0 -60
- package/src/shared/primitives/index.ts +0 -12
- package/src/shared/tokens/ColorToken.ts +0 -142
- package/src/shared/tokens/DensityToken.ts +0 -23
- package/src/shared/tokens/DesignToken.ts +0 -35
- package/src/shared/tokens/ElevationToken.ts +0 -115
- package/src/shared/tokens/MotionToken.ts +0 -107
- package/src/shared/tokens/ScrollbarToken.ts +0 -13
- package/src/shared/tokens/ShapeToken.ts +0 -138
- package/src/shared/tokens/StateToken.ts +0 -13
- package/src/shared/tokens/TypescaleToken.ts +0 -230
- package/src/shared/tokens/index.ts +0 -1
- package/src/shared/utils/getTextContent.ts +0 -31
- package/src/shared/utils/guid.ts +0 -11
- package/src/shared/utils/hasAssignedNodes.ts +0 -8
- package/src/shared/utils/index.ts +0 -5
- package/src/shared/utils/prefersReducedMotion.ts +0 -9
- package/src/shared/utils/scrollIntoViewIfNeeded.ts +0 -18
- package/tsconfig.json +0 -9
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
|
|
3
|
-
import { Constructor } from "./Constructor";
|
|
4
|
-
|
|
5
|
-
/** Specifies valid values for the ARIA `role` attribute. */
|
|
6
|
-
export type ARIARole =
|
|
7
|
-
| "alert"
|
|
8
|
-
| "alertdialog"
|
|
9
|
-
| "button"
|
|
10
|
-
| "checkbox"
|
|
11
|
-
| "dialog"
|
|
12
|
-
| "gridcell"
|
|
13
|
-
| "link"
|
|
14
|
-
| "log"
|
|
15
|
-
| "marquee"
|
|
16
|
-
| "menuitem"
|
|
17
|
-
| "menuitemcheckbox"
|
|
18
|
-
| "menuitemradio"
|
|
19
|
-
| "option"
|
|
20
|
-
| "progressbar"
|
|
21
|
-
| "radio"
|
|
22
|
-
| "scrollbar"
|
|
23
|
-
| "searchbox"
|
|
24
|
-
| "slider"
|
|
25
|
-
| "spinbutton"
|
|
26
|
-
| "status"
|
|
27
|
-
| "switch"
|
|
28
|
-
| "tab"
|
|
29
|
-
| "tabpanel"
|
|
30
|
-
| "textbox"
|
|
31
|
-
| "timer"
|
|
32
|
-
| "tooltip"
|
|
33
|
-
| "treeitem"
|
|
34
|
-
| "combobox"
|
|
35
|
-
| "grid"
|
|
36
|
-
| "listbox"
|
|
37
|
-
| "menu"
|
|
38
|
-
| "menubar"
|
|
39
|
-
| "radiogroup"
|
|
40
|
-
| "tablist"
|
|
41
|
-
| "tree"
|
|
42
|
-
| "treegrid"
|
|
43
|
-
| "application"
|
|
44
|
-
| "article"
|
|
45
|
-
| "cell"
|
|
46
|
-
| "columnheader"
|
|
47
|
-
| "definition"
|
|
48
|
-
| "directory"
|
|
49
|
-
| "document"
|
|
50
|
-
| "feed"
|
|
51
|
-
| "figure"
|
|
52
|
-
| "group"
|
|
53
|
-
| "heading"
|
|
54
|
-
| "img"
|
|
55
|
-
| "list"
|
|
56
|
-
| "listitem"
|
|
57
|
-
| "math"
|
|
58
|
-
| "none"
|
|
59
|
-
| "note"
|
|
60
|
-
| "presentation"
|
|
61
|
-
| "region"
|
|
62
|
-
| "row"
|
|
63
|
-
| "rowgroup"
|
|
64
|
-
| "rowheader"
|
|
65
|
-
| "separator"
|
|
66
|
-
| "table"
|
|
67
|
-
| "term"
|
|
68
|
-
| "text"
|
|
69
|
-
| "toolbar"
|
|
70
|
-
| "banner"
|
|
71
|
-
| "complementary"
|
|
72
|
-
| "contentinfo"
|
|
73
|
-
| "form"
|
|
74
|
-
| "main"
|
|
75
|
-
| "navigation"
|
|
76
|
-
| "region"
|
|
77
|
-
| "search"
|
|
78
|
-
| "doc-abstract"
|
|
79
|
-
| "doc-acknowledgments"
|
|
80
|
-
| "doc-afterword"
|
|
81
|
-
| "doc-appendix"
|
|
82
|
-
| "doc-backlink"
|
|
83
|
-
| "doc-biblioentry"
|
|
84
|
-
| "doc-bibliography"
|
|
85
|
-
| "doc-biblioref"
|
|
86
|
-
| "doc-chapter"
|
|
87
|
-
| "doc-colophon"
|
|
88
|
-
| "doc-conclusion"
|
|
89
|
-
| "doc-cover"
|
|
90
|
-
| "doc-credit"
|
|
91
|
-
| "doc-credits"
|
|
92
|
-
| "doc-dedication"
|
|
93
|
-
| "doc-endnote"
|
|
94
|
-
| "doc-endnotes"
|
|
95
|
-
| "doc-epigraph"
|
|
96
|
-
| "doc-epilogue"
|
|
97
|
-
| "doc-errata"
|
|
98
|
-
| "doc-example"
|
|
99
|
-
| "doc-footnote"
|
|
100
|
-
| "doc-foreword"
|
|
101
|
-
| "doc-glossary"
|
|
102
|
-
| "doc-glossref"
|
|
103
|
-
| "doc-index"
|
|
104
|
-
| "doc-introduction"
|
|
105
|
-
| "doc-noteref"
|
|
106
|
-
| "doc-notice"
|
|
107
|
-
| "doc-pagebreak"
|
|
108
|
-
| "doc-pagelist"
|
|
109
|
-
| "doc-part"
|
|
110
|
-
| "doc-preface"
|
|
111
|
-
| "doc-prologue"
|
|
112
|
-
| "doc-pullquote"
|
|
113
|
-
| "doc-qna"
|
|
114
|
-
| "doc-subtitle"
|
|
115
|
-
| "doc-tip"
|
|
116
|
-
| "doc-toc";
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Mixin to augment an element with an ARIA role.
|
|
120
|
-
* @template T The type of the base class.
|
|
121
|
-
* @param {T} base The base class.
|
|
122
|
-
* @param {ARIARole} role The ARIA role.
|
|
123
|
-
* @returns {Constructor & T} A constructor that implements focusable behavior.
|
|
124
|
-
*/
|
|
125
|
-
export function Role<T extends Constructor<LitElement>>(base: T, role: ARIARole): Constructor & T {
|
|
126
|
-
abstract class _RoleMixin extends base {
|
|
127
|
-
override connectedCallback(): void {
|
|
128
|
-
this.role = this.role || role;
|
|
129
|
-
super.connectedCallback();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return _RoleMixin;
|
|
134
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from "lit";
|
|
2
|
-
import { property } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
import { Constructor } from "./Constructor";
|
|
5
|
-
import { hasKeys } from "./hasKeys";
|
|
6
|
-
|
|
7
|
-
/** Defines functionality for an element which supports a selected state. */
|
|
8
|
-
export interface SelectedMixin {
|
|
9
|
-
/**
|
|
10
|
-
* Whether the element is selected.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
selected: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Determines whether a value is a `SelectedMixin`.
|
|
18
|
-
* @param {unknown} value The value to test.
|
|
19
|
-
* @returns Whether `value` is a `SelectedMixin`.
|
|
20
|
-
*/
|
|
21
|
-
export function isSelectedMixin(value: unknown): value is SelectedMixin {
|
|
22
|
-
return hasKeys<SelectedMixin>(value, "selected");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Mixin to augment an element with behavior that supports a selected state.
|
|
27
|
-
* @template T The type of the base class.
|
|
28
|
-
* @param {T} base The base class.
|
|
29
|
-
* @returns {Constructor<SelectedMixin> & T} A constructor that implements `SelectedMixin`.
|
|
30
|
-
*/
|
|
31
|
-
export function Selected<T extends Constructor<LitElement>>(base: T): Constructor<SelectedMixin> & T {
|
|
32
|
-
abstract class _SelectedMixin extends base implements SelectedMixin {
|
|
33
|
-
@property({ type: Boolean, reflect: true }) selected = false;
|
|
34
|
-
|
|
35
|
-
protected override update(changedProperties: PropertyValues<this>): void {
|
|
36
|
-
super.update(changedProperties);
|
|
37
|
-
|
|
38
|
-
if (changedProperties.has("selected")) {
|
|
39
|
-
if (this.role === "button") {
|
|
40
|
-
this.ariaPressed = `${this.selected}`;
|
|
41
|
-
this.ariaSelected = null;
|
|
42
|
-
} else if (this.role && this.role !== "none" && this.role !== "presentation") {
|
|
43
|
-
this.ariaSelected = `${this.selected}`;
|
|
44
|
-
this.ariaPressed = null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return _SelectedMixin;
|
|
50
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
|
|
3
|
-
import { Constructor } from "./Constructor";
|
|
4
|
-
import { hasKeys } from "./hasKeys";
|
|
5
|
-
|
|
6
|
-
/** Defines functionality for an element that can be marked as touched. */
|
|
7
|
-
export interface TouchedMixin {
|
|
8
|
-
/** Whether the user has interacted when the element. */
|
|
9
|
-
readonly touched: boolean;
|
|
10
|
-
|
|
11
|
-
/** Whether the user has not interacted when the element. */
|
|
12
|
-
readonly untouched: boolean;
|
|
13
|
-
|
|
14
|
-
/** Marks the element as touched. */
|
|
15
|
-
markAsTouched(): void;
|
|
16
|
-
|
|
17
|
-
/** Marks the element as untouched. */
|
|
18
|
-
markAsUntouched(): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Determines whether a value is a `TouchedMixin`.
|
|
23
|
-
* @param {unknown} value The value to test.
|
|
24
|
-
* @returns A value indicating whether `value` is a `TouchedMixin`.
|
|
25
|
-
*/
|
|
26
|
-
export function isTouchedMixin(value: unknown): value is TouchedMixin {
|
|
27
|
-
return hasKeys<TouchedMixin>(value, "touched", "untouched", "markAsTouched", "markAsUntouched");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const _eventHandler = Symbol("_eventHandler");
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Mixin to augment an element with functionality used to mark it as touched.
|
|
34
|
-
* @template T The type of the base class.
|
|
35
|
-
* @param {T} base The base class.
|
|
36
|
-
* @returns {Constructor<TouchedMixin> & T} A constructor that implements `TouchedMixin`.
|
|
37
|
-
*/
|
|
38
|
-
export function Touched<T extends Constructor<LitElement>>(base: T): Constructor<TouchedMixin> & T {
|
|
39
|
-
abstract class _Touched extends base implements TouchedMixin {
|
|
40
|
-
private [_eventHandler] = () => this.markAsTouched();
|
|
41
|
-
|
|
42
|
-
get touched(): boolean {
|
|
43
|
-
return this.classList.contains("-touched");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get untouched(): boolean {
|
|
47
|
-
return !this.touched;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
override connectedCallback(): void {
|
|
51
|
-
this.markAsUntouched();
|
|
52
|
-
super.connectedCallback();
|
|
53
|
-
this.addEventListener("focusout", this[_eventHandler]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
override disconnectedCallback(): void {
|
|
57
|
-
super.disconnectedCallback();
|
|
58
|
-
this.removeEventListener("focusout", this[_eventHandler]);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
markAsTouched(): void {
|
|
62
|
-
this.classList.toggle("-touched", true);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
markAsUntouched(): void {
|
|
66
|
-
this.classList.toggle("-touched", false);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return _Touched;
|
|
71
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from "lit";
|
|
2
|
-
import { property } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
import { Constructor } from "./Constructor";
|
|
5
|
-
import { hasKeys } from "./hasKeys";
|
|
6
|
-
|
|
7
|
-
/** Defines functionality for an element which supports a vertical orientation. */
|
|
8
|
-
export interface VerticalMixin {
|
|
9
|
-
/**
|
|
10
|
-
* Whether the element is oriented vertically.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
vertical: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Determines whether a value is a `VerticalMixin`.
|
|
18
|
-
* @param {unknown} value The value to test.
|
|
19
|
-
* @returns A value indicating whether `value` is a `VerticalMixin`.
|
|
20
|
-
*/
|
|
21
|
-
export function isVerticalMixin(value: unknown): value is VerticalMixin {
|
|
22
|
-
return hasKeys<VerticalMixin>(value, "vertical");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Mixin to augment an element with behavior that supports a vertical orientation.
|
|
27
|
-
* @template T The type of the base class.
|
|
28
|
-
* @param {T} base The base class.
|
|
29
|
-
* @returns {Constructor<VerticalMixin> & T} A constructor that implements `VerticalMixin`.
|
|
30
|
-
*/
|
|
31
|
-
export function Vertical<T extends Constructor<LitElement>>(base: T): Constructor<VerticalMixin> & T {
|
|
32
|
-
abstract class _VerticalMixin extends base implements VerticalMixin {
|
|
33
|
-
@property({ type: Boolean, reflect: true }) vertical = false;
|
|
34
|
-
|
|
35
|
-
protected override update(changedProperties: PropertyValues<this>): void {
|
|
36
|
-
super.update(changedProperties);
|
|
37
|
-
|
|
38
|
-
if (changedProperties.has("vertical")) {
|
|
39
|
-
this.ariaOrientation = this.vertical ? "vertical" : "horizontal";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return _VerticalMixin;
|
|
44
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines whether an object has keys for a given type.
|
|
3
|
-
* @template T The type to test.
|
|
4
|
-
* @param {unknown} value The value to test.
|
|
5
|
-
* @param {...keys: Array<keyof T>} keys The keys of `T` to test.
|
|
6
|
-
* @returns {boolean} Whether `value` has all `keys`.
|
|
7
|
-
*/
|
|
8
|
-
export function hasKeys<T extends object>(value: unknown, ...keys: Array<keyof T>): boolean {
|
|
9
|
-
return typeof value === "object" && value !== null && keys.every((x) => x in value);
|
|
10
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export * from "./AttachInternals";
|
|
2
|
-
export * from "./Checked";
|
|
3
|
-
export * from "./CheckedIndeterminate";
|
|
4
|
-
export * from "./CheckedOrSelected";
|
|
5
|
-
export * from "./ConstraintValidation";
|
|
6
|
-
export * from "./Dirty";
|
|
7
|
-
export * from "./Disabled";
|
|
8
|
-
export * from "./DisabledInteractive";
|
|
9
|
-
export * from "./EventAttribute";
|
|
10
|
-
export * from "./Focusable";
|
|
11
|
-
export * from "./FormAssociated";
|
|
12
|
-
export * from "./FormSubmitter";
|
|
13
|
-
export * from "./hasKeys";
|
|
14
|
-
export * from "./HtmlFor";
|
|
15
|
-
export * from "./KeyboardClick";
|
|
16
|
-
export * from "./Labelled";
|
|
17
|
-
export * from "./LinkButton";
|
|
18
|
-
export * from "./ReadOnly";
|
|
19
|
-
export * from "./Required";
|
|
20
|
-
export * from "./RequiredConstraintValidation";
|
|
21
|
-
export * from "./Role";
|
|
22
|
-
export * from "./Selected";
|
|
23
|
-
export * from "./Touched";
|
|
24
|
-
export * from "./Vertical";
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
2
|
-
|
|
3
|
-
import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from "lit";
|
|
4
|
-
import { customElement, property } from "lit/decorators.js";
|
|
5
|
-
|
|
6
|
-
import { EventAttribute, Role } from "../mixins";
|
|
7
|
-
import { DesignToken } from "../tokens";
|
|
8
|
-
import { prefersReducedMotion } from "../utils";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A container used to expand and collapse content.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```html
|
|
15
|
-
* <m3e-collapsible>
|
|
16
|
-
* <!-- Collapsible content -->
|
|
17
|
-
* </m3e-collapsible>
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @tag m3e-collapsible
|
|
21
|
-
*
|
|
22
|
-
* @slot - Renders the collapsible content.
|
|
23
|
-
*
|
|
24
|
-
* @attr open - Whether content is visible.
|
|
25
|
-
*
|
|
26
|
-
* @fires opening - Emitted when the collapsible begins to open.
|
|
27
|
-
* @fires opened - Emitted when the collapsible has opened.
|
|
28
|
-
* @fires closing - Emitted when the collapsible begins to close.
|
|
29
|
-
* @fires closed - Emitted when the collapsible has closed.
|
|
30
|
-
*
|
|
31
|
-
* @cssprop --m3e-collapsible-animation-duration - The duration of the expand / collapse animation.
|
|
32
|
-
*/
|
|
33
|
-
@customElement("m3e-collapsible")
|
|
34
|
-
export class M3eCollapsibleElement extends EventAttribute(
|
|
35
|
-
Role(LitElement, "none"),
|
|
36
|
-
"opening",
|
|
37
|
-
"opened",
|
|
38
|
-
"closing",
|
|
39
|
-
"closed"
|
|
40
|
-
) {
|
|
41
|
-
/** The styles of the element. */
|
|
42
|
-
static override styles: CSSResultGroup = css`
|
|
43
|
-
:host {
|
|
44
|
-
display: block;
|
|
45
|
-
height: 0px;
|
|
46
|
-
overflow: hidden;
|
|
47
|
-
transition: ${unsafeCSS(`visibility var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
48
|
-
${DesignToken.motion.easing.standard},
|
|
49
|
-
height var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
50
|
-
${DesignToken.motion.easing.standard},
|
|
51
|
-
padding-top var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
52
|
-
${DesignToken.motion.easing.standard},
|
|
53
|
-
padding-bottom var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
54
|
-
${DesignToken.motion.easing.standard}`)};
|
|
55
|
-
}
|
|
56
|
-
:host(:not(.-closing):not([open])) {
|
|
57
|
-
visibility: hidden;
|
|
58
|
-
}
|
|
59
|
-
:host([open]) {
|
|
60
|
-
visibility: visible;
|
|
61
|
-
}
|
|
62
|
-
:host(:not([open])) {
|
|
63
|
-
min-height: unset !important;
|
|
64
|
-
padding-top: 0px !important;
|
|
65
|
-
padding-bottom: 0px !important;
|
|
66
|
-
}
|
|
67
|
-
:host(.-no-animate) {
|
|
68
|
-
transition-duration: 0ms;
|
|
69
|
-
}
|
|
70
|
-
::slotted(*) {
|
|
71
|
-
--m3e-collapsible-animation-duration: initial;
|
|
72
|
-
}
|
|
73
|
-
@media (prefers-reduced-motion) {
|
|
74
|
-
:host {
|
|
75
|
-
transition: none;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
/** @private */ #slotChanged = false;
|
|
81
|
-
/** @private */ #hasOpened = false;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Whether content is visible.
|
|
85
|
-
* @default false
|
|
86
|
-
*/
|
|
87
|
-
@property({ type: Boolean, reflect: true }) open = false;
|
|
88
|
-
|
|
89
|
-
/** @inheritdoc */
|
|
90
|
-
protected override update(changedProperties: PropertyValues): void {
|
|
91
|
-
super.update(changedProperties);
|
|
92
|
-
|
|
93
|
-
this.classList.toggle("-no-animate", true);
|
|
94
|
-
|
|
95
|
-
if (!this.#slotChanged) {
|
|
96
|
-
if (this.open) {
|
|
97
|
-
this.#hasOpened = true;
|
|
98
|
-
this.#autoSize();
|
|
99
|
-
}
|
|
100
|
-
this.#slotChanged = true;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
this.toggleAttribute("inert", !this.open);
|
|
105
|
-
|
|
106
|
-
if (this.open) {
|
|
107
|
-
this.#hasOpened = true;
|
|
108
|
-
this.classList.toggle("-closing", false);
|
|
109
|
-
this.classList.toggle("-opening", true);
|
|
110
|
-
this.dispatchEvent(new Event("opening"));
|
|
111
|
-
|
|
112
|
-
this.#clearSize();
|
|
113
|
-
this.classList.toggle("-no-animate", false);
|
|
114
|
-
this.#actualSize();
|
|
115
|
-
|
|
116
|
-
if (prefersReducedMotion()) {
|
|
117
|
-
this.classList.toggle("-opening", false);
|
|
118
|
-
this.dispatchEvent(new Event("opened"));
|
|
119
|
-
} else {
|
|
120
|
-
this.addEventListener(
|
|
121
|
-
"transitionend",
|
|
122
|
-
() => {
|
|
123
|
-
if (this.open) {
|
|
124
|
-
this.#autoSize();
|
|
125
|
-
this.classList.toggle("-opening", false);
|
|
126
|
-
this.dispatchEvent(new Event("opened"));
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
{ once: true }
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
this.classList.toggle("-opening", false);
|
|
134
|
-
this.classList.toggle("-closing", true);
|
|
135
|
-
this.dispatchEvent(new Event("closing"));
|
|
136
|
-
|
|
137
|
-
this.#actualSize();
|
|
138
|
-
if (this.#hasOpened) {
|
|
139
|
-
this.classList.toggle("-no-animate", false);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (prefersReducedMotion()) {
|
|
143
|
-
this.#clearSize();
|
|
144
|
-
this.classList.toggle("-closing", false);
|
|
145
|
-
this.dispatchEvent(new Event("closed"));
|
|
146
|
-
} else {
|
|
147
|
-
requestAnimationFrame(() => {
|
|
148
|
-
this.#clearSize();
|
|
149
|
-
this.addEventListener(
|
|
150
|
-
"transitionend",
|
|
151
|
-
() => {
|
|
152
|
-
if (!this.open) {
|
|
153
|
-
this.classList.toggle("-closing", false);
|
|
154
|
-
this.dispatchEvent(new Event("closed"));
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
{ once: true }
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** @inheritdoc */
|
|
165
|
-
protected override render(): unknown {
|
|
166
|
-
return html`<slot @slotchange="${this.#handleSlotChange}"></slot>`;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** @private */
|
|
170
|
-
#handleSlotChange() {
|
|
171
|
-
this.#slotChanged = true;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/** @private */
|
|
175
|
-
#autoSize(): void {
|
|
176
|
-
this.style.height = "auto";
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/** @private */
|
|
180
|
-
#clearSize(): void {
|
|
181
|
-
this.style.height = "";
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/** @private */
|
|
185
|
-
#actualSize(): void {
|
|
186
|
-
this.style.height = `${this.scrollHeight}px`;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
interface M3eCollapsibleElementEventMap extends HTMLElementEventMap {
|
|
191
|
-
opening: Event;
|
|
192
|
-
opened: Event;
|
|
193
|
-
closing: Event;
|
|
194
|
-
closed: Event;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export interface M3eCollapsibleElement {
|
|
198
|
-
addEventListener<K extends keyof M3eCollapsibleElementEventMap>(
|
|
199
|
-
type: K,
|
|
200
|
-
listener: (this: M3eCollapsibleElement, ev: M3eCollapsibleElementEventMap[K]) => void,
|
|
201
|
-
options?: boolean | AddEventListenerOptions
|
|
202
|
-
): void;
|
|
203
|
-
|
|
204
|
-
addEventListener(
|
|
205
|
-
type: string,
|
|
206
|
-
listener: EventListenerOrEventListenerObject,
|
|
207
|
-
options?: boolean | AddEventListenerOptions
|
|
208
|
-
): void;
|
|
209
|
-
|
|
210
|
-
removeEventListener<K extends keyof M3eCollapsibleElementEventMap>(
|
|
211
|
-
type: K,
|
|
212
|
-
listener: (this: M3eCollapsibleElement, ev: M3eCollapsibleElementEventMap[K]) => void,
|
|
213
|
-
options?: boolean | EventListenerOptions
|
|
214
|
-
): void;
|
|
215
|
-
|
|
216
|
-
removeEventListener(
|
|
217
|
-
type: string,
|
|
218
|
-
listener: EventListenerOrEventListenerObject,
|
|
219
|
-
options?: boolean | EventListenerOptions
|
|
220
|
-
): void;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
declare global {
|
|
224
|
-
interface HTMLElementTagNameMap {
|
|
225
|
-
"m3e-collapsible": M3eCollapsibleElement;
|
|
226
|
-
}
|
|
227
|
-
}
|