mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) New date filter with a calendar view
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
This commit is contained in:
34
app/client/lib/popupControl.ts
Normal file
34
app/client/lib/popupControl.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user