2023-09-21 15:26:32 +02:00
/******/ ( function ( ) { // webpackBootstrap
2022-04-11 14:04:30 +02:00
/******/ var _ _webpack _modules _ _ = ( {
2021-05-07 13:48:27 +02:00
2023-09-26 16:23:26 +02:00
/***/ 5360 :
/***/ ( function ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ createUndoManager : function ( ) { return /* binding */ createUndoManager ; }
/* harmony export */ } ) ;
/* harmony import */ var _wordpress _is _shallow _equal _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 9127 ) ;
/* harmony import */ var _wordpress _is _shallow _equal _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _wordpress _is _shallow _equal _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/ * *
* WordPress dependencies
* /
/** @typedef {import('./types').HistoryRecord} HistoryRecord */
/** @typedef {import('./types').HistoryChange} HistoryChange */
/** @typedef {import('./types').HistoryChanges} HistoryChanges */
/** @typedef {import('./types').UndoManager} UndoManager */
/ * *
* Merge changes for a single item into a record of changes .
*
* @ param { Record < string , HistoryChange > } changes1 Previous changes
* @ param { Record < string , HistoryChange > } changes2 NextChanges
*
* @ return { Record < string , HistoryChange > } Merged changes
* /
function mergeHistoryChanges ( changes1 , changes2 ) {
/ * *
* @ type { Record < string , HistoryChange > }
* /
const newChanges = {
... changes1
} ;
Object . entries ( changes2 ) . forEach ( ( [ key , value ] ) => {
if ( newChanges [ key ] ) {
newChanges [ key ] = {
... newChanges [ key ] ,
to : value . to
} ;
} else {
newChanges [ key ] = value ;
}
} ) ;
return newChanges ;
}
/ * *
* Adds history changes for a single item into a record of changes .
*
* @ param { HistoryRecord } record The record to merge into .
* @ param { HistoryChanges } changes The changes to merge .
* /
const addHistoryChangesIntoRecord = ( record , changes ) => {
const existingChangesIndex = record ? . findIndex ( ( {
id : recordIdentifier
} ) => {
return typeof recordIdentifier === 'string' ? recordIdentifier === changes . id : _wordpress _is _shallow _equal _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ( recordIdentifier , changes . id ) ;
} ) ;
const nextRecord = [ ... record ] ;
if ( existingChangesIndex !== - 1 ) {
// If the edit is already in the stack leave the initial "from" value.
nextRecord [ existingChangesIndex ] = {
id : changes . id ,
changes : mergeHistoryChanges ( nextRecord [ existingChangesIndex ] . changes , changes . changes )
} ;
} else {
nextRecord . push ( changes ) ;
}
return nextRecord ;
} ;
/ * *
* Creates an undo manager .
*
* @ return { UndoManager } Undo manager .
* /
function createUndoManager ( ) {
/ * *
* @ type { HistoryRecord [ ] }
* /
let history = [ ] ;
/ * *
* @ type { HistoryRecord }
* /
let stagedRecord = [ ] ;
/ * *
* @ type { number }
* /
let offset = 0 ;
const dropPendingRedos = ( ) => {
history = history . slice ( 0 , offset || undefined ) ;
offset = 0 ;
} ;
const appendStagedRecordToLatestHistoryRecord = ( ) => {
var _history$index ;
const index = history . length === 0 ? 0 : history . length - 1 ;
let latestRecord = ( _history$index = history [ index ] ) !== null && _history$index !== void 0 ? _history$index : [ ] ;
stagedRecord . forEach ( changes => {
latestRecord = addHistoryChangesIntoRecord ( latestRecord , changes ) ;
} ) ;
stagedRecord = [ ] ;
history [ index ] = latestRecord ;
} ;
/ * *
* Checks whether a record is empty .
* A record is considered empty if it the changes keep the same values .
* Also updates to function values are ignored .
*
* @ param { HistoryRecord } record
* @ return { boolean } Whether the record is empty .
* /
const isRecordEmpty = record => {
const filteredRecord = record . filter ( ( {
changes
} ) => {
return Object . values ( changes ) . some ( ( {
from ,
to
} ) => typeof from !== 'function' && typeof to !== 'function' && ! _wordpress _is _shallow _equal _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default ( ) ( from , to ) ) ;
} ) ;
return ! filteredRecord . length ;
} ;
return {
/ * *
* Record changes into the history .
*
* @ param { HistoryRecord = } record A record of changes to record .
* @ param { boolean } isStaged Whether to immediately create an undo point or not .
* /
addRecord ( record , isStaged = false ) {
const isEmpty = ! record || isRecordEmpty ( record ) ;
if ( isStaged ) {
if ( isEmpty ) {
return ;
}
record . forEach ( changes => {
stagedRecord = addHistoryChangesIntoRecord ( stagedRecord , changes ) ;
} ) ;
} else {
dropPendingRedos ( ) ;
if ( stagedRecord . length ) {
appendStagedRecordToLatestHistoryRecord ( ) ;
}
if ( isEmpty ) {
return ;
}
history . push ( record ) ;
}
} ,
undo ( ) {
if ( stagedRecord . length ) {
dropPendingRedos ( ) ;
appendStagedRecordToLatestHistoryRecord ( ) ;
}
const undoRecord = history [ history . length - 1 + offset ] ;
if ( ! undoRecord ) {
return ;
}
offset -= 1 ;
return undoRecord ;
} ,
redo ( ) {
const redoRecord = history [ history . length + offset ] ;
if ( ! redoRecord ) {
return ;
}
offset += 1 ;
return redoRecord ;
} ,
hasUndo ( ) {
return ! ! history [ history . length - 1 + offset ] ;
} ,
hasRedo ( ) {
return ! ! history [ history . length + offset ] ;
}
} ;
}
/***/ } ) ,
2022-04-11 14:04:30 +02:00
/***/ 8294 :
/***/ ( function ( module ) {
2021-05-07 13:48:27 +02:00
2022-04-11 14:04:30 +02:00
/ * !
2022-10-04 17:55:23 +02:00
* clipboard . js v2 . 0.11
2022-04-11 14:04:30 +02:00
* https : //clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
* /
( function webpackUniversalModuleDefinition ( root , factory ) {
if ( true )
module . exports = factory ( ) ;
else { }
} ) ( this , function ( ) {
return /******/ ( function ( ) { // webpackBootstrap
/******/ var _ _webpack _modules _ _ = ( {
2021-05-07 13:48:27 +02:00
2022-04-12 19:17:22 +02:00
/***/ 686 :
2023-08-11 18:04:29 +02:00
/***/ ( function ( _ _unused _webpack _module , _ _nested _webpack _exports _ _ , _ _nested _webpack _require _623 _ _ ) {
2020-07-07 16:43:35 +02:00
"use strict" ;
2020-10-20 15:36:16 +02:00
2021-05-20 14:20:04 +02:00
// EXPORTS
2023-08-11 18:04:29 +02:00
_ _nested _webpack _require _623 _ _ . d ( _ _nested _webpack _exports _ _ , {
2022-04-11 14:04:30 +02:00
"default" : function ( ) { return /* binding */ clipboard ; }
} ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
2022-04-12 19:17:22 +02:00
var tiny _emitter = _ _nested _webpack _require _623 _ _ ( 279 ) ;
var tiny _emitter _default = /*#__PURE__*/ _ _nested _webpack _require _623 _ _ . n ( tiny _emitter ) ;
2022-04-11 14:04:30 +02:00
// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
2022-04-12 19:17:22 +02:00
var listen = _ _nested _webpack _require _623 _ _ ( 370 ) ;
var listen _default = /*#__PURE__*/ _ _nested _webpack _require _623 _ _ . n ( listen ) ;
2022-04-11 14:04:30 +02:00
// EXTERNAL MODULE: ./node_modules/select/src/select.js
2022-04-12 19:17:22 +02:00
var src _select = _ _nested _webpack _require _623 _ _ ( 817 ) ;
var select _default = /*#__PURE__*/ _ _nested _webpack _require _623 _ _ . n ( src _select ) ;
; // CONCATENATED MODULE: ./src/common/command.js
2021-05-20 14:20:04 +02:00
/ * *
2022-04-12 19:17:22 +02:00
* Executes a given operation type .
* @ param { String } type
* @ return { Boolean }
2021-05-20 14:20:04 +02:00
* /
2022-04-12 19:17:22 +02:00
function command ( type ) {
try {
return document . execCommand ( type ) ;
} catch ( err ) {
return false ;
2021-05-20 14:20:04 +02:00
}
2022-04-12 19:17:22 +02:00
}
; // CONCATENATED MODULE: ./src/actions/cut.js
2021-02-02 06:17:13 +01:00
2022-04-12 19:17:22 +02:00
/ * *
* Cut action wrapper .
* @ param { String | HTMLElement } target
* @ return { String }
* /
2021-01-28 03:04:13 +01:00
2022-04-12 19:17:22 +02:00
var ClipboardActionCut = function ClipboardActionCut ( target ) {
var selectedText = select _default ( ) ( target ) ;
command ( 'cut' ) ;
return selectedText ;
} ;
2021-01-28 03:04:13 +01:00
2022-04-12 19:17:22 +02:00
/* harmony default export */ var actions _cut = ( ClipboardActionCut ) ;
; // CONCATENATED MODULE: ./src/common/create-fake-element.js
/ * *
* Creates a fake textarea element with a value .
* @ param { String } value
* @ return { HTMLElement }
* /
function createFakeElement ( value ) {
var isRTL = document . documentElement . getAttribute ( 'dir' ) === 'rtl' ;
var fakeElement = document . createElement ( 'textarea' ) ; // Prevent zooming on iOS
2021-01-28 03:04:13 +01:00
2022-04-12 19:17:22 +02:00
fakeElement . style . fontSize = '12pt' ; // Reset box model
2021-01-28 03:04:13 +01:00
2022-04-12 19:17:22 +02:00
fakeElement . style . border = '0' ;
fakeElement . style . padding = '0' ;
fakeElement . style . margin = '0' ; // Move element out of screen horizontally
2021-01-28 03:04:13 +01:00
2022-04-12 19:17:22 +02:00
fakeElement . style . position = 'absolute' ;
fakeElement . style [ isRTL ? 'right' : 'left' ] = '-9999px' ; // Move element to the same position vertically
2021-01-28 03:04:13 +01:00
2022-04-12 19:17:22 +02:00
var yPosition = window . pageYOffset || document . documentElement . scrollTop ;
fakeElement . style . top = "" . concat ( yPosition , "px" ) ;
fakeElement . setAttribute ( 'readonly' , '' ) ;
fakeElement . value = value ;
return fakeElement ;
}
; // CONCATENATED MODULE: ./src/actions/copy.js
2021-11-08 15:29:21 +01:00
2020-06-26 15:33:47 +02:00
2022-10-04 17:55:23 +02:00
/ * *
* Create fake copy action wrapper using a fake element .
* @ param { String } target
* @ param { Object } options
* @ return { String }
* /
var fakeCopyAction = function fakeCopyAction ( value , options ) {
var fakeElement = createFakeElement ( value ) ;
options . container . appendChild ( fakeElement ) ;
var selectedText = select _default ( ) ( fakeElement ) ;
command ( 'copy' ) ;
fakeElement . remove ( ) ;
return selectedText ;
} ;
2022-04-12 19:17:22 +02:00
/ * *
* Copy action wrapper .
* @ param { String | HTMLElement } target
* @ param { Object } options
* @ return { String }
* /
2020-06-26 15:33:47 +02:00
2022-10-04 17:55:23 +02:00
2022-04-12 19:17:22 +02:00
var ClipboardActionCopy = function ClipboardActionCopy ( target ) {
var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : {
container : document . body
} ;
var selectedText = '' ;
if ( typeof target === 'string' ) {
2022-10-04 17:55:23 +02:00
selectedText = fakeCopyAction ( target , options ) ;
} else if ( target instanceof HTMLInputElement && ! [ 'text' , 'search' , 'url' , 'tel' , 'password' ] . includes ( target === null || target === void 0 ? void 0 : target . type ) ) {
// If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
selectedText = fakeCopyAction ( target . value , options ) ;
2022-04-12 19:17:22 +02:00
} else {
selectedText = select _default ( ) ( target ) ;
command ( 'copy' ) ;
}
2022-04-11 14:04:30 +02:00
2022-04-12 19:17:22 +02:00
return selectedText ;
} ;
2020-06-26 15:33:47 +02:00
2022-04-12 19:17:22 +02:00
/* harmony default export */ var actions _copy = ( ClipboardActionCopy ) ;
; // CONCATENATED MODULE: ./src/actions/default.js
function _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
2020-06-26 15:33:47 +02:00
2021-03-18 16:54:18 +01:00
2022-04-12 19:17:22 +02:00
/ * *
* Inner function which performs selection from either ` text ` or ` target `
* properties and then executes copy or cut operations .
* @ param { Object } options
* /
2021-03-18 16:54:18 +01:00
2022-04-12 19:17:22 +02:00
var ClipboardActionDefault = function ClipboardActionDefault ( ) {
var options = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
// Defines base properties passed from constructor.
var _options$action = options . action ,
action = _options$action === void 0 ? 'copy' : _options$action ,
container = options . container ,
target = options . target ,
text = options . text ; // Sets the `action` to be performed which can be either 'copy' or 'cut'.
2021-03-18 16:54:18 +01:00
2022-04-12 19:17:22 +02:00
if ( action !== 'copy' && action !== 'cut' ) {
throw new Error ( 'Invalid "action" value, use either "copy" or "cut"' ) ;
} // Sets the `target` property using an element that will be have its content copied.
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
2022-04-12 19:17:22 +02:00
if ( target !== undefined ) {
if ( target && _typeof ( target ) === 'object' && target . nodeType === 1 ) {
if ( action === 'copy' && target . hasAttribute ( 'disabled' ) ) {
throw new Error ( 'Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute' ) ;
}
2021-05-20 14:20:04 +02:00
2022-04-12 19:17:22 +02:00
if ( action === 'cut' && ( target . hasAttribute ( 'readonly' ) || target . hasAttribute ( 'disabled' ) ) ) {
throw new Error ( 'Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes' ) ;
2022-04-11 14:04:30 +02:00
}
2022-04-12 19:17:22 +02:00
} else {
throw new Error ( 'Invalid "target" value, use a valid Element' ) ;
2022-04-11 14:04:30 +02:00
}
2022-04-12 19:17:22 +02:00
} // Define selection strategy based on `text` property.
2021-03-18 16:54:18 +01:00
2022-04-12 19:17:22 +02:00
if ( text ) {
return actions _copy ( text , {
container : container
} ) ;
} // Defines which selection strategy based on `target` property.
2022-04-11 14:04:30 +02:00
2020-06-26 15:33:47 +02:00
2022-04-12 19:17:22 +02:00
if ( target ) {
return action === 'cut' ? actions _cut ( target ) : actions _copy ( target , {
container : container
} ) ;
}
} ;
2020-06-26 15:33:47 +02:00
2022-04-12 19:17:22 +02:00
/* harmony default export */ var actions _default = ( ClipboardActionDefault ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./src/clipboard.js
function clipboard _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { clipboard _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { clipboard _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return clipboard _typeof ( obj ) ; }
2022-04-12 19:17:22 +02:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2020-06-26 15:33:47 +02:00
2022-04-12 19:17:22 +02:00
function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } }
2021-03-18 16:54:18 +01:00
2022-04-12 19:17:22 +02:00
function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , writable : true , configurable : true } } ) ; if ( superClass ) _setPrototypeOf ( subClass , superClass ) ; }
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . _ _proto _ _ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
function _createSuper ( Derived ) { var hasNativeReflectConstruct = _isNativeReflectConstruct ( ) ; return function _createSuperInternal ( ) { var Super = _getPrototypeOf ( Derived ) , result ; if ( hasNativeReflectConstruct ) { var NewTarget = _getPrototypeOf ( this ) . constructor ; result = Reflect . construct ( Super , arguments , NewTarget ) ; } else { result = Super . apply ( this , arguments ) ; } return _possibleConstructorReturn ( this , result ) ; } ; }
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
function _possibleConstructorReturn ( self , call ) { if ( call && ( clipboard _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
function _isNativeReflectConstruct ( ) { if ( typeof Reflect === "undefined" || ! Reflect . construct ) return false ; if ( Reflect . construct . sham ) return false ; if ( typeof Proxy === "function" ) return true ; try { Date . prototype . toString . call ( Reflect . construct ( Date , [ ] , function ( ) { } ) ) ; return true ; } catch ( e ) { return false ; } }
function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . _ _proto _ _ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
2020-06-26 15:33:47 +02:00
2021-05-20 14:20:04 +02:00
2022-04-12 19:17:22 +02:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Helper function to retrieve attribute value .
* @ param { String } suffix
* @ param { Element } element
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
function getAttributeValue ( suffix , element ) {
var attribute = "data-clipboard-" . concat ( suffix ) ;
if ( ! element . hasAttribute ( attribute ) ) {
return ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
return element . getAttribute ( attribute ) ;
}
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Base class which takes one or more elements , adds event listeners to them ,
* and instantiates a new ` ClipboardAction ` on each click .
2021-05-20 14:20:04 +02:00
* /
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
var Clipboard = /*#__PURE__*/ function ( _Emitter ) {
_inherits ( Clipboard , _Emitter ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
var _super = _createSuper ( Clipboard ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* @ param { String | HTMLElement | HTMLCollection | NodeList } trigger
* @ param { Object } options
* /
function Clipboard ( trigger , options ) {
var _this ;
2020-06-26 15:33:47 +02:00
2022-04-12 19:17:22 +02:00
_classCallCheck ( this , Clipboard ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
_this = _super . call ( this ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
_this . resolveOptions ( options ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
_this . listenClick ( trigger ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
return _this ;
}
/ * *
* Defines if attributes would be resolved using internal setter functions
* or custom functions that were passed in the constructor .
* @ param { Object } options
* /
2020-06-26 15:33:47 +02:00
2021-03-18 16:54:18 +01:00
2022-04-12 19:17:22 +02:00
_createClass ( Clipboard , [ {
2022-04-11 14:04:30 +02:00
key : "resolveOptions" ,
value : function resolveOptions ( ) {
var options = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
this . action = typeof options . action === 'function' ? options . action : this . defaultAction ;
this . target = typeof options . target === 'function' ? options . target : this . defaultTarget ;
this . text = typeof options . text === 'function' ? options . text : this . defaultText ;
this . container = clipboard _typeof ( options . container ) === 'object' ? options . container : document . body ;
}
/ * *
* Adds a click event listener to the passed trigger .
* @ param { String | HTMLElement | HTMLCollection | NodeList } trigger
* /
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
} , {
key : "listenClick" ,
value : function listenClick ( trigger ) {
var _this2 = this ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
this . listener = listen _default ( ) ( trigger , 'click' , function ( e ) {
return _this2 . onClick ( e ) ;
} ) ;
}
/ * *
* Defines a new ` ClipboardAction ` on each click event .
* @ param { Event } e
* /
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
} , {
key : "onClick" ,
value : function onClick ( e ) {
var trigger = e . delegateTarget || e . currentTarget ;
2022-04-12 19:17:22 +02:00
var action = this . action ( trigger ) || 'copy' ;
var text = actions _default ( {
action : action ,
2022-04-11 14:04:30 +02:00
container : this . container ,
2022-04-12 19:17:22 +02:00
target : this . target ( trigger ) ,
text : this . text ( trigger )
} ) ; // Fires an event based on the copy operation result.
this . emit ( text ? 'success' : 'error' , {
action : action ,
text : text ,
2022-04-11 14:04:30 +02:00
trigger : trigger ,
2022-04-12 19:17:22 +02:00
clearSelection : function clearSelection ( ) {
if ( trigger ) {
trigger . focus ( ) ;
}
window . getSelection ( ) . removeAllRanges ( ) ;
}
2022-04-11 14:04:30 +02:00
} ) ;
}
/ * *
* Default ` action ` lookup function .
* @ param { Element } trigger
* /
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
} , {
key : "defaultAction" ,
value : function defaultAction ( trigger ) {
return getAttributeValue ( 'action' , trigger ) ;
}
/ * *
* Default ` target ` lookup function .
* @ param { Element } trigger
* /
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
} , {
key : "defaultTarget" ,
value : function defaultTarget ( trigger ) {
var selector = getAttributeValue ( 'target' , trigger ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
if ( selector ) {
return document . querySelector ( selector ) ;
}
}
/ * *
2022-04-12 19:17:22 +02:00
* Allow fire programmatically a copy action
* @ param { String | HTMLElement } target
* @ param { Object } options
* @ returns Text copied .
2022-04-11 14:04:30 +02:00
* /
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
} , {
key : "defaultText" ,
2021-05-21 12:14:23 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Default ` text ` lookup function .
* @ param { Element } trigger
* /
value : function defaultText ( trigger ) {
return getAttributeValue ( 'text' , trigger ) ;
}
/ * *
* Destroy lifecycle .
* /
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
} , {
key : "destroy" ,
value : function destroy ( ) {
this . listener . destroy ( ) ;
}
} ] , [ {
2022-04-12 19:17:22 +02:00
key : "copy" ,
value : function copy ( target ) {
var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : {
container : document . body
} ;
return actions _copy ( target , options ) ;
}
/ * *
* Allow fire programmatically a cut action
* @ param { String | HTMLElement } target
* @ returns Text cutted .
* /
} , {
key : "cut" ,
value : function cut ( target ) {
return actions _cut ( target ) ;
}
/ * *
* Returns the support of the given action , or all actions if no action is
* given .
* @ param { String } [ action ]
* /
} , {
2022-04-11 14:04:30 +02:00
key : "isSupported" ,
value : function isSupported ( ) {
var action = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : [ 'copy' , 'cut' ] ;
var actions = typeof action === 'string' ? [ action ] : action ;
var support = ! ! document . queryCommandSupported ;
actions . forEach ( function ( action ) {
support = support && ! ! document . queryCommandSupported ( action ) ;
} ) ;
return support ;
}
} ] ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
return Clipboard ;
} ( ( tiny _emitter _default ( ) ) ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
/* harmony default export */ var clipboard = ( Clipboard ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
/***/ 828 :
/***/ ( function ( module ) {
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
var DOCUMENT _NODE _TYPE = 9 ;
2020-06-26 15:33:47 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* A polyfill for Element . matches ( )
2020-06-26 15:33:47 +02:00
* /
2022-04-11 14:04:30 +02:00
if ( typeof Element !== 'undefined' && ! Element . prototype . matches ) {
var proto = Element . prototype ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
proto . matches = proto . matchesSelector ||
proto . mozMatchesSelector ||
proto . msMatchesSelector ||
proto . oMatchesSelector ||
proto . webkitMatchesSelector ;
}
2021-11-08 15:29:21 +01:00
2021-03-18 16:54:18 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* Finds the closest parent that matches a selector .
*
* @ param { Element } element
* @ param { String } selector
* @ return { Function }
2021-03-18 16:54:18 +01:00
* /
2022-04-11 14:04:30 +02:00
function closest ( element , selector ) {
while ( element && element . nodeType !== DOCUMENT _NODE _TYPE ) {
if ( typeof element . matches === 'function' &&
element . matches ( selector ) ) {
return element ;
}
element = element . parentNode ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
module . exports = closest ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
/***/ 438 :
2022-10-04 17:55:23 +02:00
/***/ ( function ( module , _ _unused _webpack _exports , _ _nested _webpack _require _15749 _ _ ) {
2021-03-18 16:54:18 +01:00
2022-10-04 17:55:23 +02:00
var closest = _ _nested _webpack _require _15749 _ _ ( 828 ) ;
2021-03-18 16:54:18 +01:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Delegates event to a selector .
*
* @ param { Element } element
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ param { Boolean } useCapture
* @ return { Object }
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
function _delegate ( element , selector , type , callback , useCapture ) {
var listenerFn = listener . apply ( this , arguments ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
element . addEventListener ( type , listenerFn , useCapture ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
return {
destroy : function ( ) {
element . removeEventListener ( type , listenerFn , useCapture ) ;
}
}
}
2021-03-18 16:54:18 +01:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Delegates event to a selector .
2021-11-08 15:29:21 +01:00
*
2022-04-11 14:04:30 +02:00
* @ param { Element | String | Array } [ elements ]
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ param { Boolean } useCapture
* @ return { Object }
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
function delegate ( elements , selector , type , callback , useCapture ) {
// Handle the regular Element usage
if ( typeof elements . addEventListener === 'function' ) {
return _delegate . apply ( null , arguments ) ;
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
// Handle Element-less usage, it defaults to global delegation
if ( typeof type === 'function' ) {
// Use `document` as the first parameter, then apply arguments
// This is a short way to .unshift `arguments` without running into deoptimizations
return _delegate . bind ( null , document ) . apply ( null , arguments ) ;
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
// Handle Selector-based usage
if ( typeof elements === 'string' ) {
elements = document . querySelectorAll ( elements ) ;
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
// Handle Array-like based usage
return Array . prototype . map . call ( elements , function ( element ) {
return _delegate ( element , selector , type , callback , useCapture ) ;
} ) ;
2021-05-20 14:20:04 +02:00
}
2021-03-18 16:54:18 +01:00
2021-11-08 15:29:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* Finds closest match and invokes callback .
2021-11-08 15:29:21 +01:00
*
2022-04-11 14:04:30 +02:00
* @ param { Element } element
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ return { Function }
2021-11-08 15:29:21 +01:00
* /
2022-04-11 14:04:30 +02:00
function listener ( element , selector , type , callback ) {
return function ( e ) {
e . delegateTarget = closest ( e . target , selector ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
if ( e . delegateTarget ) {
callback . call ( element , e ) ;
}
2021-11-08 15:29:21 +01:00
}
}
2022-04-11 14:04:30 +02:00
module . exports = delegate ;
/***/ } ) ,
/***/ 879 :
/***/ ( function ( _ _unused _webpack _module , exports ) {
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Check if argument is a HTML element .
*
* @ param { Object } value
* @ return { Boolean }
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
exports . node = function ( value ) {
return value !== undefined
&& value instanceof HTMLElement
&& value . nodeType === 1 ;
} ;
2020-06-26 15:33:47 +02:00
2021-11-08 15:29:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* Check if argument is a list of HTML elements .
*
* @ param { Object } value
* @ return { Boolean }
2021-11-08 15:29:21 +01:00
* /
2022-04-11 14:04:30 +02:00
exports . nodeList = function ( value ) {
var type = Object . prototype . toString . call ( value ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
return value !== undefined
&& ( type === '[object NodeList]' || type === '[object HTMLCollection]' )
&& ( 'length' in value )
&& ( value . length === 0 || exports . node ( value [ 0 ] ) ) ;
} ;
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Check if argument is a string .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ param { Object } value
* @ return { Boolean }
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
exports . string = function ( value ) {
return typeof value === 'string'
|| value instanceof String ;
} ;
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Check if argument is a function .
*
* @ param { Object } value
* @ return { Boolean }
* /
exports . fn = function ( value ) {
var type = Object . prototype . toString . call ( value ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
return type === '[object Function]' ;
} ;
2021-05-21 12:14:23 +02:00
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
/***/ 370 :
2022-10-04 17:55:23 +02:00
/***/ ( function ( module , _ _unused _webpack _exports , _ _nested _webpack _require _19113 _ _ ) {
2020-06-26 15:33:47 +02:00
2022-10-04 17:55:23 +02:00
var is = _ _nested _webpack _require _19113 _ _ ( 879 ) ;
var delegate = _ _nested _webpack _require _19113 _ _ ( 438 ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Validates all params and calls the right
* listener function based on its target type .
*
* @ param { String | HTMLElement | HTMLCollection | NodeList } target
* @ param { String } type
* @ param { Function } callback
* @ return { Object }
* /
function listen ( target , type , callback ) {
if ( ! target && ! type && ! callback ) {
throw new Error ( 'Missing required arguments' ) ;
2021-11-08 15:29:21 +01:00
}
2021-05-21 12:14:23 +02:00
2022-04-11 14:04:30 +02:00
if ( ! is . string ( type ) ) {
throw new TypeError ( 'Second argument must be a String' ) ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
if ( ! is . fn ( callback ) ) {
throw new TypeError ( 'Third argument must be a Function' ) ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
if ( is . node ( target ) ) {
return listenNode ( target , type , callback ) ;
}
else if ( is . nodeList ( target ) ) {
return listenNodeList ( target , type , callback ) ;
}
else if ( is . string ( target ) ) {
return listenSelector ( target , type , callback ) ;
}
else {
throw new TypeError ( 'First argument must be a String, HTMLElement, HTMLCollection, or NodeList' ) ;
}
}
2020-06-26 15:33:47 +02:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Adds an event listener to a HTML element
* and returns a remove listener function .
*
* @ param { HTMLElement } node
* @ param { String } type
* @ param { Function } callback
* @ return { Object }
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
function listenNode ( node , type , callback ) {
node . addEventListener ( type , callback ) ;
return {
destroy : function ( ) {
node . removeEventListener ( type , callback ) ;
}
}
}
2020-06-26 15:33:47 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Add an event listener to a list of HTML elements
* and returns a remove listener function .
*
* @ param { NodeList | HTMLCollection } nodeList
* @ param { String } type
* @ param { Function } callback
* @ return { Object }
2020-06-26 15:33:47 +02:00
* /
2022-04-11 14:04:30 +02:00
function listenNodeList ( nodeList , type , callback ) {
Array . prototype . forEach . call ( nodeList , function ( node ) {
node . addEventListener ( type , callback ) ;
} ) ;
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
return {
destroy : function ( ) {
Array . prototype . forEach . call ( nodeList , function ( node ) {
node . removeEventListener ( type , callback ) ;
} ) ;
}
}
}
2021-11-08 15:29:21 +01:00
2020-06-26 15:33:47 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Add an event listener to a selector
* and returns a remove listener function .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ return { Object }
2020-06-26 15:33:47 +02:00
* /
2022-04-11 14:04:30 +02:00
function listenSelector ( selector , type , callback ) {
return delegate ( document . body , selector , type , callback ) ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
module . exports = listen ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/***/ 817 :
/***/ ( function ( module ) {
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
function select ( element ) {
var selectedText ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
if ( element . nodeName === 'SELECT' ) {
element . focus ( ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
selectedText = element . value ;
}
else if ( element . nodeName === 'INPUT' || element . nodeName === 'TEXTAREA' ) {
var isReadOnly = element . hasAttribute ( 'readonly' ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
if ( ! isReadOnly ) {
element . setAttribute ( 'readonly' , '' ) ;
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
element . select ( ) ;
element . setSelectionRange ( 0 , element . value . length ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
if ( ! isReadOnly ) {
element . removeAttribute ( 'readonly' ) ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
selectedText = element . value ;
}
else {
if ( element . hasAttribute ( 'contenteditable' ) ) {
element . focus ( ) ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
var selection = window . getSelection ( ) ;
var range = document . createRange ( ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
range . selectNodeContents ( element ) ;
selection . removeAllRanges ( ) ;
selection . addRange ( range ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
selectedText = selection . toString ( ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
return selectedText ;
2021-05-20 14:20:04 +02:00
}
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
module . exports = select ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/***/ 279 :
/***/ ( function ( module ) {
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
function E ( ) {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
2021-05-20 14:20:04 +02:00
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
E . prototype = {
on : function ( name , callback , ctx ) {
var e = this . e || ( this . e = { } ) ;
( e [ name ] || ( e [ name ] = [ ] ) ) . push ( {
fn : callback ,
ctx : ctx
} ) ;
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
return this ;
} ,
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
once : function ( name , callback , ctx ) {
var self = this ;
function listener ( ) {
self . off ( name , listener ) ;
callback . apply ( ctx , arguments ) ;
} ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
listener . _ = callback
return this . on ( name , listener , ctx ) ;
} ,
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
emit : function ( name ) {
var data = [ ] . slice . call ( arguments , 1 ) ;
var evtArr = ( ( this . e || ( this . e = { } ) ) [ name ] || [ ] ) . slice ( ) ;
var i = 0 ;
var len = evtArr . length ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
for ( i ; i < len ; i ++ ) {
evtArr [ i ] . fn . apply ( evtArr [ i ] . ctx , data ) ;
2021-03-18 16:54:18 +01:00
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
return this ;
} ,
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
off : function ( name , callback ) {
var e = this . e || ( this . e = { } ) ;
var evts = e [ name ] ;
var liveEvents = [ ] ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
if ( evts && callback ) {
for ( var i = 0 , len = evts . length ; i < len ; i ++ ) {
if ( evts [ i ] . fn !== callback && evts [ i ] . fn . _ !== callback )
liveEvents . push ( evts [ i ] ) ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
// Remove event from queue to prevent memory leak
// Suggested by https://github.com/lazd
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
( liveEvents . length )
? e [ name ] = liveEvents
: delete e [ name ] ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
return this ;
}
} ;
2019-10-15 18:17:12 +02:00
2022-04-11 14:04:30 +02:00
module . exports = E ;
module . exports . TinyEmitter = E ;
2021-11-08 15:29:21 +01:00
2019-10-15 18:17:12 +02:00
2022-04-11 14:04:30 +02:00
/***/ } )
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
2022-10-04 17:55:23 +02:00
/******/ function _ _nested _webpack _require _24495 _ _ ( moduleId ) {
2022-04-11 14:04:30 +02:00
/******/ // Check if module is in cache
/******/ if ( _ _webpack _module _cache _ _ [ moduleId ] ) {
/******/ return _ _webpack _module _cache _ _ [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
2022-10-04 17:55:23 +02:00
/******/ _ _webpack _modules _ _ [ moduleId ] ( module , module . exports , _ _nested _webpack _require _24495 _ _ ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ ! function ( ) {
/******/ // getDefaultExport function for compatibility with non-harmony modules
2022-10-04 17:55:23 +02:00
/******/ _ _nested _webpack _require _24495 _ _ . n = function ( module ) {
2022-04-11 14:04:30 +02:00
/******/ var getter = module && module . _ _esModule ?
/******/ function ( ) { return module [ 'default' ] ; } :
/******/ function ( ) { return module ; } ;
2022-10-04 17:55:23 +02:00
/******/ _ _nested _webpack _require _24495 _ _ . d ( getter , { a : getter } ) ;
2022-04-11 14:04:30 +02:00
/******/ return getter ;
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/define property getters */
/******/ ! function ( ) {
/******/ // define getter functions for harmony exports
2022-10-04 17:55:23 +02:00
/******/ _ _nested _webpack _require _24495 _ _ . d = function ( exports , definition ) {
2022-04-11 14:04:30 +02:00
/******/ for ( var key in definition ) {
2022-10-04 17:55:23 +02:00
/******/ if ( _ _nested _webpack _require _24495 _ _ . o ( definition , key ) && ! _ _nested _webpack _require _24495 _ _ . o ( exports , key ) ) {
2022-04-11 14:04:30 +02:00
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ ! function ( ) {
2022-10-04 17:55:23 +02:00
/******/ _ _nested _webpack _require _24495 _ _ . o = function ( obj , prop ) { return Object . prototype . hasOwnProperty . call ( obj , prop ) ; }
2022-04-11 14:04:30 +02:00
/******/ } ( ) ;
/******/
/************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
2022-10-04 17:55:23 +02:00
/******/ return _ _nested _webpack _require _24495 _ _ ( 686 ) ;
2022-04-11 14:04:30 +02:00
/******/ } ) ( )
. default ;
} ) ;
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2020-03-24 00:40:19 +01:00
2022-04-11 14:04:30 +02:00
/***/ 7973 :
2023-09-21 15:26:32 +02:00
/***/ ( function ( module , exports , _ _webpack _require _ _ ) {
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
var _ _WEBPACK _AMD _DEFINE _RESULT _ _ ; /*global define:false */
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Copyright 2012 - 2017 Craig Campbell
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* http : //www.apache.org/licenses/LICENSE-2.0
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* Mousetrap is a simple keyboard shortcut library for Javascript with
* no external dependencies
*
* @ version 1.6 . 5
* @ url craig . is / killing / mice
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
( function ( window , document , undefined ) {
2020-03-24 00:40:19 +01:00
2022-04-11 14:04:30 +02:00
// Check if mousetrap is used inside browser, if not, return
if ( ! window ) {
return ;
}
2020-03-24 00:40:19 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* mapping of special keycodes to their corresponding keys
*
* everything in this dictionary cannot use keypress events
* so it has to be here to map to the correct keycodes for
* keyup / keydown events
*
* @ type { Object }
* /
var _MAP = {
8 : 'backspace' ,
9 : 'tab' ,
13 : 'enter' ,
16 : 'shift' ,
17 : 'ctrl' ,
18 : 'alt' ,
20 : 'capslock' ,
27 : 'esc' ,
32 : 'space' ,
33 : 'pageup' ,
34 : 'pagedown' ,
35 : 'end' ,
36 : 'home' ,
37 : 'left' ,
38 : 'up' ,
39 : 'right' ,
40 : 'down' ,
45 : 'ins' ,
46 : 'del' ,
91 : 'meta' ,
93 : 'meta' ,
224 : 'meta'
} ;
2020-03-24 00:40:19 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* mapping for special characters so they can support
*
* this dictionary is only used incase you want to bind a
* keyup or keydown event to one of these keys
*
* @ type { Object }
* /
var _KEYCODE _MAP = {
106 : '*' ,
107 : '+' ,
109 : '-' ,
110 : '.' ,
111 : '/' ,
186 : ';' ,
187 : '=' ,
188 : ',' ,
189 : '-' ,
190 : '.' ,
191 : '/' ,
192 : '`' ,
219 : '[' ,
220 : '\\' ,
221 : ']' ,
222 : '\''
} ;
2020-02-06 22:03:31 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* this is a mapping of keys that require shift on a US keypad
* back to the non shift equivelents
*
* this is so you can use keyup events with these keys
*
* note that this will only work reliably on US keyboards
*
* @ type { Object }
* /
var _SHIFT _MAP = {
'~' : '`' ,
'!' : '1' ,
'@' : '2' ,
'#' : '3' ,
'$' : '4' ,
'%' : '5' ,
'^' : '6' ,
'&' : '7' ,
'*' : '8' ,
'(' : '9' ,
')' : '0' ,
'_' : '-' ,
'+' : '=' ,
':' : ';' ,
'\"' : '\'' ,
'<' : ',' ,
'>' : '.' ,
'?' : '/' ,
'|' : '\\'
} ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* this is a list of special strings you can use to map
* to modifier keys when you specify your keyboard shortcuts
*
* @ type { Object }
* /
var _SPECIAL _ALIASES = {
'option' : 'alt' ,
'command' : 'meta' ,
'return' : 'enter' ,
'escape' : 'esc' ,
'plus' : '+' ,
'mod' : /Mac|iPod|iPhone|iPad/ . test ( navigator . platform ) ? 'meta' : 'ctrl'
} ;
2020-02-06 22:03:31 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* variable to store the flipped version of _MAP from above
* needed to check if we should use keypress or not when no action
* is specified
*
* @ type { Object | undefined }
* /
var _REVERSE _MAP ;
2020-02-06 22:03:31 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* loop through the f keys , f1 to f19 and add them to the map
* programatically
* /
for ( var i = 1 ; i < 20 ; ++ i ) {
_MAP [ 111 + i ] = 'f' + i ;
}
2020-02-06 22:03:31 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* loop through to map numbers on the numeric keypad
* /
for ( i = 0 ; i <= 9 ; ++ i ) {
2020-03-24 00:40:19 +01:00
2022-04-11 14:04:30 +02:00
// This needs to use a string cause otherwise since 0 is falsey
// mousetrap will never fire for numpad 0 pressed as part of a keydown
// event.
//
// @see https://github.com/ccampbell/mousetrap/pull/258
_MAP [ i + 96 ] = i . toString ( ) ;
}
2020-03-24 00:40:19 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* cross browser add event method
*
* @ param { Element | HTMLDocument } object
* @ param { string } type
* @ param { Function } callback
* @ returns void
* /
function _addEvent ( object , type , callback ) {
if ( object . addEventListener ) {
object . addEventListener ( type , callback , false ) ;
return ;
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
object . attachEvent ( 'on' + type , callback ) ;
2021-05-20 14:20:04 +02:00
}
2021-03-18 16:54:18 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* takes the event and returns the key character
*
* @ param { Event } e
* @ return { string }
* /
function _characterFromEvent ( e ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// for keypress events we should return the character as is
if ( e . type == 'keypress' ) {
var character = String . fromCharCode ( e . which ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if the shift key is not pressed then it is safe to assume
// that we want the character to be lowercase. this means if
// you accidentally have caps lock on then your key bindings
// will continue to work
//
// the only side effect that might not be desired is if you
// bind something like 'A' cause you want to trigger an
// event when capital A is pressed caps lock will no longer
// trigger the event. shift+a will though.
if ( ! e . shiftKey ) {
character = character . toLowerCase ( ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
return character ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// for non keypress events the special maps are needed
if ( _MAP [ e . which ] ) {
return _MAP [ e . which ] ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( _KEYCODE _MAP [ e . which ] ) {
return _KEYCODE _MAP [ e . which ] ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if it is not in the special map
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// with keydown and keyup events the character seems to always
// come in as an uppercase character whether you are pressing shift
// or not. we should make sure it is always lowercase for comparisons
return String . fromCharCode ( e . which ) . toLowerCase ( ) ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* checks if two arrays are equal
*
* @ param { Array } modifiers1
* @ param { Array } modifiers2
* @ returns { boolean }
* /
function _modifiersMatch ( modifiers1 , modifiers2 ) {
return modifiers1 . sort ( ) . join ( ',' ) === modifiers2 . sort ( ) . join ( ',' ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* takes a key event and figures out what the modifiers are
*
* @ param { Event } e
* @ returns { Array }
* /
function _eventModifiers ( e ) {
var modifiers = [ ] ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
if ( e . shiftKey ) {
modifiers . push ( 'shift' ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( e . altKey ) {
modifiers . push ( 'alt' ) ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
if ( e . ctrlKey ) {
modifiers . push ( 'ctrl' ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( e . metaKey ) {
modifiers . push ( 'meta' ) ;
}
return modifiers ;
}
/ * *
* prevents default for this event
*
* @ param { Event } e
* @ returns void
* /
function _preventDefault ( e ) {
if ( e . preventDefault ) {
e . preventDefault ( ) ;
return ;
}
2021-05-21 12:14:23 +02:00
2022-04-11 14:04:30 +02:00
e . returnValue = false ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* stops propogation for this event
*
* @ param { Event } e
* @ returns void
* /
function _stopPropagation ( e ) {
if ( e . stopPropagation ) {
e . stopPropagation ( ) ;
return ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
e . cancelBubble = true ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* determines if the keycode specified is a modifier key or not
*
* @ param { string } key
* @ returns { boolean }
* /
function _isModifier ( key ) {
return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta' ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* reverses the map lookup so that we can look for specific keys
* to see what can and can ' t use keypress
*
* @ return { Object }
* /
function _getReverseMap ( ) {
if ( ! _REVERSE _MAP ) {
_REVERSE _MAP = { } ;
for ( var key in _MAP ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// pull out the numeric keypad from here cause keypress should
// be able to detect the keys from the character
if ( key > 95 && key < 112 ) {
continue ;
}
2021-05-21 12:14:23 +02:00
2022-04-11 14:04:30 +02:00
if ( _MAP . hasOwnProperty ( key ) ) {
_REVERSE _MAP [ _MAP [ key ] ] = key ;
}
}
2021-05-21 12:14:23 +02:00
}
2022-04-11 14:04:30 +02:00
return _REVERSE _MAP ;
2021-05-21 12:14:23 +02:00
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* picks the best action based on the key combination
*
* @ param { string } key - character for key
* @ param { Array } modifiers
* @ param { string = } action passed in
* /
function _pickBestAction ( key , modifiers , action ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if no action was picked in we should try to pick the one
// that we think would work best for this key
if ( ! action ) {
action = _getReverseMap ( ) [ key ] ? 'keydown' : 'keypress' ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// modifier keys don't work as expected with keypress,
// switch to keydown
if ( action == 'keypress' && modifiers . length ) {
action = 'keydown' ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
return action ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Converts from a string key combination to an array
*
* @ param { string } combination like "command+shift+l"
* @ return { Array }
* /
function _keysFromString ( combination ) {
if ( combination === '+' ) {
return [ '+' ] ;
}
combination = combination . replace ( /\+{2}/g , '+plus' ) ;
return combination . split ( '+' ) ;
2021-05-21 12:14:23 +02:00
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Gets info for a specific key combination
*
* @ param { string } combination key combination ( "command+s" or "a" or "*" )
* @ param { string = } action
* @ returns { Object }
* /
function _getKeyInfo ( combination , action ) {
var keys ;
var key ;
var i ;
var modifiers = [ ] ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// take the keys from this pattern and figure out what the actual
// pattern is all about
keys = _keysFromString ( combination ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
for ( i = 0 ; i < keys . length ; ++ i ) {
key = keys [ i ] ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// normalize key names
if ( _SPECIAL _ALIASES [ key ] ) {
key = _SPECIAL _ALIASES [ key ] ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if this is not a keypress event then we should
// be smart about using shift keys
// this will only work for US keyboards however
if ( action && action != 'keypress' && _SHIFT _MAP [ key ] ) {
key = _SHIFT _MAP [ key ] ;
modifiers . push ( 'shift' ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if this key is a modifier then add it to the list of modifiers
if ( _isModifier ( key ) ) {
modifiers . push ( key ) ;
}
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// depending on what the key combination is
// we will try to pick the best event for it
action = _pickBestAction ( key , modifiers , action ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
return {
key : key ,
modifiers : modifiers ,
action : action
} ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
function _belongsTo ( element , ancestor ) {
if ( element === null || element === document ) {
return false ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
if ( element === ancestor ) {
return true ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
return _belongsTo ( element . parentNode , ancestor ) ;
}
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
function Mousetrap ( targetElement ) {
var self = this ;
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
targetElement = targetElement || document ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
if ( ! ( self instanceof Mousetrap ) ) {
return new Mousetrap ( targetElement ) ;
}
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* element to attach key events to
*
* @ type { Element }
* /
self . target = targetElement ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* a list of all the callbacks setup via Mousetrap . bind ( )
*
* @ type { Object }
* /
self . _callbacks = { } ;
/ * *
* direct map of string combinations to callbacks used for trigger ( )
*
* @ type { Object }
* /
self . _directMap = { } ;
/ * *
* keeps track of what level each sequence is at since multiple
* sequences can start out with the same sequence
*
* @ type { Object }
* /
var _sequenceLevels = { } ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* variable to store the setTimeout call
*
* @ type { null | number }
* /
var _resetTimer ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* temporary state where we will ignore the next keyup
*
* @ type { boolean | string }
* /
var _ignoreNextKeyup = false ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* temporary state where we will ignore the next keypress
*
* @ type { boolean }
* /
var _ignoreNextKeypress = false ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* are we currently inside of a sequence ?
* type of action ( "keyup" or "keydown" or "keypress" ) or false
*
* @ type { boolean | string }
* /
var _nextExpectedAction = false ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* resets all sequence counters except for the ones passed in
*
* @ param { Object } doNotReset
* @ returns void
* /
function _resetSequences ( doNotReset ) {
doNotReset = doNotReset || { } ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
var activeSequences = false ,
key ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
for ( key in _sequenceLevels ) {
if ( doNotReset [ key ] ) {
activeSequences = true ;
continue ;
}
_sequenceLevels [ key ] = 0 ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
if ( ! activeSequences ) {
_nextExpectedAction = false ;
}
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* finds all callbacks that match based on the keycode , modifiers ,
* and action
*
* @ param { string } character
* @ param { Array } modifiers
* @ param { Event | Object } e
* @ param { string = } sequenceName - name of the sequence we are looking for
* @ param { string = } combination
* @ param { number = } level
* @ returns { Array }
* /
function _getMatches ( character , modifiers , e , sequenceName , combination , level ) {
var i ;
var callback ;
var matches = [ ] ;
var action = e . type ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// if there are no events related to this keycode
if ( ! self . _callbacks [ character ] ) {
return [ ] ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// if a modifier key is coming up on its own we should allow it
if ( action == 'keyup' && _isModifier ( character ) ) {
modifiers = [ character ] ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// loop through all callbacks for the key that was pressed
// and see if any of them match
for ( i = 0 ; i < self . _callbacks [ character ] . length ; ++ i ) {
callback = self . _callbacks [ character ] [ i ] ;
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// if a sequence name is not specified, but this is a sequence at
// the wrong level then move onto the next match
if ( ! sequenceName && callback . seq && _sequenceLevels [ callback . seq ] != callback . level ) {
continue ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// if the action we are looking for doesn't match the action we got
// then we should keep going
if ( action != callback . action ) {
continue ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// if this is a keypress event and the meta key and control key
// are not pressed that means that we need to only look at the
// character, otherwise check the modifiers as well
//
// chrome will not fire a keypress if meta or control is down
// safari will fire a keypress if meta or meta+shift is down
// firefox will fire a keypress if meta or control is down
if ( ( action == 'keypress' && ! e . metaKey && ! e . ctrlKey ) || _modifiersMatch ( modifiers , callback . modifiers ) ) {
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// when you bind a combination or sequence a second time it
// should overwrite the first one. if a sequenceName or
// combination is specified in this call it does just that
//
// @todo make deleting its own method?
var deleteCombo = ! sequenceName && callback . combo == combination ;
var deleteSequence = sequenceName && callback . seq == sequenceName && callback . level == level ;
if ( deleteCombo || deleteSequence ) {
self . _callbacks [ character ] . splice ( i , 1 ) ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
matches . push ( callback ) ;
}
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
return matches ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* actually calls the callback function
*
* if your callback function returns false this will use the jquery
* convention - prevent default and stop propogation on the event
*
* @ param { Function } callback
* @ param { Event } e
* @ returns void
* /
function _fireCallback ( callback , e , combo , sequence ) {
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
// if this event should not happen stop here
if ( self . stopCallback ( e , e . target || e . srcElement , combo , sequence ) ) {
return ;
}
2021-12-21 08:02:34 +01:00
2022-04-11 14:04:30 +02:00
if ( callback ( e , combo ) === false ) {
_preventDefault ( e ) ;
_stopPropagation ( e ) ;
}
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* handles a character key event
*
* @ param { string } character
* @ param { Array } modifiers
* @ param { Event } e
* @ returns void
* /
self . _handleKey = function ( character , modifiers , e ) {
var callbacks = _getMatches ( character , modifiers , e ) ;
var i ;
var doNotReset = { } ;
var maxLevel = 0 ;
var processedSequenceCallback = false ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
for ( i = 0 ; i < callbacks . length ; ++ i ) {
if ( callbacks [ i ] . seq ) {
maxLevel = Math . max ( maxLevel , callbacks [ i ] . level ) ;
}
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// loop through matching callbacks for this key event
for ( i = 0 ; i < callbacks . length ; ++ i ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// fire for all sequence callbacks
// this is because if for example you have multiple sequences
// bound such as "g i" and "g t" they both need to fire the
// callback for matching g cause otherwise you can only ever
// match the first one
if ( callbacks [ i ] . seq ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// only fire callbacks for the maxLevel to prevent
// subsequences from also firing
//
// for example 'a option b' should not cause 'option b' to fire
// even though 'option b' is part of the other sequence
//
// any sequences that do not match here will be discarded
// below by the _resetSequences call
if ( callbacks [ i ] . level != maxLevel ) {
continue ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
processedSequenceCallback = true ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
// keep a list of which sequences were matches for later
doNotReset [ callbacks [ i ] . seq ] = 1 ;
_fireCallback ( callbacks [ i ] . callback , e , callbacks [ i ] . combo , callbacks [ i ] . seq ) ;
continue ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if there were no sequence matches but we are still here
// that means this is a regular match so we should fire that
if ( ! processedSequenceCallback ) {
_fireCallback ( callbacks [ i ] . callback , e , callbacks [ i ] . combo ) ;
}
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if the key you pressed matches the type of sequence without
// being a modifier (ie "keyup" or "keypress") then we should
// reset all sequences that were not matched by this event
//
// this is so, for example, if you have the sequence "h a t" and you
// type "h e a r t" it does not match. in this case the "e" will
// cause the sequence to reset
//
// modifier keys are ignored because you can have a sequence
// that contains modifiers such as "enter ctrl+space" and in most
// cases the modifier key will be pressed before the next key
//
// also if you have a sequence such as "ctrl+b a" then pressing the
// "b" key will trigger a "keypress" and a "keydown"
//
// the "keydown" is expected when there is a modifier, but the
// "keypress" ends up matching the _nextExpectedAction since it occurs
// after and that causes the sequence to reset
//
// we ignore keypresses in a sequence that directly follow a keydown
// for the same character
var ignoreThisKeypress = e . type == 'keypress' && _ignoreNextKeypress ;
if ( e . type == _nextExpectedAction && ! _isModifier ( character ) && ! ignoreThisKeypress ) {
_resetSequences ( doNotReset ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
_ignoreNextKeypress = processedSequenceCallback && e . type == 'keydown' ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* handles a keydown event
*
* @ param { Event } e
* @ returns void
* /
function _handleKeyEvent ( e ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// normalize e.which for key events
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
if ( typeof e . which !== 'number' ) {
e . which = e . keyCode ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
var character = _characterFromEvent ( e ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// no character found then stop
if ( ! character ) {
return ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// need to use === for the character check because the character can be 0
if ( e . type == 'keyup' && _ignoreNextKeyup === character ) {
_ignoreNextKeyup = false ;
return ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
self . handleKey ( character , _eventModifiers ( e ) , e ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* called to set a 1 second timeout on the specified sequence
*
* this is so after each key press in the sequence you have 1 second
* to press the next key before you have to start over
*
* @ returns void
* /
function _resetSequenceTimer ( ) {
clearTimeout ( _resetTimer ) ;
_resetTimer = setTimeout ( _resetSequences , 1000 ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* binds a key sequence to an event
*
* @ param { string } combo - combo specified in bind call
* @ param { Array } keys
* @ param { Function } callback
* @ param { string = } action
* @ returns void
* /
function _bindSequence ( combo , keys , callback , action ) {
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// start off by adding a sequence level record for this combination
// and setting the level to 0
_sequenceLevels [ combo ] = 0 ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* callback to increase the sequence level for this sequence and reset
* all other sequences that were active
*
* @ param { string } nextAction
* @ returns { Function }
* /
function _increaseSequence ( nextAction ) {
return function ( ) {
_nextExpectedAction = nextAction ;
++ _sequenceLevels [ combo ] ;
_resetSequenceTimer ( ) ;
} ;
}
2021-11-15 13:50:17 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* wraps the specified callback inside of another function in order
* to reset all sequence counters as soon as this sequence is done
*
* @ param { Event } e
* @ returns void
* /
function _callbackAndReset ( e ) {
_fireCallback ( callback , e , combo ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
// we should ignore the next key up if the action is key down
// or keypress. this is so if you finish a sequence and
// release the key the final key will not trigger a keyup
if ( action !== 'keyup' ) {
_ignoreNextKeyup = _characterFromEvent ( e ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// weird race condition if a sequence ends with the key
// another sequence begins with
setTimeout ( _resetSequences , 10 ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// loop through keys one at a time and bind the appropriate callback
// function. for any key leading up to the final one it should
// increase the sequence. after the final, it should reset all sequences
//
// if an action is specified in the original bind call then that will
// be used throughout. otherwise we will pass the action that the
// next key in the sequence should match. this allows a sequence
// to mix and match keypress and keydown events depending on which
// ones are better suited to the key provided
for ( var i = 0 ; i < keys . length ; ++ i ) {
var isFinal = i + 1 === keys . length ;
var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence ( action || _getKeyInfo ( keys [ i + 1 ] ) . action ) ;
_bindSingle ( keys [ i ] , wrappedCallback , action , combo , i ) ;
}
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* binds a single keyboard combination
*
* @ param { string } combination
* @ param { Function } callback
* @ param { string = } action
* @ param { string = } sequenceName - name of sequence if part of sequence
* @ param { number = } level - what part of the sequence the command is
* @ returns void
* /
function _bindSingle ( combination , callback , action , sequenceName , level ) {
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
// store a direct mapped reference for use with Mousetrap.trigger
self . _directMap [ combination + ':' + action ] = callback ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
// make sure multiple spaces in a row become a single space
combination = combination . replace ( /\s+/g , ' ' ) ;
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
var sequence = combination . split ( ' ' ) ;
var info ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if this pattern is a sequence of keys then run through this method
// to reprocess each pattern one key at a time
if ( sequence . length > 1 ) {
_bindSequence ( combination , sequence , callback , action ) ;
return ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
info = _getKeyInfo ( combination , action ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
// make sure to initialize array if this is the first time
// a callback is added for this key
self . _callbacks [ info . key ] = self . _callbacks [ info . key ] || [ ] ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// remove an existing match if there is one
_getMatches ( info . key , info . modifiers , { type : info . action } , sequenceName , combination , level ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// add this call back to the array
// if it is a sequence put it at the beginning
// if not put it at the end
//
// this is important because the way these are processed expects
// the sequence ones to come first
self . _callbacks [ info . key ] [ sequenceName ? 'unshift' : 'push' ] ( {
callback : callback ,
modifiers : info . modifiers ,
action : info . action ,
seq : sequenceName ,
level : level ,
combo : combination
} ) ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* binds multiple combinations to the same callback
*
* @ param { Array } combinations
* @ param { Function } callback
* @ param { string | undefined } action
* @ returns void
* /
self . _bindMultiple = function ( combinations , callback , action ) {
for ( var i = 0 ; i < combinations . length ; ++ i ) {
_bindSingle ( combinations [ i ] , callback , action ) ;
}
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// start!
_addEvent ( targetElement , 'keypress' , _handleKeyEvent ) ;
_addEvent ( targetElement , 'keydown' , _handleKeyEvent ) ;
_addEvent ( targetElement , 'keyup' , _handleKeyEvent ) ;
2021-05-20 14:20:04 +02:00
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* binds an event to mousetrap
*
* can be a single key , a combination of keys separated with + ,
* an array of keys , or a sequence of keys separated by spaces
*
* be sure to list the modifier keys first to make sure that the
* correct key ends up getting bound ( the last key in the pattern )
*
* @ param { string | Array } keys
* @ param { Function } callback
* @ param { string = } action - 'keypress' , 'keydown' , or 'keyup'
* @ returns void
* /
Mousetrap . prototype . bind = function ( keys , callback , action ) {
var self = this ;
keys = keys instanceof Array ? keys : [ keys ] ;
self . _bindMultiple . call ( self , keys , callback , action ) ;
return self ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* unbinds an event to mousetrap
*
* the unbinding sets the callback function of the specified key combo
* to an empty function and deletes the corresponding key in the
* _directMap dict .
*
* TODO : actually remove this from the _callbacks dictionary instead
* of binding an empty function
*
* the keycombo + action has to be exactly the same as
* it was defined in the bind method
*
* @ param { string | Array } keys
* @ param { string } action
* @ returns void
* /
Mousetrap . prototype . unbind = function ( keys , action ) {
var self = this ;
return self . bind . call ( self , keys , function ( ) { } , action ) ;
2021-05-20 14:20:04 +02:00
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* triggers an event that has already been bound
*
* @ param { string } keys
* @ param { string = } action
* @ returns void
* /
Mousetrap . prototype . trigger = function ( keys , action ) {
var self = this ;
if ( self . _directMap [ keys + ':' + action ] ) {
self . _directMap [ keys + ':' + action ] ( { } , keys ) ;
}
return self ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* resets the library back to its initial state . this is useful
* if you want to clear out the current keyboard shortcuts and bind
* new ones - for example if you switch to another page
*
* @ returns void
* /
Mousetrap . prototype . reset = function ( ) {
var self = this ;
self . _callbacks = { } ;
self . _directMap = { } ;
return self ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* should we stop this event before firing off callbacks
*
* @ param { Event } e
* @ param { Element } element
* @ return { boolean }
* /
Mousetrap . prototype . stopCallback = function ( e , element ) {
var self = this ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// if the element has the class "mousetrap" then no need to stop
if ( ( ' ' + element . className + ' ' ) . indexOf ( ' mousetrap ' ) > - 1 ) {
return false ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( _belongsTo ( element , self . target ) ) {
return false ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
// not the initial event target in the shadow tree. Note that not all events cross the
// shadow boundary.
// For shadow trees with `mode: 'open'`, the initial event target is the first element in
// the event’ s composed path. For shadow trees with `mode: 'closed'`, the initial event
// target cannot be obtained.
if ( 'composedPath' in e && typeof e . composedPath === 'function' ) {
// For open shadow trees, update `element` so that the following check works.
var initialEventTarget = e . composedPath ( ) [ 0 ] ;
if ( initialEventTarget !== e . target ) {
element = initialEventTarget ;
}
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// stop for input, select, and textarea
return element . tagName == 'INPUT' || element . tagName == 'SELECT' || element . tagName == 'TEXTAREA' || element . isContentEditable ;
} ;
/ * *
* exposes _handleKey publicly so it can be overwritten by extensions
* /
Mousetrap . prototype . handleKey = function ( ) {
var self = this ;
return self . _handleKey . apply ( self , arguments ) ;
} ;
/ * *
* allow custom key mappings
* /
Mousetrap . addKeycodes = function ( object ) {
for ( var key in object ) {
if ( object . hasOwnProperty ( key ) ) {
_MAP [ key ] = object [ key ] ;
}
}
_REVERSE _MAP = null ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Init the global mousetrap functions
*
* This method is needed to allow the global mousetrap functions to work
* now that mousetrap is a constructor function .
* /
Mousetrap . init = function ( ) {
var documentMousetrap = Mousetrap ( document ) ;
for ( var method in documentMousetrap ) {
if ( method . charAt ( 0 ) !== '_' ) {
Mousetrap [ method ] = ( function ( method ) {
return function ( ) {
return documentMousetrap [ method ] . apply ( documentMousetrap , arguments ) ;
} ;
} ( method ) ) ;
}
}
} ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
Mousetrap . init ( ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// expose mousetrap to the global object
window . Mousetrap = Mousetrap ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// expose as a common js module
if ( true && module . exports ) {
module . exports = Mousetrap ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// expose mousetrap as an AMD module
if ( true ) {
! ( _ _WEBPACK _AMD _DEFINE _RESULT _ _ = ( function ( ) {
return Mousetrap ;
} ) . call ( exports , _ _webpack _require _ _ , exports , module ) ,
_ _WEBPACK _AMD _DEFINE _RESULT _ _ !== undefined && ( module . exports = _ _WEBPACK _AMD _DEFINE _RESULT _ _ ) ) ;
}
} ) ( typeof window !== 'undefined' ? window : null , typeof window !== 'undefined' ? document : null ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/***/ } ) ,
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/***/ 5538 :
2023-09-21 15:26:32 +02:00
/***/ ( function ( ) {
2020-01-22 23:06:21 +01:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* adds a bindGlobal method to Mousetrap that allows you to
* bind specific keyboard shortcuts that will still work
* inside a text input field
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* usage :
* Mousetrap . bindGlobal ( 'ctrl+s' , _saveChanges ) ;
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
/* global Mousetrap:true */
( function ( Mousetrap ) {
if ( ! Mousetrap ) {
return ;
}
var _globalCallbacks = { } ;
var _originalStopCallback = Mousetrap . prototype . stopCallback ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
Mousetrap . prototype . stopCallback = function ( e , element , combo , sequence ) {
var self = this ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( self . paused ) {
return true ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( _globalCallbacks [ combo ] || _globalCallbacks [ sequence ] ) {
return false ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
return _originalStopCallback . call ( self , e , element , combo ) ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
Mousetrap . prototype . bindGlobal = function ( keys , callback , action ) {
var self = this ;
self . bind ( keys , callback , action ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
if ( keys instanceof Array ) {
for ( var i = 0 ; i < keys . length ; i ++ ) {
_globalCallbacks [ keys [ i ] ] = true ;
}
return ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
_globalCallbacks [ keys ] = true ;
} ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
Mousetrap . init ( ) ;
} ) ( typeof Mousetrap !== "undefined" ? Mousetrap : undefined ) ;
2020-01-22 23:06:21 +01:00
2023-09-26 16:23:26 +02:00
/***/ } ) ,
/***/ 9127 :
/***/ ( function ( module ) {
"use strict" ;
module . exports = window [ "wp" ] [ "isShallowEqual" ] ;
2022-04-11 14:04:30 +02:00
/***/ } )
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ _ _webpack _modules _ _ [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
2023-09-21 15:26:32 +02:00
/******/ ! function ( ) {
2022-04-11 14:04:30 +02:00
/******/ // getDefaultExport function for compatibility with non-harmony modules
2023-09-21 15:26:32 +02:00
/******/ _ _webpack _require _ _ . n = function ( module ) {
2022-04-11 14:04:30 +02:00
/******/ var getter = module && module . _ _esModule ?
2023-09-21 15:26:32 +02:00
/******/ function ( ) { return module [ 'default' ] ; } :
/******/ function ( ) { return module ; } ;
2022-04-11 14:04:30 +02:00
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
2023-09-21 15:26:32 +02:00
/******/ } ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ /* webpack/runtime/define property getters */
2023-09-21 15:26:32 +02:00
/******/ ! function ( ) {
2022-04-11 14:04:30 +02:00
/******/ // define getter functions for harmony exports
2023-09-21 15:26:32 +02:00
/******/ _ _webpack _require _ _ . d = function ( exports , definition ) {
2022-04-11 14:04:30 +02:00
/******/ for ( var key in definition ) {
/******/ if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports , key ) ) {
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
/******/ } ;
2023-09-21 15:26:32 +02:00
/******/ } ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2023-09-21 15:26:32 +02:00
/******/ ! function ( ) {
/******/ _ _webpack _require _ _ . o = function ( obj , prop ) { return Object . prototype . hasOwnProperty . call ( obj , prop ) ; }
/******/ } ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ /* webpack/runtime/make namespace object */
2023-09-21 15:26:32 +02:00
/******/ ! function ( ) {
2022-04-11 14:04:30 +02:00
/******/ // define __esModule on exports
2023-09-21 15:26:32 +02:00
/******/ _ _webpack _require _ _ . r = function ( exports ) {
2022-04-11 14:04:30 +02:00
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
2023-09-21 15:26:32 +02:00
/******/ } ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/************************************************************************/
var _ _webpack _exports _ _ = { } ;
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
2023-09-21 15:26:32 +02:00
! function ( ) {
2022-04-11 14:04:30 +02:00
"use strict" ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
2023-09-21 15:26:32 +02:00
_ _experimentalUseDialog : function ( ) { return /* reexport */ use _dialog ; } ,
_ _experimentalUseDragging : function ( ) { return /* reexport */ useDragging ; } ,
_ _experimentalUseDropZone : function ( ) { return /* reexport */ useDropZone ; } ,
_ _experimentalUseFixedWindowList : function ( ) { return /* reexport */ useFixedWindowList ; } ,
_ _experimentalUseFocusOutside : function ( ) { return /* reexport */ useFocusOutside ; } ,
compose : function ( ) { return /* reexport */ higher _order _compose ; } ,
createHigherOrderComponent : function ( ) { return /* reexport */ createHigherOrderComponent ; } ,
debounce : function ( ) { return /* reexport */ debounce ; } ,
ifCondition : function ( ) { return /* reexport */ if _condition ; } ,
pipe : function ( ) { return /* reexport */ higher _order _pipe ; } ,
pure : function ( ) { return /* reexport */ higher _order _pure ; } ,
throttle : function ( ) { return /* reexport */ throttle ; } ,
useAsyncList : function ( ) { return /* reexport */ use _async _list ; } ,
useConstrainedTabbing : function ( ) { return /* reexport */ use _constrained _tabbing ; } ,
useCopyOnClick : function ( ) { return /* reexport */ useCopyOnClick ; } ,
useCopyToClipboard : function ( ) { return /* reexport */ useCopyToClipboard ; } ,
useDebounce : function ( ) { return /* reexport */ useDebounce ; } ,
useDisabled : function ( ) { return /* reexport */ useDisabled ; } ,
useFocusOnMount : function ( ) { return /* reexport */ useFocusOnMount ; } ,
useFocusReturn : function ( ) { return /* reexport */ use _focus _return ; } ,
useFocusableIframe : function ( ) { return /* reexport */ useFocusableIframe ; } ,
useInstanceId : function ( ) { return /* reexport */ use _instance _id ; } ,
useIsomorphicLayoutEffect : function ( ) { return /* reexport */ use _isomorphic _layout _effect ; } ,
useKeyboardShortcut : function ( ) { return /* reexport */ use _keyboard _shortcut ; } ,
useMediaQuery : function ( ) { return /* reexport */ useMediaQuery ; } ,
useMergeRefs : function ( ) { return /* reexport */ useMergeRefs ; } ,
usePrevious : function ( ) { return /* reexport */ usePrevious ; } ,
useReducedMotion : function ( ) { return /* reexport */ use _reduced _motion ; } ,
useRefEffect : function ( ) { return /* reexport */ useRefEffect ; } ,
useResizeObserver : function ( ) { return /* reexport */ useResizeAware ; } ,
2023-09-26 16:23:26 +02:00
useStateWithHistory : function ( ) { return /* reexport */ useStateWithHistory ; } ,
2023-09-21 15:26:32 +02:00
useThrottle : function ( ) { return /* reexport */ useThrottle ; } ,
useViewportMatch : function ( ) { return /* reexport */ use _viewport _match ; } ,
useWarnOnChange : function ( ) { return /* reexport */ use _warn _on _change ; } ,
withGlobalEvents : function ( ) { return /* reexport */ withGlobalEvents ; } ,
withInstanceId : function ( ) { return /* reexport */ with _instance _id ; } ,
withSafeTimeout : function ( ) { return /* reexport */ with _safe _timeout ; } ,
withState : function ( ) { return /* reexport */ withState ; }
2022-04-11 14:04:30 +02:00
} ) ;
2020-01-22 23:06:21 +01:00
2023-06-27 16:24:19 +02:00
; // CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Copyright ( c ) Microsoft Corporation .
Permission to use , copy , modify , and / or distribute this software for any
purpose with or without fee is hereby granted .
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT ,
INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE , DATA OR PROFITS , WHETHER IN AN ACTION OF CONTRACT , NEGLIGENCE OR
OTHER TORTIOUS ACTION , ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/* global Reflect, Promise, SuppressedError, Symbol */
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf ||
( { _ _proto _ _ : [ ] } instanceof Array && function ( d , b ) { d . _ _proto _ _ = b ; } ) ||
function ( d , b ) { for ( var p in b ) if ( Object . prototype . hasOwnProperty . call ( b , p ) ) d [ p ] = b [ p ] ; } ;
return extendStatics ( d , b ) ;
} ;
function _ _extends ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) { this . constructor = d ; }
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
}
var _ _assign = function ( ) {
_ _assign = Object . assign || function _ _assign ( t ) {
for ( var s , i = 1 , n = arguments . length ; i < n ; i ++ ) {
s = arguments [ i ] ;
for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) ) t [ p ] = s [ p ] ;
}
return t ;
}
return _ _assign . apply ( this , arguments ) ;
}
function _ _rest ( s , e ) {
var t = { } ;
for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) && e . indexOf ( p ) < 0 )
t [ p ] = s [ p ] ;
if ( s != null && typeof Object . getOwnPropertySymbols === "function" )
for ( var i = 0 , p = Object . getOwnPropertySymbols ( s ) ; i < p . length ; i ++ ) {
if ( e . indexOf ( p [ i ] ) < 0 && Object . prototype . propertyIsEnumerable . call ( s , p [ i ] ) )
t [ p [ i ] ] = s [ p [ i ] ] ;
}
return t ;
}
function _ _decorate ( decorators , target , key , desc ) {
var c = arguments . length , r = c < 3 ? target : desc === null ? desc = Object . getOwnPropertyDescriptor ( target , key ) : desc , d ;
if ( typeof Reflect === "object" && typeof Reflect . decorate === "function" ) r = Reflect . decorate ( decorators , target , key , desc ) ;
else for ( var i = decorators . length - 1 ; i >= 0 ; i -- ) if ( d = decorators [ i ] ) r = ( c < 3 ? d ( r ) : c > 3 ? d ( target , key , r ) : d ( target , key ) ) || r ;
return c > 3 && r && Object . defineProperty ( target , key , r ) , r ;
}
function _ _param ( paramIndex , decorator ) {
return function ( target , key ) { decorator ( target , key , paramIndex ) ; }
}
function _ _esDecorate ( ctor , descriptorIn , decorators , contextIn , initializers , extraInitializers ) {
function accept ( f ) { if ( f !== void 0 && typeof f !== "function" ) throw new TypeError ( "Function expected" ) ; return f ; }
var kind = contextIn . kind , key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value" ;
var target = ! descriptorIn && ctor ? contextIn [ "static" ] ? ctor : ctor . prototype : null ;
var descriptor = descriptorIn || ( target ? Object . getOwnPropertyDescriptor ( target , contextIn . name ) : { } ) ;
var _ , done = false ;
for ( var i = decorators . length - 1 ; i >= 0 ; i -- ) {
var context = { } ;
for ( var p in contextIn ) context [ p ] = p === "access" ? { } : contextIn [ p ] ;
for ( var p in contextIn . access ) context . access [ p ] = contextIn . access [ p ] ;
context . addInitializer = function ( f ) { if ( done ) throw new TypeError ( "Cannot add initializers after decoration has completed" ) ; extraInitializers . push ( accept ( f || null ) ) ; } ;
var result = ( 0 , decorators [ i ] ) ( kind === "accessor" ? { get : descriptor . get , set : descriptor . set } : descriptor [ key ] , context ) ;
if ( kind === "accessor" ) {
if ( result === void 0 ) continue ;
if ( result === null || typeof result !== "object" ) throw new TypeError ( "Object expected" ) ;
if ( _ = accept ( result . get ) ) descriptor . get = _ ;
if ( _ = accept ( result . set ) ) descriptor . set = _ ;
if ( _ = accept ( result . init ) ) initializers . unshift ( _ ) ;
}
else if ( _ = accept ( result ) ) {
if ( kind === "field" ) initializers . unshift ( _ ) ;
else descriptor [ key ] = _ ;
}
}
if ( target ) Object . defineProperty ( target , contextIn . name , descriptor ) ;
done = true ;
} ;
function _ _runInitializers ( thisArg , initializers , value ) {
var useValue = arguments . length > 2 ;
for ( var i = 0 ; i < initializers . length ; i ++ ) {
value = useValue ? initializers [ i ] . call ( thisArg , value ) : initializers [ i ] . call ( thisArg ) ;
}
return useValue ? value : void 0 ;
} ;
function _ _propKey ( x ) {
return typeof x === "symbol" ? x : "" . concat ( x ) ;
} ;
function _ _setFunctionName ( f , name , prefix ) {
if ( typeof name === "symbol" ) name = name . description ? "[" . concat ( name . description , "]" ) : "" ;
return Object . defineProperty ( f , "name" , { configurable : true , value : prefix ? "" . concat ( prefix , " " , name ) : name } ) ;
} ;
function _ _metadata ( metadataKey , metadataValue ) {
if ( typeof Reflect === "object" && typeof Reflect . metadata === "function" ) return Reflect . metadata ( metadataKey , metadataValue ) ;
}
function _ _awaiter ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
}
function _ _generator ( thisArg , body ) {
var _ = { label : 0 , sent : function ( ) { if ( t [ 0 ] & 1 ) throw t [ 1 ] ; return t [ 1 ] ; } , trys : [ ] , ops : [ ] } , f , y , t , g ;
return g = { next : verb ( 0 ) , "throw" : verb ( 1 ) , "return" : verb ( 2 ) } , typeof Symbol === "function" && ( g [ Symbol . iterator ] = function ( ) { return this ; } ) , g ;
function verb ( n ) { return function ( v ) { return step ( [ n , v ] ) ; } ; }
function step ( op ) {
if ( f ) throw new TypeError ( "Generator is already executing." ) ;
while ( g && ( g = 0 , op [ 0 ] && ( _ = 0 ) ) , _ ) try {
if ( f = 1 , y && ( t = op [ 0 ] & 2 ? y [ "return" ] : op [ 0 ] ? y [ "throw" ] || ( ( t = y [ "return" ] ) && t . call ( y ) , 0 ) : y . next ) && ! ( t = t . call ( y , op [ 1 ] ) ) . done ) return t ;
if ( y = 0 , t ) op = [ op [ 0 ] & 2 , t . value ] ;
switch ( op [ 0 ] ) {
case 0 : case 1 : t = op ; break ;
case 4 : _ . label ++ ; return { value : op [ 1 ] , done : false } ;
case 5 : _ . label ++ ; y = op [ 1 ] ; op = [ 0 ] ; continue ;
case 7 : op = _ . ops . pop ( ) ; _ . trys . pop ( ) ; continue ;
default :
if ( ! ( t = _ . trys , t = t . length > 0 && t [ t . length - 1 ] ) && ( op [ 0 ] === 6 || op [ 0 ] === 2 ) ) { _ = 0 ; continue ; }
if ( op [ 0 ] === 3 && ( ! t || ( op [ 1 ] > t [ 0 ] && op [ 1 ] < t [ 3 ] ) ) ) { _ . label = op [ 1 ] ; break ; }
if ( op [ 0 ] === 6 && _ . label < t [ 1 ] ) { _ . label = t [ 1 ] ; t = op ; break ; }
if ( t && _ . label < t [ 2 ] ) { _ . label = t [ 2 ] ; _ . ops . push ( op ) ; break ; }
if ( t [ 2 ] ) _ . ops . pop ( ) ;
_ . trys . pop ( ) ; continue ;
}
op = body . call ( thisArg , _ ) ;
} catch ( e ) { op = [ 6 , e ] ; y = 0 ; } finally { f = t = 0 ; }
if ( op [ 0 ] & 5 ) throw op [ 1 ] ; return { value : op [ 0 ] ? op [ 1 ] : void 0 , done : true } ;
}
}
var _ _createBinding = Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
var desc = Object . getOwnPropertyDescriptor ( m , k ) ;
if ( ! desc || ( "get" in desc ? ! m . _ _esModule : desc . writable || desc . configurable ) ) {
desc = { enumerable : true , get : function ( ) { return m [ k ] ; } } ;
}
Object . defineProperty ( o , k2 , desc ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ;
function _ _exportStar ( m , o ) {
for ( var p in m ) if ( p !== "default" && ! Object . prototype . hasOwnProperty . call ( o , p ) ) _ _createBinding ( o , m , p ) ;
}
function _ _values ( o ) {
var s = typeof Symbol === "function" && Symbol . iterator , m = s && o [ s ] , i = 0 ;
if ( m ) return m . call ( o ) ;
if ( o && typeof o . length === "number" ) return {
next : function ( ) {
if ( o && i >= o . length ) o = void 0 ;
return { value : o && o [ i ++ ] , done : ! o } ;
}
} ;
throw new TypeError ( s ? "Object is not iterable." : "Symbol.iterator is not defined." ) ;
}
function _ _read ( o , n ) {
var m = typeof Symbol === "function" && o [ Symbol . iterator ] ;
if ( ! m ) return o ;
var i = m . call ( o ) , r , ar = [ ] , e ;
try {
while ( ( n === void 0 || n -- > 0 ) && ! ( r = i . next ( ) ) . done ) ar . push ( r . value ) ;
}
catch ( error ) { e = { error : error } ; }
finally {
try {
if ( r && ! r . done && ( m = i [ "return" ] ) ) m . call ( i ) ;
}
finally { if ( e ) throw e . error ; }
}
return ar ;
}
/** @deprecated */
function _ _spread ( ) {
for ( var ar = [ ] , i = 0 ; i < arguments . length ; i ++ )
ar = ar . concat ( _ _read ( arguments [ i ] ) ) ;
return ar ;
}
/** @deprecated */
function _ _spreadArrays ( ) {
for ( var s = 0 , i = 0 , il = arguments . length ; i < il ; i ++ ) s += arguments [ i ] . length ;
for ( var r = Array ( s ) , k = 0 , i = 0 ; i < il ; i ++ )
for ( var a = arguments [ i ] , j = 0 , jl = a . length ; j < jl ; j ++ , k ++ )
r [ k ] = a [ j ] ;
return r ;
}
function _ _spreadArray ( to , from , pack ) {
if ( pack || arguments . length === 2 ) for ( var i = 0 , l = from . length , ar ; i < l ; i ++ ) {
if ( ar || ! ( i in from ) ) {
if ( ! ar ) ar = Array . prototype . slice . call ( from , 0 , i ) ;
ar [ i ] = from [ i ] ;
}
}
return to . concat ( ar || Array . prototype . slice . call ( from ) ) ;
}
function _ _await ( v ) {
return this instanceof _ _await ? ( this . v = v , this ) : new _ _await ( v ) ;
}
function _ _asyncGenerator ( thisArg , _arguments , generator ) {
if ( ! Symbol . asyncIterator ) throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var g = generator . apply ( thisArg , _arguments || [ ] ) , i , q = [ ] ;
return i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) { return this ; } , i ;
function verb ( n ) { if ( g [ n ] ) i [ n ] = function ( v ) { return new Promise ( function ( a , b ) { q . push ( [ n , v , a , b ] ) > 1 || resume ( n , v ) ; } ) ; } ; }
function resume ( n , v ) { try { step ( g [ n ] ( v ) ) ; } catch ( e ) { settle ( q [ 0 ] [ 3 ] , e ) ; } }
function step ( r ) { r . value instanceof _ _await ? Promise . resolve ( r . value . v ) . then ( fulfill , reject ) : settle ( q [ 0 ] [ 2 ] , r ) ; }
function fulfill ( value ) { resume ( "next" , value ) ; }
function reject ( value ) { resume ( "throw" , value ) ; }
function settle ( f , v ) { if ( f ( v ) , q . shift ( ) , q . length ) resume ( q [ 0 ] [ 0 ] , q [ 0 ] [ 1 ] ) ; }
}
function _ _asyncDelegator ( o ) {
var i , p ;
return i = { } , verb ( "next" ) , verb ( "throw" , function ( e ) { throw e ; } ) , verb ( "return" ) , i [ Symbol . iterator ] = function ( ) { return this ; } , i ;
function verb ( n , f ) { i [ n ] = o [ n ] ? function ( v ) { return ( p = ! p ) ? { value : _ _await ( o [ n ] ( v ) ) , done : false } : f ? f ( v ) : v ; } : f ; }
}
function _ _asyncValues ( o ) {
if ( ! Symbol . asyncIterator ) throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var m = o [ Symbol . asyncIterator ] , i ;
return m ? m . call ( o ) : ( o = typeof _ _values === "function" ? _ _values ( o ) : o [ Symbol . iterator ] ( ) , i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) { return this ; } , i ) ;
function verb ( n ) { i [ n ] = o [ n ] && function ( v ) { return new Promise ( function ( resolve , reject ) { v = o [ n ] ( v ) , settle ( resolve , reject , v . done , v . value ) ; } ) ; } ; }
function settle ( resolve , reject , d , v ) { Promise . resolve ( v ) . then ( function ( v ) { resolve ( { value : v , done : d } ) ; } , reject ) ; }
}
function _ _makeTemplateObject ( cooked , raw ) {
if ( Object . defineProperty ) { Object . defineProperty ( cooked , "raw" , { value : raw } ) ; } else { cooked . raw = raw ; }
return cooked ;
} ;
var _ _setModuleDefault = Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ;
function _ _importStar ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
}
function _ _importDefault ( mod ) {
return ( mod && mod . _ _esModule ) ? mod : { default : mod } ;
}
function _ _classPrivateFieldGet ( receiver , state , kind , f ) {
if ( kind === "a" && ! f ) throw new TypeError ( "Private accessor was defined without a getter" ) ;
if ( typeof state === "function" ? receiver !== state || ! f : ! state . has ( receiver ) ) throw new TypeError ( "Cannot read private member from an object whose class did not declare it" ) ;
return kind === "m" ? f : kind === "a" ? f . call ( receiver ) : f ? f . value : state . get ( receiver ) ;
}
function _ _classPrivateFieldSet ( receiver , state , value , kind , f ) {
if ( kind === "m" ) throw new TypeError ( "Private method is not writable" ) ;
if ( kind === "a" && ! f ) throw new TypeError ( "Private accessor was defined without a setter" ) ;
if ( typeof state === "function" ? receiver !== state || ! f : ! state . has ( receiver ) ) throw new TypeError ( "Cannot write private member to an object whose class did not declare it" ) ;
return ( kind === "a" ? f . call ( receiver , value ) : f ? f . value = value : state . set ( receiver , value ) ) , value ;
}
function _ _classPrivateFieldIn ( state , receiver ) {
if ( receiver === null || ( typeof receiver !== "object" && typeof receiver !== "function" ) ) throw new TypeError ( "Cannot use 'in' operator on non-object" ) ;
return typeof state === "function" ? receiver === state : state . has ( receiver ) ;
}
function _ _addDisposableResource ( env , value , async ) {
if ( value !== null && value !== void 0 ) {
2023-09-21 15:26:32 +02:00
if ( typeof value !== "object" && typeof value !== "function" ) throw new TypeError ( "Object expected." ) ;
2023-06-27 16:24:19 +02:00
var dispose ;
if ( async ) {
if ( ! Symbol . asyncDispose ) throw new TypeError ( "Symbol.asyncDispose is not defined." ) ;
dispose = value [ Symbol . asyncDispose ] ;
}
if ( dispose === void 0 ) {
if ( ! Symbol . dispose ) throw new TypeError ( "Symbol.dispose is not defined." ) ;
dispose = value [ Symbol . dispose ] ;
}
if ( typeof dispose !== "function" ) throw new TypeError ( "Object not disposable." ) ;
env . stack . push ( { value : value , dispose : dispose , async : async } ) ;
}
else if ( async ) {
env . stack . push ( { async : true } ) ;
}
return value ;
}
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function ( error , suppressed , message ) {
var e = new Error ( message ) ;
return e . name = "SuppressedError" , e . error = error , e . suppressed = suppressed , e ;
} ;
function _ _disposeResources ( env ) {
function fail ( e ) {
env . error = env . hasError ? new _SuppressedError ( e , env . error , "An error was suppressed during disposal." ) : e ;
env . hasError = true ;
}
function next ( ) {
while ( env . stack . length ) {
var rec = env . stack . pop ( ) ;
try {
var result = rec . dispose && rec . dispose . call ( rec . value ) ;
if ( rec . async ) return Promise . resolve ( result ) . then ( next , function ( e ) { fail ( e ) ; return next ( ) ; } ) ;
}
catch ( e ) {
fail ( e ) ;
}
}
if ( env . hasError ) throw env . error ;
}
return next ( ) ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var tslib _es6 = ( {
2023-06-27 16:24:19 +02:00
_ _extends ,
_ _assign ,
_ _rest ,
_ _decorate ,
_ _param ,
_ _metadata ,
_ _awaiter ,
_ _generator ,
_ _createBinding ,
_ _exportStar ,
_ _values ,
_ _read ,
_ _spread ,
_ _spreadArrays ,
_ _spreadArray ,
_ _await ,
_ _asyncGenerator ,
_ _asyncDelegator ,
_ _asyncValues ,
_ _makeTemplateObject ,
_ _importStar ,
_ _importDefault ,
_ _classPrivateFieldGet ,
_ _classPrivateFieldSet ,
_ _classPrivateFieldIn ,
_ _addDisposableResource ,
_ _disposeResources ,
} ) ;
2022-09-20 17:43:29 +02:00
; // CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
/ * *
* Source : ftp : //ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
* /
var SUPPORTED _LOCALE = {
tr : {
regexp : /\u0130|\u0049|\u0049\u0307/g ,
map : {
İ : "\u0069" ,
I : "\u0131" ,
I ̇ : "\u0069" ,
} ,
} ,
az : {
regexp : /\u0130/g ,
map : {
İ : "\u0069" ,
I : "\u0131" ,
I ̇ : "\u0069" ,
} ,
} ,
lt : {
regexp : /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g ,
map : {
I : "\u0069\u0307" ,
J : "\u006A\u0307" ,
Į : "\u012F\u0307" ,
Ì : "\u0069\u0307\u0300" ,
Í : "\u0069\u0307\u0301" ,
Ĩ : "\u0069\u0307\u0303" ,
} ,
} ,
} ;
/ * *
* Localized lower case .
* /
function localeLowerCase ( str , locale ) {
var lang = SUPPORTED _LOCALE [ locale . toLowerCase ( ) ] ;
if ( lang )
return lowerCase ( str . replace ( lang . regexp , function ( m ) { return lang . map [ m ] ; } ) ) ;
return lowerCase ( str ) ;
}
/ * *
* Lower case as a function .
* /
function lowerCase ( str ) {
return str . toLowerCase ( ) ;
}
; // CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
var DEFAULT _SPLIT _REGEXP = [ /([a-z0-9])([A-Z])/g , /([A-Z])([A-Z][a-z])/g ] ;
// Remove all non-word characters.
var DEFAULT _STRIP _REGEXP = /[^A-Z0-9]+/gi ;
/ * *
* Normalize the string into something other libraries can manipulate easier .
* /
function noCase ( input , options ) {
if ( options === void 0 ) { options = { } ; }
var _a = options . splitRegexp , splitRegexp = _a === void 0 ? DEFAULT _SPLIT _REGEXP : _a , _b = options . stripRegexp , stripRegexp = _b === void 0 ? DEFAULT _STRIP _REGEXP : _b , _c = options . transform , transform = _c === void 0 ? lowerCase : _c , _d = options . delimiter , delimiter = _d === void 0 ? " " : _d ;
var result = replace ( replace ( input , splitRegexp , "$1\0$2" ) , stripRegexp , "\0" ) ;
var start = 0 ;
var end = result . length ;
// Trim the delimiter from around the output string.
while ( result . charAt ( start ) === "\0" )
start ++ ;
while ( result . charAt ( end - 1 ) === "\0" )
end -- ;
// Transform each token independently.
return result . slice ( start , end ) . split ( "\0" ) . map ( transform ) . join ( delimiter ) ;
}
/ * *
* Replace ` re ` in the input string with the replacement value .
* /
function replace ( input , re , value ) {
if ( re instanceof RegExp )
return input . replace ( re , value ) ;
return re . reduce ( function ( input , re ) { return input . replace ( re , value ) ; } , input ) ;
}
; // CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
function pascalCaseTransform ( input , index ) {
var firstChar = input . charAt ( 0 ) ;
var lowerChars = input . substr ( 1 ) . toLowerCase ( ) ;
if ( index > 0 && firstChar >= "0" && firstChar <= "9" ) {
return "_" + firstChar + lowerChars ;
}
return "" + firstChar . toUpperCase ( ) + lowerChars ;
}
function pascalCaseTransformMerge ( input ) {
return input . charAt ( 0 ) . toUpperCase ( ) + input . slice ( 1 ) . toLowerCase ( ) ;
}
function pascalCase ( input , options ) {
if ( options === void 0 ) { options = { } ; }
return noCase ( input , _ _assign ( { delimiter : "" , transform : pascalCaseTransform } , options ) ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* External dependencies
* /
2022-04-12 17:12:47 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Given a function mapping a component to an enhanced component and modifier
* name , returns the enhanced component augmented with a generated displayName .
2021-05-20 14:20:04 +02:00
*
2023-06-27 16:24:19 +02:00
* @ param mapComponent Function mapping component to enhanced component .
* @ param modifierName Seed name from which to generated display name .
2021-11-08 15:29:21 +01:00
*
2022-04-11 14:04:30 +02:00
* @ return Component class with generated display name assigned .
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
function createHigherOrderComponent ( mapComponent , modifierName ) {
return Inner => {
const Outer = mapComponent ( Inner ) ;
2022-09-20 17:43:29 +02:00
Outer . displayName = hocName ( modifierName , Inner ) ;
2022-04-11 14:04:30 +02:00
return Outer ;
2021-11-15 13:50:17 +01:00
} ;
2021-05-20 14:20:04 +02:00
}
2023-09-26 16:23:26 +02:00
2022-09-20 17:43:29 +02:00
/ * *
* Returns a displayName for a higher - order component , given a wrapper name .
*
* @ example
* hocName ( 'MyMemo' , Widget ) === 'MyMemo(Widget)' ;
* hocName ( 'MyMemo' , < div / > ) === 'MyMemo(Component)' ;
*
2023-06-27 16:24:19 +02:00
* @ param name Name assigned to higher - order component ' s wrapper component .
* @ param Inner Wrapped component inside higher - order component .
2022-09-20 17:43:29 +02:00
* @ return Wrapped name of higher - order component .
* /
const hocName = ( name , Inner ) => {
const inner = Inner . displayName || Inner . name || 'Component' ;
const outer = pascalCase ( name !== null && name !== void 0 ? name : '' ) ;
return ` ${ outer } ( ${ inner } ) ` ;
} ;
2020-01-22 23:06:21 +01:00
2023-02-07 08:04:52 +01:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/debounce/index.js
/ * *
* Parts of this source were derived and modified from lodash ,
* released under the MIT license .
*
* https : //github.com/lodash/lodash
*
* Copyright JS Foundation and other contributors < https : //js.foundation/>
*
* Based on Underscore . js , copyright Jeremy Ashkenas ,
* DocumentCloud and Investigative Reporters & Editors < http : //underscorejs.org/>
*
* This software consists of voluntary contributions made by many
* individuals . For exact contribution history , see the revision history
* available at https : //github.com/lodash/lodash
*
* The following license applies to all parts of this software except as
* documented below :
*
* === =
*
* Permission is hereby granted , free of charge , to any person obtaining
* a copy of this software and associated documentation files ( the
* "Software" ) , to deal in the Software without restriction , including
* without limitation the rights to use , copy , modify , merge , publish ,
* distribute , sublicense , and / or sell copies of the Software , and to
* permit persons to whom the Software is furnished to do so , subject to
* the following conditions :
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION
* OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
* /
/ * *
* A simplified and properly typed version of lodash ' s ` debounce ` , that
* always uses timers instead of sometimes using rAF .
*
* Creates a debounced function that delays invoking ` func ` until after ` wait `
* milliseconds have elapsed since the last time the debounced function was
* invoked . The debounced function comes with a ` cancel ` method to cancel delayed
* ` func ` invocations and a ` flush ` method to immediately invoke them . Provide
* ` options ` to indicate whether ` func ` should be invoked on the leading and / or
* trailing edge of the ` wait ` timeout . The ` func ` is invoked with the last
* arguments provided to the debounced function . Subsequent calls to the debounced
* function return the result of the last ` func ` invocation .
*
* * * Note : * * If ` leading ` and ` trailing ` options are ` true ` , ` func ` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the ` wait ` timeout .
*
* If ` wait ` is ` 0 ` and ` leading ` is ` false ` , ` func ` invocation is deferred
* until the next tick , similar to ` setTimeout ` with a timeout of ` 0 ` .
*
* @ param { Function } func The function to debounce .
* @ param { number } wait The number of milliseconds to delay .
* @ param { Partial < DebounceOptions > } options The options object .
* @ param { boolean } options . leading Specify invoking on the leading edge of the timeout .
* @ param { number } options . maxWait The maximum time ` func ` is allowed to be delayed before it ' s invoked .
* @ param { boolean } options . trailing Specify invoking on the trailing edge of the timeout .
*
* @ return Returns the new debounced function .
* /
const debounce = ( func , wait , options ) => {
let lastArgs ;
let lastThis ;
let maxWait = 0 ;
let result ;
let timerId ;
let lastCallTime ;
let lastInvokeTime = 0 ;
let leading = false ;
let maxing = false ;
let trailing = true ;
if ( options ) {
leading = ! ! options . leading ;
maxing = 'maxWait' in options ;
if ( options . maxWait !== undefined ) {
maxWait = Math . max ( options . maxWait , wait ) ;
}
trailing = 'trailing' in options ? ! ! options . trailing : trailing ;
}
function invokeFunc ( time ) {
const args = lastArgs ;
const thisArg = lastThis ;
lastArgs = undefined ;
lastThis = undefined ;
lastInvokeTime = time ;
result = func . apply ( thisArg , args ) ;
return result ;
}
function startTimer ( pendingFunc , waitTime ) {
timerId = setTimeout ( pendingFunc , waitTime ) ;
}
function cancelTimer ( ) {
if ( timerId !== undefined ) {
clearTimeout ( timerId ) ;
}
}
function leadingEdge ( time ) {
// Reset any `maxWait` timer.
2023-09-26 16:23:26 +02:00
lastInvokeTime = time ;
// Start the timer for the trailing edge.
startTimer ( timerExpired , wait ) ;
// Invoke the leading edge.
2023-02-07 08:04:52 +01:00
return leading ? invokeFunc ( time ) : result ;
}
function getTimeSinceLastCall ( time ) {
return time - ( lastCallTime || 0 ) ;
}
function remainingWait ( time ) {
const timeSinceLastCall = getTimeSinceLastCall ( time ) ;
const timeSinceLastInvoke = time - lastInvokeTime ;
const timeWaiting = wait - timeSinceLastCall ;
return maxing ? Math . min ( timeWaiting , maxWait - timeSinceLastInvoke ) : timeWaiting ;
}
function shouldInvoke ( time ) {
const timeSinceLastCall = getTimeSinceLastCall ( time ) ;
2023-09-26 16:23:26 +02:00
const timeSinceLastInvoke = time - lastInvokeTime ;
// Either this is the first call, activity has stopped and we're at the
2023-02-07 08:04:52 +01:00
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait ;
}
function timerExpired ( ) {
const time = Date . now ( ) ;
if ( shouldInvoke ( time ) ) {
return trailingEdge ( time ) ;
2023-09-26 16:23:26 +02:00
}
// Restart the timer.
2023-02-07 08:04:52 +01:00
startTimer ( timerExpired , remainingWait ( time ) ) ;
return undefined ;
}
function clearTimer ( ) {
timerId = undefined ;
}
function trailingEdge ( time ) {
2023-09-26 16:23:26 +02:00
clearTimer ( ) ;
2023-02-07 08:04:52 +01:00
2023-09-26 16:23:26 +02:00
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
2023-02-07 08:04:52 +01:00
if ( trailing && lastArgs ) {
return invokeFunc ( time ) ;
}
lastArgs = lastThis = undefined ;
return result ;
}
function cancel ( ) {
cancelTimer ( ) ;
lastInvokeTime = 0 ;
clearTimer ( ) ;
lastArgs = lastCallTime = lastThis = undefined ;
}
function flush ( ) {
return pending ( ) ? trailingEdge ( Date . now ( ) ) : result ;
}
function pending ( ) {
return timerId !== undefined ;
}
2023-06-27 16:24:19 +02:00
function debounced ( ... args ) {
2023-02-07 08:04:52 +01:00
const time = Date . now ( ) ;
const isInvoking = shouldInvoke ( time ) ;
lastArgs = args ;
lastThis = this ;
lastCallTime = time ;
if ( isInvoking ) {
if ( ! pending ( ) ) {
return leadingEdge ( lastCallTime ) ;
}
if ( maxing ) {
// Handle invocations in a tight loop.
startTimer ( timerExpired , wait ) ;
return invokeFunc ( lastCallTime ) ;
}
}
if ( ! pending ( ) ) {
startTimer ( timerExpired , wait ) ;
}
return result ;
}
debounced . cancel = cancel ;
debounced . flush = flush ;
debounced . pending = pending ;
return debounced ;
} ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/throttle/index.js
/ * *
* Parts of this source were derived and modified from lodash ,
* released under the MIT license .
*
* https : //github.com/lodash/lodash
*
* Copyright JS Foundation and other contributors < https : //js.foundation/>
*
* Based on Underscore . js , copyright Jeremy Ashkenas ,
* DocumentCloud and Investigative Reporters & Editors < http : //underscorejs.org/>
*
* This software consists of voluntary contributions made by many
* individuals . For exact contribution history , see the revision history
* available at https : //github.com/lodash/lodash
*
* The following license applies to all parts of this software except as
* documented below :
*
* === =
*
* Permission is hereby granted , free of charge , to any person obtaining
* a copy of this software and associated documentation files ( the
* "Software" ) , to deal in the Software without restriction , including
* without limitation the rights to use , copy , modify , merge , publish ,
* distribute , sublicense , and / or sell copies of the Software , and to
* permit persons to whom the Software is furnished to do so , subject to
* the following conditions :
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION
* OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
* /
/ * *
* Internal dependencies
* /
/ * *
* A simplified and properly typed version of lodash ' s ` throttle ` , that
* always uses timers instead of sometimes using rAF .
*
* Creates a throttled function that only invokes ` func ` at most once per
* every ` wait ` milliseconds . The throttled function comes with a ` cancel `
* method to cancel delayed ` func ` invocations and a ` flush ` method to
* immediately invoke them . Provide ` options ` to indicate whether ` func `
* should be invoked on the leading and / or trailing edge of the ` wait `
* timeout . The ` func ` is invoked with the last arguments provided to the
* throttled function . Subsequent calls to the throttled function return
* the result of the last ` func ` invocation .
*
* * * Note : * * If ` leading ` and ` trailing ` options are ` true ` , ` func ` is
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the ` wait ` timeout .
*
* If ` wait ` is ` 0 ` and ` leading ` is ` false ` , ` func ` invocation is deferred
* until the next tick , similar to ` setTimeout ` with a timeout of ` 0 ` .
*
* @ param { Function } func The function to throttle .
* @ param { number } wait The number of milliseconds to throttle invocations to .
* @ param { Partial < ThrottleOptions > } options The options object .
* @ param { boolean } options . leading Specify invoking on the leading edge of the timeout .
* @ param { boolean } options . trailing Specify invoking on the trailing edge of the timeout .
* @ return Returns the new throttled function .
* /
const throttle = ( func , wait , options ) => {
let leading = true ;
let trailing = true ;
if ( options ) {
leading = 'leading' in options ? ! ! options . leading : leading ;
trailing = 'trailing' in options ? ! ! options . trailing : trailing ;
}
return debounce ( func , wait , {
leading ,
trailing ,
maxWait : wait
} ) ;
} ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pipe.js
/ * *
* Parts of this source were derived and modified from lodash ,
* released under the MIT license .
*
* https : //github.com/lodash/lodash
*
* Copyright JS Foundation and other contributors < https : //js.foundation/>
*
* Based on Underscore . js , copyright Jeremy Ashkenas ,
* DocumentCloud and Investigative Reporters & Editors < http : //underscorejs.org/>
*
* This software consists of voluntary contributions made by many
* individuals . For exact contribution history , see the revision history
* available at https : //github.com/lodash/lodash
*
* The following license applies to all parts of this software except as
* documented below :
*
* === =
*
* Permission is hereby granted , free of charge , to any person obtaining
* a copy of this software and associated documentation files ( the
* "Software" ) , to deal in the Software without restriction , including
* without limitation the rights to use , copy , modify , merge , publish ,
* distribute , sublicense , and / or sell copies of the Software , and to
* permit persons to whom the Software is furnished to do so , subject to
* the following conditions :
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION
* OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
* /
/ * *
* Creates a pipe function .
*
* Allows to choose whether to perform left - to - right or right - to - left composition .
*
* @ see https : //docs-lodash.com/v4/flow/
*
* @ param { boolean } reverse True if right - to - left , false for left - to - right composition .
* /
2023-06-27 16:24:19 +02:00
const basePipe = ( reverse = false ) => ( ... funcs ) => ( ... args ) => {
const functions = funcs . flat ( ) ;
if ( reverse ) {
functions . reverse ( ) ;
}
return functions . reduce ( ( prev , func ) => [ func ( ... prev ) ] , args ) [ 0 ] ;
2023-02-07 08:04:52 +01:00
} ;
2023-09-26 16:23:26 +02:00
2023-02-07 08:04:52 +01:00
/ * *
* Composes multiple higher - order components into a single higher - order component . Performs left - to - right function
* composition , where each successive invocation is supplied the return value of the previous .
*
* This is inspired by ` lodash ` ' s ` flow ` function .
*
* @ see https : //docs-lodash.com/v4/flow/
* /
const pipe = basePipe ( ) ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var higher _order _pipe = ( pipe ) ;
2023-02-07 08:04:52 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js
2021-05-20 14:20:04 +02:00
/ * *
2023-02-07 08:04:52 +01:00
* Internal dependencies
2021-05-20 14:20:04 +02:00
* /
2020-01-22 23:06:21 +01:00
2023-09-26 16:23:26 +02:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Composes multiple higher - order components into a single higher - order component . Performs right - to - left function
* composition , where each successive invocation is supplied the return value of the previous .
2021-05-20 14:20:04 +02:00
*
2023-02-07 08:04:52 +01:00
* This is inspired by ` lodash ` ' s ` flowRight ` function .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ see https : //docs-lodash.com/v4/flow-right/
2021-05-20 14:20:04 +02:00
* /
2023-02-07 08:04:52 +01:00
const compose = basePipe ( true ) ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var higher _order _compose = ( compose ) ;
2019-10-15 17:37:08 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","element"]
2023-09-21 15:26:32 +02:00
var external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js
2019-10-15 17:37:08 +02:00
2022-09-20 17:43:29 +02:00
/ * *
* External dependencies
* /
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Internal dependencies
2021-05-20 14:20:04 +02:00
* /
2019-10-15 17:37:08 +02:00
2023-09-26 16:23:26 +02:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Higher - order component creator , creating a new component which renders if
* the given condition is satisfied or with the given optional prop name .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ example
* ` ` ` ts
* type Props = { foo : string } ;
* const Component = ( props : Props ) => < div > { props . foo } < / d i v > ;
* const ConditionalComponent = ifCondition ( ( props : Props ) => props . foo . length !== 0 ) ( Component ) ;
* < ConditionalComponent foo = "" / > ; // => null
* < ConditionalComponent foo = "bar" / > ; // => <div>bar</div>;
* ` ` `
2021-05-20 14:20:04 +02:00
*
2023-06-27 16:24:19 +02:00
* @ param predicate Function to test condition .
2021-11-08 15:29:21 +01:00
*
2022-04-11 14:04:30 +02:00
* @ return Higher - order component .
2021-05-20 14:20:04 +02:00
* /
2022-09-20 17:43:29 +02:00
function ifCondition ( predicate ) {
return createHigherOrderComponent ( WrappedComponent => props => {
if ( ! predicate ( props ) ) {
return null ;
}
2023-09-26 16:23:26 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( WrappedComponent , {
... props
2023-06-27 16:24:19 +02:00
} ) ;
2022-09-20 17:43:29 +02:00
} , 'ifCondition' ) ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var if _condition = ( ifCondition ) ;
2022-04-11 14:04:30 +02:00
2023-09-26 16:23:26 +02:00
// EXTERNAL MODULE: external ["wp","isShallowEqual"]
var external _wp _isShallowEqual _ = _ _webpack _require _ _ ( 9127 ) ;
var external _wp _isShallowEqual _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _isShallowEqual _ ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js
2020-02-06 22:03:31 +01:00
2021-05-20 14:20:04 +02:00
/ * *
2022-09-20 17:43:29 +02:00
* External dependencies
2021-05-20 14:20:04 +02:00
* /
2019-10-15 17:37:08 +02:00
2021-05-20 14:20:04 +02:00
/ * *
2022-09-20 17:43:29 +02:00
* WordPress dependencies
2021-05-20 14:20:04 +02:00
* /
2019-10-15 17:37:08 +02:00
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
2022-04-12 17:12:47 +02:00
/ * *
2022-09-20 17:43:29 +02:00
* Internal dependencies
2022-04-12 17:12:47 +02:00
* /
2020-06-26 15:33:47 +02:00
2022-09-20 17:43:29 +02:00
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Given a component returns the enhanced component augmented with a component
2022-04-12 17:12:47 +02:00
* only re - rendering when its props / state change
2021-05-20 14:20:04 +02:00
* /
2022-09-20 17:43:29 +02:00
const pure = createHigherOrderComponent ( function ( WrappedComponent ) {
if ( WrappedComponent . prototype instanceof external _wp _element _namespaceObject . Component ) {
return class extends WrappedComponent {
2022-04-11 14:04:30 +02:00
shouldComponentUpdate ( nextProps , nextState ) {
return ! external _wp _isShallowEqual _default ( ) ( nextProps , this . props ) || ! external _wp _isShallowEqual _default ( ) ( nextState , this . state ) ;
}
} ;
}
return class extends external _wp _element _namespaceObject . Component {
shouldComponentUpdate ( nextProps ) {
return ! external _wp _isShallowEqual _default ( ) ( nextProps , this . props ) ;
}
render ( ) {
2023-09-26 16:23:26 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( WrappedComponent , {
... this . props
2023-06-27 16:24:19 +02:00
} ) ;
2022-04-11 14:04:30 +02:00
}
} ;
} , 'pure' ) ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var higher _order _pure = ( pure ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","deprecated"]
2023-09-21 15:26:32 +02:00
var external _wp _deprecated _namespaceObject = window [ "wp" ] [ "deprecated" ] ;
2022-04-11 14:04:30 +02:00
var external _wp _deprecated _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _deprecated _namespaceObject ) ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js
/ * *
* Class responsible for orchestrating event handling on the global window ,
* binding a single event to be shared across all handling instances , and
* removing the handler when no instances are listening for the event .
2020-02-06 22:03:31 +01:00
* /
2022-04-11 14:04:30 +02:00
class Listener {
constructor ( ) {
/** @type {any} */
this . listeners = { } ;
this . handleEvent = this . handleEvent . bind ( this ) ;
}
2023-09-26 16:23:26 +02:00
add ( /** @type {any} */ eventType , /** @type {any} */ instance ) {
2022-04-11 14:04:30 +02:00
if ( ! this . listeners [ eventType ] ) {
// Adding first listener for this type, so bind event.
window . addEventListener ( eventType , this . handleEvent ) ;
this . listeners [ eventType ] = [ ] ;
}
this . listeners [ eventType ] . push ( instance ) ;
}
2023-09-26 16:23:26 +02:00
remove ( /** @type {any} */ eventType , /** @type {any} */ instance ) {
2023-02-07 08:04:52 +01:00
if ( ! this . listeners [ eventType ] ) {
return ;
}
2023-09-26 16:23:26 +02:00
this . listeners [ eventType ] = this . listeners [ eventType ] . filter ( ( /** @type {any} */ listener ) => listener !== instance ) ;
2022-04-11 14:04:30 +02:00
if ( ! this . listeners [ eventType ] . length ) {
// Removing last listener for this type, so unbind event.
window . removeEventListener ( eventType , this . handleEvent ) ;
delete this . listeners [ eventType ] ;
}
}
2023-09-26 16:23:26 +02:00
handleEvent ( /** @type {any} */ event ) {
this . listeners [ event . type ] ? . forEach ( ( /** @type {any} */ instance ) => {
2022-04-11 14:04:30 +02:00
instance . handleEvent ( event ) ;
} ) ;
}
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var listener = ( Listener ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js
2021-06-15 10:52:30 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2021-06-15 10:52:30 +02:00
2020-02-06 22:03:31 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2020-02-06 22:03:31 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Listener instance responsible for managing document event handling .
* /
const with _global _events _listener = new listener ( ) ;
2020-02-06 22:03:31 +01:00
2023-09-26 16:23:26 +02:00
/* eslint-disable jsdoc/no-undefined-types */
2022-04-11 14:04:30 +02:00
/ * *
* Higher - order component creator which , given an object of DOM event types and
* values corresponding to a callback function name on the component , will
* create or update a window event handler to invoke the callback when an event
* occurs . On behalf of the consuming developer , the higher - order component
* manages unbinding when the component unmounts , and binding at most a single
* event handler for the entire application .
*
* @ deprecated
*
* @ param { Record < keyof GlobalEventHandlersEventMap , string > } eventTypesToHandlers Object with keys of DOM
* event type , the value a
* name of the function on
* the original component ' s
* instance which handles
* the event .
*
* @ return { any } Higher - order component .
* /
function withGlobalEvents ( eventTypesToHandlers ) {
external _wp _deprecated _default ( ) ( 'wp.compose.withGlobalEvents' , {
since : '5.7' ,
alternative : 'useEffect'
2023-09-26 16:23:26 +02:00
} ) ;
2022-04-12 17:12:47 +02:00
2023-09-26 16:23:26 +02:00
// @ts-ignore We don't need to fix the type-related issues because this is deprecated.
2022-09-20 17:43:29 +02:00
return createHigherOrderComponent ( WrappedComponent => {
2022-04-11 14:04:30 +02:00
class Wrapper extends external _wp _element _namespaceObject . Component {
2023-09-26 16:23:26 +02:00
constructor ( /** @type {any} */ props ) {
2022-04-11 14:04:30 +02:00
super ( props ) ;
this . handleEvent = this . handleEvent . bind ( this ) ;
this . handleRef = this . handleRef . bind ( this ) ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
componentDidMount ( ) {
2022-09-20 17:43:29 +02:00
Object . keys ( eventTypesToHandlers ) . forEach ( eventType => {
2022-04-11 14:04:30 +02:00
with _global _events _listener . add ( eventType , this ) ;
} ) ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
componentWillUnmount ( ) {
2022-09-20 17:43:29 +02:00
Object . keys ( eventTypesToHandlers ) . forEach ( eventType => {
2022-04-11 14:04:30 +02:00
with _global _events _listener . remove ( eventType , this ) ;
} ) ;
}
2023-09-26 16:23:26 +02:00
handleEvent ( /** @type {any} */ event ) {
const handler = eventTypesToHandlers [ /** @type {keyof GlobalEventHandlersEventMap} */
2022-04-11 14:04:30 +02:00
event . type
2023-09-26 16:23:26 +02:00
/* eslint-enable jsdoc/no-undefined-types */ ] ;
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
if ( typeof this . wrappedRef [ handler ] === 'function' ) {
this . wrappedRef [ handler ] ( event ) ;
}
2021-05-20 14:20:04 +02:00
}
2023-09-26 16:23:26 +02:00
handleRef ( /** @type {any} */ el ) {
this . wrappedRef = el ;
// Any component using `withGlobalEvents` that is not setting a `ref`
2022-04-11 14:04:30 +02:00
// will cause `this.props.forwardedRef` to be `null`, so we need this
// check.
if ( this . props . forwardedRef ) {
this . props . forwardedRef ( el ) ;
}
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
render ( ) {
2023-09-26 16:23:26 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( WrappedComponent , {
... this . props . ownProps ,
2022-04-11 14:04:30 +02:00
ref : this . handleRef
2023-06-27 16:24:19 +02:00
} ) ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
}
return ( 0 , external _wp _element _namespaceObject . forwardRef ) ( ( props , ref ) => {
return ( 0 , external _wp _element _namespaceObject . createElement ) ( Wrapper , {
ownProps : props ,
forwardedRef : ref
} ) ;
} ) ;
} , 'withGlobalEvents' ) ;
2021-05-20 14:20:04 +02:00
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js
2021-11-08 15:29:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* WordPress dependencies
2021-11-08 15:29:21 +01:00
* /
2022-04-11 14:04:30 +02:00
const instanceMap = new WeakMap ( ) ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Creates a new id for a given object .
2021-11-08 15:29:21 +01:00
*
2023-06-27 16:24:19 +02:00
* @ param object Object reference to create an id for .
2023-02-07 08:04:52 +01:00
* @ return The instance id ( index ) .
2021-11-08 15:29:21 +01:00
* /
2022-04-11 14:04:30 +02:00
function createId ( object ) {
const instances = instanceMap . get ( object ) || 0 ;
instanceMap . set ( object , instances + 1 ) ;
return instances ;
}
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
2023-02-07 08:04:52 +01:00
* Specify the useInstanceId * function * signatures .
*
* More accurately , useInstanceId distinguishes between three different
* signatures :
2022-04-11 14:04:30 +02:00
*
2023-02-07 08:04:52 +01:00
* 1. When only object is given , the returned value is a number
* 2. When object and prefix is given , the returned value is a string
* 3. When preferredId is given , the returned value is the type of preferredId
*
* @ param object Object reference to create an id for .
2022-04-11 14:04:30 +02:00
* /
2021-11-08 15:29:21 +01:00
2023-02-07 08:04:52 +01:00
/ * *
* Provides a unique instance ID .
*
2023-06-27 16:24:19 +02:00
* @ param object Object reference to create an id for .
* @ param [ prefix ] Prefix for the unique id .
* @ param [ preferredId ] Default ID to use .
2023-02-07 08:04:52 +01:00
* @ return The unique instance id .
* /
function useInstanceId ( object , prefix , preferredId ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
if ( preferredId ) return preferredId ;
const id = createId ( object ) ;
return prefix ? ` ${ prefix } - ${ id } ` : id ;
2023-06-27 16:24:19 +02:00
} , [ object , preferredId , prefix ] ) ;
2021-11-08 15:29:21 +01:00
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _instance _id = ( useInstanceId ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js
2021-11-08 15:29:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* Internal dependencies
* /
2022-09-20 17:43:29 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* A Higher Order Component used to be provide a unique instance ID by
* component .
2021-11-08 15:29:21 +01:00
* /
2022-09-20 17:43:29 +02:00
const withInstanceId = createHigherOrderComponent ( WrappedComponent => {
2022-04-11 14:04:30 +02:00
return props => {
2023-09-26 16:23:26 +02:00
const instanceId = use _instance _id ( WrappedComponent ) ;
// @ts-ignore
return ( 0 , external _wp _element _namespaceObject . createElement ) ( WrappedComponent , {
... props ,
2022-04-11 14:04:30 +02:00
instanceId : instanceId
2023-06-27 16:24:19 +02:00
} ) ;
2022-04-11 14:04:30 +02:00
} ;
2022-09-20 17:43:29 +02:00
} , 'instanceId' ) ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var with _instance _id = ( withInstanceId ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js
2021-11-08 15:29:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* WordPress dependencies
2021-11-08 15:29:21 +01:00
* /
2023-09-26 16:23:26 +02:00
2021-11-08 15:29:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* Internal dependencies
2021-11-08 15:29:21 +01:00
* /
2023-09-26 16:23:26 +02:00
2022-04-12 17:12:47 +02:00
/ * *
* We cannot use the ` Window['setTimeout'] ` and ` Window['clearTimeout'] `
* types here because those functions include functionality that is not handled
* by this component , like the ability to pass extra arguments .
*
* In the case of this component , we only handle the simplest case where
* ` setTimeout ` only accepts a function ( not a string ) and an optional delay .
* /
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* A higher - order component used to provide and manage delayed function calls
* that ought to be bound to a component ' s lifecycle .
* /
2022-09-20 17:43:29 +02:00
const withSafeTimeout = createHigherOrderComponent ( OriginalComponent => {
2022-04-11 14:04:30 +02:00
return class WrappedComponent extends external _wp _element _namespaceObject . Component {
constructor ( props ) {
super ( props ) ;
this . timeouts = [ ] ;
this . setTimeout = this . setTimeout . bind ( this ) ;
this . clearTimeout = this . clearTimeout . bind ( this ) ;
2021-11-08 15:29:21 +01:00
}
2022-04-11 14:04:30 +02:00
componentWillUnmount ( ) {
this . timeouts . forEach ( clearTimeout ) ;
}
setTimeout ( fn , delay ) {
const id = setTimeout ( ( ) => {
fn ( ) ;
this . clearTimeout ( id ) ;
} , delay ) ;
this . timeouts . push ( id ) ;
return id ;
}
clearTimeout ( id ) {
clearTimeout ( id ) ;
2023-02-07 08:04:52 +01:00
this . timeouts = this . timeouts . filter ( timeoutId => timeoutId !== id ) ;
2022-04-11 14:04:30 +02:00
}
render ( ) {
2023-09-26 16:23:26 +02:00
return (
// @ts-ignore
( 0 , external _wp _element _namespaceObject . createElement ) ( OriginalComponent , {
... this . props ,
2022-09-20 17:43:29 +02:00
setTimeout : this . setTimeout ,
clearTimeout : this . clearTimeout
2023-06-27 16:24:19 +02:00
} )
2022-09-20 17:43:29 +02:00
) ;
2022-04-11 14:04:30 +02:00
}
} ;
} , 'withSafeTimeout' ) ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var with _safe _timeout = ( withSafeTimeout ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2021-11-08 15:29:21 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* A Higher Order Component used to provide and manage internal component state
* via props .
*
* @ deprecated Use ` useState ` instead .
*
* @ param { any } initialState Optional initial state of the component .
*
* @ return { any } A higher order component wrapper accepting a component that takes the state props + its own props + ` setState ` and returning a component that only accepts the own props .
* /
2023-06-27 16:24:19 +02:00
function withState ( initialState = { } ) {
2022-04-11 14:04:30 +02:00
external _wp _deprecated _default ( ) ( 'wp.compose.withState' , {
2022-04-12 17:12:47 +02:00
since : '5.8' ,
2022-04-11 14:04:30 +02:00
alternative : 'wp.element.useState'
} ) ;
2022-09-20 17:43:29 +02:00
return createHigherOrderComponent ( OriginalComponent => {
2022-04-11 14:04:30 +02:00
return class WrappedComponent extends external _wp _element _namespaceObject . Component {
2023-09-26 16:23:26 +02:00
constructor ( /** @type {any} */ props ) {
2022-04-11 14:04:30 +02:00
super ( props ) ;
this . setState = this . setState . bind ( this ) ;
this . state = initialState ;
2021-11-08 15:29:21 +01:00
}
2022-04-11 14:04:30 +02:00
render ( ) {
2023-09-26 16:23:26 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( OriginalComponent , {
... this . props ,
2023-06-27 16:24:19 +02:00
... this . state ,
2022-04-11 14:04:30 +02:00
setState : this . setState
2023-06-27 16:24:19 +02:00
} ) ;
2022-04-11 14:04:30 +02:00
}
2021-11-08 15:29:21 +01:00
} ;
2022-04-11 14:04:30 +02:00
} , 'withState' ) ;
2021-11-08 15:29:21 +01:00
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","keycodes"]
2023-09-21 15:26:32 +02:00
var external _wp _keycodes _namespaceObject = window [ "wp" ] [ "keycodes" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","dom"]
2023-09-21 15:26:32 +02:00
var external _wp _dom _namespaceObject = window [ "wp" ] [ "dom" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js
/ * *
* External dependencies
* /
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Effect - like ref callback . Just like with ` useEffect ` , this allows you to
* return a cleanup function to be run if the ref changes or one of the
* dependencies changes . The ref is provided as an argument to the callback
* functions . The main difference between this and ` useEffect ` is that
* the ` useEffect ` callback is not called when the ref changes , but this is .
* Pass the returned ref callback as the component ' s ref and merge multiple refs
* with ` useMergeRefs ` .
*
* It 's worth noting that if the dependencies array is empty, there' s not
* strictly a need to clean up event handlers for example , because the node is
* to be removed . It * is * necessary if you add dependencies because the ref
* callback will be called multiple times for the same node .
*
2023-06-27 16:24:19 +02:00
* @ param callback Callback with ref as argument .
* @ param dependencies Dependencies of the callback .
2022-04-11 14:04:30 +02:00
*
* @ return Ref callback .
* /
function useRefEffect ( callback , dependencies ) {
const cleanup = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
return ( 0 , external _wp _element _namespaceObject . useCallback ) ( node => {
if ( node ) {
cleanup . current = callback ( node ) ;
} else if ( cleanup . current ) {
cleanup . current ( ) ;
}
} , dependencies ) ;
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2018-12-14 05:41:57 +01:00
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* In Dialogs / modals , the tabbing must be constrained to the content of
* the wrapper element . This hook adds the behavior to the returned ref .
*
* @ return { import ( 'react' ) . RefCallback < Element > } Element Ref .
*
* @ example
* ` ` ` js
* import { useConstrainedTabbing } from '@wordpress/compose' ;
*
* const ConstrainedTabbingExample = ( ) => {
* const constrainedTabbingRef = useConstrainedTabbing ( )
* return (
* < div ref = { constrainedTabbingRef } >
* < Button / >
* < Button / >
* < / d i v >
* ) ;
* }
* ` ` `
* /
function useConstrainedTabbing ( ) {
2023-09-26 16:23:26 +02:00
return useRefEffect ( ( /** @type {HTMLElement} */ node ) => {
function onKeyDown ( /** @type {KeyboardEvent} */ event ) {
2022-04-11 14:04:30 +02:00
const {
keyCode ,
shiftKey ,
target
} = event ;
if ( keyCode !== external _wp _keycodes _namespaceObject . TAB ) {
return ;
}
const action = shiftKey ? 'findPrevious' : 'findNext' ;
2023-09-26 16:23:26 +02:00
const nextElement = external _wp _dom _namespaceObject . focus . tabbable [ action ] ( /** @type {HTMLElement} */ target ) || null ;
// When the target element contains the element that is about to
2023-06-27 16:24:19 +02:00
// receive focus, for example when the target is a tabbable
// container, browsers may disagree on where to move focus next.
// In this case we can't rely on native browsers behavior. We need
// to manage focus instead.
// See https://github.com/WordPress/gutenberg/issues/46041.
2023-09-26 16:23:26 +02:00
if ( /** @type {HTMLElement} */ target . contains ( nextElement ) ) {
2023-06-27 16:24:19 +02:00
event . preventDefault ( ) ;
/** @type {HTMLElement} */
nextElement ? . focus ( ) ;
return ;
2023-09-26 16:23:26 +02:00
}
// If the element that is about to receive focus is inside the
2023-06-27 16:24:19 +02:00
// area, rely on native browsers behavior and let tabbing follow
// the native tab sequence.
if ( node . contains ( nextElement ) ) {
return ;
2023-09-26 16:23:26 +02:00
}
// If the element that is about to receive focus is outside the
2022-04-11 14:04:30 +02:00
// area, move focus to a div and insert it at the start or end of
// the area, depending on the direction. Without preventing default
// behaviour, the browser will then move focus to the next element.
const domAction = shiftKey ? 'append' : 'prepend' ;
const {
ownerDocument
} = node ;
const trap = ownerDocument . createElement ( 'div' ) ;
trap . tabIndex = - 1 ;
2023-09-26 16:23:26 +02:00
node [ domAction ] ( trap ) ;
2018-12-18 04:14:52 +01:00
2023-09-26 16:23:26 +02:00
// Remove itself when the trap loses focus.
2023-02-07 08:04:52 +01:00
trap . addEventListener ( 'blur' , ( ) => node . removeChild ( trap ) ) ;
trap . focus ( ) ;
2022-04-11 14:04:30 +02:00
}
node . addEventListener ( 'keydown' , onKeyDown ) ;
return ( ) => {
node . removeEventListener ( 'keydown' , onKeyDown ) ;
} ;
} , [ ] ) ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _constrained _tabbing = ( useConstrainedTabbing ) ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
// EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js
var dist _clipboard = _ _webpack _require _ _ ( 8294 ) ;
var clipboard _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( dist _clipboard ) ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js
/ * *
* External dependencies
* /
2018-12-14 05:41:57 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/* eslint-disable jsdoc/no-undefined-types */
/ * *
* Copies the text to the clipboard when the element is clicked .
*
* @ deprecated
*
* @ param { import ( 'react' ) . RefObject < string | Element | NodeListOf < Element >> } ref Reference with the element .
* @ param { string | Function } text The text to copy .
* @ param { number } [ timeout ] Optional timeout to reset the returned
* state . 4 seconds by default .
*
* @ return { boolean } Whether or not the text has been copied . Resets after the
* timeout .
* /
2023-06-27 16:24:19 +02:00
function useCopyOnClick ( ref , text , timeout = 4000 ) {
2022-04-11 14:04:30 +02:00
/* eslint-enable jsdoc/no-undefined-types */
external _wp _deprecated _default ( ) ( 'wp.compose.useCopyOnClick' , {
2022-04-12 17:12:47 +02:00
since : '5.8' ,
2022-04-11 14:04:30 +02:00
alternative : 'wp.compose.useCopyToClipboard'
} ) ;
2021-11-08 15:29:21 +01:00
2023-09-26 16:23:26 +02:00
/** @type {import('react').MutableRefObject<Clipboard | undefined>} */
2022-04-11 14:04:30 +02:00
const clipboard = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const [ hasCopied , setHasCopied ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
/** @type {number | undefined} */
let timeoutId ;
if ( ! ref . current ) {
return ;
2023-09-26 16:23:26 +02:00
}
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
// Clipboard listens to click events.
2022-04-11 14:04:30 +02:00
clipboard . current = new ( clipboard _default ( ) ) ( ref . current , {
text : ( ) => typeof text === 'function' ? text ( ) : text
} ) ;
2023-06-27 16:24:19 +02:00
clipboard . current . on ( 'success' , ( {
clearSelection ,
trigger
} ) => {
2022-04-11 14:04:30 +02:00
// Clearing selection will move focus back to the triggering button,
// ensuring that it is not reset to the body, and further that it is
// kept within the rendered node.
2023-09-26 16:23:26 +02:00
clearSelection ( ) ;
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
2022-04-11 14:04:30 +02:00
if ( trigger ) {
2023-09-26 16:23:26 +02:00
/** @type {HTMLElement} */ trigger . focus ( ) ;
2022-04-11 14:04:30 +02:00
}
if ( timeout ) {
setHasCopied ( true ) ;
clearTimeout ( timeoutId ) ;
timeoutId = setTimeout ( ( ) => setHasCopied ( false ) , timeout ) ;
}
} ) ;
return ( ) => {
if ( clipboard . current ) {
clipboard . current . destroy ( ) ;
}
clearTimeout ( timeoutId ) ;
} ;
} , [ text , timeout , setHasCopied ] ) ;
return hasCopied ;
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js
/ * *
* External dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2018-12-14 05:41:57 +01:00
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* @ template T
* @ param { T } value
* @ return { import ( 'react' ) . RefObject < T > } The updated ref
* /
function useUpdatedRef ( value ) {
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( value ) ;
ref . current = value ;
return ref ;
}
2023-09-26 16:23:26 +02:00
2019-09-19 17:19:18 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Copies the given text to the clipboard when the element is clicked .
2019-09-19 17:19:18 +02:00
*
2022-04-11 14:04:30 +02:00
* @ template { HTMLElement } TElementType
* @ param { string | ( ( ) => string ) } text The text to copy . Use a function if not
* already available and expensive to compute .
* @ param { Function } onSuccess Called when to text is copied .
*
* @ return { import ( 'react' ) . Ref < TElementType > } A ref to assign to the target element .
2019-09-19 17:19:18 +02:00
* /
2022-04-11 14:04:30 +02:00
function useCopyToClipboard ( text , onSuccess ) {
2022-09-20 17:43:29 +02:00
// Store the dependencies as refs and continuously update them so they're
2022-04-11 14:04:30 +02:00
// fresh when the callback is called.
const textRef = useUpdatedRef ( text ) ;
const onSuccessRef = useUpdatedRef ( onSuccess ) ;
return useRefEffect ( node => {
// Clipboard listens to click events.
const clipboard = new ( clipboard _default ( ) ) ( node , {
text ( ) {
return typeof textRef . current === 'function' ? textRef . current ( ) : textRef . current || '' ;
}
} ) ;
2023-06-27 16:24:19 +02:00
clipboard . on ( 'success' , ( {
clearSelection
} ) => {
2022-04-11 14:04:30 +02:00
// Clearing selection will move focus back to the triggering
// button, ensuring that it is not reset to the body, and
// further that it is kept within the rendered node.
2023-09-26 16:23:26 +02:00
clearSelection ( ) ;
// Handle ClipboardJS focus bug, see
2022-04-11 14:04:30 +02:00
// https://github.com/zenorocha/clipboard.js/issues/680
node . focus ( ) ;
if ( onSuccessRef . current ) {
onSuccessRef . current ( ) ;
}
} ) ;
return ( ) => {
clipboard . destroy ( ) ;
} ;
} , [ ] ) ;
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Hook used to focus the first tabbable element on mount .
*
* @ param { boolean | 'firstElement' } focusOnMount Focus on mount mode .
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Ref callback .
*
* @ example
* ` ` ` js
* import { useFocusOnMount } from '@wordpress/compose' ;
*
* const WithFocusOnMount = ( ) => {
* const ref = useFocusOnMount ( )
* return (
* < div ref = { ref } >
* < Button / >
* < Button / >
* < / d i v >
* ) ;
* }
* ` ` `
* /
2023-06-27 16:24:19 +02:00
function useFocusOnMount ( focusOnMount = 'firstElement' ) {
2022-04-11 14:04:30 +02:00
const focusOnMountRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( focusOnMount ) ;
2023-09-26 16:23:26 +02:00
2023-06-27 16:24:19 +02:00
/ * *
* Sets focus on a DOM element .
*
* @ param { HTMLElement } target The DOM element to set focus to .
* @ return { void }
* /
const setFocus = target => {
target . focus ( {
// When focusing newly mounted dialogs,
// the position of the popover is often not right on the first render
// This prevents the layout shifts when focusing the dialogs.
preventScroll : true
} ) ;
} ;
2023-09-26 16:23:26 +02:00
/** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */
2023-06-27 16:24:19 +02:00
const timerId = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
focusOnMountRef . current = focusOnMount ;
} , [ focusOnMount ] ) ;
2023-06-27 16:24:19 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
return ( ) => {
if ( timerId . current ) {
clearTimeout ( timerId . current ) ;
}
} ;
} , [ ] ) ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . useCallback ) ( node => {
2023-06-27 16:24:19 +02:00
var _node$ownerDocument$a ;
2022-04-11 14:04:30 +02:00
if ( ! node || focusOnMountRef . current === false ) {
return ;
}
2023-06-27 16:24:19 +02:00
if ( node . contains ( ( _node$ownerDocument$a = node . ownerDocument ? . activeElement ) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null ) ) {
2022-04-11 14:04:30 +02:00
return ;
}
if ( focusOnMountRef . current === 'firstElement' ) {
2023-06-27 16:24:19 +02:00
timerId . current = setTimeout ( ( ) => {
const firstTabbable = external _wp _dom _namespaceObject . focus . tabbable . find ( node ) [ 0 ] ;
if ( firstTabbable ) {
2023-09-26 16:23:26 +02:00
setFocus ( /** @type {HTMLElement} */ firstTabbable ) ;
2023-06-27 16:24:19 +02:00
}
} , 0 ) ;
return ;
2022-04-11 14:04:30 +02:00
}
2023-06-27 16:24:19 +02:00
setFocus ( node ) ;
2022-04-11 14:04:30 +02:00
} , [ ] ) ;
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2023-07-25 10:40:23 +02:00
2023-09-26 16:23:26 +02:00
/** @type {Element|null} */
2023-07-25 10:40:23 +02:00
let origin = null ;
2023-09-26 16:23:26 +02:00
2018-12-14 05:41:57 +01:00
/ * *
2023-07-25 10:40:23 +02:00
* Adds the unmount behavior of returning focus to the element which had it
* previously as is expected for roles like menus or dialogs .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ param { ( ) => void } [ onFocusReturn ] Overrides the default return behavior .
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Element Ref .
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ example
* ` ` ` js
* import { useFocusReturn } from '@wordpress/compose' ;
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* const WithFocusReturn = ( ) => {
* const ref = useFocusReturn ( )
* return (
* < div ref = { ref } >
* < Button / >
* < Button / >
* < / d i v >
* ) ;
* }
* ` ` `
2018-12-14 05:41:57 +01:00
* /
2022-04-11 14:04:30 +02:00
function useFocusReturn ( onFocusReturn ) {
/** @type {import('react').MutableRefObject<null | HTMLElement>} */
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( null ) ;
/** @type {import('react').MutableRefObject<null | Element>} */
const focusedBeforeMount = ( 0 , external _wp _element _namespaceObject . useRef ) ( null ) ;
const onFocusReturnRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( onFocusReturn ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
onFocusReturnRef . current = onFocusReturn ;
} , [ onFocusReturn ] ) ;
return ( 0 , external _wp _element _namespaceObject . useCallback ) ( node => {
if ( node ) {
// Set ref to be used when unmounting.
2023-09-26 16:23:26 +02:00
ref . current = node ;
2021-05-20 14:20:04 +02:00
2023-09-26 16:23:26 +02:00
// Only set when the node mounts.
2022-04-11 14:04:30 +02:00
if ( focusedBeforeMount . current ) {
return ;
}
focusedBeforeMount . current = node . ownerDocument . activeElement ;
} else if ( focusedBeforeMount . current ) {
2023-06-27 16:24:19 +02:00
const isFocused = ref . current ? . contains ( ref . current ? . ownerDocument . activeElement ) ;
if ( ref . current ? . isConnected && ! isFocused ) {
2023-07-25 10:40:23 +02:00
var _origin ;
( _origin = origin ) !== null && _origin !== void 0 ? _origin : origin = focusedBeforeMount . current ;
2022-04-11 14:04:30 +02:00
return ;
2023-09-26 16:23:26 +02:00
}
// Defer to the component's own explicit focus return behavior, if
2022-04-11 14:04:30 +02:00
// specified. This allows for support that the `onFocusReturn`
// decides to allow the default behavior to occur under some
// conditions.
if ( onFocusReturnRef . current ) {
onFocusReturnRef . current ( ) ;
} else {
2023-09-26 16:23:26 +02:00
/** @type {null|HTMLElement} */ ( ! focusedBeforeMount . current . isConnected ? origin : focusedBeforeMount . current ) ? . focus ( ) ;
2022-04-11 14:04:30 +02:00
}
2023-07-25 10:40:23 +02:00
origin = null ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
} , [ ] ) ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _focus _return = ( useFocusReturn ) ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Input types which are classified as button types , for use in considering
* whether element is a ( focus - normalized ) button .
* /
const INPUT _BUTTON _TYPES = [ 'button' , 'submit' ] ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
2023-02-07 08:04:52 +01:00
* List of HTML button elements subject to focus normalization
*
* @ see https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
2022-04-11 14:04:30 +02:00
* /
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Returns true if the given element is a button element subject to focus
* normalization , or false otherwise .
*
* @ see https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
*
2023-06-27 16:24:19 +02:00
* @ param eventTarget The target from a mouse or touch event .
2022-04-11 14:04:30 +02:00
*
2023-02-07 08:04:52 +01:00
* @ return Whether the element is a button element subject to focus normalization .
2022-04-11 14:04:30 +02:00
* /
function isFocusNormalizedButton ( eventTarget ) {
if ( ! ( eventTarget instanceof window . HTMLElement ) ) {
return false ;
}
switch ( eventTarget . nodeName ) {
case 'A' :
case 'BUTTON' :
return true ;
case 'INPUT' :
2023-02-07 08:04:52 +01:00
return INPUT _BUTTON _TYPES . includes ( eventTarget . type ) ;
2022-04-11 14:04:30 +02:00
}
return false ;
}
/ * *
* A react hook that can be used to check whether focus has moved outside the
* element the event handlers are bound to .
*
2023-06-27 16:24:19 +02:00
* @ param onFocusOutside A callback triggered when focus moves outside
* the element the event handlers are bound to .
2022-04-11 14:04:30 +02:00
*
2023-02-07 08:04:52 +01:00
* @ return An object containing event handlers . Bind the event handlers to a
* wrapping element element to capture when focus moves outside that element .
2022-04-11 14:04:30 +02:00
* /
function useFocusOutside ( onFocusOutside ) {
const currentOnFocusOutside = ( 0 , external _wp _element _namespaceObject . useRef ) ( onFocusOutside ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
currentOnFocusOutside . current = onFocusOutside ;
} , [ onFocusOutside ] ) ;
const preventBlurCheck = ( 0 , external _wp _element _namespaceObject . useRef ) ( false ) ;
const blurCheckTimeoutId = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Cancel a blur check timeout .
* /
const cancelBlurCheck = ( 0 , external _wp _element _namespaceObject . useCallback ) ( ( ) => {
clearTimeout ( blurCheckTimeoutId . current ) ;
2023-09-26 16:23:26 +02:00
} , [ ] ) ;
2022-04-11 14:04:30 +02:00
2023-09-26 16:23:26 +02:00
// Cancel blur checks on unmount.
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
return ( ) => cancelBlurCheck ( ) ;
2023-09-26 16:23:26 +02:00
} , [ ] ) ;
2022-04-11 14:04:30 +02:00
2023-09-26 16:23:26 +02:00
// Cancel a blur check if the callback or ref is no longer provided.
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
if ( ! onFocusOutside ) {
cancelBlurCheck ( ) ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
} , [ onFocusOutside , cancelBlurCheck ] ) ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Handles a mousedown or mouseup event to respectively assign and
* unassign a flag for preventing blur check on button elements . Some
* browsers , namely Firefox and Safari , do not emit a focus event on
* button elements when clicked , while others do . The logic here
* intends to normalize this as treating click on buttons as focus .
*
2023-06-27 16:24:19 +02:00
* @ param event
2022-04-11 14:04:30 +02:00
* @ see https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
* /
const normalizeButtonFocus = ( 0 , external _wp _element _namespaceObject . useCallback ) ( event => {
const {
type ,
target
} = event ;
2023-02-07 08:04:52 +01:00
const isInteractionEnd = [ 'mouseup' , 'touchend' ] . includes ( type ) ;
2022-04-11 14:04:30 +02:00
if ( isInteractionEnd ) {
preventBlurCheck . current = false ;
} else if ( isFocusNormalizedButton ( target ) ) {
preventBlurCheck . current = true ;
}
} , [ ] ) ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* A callback triggered when a blur event occurs on the element the handler
* is bound to .
*
* Calls the ` onFocusOutside ` callback in an immediate timeout if focus has
* move outside the bound element and is still within the document .
* /
const queueBlurCheck = ( 0 , external _wp _element _namespaceObject . useCallback ) ( event => {
// React does not allow using an event reference asynchronously
// due to recycling behavior, except when explicitly persisted.
2023-09-26 16:23:26 +02:00
event . persist ( ) ;
2018-12-14 05:41:57 +01:00
2023-09-26 16:23:26 +02:00
// Skip blur check if clicking button. See `normalizeButtonFocus`.
2022-04-11 14:04:30 +02:00
if ( preventBlurCheck . current ) {
return ;
2023-09-26 16:23:26 +02:00
}
// The usage of this attribute should be avoided. The only use case
2023-02-07 08:04:52 +01:00
// would be when we load modals that are not React components and
// therefore don't exist in the React tree. An example is opening
// the Media Library modal from another dialog.
// This attribute should contain a selector of the related target
// we want to ignore, because we still need to trigger the blur event
// on all other cases.
const ignoreForRelatedTarget = event . target . getAttribute ( 'data-unstable-ignore-focus-outside-for-relatedtarget' ) ;
2023-06-27 16:24:19 +02:00
if ( ignoreForRelatedTarget && event . relatedTarget ? . closest ( ignoreForRelatedTarget ) ) {
2023-02-07 08:04:52 +01:00
return ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
blurCheckTimeoutId . current = setTimeout ( ( ) => {
// If document is not focused then focus should remain
// inside the wrapped component and therefore we cancel
// this blur event thereby leaving focus in place.
// https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus.
if ( ! document . hasFocus ( ) ) {
event . preventDefault ( ) ;
return ;
}
if ( 'function' === typeof currentOnFocusOutside . current ) {
currentOnFocusOutside . current ( event ) ;
}
} , 0 ) ;
} , [ ] ) ;
return {
onFocus : cancelBlurCheck ,
onMouseDown : normalizeButtonFocus ,
onMouseUp : normalizeButtonFocus ,
onTouchStart : normalizeButtonFocus ,
onTouchEnd : normalizeButtonFocus ,
onBlur : queueBlurCheck
} ;
}
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
/* eslint-disable jsdoc/valid-types */
2022-04-11 14:04:30 +02:00
/ * *
* @ template T
* @ typedef { T extends import ( 'react' ) . Ref < infer R > ? R : never } TypeFromRef
* /
/* eslint-enable jsdoc/valid-types */
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* @ template T
* @ param { import ( 'react' ) . Ref < T > } ref
* @ param { T } value
* /
function assignRef ( ref , value ) {
if ( typeof ref === 'function' ) {
ref ( value ) ;
} else if ( ref && ref . hasOwnProperty ( 'current' ) ) {
/* eslint-disable jsdoc/no-undefined-types */
2023-09-26 16:23:26 +02:00
/** @type {import('react').MutableRefObject<T>} */ ref . current = value ;
2022-04-11 14:04:30 +02:00
/* eslint-enable jsdoc/no-undefined-types */
}
}
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Merges refs into one ref callback .
*
* It also ensures that the merged ref callbacks are only called when they
* change ( as a result of a ` useCallback ` dependency update ) OR when the ref
* value changes , just as React does when passing a single ref callback to the
* component .
*
* As expected , if you pass a new function on every render , the ref callback
* will be called after every render .
*
* If you don ' t wish a ref callback to be called after every render , wrap it
* with ` useCallback( callback, dependencies ) ` . When a dependency changes , the
* old ref callback will be called with ` null ` and the new ref callback will be
* called with the same value .
*
* To make ref callbacks easier to use , you can also pass the result of
* ` useRefEffect ` , which makes cleanup easier by allowing you to return a
* cleanup function instead of handling ` null ` .
*
* It ' s also possible to _disable _ a ref ( and its behaviour ) by simply not
* passing the ref .
*
* ` ` ` jsx
* const ref = useRefEffect ( ( node ) => {
* node . addEventListener ( ... ) ;
* return ( ) => {
* node . removeEventListener ( ... ) ;
* } ;
* } , [ ... dependencies ] ) ;
* const otherRef = useRef ( ) ;
* const mergedRefs useMergeRefs ( [
* enabled && ref ,
* otherRef ,
* ] ) ;
* return < div ref = { mergedRefs } / > ;
* ` ` `
*
* @ template { import ( 'react' ) . Ref < any > } TRef
* @ param { Array < TRef > } refs The refs to be merged .
*
* @ return { import ( 'react' ) . RefCallback < TypeFromRef < TRef >> } The merged ref callback .
* /
function useMergeRefs ( refs ) {
const element = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2023-02-07 08:04:52 +01:00
const isAttached = ( 0 , external _wp _element _namespaceObject . useRef ) ( false ) ;
2022-04-11 14:04:30 +02:00
const didElementChange = ( 0 , external _wp _element _namespaceObject . useRef ) ( false ) ;
/* eslint-disable jsdoc/no-undefined-types */
/** @type {import('react').MutableRefObject<TRef[]>} */
/* eslint-enable jsdoc/no-undefined-types */
const previousRefs = ( 0 , external _wp _element _namespaceObject . useRef ) ( [ ] ) ;
2023-09-26 16:23:26 +02:00
const currentRefs = ( 0 , external _wp _element _namespaceObject . useRef ) ( refs ) ;
// Update on render before the ref callback is called, so the ref callback
2022-04-11 14:04:30 +02:00
// always has access to the current refs.
2023-09-26 16:23:26 +02:00
currentRefs . current = refs ;
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
// If any of the refs change, call the previous ref with `null` and the new
2022-04-11 14:04:30 +02:00
// ref with the node, except when the element changes in the same cycle, in
// which case the ref callbacks will already have been called.
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
2023-02-07 08:04:52 +01:00
if ( didElementChange . current === false && isAttached . current === true ) {
2022-04-11 14:04:30 +02:00
refs . forEach ( ( ref , index ) => {
const previousRef = previousRefs . current [ index ] ;
if ( ref !== previousRef ) {
assignRef ( previousRef , null ) ;
assignRef ( ref , element . current ) ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
} ) ;
}
previousRefs . current = refs ;
2023-09-26 16:23:26 +02:00
} , refs ) ;
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
// No dependencies, must be reset after every render so ref callbacks are
// correctly called after a ref change.
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
didElementChange . current = false ;
2023-09-26 16:23:26 +02:00
} ) ;
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
// There should be no dependencies so that `callback` is only called when
// the node changes.
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . useCallback ) ( value => {
// Update the element so it can be used when calling ref callbacks on a
// dependency change.
assignRef ( element , value ) ;
2023-02-07 08:04:52 +01:00
didElementChange . current = true ;
2023-09-26 16:23:26 +02:00
isAttached . current = value !== null ;
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
// When an element changes, the current ref callback should be called
// with the new element and the previous one with `null`.
const refsToAssign = value ? currentRefs . current : previousRefs . current ;
2020-07-21 14:14:37 +02:00
2023-09-26 16:23:26 +02:00
// Update the latest refs.
2022-04-11 14:04:30 +02:00
for ( const ref of refsToAssign ) {
assignRef ( ref , value ) ;
}
} , [ ] ) ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js
2022-09-20 17:43:29 +02:00
/ * *
* External dependencies
* /
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2020-02-06 22:03:31 +01:00
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2020-02-06 22:03:31 +01:00
2021-04-15 17:19:43 +02:00
2020-02-06 22:03:31 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Returns a ref and props to apply to a dialog wrapper to enable the following behaviors :
* - constrained tabbing .
* - focus on mount .
* - return focus on unmount .
* - focus outside .
*
2023-06-27 16:24:19 +02:00
* @ param options Dialog Options .
2022-04-11 14:04:30 +02:00
* /
function useDialog ( options ) {
const currentOptions = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
currentOptions . current = options ;
} , Object . values ( options ) ) ;
const constrainedTabbingRef = use _constrained _tabbing ( ) ;
const focusOnMountRef = useFocusOnMount ( options . focusOnMount ) ;
const focusReturnRef = use _focus _return ( ) ;
const focusOutsideProps = useFocusOutside ( event => {
// This unstable prop is here only to manage backward compatibility
// for the Popover component otherwise, the onClose should be enough.
2023-06-27 16:24:19 +02:00
if ( currentOptions . current ? . _ _unstableOnClose ) {
2022-04-11 14:04:30 +02:00
currentOptions . current . _ _unstableOnClose ( 'focus-outside' , event ) ;
2023-06-27 16:24:19 +02:00
} else if ( currentOptions . current ? . onClose ) {
2022-04-11 14:04:30 +02:00
currentOptions . current . onClose ( ) ;
}
} ) ;
const closeOnEscapeRef = ( 0 , external _wp _element _namespaceObject . useCallback ) ( node => {
if ( ! node ) {
return ;
}
2022-09-20 17:43:29 +02:00
node . addEventListener ( 'keydown' , event => {
2022-04-12 17:12:47 +02:00
// Close on escape.
2023-06-27 16:24:19 +02:00
if ( event . keyCode === external _wp _keycodes _namespaceObject . ESCAPE && ! event . defaultPrevented && currentOptions . current ? . onClose ) {
2022-04-11 14:04:30 +02:00
event . preventDefault ( ) ;
currentOptions . current . onClose ( ) ;
}
} ) ;
} , [ ] ) ;
2023-09-26 16:23:26 +02:00
return [ useMergeRefs ( [ options . focusOnMount !== false ? constrainedTabbingRef : null , options . focusOnMount !== false ? focusReturnRef : null , options . focusOnMount !== false ? focusOnMountRef : null , closeOnEscapeRef ] ) , {
... focusOutsideProps ,
2022-09-20 17:43:29 +02:00
tabIndex : - 1
2022-04-11 14:04:30 +02:00
} ] ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _dialog = ( useDialog ) ;
2021-04-15 17:19:43 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js
2022-09-20 17:43:29 +02:00
/ * *
* Internal dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* In some circumstances , such as block previews , all focusable DOM elements
* ( input fields , links , buttons , etc . ) need to be disabled . This hook adds the
* behavior to disable nested DOM elements to the returned ref .
*
2023-02-07 08:04:52 +01:00
* If you can , prefer the use of the inert HTML attribute .
*
2022-09-20 17:43:29 +02:00
* @ param { Object } config Configuration object .
* @ param { boolean = } config . isDisabled Whether the element should be disabled .
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Element Ref .
2022-04-11 14:04:30 +02:00
*
* @ example
* ` ` ` js
2022-09-20 17:43:29 +02:00
* import { useDisabled } from '@wordpress/compose' ;
2023-02-07 08:04:52 +01:00
*
2022-04-11 14:04:30 +02:00
* const DisabledExample = ( ) => {
* const disabledRef = useDisabled ( ) ;
* return (
* < div ref = { disabledRef } >
* < a href = "#" > This link will have tabindex set to - 1 < / a >
* < input placeholder = "This input will have the disabled attribute added to it." type = "text" / >
* < / d i v >
* ) ;
* } ;
* ` ` `
* /
2023-06-27 16:24:19 +02:00
function useDisabled ( {
isDisabled : isDisabledProp = false
} = { } ) {
2022-09-20 17:43:29 +02:00
return useRefEffect ( node => {
if ( isDisabledProp ) {
2022-04-11 14:04:30 +02:00
return ;
}
2023-06-27 16:24:19 +02:00
const defaultView = node ? . ownerDocument ? . defaultView ;
2023-02-07 08:04:52 +01:00
if ( ! defaultView ) {
return ;
}
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
/** A variable keeping track of the previous updates in order to restore them. */
2022-09-20 17:43:29 +02:00
const updates = [ ] ;
const disable = ( ) => {
2023-02-07 08:04:52 +01:00
node . childNodes . forEach ( child => {
if ( ! ( child instanceof defaultView . HTMLElement ) ) {
return ;
2022-09-20 17:43:29 +02:00
}
2023-02-07 08:04:52 +01:00
if ( ! child . getAttribute ( 'inert' ) ) {
child . setAttribute ( 'inert' , 'true' ) ;
2022-09-20 17:43:29 +02:00
updates . push ( ( ) => {
2023-02-07 08:04:52 +01:00
child . removeAttribute ( 'inert' ) ;
2022-09-20 17:43:29 +02:00
} ) ;
}
2022-04-11 14:04:30 +02:00
} ) ;
2023-09-26 16:23:26 +02:00
} ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// Debounce re-disable since disabling process itself will incur
// additional mutations which should be ignored.
2023-02-07 08:04:52 +01:00
const debouncedDisable = debounce ( disable , 0 , {
2022-09-20 17:43:29 +02:00
leading : true
} ) ;
disable ( ) ;
2023-09-26 16:23:26 +02:00
/** @type {MutationObserver | undefined} */
2022-09-20 17:43:29 +02:00
const observer = new window . MutationObserver ( debouncedDisable ) ;
observer . observe ( node , {
2023-02-07 08:04:52 +01:00
childList : true
2022-09-20 17:43:29 +02:00
} ) ;
2022-04-11 14:04:30 +02:00
return ( ) => {
if ( observer ) {
observer . disconnect ( ) ;
}
debouncedDisable . cancel ( ) ;
2022-09-20 17:43:29 +02:00
updates . forEach ( update => update ( ) ) ;
2022-04-11 14:04:30 +02:00
} ;
2022-09-20 17:43:29 +02:00
} , [ isDisabledProp ] ) ;
2022-04-11 14:04:30 +02:00
}
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Preferred over direct usage of ` useLayoutEffect ` when supporting
* server rendered components ( SSR ) because currently React
* throws a warning when using useLayoutEffect in that environment .
* /
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external _wp _element _namespaceObject . useLayoutEffect : external _wp _element _namespaceObject . useEffect ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _isomorphic _layout _effect = ( useIsomorphicLayoutEffect ) ;
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
// Event handlers that are triggered from `document` listeners accept a MouseEvent,
// while those triggered from React listeners accept a React.MouseEvent.
2022-04-11 14:04:30 +02:00
/ * *
2022-09-20 17:43:29 +02:00
* @ param { Object } props
* @ param { ( e : import ( 'react' ) . MouseEvent ) => void } props . onDragStart
* @ param { ( e : MouseEvent ) => void } props . onDragMove
* @ param { ( e ? : MouseEvent ) => void } props . onDragEnd
2022-04-11 14:04:30 +02:00
* /
2023-06-27 16:24:19 +02:00
function useDragging ( {
onDragStart ,
onDragMove ,
onDragEnd
} ) {
2022-04-11 14:04:30 +02:00
const [ isDragging , setIsDragging ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const eventsRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( {
onDragStart ,
onDragMove ,
onDragEnd
} ) ;
use _isomorphic _layout _effect ( ( ) => {
eventsRef . current . onDragStart = onDragStart ;
eventsRef . current . onDragMove = onDragMove ;
eventsRef . current . onDragEnd = onDragEnd ;
} , [ onDragStart , onDragMove , onDragEnd ] ) ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
/** @type {(e: MouseEvent) => void} */
2022-09-20 17:43:29 +02:00
const onMouseMove = ( 0 , external _wp _element _namespaceObject . useCallback ) ( event => eventsRef . current . onDragMove && eventsRef . current . onDragMove ( event ) , [ ] ) ;
/** @type {(e?: MouseEvent) => void} */
const endDrag = ( 0 , external _wp _element _namespaceObject . useCallback ) ( event => {
2022-04-11 14:04:30 +02:00
if ( eventsRef . current . onDragEnd ) {
eventsRef . current . onDragEnd ( event ) ;
}
document . removeEventListener ( 'mousemove' , onMouseMove ) ;
document . removeEventListener ( 'mouseup' , endDrag ) ;
setIsDragging ( false ) ;
} , [ ] ) ;
2022-09-20 17:43:29 +02:00
/** @type {(e: import('react').MouseEvent) => void} */
const startDrag = ( 0 , external _wp _element _namespaceObject . useCallback ) ( event => {
2022-04-11 14:04:30 +02:00
if ( eventsRef . current . onDragStart ) {
eventsRef . current . onDragStart ( event ) ;
}
document . addEventListener ( 'mousemove' , onMouseMove ) ;
document . addEventListener ( 'mouseup' , endDrag ) ;
setIsDragging ( true ) ;
2023-09-26 16:23:26 +02:00
} , [ ] ) ;
2022-04-11 14:04:30 +02:00
2023-09-26 16:23:26 +02:00
// Remove the global events when unmounting if needed.
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
return ( ) => {
if ( isDragging ) {
document . removeEventListener ( 'mousemove' , onMouseMove ) ;
document . removeEventListener ( 'mouseup' , endDrag ) ;
}
} ;
} , [ isDragging ] ) ;
return {
startDrag ,
endDrag ,
isDragging
} ;
}
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
// EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js
var mousetrap _mousetrap = _ _webpack _require _ _ ( 7973 ) ;
var mousetrap _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( mousetrap _mousetrap ) ;
// EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
var mousetrap _global _bind = _ _webpack _require _ _ ( 5538 ) ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js
/ * *
* External dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2022-09-20 17:43:29 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* A block selection object .
*
* @ typedef { Object } WPKeyboardShortcutConfig
*
* @ property { boolean } [ bindGlobal ] Handle keyboard events anywhere including inside textarea / input fields .
* @ property { string } [ eventName ] Event name used to trigger the handler , defaults to keydown .
* @ property { boolean } [ isDisabled ] Disables the keyboard handler if the value is true .
* @ property { import ( 'react' ) . RefObject < HTMLElement > } [ target ] React reference to the DOM element used to catch the keyboard event .
* /
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
/* eslint-disable jsdoc/valid-types */
/ * *
* Attach a keyboard shortcut handler .
*
* @ see https : //craig.is/killing/mice#api.bind for information about the `callback` parameter.
*
* @ param { string [ ] | string } shortcuts Keyboard Shortcuts .
* @ param { ( e : import ( 'mousetrap' ) . ExtendedKeyboardEvent , combo : string ) => void } callback Shortcut callback .
* @ param { WPKeyboardShortcutConfig } options Shortcut options .
* /
2023-09-26 16:23:26 +02:00
function useKeyboardShortcut ( /* eslint-enable jsdoc/valid-types */
2023-06-27 16:24:19 +02:00
shortcuts , callback , {
bindGlobal = false ,
eventName = 'keydown' ,
isDisabled = false ,
// This is important for performance considerations.
target
} = { } ) {
2022-04-11 14:04:30 +02:00
const currentCallback = ( 0 , external _wp _element _namespaceObject . useRef ) ( callback ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
currentCallback . current = callback ;
} , [ callback ] ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
if ( isDisabled ) {
return ;
}
2023-09-26 16:23:26 +02:00
const mousetrap = new ( mousetrap _default ( ) ) ( target && target . current ? target . current :
// We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
2022-04-11 14:04:30 +02:00
// Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's
2022-04-12 17:12:47 +02:00
// necessary to maintain the existing behavior.
2023-09-26 16:23:26 +02:00
/** @type {Element} */ /** @type {unknown} */
2022-04-11 14:04:30 +02:00
document ) ;
2023-02-07 08:04:52 +01:00
const shortcutsArray = Array . isArray ( shortcuts ) ? shortcuts : [ shortcuts ] ;
shortcutsArray . forEach ( shortcut => {
2023-09-26 16:23:26 +02:00
const keys = shortcut . split ( '+' ) ;
// Determines whether a key is a modifier by the length of the string.
2022-04-11 14:04:30 +02:00
// E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that
// the modifiers are Shift and Cmd because they're not a single character.
const modifiers = new Set ( keys . filter ( value => value . length > 1 ) ) ;
const hasAlt = modifiers . has ( 'alt' ) ;
2023-09-26 16:23:26 +02:00
const hasShift = modifiers . has ( 'shift' ) ;
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
// This should be better moved to the shortcut registration instead.
2022-09-20 17:43:29 +02:00
if ( ( 0 , external _wp _keycodes _namespaceObject . isAppleOS ) ( ) && ( modifiers . size === 1 && hasAlt || modifiers . size === 2 && hasAlt && hasShift ) ) {
2022-04-11 14:04:30 +02:00
throw new Error ( ` Cannot bind ${ shortcut } . Alt and Shift+Alt modifiers are reserved for character input. ` ) ;
}
2023-09-26 16:23:26 +02:00
const bindFn = bindGlobal ? 'bindGlobal' : 'bind' ;
// @ts-ignore `bindGlobal` is an undocumented property
mousetrap [ bindFn ] ( shortcut , ( /* eslint-disable jsdoc/valid-types */
/** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */ ... args ) => /* eslint-enable jsdoc/valid-types */
2023-06-27 16:24:19 +02:00
currentCallback . current ( ... args ) , eventName ) ;
2022-04-11 14:04:30 +02:00
} ) ;
return ( ) => {
mousetrap . reset ( ) ;
2021-05-20 14:20:04 +02:00
} ;
2022-04-11 14:04:30 +02:00
} , [ shortcuts , bindGlobal , eventName , target , isDisabled ] ) ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _keyboard _shortcut = ( useKeyboardShortcut ) ;
2021-04-15 17:19:43 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js
/ * *
* WordPress dependencies
* /
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
2023-06-27 16:24:19 +02:00
/ * *
* A new MediaQueryList object for the media query
*
* @ param { string } [ query ] Media Query .
* @ return { MediaQueryList | null } A new object for the media query
* /
function getMediaQueryList ( query ) {
if ( query && typeof window !== 'undefined' && typeof window . matchMedia === 'function' ) {
return window . matchMedia ( query ) ;
}
return null ;
}
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Runs a media query and returns its value when it changes .
*
* @ param { string } [ query ] Media Query .
* @ return { boolean } return value of the media query .
* /
function useMediaQuery ( query ) {
2023-06-27 16:24:19 +02:00
const source = ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
const mediaQueryList = getMediaQueryList ( query ) ;
return {
/** @type {(onStoreChange: () => void) => () => void} */
subscribe ( onStoreChange ) {
if ( ! mediaQueryList ) {
return ( ) => { } ;
}
2021-05-20 14:20:04 +02:00
2023-09-26 16:23:26 +02:00
// Avoid a fatal error when browsers don't support `addEventListener` on MediaQueryList.
mediaQueryList . addEventListener ? . ( 'change' , onStoreChange ) ;
2023-06-27 16:24:19 +02:00
return ( ) => {
2023-09-26 16:23:26 +02:00
mediaQueryList . removeEventListener ? . ( 'change' , onStoreChange ) ;
2023-06-27 16:24:19 +02:00
} ;
} ,
getValue ( ) {
var _mediaQueryList$match ;
return ( _mediaQueryList$match = mediaQueryList ? . matches ) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false ;
}
2021-05-20 14:20:04 +02:00
} ;
2022-04-11 14:04:30 +02:00
} , [ query ] ) ;
2023-06-27 16:24:19 +02:00
return ( 0 , external _wp _element _namespaceObject . useSyncExternalStore ) ( source . subscribe , source . getValue , ( ) => false ) ;
2022-04-11 14:04:30 +02:00
}
2021-04-15 17:19:43 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js
/ * *
* WordPress dependencies
* /
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Use something ' s value from the previous render .
* Based on https : //usehooks.com/usePrevious/.
*
2023-06-27 16:24:19 +02:00
* @ param value The value to track .
2022-04-11 14:04:30 +02:00
*
* @ return The value from the previous render .
* /
function usePrevious ( value ) {
2023-09-26 16:23:26 +02:00
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
// Store current value in ref.
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
ref . current = value ;
} , [ value ] ) ; // Re-run when value changes.
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
// Return previous value (happens before update in useEffect above).
2022-04-11 14:04:30 +02:00
return ref . current ;
}
2021-04-15 17:19:43 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js
/ * *
* Internal dependencies
* /
2021-04-15 17:19:43 +02:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Hook returning whether the user has a preference for reduced motion .
*
* @ return { boolean } Reduced motion preference value .
* /
const useReducedMotion = ( ) => useMediaQuery ( '(prefers-reduced-motion: reduce)' ) ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _reduced _motion = ( useReducedMotion ) ;
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
// EXTERNAL MODULE: ./node_modules/@wordpress/undo-manager/build-module/index.js
var build _module = _ _webpack _require _ _ ( 5360 ) ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-state-with-history/index.js
/ * *
* WordPress dependencies
* /
function undoRedoReducer ( state , action ) {
switch ( action . type ) {
case 'UNDO' :
{
const undoRecord = state . manager . undo ( ) ;
if ( undoRecord ) {
return {
... state ,
value : undoRecord [ 0 ] . changes . prop . from
} ;
}
return state ;
}
case 'REDO' :
{
const redoRecord = state . manager . redo ( ) ;
if ( redoRecord ) {
return {
... state ,
value : redoRecord [ 0 ] . changes . prop . to
} ;
}
return state ;
}
case 'RECORD' :
{
state . manager . addRecord ( [ {
id : 'object' ,
changes : {
prop : {
from : state . value ,
to : action . value
}
}
} ] , action . isStaged ) ;
return {
... state ,
value : action . value
} ;
}
}
return state ;
}
function initReducer ( value ) {
return {
manager : ( 0 , build _module . createUndoManager ) ( ) ,
value
} ;
}
/ * *
* useState with undo / redo history .
*
* @ param initialValue Initial value .
* @ return Value , setValue , hasUndo , hasRedo , undo , redo .
* /
function useStateWithHistory ( initialValue ) {
const [ state , dispatch ] = ( 0 , external _wp _element _namespaceObject . useReducer ) ( undoRedoReducer , initialValue , initReducer ) ;
return {
value : state . value ,
setValue : ( 0 , external _wp _element _namespaceObject . useCallback ) ( ( newValue , isStaged ) => {
dispatch ( {
type : 'RECORD' ,
value : newValue ,
isStaged
} ) ;
} , [ ] ) ,
hasUndo : state . manager . hasUndo ( ) ,
hasRedo : state . manager . hasRedo ( ) ,
undo : ( 0 , external _wp _element _namespaceObject . useCallback ) ( ( ) => {
dispatch ( {
type : 'UNDO'
} ) ;
} , [ ] ) ,
redo : ( 0 , external _wp _element _namespaceObject . useCallback ) ( ( ) => {
dispatch ( {
type : 'REDO'
} ) ;
} , [ ] )
} ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Internal dependencies
* /
2021-01-28 03:04:13 +01:00
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* @ typedef { "huge" | "wide" | "large" | "medium" | "small" | "mobile" } WPBreakpoint
* /
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Hash of breakpoint names with pixel width at which it becomes effective .
*
* @ see _breakpoints . scss
*
* @ type { Record < WPBreakpoint , number > }
* /
const BREAKPOINTS = {
huge : 1440 ,
wide : 1280 ,
large : 960 ,
medium : 782 ,
small : 600 ,
mobile : 480
} ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* @ typedef { ">=" | "<" } WPViewportOperator
* /
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
/ * *
* Object mapping media query operators to the condition to be used .
*
* @ type { Record < WPViewportOperator , string > }
* /
const CONDITIONS = {
'>=' : 'min-width' ,
'<' : 'max-width'
} ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values .
*
* @ type { Record < WPViewportOperator , ( breakpointValue : number , width : number ) => boolean > }
* /
const OPERATOR _EVALUATORS = {
'>=' : ( breakpointValue , width ) => width >= breakpointValue ,
'<' : ( breakpointValue , width ) => width < breakpointValue
} ;
2023-09-26 16:23:26 +02:00
const ViewportMatchWidthContext = ( 0 , external _wp _element _namespaceObject . createContext ) ( /** @type {null | number} */ null ) ;
2022-04-11 14:04:30 +02:00
/ * *
* Returns true if the viewport matches the given query , or false otherwise .
*
* @ param { WPBreakpoint } breakpoint Breakpoint size name .
* @ param { WPViewportOperator } [ operator = ">=" ] Viewport operator .
*
* @ example
*
* ` ` ` js
* useViewportMatch ( 'huge' , '<' ) ;
* useViewportMatch ( 'medium' ) ;
* ` ` `
*
* @ return { boolean } Whether viewport matches query .
* /
2023-06-27 16:24:19 +02:00
const useViewportMatch = ( breakpoint , operator = '>=' ) => {
2022-04-11 14:04:30 +02:00
const simulatedWidth = ( 0 , external _wp _element _namespaceObject . useContext ) ( ViewportMatchWidthContext ) ;
const mediaQuery = ! simulatedWidth && ` ( ${ CONDITIONS [ operator ] } : ${ BREAKPOINTS [ breakpoint ] } px) ` ;
const mediaQueryResult = useMediaQuery ( mediaQuery || undefined ) ;
if ( simulatedWidth ) {
return OPERATOR _EVALUATORS [ operator ] ( BREAKPOINTS [ breakpoint ] , simulatedWidth ) ;
}
return mediaQueryResult ;
} ;
useViewportMatch . _ _experimentalWidthProvider = ViewportMatchWidthContext . Provider ;
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _viewport _match = ( useViewportMatch ) ;
2021-01-28 03:04:13 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js
2022-09-20 17:43:29 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* External dependencies
* /
2021-01-28 03:04:13 +01:00
2022-09-20 17:43:29 +02:00
/ * *
* WordPress dependencies
* /
// This of course could've been more streamlined with internal state instead of
// refs, but then host hooks / components could not opt out of renders.
// This could've been exported to its own module, but the current build doesn't
// seem to work with module imports and I had no more time to spend on this...
function useResolvedElement ( subscriber , refOrElement ) {
const callbackRefElement = ( 0 , external _wp _element _namespaceObject . useRef ) ( null ) ;
const lastReportRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( null ) ;
const cleanupRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const callSubscriber = ( 0 , external _wp _element _namespaceObject . useCallback ) ( ( ) => {
let element = null ;
if ( callbackRefElement . current ) {
element = callbackRefElement . current ;
} else if ( refOrElement ) {
if ( refOrElement instanceof HTMLElement ) {
element = refOrElement ;
} else {
element = refOrElement . current ;
}
}
if ( lastReportRef . current && lastReportRef . current . element === element && lastReportRef . current . reporter === callSubscriber ) {
return ;
}
if ( cleanupRef . current ) {
2023-09-26 16:23:26 +02:00
cleanupRef . current ( ) ;
// Making sure the cleanup is not called accidentally multiple times.
2022-09-20 17:43:29 +02:00
cleanupRef . current = null ;
}
lastReportRef . current = {
reporter : callSubscriber ,
element
2023-09-26 16:23:26 +02:00
} ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// Only calling the subscriber, if there's an actual element to report.
2022-09-20 17:43:29 +02:00
if ( element ) {
cleanupRef . current = subscriber ( element ) ;
}
2023-09-26 16:23:26 +02:00
} , [ refOrElement , subscriber ] ) ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// On each render, we check whether a ref changed, or if we got a new raw
// element.
2022-09-20 17:43:29 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
// With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a
// render accompanying that change as well.
// To guarantee we always have the right element, one must use the ref callback provided instead, but we support
// RefObjects to make the hook API more convenient in certain cases.
callSubscriber ( ) ;
} , [ callSubscriber ] ) ;
return ( 0 , external _wp _element _namespaceObject . useCallback ) ( element => {
callbackRefElement . current = element ;
callSubscriber ( ) ;
} , [ callSubscriber ] ) ;
}
// We're only using the first element of the size sequences, until future versions of the spec solidify on how
// exactly it'll be used for fragments in multi-column scenarios:
// From the spec:
// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,
// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not
// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single
// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.
// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.
// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)
//
// Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,
// regardless of the "box" option.
// The spec states the following on this:
// > This does not have any impact on which box dimensions are returned to the defined callback when the event
// > is fired, it solely defines which box the author wishes to observe layout changes on.
// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
// I'm not exactly clear on what this means, especially when you consider a later section stating the following:
// > This section is non-normative. An author may desire to observe more than one CSS box.
// > In this case, author will need to use multiple ResizeObservers.
// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.
// For this reason I decided to only return the requested size,
// even though it seems we have access to results for all box types.
// This also means that we get to keep the current api, being able to return a simple { width, height } pair,
// regardless of box option.
const extractSize = ( entry , boxProp , sizeType ) => {
if ( ! entry [ boxProp ] ) {
if ( boxProp === 'contentBoxSize' ) {
// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.
// See the 6th step in the description for the RO algorithm:
// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h
// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box".
// In real browser implementations of course these objects differ, but the width/height values should be equivalent.
return entry . contentRect [ sizeType === 'inlineSize' ? 'width' : 'height' ] ;
}
return undefined ;
2023-09-26 16:23:26 +02:00
}
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// A couple bytes smaller than calling Array.isArray() and just as effective here.
return entry [ boxProp ] [ 0 ] ? entry [ boxProp ] [ 0 ] [ sizeType ] :
// TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
2022-09-20 17:43:29 +02:00
// behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
// @ts-ignore
entry [ boxProp ] [ sizeType ] ;
} ;
2023-06-27 16:24:19 +02:00
function useResizeObserver ( opts = { } ) {
2022-09-20 17:43:29 +02:00
// Saving the callback as a ref. With this, I don't need to put onResize in the
// effect dep array, and just passing in an anonymous function without memoising
// will not reinstantiate the hook's ResizeObserver.
const onResize = opts . onResize ;
const onResizeRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( undefined ) ;
onResizeRef . current = onResize ;
2023-09-26 16:23:26 +02:00
const round = opts . round || Math . round ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// Using a single instance throughout the hook's lifetime
2022-09-20 17:43:29 +02:00
const resizeObserverRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const [ size , setSize ] = ( 0 , external _wp _element _namespaceObject . useState ) ( {
width : undefined ,
height : undefined
2023-09-26 16:23:26 +02:00
} ) ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// In certain edge cases the RO might want to report a size change just after
// the component unmounted.
2022-09-20 17:43:29 +02:00
const didUnmount = ( 0 , external _wp _element _namespaceObject . useRef ) ( false ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2023-06-27 16:24:19 +02:00
didUnmount . current = false ;
2022-09-20 17:43:29 +02:00
return ( ) => {
didUnmount . current = true ;
} ;
2023-09-26 16:23:26 +02:00
} , [ ] ) ;
2022-09-20 17:43:29 +02:00
2023-09-26 16:23:26 +02:00
// Using a ref to track the previous width / height to avoid unnecessary renders.
2022-09-20 17:43:29 +02:00
const previous = ( 0 , external _wp _element _namespaceObject . useRef ) ( {
width : undefined ,
height : undefined
2023-09-26 16:23:26 +02:00
} ) ;
// This block is kinda like a useEffect, only it's called whenever a new
2022-09-20 17:43:29 +02:00
// element could be resolved based on the ref option. It also has a cleanup
// function.
const refCallback = useResolvedElement ( ( 0 , external _wp _element _namespaceObject . useCallback ) ( element => {
// We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.
// This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.
if ( ! resizeObserverRef . current || resizeObserverRef . current . box !== opts . box || resizeObserverRef . current . round !== round ) {
resizeObserverRef . current = {
box : opts . box ,
round ,
instance : new ResizeObserver ( entries => {
const entry = entries [ 0 ] ;
let boxProp = 'borderBoxSize' ;
if ( opts . box === 'border-box' ) {
boxProp = 'borderBoxSize' ;
} else {
boxProp = opts . box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize' ;
}
const reportedWidth = extractSize ( entry , boxProp , 'inlineSize' ) ;
const reportedHeight = extractSize ( entry , boxProp , 'blockSize' ) ;
const newWidth = reportedWidth ? round ( reportedWidth ) : undefined ;
const newHeight = reportedHeight ? round ( reportedHeight ) : undefined ;
if ( previous . current . width !== newWidth || previous . current . height !== newHeight ) {
const newSize = {
width : newWidth ,
height : newHeight
} ;
previous . current . width = newWidth ;
previous . current . height = newHeight ;
if ( onResizeRef . current ) {
onResizeRef . current ( newSize ) ;
} else if ( ! didUnmount . current ) {
setSize ( newSize ) ;
}
}
} )
} ;
}
resizeObserverRef . current . instance . observe ( element , {
box : opts . box
} ) ;
return ( ) => {
if ( resizeObserverRef . current ) {
resizeObserverRef . current . instance . unobserve ( element ) ;
}
} ;
} , [ opts . box , round ] ) , opts . ref ) ;
return ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => ( {
ref : refCallback ,
width : size . width ,
height : size . height
} ) , [ refCallback , size ? size . width : null , size ? size . height : null ] ) ;
}
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Hook which allows to listen the resize event of any target element when it changes sizes .
2022-09-20 17:43:29 +02:00
* _Note : ` useResizeObserver ` will report ` null ` until after first render .
2022-04-11 14:04:30 +02:00
*
* @ example
*
* ` ` ` js
* const App = ( ) => {
* const [ resizeListener , sizes ] = useResizeObserver ( ) ;
*
* return (
* < div >
* { resizeListener }
* Your content here
* < / d i v >
* ) ;
* } ;
* ` ` `
2021-01-28 03:04:13 +01:00
* /
2022-09-20 17:43:29 +02:00
function useResizeAware ( ) {
const {
ref ,
width ,
height
} = useResizeObserver ( ) ;
const sizes = ( 0 , external _wp _element _namespaceObject . useMemo ) ( ( ) => {
return {
width : width !== null && width !== void 0 ? width : null ,
height : height !== null && height !== void 0 ? height : null
} ;
} , [ width , height ] ) ;
const resizeListener = ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
style : {
position : 'absolute' ,
top : 0 ,
left : 0 ,
right : 0 ,
bottom : 0 ,
pointerEvents : 'none' ,
opacity : 0 ,
overflow : 'hidden' ,
zIndex : - 1
} ,
"aria-hidden" : "true" ,
ref : ref
} ) ;
return [ resizeListener , sizes ] ;
}
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","priorityQueue"]
2023-09-21 15:26:32 +02:00
var external _wp _priorityQueue _namespaceObject = window [ "wp" ] [ "priorityQueue" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js
2020-01-22 23:06:21 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* WordPress dependencies
2020-01-22 23:06:21 +01:00
* /
2022-04-11 14:04:30 +02:00
/ * *
* Returns the first items from list that are present on state .
*
2023-06-27 16:24:19 +02:00
* @ param list New array .
* @ param state Current state .
2022-04-11 14:04:30 +02:00
* @ return First items present iin state .
* /
function getFirstItemsPresentInState ( list , state ) {
const firstItems = [ ] ;
for ( let i = 0 ; i < list . length ; i ++ ) {
const item = list [ i ] ;
if ( ! state . includes ( item ) ) {
break ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
firstItems . push ( item ) ;
}
return firstItems ;
}
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* React hook returns an array which items get asynchronously appended from a source array .
* This behavior is useful if we want to render a list of items asynchronously for performance reasons .
*
2023-06-27 16:24:19 +02:00
* @ param list Source array .
* @ param config Configuration object .
2022-04-11 14:04:30 +02:00
*
* @ return Async array .
* /
2023-06-27 16:24:19 +02:00
function useAsyncList ( list , config = {
step : 1
} ) {
2022-04-11 14:04:30 +02:00
const {
step = 1
} = config ;
const [ current , setCurrent ] = ( 0 , external _wp _element _namespaceObject . useState ) ( [ ] ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
// On reset, we keep the first items that were previously rendered.
let firstItems = getFirstItemsPresentInState ( list , current ) ;
if ( firstItems . length < step ) {
firstItems = firstItems . concat ( list . slice ( firstItems . length , step ) ) ;
2020-01-22 23:06:21 +01:00
}
2022-04-11 14:04:30 +02:00
setCurrent ( firstItems ) ;
const asyncQueue = ( 0 , external _wp _priorityQueue _namespaceObject . createQueue ) ( ) ;
2023-02-21 14:09:42 +01:00
for ( let i = firstItems . length ; i < list . length ; i += step ) {
asyncQueue . add ( { } , ( ) => {
( 0 , external _wp _element _namespaceObject . flushSync ) ( ( ) => {
setCurrent ( state => [ ... state , ... list . slice ( i , i + step ) ] ) ;
} ) ;
} ) ;
}
2022-04-11 14:04:30 +02:00
return ( ) => asyncQueue . reset ( ) ;
} , [ list ] ) ;
return current ;
}
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _async _list = ( useAsyncList ) ;
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js
/ * *
* Internal dependencies
* /
2020-01-22 23:06:21 +01:00
2020-07-07 18:08:28 +02:00
2023-09-26 16:23:26 +02:00
// Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
// but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
/* eslint-disable jsdoc/check-types */
2022-04-11 14:04:30 +02:00
/ * *
* Hook that performs a shallow comparison between the preview value of an object
* and the new one , if there ' s a difference , it prints it to the console .
* this is useful in performance related work , to check why a component re - renders .
*
* @ example
*
* ` ` ` jsx
* function MyComponent ( props ) {
* useWarnOnChange ( props ) ;
*
* return "Something" ;
* }
* ` ` `
*
* @ param { object } object Object which changes to compare .
* @ param { string } prefix Just a prefix to show when console logging .
* /
2023-06-27 16:24:19 +02:00
function useWarnOnChange ( object , prefix = 'Change detection' ) {
2022-04-11 14:04:30 +02:00
const previousValues = usePrevious ( object ) ;
2023-06-27 16:24:19 +02:00
Object . entries ( previousValues !== null && previousValues !== void 0 ? previousValues : [ ] ) . forEach ( ( [ key , value ] ) => {
2023-09-26 16:23:26 +02:00
if ( value !== object [ /** @type {keyof typeof object} */ key ] ) {
2022-04-11 14:04:30 +02:00
// eslint-disable-next-line no-console
2023-09-26 16:23:26 +02:00
console . warn ( ` ${ prefix } : ${ key } key changed: ` , value , object [ /** @type {keyof typeof object} */ key ]
/* eslint-enable jsdoc/check-types */ ) ;
2022-04-11 14:04:30 +02:00
}
} ) ;
}
2021-05-20 14:20:04 +02:00
2023-09-21 15:26:32 +02:00
/* harmony default export */ var use _warn _on _change = ( useWarnOnChange ) ;
2021-05-20 14:20:04 +02:00
2022-09-20 17:43:29 +02:00
; // CONCATENATED MODULE: external "React"
2023-09-21 15:26:32 +02:00
var external _React _namespaceObject = window [ "React" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
2020-07-07 18:08:28 +02:00
2022-04-11 14:04:30 +02:00
function areInputsEqual ( newInputs , lastInputs ) {
if ( newInputs . length !== lastInputs . length ) {
return false ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
for ( var i = 0 ; i < newInputs . length ; i ++ ) {
if ( newInputs [ i ] !== lastInputs [ i ] ) {
return false ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
return true ;
}
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
function useMemoOne ( getResult , inputs ) {
2022-09-20 17:43:29 +02:00
var initial = ( 0 , external _React _namespaceObject . useState ) ( function ( ) {
2022-04-11 14:04:30 +02:00
return {
inputs : inputs ,
result : getResult ( )
} ;
} ) [ 0 ] ;
2022-09-20 17:43:29 +02:00
var isFirstRun = ( 0 , external _React _namespaceObject . useRef ) ( true ) ;
var committed = ( 0 , external _React _namespaceObject . useRef ) ( initial ) ;
2022-04-11 14:04:30 +02:00
var useCache = isFirstRun . current || Boolean ( inputs && committed . current . inputs && areInputsEqual ( inputs , committed . current . inputs ) ) ;
var cache = useCache ? committed . current : {
inputs : inputs ,
result : getResult ( )
} ;
2022-09-20 17:43:29 +02:00
( 0 , external _React _namespaceObject . useEffect ) ( function ( ) {
2022-04-11 14:04:30 +02:00
isFirstRun . current = false ;
committed . current = cache ;
} , [ cache ] ) ;
return cache . result ;
}
function useCallbackOne ( callback , inputs ) {
return useMemoOne ( function ( ) {
return callback ;
} , inputs ) ;
}
var useMemo = ( /* unused pure expression or super */ null && ( useMemoOne ) ) ;
var useCallback = ( /* unused pure expression or super */ null && ( useCallbackOne ) ) ;
2020-06-26 15:33:47 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js
/ * *
* External dependencies
* /
2019-09-19 17:19:18 +02:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2020-07-07 18:08:28 +02:00
2023-02-07 08:04:52 +01:00
/ * *
* Internal dependencies
* /
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
/ * *
2023-02-07 08:04:52 +01:00
* Debounces a function similar to Lodash ' s ` debounce ` . A new debounced function will
2022-04-11 14:04:30 +02:00
* be returned and any scheduled calls cancelled if any of the arguments change ,
* including the function to debounce , so please wrap functions created on
* render in components in ` useCallback ` .
*
* @ see https : //docs-lodash.com/v4/debounce/
*
* @ template { ( ... args : any [ ] ) => void } TFunc
*
2023-02-07 08:04:52 +01:00
* @ param { TFunc } fn The function to debounce .
* @ param { number } [ wait ] The number of milliseconds to delay .
* @ param { import ( '../../utils/debounce' ) . DebounceOptions } [ options ] The options object .
* @ return { import ( '../../utils/debounce' ) . DebouncedFunc < TFunc > } Debounced function .
2022-04-11 14:04:30 +02:00
* /
function useDebounce ( fn , wait , options ) {
2023-02-07 08:04:52 +01:00
const debounced = useMemoOne ( ( ) => debounce ( fn , wait !== null && wait !== void 0 ? wait : 0 , options ) , [ fn , wait , options ] ) ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => ( ) => debounced . cancel ( ) , [ debounced ] ) ;
return debounced ;
}
2018-12-18 04:14:52 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js
/ * *
* External dependencies
* /
2020-01-22 23:06:21 +01:00
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* WordPress dependencies
* /
2021-05-20 14:20:04 +02:00
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/ * *
2023-02-07 08:04:52 +01:00
* Internal dependencies
* /
/ * *
* Throttles a function similar to Lodash ' s ` throttle ` . A new throttled function will
2022-04-11 14:04:30 +02:00
* be returned and any scheduled calls cancelled if any of the arguments change ,
* including the function to throttle , so please wrap functions created on
* render in components in ` useCallback ` .
*
* @ see https : //docs-lodash.com/v4/throttle/
*
* @ template { ( ... args : any [ ] ) => void } TFunc
*
2023-02-07 08:04:52 +01:00
* @ param { TFunc } fn The function to throttle .
* @ param { number } [ wait ] The number of milliseconds to throttle invocations to .
* @ param { import ( '../../utils/throttle' ) . ThrottleOptions } [ options ] The options object . See linked documentation for details .
* @ return { import ( '../../utils/debounce' ) . DebouncedFunc < TFunc > } Throttled function .
2022-04-11 14:04:30 +02:00
* /
function useThrottle ( fn , wait , options ) {
2023-02-07 08:04:52 +01:00
const throttled = useMemoOne ( ( ) => throttle ( fn , wait !== null && wait !== void 0 ? wait : 0 , options ) , [ fn , wait , options ] ) ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => ( ) => throttled . cancel ( ) , [ throttled ] ) ;
return throttled ;
}
2019-09-19 17:19:18 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 23:06:21 +01:00
2023-09-26 16:23:26 +02:00
2020-01-08 12:57:23 +01:00
/ * *
2022-04-11 14:04:30 +02:00
* Internal dependencies
2020-01-08 12:57:23 +01:00
* /
2019-09-19 17:19:18 +02:00
2020-01-22 23:06:21 +01:00
2022-04-11 14:04:30 +02:00
/* eslint-disable jsdoc/valid-types */
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* @ template T
* @ param { T } value
2022-04-12 17:12:47 +02:00
* @ return { import ( 'react' ) . MutableRefObject < T | null > } A ref with the value .
2021-05-20 14:20:04 +02:00
* /
2022-04-11 14:04:30 +02:00
function useFreshRef ( value ) {
/* eslint-enable jsdoc/valid-types */
/* eslint-disable jsdoc/no-undefined-types */
/** @type {import('react').MutableRefObject<T>} */
/* eslint-enable jsdoc/no-undefined-types */
// Disable reason: We're doing something pretty JavaScript-y here where the
// ref will always have a current value that is not null or undefined but it
// needs to start as undefined. We don't want to change the return type so
// it's easier to just ts-ignore this specific line that's complaining about
// undefined not being part of T.
// @ts-ignore
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
ref . current = value ;
return ref ;
}
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* A hook to facilitate drag and drop handling .
*
2023-06-27 16:24:19 +02:00
* @ param { Object } props Named parameters .
* @ param { ? HTMLElement } [ props . dropZoneElement ] Optional element to be used as the drop zone .
* @ param { boolean } [ props . isDisabled ] Whether or not to disable the drop zone .
* @ param { ( e : DragEvent ) => void } [ props . onDragStart ] Called when dragging has started .
* @ param { ( e : DragEvent ) => void } [ props . onDragEnter ] Called when the zone is entered .
* @ param { ( e : DragEvent ) => void } [ props . onDragOver ] Called when the zone is moved within .
* @ param { ( e : DragEvent ) => void } [ props . onDragLeave ] Called when the zone is left .
* @ param { ( e : MouseEvent ) => void } [ props . onDragEnd ] Called when dragging has ended .
* @ param { ( e : DragEvent ) => void } [ props . onDrop ] Called when dropping in the zone .
2022-04-11 14:04:30 +02:00
*
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Ref callback to be passed to the drop zone element .
* /
2023-06-27 16:24:19 +02:00
function useDropZone ( {
dropZoneElement ,
isDisabled ,
onDrop : _onDrop ,
onDragStart : _onDragStart ,
onDragEnter : _onDragEnter ,
onDragLeave : _onDragLeave ,
onDragEnd : _onDragEnd ,
onDragOver : _onDragOver
} ) {
2022-04-11 14:04:30 +02:00
const onDropRef = useFreshRef ( _onDrop ) ;
const onDragStartRef = useFreshRef ( _onDragStart ) ;
const onDragEnterRef = useFreshRef ( _onDragEnter ) ;
const onDragLeaveRef = useFreshRef ( _onDragLeave ) ;
const onDragEndRef = useFreshRef ( _onDragEnd ) ;
const onDragOverRef = useFreshRef ( _onDragOver ) ;
2023-06-27 16:24:19 +02:00
return useRefEffect ( elem => {
2022-04-11 14:04:30 +02:00
if ( isDisabled ) {
return ;
2023-09-26 16:23:26 +02:00
}
// If a custom dropZoneRef is passed, use that instead of the element.
2023-06-27 16:24:19 +02:00
// This allows the dropzone to cover an expanded area, rather than
// be restricted to the area of the ref returned by this hook.
const element = dropZoneElement !== null && dropZoneElement !== void 0 ? dropZoneElement : elem ;
2022-04-11 14:04:30 +02:00
let isDragging = false ;
const {
ownerDocument
} = element ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Checks if an element is in the drop zone .
*
* @ param { EventTarget | null } targetToCheck
*
* @ return { boolean } True if in drop zone , false if not .
* /
function isElementInZone ( targetToCheck ) {
const {
defaultView
} = ownerDocument ;
if ( ! targetToCheck || ! defaultView || ! ( targetToCheck instanceof defaultView . HTMLElement ) || ! element . contains ( targetToCheck ) ) {
return false ;
}
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
/** @type {HTMLElement|null} */
2022-04-11 14:04:30 +02:00
let elementToCheck = targetToCheck ;
do {
if ( elementToCheck . dataset . isDropZone ) {
return elementToCheck === element ;
}
} while ( elementToCheck = elementToCheck . parentElement ) ;
return false ;
2021-05-20 14:20:04 +02:00
}
2023-09-26 16:23:26 +02:00
function maybeDragStart ( /** @type {DragEvent} */ event ) {
2022-04-11 14:04:30 +02:00
if ( isDragging ) {
return ;
}
2023-09-26 16:23:26 +02:00
isDragging = true ;
2021-05-20 14:20:04 +02:00
2023-09-26 16:23:26 +02:00
// Note that `dragend` doesn't fire consistently for file and
2022-04-11 14:04:30 +02:00
// HTML drag events where the drag origin is outside the browser
// window. In Firefox it may also not fire if the originating
// node is removed.
ownerDocument . addEventListener ( 'dragend' , maybeDragEnd ) ;
ownerDocument . addEventListener ( 'mousemove' , maybeDragEnd ) ;
if ( onDragStartRef . current ) {
onDragStartRef . current ( event ) ;
2021-05-20 14:20:04 +02:00
}
}
2023-09-26 16:23:26 +02:00
function onDragEnter ( /** @type {DragEvent} */ event ) {
event . preventDefault ( ) ;
2020-06-26 15:33:47 +02:00
2023-09-26 16:23:26 +02:00
// The `dragenter` event will also fire when entering child
2022-04-11 14:04:30 +02:00
// elements, but we only want to call `onDragEnter` when
// entering the drop zone, which means the `relatedTarget`
// (element that has been left) should be outside the drop zone.
2023-09-26 16:23:26 +02:00
if ( element . contains ( /** @type {Node} */ event . relatedTarget ) ) {
2022-04-11 14:04:30 +02:00
return ;
}
if ( onDragEnterRef . current ) {
onDragEnterRef . current ( event ) ;
2021-05-20 14:20:04 +02:00
}
}
2023-09-26 16:23:26 +02:00
function onDragOver ( /** @type {DragEvent} */ event ) {
2022-04-11 14:04:30 +02:00
// Only call onDragOver for the innermost hovered drop zones.
if ( ! event . defaultPrevented && onDragOverRef . current ) {
onDragOverRef . current ( event ) ;
2023-09-26 16:23:26 +02:00
}
2022-04-11 14:04:30 +02:00
2023-09-26 16:23:26 +02:00
// Prevent the browser default while also signalling to parent
// drop zones that `onDragOver` is already handled.
2022-04-11 14:04:30 +02:00
event . preventDefault ( ) ;
2021-05-20 14:20:04 +02:00
}
2023-09-26 16:23:26 +02:00
function onDragLeave ( /** @type {DragEvent} */ event ) {
2022-04-11 14:04:30 +02:00
// The `dragleave` event will also fire when leaving child
// elements, but we only want to call `onDragLeave` when
// leaving the drop zone, which means the `relatedTarget`
// (element that has been entered) should be outside the drop
// zone.
2023-02-07 08:04:52 +01:00
// Note: This is not entirely reliable in Safari due to this bug
// https://bugs.webkit.org/show_bug.cgi?id=66547
2022-04-11 14:04:30 +02:00
if ( isElementInZone ( event . relatedTarget ) ) {
return ;
}
if ( onDragLeaveRef . current ) {
onDragLeaveRef . current ( event ) ;
2021-05-20 14:20:04 +02:00
}
}
2023-09-26 16:23:26 +02:00
function onDrop ( /** @type {DragEvent} */ event ) {
2022-04-11 14:04:30 +02:00
// Don't handle drop if an inner drop zone already handled it.
if ( event . defaultPrevented ) {
return ;
2023-09-26 16:23:26 +02:00
}
2021-05-20 14:20:04 +02:00
2023-09-26 16:23:26 +02:00
// Prevent the browser default while also signalling to parent
// drop zones that `onDrop` is already handled.
event . preventDefault ( ) ;
2021-05-20 14:20:04 +02:00
2023-09-26 16:23:26 +02:00
// This seemingly useless line has been shown to resolve a
2022-04-11 14:04:30 +02:00
// Safari issue where files dragged directly from the dock are
// not recognized.
// eslint-disable-next-line no-unused-expressions
event . dataTransfer && event . dataTransfer . files . length ;
if ( onDropRef . current ) {
onDropRef . current ( event ) ;
}
maybeDragEnd ( event ) ;
2020-07-14 13:39:09 +02:00
}
2023-09-26 16:23:26 +02:00
function maybeDragEnd ( /** @type {MouseEvent} */ event ) {
2022-04-11 14:04:30 +02:00
if ( ! isDragging ) {
return ;
}
isDragging = false ;
ownerDocument . removeEventListener ( 'dragend' , maybeDragEnd ) ;
ownerDocument . removeEventListener ( 'mousemove' , maybeDragEnd ) ;
if ( onDragEndRef . current ) {
onDragEndRef . current ( event ) ;
}
}
element . dataset . isDropZone = 'true' ;
element . addEventListener ( 'drop' , onDrop ) ;
element . addEventListener ( 'dragenter' , onDragEnter ) ;
element . addEventListener ( 'dragover' , onDragOver ) ;
2023-09-26 16:23:26 +02:00
element . addEventListener ( 'dragleave' , onDragLeave ) ;
// The `dragstart` event doesn't fire if the drag started outside
2022-04-11 14:04:30 +02:00
// the document.
ownerDocument . addEventListener ( 'dragenter' , maybeDragStart ) ;
return ( ) => {
delete element . dataset . isDropZone ;
element . removeEventListener ( 'drop' , onDrop ) ;
element . removeEventListener ( 'dragenter' , onDragEnter ) ;
element . removeEventListener ( 'dragover' , onDragOver ) ;
element . removeEventListener ( 'dragleave' , onDragLeave ) ;
ownerDocument . removeEventListener ( 'dragend' , maybeDragEnd ) ;
ownerDocument . removeEventListener ( 'mousemove' , maybeDragEnd ) ;
2023-02-07 08:04:52 +01:00
ownerDocument . removeEventListener ( 'dragenter' , maybeDragStart ) ;
2022-04-11 14:04:30 +02:00
} ;
2023-06-27 16:24:19 +02:00
} , [ isDisabled , dropZoneElement ] // Refresh when the passed in dropZoneElement changes.
) ;
2022-04-11 14:04:30 +02:00
}
2021-05-20 14:20:04 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js
2023-02-07 08:04:52 +01:00
/ * *
* External dependencies
* /
2021-05-20 14:20:04 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Internal dependencies
2021-05-20 14:20:04 +02:00
* /
2020-10-20 15:36:16 +02:00
2023-09-26 16:23:26 +02:00
2020-10-20 15:36:16 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* Dispatches a bubbling focus event when the iframe receives focus . Use
* ` onFocus ` as usual on the iframe or a parent element .
2021-05-20 14:20:04 +02:00
*
2023-02-07 08:04:52 +01:00
* @ return Ref to pass to the iframe .
2020-10-20 15:36:16 +02:00
* /
2022-04-11 14:04:30 +02:00
function useFocusableIframe ( ) {
return useRefEffect ( element => {
const {
ownerDocument
} = element ;
if ( ! ownerDocument ) return ;
const {
defaultView
} = ownerDocument ;
if ( ! defaultView ) return ;
2023-09-26 16:23:26 +02:00
2022-04-11 14:04:30 +02:00
/ * *
* Checks whether the iframe is the activeElement , inferring that it has
* then received focus , and dispatches a focus event .
* /
function checkFocus ( ) {
if ( ownerDocument && ownerDocument . activeElement === element ) {
element . focus ( ) ;
}
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
defaultView . addEventListener ( 'blur' , checkFocus ) ;
return ( ) => {
defaultView . removeEventListener ( 'blur' , checkFocus ) ;
} ;
} , [ ] ) ;
2021-05-20 14:20:04 +02:00
}
2020-10-20 15:36:16 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2023-09-26 16:23:26 +02:00
2023-02-07 08:04:52 +01:00
/ * *
* Internal dependencies
* /
2022-04-11 14:04:30 +02:00
const DEFAULT _INIT _WINDOW _SIZE = 30 ;
2023-09-26 16:23:26 +02:00
2021-05-07 13:48:27 +02:00
/ * *
2022-04-11 14:04:30 +02:00
* @ typedef { Object } WPFixedWindowList
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ property { number } visibleItems Items visible in the current viewport
* @ property { number } start Start index of the window
* @ property { number } end End index of the window
* @ property { ( index : number ) => boolean } itemInView Returns true if item is in the window
2021-05-07 13:48:27 +02:00
* /
/ * *
2022-04-11 14:04:30 +02:00
* @ typedef { Object } WPFixedWindowListOptions
2021-05-20 14:20:04 +02:00
*
2022-04-11 14:04:30 +02:00
* @ property { number } [ windowOverscan ] Renders windowOverscan number of items before and after the calculated visible window .
* @ property { boolean } [ useWindowing ] When false avoids calculating the window size
* @ property { number } [ initWindowSize ] Initial window size to use on first render before we can calculate the window size .
2023-09-26 16:23:26 +02:00
* @ property { any } [ expandedState ] Used to recalculate the window size when the expanded state of a list changes .
2021-05-07 13:48:27 +02:00
* /
/ * *
*
2022-04-11 14:04:30 +02:00
* @ param { import ( 'react' ) . RefObject < HTMLElement > } elementRef Used to find the closest scroll container that contains element .
* @ param { number } itemHeight Fixed item height in pixels
* @ param { number } totalItems Total items in list
* @ param { WPFixedWindowListOptions } [ options ] Options object
* @ return { [ WPFixedWindowList , setFixedListWindow : ( nextWindow : WPFixedWindowList ) => void ] } Array with the fixed window list and setter
2021-05-07 13:48:27 +02:00
* /
2022-04-11 14:04:30 +02:00
function useFixedWindowList ( elementRef , itemHeight , totalItems , options ) {
var _options$initWindowSi , _options$useWindowing ;
2023-06-27 16:24:19 +02:00
const initWindowSize = ( _options$initWindowSi = options ? . initWindowSize ) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT _INIT _WINDOW _SIZE ;
const useWindowing = ( _options$useWindowing = options ? . useWindowing ) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true ;
2022-04-11 14:04:30 +02:00
const [ fixedListWindow , setFixedListWindow ] = ( 0 , external _wp _element _namespaceObject . useState ) ( {
visibleItems : initWindowSize ,
start : 0 ,
end : initWindowSize ,
2023-09-26 16:23:26 +02:00
itemInView : ( /** @type {number} */ index ) => {
2022-04-11 14:04:30 +02:00
return index >= 0 && index <= initWindowSize ;
2021-05-07 13:48:27 +02:00
}
2022-04-11 14:04:30 +02:00
} ) ;
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
if ( ! useWindowing ) {
return ;
2021-05-07 13:48:27 +02:00
}
2022-04-11 14:04:30 +02:00
const scrollContainer = ( 0 , external _wp _dom _namespaceObject . getScrollContainer ) ( elementRef . current ) ;
2023-09-26 16:23:26 +02:00
const measureWindow = ( /** @type {boolean | undefined} */ initRender ) => {
2022-04-11 14:04:30 +02:00
var _options$windowOversc ;
if ( ! scrollContainer ) {
return ;
}
2023-09-26 16:23:26 +02:00
const visibleItems = Math . ceil ( scrollContainer . clientHeight / itemHeight ) ;
// Aim to keep opening list view fast, afterward we can optimize for scrolling.
2023-06-27 16:24:19 +02:00
const windowOverscan = initRender ? visibleItems : ( _options$windowOversc = options ? . windowOverscan ) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems ;
2022-04-11 14:04:30 +02:00
const firstViewableIndex = Math . floor ( scrollContainer . scrollTop / itemHeight ) ;
const start = Math . max ( 0 , firstViewableIndex - windowOverscan ) ;
const end = Math . min ( totalItems - 1 , firstViewableIndex + visibleItems + windowOverscan ) ;
setFixedListWindow ( lastWindow => {
const nextWindow = {
visibleItems ,
start ,
end ,
2023-09-26 16:23:26 +02:00
itemInView : ( /** @type {number} */ index ) => {
2022-04-11 14:04:30 +02:00
return start <= index && index <= end ;
}
} ;
if ( lastWindow . start !== nextWindow . start || lastWindow . end !== nextWindow . end || lastWindow . visibleItems !== nextWindow . visibleItems ) {
return nextWindow ;
2021-05-20 14:20:04 +02:00
}
2022-04-11 14:04:30 +02:00
return lastWindow ;
} ) ;
} ;
measureWindow ( true ) ;
2023-02-07 08:04:52 +01:00
const debounceMeasureList = debounce ( ( ) => {
2022-04-11 14:04:30 +02:00
measureWindow ( ) ;
} , 16 ) ;
2023-06-27 16:24:19 +02:00
scrollContainer ? . addEventListener ( 'scroll' , debounceMeasureList ) ;
scrollContainer ? . ownerDocument ? . defaultView ? . addEventListener ( 'resize' , debounceMeasureList ) ;
scrollContainer ? . ownerDocument ? . defaultView ? . addEventListener ( 'resize' , debounceMeasureList ) ;
2022-04-11 14:04:30 +02:00
return ( ) => {
2023-06-27 16:24:19 +02:00
scrollContainer ? . removeEventListener ( 'scroll' , debounceMeasureList ) ;
scrollContainer ? . ownerDocument ? . defaultView ? . removeEventListener ( 'resize' , debounceMeasureList ) ;
2022-04-11 14:04:30 +02:00
} ;
2023-09-26 16:23:26 +02:00
} , [ itemHeight , elementRef , totalItems , options ? . expandedState , options ? . windowOverscan , useWindowing ] ) ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _element _namespaceObject . useLayoutEffect ) ( ( ) => {
if ( ! useWindowing ) {
return ;
}
const scrollContainer = ( 0 , external _wp _dom _namespaceObject . getScrollContainer ) ( elementRef . current ) ;
2023-09-26 16:23:26 +02:00
const handleKeyDown = ( /** @type {KeyboardEvent} */ event ) => {
2022-04-11 14:04:30 +02:00
switch ( event . keyCode ) {
case external _wp _keycodes _namespaceObject . HOME :
{
2023-06-27 16:24:19 +02:00
return scrollContainer ? . scrollTo ( {
2022-04-11 14:04:30 +02:00
top : 0
} ) ;
}
case external _wp _keycodes _namespaceObject . END :
{
2023-06-27 16:24:19 +02:00
return scrollContainer ? . scrollTo ( {
2022-04-11 14:04:30 +02:00
top : totalItems * itemHeight
} ) ;
}
case external _wp _keycodes _namespaceObject . PAGEUP :
{
2023-06-27 16:24:19 +02:00
return scrollContainer ? . scrollTo ( {
2022-04-11 14:04:30 +02:00
top : scrollContainer . scrollTop - fixedListWindow . visibleItems * itemHeight
} ) ;
}
case external _wp _keycodes _namespaceObject . PAGEDOWN :
{
2023-06-27 16:24:19 +02:00
return scrollContainer ? . scrollTo ( {
2022-04-11 14:04:30 +02:00
top : scrollContainer . scrollTop + fixedListWindow . visibleItems * itemHeight
} ) ;
}
}
} ;
2023-06-27 16:24:19 +02:00
scrollContainer ? . ownerDocument ? . defaultView ? . addEventListener ( 'keydown' , handleKeyDown ) ;
2022-04-11 14:04:30 +02:00
return ( ) => {
2023-06-27 16:24:19 +02:00
scrollContainer ? . ownerDocument ? . defaultView ? . removeEventListener ( 'keydown' , handleKeyDown ) ;
2022-04-11 14:04:30 +02:00
} ;
2023-09-26 16:23:26 +02:00
} , [ totalItems , itemHeight , elementRef , fixedListWindow . visibleItems , useWindowing , options ? . expandedState ] ) ;
2022-04-11 14:04:30 +02:00
return [ fixedListWindow , setFixedListWindow ] ;
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js
2022-09-20 17:43:29 +02:00
// The `createHigherOrderComponent` helper and helper types.
2023-02-07 08:04:52 +01:00
2023-09-26 16:23:26 +02:00
// The `debounce` helper and its types.
// The `throttle` helper and its types.
// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).
2023-02-07 08:04:52 +01:00
2023-09-26 16:23:26 +02:00
// Higher-order components.
2018-12-14 05:41:57 +01:00
2020-01-08 12:57:23 +01:00
2018-12-14 05:41:57 +01:00
2018-12-18 04:14:52 +01:00
2023-09-26 16:23:26 +02:00
// Hooks.
2022-04-11 14:04:30 +02:00
2020-01-22 23:06:21 +01:00
2020-02-06 22:03:31 +01:00
2020-06-26 15:33:47 +02:00
2021-01-28 03:04:13 +01:00
2021-04-15 17:19:43 +02:00
2021-03-05 05:10:44 +01:00
2021-05-07 13:48:27 +02:00
2020-07-14 13:39:09 +02:00
2020-10-20 15:36:16 +02:00
2019-09-19 17:19:18 +02:00
2020-06-26 15:33:47 +02:00
2018-12-14 05:41:57 +01:00
2023-09-21 15:26:32 +02:00
} ( ) ;
2022-04-11 14:04:30 +02:00
( window . wp = window . wp || { } ) . compose = _ _webpack _exports _ _ ;
/******/ } ) ( )
;