mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
620e86a9f1
Summary: Implements the new date filtering panel. Design results from long discussion between: Alex, Anais, Cyprien and Dmitry. Test environment: https://grist-new-date-range-filter.fly.dev/ Test Plan: Include various new tests. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3720
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
/**
|
|
*
|
|
* Returns a popup control allowing to open/close a popup using as content the element returned by
|
|
* the given func. Note that the `trigger` option is ignored by this function and that the default
|
|
* of the `attach` option is `body` instead of `null`.
|
|
*
|
|
* It allows you to bind the creation of the popup to a menu item as follow:
|
|
* const ctl = popupControl(triggerElem, (ctl) => buildDom(ctl));
|
|
* ...
|
|
* menuItem(elem => ctl.open(), 'do stuff...')
|
|
*/
|
|
|
|
import { domDispose } from "grainjs";
|
|
import { IOpenController, IPopupDomCreator, IPopupOptions, PopupControl } from "popweasel";
|
|
|
|
export function popupControl(reference: Element, domCreator: IPopupDomCreator, options: IPopupOptions): PopupControl {
|
|
|
|
function openFunc(openCtl: IOpenController) {
|
|
const content = domCreator(openCtl);
|
|
function dispose() { domDispose(content); }
|
|
return {content, dispose};
|
|
}
|
|
|
|
const ctl = PopupControl.create(null);
|
|
|
|
ctl.attachElem(reference, openFunc, {
|
|
attach: 'body',
|
|
boundaries: 'viewport',
|
|
...options,
|
|
trigger: undefined
|
|
});
|
|
|
|
return ctl;
|
|
}
|