dist/js/gnexus-ui-kit.js публикует API двумя способами:
Toasts.createSuccess("Saved", "Changes applied").show();
GNexusUIKit.Toasts.createInfo("Info", "Message").show();
GNexusUIKit.Helper GNexusUIKit.Toasts GNexusUIKit.Modals GNexusUIKit.advancedSelect GNexusUIKit.editableString GNexusUIKit.confirmPopup GNexusUIKit.Drawer GNexusUIKit.NavigationShell GNexusUIKit.Overlays GNexusUIKit.InputPatterns GNexusUIKit.Accordion
На DOMContentLoaded автоматически запускаются:
Overlays.init(); NavigationShell.init(); InputPatterns.init(); Accordion.init();
Если вы динамически вставляете HTML после загрузки страницы, можно повторно вызвать init для root-элемента:
GNexusUIKit.NavigationShell.init(document.querySelector("#dynamic-root"));
GNexusUIKit.InputPatterns.init(document.querySelector("#dynamic-root"));
GNexusUIKit.Accordion.init(document.querySelector("#dynamic-root"));
Модули защищены от повторной инициализации одного и того же root.
Компоненты используют declarative attributes:
data-navigation-toggledata-navigation-drawerdata-navigation-closedata-navigation-linkdata-dropdown-toggledata-popover-toggledata-tooltip-toggledata-input-cleardata-file-upload-inputdata-file-upload-previewdata-date-pickerНекоторые компоненты создаются через JS:
const drawer = GNexusUIKit.Drawer.create("details-drawer", {
title: "Details",
bodyText: "Drawer content",
position: "left"
});
drawer.show();
const modal = GNexusUIKit.Modals.create("edit-modal", {
title: "Edit",
bodyText: "Modal content"
});
modal.show();
GNexusUIKit.Toasts.createSuccess("Saved", "Changes applied").show();