{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-ui/src/dropdown/utils.js"],"names":["createDropdown","locale","ButtonClass","arguments","length","undefined","DropdownButtonView","buttonView","panelView","DropdownPanelView","dropdownView","DropdownView","bind","to","arrowView","addDefaultBehavior","addToolbarToDropdown","buttons","t","toolbarView","ToolbarView","set","extendTemplate","attributes","class","map","view","items","add","children","delegate","addListToDropdown","listView","ListView","bindTo","using","_ref","type","model","ListSeparatorView","_buttonView","listItemView","ListItemView","ButtonView","SwitchButtonView","apply","Object","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_2__","keys","closeDropdownOnBlur","closeDropdownOnExecute","focusDropdownContentsOnArrows","on","clickOutsideHandler","emitter","activator","isOpen","callback","contextElements","element","evt","source","keystrokes","data","cancel","focus","focusLast"],"mappings":";;;;;AAsFO,SAASA,EAAgBC,GAA2C,IAAnCC,EAAmCC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAArBG,OAC/CC,EAAa,IAAIL,EAAaD,GAE9BO,EAAY,IAAIC,OAAmBR,GACnCS,EAAe,IAAIC,OAAcV,EAAQM,EAAYC,GAY3D,OAVAD,EAAWK,KAAM,aAAcC,GAAIH,GAE9BH,aAAsBD,OAC1BC,EAAWK,KAAM,QAASC,GAAIH,EAAc,UAE5CH,EAAWO,UAAUF,KAAM,QAASC,GAAIH,EAAc,UAGvDK,EAAoBL,GAEbA,EA4BD,SAASM,EAAsBN,EAAcO,GACnD,IAAMhB,EAASS,EAAaT,OACtBiB,EAAIjB,EAAOiB,EACXC,EAAcT,EAAaS,YAAc,IAAIC,OAAanB,GAEhEkB,EAAYE,IAAK,YAAaH,EAAG,qBAEjCR,EAAaY,gBACZC,YACCC,OAAS,0BAIXP,EAAQQ,IAAK,SAAAC,GAAI,OAAIP,EAAYQ,MAAMC,IAAKF,KAE5ChB,EAAaF,UAAUqB,SAASD,IAAKT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WAAWzC,IAAK,UAAW,SAAE0C,EAAMC,GAC1CtD,EAAa8C,SACjB9C,EAAaF,UAAU0D,YACvBF","file":"js/chunk-2d222974.971ecd10.js","sourcesContent":["/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module ui/dropdown/utils\n */\n\nimport DropdownPanelView from './dropdownpanelview';\nimport DropdownView from './dropdownview';\nimport DropdownButtonView from './button/dropdownbuttonview';\nimport ToolbarView from '../toolbar/toolbarview';\nimport ListView from '../list/listview';\nimport ListItemView from '../list/listitemview';\nimport ListSeparatorView from '../list/listseparatorview';\nimport ButtonView from '../button/buttonview';\nimport SwitchButtonView from '../button/switchbuttonview';\n\nimport clickOutsideHandler from '../bindings/clickoutsidehandler';\n\nimport '../../theme/components/dropdown/toolbardropdown.css';\nimport '../../theme/components/dropdown/listdropdown.css';\n\n/**\n * A helper for creating dropdowns. It creates an instance of a {@link module:ui/dropdown/dropdownview~DropdownView dropdown},\n * with a {@link module:ui/dropdown/button/dropdownbutton~DropdownButton button},\n * {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView panel} and all standard dropdown's behaviors.\n *\n * # Creating dropdowns\n *\n * By default, the default {@link module:ui/dropdown/button/dropdownbuttonview~DropdownButtonView} class is used as\n * definition of the button:\n *\n *\t\tconst dropdown = createDropdown( model );\n *\n *\t\t// Configure dropdown's button properties:\n *\t\tdropdown.buttonView.set( {\n *\t\t\tlabel: 'A dropdown',\n *\t\t\twithText: true\n *\t\t} );\n *\n *\t\tdropdown.render();\n *\n *\t\t// Will render a dropdown labeled \"A dropdown\" with an empty panel.\n *\t\tdocument.body.appendChild( dropdown.element );\n *\n * You can also provide other button views (they need to implement the\n * {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface). For instance, you can use\n * {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} to create a dropdown with a split button.\n *\n *\t\tconst dropdown = createDropdown( model, SplitButtonView );\n *\n *\t\t// Configure dropdown's button properties:\n *\t\tdropdown.buttonView.set( {\n *\t\t\tlabel: 'A dropdown',\n *\t\t\twithText: true\n *\t\t} );\n *\n *\t\tdropdown.buttonView.on( 'execute', () => {\n *\t\t\t// Add the behavior of the \"action part\" of the split button.\n *\t\t\t// Split button consists of the \"action part\" and \"arrow part\".\n *\t\t\t// The arrow opens the dropdown while the action part can have some other behavior.\n * \t\t} );\n *\n *\t\tdropdown.render();\n *\n *\t\t// Will render a dropdown labeled \"A dropdown\" with an empty panel.\n *\t\tdocument.body.appendChild( dropdown.element );\n *\n * # Adding content to the dropdown's panel\n *\n * The content of the panel can be inserted directly into the `dropdown.panelView.element`:\n *\n *\t\tdropdown.panelView.element.textContent = 'Content of the panel';\n *\n * However, most of the time you will want to add there either a {@link module:ui/list/listview~ListView list of options}\n * or a list of buttons (i.e. a {@link module:ui/toolbar/toolbarview~ToolbarView toolbar}).\n * To simplify the task, you can use, respectively, {@link module:ui/dropdown/utils~addListToDropdown} or\n * {@link module:ui/dropdown/utils~addToolbarToDropdown} utils.\n *\n * @param {module:utils/locale~Locale} locale The locale instance.\n * @param {Function} ButtonClass The dropdown button view class. Needs to implement the\n * {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface.\n * @returns {module:ui/dropdown/dropdownview~DropdownView} The dropdown view instance.\n */\nexport function createDropdown( locale, ButtonClass = DropdownButtonView ) {\n\tconst buttonView = new ButtonClass( locale );\n\n\tconst panelView = new DropdownPanelView( locale );\n\tconst dropdownView = new DropdownView( locale, buttonView, panelView );\n\n\tbuttonView.bind( 'isEnabled' ).to( dropdownView );\n\n\tif ( buttonView instanceof DropdownButtonView ) {\n\t\tbuttonView.bind( 'isOn' ).to( dropdownView, 'isOpen' );\n\t} else {\n\t\tbuttonView.arrowView.bind( 'isOn' ).to( dropdownView, 'isOpen' );\n\t}\n\n\taddDefaultBehavior( dropdownView );\n\n\treturn dropdownView;\n}\n\n/**\n * Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.\n *\n *\t\tconst buttons = [];\n *\n *\t\t// Either create a new ButtonView instance or create existing.\n *\t\tbuttons.push( new ButtonView() );\n *\t\tbuttons.push( editor.ui.componentFactory.create( 'someButton' ) );\n *\n *\t\tconst dropdown = createDropdown( locale );\n *\n *\t\taddToolbarToDropdown( dropdown, buttons );\n *\n *\t\tdropdown.toolbarView.isVertical = true;\n *\n *\t\t// Will render a vertical button dropdown labeled \"A button dropdown\"\n *\t\t// with a button group in the panel containing two buttons.\n *\t\tdropdown.render()\n *\t\tdocument.body.appendChild( dropdown.element );\n *\n * See {@link module:ui/dropdown/utils~createDropdown} and {@link module:ui/toolbar/toolbarview~ToolbarView}.\n *\n * @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView A dropdown instance to which `ToolbarView` will be added.\n * @param {Iterable.} buttons\n */\nexport function addToolbarToDropdown( dropdownView, buttons ) {\n\tconst locale = dropdownView.locale;\n\tconst t = locale.t;\n\tconst toolbarView = dropdownView.toolbarView = new ToolbarView( locale );\n\n\ttoolbarView.set( 'ariaLabel', t( 'Dropdown toolbar' ) );\n\n\tdropdownView.extendTemplate( {\n\t\tattributes: {\n\t\t\tclass: [ 'ck-toolbar-dropdown' ]\n\t\t}\n\t} );\n\n\tbuttons.map( view => toolbarView.items.add( view ) );\n\n\tdropdownView.panelView.children.add( toolbarView );\n\ttoolbarView.items.delegate( 'execute' ).to( dropdownView );\n}\n\n/**\n * Adds an instance of {@link module:ui/list/listview~ListView} to a dropdown.\n *\n *\t\tconst items = new Collection();\n *\n *\t\titems.add( {\n *\t\t\ttype: 'button',\n *\t\t\tmodel: new Model( {\n *\t\t\t\twithText: true,\n *\t\t\t\tlabel: 'First item',\n *\t\t\t\tlabelStyle: 'color: red'\n *\t\t\t} )\n *\t\t} );\n *\n *\t\titems.add( {\n *\t\t\t type: 'button',\n *\t\t\t model: new Model( {\n *\t\t\t\twithText: true,\n *\t\t\t\tlabel: 'Second item',\n *\t\t\t\tlabelStyle: 'color: green',\n *\t\t\t\tclass: 'foo'\n *\t\t\t} )\n *\t\t} );\n *\n *\t\tconst dropdown = createDropdown( locale );\n *\n *\t\taddListToDropdown( dropdown, items );\n *\n *\t\t// Will render a dropdown with a list in the panel containing two items.\n *\t\tdropdown.render()\n *\t\tdocument.body.appendChild( dropdown.element );\n *\n * The `items` collection passed to this methods controls the presence and attributes of respective\n * {@link module:ui/list/listitemview~ListItemView list items}.\n *\n *\n * See {@link module:ui/dropdown/utils~createDropdown} and {@link module:list/list~List}.\n *\n * @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView A dropdown instance to which `ListVIew` will be added.\n * @param {Iterable.} items\n * A collection of the list item definitions to populate the list.\n */\nexport function addListToDropdown( dropdownView, items ) {\n\tconst locale = dropdownView.locale;\n\tconst listView = dropdownView.listView = new ListView( locale );\n\n\tlistView.items.bindTo( items ).using( ( { type, model } ) => {\n\t\tif ( type === 'separator' ) {\n\t\t\treturn new ListSeparatorView( locale );\n\t\t} else if ( type === 'button' || type === 'switchbutton' ) {\n\t\t\tconst listItemView = new ListItemView( locale );\n\t\t\tlet buttonView;\n\n\t\t\tif ( type === 'button' ) {\n\t\t\t\tbuttonView = new ButtonView( locale );\n\t\t\t} else {\n\t\t\t\tbuttonView = new SwitchButtonView( locale );\n\t\t\t}\n\n\t\t\t// Bind all model properties to the button view.\n\t\t\tbuttonView.bind( ...Object.keys( model ) ).to( model );\n\t\t\tbuttonView.delegate( 'execute' ).to( listItemView );\n\n\t\t\tlistItemView.children.add( buttonView );\n\n\t\t\treturn listItemView;\n\t\t}\n\t} );\n\n\tdropdownView.panelView.children.add( listView );\n\n\tlistView.items.delegate( 'execute' ).to( dropdownView );\n}\n\n// Add a set of default behaviors to dropdown view.\n//\n// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView\nfunction addDefaultBehavior( dropdownView ) {\n\tcloseDropdownOnBlur( dropdownView );\n\tcloseDropdownOnExecute( dropdownView );\n\tfocusDropdownContentsOnArrows( dropdownView );\n}\n\n// Adds a behavior to a dropdownView that closes opened dropdown when user clicks outside the dropdown.\n//\n// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView\nfunction closeDropdownOnBlur( dropdownView ) {\n\tdropdownView.on( 'render', () => {\n\t\tclickOutsideHandler( {\n\t\t\temitter: dropdownView,\n\t\t\tactivator: () => dropdownView.isOpen,\n\t\t\tcallback: () => {\n\t\t\t\tdropdownView.isOpen = false;\n\t\t\t},\n\t\t\tcontextElements: [ dropdownView.element ]\n\t\t} );\n\t} );\n}\n\n// Adds a behavior to a dropdownView that closes the dropdown view on \"execute\" event.\n//\n// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView\nfunction closeDropdownOnExecute( dropdownView ) {\n\t// Close the dropdown when one of the list items has been executed.\n\tdropdownView.on( 'execute', evt => {\n\t\t// Toggling a switch button view should not close the dropdown.\n\t\tif ( evt.source instanceof SwitchButtonView ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdropdownView.isOpen = false;\n\t} );\n}\n\n// Adds a behavior to a dropdownView that focuses the dropdown's panel view contents on keystrokes.\n//\n// @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView\nfunction focusDropdownContentsOnArrows( dropdownView ) {\n\t// If the dropdown panel is already open, the arrow down key should focus the first child of the #panelView.\n\tdropdownView.keystrokes.set( 'arrowdown', ( data, cancel ) => {\n\t\tif ( dropdownView.isOpen ) {\n\t\t\tdropdownView.panelView.focus();\n\t\t\tcancel();\n\t\t}\n\t} );\n\n\t// If the dropdown panel is already open, the arrow up key should focus the last child of the #panelView.\n\tdropdownView.keystrokes.set( 'arrowup', ( data, cancel ) => {\n\t\tif ( dropdownView.isOpen ) {\n\t\t\tdropdownView.panelView.focusLast();\n\t\t\tcancel();\n\t\t}\n\t} );\n}\n\n/**\n * A definition of the list item used by the {@link module:ui/dropdown/utils~addListToDropdown}\n * utility.\n *\n * @typedef {Object} module:ui/dropdown/utils~ListDropdownItemDefinition\n *\n * @property {String} type Either `'separator'`, `'button'` or `'switchbutton'`.\n * @property {module:ui/model~Model} [model] Model of the item (when **not** `'separator'`).\n * Its properties fuel the newly created list item (or its children, depending on the `type`).\n */\n"],"sourceRoot":""}