shared
NPM
1.0.3
1.0.1 (2024-11-11) #
Note: Version bump only for package @spectrum-web-components/shared
1.0.0 (2024-10-31) #
Note: Version bump only for package @spectrum-web-components/shared
0.49.0 (2024-10-15) #
Note: Version bump only for package @spectrum-web-components/shared
0.48.1 (2024-10-01) #
Note: Version bump only for package @spectrum-web-components/shared
0.48.0 (2024-09-17) #
Note: Version bump only for package @spectrum-web-components/shared
0.47.2 (2024-09-03) #
Note: Version bump only for package @spectrum-web-components/shared
0.47.1 (2024-08-27) #
Note: Version bump only for package @spectrum-web-components/shared
0.47.0 (2024-08-20) #
Note: Version bump only for package @spectrum-web-components/shared
0.46.0 (2024-08-08) #
Note: Version bump only for package @spectrum-web-components/shared
0.45.0 (2024-07-30) #
Note: Version bump only for package @spectrum-web-components/shared
0.44.0 (2024-07-15) #
Features #
- action-bar: support for action-menus (
#3780 ) (4aff599 )
0.43.0 (2024-06-11) #
Note: Version bump only for package @spectrum-web-components/shared
0.42.5 (2024-05-24) #
Note: Version bump only for package @spectrum-web-components/shared
0.42.4 (2024-05-14) #
Note: Version bump only for package @spectrum-web-components/shared
0.42.3 (2024-05-01) #
Note: Version bump only for package @spectrum-web-components/shared
0.42.2 (2024-04-03) #
Note: Version bump only for package @spectrum-web-components/shared
0.42.1 (2024-04-02) #
Bug Fixes #
- shared: ensure the "updateComplete" in Focusable is stable (
885b4a5 )
0.42.0 (2024-03-19) #
Note: Version bump only for package @spectrum-web-components/shared
0.41.2 (2024-03-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.41.1 (2024-02-22) #
Note: Version bump only for package @spectrum-web-components/shared
0.41.0 (2024-02-13) #
Bug Fixes #
- support generating random IDs outside of secure contexts (
485a67c )
0.40.5 (2024-02-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.40.4 (2024-01-29) #
Bug Fixes #
- shared: update and expand attribute coverage in likeAnchor (
5cb5f1d )
0.40.3 (2024-01-11) #
Note: Version bump only for package @spectrum-web-components/shared
0.40.2 (2023-12-18) #
Note: Version bump only for package @spectrum-web-components/shared
0.40.1 (2023-12-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.40.0 (2023-11-16) #
Note: Version bump only for package @spectrum-web-components/shared
0.39.4 (2023-11-02) #
Note: Version bump only for package @spectrum-web-components/shared
0.39.3 (2023-10-18) #
Note: Version bump only for package @spectrum-web-components/shared
0.39.2 (2023-10-13) #
Note: Version bump only for package @spectrum-web-components/shared
0.39.1 (2023-10-06) #
Note: Version bump only for package @spectrum-web-components/shared
0.39.0 (2023-09-25) #
Bug Fixes #
- shared: scope querySelector to direct children, like slots are (
515eaee )
0.38.0 (2023-09-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.37.0 (2023-08-18) #
Features #
- overlay: ship Overlay API v2 (
67b5d1b )
0.36.0 (2023-08-18) #
Note: Version bump only for package @spectrum-web-components/shared
0.35.0 (2023-07-31) #
Bug Fixes #
- meter, progress-bar, progress-circle: use innerText when label is not provided (
#3483 ) (59358c7 )
0.34.0 (2023-07-11) #
Note: Version bump only for package @spectrum-web-components/shared
0.33.2 (2023-06-14) #
Note: Version bump only for package @spectrum-web-components/shared
0.33.0 (2023-06-08) #
Note: Version bump only for package @spectrum-web-components/shared
0.32.0 (2023-06-01) #
Note: Version bump only for package @spectrum-web-components/shared
0.31.0 (2023-05-17) #
Bug Fixes #
- shared: allow "disabled" first to return to "tabindex=0" in "focusable" (
160bc59 )
0.30.0 (2023-05-03) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.7 (2023-04-24) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.6 (2023-04-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.5 (2023-01-23) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.4 (2023-01-09) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.3 (2022-11-21) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.2 (2022-11-14) #
Note: Version bump only for package @spectrum-web-components/shared
0.15.1 (2022-10-17) #
Bug Fixes #
- correct the relationship between overlayWillCloseCallback and phased animations (
c63db8d )
0.15.0 (2022-08-09) #
Features #
- include all Dev Mode files in side effects (
f70817c )
0.14.5 (2022-08-04) #
Note: Version bump only for package @spectrum-web-components/shared
0.14.4 (2022-07-18) #
Note: Version bump only for package @spectrum-web-components/shared
0.14.3 (2022-06-29) #
Note: Version bump only for package @spectrum-web-components/shared
0.14.2 (2022-06-07) #
Note: Version bump only for package @spectrum-web-components/shared
0.14.1 (2022-05-12) #
Note: Version bump only for package @spectrum-web-components/shared
0.14.0 (2022-04-21) #
Features #
- conditionally load focus-visible polyfill (
6b5e5cf ) - reparentChildren - insertAdjacentElement style API (
07f966f ) - reparentChildren - refactored arguments - breaking change (
dea2bc5 )
0.13.7 (2022-03-30) #
Note: Version bump only for package @spectrum-web-components/shared
0.13.6 (2022-03-08) #
Note: Version bump only for package @spectrum-web-components/shared
0.13.5 (2022-03-04) #
Note: Version bump only for package @spectrum-web-components/shared
0.13.4 (2022-02-22) #
Bug Fixes #
- dialog: updates for delivering dialog content accessibly (
f0ed33c )
0.13.3 (2022-01-26) #
Note: Version bump only for package @spectrum-web-components/shared
0.13.2 (2022-01-07) #
Note: Version bump only for package @spectrum-web-components/shared
0.13.1 (2021-12-13) #
Note: Version bump only for package @spectrum-web-components/shared
0.13.0 (2021-11-08) #
Features #
- update lit-* dependencies, wip (
377f3c8 )
0.12.11 (2021-11-08) #
Note: Version bump only for package @spectrum-web-components/shared
0.12.10 (2021-11-02) #
Bug Fixes #
- centralize updated first focusable selector (
300e84c )
0.12.9 (2021-10-12) #
Bug Fixes #
- add likeAnchor API to Card element (
5c338fb )
0.12.8 (2021-09-13) #
Bug Fixes #
- ensure lazily loaded focusElements do not crash (
64f2a54 )
0.12.7 (2021-07-22) #
Note: Version bump only for package @spectrum-web-components/shared
0.12.6 (2021-07-01) #
Bug Fixes #
- allow detached elements to be used as content for an overlay (
3ad8383 ) - manage "lang" via context provided by "sp-theme" (
b1e3457 )
0.12.5 (2021-06-16) #
Note: Version bump only for package @spectrum-web-components/shared
0.12.4 (2021-05-24) #
Bug Fixes #
- no scroll update when managing elements outside of the tab order (
144c548 ) - prevent tabindex=-1 elements from placing focus on their host (
1ac1293 )
0.12.3 (2021-05-12) #
Bug Fixes #
- allow rendered anchors to be aria-hidden (
2e9aa23 ) - update "reparentChildren" types for flexibility (
2d358be )
0.12.2 (2021-04-09) #
Note: Version bump only for package @spectrum-web-components/shared
0.12.1 (2021-03-29) #
Note: Version bump only for package @spectrum-web-components/shared
0.12.0 (2021-03-22) #
Bug Fixes #
- renamed the file but not this (
ad94e53 ) - split-button tests & lots of cleanup based on review feedback (
10b4a04 ), closes#1189
Features #
- picker: process field-label content for more accurate a11y tree (
dc9df54 ) - deprecate sp-menu in PickerBase derived classes (
bbb773c )
0.11.1 (2021-03-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.11.0 (2021-03-04) #
Features #
- use latest exports specification (
a7ecf4b )
0.10.0 (2021-02-11) #
Bug Fixes #
- update to latest spectrum-css packages (
a5ca19f )
Features #
- allow activation of longpress content (
55e71fd )
0.9.0 (2021-01-21) #
Bug Fixes #
- button: relate to this.href correctly (
fade3ea ) - include the "types" entry in package.json files (
b432f59 ) - use latest @spectrum-css/* versions (
c35eb86 )
Features #
- button: use synthetic button instead of native (
49e94bc ) - shared: conditionally apply focus-visible polyfill (
b854df6 )
Performance Improvements #
- shared: focus-visible, lazily instantiate the focus-visible polyfilling (
fe257c1 )
0.8.0 (2021-01-13) #
Bug Fixes #
- button: relate to this.href correctly (
fade3ea ) - include the "types" entry in package.json files (
b432f59 ) - use latest @spectrum-css/* versions (
c35eb86 )
Features #
- button: use synthetic button instead of native (
49e94bc ) - shared: conditionally apply focus-visible polyfill (
b854df6 )
Performance Improvements #
- shared: focus-visible, lazily instantiate the focus-visible polyfilling (
fe257c1 )
0.7.4 (2020-10-12) #
Note: Version bump only for package @spectrum-web-components/shared
0.7.3 (2020-10-12) #
Bug Fixes #
- include default export in the "exports" fields (
f32407d )
0.7.2 (2020-09-25) #
Bug Fixes #
- update side effect listings (
8160d3a )
0.7.1 (2020-09-14) #
Bug Fixes #
- top-nav: prototype top-nav pattern (
9708f6f ) - flatten assigned nodes to observe text of nested slots (
08ffd68 )
0.7.0 (2020-08-31) #
Bug Fixes #
- split-button: follow visible tab order (
966d3b6 )
Features #
- split-button: add split-button pattern (
4833a59 ) - use 3.0.0-beta.* release for styles (
877b485 )
0.6.0 (2020-07-27) #
Bug Fixes #
- ensure browser understandable extensions (
f4e59f7 )
Features #
- link: support rel attribute (
df4b5a8 )
0.5.1 (2020-07-22) #
Bug Fixes #
- shared: prevent focusable returning focus to host (
745f7b0 ) - tabs: correct entry focus element (
64407d3 )
0.5.0 (2020-07-17) #
Features #
- leverage "exports" field in package.json (
321abd7 )
0.4.7 (2020-06-08) #
Note: Version bump only for package @spectrum-web-components/shared
0.4.6 (2020-04-16) #
Performance Improvements #
- use "sideEffects" listing in package.json (
7271614 )
0.4.5 (2020-04-10) #
Note: Version bump only for package @spectrum-web-components/shared
0.4.4 (2020-04-07) #
Note: Version bump only for package @spectrum-web-components/shared
0.4.3 (2020-02-05) #
Note: Version bump only for package @spectrum-web-components/shared
0.4.2 (2020-02-01) #
Bug Fixes #
- shared: fixes search input - fixes
#463 (6833944 ) - shared: removes mousedown event handling in focusable (
4e90d4c )
0.4.1 (2020-01-30) #
Bug Fixes #
- shared: prevent focusing focusable root on second click (
0fb5006 )
0.4.0 (2020-01-06) #
Features #
- sidenav: add keyboard accessibility (
6ff622b ) - tab-list: autofocus, :before/after processing, visual test (
83dddb0 )
0.3.3 (2019-12-12) #
Bug Fixes #
- apply Focuable styles in class extensions (
38f7afd )
0.3.2 (2019-12-02) #
Bug Fixes #
- shared: include an actual entry point for bundlephobia (
00fd6ab ) - normalize "event" and "error" argument names (
8d382cd )
0.3.1 (2019-11-27) #
Bug Fixes #
- include "type" in package.json, generate custom-elements.json (
1a8d716 )
0.3.0 (2019-11-19) #
Bug Fixes #
- shared: fixes focus-visible types in test (
0dc7d68 ) - shared: improves types for focus-visible (
b980f2a )
Features #
- add screenshot regression testing to CI (
8205dfe ) - use :focus-visable (via polyfill) instead of :focus (
11c6fc7 )
0.2.0 (2019-11-01) #
Bug Fixes #
- shared: make Focusable pass disabled always (
a339d6f ) - shared: quiet the angry soul of the explicit any linter (
c278263 )
Features #
- shared: add mixing for observing text content changes in a slot (
1318150 )
0.1.4 (2019-10-14) #
Performance Improvements #
- use imported TypeScript helpers instead of inlining them (
cc2bd0a )
0.1.3 (2019-10-03) #
Note: Version bump only for package @spectrum-web-components/shared
Description #
Shared mixins, tools, etc. that support developing Spectrum Web Components.
Usage #
npm install @spectrum-web-components/shared
Individual base classes and mixins can be imported as follows:
import { Focusable, FocusVisiblePolyfillMixin, getActiveElement, LikeAnchor, ObserveSlotText, } from '@spectrum-web-components/shared';
getDeepElementFromPoint #
The getDeepElementFromPoint
method allows you to obtain the deepest possible element at a given coordinates on the current page. The method will step into any available shadowRoot
s until it reaches the first element with no shadowRoot
or no children available at the given coordinates.
Focusable #
The Focusable
subclass of LitElement
adds some helpers method and lifecycle coverage in order to support passing focus to a container element inside of a custom element. The Focusable base class handles tabindex setting into shadowed elements automatically and is based heavily on the
import { Focusable } from '@spectrum-web-components/shared'; import { html } from 'lit-element'; class FocusableButton extends Focusable { public static override get styles(): CSSResultArray { return [...super.styles]; } public get focusElement(): HTMLElement { return this.shadowRoot.querySelector('#button') as HTMLElement; } protected override render(): TemplateResult { return html` <button id="button" > Focus for this button is being managed by the focusable base class. </button> `; } }
FocusVisiblePolyfillMixin #
Use this mixin if you would like to leverage :focus-visible
based selectors in your CSS.
getActiveElement #
Use this helper to find an activeElement
in your component.
LikeAnchor #
Mix download
, label
, href
, and target
properties into your element to allow it to act more like an HTMLAnchorElement
.
ObserveSlotPresence #
When working with styles that are driven by the conditional presence of <slot>
s in a component's shadow DOM, you will need to track whether light DOM that is meant for that slot exists. Use the ObserveSlotPresence
mixin to target specific light DOM to observe the presence of and trigger this.requestUpdate()
calls when content fulfilling that selector comes in and out of availability.
import { ObserveSlotPresence } from '@spectrum-web-components/shared'; import { LitElement, html } from 'lit-element'; class ObserveSlotPresenceElement extends ObserveSlotPresence(LitElement, '[slot="conditional-slot"]') { // translate the mixin properties into locally understandable language protected get hasConditionalSlotContent() { return this.slotContentIsPresent; } protected override render(): TemplateResult { return html` <button id="button" > ${this.hasConditionalSlotContent ? html` <slot name="conditional-slot" ></slot> ` : html`` } </button> `; } protected updated(): void { console.log(this.slotContentIsPresent); // => true when <observing-slot-presence-element><div slot="conditional-slot"></div></observing-slot-presence-element> } } customElements.define('observing-slot-presence-element', ObserveSlotPresenceElement);
ObserveSlotText #
When working with <slot>
s and their slotchange
event, you will have the opportunity to capture when the nodes and/or elements in your element are added or removed. However, if the textContent
of a text node changes, you will not receive the slotchange
event because the slot hasn't actually received new nodes and/or elements in the exchange. When working with a lit-html binding <your-element>${text}</your-element>
that means you will not receive a slotchange
event when the value of text
goes from text = ''
to text = 'something'
or the other way. In these cases the ObserveSlotText
can be leverages to apply a mutation observe onto your element that tracks characterData
mutations so that you can resspond as desired.
import { ObserveSlotText } from '@spectrum-web-components/shared'; import { LitElement, html } from 'lit-element'; class ObserveSlotTextElement extends ObserveSlotText(LitElement, '#observing-slot') { protected override render(): TemplateResult { return html` <button id="button" > <slot id="observing-slot" @slotchange=${this.manageObservedSlot} ></slot> </button> `; } protected updated(): void { console.log(this.slotHasContent); // => true when <observing-slot-text-element>Text</observing-slot-text-element> } } customElements.define('observing-slot-text-element', ObserveSlotTextElement);