import { InnerData, Position, TitleBarOptions } from './types/titlebar'; import { Menu } from './types/menu'; import 'custom-tauri-titlebar-bootstrap/dist/js/bootstrap.bundle.min.js'; import 'custom-tauri-titlebar-bootstrap/dist/css/bootstrap.min.css'; export default class Titlebar { private options; private start; private middle; private end; private slots; /** * Constructor to handle initialization of the Titlebar. This includes insertion of the Titlebar to the begining of the \ and the styles at the end of the \ * * @constructor * @param _options - Object containing customization settings for the titlebar * @param {string} [_options.className=titlebar] - The class name of the Titlebar container and the prefix used for all subclasses. If no class name is specified, "titlebar" is used as the default. If a custom class name is given, ensure you are using the given name when adding your own styles targeting subclasses. * @param {number} [_options.height=30] - The height of the titlebar, in pixels. * @param {string} [_options.theme] - Theme colors for the titlebar. Primary is used for the titlebar and secondary is used for the menu dropdowns. Please ensure that the provided colors are 6-digit hexidecimal codes. */ constructor(_options: Partial); private subclass; private createDropdownButton; private createDropdown; /** * Insert a div containing a dropdown menu into the titlebar * @async * @param menu - Object containing the structure of the menu * @param {Position} [position = start] - Position to insert the menu at. Defaults to "start" if unspecified. * @example * // Simple menu with a divider at the default position * titlebar.addMenu({ * label: 'File', * items: [ * { * type: 'item', * label: 'Open', * action: () => { open() } * }, * { type: 'divider' } * { * type: 'item', * label: 'Save', * action: () => { save() } * } * ] * }) */ addMenu(menu: Menu, position?: Position): Promise; /** * Insert a div containing an icon into the titlebar * * @param inner - Object containing the div's inner data and the method of insertion. * @param inner.type - Method of insertion into the titlebar. * - "src" creates an \ with its source set to inner.data. * - "element" inserts a user-defined Element into the div. * - "html" inserts html as a string into the div. * @param {Position} [position=start] - Position to insert the icon at. Defaults to "start" if unspecified. * @example * // insert an icon as an img element with src='../icon.svg' at the default position * titlebar.addIcon({type: 'src', data: '../icon.svg'}) * @example * // insert an icon as a fa-icon provided as an html string at the end position * titlebar.addIcon({type: 'html', data: ''}, 'end') */ addIcon(inner: InnerData, position?: Position): void; /** * Insert a div containing a title into the titlebar. * * @param text - Text to insert into the titlebar. * @param {Position} [position=middle] - Position to insert the icon at. Defaults to "middle" if unspecified. * @example * // insert the title 'Hello, world!' at the default position * titlebar.addTitle('Hello, world!') */ addTitle(text: string, position?: Position): void; /** * Insert a button into the titlebar * @param id - id to be assigned to the element * @param inner - Object containing the button's inner data and the method of insertion. * @param inner.type - Method of insertion into the titlebar. * - "src" creates an \ with its source set to inner.data. * - "element" inserts a user-defined Element into the button. * - "html" inserts html as a string into the button. * @param onClick - Event handler for when the button is clicked. * @param {Position} [position=end] - Position to insert the button at. Defaults to "end" if unspecified. * @example * // add a button with id 'close-button' at the default position which prints to the console when clicked * titlebar.addButton('close-button', { type: 'src', data: 'https://api.iconify.design/mdi:close.svg' }, () => console.log('close!')); ); */ addButton(id: string, inner: InnerData, onClick: (e: MouseEvent) => void, position?: Position): void; }