88 * See https://vaadin.com/commercial-license-and-service-terms for the full
99 * license.
1010 */
11- import { css , html , LitElement } from 'lit' ;
11+ import { css , html , LitElement , render } from 'lit' ;
1212import { defineCustomElement } from '@vaadin/component-base/src/define.js' ;
1313import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js' ;
1414import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js' ;
1515import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js' ;
1616import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js' ;
1717import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js' ;
1818import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js' ;
19- import { RichTextEditorPopupMixin } from './vaadin-rich-text-editor-popup-mixin.js' ;
2019
2120/**
2221 * An element used internally by `<vaadin-rich-text-editor>`. Not intended to be used separately.
2322 *
2423 * @customElement
2524 * @extends HTMLElement
26- * @mixes RichTextEditorPopupMixin
2725 * @private
2826 */
29- class RichTextEditorPopup extends RichTextEditorPopupMixin ( PolylitMixin ( LitElement ) ) {
27+ class RichTextEditorPopup extends PolylitMixin ( LitElement ) {
3028 static get is ( ) {
3129 return 'vaadin-rich-text-editor-popup' ;
3230 }
@@ -39,6 +37,31 @@ class RichTextEditorPopup extends RichTextEditorPopupMixin(PolylitMixin(LitEleme
3937 ` ;
4038 }
4139
40+ static get properties ( ) {
41+ return {
42+ target : {
43+ type : Object ,
44+ } ,
45+
46+ opened : {
47+ type : Boolean ,
48+ notify : true ,
49+ } ,
50+
51+ colors : {
52+ type : Array ,
53+ } ,
54+
55+ renderer : {
56+ type : Object ,
57+ } ,
58+ } ;
59+ }
60+
61+ static get observers ( ) {
62+ return [ '__openedOrTargetChanged(opened, target)' , '__colorsChanged(colors)' ] ;
63+ }
64+
4265 /** @protected */
4366 render ( ) {
4467 return html `
@@ -60,6 +83,41 @@ class RichTextEditorPopup extends RichTextEditorPopupMixin(PolylitMixin(LitEleme
6083 _onOpenedChanged ( event ) {
6184 this . opened = event . detail . value ;
6285 }
86+
87+ /** @private */
88+ _onOverlayEscapePress ( ) {
89+ this . target . focus ( ) ;
90+ }
91+
92+ /** @private */
93+ _onColorClick ( e ) {
94+ const { color } = e . target . dataset ;
95+ this . dispatchEvent ( new CustomEvent ( 'color-selected' , { detail : { color } } ) ) ;
96+ }
97+
98+ /** @private */
99+ __colorsChanged ( colors ) {
100+ this . renderer = ( root ) => {
101+ render (
102+ html `
103+ ${ colors . map (
104+ ( color ) => html `
105+ < button data-color ="${ color } " style ="background: ${ color } " @click ="${ this . _onColorClick } "> </ button >
106+ ` ,
107+ ) }
108+ ` ,
109+ root ,
110+ { host : this } ,
111+ ) ;
112+ } ;
113+ }
114+
115+ /** @private */
116+ __openedOrTargetChanged ( opened , target ) {
117+ if ( target ) {
118+ target . setAttribute ( 'aria-expanded' , opened ? 'true' : 'false' ) ;
119+ }
120+ }
63121}
64122
65123defineCustomElement ( RichTextEditorPopup ) ;
0 commit comments