import { OrTreeMenu, TreeMenuSelection, type TreeMenuSorting, type TreeNode } from "@openremote/or-tree-menu"; import { RulesetLang, RulesetStatus, type RulesetUnion } from "@openremote/model"; import { type PropertyValues, type TemplateResult } from "lit"; import { type RulesConfig } from "./index"; export interface RuleTreeNode extends TreeNode { ruleset?: RulesetUnion; } export declare enum RuleTreeSorting { NAME = "name", CREATED_ON = "createdOn", LANGUAGE = "language", STATUS = "status" } export declare class OrRuleTree extends OrTreeMenu { static DEFAULT_ALLOWED_LANGUAGES: RulesetLang[]; /** * List of rules visible in the tree menu */ rules?: RulesetUnion[]; /** * Rules configuration object, for example to only allow certain ruleset types */ config?: RulesConfig; /** * Defines whether only global rulesets should be visible. */ global: boolean; /** * Sets every element in the tree to readonly mode */ readonly: boolean; nodes: RuleTreeNode[]; draggable: boolean; selection: TreeMenuSelection; sortOptions: any[]; sortBy: any; groupFirst: boolean; menuTitle: string; protected _loadingPromises: Promise[]; protected _selectedTypes: Set<"group" | "ruleset">; protected _cachedEmptyGroupNodes: RuleTreeNode[]; static get styles(): any[]; protected willUpdate(changedProps: PropertyValues): void; protected firstUpdated(changedProps: PropertyValues): void; protected _getSingleNodeSlotTemplate(node: RuleTreeNode): TemplateResult; protected _getGroupNodeSlotTemplate(node: RuleTreeNode): TemplateResult; protected _getHeaderTemplate(): TemplateResult; /** * HTML callback on when the global switch is toggled. * It normally toggles between 'global' and 'realm' rulesets when the user is a superuser. */ protected _onGlobalSwitch(ev: Event): void; /** * HTML callback on when the 'copy' menu option is pressed. * The function duplicates the current selected rule, and shows it inside the viewer window. */ protected _onCopyClicked(_ev: Event): void; /** * HTML callback on when the 'delete' menu option is pressed. * The function deletes the rule that is affiliated with selected tree node, * after prompting a modal that the user confirms this action. */ protected _onDeleteClicked(_ev: Event): void; /** * Utility function that returns a promise for deleting a list of rulesets, based on their type. * @param rulesets - List of rulesets to delete. */ protected _deleteRulesets(rulesets: RulesetUnion[]): Promise; /** * Public function that allows consumers to select a ruleset in the tree. * It finds the tree node in the UI, and selects it. * @param ruleset - ruleset in the tree to be selected * @param silent - skips the modal of 'discard changes' and does not dispatch an event */ selectRuleset(ruleset: RulesetUnion, silent?: boolean): void; protected _dispatchSelectEvent(nodes?: RuleTreeNode[]): boolean; deselectAllNodes(): void; /** * Gets the list of {@link RuleTreeNode[]} (tree nodes) based on a list of rulesets. * It maps the ruleset to the correct tree node format. For example, when a groupId is set in the Ruleset meta, * we group them together as children of a new group node. * @param rules - List of rulesets */ protected _getRuleNodes(rules: RulesetUnion[]): RuleTreeNode[]; /** * Utility function that returns a promise for loading the rulesets, based on the {@link global} and {@link realm} parameters * @param global - Whether only global rulesets should be loaded instead. * @param realm - Name of the realm to load (if global is `false` or `undefined`) */ protected _loadRulesets(global?: boolean, realm?: string): Promise; /** * Refreshes the tree content, and re-fetches the list of rules. */ refresh(): Promise; /** * Generates a HTML {@link TemplateResult} for the "add" button in the controls menu. */ protected _getAddActionTemplate(): TemplateResult; /** * HTML callback function for clicking a ruleset language in the "add rule" menu. * @param lang - The language to be used for adding a rule. * @param global - Whether to create a global ruleset or not. */ protected _onRulesetAddClick(lang: RulesetLang, global?: boolean): void; /** * HTML callback function for clicking "add group" in the controls menu. */ protected _onGroupAddClick(): void; protected _getSortFunction(sortBy?: TreeMenuSorting): (a: RuleTreeNode, b: RuleTreeNode) => number; /** * Utility function for getting the list of allowed languages based on {@link config} and {@link global} parameters. * @param config - Rules configuration to use * @param global - Whether only to include global rulesets */ protected _getAllowedLanguages(config?: RulesConfig | undefined, global?: boolean): RulesetLang[] | undefined; protected _isLegacyJavascriptRuleset(ruleset?: RulesetUnion): boolean; protected _isSelectedLegacyJavascriptRuleset(): boolean; /** * Utility function that gets a Material Design icon based on the ruleset language * @param lang - The ruleset language to get an icon of. */ protected _getRulesetLangIcon(lang?: RulesetLang): string; /** * Utility function that gets a Material Design icon based on the ruleset status * @param status - The ruleset status to get an icon of. */ protected _getRulesetStatusIcon(status?: RulesetStatus): string | undefined; /** * Utility function that returns a CSS class for the icon element, based on the ruleset status * @param status - The ruleset status to get a CSS class of. */ protected _getRulesetStatusColorClass(status?: RulesetStatus): string; } //# sourceMappingURL=or-rule-tree.d.ts.map