@hashicorp/design-system-components 5.1.1-rc-20251210200104 → 5.2.0-rc-20251216180742
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/components/hds/breadcrumb/item.d.ts +4 -7
- package/declarations/components/hds/dropdown/index.d.ts +2 -0
- package/declarations/components/hds/interactive/index.d.ts +4 -8
- package/declarations/components/hds/popover-primitive/index.d.ts +2 -0
- package/declarations/components/hds/rich-tooltip/bubble.d.ts +2 -0
- package/declarations/components/hds/theme-context/index.d.ts +24 -0
- package/declarations/components/hds/theme-context/types.d.ts +19 -0
- package/declarations/components/hds/theme-switcher/index.d.ts +43 -0
- package/declarations/components.d.ts +2 -0
- package/declarations/modifiers/hds-anchored-position.d.ts +3 -1
- package/declarations/services/hds-theming.d.ts +57 -0
- package/declarations/services.d.ts +1 -0
- package/declarations/template-registry.d.ts +6 -0
- package/declarations/utils/hds-resolve-link-to-external.d.ts +12 -0
- package/dist/_app_/components/hds/theme-context.js +1 -0
- package/dist/_app_/components/hds/theme-switcher.js +1 -0
- package/dist/_app_/services/hds-theming.js +1 -0
- package/dist/components/hds/breadcrumb/item.js +17 -14
- package/dist/components/hds/breadcrumb/item.js.map +1 -1
- package/dist/components/hds/dropdown/index.js +3 -2
- package/dist/components/hds/dropdown/index.js.map +1 -1
- package/dist/components/hds/interactive/index.js +17 -18
- package/dist/components/hds/interactive/index.js.map +1 -1
- package/dist/components/hds/popover-primitive/index.js +1 -1
- package/dist/components/hds/popover-primitive/index.js.map +1 -1
- package/dist/components/hds/rich-tooltip/bubble.js +2 -1
- package/dist/components/hds/rich-tooltip/bubble.js.map +1 -1
- package/dist/components/hds/theme-context/index.js +45 -0
- package/dist/components/hds/theme-context/index.js.map +1 -0
- package/dist/components/hds/theme-context/types.js +27 -0
- package/dist/components/hds/theme-context/types.js.map +1 -0
- package/dist/components/hds/theme-switcher/index.js +100 -0
- package/dist/components/hds/theme-switcher/index.js.map +1 -0
- package/dist/components.js +2 -0
- package/dist/components.js.map +1 -1
- package/dist/modifiers/hds-anchored-position.js +42 -4
- package/dist/modifiers/hds-anchored-position.js.map +1 -1
- package/dist/services/hds-theming.js +214 -0
- package/dist/services/hds-theming.js.map +1 -0
- package/dist/services.js +1 -1
- package/dist/styles/@hashicorp/design-system-components-common.css +9584 -0
- package/dist/styles/@hashicorp/design-system-components-common.css.map +1 -0
- package/dist/styles/@hashicorp/design-system-components-common.scss +24 -0
- package/dist/styles/@hashicorp/design-system-components.css +544 -337
- package/dist/styles/@hashicorp/design-system-components.css.map +1 -0
- package/dist/styles/@hashicorp/design-system-components.scss +4 -62
- package/dist/styles/@hashicorp/design-system-power-select-overrides.css +229 -0
- package/dist/styles/@hashicorp/design-system-power-select-overrides.css.map +1 -0
- package/dist/styles/components/badge-count.scss +26 -76
- package/dist/styles/components/badge.scss +26 -131
- package/dist/styles/components/button.scss +5 -0
- package/dist/styles/components/dropdown.scss +3 -5
- package/dist/styles/components/form/file-input.scss +2 -2
- package/dist/styles/components/form/key-value-inputs.scss +2 -4
- package/dist/styles/components/form/super-select.scss +12 -4
- package/dist/styles/components/index.scss +52 -0
- package/dist/styles/components/theme-context.scss +12 -0
- package/dist/styles/mixins/_button.scss +82 -129
- package/dist/styles/mixins/_carbonization.scss +31 -0
- package/dist/styles/mixins/_interactive-dark-theme.scss +1 -1
- package/dist/utils/hds-resolve-link-to-external.js +33 -0
- package/dist/utils/hds-resolve-link-to-external.js.map +1 -0
- package/package.json +12 -4
- package/declarations/utils/hds-link-to-external.d.ts +0 -3
- package/dist/styles/@hashicorp/design-system-components.scss.map +0 -1
- package/dist/utils/hds-link-to-external.js +0 -10
- package/dist/utils/hds-link-to-external.js.map +0 -1
|
@@ -11,7 +11,7 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
11
11
|
import { g, i, n } from 'decorator-transforms/runtime';
|
|
12
12
|
import { setComponentTemplate } from '@ember/component';
|
|
13
13
|
|
|
14
|
-
var TEMPLATE = precompileTemplate("{{!\n Copyright IBM Corp. 2021, 2025\n SPDX-License-Identifier: MPL-2.0\n}}\n{{yield\n (hash\n setupPrimitiveContainer=this.setupPrimitiveContainer\n setupPrimitiveToggle=this.setupPrimitiveToggle\n setupPrimitivePopover=this.setupPrimitivePopover\n toggleElement=this._toggleElement\n popoverElement=this._popoverElement\n isOpen=this._isOpen\n showPopover=this.showPopover\n hidePopover=this.hidePopover\n togglePopover=this.togglePopover\n )\n}}");
|
|
14
|
+
var TEMPLATE = precompileTemplate("{{!\n Copyright IBM Corp. 2021, 2025\n SPDX-License-Identifier: MPL-2.0\n}}\n{{yield\n (hash\n setupPrimitiveContainer=this.setupPrimitiveContainer\n setupPrimitiveToggle=this.setupPrimitiveToggle\n setupPrimitivePopover=this.setupPrimitivePopover\n toggleElement=this._toggleElement\n popoverElement=this._popoverElement\n isOpen=this._isOpen\n showPopover=this.showPopover\n hidePopover=this.hidePopover\n togglePopover=this.togglePopover\n boundary=@boundary\n )\n}}");
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Copyright IBM Corp. 2021, 2025
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/popover-primitive/index.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2021, 2025\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert, warn } from '@ember/debug';\nimport { next } from '@ember/runloop';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\n\nimport registerEvent from '../../../modifiers/hds-register-event.ts';\nimport anchoredPositionModifier from '../../../modifiers/hds-anchored-position.ts';\n\nimport type { HdsAnchoredPositionOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport type { ModifierLike } from '@glint/template';\nimport type Owner from '@ember/owner';\n\nexport interface HdsPopoverPrimitiveSignature {\n Args: {\n isOpen?: boolean;\n enableSoftEvents?: boolean;\n enableClickEvents?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n };\n Blocks: {\n default: [\n {\n setupPrimitiveContainer: ModifierLike<SetupPrimitiveContainerModifier>;\n setupPrimitiveToggle: ModifierLike<SetupPrimitiveToggleModifier>;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n isOpen: boolean;\n showPopover: () => void;\n hidePopover: (event?: Event) => void;\n togglePopover: () => void;\n },\n ];\n };\n}\n\ninterface SetupPrimitiveContainerModifier {\n Element: HTMLElement;\n}\n\nexport interface SetupPrimitiveToggleModifier {\n Element: HTMLButtonElement;\n}\n\nexport interface SetupPrimitivePopoverModifier {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: { anchoredPositionOptions: HdsAnchoredPositionOptions };\n };\n}\n\nexport default class HdsPopoverPrimitive extends Component<HdsPopoverPrimitiveSignature> {\n @tracked private _isOpen;\n @tracked private _isClosing = false;\n @tracked private _anchoredPositionOptions?: HdsAnchoredPositionOptions;\n private _containerElement?: HTMLElement;\n private _toggleElement?: HTMLButtonElement;\n private _popoverElement?: HTMLElement;\n // this will enable \"soft\" events for the toggle (\"hover\" and \"focus\")\n enableSoftEvents = this.args.enableSoftEvents ?? false;\n // this will enable \"click\" events for the toggle\n enableClickEvents = this.args.enableClickEvents ?? false;\n private _timer?: ReturnType<typeof setTimeout> | null;\n\n constructor(owner: Owner, args: HdsPopoverPrimitiveSignature['Args']) {\n super(owner, args);\n this._isOpen = this.args.isOpen ?? false;\n }\n\n setupPrimitiveContainer = modifier<SetupPrimitiveContainerModifier>(\n (element: HTMLElement): void => {\n this._containerElement = element;\n\n // we register the \"soft\" events\n if (this.enableSoftEvents) {\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseenter',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseEnter,\n ]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseleave',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseLeave,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusin', this.onFocusIn]);\n }\n // we always want the focusOut event\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusout', this.onFocusOut]);\n }\n );\n\n setupPrimitiveToggle = modifier<SetupPrimitiveToggleModifier>(\n (element: HTMLButtonElement) => {\n this._toggleElement = element;\n\n assert(\n `The toggle element of \"Hds::PopoverPrimitive\" must be a <button>; element received: <${element.tagName.toLowerCase()}>`,\n element instanceof HTMLButtonElement\n );\n\n this._linkToggleAndPopover();\n\n // Return a teardown function to clean up the modifier's side effects.\n // This is a safeguard against bugs where this element might be\n // cached and re-parented in the DOM, rather than being fully destroyed.\n return () => {\n element.removeAttribute('aria-controls');\n element.removeAttribute('popovertarget');\n };\n }\n );\n\n setupPrimitivePopover = modifier(\n (\n element: HTMLElement,\n _positional,\n named: { anchoredPositionOptions: HdsAnchoredPositionOptions }\n ): void => {\n this._popoverElement = element;\n\n // We need to create a popoverId in order to connect the popover and the toggle with aria-controls\n // and an id is needed to implement `onclick` event listeners\n if (!this._popoverElement.id) {\n this._popoverElement.id = guidFor(this);\n }\n\n // this should be an extremely edge case, but in the case the popover needs to be initially forced to be open\n // we need to use the \"manual\" state to support the case of multiple \"menus\" opened at the same time\n // IMPORTANT! if a \"popover\" is set to \"open\" with a \"manual\" state, then it can't be closed via `esc` and `click outside`\n if (this.args.isOpen) {\n this._popoverElement.popover = 'manual';\n this._popoverElement.showPopover();\n } else {\n this._popoverElement.popover = 'auto';\n }\n\n // Register \"onBeforeToggle\" + \"onToggle\" callback functions to be called when a native 'toggle' event is dispatched\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._popoverElement, [\n 'beforetoggle',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onBeforeTogglePopover,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._popoverElement, ['toggle', this.onTogglePopover]);\n\n // we need to spread the argument because if it's set via `{{ hash … }}` Ember complains when we overwrite one of its values\n this._anchoredPositionOptions = {\n ...named.anchoredPositionOptions,\n };\n\n this._linkToggleAndPopover();\n }\n );\n\n // Apply the `hds-anchored-position` modifier to the \"popover\" element\n // (notice: this function runs the first time when the element the modifier was applied to is inserted into the DOM, and it autotracks while running.\n // Any tracked values that it accesses will be tracked, including the arguments it receives, and if any of them changes, the function will run again)\n // This modifiers uses the Floating UI library to provide:\n // - positioning of the \"popover\" in relation to the \"toggle\"\n // - collision detection (optional)\n private _applyAnchoredPositionModifier(): void {\n if (\n this._toggleElement !== undefined &&\n this._popoverElement !== undefined &&\n this._anchoredPositionOptions !== undefined\n ) {\n // eslint-disable-next-line ember/no-runloop\n next((): void => {\n // @ts-expect-error: known issue with type of invocation\n anchoredPositionModifier(\n this._popoverElement, // element the modifier is attached to\n [this._toggleElement], // positional arguments\n this._anchoredPositionOptions // named arguments\n );\n });\n }\n }\n\n private _linkToggleAndPopover(): void {\n if (\n this._toggleElement === undefined ||\n this._popoverElement === undefined\n ) {\n return;\n }\n\n const popoverId = this._popoverElement.id;\n\n this._toggleElement.setAttribute('aria-controls', popoverId);\n\n if (this.enableClickEvents) {\n this._toggleElement.setAttribute('popovertarget', popoverId);\n } else {\n this._toggleElement.removeAttribute('popovertarget');\n }\n\n this._applyAnchoredPositionModifier();\n }\n\n @action\n showPopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.showPopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`showPopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.show-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n // the event may be passed by the `on` modifier, so we need to keep it as an argument here\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n hidePopover(_event?: Event): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.hidePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`hidePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.hide-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n togglePopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.togglePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`togglePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.toggle-popover-action.invocation-failed',\n }\n );\n }\n }\n\n // fired just _before_ the \"popover\" is shown or hidden\n @action\n onBeforeTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'closed') {\n // we need this flag to check if it's in the \"closing\" process,\n // because the browser automatically returns the focus to the \"trigger\" button\n // and this would re-open immediately the popover because of the `focusin` event\n this._isClosing = true;\n }\n }\n\n // fired just _after_ the \"popover\" is shown or hidden\n @action\n onTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'open') {\n this._isOpen = true;\n\n // we call the \"onOpen\" callback if it exists (and is a function)\n const { onOpen } = this.args;\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else {\n this._isOpen = false;\n\n // reset the \"isClosing\" flag (the `toggle` event is fired _after_ the popover is closed)\n this._isClosing = false;\n\n // if the popover was initially forced to be open (using the \"manual\" state) then revert its status to `auto` once the user interacts with it\n if (this.args.isOpen) {\n if (this._popoverElement) {\n this._popoverElement.popover = 'auto';\n }\n }\n\n // we call the \"onClose\" callback if it exists (and is a function)\n const { onClose } = this.args;\n if (typeof onClose === 'function') {\n onClose();\n }\n }\n }\n\n @action\n onMouseEnter(): void {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n\n @action\n onFocusIn(): void {\n // don't re-open the popover if the focus is returned because the closing\n if (!this._isClosing) {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n }\n\n @action\n onMouseLeave(): void {\n this._timer = setTimeout((): void => this.hidePopover(), 500);\n }\n\n @action\n onFocusOut(event: FocusEvent): void {\n if (this._containerElement) {\n let isFocusStillInside = false;\n if (\n event.relatedTarget &&\n // if the related target is not part of the disclosed content we close the disclosed container\n this._containerElement.contains(event.relatedTarget as Node)\n ) {\n isFocusStillInside = true;\n } else if (\n document.activeElement &&\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n this._containerElement.contains(document.activeElement)\n ) {\n isFocusStillInside = true;\n }\n // if the target receiving the focus is _not_ part of the disclosed content we close the disclosed container\n if (!isFocusStillInside) {\n this.hidePopover();\n }\n }\n }\n}\n"],"names":["HdsPopoverPrimitive","Component","g","prototype","tracked","i","void 0","_containerElement","_toggleElement","_popoverElement","enableSoftEvents","args","enableClickEvents","_timer","constructor","owner","_isOpen","isOpen","setupPrimitiveContainer","modifier","element","registerEvent","onMouseEnter","onMouseLeave","onFocusIn","onFocusOut","setupPrimitiveToggle","assert","tagName","toLowerCase","HTMLButtonElement","_linkToggleAndPopover","removeAttribute","setupPrimitivePopover","_positional","named","id","guidFor","popover","showPopover","onBeforeTogglePopover","onTogglePopover","_anchoredPositionOptions","anchoredPositionOptions","_applyAnchoredPositionModifier","undefined","next","anchoredPositionModifier","popoverId","setAttribute","error","warn","JSON","stringify","n","action","hidePopover","_event","togglePopover","event","newState","_isClosing","onOpen","onClose","clearTimeout","setTimeout","isFocusStillInside","relatedTarget","contains","document","activeElement","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AA0De,MAAMA,mBAAmB,SAASC,SAAS,CAA+B;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACtFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,CAAA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Aa,CAAC,EACvD;AACAJ,QAAAA,kBAAkB,GAAG,IAAI;AAC3B,MAAA;AACA;MACA,IAAI,CAACA,kBAAkB,EAAE;QACvB,IAAI,CAACV,WAAW,EAAE;AACpB,MAAA;AACF,IAAA;AACF,EAAA;AAAC,EAAA;IAAAF,CAAA,CAAA,IAAA,CAAAnD,SAAA,EAAA,YAAA,EAAA,CAtBAoD,MAAM,CAAA,CAAA;AAAA;AAuBT;AAACgB,oBAAA,CAAAC,QAAA,EA/SoBxE,mBAAmB,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/popover-primitive/index.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2021, 2025\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert, warn } from '@ember/debug';\nimport { next } from '@ember/runloop';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\n\nimport registerEvent from '../../../modifiers/hds-register-event.ts';\nimport anchoredPositionModifier from '../../../modifiers/hds-anchored-position.ts';\n\nimport type { HdsAnchoredPositionOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport type { ModifierLike } from '@glint/template';\nimport type Owner from '@ember/owner';\n\nexport interface HdsPopoverPrimitiveSignature {\n Args: {\n isOpen?: boolean;\n enableSoftEvents?: boolean;\n enableClickEvents?: boolean;\n boundary?: HdsAnchoredPositionOptions['boundary'];\n onOpen?: () => void;\n onClose?: () => void;\n };\n Blocks: {\n default: [\n {\n setupPrimitiveContainer: ModifierLike<SetupPrimitiveContainerModifier>;\n setupPrimitiveToggle: ModifierLike<SetupPrimitiveToggleModifier>;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n isOpen: boolean;\n showPopover: () => void;\n hidePopover: (event?: Event) => void;\n togglePopover: () => void;\n boundary?: HdsAnchoredPositionOptions['boundary'];\n },\n ];\n };\n}\n\ninterface SetupPrimitiveContainerModifier {\n Element: HTMLElement;\n}\n\nexport interface SetupPrimitiveToggleModifier {\n Element: HTMLButtonElement;\n}\n\nexport interface SetupPrimitivePopoverModifier {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: { anchoredPositionOptions: HdsAnchoredPositionOptions };\n };\n}\n\nexport default class HdsPopoverPrimitive extends Component<HdsPopoverPrimitiveSignature> {\n @tracked private _isOpen;\n @tracked private _isClosing = false;\n @tracked private _anchoredPositionOptions?: HdsAnchoredPositionOptions;\n private _containerElement?: HTMLElement;\n private _toggleElement?: HTMLButtonElement;\n private _popoverElement?: HTMLElement;\n // this will enable \"soft\" events for the toggle (\"hover\" and \"focus\")\n enableSoftEvents = this.args.enableSoftEvents ?? false;\n // this will enable \"click\" events for the toggle\n enableClickEvents = this.args.enableClickEvents ?? false;\n private _timer?: ReturnType<typeof setTimeout> | null;\n\n constructor(owner: Owner, args: HdsPopoverPrimitiveSignature['Args']) {\n super(owner, args);\n this._isOpen = this.args.isOpen ?? false;\n }\n\n setupPrimitiveContainer = modifier<SetupPrimitiveContainerModifier>(\n (element: HTMLElement): void => {\n this._containerElement = element;\n\n // we register the \"soft\" events\n if (this.enableSoftEvents) {\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseenter',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseEnter,\n ]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._containerElement, [\n 'mouseleave',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onMouseLeave,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusin', this.onFocusIn]);\n }\n // we always want the focusOut event\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._containerElement, ['focusout', this.onFocusOut]);\n }\n );\n\n setupPrimitiveToggle = modifier<SetupPrimitiveToggleModifier>(\n (element: HTMLButtonElement) => {\n this._toggleElement = element;\n\n assert(\n `The toggle element of \"Hds::PopoverPrimitive\" must be a <button>; element received: <${element.tagName.toLowerCase()}>`,\n element instanceof HTMLButtonElement\n );\n\n this._linkToggleAndPopover();\n\n // Return a teardown function to clean up the modifier's side effects.\n // This is a safeguard against bugs where this element might be\n // cached and re-parented in the DOM, rather than being fully destroyed.\n return () => {\n element.removeAttribute('aria-controls');\n element.removeAttribute('popovertarget');\n };\n }\n );\n\n setupPrimitivePopover = modifier(\n (\n element: HTMLElement,\n _positional,\n named: { anchoredPositionOptions: HdsAnchoredPositionOptions }\n ): void => {\n this._popoverElement = element;\n\n // We need to create a popoverId in order to connect the popover and the toggle with aria-controls\n // and an id is needed to implement `onclick` event listeners\n if (!this._popoverElement.id) {\n this._popoverElement.id = guidFor(this);\n }\n\n // this should be an extremely edge case, but in the case the popover needs to be initially forced to be open\n // we need to use the \"manual\" state to support the case of multiple \"menus\" opened at the same time\n // IMPORTANT! if a \"popover\" is set to \"open\" with a \"manual\" state, then it can't be closed via `esc` and `click outside`\n if (this.args.isOpen) {\n this._popoverElement.popover = 'manual';\n this._popoverElement.showPopover();\n } else {\n this._popoverElement.popover = 'auto';\n }\n\n // Register \"onBeforeToggle\" + \"onToggle\" callback functions to be called when a native 'toggle' event is dispatched\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this._popoverElement, [\n 'beforetoggle',\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.onBeforeTogglePopover,\n ]);\n // @ts-expect-error: known issue with type of invocation\n // eslint-disable-next-line @typescript-eslint/unbound-method\n registerEvent(this._popoverElement, ['toggle', this.onTogglePopover]);\n\n // we need to spread the argument because if it's set via `{{ hash … }}` Ember complains when we overwrite one of its values\n this._anchoredPositionOptions = {\n ...named.anchoredPositionOptions,\n };\n\n this._linkToggleAndPopover();\n }\n );\n\n // Apply the `hds-anchored-position` modifier to the \"popover\" element\n // (notice: this function runs the first time when the element the modifier was applied to is inserted into the DOM, and it autotracks while running.\n // Any tracked values that it accesses will be tracked, including the arguments it receives, and if any of them changes, the function will run again)\n // This modifiers uses the Floating UI library to provide:\n // - positioning of the \"popover\" in relation to the \"toggle\"\n // - collision detection (optional)\n private _applyAnchoredPositionModifier(): void {\n if (\n this._toggleElement !== undefined &&\n this._popoverElement !== undefined &&\n this._anchoredPositionOptions !== undefined\n ) {\n // eslint-disable-next-line ember/no-runloop\n next((): void => {\n // @ts-expect-error: known issue with type of invocation\n anchoredPositionModifier(\n this._popoverElement, // element the modifier is attached to\n [this._toggleElement], // positional arguments\n this._anchoredPositionOptions // named arguments\n );\n });\n }\n }\n\n private _linkToggleAndPopover(): void {\n if (\n this._toggleElement === undefined ||\n this._popoverElement === undefined\n ) {\n return;\n }\n\n const popoverId = this._popoverElement.id;\n\n this._toggleElement.setAttribute('aria-controls', popoverId);\n\n if (this.enableClickEvents) {\n this._toggleElement.setAttribute('popovertarget', popoverId);\n } else {\n this._toggleElement.removeAttribute('popovertarget');\n }\n\n this._applyAnchoredPositionModifier();\n }\n\n @action\n showPopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.showPopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`showPopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.show-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n // the event may be passed by the `on` modifier, so we need to keep it as an argument here\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n hidePopover(_event?: Event): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.hidePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`hidePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.hide-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n togglePopover(): void {\n try {\n if (this._popoverElement) {\n this._popoverElement.togglePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`togglePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.toggle-popover-action.invocation-failed',\n }\n );\n }\n }\n\n // fired just _before_ the \"popover\" is shown or hidden\n @action\n onBeforeTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'closed') {\n // we need this flag to check if it's in the \"closing\" process,\n // because the browser automatically returns the focus to the \"trigger\" button\n // and this would re-open immediately the popover because of the `focusin` event\n this._isClosing = true;\n }\n }\n\n // fired just _after_ the \"popover\" is shown or hidden\n @action\n onTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'open') {\n this._isOpen = true;\n\n // we call the \"onOpen\" callback if it exists (and is a function)\n const { onOpen } = this.args;\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else {\n this._isOpen = false;\n\n // reset the \"isClosing\" flag (the `toggle` event is fired _after_ the popover is closed)\n this._isClosing = false;\n\n // if the popover was initially forced to be open (using the \"manual\" state) then revert its status to `auto` once the user interacts with it\n if (this.args.isOpen) {\n if (this._popoverElement) {\n this._popoverElement.popover = 'auto';\n }\n }\n\n // we call the \"onClose\" callback if it exists (and is a function)\n const { onClose } = this.args;\n if (typeof onClose === 'function') {\n onClose();\n }\n }\n }\n\n @action\n onMouseEnter(): void {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n\n @action\n onFocusIn(): void {\n // don't re-open the popover if the focus is returned because the closing\n if (!this._isClosing) {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n this.showPopover();\n }\n }\n\n @action\n onMouseLeave(): void {\n this._timer = setTimeout((): void => this.hidePopover(), 500);\n }\n\n @action\n onFocusOut(event: FocusEvent): void {\n if (this._containerElement) {\n let isFocusStillInside = false;\n if (\n event.relatedTarget &&\n // if the related target is not part of the disclosed content we close the disclosed container\n this._containerElement.contains(event.relatedTarget as Node)\n ) {\n isFocusStillInside = true;\n } else if (\n document.activeElement &&\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n this._containerElement.contains(document.activeElement)\n ) {\n isFocusStillInside = true;\n }\n // if the target receiving the focus is _not_ part of the disclosed content we close the disclosed container\n if (!isFocusStillInside) {\n this.hidePopover();\n }\n }\n }\n}\n"],"names":["HdsPopoverPrimitive","Component","g","prototype","tracked","i","void 0","_containerElement","_toggleElement","_popoverElement","enableSoftEvents","args","enableClickEvents","_timer","constructor","owner","_isOpen","isOpen","setupPrimitiveContainer","modifier","element","registerEvent","onMouseEnter","onMouseLeave","onFocusIn","onFocusOut","setupPrimitiveToggle","assert","tagName","toLowerCase","HTMLButtonElement","_linkToggleAndPopover","removeAttribute","setupPrimitivePopover","_positional","named","id","guidFor","popover","showPopover","onBeforeTogglePopover","onTogglePopover","_anchoredPositionOptions","anchoredPositionOptions","_applyAnchoredPositionModifier","undefined","next","anchoredPositionModifier","popoverId","setAttribute","error","warn","JSON","stringify","n","action","hidePopover","_event","togglePopover","event","newState","_isClosing","onOpen","onClose","clearTimeout","setTimeout","isFocusStillInside","relatedTarget","contains","document","activeElement","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;AA4De,MAAMA,mBAAmB,SAASC,SAAS,CAA+B;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CACtFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,QAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CACPC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAsB,KAAK;AAAA,IAAA,CAAA,CAAA;AAAA;AAAA,EAAA,WAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,YAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,0BAAA,EAAA,CAClCC,OAAO,CAAA,CAAA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A,EA/SoBxE,mBAAmB,CAAA;;;;"}
|
|
@@ -47,7 +47,8 @@ class HdsRichTooltipBubble extends Component {
|
|
|
47
47
|
offsetOptions: this.args.offset ?? 12,
|
|
48
48
|
enableCollisionDetection: this.args.enableCollisionDetection ?? true,
|
|
49
49
|
arrowSelector: `#${this.args.arrowId}`,
|
|
50
|
-
arrowPadding: 12
|
|
50
|
+
arrowPadding: 12,
|
|
51
|
+
boundary: this.args.boundary
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubble.js","sources":["../../../../src/components/hds/rich-tooltip/bubble.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2021, 2025\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport type { ModifierLike } from '@glint/template';\nimport type { SetupPrimitivePopoverModifier } from '../popover-primitive';\nimport type { HdsAnchoredPositionOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport {\n DEFAULT_PLACEMENT,\n PLACEMENTS,\n} from '../../../modifiers/hds-anchored-position.ts';\n\nexport interface HdsRichTooltipBubbleSignature {\n Args: {\n placement?: HdsAnchoredPositionOptions['placement'];\n offset?: HdsAnchoredPositionOptions['offsetOptions'];\n enableCollisionDetection?: HdsAnchoredPositionOptions['enableCollisionDetection'];\n width?: string;\n height?: string;\n isOpen?: boolean;\n popoverId: string;\n arrowId: string;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsRichTooltipBubble extends Component<HdsRichTooltipBubbleSignature> {\n /**\n * @param placement\n * @type {string}\n * @description Determines the position of the \"popover\"\n */\n get placement(): HdsAnchoredPositionOptions['placement'] {\n const { placement = DEFAULT_PLACEMENT } = this.args;\n\n assert(\n `@placement for \"Hds::RichTooltip::Bubble\" must be one of the following: ${PLACEMENTS.join(\n ', '\n )}; received: ${placement}`,\n PLACEMENTS.includes(placement)\n );\n\n return placement;\n }\n\n get enableCollisionDetection(): HdsAnchoredPositionOptions['enableCollisionDetection'] {\n return this.args.enableCollisionDetection ?? true;\n }\n\n get sizingStyles(): Record<string, string> {\n const sizingStyles: {\n width?: string;\n 'max-width'?: string;\n height?: string;\n 'max-height'?: string;\n } = {};\n\n if (this.args.width) {\n sizingStyles['width'] = this.args.width;\n sizingStyles['max-width'] = 'none';\n }\n\n if (this.args.height) {\n sizingStyles['height'] = this.args.height;\n sizingStyles['max-height'] = 'none';\n }\n\n return sizingStyles;\n }\n\n get anchoredPositionOptions(): {\n placement: HdsAnchoredPositionOptions['placement'];\n offsetOptions: HdsAnchoredPositionOptions['offsetOptions'];\n enableCollisionDetection: HdsAnchoredPositionOptions['enableCollisionDetection'];\n arrowSelector: string;\n arrowPadding: HdsAnchoredPositionOptions['arrowPadding'];\n } {\n // custom options specific for the `RichTooltip` component\n // for details see the `hds-anchored-position` modifier\n return {\n placement: this.placement,\n offsetOptions: this.args.offset ?? 12,\n enableCollisionDetection: this.args.enableCollisionDetection ?? true,\n arrowSelector: `#${this.args.arrowId}`,\n arrowPadding: 12,\n };\n }\n}\n"],"names":["HdsRichTooltipBubble","Component","placement","DEFAULT_PLACEMENT","args","assert","PLACEMENTS","join","includes","enableCollisionDetection","sizingStyles","width","height","anchoredPositionOptions","offsetOptions","offset","arrowSelector","arrowId","arrowPadding","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"file":"bubble.js","sources":["../../../../src/components/hds/rich-tooltip/bubble.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2021, 2025\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport type { ModifierLike } from '@glint/template';\nimport type { SetupPrimitivePopoverModifier } from '../popover-primitive';\nimport type { HdsAnchoredPositionOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport {\n DEFAULT_PLACEMENT,\n PLACEMENTS,\n} from '../../../modifiers/hds-anchored-position.ts';\n\nexport interface HdsRichTooltipBubbleSignature {\n Args: {\n placement?: HdsAnchoredPositionOptions['placement'];\n offset?: HdsAnchoredPositionOptions['offsetOptions'];\n enableCollisionDetection?: HdsAnchoredPositionOptions['enableCollisionDetection'];\n width?: string;\n height?: string;\n isOpen?: boolean;\n popoverId: string;\n arrowId: string;\n boundary?: HdsAnchoredPositionOptions['boundary'];\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsRichTooltipBubble extends Component<HdsRichTooltipBubbleSignature> {\n /**\n * @param placement\n * @type {string}\n * @description Determines the position of the \"popover\"\n */\n get placement(): HdsAnchoredPositionOptions['placement'] {\n const { placement = DEFAULT_PLACEMENT } = this.args;\n\n assert(\n `@placement for \"Hds::RichTooltip::Bubble\" must be one of the following: ${PLACEMENTS.join(\n ', '\n )}; received: ${placement}`,\n PLACEMENTS.includes(placement)\n );\n\n return placement;\n }\n\n get enableCollisionDetection(): HdsAnchoredPositionOptions['enableCollisionDetection'] {\n return this.args.enableCollisionDetection ?? true;\n }\n\n get sizingStyles(): Record<string, string> {\n const sizingStyles: {\n width?: string;\n 'max-width'?: string;\n height?: string;\n 'max-height'?: string;\n } = {};\n\n if (this.args.width) {\n sizingStyles['width'] = this.args.width;\n sizingStyles['max-width'] = 'none';\n }\n\n if (this.args.height) {\n sizingStyles['height'] = this.args.height;\n sizingStyles['max-height'] = 'none';\n }\n\n return sizingStyles;\n }\n\n get anchoredPositionOptions(): {\n placement: HdsAnchoredPositionOptions['placement'];\n offsetOptions: HdsAnchoredPositionOptions['offsetOptions'];\n enableCollisionDetection: HdsAnchoredPositionOptions['enableCollisionDetection'];\n arrowSelector: string;\n arrowPadding: HdsAnchoredPositionOptions['arrowPadding'];\n boundary: HdsAnchoredPositionOptions['boundary'];\n } {\n // custom options specific for the `RichTooltip` component\n // for details see the `hds-anchored-position` modifier\n return {\n placement: this.placement,\n offsetOptions: this.args.offset ?? 12,\n enableCollisionDetection: this.args.enableCollisionDetection ?? true,\n arrowSelector: `#${this.args.arrowId}`,\n arrowPadding: 12,\n boundary: this.args.boundary,\n };\n }\n}\n"],"names":["HdsRichTooltipBubble","Component","placement","DEFAULT_PLACEMENT","args","assert","PLACEMENTS","join","includes","enableCollisionDetection","sizingStyles","width","height","anchoredPositionOptions","offsetOptions","offset","arrowSelector","arrowId","arrowPadding","boundary","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAgCe,MAAMA,oBAAoB,SAASC,SAAS,CAAgC;AACzF;AACF;AACA;AACA;AACA;EACE,IAAIC,SAASA,GAA4C;IACvD,MAAM;AAAEA,MAAAA,SAAS,GAAGC;KAAmB,GAAG,IAAI,CAACC,IAAI;AAEnDC,IAAAA,MAAM,CACJ,CAAA,wEAAA,EAA2EC,UAAU,CAACC,IAAI,CACxF,IACF,CAAC,CAAA,YAAA,EAAeL,SAAS,CAAA,CAAE,EAC3BI,UAAU,CAACE,QAAQ,CAACN,SAAS,CAC/B,CAAC;AAED,IAAA,OAAOA,SAAS;AAClB,EAAA;EAEA,IAAIO,wBAAwBA,GAA2D;AACrF,IAAA,OAAO,IAAI,CAACL,IAAI,CAACK,wBAAwB,IAAI,IAAI;AACnD,EAAA;EAEA,IAAIC,YAAYA,GAA2B;IACzC,MAAMA,YAKL,GAAG,EAAE;AAEN,IAAA,IAAI,IAAI,CAACN,IAAI,CAACO,KAAK,EAAE;MACnBD,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAACN,IAAI,CAACO,KAAK;AACvCD,MAAAA,YAAY,CAAC,WAAW,CAAC,GAAG,MAAM;AACpC,IAAA;AAEA,IAAA,IAAI,IAAI,CAACN,IAAI,CAACQ,MAAM,EAAE;MACpBF,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAACN,IAAI,CAACQ,MAAM;AACzCF,MAAAA,YAAY,CAAC,YAAY,CAAC,GAAG,MAAM;AACrC,IAAA;AAEA,IAAA,OAAOA,YAAY;AACrB,EAAA;EAEA,IAAIG,uBAAuBA,GAOzB;AACA;AACA;IACA,OAAO;MACLX,SAAS,EAAE,IAAI,CAACA,SAAS;AACzBY,MAAAA,aAAa,EAAE,IAAI,CAACV,IAAI,CAACW,MAAM,IAAI,EAAE;AACrCN,MAAAA,wBAAwB,EAAE,IAAI,CAACL,IAAI,CAACK,wBAAwB,IAAI,IAAI;AACpEO,MAAAA,aAAa,EAAE,CAAA,CAAA,EAAI,IAAI,CAACZ,IAAI,CAACa,OAAO,CAAA,CAAE;AACtCC,MAAAA,YAAY,EAAE,EAAE;AAChBC,MAAAA,QAAQ,EAAE,IAAI,CAACf,IAAI,CAACe;KACrB;AACH,EAAA;AACF;AAACC,oBAAA,CAAAC,QAAA,EA/DoBrB,oBAAoB,CAAA;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { assert } from '@ember/debug';
|
|
3
|
+
import { HdsThemeContextThemesValues, HdsThemeContextModesValues } from './types.js';
|
|
4
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
+
import { setComponentTemplate } from '@ember/component';
|
|
6
|
+
|
|
7
|
+
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<div class={{this.classNames}} ...attributes>{{yield}}</div>");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) HashiCorp, Inc.
|
|
11
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const CONTEXTUAL_THEMES = Object.values(HdsThemeContextThemesValues);
|
|
15
|
+
const CONTEXTUAL_MODES = Object.values(HdsThemeContextModesValues);
|
|
16
|
+
const CONTEXTUAL_VALUES = [...CONTEXTUAL_THEMES, ...CONTEXTUAL_MODES];
|
|
17
|
+
class HdsThemeContext extends Component {
|
|
18
|
+
constructor(owner, args) {
|
|
19
|
+
super(owner, args);
|
|
20
|
+
const {
|
|
21
|
+
context
|
|
22
|
+
} = args;
|
|
23
|
+
assert(`@context for "Hds::ThemeContext" must be one of the following: ${CONTEXTUAL_VALUES.join(', ')}; received: ${context}`, CONTEXTUAL_VALUES.includes(context));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Get the class names to apply to the component.
|
|
27
|
+
get classNames() {
|
|
28
|
+
const classes = ['hds-theme-context'];
|
|
29
|
+
const {
|
|
30
|
+
context
|
|
31
|
+
} = this.args;
|
|
32
|
+
|
|
33
|
+
// add "theme" or "mode" classes based on the @context arguments
|
|
34
|
+
if (CONTEXTUAL_THEMES.includes(context)) {
|
|
35
|
+
classes.push(`hds-theme-${context}`);
|
|
36
|
+
} else if (CONTEXTUAL_MODES.includes(context)) {
|
|
37
|
+
classes.push(`hds-mode-${context}`);
|
|
38
|
+
}
|
|
39
|
+
return classes.join(' ');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
setComponentTemplate(TEMPLATE, HdsThemeContext);
|
|
43
|
+
|
|
44
|
+
export { CONTEXTUAL_MODES, CONTEXTUAL_THEMES, CONTEXTUAL_VALUES, HdsThemeContext as default };
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/theme-context/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport type Owner from '@ember/owner';\n\nimport {\n HdsThemeContextThemesValues,\n HdsThemeContextModesValues,\n} from './types.ts';\nimport type { HdsThemeContexts } from './types.ts';\n\nimport type { HdsThemes, HdsModes } from '../../../services/hds-theming.ts';\n\nexport interface HdsThemeContextSignature {\n Args: {\n // can be either an `HdsTheme` or an `HdsMode`\n context: HdsThemeContexts;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLElement;\n}\n\nexport const CONTEXTUAL_THEMES: HdsThemes[] = Object.values(\n HdsThemeContextThemesValues\n);\nexport const CONTEXTUAL_MODES: HdsModes[] = Object.values(\n HdsThemeContextModesValues\n);\nexport const CONTEXTUAL_VALUES: HdsThemeContexts[] = [\n ...CONTEXTUAL_THEMES,\n ...CONTEXTUAL_MODES,\n];\n\nexport default class HdsThemeContext extends Component<HdsThemeContextSignature> {\n constructor(owner: Owner, args: HdsThemeContextSignature['Args']) {\n super(owner, args);\n\n const { context } = args;\n\n assert(\n `@context for \"Hds::ThemeContext\" must be one of the following: ${CONTEXTUAL_VALUES.join(\n ', '\n )}; received: ${context}`,\n CONTEXTUAL_VALUES.includes(context)\n );\n }\n\n // Get the class names to apply to the component.\n get classNames(): string {\n const classes = ['hds-theme-context'];\n\n const { context } = this.args;\n\n // add \"theme\" or \"mode\" classes based on the @context arguments\n if (CONTEXTUAL_THEMES.includes(context as HdsThemes)) {\n classes.push(`hds-theme-${context}`);\n } else if (CONTEXTUAL_MODES.includes(context as HdsModes)) {\n classes.push(`hds-mode-${context}`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["CONTEXTUAL_THEMES","Object","values","HdsThemeContextThemesValues","CONTEXTUAL_MODES","HdsThemeContextModesValues","CONTEXTUAL_VALUES","HdsThemeContext","Component","constructor","owner","args","context","assert","join","includes","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;;AAyBO,MAAMA,iBAA8B,GAAGC,MAAM,CAACC,MAAM,CACzDC,2BACF;AACO,MAAMC,gBAA4B,GAAGH,MAAM,CAACC,MAAM,CACvDG,0BACF;AACO,MAAMC,iBAAqC,GAAG,CACnD,GAAGN,iBAAiB,EACpB,GAAGI,gBAAgB;AAGN,MAAMG,eAAe,SAASC,SAAS,CAA2B;AAC/EC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,IAAsC,EAAE;AAChE,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;IAElB,MAAM;AAAEC,MAAAA;AAAQ,KAAC,GAAGD,IAAI;AAExBE,IAAAA,MAAM,CACJ,CAAA,+DAAA,EAAkEP,iBAAiB,CAACQ,IAAI,CACtF,IACF,CAAC,CAAA,YAAA,EAAeF,OAAO,CAAA,CAAE,EACzBN,iBAAiB,CAACS,QAAQ,CAACH,OAAO,CACpC,CAAC;AACH,EAAA;;AAEA;EACA,IAAII,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,mBAAmB,CAAC;IAErC,MAAM;AAAEL,MAAAA;KAAS,GAAG,IAAI,CAACD,IAAI;;AAE7B;AACA,IAAA,IAAIX,iBAAiB,CAACe,QAAQ,CAACH,OAAoB,CAAC,EAAE;AACpDK,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAA,UAAA,EAAaN,OAAO,EAAE,CAAC;IACtC,CAAC,MAAM,IAAIR,gBAAgB,CAACW,QAAQ,CAACH,OAAmB,CAAC,EAAE;AACzDK,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYN,OAAO,EAAE,CAAC;AACrC,IAAA;AAEA,IAAA,OAAOK,OAAO,CAACH,IAAI,CAAC,GAAG,CAAC;AAC1B,EAAA;AACF;AAACK,oBAAA,CAAAC,QAAA,EA7BoBb,eAAe,CAAA;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HdsThemeValues, HdsModesDarkValues, HdsModesLightValues } from '../../../services/hds-theming.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) HashiCorp, Inc.
|
|
5
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// re-export the enum values for the `HdsThemes` to use in the component
|
|
9
|
+
// note: using `as const` ensures Object.values() returns only the values (not keys _and_ values)
|
|
10
|
+
const HdsThemeContextThemesValues = {
|
|
11
|
+
Default: HdsThemeValues.Default,
|
|
12
|
+
System: HdsThemeValues.System,
|
|
13
|
+
Light: HdsThemeValues.Light,
|
|
14
|
+
Dark: HdsThemeValues.Dark
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// re-export the enum values for the `HdsModes` to use in the component
|
|
18
|
+
// note: using `as const` ensures Object.values() returns only the values (not keys _and_ values)
|
|
19
|
+
const HdsThemeContextModesValues = {
|
|
20
|
+
CdsG0: HdsModesLightValues.CdsG0,
|
|
21
|
+
CdsG10: HdsModesLightValues.CdsG10,
|
|
22
|
+
CdsG90: HdsModesDarkValues.CdsG90,
|
|
23
|
+
CdsG100: HdsModesDarkValues.CdsG100
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { HdsThemeContextModesValues, HdsThemeContextThemesValues };
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/components/hds/theme-context/types.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport {\n HdsThemeValues,\n HdsModesLightValues,\n HdsModesDarkValues,\n} from '../../../services/hds-theming.ts';\n\nimport type { HdsThemes, HdsModes } from '../../../services/hds-theming.ts';\n\n// re-export the enum values for the `HdsThemes` to use in the component\n// note: using `as const` ensures Object.values() returns only the values (not keys _and_ values)\nexport const HdsThemeContextThemesValues = {\n Default: HdsThemeValues.Default,\n System: HdsThemeValues.System,\n Light: HdsThemeValues.Light,\n Dark: HdsThemeValues.Dark,\n} as const;\n\n// re-export the enum values for the `HdsModes` to use in the component\n// note: using `as const` ensures Object.values() returns only the values (not keys _and_ values)\nexport const HdsThemeContextModesValues = {\n CdsG0: HdsModesLightValues.CdsG0,\n CdsG10: HdsModesLightValues.CdsG10,\n CdsG90: HdsModesDarkValues.CdsG90,\n CdsG100: HdsModesDarkValues.CdsG100,\n} as const;\n\nexport type HdsThemeContexts = HdsThemes | Exclude<HdsModes, 'default'>;\n"],"names":["HdsThemeContextThemesValues","Default","HdsThemeValues","System","Light","Dark","HdsThemeContextModesValues","CdsG0","HdsModesLightValues","CdsG10","CdsG90","HdsModesDarkValues","CdsG100"],"mappings":";;AAAA;AACA;AACA;AACA;;AAUA;AACA;AACO,MAAMA,2BAA2B,GAAG;EACzCC,OAAO,EAAEC,cAAc,CAACD,OAAO;EAC/BE,MAAM,EAAED,cAAc,CAACC,MAAM;EAC7BC,KAAK,EAAEF,cAAc,CAACE,KAAK;EAC3BC,IAAI,EAAEH,cAAc,CAACG;AACvB;;AAEA;AACA;AACO,MAAMC,0BAA0B,GAAG;EACxCC,KAAK,EAAEC,mBAAmB,CAACD,KAAK;EAChCE,MAAM,EAAED,mBAAmB,CAACC,MAAM;EAClCC,MAAM,EAAEC,kBAAkB,CAACD,MAAM;EACjCE,OAAO,EAAED,kBAAkB,CAACC;AAC9B;;;;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { inject } from '@ember/service';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
6
|
+
import { setComponentTemplate } from '@ember/component';
|
|
7
|
+
|
|
8
|
+
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n{{!\n ------------------------------------------------------------------------------------------\n IMPORTANT: this is a temporary implementation, while we wait for the design specifications\n ------------------------------------------------------------------------------------------\n}}\n\n<Hds::Dropdown\n @enableCollisionDetection={{true}}\n @matchToggleWidth={{@toggleIsFullWidth}}\n class=\"hds-theme-switcher-control\"\n ...attributes\n as |D|\n>\n <D.ToggleButton\n @color=\"secondary\"\n @size={{this.toggleSize}}\n @isFullWidth={{this.toggleIsFullWidth}}\n @text={{this.toggleContent.label}}\n @icon={{this.toggleContent.icon}}\n />\n {{#each-in this._options as |key data|}}\n <D.Interactive @icon={{data.icon}} {{on \"click\" (fn this.onSelectTheme data.theme)}}>{{data.label}}</D.Interactive>\n {{/each-in}}\n</Hds::Dropdown>");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) HashiCorp, Inc.
|
|
12
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const OPTIONS = {
|
|
16
|
+
default: {
|
|
17
|
+
theme: 'default',
|
|
18
|
+
icon: 'hashicorp',
|
|
19
|
+
label: 'Default'
|
|
20
|
+
},
|
|
21
|
+
system: {
|
|
22
|
+
theme: 'system',
|
|
23
|
+
icon: 'monitor',
|
|
24
|
+
label: 'System'
|
|
25
|
+
},
|
|
26
|
+
light: {
|
|
27
|
+
theme: 'light',
|
|
28
|
+
icon: 'sun',
|
|
29
|
+
label: 'Light'
|
|
30
|
+
},
|
|
31
|
+
dark: {
|
|
32
|
+
theme: 'dark',
|
|
33
|
+
icon: 'moon',
|
|
34
|
+
label: 'Dark'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
class HdsThemeSwitcher extends Component {
|
|
38
|
+
static {
|
|
39
|
+
g(this.prototype, "hdsTheming", [inject]);
|
|
40
|
+
}
|
|
41
|
+
#hdsTheming = (i(this, "hdsTheming"), void 0);
|
|
42
|
+
get toggleSize() {
|
|
43
|
+
return this.args.toggleSize ?? 'small';
|
|
44
|
+
}
|
|
45
|
+
get toggleIsFullWidth() {
|
|
46
|
+
return this.args.toggleIsFullWidth ?? false;
|
|
47
|
+
}
|
|
48
|
+
get toggleContent() {
|
|
49
|
+
if (this.currentTheme === 'default' && this.hasDefaultOption || this.currentTheme === 'system' && this.hasSystemOption || this.currentTheme === 'light' || this.currentTheme === 'dark') {
|
|
50
|
+
return {
|
|
51
|
+
label: OPTIONS[this.currentTheme].label,
|
|
52
|
+
icon: OPTIONS[this.currentTheme].icon
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
return {
|
|
56
|
+
label: 'Theme',
|
|
57
|
+
icon: undefined
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// note: we will use the `default` option in development, while migrating to the `cds` theming
|
|
63
|
+
// during this process, consumers will enable/disable this option via code logic or feature flag
|
|
64
|
+
get hasDefaultOption() {
|
|
65
|
+
return this.args.hasDefaultOption ?? false;
|
|
66
|
+
}
|
|
67
|
+
get hasSystemOption() {
|
|
68
|
+
return this.args.hasSystemOption ?? true;
|
|
69
|
+
}
|
|
70
|
+
get _options() {
|
|
71
|
+
const options = {
|
|
72
|
+
...OPTIONS
|
|
73
|
+
};
|
|
74
|
+
if (!this.hasDefaultOption) {
|
|
75
|
+
delete options.default;
|
|
76
|
+
}
|
|
77
|
+
if (!this.hasSystemOption) {
|
|
78
|
+
delete options.system;
|
|
79
|
+
}
|
|
80
|
+
return options;
|
|
81
|
+
}
|
|
82
|
+
get currentTheme() {
|
|
83
|
+
// we get the theme from the global service
|
|
84
|
+
return this.hdsTheming.currentTheme;
|
|
85
|
+
}
|
|
86
|
+
onSelectTheme(theme) {
|
|
87
|
+
// we set the theme in the global service (and provide an optional user-defined callback)
|
|
88
|
+
this.hdsTheming.setTheme({
|
|
89
|
+
theme,
|
|
90
|
+
onSetTheme: this.args.onSetTheme
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
static {
|
|
94
|
+
n(this.prototype, "onSelectTheme", [action]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
setComponentTemplate(TEMPLATE, HdsThemeSwitcher);
|
|
98
|
+
|
|
99
|
+
export { HdsThemeSwitcher as default };
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/theme-switcher/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\n// ------------------------------------------------------------------------------------------\n// IMPORTANT: this is a temporary implementation, while we wait for the design specifications\n// ------------------------------------------------------------------------------------------\n\nimport Component from '@glimmer/component';\nimport { inject as service } from '@ember/service';\nimport { action } from '@ember/object';\n\nimport type { HdsDropdownSignature } from '../dropdown/index.ts';\nimport type { HdsDropdownToggleButtonSignature } from '../dropdown/toggle/button.ts';\nimport type { HdsIconSignature } from '../icon/index.ts';\nimport type HdsThemingService from '../../../services/hds-theming.ts';\nimport type {\n HdsThemes,\n HdsOnSetThemeCallback,\n} from '../../../services/hds-theming.ts';\n\ninterface ThemeOption {\n theme: HdsThemes | undefined;\n icon: HdsIconSignature['Args']['name'];\n label: string;\n}\n\nconst OPTIONS: Record<HdsThemes, ThemeOption> = {\n default: { theme: 'default', icon: 'hashicorp', label: 'Default' },\n system: { theme: 'system', icon: 'monitor', label: 'System' },\n light: { theme: 'light', icon: 'sun', label: 'Light' },\n dark: { theme: 'dark', icon: 'moon', label: 'Dark' },\n};\n\nexport interface HdsThemeSwitcherSignature {\n Args: {\n toggleSize?: HdsDropdownToggleButtonSignature['Args']['size'];\n toggleIsFullWidth?: HdsDropdownToggleButtonSignature['Args']['isFullWidth'];\n hasDefaultOption?: boolean;\n hasSystemOption?: boolean;\n onSetTheme?: HdsOnSetThemeCallback;\n };\n Element: HdsDropdownSignature['Element'];\n}\n\nexport default class HdsThemeSwitcher extends Component<HdsThemeSwitcherSignature> {\n @service declare readonly hdsTheming: HdsThemingService;\n\n get toggleSize() {\n return this.args.toggleSize ?? 'small';\n }\n\n get toggleIsFullWidth() {\n return this.args.toggleIsFullWidth ?? false;\n }\n\n get toggleContent() {\n if (\n (this.currentTheme === 'default' && this.hasDefaultOption) ||\n (this.currentTheme === 'system' && this.hasSystemOption) ||\n this.currentTheme === 'light' ||\n this.currentTheme === 'dark'\n ) {\n return {\n label: OPTIONS[this.currentTheme].label,\n icon: OPTIONS[this.currentTheme].icon,\n };\n } else {\n return { label: 'Theme', icon: undefined };\n }\n }\n\n // note: we will use the `default` option in development, while migrating to the `cds` theming\n // during this process, consumers will enable/disable this option via code logic or feature flag\n get hasDefaultOption() {\n return this.args.hasDefaultOption ?? false;\n }\n\n get hasSystemOption() {\n return this.args.hasSystemOption ?? true;\n }\n\n get _options() {\n const options: Partial<typeof OPTIONS> = { ...OPTIONS };\n\n if (!this.hasDefaultOption) {\n delete options.default;\n }\n\n if (!this.hasSystemOption) {\n delete options.system;\n }\n\n return options;\n }\n\n get currentTheme() {\n // we get the theme from the global service\n return this.hdsTheming.currentTheme;\n }\n\n @action\n onSelectTheme(theme: HdsThemes | undefined): void {\n // we set the theme in the global service (and provide an optional user-defined callback)\n this.hdsTheming.setTheme({ theme, onSetTheme: this.args.onSetTheme });\n }\n}\n"],"names":["OPTIONS","default","theme","icon","label","system","light","dark","HdsThemeSwitcher","Component","g","prototype","service","i","void 0","toggleSize","args","toggleIsFullWidth","toggleContent","currentTheme","hasDefaultOption","hasSystemOption","undefined","_options","options","hdsTheming","onSelectTheme","setTheme","onSetTheme","n","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;;AAyBA,MAAMA,OAAuC,GAAG;AAC9CC,EAAAA,OAAO,EAAE;AAAEC,IAAAA,KAAK,EAAE,SAAS;AAAEC,IAAAA,IAAI,EAAE,WAAW;AAAEC,IAAAA,KAAK,EAAE;GAAW;AAClEC,EAAAA,MAAM,EAAE;AAAEH,IAAAA,KAAK,EAAE,QAAQ;AAAEC,IAAAA,IAAI,EAAE,SAAS;AAAEC,IAAAA,KAAK,EAAE;GAAU;AAC7DE,EAAAA,KAAK,EAAE;AAAEJ,IAAAA,KAAK,EAAE,OAAO;AAAEC,IAAAA,IAAI,EAAE,KAAK;AAAEC,IAAAA,KAAK,EAAE;GAAS;AACtDG,EAAAA,IAAI,EAAE;AAAEL,IAAAA,KAAK,EAAE,MAAM;AAAE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EA,IAAIE,QAAQA,GAAG;AACb,IAAA,MAAMC,OAAgC,GAAG;MAAE,GAAGxB;KAAS;AAEvD,IAAA,IAAI,CAAC,IAAI,CAACoB,gBAAgB,EAAE;MAC1B,OAAOI,OAAO,CAACvB,OAAO;AACxB,IAAA;AAEA,IAAA,IAAI,CAAC,IAAI,CAACoB,eAAe,EAAE;MACzB,OAAOG,OAAO,CAACnB,MAAM;AACvB,IAAA;AAEA,IAAA,OAAOmB,OAAO;AAChB,EAAA;EAEA,IAAIL,YAAYA,GAAG;AACjB;AACA,IAAA,OAAO,IAAI,CAACM,UAAU,CAACN,YAAY;AACrC,EAAA;EAGAO,aAAaA,CAACxB,KAA4B,EAAQ;AAChD;AACA,IAAA,IAAI,CAACuB,UAAU,CAACE,QAAQ,CAAC;MAAEzB,KAAK;AAAE0B,MAAAA,UAAU,EAAE,IAAI,CAACZ,IAAI,CAACY;AAAW,KAAC,CAAC;AACvE,EAAA;AAAC,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAlB,SAAA,EAAA,eAAA,EAAA,CAJAmB,MAAM,CAAA,CAAA;AAAA;AAKT;AAACC,oBAAA,CAAAC,QAAA,EA7DoBxB,gBAAgB,CAAA;;;;"}
|
package/dist/components.js
CHANGED
|
@@ -218,6 +218,8 @@ export { default as HdsTextBody } from './components/hds/text/body.js';
|
|
|
218
218
|
export { default as HdsTextCode } from './components/hds/text/code.js';
|
|
219
219
|
export { default as HdsTextDisplay } from './components/hds/text/display.js';
|
|
220
220
|
export { HdsTextAlignValues, HdsTextColorValues, HdsTextGroupValues, HdsTextSizeValues, HdsTextWeightValues } from './components/hds/text/types.js';
|
|
221
|
+
export { default as HdsThemeContext } from './components/hds/theme-context/index.js';
|
|
222
|
+
export { default as HdsThemeSwitcher } from './components/hds/theme-switcher/index.js';
|
|
221
223
|
export { default as HdsTime } from './components/hds/time/index.js';
|
|
222
224
|
export { default as HdsTimeSingle } from './components/hds/time/single.js';
|
|
223
225
|
export { default as HdsTimeRange } from './components/hds/time/range.js';
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -21,6 +21,21 @@ const ENABLE_COLLISION_DETECTION_OPTIONS = Object.values(HdsEnableCollisionDetec
|
|
|
21
21
|
// this refers to the minimum distance from the boundaries' edges (the viewport)
|
|
22
22
|
// before the floating element changes its position (flips, shifts, or autoplace itself)
|
|
23
23
|
const DEFAULT_EDGE_DISTANCE = 8;
|
|
24
|
+
// resolve boundary selector/values to Floating UI Boundary
|
|
25
|
+
const resolveBoundary = boundary => {
|
|
26
|
+
if (typeof boundary === 'string') {
|
|
27
|
+
// this is necessary to satisfy TypeScript
|
|
28
|
+
if (boundary === 'clippingAncestors') {
|
|
29
|
+
return 'clippingAncestors';
|
|
30
|
+
}
|
|
31
|
+
const el = document.querySelector(boundary);
|
|
32
|
+
assert('`hds-anchored-position` modifier - the `boundary` selector `' + boundary + '` did not resolve to an element', el !== null && el.nodeType === Node.ELEMENT_NODE);
|
|
33
|
+
return el;
|
|
34
|
+
} else {
|
|
35
|
+
return boundary;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
24
39
|
// we use this function to process all the options provided to the modifier in a single place,
|
|
25
40
|
// in relation to the Floating UI APIs, and keep the modifier code more clean/simple
|
|
26
41
|
const getFloatingUIOptions = options => {
|
|
@@ -43,8 +58,31 @@ const getFloatingUIOptions = options => {
|
|
|
43
58
|
enableCollisionDetection,
|
|
44
59
|
arrowElement,
|
|
45
60
|
arrowPadding,
|
|
46
|
-
matchToggleWidth
|
|
61
|
+
matchToggleWidth,
|
|
62
|
+
boundary
|
|
47
63
|
} = options;
|
|
64
|
+
const resolvedBoundary = resolveBoundary(boundary);
|
|
65
|
+
|
|
66
|
+
// build options for each type of collision detection, adding the `boundary` if defined
|
|
67
|
+
|
|
68
|
+
const flipOptsExtended = {
|
|
69
|
+
...flipOptions,
|
|
70
|
+
...(resolvedBoundary ? {
|
|
71
|
+
boundary: resolvedBoundary
|
|
72
|
+
} : {})
|
|
73
|
+
};
|
|
74
|
+
const autoPlacementOptsExtended = {
|
|
75
|
+
...autoPlacementOptions,
|
|
76
|
+
...(resolvedBoundary ? {
|
|
77
|
+
boundary: resolvedBoundary
|
|
78
|
+
} : {})
|
|
79
|
+
};
|
|
80
|
+
const shiftOptsExtended = {
|
|
81
|
+
...shiftOptions,
|
|
82
|
+
...(resolvedBoundary ? {
|
|
83
|
+
boundary: resolvedBoundary
|
|
84
|
+
} : {})
|
|
85
|
+
};
|
|
48
86
|
|
|
49
87
|
// we build dynamically the list of middleware functions to invoke, depending on the options provided
|
|
50
88
|
|
|
@@ -57,13 +95,13 @@ const getFloatingUIOptions = options => {
|
|
|
57
95
|
// https://floating-ui.com/docs/shift
|
|
58
96
|
// https://floating-ui.com/docs/autoPlacement
|
|
59
97
|
if (enableCollisionDetection === true || enableCollisionDetection === 'flip') {
|
|
60
|
-
middleware.push(flip(
|
|
98
|
+
middleware.push(flip(flipOptsExtended));
|
|
61
99
|
}
|
|
62
100
|
if (enableCollisionDetection === true || enableCollisionDetection === 'shift') {
|
|
63
|
-
middleware.push(shift(
|
|
101
|
+
middleware.push(shift(shiftOptsExtended));
|
|
64
102
|
}
|
|
65
103
|
if (enableCollisionDetection === 'auto') {
|
|
66
|
-
middleware.push(autoPlacement(
|
|
104
|
+
middleware.push(autoPlacement(autoPlacementOptsExtended));
|
|
67
105
|
}
|
|
68
106
|
|
|
69
107
|
// https://floating-ui.com/docs/arrow
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hds-anchored-position.js","sources":["../../src/modifiers/hds-anchored-position.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2021, 2025\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport { modifier } from 'ember-modifier';\nimport { assert } from '@ember/debug';\n\nimport {\n autoUpdate,\n computePosition,\n offset,\n flip,\n shift,\n limitShift,\n autoPlacement,\n arrow,\n // ---\n // this could be used in the future if we want to give consumers an option to hide the \"floating\" element when the \"anchor\" hides from the viewport\n // see: https://floating-ui.com/docs/hide\n // hide,\n // ---\n size,\n} from '@floating-ui/dom';\n\nimport type {\n Placement,\n Strategy,\n OffsetOptions,\n FlipOptions,\n ShiftOptions,\n AutoPlacementOptions,\n ArrowOptions,\n Middleware,\n} from '@floating-ui/dom';\n\nexport enum HdsEnableCollisionDetectionOptions {\n Shift = 'shift',\n Flip = 'flip',\n Auto = 'auto',\n}\n\nexport type HdsEnableCollisionDetection =\n `${HdsEnableCollisionDetectionOptions}`;\n\nexport const DEFAULT_PLACEMENT = 'bottom';\nexport const PLACEMENTS: Placement[] = [\n 'top',\n 'top-start',\n 'top-end',\n 'right',\n 'right-start',\n 'right-end',\n 'bottom',\n 'bottom-start',\n 'bottom-end',\n 'left',\n 'left-start',\n 'left-end',\n];\n\nexport const ENABLE_COLLISION_DETECTION_OPTIONS: HdsEnableCollisionDetection[] =\n Object.values(HdsEnableCollisionDetectionOptions);\n\n// share the same default value of \"padding\" for `flip/shift/autoPlacement` options\n// this refers to the minimum distance from the boundaries' edges (the viewport)\n// before the floating element changes its position (flips, shifts, or autoplace itself)\nconst DEFAULT_EDGE_DISTANCE = 8;\n\nexport type FloatingUIOptions = {\n placement?: Placement;\n strategy?: Strategy;\n offsetOptions?: OffsetOptions;\n flipOptions?: FlipOptions;\n shiftOptions?: ShiftOptions;\n autoPlacementOptions?: AutoPlacementOptions;\n middlewareExtra?: Middleware[];\n enableCollisionDetection?: boolean | HdsEnableCollisionDetection;\n arrowElement?: ArrowOptions['element'];\n arrowPadding?: ArrowOptions['padding'];\n matchToggleWidth?: boolean;\n};\n\nexport type HdsAnchoredPositionOptions = FloatingUIOptions & {\n arrowSelector?: string;\n};\n\n// we use this function to process all the options provided to the modifier in a single place,\n// in relation to the Floating UI APIs, and keep the modifier code more clean/simple\nexport const getFloatingUIOptions = (\n options: FloatingUIOptions\n): {\n placement: Placement;\n strategy: Strategy;\n middleware: Middleware[];\n} => {\n const {\n placement = DEFAULT_PLACEMENT,\n strategy = 'absolute', // we don't need to use `fixed` if we use the Popover API for the \"floating\" element (it puts the element in the `top-layer`)\n offsetOptions,\n flipOptions = { padding: DEFAULT_EDGE_DISTANCE },\n shiftOptions = { padding: DEFAULT_EDGE_DISTANCE, limiter: limitShift() },\n autoPlacementOptions = { padding: DEFAULT_EDGE_DISTANCE },\n middlewareExtra = [],\n enableCollisionDetection,\n arrowElement,\n arrowPadding,\n matchToggleWidth,\n } = options;\n\n // we build dynamically the list of middleware functions to invoke, depending on the options provided\n\n const middleware = [];\n\n // https://floating-ui.com/docs/offset\n middleware.push(offset(offsetOptions));\n\n // https://floating-ui.com/docs/flip\n // https://floating-ui.com/docs/shift\n // https://floating-ui.com/docs/autoPlacement\n if (\n enableCollisionDetection === true ||\n enableCollisionDetection === 'flip'\n ) {\n middleware.push(flip(flipOptions));\n }\n if (\n enableCollisionDetection === true ||\n enableCollisionDetection === 'shift'\n ) {\n middleware.push(shift(shiftOptions));\n }\n if (enableCollisionDetection === 'auto') {\n middleware.push(autoPlacement(autoPlacementOptions));\n }\n\n // https://floating-ui.com/docs/arrow\n if (arrowElement) {\n middleware.push(\n arrow({\n element: arrowElement,\n padding: arrowPadding ?? 0,\n })\n );\n }\n\n // https://floating-ui.com/docs/size#match-reference-width\n if (matchToggleWidth) {\n middleware.push(\n size({\n apply({ rects, elements }) {\n // wrap Object.assign inside a requestAnimationFrame to avoid ResizeObserver loop limit exceeded error\n // https://github.com/floating-ui/floating-ui/issues/1740\n requestAnimationFrame(() => {\n Object.assign(elements.floating.style, {\n width: `${rects.reference.width}px`,\n });\n });\n },\n })\n );\n }\n\n middleware.push(...middlewareExtra);\n\n return {\n placement,\n strategy,\n middleware,\n };\n};\n\nexport interface HdsAnchoredPositionSignature {\n Element: HTMLElement;\n Args: {\n Positional: [HTMLElement | SVGElement];\n Named: HdsAnchoredPositionOptions;\n };\n}\n\n// Notice: we use a function-based modifier here instead of a class-based one\n// because it's quite simple in its logic, and doesn't require injecting services\n// see: https://github.com/ember-modifier/ember-modifier#function-based-modifiers\n\nexport default modifier<HdsAnchoredPositionSignature>(\n (element, positional, named = {}) => {\n // the element that \"floats\" next to the \"anchor\" (whose position is calculated in relation to the anchor)\n // notice: this is the element the Ember modifier is attached to\n const _floatingElement = element;\n\n // the element that acts as an \"anchor\" for the \"floating\" element\n // it can be a DOM (string) selector or a DOM element\n // notice: it's expressed as \"positional\" argument (array of arguments) for the modifier\n const _anchorTarget = positional[0];\n const _anchorElement =\n typeof _anchorTarget === 'string'\n ? document.querySelector(_anchorTarget)\n : _anchorTarget;\n\n assert(\n '`hds-anchored-position` modifier - the provided \"anchoring\" element is not defined correctly',\n _anchorElement instanceof HTMLElement ||\n _anchorElement instanceof SVGElement\n );\n\n // the \"arrow\" element (optional) associated with the \"floating\" element\n // it can be a DOM selector (string) or a DOM element\n // notice: it's declared inside the \"named\" argument (object) for the modifier\n // but we need to extract it also here so it can be used to assign inline styles to it\n let arrowElement: HTMLElement | SVGElement | undefined;\n\n if (named.arrowElement) {\n assert(\n '`hds-anchored-position` modifier - the `element` provided for the \"arrow\" element is not a valid DOM node',\n named.arrowElement instanceof HTMLElement ||\n named.arrowElement instanceof SVGElement\n );\n\n arrowElement = named.arrowElement;\n } else if (named.arrowSelector) {\n assert(\n '`hds-anchored-position` modifier - the `selector` provided for the \"arrow\" element must be a string',\n typeof named.arrowSelector === 'string'\n );\n\n const selectedArrowElement = document.querySelector(named.arrowSelector);\n if (selectedArrowElement instanceof HTMLElement) {\n arrowElement = selectedArrowElement;\n } else {\n assert(\n '`hds-anchored-position` modifier - the `selector` provided for the \"arrow\" element is not a valid DOM selector'\n );\n }\n }\n\n // the Floating UI \"options\" to apply to the \"floating\" element\n // notice: we spread the `named` argument and override its `arrowElement` value instead of setting it directly because Ember complains that modifier's arguments must be immutable\n const floatingOptions = getFloatingUIOptions({ ...named, arrowElement });\n\n const computeFloatingPosition = async () => {\n // important to know: `computePosition()` is not stateful, it only positions the \"floating\" element once\n // see: https://floating-ui.com/docs/computePosition\n const state = await computePosition(\n _anchorElement,\n _floatingElement,\n floatingOptions\n );\n\n const { x, y, placement, strategy, middlewareData } = state;\n\n Object.assign(_floatingElement.style, {\n position: strategy,\n top: `${y}px`,\n left: `${x}px`,\n // TODO? commenting this for now, will need to make this conditional to some argument (and understand how this relates to the `@height` argument)\n // maxHeight: `${middlewareData.size.availableHeight - 10}px`,\n });\n\n if (arrowElement && middlewareData.arrow) {\n // we assign a \"data\" attribute to the \"arrow\" element so we can use CSS (in the consuming components) to position/rotate it accordingly and we avoid calculating at runtime values that technically we already know\n // (similar to what Tippy.js does: https://github.com/atomiks/tippyjs/blob/master/src/scss/svg-arrow.scss)\n // IMPORTANT: floating-ui assumes the \"arrow\" container is square!\n arrowElement.setAttribute(\n 'data-hds-anchored-arrow-placement',\n placement\n );\n\n // we set `x` or `y` value (depends on the position of the arrow in relation to the \"floating\" element placement)\n // see: https://floating-ui.com/docs/arrow#usage\n Object.assign(arrowElement.style, {\n left:\n middlewareData.arrow.x != null ? `${middlewareData.arrow.x}px` : '',\n top:\n middlewareData.arrow.y != null ? `${middlewareData.arrow.y}px` : '',\n });\n }\n };\n\n // the `autoUpdate` function automatically updates the position of the floating element when necessary.\n // it should only be called when the floating element is mounted on the DOM or visible on the screen.\n // it returns a \"cleanup\" function that should be invoked when the floating element is removed from the DOM or hidden from the screen.\n // see: https://floating-ui.com/docs/autoUpdate\n const cleanupFloatingUI = autoUpdate(\n _anchorElement,\n _floatingElement,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n computeFloatingPosition\n );\n\n // this (teardown) function is run when the element is removed from the DOM\n return (): void => {\n cleanupFloatingUI();\n };\n }\n);\n"],"names":["HdsEnableCollisionDetectionOptions","DEFAULT_PLACEMENT","PLACEMENTS","ENABLE_COLLISION_DETECTION_OPTIONS","Object","values","DEFAULT_EDGE_DISTANCE","getFloatingUIOptions","options","placement","strategy","offsetOptions","flipOptions","padding","shiftOptions","limiter","limitShift","autoPlacementOptions","middlewareExtra","enableCollisionDetection","arrowElement","arrowPadding","matchToggleWidth","middleware","push","offset","flip","shift","autoPlacement","arrow","element","size","apply","rects","elements","requestAnimationFrame","assign","floating","style","width","reference","modifier","positional","named","_floatingElement","_anchorTarget","_anchorElement","document","querySelector","assert","HTMLElement","SVGElement","arrowSelector","selectedArrowElement","floatingOptions","computeFloatingPosition","state","computePosition","x","y","middlewareData","position","top","left","setAttribute","cleanupFloatingUI","autoUpdate"],"mappings":";;;;AAAA;AACA;AACA;AACA;;AAiCA,IAAYA,kCAAkC,0BAAlCA,kCAAkC,EAAA;EAAlCA,kCAAkC,CAAA,OAAA,CAAA,GAAA,OAAA;EAAlCA,kCAAkC,CAAA,MAAA,CAAA,GAAA,MAAA;EAAlCA,kCAAkC,CAAA,MAAA,CAAA,GAAA,MAAA;AAAA,EAAA,OAAlCA,kCAAkC;AAAA,CAAA,CAAA,EAAA;AASvC,MAAMC,iBAAiB,GAAG;AAC1B,MAAMC,UAAuB,GAAG,CACrC,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,UAAU;AAGL,MAAMC,kCAAiE,GAC5EC,MAAM,CAACC,MAAM,CAACL,kCAAkC;;AAElD;A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AAE;AAChCyB,QAAAA,IAAI,EACFH,cAAc,CAAC/B,KAAK,CAAC6B,CAAC,IAAI,IAAI,GAAG,CAAA,EAAGE,cAAc,CAAC/B,KAAK,CAAC6B,CAAC,CAAA,EAAA,CAAI,GAAG,EAAE;AACrEI,QAAAA,GAAG,EACDF,cAAc,CAAC/B,KAAK,CAAC8B,CAAC,IAAI,IAAI,GAAG,CAAA,EAAGC,cAAc,CAAC/B,KAAK,CAAC8B,CAAC,IAAI,GAAG;AACrE,OAAC,CAAC;AACJ,IAAA;EACF,CAAC;;AAED;AACA;AACA;AACA;AACA,EAAA,MAAMM,iBAAiB,GAAGC,UAAU,CAClCpB,cAAc,EACdF,gBAAgB;AAChB;AACAW,EAAAA,uBACF,CAAC;;AAED;AACA,EAAA,OAAO,MAAY;AACjBU,IAAAA,iBAAiB,EAAE;EACrB,CAAC;AACH,CACF,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"hds-anchored-position.js","sources":["../../src/modifiers/hds-anchored-position.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2021, 2025\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport { modifier } from 'ember-modifier';\nimport { assert } from '@ember/debug';\n\nimport {\n autoUpdate,\n computePosition,\n offset,\n flip,\n shift,\n limitShift,\n autoPlacement,\n arrow,\n // ---\n // this could be used in the future if we want to give consumers an option to hide the \"floating\" element when the \"anchor\" hides from the viewport\n // see: https://floating-ui.com/docs/hide\n // hide,\n // ---\n size,\n} from '@floating-ui/dom';\n\nimport type {\n Placement,\n Strategy,\n OffsetOptions,\n FlipOptions,\n ShiftOptions,\n AutoPlacementOptions,\n ArrowOptions,\n Middleware,\n Boundary,\n} from '@floating-ui/dom';\n\ntype BoundaryExtended = Boundary | (string & {});\n\nexport enum HdsEnableCollisionDetectionOptions {\n Shift = 'shift',\n Flip = 'flip',\n Auto = 'auto',\n}\n\nexport type HdsEnableCollisionDetection =\n `${HdsEnableCollisionDetectionOptions}`;\n\nexport const DEFAULT_PLACEMENT = 'bottom';\nexport const PLACEMENTS: Placement[] = [\n 'top',\n 'top-start',\n 'top-end',\n 'right',\n 'right-start',\n 'right-end',\n 'bottom',\n 'bottom-start',\n 'bottom-end',\n 'left',\n 'left-start',\n 'left-end',\n];\n\nexport const ENABLE_COLLISION_DETECTION_OPTIONS: HdsEnableCollisionDetection[] =\n Object.values(HdsEnableCollisionDetectionOptions);\n\n// share the same default value of \"padding\" for `flip/shift/autoPlacement` options\n// this refers to the minimum distance from the boundaries' edges (the viewport)\n// before the floating element changes its position (flips, shifts, or autoplace itself)\nconst DEFAULT_EDGE_DISTANCE = 8;\n\nexport type FloatingUIOptions = {\n placement?: Placement;\n strategy?: Strategy;\n offsetOptions?: OffsetOptions;\n flipOptions?: FlipOptions;\n shiftOptions?: ShiftOptions;\n autoPlacementOptions?: AutoPlacementOptions;\n middlewareExtra?: Middleware[];\n enableCollisionDetection?: boolean | HdsEnableCollisionDetection;\n arrowElement?: ArrowOptions['element'];\n arrowPadding?: ArrowOptions['padding'];\n matchToggleWidth?: boolean;\n boundary?: BoundaryExtended;\n};\n\nexport type HdsAnchoredPositionOptions = FloatingUIOptions & {\n arrowSelector?: string;\n};\n\n// resolve boundary selector/values to Floating UI Boundary\nconst resolveBoundary = (boundary?: BoundaryExtended): Boundary | undefined => {\n if (typeof boundary === 'string') {\n // this is necessary to satisfy TypeScript\n if (boundary === 'clippingAncestors') {\n return 'clippingAncestors';\n }\n const el = document.querySelector(boundary);\n assert(\n '`hds-anchored-position` modifier - the `boundary` selector `' +\n boundary +\n '` did not resolve to an element',\n el !== null && el.nodeType === Node.ELEMENT_NODE\n );\n return el;\n } else {\n return boundary;\n }\n};\n\n// we use this function to process all the options provided to the modifier in a single place,\n// in relation to the Floating UI APIs, and keep the modifier code more clean/simple\nexport const getFloatingUIOptions = (\n options: FloatingUIOptions\n): {\n placement: Placement;\n strategy: Strategy;\n middleware: Middleware[];\n} => {\n const {\n placement = DEFAULT_PLACEMENT,\n strategy = 'absolute', // we don't need to use `fixed` if we use the Popover API for the \"floating\" element (it puts the element in the `top-layer`)\n offsetOptions,\n flipOptions = { padding: DEFAULT_EDGE_DISTANCE },\n shiftOptions = { padding: DEFAULT_EDGE_DISTANCE, limiter: limitShift() },\n autoPlacementOptions = { padding: DEFAULT_EDGE_DISTANCE },\n middlewareExtra = [],\n enableCollisionDetection,\n arrowElement,\n arrowPadding,\n matchToggleWidth,\n boundary,\n } = options;\n\n const resolvedBoundary = resolveBoundary(boundary);\n\n // build options for each type of collision detection, adding the `boundary` if defined\n\n const flipOptsExtended: FlipOptions = {\n ...flipOptions,\n ...(resolvedBoundary ? { boundary: resolvedBoundary } : {}),\n };\n\n const autoPlacementOptsExtended: AutoPlacementOptions = {\n ...autoPlacementOptions,\n ...(resolvedBoundary ? { boundary: resolvedBoundary } : {}),\n };\n\n const shiftOptsExtended: ShiftOptions = {\n ...shiftOptions,\n ...(resolvedBoundary ? { boundary: resolvedBoundary } : {}),\n };\n\n // we build dynamically the list of middleware functions to invoke, depending on the options provided\n\n const middleware = [];\n\n // https://floating-ui.com/docs/offset\n middleware.push(offset(offsetOptions));\n\n // https://floating-ui.com/docs/flip\n // https://floating-ui.com/docs/shift\n // https://floating-ui.com/docs/autoPlacement\n if (\n enableCollisionDetection === true ||\n enableCollisionDetection === 'flip'\n ) {\n middleware.push(flip(flipOptsExtended));\n }\n if (\n enableCollisionDetection === true ||\n enableCollisionDetection === 'shift'\n ) {\n middleware.push(shift(shiftOptsExtended));\n }\n if (enableCollisionDetection === 'auto') {\n middleware.push(autoPlacement(autoPlacementOptsExtended));\n }\n\n // https://floating-ui.com/docs/arrow\n if (arrowElement) {\n middleware.push(\n arrow({\n element: arrowElement,\n padding: arrowPadding ?? 0,\n })\n );\n }\n\n // https://floating-ui.com/docs/size#match-reference-width\n if (matchToggleWidth) {\n middleware.push(\n size({\n apply({ rects, elements }) {\n // wrap Object.assign inside a requestAnimationFrame to avoid ResizeObserver loop limit exceeded error\n // https://github.com/floating-ui/floating-ui/issues/1740\n requestAnimationFrame(() => {\n Object.assign(elements.floating.style, {\n width: `${rects.reference.width}px`,\n });\n });\n },\n })\n );\n }\n\n middleware.push(...middlewareExtra);\n\n return {\n placement,\n strategy,\n middleware,\n };\n};\n\nexport interface HdsAnchoredPositionSignature {\n Element: HTMLElement;\n Args: {\n Positional: [HTMLElement | SVGElement];\n Named: HdsAnchoredPositionOptions;\n };\n}\n\n// Notice: we use a function-based modifier here instead of a class-based one\n// because it's quite simple in its logic, and doesn't require injecting services\n// see: https://github.com/ember-modifier/ember-modifier#function-based-modifiers\n\nexport default modifier<HdsAnchoredPositionSignature>(\n (element, positional, named = {}) => {\n // the element that \"floats\" next to the \"anchor\" (whose position is calculated in relation to the anchor)\n // notice: this is the element the Ember modifier is attached to\n const _floatingElement = element;\n\n // the element that acts as an \"anchor\" for the \"floating\" element\n // it can be a DOM (string) selector or a DOM element\n // notice: it's expressed as \"positional\" argument (array of arguments) for the modifier\n const _anchorTarget = positional[0];\n const _anchorElement =\n typeof _anchorTarget === 'string'\n ? document.querySelector(_anchorTarget)\n : _anchorTarget;\n\n assert(\n '`hds-anchored-position` modifier - the provided \"anchoring\" element is not defined correctly',\n _anchorElement instanceof HTMLElement ||\n _anchorElement instanceof SVGElement\n );\n\n // the \"arrow\" element (optional) associated with the \"floating\" element\n // it can be a DOM selector (string) or a DOM element\n // notice: it's declared inside the \"named\" argument (object) for the modifier\n // but we need to extract it also here so it can be used to assign inline styles to it\n let arrowElement: HTMLElement | SVGElement | undefined;\n\n if (named.arrowElement) {\n assert(\n '`hds-anchored-position` modifier - the `element` provided for the \"arrow\" element is not a valid DOM node',\n named.arrowElement instanceof HTMLElement ||\n named.arrowElement instanceof SVGElement\n );\n\n arrowElement = named.arrowElement;\n } else if (named.arrowSelector) {\n assert(\n '`hds-anchored-position` modifier - the `selector` provided for the \"arrow\" element must be a string',\n typeof named.arrowSelector === 'string'\n );\n\n const selectedArrowElement = document.querySelector(named.arrowSelector);\n if (selectedArrowElement instanceof HTMLElement) {\n arrowElement = selectedArrowElement;\n } else {\n assert(\n '`hds-anchored-position` modifier - the `selector` provided for the \"arrow\" element is not a valid DOM selector'\n );\n }\n }\n\n // the Floating UI \"options\" to apply to the \"floating\" element\n // notice: we spread the `named` argument and override its `arrowElement` value instead of setting it directly because Ember complains that modifier's arguments must be immutable\n const floatingOptions = getFloatingUIOptions({ ...named, arrowElement });\n\n const computeFloatingPosition = async () => {\n // important to know: `computePosition()` is not stateful, it only positions the \"floating\" element once\n // see: https://floating-ui.com/docs/computePosition\n const state = await computePosition(\n _anchorElement,\n _floatingElement,\n floatingOptions\n );\n\n const { x, y, placement, strategy, middlewareData } = state;\n\n Object.assign(_floatingElement.style, {\n position: strategy,\n top: `${y}px`,\n left: `${x}px`,\n // TODO? commenting this for now, will need to make this conditional to some argument (and understand how this relates to the `@height` argument)\n // maxHeight: `${middlewareData.size.availableHeight - 10}px`,\n });\n\n if (arrowElement && middlewareData.arrow) {\n // we assign a \"data\" attribute to the \"arrow\" element so we can use CSS (in the consuming components) to position/rotate it accordingly and we avoid calculating at runtime values that technically we already know\n // (similar to what Tippy.js does: https://github.com/atomiks/tippyjs/blob/master/src/scss/svg-arrow.scss)\n // IMPORTANT: floating-ui assumes the \"arrow\" container is square!\n arrowElement.setAttribute(\n 'data-hds-anchored-arrow-placement',\n placement\n );\n\n // we set `x` or `y` value (depends on the position of the arrow in relation to the \"floating\" element placement)\n // see: https://floating-ui.com/docs/arrow#usage\n Object.assign(arrowElement.style, {\n left:\n middlewareData.arrow.x != null ? `${middlewareData.arrow.x}px` : '',\n top:\n middlewareData.arrow.y != null ? `${middlewareData.arrow.y}px` : '',\n });\n }\n };\n\n // the `autoUpdate` function automatically updates the position of the floating element when necessary.\n // it should only be called when the floating element is mounted on the DOM or visible on the screen.\n // it returns a \"cleanup\" function that should be invoked when the floating element is removed from the DOM or hidden from the screen.\n // see: https://floating-ui.com/docs/autoUpdate\n const cleanupFloatingUI = autoUpdate(\n _anchorElement,\n _floatingElement,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n computeFloatingPosition\n );\n\n // this (teardown) function is run when the element is removed from the DOM\n return (): void => {\n cleanupFloatingUI();\n };\n }\n);\n"],"names":["HdsEnableCollisionDetectionOptions","DEFAULT_PLACEMENT","PLACEMENTS","ENABLE_COLLISION_DETECTION_OPTIONS","Object","values","DEFAULT_EDGE_DISTANCE","resolveBoundary","boundary","el","document","querySelector","assert","nodeType","Node","ELEMENT_NODE","getFloatingUIOptions","options","placement","strategy","offsetOptions","flipOptions","padding","shiftOptions","limiter","limitShift","autoPlacementOptions","middlewareExtra","enableCollisionDetection","arrowElement","arrowPadding","matchToggleWidth","resolvedBoundary","flipOptsExtended","autoPlacementOptsExtended","shiftOptsExtended","middleware","push","offset","flip","shift","autoPlacement","arrow","element","size","apply","rects","elements","requestAnimationFrame","assign","floating","style","width","reference","modifier","positional","named","_floatingElement","_anchorTarget","_anchorElement","HTMLElement","SVGElement","arrowSelector","selectedArrowElement","floatingOptions","computeFloatingPosition","state","computePosition","x","y","middlewareData","position","top","left","setAttribute","cleanupFloatingUI","autoUpdate"],"mappings":";;;;AAAA;AACA;AACA;AACA;;AAoCA,IAAYA,kCAAkC,0BAAlCA,kCAAkC,EAAA;EAAlCA,kCAAkC,CAAA,OAAA,CAAA,GAAA,OAAA;EAAlCA,kCAAkC,CAAA,MAAA,CAAA,GAAA,MAAA;EAAlCA,kCAAkC,CAAA,MAAA,CAAA,GAAA,MAAA;AAAA,EAAA,OAAlCA,kCAAkC;AAAA,CAAA,CAAA,EAAA;AASvC,MAAMC,iBAAiB,GAAG;AAC1B,MAAMC,UAAuB,GAAG,CACrC,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,UAAU;AAGL,MAAMC,kCAAiE,GAC5EC,MAAM,CAACC,MAAM,CAACL,kCAAkC;;AAElD;A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