@wordpress/customize-widgets 2.0.6 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/build/components/block-inspector-button/index.js +6 -5
  2. package/build/components/block-inspector-button/index.js.map +1 -1
  3. package/build/components/customize-widgets/index.js +6 -5
  4. package/build/components/customize-widgets/index.js.map +1 -1
  5. package/build/components/error-boundary/index.js +5 -4
  6. package/build/components/error-boundary/index.js.map +1 -1
  7. package/build/components/focus-control/index.js +6 -5
  8. package/build/components/focus-control/index.js.map +1 -1
  9. package/build/components/header/index.js +8 -7
  10. package/build/components/header/index.js.map +1 -1
  11. package/build/components/inserter/index.js +4 -3
  12. package/build/components/inserter/index.js.map +1 -1
  13. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +4 -3
  14. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  15. package/build/components/keyboard-shortcut-help-modal/index.js +50 -41
  16. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  17. package/build/components/keyboard-shortcut-help-modal/shortcut.js +12 -10
  18. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  19. package/build/components/keyboard-shortcuts/index.js +6 -5
  20. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  21. package/build/components/sidebar-block-editor/index.js +27 -19
  22. package/build/components/sidebar-block-editor/index.js.map +1 -1
  23. package/build/components/sidebar-block-editor/sidebar-adapter.js +7 -3
  24. package/build/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
  25. package/build/components/sidebar-block-editor/sidebar-editor-provider.js +6 -5
  26. package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
  27. package/build/components/sidebar-controls/index.js +8 -7
  28. package/build/components/sidebar-controls/index.js.map +1 -1
  29. package/build/components/welcome-guide/index.js +4 -3
  30. package/build/components/welcome-guide/index.js.map +1 -1
  31. package/build/controls/inserter-outer-section.js +2 -2
  32. package/build/controls/inserter-outer-section.js.map +1 -1
  33. package/build/controls/inspector-section.js +4 -3
  34. package/build/controls/inspector-section.js.map +1 -1
  35. package/build/controls/sidebar-control.js +2 -2
  36. package/build/controls/sidebar-control.js.map +1 -1
  37. package/build/store/index.js +4 -2
  38. package/build/store/index.js.map +1 -1
  39. package/build/store/reducer.js +4 -1
  40. package/build/store/reducer.js.map +1 -1
  41. package/build/store/selectors.js +1 -1
  42. package/build/utils.js +10 -8
  43. package/build/utils.js.map +1 -1
  44. package/build-module/components/block-inspector-button/index.js +6 -5
  45. package/build-module/components/block-inspector-button/index.js.map +1 -1
  46. package/build-module/components/customize-widgets/index.js +6 -5
  47. package/build-module/components/customize-widgets/index.js.map +1 -1
  48. package/build-module/components/error-boundary/index.js +5 -4
  49. package/build-module/components/error-boundary/index.js.map +1 -1
  50. package/build-module/components/focus-control/index.js +6 -5
  51. package/build-module/components/focus-control/index.js.map +1 -1
  52. package/build-module/components/header/index.js +8 -7
  53. package/build-module/components/header/index.js.map +1 -1
  54. package/build-module/components/inserter/index.js +4 -3
  55. package/build-module/components/inserter/index.js.map +1 -1
  56. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +4 -3
  57. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  58. package/build-module/components/keyboard-shortcut-help-modal/index.js +48 -39
  59. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  60. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +12 -10
  61. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  62. package/build-module/components/keyboard-shortcuts/index.js +6 -5
  63. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  64. package/build-module/components/sidebar-block-editor/index.js +27 -19
  65. package/build-module/components/sidebar-block-editor/index.js.map +1 -1
  66. package/build-module/components/sidebar-block-editor/sidebar-adapter.js +7 -3
  67. package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +1 -1
  68. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +6 -5
  69. package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +1 -1
  70. package/build-module/components/sidebar-controls/index.js +6 -5
  71. package/build-module/components/sidebar-controls/index.js.map +1 -1
  72. package/build-module/components/welcome-guide/index.js +4 -3
  73. package/build-module/components/welcome-guide/index.js.map +1 -1
  74. package/build-module/controls/inserter-outer-section.js +2 -2
  75. package/build-module/controls/inserter-outer-section.js.map +1 -1
  76. package/build-module/controls/inspector-section.js +4 -3
  77. package/build-module/controls/inspector-section.js.map +1 -1
  78. package/build-module/controls/sidebar-control.js +2 -2
  79. package/build-module/controls/sidebar-control.js.map +1 -1
  80. package/build-module/store/reducer.js +4 -1
  81. package/build-module/store/reducer.js.map +1 -1
  82. package/build-module/utils.js +9 -7
  83. package/build-module/utils.js.map +1 -1
  84. package/package.json +22 -22
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/index.js"],"names":["defaultTo","store","coreStore","useSelect","useMemo","createPortal","BlockList","BlockTools","BlockSelectionClearer","BlockInspector","CopyHandler","ObserveTyping","WritingFlow","BlockEditorKeyboardShortcuts","__unstableBlockSettingsMenuFirstItem","__unstableEditorStyles","EditorStyles","uploadMedia","interfaceStore","BlockInspectorButton","Header","useInserter","SidebarEditorProvider","WelcomeGuide","KeyboardShortcuts","BlockAppender","SidebarBlockEditor","blockEditorSettings","sidebar","inserter","inspector","isInserterOpened","setIsInserterOpened","hasUploadPermissions","isFixedToolbarActive","keepCaretInsideBlock","isWelcomeGuideActive","select","isFeatureActive","canUser","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalSetIsInserterOpened","mediaUpload","hasFixedToolbar","__unstableHasCustomAppender","undo","redo","save","defaultEditorStyles","event","preventDefault","contentContainer","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA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,IAAA,IAAI,EAAGZ,OAAO,CAACuB,IADhB;AAEC,IAAA,IAAI,EAAGvB,OAAO,CAACwB,IAFhB;AAGC,IAAA,IAAI,EAAGxB,OAAO,CAACyB;AAHhB,IADD,EAOC,cAAC,MAAD;AACC,IAAA,OAAO,EAAGzB,OADX;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,gBAAgB,EAAGE,gBAHpB;AAIC,IAAA,mBAAmB,EAAGC,mBAJvB;AAKC,IAAA,oBAAoB,EAAGE;AALxB,IAPD,EAeC,cAAC,WAAD,QACC,cAAC,UAAD,QACC,cAAC,YAAD;AAAc,IAAA,MAAM,EAAGM,QAAQ,CAACc;AAAhC,IADD,EAEC,cAAC,qBAAD,QACC,cAAC,WAAD;AAAa,IAAA,SAAS,EAAC;AAAvB,KACC,cAAC,aAAD,QACC,cAAC,SAAD;AACC,IAAA,cAAc,EAAG7B;AADlB,IADD,CADD,CADD,CAFD,CADD,CAfD,EA8BGpB,YAAY,EACb;AACA;AACA;AAAM,IAAA,QAAQ,EAAKkD,KAAF,IAAaA,KAAK,CAACC,cAAN;AAA9B,KACC,cAAC,cAAD,OADD,CAHa,EAMb1B,SAAS,CAAC2B,gBAAV,CAA4B,CAA5B,CANa,CA9Bf,CAJD,EA4CC,cAAC,oCAAD,QACG,CAAE;AAAEC,IAAAA;AAAF,GAAF,KACD,cAAC,oBAAD;AACC,IAAA,SAAS,EAAG5B,SADb;AAEC,IAAA,SAAS,EAAG4B;AAFb,IAFF,CA5CD,CADD;AAuDA","sourcesContent":["/**\n * External dependencies\n */\nimport { defaultTo } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, createPortal } from '@wordpress/element';\nimport {\n\tBlockList,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tBlockInspector,\n\tCopyHandler,\n\tObserveTyping,\n\tWritingFlow,\n\tBlockEditorKeyboardShortcuts,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from '../block-inspector-button';\nimport Header from '../header';\nimport useInserter from '../inserter/use-inserter';\nimport SidebarEditorProvider from './sidebar-editor-provider';\nimport WelcomeGuide from '../welcome-guide';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport BlockAppender from '../block-appender';\n\nexport default function SidebarBlockEditor( {\n\tblockEditorSettings,\n\tsidebar,\n\tinserter,\n\tinspector,\n} ) {\n\tconst [ isInserterOpened, setIsInserterOpened ] = useInserter( inserter );\n\tconst {\n\t\thasUploadPermissions,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tisWelcomeGuideActive,\n\t} = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( interfaceStore );\n\t\treturn {\n\t\t\thasUploadPermissions: defaultTo(\n\t\t\t\tselect( coreStore ).canUser( 'create', 'media' ),\n\t\t\t\ttrue\n\t\t\t),\n\t\t\tisFixedToolbarActive: isFeatureActive(\n\t\t\t\t'core/customize-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: isFeatureActive(\n\t\t\t\t'core/customize-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tisWelcomeGuideActive: isFeatureActive(\n\t\t\t\t'core/customize-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\thasFixedToolbar: isFixedToolbarActive,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t__unstableHasCustomAppender: true,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tsetIsInserterOpened,\n\t] );\n\n\tif ( isWelcomeGuideActive ) {\n\t\treturn <WelcomeGuide sidebar={ sidebar } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t<KeyboardShortcuts.Register />\n\n\t\t\t<SidebarEditorProvider sidebar={ sidebar } settings={ settings }>\n\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\tundo={ sidebar.undo }\n\t\t\t\t\tredo={ sidebar.redo }\n\t\t\t\t\tsave={ sidebar.save }\n\t\t\t\t/>\n\n\t\t\t\t<Header\n\t\t\t\t\tsidebar={ sidebar }\n\t\t\t\t\tinserter={ inserter }\n\t\t\t\t\tisInserterOpened={ isInserterOpened }\n\t\t\t\t\tsetIsInserterOpened={ setIsInserterOpened }\n\t\t\t\t\tisFixedToolbarActive={ isFixedToolbarActive }\n\t\t\t\t/>\n\n\t\t\t\t<CopyHandler>\n\t\t\t\t\t<BlockTools>\n\t\t\t\t\t\t<EditorStyles styles={ settings.defaultEditorStyles } />\n\t\t\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t\t\t<WritingFlow className=\"editor-styles-wrapper\">\n\t\t\t\t\t\t\t\t<ObserveTyping>\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\trenderAppender={ BlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ObserveTyping>\n\t\t\t\t\t\t\t</WritingFlow>\n\t\t\t\t\t\t</BlockSelectionClearer>\n\t\t\t\t\t</BlockTools>\n\t\t\t\t</CopyHandler>\n\n\t\t\t\t{ createPortal(\n\t\t\t\t\t// This is a temporary hack to prevent button component inside <BlockInspector>\n\t\t\t\t\t// from submitting form when type=\"button\" is not specified.\n\t\t\t\t\t<form onSubmit={ ( event ) => event.preventDefault() }>\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t</form>,\n\t\t\t\t\tinspector.contentContainer[ 0 ]\n\t\t\t\t) }\n\t\t\t</SidebarEditorProvider>\n\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton\n\t\t\t\t\t\tinspector={ inspector }\n\t\t\t\t\t\tcloseMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/index.js"],"names":["defaultTo","store","coreStore","useSelect","useMemo","createPortal","BlockList","BlockTools","BlockSelectionClearer","BlockInspector","CopyHandler","ObserveTyping","WritingFlow","BlockEditorKeyboardShortcuts","__unstableBlockSettingsMenuFirstItem","__unstableEditorStyles","EditorStyles","uploadMedia","interfaceStore","BlockInspectorButton","Header","useInserter","SidebarEditorProvider","WelcomeGuide","KeyboardShortcuts","BlockAppender","SidebarBlockEditor","blockEditorSettings","sidebar","inserter","inspector","isInserterOpened","setIsInserterOpened","hasUploadPermissions","isFixedToolbarActive","keepCaretInsideBlock","isWelcomeGuideActive","select","isFeatureActive","canUser","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalSetIsInserterOpened","mediaUpload","hasFixedToolbar","__unstableHasCustomAppender","undo","redo","save","defaultEditorStyles","event","preventDefault","contentContainer","onClose"],"m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D,EAIC,cAAC,qBAAD;AAAuB,IAAA,OAAO,EAAGA,OAAjC;AAA2C,IAAA,QAAQ,EAAGY;AAAtD,KACC,cAAC,iBAAD;AACC,IAAA,IAAI,EAAGZ,OAAO,CAACuB,IADhB;AAEC,IAAA,IAAI,EAAGvB,OAAO,CAACwB,IAFhB;AAGC,IAAA,IAAI,EAAGxB,OAAO,CAACyB;AAHhB,IADD,EAOC,cAAC,MAAD;AACC,IAAA,OAAO,EAAGzB,OADX;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,gBAAgB,EAAGE,gBAHpB;AAIC,IAAA,mBAAmB,EAAGC,mBAJvB;AAKC,IAAA,oBAAoB,EAAGE;AALxB,IAPD,EAeC,cAAC,WAAD,QACC,cAAC,UAAD,QACC,cAAC,YAAD;AAAc,IAAA,MAAM,EAAGM,QAAQ,CAACc;AAAhC,IADD,EAEC,cAAC,qBAAD,QACC,cAAC,WAAD;AAAa,IAAA,SAAS,EAAC;AAAvB,KACC,cAAC,aAAD,QACC,cAAC,SAAD;AACC,IAAA,cAAc,EAAG7B;AADlB,IADD,CADD,CADD,CAFD,CADD,CAfD,EA8BGpB,YAAY,EACb;AACA;AACA;AAAM,IAAA,QAAQ,EAAKkD,KAAF,IAAaA,KAAK,CAACC,cAAN;AAA9B,KACC,cAAC,cAAD,OADD,CAHa,EAMb1B,SAAS,CAAC2B,gBAAV,CAA4B,CAA5B,CANa,CA9Bf,CAJD,EA4CC,cAAC,oCAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,oBAAD;AACC,MAAA,SAAS,EAAG5B,SADb;AAEC,MAAA,SAAS,EAAG4B;AAFb,MADC;AAAA,GADH,CA5CD,CADD;AAuDA","sourcesContent":["/**\n * External dependencies\n */\nimport { defaultTo } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, createPortal } from '@wordpress/element';\nimport {\n\tBlockList,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tBlockInspector,\n\tCopyHandler,\n\tObserveTyping,\n\tWritingFlow,\n\tBlockEditorKeyboardShortcuts,\n\t__unstableBlockSettingsMenuFirstItem,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport BlockInspectorButton from '../block-inspector-button';\nimport Header from '../header';\nimport useInserter from '../inserter/use-inserter';\nimport SidebarEditorProvider from './sidebar-editor-provider';\nimport WelcomeGuide from '../welcome-guide';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport BlockAppender from '../block-appender';\n\nexport default function SidebarBlockEditor( {\n\tblockEditorSettings,\n\tsidebar,\n\tinserter,\n\tinspector,\n} ) {\n\tconst [ isInserterOpened, setIsInserterOpened ] = useInserter( inserter );\n\tconst {\n\t\thasUploadPermissions,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tisWelcomeGuideActive,\n\t} = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( interfaceStore );\n\t\treturn {\n\t\t\thasUploadPermissions: defaultTo(\n\t\t\t\tselect( coreStore ).canUser( 'create', 'media' ),\n\t\t\t\ttrue\n\t\t\t),\n\t\t\tisFixedToolbarActive: isFeatureActive(\n\t\t\t\t'core/customize-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: isFeatureActive(\n\t\t\t\t'core/customize-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tisWelcomeGuideActive: isFeatureActive(\n\t\t\t\t'core/customize-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\thasFixedToolbar: isFixedToolbarActive,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t__unstableHasCustomAppender: true,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tsetIsInserterOpened,\n\t] );\n\n\tif ( isWelcomeGuideActive ) {\n\t\treturn <WelcomeGuide sidebar={ sidebar } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t<KeyboardShortcuts.Register />\n\n\t\t\t<SidebarEditorProvider sidebar={ sidebar } settings={ settings }>\n\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\tundo={ sidebar.undo }\n\t\t\t\t\tredo={ sidebar.redo }\n\t\t\t\t\tsave={ sidebar.save }\n\t\t\t\t/>\n\n\t\t\t\t<Header\n\t\t\t\t\tsidebar={ sidebar }\n\t\t\t\t\tinserter={ inserter }\n\t\t\t\t\tisInserterOpened={ isInserterOpened }\n\t\t\t\t\tsetIsInserterOpened={ setIsInserterOpened }\n\t\t\t\t\tisFixedToolbarActive={ isFixedToolbarActive }\n\t\t\t\t/>\n\n\t\t\t\t<CopyHandler>\n\t\t\t\t\t<BlockTools>\n\t\t\t\t\t\t<EditorStyles styles={ settings.defaultEditorStyles } />\n\t\t\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t\t\t<WritingFlow className=\"editor-styles-wrapper\">\n\t\t\t\t\t\t\t\t<ObserveTyping>\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\trenderAppender={ BlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ObserveTyping>\n\t\t\t\t\t\t\t</WritingFlow>\n\t\t\t\t\t\t</BlockSelectionClearer>\n\t\t\t\t\t</BlockTools>\n\t\t\t\t</CopyHandler>\n\n\t\t\t\t{ createPortal(\n\t\t\t\t\t// This is a temporary hack to prevent button component inside <BlockInspector>\n\t\t\t\t\t// from submitting form when type=\"button\" is not specified.\n\t\t\t\t\t<form onSubmit={ ( event ) => event.preventDefault() }>\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t</form>,\n\t\t\t\t\tinspector.contentContainer[ 0 ]\n\t\t\t\t) }\n\t\t\t</SidebarEditorProvider>\n\n\t\t\t<__unstableBlockSettingsMenuFirstItem>\n\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t<BlockInspectorButton\n\t\t\t\t\t\tinspector={ inspector }\n\t\t\t\t\t\tcloseMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</__unstableBlockSettingsMenuFirstItem>\n\t\t</>\n\t);\n}\n"]}
@@ -49,7 +49,11 @@ function debounce(leading, callback, timeout) {
49
49
  let isLeading = false;
50
50
  let timerID;
51
51
 
52
- function debounced(...args) {
52
+ function debounced() {
53
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54
+ args[_key] = arguments[_key];
55
+ }
56
+
53
57
  const result = (isLeading ? callback : leading).apply(this, args);
54
58
  isLeading = true;
55
59
  clearTimeout(timerID);
@@ -97,9 +101,9 @@ export default class SidebarAdapter {
97
101
  return this.history[this.historyIndex];
98
102
  }
99
103
 
100
- _emit(...args) {
104
+ _emit() {
101
105
  for (const callback of this.subscribers) {
102
- callback(...args);
106
+ callback(...arguments);
103
107
  }
104
108
  }
105
109
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/sidebar-adapter.js"],"names":["settingIdToWidgetId","wp","window","parseWidgetId","widgetId","matches","match","idBase","number","parseInt","widgetIdToSettingId","debounce","leading","callback","timeout","isLeading","timerID","debounced","args","result","apply","clearTimeout","setTimeout","cancel","SidebarAdapter","constructor","setting","api","locked","widgetsCache","WeakMap","subscribers","Set","history","_getWidgetIds","map","getWidget","historyIndex","historySubscribers","_debounceSetHistory","_pushHistory","_replaceHistory","bind","_handleSettingChange","_handleAllSettingsChange","undo","redo","save","subscribe","add","delete","getWidgets","_emit","get","slice","forEach","listener","prevWidgets","id","startsWith","includes","_createWidget","widget","widgetModel","customize","Widgets","availableWidgets","findWhere","id_base","set","settingId","settingArgs","transport","data","selectiveRefreshableWidgets","previewer","create","instance","_removeWidget","remove","_updateWidget","prevWidget","has","_updateWidgets","nextWidgets","addedWidgetIds","nextWidgetIds","nextWidget","push","deletedWidgets","filter","setWidgets","hasUndo","hasRedo","length","_seek","currentWidgets","widgets","subscribeHistory"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAT,QAAoC,aAApC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAASC,MAAf;;AAEA,SAASC,aAAT,CAAwBC,QAAxB,EAAmC;AAClC,QAAMC,OAAO,GAAGD,QAAQ,CAACE,KAAT,CAAgB,cAAhB,CAAhB;;AACA,MAAKD,OAAL,EAAe;AACd,WAAO;AACNE,MAAAA,MAAM,EAAEF,OAAO,CAAE,CAAF,CADT;AAENG,MAAAA,MAAM,EAAEC,QAAQ,CAAEJ,OAAO,CAAE,CAAF,CAAT,EAAgB,EAAhB;AAFV,KAAP;AAIA,GAPiC,CASlC;;;AACA,SAAO;AAAEE,IAAAA,MAAM,EAAEH;AAAV,GAAP;AACA;;AAED,SAASM,mBAAT,CAA8BN,QAA9B,EAAyC;AACxC,QAAM;AAAEG,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAqBL,aAAa,CAAEC,QAAF,CAAxC;;A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;;AAEDT,EAAAA,IAAI,GAAG;AACN,SAAKpB,GAAL,CAASgD,SAAT,CAAmB5B,IAAnB;AACA;;AA/SkC","sourcesContent":["/**\n * Internal dependencies\n */\nimport { settingIdToWidgetId } from '../../utils';\n\nconst { wp } = window;\n\nfunction parseWidgetId( widgetId ) {\n\tconst matches = widgetId.match( /^(.+)-(\\d+)$/ );\n\tif ( matches ) {\n\t\treturn {\n\t\t\tidBase: matches[ 1 ],\n\t\t\tnumber: parseInt( matches[ 2 ], 10 ),\n\t\t};\n\t}\n\n\t// Likely an old single widget.\n\treturn { idBase: widgetId };\n}\n\nfunction widgetIdToSettingId( widgetId ) {\n\tconst { idBase, number } = parseWidgetId( widgetId );\n\tif ( number ) {\n\t\treturn `widget_${ idBase }[${ number }]`;\n\t}\n\n\treturn `widget_${ idBase }`;\n}\n\n/**\n * This is a custom debounce function to call different callbacks depending on\n * whether it's the _leading_ call or not.\n *\n * @param {Function} leading The callback that gets called first.\n * @param {Function} callback The callback that gets called after the first time.\n * @param {number} timeout The debounced time in milliseconds.\n * @return {Function} The debounced function.\n */\nfunction debounce( leading, callback, timeout ) {\n\tlet isLeading = false;\n\tlet timerID;\n\n\tfunction debounced( ...args ) {\n\t\tconst result = ( isLeading ? callback : leading ).apply( this, args );\n\n\t\tisLeading = true;\n\n\t\tclearTimeout( timerID );\n\n\t\ttimerID = setTimeout( () => {\n\t\t\tisLeading = false;\n\t\t}, timeout );\n\n\t\treturn result;\n\t}\n\n\tdebounced.cancel = () => {\n\t\tisLeading = false;\n\t\tclearTimeout( timerID );\n\t};\n\n\treturn debounced;\n}\n\nexport default class SidebarAdapter {\n\tconstructor( setting, api ) {\n\t\tthis.setting = setting;\n\t\tthis.api = api;\n\n\t\tthis.locked = false;\n\t\tthis.widgetsCache = new WeakMap();\n\t\tthis.subscribers = new Set();\n\n\t\tthis.history = [\n\t\t\tthis._getWidgetIds().map( ( widgetId ) =>\n\t\t\t\tthis.getWidget( widgetId )\n\t\t\t),\n\t\t];\n\t\tthis.historyIndex = 0;\n\t\tthis.historySubscribers = new Set();\n\t\t// Debounce the input for 1 second.\n\t\tthis._debounceSetHistory = debounce(\n\t\t\tthis._pushHistory,\n\t\t\tthis._replaceHistory,\n\t\t\t1000\n\t\t);\n\n\t\tthis.setting.bind( this._handleSettingChange.bind( this ) );\n\t\tthis.api.bind( 'change', this._handleAllSettingsChange.bind( this ) );\n\n\t\tthis.undo = this.undo.bind( this );\n\t\tthis.redo = this.redo.bind( this );\n\t\tthis.save = this.save.bind( this );\n\t}\n\n\tsubscribe( callback ) {\n\t\tthis.subscribers.add( callback );\n\n\t\treturn () => {\n\t\t\tthis.subscribers.delete( callback );\n\t\t};\n\t}\n\n\tgetWidgets() {\n\t\treturn this.history[ this.historyIndex ];\n\t}\n\n\t_emit( ...args ) {\n\t\tfor ( const callback of this.subscribers ) {\n\t\t\tcallback( ...args );\n\t\t}\n\t}\n\n\t_getWidgetIds() {\n\t\treturn this.setting.get();\n\t}\n\n\t_pushHistory() {\n\t\tthis.history = [\n\t\t\t...this.history.slice( 0, this.historyIndex + 1 ),\n\t\t\tthis._getWidgetIds().map( ( widgetId ) =>\n\t\t\t\tthis.getWidget( widgetId )\n\t\t\t),\n\t\t];\n\t\tthis.historyIndex += 1;\n\n\t\tthis.historySubscribers.forEach( ( listener ) => listener() );\n\t}\n\n\t_replaceHistory() {\n\t\tthis.history[\n\t\t\tthis.historyIndex\n\t\t] = this._getWidgetIds().map( ( widgetId ) =>\n\t\t\tthis.getWidget( widgetId )\n\t\t);\n\t}\n\n\t_handleSettingChange() {\n\t\tif ( this.locked ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevWidgets = this.getWidgets();\n\n\t\tthis._pushHistory();\n\n\t\tthis._emit( prevWidgets, this.getWidgets() );\n\t}\n\n\t_handleAllSettingsChange( setting ) {\n\t\tif ( this.locked ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! setting.id.startsWith( 'widget_' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst widgetId = settingIdToWidgetId( setting.id );\n\t\tif ( ! this.setting.get().includes( widgetId ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevWidgets = this.getWidgets();\n\n\t\tthis._pushHistory();\n\n\t\tthis._emit( prevWidgets, this.getWidgets() );\n\t}\n\n\t_createWidget( widget ) {\n\t\tconst widgetModel = wp.customize.Widgets.availableWidgets.findWhere( {\n\t\t\tid_base: widget.idBase,\n\t\t} );\n\n\t\tlet number = widget.number;\n\t\tif ( widgetModel.get( 'is_multi' ) && ! number ) {\n\t\t\twidgetModel.set(\n\t\t\t\t'multi_number',\n\t\t\t\twidgetModel.get( 'multi_number' ) + 1\n\t\t\t);\n\t\t\tnumber = widgetModel.get( 'multi_number' );\n\t\t}\n\n\t\tconst settingId = number\n\t\t\t? `widget_${ widget.idBase }[${ number }]`\n\t\t\t: `widget_${ widget.idBase }`;\n\n\t\tconst settingArgs = {\n\t\t\ttransport: wp.customize.Widgets.data.selectiveRefreshableWidgets[\n\t\t\t\twidgetModel.get( 'id_base' )\n\t\t\t]\n\t\t\t\t? 'postMessage'\n\t\t\t\t: 'refresh',\n\t\t\tpreviewer: this.setting.previewer,\n\t\t};\n\t\tconst setting = this.api.create(\n\t\t\tsettingId,\n\t\t\tsettingId,\n\t\t\t'',\n\t\t\tsettingArgs\n\t\t);\n\t\tsetting.set( widget.instance );\n\n\t\tconst widgetId = settingIdToWidgetId( settingId );\n\n\t\treturn widgetId;\n\t}\n\n\t_removeWidget( widget ) {\n\t\tconst settingId = widgetIdToSettingId( widget.id );\n\t\tconst setting = this.api( settingId );\n\n\t\tif ( setting ) {\n\t\t\tconst instance = setting.get();\n\t\t\tthis.widgetsCache.delete( instance );\n\t\t}\n\n\t\tthis.api.remove( settingId );\n\t}\n\n\t_updateWidget( widget ) {\n\t\tconst prevWidget = this.getWidget( widget.id );\n\n\t\t// Bail out update if nothing changed.\n\t\tif ( prevWidget === widget ) {\n\t\t\treturn widget.id;\n\t\t}\n\n\t\t// Update existing setting if only the widget's instance changed.\n\t\tif (\n\t\t\tprevWidget.idBase &&\n\t\t\twidget.idBase &&\n\t\t\tprevWidget.idBase === widget.idBase\n\t\t) {\n\t\t\tconst settingId = widgetIdToSettingId( widget.id );\n\t\t\tthis.api( settingId ).set( widget.instance );\n\t\t\treturn widget.id;\n\t\t}\n\n\t\t// Otherwise delete and re-create.\n\t\tthis._removeWidget( widget );\n\t\treturn this._createWidget( widget );\n\t}\n\n\tgetWidget( widgetId ) {\n\t\tif ( ! widgetId ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { idBase, number } = parseWidgetId( widgetId );\n\t\tconst settingId = widgetIdToSettingId( widgetId );\n\t\tconst setting = this.api( settingId );\n\n\t\tif ( ! setting ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst instance = setting.get();\n\n\t\tif ( this.widgetsCache.has( instance ) ) {\n\t\t\treturn this.widgetsCache.get( instance );\n\t\t}\n\n\t\tconst widget = {\n\t\t\tid: widgetId,\n\t\t\tidBase,\n\t\t\tnumber,\n\t\t\tinstance,\n\t\t};\n\n\t\tthis.widgetsCache.set( instance, widget );\n\n\t\treturn widget;\n\t}\n\n\t_updateWidgets( nextWidgets ) {\n\t\tthis.locked = true;\n\n\t\tconst addedWidgetIds = [];\n\n\t\tconst nextWidgetIds = nextWidgets.map( ( nextWidget ) => {\n\t\t\tif ( nextWidget.id && this.getWidget( nextWidget.id ) ) {\n\t\t\t\taddedWidgetIds.push( null );\n\n\t\t\t\treturn this._updateWidget( nextWidget );\n\t\t\t}\n\n\t\t\tconst widgetId = this._createWidget( nextWidget );\n\n\t\t\taddedWidgetIds.push( widgetId );\n\n\t\t\treturn widgetId;\n\t\t} );\n\n\t\tconst deletedWidgets = this.getWidgets().filter(\n\t\t\t( widget ) => ! nextWidgetIds.includes( widget.id )\n\t\t);\n\t\tdeletedWidgets.forEach( ( widget ) => this._removeWidget( widget ) );\n\n\t\tthis.setting.set( nextWidgetIds );\n\n\t\tthis.locked = false;\n\n\t\treturn addedWidgetIds;\n\t}\n\n\tsetWidgets( nextWidgets ) {\n\t\tconst addedWidgetIds = this._updateWidgets( nextWidgets );\n\n\t\tthis._debounceSetHistory();\n\n\t\treturn addedWidgetIds;\n\t}\n\n\t/**\n\t * Undo/Redo related features\n\t */\n\thasUndo() {\n\t\treturn this.historyIndex > 0;\n\t}\n\n\thasRedo() {\n\t\treturn this.historyIndex < this.history.length - 1;\n\t}\n\n\t_seek( historyIndex ) {\n\t\tconst currentWidgets = this.getWidgets();\n\n\t\tthis.historyIndex = historyIndex;\n\n\t\tconst widgets = this.history[ this.historyIndex ];\n\n\t\tthis._updateWidgets( widgets );\n\n\t\tthis._emit( currentWidgets, this.getWidgets() );\n\n\t\tthis.historySubscribers.forEach( ( listener ) => listener() );\n\t\tthis._debounceSetHistory.cancel();\n\t}\n\n\tundo() {\n\t\tif ( ! this.hasUndo() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._seek( this.historyIndex - 1 );\n\t}\n\n\tredo() {\n\t\tif ( ! this.hasRedo() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._seek( this.historyIndex + 1 );\n\t}\n\n\tsubscribeHistory( listener ) {\n\t\tthis.historySubscribers.add( listener );\n\n\t\treturn () => {\n\t\t\tthis.historySubscribers.delete( listener );\n\t\t};\n\t}\n\n\tsave() {\n\t\tthis.api.previewer.save();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/sidebar-adapter.js"],"names":["settingIdToWidgetId","wp","window","parseWidgetId","widgetId","matches","match","idBase","number","parseInt","widgetIdToSettingId","debounce","leading","callback","timeout","isLeading","timerID","debounced","args","result","apply","clearTimeout","setTimeout","cancel","SidebarAdapter","constructor","setting","api","locked","widgetsCache","WeakMap","subscribers","Set","history","_getWidgetIds","map","getWidget","historyIndex","historySubscribers","_debounceSetHistory","_pushHistory","_replaceHistory","bind","_handleSettingChange","_handleAllSettingsChange","undo","redo","save","subscribe","add","delete","getWidgets","_emit","get","slice","forEach","listener","prevWidgets","id","startsWith","includes","_createWidget","widget","widgetModel","customize","Widgets","availableWidgets","findWhere","id_base","set","settingId","settingArgs","transport","data","selectiveRefreshableWidgets","previewer","create","instance","_removeWidget","remove","_updateWidget","prevWidget","has","_updateWidgets","nextWidgets","addedWidgetIds","nextWidgetIds","nextWidget","push","deletedWidgets","filter","setWidgets","hasUndo","hasRedo","length","_seek","currentWidgets","widgets","subscribeHistory"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAT,QAAoC,aAApC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAASC,MAAf;;AAEA,SAASC,aAAT,CAAwBC,QAAxB,EAAmC;AAClC,QAAMC,OAAO,GAAGD,QAAQ,CAACE,KAAT,CAAgB,cAAhB,CAAhB;;AACA,MAAKD,OAAL,EAAe;AACd,WAAO;AACNE,MAAAA,MAAM,EAAEF,OAAO,CAAE,CAAF,CADT;AAENG,MAAAA,MAAM,EAAEC,QAAQ,CAAEJ,OAAO,CAAE,CAAF,CAAT,EAAgB,EAAhB;AAFV,KAAP;AAIA,GAPiC,CASlC;;;AACA,SAAO;AAAEE,IAAAA,MAAM,EAAEH;AAAV,GAAP;AACA;;AAED,SAASM,mBAAT,CAA8BN,QAA9B,EAAyC;AACxC,QAAM;AAAEG,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAqBL,aAAa,CAAEC,QAAF,CAAxC;;AACA,MAAKI,MAAL,EAAc;AACb,WAAQ,UAAUD,MAAQ,IAAIC,MAAQ,GAAtC;AACA;;AAED,SAAQ,UAAUD,MAAQ,EAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,QAAT,CAAmBC,OAAnB,EAA4BC,QAA5B,EAAsCC,OAAtC,EAAgD;AAC/C,MAAIC,SAAS,GAAG,KAAhB;AACA,MAAIC,OAAJ;;AAEA,WAASC,SAAT,GAA8B;AAAA,sCAAPC,IAAO;AAA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CAAjD;AACA;;AAEDC,EAAAA,KAAK,CAAE1D,YAAF,EAAiB;AACrB,UAAM2D,cAAc,GAAG,KAAK7C,UAAL,EAAvB;AAEA,SAAKd,YAAL,GAAoBA,YAApB;AAEA,UAAM4D,OAAO,GAAG,KAAKhE,OAAL,CAAc,KAAKI,YAAnB,CAAhB;;AAEA,SAAK8C,cAAL,CAAqBc,OAArB;;AAEA,SAAK7C,KAAL,CAAY4C,cAAZ,EAA4B,KAAK7C,UAAL,EAA5B;;AAEA,SAAKb,kBAAL,CAAwBiB,OAAxB,CAAmCC,QAAF,IAAgBA,QAAQ,EAAzD;;AACA,SAAKjB,mBAAL,CAAyBhB,MAAzB;AACA;;AAEDsB,EAAAA,IAAI,GAAG;AACN,QAAK,CAAE,KAAK+C,OAAL,EAAP,EAAwB;AACvB;AACA;;AAED,SAAKG,KAAL,CAAY,KAAK1D,YAAL,GAAoB,CAAhC;AACA;;AAEDS,EAAAA,IAAI,GAAG;AACN,QAAK,CAAE,KAAK+C,OAAL,EAAP,EAAwB;AACvB;AACA;;AAED,SAAKE,KAAL,CAAY,KAAK1D,YAAL,GAAoB,CAAhC;AACA;;AAED6D,EAAAA,gBAAgB,CAAE1C,QAAF,EAAa;AAC5B,SAAKlB,kBAAL,CAAwBW,GAAxB,CAA6BO,QAA7B;AAEA,WAAO,MAAM;AACZ,WAAKlB,kBAAL,CAAwBY,MAAxB,CAAgCM,QAAhC;AACA,KAFD;AAGA;;AAEDT,EAAAA,IAAI,GAAG;AACN,SAAKpB,GAAL,CAASgD,SAAT,CAAmB5B,IAAnB;AACA;;AA/SkC","sourcesContent":["/**\n * Internal dependencies\n */\nimport { settingIdToWidgetId } from '../../utils';\n\nconst { wp } = window;\n\nfunction parseWidgetId( widgetId ) {\n\tconst matches = widgetId.match( /^(.+)-(\\d+)$/ );\n\tif ( matches ) {\n\t\treturn {\n\t\t\tidBase: matches[ 1 ],\n\t\t\tnumber: parseInt( matches[ 2 ], 10 ),\n\t\t};\n\t}\n\n\t// Likely an old single widget.\n\treturn { idBase: widgetId };\n}\n\nfunction widgetIdToSettingId( widgetId ) {\n\tconst { idBase, number } = parseWidgetId( widgetId );\n\tif ( number ) {\n\t\treturn `widget_${ idBase }[${ number }]`;\n\t}\n\n\treturn `widget_${ idBase }`;\n}\n\n/**\n * This is a custom debounce function to call different callbacks depending on\n * whether it's the _leading_ call or not.\n *\n * @param {Function} leading The callback that gets called first.\n * @param {Function} callback The callback that gets called after the first time.\n * @param {number} timeout The debounced time in milliseconds.\n * @return {Function} The debounced function.\n */\nfunction debounce( leading, callback, timeout ) {\n\tlet isLeading = false;\n\tlet timerID;\n\n\tfunction debounced( ...args ) {\n\t\tconst result = ( isLeading ? callback : leading ).apply( this, args );\n\n\t\tisLeading = true;\n\n\t\tclearTimeout( timerID );\n\n\t\ttimerID = setTimeout( () => {\n\t\t\tisLeading = false;\n\t\t}, timeout );\n\n\t\treturn result;\n\t}\n\n\tdebounced.cancel = () => {\n\t\tisLeading = false;\n\t\tclearTimeout( timerID );\n\t};\n\n\treturn debounced;\n}\n\nexport default class SidebarAdapter {\n\tconstructor( setting, api ) {\n\t\tthis.setting = setting;\n\t\tthis.api = api;\n\n\t\tthis.locked = false;\n\t\tthis.widgetsCache = new WeakMap();\n\t\tthis.subscribers = new Set();\n\n\t\tthis.history = [\n\t\t\tthis._getWidgetIds().map( ( widgetId ) =>\n\t\t\t\tthis.getWidget( widgetId )\n\t\t\t),\n\t\t];\n\t\tthis.historyIndex = 0;\n\t\tthis.historySubscribers = new Set();\n\t\t// Debounce the input for 1 second.\n\t\tthis._debounceSetHistory = debounce(\n\t\t\tthis._pushHistory,\n\t\t\tthis._replaceHistory,\n\t\t\t1000\n\t\t);\n\n\t\tthis.setting.bind( this._handleSettingChange.bind( this ) );\n\t\tthis.api.bind( 'change', this._handleAllSettingsChange.bind( this ) );\n\n\t\tthis.undo = this.undo.bind( this );\n\t\tthis.redo = this.redo.bind( this );\n\t\tthis.save = this.save.bind( this );\n\t}\n\n\tsubscribe( callback ) {\n\t\tthis.subscribers.add( callback );\n\n\t\treturn () => {\n\t\t\tthis.subscribers.delete( callback );\n\t\t};\n\t}\n\n\tgetWidgets() {\n\t\treturn this.history[ this.historyIndex ];\n\t}\n\n\t_emit( ...args ) {\n\t\tfor ( const callback of this.subscribers ) {\n\t\t\tcallback( ...args );\n\t\t}\n\t}\n\n\t_getWidgetIds() {\n\t\treturn this.setting.get();\n\t}\n\n\t_pushHistory() {\n\t\tthis.history = [\n\t\t\t...this.history.slice( 0, this.historyIndex + 1 ),\n\t\t\tthis._getWidgetIds().map( ( widgetId ) =>\n\t\t\t\tthis.getWidget( widgetId )\n\t\t\t),\n\t\t];\n\t\tthis.historyIndex += 1;\n\n\t\tthis.historySubscribers.forEach( ( listener ) => listener() );\n\t}\n\n\t_replaceHistory() {\n\t\tthis.history[\n\t\t\tthis.historyIndex\n\t\t] = this._getWidgetIds().map( ( widgetId ) =>\n\t\t\tthis.getWidget( widgetId )\n\t\t);\n\t}\n\n\t_handleSettingChange() {\n\t\tif ( this.locked ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevWidgets = this.getWidgets();\n\n\t\tthis._pushHistory();\n\n\t\tthis._emit( prevWidgets, this.getWidgets() );\n\t}\n\n\t_handleAllSettingsChange( setting ) {\n\t\tif ( this.locked ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! setting.id.startsWith( 'widget_' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst widgetId = settingIdToWidgetId( setting.id );\n\t\tif ( ! this.setting.get().includes( widgetId ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevWidgets = this.getWidgets();\n\n\t\tthis._pushHistory();\n\n\t\tthis._emit( prevWidgets, this.getWidgets() );\n\t}\n\n\t_createWidget( widget ) {\n\t\tconst widgetModel = wp.customize.Widgets.availableWidgets.findWhere( {\n\t\t\tid_base: widget.idBase,\n\t\t} );\n\n\t\tlet number = widget.number;\n\t\tif ( widgetModel.get( 'is_multi' ) && ! number ) {\n\t\t\twidgetModel.set(\n\t\t\t\t'multi_number',\n\t\t\t\twidgetModel.get( 'multi_number' ) + 1\n\t\t\t);\n\t\t\tnumber = widgetModel.get( 'multi_number' );\n\t\t}\n\n\t\tconst settingId = number\n\t\t\t? `widget_${ widget.idBase }[${ number }]`\n\t\t\t: `widget_${ widget.idBase }`;\n\n\t\tconst settingArgs = {\n\t\t\ttransport: wp.customize.Widgets.data.selectiveRefreshableWidgets[\n\t\t\t\twidgetModel.get( 'id_base' )\n\t\t\t]\n\t\t\t\t? 'postMessage'\n\t\t\t\t: 'refresh',\n\t\t\tpreviewer: this.setting.previewer,\n\t\t};\n\t\tconst setting = this.api.create(\n\t\t\tsettingId,\n\t\t\tsettingId,\n\t\t\t'',\n\t\t\tsettingArgs\n\t\t);\n\t\tsetting.set( widget.instance );\n\n\t\tconst widgetId = settingIdToWidgetId( settingId );\n\n\t\treturn widgetId;\n\t}\n\n\t_removeWidget( widget ) {\n\t\tconst settingId = widgetIdToSettingId( widget.id );\n\t\tconst setting = this.api( settingId );\n\n\t\tif ( setting ) {\n\t\t\tconst instance = setting.get();\n\t\t\tthis.widgetsCache.delete( instance );\n\t\t}\n\n\t\tthis.api.remove( settingId );\n\t}\n\n\t_updateWidget( widget ) {\n\t\tconst prevWidget = this.getWidget( widget.id );\n\n\t\t// Bail out update if nothing changed.\n\t\tif ( prevWidget === widget ) {\n\t\t\treturn widget.id;\n\t\t}\n\n\t\t// Update existing setting if only the widget's instance changed.\n\t\tif (\n\t\t\tprevWidget.idBase &&\n\t\t\twidget.idBase &&\n\t\t\tprevWidget.idBase === widget.idBase\n\t\t) {\n\t\t\tconst settingId = widgetIdToSettingId( widget.id );\n\t\t\tthis.api( settingId ).set( widget.instance );\n\t\t\treturn widget.id;\n\t\t}\n\n\t\t// Otherwise delete and re-create.\n\t\tthis._removeWidget( widget );\n\t\treturn this._createWidget( widget );\n\t}\n\n\tgetWidget( widgetId ) {\n\t\tif ( ! widgetId ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { idBase, number } = parseWidgetId( widgetId );\n\t\tconst settingId = widgetIdToSettingId( widgetId );\n\t\tconst setting = this.api( settingId );\n\n\t\tif ( ! setting ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst instance = setting.get();\n\n\t\tif ( this.widgetsCache.has( instance ) ) {\n\t\t\treturn this.widgetsCache.get( instance );\n\t\t}\n\n\t\tconst widget = {\n\t\t\tid: widgetId,\n\t\t\tidBase,\n\t\t\tnumber,\n\t\t\tinstance,\n\t\t};\n\n\t\tthis.widgetsCache.set( instance, widget );\n\n\t\treturn widget;\n\t}\n\n\t_updateWidgets( nextWidgets ) {\n\t\tthis.locked = true;\n\n\t\tconst addedWidgetIds = [];\n\n\t\tconst nextWidgetIds = nextWidgets.map( ( nextWidget ) => {\n\t\t\tif ( nextWidget.id && this.getWidget( nextWidget.id ) ) {\n\t\t\t\taddedWidgetIds.push( null );\n\n\t\t\t\treturn this._updateWidget( nextWidget );\n\t\t\t}\n\n\t\t\tconst widgetId = this._createWidget( nextWidget );\n\n\t\t\taddedWidgetIds.push( widgetId );\n\n\t\t\treturn widgetId;\n\t\t} );\n\n\t\tconst deletedWidgets = this.getWidgets().filter(\n\t\t\t( widget ) => ! nextWidgetIds.includes( widget.id )\n\t\t);\n\t\tdeletedWidgets.forEach( ( widget ) => this._removeWidget( widget ) );\n\n\t\tthis.setting.set( nextWidgetIds );\n\n\t\tthis.locked = false;\n\n\t\treturn addedWidgetIds;\n\t}\n\n\tsetWidgets( nextWidgets ) {\n\t\tconst addedWidgetIds = this._updateWidgets( nextWidgets );\n\n\t\tthis._debounceSetHistory();\n\n\t\treturn addedWidgetIds;\n\t}\n\n\t/**\n\t * Undo/Redo related features\n\t */\n\thasUndo() {\n\t\treturn this.historyIndex > 0;\n\t}\n\n\thasRedo() {\n\t\treturn this.historyIndex < this.history.length - 1;\n\t}\n\n\t_seek( historyIndex ) {\n\t\tconst currentWidgets = this.getWidgets();\n\n\t\tthis.historyIndex = historyIndex;\n\n\t\tconst widgets = this.history[ this.historyIndex ];\n\n\t\tthis._updateWidgets( widgets );\n\n\t\tthis._emit( currentWidgets, this.getWidgets() );\n\n\t\tthis.historySubscribers.forEach( ( listener ) => listener() );\n\t\tthis._debounceSetHistory.cancel();\n\t}\n\n\tundo() {\n\t\tif ( ! this.hasUndo() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._seek( this.historyIndex - 1 );\n\t}\n\n\tredo() {\n\t\tif ( ! this.hasRedo() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._seek( this.historyIndex + 1 );\n\t}\n\n\tsubscribeHistory( listener ) {\n\t\tthis.historySubscribers.add( listener );\n\n\t\treturn () => {\n\t\t\tthis.historySubscribers.delete( listener );\n\t\t};\n\t}\n\n\tsave() {\n\t\tthis.api.previewer.save();\n\t}\n}\n"]}
@@ -10,11 +10,12 @@ import { BlockEditorProvider } from '@wordpress/block-editor';
10
10
 
11
11
  import useSidebarBlockEditor from './use-sidebar-block-editor';
12
12
  import useBlocksFocusControl from '../focus-control/use-blocks-focus-control';
13
- export default function SidebarEditorProvider({
14
- sidebar,
15
- settings,
16
- children
17
- }) {
13
+ export default function SidebarEditorProvider(_ref) {
14
+ let {
15
+ sidebar,
16
+ settings,
17
+ children
18
+ } = _ref;
18
19
  const [blocks, onInput, onChange] = useSidebarBlockEditor(sidebar);
19
20
  useBlocksFocusControl(blocks);
20
21
  return createElement(BlockEditorProvider, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/sidebar-editor-provider.js"],"names":["BlockEditorProvider","useSidebarBlockEditor","useBlocksFocusControl","SidebarEditorProvider","sidebar","settings","children","blocks","onInput","onChange"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,mBAAT,QAAoC,yBAApC;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,qBAAP,MAAkC,2CAAlC;AAEA,eAAe,SAASC,qBAAT,CAAgC;AAC9CC,EAAAA,OAD8C;AAE9CC,EAAAA,QAF8C;AAG9CC,EAAAA;AAH8C,CAAhC,EAIX;AACH,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgCR,qBAAqB,CAAEG,OAAF,CAA3D;AAEAF,EAAAA,qBAAqB,CAAEK,MAAF,CAArB;AAEA,SACC,cAAC,mBAAD;AACC,IAAA,KAAK,EAAGA,MADT;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ,EAAGJ,QAJZ;AAKC,IAAA,cAAc,EAAG;AALlB,KAOGC,QAPH,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockEditorProvider } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useSidebarBlockEditor from './use-sidebar-block-editor';\nimport useBlocksFocusControl from '../focus-control/use-blocks-focus-control';\n\nexport default function SidebarEditorProvider( {\n\tsidebar,\n\tsettings,\n\tchildren,\n} ) {\n\tconst [ blocks, onInput, onChange ] = useSidebarBlockEditor( sidebar );\n\n\tuseBlocksFocusControl( blocks );\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t{ children }\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-block-editor/sidebar-editor-provider.js"],"names":["BlockEditorProvider","useSidebarBlockEditor","useBlocksFocusControl","SidebarEditorProvider","sidebar","settings","children","blocks","onInput","onChange"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,mBAAT,QAAoC,yBAApC;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,qBAAP,MAAkC,2CAAlC;AAEA,eAAe,SAASC,qBAAT,OAIX;AAAA,MAJ2C;AAC9CC,IAAAA,OAD8C;AAE9CC,IAAAA,QAF8C;AAG9CC,IAAAA;AAH8C,GAI3C;AACH,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgCR,qBAAqB,CAAEG,OAAF,CAA3D;AAEAF,EAAAA,qBAAqB,CAAEK,MAAF,CAArB;AAEA,SACC,cAAC,mBAAD;AACC,IAAA,KAAK,EAAGA,MADT;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ,EAAGJ,QAJZ;AAKC,IAAA,cAAc,EAAG;AALlB,KAOGC,QAPH,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockEditorProvider } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useSidebarBlockEditor from './use-sidebar-block-editor';\nimport useBlocksFocusControl from '../focus-control/use-blocks-focus-control';\n\nexport default function SidebarEditorProvider( {\n\tsidebar,\n\tsettings,\n\tchildren,\n} ) {\n\tconst [ blocks, onInput, onChange ] = useSidebarBlockEditor( sidebar );\n\n\tuseBlocksFocusControl( blocks );\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tsettings={ settings }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t{ children }\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
@@ -5,11 +5,12 @@ import { createElement } from "@wordpress/element";
5
5
  */
6
6
  import { createContext, useMemo, useContext } from '@wordpress/element';
7
7
  export const SidebarControlsContext = createContext();
8
- export default function SidebarControls({
9
- sidebarControls,
10
- activeSidebarControl,
11
- children
12
- }) {
8
+ export default function SidebarControls(_ref) {
9
+ let {
10
+ sidebarControls,
11
+ activeSidebarControl,
12
+ children
13
+ } = _ref;
13
14
  const context = useMemo(() => ({
14
15
  sidebarControls,
15
16
  activeSidebarControl
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-controls/index.js"],"names":["createContext","useMemo","useContext","SidebarControlsContext","SidebarControls","sidebarControls","activeSidebarControl","children","context","useSidebarControls","useActiveSidebarControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,OAAxB,EAAiCC,UAAjC,QAAmD,oBAAnD;AAEA,OAAO,MAAMC,sBAAsB,GAAGH,aAAa,EAA5C;AAEP,eAAe,SAASI,eAAT,CAA0B;AACxCC,EAAAA,eADwC;AAExCC,EAAAA,oBAFwC;AAGxCC,EAAAA;AAHwC,CAA1B,EAIX;AACH,QAAMC,OAAO,GAAGP,OAAO,CACtB,OAAQ;AACPI,IAAAA,eADO;AAEPC,IAAAA;AAFO,GAAR,CADsB,EAKtB,CAAED,eAAF,EAAmBC,oBAAnB,CALsB,CAAvB;AAQA,SACC,cAAC,sBAAD,CAAwB,QAAxB;AAAiC,IAAA,KAAK,EAAGE;AAAzC,KACGD,QADH,CADD;AAKA;AAED,OAAO,SAASE,kBAAT,GAA8B;AACpC,QAAM;AAAEJ,IAAAA;AAAF,MAAsBH,UAAU,CAAEC,sBAAF,CAAtC;AAEA,SAAOE,eAAP;AACA;AAED,OAAO,SAASK,uBAAT,GAAmC;AACzC,QAAM;AAAEJ,IAAAA;AAAF,MAA2BJ,UAAU,CAAEC,sBAAF,CAA3C;AAEA,SAAOG,oBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\n\nexport default function SidebarControls( {\n\tsidebarControls,\n\tactiveSidebarControl,\n\tchildren,\n} ) {\n\tconst context = useMemo(\n\t\t() => ( {\n\t\t\tsidebarControls,\n\t\t\tactiveSidebarControl,\n\t\t} ),\n\t\t[ sidebarControls, activeSidebarControl ]\n\t);\n\n\treturn (\n\t\t<SidebarControlsContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</SidebarControlsContext.Provider>\n\t);\n}\n\nexport function useSidebarControls() {\n\tconst { sidebarControls } = useContext( SidebarControlsContext );\n\n\treturn sidebarControls;\n}\n\nexport function useActiveSidebarControl() {\n\tconst { activeSidebarControl } = useContext( SidebarControlsContext );\n\n\treturn activeSidebarControl;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/components/sidebar-controls/index.js"],"names":["createContext","useMemo","useContext","SidebarControlsContext","SidebarControls","sidebarControls","activeSidebarControl","children","context","useSidebarControls","useActiveSidebarControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,OAAxB,EAAiCC,UAAjC,QAAmD,oBAAnD;AAEA,OAAO,MAAMC,sBAAsB,GAAGH,aAAa,EAA5C;AAEP,eAAe,SAASI,eAAT,OAIX;AAAA,MAJqC;AACxCC,IAAAA,eADwC;AAExCC,IAAAA,oBAFwC;AAGxCC,IAAAA;AAHwC,GAIrC;AACH,QAAMC,OAAO,GAAGP,OAAO,CACtB,OAAQ;AACPI,IAAAA,eADO;AAEPC,IAAAA;AAFO,GAAR,CADsB,EAKtB,CAAED,eAAF,EAAmBC,oBAAnB,CALsB,CAAvB;AAQA,SACC,cAAC,sBAAD,CAAwB,QAAxB;AAAiC,IAAA,KAAK,EAAGE;AAAzC,KACGD,QADH,CADD;AAKA;AAED,OAAO,SAASE,kBAAT,GAA8B;AACpC,QAAM;AAAEJ,IAAAA;AAAF,MAAsBH,UAAU,CAAEC,sBAAF,CAAtC;AAEA,SAAOE,eAAP;AACA;AAED,OAAO,SAASK,uBAAT,GAAmC;AACzC,QAAM;AAAEJ,IAAAA;AAAF,MAA2BJ,UAAU,CAAEC,sBAAF,CAA3C;AAEA,SAAOG,oBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useMemo, useContext } from '@wordpress/element';\n\nexport const SidebarControlsContext = createContext();\n\nexport default function SidebarControls( {\n\tsidebarControls,\n\tactiveSidebarControl,\n\tchildren,\n} ) {\n\tconst context = useMemo(\n\t\t() => ( {\n\t\t\tsidebarControls,\n\t\t\tactiveSidebarControl,\n\t\t} ),\n\t\t[ sidebarControls, activeSidebarControl ]\n\t);\n\n\treturn (\n\t\t<SidebarControlsContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</SidebarControlsContext.Provider>\n\t);\n}\n\nexport function useSidebarControls() {\n\tconst { sidebarControls } = useContext( SidebarControlsContext );\n\n\treturn sidebarControls;\n}\n\nexport function useActiveSidebarControl() {\n\tconst { activeSidebarControl } = useContext( SidebarControlsContext );\n\n\treturn activeSidebarControl;\n}\n"]}
@@ -7,9 +7,10 @@ import { __ } from '@wordpress/i18n';
7
7
  import { Button, ExternalLink } from '@wordpress/components';
8
8
  import { useDispatch } from '@wordpress/data';
9
9
  import { store as interfaceStore } from '@wordpress/interface';
10
- export default function WelcomeGuide({
11
- sidebar
12
- }) {
10
+ export default function WelcomeGuide(_ref) {
11
+ let {
12
+ sidebar
13
+ } = _ref;
13
14
  const {
14
15
  toggleFeature
15
16
  } = useDispatch(interfaceStore);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/components/welcome-guide/index.js"],"names":["__","Button","ExternalLink","useDispatch","store","interfaceStore","WelcomeGuide","sidebar","toggleFeature","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,uBAArC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AAEA,eAAe,SAASC,YAAT,CAAuB;AAAEC,EAAAA;AAAF,CAAvB,EAAqC;AACnD,QAAM;AAAEC,IAAAA;AAAF,MAAoBL,WAAW,CAAEE,cAAF,CAArC;AAEA,QAAMI,sBAAsB,GAAGF,OAAO,CACpCG,UAD6B,GAE7BC,KAF6B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AiEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button, ExternalLink } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\nexport default function WelcomeGuide( { sidebar } ) {\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\n\tconst isEntirelyBlockWidgets = sidebar\n\t\t.getWidgets()\n\t\t.every( ( widget ) => widget.id.startsWith( 'block-' ) );\n\n\treturn (\n\t\t<div className=\"customize-widgets-welcome-guide\">\n\t\t\t<div className=\"customize-widgets-welcome-guide__image__wrapper\">\n\t\t\t\t<picture>\n\t\t\t\t\t<source\n\t\t\t\t\t\tsrcSet=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t\t\t/>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"customize-widgets-welcome-guide__image\"\n\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t/>\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<h1 className=\"customize-widgets-welcome-guide__heading\">\n\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t</h1>\n\t\t\t<p className=\"customize-widgets-welcome-guide__text\">\n\t\t\t\t{ isEntirelyBlockWidgets\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t ) }\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tclassName=\"customize-widgets-welcome-guide__button\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () =>\n\t\t\t\t\ttoggleFeature( 'core/customize-widgets', 'welcomeGuide' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Got it' ) }\n\t\t\t</Button>\n\t\t\t<hr className=\"customize-widgets-welcome-guide__separator\" />\n\t\t\t{ ! isEntirelyBlockWidgets && (\n\t\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t\t{ __( 'Want to stick with the old widgets?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Get the Classic Widgets plugin.' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t{ __( 'New to the block editor?' ) }\n\t\t\t\t<br />\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/support/article/wordpress-editor/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t</ExternalLink>\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/components/welcome-guide/index.js"],"names":["__","Button","ExternalLink","useDispatch","store","interfaceStore","WelcomeGuide","sidebar","toggleFeature","isEntirelyBlockWidgets","getWidgets","every","widget","id","startsWith"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,uBAArC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AAEA,eAAe,SAASC,YAAT,OAAqC;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AC;AAAb,KACGA,EAAE,CAAE,0BAAF,CADL,EAEC,yBAFD,EAGC,cAAC,YAAD;AACC,IAAA,IAAI,EAAGA,EAAE,CACR,yDADQ;AADV,KAKGA,EAAE,CAAE,0BAAF,CALL,CAHD,CAnDD,CADD;AAiEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button, ExternalLink } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\nexport default function WelcomeGuide( { sidebar } ) {\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\n\tconst isEntirelyBlockWidgets = sidebar\n\t\t.getWidgets()\n\t\t.every( ( widget ) => widget.id.startsWith( 'block-' ) );\n\n\treturn (\n\t\t<div className=\"customize-widgets-welcome-guide\">\n\t\t\t<div className=\"customize-widgets-welcome-guide__image__wrapper\">\n\t\t\t\t<picture>\n\t\t\t\t\t<source\n\t\t\t\t\t\tsrcSet=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t\t\t/>\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName=\"customize-widgets-welcome-guide__image\"\n\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t/>\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<h1 className=\"customize-widgets-welcome-guide__heading\">\n\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t</h1>\n\t\t\t<p className=\"customize-widgets-welcome-guide__text\">\n\t\t\t\t{ isEntirelyBlockWidgets\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t ) }\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tclassName=\"customize-widgets-welcome-guide__button\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ () =>\n\t\t\t\t\ttoggleFeature( 'core/customize-widgets', 'welcomeGuide' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ __( 'Got it' ) }\n\t\t\t</Button>\n\t\t\t<hr className=\"customize-widgets-welcome-guide__separator\" />\n\t\t\t{ ! isEntirelyBlockWidgets && (\n\t\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t\t{ __( 'Want to stick with the old widgets?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Get the Classic Widgets plugin.' ) }\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t<p className=\"customize-widgets-welcome-guide__more-info\">\n\t\t\t\t{ __( 'New to the block editor?' ) }\n\t\t\t\t<br />\n\t\t\t\t<ExternalLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/support/article/wordpress-editor/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t</ExternalLink>\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"]}
@@ -38,8 +38,8 @@ export default function getInserterOuterSection() {
38
38
 
39
39
  customize.sectionConstructor.outer = customize.OuterSection;
40
40
  return class InserterOuterSection extends customize.OuterSection {
41
- constructor(...args) {
42
- super(...args); // This is necessary since we're creating a new class which is not identical to the original OuterSection.
41
+ constructor() {
42
+ super(...arguments); // This is necessary since we're creating a new class which is not identical to the original OuterSection.
43
43
  // @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436
44
44
 
45
45
  this.params.type = 'outer';
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"names":["ESCAPE","focus","dispatch","store","customizeWidgetsStore","getInserterOuterSection","wp","customize","window","OuterSection","onChangeExpanded","expanded","args","section","each","params","type","id","collapse","sectionConstructor","outer","InserterOuterSection","constructor","activeElementBeforeExpanded","ownerWindow","contentContainer","ownerDocument","defaultView","addEventListener","event","keyCode","code","defaultPrevented","preventDefault","stopPropagation","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","tabbable","find","close","contains"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,qBAAvB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,UAA/C;AAEA,eAAe,SAASC,uBAAT,GAAmC;AACjD,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,QAAMC,YAAY,GAAGF,SAAS,CAACE,YAA/B,CALiD,CAMjD;AACA;AACA;;AACAF,EAAAA,SAAS,CAACE,YAAV,GAAyB,cAAcA,YAAd,CAA2B;AACnDC,IAAAA,gBAAgB,CAAEC,QAAF,EAAYC,IAAZ,EAAmB;AAClC,UAAKD,QAAL,EAAgB;AACfJ,QAAAA,SAAS,CAACM,OAAV,CAAkBC,IAAlB,CAA0BD,OAAF,IAAe;AACtC,cACCA,OAAO,CAACE,MAAR,CAAeC,IAAf,KAAwB,OAAxB,IACAH,OAAO,CAACI,EAAR,KAAe,KAAKA,EAFrB,EAGE;AACD,gBAAKJ,OAAO,CAACF,QAAR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AAL,EADD;AAGA;;AACD,aAAK0B,oBAAL,GAA4B,KAA5B;AACA,OARD;AASA;;AACDE,IAAAA,IAAI,GAAG;AACN,UAAK,CAAE,KAAK5B,QAAL,EAAP,EAAyB;AACxB,cAAMc,gBAAgB,GAAG,KAAKA,gBAAL,CAAuB,CAAvB,CAAzB;AACA,aAAKF,2BAAL,GACCE,gBAAgB,CAACC,aAAjB,CAA+Bc,aADhC;AAGA,aAAKH,oBAAL,GAA4B,IAA5B;AAEA,aAAKI,MAAL,CAAa;AACZC,UAAAA,gBAAgB,GAAG;AAClB;AACA;AACA;AACA,kBAAMC,SAAS,GAAG1C,KAAK,CAAC2C,QAAN,CAAeC,IAAf,CACjBpB,gBADiB,EAEf,CAFe,CAAlB;;AAGA,gBAAKkB,SAAL,EAAiB;AAChBA,cAAAA,SAAS,CAAC1C,KAAV;AACA;AACD;;AAXW,SAAb;AAaA;AACD;;AACD6C,IAAAA,KAAK,GAAG;AACP,UAAK,KAAKnC,QAAL,EAAL,EAAuB;AACtB,cAAMc,gBAAgB,GAAG,KAAKA,gBAAL,CAAuB,CAAvB,CAAzB;AACA,cAAMe,aAAa,GAClBf,gBAAgB,CAACC,aAAjB,CAA+Bc,aADhC;AAGA,aAAKH,oBAAL,GAA4B,IAA5B;AAEA,aAAKnB,QAAL,CAAe;AACdwB,UAAAA,gBAAgB,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA,gBAAKjB,gBAAgB,CAACsB,QAAjB,CAA2BP,aAA3B,CAAL,EAAkD;AACjD;AACA,kBAAK,KAAKjB,2BAAV,EAAwC;AACvC,qBAAKA,2BAAL,CAAiCtB,KAAjC;AACA;AACD;AACD;;AAba,SAAf;AAeA;AACD;;AAhG+D,GAAjE;AAkGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow = this.contentContainer[ 0 ].ownerDocument\n\t\t\t\t.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE ||\n\t\t\t\t\t\t\tevent.code === 'Escape' ) &&\n\t\t\t\t\t\t! event.defaultPrevented\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox = focus.tabbable.find(\n\t\t\t\t\t\t\tcontentContainer\n\t\t\t\t\t\t)[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBeforeExpanded.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/controls/inserter-outer-section.js"],"names":["ESCAPE","focus","dispatch","store","customizeWidgetsStore","getInserterOuterSection","wp","customize","window","OuterSection","onChangeExpanded","expanded","args","section","each","params","type","id","collapse","sectionConstructor","outer","InserterOuterSection","constructor","activeElementBeforeExpanded","ownerWindow","contentContainer","ownerDocument","defaultView","addEventListener","event","keyCode","code","defaultPrevented","preventDefault","stopPropagation","setIsInserterOpened","addClass","isFromInternalAction","bind","open","activeElement","expand","completeCallback","searchBox","tabbable","find","close","contains"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,qBAAvB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,UAA/C;AAEA,eAAe,SAASC,uBAAT,GAAmC;AACjD,QAAM;AACLC,IAAAA,EAAE,EA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,aAAKnB,QAAL,CAAe;AACdwB,UAAAA,gBAAgB,GAAG;AAClB;AACA;AACA;AACA;AACA;AACA,gBAAKjB,gBAAgB,CAACsB,QAAjB,CAA2BP,aAA3B,CAAL,EAAkD;AACjD;AACA,kBAAK,KAAKjB,2BAAV,EAAwC;AACvC,qBAAKA,2BAAL,CAAiCtB,KAAjC;AACA;AACD;AACD;;AAba,SAAf;AAeA;AACD;;AAhG+D,GAAjE;AAkGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as customizeWidgetsStore } from '../store';\n\nexport default function getInserterOuterSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\tconst OuterSection = customize.OuterSection;\n\t// Override the OuterSection class to handle multiple outer sections.\n\t// It closes all the other outer sections whenever one is opened.\n\t// The result is that at most one outer section can be opened at the same time.\n\tcustomize.OuterSection = class extends OuterSection {\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tif ( expanded ) {\n\t\t\t\tcustomize.section.each( ( section ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tsection.params.type === 'outer' &&\n\t\t\t\t\t\tsection.id !== this.id\n\t\t\t\t\t) {\n\t\t\t\t\t\tif ( section.expanded() ) {\n\t\t\t\t\t\t\tsection.collapse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn super.onChangeExpanded( expanded, args );\n\t\t}\n\t};\n\t// Handle constructor so that \"params.type\" can be correctly pointed to \"outer\".\n\tcustomize.sectionConstructor.outer = customize.OuterSection;\n\n\treturn class InserterOuterSection extends customize.OuterSection {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\t// This is necessary since we're creating a new class which is not identical to the original OuterSection.\n\t\t\t// @See https://github.com/WordPress/wordpress-develop/blob/42b05c397c50d9dc244083eff52991413909d4bd/src/js/_enqueues/wp/customize/controls.js#L1427-L1436\n\t\t\tthis.params.type = 'outer';\n\n\t\t\tthis.activeElementBeforeExpanded = null;\n\n\t\t\tconst ownerWindow = this.contentContainer[ 0 ].ownerDocument\n\t\t\t\t.defaultView;\n\n\t\t\t// Handle closing the inserter when pressing the Escape key.\n\t\t\townerWindow.addEventListener(\n\t\t\t\t'keydown',\n\t\t\t\t( event ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.expanded() &&\n\t\t\t\t\t\t( event.keyCode === ESCAPE ||\n\t\t\t\t\t\t\tevent.code === 'Escape' ) &&\n\t\t\t\t\t\t! event.defaultPrevented\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Use capture mode to make this run before other event listeners.\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tthis.contentContainer.addClass( 'widgets-inserter' );\n\n\t\t\t// Set a flag if the state is being changed from open() or close().\n\t\t\t// Don't propagate the event if it's an internal action to prevent infinite loop.\n\t\t\tthis.isFromInternalAction = false;\n\t\t\tthis.expanded.bind( () => {\n\t\t\t\tif ( ! this.isFromInternalAction ) {\n\t\t\t\t\t// Propagate the event to React to sync the state.\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tthis.expanded()\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.isFromInternalAction = false;\n\t\t\t} );\n\t\t}\n\t\topen() {\n\t\t\tif ( ! this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tthis.activeElementBeforeExpanded =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.expand( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// We have to do this in a \"completeCallback\" or else the elements will not yet be visible/tabbable.\n\t\t\t\t\t\t// The first one should be the close button,\n\t\t\t\t\t\t// we want to skip it and choose the second one instead, which is the search box.\n\t\t\t\t\t\tconst searchBox = focus.tabbable.find(\n\t\t\t\t\t\t\tcontentContainer\n\t\t\t\t\t\t)[ 1 ];\n\t\t\t\t\t\tif ( searchBox ) {\n\t\t\t\t\t\t\tsearchBox.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t\tclose() {\n\t\t\tif ( this.expanded() ) {\n\t\t\t\tconst contentContainer = this.contentContainer[ 0 ];\n\t\t\t\tconst activeElement =\n\t\t\t\t\tcontentContainer.ownerDocument.activeElement;\n\n\t\t\t\tthis.isFromInternalAction = true;\n\n\t\t\t\tthis.collapse( {\n\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t// Only do this if the active element which triggers the action is inside the inserter,\n\t\t\t\t\t\t// (the close button for instance). In that case the focus will be lost.\n\t\t\t\t\t\t// Otherwise, we don't hijack the focus when the user is focusing on other elements\n\t\t\t\t\t\t// (like the quick inserter).\n\t\t\t\t\t\tif ( contentContainer.contains( activeElement ) ) {\n\t\t\t\t\t\t\t// Return back the focus when closing the inserter.\n\t\t\t\t\t\t\tif ( this.activeElementBeforeExpanded ) {\n\t\t\t\t\t\t\t\tthis.activeElementBeforeExpanded.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
@@ -51,9 +51,10 @@ export default function getInspectorSection() {
51
51
  }
52
52
  }
53
53
 
54
- open({
55
- returnFocusWhenClose
56
- } = {}) {
54
+ open() {
55
+ let {
56
+ returnFocusWhenClose
57
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
57
58
  this.isOpen = true;
58
59
  this.returnFocusWhenClose = returnFocusWhenClose;
59
60
  this.expand({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/controls/inspector-section.js"],"names":["getInspectorSection","wp","customize","window","InspectorSection","Section","constructor","id","options","parentSection","returnFocusWhenClose","_isOpen","isOpen","value","triggerActiveCallbacks","ready","contentContainer","classList","add","isContextuallyActive","onChangeExpanded","expanded","args","unchanged","collapse","manualTransition","expand","completeCallback","contains","focus","open","allowMultiple","close","active","callbacks","fireWith"],"mappings":"AAAA,eAAe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,SAAO,MAAMC,gBAAN,SAA+BF,SAAS,CAACG,OAAzC,CAAiD;AACvDC,IAAAA,WAAW,CAAEC,EAAF,EAAMC,OAAN,EAAgB;AAC1B,YAAOD,EAAP,EAAWC,OAAX;AAEA,WAAKC,aAAL,GAAqBD,OAAO,CAACC,aAA7B;AAEA,WAAKC,oBAAL,GAA4B,IAA5B;AACA,WAAKC,OAAL,GAAe,KAAf;AACA;;AACS,QAANC,MAAM,GAAG;AACZ,aAAO,KAAKD,OAAZ;AACA;;AACS,QAANC,MAAM,CAAEC,KAAF,EAAU;AACnB,WAAKF,OAAL,GAAeE,KAAf;AACA,WAAKC,sBAAL;AACA;;AACDC,IAAAA,KAAK,GAAG;AACP,WAAKC,gBAAL,CAAuB,CAAvB,EAA2BC,SAA3B,CAAqCC,GAArC,CACC,qCADD;AAGA;;AACDC,IAAAA,oBAAoB,GAAG;AACtB,aAAO,KAAKP,MAAZ;AACA;;AACDQ,IAAAA,gBAAgB,CAAEC,QAAF,EAAYC,IAAZ,EAAmB;AAClC,YAAMF,gBAAN,CAAwBC,QAAxB,EAAkCC,IAAlC;;AAEA,UAAK,KAAKb,aAAL,IAAsB,CAAEa,IAAI,CAACC,SAAlC,EAA8C;AAC7C,YAAKF,QAAL,EAAgB;AACf,eAAKZ,aAAL,CAAmBe,QAAnB,CAA6B;AAC5BC,YAAAA,gBAAgB,EAAE;AADU,WAA7B;AAGA,SAJD,MAIO;AACN,eAAKhB,aAAL,CAAmBiB,MAAnB,CAA2B;AAC1BD,YAAAA,gBAAgB,EAAE,IADQ;AAE1BE,YAAAA,gBAAgB,EAAE,MAAM;AACvB;AACA,kBACC,KAAKjB,oBAAL,IACA,CAAE,KAAKM,gBAAL,CAAuB,CAAvB,EAA2BY,QAA3B,CACD,KAAKlB,oBADJ,CAFH,EAKE;AACD,qBAAKA,oBAAL,CAA0BmB,KAA1B;AACA;AACD;AAZyB,WAA3B;AAcA;AACD;AACD;;AACDC,IAAAA,IAAI,CAAE;AAAEpB,MAAAA;AAAF,QAA2B,EAA7B,EAAkC;AACrC,WAAKE,MAAL,GAAc,IAAd;AACA,WAAKF,oBAAL,GAA4BA,oBAA5B;AAEA,WAAKgB,MAAL,CAAa;AACZK,QAAAA,aAAa,EAAE;AADH,OAAb;AAGA;;AACDC,IAAAA,KAAK,GAAG;AACP,WAAKR,QAAL,CAAe;AACdO,QAAAA,aAAa,EAAE;AADD,OAAf;AAGA;;AACDP,IAAAA,QAAQ,CAAEhB,OAAF,EAAY;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAKI,MAAL,GAAc,KAAd;AACA,YAAMY,QAAN,CAAgBhB,OAAhB;AACA;;AACDM,IAAAA,sBAAsB,GAAG;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAKmB,MAAL,CAAYC,SAAZ,CAAsBC,QAAtB,CAAgC,KAAKF,MAArC,EAA6C,CAAE,KAAF,EAAS,IAAT,CAA7C;AACA;;AA1FsD,GAAxD;AA4FA","sourcesContent":["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/controls/inspector-section.js"],"names":["getInspectorSection","wp","customize","window","InspectorSection","Section","constructor","id","options","parentSection","returnFocusWhenClose","_isOpen","isOpen","value","triggerActiveCallbacks","ready","contentContainer","classList","add","isContextuallyActive","onChangeExpanded","expanded","args","unchanged","collapse","manualTransition","expand","completeCallback","contains","focus","open","allowMultiple","close","active","callbacks","fireWith"],"mappings":"AAAA,eAAe,SAASA,mBAAT,GAA+B;AAC7C,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;A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AA,UAAhC;AAAEpB,QAAAA;AAAF,OAAgC,uEAAL,EAAK;AACrC,WAAKE,MAAL,GAAc,IAAd;AACA,WAAKF,oBAAL,GAA4BA,oBAA5B;AAEA,WAAKgB,MAAL,CAAa;AACZK,QAAAA,aAAa,EAAE;AADH,OAAb;AAGA;;AACDC,IAAAA,KAAK,GAAG;AACP,WAAKR,QAAL,CAAe;AACdO,QAAAA,aAAa,EAAE;AADD,OAAf;AAGA;;AACDP,IAAAA,QAAQ,CAAEhB,OAAF,EAAY;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAKI,MAAL,GAAc,KAAd;AACA,YAAMY,QAAN,CAAgBhB,OAAhB;AACA;;AACDM,IAAAA,sBAAsB,GAAG;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAKmB,MAAL,CAAYC,SAAZ,CAAsBC,QAAtB,CAAgC,KAAKF,MAArC,EAA6C,CAAE,KAAF,EAAS,IAAT,CAA7C;AACA;;AA1FsD,GAAxD;AA4FA","sourcesContent":["export default function getInspectorSection() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class InspectorSection extends customize.Section {\n\t\tconstructor( id, options ) {\n\t\t\tsuper( id, options );\n\n\t\t\tthis.parentSection = options.parentSection;\n\n\t\t\tthis.returnFocusWhenClose = null;\n\t\t\tthis._isOpen = false;\n\t\t}\n\t\tget isOpen() {\n\t\t\treturn this._isOpen;\n\t\t}\n\t\tset isOpen( value ) {\n\t\t\tthis._isOpen = value;\n\t\t\tthis.triggerActiveCallbacks();\n\t\t}\n\t\tready() {\n\t\t\tthis.contentContainer[ 0 ].classList.add(\n\t\t\t\t'customize-widgets-layout__inspector'\n\t\t\t);\n\t\t}\n\t\tisContextuallyActive() {\n\t\t\treturn this.isOpen;\n\t\t}\n\t\tonChangeExpanded( expanded, args ) {\n\t\t\tsuper.onChangeExpanded( expanded, args );\n\n\t\t\tif ( this.parentSection && ! args.unchanged ) {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tthis.parentSection.collapse( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tthis.parentSection.expand( {\n\t\t\t\t\t\tmanualTransition: true,\n\t\t\t\t\t\tcompleteCallback: () => {\n\t\t\t\t\t\t\t// Return focus after finishing the transition.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose &&\n\t\t\t\t\t\t\t\t! this.contentContainer[ 0 ].contains(\n\t\t\t\t\t\t\t\t\tthis.returnFocusWhenClose\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis.returnFocusWhenClose.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\topen( { returnFocusWhenClose } = {} ) {\n\t\t\tthis.isOpen = true;\n\t\t\tthis.returnFocusWhenClose = returnFocusWhenClose;\n\n\t\t\tthis.expand( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tclose() {\n\t\t\tthis.collapse( {\n\t\t\t\tallowMultiple: true,\n\t\t\t} );\n\t\t}\n\t\tcollapse( options ) {\n\t\t\t// Overridden collapse() function. Mostly call the parent collapse(), but also\n\t\t\t// move our .isOpen to false.\n\t\t\t// Initially, I tried tracking this with onChangeExpanded(), but it doesn't work\n\t\t\t// because the block settings sidebar is a layer \"on top of\" the G editor sidebar.\n\t\t\t//\n\t\t\t// For example, when closing the block settings sidebar, the G\n\t\t\t// editor sidebar would display, and onChangeExpanded in\n\t\t\t// inspector-section would run with expanded=true, but I want\n\t\t\t// isOpen to be false when the block settings is closed.\n\t\t\tthis.isOpen = false;\n\t\t\tsuper.collapse( options );\n\t\t}\n\t\ttriggerActiveCallbacks() {\n\t\t\t// Manually fire the callbacks associated with moving this.active\n\t\t\t// from false to true. \"active\" is always true for this section,\n\t\t\t// and \"isContextuallyActive\" reflects if the block settings\n\t\t\t// sidebar is currently visible, that is, it has replaced the main\n\t\t\t// Gutenberg view.\n\t\t\t// The WP customizer only checks \".isContextuallyActive()\" when\n\t\t\t// \".active\" changes values. But our \".active\" never changes value.\n\t\t\t// The WP customizer never foresaw a section being used a way we\n\t\t\t// fit the block settings sidebar into a section. By manually\n\t\t\t// triggering the \"this.active\" callbacks, we force the WP\n\t\t\t// customizer to query our .isContextuallyActive() function and\n\t\t\t// update its view of our status.\n\t\t\tthis.active.callbacks.fireWith( this.active, [ false, true ] );\n\t\t}\n\t};\n}\n"]}
@@ -19,8 +19,8 @@ export default function getSidebarControl() {
19
19
  }
20
20
  } = window;
21
21
  return class SidebarControl extends customize.Control {
22
- constructor(...args) {
23
- super(...args);
22
+ constructor() {
23
+ super(...arguments);
24
24
  this.subscribers = new Set();
25
25
  }
26
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"names":["dispatch","SidebarAdapter","getInserterOuterSection","store","customizeWidgetsStore","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","args","subscribers","Set","ready","InserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","unchanged","setIsInserterOpened","forEach","subscriber"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oDAA3B;AACA,OAAOC,uBAAP,MAAoC,0BAApC;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,UAA/C;;AAEA,MAAMC,aAAa,GAAKC,SAAF,IAAkB,oBAAoBA,SAAW,EAAvE;;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,SAAO,MA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* Internal dependencies\n */\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/controls/sidebar-control.js"],"names":["dispatch","SidebarAdapter","getInserterOuterSection","store","customizeWidgetsStore","getInserterId","controlId","getSidebarControl","wp","customize","window","SidebarControl","Control","constructor","subscribers","Set","ready","InserterOuterSection","inserter","id","section","add","sectionInstance","inspector","sidebarAdapter","setting","subscribe","callback","delete","onChangeSectionExpanded","expanded","args","unchanged","setIsInserterOpened","forEach","subscriber"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oDAA3B;AACA,OAAOC,uBAAP,MAAoC,0BAApC;AACA,SAASC,KAAK,IAAIC,qBAAlB,QAA+C,UAA/C;;AAEA,MAAMC,aAAa,GAAKC,SAAF,IAAkB,oBAAoBA,SAAW,EAAvE;;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM;AACLC,IAAAA,EAAE,EAAE;AAAEC,MAAAA;AAAF;AADC,MAEFC,MAFJ;AAIA,SAAO,MAAMC,cAAN,SAA6BF,SAAS,CAACG,OAAvC,CAA+C;AACrDC,IAAAA,WAAW,GAAY;AACtB,YAAO,YAAP;AAEA,WAAKC,WAAL,GAAmB,IAAIC,GAAJ,EAAnB;AACA;;AAEDC,IAAAA,KAAK,GAAG;AACP,YAAMC,oBAAoB,GAAGf,uBAAuB,EAApD;AACA,WAAKgB,QAAL,GAAgB,IAAID,oBAAJ,CACfZ,aAAa,CAAE,KAAKc,EAAP,CADE,EAEf,EAFe,CAAhB;AAIAV,MAAAA,SAAS,CAACW,OAAV,CAAkBC,GAAlB,CAAuB,KAAKH,QAA5B;AAEA,WAAKI,eAAL,GAAuBb,SAAS,CAACW,OAAV,CAAmB,KAAKA,OAAL,EAAnB,CAAvB;AAEA,WAAKG,SAAL,GAAiB,KAAKD,eAAL,CAAqBC,SAAtC;AAEA,WAAKC,cAAL,GAAsB,IAAIvB,cAAJ,CAAoB,KAAKwB,OAAzB,EAAkChB,SAAlC,CAAtB;AACA;;AAEDiB,IAAAA,SAAS,CAAEC,QAAF,EAAa;AACrB,WAAKb,WAAL,CAAiBO,GAAjB,CAAsBM,QAAtB;AAEA,aAAO,MAAM;AACZ,aAAKb,WAAL,CAAiBc,MAAjB,CAAyBD,QAAzB;AACA,OAFD;AAGA;;AAEDE,IAAAA,uBAAuB,CAAEC,QAAF,EAAYC,IAAZ,EAAmB;AACzC,UAAK,CAAEA,IAAI,CAACC,SAAZ,EAAwB;AACvB;AACA,YAAK,CAAEF,QAAP,EAAkB;AACjB9B,UAAAA,QAAQ,CAAEI,qBAAF,CAAR,CAAkC6B,mBAAlC,CACC,KADD;AAGA;;AAED,aAAKnB,WAAL,CAAiBoB,OAAjB,CAA4BC,UAAF,IACzBA,UAAU,CAAEL,QAAF,EAAYC,IAAZ,CADX;AAGA;AACD;;AA3CoD,GAAtD;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SidebarAdapter from '../components/sidebar-block-editor/sidebar-adapter';\nimport getInserterOuterSection from './inserter-outer-section';\nimport { store as customizeWidgetsStore } from '../store';\n\nconst getInserterId = ( controlId ) => `widgets-inserter-${ controlId }`;\n\nexport default function getSidebarControl() {\n\tconst {\n\t\twp: { customize },\n\t} = window;\n\n\treturn class SidebarControl extends customize.Control {\n\t\tconstructor( ...args ) {\n\t\t\tsuper( ...args );\n\n\t\t\tthis.subscribers = new Set();\n\t\t}\n\n\t\tready() {\n\t\t\tconst InserterOuterSection = getInserterOuterSection();\n\t\t\tthis.inserter = new InserterOuterSection(\n\t\t\t\tgetInserterId( this.id ),\n\t\t\t\t{}\n\t\t\t);\n\t\t\tcustomize.section.add( this.inserter );\n\n\t\t\tthis.sectionInstance = customize.section( this.section() );\n\n\t\t\tthis.inspector = this.sectionInstance.inspector;\n\n\t\t\tthis.sidebarAdapter = new SidebarAdapter( this.setting, customize );\n\t\t}\n\n\t\tsubscribe( callback ) {\n\t\t\tthis.subscribers.add( callback );\n\n\t\t\treturn () => {\n\t\t\t\tthis.subscribers.delete( callback );\n\t\t\t};\n\t\t}\n\n\t\tonChangeSectionExpanded( expanded, args ) {\n\t\t\tif ( ! args.unchanged ) {\n\t\t\t\t// Close the inserter when the section collapses.\n\t\t\t\tif ( ! expanded ) {\n\t\t\t\t\tdispatch( customizeWidgetsStore ).setIsInserterOpened(\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.subscribers.forEach( ( subscriber ) =>\n\t\t\t\t\tsubscriber( expanded, args )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
@@ -9,7 +9,10 @@ import { combineReducers } from '@wordpress/data';
9
9
  * @param {Object} action
10
10
  */
11
11
 
12
- function blockInserterPanel(state = false, action) {
12
+ function blockInserterPanel() {
13
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
14
+ let action = arguments.length > 1 ? arguments[1] : undefined;
15
+
13
16
  switch (action.type) {
14
17
  case 'SET_IS_INSERTER_OPENED':
15
18
  return action.value;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/store/reducer.js"],"names":["combineReducers","blockInserterPanel","state","action","type","value"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,kBAAT,CAA6BC,KAAK,GAAG,KAArC,EAA4CC,MAA5C,EAAqD;AACpD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,wBAAL;AACC,aAAOD,MAAM,CAACE,KAAd;AAFF;;AAIA,SAAOH,KAAP;AACA;;AAED,eAAeF,eAAe,CAAE;AAC/BC,EAAAA;AAD+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer tracking whether the inserter is open.\n *\n * @param {boolean|Object} state\n * @param {Object} action\n */\nfunction blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tblockInserterPanel,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/store/reducer.js"],"names":["combineReducers","blockInserterPanel","state","action","type","value"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,kBAAT,GAAqD;AAAA,MAAxBC,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AACpD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,wBAAL;AACC,aAAOD,MAAM,CAACE,KAAd;AAFF;;AAIA,SAAOH,KAAP;AACA;;AAED,eAAeF,eAAe,CAAE;AAC/BC,EAAAA;AAD+B,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer tracking whether the inserter is open.\n *\n * @param {boolean|Object} state\n * @param {Object} action\n */\nfunction blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tblockInserterPanel,\n} );\n"]}
@@ -36,7 +36,8 @@ export function settingIdToWidgetId(settingId) {
36
36
  * @return {Object} The transformed widget.
37
37
  */
38
38
 
39
- export function blockToWidget(block, existingWidget = null) {
39
+ export function blockToWidget(block) {
40
+ let existingWidget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
40
41
  let widget;
41
42
  const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance);
42
43
 
@@ -94,12 +95,13 @@ export function blockToWidget(block, existingWidget = null) {
94
95
  * @return {WPBlock} The transformed block.
95
96
  */
96
97
 
97
- export function widgetToBlock({
98
- id,
99
- idBase,
100
- number,
101
- instance
102
- }) {
98
+ export function widgetToBlock(_ref) {
99
+ let {
100
+ id,
101
+ idBase,
102
+ number,
103
+ instance
104
+ } = _ref;
103
105
  let block;
104
106
  const {
105
107
  encoded_serialized_instance: encoded,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/utils.js"],"names":["serialize","parse","createBlock","addWidgetIdToBlock","omit","settingIdToWidgetId","settingId","matches","match","idBase","number","parseInt","blockToWidget","block","existingWidget","widget","isValidLegacyWidgetBlock","name","attributes","id","instance","encoded","hash","raw","rest","is_widget_customizer_js_value","encoded_serialized_instance","instance_hash_key","raw_instance","content","widgetClass","widgetToBlock","parsedBlocks","length"],"mappings":"AAAA;;AACA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,KAApB,EAA2BC,WAA3B,QAA8C,mBAA9C;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BC,SAA9B,EAA0C;AAChD,QAAMC,OAAO,GAAGD,SAAS,CAACE,KAAV,CAAiB,4BAAjB,CAAhB;;AAEA,MAAKD,OAAL,EAAe;AACd,UAAME,MAAM,GAAGF,OAAO,CAAE,CAAF,CAAtB;AACA,UAAMG,MAAM,GAAGC,QAAQ,CAAEJ,OAAO,CAAE,CAAF,CAAT,EAAgB,EAAhB,CAAvB;AAEA,WAAQ,GAAGE,MAAQ,IAAIC,MAAQ,EAA/B;AACA;;AAED,SAAOJ,SAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASM,aAAT,CAAwBC,KAAxB,EAA+BC,cAAc,GAAG,IAAhD,EAAuD;AAC7D,MAAIC,MAAJ;AAEA,QAAMC,wBAAwB,GAC7BH,KAAK,CAACI,IAAN,KAAe,oBAAf,KACEJ,KAAK,CAACK,UAAN,CAAiBC,EAAjB,IAAuBN,KAAK,CAACK,UAAN,CAAiBE,QAD1C,CADD;;AAIA,MAAKJ,wBAAL,EAAgC;AAC/B,QAAKH,KAAK,CAACK,UAAN,CAAiBC,EAAtB,EAA2B;AAC1B;AACAJ,MAAAA,MAAM,GAAG;AACRI,Q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,iBAAiB,EAAEL,IAFd;AAGLM,IAAAA,YAAY,EAAEL,GAHT;AAIL,OAAGC;AAJE,MAKFJ,QALJ;;AAOA,MAAKX,MAAM,KAAK,OAAhB,EAA0B;AACzB,UAAMuB,YAAY,GAAG/B,KAAK,CAAEsB,GAAG,CAACM,OAAN,CAA1B;AACAhB,IAAAA,KAAK,GAAGmB,YAAY,CAACC,MAAb,GACLD,YAAY,CAAE,CAAF,CADP,GAEL9B,WAAW,CAAE,gBAAF,EAAoB,EAApB,CAFd;AAGA,GALD,MAKO,IAAKQ,MAAL,EAAc;AACpB;AACAG,IAAAA,KAAK,GAAGX,WAAW,CAAE,oBAAF,EAAwB;AAC1CO,MAAAA,MAD0C;AAE1CW,MAAAA,QAAQ,EAAE;AACTC,QAAAA,OADS;AAETC,QAAAA,IAFS;AAGTC,QAAAA,GAHS;AAIT,WAAGC;AAJM;AAFgC,KAAxB,CAAnB;AASA,GAXM,MAWA;AACN;AACAX,IAAAA,KAAK,GAAGX,WAAW,CAAE,oBAAF,EAAwB;AAC1CiB,MAAAA;AAD0C,KAAxB,CAAnB;AAGA;;AAED,SAAOhB,kBAAkB,CAAEU,KAAF,EAASM,EAAT,CAAzB;AACA","sourcesContent":["// @ts-check\n/**\n * WordPress dependencies\n */\nimport { serialize, parse, createBlock } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\n * Convert settingId to widgetId.\n *\n * @param {string} settingId The setting id.\n * @return {string} The widget id.\n */\nexport function settingIdToWidgetId( settingId ) {\n\tconst matches = settingId.match( /^widget_(.+)(?:\\[(\\d+)\\])$/ );\n\n\tif ( matches ) {\n\t\tconst idBase = matches[ 1 ];\n\t\tconst number = parseInt( matches[ 2 ], 10 );\n\n\t\treturn `${ idBase }-${ number }`;\n\t}\n\n\treturn settingId;\n}\n\n/**\n * Transform a block to a customizable widget.\n *\n * @param {WPBlock} block The block to be transformed from.\n * @param {Object} existingWidget The widget to be extended from.\n * @return {Object} The transformed widget.\n */\nexport function blockToWidget( block, existingWidget = null ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\tif ( block.attributes.id ) {\n\t\t\t// Widget that does not extend WP_Widget.\n\t\t\twidget = {\n\t\t\t\tid: block.attributes.id,\n\t\t\t};\n\t\t} else {\n\t\t\tconst { encoded, hash, raw, ...rest } = block.attributes.instance;\n\n\t\t\t// Widget that extends WP_Widget.\n\t\t\twidget = {\n\t\t\t\tidBase: block.attributes.idBase,\n\t\t\t\tinstance: {\n\t\t\t\t\t...existingWidget?.instance,\n\t\t\t\t\t// Required only for the customizer.\n\t\t\t\t\tis_widget_customizer_js_value: true,\n\t\t\t\t\tencoded_serialized_instance: encoded,\n\t\t\t\t\tinstance_hash_key: hash,\n\t\t\t\t\traw_instance: raw,\n\t\t\t\t\t...rest,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} else {\n\t\tconst instance = {\n\t\t\tcontent: serialize( block ),\n\t\t};\n\t\twidget = {\n\t\t\tidBase: 'block',\n\t\t\twidgetClass: 'WP_Widget_Block',\n\t\t\tinstance: {\n\t\t\t\traw_instance: instance,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\t...omit( existingWidget, [ 'form', 'rendered' ] ),\n\t\t...widget,\n\t};\n}\n\n/**\n * Transform a widget to a block.\n *\n * @param {Object} widget The widget to be transformed from.\n * @param {string} widget.id The widget id.\n * @param {string} widget.idBase The id base of the widget.\n * @param {number} widget.number The number/index of the widget.\n * @param {Object} widget.instance The instance of the widget.\n * @return {WPBlock} The transformed block.\n */\nexport function widgetToBlock( { id, idBase, number, instance } ) {\n\tlet block;\n\n\tconst {\n\t\tencoded_serialized_instance: encoded,\n\t\tinstance_hash_key: hash,\n\t\traw_instance: raw,\n\t\t...rest\n\t} = instance;\n\n\tif ( idBase === 'block' ) {\n\t\tconst parsedBlocks = parse( raw.content );\n\t\tblock = parsedBlocks.length\n\t\t\t? parsedBlocks[ 0 ]\n\t\t\t: createBlock( 'core/paragraph', {} );\n\t} else if ( number ) {\n\t\t// Widget that extends WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tidBase,\n\t\t\tinstance: {\n\t\t\t\tencoded,\n\t\t\t\thash,\n\t\t\t\traw,\n\t\t\t\t...rest,\n\t\t\t},\n\t\t} );\n\t} else {\n\t\t// Widget that does not extend WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tid,\n\t\t} );\n\t}\n\n\treturn addWidgetIdToBlock( block, id );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/utils.js"],"names":["serialize","parse","createBlock","addWidgetIdToBlock","omit","settingIdToWidgetId","settingId","matches","match","idBase","number","parseInt","blockToWidget","block","existingWidget","widget","isValidLegacyWidgetBlock","name","attributes","id","instance","encoded","hash","raw","rest","is_widget_customizer_js_value","encoded_serialized_instance","instance_hash_key","raw_instance","content","widgetClass","widgetToBlock","parsedBlocks","length"],"mappings":"AAAA;;AACA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,KAApB,EAA2BC,WAA3B,QAA8C,mBAA9C;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BC,SAA9B,EAA0C;AAChD,QAAMC,OAAO,GAAGD,SAAS,CAACE,KAAV,CAAiB,4BAAjB,CAAhB;;AAEA,MAAKD,OAAL,EAAe;AACd,UAAME,MAAM,GAAGF,OAAO,CAAE,CAAF,CAAtB;AACA,UAAMG,MAAM,GAAGC,QAAQ,CAAEJ,OAAO,CAAE,CAAF,CAAT,EAAgB,EAAhB,CAAvB;AAEA,WAAQ,GAAGE,MAAQ,IAAI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n/**\n * WordPress dependencies\n */\nimport { serialize, parse, createBlock } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\n * Convert settingId to widgetId.\n *\n * @param {string} settingId The setting id.\n * @return {string} The widget id.\n */\nexport function settingIdToWidgetId( settingId ) {\n\tconst matches = settingId.match( /^widget_(.+)(?:\\[(\\d+)\\])$/ );\n\n\tif ( matches ) {\n\t\tconst idBase = matches[ 1 ];\n\t\tconst number = parseInt( matches[ 2 ], 10 );\n\n\t\treturn `${ idBase }-${ number }`;\n\t}\n\n\treturn settingId;\n}\n\n/**\n * Transform a block to a customizable widget.\n *\n * @param {WPBlock} block The block to be transformed from.\n * @param {Object} existingWidget The widget to be extended from.\n * @return {Object} The transformed widget.\n */\nexport function blockToWidget( block, existingWidget = null ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\tif ( block.attributes.id ) {\n\t\t\t// Widget that does not extend WP_Widget.\n\t\t\twidget = {\n\t\t\t\tid: block.attributes.id,\n\t\t\t};\n\t\t} else {\n\t\t\tconst { encoded, hash, raw, ...rest } = block.attributes.instance;\n\n\t\t\t// Widget that extends WP_Widget.\n\t\t\twidget = {\n\t\t\t\tidBase: block.attributes.idBase,\n\t\t\t\tinstance: {\n\t\t\t\t\t...existingWidget?.instance,\n\t\t\t\t\t// Required only for the customizer.\n\t\t\t\t\tis_widget_customizer_js_value: true,\n\t\t\t\t\tencoded_serialized_instance: encoded,\n\t\t\t\t\tinstance_hash_key: hash,\n\t\t\t\t\traw_instance: raw,\n\t\t\t\t\t...rest,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} else {\n\t\tconst instance = {\n\t\t\tcontent: serialize( block ),\n\t\t};\n\t\twidget = {\n\t\t\tidBase: 'block',\n\t\t\twidgetClass: 'WP_Widget_Block',\n\t\t\tinstance: {\n\t\t\t\traw_instance: instance,\n\t\t\t},\n\t\t};\n\t}\n\n\treturn {\n\t\t...omit( existingWidget, [ 'form', 'rendered' ] ),\n\t\t...widget,\n\t};\n}\n\n/**\n * Transform a widget to a block.\n *\n * @param {Object} widget The widget to be transformed from.\n * @param {string} widget.id The widget id.\n * @param {string} widget.idBase The id base of the widget.\n * @param {number} widget.number The number/index of the widget.\n * @param {Object} widget.instance The instance of the widget.\n * @return {WPBlock} The transformed block.\n */\nexport function widgetToBlock( { id, idBase, number, instance } ) {\n\tlet block;\n\n\tconst {\n\t\tencoded_serialized_instance: encoded,\n\t\tinstance_hash_key: hash,\n\t\traw_instance: raw,\n\t\t...rest\n\t} = instance;\n\n\tif ( idBase === 'block' ) {\n\t\tconst parsedBlocks = parse( raw.content );\n\t\tblock = parsedBlocks.length\n\t\t\t? parsedBlocks[ 0 ]\n\t\t\t: createBlock( 'core/paragraph', {} );\n\t} else if ( number ) {\n\t\t// Widget that extends WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tidBase,\n\t\t\tinstance: {\n\t\t\t\tencoded,\n\t\t\t\thash,\n\t\t\t\traw,\n\t\t\t\t...rest,\n\t\t\t},\n\t\t} );\n\t} else {\n\t\t// Widget that does not extend WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tid,\n\t\t} );\n\t}\n\n\treturn addWidgetIdToBlock( block, id );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/customize-widgets",
3
- "version": "2.0.6",
3
+ "version": "2.0.10",
4
4
  "description": "Widgets blocks in Customizer Module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -23,31 +23,31 @@
23
23
  "module": "build-module/index.js",
24
24
  "react-native": "src/index",
25
25
  "dependencies": {
26
- "@babel/runtime": "^7.11.2",
27
- "@wordpress/a11y": "^3.2.3",
28
- "@wordpress/block-editor": "^8.0.1",
29
- "@wordpress/block-library": "^6.0.4",
30
- "@wordpress/blocks": "^11.1.3",
31
- "@wordpress/components": "^19.0.1",
32
- "@wordpress/compose": "^5.0.5",
33
- "@wordpress/core-data": "^4.0.5",
34
- "@wordpress/data": "^6.1.3",
35
- "@wordpress/dom": "^3.2.6",
36
- "@wordpress/element": "^4.0.3",
37
- "@wordpress/hooks": "^3.2.1",
38
- "@wordpress/i18n": "^4.2.3",
39
- "@wordpress/icons": "^6.1.0",
40
- "@wordpress/interface": "^4.1.3",
41
- "@wordpress/is-shallow-equal": "^4.2.0",
42
- "@wordpress/keyboard-shortcuts": "^3.0.5",
43
- "@wordpress/keycodes": "^3.2.3",
44
- "@wordpress/media-utils": "^3.0.4",
45
- "@wordpress/widgets": "^2.0.6",
26
+ "@babel/runtime": "^7.16.0",
27
+ "@wordpress/a11y": "^3.2.4",
28
+ "@wordpress/block-editor": "^8.0.4",
29
+ "@wordpress/block-library": "^6.0.8",
30
+ "@wordpress/blocks": "^11.1.4",
31
+ "@wordpress/components": "^19.0.4",
32
+ "@wordpress/compose": "^5.0.6",
33
+ "@wordpress/core-data": "^4.0.7",
34
+ "@wordpress/data": "^6.1.4",
35
+ "@wordpress/dom": "^3.2.7",
36
+ "@wordpress/element": "^4.0.4",
37
+ "@wordpress/hooks": "^3.2.2",
38
+ "@wordpress/i18n": "^4.2.4",
39
+ "@wordpress/icons": "^6.1.1",
40
+ "@wordpress/interface": "^4.1.6",
41
+ "@wordpress/is-shallow-equal": "^4.2.1",
42
+ "@wordpress/keyboard-shortcuts": "^3.0.6",
43
+ "@wordpress/keycodes": "^3.2.4",
44
+ "@wordpress/media-utils": "^3.0.5",
45
+ "@wordpress/widgets": "^2.0.10",
46
46
  "classnames": "^2.3.1",
47
47
  "lodash": "^4.17.21"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "gitHead": "f89b63995376fe6efe920d858b48268b510920e1"
52
+ "gitHead": "ca22e8852fcc91889510e417bdaa180ad60f8dac"
53
53
  }