2018-12-13 23:41:57 -05:00
this [ "wp" ] = this [ "wp" ] || { } ; this [ "wp" ] [ "compose" ] =
/******/ ( function ( modules ) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/
/******/ // Check if module is in cache
/******/ if ( installedModules [ moduleId ] ) {
/******/ return installedModules [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules [ moduleId ] = {
/******/ i : moduleId ,
/******/ l : false ,
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ modules [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Flag the module as loaded
/******/ module . l = true ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ _ _webpack _require _ _ . m = modules ;
/******/
/******/ // expose the module cache
/******/ _ _webpack _require _ _ . c = installedModules ;
/******/
/******/ // define getter function for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , name , getter ) {
/******/ if ( ! _ _webpack _require _ _ . o ( exports , name ) ) {
/******/ Object . defineProperty ( exports , name , { enumerable : true , get : getter } ) ;
/******/ }
/******/ } ;
/******/
/******/ // define __esModule on exports
/******/ _ _webpack _require _ _ . r = function ( exports ) {
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ _ _webpack _require _ _ . t = function ( value , mode ) {
/******/ if ( mode & 1 ) value = _ _webpack _require _ _ ( value ) ;
/******/ if ( mode & 8 ) return value ;
/******/ if ( ( mode & 4 ) && typeof value === 'object' && value && value . _ _esModule ) return value ;
/******/ var ns = Object . create ( null ) ;
/******/ _ _webpack _require _ _ . r ( ns ) ;
/******/ Object . defineProperty ( ns , 'default' , { enumerable : true , value : value } ) ;
/******/ if ( mode & 2 && typeof value != 'string' ) for ( var key in value ) _ _webpack _require _ _ . d ( ns , key , function ( key ) { return value [ key ] ; } . bind ( null , key ) ) ;
/******/ return ns ;
/******/ } ;
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function getDefault ( ) { return module [ 'default' ] ; } :
/******/ function getModuleExports ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , 'a' , getter ) ;
/******/ return getter ;
/******/ } ;
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ _ _webpack _require _ _ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
/******/
/******/ // __webpack_public_path__
/******/ _ _webpack _require _ _ . p = "" ;
/******/
/******/
/******/ // Load entry module and return exports
2021-05-20 08:20:04 -04:00
/******/ return _ _webpack _require _ _ ( _ _webpack _require _ _ . s = "PD33" ) ;
2018-12-13 23:41:57 -05:00
/******/ } )
/************************************************************************/
/******/ ( {
2021-05-20 08:20:04 -04:00
/***/ "1CF3" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "dom" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "GRId" :
2018-12-17 22:14:52 -05:00
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2021-01-27 21:04:13 -05:00
( function ( ) { module . exports = window [ "wp" ] [ "element" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
/***/ } ) ,
2021-05-20 08:20:04 -04:00
/***/ "NMb1" :
2021-05-07 07:48:27 -04:00
/***/ ( function ( module , exports ) {
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "wp" ] [ "deprecated" ] ; } ( ) ) ;
2021-05-07 07:48:27 -04:00
/***/ } ) ,
2021-05-20 08:20:04 -04:00
/***/ "PD33" :
2020-07-07 10:43:35 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
2021-05-20 08:20:04 -04:00
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "createHigherOrderComponent" , function ( ) { return /* reexport */ create _higher _order _component ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "compose" , function ( ) { return /* reexport */ compose ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "ifCondition" , function ( ) { return /* reexport */ if _condition ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "pure" , function ( ) { return /* reexport */ higher _order _pure ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "withGlobalEvents" , function ( ) { return /* reexport */ withGlobalEvents ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "withInstanceId" , function ( ) { return /* reexport */ with _instance _id ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "withSafeTimeout" , function ( ) { return /* reexport */ with _safe _timeout ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "withState" , function ( ) { return /* reexport */ withState ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useConstrainedTabbing" , function ( ) { return /* reexport */ use _constrained _tabbing ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useCopyOnClick" , function ( ) { return /* reexport */ useCopyOnClick ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useCopyToClipboard" , function ( ) { return /* reexport */ useCopyToClipboard ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__experimentalUseDialog" , function ( ) { return /* reexport */ use _dialog ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__experimentalUseDragging" , function ( ) { return /* reexport */ useDragging ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useFocusOnMount" , function ( ) { return /* reexport */ useFocusOnMount ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__experimentalUseFocusOutside" , function ( ) { return /* reexport */ useFocusOutside ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useFocusReturn" , function ( ) { return /* reexport */ use _focus _return ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useInstanceId" , function ( ) { return /* reexport */ useInstanceId ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useIsomorphicLayoutEffect" , function ( ) { return /* reexport */ use _isomorphic _layout _effect ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useKeyboardShortcut" , function ( ) { return /* reexport */ use _keyboard _shortcut ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useMediaQuery" , function ( ) { return /* reexport */ useMediaQuery ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "usePrevious" , function ( ) { return /* reexport */ usePrevious ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useReducedMotion" , function ( ) { return /* reexport */ use _reduced _motion ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useViewportMatch" , function ( ) { return /* reexport */ use _viewport _match ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useResizeObserver" , function ( ) { return /* reexport */ use _resize _observer ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useAsyncList" , function ( ) { return /* reexport */ use _async _list ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useWarnOnChange" , function ( ) { return /* reexport */ use _warn _on _change ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useDebounce" , function ( ) { return /* reexport */ useDebounce ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useThrottle" , function ( ) { return /* reexport */ useThrottle ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useMergeRefs" , function ( ) { return /* reexport */ useMergeRefs ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useRefEffect" , function ( ) { return /* reexport */ useRefEffect ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__experimentalUseDropZone" , function ( ) { return /* reexport */ useDropZone ; } ) ;
2021-11-08 09:29:21 -05:00
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "useFocusableIframe" , function ( ) { return /* reexport */ useFocusableIframe ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "__experimentalUseFixedWindowList" , function ( ) { return /* reexport */ useFixedWindowList ; } ) ;
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external "lodash"
var external _lodash _ = _ _webpack _require _ _ ( "YLtl" ) ;
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js
/ * *
* External dependencies
* /
// eslint-disable-next-line no-restricted-imports
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Given a function mapping a component to an enhanced component and modifier
* name , returns the enhanced component augmented with a generated displayName .
*
2021-11-08 09:29:21 -05:00
* @ param mapComponentToEnhancedComponent Function mapping component to enhanced component .
* @ param modifierName Seed name from which to generated display name .
2021-05-20 08:20:04 -04:00
*
* @ return Component class with generated display name assigned .
* /
function createHigherOrderComponent ( mapComponent , modifierName ) {
return Inner => {
const Outer = mapComponent ( Inner ) ;
const displayName = Inner . displayName || Inner . name || 'Component' ;
Outer . displayName = ` ${ Object ( external _lodash _ [ "upperFirst" ] ) ( Object ( external _lodash _ [ "camelCase" ] ) ( modifierName ) ) } ( ${ displayName } ) ` ;
return Outer ;
2020-07-07 10:43:35 -04:00
} ;
2020-10-20 09:36:16 -04:00
}
2020-07-07 10:43:35 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var create _higher _order _component = ( createHigherOrderComponent ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js
/ * *
* External dependencies
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04: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-11-08 09:29:21 -05:00
* This is just a re - export of ` lodash ` ' s ` flowRight ` function .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ see https : //docs-lodash.com/v4/flow-right/
2021-05-20 08:20:04 -04:00
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var compose = ( external _lodash _ [ "flowRight" ] ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external ["wp","element"]
var external _wp _element _ = _ _webpack _require _ _ ( "GRId" ) ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-11-08 09:29:21 -05:00
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Higher - order component creator , creating a new component which renders if
* the given condition is satisfied or with the given optional prop name .
*
* @ 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-11-08 09:29:21 -05:00
* @ param predicate Function to test condition .
2021-05-20 08:20:04 -04:00
*
* @ return Higher - order component .
* /
const ifCondition = predicate => create _higher _order _component ( WrappedComponent => props => {
if ( ! predicate ( props ) ) {
return null ;
}
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
return Object ( external _wp _element _ [ "createElement" ] ) ( WrappedComponent , props ) ;
} , 'ifCondition' ) ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var if _condition = ( ifCondition ) ;
2021-02-02 00:17:13 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external ["wp","isShallowEqual"]
var external _wp _isShallowEqual _ = _ _webpack _require _ _ ( "rl8x" ) ;
var external _wp _isShallowEqual _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _isShallowEqual _ ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-01-27 21:04:13 -05:00
2021-11-08 09:29:21 -05:00
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Given a component returns the enhanced component augmented with a component
* only rerendering when its props / state change
2020-06-26 09:33:47 -04:00
* /
2021-05-20 08:20:04 -04:00
const pure = create _higher _order _component ( Wrapped => {
if ( Wrapped . prototype instanceof external _wp _element _ [ "Component" ] ) {
return class extends Wrapped {
shouldComponentUpdate ( nextProps , nextState ) {
return ! external _wp _isShallowEqual _default ( ) ( nextProps , this . props ) || ! external _wp _isShallowEqual _default ( ) ( nextState , this . state ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
return class extends external _wp _element _ [ "Component" ] {
shouldComponentUpdate ( nextProps ) {
return ! external _wp _isShallowEqual _default ( ) ( nextProps , this . props ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
render ( ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( Wrapped , this . props ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} ;
} , 'pure' ) ;
/* harmony default export */ var higher _order _pure = ( pure ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
var esm _extends = _ _webpack _require _ _ ( "wx14" ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external ["wp","deprecated"]
var external _wp _deprecated _ = _ _webpack _require _ _ ( "NMb1" ) ;
var external _wp _deprecated _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _deprecated _ ) ;
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js
/ * *
* External dependencies
* /
2021-03-18 11:54:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* 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 .
2021-03-18 11:54:18 -04:00
* /
2021-05-20 08:20:04 -04:00
class listener _Listener {
constructor ( ) {
2021-11-08 09:29:21 -05:00
/** @type {any} */
2021-05-20 08:20:04 -04:00
this . listeners = { } ;
this . handleEvent = this . handleEvent . bind ( this ) ;
}
2021-03-18 11:54:18 -04:00
2021-11-08 09:29:21 -05:00
add (
/** @type {any} */
eventType ,
/** @type {any} */
instance ) {
2021-05-20 08:20:04 -04: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 ) ;
2021-03-18 11:54:18 -04:00
}
2021-11-08 09:29:21 -05:00
remove (
/** @type {any} */
eventType ,
/** @type {any} */
instance ) {
2021-05-20 08:20:04 -04:00
this . listeners [ eventType ] = Object ( external _lodash _ [ "without" ] ) ( this . listeners [ eventType ] , instance ) ;
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
if ( ! this . listeners [ eventType ] . length ) {
// Removing last listener for this type, so unbind event.
window . removeEventListener ( eventType , this . handleEvent ) ;
delete this . listeners [ eventType ] ;
2020-06-26 09:33:47 -04:00
}
2021-05-20 08:20:04 -04:00
}
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
handleEvent (
/** @type {any} */
event ) {
2021-05-20 08:20:04 -04:00
Object ( external _lodash _ [ "forEach" ] ) ( this . listeners [ event . type ] , instance => {
instance . handleEvent ( event ) ;
} ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var listener = ( listener _Listener ) ;
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js
2021-03-18 11:54:18 -04:00
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* External dependencies
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
/ * *
* Listener instance responsible for managing document event handling .
* /
const with _global _events _listener = new listener ( ) ;
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/no-undefined-types */
2021-05-20 08:20:04 -04: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
*
2021-11-08 09:29:21 -05:00
* @ 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 .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { any } Higher - order component .
2021-05-20 08:20:04 -04:00
* /
function withGlobalEvents ( eventTypesToHandlers ) {
external _wp _deprecated _default ( ) ( 'wp.compose.withGlobalEvents' , {
since : '5.7' ,
alternative : 'useEffect'
} ) ;
return create _higher _order _component ( WrappedComponent => {
class Wrapper extends external _wp _element _ [ "Component" ] {
2021-11-08 09:29:21 -05:00
constructor (
/** @type {any} */
props ) {
super ( props ) ;
2021-05-20 08:20:04 -04:00
this . handleEvent = this . handleEvent . bind ( this ) ;
this . handleRef = this . handleRef . bind ( this ) ;
2021-03-18 11:54:18 -04:00
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
componentDidMount ( ) {
2021-11-08 09:29:21 -05:00
Object ( external _lodash _ [ "forEach" ] ) ( eventTypesToHandlers , ( _ , eventType ) => {
2021-05-20 08:20:04 -04:00
with _global _events _listener . add ( eventType , this ) ;
} ) ;
2021-03-18 11:54:18 -04:00
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
componentWillUnmount ( ) {
2021-11-08 09:29:21 -05:00
Object ( external _lodash _ [ "forEach" ] ) ( eventTypesToHandlers , ( _ , eventType ) => {
2021-05-20 08:20:04 -04:00
with _global _events _listener . remove ( eventType , this ) ;
} ) ;
}
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
handleEvent (
/** @type {any} */
event ) {
const handler = eventTypesToHandlers [
/** @type {keyof GlobalEventHandlersEventMap} */
2021-11-15 07:50:17 -05:00
event . type
/* eslint-enable jsdoc/no-undefined-types */
] ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( typeof this . wrappedRef [ handler ] === 'function' ) {
this . wrappedRef [ handler ] ( event ) ;
}
2021-03-18 11:54:18 -04:00
}
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
handleRef (
/** @type {any} */
el ) {
2021-05-20 08:20:04 -04:00
this . wrappedRef = el ; // Any component using `withGlobalEvents` that is not setting a `ref`
// will cause `this.props.forwardedRef` to be `null`, so we need this
// check.
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( this . props . forwardedRef ) {
this . props . forwardedRef ( el ) ;
}
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
render ( ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( WrappedComponent , Object ( esm _extends [ "a" /* default */ ] ) ( { } , this . props . ownProps , {
ref : this . handleRef
} ) ) ;
2021-03-18 11:54:18 -04:00
}
2020-06-26 09:33:47 -04:00
}
2021-05-20 08:20:04 -04:00
return Object ( external _wp _element _ [ "forwardRef" ] ) ( ( props , ref ) => {
return Object ( external _wp _element _ [ "createElement" ] ) ( Wrapper , {
ownProps : props ,
forwardedRef : ref
} ) ;
} ) ;
} , 'withGlobalEvents' ) ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js
2021-05-21 06:14:23 -04: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 */
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
2021-05-21 06:14:23 -04:00
* @ type { WeakMap < object , number > }
2021-05-20 08:20:04 -04:00
* /
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
const instanceMap = new WeakMap ( ) ;
/ * *
* Creates a new id for a given object .
*
2021-05-21 06:14:23 -04:00
* @ param { object } object Object reference to create an id for .
2021-05-20 08:20:04 -04:00
* @ return { number } The instance id ( index ) .
* /
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
function createId ( object ) {
const instances = instanceMap . get ( object ) || 0 ;
instanceMap . set ( object , instances + 1 ) ;
return instances ;
}
/ * *
* Provides a unique instance ID .
*
2021-11-08 09:29:21 -05:00
* @ param { object } object Object reference to create an id for .
* @ param { string } [ prefix ] Prefix for the unique id .
* @ param { string | number } [ preferredId = '' ] Default ID to use .
2021-05-20 08:20:04 -04:00
* @ return { string | number } The unique instance id .
* /
2020-06-26 09:33:47 -04:00
2021-11-15 07:50:17 -05:00
function useInstanceId ( object , prefix ) {
let preferredId = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : '' ;
2021-05-20 08:20:04 -04:00
return Object ( external _wp _element _ [ "useMemo" ] ) ( ( ) => {
if ( preferredId ) return preferredId ;
const id = createId ( object ) ;
return prefix ? ` ${ prefix } - ${ id } ` : id ;
} , [ object ] ) ;
}
2021-05-21 06:14:23 -04:00
/* eslint-enable jsdoc/check-types */
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js
2020-06-26 09:33:47 -04:00
2021-03-18 11:54:18 -04:00
2021-05-21 06:14:23 -04:00
/ * *
* External dependencies
* /
// eslint-disable-next-line no-restricted-imports
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* A Higher Order Component used to be provide a unique instance ID by
* component .
* /
2021-03-18 11:54:18 -04:00
2021-05-21 06:14:23 -04:00
const withInstanceId = create _higher _order _component ( WrappedComponent => {
2021-05-20 08:20:04 -04:00
return props => {
const instanceId = useInstanceId ( WrappedComponent ) ;
return Object ( external _wp _element _ [ "createElement" ] ) ( WrappedComponent , Object ( esm _extends [ "a" /* default */ ] ) ( { } , props , {
instanceId : instanceId
} ) ) ;
} ;
2021-05-21 06:14:23 -04:00
} , 'withInstanceId' ) ;
/* harmony default export */ var with _instance _id = ( withInstanceId ) ;
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* External dependencies
* /
2021-11-08 09:29:21 -05:00
// eslint-disable-next-line no-restricted-imports
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2020-06-26 09:33:47 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2020-06-26 09:33:47 -04:00
* /
2021-03-18 11:54:18 -04:00
2021-11-08 09:29:21 -05:00
2021-03-18 11:54:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* A higher - order component used to provide and manage delayed function calls
* that ought to be bound to a component ' s lifecycle .
2021-03-18 11:54:18 -04:00
* /
2021-05-20 08:20:04 -04:00
const withSafeTimeout = create _higher _order _component ( OriginalComponent => {
return class WrappedComponent extends external _wp _element _ [ "Component" ] {
2021-11-08 09:29:21 -05:00
constructor ( props ) {
super ( props ) ;
2021-05-20 08:20:04 -04:00
this . timeouts = [ ] ;
this . setTimeout = this . setTimeout . bind ( this ) ;
this . clearTimeout = this . clearTimeout . bind ( this ) ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
componentWillUnmount ( ) {
this . timeouts . forEach ( clearTimeout ) ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
setTimeout ( fn , delay ) {
const id = setTimeout ( ( ) => {
fn ( ) ;
this . clearTimeout ( id ) ;
} , delay ) ;
this . timeouts . push ( id ) ;
return id ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
clearTimeout ( id ) {
clearTimeout ( id ) ;
this . timeouts = Object ( external _lodash _ [ "without" ] ) ( this . timeouts , id ) ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
render ( ) {
2021-11-08 09:29:21 -05:00
const props = { ... this . props ,
2021-05-20 08:20:04 -04:00
setTimeout : this . setTimeout ,
clearTimeout : this . clearTimeout
2021-11-08 09:29:21 -05:00
} ;
return Object ( external _wp _element _ [ "createElement" ] ) ( OriginalComponent , props ) ;
2021-05-20 08:20:04 -04:00
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} ;
} , 'withSafeTimeout' ) ;
/* harmony default export */ var with _safe _timeout = ( withSafeTimeout ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2021-03-18 11:54:18 -04:00
2021-11-08 09:29:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* A Higher Order Component used to provide and manage internal component state
* via props .
*
2021-11-08 09:29:21 -05:00
* @ deprecated Use ` useState ` instead .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ 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 .
2021-05-20 08:20:04 -04:00
* /
2021-03-18 11:54:18 -04:00
2021-11-15 07:50:17 -05:00
function withState ( ) {
let initialState = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
2021-11-08 09:29:21 -05:00
external _wp _deprecated _default ( ) ( 'wp.compose.withState' , {
alternative : 'wp.element.useState'
} ) ;
2021-05-20 08:20:04 -04:00
return create _higher _order _component ( OriginalComponent => {
return class WrappedComponent extends external _wp _element _ [ "Component" ] {
2021-11-08 09:29:21 -05:00
constructor (
/** @type {any} */
props ) {
super ( props ) ;
2021-05-20 08:20:04 -04:00
this . setState = this . setState . bind ( this ) ;
this . state = initialState ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
render ( ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( OriginalComponent , Object ( esm _extends [ "a" /* default */ ] ) ( { } , this . props , this . state , {
setState : this . setState
} ) ) ;
2021-03-18 11:54:18 -04:00
}
2021-05-20 08:20:04 -04:00
} ;
} , 'withState' ) ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external ["wp","keycodes"]
var external _wp _keycodes _ = _ _webpack _require _ _ ( "RxS6" ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external ["wp","dom"]
var external _wp _dom _ = _ _webpack _require _ _ ( "1CF3" ) ;
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js
/ * *
* External dependencies
* /
// eslint-disable-next-line no-restricted-imports
/ * *
* WordPress dependencies
* /
/ * *
* 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 .
*
* @ param callback Callback with ref as argument .
* @ param dependencies Dependencies of the callback .
*
* @ return Ref callback .
* /
function useRefEffect ( callback , dependencies ) {
const cleanup = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
return Object ( external _wp _element _ [ "useCallback" ] ) ( node => {
if ( node ) {
cleanup . current = callback ( node ) ;
} else if ( cleanup . current ) {
cleanup . current ( ) ;
}
} , dependencies ) ;
}
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js
/ * *
* WordPress dependencies
* /
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
/ * *
* Internal dependencies
* /
2021-05-20 08:20:04 -04: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 .
*
2021-11-08 09:29:21 -05:00
* @ return { import ( 'react' ) . RefCallback < Element > } Element Ref .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { useConstrainedTabbing } from '@wordpress/compose' ;
*
* const ConstrainedTabbingExample = ( ) => {
* const constrainedTabbingRef = useConstrainedTabbing ( )
* return (
* < div ref = { constrainedTabbingRef } >
* < Button / >
* < Button / >
* < / d i v >
* ) ;
* }
* ` ` `
* /
function useConstrainedTabbing ( ) {
2021-11-15 07:50:17 -05:00
return useRefEffect ( (
2021-11-08 09:29:21 -05:00
/** @type {HTMLElement} */
2021-11-15 07:50:17 -05:00
node ) => {
2021-11-08 09:29:21 -05:00
/** @type {number|undefined} */
let timeoutId ;
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
function onKeyDown (
/** @type {KeyboardEvent} */
event ) {
const {
keyCode ,
shiftKey ,
target
} = event ;
2021-05-21 06:14:23 -04:00
2021-11-08 09:29:21 -05:00
if ( keyCode !== external _wp _keycodes _ [ "TAB" ] ) {
2021-05-20 08:20:04 -04:00
return ;
}
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
const action = shiftKey ? 'findPrevious' : 'findNext' ;
const nextElement = external _wp _dom _ [ "focus" ] . tabbable [ action ] (
/** @type {HTMLElement} */
target ) || null ; // If the element that is about to receive focus is outside the
// 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.
2021-05-20 08:20:04 -04:00
2021-11-08 09:29:21 -05:00
if ( node . contains ( nextElement ) ) {
2021-05-20 08:20:04 -04:00
return ;
2021-03-18 11:54:18 -04:00
}
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
const domAction = shiftKey ? 'append' : 'prepend' ;
const {
ownerDocument
} = node ;
const trap = ownerDocument . createElement ( 'div' ) ;
trap . tabIndex = - 1 ;
node [ domAction ] ( trap ) ;
trap . focus ( ) ; // Remove after the browser moves focus to the next element.
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
timeoutId = setTimeout ( ( ) => node . removeChild ( trap ) ) ;
}
2021-05-21 06:14:23 -04:00
2021-11-08 09:29:21 -05:00
node . addEventListener ( 'keydown' , onKeyDown ) ;
return ( ) => {
node . removeEventListener ( 'keydown' , onKeyDown ) ;
clearTimeout ( timeoutId ) ;
} ;
2021-05-20 08:20:04 -04:00
} , [ ] ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _constrained _tabbing = ( useConstrainedTabbing ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js
var dist _clipboard = _ _webpack _require _ _ ( "sxGJ" ) ;
var clipboard _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( dist _clipboard ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js
/ * *
* External dependencies
* /
2020-06-26 09:33:47 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
2020-06-26 09:33:47 -04:00
* /
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
2020-06-26 09:33:47 -04:00
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/no-undefined-types */
2020-06-26 09:33:47 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Copies the text to the clipboard when the element is clicked .
2020-06-26 09:33:47 -04:00
*
2021-05-20 08:20:04 -04:00
* @ deprecated
*
2021-11-08 09:29:21 -05:00
* @ 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 .
2021-05-20 08:20:04 -04:00
*
* @ return { boolean } Whether or not the text has been copied . Resets after the
* timeout .
2020-06-26 09:33:47 -04:00
* /
2021-11-15 07:50:17 -05:00
function useCopyOnClick ( ref , text ) {
let timeout = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 4000 ;
2021-11-08 09:29:21 -05:00
/* eslint-enable jsdoc/no-undefined-types */
2021-05-20 08:20:04 -04:00
external _wp _deprecated _default ( ) ( 'wp.compose.useCopyOnClick' , {
since : '10.3' ,
plugin : 'Gutenberg' ,
alternative : 'wp.compose.useCopyToClipboard'
} ) ;
2021-11-08 09:29:21 -05:00
/** @type {import('react').MutableRefObject<Clipboard | undefined>} */
2021-05-20 08:20:04 -04:00
const clipboard = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
const [ hasCopied , setHasCopied ] = Object ( external _wp _element _ [ "useState" ] ) ( false ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
2021-11-08 09:29:21 -05:00
/** @type {number | undefined} */
let timeoutId ;
if ( ! ref . current ) {
return ;
} // Clipboard listens to click events.
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
clipboard . current = new clipboard _default . a ( ref . current , {
text : ( ) => typeof text === 'function' ? text ( ) : text
} ) ;
2021-11-15 07:50:17 -05:00
clipboard . current . on ( 'success' , _ref => {
let {
clearSelection ,
trigger
} = _ref ;
2021-05-20 08:20:04 -04: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.
clearSelection ( ) ; // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( trigger ) {
2021-11-08 09:29:21 -05:00
/** @type {HTMLElement} */
2021-05-20 08:20:04 -04:00
trigger . focus ( ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( timeout ) {
setHasCopied ( true ) ;
clearTimeout ( timeoutId ) ;
timeoutId = setTimeout ( ( ) => setHasCopied ( false ) , timeout ) ;
}
} ) ;
return ( ) => {
2021-11-08 09:29:21 -05:00
if ( clipboard . current ) {
clipboard . current . destroy ( ) ;
}
2021-05-20 08:20:04 -04:00
clearTimeout ( timeoutId ) ;
} ;
} , [ text , timeout , setHasCopied ] ) ;
return hasCopied ;
}
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js
2020-06-26 09:33:47 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* External dependencies
2020-06-26 09:33:47 -04:00
* /
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
2020-06-26 09:33:47 -04:00
* /
/ * *
2021-05-20 08:20:04 -04:00
* Internal dependencies
2020-06-26 09:33:47 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
/ * *
* @ template T
* @ param { T } value
* @ return { import ( 'react' ) . RefObject < T > } The updated ref
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
function useUpdatedRef ( value ) {
const ref = Object ( external _wp _element _ [ "useRef" ] ) ( value ) ;
ref . current = value ;
return ref ;
}
2021-03-18 11:54:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Copies the given text to the clipboard when the element is clicked .
2021-03-18 11:54:18 -04:00
*
2021-11-08 09:29:21 -05: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 .
2021-03-18 11:54:18 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { import ( 'react' ) . Ref < TElementType > } A ref to assign to the target element .
2021-03-18 11:54:18 -04:00
* /
2019-09-19 11:19:18 -04:00
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
function useCopyToClipboard ( text , onSuccess ) {
// Store the dependencies as refs and continuesly update them so they're
// fresh when the callback is called.
const textRef = useUpdatedRef ( text ) ;
2021-11-08 09:29:21 -05:00
const onSuccessRef = useUpdatedRef ( onSuccess ) ;
2021-05-20 08:20:04 -04:00
return useRefEffect ( node => {
// Clipboard listens to click events.
const clipboard = new clipboard _default . a ( node , {
text ( ) {
2021-11-08 09:29:21 -05:00
return typeof textRef . current === 'function' ? textRef . current ( ) : textRef . current || '' ;
2021-05-20 08:20:04 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
} ) ;
2021-11-15 07:50:17 -05:00
clipboard . on ( 'success' , _ref => {
let {
clearSelection
} = _ref ;
2021-05-20 08:20:04 -04: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.
clearSelection ( ) ; // Handle ClipboardJS focus bug, see
// https://github.com/zenorocha/clipboard.js/issues/680
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
node . focus ( ) ;
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
if ( onSuccessRef . current ) {
onSuccessRef . current ( ) ;
2021-05-20 08:20:04 -04:00
}
} ) ;
return ( ) => {
clipboard . destroy ( ) ;
} ;
} , [ ] ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js
2021-03-18 11:54:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
* /
/ * *
* Hook used to focus the first tabbable element on mount .
2021-03-18 11:54:18 -04:00
*
2021-11-08 09:29:21 -05:00
* @ param { boolean | 'firstElement' } focusOnMount Focus on mount mode .
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Ref callback .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { useFocusOnMount } from '@wordpress/compose' ;
*
* const WithFocusOnMount = ( ) => {
* const ref = useFocusOnMount ( )
* return (
* < div ref = { ref } >
* < Button / >
* < Button / >
* < / d i v >
* ) ;
* }
* ` ` `
2021-03-18 11:54:18 -04:00
* /
2018-12-13 23:41:57 -05:00
2021-11-15 07:50:17 -05:00
function useFocusOnMount ( ) {
let focusOnMount = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : 'firstElement' ;
2021-05-20 08:20:04 -04:00
const focusOnMountRef = Object ( external _wp _element _ [ "useRef" ] ) ( focusOnMount ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
focusOnMountRef . current = focusOnMount ;
} , [ focusOnMount ] ) ;
return Object ( external _wp _element _ [ "useCallback" ] ) ( node => {
2021-11-08 09:29:21 -05:00
var _node$ownerDocument$a , _node$ownerDocument ;
2021-05-20 08:20:04 -04:00
if ( ! node || focusOnMountRef . current === false ) {
return ;
2021-03-18 11:54:18 -04:00
}
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
if ( node . contains ( ( _node$ownerDocument$a = ( _node$ownerDocument = node . ownerDocument ) === null || _node$ownerDocument === void 0 ? void 0 : _node$ownerDocument . activeElement ) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null ) ) {
2021-05-20 08:20:04 -04:00
return ;
2021-03-18 11:54:18 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
let target = node ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( focusOnMountRef . current === 'firstElement' ) {
const firstTabbable = external _wp _dom _ [ "focus" ] . tabbable . find ( node ) [ 0 ] ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( firstTabbable ) {
2021-11-08 09:29:21 -05:00
target =
/** @type {HTMLElement} */
firstTabbable ;
2021-05-20 08:20:04 -04:00
}
2021-03-18 11:54:18 -04:00
}
2021-05-20 08:20:04 -04:00
target . focus ( ) ;
} , [ ] ) ;
2021-03-18 11:54:18 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js
2021-03-18 11:54:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* WordPress dependencies
2021-03-18 11:54:18 -04:00
* /
2018-12-13 23:41:57 -05:00
2020-06-26 09:33:47 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* When opening modals / sidebars / dialogs , the focus
* must move to the opened area and return to the
* previously focused element when closed .
* The current hook implements the returning behavior .
2021-03-18 11:54:18 -04:00
*
2021-11-08 09:29:21 -05:00
* @ param { ( ) => void } [ onFocusReturn ] Overrides the default return behavior .
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Element Ref .
2021-05-20 08:20:04 -04:00
*
* @ example
* ` ` ` js
* import { useFocusReturn } from '@wordpress/compose' ;
*
* const WithFocusReturn = ( ) => {
* const ref = useFocusReturn ( )
* return (
* < div ref = { ref } >
* < Button / >
* < Button / >
* < / d i v >
* ) ;
* }
* ` ` `
2020-06-26 09:33:47 -04:00
* /
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
function useFocusReturn ( onFocusReturn ) {
2021-11-08 09:29:21 -05:00
/** @type {import('react').MutableRefObject<null | HTMLElement>} */
const ref = Object ( external _wp _element _ [ "useRef" ] ) ( null ) ;
/** @type {import('react').MutableRefObject<null | Element>} */
const focusedBeforeMount = Object ( external _wp _element _ [ "useRef" ] ) ( null ) ;
2021-05-20 08:20:04 -04:00
const onFocusReturnRef = Object ( external _wp _element _ [ "useRef" ] ) ( onFocusReturn ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
onFocusReturnRef . current = onFocusReturn ;
} , [ onFocusReturn ] ) ;
return Object ( external _wp _element _ [ "useCallback" ] ) ( node => {
if ( node ) {
// Set ref to be used when unmounting.
ref . current = node ; // Only set when the node mounts.
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( focusedBeforeMount . current ) {
return ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
focusedBeforeMount . current = node . ownerDocument . activeElement ;
} else if ( focusedBeforeMount . current ) {
2021-11-08 09:29:21 -05:00
var _ref$current , _ref$current2 , _ref$current3 ;
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
const isFocused = ( _ref$current = ref . current ) === null || _ref$current === void 0 ? void 0 : _ref$current . contains ( ( _ref$current2 = ref . current ) === null || _ref$current2 === void 0 ? void 0 : _ref$current2 . ownerDocument . activeElement ) ;
if ( ( _ref$current3 = ref . current ) !== null && _ref$current3 !== void 0 && _ref$current3 . isConnected && ! isFocused ) {
2021-05-20 08:20:04 -04:00
return ;
} // Defer to the component's own explicit focus return behavior, if
// specified. This allows for support that the `onFocusReturn`
// decides to allow the default behavior to occur under some
// conditions.
2018-12-13 23:41:57 -05:00
2019-10-15 12:17:12 -04:00
2021-05-20 08:20:04 -04:00
if ( onFocusReturnRef . current ) {
onFocusReturnRef . current ( ) ;
} else {
2021-11-08 09:29:21 -05:00
var _focusedBeforeMount$c ;
/** @type {null | HTMLElement} */
( _focusedBeforeMount$c = focusedBeforeMount . current ) === null || _focusedBeforeMount$c === void 0 ? void 0 : _focusedBeforeMount$c . focus ( ) ;
2021-05-20 08:20:04 -04:00
}
2021-03-18 11:54:18 -04:00
}
2021-05-20 08:20:04 -04:00
} , [ ] ) ;
}
2019-10-15 12:17:12 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _focus _return = ( useFocusReturn ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js
/ * *
* External dependencies
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2020-03-23 19:40:19 -04:00
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Input types which are classified as button types , for use in considering
* whether element is a ( focus - normalized ) button .
*
* @ type { string [ ] }
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
const INPUT _BUTTON _TYPES = [ 'button' , 'submit' ] ;
/ * *
* @ typedef { HTMLButtonElement | HTMLLinkElement | HTMLInputElement } FocusNormalizedButton
* /
// Disable reason: Rule doesn't support predicate return types
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
/* eslint-disable jsdoc/valid-types */
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04: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
*
* @ param { EventTarget } eventTarget The target from a mouse or touch event .
*
* @ return { eventTarget is FocusNormalizedButton } Whether element is a button .
* /
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
function isFocusNormalizedButton ( eventTarget ) {
if ( ! ( eventTarget instanceof window . HTMLElement ) ) {
return false ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
switch ( eventTarget . nodeName ) {
case 'A' :
case 'BUTTON' :
return true ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
case 'INPUT' :
return Object ( external _lodash _ [ "includes" ] ) ( INPUT _BUTTON _TYPES ,
/** @type {HTMLInputElement} */
eventTarget . type ) ;
}
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
return false ;
2021-03-18 11:54:18 -04:00
}
2021-05-20 08:20:04 -04:00
/* eslint-enable jsdoc/valid-types */
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* @ typedef { import ( 'react' ) . SyntheticEvent } SyntheticEvent
* /
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* @ callback EventCallback
* @ param { SyntheticEvent } event input related event .
* /
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* @ typedef FocusOutsideReactElement
* @ property { EventCallback } handleFocusOutside callback for a focus outside event .
* /
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* @ typedef { import ( 'react' ) . MutableRefObject < FocusOutsideReactElement | undefined > } FocusOutsideRef
* /
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* @ typedef { Object } FocusOutsideReturnValue
* @ property { EventCallback } onFocus An event handler for focus events .
* @ property { EventCallback } onBlur An event handler for blur events .
* @ property { EventCallback } onMouseDown An event handler for mouse down events .
* @ property { EventCallback } onMouseUp An event handler for mouse up events .
* @ property { EventCallback } onTouchStart An event handler for touch start events .
* @ property { EventCallback } onTouchEnd An event handler for touch end events .
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* A react hook that can be used to check whether focus has moved outside the
* element the event handlers are bound to .
*
2021-11-08 09:29:21 -05:00
* @ param { EventCallback } onFocusOutside A callback triggered when focus moves outside
* the element the event handlers are bound to .
2021-05-20 08:20:04 -04:00
*
* @ return { FocusOutsideReturnValue } An object containing event handlers . Bind the event handlers
* to a wrapping element element to capture when focus moves
* outside that element .
* /
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
function useFocusOutside ( onFocusOutside ) {
const currentOnFocusOutside = Object ( external _wp _element _ [ "useRef" ] ) ( onFocusOutside ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
currentOnFocusOutside . current = onFocusOutside ;
} , [ onFocusOutside ] ) ;
const preventBlurCheck = Object ( external _wp _element _ [ "useRef" ] ) ( false ) ;
/ * *
* @ type { import ( 'react' ) . MutableRefObject < number | undefined > }
* /
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
const blurCheckTimeoutId = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
/ * *
* Cancel a blur check timeout .
* /
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
const cancelBlurCheck = Object ( external _wp _element _ [ "useCallback" ] ) ( ( ) => {
clearTimeout ( blurCheckTimeoutId . current ) ;
} , [ ] ) ; // Cancel blur checks on unmount.
2020-03-23 19:40:19 -04:00
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
return ( ) => cancelBlurCheck ( ) ;
} , [ ] ) ; // Cancel a blur check if the callback or ref is no longer provided.
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
if ( ! onFocusOutside ) {
cancelBlurCheck ( ) ;
}
} , [ onFocusOutside , cancelBlurCheck ] ) ;
/ * *
* 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 .
*
* @ see https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
*
* @ param { SyntheticEvent } event Event for mousedown or mouseup .
* /
2021-03-18 11:54:18 -04:00
2021-05-20 08:20:04 -04:00
const normalizeButtonFocus = Object ( external _wp _element _ [ "useCallback" ] ) ( event => {
const {
type ,
target
} = event ;
const isInteractionEnd = Object ( external _lodash _ [ "includes" ] ) ( [ 'mouseup' , 'touchend' ] , type ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( isInteractionEnd ) {
preventBlurCheck . current = false ;
} else if ( isFocusNormalizedButton ( target ) ) {
preventBlurCheck . current = true ;
2020-01-22 17:06:21 -05:00
}
2021-05-20 08:20:04 -04: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 .
*
* @ param { SyntheticEvent } event Blur event .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const queueBlurCheck = Object ( external _wp _element _ [ "useCallback" ] ) ( event => {
// React does not allow using an event reference asynchronously
// due to recycling behavior, except when explicitly persisted.
event . persist ( ) ; // Skip blur check if clicking button. See `normalizeButtonFocus`.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( preventBlurCheck . current ) {
return ;
2020-01-22 17:06:21 -05:00
}
2021-05-20 08:20:04 -04: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 ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( 'function' === typeof currentOnFocusOutside . current ) {
currentOnFocusOutside . current ( event ) ;
}
} , 0 ) ;
} , [ ] ) ;
return {
onFocus : cancelBlurCheck ,
onMouseDown : normalizeButtonFocus ,
onMouseUp : normalizeButtonFocus ,
onTouchStart : normalizeButtonFocus ,
onTouchEnd : normalizeButtonFocus ,
onBlur : queueBlurCheck
} ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/valid-types */
/ * *
* @ template T
* @ typedef { T extends import ( 'react' ) . Ref < infer R > ? R : never } TypeFromRef
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
/* eslint-enable jsdoc/valid-types */
/ * *
* @ template T
* @ param { import ( 'react' ) . Ref < T > } ref
* @ param { T } value
* /
2020-01-22 17:06:21 -05:00
2021-05-21 06:14:23 -04:00
function assignRef ( ref , value ) {
if ( typeof ref === 'function' ) {
ref ( value ) ;
} else if ( ref && ref . hasOwnProperty ( 'current' ) ) {
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/no-undefined-types */
/** @type {import('react').MutableRefObject<T>} */
2021-05-21 06:14:23 -04:00
ref . current = value ;
2021-11-08 09:29:21 -05:00
/* eslint-enable jsdoc/no-undefined-types */
2021-05-21 06:14:23 -04:00
}
}
2021-05-20 08:20:04 -04:00
/ * *
2021-11-08 09:29:21 -05: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 .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* As expected , if you pass a new function on every render , the ref callback
* will be called after every render .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* 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 .
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-21 06:14:23 -04:00
2021-05-20 08:20:04 -04:00
function useMergeRefs ( refs ) {
2021-05-21 06:14:23 -04:00
const element = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
2021-05-20 08:20:04 -04:00
const didElementChange = Object ( external _wp _element _ [ "useRef" ] ) ( false ) ;
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/no-undefined-types */
/** @type {import('react').MutableRefObject<TRef[]>} */
/* eslint-enable jsdoc/no-undefined-types */
2021-05-21 06:14:23 -04:00
const previousRefs = Object ( external _wp _element _ [ "useRef" ] ) ( [ ] ) ;
2021-05-20 08:20:04 -04:00
const currentRefs = Object ( external _wp _element _ [ "useRef" ] ) ( refs ) ; // Update on render before the ref callback is called, so the ref callback
// always has access to the current refs.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
currentRefs . current = refs ; // If any of the refs change, call the previous ref with `null` and the new
// ref with the node, except when the element changes in the same cycle, in
// which case the ref callbacks will already have been called.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useLayoutEffect" ] ) ( ( ) => {
2021-05-21 06:14:23 -04:00
if ( didElementChange . current === false ) {
refs . forEach ( ( ref , index ) => {
const previousRef = previousRefs . current [ index ] ;
if ( ref !== previousRef ) {
assignRef ( previousRef , null ) ;
assignRef ( ref , element . current ) ;
}
} ) ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
previousRefs . current = refs ;
} , refs ) ; // No dependencies, must be reset after every render so ref callbacks are
// correctly called after a ref change.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useLayoutEffect" ] ) ( ( ) => {
didElementChange . current = false ;
} ) ; // There should be no dependencies so that `callback` is only called when
// the node changes.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
return Object ( external _wp _element _ [ "useCallback" ] ) ( value => {
// Update the element so it can be used when calling ref callbacks on a
// dependency change.
2021-05-21 06:14:23 -04:00
assignRef ( element , value ) ;
2021-05-20 08:20:04 -04:00
didElementChange . current = true ; // When an element changes, the current ref callback should be called
// with the new element and the previous one with `null`.
2020-01-22 17:06:21 -05:00
2021-05-21 06:14:23 -04:00
const refsToAssign = value ? currentRefs . current : previousRefs . current ; // Update the latest refs.
2020-01-22 17:06:21 -05:00
2021-05-21 06:14:23 -04:00
for ( const ref of refsToAssign ) {
assignRef ( ref , value ) ;
}
2021-05-20 08:20:04 -04:00
} , [ ] ) ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/valid-types */
/ * *
* @ typedef DialogOptions
* @ property { Parameters < useFocusOnMount > [ 0 ] } focusOnMount Focus on mount arguments .
* @ property { ( ) => void } onClose Function to call when the dialog is closed .
* /
/* eslint-enable jsdoc/valid-types */
2021-05-20 08:20:04 -04: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 .
*
2021-11-08 09:29:21 -05:00
* @ param { DialogOptions } options Dialog Options .
2021-05-20 08:20:04 -04:00
* /
function useDialog ( options ) {
2021-11-08 09:29:21 -05:00
/ * *
* @ type { import ( 'react' ) . MutableRefObject < DialogOptions | undefined > }
* /
const currentOptions = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
2021-11-08 09:29:21 -05:00
currentOptions . current = options ;
} , Object . values ( options ) ) ;
2021-05-20 08:20:04 -04:00
const constrainedTabbingRef = use _constrained _tabbing ( ) ;
2021-11-08 09:29:21 -05:00
const focusOnMountRef = useFocusOnMount ( options . focusOnMount ) ;
2021-05-20 08:20:04 -04:00
const focusReturnRef = use _focus _return ( ) ;
2021-11-08 09:29:21 -05:00
const focusOutsideProps = useFocusOutside ( event => {
var _currentOptions$curre , _currentOptions$curre2 ;
// This unstable prop is here only to manage backward compatibility
// for the Popover component otherwise, the onClose should be enough.
// @ts-ignore unstable property
if ( ( _currentOptions$curre = currentOptions . current ) !== null && _currentOptions$curre !== void 0 && _currentOptions$curre . _ _unstableOnClose ) {
// @ts-ignore unstable property
currentOptions . current . _ _unstableOnClose ( 'focus-outside' , event ) ;
} else if ( ( _currentOptions$curre2 = currentOptions . current ) !== null && _currentOptions$curre2 !== void 0 && _currentOptions$curre2 . onClose ) {
currentOptions . current . onClose ( ) ;
}
} ) ;
2021-05-20 08:20:04 -04:00
const closeOnEscapeRef = Object ( external _wp _element _ [ "useCallback" ] ) ( node => {
if ( ! node ) {
return ;
}
2021-11-15 07:50:17 -05:00
node . addEventListener ( 'keydown' , (
2021-11-08 09:29:21 -05:00
/** @type {KeyboardEvent} */
2021-11-15 07:50:17 -05:00
event ) => {
2021-11-08 09:29:21 -05:00
var _currentOptions$curre3 ;
2021-05-20 08:20:04 -04:00
// Close on escape
2021-11-08 09:29:21 -05:00
if ( event . keyCode === external _wp _keycodes _ [ "ESCAPE" ] && ! event . defaultPrevented && ( _currentOptions$curre3 = currentOptions . current ) !== null && _currentOptions$curre3 !== void 0 && _currentOptions$curre3 . onClose ) {
event . preventDefault ( ) ;
currentOptions . current . onClose ( ) ;
2021-05-20 08:20:04 -04:00
}
} ) ;
} , [ ] ) ;
2021-11-08 09:29:21 -05:00
return [ useMergeRefs ( [ options . focusOnMount !== false ? constrainedTabbingRef : null , options . focusOnMount !== false ? focusReturnRef : null , options . focusOnMount !== false ? focusOnMountRef : null , closeOnEscapeRef ] ) , { ... focusOutsideProps ,
2021-05-20 08:20:04 -04:00
tabIndex : '-1'
} ] ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _dialog = ( useDialog ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04: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 .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external _wp _element _ [ "useLayoutEffect" ] : external _wp _element _ [ "useEffect" ] ;
/* harmony default export */ var use _isomorphic _layout _effect = ( useIsomorphicLayoutEffect ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
/ * *
* @ param { Object } props
* @ param { ( e : MouseEvent ) => void } props . onDragStart
* @ param { ( e : MouseEvent ) => void } props . onDragMove
* @ param { ( e : MouseEvent ) => void } props . onDragEnd
* /
2021-11-15 07:50:17 -05:00
function useDragging ( _ref ) {
let {
onDragStart ,
onDragMove ,
onDragEnd
} = _ref ;
2021-05-20 08:20:04 -04:00
const [ isDragging , setIsDragging ] = Object ( external _wp _element _ [ "useState" ] ) ( false ) ;
const eventsRef = Object ( external _wp _element _ [ "useRef" ] ) ( {
onDragStart ,
onDragMove ,
onDragEnd
} ) ;
use _isomorphic _layout _effect ( ( ) => {
eventsRef . current . onDragStart = onDragStart ;
eventsRef . current . onDragMove = onDragMove ;
eventsRef . current . onDragEnd = onDragEnd ;
} , [ onDragStart , onDragMove , onDragEnd ] ) ;
2021-11-15 07:50:17 -05:00
const onMouseMove = Object ( external _wp _element _ [ "useCallback" ] ) ( (
2021-11-08 09:29:21 -05:00
/** @type {MouseEvent} */
2021-11-15 07:50:17 -05:00
event ) => eventsRef . current . onDragMove && eventsRef . current . onDragMove ( event ) , [ ] ) ;
const endDrag = Object ( external _wp _element _ [ "useCallback" ] ) ( (
2021-11-08 09:29:21 -05:00
/** @type {MouseEvent} */
2021-11-15 07:50:17 -05:00
event ) => {
2021-05-20 08:20:04 -04:00
if ( eventsRef . current . onDragEnd ) {
2021-11-08 09:29:21 -05:00
eventsRef . current . onDragEnd ( event ) ;
2021-05-20 08:20:04 -04:00
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
document . removeEventListener ( 'mousemove' , onMouseMove ) ;
document . removeEventListener ( 'mouseup' , endDrag ) ;
setIsDragging ( false ) ;
} , [ ] ) ;
2021-11-15 07:50:17 -05:00
const startDrag = Object ( external _wp _element _ [ "useCallback" ] ) ( (
2021-11-08 09:29:21 -05:00
/** @type {MouseEvent} */
2021-11-15 07:50:17 -05:00
event ) => {
2021-05-20 08:20:04 -04:00
if ( eventsRef . current . onDragStart ) {
2021-11-08 09:29:21 -05:00
eventsRef . current . onDragStart ( event ) ;
2020-01-22 17:06:21 -05:00
}
2021-05-20 08:20:04 -04:00
document . addEventListener ( 'mousemove' , onMouseMove ) ;
document . addEventListener ( 'mouseup' , endDrag ) ;
setIsDragging ( true ) ;
} , [ ] ) ; // Remove the global events when unmounting if needed.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
return ( ) => {
if ( isDragging ) {
document . removeEventListener ( 'mousemove' , onMouseMove ) ;
document . removeEventListener ( 'mouseup' , endDrag ) ;
}
} ;
} , [ isDragging ] ) ;
return {
startDrag ,
endDrag ,
isDragging
} ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js
var mousetrap _mousetrap = _ _webpack _require _ _ ( "imBb" ) ;
var mousetrap _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( mousetrap _mousetrap ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
var mousetrap _global _bind = _ _webpack _require _ _ ( "VcSt" ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js
/ * *
* External dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* A block selection object .
*
* @ typedef { Object } WPKeyboardShortcutConfig
*
2021-11-08 09:29:21 -05:00
* @ 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-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Return true if platform is MacOS .
*
2021-11-08 09:29:21 -05:00
* @ param { Window } [ _window ] window object by default ; used for DI testing .
2021-05-20 08:20:04 -04:00
*
* @ return { boolean } True if MacOS ; false otherwise .
* /
2020-01-22 17:06:21 -05:00
2021-11-15 07:50:17 -05:00
function isAppleOS ( ) {
let _window = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : window ;
2021-05-20 08:20:04 -04:00
const {
platform
} = _window . navigator ;
return platform . indexOf ( 'Mac' ) !== - 1 || Object ( external _lodash _ [ "includes" ] ) ( [ 'iPad' , 'iPhone' ] , platform ) ;
}
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/valid-types */
2021-05-20 08:20:04 -04:00
/ * *
* Attach a keyboard shortcut handler .
*
2021-11-08 09:29:21 -05:00
* @ 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 .
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
function useKeyboardShortcut (
/* eslint-enable jsdoc/valid-types */
2021-11-15 07:50:17 -05:00
shortcuts , callback ) {
let {
bindGlobal = false ,
eventName = 'keydown' ,
isDisabled = false ,
// This is important for performance considerations.
target
} = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
2021-05-20 08:20:04 -04:00
const currentCallback = Object ( external _wp _element _ [ "useRef" ] ) ( callback ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
currentCallback . current = callback ;
} , [ callback ] ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
if ( isDisabled ) {
return ;
}
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
const mousetrap = new mousetrap _default . a ( 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`.
// 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
// necessary to maintain the existing behavior
/** @type {Element} */
/** @type {unknown} */
document ) ;
2021-05-20 08:20:04 -04:00
Object ( external _lodash _ [ "castArray" ] ) ( shortcuts ) . forEach ( shortcut => {
const keys = shortcut . split ( '+' ) ; // Determines whether a key is a modifier by the length of the string.
// 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' ) ;
const hasShift = modifiers . has ( 'shift' ) ; // This should be better moved to the shortcut registration instead.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( isAppleOS ( ) && ( modifiers . size === 1 && hasAlt || modifiers . size === 2 && hasAlt && hasShift ) ) {
throw new Error ( ` Cannot bind ${ shortcut } . Alt and Shift+Alt modifiers are reserved for character input. ` ) ;
}
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
const bindFn = bindGlobal ? 'bindGlobal' : 'bind' ; // @ts-ignore `bindGlobal` is an undocumented property
2021-11-15 07:50:17 -05:00
mousetrap [ bindFn ] ( shortcut , function ( ) {
return (
/* eslint-enable jsdoc/valid-types */
currentCallback . current ( ... arguments )
) ;
} , eventName ) ;
2021-05-20 08:20:04 -04:00
} ) ;
return ( ) => {
mousetrap . reset ( ) ;
} ;
} , [ shortcuts , bindGlobal , eventName , target , isDisabled ] ) ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _keyboard _shortcut = ( useKeyboardShortcut ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04: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 .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
function useMediaQuery ( query ) {
const [ match , setMatch ] = Object ( external _wp _element _ [ "useState" ] ) ( ( ) => ! ! ( query && typeof window !== 'undefined' && window . matchMedia ( query ) . matches ) ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
if ( ! query ) {
return ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const updateMatch = ( ) => setMatch ( window . matchMedia ( query ) . matches ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
updateMatch ( ) ;
const list = window . matchMedia ( query ) ;
list . addListener ( updateMatch ) ;
return ( ) => {
list . removeListener ( updateMatch ) ;
} ;
} , [ query ] ) ;
2021-11-08 09:29:21 -05:00
return ! ! query && match ;
2021-05-20 08:20:04 -04:00
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Use something ' s value from the previous render .
* Based on https : //usehooks.com/usePrevious/.
*
2021-11-08 09:29:21 -05:00
* @ param value The value to track .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return The value from the previous render .
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
function usePrevious ( value ) {
2021-11-08 09:29:21 -05:00
const ref = Object ( external _wp _element _ [ "useRef" ] ) ( ) ; // Store current value in ref.
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
ref . current = value ;
} , [ value ] ) ; // Re-run when value changes.
// Return previous value (happens before update in useEffect above).
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
return ref . current ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js
/ * *
* Internal dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Hook returning whether the user has a preference for reduced motion .
*
* @ return { boolean } Reduced motion preference value .
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
const useReducedMotion = ( ) => useMediaQuery ( '(prefers-reduced-motion: reduce)' ) ;
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _reduced _motion = ( useReducedMotion ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
2021-11-08 09:29:21 -05:00
* @ typedef { "huge" | "wide" | "large" | "medium" | "small" | "mobile" } WPBreakpoint
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Hash of breakpoint names with pixel width at which it becomes effective .
*
* @ see _breakpoints . scss
*
2021-11-08 09:29:21 -05:00
* @ type { Record < WPBreakpoint , number > }
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const BREAKPOINTS = {
huge : 1440 ,
wide : 1280 ,
large : 960 ,
medium : 782 ,
small : 600 ,
mobile : 480
} ;
/ * *
2021-11-08 09:29:21 -05:00
* @ typedef { ">=" | "<" } WPViewportOperator
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Object mapping media query operators to the condition to be used .
*
2021-11-08 09:29:21 -05:00
* @ type { Record < WPViewportOperator , string > }
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const CONDITIONS = {
'>=' : 'min-width' ,
'<' : 'max-width'
} ;
/ * *
* Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values .
*
2021-11-08 09:29:21 -05:00
* @ type { Record < WPViewportOperator , ( breakpointValue : number , width : number ) => boolean > }
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
const OPERATOR _EVALUATORS = {
'>=' : ( breakpointValue , width ) => width >= breakpointValue ,
'<' : ( breakpointValue , width ) => width < breakpointValue
} ;
2021-11-08 09:29:21 -05:00
const ViewportMatchWidthContext = Object ( external _wp _element _ [ "createContext" ] ) (
/** @type {null | number} */
null ) ;
2021-05-20 08:20:04 -04: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 .
* /
2020-01-22 17:06:21 -05:00
2021-11-15 07:50:17 -05:00
const useViewportMatch = function ( breakpoint ) {
let operator = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '>=' ;
2021-05-20 08:20:04 -04:00
const simulatedWidth = Object ( external _wp _element _ [ "useContext" ] ) ( ViewportMatchWidthContext ) ;
const mediaQuery = ! simulatedWidth && ` ( ${ CONDITIONS [ operator ] } : ${ BREAKPOINTS [ breakpoint ] } px) ` ;
2021-11-08 09:29:21 -05:00
const mediaQueryResult = useMediaQuery ( mediaQuery || undefined ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( simulatedWidth ) {
return OPERATOR _EVALUATORS [ operator ] ( BREAKPOINTS [ breakpoint ] , simulatedWidth ) ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
return mediaQueryResult ;
} ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
useViewportMatch . _ _experimentalWidthProvider = ViewportMatchWidthContext . Provider ;
/* harmony default export */ var use _viewport _match = ( useViewportMatch ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/react-resize-aware/dist/index.js
var dist = _ _webpack _require _ _ ( "SSiF" ) ;
var dist _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( dist ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js
/ * *
* External dependencies
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Hook which allows to listen the resize event of any target element when it changes sizes .
* _Note : ` useResizeObserver ` will report ` null ` until after first render _
*
2021-11-08 09:29:21 -05:00
* Simply a re - export of ` react-resize-aware ` so refer to its documentation < https : //github.com/FezVrasta/react-resize-aware>
* for more details .
*
* @ see https : //github.com/FezVrasta/react-resize-aware
2021-05-20 08:20:04 -04:00
*
* @ example
*
* ` ` ` js
* const App = ( ) => {
* const [ resizeListener , sizes ] = useResizeObserver ( ) ;
*
* return (
* < div >
* { resizeListener }
* Your content here
* < / d i v >
* ) ;
* } ;
* ` ` `
*
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _resize _observer = ( dist _default . a ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: external ["wp","priorityQueue"]
var external _wp _priorityQueue _ = _ _webpack _require _ _ ( "XI5e" ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js
/ * *
* WordPress dependencies
* /
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* Returns the first items from list that are present on state .
*
2021-11-08 09:29:21 -05:00
* @ param list New array .
* @ param state Current state .
2021-05-21 06:14:23 -04:00
* @ return First items present iin state .
2021-05-20 08:20:04 -04:00
* /
function getFirstItemsPresentInState ( list , state ) {
const firstItems = [ ] ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
for ( let i = 0 ; i < list . length ; i ++ ) {
const item = list [ i ] ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( ! state . includes ( item ) ) {
break ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
firstItems . push ( item ) ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
return firstItems ;
}
/ * *
* 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 .
*
2021-11-08 09:29:21 -05:00
* @ param list Source array .
* @ param config Configuration object .
*
2021-05-21 06:14:23 -04:00
* @ return Async array .
2021-05-20 08:20:04 -04:00
* /
2020-01-22 17:06:21 -05:00
2021-11-15 07:50:17 -05:00
function useAsyncList ( list ) {
let config = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : {
step : 1
} ;
2021-11-08 09:29:21 -05:00
const {
step = 1
} = config ;
2021-05-21 06:14:23 -04:00
const [ current , setCurrent ] = Object ( external _wp _element _ [ "useState" ] ) ( [ ] ) ;
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
// On reset, we keep the first items that were previously rendered.
2021-11-08 09:29:21 -05:00
let firstItems = getFirstItemsPresentInState ( list , current ) ;
if ( firstItems . length < step ) {
firstItems = firstItems . concat ( list . slice ( firstItems . length , step ) ) ;
}
2021-05-21 06:14:23 -04:00
setCurrent ( firstItems ) ;
2021-11-08 09:29:21 -05:00
let nextIndex = firstItems . length ;
2021-05-20 08:20:04 -04:00
const asyncQueue = Object ( external _wp _priorityQueue _ [ "createQueue" ] ) ( ) ;
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
const append = ( ) => {
if ( list . length <= nextIndex ) {
2021-05-20 08:20:04 -04:00
return ;
}
2020-01-22 17:06:21 -05:00
2021-11-08 09:29:21 -05:00
setCurrent ( state => [ ... state , ... list . slice ( nextIndex , nextIndex + step ) ] ) ;
nextIndex += step ;
asyncQueue . add ( { } , append ) ;
2020-01-22 17:06:21 -05:00
} ;
2021-11-08 09:29:21 -05:00
asyncQueue . add ( { } , append ) ;
2021-05-20 08:20:04 -04:00
return ( ) => asyncQueue . reset ( ) ;
} , [ list ] ) ;
return current ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _async _list = ( useAsyncList ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js
/ * *
* Internal dependencies
* /
2021-11-08 09:29:21 -05: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 */
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04: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" ;
* }
* ` ` `
*
2021-11-08 09:29:21 -05:00
* @ param { object } object Object which changes to compare .
2021-05-20 08:20:04 -04:00
* @ param { string } prefix Just a prefix to show when console logging .
* /
2020-01-22 17:06:21 -05:00
2021-11-15 07:50:17 -05:00
function useWarnOnChange ( object ) {
let prefix = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 'Change detection' ;
2021-05-20 08:20:04 -04:00
const previousValues = usePrevious ( object ) ;
2021-11-15 07:50:17 -05:00
Object . entries ( previousValues !== null && previousValues !== void 0 ? previousValues : [ ] ) . forEach ( _ref => {
let [ key , value ] = _ref ;
2021-11-08 09:29:21 -05:00
if ( value !== object [
/** @type {keyof typeof object} */
key ] ) {
2021-05-20 08:20:04 -04:00
// eslint-disable-next-line no-console
2021-11-08 09:29:21 -05:00
console . warn ( ` ${ prefix } : ${ key } key changed: ` , value , object [
/** @type {keyof typeof object} */
key ]
/* eslint-enable jsdoc/check-types */
) ;
2021-05-20 08:20:04 -04:00
}
} ) ;
}
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var use _warn _on _change = ( useWarnOnChange ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
var use _memo _one _esm = _ _webpack _require _ _ ( "mHlH" ) ;
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js
/ * *
* External dependencies
* /
2019-10-15 11:37:08 -04:00
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2019-10-15 11:37:08 -04:00
2020-02-06 16:03:31 -05:00
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/valid-types */
2021-05-20 08:20:04 -04:00
/ * *
* Debounces a function with Lodash ' s ` debounce ` . A new debounced function will
* 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 ` .
*
2021-11-08 09:29:21 -05:00
* @ see https : //docs-lodash.com/v4/debounce/
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ template { ( ... args : any [ ] ) => void } TFunc
*
* @ param { TFunc } fn The function to debounce .
* @ param { number } [ wait ] The number of milliseconds to delay .
* @ param { import ( 'lodash' ) . DebounceSettings } [ options ] The options object .
* @ return { import ( 'lodash' ) . DebouncedFunc < TFunc > } Debounced function .
2021-05-20 08:20:04 -04:00
* /
2021-11-08 09:29:21 -05:00
function useDebounce ( fn , wait , options ) {
/* eslint-enable jsdoc/valid-types */
const debounced = Object ( use _memo _one _esm [ "a" /* useMemoOne */ ] ) ( ( ) => Object ( external _lodash _ [ "debounce" ] ) ( fn , wait , options ) , [ fn , wait , options ] ) ;
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => ( ) => debounced . cancel ( ) , [ debounced ] ) ;
return debounced ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js
/ * *
* External dependencies
* /
2020-02-06 16:03:31 -05:00
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* WordPress dependencies
* /
2019-10-15 11:37:08 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Throttles a function with Lodash ' s ` throttle ` . A new throttled function will
* 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 ` .
*
2021-11-08 09:29:21 -05:00
* @ see https : //docs-lodash.com/v4/throttle/
*
* @ template { ( ... args : any [ ] ) => void } TFunc
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ param { TFunc } fn The function to throttle .
* @ param { number } [ wait ] The number of milliseconds to throttle invocations to .
* @ param { import ( 'lodash' ) . ThrottleSettings } [ options ] The options object . See linked documentation for details .
* @ return { import ( 'lodash' ) . DebouncedFunc < TFunc > } Throttled function .
2021-05-20 08:20:04 -04:00
* /
2019-10-15 11:37:08 -04:00
2021-11-08 09:29:21 -05:00
function useThrottle ( fn , wait , options ) {
const throttled = Object ( use _memo _one _esm [ "a" /* useMemoOne */ ] ) ( ( ) => Object ( external _lodash _ [ "throttle" ] ) ( fn , wait , options ) , [ fn , wait , options ] ) ;
2021-05-20 08:20:04 -04:00
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => ( ) => throttled . cancel ( ) , [ throttled ] ) ;
return throttled ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js
/ * *
* WordPress dependencies
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Internal dependencies
* /
2020-06-26 09:33:47 -04:00
2020-02-06 16:03:31 -05:00
2021-11-08 09:29:21 -05:00
/* eslint-disable jsdoc/valid-types */
/ * *
* @ template T
* @ param { T } value
* @ return { import ( 'react' ) . MutableRefObject < T > } A ref with the value .
* /
2021-05-20 08:20:04 -04:00
function useFreshRef ( value ) {
2021-11-08 09:29:21 -05:00
/* 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
2021-05-20 08:20:04 -04:00
const ref = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
ref . current = value ;
return ref ;
}
2020-02-06 16:03:31 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* A hook to facilitate drag and drop handling .
2020-02-06 16:03:31 -05:00
*
2021-11-08 09:29:21 -05:00
* @ param { Object } props Named parameters .
* @ 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 .
2021-05-20 08:20:04 -04:00
*
2021-11-08 09:29:21 -05:00
* @ return { import ( 'react' ) . RefCallback < HTMLElement > } Ref callback to be passed to the drop zone element .
2020-02-06 16:03:31 -05:00
* /
2021-05-20 08:20:04 -04:00
2021-11-15 07:50:17 -05:00
function useDropZone ( _ref ) {
let {
isDisabled ,
onDrop : _onDrop ,
onDragStart : _onDragStart ,
onDragEnter : _onDragEnter ,
onDragLeave : _onDragLeave ,
onDragEnd : _onDragEnd ,
onDragOver : _onDragOver
} = _ref ;
2021-05-20 08:20:04 -04: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 ) ;
return useRefEffect ( element => {
if ( isDisabled ) {
return ;
2020-02-06 16:03:31 -05:00
}
2021-05-20 08:20:04 -04:00
let isDragging = false ;
const {
ownerDocument
} = element ;
2021-06-15 04:52:30 -04:00
/ * *
* Checks if an element is in the drop zone .
*
2021-11-08 09:29:21 -05:00
* @ param { EventTarget | null } targetToCheck
2021-06-15 04:52:30 -04:00
*
* @ return { boolean } True if in drop zone , false if not .
* /
2021-11-08 09:29:21 -05:00
function isElementInZone ( targetToCheck ) {
const {
defaultView
} = ownerDocument ;
if ( ! targetToCheck || ! defaultView || ! ( targetToCheck instanceof defaultView . HTMLElement ) || ! element . contains ( targetToCheck ) ) {
2021-06-15 04:52:30 -04:00
return false ;
}
2021-11-08 09:29:21 -05:00
/** @type {HTMLElement|null} */
let elementToCheck = targetToCheck ;
2021-06-15 04:52:30 -04:00
do {
if ( elementToCheck . dataset . isDropZone ) {
return elementToCheck === element ;
}
} while ( elementToCheck = elementToCheck . parentElement ) ;
return false ;
}
2020-02-06 16:03:31 -05:00
2021-06-15 04:52:30 -04:00
function maybeDragStart (
/** @type {DragEvent} */
event ) {
2021-05-20 08:20:04 -04:00
if ( isDragging ) {
return ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
isDragging = true ;
2021-06-15 04:52:30 -04:00
ownerDocument . removeEventListener ( 'dragenter' , maybeDragStart ) ; // Note that `dragend` doesn't fire consistently for file and
// 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 ) ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
if ( onDragStartRef . current ) {
onDragStartRef . current ( event ) ;
}
}
2020-02-06 16:03:31 -05:00
2021-11-08 09:29:21 -05:00
function onDragEnter (
/** @type {DragEvent} */
event ) {
2021-05-20 08:20:04 -04:00
event . preventDefault ( ) ; // The `dragenter` event will also fire when entering child
// 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.
2020-02-06 16:03:31 -05:00
2021-11-08 09:29:21 -05:00
if ( element . contains (
/** @type {Node} */
event . relatedTarget ) ) {
2021-05-20 08:20:04 -04:00
return ;
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
if ( onDragEnterRef . current ) {
onDragEnterRef . current ( event ) ;
}
}
2020-02-06 16:03:31 -05:00
2021-11-08 09:29:21 -05:00
function onDragOver (
/** @type {DragEvent} */
event ) {
2021-05-20 08:20:04 -04:00
// Only call onDragOver for the innermost hovered drop zones.
if ( ! event . defaultPrevented && onDragOverRef . current ) {
onDragOverRef . current ( event ) ;
} // Prevent the browser default while also signalling to parent
// drop zones that `onDragOver` is already handled.
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
event . preventDefault ( ) ;
}
2020-02-06 16:03:31 -05:00
2021-11-08 09:29:21 -05:00
function onDragLeave (
/** @type {DragEvent} */
event ) {
2021-05-20 08:20:04 -04: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.
2021-06-15 04:52:30 -04:00
if ( isElementInZone ( event . relatedTarget ) ) {
2021-05-20 08:20:04 -04:00
return ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( onDragLeaveRef . current ) {
onDragLeaveRef . current ( event ) ;
}
}
2018-12-17 22:14:52 -05:00
2021-11-08 09:29:21 -05:00
function onDrop (
/** @type {DragEvent} */
event ) {
2021-05-20 08:20:04 -04:00
// Don't handle drop if an inner drop zone already handled it.
if ( event . defaultPrevented ) {
return ;
} // Prevent the browser default while also signalling to parent
// drop zones that `onDrop` is already handled.
2020-06-29 07:50:29 -04:00
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
event . preventDefault ( ) ; // This seemingly useless line has been shown to resolve a
// Safari issue where files dragged directly from the dock are
// not recognized.
// eslint-disable-next-line no-unused-expressions
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
event . dataTransfer && event . dataTransfer . files . length ;
if ( onDropRef . current ) {
onDropRef . current ( event ) ;
}
maybeDragEnd ( event ) ;
}
2021-11-08 09:29:21 -05:00
function maybeDragEnd (
/** @type {MouseEvent} */
event ) {
2021-05-20 08:20:04 -04:00
if ( ! isDragging ) {
return ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
isDragging = false ;
ownerDocument . addEventListener ( 'dragenter' , maybeDragStart ) ;
2021-06-15 04:52:30 -04:00
ownerDocument . removeEventListener ( 'dragend' , maybeDragEnd ) ;
ownerDocument . removeEventListener ( 'mousemove' , maybeDragEnd ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( onDragEndRef . current ) {
onDragEndRef . current ( event ) ;
}
}
2020-01-08 06:57:23 -05:00
2021-06-15 04:52:30 -04:00
element . dataset . isDropZone = 'true' ;
2021-05-20 08:20:04 -04:00
element . addEventListener ( 'drop' , onDrop ) ;
element . addEventListener ( 'dragenter' , onDragEnter ) ;
element . addEventListener ( 'dragover' , onDragOver ) ;
2021-06-15 04:52:30 -04:00
element . addEventListener ( 'dragleave' , onDragLeave ) ; // The `dragstart` event doesn't fire if the drag started outside
2021-05-20 08:20:04 -04:00
// the document.
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
ownerDocument . addEventListener ( 'dragenter' , maybeDragStart ) ;
return ( ) => {
2021-06-15 04:52:30 -04:00
delete element . dataset . isDropZone ;
2021-05-20 08:20:04 -04:00
element . removeEventListener ( 'drop' , onDrop ) ;
element . removeEventListener ( 'dragenter' , onDragEnter ) ;
element . removeEventListener ( 'dragover' , onDragOver ) ;
element . removeEventListener ( 'dragleave' , onDragLeave ) ;
ownerDocument . removeEventListener ( 'dragend' , maybeDragEnd ) ;
2021-06-15 04:52:30 -04:00
ownerDocument . removeEventListener ( 'mousemove' , maybeDragEnd ) ;
2021-05-20 08:20:04 -04:00
ownerDocument . addEventListener ( 'dragenter' , maybeDragStart ) ;
} ;
} , [ isDisabled ] ) ;
}
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js
/ * *
* Internal dependencies
* /
/ * *
* Dispatches a bubbling focus event when the iframe receives focus . Use
* ` onFocus ` as usual on the iframe or a parent element .
*
* @ return { Object } Ref to pass to the iframe .
* /
function useFocusableIframe ( ) {
return useRefEffect ( element => {
const {
ownerDocument
} = element ;
if ( ! ownerDocument ) return ;
const {
defaultView
} = ownerDocument ;
if ( ! defaultView ) return ;
/ * *
* 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 ) {
/** @type {HTMLElement} */
element . focus ( ) ;
}
}
defaultView . addEventListener ( 'blur' , checkFocus ) ;
return ( ) => {
defaultView . removeEventListener ( 'blur' , checkFocus ) ;
} ;
} , [ ] ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
const DEFAULT _INIT _WINDOW _SIZE = 30 ;
/ * *
* @ typedef { Object } WPFixedWindowList
*
* @ 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
* /
/ * *
* @ typedef { Object } WPFixedWindowListOptions
*
* @ 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 .
* /
/ * *
*
* @ 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
* /
function useFixedWindowList ( elementRef , itemHeight , totalItems , options ) {
var _options$initWindowSi , _options$useWindowing ;
const initWindowSize = ( _options$initWindowSi = options === null || options === void 0 ? void 0 : options . initWindowSize ) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT _INIT _WINDOW _SIZE ;
const useWindowing = ( _options$useWindowing = options === null || options === void 0 ? void 0 : options . useWindowing ) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true ;
const [ fixedListWindow , setFixedListWindow ] = Object ( external _wp _element _ [ "useState" ] ) ( {
visibleItems : initWindowSize ,
start : 0 ,
end : initWindowSize ,
2021-11-15 07:50:17 -05:00
itemInView : (
2021-11-08 09:29:21 -05:00
/** @type {number} */
2021-11-15 07:50:17 -05:00
index ) => {
2021-11-08 09:29:21 -05:00
return index >= 0 && index <= initWindowSize ;
}
} ) ;
Object ( external _wp _element _ [ "useLayoutEffect" ] ) ( ( ) => {
var _scrollContainer$owne , _scrollContainer$owne2 , _scrollContainer$owne3 , _scrollContainer$owne4 ;
if ( ! useWindowing ) {
return ;
}
const scrollContainer = Object ( external _wp _dom _ [ "getScrollContainer" ] ) ( elementRef . current ) ;
2021-11-15 07:50:17 -05:00
const measureWindow = (
2021-11-08 09:29:21 -05:00
/** @type {boolean | undefined} */
2021-11-15 07:50:17 -05:00
initRender ) => {
2021-11-08 09:29:21 -05:00
var _options$windowOversc ;
if ( ! scrollContainer ) {
return ;
}
const visibleItems = Math . ceil ( scrollContainer . clientHeight / itemHeight ) ; // Aim to keep opening list view fast, afterward we can optimize for scrolling
const windowOverscan = initRender ? visibleItems : ( _options$windowOversc = options === null || options === void 0 ? void 0 : options . windowOverscan ) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems ;
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 ,
2021-11-15 07:50:17 -05:00
itemInView : (
2021-11-08 09:29:21 -05:00
/** @type {number} */
2021-11-15 07:50:17 -05:00
index ) => {
2021-11-08 09:29:21 -05:00
return start <= index && index <= end ;
}
} ;
if ( lastWindow . start !== nextWindow . start || lastWindow . end !== nextWindow . end || lastWindow . visibleItems !== nextWindow . visibleItems ) {
return nextWindow ;
}
return lastWindow ;
} ) ;
} ;
measureWindow ( true ) ;
const debounceMeasureList = Object ( external _lodash _ [ "debounce" ] ) ( ( ) => {
measureWindow ( ) ;
} , 16 ) ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer . addEventListener ( 'scroll' , debounceMeasureList ) ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : ( _scrollContainer$owne = scrollContainer . ownerDocument ) === null || _scrollContainer$owne === void 0 ? void 0 : ( _scrollContainer$owne2 = _scrollContainer$owne . defaultView ) === null || _scrollContainer$owne2 === void 0 ? void 0 : _scrollContainer$owne2 . addEventListener ( 'resize' , debounceMeasureList ) ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : ( _scrollContainer$owne3 = scrollContainer . ownerDocument ) === null || _scrollContainer$owne3 === void 0 ? void 0 : ( _scrollContainer$owne4 = _scrollContainer$owne3 . defaultView ) === null || _scrollContainer$owne4 === void 0 ? void 0 : _scrollContainer$owne4 . addEventListener ( 'resize' , debounceMeasureList ) ;
return ( ) => {
var _scrollContainer$owne5 , _scrollContainer$owne6 ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer . removeEventListener ( 'scroll' , debounceMeasureList ) ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : ( _scrollContainer$owne5 = scrollContainer . ownerDocument ) === null || _scrollContainer$owne5 === void 0 ? void 0 : ( _scrollContainer$owne6 = _scrollContainer$owne5 . defaultView ) === null || _scrollContainer$owne6 === void 0 ? void 0 : _scrollContainer$owne6 . removeEventListener ( 'resize' , debounceMeasureList ) ;
} ;
} , [ itemHeight , elementRef , totalItems ] ) ;
Object ( external _wp _element _ [ "useLayoutEffect" ] ) ( ( ) => {
var _scrollContainer$owne7 , _scrollContainer$owne8 ;
if ( ! useWindowing ) {
return ;
}
const scrollContainer = Object ( external _wp _dom _ [ "getScrollContainer" ] ) ( elementRef . current ) ;
2021-11-15 07:50:17 -05:00
const handleKeyDown = (
2021-11-08 09:29:21 -05:00
/** @type {KeyboardEvent} */
2021-11-15 07:50:17 -05:00
event ) => {
2021-11-08 09:29:21 -05:00
switch ( event . keyCode ) {
case external _wp _keycodes _ [ "HOME" ] :
{
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer . scrollTo ( {
top : 0
} ) ;
}
case external _wp _keycodes _ [ "END" ] :
{
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer . scrollTo ( {
top : totalItems * itemHeight
} ) ;
}
case external _wp _keycodes _ [ "PAGEUP" ] :
{
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer . scrollTo ( {
top : scrollContainer . scrollTop - fixedListWindow . visibleItems * itemHeight
} ) ;
}
case external _wp _keycodes _ [ "PAGEDOWN" ] :
{
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer . scrollTo ( {
top : scrollContainer . scrollTop + fixedListWindow . visibleItems * itemHeight
} ) ;
}
}
} ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : ( _scrollContainer$owne7 = scrollContainer . ownerDocument ) === null || _scrollContainer$owne7 === void 0 ? void 0 : ( _scrollContainer$owne8 = _scrollContainer$owne7 . defaultView ) === null || _scrollContainer$owne8 === void 0 ? void 0 : _scrollContainer$owne8 . addEventListener ( 'keydown' , handleKeyDown ) ;
return ( ) => {
var _scrollContainer$owne9 , _scrollContainer$owne10 ;
scrollContainer === null || scrollContainer === void 0 ? void 0 : ( _scrollContainer$owne9 = scrollContainer . ownerDocument ) === null || _scrollContainer$owne9 === void 0 ? void 0 : ( _scrollContainer$owne10 = _scrollContainer$owne9 . defaultView ) === null || _scrollContainer$owne10 === void 0 ? void 0 : _scrollContainer$owne10 . removeEventListener ( 'keydown' , handleKeyDown ) ;
} ;
} , [ totalItems , itemHeight , elementRef , fixedListWindow . visibleItems ] ) ;
return [ fixedListWindow , setFixedListWindow ] ;
}
2021-05-20 08:20:04 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js
// Utils
// Compose helper (aliased flowRight from Lodash)
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// Higher-order components
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// Hooks
2018-12-13 23:41:57 -05:00
2020-06-26 09:33:47 -04:00
2018-12-13 23:41:57 -05:00
2020-06-26 09:33:47 -04:00
2018-12-13 23:41:57 -05:00
2021-01-27 21:04:13 -05:00
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
2018-12-13 23:41:57 -05:00
2021-11-08 09:29:21 -05:00
2018-12-13 23:41:57 -05:00
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ "RxS6" :
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "wp" ] [ "keycodes" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ "SSiF" :
/***/ ( function ( module , exports , _ _webpack _require _ _ ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
var e = _ _webpack _require _ _ ( "cDcd" ) , n = { display : "block" , opacity : 0 , position : "absolute" , top : 0 , left : 0 , height : "100%" , width : "100%" , overflow : "hidden" , pointerEvents : "none" , zIndex : - 1 } , t = function ( t ) { var r = t . onResize , u = e . useRef ( ) ; return function ( n , t ) { var r = function ( ) { return n . current && n . current . contentDocument && n . current . contentDocument . defaultView } ; function u ( ) { t ( ) ; var e = r ( ) ; e && e . addEventListener ( "resize" , t ) } e . useEffect ( ( function ( ) { return r ( ) ? u ( ) : n . current && n . current . addEventListener && n . current . addEventListener ( "load" , u ) , function ( ) { var e = r ( ) ; e && "function" == typeof e . removeEventListener && e . removeEventListener ( "resize" , t ) } } ) , [ ] ) } ( u , ( function ( ) { return r ( u ) } ) ) , e . createElement ( "iframe" , { style : n , src : "about:blank" , ref : u , "aria-hidden" : ! 0 , tabIndex : - 1 , frameBorder : 0 } ) } , r = function ( e ) { return { width : null != e ? e . offsetWidth : null , height : null != e ? e . offsetHeight : null } } ; module . exports = function ( n ) { void 0 === n && ( n = r ) ; var u = e . useState ( n ( null ) ) , o = u [ 0 ] , i = u [ 1 ] , c = e . useCallback ( ( function ( e ) { return i ( n ( e . current ) ) } ) , [ n ] ) ; return [ e . useMemo ( ( function ( ) { return e . createElement ( t , { onResize : c } ) } ) , [ c ] ) , o ] } ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
/***/ "VcSt" :
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* adds a bindGlobal method to Mousetrap that allows you to
* bind specific keyboard shortcuts that will still work
* inside a text input field
2019-09-19 11:19:18 -04:00
*
2021-05-20 08:20:04 -04:00
* usage :
* Mousetrap . bindGlobal ( 'ctrl+s' , _saveChanges ) ;
2019-09-19 11:19:18 -04:00
* /
2021-05-20 08:20:04 -04:00
/* global Mousetrap:true */
( function ( Mousetrap ) {
if ( ! Mousetrap ) {
return ;
}
var _globalCallbacks = { } ;
var _originalStopCallback = Mousetrap . prototype . stopCallback ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
Mousetrap . prototype . stopCallback = function ( e , element , combo , sequence ) {
var self = this ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( self . paused ) {
return true ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( _globalCallbacks [ combo ] || _globalCallbacks [ sequence ] ) {
return false ;
2021-05-19 11:09:27 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return _originalStopCallback . call ( self , e , element , combo ) ;
} ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
Mousetrap . prototype . bindGlobal = function ( keys , callback , action ) {
var self = this ;
self . bind ( keys , callback , action ) ;
if ( keys instanceof Array ) {
for ( var i = 0 ; i < keys . length ; i ++ ) {
_globalCallbacks [ keys [ i ] ] = true ;
}
return ;
2018-12-13 23:41:57 -05:00
}
2021-05-20 08:20:04 -04:00
_globalCallbacks [ keys ] = true ;
} ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
Mousetrap . init ( ) ;
} ) ( typeof Mousetrap !== "undefined" ? Mousetrap : undefined ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ "XI5e" :
/***/ ( function ( module , exports ) {
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "wp" ] [ "priorityQueue" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ "YLtl" :
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "lodash" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ "cDcd" :
/***/ ( function ( module , exports ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "React" ] ; } ( ) ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/***/ "imBb" :
/***/ ( function ( module , exports , _ _webpack _require _ _ ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
var _ _WEBPACK _AMD _DEFINE _RESULT _ _ ; /*global define:false */
2018-12-13 23:41:57 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Copyright 2012 - 2017 Craig Campbell
2018-12-13 23:41:57 -05:00
*
2021-05-20 08:20:04 -04: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
2018-12-13 23:41:57 -05:00
*
2021-05-20 08:20:04 -04:00
* http : //www.apache.org/licenses/LICENSE-2.0
*
* 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 .
*
* Mousetrap is a simple keyboard shortcut library for Javascript with
* no external dependencies
*
* @ version 1.6 . 5
* @ url craig . is / killing / mice
2018-12-13 23:41:57 -05:00
* /
2021-05-20 08:20:04 -04:00
( function ( window , document , undefined ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// Check if mousetrap is used inside browser, if not, return
if ( ! window ) {
return ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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'
} ;
/ * *
* 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 : '\''
} ;
/ * *
* 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' ,
'_' : '-' ,
'+' : '=' ,
':' : ';' ,
'\"' : '\'' ,
'<' : ',' ,
'>' : '.' ,
'?' : '/' ,
'|' : '\\'
} ;
/ * *
* 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'
} ;
/ * *
* 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 ;
/ * *
* 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 ;
}
/ * *
* loop through to map numbers on the numeric keypad
* /
for ( i = 0 ; i <= 9 ; ++ i ) {
// 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 ( ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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 ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
object . attachEvent ( 'on' + type , callback ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* takes the event and returns the key character
*
* @ param { Event } e
* @ return { string }
* /
function _characterFromEvent ( e ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// for keypress events we should return the character as is
if ( e . type == 'keypress' ) {
var character = String . fromCharCode ( e . which ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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 ( ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return character ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// for non keypress events the special maps are needed
if ( _MAP [ e . which ] ) {
return _MAP [ e . which ] ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( _KEYCODE _MAP [ e . which ] ) {
return _KEYCODE _MAP [ e . which ] ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
// if it is not in the special map
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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-05-19 11:09:27 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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 ( ',' ) ;
2021-05-19 11:09:27 -04:00
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* takes a key event and figures out what the modifiers are
*
* @ param { Event } e
* @ returns { Array }
* /
function _eventModifiers ( e ) {
var modifiers = [ ] ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( e . shiftKey ) {
modifiers . push ( 'shift' ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( e . altKey ) {
modifiers . push ( 'alt' ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( e . ctrlKey ) {
modifiers . push ( 'ctrl' ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( e . metaKey ) {
modifiers . push ( 'meta' ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return modifiers ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* prevents default for this event
*
* @ param { Event } e
* @ returns void
* /
function _preventDefault ( e ) {
if ( e . preventDefault ) {
e . preventDefault ( ) ;
return ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
e . returnValue = false ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* stops propogation for this event
*
* @ param { Event } e
* @ returns void
* /
function _stopPropagation ( e ) {
if ( e . stopPropagation ) {
e . stopPropagation ( ) ;
return ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
e . cancelBubble = true ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04: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 ) {
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04: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 ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( _MAP . hasOwnProperty ( key ) ) {
_REVERSE _MAP [ _MAP [ key ] ] = key ;
}
}
}
return _REVERSE _MAP ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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' ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// modifier keys don't work as expected with keypress,
// switch to keydown
if ( action == 'keypress' && modifiers . length ) {
action = 'keydown' ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
return action ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 [ '+' ] ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
combination = combination . replace ( /\+{2}/g , '+plus' ) ;
return combination . split ( '+' ) ;
2021-01-27 21:04:13 -05:00
}
2021-05-20 08:20:04 -04: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 = [ ] ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// take the keys from this pattern and figure out what the actual
// pattern is all about
keys = _keysFromString ( combination ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
for ( i = 0 ; i < keys . length ; ++ i ) {
key = keys [ i ] ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// normalize key names
if ( _SPECIAL _ALIASES [ key ] ) {
key = _SPECIAL _ALIASES [ key ] ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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' ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// if this key is a modifier then add it to the list of modifiers
if ( _isModifier ( key ) ) {
modifiers . push ( key ) ;
}
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
// depending on what the key combination is
// we will try to pick the best event for it
action = _pickBestAction ( key , modifiers , action ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
return {
key : key ,
modifiers : modifiers ,
action : action
} ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
function _belongsTo ( element , ancestor ) {
if ( element === null || element === document ) {
return false ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( element === ancestor ) {
return true ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
return _belongsTo ( element . parentNode , ancestor ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
function Mousetrap ( targetElement ) {
var self = this ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
targetElement = targetElement || document ;
2020-07-21 08:14:37 -04:00
2021-05-20 08:20:04 -04:00
if ( ! ( self instanceof Mousetrap ) ) {
return new Mousetrap ( targetElement ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* element to attach key events to
*
* @ type { Element }
* /
self . target = targetElement ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* a list of all the callbacks setup via Mousetrap . bind ( )
*
* @ type { Object }
* /
self . _callbacks = { } ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* direct map of string combinations to callbacks used for trigger ( )
*
* @ type { Object }
* /
self . _directMap = { } ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* keeps track of what level each sequence is at since multiple
* sequences can start out with the same sequence
*
* @ type { Object }
* /
var _sequenceLevels = { } ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* variable to store the setTimeout call
*
* @ type { null | number }
* /
var _resetTimer ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* temporary state where we will ignore the next keyup
*
* @ type { boolean | string }
* /
var _ignoreNextKeyup = false ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* temporary state where we will ignore the next keypress
*
* @ type { boolean }
* /
var _ignoreNextKeypress = false ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* resets all sequence counters except for the ones passed in
*
* @ param { Object } doNotReset
* @ returns void
* /
function _resetSequences ( doNotReset ) {
doNotReset = doNotReset || { } ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
var activeSequences = false ,
key ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
for ( key in _sequenceLevels ) {
if ( doNotReset [ key ] ) {
activeSequences = true ;
continue ;
}
_sequenceLevels [ key ] = 0 ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
if ( ! activeSequences ) {
_nextExpectedAction = false ;
}
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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-05-19 11:09:27 -04:00
2021-05-20 08:20:04 -04:00
// if there are no events related to this keycode
if ( ! self . _callbacks [ character ] ) {
return [ ] ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
// if a modifier key is coming up on its own we should allow it
if ( action == 'keyup' && _isModifier ( character ) ) {
modifiers = [ character ] ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
matches . push ( callback ) ;
}
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
return matches ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// if this event should not happen stop here
if ( self . stopCallback ( e , e . target || e . srcElement , combo , sequence ) ) {
return ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
if ( callback ( e , combo ) === false ) {
_preventDefault ( e ) ;
_stopPropagation ( e ) ;
}
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// loop through matching callbacks for this key event
for ( i = 0 ; i < callbacks . length ; ++ i ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
}
2021-02-22 01:04:39 -05:00
2021-05-20 08:20:04 -04:00
processedSequenceCallback = true ;
2021-02-22 01:04:39 -05:00
2021-05-20 08:20:04 -04: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 ;
}
2021-02-22 01:04:39 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
_ignoreNextKeypress = processedSequenceCallback && e . type == 'keydown' ;
} ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/ * *
* handles a keydown event
*
* @ param { Event } e
* @ returns void
* /
function _handleKeyEvent ( e ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
var character = _characterFromEvent ( e ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// no character found then stop
if ( ! character ) {
return ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// need to use === for the character check because the character can be 0
if ( e . type == 'keyup' && _ignoreNextKeyup === character ) {
_ignoreNextKeyup = false ;
return ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
self . handleKey ( character , _eventModifiers ( e ) , e ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// start off by adding a sequence level record for this combination
// and setting the level to 0
_sequenceLevels [ combo ] = 0 ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// weird race condition if a sequence ends with the key
// another sequence begins with
setTimeout ( _resetSequences , 10 ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// store a direct mapped reference for use with Mousetrap.trigger
self . _directMap [ combination + ':' + action ] = callback ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// make sure multiple spaces in a row become a single space
combination = combination . replace ( /\s+/g , ' ' ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
var sequence = combination . split ( ' ' ) ;
var info ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
info = _getKeyInfo ( combination , action ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ] || [ ] ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// remove an existing match if there is one
_getMatches ( info . key , info . modifiers , { type : info . action } , sequenceName , combination , level ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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
} ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ) ;
}
} ;
// start!
_addEvent ( targetElement , 'keypress' , _handleKeyEvent ) ;
_addEvent ( targetElement , 'keydown' , _handleKeyEvent ) ;
_addEvent ( targetElement , 'keyup' , _handleKeyEvent ) ;
2021-01-27 21:04:13 -05:00
}
2021-05-20 08:20:04 -04: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 ;
} ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
} ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
} ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
// if the element has the class "mousetrap" then no need to stop
if ( ( ' ' + element . className + ' ' ) . indexOf ( ' mousetrap ' ) > - 1 ) {
return false ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
if ( _belongsTo ( element , self . target ) ) {
return false ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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 ;
}
}
// stop for input, select, and textarea
return element . tagName == 'INPUT' || element . tagName == 'SELECT' || element . tagName == 'TEXTAREA' || element . isContentEditable ;
} ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* exposes _handleKey publicly so it can be overwritten by extensions
* /
Mousetrap . prototype . handleKey = function ( ) {
var self = this ;
return self . _handleKey . apply ( self , arguments ) ;
} ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* allow custom key mappings
* /
Mousetrap . addKeycodes = function ( object ) {
for ( var key in object ) {
if ( object . hasOwnProperty ( key ) ) {
_MAP [ key ] = object [ key ] ;
}
}
_REVERSE _MAP = null ;
} ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
Mousetrap . init ( ) ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
// expose mousetrap to the global object
window . Mousetrap = Mousetrap ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
// expose as a common js module
if ( true && module . exports ) {
module . exports = Mousetrap ;
}
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04: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 ) ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ "mHlH" :
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
"use strict" ;
/* unused harmony export useCallback */
/* unused harmony export useCallbackOne */
/* unused harmony export useMemo */
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return useMemoOne ; } ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( "cDcd" ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
function areInputsEqual ( newInputs , lastInputs ) {
if ( newInputs . length !== lastInputs . length ) {
return false ;
}
for ( var i = 0 ; i < newInputs . length ; i ++ ) {
if ( newInputs [ i ] !== lastInputs [ i ] ) {
return false ;
}
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
return true ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
function useMemoOne ( getResult , inputs ) {
var initial = Object ( react _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ "useState" ] ) ( function ( ) {
return {
inputs : inputs ,
result : getResult ( )
} ;
} ) [ 0 ] ;
var isFirstRun = Object ( react _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ "useRef" ] ) ( true ) ;
var committed = Object ( react _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ "useRef" ] ) ( initial ) ;
var useCache = isFirstRun . current || Boolean ( inputs && committed . current . inputs && areInputsEqual ( inputs , committed . current . inputs ) ) ;
var cache = useCache ? committed . current : {
inputs : inputs ,
result : getResult ( )
} ;
Object ( react _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ "useEffect" ] ) ( function ( ) {
isFirstRun . current = false ;
committed . current = cache ;
} , [ cache ] ) ;
return cache . result ;
}
function useCallbackOne ( callback , inputs ) {
return useMemoOne ( function ( ) {
return callback ;
} , inputs ) ;
}
var useMemo = useMemoOne ;
var useCallback = useCallbackOne ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ "rl8x" :
/***/ ( function ( module , exports ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
( function ( ) { module . exports = window [ "wp" ] [ "isShallowEqual" ] ; } ( ) ) ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ "sxGJ" :
/***/ ( function ( module , exports , _ _webpack _require _ _ ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/ * !
* clipboard . js v2 . 0.8
* https : //clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
2021-01-27 21:04:13 -05:00
* /
2021-05-20 08:20:04 -04:00
( function webpackUniversalModuleDefinition ( root , factory ) {
if ( true )
module . exports = factory ( ) ;
else { }
} ) ( this , function ( ) {
return /******/ ( function ( ) { // webpackBootstrap
/******/ var _ _webpack _modules _ _ = ( {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ 134 :
/***/ ( function ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
"use strict" ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"default" : function ( ) { return /* binding */ clipboard ; }
} ) ;
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
var tiny _emitter = _ _webpack _require _ _ ( 279 ) ;
var tiny _emitter _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( tiny _emitter ) ;
// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
var listen = _ _webpack _require _ _ ( 370 ) ;
var listen _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( listen ) ;
// EXTERNAL MODULE: ./node_modules/select/src/select.js
var src _select = _ _webpack _require _ _ ( 817 ) ;
var select _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( src _select ) ;
; // CONCATENATED MODULE: ./src/clipboard-action.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-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04: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 ) ; } }
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
2020-01-22 17:06:21 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Inner class which performs selection from either ` text ` or ` target `
* properties and then executes copy or cut operations .
2020-01-22 17:06:21 -05:00
* /
2021-05-20 08:20:04 -04:00
var ClipboardAction = /*#__PURE__*/ function ( ) {
/ * *
* @ param { Object } options
* /
function ClipboardAction ( options ) {
_classCallCheck ( this , ClipboardAction ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
this . resolveOptions ( options ) ;
this . initSelection ( ) ;
}
/ * *
* Defines base properties passed from constructor .
* @ param { Object } options
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
_createClass ( ClipboardAction , [ {
key : "resolveOptions" ,
value : function resolveOptions ( ) {
var options = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
this . action = options . action ;
this . container = options . container ;
this . emitter = options . emitter ;
this . target = options . target ;
this . text = options . text ;
this . trigger = options . trigger ;
this . selectedText = '' ;
}
/ * *
* Decides which selection strategy is going to be applied based
* on the existence of ` text ` and ` target ` properties .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "initSelection" ,
value : function initSelection ( ) {
if ( this . text ) {
this . selectFake ( ) ;
} else if ( this . target ) {
this . selectTarget ( ) ;
}
}
/ * *
* Creates a fake textarea element , sets its value from ` text ` property ,
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "createFakeElement" ,
value : function createFakeElement ( ) {
var isRTL = document . documentElement . getAttribute ( 'dir' ) === 'rtl' ;
this . fakeElem = document . createElement ( 'textarea' ) ; // Prevent zooming on iOS
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
this . fakeElem . style . fontSize = '12pt' ; // Reset box model
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
this . fakeElem . style . border = '0' ;
this . fakeElem . style . padding = '0' ;
this . fakeElem . style . margin = '0' ; // Move element out of screen horizontally
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
this . fakeElem . style . position = 'absolute' ;
this . fakeElem . style [ isRTL ? 'right' : 'left' ] = '-9999px' ; // Move element to the same position vertically
var yPosition = window . pageYOffset || document . documentElement . scrollTop ;
this . fakeElem . style . top = "" . concat ( yPosition , "px" ) ;
this . fakeElem . setAttribute ( 'readonly' , '' ) ;
this . fakeElem . value = this . text ;
return this . fakeElem ;
2020-01-22 17:06:21 -05:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Get ' s the value of fakeElem ,
* and makes a selection on it .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "selectFake" ,
value : function selectFake ( ) {
var _this = this ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
var fakeElem = this . createFakeElement ( ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
this . fakeHandlerCallback = function ( ) {
return _this . removeFake ( ) ;
} ;
this . fakeHandler = this . container . addEventListener ( 'click' , this . fakeHandlerCallback ) || true ;
this . container . appendChild ( fakeElem ) ;
this . selectedText = select _default ( ) ( fakeElem ) ;
this . copyText ( ) ;
this . removeFake ( ) ;
}
/ * *
* Only removes the fake element after another click event , that way
* a user can hit ` Ctrl+C ` to copy because selection still exists .
* /
} , {
key : "removeFake" ,
value : function removeFake ( ) {
if ( this . fakeHandler ) {
this . container . removeEventListener ( 'click' , this . fakeHandlerCallback ) ;
this . fakeHandler = null ;
this . fakeHandlerCallback = null ;
2020-01-22 17:06:21 -05:00
}
2021-05-20 08:20:04 -04:00
if ( this . fakeElem ) {
this . container . removeChild ( this . fakeElem ) ;
this . fakeElem = null ;
}
}
/ * *
* Selects the content from element passed on ` target ` property .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "selectTarget" ,
value : function selectTarget ( ) {
this . selectedText = select _default ( ) ( this . target ) ;
this . copyText ( ) ;
}
/ * *
* Executes the copy operation based on the current selection .
* /
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
} , {
key : "copyText" ,
value : function copyText ( ) {
var succeeded ;
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04:00
try {
succeeded = document . execCommand ( this . action ) ;
} catch ( err ) {
succeeded = false ;
}
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04:00
this . handleResult ( succeeded ) ;
}
/ * *
* Fires an event based on the copy operation result .
* @ param { Boolean } succeeded
* /
} , {
key : "handleResult" ,
value : function handleResult ( succeeded ) {
this . emitter . emit ( succeeded ? 'success' : 'error' , {
action : this . action ,
text : this . selectedText ,
trigger : this . trigger ,
clearSelection : this . clearSelection . bind ( this )
} ) ;
}
/ * *
* Moves focus away from ` target ` and back to the trigger , removes current selection .
* /
} , {
key : "clearSelection" ,
value : function clearSelection ( ) {
if ( this . trigger ) {
this . trigger . focus ( ) ;
}
document . activeElement . blur ( ) ;
window . getSelection ( ) . removeAllRanges ( ) ;
2020-07-07 12:08:28 -04:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Sets the ` action ` to be performed which can be either 'copy' or 'cut' .
* @ param { String } action
* /
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "destroy" ,
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Destroy lifecycle .
* /
value : function destroy ( ) {
this . removeFake ( ) ;
}
} , {
key : "action" ,
set : function set ( ) {
var action = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : 'copy' ;
this . _action = action ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( this . _action !== 'copy' && this . _action !== 'cut' ) {
throw new Error ( 'Invalid "action" value, use either "copy" or "cut"' ) ;
}
}
/ * *
* Gets the ` action ` property .
* @ return { String }
* /
,
get : function get ( ) {
return this . _action ;
}
/ * *
* Sets the ` target ` property using an element
* that will be have its content copied .
* @ param { Element } target
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "target" ,
set : function set ( target ) {
if ( target !== undefined ) {
if ( target && _typeof ( target ) === 'object' && target . nodeType === 1 ) {
if ( this . action === 'copy' && target . hasAttribute ( 'disabled' ) ) {
throw new Error ( 'Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute' ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( this . 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' ) ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
this . _target = target ;
} else {
throw new Error ( 'Invalid "target" value, use a valid Element' ) ;
}
}
}
/ * *
* Gets the ` target ` property .
* @ return { String | HTMLElement }
* /
,
get : function get ( ) {
return this . _target ;
}
} ] ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
return ClipboardAction ;
} ( ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var clipboard _action = ( ClipboardAction ) ;
; // 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 ) ; }
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function clipboard _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04:00
function clipboard _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 ) ; } }
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04:00
function clipboard _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) clipboard _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) clipboard _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
2020-07-07 12:08:28 -04:00
2021-05-20 08:20:04 -04: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 ) ; }
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . _ _proto _ _ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04: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 ) ; } ; }
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
function _possibleConstructorReturn ( self , call ) { if ( call && ( clipboard _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04: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 ) ; }
2018-12-13 23:41:57 -05:00
2019-09-19 11:19:18 -04:00
2020-01-22 17:06:21 -05:00
2020-01-08 06:57:23 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Helper function to retrieve attribute value .
* @ param { String } suffix
* @ param { Element } element
2020-01-08 06:57:23 -05:00
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
function getAttributeValue ( suffix , element ) {
var attribute = "data-clipboard-" . concat ( suffix ) ;
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
if ( ! element . hasAttribute ( attribute ) ) {
return ;
2020-01-22 17:06:21 -05:00
}
2021-05-20 08:20:04 -04:00
return element . getAttribute ( attribute ) ;
}
/ * *
* Base class which takes one or more elements , adds event listeners to them ,
* and instantiates a new ` ClipboardAction ` on each click .
* /
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
var Clipboard = /*#__PURE__*/ function ( _Emitter ) {
_inherits ( Clipboard , _Emitter ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
var _super = _createSuper ( Clipboard ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* @ param { String | HTMLElement | HTMLCollection | NodeList } trigger
* @ param { Object } options
* /
function Clipboard ( trigger , options ) {
var _this ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
clipboard _classCallCheck ( this , Clipboard ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
_this = _super . call ( this ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
_this . resolveOptions ( options ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
_this . listenClick ( trigger ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04: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 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
clipboard _createClass ( Clipboard , [ {
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 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "listenClick" ,
value : function listenClick ( trigger ) {
var _this2 = this ;
this . listener = listen _default ( ) ( trigger , 'click' , function ( e ) {
return _this2 . onClick ( e ) ;
} ) ;
2020-06-26 09:33:47 -04:00
}
2021-05-20 08:20:04 -04:00
/ * *
* Defines a new ` ClipboardAction ` on each click event .
* @ param { Event } e
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "onClick" ,
value : function onClick ( e ) {
var trigger = e . delegateTarget || e . currentTarget ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( this . clipboardAction ) {
this . clipboardAction = null ;
}
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
this . clipboardAction = new clipboard _action ( {
action : this . action ( trigger ) ,
target : this . target ( trigger ) ,
text : this . text ( trigger ) ,
container : this . container ,
trigger : trigger ,
emitter : this
} ) ;
}
/ * *
* Default ` action ` lookup function .
* @ param { Element } trigger
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "defaultAction" ,
value : function defaultAction ( trigger ) {
return getAttributeValue ( 'action' , trigger ) ;
}
/ * *
* Default ` target ` lookup function .
* @ param { Element } trigger
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "defaultTarget" ,
value : function defaultTarget ( trigger ) {
var selector = getAttributeValue ( 'target' , trigger ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( selector ) {
return document . querySelector ( selector ) ;
}
}
/ * *
* Returns the support of the given action , or all actions if no action is
* given .
* @ param { String } [ action ]
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "defaultText" ,
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Default ` text ` lookup function .
* @ param { Element } trigger
* /
value : function defaultText ( trigger ) {
return getAttributeValue ( 'text' , trigger ) ;
}
/ * *
* Destroy lifecycle .
* /
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
} , {
key : "destroy" ,
value : function destroy ( ) {
this . listener . destroy ( ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
if ( this . clipboardAction ) {
this . clipboardAction . destroy ( ) ;
this . clipboardAction = null ;
}
}
} ] , [ {
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 ) ;
2021-05-19 11:09:27 -04:00
} ) ;
2021-05-20 08:20:04 -04:00
return support ;
}
} ] ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
return Clipboard ;
} ( ( tiny _emitter _default ( ) ) ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
/* harmony default export */ var clipboard = ( Clipboard ) ;
/***/ } ) ,
/***/ 828 :
/***/ ( function ( module ) {
var DOCUMENT _NODE _TYPE = 9 ;
2020-06-26 09:33:47 -04:00
2020-07-14 07:39:09 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* A polyfill for Element . matches ( )
2020-07-14 07:39:09 -04:00
* /
2021-05-20 08:20:04 -04:00
if ( typeof Element !== 'undefined' && ! Element . prototype . matches ) {
var proto = Element . prototype ;
proto . matches = proto . matchesSelector ||
proto . mozMatchesSelector ||
proto . msMatchesSelector ||
proto . oMatchesSelector ||
proto . webkitMatchesSelector ;
}
2020-07-14 07:39:09 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Finds the closest parent that matches a selector .
2020-07-14 07:39:09 -04:00
*
2021-05-20 08:20:04 -04:00
* @ param { Element } element
* @ param { String } selector
* @ return { Function }
2020-07-14 07:39:09 -04:00
* /
2021-05-20 08:20:04 -04: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 ;
2020-07-14 07:39:09 -04:00
}
}
2021-05-20 08:20:04 -04:00
module . exports = closest ;
/***/ } ) ,
/***/ 438 :
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
var closest = _ _webpack _require _ _ ( 828 ) ;
/ * *
* Delegates event to a selector .
*
* @ param { Element } element
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ param { Boolean } useCapture
* @ return { Object }
* /
function _delegate ( element , selector , type , callback , useCapture ) {
var listenerFn = listener . apply ( this , arguments ) ;
element . addEventListener ( type , listenerFn , useCapture ) ;
2020-07-14 07:39:09 -04:00
2021-05-20 08:20:04 -04:00
return {
destroy : function ( ) {
element . removeEventListener ( type , listenerFn , useCapture ) ;
}
}
}
2020-10-20 09:36:16 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Delegates event to a selector .
*
* @ param { Element | String | Array } [ elements ]
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ param { Boolean } useCapture
* @ return { Object }
2020-10-20 09:36:16 -04:00
* /
2021-05-20 08:20:04 -04:00
function delegate ( elements , selector , type , callback , useCapture ) {
// Handle the regular Element usage
if ( typeof elements . addEventListener === 'function' ) {
return _delegate . apply ( null , arguments ) ;
}
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04: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 ) ;
}
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
// Handle Selector-based usage
if ( typeof elements === 'string' ) {
elements = document . querySelectorAll ( elements ) ;
}
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
// Handle Array-like based usage
return Array . prototype . map . call ( elements , function ( element ) {
return _delegate ( element , selector , type , callback , useCapture ) ;
} ) ;
}
2020-10-20 09:36:16 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Finds closest match and invokes callback .
2021-01-27 21:04:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Element } element
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ return { Function }
2020-10-20 09:36:16 -04:00
* /
2021-05-20 08:20:04 -04:00
function listener ( element , selector , type , callback ) {
return function ( e ) {
e . delegateTarget = closest ( e . target , selector ) ;
2020-10-20 09:36:16 -04:00
2021-05-20 08:20:04 -04:00
if ( e . delegateTarget ) {
callback . call ( element , e ) ;
}
}
2020-10-20 09:36:16 -04:00
}
2021-05-20 08:20:04 -04:00
module . exports = delegate ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
/***/ 879 :
/***/ ( function ( _ _unused _webpack _module , exports ) {
2021-01-27 21:04:13 -05:00
/ * *
2021-05-20 08:20:04 -04:00
* Check if argument is a HTML element .
2021-01-27 21:04:13 -05:00
*
2021-05-20 08:20:04 -04:00
* @ param { Object } value
* @ return { Boolean }
2021-01-27 21:04:13 -05:00
* /
2021-05-20 08:20:04 -04:00
exports . node = function ( value ) {
return value !== undefined
&& value instanceof HTMLElement
&& value . nodeType === 1 ;
} ;
2021-01-27 21:04:13 -05:00
2021-05-07 07:48:27 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Check if argument is a list of HTML elements .
*
* @ param { Object } value
* @ return { Boolean }
2021-05-07 07:48:27 -04:00
* /
2021-05-20 08:20:04 -04:00
exports . nodeList = function ( value ) {
var type = Object . prototype . toString . call ( value ) ;
return value !== undefined
&& ( type === '[object NodeList]' || type === '[object HTMLCollection]' )
&& ( 'length' in value )
&& ( value . length === 0 || exports . node ( value [ 0 ] ) ) ;
} ;
2021-05-07 07:48:27 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Check if argument is a string .
*
* @ param { Object } value
* @ return { Boolean }
2021-05-07 07:48:27 -04:00
* /
2021-05-20 08:20:04 -04:00
exports . string = function ( value ) {
return typeof value === 'string'
|| value instanceof String ;
} ;
2021-05-07 07:48:27 -04:00
/ * *
2021-05-20 08:20:04 -04:00
* Check if argument is a function .
2021-05-07 07:48:27 -04:00
*
2021-05-20 08:20:04 -04:00
* @ param { Object } value
* @ return { Boolean }
2021-05-07 07:48:27 -04:00
* /
2021-05-20 08:20:04 -04:00
exports . fn = function ( value ) {
var type = Object . prototype . toString . call ( value ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
return type === '[object Function]' ;
} ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
/***/ 370 :
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
var is = _ _webpack _require _ _ ( 879 ) ;
var delegate = _ _webpack _require _ _ ( 438 ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04: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-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
if ( ! is . string ( type ) ) {
throw new TypeError ( 'Second argument must be a String' ) ;
2021-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
if ( ! is . fn ( callback ) ) {
throw new TypeError ( 'Third argument must be a Function' ) ;
2021-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
if ( is . node ( target ) ) {
return listenNode ( target , type , callback ) ;
2021-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
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' ) ;
}
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04: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 }
* /
function listenNode ( node , type , callback ) {
node . addEventListener ( type , callback ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
return {
destroy : function ( ) {
node . removeEventListener ( type , callback ) ;
}
}
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04: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 }
* /
function listenNodeList ( nodeList , type , callback ) {
Array . prototype . forEach . call ( nodeList , function ( node ) {
node . addEventListener ( type , callback ) ;
} ) ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
return {
destroy : function ( ) {
Array . prototype . forEach . call ( nodeList , function ( node ) {
node . removeEventListener ( type , callback ) ;
} ) ;
}
2021-05-07 07:48:27 -04:00
}
2021-05-20 08:20:04 -04:00
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
/ * *
* Add an event listener to a selector
* and returns a remove listener function .
*
* @ param { String } selector
* @ param { String } type
* @ param { Function } callback
* @ return { Object }
* /
function listenSelector ( selector , type , callback ) {
return delegate ( document . body , selector , type , callback ) ;
}
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
module . exports = listen ;
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
/***/ 817 :
/***/ ( function ( module ) {
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
function select ( element ) {
var selectedText ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( element . nodeName === 'SELECT' ) {
element . focus ( ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
selectedText = element . value ;
}
else if ( element . nodeName === 'INPUT' || element . nodeName === 'TEXTAREA' ) {
var isReadOnly = element . hasAttribute ( 'readonly' ) ;
2019-09-19 11:19:18 -04:00
2021-05-20 08:20:04 -04:00
if ( ! isReadOnly ) {
element . setAttribute ( 'readonly' , '' ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
element . select ( ) ;
element . setSelectionRange ( 0 , element . value . length ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
if ( ! isReadOnly ) {
element . removeAttribute ( 'readonly' ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
selectedText = element . value ;
}
else {
if ( element . hasAttribute ( 'contenteditable' ) ) {
element . focus ( ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
var selection = window . getSelection ( ) ;
var range = document . createRange ( ) ;
2020-01-08 06:57:23 -05:00
2021-05-20 08:20:04 -04:00
range . selectNodeContents ( element ) ;
selection . removeAllRanges ( ) ;
selection . addRange ( range ) ;
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
selectedText = selection . toString ( ) ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
return selectedText ;
}
2018-12-13 23:41:57 -05:00
2021-05-20 08:20:04 -04:00
module . exports = select ;
2018-12-13 23:41:57 -05:00
2018-12-17 22:14:52 -05:00
2021-05-20 08:20:04 -04:00
/***/ } ) ,
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04:00
/***/ 279 :
/***/ ( function ( module ) {
2020-01-22 17:06:21 -05:00
2021-05-20 08:20:04 -04: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)
}
2020-02-06 16:03:31 -05:00
2021-05-20 08:20:04 -04:00
E . prototype = {
on : function ( name , callback , ctx ) {
var e = this . e || ( this . e = { } ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
( e [ name ] || ( e [ name ] = [ ] ) ) . push ( {
fn : callback ,
ctx : ctx
} ) ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
return this ;
} ,
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
once : function ( name , callback , ctx ) {
var self = this ;
function listener ( ) {
self . off ( name , listener ) ;
callback . apply ( ctx , arguments ) ;
} ;
2020-06-26 09:33:47 -04:00
2021-05-20 08:20:04 -04:00
listener . _ = callback
return this . on ( name , listener , ctx ) ;
} ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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 ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
for ( i ; i < len ; i ++ ) {
evtArr [ i ] . fn . apply ( evtArr [ i ] . ctx , data ) ;
}
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
return this ;
} ,
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
off : function ( name , callback ) {
var e = this . e || ( this . e = { } ) ;
var evts = e [ name ] ;
var liveEvents = [ ] ;
2021-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04: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-01-27 21:04:13 -05:00
2021-05-20 08:20:04 -04:00
( liveEvents . length )
? e [ name ] = liveEvents
: delete e [ name ] ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
return this ;
}
} ;
2021-04-15 11:19:43 -04:00
2021-05-20 08:20:04 -04:00
module . exports = E ;
module . exports . TinyEmitter = E ;
2021-03-04 23:10:44 -05:00
2021-05-07 07:48:27 -04:00
2021-05-20 08:20:04 -04:00
/***/ } )
2020-07-14 07:39:09 -04:00
2021-05-20 08:20:04 -04:00
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // 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
/******/ _ _webpack _modules _ _ [ moduleId ] ( module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ ! function ( ) {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function ( ) { return module [ 'default' ] ; } :
/******/ function ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/define property getters */
/******/ ! function ( ) {
/******/ // define getter functions for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , definition ) {
/******/ 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 ] } ) ;
/******/ }
/******/ }
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ ! function ( ) {
/******/ _ _webpack _require _ _ . o = function ( obj , prop ) { return Object . prototype . hasOwnProperty . call ( obj , prop ) ; }
/******/ } ( ) ;
/******/
/************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return _ _webpack _require _ _ ( 134 ) ;
/******/ } ) ( )
. default ;
} ) ;
2020-10-20 09:36:16 -04:00
2019-09-19 11:19:18 -04:00
/***/ } ) ,
2021-05-20 08:20:04 -04:00
/***/ "wx14" :
2019-10-15 11:37:08 -04:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
2019-09-19 11:19:18 -04:00
2019-10-15 11:37:08 -04:00
"use strict" ;
2020-06-26 09:33:47 -04:00
/* harmony export (binding) */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "a" , function ( ) { return _extends ; } ) ;
function _extends ( ) {
_extends = Object . assign || function ( target ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
var source = arguments [ i ] ;
2019-09-19 11:19:18 -04:00
2020-06-26 09:33:47 -04:00
for ( var key in source ) {
if ( Object . prototype . hasOwnProperty . call ( source , key ) ) {
target [ key ] = source [ key ] ;
}
}
}
return target ;
} ;
return _extends . apply ( this , arguments ) ;
2019-09-19 11:19:18 -04:00
}
2018-12-13 23:41:57 -05:00
/***/ } )
2018-12-17 22:14:52 -05:00
/******/ } ) ;