feat(overlays): make arrow config more composable (#1101)
This commit is contained in:
parent
4bacc17b16
commit
9142a53da3
2 changed files with 37 additions and 22 deletions
5
.changeset/proud-geckos-arrive.md
Normal file
5
.changeset/proud-geckos-arrive.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"@lion/overlays": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
overlays: make arrow config more composable
|
||||||
|
|
@ -4,7 +4,7 @@ import { OverlayMixin } from './OverlayMixin.js';
|
||||||
/**
|
/**
|
||||||
* @typedef {import('../types/OverlayConfig').OverlayConfig} OverlayConfig
|
* @typedef {import('../types/OverlayConfig').OverlayConfig} OverlayConfig
|
||||||
* @typedef {import('../types/ArrowMixinTypes').ArrowMixin} ArrowMixin
|
* @typedef {import('../types/ArrowMixinTypes').ArrowMixin} ArrowMixin
|
||||||
*
|
* @typedef {import('popper.js').PopperOptions} PopperOptions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -109,23 +109,34 @@ export const ArrowMixinImplementation = superclass =>
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
_defineOverlayConfig() {
|
_defineOverlayConfig() {
|
||||||
|
const superConfig = super._defineOverlayConfig() || {};
|
||||||
if (!this.hasArrow) {
|
if (!this.hasArrow) {
|
||||||
return super._defineOverlayConfig();
|
return superConfig;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...super._defineOverlayConfig(),
|
...superConfig,
|
||||||
popperConfig: {
|
popperConfig: {
|
||||||
...super._defineOverlayConfig()?.popperConfig,
|
...this._getPopperArrowConfig(superConfig.popperConfig),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {PopperOptions} popperConfigToExtendFrom
|
||||||
|
* @returns {PopperOptions}
|
||||||
|
*/
|
||||||
|
_getPopperArrowConfig(popperConfigToExtendFrom = {}) {
|
||||||
|
return {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
|
|
||||||
modifiers: {
|
modifiers: {
|
||||||
...super._defineOverlayConfig()?.popperConfig?.modifiers,
|
...popperConfigToExtendFrom.modifiers,
|
||||||
keepTogether: {
|
keepTogether: {
|
||||||
...super._defineOverlayConfig()?.popperConfig?.modifiers?.keepTogether,
|
...popperConfigToExtendFrom.modifiers?.keepTogether,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
arrow: {
|
arrow: {
|
||||||
...super._defineOverlayConfig()?.popperConfig?.modifiers?.arrow,
|
...popperConfigToExtendFrom.modifiers?.arrow,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -138,7 +149,6 @@ export const ArrowMixinImplementation = superclass =>
|
||||||
onUpdate: data => {
|
onUpdate: data => {
|
||||||
this.__syncFromPopperState(data);
|
this.__syncFromPopperState(data);
|
||||||
},
|
},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue