Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/advice/dist/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/advice/dist/advice.bundle.js.map |
{"version":3,"file":"advice.bundle.js","sources":["../src/advice.js"],"sourcesContent":["import {Type, Tag, Dom} from 'main.core';\n\nimport './advice.css';\n\nexport const AdviceAnglePosition = Object.freeze({\n\tTOP: 'top',\n\tBOTTOM: 'bottom',\n});\n\nexport type AdviceContent = HTMLElement | string | null;\n\nexport type AdviceOptions = {\n\tavatarImg?: string,\n\tcontent?: AdviceContent,\n\ttext?: string,\n\tanglePosition?: string,\n}\n\nexport class Advice\n{\n\t#container: HTMLElement = null;\n\t#avatar: string;\n\t#anglePosition: AdviceAnglePosition;\n\n\t#content: AdviceContent = '';\n\t#textBoxBaseClassname = 'ui-advice__text-box';\n\t#containerBaseClassname = 'ui-advice';\n\n\tstatic AnglePosition = AdviceAnglePosition;\n\n\tconstructor(options: AdviceOptions)\n\t{\n\t\tthis.#avatar = Type.isString(options.avatarImg) ? options.avatarImg : '';\n\t\tthis.#anglePosition = this.#isValidAnglePosition(options.anglePosition) ? options.anglePosition : Advice.AnglePosition.TOP;\n\t\tthis.#content = this.#isValidContent(options.content) ? options.content : '';\n\n\t\tthis.#createContainer();\n\t}\n\n\tgetAvatar(): string\n\t{\n\t\treturn this.#avatar;\n\t}\n\n\tsetAvatar(avatarImg: string): string\n\t{\n\t\tthis.#avatar = avatarImg;\n\t\treturn this.#avatar;\n\t}\n\n\tgetContent(): AdviceContent\n\t{\n\t\treturn this.#content;\n\t}\n\n\tsetContent(content: AdviceContent): AdviceContent\n\t{\n\t\tif (this.#isValidContent(content))\n\t\t{\n\t\t\tthis.#content = content;\n\t\t\treturn this.#content;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t#getTextBoxClassname(): string\n\t{\n\t\tlet className = this.#textBoxBaseClassname;\n\n\t\tif (this.#anglePosition === AdviceAnglePosition.BOTTOM)\n\t\t{\n\t\t\tclassName += ' --angle-bottom';\n\t\t}\n\t\telse if (this.#anglePosition === AdviceAnglePosition.TOP)\n\t\t{\n\t\t\tclassName += ' --angle-top';\n\t\t}\n\t\telse\n\t\t{\n\t\t\tclassName += ' --angle-bottom';\n\t\t}\n\n\t\treturn className;\n\t}\n\n\t#getContainerClassname(): string\n\t{\n\t\tlet className = this.#containerBaseClassname;\n\t\tswitch (this.#anglePosition)\n\t\t{\n\t\t\tcase AdviceAnglePosition.BOTTOM: className += ' --angle-bottom'; break;\n\t\t\tcase AdviceAnglePosition.TOP: className+= ' --angle-top'; break;\n\t\t\tdefault: className += ' --angle-bottom';\n\t\t}\n\n\t\treturn className;\n\t}\n\n\t#getHtmlContent(): HTMLElement\n\t{\n\t\tif (Type.isString(this.#content))\n\t\t{\n\t\t\treturn Tag.render`<span>${this.#content}</span>`;\n\t\t}\n\n\t\treturn this.#content;\n\t}\n\n\t#createContainer(): HTMLElement\n\t{\n\t\tif (!this.#container)\n\t\t{\n\t\t\tthis.#container = Tag.render`\n\t\t\t\t<div class=\"${this.#getContainerClassname()}\">\n\t\t\t\t\t<div class=\"ui-advice__avatar-box\">\n\t\t\t\t\t\t<span class=\"ui-advice__avatar ui-icon ui-icon-common-user\">\n\t\t\t\t\t\t\t<i ${this.#avatar ? `style=\"background-image: url(${encodeURI(this.getAvatar())})\"` : ''}></i>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"${this.#getTextBoxClassname()}\"></div>\n\t\t\t\t</div>\n\t\t\t\t`;\n\n\t\t\tconst contentContainer = this.#container.querySelector(`.${this.#textBoxBaseClassname}`);\n\n\t\t\tDom.append(this.#getHtmlContent(), contentContainer);\n\t\t}\n\n\t\treturn this.#container;\n\t}\n\n\tgetContainer(): HTMLElement\n\t{\n\t\treturn this.#container;\n\t}\n\n\t#isValidAnglePosition(anglePosition: string): boolean\n\t{\n\t\treturn Type.isString(anglePosition) && Object.values(AdviceAnglePosition).includes(anglePosition);\n\t}\n\n\t#isValidContent(content: HTMLElement | string): boolean {\n\t\treturn Type.isString(content) || Type.isDomNode(content);\n\t}\n\n\trenderTo(targetContainer: HTMLElement): HTMLElement | null\n\t{\n\t\tif (Type.isDomNode(targetContainer))\n\t\t{\n\t\t\tDom.append(this.#container, targetContainer);\n\t\t\treturn targetContainer;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"],"names":["AdviceAnglePosition","Object","freeze","TOP","BOTTOM","Advice","constructor","options","Type","isString","avatarImg","anglePosition","AnglePosition","content","getAvatar","setAvatar","getContent","setContent","getContainer","renderTo","targetContainer","isDomNode","Dom","append","className","Tag","render","encodeURI","contentContainer","querySelector","values","includes"],"mappings":";;;;;;;;AAAA,OAIaA,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAAC;GAChDC,GAAG,EAAE,KAAK;GACVC,MAAM,EAAE;CACT,CAAC,CAAC;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAWH,CAAO,MAAMC,MAAM,CACnB;GAWCC,WAAW,CAACC,OAAsB,EAClC;KAAA;OAAA;;KAAA;OAAA;;KAAA;OAAA;;KAAA;OAAA;;KAAA;OAAA;;KAAA;OAAA;;KAAA;OAAA;OAAA,OAX0B;;KAAI;OAAA;OAAA;;KAAA;OAAA;OAAA;;KAAA;OAAA;OAAA,OAIJ;;KAAE;OAAA;OAAA,OACJ;;KAAqB;OAAA;OAAA,OACnB;;KAMzB,4CAAI,sBAAWC,cAAI,CAACC,QAAQ,CAACF,OAAO,CAACG,SAAS,CAAC,GAAGH,OAAO,CAACG,SAAS,GAAG,EAAE;KACxE,4CAAI,oCAAkB,4CAAI,gDAAuBH,OAAO,CAACI,aAAa,IAAIJ,OAAO,CAACI,aAAa,GAAGN,MAAM,CAACO,aAAa,CAACT,GAAG;KAC1H,4CAAI,wBAAY,4CAAI,oCAAiBI,OAAO,CAACM,OAAO,IAAIN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