@aceshooting/lyra-ui 32.1.0 → 33.1.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.
Files changed (212) hide show
  1. package/CHANGELOG.md +247 -1576
  2. package/README.md +15 -2
  3. package/custom-elements.slim.json +1 -0
  4. package/dist/accent-roles.css +1 -0
  5. package/dist/cli/migrate-wa.mjs +50 -48
  6. package/dist/cli/migration-contract.json.gz +0 -0
  7. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +1 -1
  8. package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +10 -0
  9. package/dist/components/conversation/code-block/code-block-base.class.d.ts +3 -1
  10. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  11. package/dist/components/conversation/code-block/code-block-core.class.d.ts +1 -1
  12. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  13. package/dist/components/conversation/code-block/code-block.class.d.ts +3 -2
  14. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  15. package/dist/components/conversation/code-block/code-grammar-registry.d.ts +35 -0
  16. package/dist/components/conversation/code-block/code-grammar-registry.js +1 -0
  17. package/dist/components/conversation/model-select/model-select.class.d.ts +8 -7
  18. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +1 -1
  19. package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +1 -1
  20. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +8 -7
  21. package/dist/components/data/table/table-support.d.ts +2 -3
  22. package/dist/components/data/table/table.class.d.ts +2 -1
  23. package/dist/components/data/timeline/timeline.class.d.ts +17 -6
  24. package/dist/components/data/timeline/timeline.class.js +2 -2
  25. package/dist/components/data/timeline/timeline.styles.js +1 -1
  26. package/dist/components/forms/catalog-picker-base.d.ts +14 -1
  27. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  28. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +4 -5
  29. package/dist/components/forms/checkbox-group/checkbox-group.styles.js +1 -1
  30. package/dist/components/forms/code-editor/code-editor.class.d.ts +14 -5
  31. package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
  32. package/dist/components/forms/color-picker/color-picker.class.d.ts +18 -7
  33. package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
  34. package/dist/components/forms/combobox/combobox-option-html.js +1 -0
  35. package/dist/components/forms/combobox/combobox.class.d.ts +30 -9
  36. package/dist/components/forms/combobox/combobox.class.js +110 -21
  37. package/dist/components/forms/combobox/combobox.styles.js +1 -1
  38. package/dist/components/forms/country-picker/country-picker.class.d.ts +4 -5
  39. package/dist/components/forms/currency-picker/currency-picker.class.d.ts +4 -5
  40. package/dist/components/forms/date-picker/date-input.class.d.ts +14 -5
  41. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  42. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +10 -0
  43. package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
  44. package/dist/components/forms/icon-button/icon-button.class.d.ts +2 -1
  45. package/dist/components/forms/input/input-shared.d.ts +14 -5
  46. package/dist/components/forms/input/time-input.class.d.ts +15 -6
  47. package/dist/components/forms/input/time-input.styles.js +1 -1
  48. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +8 -7
  49. package/dist/components/forms/otp-input/otp-input.class.d.ts +4 -5
  50. package/dist/components/forms/otp-input/otp-input.styles.js +1 -1
  51. package/dist/components/forms/phone-input/phone-input.class.d.ts +14 -5
  52. package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
  53. package/dist/components/forms/radio/radio-group.class.d.ts +4 -5
  54. package/dist/components/forms/radio/radio-group.styles.js +1 -1
  55. package/dist/components/forms/radio/radio.class.js +2 -2
  56. package/dist/components/forms/select/select.class.d.ts +5 -6
  57. package/dist/components/forms/signature-pad/signature-pad.class.d.ts +4 -5
  58. package/dist/components/forms/signature-pad/signature-pad.styles.js +1 -1
  59. package/dist/components/forms/slider/slider.class.d.ts +6 -5
  60. package/dist/components/forms/slider/slider.styles.js +1 -1
  61. package/dist/components/forms/textarea/textarea.class.d.ts +14 -5
  62. package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +4 -5
  63. package/dist/components/forms/token-input/token-input.class.d.ts +10 -10
  64. package/dist/components/forms/token-input/token-input.class.js +1 -1
  65. package/dist/components/forms/token-input/token-input.styles.js +1 -1
  66. package/dist/components/forms/unit-picker/unit-picker.class.d.ts +4 -5
  67. package/dist/components/layout/command-palette/command-palette.class.d.ts +1 -1
  68. package/dist/components/layout/menu/menu.class.d.ts +1 -1
  69. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +1 -1
  70. package/dist/components/layout/segmented/segmented.class.d.ts +2 -2
  71. package/dist/components/layout/stepper/step.class.d.ts +14 -1
  72. package/dist/components/layout/stepper/step.class.js +2 -2
  73. package/dist/components/lr-map-anchor.d.ts +1 -1
  74. package/dist/components/media/file-input/file-input.class.d.ts +2 -1
  75. package/dist/components/media/file-input/file-input.class.js +1 -1
  76. package/dist/components/media/file-input/file-input.styles.js +1 -1
  77. package/dist/components/media/lightbox/lightbox-item.class.d.ts +10 -0
  78. package/dist/components/media/lightbox/lightbox-item.class.js +1 -1
  79. package/dist/components/media/lightbox/lightbox-source.js +1 -1
  80. package/dist/components/media/lightbox/lightbox-types.d.ts +4 -1
  81. package/dist/components/media/lightbox/lightbox.class.d.ts +42 -19
  82. package/dist/components/media/lightbox/lightbox.class.js +4 -3
  83. package/dist/components/media/lightbox/lightbox.styles.js +1 -1
  84. package/dist/components/media/map/map-anchor-avoid.js +1 -1
  85. package/dist/components/media/map/map-anchor-options.d.ts +9 -0
  86. package/dist/components/media/map/map.class.d.ts +19 -5
  87. package/dist/components/media/map/map.class.js +3 -3
  88. package/dist/components/overlays/context-menu/context-menu.class.d.ts +1 -1
  89. package/dist/components/overlays/dialog/dialog.class.d.ts +19 -3
  90. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  91. package/dist/components/overlays/dialog/dialog.styles.js +1 -1
  92. package/dist/components/overlays/drawer/drawer.class.d.ts +8 -2
  93. package/dist/components/overlays/drawer/drawer.class.js +1 -1
  94. package/dist/components/overlays/overlay/dropdown.class.d.ts +1 -1
  95. package/dist/components/overlays/overlay/overlay.styles.js +1 -1
  96. package/dist/components/overlays/overlay/popover.class.d.ts +1 -1
  97. package/dist/components/overlays/overlay/popover.class.js +1 -1
  98. package/dist/components/overlays/overlay/tooltip.class.d.ts +5 -0
  99. package/dist/components/overlays/overlay/tooltip.class.js +2 -2
  100. package/dist/components/overlays/toast/toast-item.class.d.ts +2 -2
  101. package/dist/components/overlays/toast/toast-item.styles.js +1 -1
  102. package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +1 -1
  103. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +1 -1
  104. package/dist/components/utility/copy-button/copy-button.class.d.ts +2 -1
  105. package/dist/components/utility/copy-button/copy-button.class.js +1 -1
  106. package/dist/components/utility/export-button/export-button.class.d.ts +1 -1
  107. package/dist/components/utility/icon/icon-library-bootstrap.d.ts +50 -0
  108. package/dist/components/utility/icon/icon-library-bootstrap.js +1 -0
  109. package/dist/components/utility/icon/icon-library-font-awesome.d.ts +68 -0
  110. package/dist/components/utility/icon/icon-library-font-awesome.js +1 -0
  111. package/dist/components/utility/known-date/known-date.class.d.ts +10 -0
  112. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +1 -1
  113. package/dist/components/utility/number-ticker/number-ticker.class.d.ts +10 -2
  114. package/dist/components/utility/number-ticker/number-ticker.class.js +1 -1
  115. package/dist/components/utility/tour/tour.class.d.ts +1 -1
  116. package/dist/framework-types.d.ts +1 -1
  117. package/dist/internal/accessibility-visibility.js +1 -1
  118. package/dist/internal/autoloader-manifest.js +1 -1
  119. package/dist/internal/declarative-overlay-action.js +1 -0
  120. package/dist/internal/default-strings/forms.generated.js +1 -1
  121. package/dist/internal/document-token-css.generated.js +10 -0
  122. package/dist/internal/document-tokens.generated.js +2 -11
  123. package/dist/internal/document-tokens.js +2 -2
  124. package/dist/internal/dom-guards.js +1 -1
  125. package/dist/internal/external-label-association.js +1 -0
  126. package/dist/internal/focus-navigation.js +1 -1
  127. package/dist/internal/form-control/chrome.styles.js +1 -1
  128. package/dist/internal/form-control-labels.js +1 -1
  129. package/dist/internal/localization-runtime.js +1 -1
  130. package/dist/internal/localization-types.d.ts +1 -1
  131. package/dist/internal/localization.js +1 -1
  132. package/dist/internal/lyra-element.d.ts +12 -3
  133. package/dist/internal/lyra-element.js +2 -2
  134. package/dist/internal/package-metadata.js +1 -1
  135. package/dist/internal/theme-observation.js +1 -1
  136. package/dist/lyra.d.ts +1 -1
  137. package/dist/lyra.js +1 -1
  138. package/dist/ssr.d.ts +1 -1
  139. package/dist/styles/tokens-root.css +1 -1
  140. package/dist/styles/utilities.css +1 -1
  141. package/dist/theme-core.css +1 -1
  142. package/dist/theme.css +1 -1
  143. package/llms/components/lr-button.md +4 -0
  144. package/llms/components/lr-card.md +2 -0
  145. package/llms/components/lr-checkbox-group.md +2 -2
  146. package/llms/components/lr-citation-badge.md +1 -1
  147. package/llms/components/lr-code-block-core.md +3 -1
  148. package/llms/components/lr-code-block.md +14 -0
  149. package/llms/components/lr-code-editor.md +2 -2
  150. package/llms/components/lr-color-picker.md +4 -4
  151. package/llms/components/lr-combobox.md +21 -5
  152. package/llms/components/lr-context-menu.md +1 -1
  153. package/llms/components/lr-copy-button.md +4 -3
  154. package/llms/components/lr-country-picker.md +2 -2
  155. package/llms/components/lr-currency-picker.md +2 -2
  156. package/llms/components/lr-date-input.md +1 -1
  157. package/llms/components/lr-date-picker.md +1 -1
  158. package/llms/components/lr-dialog.md +30 -2
  159. package/llms/components/lr-drawer.md +7 -1
  160. package/llms/components/lr-entity-chip.md +1 -1
  161. package/llms/components/lr-export-button.md +1 -1
  162. package/llms/components/lr-file-input.md +1 -1
  163. package/llms/components/lr-icon.md +96 -0
  164. package/llms/components/lr-input.md +2 -2
  165. package/llms/components/lr-lightbox.md +43 -17
  166. package/llms/components/lr-locale-picker.md +2 -2
  167. package/llms/components/lr-map.md +16 -1
  168. package/llms/components/lr-mention-popover.md +1 -1
  169. package/llms/components/lr-menu.md +1 -1
  170. package/llms/components/lr-model-select.md +4 -4
  171. package/llms/components/lr-native-time-input.md +2 -2
  172. package/llms/components/lr-number-input.md +2 -2
  173. package/llms/components/lr-number-ticker.md +7 -2
  174. package/llms/components/lr-otp-input.md +2 -2
  175. package/llms/components/lr-phone-input.md +2 -2
  176. package/llms/components/lr-popover.md +1 -1
  177. package/llms/components/lr-radio-group.md +2 -2
  178. package/llms/components/lr-segmented.md +1 -1
  179. package/llms/components/lr-select.md +3 -3
  180. package/llms/components/lr-selection-toolbar.md +1 -1
  181. package/llms/components/lr-signature-pad.md +2 -2
  182. package/llms/components/lr-slider.md +1 -1
  183. package/llms/components/lr-step.md +7 -1
  184. package/llms/components/lr-textarea.md +2 -2
  185. package/llms/components/lr-time-input.md +3 -3
  186. package/llms/components/lr-time-zone-picker.md +2 -2
  187. package/llms/components/lr-timeline.md +12 -5
  188. package/llms/components/lr-toast.md +1 -1
  189. package/llms/components/lr-token-input.md +10 -9
  190. package/llms/components/lr-tool-call-chip.md +1 -1
  191. package/llms/components/lr-tooltip.md +5 -0
  192. package/llms/components/lr-unit-picker.md +2 -2
  193. package/llms/components/lr-usage-badge.md +1 -1
  194. package/llms/components/lr-voice-picker.md +4 -3
  195. package/llms/index.md +128 -128
  196. package/llms/migration.md +87 -8
  197. package/llms/peers.md +2 -2
  198. package/llms/shared/events-and-types.md +1 -1
  199. package/llms/shared/forms-and-accessibility.md +4 -1
  200. package/llms/shared/frameworks-and-ssr.md +47 -1
  201. package/llms/shared/imports-and-registration.md +8 -1
  202. package/llms/shared/localization-and-rtl.md +5 -0
  203. package/llms/shared/native-styles-and-utilities.md +85 -8
  204. package/llms/shared/styles-and-tokens.md +58 -4
  205. package/llms/shared/testing-and-utilities.md +9 -0
  206. package/llms/shared.md +217 -16
  207. package/locales.json +1 -1
  208. package/package.json +15 -6
  209. package/registrations.json +1 -1
  210. package/skills/compose-lyra-interfaces/SKILL.md +1 -1
  211. package/skills/lyra-ui/SKILL.md +1 -1
  212. package/skills/lyra-ui/commands/migrate.md +1 -1
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{AnchoredDisclosureController}from"../../../internal/anchored-disclosure-controller.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isAccessibilitySubtreeExcluded,isAccessibilityVisibilityHidden,nextId}from"../../../internal/a11y.js";import{resolveAccessibleTrigger}from"../../../internal/accessible-trigger.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{isActionableElement}from"../../../internal/focus-navigation.js";import{imageMapImageFor}from"../../../internal/dom-guards.js";import{deferredPlaceReady as place,syncTopLayerRelease,topLayerPlacement,waitForDeferredPlacement}from"../../../internal/anchored-overlay-runtime.js";import{virtualAnchorFromRect}from"../../../internal/positioner-geometry.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedParentElement,deepActiveElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{parseCssTimeToken}from"../../../internal/css-motion-time.js";import{finiteDuration,finiteNumber}from"../../../internal/numbers.js";import{declaredDefaultConverter,literalSetConverter,omittedEmptyStringConverter,blankNumberConverter}from"../../../internal/converters.js";import{PositioningStrategyState,positioningStrategyConverter,resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{subscribeInheritedAttributes}from"../../../internal/inherited-attribute-hub.js";import{accessibleTextRecordsMatter,bindAccessibleTextObserver,labelReferenceRecordsMatter,composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{applyOverlayArrow}from"./overlay-arrow.js";import{normalizeVirtualRect,OverlayAnchorIdentity,OverlayDelayTimer,resolveOverlayAnchor,resolveOverlayAccessibleTrigger,resolveOverlayInteractionTrigger}from"../../../internal/overlay-shared.js";import{tooltipStyles}from"./overlay.styles.js";import{LYRA_DEFAULT_popover}from"../../../internal/default-strings/overlays.generated.js";const DEFAULT_SHOW_DELAY=150,DEFAULT_HIDE_DELAY=0,DEFAULT_DISTANCE=8,MAX_SHADOW_CONTENT_SCAN_FRAMES=4;function safelyComposedContains(container,candidate){try{return candidate?.nodeType===1&&composedContains(container,candidate)}catch{return!1}}const TOOLTIP_LABEL_MODE=literalSetConverter(["description","label","none"],"description"),BLANK_TEXT=/^[ \t\n\f\r]*$/;function isBlankText(node){return node.nodeType===Node.TEXT_NODE&&BLANK_TEXT.test(node.textContent??"")}class LyraTooltip extends LyraElement{constructor(){super(...arguments),this._open=!1,this.trigger="hover focus",this._labelMode="description",this.manual=!1,this.showDelay=150,this.hideDelay=0,this.placement="top",this.distance=8,this.skidding=0,this._for="",this.anchor=null,this.disabled=!1,this.strategy=new PositioningStrategyState(this),this.topLayer=!1,this.withoutArrow=!1,this.arrowPlacement="anchor",this.arrowPadding=0,this.content="",this.accessibleLabel="",this.namedTriggerMode=!0,this.interactiveContent=!1,this.blankContentAssignment=!1,this.resolvedSide="top",this.anchorPositioned=!1,this.popupHidden=!0,this.directionChanged=!1,this.anchorIdentity=new OverlayAnchorIdentity,this.placementPending=!1,this.delayTimer=new OverlayDelayTimer,this.restoreFocusOnClose=!1,this.suppressTriggerFocusOpen=!1,this.openedByPointer=!1,this.tooltipId=nextId("tooltip"),this.descriptionId=nextId("tooltip-description"),this.focusDescribesTrigger=!1,this.triggerSyncGeneration=0,this.contentSlotListeners=new Set,this.shadowContentScanAttempts=0,this.disclosure=new AnchoredDisclosureController({host:this,isOpen:()=>this._open,setOpen:value=>this.applyOpenState(value),emit:name=>name==="lr-show"||name==="lr-hide"?this.emit(name,null,{cancelable:!0}).defaultPrevented:this.emit(name).defaultPrevented,popup:()=>this.renderRoot.querySelector('[part~="popup"]'),readyToShow:async isCurrent=>{const positioned=await waitForDeferredPlacement(()=>this.cleanup);return isCurrent()&&positioned&&this.anchorPositioned&&!this.placementPending},animate:(showing,popup)=>animateRegistered(this,popup,`tooltip.${showing?"show":"hide"}`,this.effectiveDirection,{keyframes:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:["--lr-transition-fast","--lr-duration-fast"],easingProperties:["--lr-easing-standard"]}),afterHide:()=>{this.popupHidden=!0}}),this.onTriggerSlotChange=event=>{this.syncNamedTriggerMode();const slot=event.target;this.slottedTriggerElement=slot.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()},this.onEnter=event=>{if(!this.disabled){if(event.type==="focusin"){if(this.updateInteractiveContent(),this.opensOn("focus")&&(this.focusDescribesTrigger=!0),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y(),this.suppressTriggerFocusOpen||!this.opensOn("focus")||!isKeyboardFocusEvent(event))return}else{if(this.syncTriggerA11y(),!this.opensOn("hover"))return;this.openedByPointer=!0}this.requestTransition(!0)}},this.onLeave=event=>{if(event.type==="focusout"?!this.opensOn("focus"):!this.opensOn("hover"))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&this.triggerElement&&composedContains(this.triggerElement,next)||(event.type==="focusout"&&(this.focusDescribesTrigger=!1,this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y()),!(this.interactiveContent&&(this.isPopupTarget(next)||this.retainsPopupInteraction(event)))&&this.requestTransition(!1))},this.onTriggerClick=()=>{this.disabled||this.opensOn("click")&&(this.syncTriggerA11y(),this._open?this.hide():this.show())},this.onPopupEnter=()=>{!this.interactiveContent||this.isManual||(this.cancelPendingTransition(),this.show())},this.onPopupLeave=event=>{if(!this.interactiveContent||this.isManual||this.retainsPopupInteraction(event))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&(this.triggerElement&&composedContains(this.triggerElement,next)||this.isPopupTarget(next))||this.requestTransition(!1)},this.onContentSlotChange=event=>{event.target?.localName==="slot"&&this.updateInteractiveContent()}}static{this.defaultStrings={...super.defaultStrings,popover:LYRA_DEFAULT_popover}}static{this.styles=[LyraElement.styles,tooltipStyles]}get open(){return this._open}set open(next){const normalized=!!next;if(normalized||this.cancelPendingTransition(),normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.hide()}}get labelMode(){return this._labelMode}set labelMode(next){this._labelMode=TOOLTIP_LABEL_MODE.normalize(next)}get for(){return this._for}set for(next){this._for=next??""}get positioningStrategy(){return this.strategy.value}set positioningStrategy(next){this.strategy.set(next)}get hoist(){return this.strategy.hoist}set hoist(next){this.strategy.setHoist(next)}get rendersArrow(){return!this.withoutArrow}get activeContentSlot(){const selector=this.namedTriggerMode?'[part~="body"] slot:not([name])':'[part~="body"] slot[name="content"]';return(this.renderRoot??this.shadowRoot)?.querySelector(selector)??null}syncNamedTriggerMode(schedule=!0){const children=Array.from(this.children),hasNamedTrigger=children.some(child=>child.getAttribute("slot")==="trigger"),hasShoelaceContent=(this.content??"").length>0||children.some(child=>child.getAttribute("slot")==="content"),next=hasNamedTrigger||!hasShoelaceContent;if(next===this.namedTriggerMode)return;const old=this.namedTriggerMode;this.namedTriggerMode=next,schedule&&this.hasUpdated&&this.requestUpdate("namedTriggerMode",old)}get triggerKeywords(){return new Set(String(this.trigger??"").trim().split(/\s+/).filter(Boolean))}get isManual(){const keywords=this.triggerKeywords;return this.manual||keywords.size===0||keywords.has("manual")}opensOn(keyword){return!this.isManual&&this.triggerKeywords.has(keyword)}willUpdate(changed){super.willUpdate(changed);const direction=this.effectiveDirection;this.directionChanged=direction!==this.positioningDirection,this.positioningDirection=direction,this.syncNamedTriggerMode(!1),(changed.has("manual")||changed.has("trigger"))&&this.isManual&&this.cancelPendingTransition(),(changed.has("manual")||changed.has("trigger"))&&this.focusDescribesTrigger&&!this.opensOn("focus")&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),changed.has("disabled")&&this.disabled&&(this.cancelPendingTransition(),this.focusDescribesTrigger&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),this._open&&(this.hasUpdated?this.hide():this.applyOpenState(!1))),this.anchorIdentity.lostAnchorProperty(changed,this.anchor)&&this.open&&!this.resolveAnchor()&&this.forceClose(),changed.has("showDelay")&&this.delayTimer.pendingDirection==="show"&&this.requestTransition(!0),changed.has("hideDelay")&&this.delayTimer.pendingDirection==="hide"&&this.requestTransition(!1),changed.has("for")&&this.syncInteractionTrigger(),changed.has("open")&&!this.open&&(this.anchorPositioned=!1),changed.has("open")&&this.open&&(this.popupHidden=!1),changed.has("open")&&this.open&&this.hasUpdated&&this.isConnected&&this.updateInteractiveContent(),changed.has("labelMode")&&this.hasUpdated&&this.isConnected&&(this.contentNeeded?this.updateInteractiveContent():this.observeStructureOnly()),(changed.has("anchor")||changed.has("for"))&&(this.anchorPositioned=!1)}updated(changed){if(super.updated(changed),(changed.has("for")||changed.has("anchor")||changed.has("open"))&&this.syncAnchorIdentityObservation(),this.directionChanged||changed.has("open")||changed.has("placement")||changed.has("distance")||changed.has("skidding")||changed.has("for")||changed.has("anchor")||changed.has("positioningStrategy")||changed.has("topLayer")||changed.has("arrow")||changed.has("withoutArrow")||changed.has("arrowPlacement")||changed.has("arrowPadding")||changed.has("interactiveContent")){if(this.cleanup?.(),this.cleanup=void 0,this.open&&this.isConnected&&this.position(),changed.has("open"))if(this.open)this.updateInteractiveContent(),this.isConnected&&this.requiresOverlayManager&&this.activateTooltipOverlay();else{this.positionedAnchor=void 0;const restoreFocus=this.restoreFocusOnClose;this.suppressTriggerFocusOpen=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.suppressTriggerFocusOpen=!1}this.overlayHandle=void 0,this.restoreFocusOnClose=!1,this.virtualAnchor=void 0,this.returnFocusTo=void 0,this.syncInteractionTrigger(),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot)}else changed.has("interactiveContent")&&this.open&&this.isConnected&&this.activateTooltipOverlay();this.syncTriggerA11y()}changed.has("labelMode")&&this.syncTriggerA11y(),(changed.has("content")||changed.has("accessibleLabel"))&&this.updateDescriptionProxy()}connectedCallback(){super.connectedCallback();const triggerSyncGeneration=++this.triggerSyncGeneration,triggerSyncDocument=this.ownerDocument;this.syncAnchorIdentityObservation(),this.ensureDescriptionProxy(),this.contentObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.contentObserver=MutationObserverCtor?new MutationObserverCtor((records,observer)=>{if(!this.contentNeeded){this.syncNamedTriggerMode();return}accessibleTextRecordsMatter(observer,records)&&(this.syncNamedTriggerMode(),this.updateInteractiveContent())}):void 0,this.updateInteractiveContent(),this.syncInteractionTrigger(),this.updateComplete.then(()=>{if(triggerSyncGeneration!==this.triggerSyncGeneration||!this.isConnected||this.ownerDocument!==triggerSyncDocument)return;const slot=this.renderRoot.querySelector('[part="trigger"] > slot');this.slottedTriggerElement=slot?.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()}),this.hasUpdated&&this.open&&(this.popupHidden=!1,this.position(),this.requiresOverlayManager&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateTooltipOverlay()))}disconnectedCallback(){this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.suspend(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.releaseTriggerA11y(),this.focusDescribesTrigger=!1,this.triggerElement=void 0,this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.cancelShadowContentScan(),this.disclosure.reset(),this.popupHidden=!0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cancelShadowContentScan(),this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.releaseTriggerA11y()}syncAnchorIdentityObservation(){this.anchorIdentity.stop();const directAnchor=this.open?this.anchor??void 0:void 0;this.anchorIdentity.observe(this,directAnchor,this.for,()=>this.anchor,directAnchorRemoved=>{if((this.resolveInteractionTrigger()!==this.triggerElement||this.open||this.focusDescribesTrigger)&&this.syncInteractionTrigger(),!this.open)return;const nextAnchor=this.resolveAnchor();if(directAnchorRemoved&&!nextAnchor){this.forceClose();return}nextAnchor!==this.positionedAnchor&&this.position()})}resolveInteractionTrigger(){return resolveOverlayInteractionTrigger(this,this.virtualAnchor,this.slottedTriggerElement,this.for)}syncInteractionTrigger(){const next=this.resolveInteractionTrigger();this.adoptTrigger(next)}activateTooltipOverlay(){if(!this.isConnected)return;const restoreFocusTarget=this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger;if(this.overlayHandle?.isActive()){this.overlayHandle.updateRestoreFocusTo(restoreFocusTarget);return}this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part~="popup"]'),onEscape:()=>{this.hide({restoreFocus:this.shouldRestoreFocusAfterEscape()})},restoreFocusTo:restoreFocusTarget}),this.overlayHandle.focusAutofocus()}shouldRestoreFocusAfterEscape(){if(this.virtualAnchor)return this.returnFocusTo!==void 0;const active=deepActiveElementIn(this.ownerDocument);return safelyComposedContains(this,active)}get requiresOverlayManager(){return this.open}showAt(rect,options){const normalizedRect=normalizeVirtualRect(rect);if(!normalizedRect)return;const previousAnchor=this.virtualAnchor,previousReturnFocusTo=this.returnFocusTo;if(this.virtualAnchor=virtualAnchorFromRect(normalizedRect),this.returnFocusTo=options?.returnFocusTo,this.syncInteractionTrigger(),this.open){this.activateTooltipOverlay(),this.position();return}this.show(),!this.open&&(this.virtualAnchor=previousAnchor,this.returnFocusTo=previousReturnFocusTo,this.syncInteractionTrigger())}show(){return this.cancelPendingTransition(),this.disabled?Promise.resolve():this.disclosure.show()}hide(options){return this.cancelPendingTransition(),this.disclosure.hide(()=>{options?.restoreFocus&&(this.restoreFocusOnClose=!0)})}forceClose(){return this.cancelPendingTransition(),this.disclosure.forceClose()}applyOpenState(next){const old=this._open;this._open=next,next||(this.cancelShadowContentScan(),this.placementPending=!1),next||(this.openedByPointer=!1),this.requestUpdate("open",old)}resolveAnchor(){return resolveOverlayAnchor(this,{virtualAnchor:this.virtualAnchor,anchor:this.anchor,for:this.for,trigger:this.triggerElement})}position(){this.cleanup?.(),this.cleanup=void 0;const popup=this.renderRoot.querySelector('[part~="popup"]'),arrowElement=this.renderRoot.querySelector('[part~="arrow"]'),anchor=this.resolveAnchor();if(!this.open||!anchor||!popup){this.positionedAnchor=void 0,this.anchorPositioned=!1,this.placementPending=!1;return}if(anchor!==this.positionedAnchor&&(this.anchorPositioned=!1),this.open&&anchor&&popup){const arrowPadding=Math.max(0,finiteNumber(this.arrowPadding,0));this.placementPending=!0,this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,this.topLayer);const operation=place(anchor,popup,{placement:rtlAwarePlacement(this.placement,this),...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this.strategy.authored,"absolute")),offset:finiteNumber(this.distance,DEFAULT_DISTANCE),skidding:finiteNumber(this.skidding,0),arrow:this.rendersArrow&&arrowElement?arrowElement:void 0,arrowPadding,onPlaced:({placement,arrow})=>{this.placementPending=!1,this.positionedAnchor=anchor,this.anchorPositioned=!0;const side=applyOverlayArrow(arrowElement,{placement,coords:arrow,enabled:this.rendersArrow,arrowPlacement:this.arrowPlacement,arrowPadding,rtl:this.effectiveDirection==="rtl",sizeProperty:"--arrow-size",fallbackSizeProperty:"--lr-tooltip-arrow-size"});side!==this.resolvedSide&&(this.resolvedSide=side)}});this.cleanup=operation,operation.ready.then(positioned=>{!positioned&&this.cleanup===operation&&this.open&&(this.restoreFocusOnClose=safelyComposedContains(this,deepActiveElementIn(this.ownerDocument)),this.forceClose())})}}syncTriggerA11y(){const trigger=this.triggerElement??null,proxy=this.descriptionProxy,contribution={labels:proxy&&this.labelMode==="label"?[proxy]:[],descriptions:proxy&&this.labelMode==="description"&&(this.open||this.focusDescribesTrigger)?[proxy]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution);const accessibleTrigger=this.accessibleTrigger;this.observeTriggerTarget(contribution.labels.length||contribution.descriptions.length?trigger:null,accessibleTrigger);const distinctAccessibleTrigger=accessibleTrigger!==trigger?accessibleTrigger:null;this.accessibleTriggerAria?this.accessibleTriggerAria.update(distinctAccessibleTrigger,contribution):this.accessibleTriggerAria=acquireAriaOwnership(distinctAccessibleTrigger,contribution),this.overlayHandle?.isActive()&&!this.virtualAnchor&&this.overlayHandle.updateRestoreFocusTo(accessibleTrigger)}observeTriggerTarget(trigger,control){if(this.triggerTargetObserver?.disconnect(),!trigger||!this.isConnected){this.triggerTargetUpgrades?.disconnect();return}this.triggerTargetUpgrades??=new CustomElementUpgradeObserver(()=>this.syncTriggerA11y()),this.triggerTargetUpgrades.observeElement(trigger);const Observer=this.ownerDocument.defaultView?.MutationObserver;if(!Observer)return;this.triggerTargetObserver??=new Observer(()=>this.syncTriggerA11y());const options={childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-disabled","aria-hidden","class","disabled","hidden","href","inert","name","role","slot","style","tabindex","type"]};this.triggerTargetObserver.observe(trigger,options);for(let node=control;node&&(node.shadowRoot&&this.triggerTargetObserver.observe(node.shadowRoot,options),node!==trigger);node=composedParentElement(node));}get accessibleTrigger(){return this.triggerElement?this.labelMode==="label"?resolveOverlayAccessibleTrigger(this.triggerElement):resolveAccessibleTrigger(this.triggerElement):null}releaseTriggerA11y(){this.triggerTargetObserver?.disconnect(),this.triggerTargetObserver=void 0,this.triggerTargetUpgrades?.disconnect(),this.triggerTargetUpgrades=void 0,this.accessibleTriggerAria?.release(),this.accessibleTriggerAria=void 0,this.triggerAria?.release(),this.triggerAria=void 0}requestTransition(next){if(this.cancelPendingTransition(),this.disabled)return;const delay=this.interactionDelay(next);if(delay<=0){next?this.show():this.hide();return}const view=this.ownerDocument.defaultView;view&&this.delayTimer.schedule(view,delay,next?"show":"hide",()=>{next?this.show():this.hide()})}interactionDelay(showing){const value=showing?this.showDelay:this.hideDelay,fallback=showing?DEFAULT_SHOW_DELAY:DEFAULT_HIDE_DELAY,attribute=showing?"show-delay":"hide-delay";if(this.hasAttribute(attribute)||value!==fallback)return finiteDuration(value,fallback);const property2=showing?"--show-delay":"--hide-delay",raw=this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(property2).trim()??"",token=parseCssTimeToken(raw);return token&&!token.rest?finiteDuration(token.ms,fallback):fallback}cancelPendingTransition(){this.delayTimer.cancel()}bindTrigger(trigger){trigger.addEventListener("mouseenter",this.onEnter),trigger.addEventListener("mouseleave",this.onLeave),trigger.addEventListener("focusin",this.onEnter),trigger.addEventListener("focusout",this.onLeave),trigger.addEventListener("click",this.onTriggerClick)}unbindTrigger(trigger){trigger.removeEventListener("mouseenter",this.onEnter),trigger.removeEventListener("mouseleave",this.onLeave),trigger.removeEventListener("focusin",this.onEnter),trigger.removeEventListener("focusout",this.onLeave),trigger.removeEventListener("click",this.onTriggerClick),this.focusDescribesTrigger=!1}isTriggerHeld(trigger){try{if(trigger.matches(":hover"))return!0}catch{}const active=deepActiveElementIn(trigger.ownerDocument);return safelyComposedContains(trigger,active)}adoptTrigger(next){if(next===this.triggerElement){this.syncTriggerA11y();return}const hadTrigger=this.triggerElement!==void 0;if(this.cancelPendingTransition(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.triggerElement=next,!this.triggerElement){this.syncTriggerA11y(),hadTrigger&&this.open&&!this.resolveAnchor()&&this.forceClose();return}this.bindTrigger(this.triggerElement),this.syncTriggerA11y(),hadTrigger&&this._open&&this.openedByPointer&&!this.isTriggerHeld(this.triggerElement)&&this.forceClose(),this.open&&this.position(),this.open&&this.interactiveContent&&this.activateTooltipOverlay()}retainsPopupInteraction(event){return event.type==="mouseleave"?this.isPopupTarget(deepActiveElementIn(this.ownerDocument)):this.opensOn("hover")&&(this.triggerElement?.matches(":hover")===!0||this.renderRoot.querySelector('[part~="popup"]:hover')!==null)}isPopupTarget(target){if(target===null||target.nodeType!==1)return!1;const element=target,slot=this.activeContentSlot;return this.renderRoot.querySelector('[part~="popup"]')?.contains(element)===!0||slot?.assignedElements({flatten:!0}).some(root=>composedContains(root,element))===!0}clearContentSlotListeners(){for(const slot of this.contentSlotListeners)slot.removeEventListener("slotchange",this.onContentSlotChange);this.contentSlotListeners.clear()}syncContentSlotListeners(slots){const activeSlot=this.activeContentSlot;for(const slot of this.contentSlotListeners)slots.has(slot)&&slot!==activeSlot||(slot.removeEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.delete(slot));for(const slot of slots)slot===activeSlot||this.contentSlotListeners.has(slot)||(slot.addEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.add(slot))}inspectContent(){const snapshot={actionable:!1,assigned:!1,blank:!1,awaitingShadowRoot:!1,labelReferenceRoots:new Set,labelReferenceIds:new Set,referencedElements:new Set,text:"",externalRoots:new Set,shadowRoots:new Set,forwardingSlots:new Set,composedAncestors:new Set},activeSlot=this.activeContentSlot;if(!activeSlot)return snapshot;const renderRoot=this.renderRoot??this.shadowRoot,assignedNodes=activeSlot.assignedNodes();if(snapshot.assigned=assignedNodes.some(node=>!isBlankText(node)),snapshot.blank=assignedNodes.length>0&&!snapshot.assigned,!snapshot.assigned)return snapshot;const popup=renderRoot?.querySelector('[part~="popup"]'),bypassClosedVisibility=popup?.hasAttribute("data-hidden")===!0||this.placementPending,previousVisibility=popup?.style.getPropertyValue("visibility")??"",previousVisibilityPriority=popup?.style.getPropertyPriority("visibility")??"",previousHidden=popup?.hidden??!1;if(popup&&bypassClosedVisibility){const hostVisibility=this.ownerDocument.defaultView?.getComputedStyle(this).visibility??"visible";popup.style.setProperty("visibility",hostVisibility),popup.hidden=!1}try{const visitedContentElements=new Set,elementStates=new Map,accessibilityText=composedAccessibilityTextResult(activeSlot,{shouldPruneNode:node=>{if(node.getRootNode()!==renderRoot&&!this.contains(node)&&snapshot.externalRoots.add(node),node.nodeType!==1)return!1;const element=node;return visitedContentElements.add(element),element.localName==="slot"&&snapshot.forwardingSlots.add(element),element.shadowRoot?snapshot.shadowRoots.add(element.shadowRoot):element.localName.includes("-")&&(snapshot.awaitingShadowRoot=!0),!1},onElementState:(element,state2)=>elementStates.set(element,state2)});for(const element of elementStates.keys())!visitedContentElements.has(element)&&element!==this&&snapshot.composedAncestors.add(element);for(const element of visitedContentElements){const imageMapElement=element.localName==="map"||element.localName==="area";if(imageMapElement){const image=imageMapImageFor(element);image&&snapshot.externalRoots.add(image)}if(!isActionableElement(element))continue;const state2=imageMapElement?void 0:elementStates.get(element);if(state2?.subtreeExcluded??isAccessibilitySubtreeExcluded(element))continue;(state2?.visibilityHidden??isAccessibilityVisibilityHidden(element))||(snapshot.actionable=!0)}snapshot.text=accessibilityText.text.replace(/\s+/g," ").trim();for(const root of accessibilityText.labelReferenceRoots)snapshot.labelReferenceRoots.add(root);for(const id of accessibilityText.labelReferenceIds)snapshot.labelReferenceIds.add(id);for(const reference of accessibilityText.referencedElements)snapshot.referencedElements.add(reference),snapshot.externalRoots.add(reference)}finally{popup&&bypassClosedVisibility&&(previousVisibility?popup.style.setProperty("visibility",previousVisibility,previousVisibilityPriority):popup.style.removeProperty("visibility"),popup.hidden=previousHidden)}return snapshot}observeContentNode(node){if(this.contentObserver){if(node.nodeType===3){this.contentObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.contentObserver.observe(node,{attributes:!0,attributeFilter:["aria-hidden","aria-label","aria-labelledby","alt","class","contenteditable","hidden","href","inert","name","open","role","slot","style","tabindex","usemap"],childList:!0,characterData:!0,subtree:!0})}}get contentNeeded(){return this.open||this.focusDescribesTrigger||this.labelMode==="label"}observeStructureOnly(){this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.cancelShadowContentScan();const observer=this.contentObserver;observer&&(observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}bindContentObservation(snapshot){if(!this.contentNeeded){this.observeStructureOnly();return}if(this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.isConnected&&snapshot.labelReferenceRoots.size>0){const Observer=this.ownerDocument.defaultView?.MutationObserver,cleanups=[...snapshot.labelReferenceRoots].map(root=>subscribeInheritedAttributes(root,Observer,{attributes:["id"],childList:!0,changed:records=>{labelReferenceRecordsMatter(records,snapshot.labelReferenceIds,snapshot.referencedElements)&&this.updateInteractiveContent()}}));this.stopLabelReferenceIdentityObservation=()=>{for(const cleanup of cleanups)cleanup?.()}}if(!this.contentObserver)return;const pendingRecords=this.contentObserver.takeRecords(),pendingMatter=pendingRecords.length>0&&accessibleTextRecordsMatter(this.contentObserver,pendingRecords),observer=this.contentObserver;if(!snapshot.assigned&&!snapshot.blank){observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0});return}bindAccessibleTextObserver(observer,this),pendingMatter&&queueMicrotask(()=>{this.isConnected&&this.contentObserver===observer&&this.updateInteractiveContent()}),this.observeContentNode(this);for(const root of snapshot.externalRoots)this.observeContentNode(root);for(const root of snapshot.shadowRoots)this.observeContentNode(root)}updateInteractiveContent(fromShadowContentScan=!1){fromShadowContentScan||(this.shadowContentScanAttempts=0);const snapshot=this.inspectContent();this.contentSnapshot=snapshot,this.interactiveContent=snapshot.actionable,this.blankContentAssignment=snapshot.blank,this.syncContentSlotListeners(snapshot.forwardingSlots),this.bindContentObservation(snapshot),this.scheduleShadowContentScan(snapshot.awaitingShadowRoot),this.updateDescriptionProxy()}scheduleShadowContentScan(awaitingShadowRoot){if(this.cancelShadowContentScan(!1),!awaitingShadowRoot||!this.open||!this.isConnected||this.shadowContentScanAttempts>=MAX_SHADOW_CONTENT_SCAN_FRAMES)return;const view=this.ownerDocument.defaultView;view&&(this.shadowContentScanView=view,this.shadowContentScanFrame=view.requestAnimationFrame(()=>{this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,this.shadowContentScanAttempts++,this.updateInteractiveContent(!0)}))}cancelShadowContentScan(resetAttempts=!0){this.shadowContentScanFrame!==void 0&&this.shadowContentScanView?.cancelAnimationFrame(this.shadowContentScanFrame),this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,resetAttempts&&(this.shadowContentScanAttempts=0)}ensureDescriptionProxy(){this.descriptionProxy||(this.descriptionProxy=this.ownerDocument.createElement("span"),this.descriptionProxy.id=this.descriptionId,this.descriptionProxy.slot="__lr-tooltip-description",this.descriptionProxy.hidden=!0,this.descriptionProxy.dataset.lyraTooltipDescription=""),this.updateDescriptionProxy()}updateDescriptionProxy(){if(!this.descriptionProxy)return;this.descriptionProxy.parentNode!==this&&this.append(this.descriptionProxy);const hostLabel=this.getAttribute("aria-label"),visibleContent=this.contentSnapshot?.text??"",hasAssignment=this.contentSnapshot?.assigned??!1,description=hostLabel!==null?hostLabel.trim():(this.accessibleLabel||visibleContent||(hasAssignment?"":this.content??"")).trim();this.descriptionProxy.textContent!==description&&(this.descriptionProxy.textContent=description)}render(){const hostLabel=this.getAttribute("aria-label"),propertyLabel=this.accessibleLabel??"",hasExplicitLabel=hostLabel!==null||propertyLabel.length>0,label=hostLabel!==null?hostLabel:propertyLabel,popupLabel=this.interactiveContent?hasExplicitLabel?label:this.localize("popover"):hasExplicitLabel?label:nothing;return html`
1
+ import{__decorate}from"tslib";import{AnchoredDisclosureController}from"../../../internal/anchored-disclosure-controller.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isAccessibilitySubtreeExcluded,isAccessibilityVisibilityHidden,nextId}from"../../../internal/a11y.js";import{resolveAccessibleTrigger}from"../../../internal/accessible-trigger.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{isActionableElement}from"../../../internal/focus-navigation.js";import{imageMapImageFor}from"../../../internal/dom-guards.js";import{deferredPlaceReady as place,syncTopLayerRelease,topLayerPlacement,waitForDeferredPlacement}from"../../../internal/anchored-overlay-runtime.js";import{virtualAnchorFromRect}from"../../../internal/positioner-geometry.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedParentElement,deepActiveElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{parseCssTimeToken}from"../../../internal/css-motion-time.js";import{finiteDuration,finiteNumber}from"../../../internal/numbers.js";import{declaredDefaultConverter,literalSetConverter,omittedEmptyStringConverter,blankNumberConverter}from"../../../internal/converters.js";import{PositioningStrategyState,positioningStrategyConverter,resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{subscribeInheritedAttributes}from"../../../internal/inherited-attribute-hub.js";import{accessibleTextRecordsMatter,bindAccessibleTextObserver,labelReferenceRecordsMatter,composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{applyOverlayArrow}from"./overlay-arrow.js";import{normalizeVirtualRect,OverlayAnchorIdentity,OverlayDelayTimer,resolveOverlayAnchor,resolveOverlayAccessibleTrigger,resolveOverlayInteractionTrigger}from"../../../internal/overlay-shared.js";import{tooltipStyles}from"./overlay.styles.js";import{LYRA_DEFAULT_popover}from"../../../internal/default-strings/overlays.generated.js";const DEFAULT_SHOW_DELAY=150,DEFAULT_HIDE_DELAY=0,DEFAULT_DISTANCE=8,MAX_SHADOW_CONTENT_SCAN_FRAMES=4;function safelyComposedContains(container,candidate){try{return candidate?.nodeType===1&&composedContains(container,candidate)}catch{return!1}}const TOOLTIP_LABEL_MODE=literalSetConverter(["description","label","none"],"description"),BLANK_TEXT=/^[ \t\n\f\r]*$/;function isBlankText(node){return node.nodeType===Node.TEXT_NODE&&BLANK_TEXT.test(node.textContent??"")}class LyraTooltip extends LyraElement{constructor(){super(...arguments),this._open=!1,this.trigger="hover focus",this._labelMode="description",this.manual=!1,this.showDelay=150,this.hideDelay=0,this.placement="top",this.distance=8,this.skidding=0,this._for="",this.anchor=null,this.disabled=!1,this.strategy=new PositioningStrategyState(this),this.topLayer=!1,this.withoutArrow=!1,this.arrowPlacement="anchor",this.arrowPadding=0,this.fullWidthTrigger=!1,this.content="",this.accessibleLabel="",this.namedTriggerMode=!0,this.interactiveContent=!1,this.blankContentAssignment=!1,this.resolvedSide="top",this.anchorPositioned=!1,this.popupHidden=!0,this.directionChanged=!1,this.anchorIdentity=new OverlayAnchorIdentity,this.placementPending=!1,this.delayTimer=new OverlayDelayTimer,this.restoreFocusOnClose=!1,this.suppressTriggerFocusOpen=!1,this.openedByPointer=!1,this.tooltipId=nextId("tooltip"),this.descriptionId=nextId("tooltip-description"),this.focusDescribesTrigger=!1,this.triggerSyncGeneration=0,this.contentSlotListeners=new Set,this.shadowContentScanAttempts=0,this.disclosure=new AnchoredDisclosureController({host:this,isOpen:()=>this._open,setOpen:value=>this.applyOpenState(value),emit:name=>name==="lr-show"||name==="lr-hide"?this.emit(name,null,{cancelable:!0}).defaultPrevented:this.emit(name).defaultPrevented,popup:()=>this.renderRoot.querySelector('[part~="popup"]'),readyToShow:async isCurrent=>{const positioned=await waitForDeferredPlacement(()=>this.cleanup);return isCurrent()&&positioned&&this.anchorPositioned&&!this.placementPending},animate:(showing,popup)=>animateRegistered(this,popup,`tooltip.${showing?"show":"hide"}`,this.effectiveDirection,{keyframes:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:["--lr-transition-fast","--lr-duration-fast"],easingProperties:["--lr-easing-standard"]}),afterHide:()=>{this.popupHidden=!0}}),this.onTriggerSlotChange=event=>{this.syncNamedTriggerMode();const slot=event.target;this.slottedTriggerElement=slot.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()},this.onEnter=event=>{if(!this.disabled){if(event.type==="focusin"){if(this.updateInteractiveContent(),this.opensOn("focus")&&(this.focusDescribesTrigger=!0),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y(),this.suppressTriggerFocusOpen||!this.opensOn("focus")||!isKeyboardFocusEvent(event))return}else{if(this.syncTriggerA11y(),!this.opensOn("hover"))return;this.openedByPointer=!0}this.requestTransition(!0)}},this.onLeave=event=>{if(event.type==="focusout"?!this.opensOn("focus"):!this.opensOn("hover"))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&this.triggerElement&&composedContains(this.triggerElement,next)||(event.type==="focusout"&&(this.focusDescribesTrigger=!1,this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y()),!(this.interactiveContent&&(this.isPopupTarget(next)||this.retainsPopupInteraction(event)))&&this.requestTransition(!1))},this.onTriggerClick=()=>{this.disabled||this.opensOn("click")&&(this.syncTriggerA11y(),this._open?this.hide():this.show())},this.onPopupEnter=()=>{!this.interactiveContent||this.isManual||(this.cancelPendingTransition(),this.show())},this.onPopupLeave=event=>{if(!this.interactiveContent||this.isManual||this.retainsPopupInteraction(event))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&(this.triggerElement&&composedContains(this.triggerElement,next)||this.isPopupTarget(next))||this.requestTransition(!1)},this.onContentSlotChange=event=>{event.target?.localName==="slot"&&this.updateInteractiveContent()}}static{this.defaultStrings={...super.defaultStrings,popover:LYRA_DEFAULT_popover}}static{this.styles=[LyraElement.styles,tooltipStyles]}get open(){return this._open}set open(next){const normalized=!!next;if(normalized||this.cancelPendingTransition(),normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.hide()}}get labelMode(){return this._labelMode}set labelMode(next){this._labelMode=TOOLTIP_LABEL_MODE.normalize(next)}get for(){return this._for}set for(next){this._for=next??""}get positioningStrategy(){return this.strategy.value}set positioningStrategy(next){this.strategy.set(next)}get hoist(){return this.strategy.hoist}set hoist(next){this.strategy.setHoist(next)}get rendersArrow(){return!this.withoutArrow}get activeContentSlot(){const selector=this.namedTriggerMode?'[part~="body"] slot:not([name])':'[part~="body"] slot[name="content"]';return(this.renderRoot??this.shadowRoot)?.querySelector(selector)??null}syncNamedTriggerMode(schedule=!0){const children=Array.from(this.children),hasNamedTrigger=children.some(child=>child.getAttribute("slot")==="trigger"),hasShoelaceContent=(this.content??"").length>0||children.some(child=>child.getAttribute("slot")==="content"),next=hasNamedTrigger||!hasShoelaceContent;if(next===this.namedTriggerMode)return;const old=this.namedTriggerMode;this.namedTriggerMode=next,schedule&&this.hasUpdated&&this.requestUpdate("namedTriggerMode",old)}get triggerKeywords(){return new Set(String(this.trigger??"").trim().split(/\s+/).filter(Boolean))}get isManual(){const keywords=this.triggerKeywords;return this.manual||keywords.size===0||keywords.has("manual")}opensOn(keyword){return!this.isManual&&this.triggerKeywords.has(keyword)}willUpdate(changed){super.willUpdate(changed);const direction=this.effectiveDirection;this.directionChanged=direction!==this.positioningDirection,this.positioningDirection=direction,this.syncNamedTriggerMode(!1),(changed.has("manual")||changed.has("trigger"))&&this.isManual&&this.cancelPendingTransition(),(changed.has("manual")||changed.has("trigger"))&&this.focusDescribesTrigger&&!this.opensOn("focus")&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),changed.has("disabled")&&this.disabled&&(this.cancelPendingTransition(),this.focusDescribesTrigger&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),this._open&&(this.hasUpdated?this.hide():this.applyOpenState(!1))),this.anchorIdentity.lostAnchorProperty(changed,this.anchor)&&this.open&&!this.resolveAnchor()&&this.forceClose(),changed.has("showDelay")&&this.delayTimer.pendingDirection==="show"&&this.requestTransition(!0),changed.has("hideDelay")&&this.delayTimer.pendingDirection==="hide"&&this.requestTransition(!1),changed.has("for")&&this.syncInteractionTrigger(),changed.has("open")&&!this.open&&(this.anchorPositioned=!1),changed.has("open")&&this.open&&(this.popupHidden=!1),changed.has("open")&&this.open&&this.hasUpdated&&this.isConnected&&this.updateInteractiveContent(),changed.has("labelMode")&&this.hasUpdated&&this.isConnected&&(this.contentNeeded?this.updateInteractiveContent():this.observeStructureOnly()),(changed.has("anchor")||changed.has("for"))&&(this.anchorPositioned=!1)}updated(changed){if(super.updated(changed),(changed.has("for")||changed.has("anchor")||changed.has("open"))&&this.syncAnchorIdentityObservation(),this.directionChanged||changed.has("open")||changed.has("placement")||changed.has("distance")||changed.has("skidding")||changed.has("for")||changed.has("anchor")||changed.has("positioningStrategy")||changed.has("topLayer")||changed.has("arrow")||changed.has("withoutArrow")||changed.has("arrowPlacement")||changed.has("arrowPadding")||changed.has("interactiveContent")){if(this.cleanup?.(),this.cleanup=void 0,this.open&&this.isConnected&&this.position(),changed.has("open"))if(this.open)changed.get("open")===void 0?this.updateComplete.then(()=>{this.open&&this.isConnected&&this.updateInteractiveContent()}):this.updateInteractiveContent(),this.isConnected&&this.requiresOverlayManager&&this.activateTooltipOverlay();else{this.positionedAnchor=void 0;const restoreFocus=this.restoreFocusOnClose;this.suppressTriggerFocusOpen=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.suppressTriggerFocusOpen=!1}this.overlayHandle=void 0,this.restoreFocusOnClose=!1,this.virtualAnchor=void 0,this.returnFocusTo=void 0,this.syncInteractionTrigger(),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot)}else changed.has("interactiveContent")&&this.open&&this.isConnected&&this.activateTooltipOverlay();this.syncTriggerA11y()}changed.has("labelMode")&&this.syncTriggerA11y(),(changed.has("content")||changed.has("accessibleLabel"))&&this.updateDescriptionProxy()}connectedCallback(){super.connectedCallback();const triggerSyncGeneration=++this.triggerSyncGeneration,triggerSyncDocument=this.ownerDocument;this.syncAnchorIdentityObservation(),this.ensureDescriptionProxy(),this.contentObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.contentObserver=MutationObserverCtor?new MutationObserverCtor((records,observer)=>{if(!this.contentNeeded){this.syncNamedTriggerMode();return}accessibleTextRecordsMatter(observer,records)&&(this.syncNamedTriggerMode(),this.updateInteractiveContent())}):void 0,this.updateInteractiveContent(),this.syncInteractionTrigger(),this.updateComplete.then(()=>{if(triggerSyncGeneration!==this.triggerSyncGeneration||!this.isConnected||this.ownerDocument!==triggerSyncDocument)return;const slot=this.renderRoot.querySelector('[part="trigger"] > slot');this.slottedTriggerElement=slot?.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()}),this.hasUpdated&&this.open&&(this.popupHidden=!1,this.position(),this.requiresOverlayManager&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateTooltipOverlay()))}disconnectedCallback(){this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.suspend(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.releaseTriggerA11y(),this.focusDescribesTrigger=!1,this.triggerElement=void 0,this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.cancelShadowContentScan(),this.disclosure.reset(),this.popupHidden=!0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cancelShadowContentScan(),this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.releaseTriggerA11y()}syncAnchorIdentityObservation(){this.anchorIdentity.stop();const directAnchor=this.open?this.anchor??void 0:void 0;this.anchorIdentity.observe(this,directAnchor,this.for,()=>this.anchor,directAnchorRemoved=>{if((this.resolveInteractionTrigger()!==this.triggerElement||this.open||this.focusDescribesTrigger)&&this.syncInteractionTrigger(),!this.open)return;const nextAnchor=this.resolveAnchor();if(directAnchorRemoved&&!nextAnchor){this.forceClose();return}nextAnchor!==this.positionedAnchor&&this.position()})}resolveInteractionTrigger(){return resolveOverlayInteractionTrigger(this,this.virtualAnchor,this.slottedTriggerElement,this.for)}syncInteractionTrigger(){const next=this.resolveInteractionTrigger();this.adoptTrigger(next)}activateTooltipOverlay(){if(!this.isConnected)return;const restoreFocusTarget=this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger;if(this.overlayHandle?.isActive()){this.overlayHandle.updateRestoreFocusTo(restoreFocusTarget);return}this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part~="popup"]'),onEscape:()=>{this.hide({restoreFocus:this.shouldRestoreFocusAfterEscape()})},restoreFocusTo:restoreFocusTarget}),this.overlayHandle.focusAutofocus()}shouldRestoreFocusAfterEscape(){if(this.virtualAnchor)return this.returnFocusTo!==void 0;const active=deepActiveElementIn(this.ownerDocument);return safelyComposedContains(this,active)}get requiresOverlayManager(){return this.open}showAt(rect,options){const normalizedRect=normalizeVirtualRect(rect);if(!normalizedRect)return;const previousAnchor=this.virtualAnchor,previousReturnFocusTo=this.returnFocusTo;if(this.virtualAnchor=virtualAnchorFromRect(normalizedRect),this.returnFocusTo=options?.returnFocusTo,this.syncInteractionTrigger(),this.open){this.activateTooltipOverlay(),this.position();return}this.show(),!this.open&&(this.virtualAnchor=previousAnchor,this.returnFocusTo=previousReturnFocusTo,this.syncInteractionTrigger())}show(){return this.cancelPendingTransition(),this.disabled?Promise.resolve():this.disclosure.show()}hide(options){return this.cancelPendingTransition(),this.disclosure.hide(()=>{options?.restoreFocus&&(this.restoreFocusOnClose=!0)})}forceClose(){return this.cancelPendingTransition(),this.disclosure.forceClose()}applyOpenState(next){const old=this._open;this._open=next,next||(this.cancelShadowContentScan(),this.placementPending=!1),next||(this.openedByPointer=!1),this.requestUpdate("open",old)}resolveAnchor(){return resolveOverlayAnchor(this,{virtualAnchor:this.virtualAnchor,anchor:this.anchor,for:this.for,trigger:this.triggerElement})}position(){this.cleanup?.(),this.cleanup=void 0;const popup=this.renderRoot.querySelector('[part~="popup"]'),arrowElement=this.renderRoot.querySelector('[part~="arrow"]'),anchor=this.resolveAnchor();if(!this.open||!anchor||!popup){this.positionedAnchor=void 0,this.anchorPositioned=!1,this.placementPending=!1;return}if(anchor!==this.positionedAnchor&&(this.anchorPositioned=!1),this.open&&anchor&&popup){const arrowPadding=Math.max(0,finiteNumber(this.arrowPadding,0));this.placementPending=!0,this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,this.topLayer);const operation=place(anchor,popup,{placement:rtlAwarePlacement(this.placement,this),...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this.strategy.authored,"absolute")),offset:finiteNumber(this.distance,DEFAULT_DISTANCE),skidding:finiteNumber(this.skidding,0),arrow:this.rendersArrow&&arrowElement?arrowElement:void 0,arrowPadding,onPlaced:({placement,arrow})=>{this.placementPending=!1,this.positionedAnchor=anchor,this.anchorPositioned=!0;const side=applyOverlayArrow(arrowElement,{placement,coords:arrow,enabled:this.rendersArrow,arrowPlacement:this.arrowPlacement,arrowPadding,rtl:this.effectiveDirection==="rtl",sizeProperty:"--arrow-size",fallbackSizeProperty:"--lr-tooltip-arrow-size"});side!==this.resolvedSide&&(this.resolvedSide=side)}});this.cleanup=operation,operation.ready.then(positioned=>{!positioned&&this.cleanup===operation&&this.open&&(this.restoreFocusOnClose=safelyComposedContains(this,deepActiveElementIn(this.ownerDocument)),this.forceClose())})}}syncTriggerA11y(){const trigger=this.triggerElement??null,proxy=this.descriptionProxy,contribution={labels:proxy&&this.labelMode==="label"?[proxy]:[],descriptions:proxy&&this.labelMode==="description"&&(this.open||this.focusDescribesTrigger)?[proxy]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution);const accessibleTrigger=this.accessibleTrigger;this.observeTriggerTarget(contribution.labels.length||contribution.descriptions.length?trigger:null,accessibleTrigger);const distinctAccessibleTrigger=accessibleTrigger!==trigger?accessibleTrigger:null;this.accessibleTriggerAria?this.accessibleTriggerAria.update(distinctAccessibleTrigger,contribution):this.accessibleTriggerAria=acquireAriaOwnership(distinctAccessibleTrigger,contribution),this.overlayHandle?.isActive()&&!this.virtualAnchor&&this.overlayHandle.updateRestoreFocusTo(accessibleTrigger)}observeTriggerTarget(trigger,control){if(this.triggerTargetObserver?.disconnect(),!trigger||!this.isConnected){this.triggerTargetUpgrades?.disconnect();return}this.triggerTargetUpgrades??=new CustomElementUpgradeObserver(()=>this.syncTriggerA11y()),this.triggerTargetUpgrades.observeElement(trigger);const Observer=this.ownerDocument.defaultView?.MutationObserver;if(!Observer)return;this.triggerTargetObserver??=new Observer(()=>this.syncTriggerA11y());const options={childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-disabled","aria-hidden","class","disabled","hidden","href","inert","name","role","slot","style","tabindex","type"]};this.triggerTargetObserver.observe(trigger,options);for(let node=control;node&&(node.shadowRoot&&this.triggerTargetObserver.observe(node.shadowRoot,options),node!==trigger);node=composedParentElement(node));}get accessibleTrigger(){return this.triggerElement?this.labelMode==="label"?resolveOverlayAccessibleTrigger(this.triggerElement):resolveAccessibleTrigger(this.triggerElement):null}releaseTriggerA11y(){this.triggerTargetObserver?.disconnect(),this.triggerTargetObserver=void 0,this.triggerTargetUpgrades?.disconnect(),this.triggerTargetUpgrades=void 0,this.accessibleTriggerAria?.release(),this.accessibleTriggerAria=void 0,this.triggerAria?.release(),this.triggerAria=void 0}requestTransition(next){if(this.cancelPendingTransition(),this.disabled)return;const delay=this.interactionDelay(next);if(delay<=0){next?this.show():this.hide();return}const view=this.ownerDocument.defaultView;view&&this.delayTimer.schedule(view,delay,next?"show":"hide",()=>{next?this.show():this.hide()})}interactionDelay(showing){const value=showing?this.showDelay:this.hideDelay,fallback=showing?DEFAULT_SHOW_DELAY:DEFAULT_HIDE_DELAY,attribute=showing?"show-delay":"hide-delay";if(this.hasAttribute(attribute)||value!==fallback)return finiteDuration(value,fallback);const property2=showing?"--show-delay":"--hide-delay",raw=this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(property2).trim()??"",token=parseCssTimeToken(raw);return token&&!token.rest?finiteDuration(token.ms,fallback):fallback}cancelPendingTransition(){this.delayTimer.cancel()}bindTrigger(trigger){trigger.addEventListener("mouseenter",this.onEnter),trigger.addEventListener("mouseleave",this.onLeave),trigger.addEventListener("focusin",this.onEnter),trigger.addEventListener("focusout",this.onLeave),trigger.addEventListener("click",this.onTriggerClick)}unbindTrigger(trigger){trigger.removeEventListener("mouseenter",this.onEnter),trigger.removeEventListener("mouseleave",this.onLeave),trigger.removeEventListener("focusin",this.onEnter),trigger.removeEventListener("focusout",this.onLeave),trigger.removeEventListener("click",this.onTriggerClick),this.focusDescribesTrigger=!1}isTriggerHeld(trigger){try{if(trigger.matches(":hover"))return!0}catch{}const active=deepActiveElementIn(trigger.ownerDocument);return safelyComposedContains(trigger,active)}adoptTrigger(next){if(next===this.triggerElement){this.syncTriggerA11y();return}const hadTrigger=this.triggerElement!==void 0;if(this.cancelPendingTransition(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.triggerElement=next,!this.triggerElement){this.syncTriggerA11y(),hadTrigger&&this.open&&!this.resolveAnchor()&&this.forceClose();return}this.bindTrigger(this.triggerElement),this.syncTriggerA11y(),hadTrigger&&this._open&&this.openedByPointer&&!this.isTriggerHeld(this.triggerElement)&&this.forceClose(),this.open&&this.position(),this.open&&this.interactiveContent&&this.activateTooltipOverlay()}retainsPopupInteraction(event){return event.type==="mouseleave"?this.isPopupTarget(deepActiveElementIn(this.ownerDocument)):this.opensOn("hover")&&(this.triggerElement?.matches(":hover")===!0||this.renderRoot.querySelector('[part~="popup"]:hover')!==null)}isPopupTarget(target){if(target===null||target.nodeType!==1)return!1;const element=target,slot=this.activeContentSlot;return this.renderRoot.querySelector('[part~="popup"]')?.contains(element)===!0||slot?.assignedElements({flatten:!0}).some(root=>composedContains(root,element))===!0}clearContentSlotListeners(){for(const slot of this.contentSlotListeners)slot.removeEventListener("slotchange",this.onContentSlotChange);this.contentSlotListeners.clear()}syncContentSlotListeners(slots){const activeSlot=this.activeContentSlot;for(const slot of this.contentSlotListeners)slots.has(slot)&&slot!==activeSlot||(slot.removeEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.delete(slot));for(const slot of slots)slot===activeSlot||this.contentSlotListeners.has(slot)||(slot.addEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.add(slot))}inspectContent(){const snapshot={actionable:!1,assigned:!1,blank:!1,awaitingShadowRoot:!1,labelReferenceRoots:new Set,labelReferenceIds:new Set,referencedElements:new Set,text:"",externalRoots:new Set,shadowRoots:new Set,forwardingSlots:new Set,composedAncestors:new Set},activeSlot=this.activeContentSlot;if(!activeSlot)return snapshot;const renderRoot=this.renderRoot??this.shadowRoot,assignedNodes=activeSlot.assignedNodes();if(snapshot.assigned=assignedNodes.some(node=>!isBlankText(node)),snapshot.blank=assignedNodes.length>0&&!snapshot.assigned,!snapshot.assigned)return snapshot;const popup=renderRoot?.querySelector('[part~="popup"]'),bypassClosedVisibility=popup?.hasAttribute("data-hidden")===!0||this.placementPending,previousVisibility=popup?.style.getPropertyValue("visibility")??"",previousVisibilityPriority=popup?.style.getPropertyPriority("visibility")??"",previousHidden=popup?.hidden??!1;if(popup&&bypassClosedVisibility){const hostVisibility=this.ownerDocument.defaultView?.getComputedStyle(this).visibility??"visible";popup.style.setProperty("visibility",hostVisibility),popup.hidden=!1}try{const visitedContentElements=new Set,elementStates=new Map,accessibilityText=composedAccessibilityTextResult(activeSlot,{shouldPruneNode:node=>{if(node.getRootNode()!==renderRoot&&!this.contains(node)&&snapshot.externalRoots.add(node),node.nodeType!==1)return!1;const element=node;return visitedContentElements.add(element),element.localName==="slot"&&snapshot.forwardingSlots.add(element),element.shadowRoot?snapshot.shadowRoots.add(element.shadowRoot):element.localName.includes("-")&&(snapshot.awaitingShadowRoot=!0),!1},onElementState:(element,state2)=>elementStates.set(element,state2)});for(const element of elementStates.keys())!visitedContentElements.has(element)&&element!==this&&snapshot.composedAncestors.add(element);for(const element of visitedContentElements){const imageMapElement=element.localName==="map"||element.localName==="area";if(imageMapElement){const image=imageMapImageFor(element);image&&snapshot.externalRoots.add(image)}if(!isActionableElement(element))continue;const state2=imageMapElement?void 0:elementStates.get(element);if(state2?.subtreeExcluded??isAccessibilitySubtreeExcluded(element))continue;(state2?.visibilityHidden??isAccessibilityVisibilityHidden(element))||(snapshot.actionable=!0)}snapshot.text=accessibilityText.text.replace(/\s+/g," ").trim();for(const root of accessibilityText.labelReferenceRoots)snapshot.labelReferenceRoots.add(root);for(const id of accessibilityText.labelReferenceIds)snapshot.labelReferenceIds.add(id);for(const reference of accessibilityText.referencedElements)snapshot.referencedElements.add(reference),snapshot.externalRoots.add(reference)}finally{popup&&bypassClosedVisibility&&(previousVisibility?popup.style.setProperty("visibility",previousVisibility,previousVisibilityPriority):popup.style.removeProperty("visibility"),popup.hidden=previousHidden)}return snapshot}observeContentNode(node){if(this.contentObserver){if(node.nodeType===3){this.contentObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.contentObserver.observe(node,{attributes:!0,attributeFilter:["aria-hidden","aria-label","aria-labelledby","alt","class","contenteditable","hidden","href","inert","name","open","role","slot","style","tabindex","usemap"],childList:!0,characterData:!0,subtree:!0})}}get contentNeeded(){return this.open||this.focusDescribesTrigger||this.labelMode==="label"}observeStructureOnly(){this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.cancelShadowContentScan();const observer=this.contentObserver;observer&&(observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}bindContentObservation(snapshot){if(!this.contentNeeded){this.observeStructureOnly();return}if(this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.isConnected&&snapshot.labelReferenceRoots.size>0){const Observer=this.ownerDocument.defaultView?.MutationObserver,cleanups=[...snapshot.labelReferenceRoots].map(root=>subscribeInheritedAttributes(root,Observer,{attributes:["id"],childList:!0,changed:records=>{labelReferenceRecordsMatter(records,snapshot.labelReferenceIds,snapshot.referencedElements)&&this.updateInteractiveContent()}}));this.stopLabelReferenceIdentityObservation=()=>{for(const cleanup of cleanups)cleanup?.()}}if(!this.contentObserver)return;const pendingRecords=this.contentObserver.takeRecords(),pendingMatter=pendingRecords.length>0&&accessibleTextRecordsMatter(this.contentObserver,pendingRecords),observer=this.contentObserver;if(!snapshot.assigned&&!snapshot.blank){observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0});return}bindAccessibleTextObserver(observer,this),pendingMatter&&queueMicrotask(()=>{this.isConnected&&this.contentObserver===observer&&this.updateInteractiveContent()}),this.observeContentNode(this);for(const root of snapshot.externalRoots)this.observeContentNode(root);for(const root of snapshot.shadowRoots)this.observeContentNode(root)}updateInteractiveContent(fromShadowContentScan=!1){fromShadowContentScan||(this.shadowContentScanAttempts=0);const snapshot=this.inspectContent();this.contentSnapshot=snapshot,this.interactiveContent=snapshot.actionable,this.blankContentAssignment=snapshot.blank,this.syncContentSlotListeners(snapshot.forwardingSlots),this.bindContentObservation(snapshot),this.scheduleShadowContentScan(snapshot.awaitingShadowRoot),this.updateDescriptionProxy()}scheduleShadowContentScan(awaitingShadowRoot){if(this.cancelShadowContentScan(!1),!awaitingShadowRoot||!this.open||!this.isConnected||this.shadowContentScanAttempts>=MAX_SHADOW_CONTENT_SCAN_FRAMES)return;const view=this.ownerDocument.defaultView;view&&(this.shadowContentScanView=view,this.shadowContentScanFrame=view.requestAnimationFrame(()=>{this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,this.shadowContentScanAttempts++,this.updateInteractiveContent(!0)}))}cancelShadowContentScan(resetAttempts=!0){this.shadowContentScanFrame!==void 0&&this.shadowContentScanView?.cancelAnimationFrame(this.shadowContentScanFrame),this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,resetAttempts&&(this.shadowContentScanAttempts=0)}ensureDescriptionProxy(){this.descriptionProxy||(this.descriptionProxy=this.ownerDocument.createElement("span"),this.descriptionProxy.id=this.descriptionId,this.descriptionProxy.slot="__lr-tooltip-description",this.descriptionProxy.hidden=!0,this.descriptionProxy.dataset.lyraTooltipDescription=""),this.updateDescriptionProxy()}updateDescriptionProxy(){if(!this.descriptionProxy)return;this.descriptionProxy.parentNode!==this&&this.append(this.descriptionProxy);const hostLabel=this.getAttribute("aria-label"),visibleContent=this.contentSnapshot?.text??"",hasAssignment=this.contentSnapshot?.assigned??!1,description=hostLabel!==null?hostLabel.trim():(this.accessibleLabel||visibleContent||(hasAssignment?"":this.content??"")).trim();this.descriptionProxy.textContent!==description&&(this.descriptionProxy.textContent=description)}render(){const hostLabel=this.getAttribute("aria-label"),propertyLabel=this.accessibleLabel??"",hasExplicitLabel=hostLabel!==null||propertyLabel.length>0,label=hostLabel!==null?hostLabel:propertyLabel,popupLabel=this.interactiveContent?hasExplicitLabel?label:this.localize("popover"):hasExplicitLabel?label:nothing;return html`
2
2
  <span part="trigger">
3
3
  ${this.namedTriggerMode?html`<slot name="trigger" @slotchange=${this.onTriggerSlotChange}></slot>`:html`<slot @slotchange=${this.onTriggerSlotChange}></slot>`}
4
4
  </span>
@@ -9,4 +9,4 @@ import{__decorate}from"tslib";import{AnchoredDisclosureController}from"../../../
9
9
  </span>
10
10
  ${this.rendersArrow?html`<span part="arrow base__arrow tooltip__arrow arrow-${this.resolvedSide}"></span>`:nothing}
11
11
  </div>
12
- `}}__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"open",null),__decorate([property({converter:declaredDefaultConverter("hover focus")})],LyraTooltip.prototype,"trigger",void 0),__decorate([property({attribute:"label-mode",converter:TOOLTIP_LABEL_MODE})],LyraTooltip.prototype,"labelMode",null),__decorate([property({type:Boolean})],LyraTooltip.prototype,"manual",void 0),__decorate([property({converter:blankNumberConverter(150),attribute:"show-delay"})],LyraTooltip.prototype,"showDelay",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"hide-delay"})],LyraTooltip.prototype,"hideDelay",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("top")})],LyraTooltip.prototype,"placement",void 0),__decorate([property({converter:blankNumberConverter(8)})],LyraTooltip.prototype,"distance",void 0),__decorate([property({converter:blankNumberConverter(0)})],LyraTooltip.prototype,"skidding",void 0),__decorate([property({reflect:!0,converter:omittedEmptyStringConverter})],LyraTooltip.prototype,"for",null),__decorate([property({attribute:!1})],LyraTooltip.prototype,"anchor",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"disabled",void 0),__decorate([property({attribute:"positioning-strategy",reflect:!0,converter:positioningStrategyConverter})],LyraTooltip.prototype,"positioningStrategy",null),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"hoist",null),__decorate([property({type:Boolean,attribute:"top-layer",reflect:!0})],LyraTooltip.prototype,"topLayer",void 0),__decorate([property({type:Boolean,attribute:"without-arrow",reflect:!0})],LyraTooltip.prototype,"withoutArrow",void 0),__decorate([property({attribute:"arrow-placement"})],LyraTooltip.prototype,"arrowPlacement",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"arrow-padding"})],LyraTooltip.prototype,"arrowPadding",void 0),__decorate([property()],LyraTooltip.prototype,"content",void 0),__decorate([property({attribute:"aria-label"})],LyraTooltip.prototype,"accessibleLabel",void 0),__decorate([state()],LyraTooltip.prototype,"interactiveContent",void 0),__decorate([state()],LyraTooltip.prototype,"blankContentAssignment",void 0),__decorate([state()],LyraTooltip.prototype,"resolvedSide",void 0),__decorate([state()],LyraTooltip.prototype,"anchorPositioned",void 0),__decorate([state()],LyraTooltip.prototype,"popupHidden",void 0);export{LyraTooltip};
12
+ `}}__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"open",null),__decorate([property({converter:declaredDefaultConverter("hover focus")})],LyraTooltip.prototype,"trigger",void 0),__decorate([property({attribute:"label-mode",converter:TOOLTIP_LABEL_MODE})],LyraTooltip.prototype,"labelMode",null),__decorate([property({type:Boolean})],LyraTooltip.prototype,"manual",void 0),__decorate([property({converter:blankNumberConverter(150),attribute:"show-delay"})],LyraTooltip.prototype,"showDelay",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"hide-delay"})],LyraTooltip.prototype,"hideDelay",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("top")})],LyraTooltip.prototype,"placement",void 0),__decorate([property({converter:blankNumberConverter(8)})],LyraTooltip.prototype,"distance",void 0),__decorate([property({converter:blankNumberConverter(0)})],LyraTooltip.prototype,"skidding",void 0),__decorate([property({reflect:!0,converter:omittedEmptyStringConverter})],LyraTooltip.prototype,"for",null),__decorate([property({attribute:!1})],LyraTooltip.prototype,"anchor",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"disabled",void 0),__decorate([property({attribute:"positioning-strategy",reflect:!0,converter:positioningStrategyConverter})],LyraTooltip.prototype,"positioningStrategy",null),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"hoist",null),__decorate([property({type:Boolean,attribute:"top-layer",reflect:!0})],LyraTooltip.prototype,"topLayer",void 0),__decorate([property({type:Boolean,attribute:"without-arrow",reflect:!0})],LyraTooltip.prototype,"withoutArrow",void 0),__decorate([property({attribute:"arrow-placement"})],LyraTooltip.prototype,"arrowPlacement",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"arrow-padding"})],LyraTooltip.prototype,"arrowPadding",void 0),__decorate([property({type:Boolean,attribute:"full-width-trigger",reflect:!0})],LyraTooltip.prototype,"fullWidthTrigger",void 0),__decorate([property()],LyraTooltip.prototype,"content",void 0),__decorate([property({attribute:"aria-label"})],LyraTooltip.prototype,"accessibleLabel",void 0),__decorate([state()],LyraTooltip.prototype,"interactiveContent",void 0),__decorate([state()],LyraTooltip.prototype,"blankContentAssignment",void 0),__decorate([state()],LyraTooltip.prototype,"resolvedSide",void 0),__decorate([state()],LyraTooltip.prototype,"anchorPositioned",void 0),__decorate([state()],LyraTooltip.prototype,"popupHidden",void 0);export{LyraTooltip};
@@ -59,7 +59,7 @@ export type LyraToastSize=LyraSize;export interface LyraToastItemEventMap{'lr-sh
59
59
  * follows `size` across the shared six-step ladder; an inherited or direct public value wins.
60
60
  * @cssprop [--lr-toast-item-gap=var(--lr-space-s)] - Gap between the item icon, message, and close
61
61
  * button. Unlike `--lr-toast-gap`, this does not affect spacing between stacked items.
62
- * @cssprop [--lr-toast-item-radius=var(--lr-radius)] - Corner radius of the item surface and its
62
+ * @cssprop [--lr-toast-item-radius=var(--lr-radius-container)] - Corner radius of the item surface and its
63
63
  * accent bar's inline-start corners.
64
64
  * Pointer-state hooks are inline fallbacks, so they inherit from the item or an ancestor without
65
65
  * recoloring the item surface or the stack.
@@ -79,7 +79,7 @@ export type LyraToastSize=LyraSize;export interface LyraToastItemEventMap{'lr-sh
79
79
  * @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge of the item.
80
80
  * @cssprop [--lr-overlay-shadow-modal=var(--lr-shadow-l)] - Shared modal elevation of the item; its
81
81
  * default is the lower modal step, below lr-dialog's.
82
- * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, behind
82
+ * @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, behind
83
83
  * `--lr-toast-item-radius`.
84
84
  * @cssprop --lr-icon-button-bg - Resting background of the icon-only action buttons.
85
85
  * @cssprop --lr-icon-button-active-bg - Pressed background of the icon-only action buttons.
@@ -1 +1 @@
1
- import{iconAction,iconActionHover,iconActionActive}from"../../../internal/icon-action.styles.js";import{activeFill,disabledControl,focusRing,iconHitTarget}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{overlaySurfaceFill}from"../../../internal/overlay-surface.styles.js";const styles=css` :host{display:block;--_lr-toast-accent-width:var(--accent-width, var(--lr-size-4px));--_lr-toast-show-duration:var( --show-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-hide-duration:var( --hide-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m);--_lr-toast-accent-color:var(--lr-color-border)}:host([variant]:not([variant=neutral])){--_lr-toast-accent-color:var(--lr-color-fill-loud)}:host([data-effective-size="2xs"]){--_lr-toast-padding:var(--padding, var(--lr-space-2xs));--_lr-toast-font-size:var(--lr-font-size-2xs)}:host([data-effective-size=xs]){--_lr-toast-padding:var(--padding, var(--lr-space-xs));--_lr-toast-font-size:var(--lr-font-size-xs)}:host([data-effective-size=s]){--_lr-toast-padding:var(--padding, var(--lr-space-s));--_lr-toast-font-size:var(--lr-font-size-md-sm)}:host([data-effective-size=m]){--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m)}:host([data-effective-size=l]){--_lr-toast-padding:var(--padding, var(--lr-space-l));--_lr-toast-font-size:var(--lr-font-size-lg)}:host([data-effective-size=xl]){--_lr-toast-padding:var(--padding, calc(var(--lr-space-l) * 1.5));--_lr-toast-font-size:var(--lr-font-size-xl)}[part=toast-item]{position:relative;display:flex;align-items:start;gap:var(--lr-toast-item-gap,var(--lr-space-s));inline-size:100%;padding:var(--lr-toast-padding,var(--_lr-toast-padding));padding-inline-start:calc(var(--lr-toast-padding,var(--_lr-toast-padding)) + var(--lr-toast-accent-width,var(--_lr-toast-accent-width)));font-size:var(--lr-toast-font-size,var(--_lr-toast-font-size));${overlaySurfaceFill} color:var(--lr-color-text);border-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius)));box-shadow:var(--lr-overlay-shadow-modal,var(--lr-shadow-l));opacity:0;transform:translateY(var(--lr-size-neg-8px));transition:opacity var(--lr-toast-show-duration,var(--_lr-toast-show-duration)),transform var(--lr-toast-show-duration,var(--_lr-toast-show-duration))}[part=toast-item][hidden]{display:none}:host([data-hiding]) [part=toast-item]{transition:opacity var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration)),transform var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration))}:host([data-visible]) [part=toast-item]{opacity:1;transform:none}@media (prefers-reduced-motion:reduce){[part=toast-item]{transition-duration:0.01ms!important}}[part=accent]{position:absolute;inset-block:0;inset-inline-start:0;inline-size:var(--lr-toast-accent-width,var(--_lr-toast-accent-width));background:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));border-start-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius)));border-end-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius)))}[part=icon]{display:inline-flex;flex:0 1 auto;min-inline-size:0;max-inline-size:var(--lr-icon-button-size);overflow:hidden;color:var(--lr-toast-accent-color,var(--_lr-toast-accent-color))}[part=icon] ::slotted(*){max-inline-size:100%}[part=content]{flex:1 1 auto;min-inline-size:0;overflow-wrap:anywhere;unicode-bidi:plaintext}::slotted(button){display:inline-block;margin-inline:var(--lr-space-s)!important;padding:0;border:none;background:none;font:inherit;font-weight:var(--lr-font-weight-bold);color:var(--lr-color-on-quiet);text-decoration:underline;cursor:pointer}::slotted(button:hover){color:var(--lr-color-text)}::slotted(button:focus-visible){${focusRing}}::slotted([hidden]:not([hidden="until-found" i])){display:none}[part=close-button]{${iconAction} --_lr-icon-button-color-default:var(--lr-color-text-quiet);--_lr-icon-button-color-hover-default:var(--lr-toast-close-button-hover-color, var(--lr-color-text));--_lr-icon-button-color-active-default:var(--lr-toast-close-button-active-color, var(--lr-color-text));--_lr-icon-button-background-hover-default:var(--lr-toast-close-button-hover-bg, transparent);--_lr-icon-button-background-active-default:var(--lr-toast-close-button-active-bg, ${activeFill("transparent")});position:relative;display:inline-grid;place-items:center;flex:0 0 auto;margin-inline-start:auto;font-size:var(--lr-size-1em);line-height:var(--lr-line-height-none);padding:var(--lr-space-xs);${iconHitTarget}}[part=progress-ring]{position:relative;display:inline-grid;place-items:center;inline-size:var(--lr-size-24px);block-size:var(--lr-size-24px);pointer-events:none}[part~=progress-ring__base]{position:absolute;inset:0;inline-size:100%;block-size:100%;overflow:visible;fill:none;transform:rotate(-90deg)}[part=progress-ring__track],[part=progress-ring__indicator]{fill:none;stroke-width:var(--lr-border-width-medium)}[part=progress-ring__track]{stroke:var(--lr-color-border)}[part=progress-ring__indicator]{stroke:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:0;animation-timing-function:linear;animation-fill-mode:forwards}:host([data-visible]) [part=progress-ring__indicator]{animation-name:var(--_lr-motion-animation,lr-toast-progress)}:host(:hover) [part=progress-ring__indicator],:host(:focus-within) [part=progress-ring__indicator]{animation-play-state:paused}[part=progress-ring__label],[part=close-icon]{display:inline-flex;align-items:center;justify-content:center}[part=close-icon__svg]{display:block}[part=close-button]:where(:hover):where(:not([aria-disabled=true])){${iconActionHover}}[part=close-button]:where(:active):where(:not([aria-disabled=true])){${iconActionActive}}[part=close-button][aria-disabled=true]{${disabledControl}}[part=close-button]:focus-visible{${focusRing}}@keyframes lr-toast-progress{to{stroke-dashoffset:1}}@media (prefers-reduced-motion:reduce){[part=progress-ring__indicator]{animation:none!important;stroke-dashoffset:1}}${glassSurface('[part="toast-item"]',css`var(--lr-overlay-surface, var(--lr-color-surface-container-high))`)} `;export{styles};
1
+ import{iconAction,iconActionHover,iconActionActive}from"../../../internal/icon-action.styles.js";import{activeFill,disabledControl,focusRing,iconHitTarget}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{overlaySurfaceFill}from"../../../internal/overlay-surface.styles.js";const styles=css` :host{display:block;--_lr-toast-accent-width:var(--accent-width, var(--lr-size-4px));--_lr-toast-show-duration:var( --show-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-hide-duration:var( --hide-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m);--_lr-toast-accent-color:var(--lr-color-border)}:host([variant]:not([variant=neutral])){--_lr-toast-accent-color:var(--lr-color-fill-loud)}:host([data-effective-size="2xs"]){--_lr-toast-padding:var(--padding, var(--lr-space-2xs));--_lr-toast-font-size:var(--lr-font-size-2xs)}:host([data-effective-size=xs]){--_lr-toast-padding:var(--padding, var(--lr-space-xs));--_lr-toast-font-size:var(--lr-font-size-xs)}:host([data-effective-size=s]){--_lr-toast-padding:var(--padding, var(--lr-space-s));--_lr-toast-font-size:var(--lr-font-size-md-sm)}:host([data-effective-size=m]){--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m)}:host([data-effective-size=l]){--_lr-toast-padding:var(--padding, var(--lr-space-l));--_lr-toast-font-size:var(--lr-font-size-lg)}:host([data-effective-size=xl]){--_lr-toast-padding:var(--padding, calc(var(--lr-space-l) * 1.5));--_lr-toast-font-size:var(--lr-font-size-xl)}[part=toast-item]{position:relative;display:flex;align-items:start;gap:var(--lr-toast-item-gap,var(--lr-space-s));inline-size:100%;padding:var(--lr-toast-padding,var(--_lr-toast-padding));padding-inline-start:calc(var(--lr-toast-padding,var(--_lr-toast-padding)) + var(--lr-toast-accent-width,var(--_lr-toast-accent-width)));font-size:var(--lr-toast-font-size,var(--_lr-toast-font-size));${overlaySurfaceFill} color:var(--lr-color-text);border-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius-container)));box-shadow:var(--lr-overlay-shadow-modal,var(--lr-shadow-l));opacity:0;transform:translateY(var(--lr-size-neg-8px));transition:opacity var(--lr-toast-show-duration,var(--_lr-toast-show-duration)),transform var(--lr-toast-show-duration,var(--_lr-toast-show-duration))}[part=toast-item][hidden]{display:none}:host([data-hiding]) [part=toast-item]{transition:opacity var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration)),transform var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration))}:host([data-visible]) [part=toast-item]{opacity:1;transform:none}@media (prefers-reduced-motion:reduce){[part=toast-item]{transition-duration:0.01ms!important}}[part=accent]{position:absolute;inset-block:0;inset-inline-start:0;inline-size:var(--lr-toast-accent-width,var(--_lr-toast-accent-width));background:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));border-start-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius-container)));border-end-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius-container)))}[part=icon]{display:inline-flex;flex:0 1 auto;min-inline-size:0;max-inline-size:var(--lr-icon-button-size);overflow:hidden;color:var(--lr-toast-accent-color,var(--_lr-toast-accent-color))}[part=icon] ::slotted(*){max-inline-size:100%}[part=content]{flex:1 1 auto;min-inline-size:0;overflow-wrap:anywhere;unicode-bidi:plaintext}::slotted(button){display:inline-block;margin-inline:var(--lr-space-s)!important;padding:0;border:none;background:none;font:inherit;font-weight:var(--lr-font-weight-bold);color:var(--lr-color-on-quiet);text-decoration:underline;cursor:pointer}::slotted(button:hover){color:var(--lr-color-text)}::slotted(button:focus-visible){${focusRing}}::slotted([hidden]:not([hidden="until-found" i])){display:none}[part=close-button]{${iconAction} --_lr-icon-button-color-default:var(--lr-color-text-quiet);--_lr-icon-button-color-hover-default:var(--lr-toast-close-button-hover-color, var(--lr-color-text));--_lr-icon-button-color-active-default:var(--lr-toast-close-button-active-color, var(--lr-color-text));--_lr-icon-button-background-hover-default:var(--lr-toast-close-button-hover-bg, transparent);--_lr-icon-button-background-active-default:var(--lr-toast-close-button-active-bg, ${activeFill("transparent")});position:relative;display:inline-grid;place-items:center;flex:0 0 auto;margin-inline-start:auto;font-size:var(--lr-size-1em);line-height:var(--lr-line-height-none);padding:var(--lr-space-xs);${iconHitTarget}}[part=progress-ring]{position:relative;display:inline-grid;place-items:center;inline-size:var(--lr-size-24px);block-size:var(--lr-size-24px);pointer-events:none}[part~=progress-ring__base]{position:absolute;inset:0;inline-size:100%;block-size:100%;overflow:visible;fill:none;transform:rotate(-90deg)}[part=progress-ring__track],[part=progress-ring__indicator]{fill:none;stroke-width:var(--lr-border-width-medium)}[part=progress-ring__track]{stroke:var(--lr-color-border)}[part=progress-ring__indicator]{stroke:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:0;animation-timing-function:linear;animation-fill-mode:forwards}:host([data-visible]) [part=progress-ring__indicator]{animation-name:var(--_lr-motion-animation,lr-toast-progress)}:host(:hover) [part=progress-ring__indicator],:host(:focus-within) [part=progress-ring__indicator]{animation-play-state:paused}[part=progress-ring__label],[part=close-icon]{display:inline-flex;align-items:center;justify-content:center}[part=close-icon__svg]{display:block}[part=close-button]:where(:hover):where(:not([aria-disabled=true])){${iconActionHover}}[part=close-button]:where(:active):where(:not([aria-disabled=true])){${iconActionActive}}[part=close-button][aria-disabled=true]{${disabledControl}}[part=close-button]:focus-visible{${focusRing}}@keyframes lr-toast-progress{to{stroke-dashoffset:1}}@media (prefers-reduced-motion:reduce){[part=progress-ring__indicator]{animation:none!important;stroke-dashoffset:1}}${glassSurface('[part="toast-item"]',css`var(--lr-overlay-surface, var(--lr-color-surface-container-high))`)} `;export{styles};
@@ -73,7 +73,7 @@ import{type TemplateResult}from'lit';import{LyraElement}from'../../../internal/l
73
73
  * on the anchored source-preview popover.
74
74
  * @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge
75
75
  * colour, on the anchored source-preview popover.
76
- * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on the
76
+ * @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, on the
77
77
  * anchored source-preview popover.
78
78
  * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface.
79
79
  * @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the preview
@@ -30,7 +30,7 @@ import{type TemplateResult}from'lit';import{LyraElement}from'../../../internal/l
30
30
  * on the anchored detail popover.
31
31
  * @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge
32
32
  * colour, on the anchored detail popover.
33
- * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on the
33
+ * @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, on the
34
34
  * anchored detail popover.
35
35
  * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface.
36
36
  * @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the preview
@@ -108,7 +108,8 @@ accessibleLabel:string|null;
108
108
  disabled:boolean;private _size?;
109
109
  /** Optional shared density tier for the built-in trigger. Unset preserves its original geometry.*/
110
110
  get size():LyraSize|undefined;set size(next:LyraSize|undefined);
111
- /** How long, in milliseconds, the copied confirmation or failure state remains visible.*/
111
+ /** How long, in milliseconds, the copied confirmation or failure state remains visible.
112
+ * Defaults to `1000`. A non-finite value falls back to `1000`; a negative one clamps to `0`. */
112
113
  feedbackDuration:number;private status;private readonly sink;private hasCustomTrigger;private triggerCollected;private lastObservedTrigger;private buttonEl?;private defaultSlot?;private readonly internals;private readonly toolbarAction;constructor();private copyTimer?;private copyGeneration;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private hostRelationshipLeases;private syncHostRelationships;private releaseHostRelationships;protected firstUpdated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private cancelFeedbackTimer;private resetFeedback;private setStatus;private customTrigger;private activeTrigger;private composedTriggerAction;private createToolbarAction;
113
114
  /** The stable logical copy action exposed to an enclosing composite toolbar. Its optional
114
115
  * release method restores an untouched authored trigger tabindex when the parent leaves. */
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{tag}from"../../../internal/prefix.js";import{copyOutcome,reportCopyOutcome}from"../../../internal/record-copy-feedback.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{checkIcon,copyIcon,errorCircleIcon}from"../../../internal/icons.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{optionalSizeConverter,writeOptionalSize}from"../../../internal/variants.js";import{sizes}from"../../../internal/sizes.styles.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{styles}from"./copy-button.styles.js";import{COPY_FEEDBACK_MS}from"../../../internal/copy-feedback.js";import{leaseTabIndex}from"../../../internal/tab-index-lease.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_FEEDBACK_DURATION=COPY_FEEDBACK_MS;function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.getAttribute=="function"}function isHtmlElementValue(value){if(!isElementValue(value))return!1;const candidate=value;return candidate.namespaceURI==="http://www.w3.org/1999/xhtml"&&typeof candidate.focus=="function"&&typeof candidate.blur=="function"&&typeof candidate.click=="function"}class CopySourceError extends Error{constructor(message){super(message),this.name="CopySourceError"}}class LyraCopyButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.styles=[LyraElement.styles,sizes,styles]}get size(){return this._size}set size(next){writeOptionalSize(this,this._size,next,value=>{this._size=value})}constructor(){super(),this.value="",this.from="",this.tooltip="full",this.tooltipPlacement="top",this.hoist=!1,this.accessibleLabel=null,this.disabled=!1,this.feedbackDuration=DEFAULT_FEEDBACK_DURATION,this.status="rest",this.sink=new AnnouncementSinkController(this,{eager:["polite"]}),this.hasCustomTrigger=!1,this.triggerCollected=!1,this.internals=attachInternalsSafely(this),this.toolbarAction=this.createToolbarAction(),this.copyGeneration=0,this.hostRelationshipLeases=[],this.onClick=()=>{this.copy()},this.onDefaultSlotChange=event=>{this.onDefaultSlotChangeFromSlot(event.currentTarget)},this.onCustomTriggerClick=()=>{this.hasCustomTrigger&&this.copy()},this.stopInternalTooltipEvent=event=>{event.stopPropagation()},this.internals.role="group"}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&(changed.has("value")||changed.has("from"))&&this.resetFeedback()}updated(changed){super.updated(changed),(changed.has("disabled")||changed.has("hasCustomTrigger"))&&this.emit("lr-toolbar-actions-change"),this.syncHostRelationships()}syncHostRelationships(){const iconButton=this.renderRoot.querySelector(tag("icon-button"));if(!iconButton){this.releaseHostRelationships();return}iconButton.updateComplete.then(()=>{if(!iconButton.isConnected||iconButton.getRootNode()!==this.renderRoot)return;const target=iconButton.control;if(this.hostRelationshipLeases.length===0)this.hostRelationshipLeases=[acquireNativeControlDescription(this,target,()=>""),acquireResolvedAriaRelationship(this,target,"aria-labelledby")];else for(const lease of this.hostRelationshipLeases)lease.update(target)})}releaseHostRelationships(){for(const lease of this.hostRelationshipLeases)lease.release();this.hostRelationshipLeases=[]}firstUpdated(changed){super.firstUpdated(changed);const slot=this.defaultSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.onDefaultSlotChangeFromSlot(s))})}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","group"),this.getAttribute("hydrate-internals-role")===this.getAttribute("role")&&this.removeAttribute("hydrate-internals-role")}disconnectedCallback(){this.toolbarAction.releaseTabIndex?.(),this.releaseHostRelationships(),super.disconnectedCallback(),this.resetFeedback()}adoptedCallback(){this.toolbarAction.releaseTabIndex?.(),super.adoptedCallback(),this.sink.adopted(),this.resetFeedback()}cancelFeedbackTimer(){const timer=this.copyTimer;this.copyTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}resetFeedback(){this.copyGeneration+=1,this.cancelFeedbackTimer(),this.setStatus("rest")}setStatus(status){this.status=status,setCustomState(this.internals,"success",status==="success"),setCustomState(this.internals,"error",status==="error")}customTrigger(){return this.defaultSlot?.assignedElements({flatten:!0}).find(isHtmlElementValue)}activeTrigger(){return this.hasCustomTrigger?this.customTrigger():this.buttonEl}composedTriggerAction(){if(this.hasCustomTrigger)return;const[action]=this.buttonEl?.getToolbarActions()??[];return action}createToolbarAction(){const host=this,lease=leaseTabIndex();let delegated;const releaseDelegated=()=>{const previous=delegated;delegated=void 0,previous?.releaseTabIndex?.()},releaseTabIndex=()=>{releaseDelegated(),lease.release()};return{id:"copy",get disabled(){const trigger=host.activeTrigger();return!trigger||host.disabled||trigger.disabled===!0},focus(options){host.activeTrigger()?.focus(options)},setTabIndex(tabIndex){const composed=host.composedTriggerAction();if(composed){delegated!==composed&&(releaseTabIndex(),delegated=composed),composed.setTabIndex(tabIndex);return}releaseDelegated(),lease.set(host.activeTrigger()??void 0,tabIndex)},releaseTabIndex,matchesEventPath(path){const trigger=host.activeTrigger();return trigger!=null&&path.includes(trigger)}}}getToolbarActions(){return[this.toolbarAction]}focus(options){this.deferFocusUntilRendered(options)||this.activeTrigger()?.focus(options)}blur(){this.activeTrigger()?.blur()}click(){this.activeTrigger()?.click()}sourceById(id){const root=this.getRootNode();if((root.nodeType===9||root.nodeType===11)&&typeof root.getElementById=="function"){const source=root.getElementById(id);if(isElementValue(source))return source}const documentSource=this.ownerDocument.getElementById(id);return isElementValue(documentSource)?documentSource:null}resolveCopyText(){if(!this.from){if(!this.value)throw new CopySourceError("The copy value is empty.");return this.value}const expression=this.from.trim(),attributeMatch=/^(.*?)\[([^\]]+)\]$/.exec(expression),propertyMatch=attributeMatch?null:/^(.*?)\.([^.]*)$/.exec(expression),id=(attributeMatch?.[1]??propertyMatch?.[1]??expression).trim(),splitSource=id?this.sourceById(id):null,wholeIdSource=!splitSource&&(attributeMatch||propertyMatch)?this.sourceById(expression):null,source=splitSource??wholeIdSource;if(!source)throw new CopySourceError(`The copy source "${id}" was not found.`);let resolved;if(wholeIdSource)resolved=source.textContent;else if(attributeMatch){const attribute=attributeMatch[2].trim();resolved=attribute?source.getAttribute(attribute):null}else if(propertyMatch){const propertyName=propertyMatch[2].trim();resolved=propertyName?source[propertyName]:void 0}else resolved=source.textContent;const text=resolved==null?"":String(resolved);if(!text)throw new CopySourceError(`The copy source "${expression}" resolved to an empty value.`);return text}showStatus(status){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner)return;this.setStatus(status),this.sink.announcePolite(this.statusLabel(status)),this.cancelFeedbackTimer();const duration=finiteDuration(this.feedbackDuration,DEFAULT_FEEDBACK_DURATION,0),generation=this.copyGeneration;let handle=0;handle=owner.setTimeout(()=>{const timer=this.copyTimer;timer?.owner!==owner||timer.handle!==handle||timer.generation!==generation||generation!==this.copyGeneration||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.copyTimer=void 0,this.setStatus("rest"))},duration),this.copyTimer={owner,handle,generation}}reportCopy(outcome,generation,owner){reportCopyOutcome({announce:ok=>this.showStatus(ok?"success":"error"),emit:(name,detail)=>this.emit(name,detail??null)},outcome,()=>this.isCurrentCopy(generation,owner))}async copy(){if(this.disabled)return;const generation=++this.copyGeneration,owner=this.isConnected?this.ownerDocument.defaultView:null;let text="";try{text=this.resolveCopyText()}catch(error){this.reportCopy(copyOutcome("failure",{text,error}),generation);return}if(!owner)return;const outcome=await writeClipboardText(owner,text);this.reportCopy(outcome,generation,owner)}isCurrentCopy(generation,owner){return this.isConnected&&generation===this.copyGeneration&&(owner===void 0||this.ownerDocument.defaultView===owner)}onDefaultSlotChangeFromSlot(slot){const trigger=slot.assignedElements({flatten:!0}).find(isHtmlElementValue);if(this.triggerCollected&&trigger===this.lastObservedTrigger)return;this.triggerCollected=!0,this.lastObservedTrigger=trigger;const hasCustomTrigger=trigger!==void 0;if(hasCustomTrigger!==this.hasCustomTrigger){this.hasCustomTrigger=hasCustomTrigger;return}this.emit("lr-toolbar-actions-change")}statusLabel(status){const label=status==="success"?this.successLabel:status==="error"?this.errorLabel:this.copyLabel;return label===""?"":normalizeLabel(label)??this.localize(status==="success"?"copied":status==="error"?"copyFailed":"copy")}renderIcon(){return this.status==="error"?html`<span part="error-icon" aria-hidden="true"><slot name="error-icon">${errorCircleIcon()}</slot></span>`:this.status==="success"?html`<span part="success-icon" aria-hidden="true"><slot name="success-icon">${checkIcon()}</slot></span>`:html`<span part="copy-icon" aria-hidden="true"><slot name="copy-icon">${copyIcon()}</slot></span>`}render(){const statusLabel=this.statusLabel(this.status),feedback=this.status==="rest"?"":statusLabel,part=this.status==="success"?"base button base-success":this.status==="error"?"base button base-error":"base button",tooltipDisabled=this.tooltip==="none"||statusLabel.trim()==="",tooltipOpen=!tooltipDisabled&&this.status!=="rest",buttonLabel=this.accessibleLabel?.trim()?this.accessibleLabel:statusLabel;return html`
1
+ import{__decorate}from"tslib";import{tag}from"../../../internal/prefix.js";import{copyOutcome,reportCopyOutcome}from"../../../internal/record-copy-feedback.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{checkIcon,copyIcon,errorCircleIcon}from"../../../internal/icons.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{optionalSizeConverter,writeOptionalSize}from"../../../internal/variants.js";import{sizes}from"../../../internal/sizes.styles.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{styles}from"./copy-button.styles.js";import{leaseTabIndex}from"../../../internal/tab-index-lease.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_FEEDBACK_DURATION=1e3;function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.getAttribute=="function"}function isHtmlElementValue(value){if(!isElementValue(value))return!1;const candidate=value;return candidate.namespaceURI==="http://www.w3.org/1999/xhtml"&&typeof candidate.focus=="function"&&typeof candidate.blur=="function"&&typeof candidate.click=="function"}class CopySourceError extends Error{constructor(message){super(message),this.name="CopySourceError"}}class LyraCopyButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.styles=[LyraElement.styles,sizes,styles]}get size(){return this._size}set size(next){writeOptionalSize(this,this._size,next,value=>{this._size=value})}constructor(){super(),this.value="",this.from="",this.tooltip="full",this.tooltipPlacement="top",this.hoist=!1,this.accessibleLabel=null,this.disabled=!1,this.feedbackDuration=DEFAULT_FEEDBACK_DURATION,this.status="rest",this.sink=new AnnouncementSinkController(this,{eager:["polite"]}),this.hasCustomTrigger=!1,this.triggerCollected=!1,this.internals=attachInternalsSafely(this),this.toolbarAction=this.createToolbarAction(),this.copyGeneration=0,this.hostRelationshipLeases=[],this.onClick=()=>{this.copy()},this.onDefaultSlotChange=event=>{this.onDefaultSlotChangeFromSlot(event.currentTarget)},this.onCustomTriggerClick=()=>{this.hasCustomTrigger&&this.copy()},this.stopInternalTooltipEvent=event=>{event.stopPropagation()},this.internals.role="group"}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&(changed.has("value")||changed.has("from"))&&this.resetFeedback()}updated(changed){super.updated(changed),(changed.has("disabled")||changed.has("hasCustomTrigger"))&&this.emit("lr-toolbar-actions-change"),this.syncHostRelationships()}syncHostRelationships(){const iconButton=this.renderRoot.querySelector(tag("icon-button"));if(!iconButton){this.releaseHostRelationships();return}iconButton.updateComplete.then(()=>{if(!iconButton.isConnected||iconButton.getRootNode()!==this.renderRoot)return;const target=iconButton.control;if(this.hostRelationshipLeases.length===0)this.hostRelationshipLeases=[acquireNativeControlDescription(this,target,()=>""),acquireResolvedAriaRelationship(this,target,"aria-labelledby")];else for(const lease of this.hostRelationshipLeases)lease.update(target)})}releaseHostRelationships(){for(const lease of this.hostRelationshipLeases)lease.release();this.hostRelationshipLeases=[]}firstUpdated(changed){super.firstUpdated(changed);const slot=this.defaultSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.onDefaultSlotChangeFromSlot(s))})}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","group"),this.getAttribute("hydrate-internals-role")===this.getAttribute("role")&&this.removeAttribute("hydrate-internals-role")}disconnectedCallback(){this.toolbarAction.releaseTabIndex?.(),this.releaseHostRelationships(),super.disconnectedCallback(),this.resetFeedback()}adoptedCallback(){this.toolbarAction.releaseTabIndex?.(),super.adoptedCallback(),this.sink.adopted(),this.resetFeedback()}cancelFeedbackTimer(){const timer=this.copyTimer;this.copyTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}resetFeedback(){this.copyGeneration+=1,this.cancelFeedbackTimer(),this.setStatus("rest")}setStatus(status){this.status=status,setCustomState(this.internals,"success",status==="success"),setCustomState(this.internals,"error",status==="error")}customTrigger(){return this.defaultSlot?.assignedElements({flatten:!0}).find(isHtmlElementValue)}activeTrigger(){return this.hasCustomTrigger?this.customTrigger():this.buttonEl}composedTriggerAction(){if(this.hasCustomTrigger)return;const[action]=this.buttonEl?.getToolbarActions()??[];return action}createToolbarAction(){const host=this,lease=leaseTabIndex();let delegated;const releaseDelegated=()=>{const previous=delegated;delegated=void 0,previous?.releaseTabIndex?.()},releaseTabIndex=()=>{releaseDelegated(),lease.release()};return{id:"copy",get disabled(){const trigger=host.activeTrigger();return!trigger||host.disabled||trigger.disabled===!0},focus(options){host.activeTrigger()?.focus(options)},setTabIndex(tabIndex){const composed=host.composedTriggerAction();if(composed){delegated!==composed&&(releaseTabIndex(),delegated=composed),composed.setTabIndex(tabIndex);return}releaseDelegated(),lease.set(host.activeTrigger()??void 0,tabIndex)},releaseTabIndex,matchesEventPath(path){const trigger=host.activeTrigger();return trigger!=null&&path.includes(trigger)}}}getToolbarActions(){return[this.toolbarAction]}focus(options){this.deferFocusUntilRendered(options)||this.activeTrigger()?.focus(options)}blur(){this.activeTrigger()?.blur()}click(){this.activeTrigger()?.click()}sourceById(id){const root=this.getRootNode();if((root.nodeType===9||root.nodeType===11)&&typeof root.getElementById=="function"){const source=root.getElementById(id);if(isElementValue(source))return source}const documentSource=this.ownerDocument.getElementById(id);return isElementValue(documentSource)?documentSource:null}resolveCopyText(){if(!this.from){if(!this.value)throw new CopySourceError("The copy value is empty.");return this.value}const expression=this.from.trim(),attributeMatch=/^(.*?)\[([^\]]+)\]$/.exec(expression),propertyMatch=attributeMatch?null:/^(.*?)\.([^.]*)$/.exec(expression),id=(attributeMatch?.[1]??propertyMatch?.[1]??expression).trim(),splitSource=id?this.sourceById(id):null,wholeIdSource=!splitSource&&(attributeMatch||propertyMatch)?this.sourceById(expression):null,source=splitSource??wholeIdSource;if(!source)throw new CopySourceError(`The copy source "${id}" was not found.`);let resolved;if(wholeIdSource)resolved=source.textContent;else if(attributeMatch){const attribute=attributeMatch[2].trim();resolved=attribute?source.getAttribute(attribute):null}else if(propertyMatch){const propertyName=propertyMatch[2].trim();resolved=propertyName?source[propertyName]:void 0}else resolved=source.textContent;const text=resolved==null?"":String(resolved);if(!text)throw new CopySourceError(`The copy source "${expression}" resolved to an empty value.`);return text}showStatus(status){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner)return;this.setStatus(status),this.sink.announcePolite(this.statusLabel(status)),this.cancelFeedbackTimer();const duration=finiteDuration(this.feedbackDuration,DEFAULT_FEEDBACK_DURATION,0),generation=this.copyGeneration;let handle=0;handle=owner.setTimeout(()=>{const timer=this.copyTimer;timer?.owner!==owner||timer.handle!==handle||timer.generation!==generation||generation!==this.copyGeneration||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.copyTimer=void 0,this.setStatus("rest"))},duration),this.copyTimer={owner,handle,generation}}reportCopy(outcome,generation,owner){reportCopyOutcome({announce:ok=>this.showStatus(ok?"success":"error"),emit:(name,detail)=>this.emit(name,detail??null)},outcome,()=>this.isCurrentCopy(generation,owner))}async copy(){if(this.disabled)return;const generation=++this.copyGeneration,owner=this.isConnected?this.ownerDocument.defaultView:null;let text="";try{text=this.resolveCopyText()}catch(error){this.reportCopy(copyOutcome("failure",{text,error}),generation);return}if(!owner)return;const outcome=await writeClipboardText(owner,text);this.reportCopy(outcome,generation,owner)}isCurrentCopy(generation,owner){return this.isConnected&&generation===this.copyGeneration&&(owner===void 0||this.ownerDocument.defaultView===owner)}onDefaultSlotChangeFromSlot(slot){const trigger=slot.assignedElements({flatten:!0}).find(isHtmlElementValue);if(this.triggerCollected&&trigger===this.lastObservedTrigger)return;this.triggerCollected=!0,this.lastObservedTrigger=trigger;const hasCustomTrigger=trigger!==void 0;if(hasCustomTrigger!==this.hasCustomTrigger){this.hasCustomTrigger=hasCustomTrigger;return}this.emit("lr-toolbar-actions-change")}statusLabel(status){const label=status==="success"?this.successLabel:status==="error"?this.errorLabel:this.copyLabel;return label===""?"":normalizeLabel(label)??this.localize(status==="success"?"copied":status==="error"?"copyFailed":"copy")}renderIcon(){return this.status==="error"?html`<span part="error-icon" aria-hidden="true"><slot name="error-icon">${errorCircleIcon()}</slot></span>`:this.status==="success"?html`<span part="success-icon" aria-hidden="true"><slot name="success-icon">${checkIcon()}</slot></span>`:html`<span part="copy-icon" aria-hidden="true"><slot name="copy-icon">${copyIcon()}</slot></span>`}render(){const statusLabel=this.statusLabel(this.status),feedback=this.status==="rest"?"":statusLabel,part=this.status==="success"?"base button base-success":this.status==="error"?"base button base-error":"base button",tooltipDisabled=this.tooltip==="none"||statusLabel.trim()==="",tooltipOpen=!tooltipDisabled&&this.status!=="rest",buttonLabel=this.accessibleLabel?.trim()?this.accessibleLabel:statusLabel;return html`
2
2
  <lr-tooltip part="copy-button" .trigger=${this.tooltip==="full"?"hover focus":"manual"} .placement=${this.tooltipPlacement} .hoist=${this.hoist} .disabled=${tooltipDisabled} .open=${tooltipOpen} @lr-show=${this.stopInternalTooltipEvent} @lr-after-show=${this.stopInternalTooltipEvent} @lr-hide=${this.stopInternalTooltipEvent} @lr-after-hide=${this.stopInternalTooltipEvent} exportparts="base:tooltip__base, base__popup:tooltip__base__popup, base__arrow:tooltip__base__arrow, body:tooltip__body" >
