{"version":3,"file":"ui.buttons.bundle.js","sources":["../src/button/button-tag.js","../src/base-button.js","../src/button/button-color.js","../src/button/button-size.js","../src/button/button-icon.js","../src/button/button-state.js","../src/button/button-style.js","../src/button/button.js","../src/split-button/split-button-state.js","../src/split-button/split-sub-button-type.js","../src/split-button/split-sub-button.js","../src/split-button/split-button.js","../src/button-manager.js","../src/ibutton.js","../src/button/presets/add-button.js","../src/button/presets/apply-button.js","../src/button/presets/cancel-button.js","../src/button/presets/close-button.js","../src/button/presets/create-button.js","../src/button/presets/save-button.js","../src/button/presets/send-button.js","../src/button/presets/settings-button.js","../src/split-button/presets/add-split-button.js","../src/split-button/presets/apply-split-button.js","../src/split-button/presets/cancel-split-button.js","../src/split-button/presets/close-split-button.js","../src/split-button/presets/create-split-button.js","../src/split-button/presets/save-split-button.js","../src/split-button/presets/send-split-button.js"],"sourcesContent":["/**\n * @namespace {BX.UI}\n */\nexport default class ButtonTag\n{\n\tstatic BUTTON = 0;\n\tstatic LINK = 1;\n\tstatic SUBMIT = 2;\n\tstatic INPUT = 3;\n\tstatic DIV = 4;\n\tstatic SPAN = 5;\n}","import type IButton from './ibutton';\nimport ButtonTag from './button/button-tag';\nimport { Type, Tag, Dom, Event } from 'main.core';\nimport { type BaseButtonOptions } from './base-button-options';\nimport './ui.buttons.css';\n\nexport default class BaseButton implements IButton\n{\n\tconstructor(options: BaseButtonOptions)\n\t{\n\t\toptions = Type.isPlainObject(options) ? options : {};\n\t\tthis.options = Object.assign(this.getDefaultOptions(), options);\n\n\t\t/**\n\t\t * 'buttonNode', 'textNode' and counterNode options use only in ButtonManager.createFromNode\n\t\t */\n\t\tthis.button = Type.isDomNode(this.options.buttonNode) ? this.options.buttonNode : null;\n\t\tthis.textNode = Type.isDomNode(this.options.textNode) ? this.options.textNode : null;\n\t\tthis.counterNode = Type.isDomNode(this.options.counterNode) ? this.options.counterNode : null;\n\n\t\tthis.text = '';\n\t\tthis.counter = null;\n\t\tthis.events = {};\n\t\tthis.link = '';\n\t\tthis.maxWidth = null;\n\n\t\tthis.tag = this.isEnumValue(this.options.tag, ButtonTag) ? this.options.tag : ButtonTag.BUTTON;\n\t\tif (Type.isStringFilled(this.options.link))\n\t\t{\n\t\t\tthis.tag = ButtonTag.LINK;\n\t\t}\n\n\t\tthis.baseClass = Type.isStringFilled(this.options.baseClass) ? this.options.baseClass : '';\n\t\tthis.disabled = false;\n\n\t\tthis.handleEvent = this.handleEvent.bind(this);\n\n\t\tthis.init(); // needs to initialize private properties in derived classes.\n\n\t\tif (this.options.disabled === true)\n\t\t{\n\t\t\tthis.setDisabled();\n\t\t}\n\n\t\tthis.setText(this.options.text);\n\t\tthis.setCounter(this.options.counter);\n\t\tthis.setProps(this.options.props);\n\t\tthis.setDataSet(this.options.dataset);\n\t\tthis.addClass(this.options.className);\n\t\tthis.setLink(this.options.link);\n\t\tthis.setMaxWidth(this.options.maxWidth);\n\n\t\tthis.bindEvent('click', this.options.onclick);\n\t\tthis.bindEvents(this.options.events);\n\t}\n\n\t/**\n\t * @protected\n\t */\n\tinit(): void\n\t{\n\t\t// needs to initialize private properties in derived classes.\n\t}\n\n\t/**\n\t * @protected\n\t */\n\tgetDefaultOptions(): Object\n\t{\n\t\treturn {};\n\t}\n\n\t/**\n\t * @public\n\t * @return {HTMLElement}\n\t */\n\trender(): HTMLElement\n\t{\n\t\treturn this.getContainer();\n\t}\n\n\t/**\n\t * @public\n\t * @param {HTMLElement} node\n\t * @return {?HTMLElement}\n\t */\n\trenderTo(node: HTMLElement): HTMLElement | null\n\t{\n\t\tif (Type.isDomNode(node))\n\t\t{\n\t\t\treturn node.appendChild(this.getContainer());\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * @public\n\t * @return {HTMLElement}\n\t */\n\tgetContainer(): HTMLElement\n\t{\n\t\tif (this.button !== null)\n\t\t{\n\t\t\treturn this.button;\n\t\t}\n\n\t\tswitch (this.getTag())\n\t\t{\n\t\t\tcase ButtonTag.BUTTON:\n\t\t\tdefault:\n\t\t\t\tthis.button = Tag.render``;\n\t\t\t\tbreak;\n\t\t\tcase ButtonTag.INPUT:\n\t\t\t\tthis.button = Tag.render``;\n\t\t\t\tbreak;\n\t\t\tcase ButtonTag.LINK:\n\t\t\t\tthis.button = Tag.render``;\n\t\t\t\tbreak;\n\t\t\tcase ButtonTag.SUBMIT:\n\t\t\t\tthis.button = Tag.render``;\n\t\t\t\tbreak;\n\t\t\tcase ButtonTag.DIV:\n\t\t\t\tthis.button = Tag.render`
`;\n\t\t\t\tbreak;\n\t\t\tcase ButtonTag.SPAN:\n\t\t\t\tthis.button = Tag.render``;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn this.button;\n\t}\n\n\t/**\n\t * @protected\n\t * @return {string}\n\t */\n\tgetBaseClass(): string\n\t{\n\t\treturn this.baseClass;\n\t}\n\n\t/**\n\t * @public\n\t * @param {string} text\n\t * @return {this}\n\t */\n\tsetText(text: string): this\n\t{\n\t\tif (Type.isString(text))\n\t\t{\n\t\t\tthis.text = text;\n\n\t\t\tif (this.isInputType())\n\t\t\t{\n\t\t\t\tthis.getContainer().value = text;\n\t\t\t}\n\t\t\telse if (text.length > 0)\n\t\t\t{\n\t\t\t\tif (this.textNode === null)\n\t\t\t\t{\n\t\t\t\t\tthis.textNode = Tag.render``;\n\t\t\t\t}\n\n\t\t\t\tif (!this.textNode.parentNode)\n\t\t\t\t{\n\t\t\t\t\tDom.prepend(this.textNode, this.getContainer());\n\t\t\t\t}\n\n\t\t\t\tthis.textNode.textContent = text;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (this.textNode !== null)\n\t\t\t\t{\n\t\t\t\t\tDom.remove(this.textNode);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * @public\n\t * @return {string}\n\t */\n\tgetText(): string\n\t{\n\t\treturn this.text;\n\t}\n\n\t/**\n\t *\n\t * @param {number | string} counter\n\t * @return {this}\n\t */\n\tsetCounter(counter: number | string): this\n\t{\n\t\tif ([0, '0', '', null, false].includes(counter))\n\t\t{\n\t\t\tif (this.counterNode !== null)\n\t\t\t{\n\t\t\t\tDom.remove(this.counterNode);\n\t\t\t\tthis.counterNode = null;\n\t\t\t}\n\n\t\t\tthis.counter = null;\n\t\t}\n\t\telse if ((Type.isNumber(counter) && counter > 0) || Type.isStringFilled(counter))\n\t\t{\n\t\t\tif (this.isInputType())\n\t\t\t{\n\t\t\t\tthrow new Error('BX.UI.Button: an input button cannot have a counter.');\n\t\t\t}\n\n\t\t\tif (this.counterNode === null)\n\t\t\t{\n\t\t\t\tthis.counterNode = Tag.render``;\n\t\t\t\tDom.append(this.counterNode, this.getContainer());\n\t\t\t}\n\n\t\t\tthis.counter = counter;\n\t\t\tthis.counterNode.textContent = counter;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t *\n\t * @return {number | string | null}\n\t */\n\tgetCounter(): number | string | null\n\t{\n\t\treturn this.counter;\n\t}\n\n\t/**\n\t *\n\t * @param {string} link\n\t * @return {this}\n\t */\n\tsetLink(link: string): this\n\t{\n\t\tif (Type.isString(link))\n\t\t{\n\t\t\tif (this.getTag() !== ButtonTag.LINK)\n\t\t\t{\n\t\t\t\tthrow new Error('BX.UI.Button: only an anchor button tag supports a link.');\n\t\t\t}\n\n\t\t\tthis.getContainer().href = link;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t *\n\t * @return {string}\n\t */\n\tgetLink(): string\n\t{\n\t\treturn this.getContainer().href;\n\t}\n\n\tsetMaxWidth(maxWidth: number): this\n\t{\n\t\tif (Type.isNumber(maxWidth) && maxWidth > 0)\n\t\t{\n\t\t\tthis.maxWidth = maxWidth;\n\t\t\tthis.getContainer().style.maxWidth = `${maxWidth}px`;\n\t\t}\n\t\telse if (maxWidth === null)\n\t\t{\n\t\t\tthis.getContainer().style.removeProperty('max-width');\n\t\t\tthis.maxWidth = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tgetMaxWidth(): number | null\n\t{\n\t\treturn this.maxWidth;\n\t}\n\n\t/**\n\t * @public\n\t * @return {ButtonTag}\n\t */\n\tgetTag(): ButtonTag\n\t{\n\t\treturn this.tag;\n\t}\n\n\t/**\n\t * @public\n\t * @param {object.