3
3
  ${this.hasCustomTrigger?nothing:html`
4
4
  <lr-icon-button slot="trigger" part=${part} exportparts="button:base-control" ?disabled=${this.disabled} aria-label=${buttonLabel} @click=${this.onClick} >
@@ -56,7 +56,7 @@ readonly extension?:string;}export type LyraExportFormatOption=LyraExportFormat|
56
56
  * on the menu popup.
57
57
  * @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge
58
58
  * colour, on the menu popup.
59
- * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on
59
+ * @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, on
60
60
  * the menu popup.
61
61
  * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface.
62
62
  * @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the format
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Opt-in Bootstrap Icons preset for `<lr-icon library="…">`.
3
+ *
4
+ * Bootstrap Icons (MIT) is the vocabulary Shoelace's `<sl-icon>` resolves by default, so
5
+ * registering this preset under `'default'` keeps migrated `<lr-icon name="gear">` markup
6
+ * rendering the same glyphs.
7
+ *
8
+ * Importing this module has no side effects and requests nothing: the built-in glyph set stays
9
+ * the offline default. Only `registerBootstrapIconLibrary()` installs the resolver, and even then
10
+ * an icon is fetched only when an `<lr-icon>` actually names that library. Every request still runs
11
+ * the `<lr-icon>` pipeline: fetch-URL allowlist, 1 MiB byte cap before parsing, unconditional
12
+ * DOMPurify SVG sanitizing, external-resource stripping, a shared bounded cache, and a localized
13
+ * fail-closed alert plus `lr-error` on any failure.
14
+ *
15
+ * The resolver validates the icon name before building a URL, so a typo in its shape or a
16
+ * path-like name fails at once, without a network request.
17
+ */
18
+ import{type LyraIconLibraryMutator,type LyraIconLibraryResolver}from'./icon-library.js';export interface LyraBootstrapIconLibraryOptions{
19
+ /** Library name used by `<lr-icon library>`. Default `'bi'`. Passing `'default'` makes Bootstrap
20
+ * Icons own every icon that sets no `library`, as Shoelace's default library did. */
21
+ name?:string;
22
+ /** Self-hosted folder holding the Bootstrap Icons SVG files (the package's `icons/` folder), for
23
+ * example `/assets/bootstrap-icons`. Icons resolve to `<basePath>/<name>.svg` and nothing is
24
+ * requested from a third-party host. */
25
+ basePath?:string;
26
+ /** Exact Bootstrap Icons release (`major.minor.patch`) used for the CDN URL. Default
27
+ * `BOOTSTRAP_ICONS_DEFAULT_VERSION`. Pinning keeps every icon URL immutable and cacheable.
28
+ * Ignored when `basePath` is set. */
29
+ version?:string;}
30
+ /** Bootstrap Icons release pinned by the preset when no `version` is given.*/
31
+ export declare const BOOTSTRAP_ICONS_DEFAULT_VERSION="1.13.2";
32
+ /**
33
+ * Builds the resolver the preset registers, for composing with other libraries or wrapping. It
34
+ * accepts `house` and the copy-pasted class form `bi-house`, and rejects any other name shape (so
35
+ * no name can add path segments, a query, or a fragment) by throwing, which `<lr-icon>` reports
36
+ * as a localized load failure. Bootstrap Icons has no families or variants, so `family` and
37
+ * `variant` are ignored; a filled glyph is its own name, such as `house-fill`.
38
+ */
39
+ export declare function createBootstrapIconResolver(options?:LyraBootstrapIconLibraryOptions):LyraIconLibraryResolver;
40
+ /** Paints Bootstrap Icons SVGs with the text color: sets `fill="currentColor"` on the root when
41
+ * the document declares no fill (published files already do), so a self-hosted or edited copy
42
+ * still follows `color`. */
43
+ export declare const bootstrapIconMutator:LyraIconLibraryMutator;
44
+ /**
45
+ * Registers the Bootstrap Icons preset under `options.name` (default `'bi'`) and returns a
46
+ * function that unregisters it again, but only while that name still holds this registration.
47
+ * Options are validated here, so a malformed version or base path throws at the call site. Icons
48
+ * load from a pinned jsDelivr release unless `basePath` points at a self-hosted copy.
49
+ */
50
+ export declare function registerBootstrapIconLibrary(options?:LyraBootstrapIconLibraryOptions):()=>void;
@@ -0,0 +1 @@
1
+ import{getIconLibrary,registerIconLibrary,unregisterIconLibrary}from"./icon-library.js";const BOOTSTRAP_ICONS_DEFAULT_VERSION="1.13.2",ICON_NAME=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,VERSION=/^\d+\.\d+\.\d+$/;function validateOptions(options){if(options.version!==void 0&&!VERSION.test(options.version))throw new TypeError("Bootstrap Icons version must be an exact major.minor.patch release");if(options.basePath!==void 0&&(options.basePath.trim()===""||/[?#]/.test(options.basePath)))throw new TypeError("Bootstrap Icons basePath must be a non-empty path without a query or fragment")}function createBootstrapIconResolver(options={}){validateOptions(options);const version=options.version??BOOTSTRAP_ICONS_DEFAULT_VERSION,basePath=options.basePath===void 0?void 0:withoutTrailingSlashes(options.basePath);return name=>{const iconName=name.startsWith("bi-")?name.slice(3):name;if(!ICON_NAME.test(iconName))throw new RangeError(`Invalid Bootstrap Icons name: ${name}`);return basePath!==void 0?`${basePath}/${iconName}.svg`:`https://cdn.jsdelivr.net/npm/bootstrap-icons@${version}/icons/${iconName}.svg`}}const bootstrapIconMutator=svg=>{svg.hasAttribute("fill")||svg.setAttribute("fill","currentColor")};function registerBootstrapIconLibrary(options={}){const name=options.name??"bi",resolver=createBootstrapIconResolver(options);return registerIconLibrary(name,{resolver,mutator:bootstrapIconMutator}),()=>{getIconLibrary(name)?.resolver===resolver&&unregisterIconLibrary(name)}}function withoutTrailingSlashes(value){let end=value.length;for(;end>0&&value.charCodeAt(end-1)===47;)end-=1;return value.slice(0,end)}export{BOOTSTRAP_ICONS_DEFAULT_VERSION,bootstrapIconMutator,createBootstrapIconResolver,registerBootstrapIconLibrary};
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Opt-in Font Awesome preset for `<lr-icon library="…">`.
3
+ *
4
+ * Importing this module has no side effects and requests nothing: the built-in glyph set stays
5
+ * the offline default. Only `registerFontAwesomeIconLibrary()` installs the resolver, and even
6
+ * then an icon is fetched only when an `<lr-icon>` actually names that library. Every request
7
+ * still runs the `<lr-icon>` pipeline: fetch-URL allowlist, 1 MiB byte cap before parsing,
8
+ * unconditional DOMPurify SVG sanitizing, external-resource stripping, a shared bounded cache, and
9
+ * a localized fail-closed alert plus `lr-error` on any failure.
10
+ *
11
+ * The resolver validates the icon name, family, and variant before building a URL, so a typo, a
12
+ * path-like name, or a Pro family without a kit fails at once, without a network request.
13
+ */
14
+ import{type LyraIconLibraryMutator,type LyraIconLibraryResolver}from'./icon-library.js';
15
+ /** Font Awesome families understood by the preset. `classic` and `brands` are free; the rest need
16
+ * a Font Awesome kit code or a self-hosted `basePath` holding those SVG folders. */
17
+ export type LyraFontAwesomeFamily='classic'|'brands'|'duotone'|'sharp'|'sharp-duotone'|'chisel'|'etch'|'graphite'|'jelly'|'jelly-duo'|'jelly-fill'|'mosaic'|'notdog'|'notdog-duo'|'pixel'|'slab'|'slab-press'|'slab-duo'|'slab-press-duo'|'thumbprint'|'utility'|'utility-duo'|'utility-fill'|'vellum'|'whiteboard';
18
+ /** Font Awesome variants (styles) understood by the preset.*/
19
+ export type LyraFontAwesomeVariant='solid'|'regular'|'light'|'thin'|'semibold';export interface LyraFontAwesomeIconLibraryOptions{
20
+ /** Library name used by `<lr-icon library>`. Default `'fa'`. Passing `'default'` makes Font
21
+ * Awesome own every icon that sets no `library`. */
22
+ name?:string;
23
+ /** Font Awesome kit code. When set, icons load from Font Awesome's kit SVG host with the code as
24
+ * the `token` query parameter, and every family is allowed. Ignored when `basePath` is set. */
25
+ kitCode?:string;
26
+ /** Self-hosted root holding Font Awesome's `svgs/` folders, for example `/assets/fa/svgs`.
27
+ * Icons resolve to `<basePath>/<folder>/<name>.svg`, every family is allowed, and nothing is
28
+ * requested from a third-party host. */
29
+ basePath?:string;
30
+ /** Exact Font Awesome release (`major.minor.patch`) used for CDN and kit URLs. Default
31
+ * `FONT_AWESOME_DEFAULT_VERSION`. Pinning keeps every icon URL immutable and cacheable. */
32
+ version?:string;
33
+ /** Family used while neither the icon's `family` nor `setDefaultIconFamily()` names one.
34
+ * Default `'classic'`. */
35
+ defaultFamily?:LyraFontAwesomeFamily;
36
+ /** Variant used while neither the icon's `variant` nor `setDefaultIconFamily()` names one.
37
+ * Default: the family's first style (`solid` for the four-style families). */
38
+ defaultVariant?:LyraFontAwesomeVariant;}
39
+ /** Font Awesome release pinned by the preset when no `version` is given.*/
40
+ export declare const FONT_AWESOME_DEFAULT_VERSION="7.3.1";
41
+ /**
42
+ * The Font Awesome SVG folder for a family and variant, for example `classic`/`solid` → `solid`,
43
+ * `duotone`/`light` → `duotone-light`, `sharp-duotone`/`thin` → `sharp-duotone-thin`, and
44
+ * `brands` → `brands`. An empty family or variant takes the family's default. Throws a
45
+ * `RangeError` for a family or variant Font Awesome does not publish, so a custom resolver can
46
+ * reuse the same validation.
47
+ */
48
+ export declare function fontAwesomeIconFolder(family:string,variant?:string):string;
49
+ /**
50
+ * Builds the resolver the preset registers, for composing with other libraries or wrapping. It
51
+ * accepts `house` and the copy-pasted class form `fa-house`, rejects any other name shape (so no
52
+ * name can add path segments, a query, or a fragment), and throws, which `<lr-icon>` reports as
53
+ * a localized load failure, for an unknown family or variant, or for a Pro family without a
54
+ * `kitCode` or `basePath`.
55
+ */
56
+ export declare function createFontAwesomeIconResolver(options?:LyraFontAwesomeIconLibraryOptions):LyraIconLibraryResolver;
57
+ /** Paints Font Awesome SVGs with the text color: sets `fill="currentColor"` on the root when the
58
+ * document declares no fill (older self-hosted releases), and leaves duotone `.fa-primary`/
59
+ * `.fa-secondary` layers to `<lr-icon>`'s `--primary-*`/`--secondary-*` hooks. */
60
+ export declare const fontAwesomeIconMutator:LyraIconLibraryMutator;
61
+ /**
62
+ * Registers the Font Awesome preset under `options.name` (default `'fa'`) and returns a function
63
+ * that unregisters it again, but only while that name still holds this registration. Options are
64
+ * validated here, so a malformed kit code, version, base path, or default throws at the call
65
+ * site. The free tier (`classic` solid/regular and `brands`) loads from a pinned jsDelivr release;
66
+ * a `kitCode` or `basePath` unlocks the other families.
67
+ */
68
+ export declare function registerFontAwesomeIconLibrary(options?:LyraFontAwesomeIconLibraryOptions):()=>void;
@@ -0,0 +1 @@
1
+ import{getIconLibrary,registerIconLibrary,unregisterIconLibrary}from"./icon-library.js";const FONT_AWESOME_DEFAULT_VERSION="7.3.1",FOUR_STYLES=["solid","regular","light","thin"],FAMILY_STYLES={classic:FOUR_STYLES,brands:[],duotone:FOUR_STYLES,sharp:FOUR_STYLES,"sharp-duotone":FOUR_STYLES,chisel:["regular"],etch:["solid"],graphite:["thin"],jelly:["regular"],"jelly-duo":["regular"],"jelly-fill":["regular"],mosaic:["solid"],notdog:["solid"],"notdog-duo":["solid"],pixel:["regular"],slab:["regular"],"slab-press":["regular"],"slab-duo":["regular"],"slab-press-duo":["regular"],thumbprint:["light"],utility:["semibold"],"utility-duo":["semibold"],"utility-fill":["semibold"],vellum:["solid"],whiteboard:["semibold"]},FREE_FOLDERS=new Set(["solid","regular","brands"]),ICON_NAME=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,KIT_CODE=/^[A-Za-z0-9]+$/,VERSION=/^\d+\.\d+\.\d+$/;function isFamily(value){return Object.prototype.hasOwnProperty.call(FAMILY_STYLES,value)}function fontAwesomeIconFolder(family,variant=""){const resolvedFamily=family||"classic";if(!isFamily(resolvedFamily))throw new RangeError(`Unknown Font Awesome family: ${resolvedFamily}`);if(resolvedFamily==="brands")return"brands";const styles=FAMILY_STYLES[resolvedFamily];let style;if(styles.length===1)style=styles[0];else if(!variant)style=styles[0];else if(styles.includes(variant))style=variant;else throw new RangeError(`Font Awesome family ${resolvedFamily} has no ${variant} variant`);return resolvedFamily==="classic"?style:resolvedFamily==="duotone"&&style==="solid"?"duotone":`${resolvedFamily}-${style}`}function validateOptions(options){if(options.kitCode!==void 0&&!KIT_CODE.test(options.kitCode))throw new TypeError("Font Awesome kitCode must be alphanumeric");if(options.version!==void 0&&!VERSION.test(options.version))throw new TypeError("Font Awesome version must be an exact major.minor.patch release");if(options.basePath!==void 0&&(options.basePath.trim()===""||/[?#]/.test(options.basePath)))throw new TypeError("Font Awesome basePath must be a non-empty path without a query or fragment");if(options.defaultFamily!==void 0&&!isFamily(options.defaultFamily))throw new TypeError(`Unknown Font Awesome family: ${String(options.defaultFamily)}`);options.defaultVariant!==void 0&&fontAwesomeIconFolder(options.defaultFamily??"classic",options.defaultVariant)}function createFontAwesomeIconResolver(options={}){validateOptions(options);const version=options.version??FONT_AWESOME_DEFAULT_VERSION,basePath=options.basePath===void 0?void 0:withoutTrailingSlashes(options.basePath),kitCode=options.kitCode;return(name,family,variant)=>{const iconName=name.startsWith("fa-")?name.slice(3):name;if(!ICON_NAME.test(iconName))throw new RangeError(`Invalid Font Awesome icon name: ${name}`);const resolvedFamily=family||options.defaultFamily||"classic",resolvedVariant=variant||(family?"":options.defaultVariant??""),folder=fontAwesomeIconFolder(resolvedFamily,resolvedVariant);if(basePath!==void 0)return`${basePath}/${folder}/${iconName}.svg`;if(kitCode)return`https://ka-p.fontawesome.com/releases/v${version}/svgs/${folder}/${iconName}.svg?token=${kitCode}`;if(!FREE_FOLDERS.has(folder))throw new RangeError(`Font Awesome ${folder} icons need a kitCode or a self-hosted basePath`);return`https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@${version}/svgs/${folder}/${iconName}.svg`}}const fontAwesomeIconMutator=svg=>{svg.hasAttribute("fill")||svg.setAttribute("fill","currentColor")};function registerFontAwesomeIconLibrary(options={}){const name=options.name??"fa",resolver=createFontAwesomeIconResolver(options);return registerIconLibrary(name,{resolver,mutator:fontAwesomeIconMutator}),()=>{getIconLibrary(name)?.resolver===resolver&&unregisterIconLibrary(name)}}function withoutTrailingSlashes(value){let end=value.length;for(;end>0&&value.charCodeAt(end-1)===47;)end-=1;return value.slice(0,end)}export{FONT_AWESOME_DEFAULT_VERSION,createFontAwesomeIconResolver,fontAwesomeIconFolder,fontAwesomeIconMutator,registerFontAwesomeIconLibrary};
@@ -135,6 +135,16 @@ field:LyraKnownDateField;}export interface LyraKnownDateEventMap{'lr-invalid':Cu
135
135
  * @cssstate blank - The composite value is empty or incomplete.
136
136
  * @cssstate disabled - The control is disabled directly or through an ancestor fieldset.
137
137
  * @cssprop [--lr-form-control-label-line-height=inherit] - Line height of the field label.
138
+ * @cssstate required - Matches while `required` is set. Style with `lr-known-date:state(required)`.
139
+ * @cssstate optional - Matches while `required` is not set — the complement of `required`.
140
+ * @cssstate valid - Matches while the control satisfies its constraints, including any
141
+ * `setCustomValidity()` error. Never matches while disabled or readonly.
142
+ * @cssstate invalid - Matches while it does not — from the very first render, before the user has
143
+ * touched anything. Never matches while disabled or readonly.
144
+ * @cssstate user-valid - `valid`, but only after the user has interacted: an edit, a blur,
145
+ * `reportValidity()`, or a submission attempt.
146
+ * @cssstate user-invalid - `invalid` after that same interaction. Style validation errors with this
147
+ * rather than `invalid`, so a pristine required field is not painted red before the user acts.
138
148
  * @status stable
139
149
  * @since 4.0.0
140
150
  */
@@ -155,7 +155,7 @@ readonly ownsFocus?:()=>boolean;}export interface LyraMentionPopoverEventMap{'lr
155
155
  * @cssprop [--lr-overlay-border=var(--lr-color-border)] - Shared floating-surface edge colour, on
156
156
  * the listbox. Unlike a floating panel's decorative edge, it defaults to
157
157
  * the control tier: the listbox completes the value of the text field it is bound to.
158
- * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on
158
+ * @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, on
159
159
  * the listbox.
160
160
  * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface.
161
161
  * @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the listbox's
@@ -8,7 +8,14 @@ export type LyraNumberTickerCurrencyDisplay='symbol'|'narrowSymbol'|'code'|'name
8
8
  * `Intl.NumberFormat` in the effective locale. Use it for dashboard figures and landing-page metrics.
9
9
  *
10
10
  * Under `prefers-reduced-motion: reduce` (or when `duration` is 0) it jumps straight to the final
11
- * value. Assistive technology never hears the animation: the counting text is `aria-hidden` and the
11
+ * value; reduced motion turning on mid-count settles the run at once.
12
+ *
13
+ * A count settles early: on the first frame whose formatted text equals the formatted final value
14
+ * it shows that value, leaves `:state(counting)` and emits `lr-finish`, instead of repainting the
15
+ * same text until `duration` ends. With the default ease-out curve the last stretch of a count
16
+ * never changes the rounded text, so `lr-finish` arrives when the number visibly stops. An
17
+ * overshooting easing settles the first time its text reaches the final value. A `value` change
18
+ * during a count is not a settle: the count continues from the number shown to the new value. Assistive technology never hears the animation: the counting text is `aria-hidden` and the
12
19
  * final value is present in visually hidden text from the start. A later `value` change after the
13
20
  * first count is announced once, politely, through the shared light-DOM live region. It renders its
14
21
  * start value during SSR and counts after hydration, once it is on screen.
@@ -17,7 +24,8 @@ export type LyraNumberTickerCurrencyDisplay='symbol'|'narrowSymbol'|'code'|'name
17
24
  * @csspart base - The container around the displayed number.
18
25
  * @csspart value - The displayed (counting) number.
19
26
  * @cssstate counting - Applied while the number is counting.
20
- * @event lr-finish - The ticker settled on its value, including the instant reduced-motion and zero-duration paths.
27
+ * @event lr-finish - The ticker settled on its value: when the shown text first equals the final text
28
+ * (early settle), and on the instant reduced-motion and zero-duration paths.
21
29
  * @status experimental
22
30
  * @since 32.1.0
23
31
  */
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{html}from"lit";import{property,state}from"lit/decorators.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{blankNumberConverter}from"../../../internal/converters.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{finiteInteger,finiteNumber}from"../../../internal/numbers.js";import{styles}from"./number-ticker.styles.js";const DEFAULT_EASING="cubic-bezier(0.16, 1, 0.3, 1)",TYPES=["decimal","currency","percent"],CURRENCY_DISPLAYS=["symbol","narrowSymbol","code","name"],optionalDigits=blankNumberConverter(void 0);function decimalPlaces(n){return getNumberFormat("en-US",{maximumFractionDigits:20,useGrouping:!1}).format(Number(Number(n).toPrecision(15))).split(".")[1]?.length??0}class LyraNumberTicker extends LyraElement{constructor(){super(...arguments),this.value=0,this.startValue=0,this.duration=2e3,this.delay=0,this.easing=DEFAULT_EASING,this.eager=!1,this.type="decimal",this.withoutGrouping=!1,this.currency="USD",this.currencyDisplay="symbol",this.displayValue=null,this.internals=attachInternalsSafely(this),this.announcer=new AnnouncementSinkController(this),this.intersecting=!1,this.pending=!0,this.frame=0,this.hasCounted=!1,this.run=0}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback();const view=this.ownerDocument.defaultView;view&&"IntersectionObserver"in view&&(this.observer=new view.IntersectionObserver(entries=>{const entry=entries[entries.length-1];entry&&(this.intersecting=entry.intersectionRatio>=.5,this.intersecting&&this.pending&&this.start())},{threshold:.5}),this.observer.observe(this)),this.stopMotionWatch=observeReducedMotion(this,reduced=>{reduced&&this.animation&&this.finish()}),this.eager&&this.pending&&this.hasUpdated&&this.start()}disconnectedCallback(){super.disconnectedCallback(),this.observer?.disconnect(),this.observer=void 0,this.stopMotionWatch?.(),this.stopMotionWatch=void 0,this.intersecting=!1,this.animation&&(this.pending=!0),this.stop()}firstUpdated(changed){super.firstUpdated(changed),this.eager&&this.startSoon()}updated(changed){super.updated(changed),!(!changed.has("value")||changed.get("value")===void 0)&&(this.pending=!0,(this.eager||this.intersecting||this.animation)&&this.startSoon())}startSoon(){Promise.resolve().then(()=>{this.isConnected&&this.pending&&this.start()})}restart(){this.stop(),this.hasCounted=!1,this.displayValue=null,this.pending=!0,(this.eager||this.intersecting)&&this.start()}start(){const from=this.displayValue??finiteNumber(this.startValue,0),to=finiteNumber(this.value,0),delay=this.displayValue===null?Math.max(0,finiteNumber(this.delay,0)):0,duration=Math.max(0,finiteNumber(this.duration,0));if(this.stop(),this.pending=!1,prefersReducedMotion(this)||!(duration>0)||from===to||typeof this.animate!="function"){this.finish();return}const options={duration,delay,fill:"both"};let animation;try{animation=this.animate(null,{...options,easing:this.easing})}catch{animation=this.animate(null,{...options,easing:DEFAULT_EASING})}this.animation=animation;const tick=()=>{if(this.animation!==animation)return;const time=Number(animation.currentTime);if(animation.playState==="finished"||animation.playState==="idle"||time>=delay+duration){this.finish();return}if(time>=delay){setCustomState(this.internals,"counting",!0);const progress=animation.effect?.getComputedTiming().progress??0;this.displayValue=from+(to-from)*finiteNumber(Number(progress),0)}this.frame=requestAnimationFrame(tick)};tick()}async finish(){this.stop();const run=++this.run;this.displayValue=finiteNumber(this.value,0),await this.updateComplete,!(run!==this.run||this.animation||this.pending)&&(this.hasCounted&&this.announcer.announcePolite(this.format(this.displayValue??0)),this.value!==this.startValue&&(this.hasCounted=!0),this.emit("lr-finish",null))}stop(){cancelAnimationFrame(this.frame),setCustomState(this.internals,"counting",!1);const animation=this.animation;this.animation=void 0,animation?.cancel()}format(n){if(!Number.isFinite(n))return"";try{if(typeof this.valueFormatter=="function")return String(this.valueFormatter(n));const type=TYPES.includes(this.type)?this.type:"decimal",digit=(value,min,max)=>value===void 0||!Number.isFinite(value)?void 0:finiteInteger(value,min,min,max),minFraction=digit(this.minimumFractionDigits,0,100),maxFraction=digit(this.maximumFractionDigits,0,100),minSignificant=digit(this.minimumSignificantDigits,1,21),maxSignificant=digit(this.maximumSignificantDigits,1,21),steady=type==="decimal"&&minFraction===void 0&&maxFraction===void 0&&minSignificant===void 0&&maxSignificant===void 0?Math.max(decimalPlaces(this.startValue),decimalPlaces(this.value)):void 0,options={style:type,useGrouping:this.withoutGrouping?!1:void 0,minimumIntegerDigits:digit(this.minimumIntegerDigits,1,21),minimumFractionDigits:steady??minFraction??maxFraction,maximumFractionDigits:steady??maxFraction??minFraction,minimumSignificantDigits:minSignificant,maximumSignificantDigits:maxSignificant};type==="currency"&&(options.currency=typeof this.currency=="string"&&this.currency.trim()||"USD",options.currencyDisplay=CURRENCY_DISPLAYS.includes(this.currencyDisplay)?this.currencyDisplay:"symbol");const formatter=getNumberFormat(this.effectiveLocale,options),text=formatter.format(n);return n<0&&text===formatter.format(-0)?formatter.format(0):text}catch{return""}}render(){const shown=this.format(this.displayValue??finiteNumber(this.startValue,0)),final=this.format(finiteNumber(this.value,0));return shown===final?html`<span part="base"><span part="value">${final}</span></span>`:html`<span part="base"><span part="value" aria-hidden="true">${shown}</span><span class="sr-only">${final}</span></span>`}}__decorate([property({converter:blankNumberConverter(0)})],LyraNumberTicker.prototype,"value",void 0),__decorate([property({attribute:"start-value",converter:blankNumberConverter(0)})],LyraNumberTicker.prototype,"startValue",void 0),__decorate([property({converter:blankNumberConverter(2e3)})],LyraNumberTicker.prototype,"duration",void 0),__decorate([property({converter:blankNumberConverter(0)})],LyraNumberTicker.prototype,"delay",void 0),__decorate([property()],LyraNumberTicker.prototype,"easing",void 0),__decorate([property({type:Boolean})],LyraNumberTicker.prototype,"eager",void 0),__decorate([property()],LyraNumberTicker.prototype,"type",void 0),__decorate([property({type:Boolean,attribute:"without-grouping"})],LyraNumberTicker.prototype,"withoutGrouping",void 0),__decorate([property()],LyraNumberTicker.prototype,"currency",void 0),__decorate([property({attribute:"currency-display"})],LyraNumberTicker.prototype,"currencyDisplay",void 0),__decorate([property({attribute:"minimum-integer-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"minimumIntegerDigits",void 0),__decorate([property({attribute:"minimum-fraction-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"minimumFractionDigits",void 0),__decorate([property({attribute:"maximum-fraction-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"maximumFractionDigits",void 0),__decorate([property({attribute:"minimum-significant-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"minimumSignificantDigits",void 0),__decorate([property({attribute:"maximum-significant-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"maximumSignificantDigits",void 0),__decorate([property({attribute:!1})],LyraNumberTicker.prototype,"valueFormatter",void 0),__decorate([state()],LyraNumberTicker.prototype,"displayValue",void 0);export{LyraNumberTicker};
1
+ import{__decorate}from"tslib";import{html}from"lit";import{property,state}from"lit/decorators.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{blankNumberConverter}from"../../../internal/converters.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{finiteInteger,finiteNumber}from"../../../internal/numbers.js";import{styles}from"./number-ticker.styles.js";const DEFAULT_EASING="cubic-bezier(0.16, 1, 0.3, 1)",TYPES=["decimal","currency","percent"],CURRENCY_DISPLAYS=["symbol","narrowSymbol","code","name"],optionalDigits=blankNumberConverter(void 0);function decimalPlaces(n){return getNumberFormat("en-US",{maximumFractionDigits:20,useGrouping:!1}).format(Number(Number(n).toPrecision(15))).split(".")[1]?.length??0}class LyraNumberTicker extends LyraElement{constructor(){super(...arguments),this.value=0,this.startValue=0,this.duration=2e3,this.delay=0,this.easing=DEFAULT_EASING,this.eager=!1,this.type="decimal",this.withoutGrouping=!1,this.currency="USD",this.currencyDisplay="symbol",this.displayValue=null,this.internals=attachInternalsSafely(this),this.announcer=new AnnouncementSinkController(this),this.intersecting=!1,this.pending=!0,this.frame=0,this.hasCounted=!1,this.run=0}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback();const view=this.ownerDocument.defaultView;view&&"IntersectionObserver"in view&&(this.observer=new view.IntersectionObserver(entries=>{const entry=entries[entries.length-1];entry&&(this.intersecting=entry.intersectionRatio>=.5,this.intersecting&&this.pending&&this.start())},{threshold:.5}),this.observer.observe(this)),this.stopMotionWatch=observeReducedMotion(this,reduced=>{reduced&&this.animation&&this.finish()}),this.eager&&this.pending&&this.hasUpdated&&this.start()}disconnectedCallback(){super.disconnectedCallback(),this.observer?.disconnect(),this.observer=void 0,this.stopMotionWatch?.(),this.stopMotionWatch=void 0,this.intersecting=!1,this.animation&&(this.pending=!0),this.stop()}firstUpdated(changed){super.firstUpdated(changed),this.eager&&this.startSoon()}updated(changed){super.updated(changed),!(!changed.has("value")||changed.get("value")===void 0)&&(this.pending=!0,(this.eager||this.intersecting||this.animation)&&this.startSoon())}startSoon(){Promise.resolve().then(()=>{this.isConnected&&this.pending&&this.start()})}restart(){this.stop(),this.hasCounted=!1,this.displayValue=null,this.pending=!0,(this.eager||this.intersecting)&&this.start()}start(){const from=this.displayValue??finiteNumber(this.startValue,0),to=finiteNumber(this.value,0),delay=this.displayValue===null?Math.max(0,finiteNumber(this.delay,0)):0,duration=Math.max(0,finiteNumber(this.duration,0));if(this.stop(),this.pending=!1,prefersReducedMotion(this)||!(duration>0)||from===to||typeof this.animate!="function"){this.finish();return}const options={duration,delay,fill:"both"};let animation;try{animation=this.animate(null,{...options,easing:this.easing})}catch{animation=this.animate(null,{...options,easing:DEFAULT_EASING})}this.animation=animation;const tick=()=>{if(this.animation!==animation)return;const time=Number(animation.currentTime);if(animation.playState==="finished"||animation.playState==="idle"||time>=delay+duration){this.finish();return}if(time>=delay){const progress=animation.effect?.getComputedTiming().progress??0,shown=from+(to-from)*finiteNumber(Number(progress),0);if(this.format(shown)===this.format(to)){this.finish();return}setCustomState(this.internals,"counting",!0),this.displayValue=shown}this.frame=requestAnimationFrame(tick)};tick()}async finish(){this.stop();const run=++this.run;this.displayValue=finiteNumber(this.value,0),await this.updateComplete,!(run!==this.run||this.animation||this.pending)&&(this.hasCounted&&this.announcer.announcePolite(this.format(this.displayValue??0)),this.value!==this.startValue&&(this.hasCounted=!0),this.emit("lr-finish",null))}stop(){cancelAnimationFrame(this.frame),setCustomState(this.internals,"counting",!1);const animation=this.animation;this.animation=void 0,animation?.cancel()}format(n){if(!Number.isFinite(n))return"";try{if(typeof this.valueFormatter=="function")return String(this.valueFormatter(n));const type=TYPES.includes(this.type)?this.type:"decimal",digit=(value,min,max)=>value===void 0||!Number.isFinite(value)?void 0:finiteInteger(value,min,min,max),minFraction=digit(this.minimumFractionDigits,0,100),maxFraction=digit(this.maximumFractionDigits,0,100),minSignificant=digit(this.minimumSignificantDigits,1,21),maxSignificant=digit(this.maximumSignificantDigits,1,21),steady=type==="decimal"&&minFraction===void 0&&maxFraction===void 0&&minSignificant===void 0&&maxSignificant===void 0?Math.max(decimalPlaces(this.startValue),decimalPlaces(this.value)):void 0,options={style:type,useGrouping:this.withoutGrouping?!1:void 0,minimumIntegerDigits:digit(this.minimumIntegerDigits,1,21),minimumFractionDigits:steady??minFraction??maxFraction,maximumFractionDigits:steady??maxFraction??minFraction,minimumSignificantDigits:minSignificant,maximumSignificantDigits:maxSignificant};type==="currency"&&(options.currency=typeof this.currency=="string"&&this.currency.trim()||"USD",options.currencyDisplay=CURRENCY_DISPLAYS.includes(this.currencyDisplay)?this.currencyDisplay:"symbol");const formatter=getNumberFormat(this.effectiveLocale,options),text=formatter.format(n);return n<0&&text===formatter.format(-0)?formatter.format(0):text}catch{return""}}render(){const shown=this.format(this.displayValue??finiteNumber(this.startValue,0)),final=this.format(finiteNumber(this.value,0));return shown===final?html`<span part="base"><span part="value">${final}</span></span>`:html`<span part="base"><span part="value" aria-hidden="true">${shown}</span><span class="sr-only">${final}</span></span>`}}__decorate([property({converter:blankNumberConverter(0)})],LyraNumberTicker.prototype,"value",void 0),__decorate([property({attribute:"start-value",converter:blankNumberConverter(0)})],LyraNumberTicker.prototype,"startValue",void 0),__decorate([property({converter:blankNumberConverter(2e3)})],LyraNumberTicker.prototype,"duration",void 0),__decorate([property({converter:blankNumberConverter(0)})],LyraNumberTicker.prototype,"delay",void 0),__decorate([property()],LyraNumberTicker.prototype,"easing",void 0),__decorate([property({type:Boolean})],LyraNumberTicker.prototype,"eager",void 0),__decorate([property()],LyraNumberTicker.prototype,"type",void 0),__decorate([property({type:Boolean,attribute:"without-grouping"})],LyraNumberTicker.prototype,"withoutGrouping",void 0),__decorate([property()],LyraNumberTicker.prototype,"currency",void 0),__decorate([property({attribute:"currency-display"})],LyraNumberTicker.prototype,"currencyDisplay",void 0),__decorate([property({attribute:"minimum-integer-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"minimumIntegerDigits",void 0),__decorate([property({attribute:"minimum-fraction-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"minimumFractionDigits",void 0),__decorate([property({attribute:"maximum-fraction-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"maximumFractionDigits",void 0),__decorate([property({attribute:"minimum-significant-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"minimumSignificantDigits",void 0),__decorate([property({attribute:"maximum-significant-digits",converter:optionalDigits})],LyraNumberTicker.prototype,"maximumSignificantDigits",void 0),__decorate([property({attribute:!1})],LyraNumberTicker.prototype,"valueFormatter",void 0),__decorate([state()],LyraNumberTicker.prototype,"displayValue",void 0);export{LyraNumberTicker};
@@ -162,7 +162,7 @@ export type LyraTourEndReason='completed'|'skip'|'escape'|'api'|'unmount'|'unava
162
162
  * unrecognized value falls back to `fixed`.
163
163
  * @cssprop [--lr-overlay-surface=var(--lr-color-surface-container-highest)] - Shared floating-surface fill of the step panel.
164
164
  * @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge of the step panel.
165
- * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius of the step panel.
165
+ * @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius of the step panel.
166
166
  * @cssprop [--lr-overlay-shadow-modal=var(--lr-shadow-l)] - Elevation of the step panel.
167
167
  * @cssprop [--lr-tour-button-hover-bg=var(--lr-color-brand-quiet)] - Hover background of the previous and skip buttons.
168
168
  * @cssprop --lr-tour-button-active-bg - Pressed background of those buttons. Defaults to the hover background mixed by the press step.