@wordpress/edit-site 6.15.0 → 6.16.0

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 (66) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/utils.js +1 -1
  3. package/build/components/add-new-template/utils.js.map +1 -1
  4. package/build/components/global-styles/screen-root.js +1 -1
  5. package/build/components/global-styles/screen-root.js.map +1 -1
  6. package/build/components/maybe-editor/index.js +1 -0
  7. package/build/components/maybe-editor/index.js.map +1 -1
  8. package/build/components/resizable-frame/index.js +1 -1
  9. package/build/components/resizable-frame/index.js.map +1 -1
  10. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
  11. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  12. package/build/components/style-book/categories.js +13 -6
  13. package/build/components/style-book/categories.js.map +1 -1
  14. package/build/components/style-book/color-examples.js.map +1 -1
  15. package/build/components/style-book/duotone-examples.js.map +1 -1
  16. package/build/components/style-book/examples.js +7 -6
  17. package/build/components/style-book/examples.js.map +1 -1
  18. package/build/components/style-book/types.js.map +1 -1
  19. package/build-module/components/add-new-template/utils.js +1 -1
  20. package/build-module/components/add-new-template/utils.js.map +1 -1
  21. package/build-module/components/global-styles/screen-root.js +1 -1
  22. package/build-module/components/global-styles/screen-root.js.map +1 -1
  23. package/build-module/components/maybe-editor/index.js +1 -0
  24. package/build-module/components/maybe-editor/index.js.map +1 -1
  25. package/build-module/components/resizable-frame/index.js +1 -1
  26. package/build-module/components/resizable-frame/index.js.map +1 -1
  27. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
  28. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  29. package/build-module/components/style-book/categories.js +13 -6
  30. package/build-module/components/style-book/categories.js.map +1 -1
  31. package/build-module/components/style-book/color-examples.js +4 -1
  32. package/build-module/components/style-book/color-examples.js.map +1 -1
  33. package/build-module/components/style-book/duotone-examples.js.map +1 -1
  34. package/build-module/components/style-book/examples.js +11 -7
  35. package/build-module/components/style-book/examples.js.map +1 -1
  36. package/build-module/components/style-book/types.js.map +1 -1
  37. package/build-style/posts-rtl.css +29 -26
  38. package/build-style/posts.css +29 -26
  39. package/build-style/style-rtl.css +29 -26
  40. package/build-style/style.css +29 -26
  41. package/build-types/components/style-book/categories.d.ts +18 -0
  42. package/build-types/components/style-book/categories.d.ts.map +1 -0
  43. package/build-types/components/style-book/color-examples.d.ts +7 -0
  44. package/build-types/components/style-book/color-examples.d.ts.map +1 -0
  45. package/build-types/components/style-book/constants.d.ts +11 -0
  46. package/build-types/components/style-book/constants.d.ts.map +1 -0
  47. package/build-types/components/style-book/duotone-examples.d.ts +9 -0
  48. package/build-types/components/style-book/duotone-examples.d.ts.map +1 -0
  49. package/build-types/components/style-book/examples.d.ts +12 -0
  50. package/build-types/components/style-book/examples.d.ts.map +1 -0
  51. package/build-types/components/style-book/types.d.ts +72 -0
  52. package/build-types/components/style-book/types.d.ts.map +1 -0
  53. package/package.json +42 -42
  54. package/src/components/add-new-template/utils.js +1 -1
  55. package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +1 -1
  56. package/src/components/global-styles/screen-root.js +1 -1
  57. package/src/components/maybe-editor/index.js +3 -0
  58. package/src/components/resizable-frame/index.js +1 -1
  59. package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +1 -1
  60. package/src/components/style-book/categories.ts +12 -6
  61. package/src/components/style-book/color-examples.tsx +4 -9
  62. package/src/components/style-book/duotone-examples.tsx +5 -1
  63. package/src/components/style-book/examples.tsx +23 -14
  64. package/src/components/style-book/types.ts +21 -1
  65. package/tsconfig.json +53 -0
  66. package/tsconfig.tsbuildinfo +1 -0
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","useState","useRef","ResizableBox","Tooltip","__unstableMotion","motion","useInstanceId","useReducedMotion","__","isRTL","privateApis","routerPrivateApis","useSelect","store","coreStore","unlock","addQueryArgs","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useLocation","useHistory","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","width","height","top","right","bottom","left","FRAME_MIN_WIDTH","FRAME_REFERENCE_WIDTH","FRAME_TARGET_ASPECT_RATIO","SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD","INITIAL_FRAME_SIZE","calculateNewHeight","initialAspectRatio","lerp","a","b","amount","lerpFactor","Math","max","min","intermediateAspectRatio","ResizableFrame","isFullWidth","isOversized","setIsOversized","isReady","children","defaultSize","innerContentStyle","history","path","query","canvas","disableMotion","frameSize","setFrameSize","startingWidth","setStartingWidth","isResizing","setIsResizing","shouldShowHandle","setShouldShowHandle","resizeRatio","setResizeRatio","FRAME_TRANSITION","type","duration","frameRef","resizableHandleHelpId","defaultAspectRatio","isBlockTheme","select","getCurrentTheme","is_block_theme","handleResizeStart","_event","_direction","ref","offsetWidth","handleResize","_ref","delta","normalizedDelta","deltaAbs","abs","maxDoubledDelta","deltaToDouble","doubleSegment","singleSegment","updatedWidth","handleResizeStop","remainingWidth","ownerDocument","documentElement","navigate","transition","handleResizableHandleKeyDown","event","includes","key","preventDefault","step","shiftKey","newWidth","current","resizable","frameAnimationVariants","default","flexGrow","fullWidth","resizeHandleVariants","hidden","opacity","visible","active","scaleY","currentResizeHandleVariant","as","div","initial","variants","animate","onAnimationComplete","definition","whileHover","scale","ease","size","enable","topRight","bottomRight","bottomLeft","topLeft","handleClasses","handleStyles","minWidth","maxWidth","maxHeight","onFocus","onBlur","onMouseOver","onMouseOut","handleComponent","text","button","role","className","onKeyDown","exit","whileFocus","id","onResizeStart","onResize","onResizeStop","showHandle","style"],"sources":["@wordpress/edit-site/src/components/resizable-frame/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport {\n\tResizableBox,\n\tTooltip,\n\t__unstableMotion as motion,\n} from '@wordpress/components';\nimport { useInstanceId, useReducedMotion } from '@wordpress/compose';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { addQueryArgs } from '@wordpress/url';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\n// The minimum width of the frame (in px) while resizing.\nconst FRAME_MIN_WIDTH = 320;\n// The reference width of the frame (in px) used to calculate the aspect ratio.\nconst FRAME_REFERENCE_WIDTH = 1300;\n// 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing.\nconst FRAME_TARGET_ASPECT_RATIO = 9 / 19.5;\n// The minimum distance (in px) between the frame resize handle and the\n// viewport's edge. If the frame is resized to be closer to the viewport's edge\n// than this distance, then \"canvas mode\" will be enabled.\nconst SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200;\n// Default size for the `frameSize` state.\nconst INITIAL_FRAME_SIZE = { width: '100%', height: '100%' };\n\nfunction calculateNewHeight( width, initialAspectRatio ) {\n\tconst lerp = ( a, b, amount ) => {\n\t\treturn a + ( b - a ) * amount;\n\t};\n\n\t// Calculate the intermediate aspect ratio based on the current width.\n\tconst lerpFactor =\n\t\t1 -\n\t\tMath.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\t1,\n\t\t\t\t( width - FRAME_MIN_WIDTH ) /\n\t\t\t\t\t( FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH )\n\t\t\t)\n\t\t);\n\n\t// Calculate the height based on the intermediate aspect ratio\n\t// ensuring the frame arrives at the target aspect ratio.\n\tconst intermediateAspectRatio = lerp(\n\t\tinitialAspectRatio,\n\t\tFRAME_TARGET_ASPECT_RATIO,\n\t\tlerpFactor\n\t);\n\n\treturn width / intermediateAspectRatio;\n}\n\nfunction ResizableFrame( {\n\tisFullWidth,\n\tisOversized,\n\tsetIsOversized,\n\tisReady,\n\tchildren,\n\t/** The default (unresized) width/height of the frame, based on the space availalbe in the viewport. */\n\tdefaultSize,\n\tinnerContentStyle,\n} ) {\n\tconst history = useHistory();\n\tconst { path, query } = useLocation();\n\tconst { canvas = 'view' } = query;\n\tconst disableMotion = useReducedMotion();\n\tconst [ frameSize, setFrameSize ] = useState( INITIAL_FRAME_SIZE );\n\t// The width of the resizable frame when a new resize gesture starts.\n\tconst [ startingWidth, setStartingWidth ] = useState();\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ shouldShowHandle, setShouldShowHandle ] = useState( false );\n\tconst [ resizeRatio, setResizeRatio ] = useState( 1 );\n\n\tconst FRAME_TRANSITION = { type: 'tween', duration: isResizing ? 0 : 0.5 };\n\tconst frameRef = useRef( null );\n\tconst resizableHandleHelpId = useInstanceId(\n\t\tResizableFrame,\n\t\t'edit-site-resizable-frame-handle-help'\n\t);\n\tconst defaultAspectRatio = defaultSize.width / defaultSize.height;\n\tconst isBlockTheme = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme } = select( coreStore );\n\t\treturn getCurrentTheme()?.is_block_theme;\n\t}, [] );\n\n\tconst handleResizeStart = ( _event, _direction, ref ) => {\n\t\t// Remember the starting width so we don't have to get `ref.offsetWidth` on\n\t\t// every resize event thereafter, which will cause layout thrashing.\n\t\tsetStartingWidth( ref.offsetWidth );\n\t\tsetIsResizing( true );\n\t};\n\n\t// Calculate the frame size based on the window width as its resized.\n\tconst handleResize = ( _event, _direction, _ref, delta ) => {\n\t\tconst normalizedDelta = delta.width / resizeRatio;\n\t\tconst deltaAbs = Math.abs( normalizedDelta );\n\t\tconst maxDoubledDelta =\n\t\t\tdelta.width < 0 // is shrinking\n\t\t\t\t? deltaAbs\n\t\t\t\t: ( defaultSize.width - startingWidth ) / 2;\n\t\tconst deltaToDouble = Math.min( deltaAbs, maxDoubledDelta );\n\t\tconst doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs;\n\t\tconst singleSegment = 1 - doubleSegment;\n\n\t\tsetResizeRatio( singleSegment + doubleSegment * 2 );\n\n\t\tconst updatedWidth = startingWidth + delta.width;\n\n\t\tsetIsOversized( updatedWidth > defaultSize.width );\n\n\t\t// Width will be controlled by the library (via `resizeRatio`),\n\t\t// so we only need to update the height.\n\t\tsetFrameSize( {\n\t\t\theight: isOversized\n\t\t\t\t? '100%'\n\t\t\t\t: calculateNewHeight( updatedWidth, defaultAspectRatio ),\n\t\t} );\n\t};\n\n\tconst handleResizeStop = ( _event, _direction, ref ) => {\n\t\tsetIsResizing( false );\n\n\t\tif ( ! isOversized ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsOversized( false );\n\n\t\tconst remainingWidth =\n\t\t\tref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth;\n\n\t\tif (\n\t\t\tremainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD ||\n\t\t\t! isBlockTheme\n\t\t) {\n\t\t\t// Reset the initial aspect ratio if the frame is resized slightly\n\t\t\t// above the sidebar but not far enough to trigger full screen.\n\t\t\tsetFrameSize( INITIAL_FRAME_SIZE );\n\t\t} else {\n\t\t\t// Trigger full screen if the frame is resized far enough to the left.\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} ),\n\t\t\t\t{\n\t\t\t\t\ttransition: 'canvas-mode-edit-transition',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\t// Handle resize by arrow keys\n\tconst handleResizableHandleKeyDown = ( event ) => {\n\t\tif ( ! [ 'ArrowLeft', 'ArrowRight' ].includes( event.key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\n\t\tconst step = 20 * ( event.shiftKey ? 5 : 1 );\n\t\tconst delta =\n\t\t\tstep *\n\t\t\t( event.key === 'ArrowLeft' ? 1 : -1 ) *\n\t\t\t( isRTL() ? -1 : 1 );\n\t\tconst newWidth = Math.min(\n\t\t\tMath.max(\n\t\t\t\tFRAME_MIN_WIDTH,\n\t\t\t\tframeRef.current.resizable.offsetWidth + delta\n\t\t\t),\n\t\t\tdefaultSize.width\n\t\t);\n\n\t\tsetFrameSize( {\n\t\t\twidth: newWidth,\n\t\t\theight: calculateNewHeight( newWidth, defaultAspectRatio ),\n\t\t} );\n\t};\n\n\tconst frameAnimationVariants = {\n\t\tdefault: {\n\t\t\tflexGrow: 0,\n\t\t\theight: frameSize.height,\n\t\t},\n\t\tfullWidth: {\n\t\t\tflexGrow: 1,\n\t\t\theight: frameSize.height,\n\t\t},\n\t};\n\n\tconst resizeHandleVariants = {\n\t\thidden: {\n\t\t\topacity: 0,\n\t\t\t...( isRTL() ? { right: 0 } : { left: 0 } ),\n\t\t},\n\t\tvisible: {\n\t\t\topacity: 1,\n\t\t\t// Account for the handle's width.\n\t\t\t...( isRTL() ? { right: -14 } : { left: -14 } ),\n\t\t},\n\t\tactive: {\n\t\t\topacity: 1,\n\t\t\t// Account for the handle's width.\n\t\t\t...( isRTL() ? { right: -14 } : { left: -14 } ),\n\t\t\tscaleY: 1.3,\n\t\t},\n\t};\n\tconst currentResizeHandleVariant = ( () => {\n\t\tif ( isResizing ) {\n\t\t\treturn 'active';\n\t\t}\n\t\treturn shouldShowHandle ? 'visible' : 'hidden';\n\t} )();\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tas={ motion.div }\n\t\t\tref={ frameRef }\n\t\t\tinitial={ false }\n\t\t\tvariants={ frameAnimationVariants }\n\t\t\tanimate={ isFullWidth ? 'fullWidth' : 'default' }\n\t\t\tonAnimationComplete={ ( definition ) => {\n\t\t\t\tif ( definition === 'fullWidth' ) {\n\t\t\t\t\tsetFrameSize( { width: '100%', height: '100%' } );\n\t\t\t\t}\n\t\t\t} }\n\t\t\twhileHover={\n\t\t\t\tcanvas === 'view'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscale: 1.005,\n\t\t\t\t\t\t\ttransition: {\n\t\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.5,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: {}\n\t\t\t}\n\t\t\ttransition={ FRAME_TRANSITION }\n\t\t\tsize={ frameSize }\n\t\t\tenable={ {\n\t\t\t\ttop: false,\n\t\t\t\tbottom: false,\n\t\t\t\t// Resizing will be disabled until the editor content is loaded.\n\t\t\t\t...( isRTL()\n\t\t\t\t\t? { right: isReady, left: false }\n\t\t\t\t\t: { left: isReady, right: false } ),\n\t\t\t\ttopRight: false,\n\t\t\t\tbottomRight: false,\n\t\t\t\tbottomLeft: false,\n\t\t\t\ttopLeft: false,\n\t\t\t} }\n\t\t\tresizeRatio={ resizeRatio }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t\tminWidth={ FRAME_MIN_WIDTH }\n\t\t\tmaxWidth={ isFullWidth ? '100%' : '150%' }\n\t\t\tmaxHeight=\"100%\"\n\t\t\tonFocus={ () => setShouldShowHandle( true ) }\n\t\t\tonBlur={ () => setShouldShowHandle( false ) }\n\t\t\tonMouseOver={ () => setShouldShowHandle( true ) }\n\t\t\tonMouseOut={ () => setShouldShowHandle( false ) }\n\t\t\thandleComponent={ {\n\t\t\t\t[ isRTL() ? 'right' : 'left' ]: canvas === 'view' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t\t\t\t{ /* Disable reason: role=\"separator\" does in fact support aria-valuenow */ }\n\t\t\t\t\t\t\t{ /* eslint-disable-next-line jsx-a11y/role-supports-aria-props */ }\n\t\t\t\t\t\t\t<motion.button\n\t\t\t\t\t\t\t\tkey=\"handle\"\n\t\t\t\t\t\t\t\trole=\"separator\"\n\t\t\t\t\t\t\t\taria-orientation=\"vertical\"\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'edit-site-resizable-frame__handle',\n\t\t\t\t\t\t\t\t\t{ 'is-resizing': isResizing }\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvariants={ resizeHandleVariants }\n\t\t\t\t\t\t\t\tanimate={ currentResizeHandleVariant }\n\t\t\t\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\t\t\t\taria-describedby={ resizableHandleHelpId }\n\t\t\t\t\t\t\t\taria-valuenow={\n\t\t\t\t\t\t\t\t\tframeRef.current?.resizable?.offsetWidth ||\n\t\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-valuemin={ FRAME_MIN_WIDTH }\n\t\t\t\t\t\t\t\taria-valuemax={ defaultSize.width }\n\t\t\t\t\t\t\t\tonKeyDown={ handleResizableHandleKeyDown }\n\t\t\t\t\t\t\t\tinitial=\"hidden\"\n\t\t\t\t\t\t\t\texit=\"hidden\"\n\t\t\t\t\t\t\t\twhileFocus=\"active\"\n\t\t\t\t\t\t\t\twhileHover=\"active\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t<div hidden id={ resizableHandleHelpId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t),\n\t\t\t} }\n\t\t\tonResizeStart={ handleResizeStart }\n\t\t\tonResize={ handleResize }\n\t\t\tonResizeStop={ handleResizeStop }\n\t\t\tclassName={ clsx( 'edit-site-resizable-frame__inner', {\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t} ) }\n\t\t\tshowHandle={ false } // Do not show the default handle, as we're using a custom one.\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-resizable-frame__inner-content\"\n\t\t\t\tstyle={ innerContentStyle }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableFrame;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SACCC,YAAY,EACZC,OAAO,EACPC,gBAAgB,IAAIC,MAAM,QACpB,uBAAuB;AAC9B,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,YAAY,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9C,MAAM;EAAEC,WAAW;EAAEC;AAAW,CAAC,GAAGT,MAAM,CAAEJ,iBAAkB,CAAC;;AAE/D;AACA,MAAMc,sBAAsB,GAAG;EAC9BC,QAAQ,EAAEC,SAAS;EACnBC,UAAU,EAAED,SAAS;EACrBE,MAAM,EAAEF,SAAS;EACjBG,KAAK,EAAEH,SAAS;EAChBI,MAAM,EAAEJ,SAAS;EACjBK,GAAG,EAAEL,SAAS;EACdM,KAAK,EAAEN,SAAS;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I,CACf,mCAAmC,EACnC;cAAE,aAAa,EAAEsE;YAAW,CAC7B,CAAG;YACH8D,QAAQ,EAAGV,oBAAsB;YACjCW,OAAO,EAAGL,0BAA4B;YACtC,cAAavH,EAAE,CAAE,gBAAiB,CAAG;YACrC,oBAAmBuE,qBAAuB;YAC1C,iBACCD,QAAQ,CAACqC,OAAO,EAAEC,SAAS,EAAE3B,WAAW,IACxC9D,SACA;YACD,iBAAgBS,eAAiB;YACjC,iBAAgBsB,WAAW,CAAC5B,KAAO;YACnCgI,SAAS,EAAGnD,4BAA8B;YAC1CuB,OAAO,EAAC,QAAQ;YAChB6B,IAAI,EAAC,QAAQ;YACbC,UAAU,EAAC,QAAQ;YACnBzB,UAAU,EAAC;UAAQ,GArBf,QAsBJ;QAAC,CACM,CAAC,eACVrH,IAAA;UAAKwG,MAAM;UAACuC,EAAE,EAAGlF,qBAAuB;UAAAtB,QAAA,EACrCjD,EAAE,CACH,gGACD;QAAC,CACG,CAAC;MAAA,CACL;IAEJ,CAAG;IACH0J,aAAa,EAAG7E,iBAAmB;IACnC8E,QAAQ,EAAGzE,YAAc;IACzB0E,YAAY,EAAG/D,gBAAkB;IACjCwD,SAAS,EAAG9J,IAAI,CAAE,kCAAkC,EAAE;MACrD,aAAa,EAAEsE;IAChB,CAAE,CAAG;IACLgG,UAAU,EAAG,KAAO,CAAC;IAAA;IAAA5G,QAAA,eAErBvC,IAAA;MACC2I,SAAS,EAAC,0CAA0C;MACpDS,KAAK,EAAG3G,iBAAmB;MAAAF,QAAA,EAEzBA;IAAQ,CACN;EAAC,CACO,CAAC;AAEjB;AAEA,eAAeL,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["clsx","useState","useRef","ResizableBox","Tooltip","__unstableMotion","motion","useInstanceId","useReducedMotion","__","isRTL","privateApis","routerPrivateApis","useSelect","store","coreStore","unlock","addQueryArgs","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useLocation","useHistory","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","width","height","top","right","bottom","left","FRAME_MIN_WIDTH","FRAME_REFERENCE_WIDTH","FRAME_TARGET_ASPECT_RATIO","SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD","INITIAL_FRAME_SIZE","calculateNewHeight","initialAspectRatio","lerp","a","b","amount","lerpFactor","Math","max","min","intermediateAspectRatio","ResizableFrame","isFullWidth","isOversized","setIsOversized","isReady","children","defaultSize","innerContentStyle","history","path","query","canvas","disableMotion","frameSize","setFrameSize","startingWidth","setStartingWidth","isResizing","setIsResizing","shouldShowHandle","setShouldShowHandle","resizeRatio","setResizeRatio","FRAME_TRANSITION","type","duration","frameRef","resizableHandleHelpId","defaultAspectRatio","isBlockTheme","select","getCurrentTheme","is_block_theme","handleResizeStart","_event","_direction","ref","offsetWidth","handleResize","_ref","delta","normalizedDelta","deltaAbs","abs","maxDoubledDelta","deltaToDouble","doubleSegment","singleSegment","updatedWidth","handleResizeStop","remainingWidth","ownerDocument","documentElement","navigate","transition","handleResizableHandleKeyDown","event","includes","key","preventDefault","step","shiftKey","newWidth","current","resizable","frameAnimationVariants","default","flexGrow","fullWidth","resizeHandleVariants","hidden","opacity","visible","active","scaleY","currentResizeHandleVariant","as","div","initial","variants","animate","onAnimationComplete","definition","whileHover","scale","ease","size","enable","topRight","bottomRight","bottomLeft","topLeft","handleClasses","handleStyles","minWidth","maxWidth","maxHeight","onFocus","onBlur","onMouseOver","onMouseOut","handleComponent","text","button","role","className","onKeyDown","exit","whileFocus","id","onResizeStart","onResize","onResizeStop","showHandle","style"],"sources":["@wordpress/edit-site/src/components/resizable-frame/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport {\n\tResizableBox,\n\tTooltip,\n\t__unstableMotion as motion,\n} from '@wordpress/components';\nimport { useInstanceId, useReducedMotion } from '@wordpress/compose';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { addQueryArgs } from '@wordpress/url';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\n// The minimum width of the frame (in px) while resizing.\nconst FRAME_MIN_WIDTH = 320;\n// The reference width of the frame (in px) used to calculate the aspect ratio.\nconst FRAME_REFERENCE_WIDTH = 1300;\n// 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing.\nconst FRAME_TARGET_ASPECT_RATIO = 9 / 19.5;\n// The minimum distance (in px) between the frame resize handle and the\n// viewport's edge. If the frame is resized to be closer to the viewport's edge\n// than this distance, then \"canvas mode\" will be enabled.\nconst SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200;\n// Default size for the `frameSize` state.\nconst INITIAL_FRAME_SIZE = { width: '100%', height: '100%' };\n\nfunction calculateNewHeight( width, initialAspectRatio ) {\n\tconst lerp = ( a, b, amount ) => {\n\t\treturn a + ( b - a ) * amount;\n\t};\n\n\t// Calculate the intermediate aspect ratio based on the current width.\n\tconst lerpFactor =\n\t\t1 -\n\t\tMath.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\t1,\n\t\t\t\t( width - FRAME_MIN_WIDTH ) /\n\t\t\t\t\t( FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH )\n\t\t\t)\n\t\t);\n\n\t// Calculate the height based on the intermediate aspect ratio\n\t// ensuring the frame arrives at the target aspect ratio.\n\tconst intermediateAspectRatio = lerp(\n\t\tinitialAspectRatio,\n\t\tFRAME_TARGET_ASPECT_RATIO,\n\t\tlerpFactor\n\t);\n\n\treturn width / intermediateAspectRatio;\n}\n\nfunction ResizableFrame( {\n\tisFullWidth,\n\tisOversized,\n\tsetIsOversized,\n\tisReady,\n\tchildren,\n\t/** The default (unresized) width/height of the frame, based on the space available in the viewport. */\n\tdefaultSize,\n\tinnerContentStyle,\n} ) {\n\tconst history = useHistory();\n\tconst { path, query } = useLocation();\n\tconst { canvas = 'view' } = query;\n\tconst disableMotion = useReducedMotion();\n\tconst [ frameSize, setFrameSize ] = useState( INITIAL_FRAME_SIZE );\n\t// The width of the resizable frame when a new resize gesture starts.\n\tconst [ startingWidth, setStartingWidth ] = useState();\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ shouldShowHandle, setShouldShowHandle ] = useState( false );\n\tconst [ resizeRatio, setResizeRatio ] = useState( 1 );\n\n\tconst FRAME_TRANSITION = { type: 'tween', duration: isResizing ? 0 : 0.5 };\n\tconst frameRef = useRef( null );\n\tconst resizableHandleHelpId = useInstanceId(\n\t\tResizableFrame,\n\t\t'edit-site-resizable-frame-handle-help'\n\t);\n\tconst defaultAspectRatio = defaultSize.width / defaultSize.height;\n\tconst isBlockTheme = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme } = select( coreStore );\n\t\treturn getCurrentTheme()?.is_block_theme;\n\t}, [] );\n\n\tconst handleResizeStart = ( _event, _direction, ref ) => {\n\t\t// Remember the starting width so we don't have to get `ref.offsetWidth` on\n\t\t// every resize event thereafter, which will cause layout thrashing.\n\t\tsetStartingWidth( ref.offsetWidth );\n\t\tsetIsResizing( true );\n\t};\n\n\t// Calculate the frame size based on the window width as its resized.\n\tconst handleResize = ( _event, _direction, _ref, delta ) => {\n\t\tconst normalizedDelta = delta.width / resizeRatio;\n\t\tconst deltaAbs = Math.abs( normalizedDelta );\n\t\tconst maxDoubledDelta =\n\t\t\tdelta.width < 0 // is shrinking\n\t\t\t\t? deltaAbs\n\t\t\t\t: ( defaultSize.width - startingWidth ) / 2;\n\t\tconst deltaToDouble = Math.min( deltaAbs, maxDoubledDelta );\n\t\tconst doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs;\n\t\tconst singleSegment = 1 - doubleSegment;\n\n\t\tsetResizeRatio( singleSegment + doubleSegment * 2 );\n\n\t\tconst updatedWidth = startingWidth + delta.width;\n\n\t\tsetIsOversized( updatedWidth > defaultSize.width );\n\n\t\t// Width will be controlled by the library (via `resizeRatio`),\n\t\t// so we only need to update the height.\n\t\tsetFrameSize( {\n\t\t\theight: isOversized\n\t\t\t\t? '100%'\n\t\t\t\t: calculateNewHeight( updatedWidth, defaultAspectRatio ),\n\t\t} );\n\t};\n\n\tconst handleResizeStop = ( _event, _direction, ref ) => {\n\t\tsetIsResizing( false );\n\n\t\tif ( ! isOversized ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsOversized( false );\n\n\t\tconst remainingWidth =\n\t\t\tref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth;\n\n\t\tif (\n\t\t\tremainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD ||\n\t\t\t! isBlockTheme\n\t\t) {\n\t\t\t// Reset the initial aspect ratio if the frame is resized slightly\n\t\t\t// above the sidebar but not far enough to trigger full screen.\n\t\t\tsetFrameSize( INITIAL_FRAME_SIZE );\n\t\t} else {\n\t\t\t// Trigger full screen if the frame is resized far enough to the left.\n\t\t\thistory.navigate(\n\t\t\t\taddQueryArgs( path, {\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} ),\n\t\t\t\t{\n\t\t\t\t\ttransition: 'canvas-mode-edit-transition',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\t// Handle resize by arrow keys\n\tconst handleResizableHandleKeyDown = ( event ) => {\n\t\tif ( ! [ 'ArrowLeft', 'ArrowRight' ].includes( event.key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tevent.preventDefault();\n\n\t\tconst step = 20 * ( event.shiftKey ? 5 : 1 );\n\t\tconst delta =\n\t\t\tstep *\n\t\t\t( event.key === 'ArrowLeft' ? 1 : -1 ) *\n\t\t\t( isRTL() ? -1 : 1 );\n\t\tconst newWidth = Math.min(\n\t\t\tMath.max(\n\t\t\t\tFRAME_MIN_WIDTH,\n\t\t\t\tframeRef.current.resizable.offsetWidth + delta\n\t\t\t),\n\t\t\tdefaultSize.width\n\t\t);\n\n\t\tsetFrameSize( {\n\t\t\twidth: newWidth,\n\t\t\theight: calculateNewHeight( newWidth, defaultAspectRatio ),\n\t\t} );\n\t};\n\n\tconst frameAnimationVariants = {\n\t\tdefault: {\n\t\t\tflexGrow: 0,\n\t\t\theight: frameSize.height,\n\t\t},\n\t\tfullWidth: {\n\t\t\tflexGrow: 1,\n\t\t\theight: frameSize.height,\n\t\t},\n\t};\n\n\tconst resizeHandleVariants = {\n\t\thidden: {\n\t\t\topacity: 0,\n\t\t\t...( isRTL() ? { right: 0 } : { left: 0 } ),\n\t\t},\n\t\tvisible: {\n\t\t\topacity: 1,\n\t\t\t// Account for the handle's width.\n\t\t\t...( isRTL() ? { right: -14 } : { left: -14 } ),\n\t\t},\n\t\tactive: {\n\t\t\topacity: 1,\n\t\t\t// Account for the handle's width.\n\t\t\t...( isRTL() ? { right: -14 } : { left: -14 } ),\n\t\t\tscaleY: 1.3,\n\t\t},\n\t};\n\tconst currentResizeHandleVariant = ( () => {\n\t\tif ( isResizing ) {\n\t\t\treturn 'active';\n\t\t}\n\t\treturn shouldShowHandle ? 'visible' : 'hidden';\n\t} )();\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tas={ motion.div }\n\t\t\tref={ frameRef }\n\t\t\tinitial={ false }\n\t\t\tvariants={ frameAnimationVariants }\n\t\t\tanimate={ isFullWidth ? 'fullWidth' : 'default' }\n\t\t\tonAnimationComplete={ ( definition ) => {\n\t\t\t\tif ( definition === 'fullWidth' ) {\n\t\t\t\t\tsetFrameSize( { width: '100%', height: '100%' } );\n\t\t\t\t}\n\t\t\t} }\n\t\t\twhileHover={\n\t\t\t\tcanvas === 'view'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tscale: 1.005,\n\t\t\t\t\t\t\ttransition: {\n\t\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.5,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: {}\n\t\t\t}\n\t\t\ttransition={ FRAME_TRANSITION }\n\t\t\tsize={ frameSize }\n\t\t\tenable={ {\n\t\t\t\ttop: false,\n\t\t\t\tbottom: false,\n\t\t\t\t// Resizing will be disabled until the editor content is loaded.\n\t\t\t\t...( isRTL()\n\t\t\t\t\t? { right: isReady, left: false }\n\t\t\t\t\t: { left: isReady, right: false } ),\n\t\t\t\ttopRight: false,\n\t\t\t\tbottomRight: false,\n\t\t\t\tbottomLeft: false,\n\t\t\t\ttopLeft: false,\n\t\t\t} }\n\t\t\tresizeRatio={ resizeRatio }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t\tminWidth={ FRAME_MIN_WIDTH }\n\t\t\tmaxWidth={ isFullWidth ? '100%' : '150%' }\n\t\t\tmaxHeight=\"100%\"\n\t\t\tonFocus={ () => setShouldShowHandle( true ) }\n\t\t\tonBlur={ () => setShouldShowHandle( false ) }\n\t\t\tonMouseOver={ () => setShouldShowHandle( true ) }\n\t\t\tonMouseOut={ () => setShouldShowHandle( false ) }\n\t\t\thandleComponent={ {\n\t\t\t\t[ isRTL() ? 'right' : 'left' ]: canvas === 'view' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Tooltip text={ __( 'Drag to resize' ) }>\n\t\t\t\t\t\t\t{ /* Disable reason: role=\"separator\" does in fact support aria-valuenow */ }\n\t\t\t\t\t\t\t{ /* eslint-disable-next-line jsx-a11y/role-supports-aria-props */ }\n\t\t\t\t\t\t\t<motion.button\n\t\t\t\t\t\t\t\tkey=\"handle\"\n\t\t\t\t\t\t\t\trole=\"separator\"\n\t\t\t\t\t\t\t\taria-orientation=\"vertical\"\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'edit-site-resizable-frame__handle',\n\t\t\t\t\t\t\t\t\t{ 'is-resizing': isResizing }\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvariants={ resizeHandleVariants }\n\t\t\t\t\t\t\t\tanimate={ currentResizeHandleVariant }\n\t\t\t\t\t\t\t\taria-label={ __( 'Drag to resize' ) }\n\t\t\t\t\t\t\t\taria-describedby={ resizableHandleHelpId }\n\t\t\t\t\t\t\t\taria-valuenow={\n\t\t\t\t\t\t\t\t\tframeRef.current?.resizable?.offsetWidth ||\n\t\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-valuemin={ FRAME_MIN_WIDTH }\n\t\t\t\t\t\t\t\taria-valuemax={ defaultSize.width }\n\t\t\t\t\t\t\t\tonKeyDown={ handleResizableHandleKeyDown }\n\t\t\t\t\t\t\t\tinitial=\"hidden\"\n\t\t\t\t\t\t\t\texit=\"hidden\"\n\t\t\t\t\t\t\t\twhileFocus=\"active\"\n\t\t\t\t\t\t\t\twhileHover=\"active\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t<div hidden id={ resizableHandleHelpId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t),\n\t\t\t} }\n\t\t\tonResizeStart={ handleResizeStart }\n\t\t\tonResize={ handleResize }\n\t\t\tonResizeStop={ handleResizeStop }\n\t\t\tclassName={ clsx( 'edit-site-resizable-frame__inner', {\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t} ) }\n\t\t\tshowHandle={ false } // Do not show the default handle, as we're using a custom one.\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-resizable-frame__inner-content\"\n\t\t\t\tstyle={ innerContentStyle }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableFrame;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SACCC,YAAY,EACZC,OAAO,EACPC,gBAAgB,IAAIC,MAAM,QACpB,uBAAuB;AAC9B,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,YAAY,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9C,MAAM;EAAEC,WAAW;EAAEC;AAAW,CAAC,GAAGT,MAAM,CAAEJ,iBAAkB,CAAC;;AAE/D;AACA,MAAMc,sBAAsB,GAAG;EAC9BC,QAAQ,EAAEC,SAAS;EACnBC,UAAU,EAAED,SAAS;EACrBE,MAAM,EAAEF,SAAS;EACjBG,KAAK,EAAEH,SAAS;EAChBI,MAAM,EAAEJ,SAAS;EACjBK,GAAG,EAAEL,SAAS;EACdM,KAAK,EAAEN,SAAS;EAChBO,MAAM,EAAEP,SAAS;EACjBQ,IAAI,EAAER;AACP,CAAC;;AAED;AACA,MAAMS,eAAe,GAAG,GAAG;AAC3B;AACA,MAAMC,qBAAqB,GAAG,IAAI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,EAAE,CAAE,gBAAiB,CAAG;YACrC,oBAAmBuE,qBAAuB;YAC1C,iBACCD,QAAQ,CAACqC,OAAO,EAAEC,SAAS,EAAE3B,WAAW,IACxC9D,SACA;YACD,iBAAgBS,eAAiB;YACjC,iBAAgBsB,WAAW,CAAC5B,KAAO;YACnCgI,SAAS,EAAGnD,4BAA8B;YAC1CuB,OAAO,EAAC,QAAQ;YAChB6B,IAAI,EAAC,QAAQ;YACbC,UAAU,EAAC,QAAQ;YACnBzB,UAAU,EAAC;UAAQ,GArBf,QAsBJ;QAAC,CACM,CAAC,eACVrH,IAAA;UAAKwG,MAAM;UAACuC,EAAE,EAAGlF,qBAAuB;UAAAtB,QAAA,EACrCjD,EAAE,CACH,gGACD;QAAC,CACG,CAAC;MAAA,CACL;IAEJ,CAAG;IACH0J,aAAa,EAAG7E,iBAAmB;IACnC8E,QAAQ,EAAGzE,YAAc;IACzB0E,YAAY,EAAG/D,gBAAkB;IACjCwD,SAAS,EAAG9J,IAAI,CAAE,kCAAkC,EAAE;MACrD,aAAa,EAAEsE;IAChB,CAAE,CAAG;IACLgG,UAAU,EAAG,KAAO,CAAC;IAAA;IAAA5G,QAAA,eAErBvC,IAAA;MACC2I,SAAS,EAAC,0CAA0C;MACpDS,KAAK,EAAG3G,iBAAmB;MAAAF,QAAA,EAEzBA;IAAQ,CACN;EAAC,CACO,CAAC;AAEjB;AAEA,eAAeL,cAAc","ignoreList":[]}
@@ -36,7 +36,7 @@ function useDeleteNavigationMenu() {
36
36
  createSuccessNotice(__('Navigation Menu successfully deleted.'), {
37
37
  type: 'snackbar'
38
38
  });
39
- history.navivate('/navigation');
39
+ history.navigate('/navigation');
40
40
  } catch (error) {
41
41
  createErrorNotice(sprintf(/* translators: %s: error message describing why the navigation menu could not be deleted. */
42
42
  __(`Unable to delete Navigation Menu (%s).`), error?.message), {
@@ -1 +1 @@
1
- {"version":3,"names":["store","coreStore","__","_x","sprintf","useSelect","useDispatch","noticesStore","privateApis","routerPrivateApis","postType","NAVIGATION_POST_TYPE","unlock","useHistory","useDeleteNavigationMenu","deleteEntityRecord","createSuccessNotice","createErrorNotice","history","handleDelete","navigationMenu","postId","id","force","throwOnError","type","navivate","error","message","useSaveNavigationMenu","getEditedEntityRecord","select","getEditedEntityRecordSelector","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","handleSave","edits","originalRecord","recordPropertiesToSave","Object","keys","useDuplicateNavigationMenu","saveEntityRecord","handleDuplicate","menuTitle","title","rendered","slug","savedRecord","content","raw","status","navigate","useNavigationMenuHandlers"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { postType } from '.';\nimport { NAVIGATION_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction useDeleteNavigationMenu() {\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst history = useHistory();\n\n\tconst handleDelete = async ( navigationMenu ) => {\n\t\tconst postId = navigationMenu?.id;\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\t{\n\t\t\t\t\tforce: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__( 'Navigation Menu successfully deleted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\thistory.navivate( '/navigation' );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be deleted. */\n\t\t\t\t\t__( `Unable to delete Navigation Menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleDelete;\n}\n\nfunction useSaveNavigationMenu() {\n\tconst { getEditedEntityRecord } = useSelect( ( select ) => {\n\t\tconst { getEditedEntityRecord: getEditedEntityRecordSelector } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\tgetEditedEntityRecord: getEditedEntityRecordSelector,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleSave = async ( navigationMenu, edits ) => {\n\t\tif ( ! edits ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst postId = navigationMenu?.id;\n\t\t// Prepare for revert in case of error.\n\t\tconst originalRecord = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tNAVIGATION_POST_TYPE,\n\t\t\tpostId\n\t\t);\n\n\t\t// Apply the edits.\n\t\teditEntityRecord( 'postType', postType, postId, edits );\n\n\t\tconst recordPropertiesToSave = Object.keys( edits );\n\n\t\t// Attempt to persist.\n\t\ttry {\n\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\trecordPropertiesToSave,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice( __( 'Renamed Navigation Menu' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Revert to original in case of error.\n\t\t\teditEntityRecord( 'postType', postType, postId, originalRecord );\n\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be renamed. */\n\t\t\t\t\t__( `Unable to rename Navigation Menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleSave;\n}\n\nfunction useDuplicateNavigationMenu() {\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleDuplicate = async ( navigationMenu ) => {\n\t\tconst menuTitle =\n\t\t\tnavigationMenu?.title?.rendered || navigationMenu?.slug;\n\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t/* translators: %s: Navigation menu title */\n\t\t\t\t\t\t_x( '%s (Copy)', 'navigation menu' ),\n\t\t\t\t\t\tmenuTitle\n\t\t\t\t\t),\n\t\t\t\t\tcontent: navigationMenu?.content?.raw,\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\tcreateSuccessNotice( __( 'Duplicated Navigation Menu' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\thistory.navigate( `/wp_navigation/${ savedRecord.id }` );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be deleted. */\n\t\t\t\t\t__( `Unable to duplicate Navigation Menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleDuplicate;\n}\n\nexport default function useNavigationMenuHandlers() {\n\treturn {\n\t\thandleDelete: useDeleteNavigationMenu(),\n\t\thandleSave: useSaveNavigationMenu(),\n\t\thandleDuplicate: useDuplicateNavigationMenu(),\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASN,KAAK,IAAIO,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,GAAG;AAC5B,SAASC,oBAAoB,QAAQ,uBAAuB;AAC5D,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAW,CAAC,GAAGD,MAAM,CAAEH,iBAAkB,CAAC;AAElD,SAASK,uBAAuBA,CAAA,EAAG;EAClC,MAAM;IAAEC;EAAmB,CAAC,GAAGT,WAAW,CAAEL,SAAU,CAAC;EACvD,MAAM;IAAEe,mBAAmB;IAAEC;EAAkB,CAAC,GAC/CX,WAAW,CAAEC,YAAa,CAAC;EAC5B,MAAMW,OAAO,GAAGL,UAAU,CAAC,CAAC;EAE5B,MAAMM,YAAY,GAAG,MAAQC,cAAc,IAAM;IAChD,MAAMC,MAAM,GAAGD,cAAc,EAAEE,EAAE;IACjC,IAAI;MACH,MAAMP,kBAAkB,CACvB,UAAU,EACVL,QAAQ,EACRW,MAAM,EACN;QACCE,KAAK,EAAE;MACR,CAAC,EACD;Q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AE,CAAE,4BAA6B,CAAC,EAAE;UACxDuB,IAAI,EAAE;QACP,CAAE,CAAC;QACHP,OAAO,CAACmC,QAAQ,CAAE,kBAAmBJ,WAAW,CAAC3B,EAAE,EAAI,CAAC;MACzD;IACD,CAAC,CAAC,OAAQK,KAAK,EAAG;MACjBV,iBAAiB,CAChBb,OAAO,CACN;MACAF,EAAE,CAAE,2CAA4C,CAAC,EACjDyB,KAAK,EAAEC,OACR,CAAC,EAED;QACCH,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAC;EAED,OAAOmB,eAAe;AACvB;AAEA,eAAe,SAASU,yBAAyBA,CAAA,EAAG;EACnD,OAAO;IACNnC,YAAY,EAAEL,uBAAuB,CAAC,CAAC;IACvCsB,UAAU,EAAEP,qBAAqB,CAAC,CAAC;IACnCe,eAAe,EAAEF,0BAA0B,CAAC;EAC7C,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["store","coreStore","__","_x","sprintf","useSelect","useDispatch","noticesStore","privateApis","routerPrivateApis","postType","NAVIGATION_POST_TYPE","unlock","useHistory","useDeleteNavigationMenu","deleteEntityRecord","createSuccessNotice","createErrorNotice","history","handleDelete","navigationMenu","postId","id","force","throwOnError","type","navigate","error","message","useSaveNavigationMenu","getEditedEntityRecord","select","getEditedEntityRecordSelector","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","handleSave","edits","originalRecord","recordPropertiesToSave","Object","keys","useDuplicateNavigationMenu","saveEntityRecord","handleDuplicate","menuTitle","title","rendered","slug","savedRecord","content","raw","status","useNavigationMenuHandlers"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { postType } from '.';\nimport { NAVIGATION_POST_TYPE } from '../../utils/constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction useDeleteNavigationMenu() {\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst history = useHistory();\n\n\tconst handleDelete = async ( navigationMenu ) => {\n\t\tconst postId = navigationMenu?.id;\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\t{\n\t\t\t\t\tforce: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\t__( 'Navigation Menu successfully deleted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\thistory.navigate( '/navigation' );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be deleted. */\n\t\t\t\t\t__( `Unable to delete Navigation Menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleDelete;\n}\n\nfunction useSaveNavigationMenu() {\n\tconst { getEditedEntityRecord } = useSelect( ( select ) => {\n\t\tconst { getEditedEntityRecord: getEditedEntityRecordSelector } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\tgetEditedEntityRecord: getEditedEntityRecordSelector,\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleSave = async ( navigationMenu, edits ) => {\n\t\tif ( ! edits ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst postId = navigationMenu?.id;\n\t\t// Prepare for revert in case of error.\n\t\tconst originalRecord = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tNAVIGATION_POST_TYPE,\n\t\t\tpostId\n\t\t);\n\n\t\t// Apply the edits.\n\t\teditEntityRecord( 'postType', postType, postId, edits );\n\n\t\tconst recordPropertiesToSave = Object.keys( edits );\n\n\t\t// Attempt to persist.\n\t\ttry {\n\t\t\tawait saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t\trecordPropertiesToSave,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t\tcreateSuccessNotice( __( 'Renamed Navigation Menu' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Revert to original in case of error.\n\t\t\teditEntityRecord( 'postType', postType, postId, originalRecord );\n\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be renamed. */\n\t\t\t\t\t__( `Unable to rename Navigation Menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleSave;\n}\n\nfunction useDuplicateNavigationMenu() {\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst handleDuplicate = async ( navigationMenu ) => {\n\t\tconst menuTitle =\n\t\t\tnavigationMenu?.title?.rendered || navigationMenu?.slug;\n\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\ttitle: sprintf(\n\t\t\t\t\t\t/* translators: %s: Navigation menu title */\n\t\t\t\t\t\t_x( '%s (Copy)', 'navigation menu' ),\n\t\t\t\t\t\tmenuTitle\n\t\t\t\t\t),\n\t\t\t\t\tcontent: navigationMenu?.content?.raw,\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\tcreateSuccessNotice( __( 'Duplicated Navigation Menu' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\thistory.navigate( `/wp_navigation/${ savedRecord.id }` );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: error message describing why the navigation menu could not be deleted. */\n\t\t\t\t\t__( `Unable to duplicate Navigation Menu (%s).` ),\n\t\t\t\t\terror?.message\n\t\t\t\t),\n\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\treturn handleDuplicate;\n}\n\nexport default function useNavigationMenuHandlers() {\n\treturn {\n\t\thandleDelete: useDeleteNavigationMenu(),\n\t\thandleSave: useSaveNavigationMenu(),\n\t\thandleDuplicate: useDuplicateNavigationMenu(),\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASN,KAAK,IAAIO,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,IAAIC,iBAAiB,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ordPress dependencies
4
4
  */
5
+ // @wordpress/blocks imports are not typed.
6
+ // @ts-expect-error
5
7
  import { getCategories } from '@wordpress/blocks';
6
8
 
7
9
  /**
@@ -17,20 +19,24 @@ import { STYLE_BOOK_CATEGORIES, STYLE_BOOK_THEME_SUBCATEGORIES } from './constan
17
19
  * @return {CategoryExamples|undefined} An object containing the category examples.
18
20
  */
19
21
  export function getExamplesByCategory(categoryDefinition, examples) {
22
+ var _categoryDefinition$s;
20
23
  if (!categoryDefinition?.slug || !examples?.length) {
21
24
  return;
22
25
  }
23
- if (categoryDefinition?.subcategories?.length) {
24
- return categoryDefinition.subcategories.reduce((acc, subcategoryDefinition) => {
26
+ const categories = (_categoryDefinition$s = categoryDefinition?.subcategories) !== null && _categoryDefinition$s !== void 0 ? _categoryDefinition$s : [];
27
+ if (categories.length) {
28
+ return categories.reduce((acc, subcategoryDefinition) => {
25
29
  const subcategoryExamples = getExamplesByCategory(subcategoryDefinition, examples);
26
30
  if (subcategoryExamples) {
31
+ if (!acc.subcategories) {
32
+ acc.subcategories = [];
33
+ }
27
34
  acc.subcategories = [...acc.subcategories, subcategoryExamples];
28
35
  }
29
36
  return acc;
30
37
  }, {
31
38
  title: categoryDefinition.title,
32
- slug: categoryDefinition.slug,
33
- subcategories: []
39
+ slug: categoryDefinition.slug
34
40
  });
35
41
  }
36
42
  const blocksToInclude = categoryDefinition?.blocks || [];
@@ -57,9 +63,10 @@ export function getTopLevelStyleBookCategories() {
57
63
  const reservedCategories = [...STYLE_BOOK_THEME_SUBCATEGORIES, ...STYLE_BOOK_CATEGORIES].map(({
58
64
  slug
59
65
  }) => slug);
60
- const extraCategories = getCategories().filter(({
66
+ const extraCategories = getCategories();
67
+ const extraCategoriesFiltered = extraCategories.filter(({
61
68
  slug
62
69
  }) => !reservedCategories.includes(slug));
63
- return [...STYLE_BOOK_CATEGORIES, ...extraCategories];
70
+ return [...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered];
64
71
  }
65
72
  //# sourceMappingURL=categories.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getCategories","STYLE_BOOK_CATEGORIES","STYLE_BOOK_THEME_SUBCATEGORIES","getExamplesByCategory","categoryDefinition","examples","slug","length","subcategories","reduce","acc","subcategoryDefinition","subcategoryExamples","title","blocksToInclude","blocks","blocksToExclude","exclude","categoryExamples","filter","example","includes","name","category","getTopLevelStyleBookCategories","reservedCategories","map","extraCategories"],"sources":["@wordpress/edit-site/src/components/style-book/categories.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getCategories } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tBlockExample,\n\tStyleBookCategory,\n\tCategoryExamples,\n} from './types';\nimport {\n\tSTYLE_BOOK_CATEGORIES,\n\tSTYLE_BOOK_THEME_SUBCATEGORIES,\n} from './constants';\n\n/**\n * Returns category examples for a given category definition and list of examples.\n * @param {StyleBookCategory} categoryDefinition The category definition.\n * @param {BlockExample[]} examples An array of block examples.\n * @return {CategoryExamples|undefined} An object containing the category examples.\n */\nexport function getExamplesByCategory(\n\tcategoryDefinition: StyleBookCategory,\n\texamples: BlockExample[]\n): CategoryExamples | undefined {\n\tif ( ! categoryDefinition?.slug || ! examples?.length ) {\n\t\treturn;\n\t}\n\n\tif ( categoryDefinition?.subcategories?.length ) {\n\t\treturn categoryDefinition.subcategories.reduce(\n\t\t\t( acc, subcategoryDefinition ) => {\n\t\t\t\tconst subcategoryExamples = getExamplesByCategory(\n\t\t\t\t\tsubcategoryDefinition,\n\t\t\t\t\texamples\n\t\t\t\t);\n\t\t\t\tif ( subcategoryExamples ) {\n\t\t\t\t\tacc.subcategories = [\n\t\t\t\t\t\t...acc.subcategories,\n\t\t\t\t\t\tsubcategoryExamples,\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: categoryDefinition.title,\n\t\t\t\tslug: categoryDefinition.slug,\n\t\t\t\tsubcategories: [],\n\t\t\t}\n\t\t);\n\t}\n\n\tconst blocksToInclude = categoryDefinition?.blocks || [];\n\tconst blocksToExclude = categoryDefinition?.exclude || [];\n\tconst categoryExamples = examples.filter( ( example ) => {\n\t\treturn (\n\t\t\t! blocksToExclude.includes( example.name ) &&\n\t\t\t( example.category === categoryDefinition.slug ||\n\t\t\t\tblocksToInclude.includes( example.name ) )\n\t\t);\n\t} );\n\n\tif ( ! categoryExamples.length ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\ttitle: categoryDefinition.title,\n\t\tslug: categoryDefinition.slug,\n\t\texamples: categoryExamples,\n\t};\n}\n\n/**\n * Returns category examples for a given category definition and list of examples.\n *\n * @return {StyleBookCategory[]} An array of top-level category definitions.\n */\nexport function getTopLevelStyleBookCategories(): StyleBookCategory[] {\n\tconst reservedCategories = [\n\t\t...STYLE_BOOK_THEME_SUBCATEGORIES,\n\t\t...STYLE_BOOK_CATEGORIES,\n\t].map( ( { slug } ) => slug );\n\tconst extraCategories = getCategories().filter(\n\t\t( { slug } ) => ! reservedCategories.includes( slug )\n\t);\n\treturn [ ...STYLE_BOOK_CATEGORIES, ...extraCategories ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,mBAAmB;;AAEjD;AACA;AACA;;AAMA,SACCC,qBAAqB,EACrBC,8BAA8B,QACxB,aAAa;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,kBAAqC,EACrCC,QAAwB,EACO;EAC/B,IAAK,CAAED,kBAAkB,EAAEE,IAAI,IAAI,CAAED,QAAQ,EAAEE,MAAM,EAAG;IACvD;EACD;EAEA,IAAKH,kBAAkB,EAAEI,aAAa,EAAED,MAAM,EAAG;IAChD,OAAOH,kBAAkB,CAACI,aAAa,CAACC,MAAM,CAC7C,CAAEC,GAAG,EAAEC,qBAAqB,KAAM;MACjC,MAAMC,mBAAmB,GAAGT,qBAAqB,CAChDQ,qBAAqB,EACrBN,QACD,CAA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,OAAO,CAAE,GAAGL,qBAAqB,EAAE,GAAG0B,eAAe,CAAE;AACxD","ignoreList":[]}
1
+ {"version":3,"names":["getCategories","STYLE_BOOK_CATEGORIES","STYLE_BOOK_THEME_SUBCATEGORIES","getExamplesByCategory","categoryDefinition","examples","_categoryDefinition$s","slug","length","categories","subcategories","reduce","acc","subcategoryDefinition","subcategoryExamples","title","blocksToInclude","blocks","blocksToExclude","exclude","categoryExamples","filter","example","includes","name","category","getTopLevelStyleBookCategories","reservedCategories","map","extraCategories","extraCategoriesFiltered"],"sources":["@wordpress/edit-site/src/components/style-book/categories.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\n// @wordpress/blocks imports are not typed.\n// @ts-expect-error\nimport { getCategories } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tBlockExample,\n\tStyleBookCategory,\n\tCategoryExamples,\n} from './types';\nimport {\n\tSTYLE_BOOK_CATEGORIES,\n\tSTYLE_BOOK_THEME_SUBCATEGORIES,\n} from './constants';\n\n/**\n * Returns category examples for a given category definition and list of examples.\n * @param {StyleBookCategory} categoryDefinition The category definition.\n * @param {BlockExample[]} examples An array of block examples.\n * @return {CategoryExamples|undefined} An object containing the category examples.\n */\nexport function getExamplesByCategory(\n\tcategoryDefinition: StyleBookCategory,\n\texamples: BlockExample[]\n): CategoryExamples | undefined {\n\tif ( ! categoryDefinition?.slug || ! examples?.length ) {\n\t\treturn;\n\t}\n\tconst categories: CategoryExamples[] =\n\t\tcategoryDefinition?.subcategories ?? [];\n\tif ( categories.length ) {\n\t\treturn categories.reduce(\n\t\t\t( acc, subcategoryDefinition ) => {\n\t\t\t\tconst subcategoryExamples = getExamplesByCategory(\n\t\t\t\t\tsubcategoryDefinition,\n\t\t\t\t\texamples\n\t\t\t\t);\n\t\t\t\tif ( subcategoryExamples ) {\n\t\t\t\t\tif ( ! acc.subcategories ) {\n\t\t\t\t\t\tacc.subcategories = [];\n\t\t\t\t\t}\n\t\t\t\t\tacc.subcategories = [\n\t\t\t\t\t\t...acc.subcategories,\n\t\t\t\t\t\tsubcategoryExamples,\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: categoryDefinition.title,\n\t\t\t\tslug: categoryDefinition.slug,\n\t\t\t}\n\t\t);\n\t}\n\n\tconst blocksToInclude = categoryDefinition?.blocks || [];\n\tconst blocksToExclude = categoryDefinition?.exclude || [];\n\tconst categoryExamples = examples.filter( ( example ) => {\n\t\treturn (\n\t\t\t! blocksToExclude.includes( example.name ) &&\n\t\t\t( example.category === categoryDefinition.slug ||\n\t\t\t\tblocksToInclude.includes( example.name ) )\n\t\t);\n\t} );\n\n\tif ( ! categoryExamples.length ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\ttitle: categoryDefinition.title,\n\t\tslug: categoryDefinition.slug,\n\t\texamples: categoryExamples,\n\t};\n}\n\n/**\n * Returns category examples for a given category definition and list of examples.\n *\n * @return {StyleBookCategory[]} An array of top-level category definitions.\n */\nexport function getTopLevelStyleBookCategories(): StyleBookCategory[] {\n\tconst reservedCategories = [\n\t\t...STYLE_BOOK_THEME_SUBCATEGORIES,\n\t\t...STYLE_BOOK_CATEGORIES,\n\t].map( ( { slug } ) => slug );\n\tconst extraCategories: StyleBookCategory[] = getCategories();\n\tconst extraCategoriesFiltered = extraCategories.filter(\n\t\t( { slug } ) => ! reservedCategories.includes( slug )\n\t);\n\treturn [ ...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,mBAAmB;;AAEjD;AACA;AACA;;AAMA,SACCC,qBAAqB,EACrBC,8BAA8B,QACxB,aAAa;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACpCC,kBAAqC,EACrCC,QAAwB,EACO;EAAA,IAAAC,qBAAA;EAC/B,IAAK,CAAEF,kBAAkB,E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;IAC7BF,QAAQ,EAAEe;EACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,8BAA8BA,CAAA,EAAwB;EACrE,MAAMC,kBAAkB,GAAG,CAC1B,GAAGzB,8BAA8B,EACjC,GAAGD,qBAAqB,CACxB,CAAC2B,GAAG,CAAE,CAAE;IAAErB;EAAK,CAAC,KAAMA,IAAK,CAAC;EAC7B,MAAMsB,eAAoC,GAAG7B,aAAa,CAAC,CAAC;EAC5D,MAAM8B,uBAAuB,GAAGD,eAAe,CAACR,MAAM,CACrD,CAAE;IAAEd;EAAK,CAAC,KAAM,CAAEoB,kBAAkB,CAACJ,QAAQ,CAAEhB,IAAK,CACrD,CAAC;EACD,OAAO,CAAE,GAAGN,qBAAqB,EAAE,GAAG6B,uBAAuB,CAAE;AAChE","ignoreList":[]}
@@ -9,7 +9,10 @@ import clsx from 'clsx';
9
9
  */
10
10
  import { __experimentalGrid as Grid } from '@wordpress/components';
11
11
  import { View } from '@wordpress/primitives';
12
- import { getColorClassName, __experimentalGetGradientClass } from '@wordpress/block-editor';
12
+ import { getColorClassName, __experimentalGetGradientClass
13
+ // @wordpress/block-editor imports are not typed.
14
+ // @ts-expect-error
15
+ } from '@wordpress/block-editor';
13
16
 
14
17
  /**
15
18
  * Internal dependencies
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","__experimentalGrid","Grid","View","getColorClassName","__experimentalGetGradientClass","jsx","_jsx","ColorExamples","colors","type","templateColumns","itemHeight","rowGap","columnGap","children","map","color","className","slug","classes","style","height"],"sources":["@wordpress/edit-site/src/components/style-book/color-examples.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalGrid as Grid } from '@wordpress/components';\nimport { View } from '@wordpress/primitives';\nimport {\n\tgetColorClassName,\n\t__experimentalGetGradientClass,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport type { Color, Gradient } from './types';\n\ntype Props = {\n\tcolors: Color[] | Gradient[];\n\ttype: 'colors' | 'gradients';\n\ttemplateColumns?: string | number;\n\titemHeight?: string;\n};\n\nconst ColorExamples = ( {\n\tcolors,\n\ttype,\n\ttemplateColumns = '1fr 1fr',\n\titemHeight = '52px',\n}: Props ): JSX.Element | null => {\n\tif ( ! colors ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Grid templateColumns={ templateColumns } rowGap={ 8 } columnGap={ 16 }>\n\t\t\t{ colors.map( ( color: Color | Gradient ) => {\n\t\t\t\tconst className =\n\t\t\t\t\ttype === 'gradients'\n\t\t\t\t\t\t? __experimentalGetGradientClass( color.slug )\n\t\t\t\t\t\t: getColorClassName( 'background-color', color.slug );\n\t\t\t\tconst classes = clsx(\n\t\t\t\t\t'edit-site-style-book__color-example',\n\t\t\t\t\tclassName\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<View\n\t\t\t\t\t\tkey={ color.slug }\n\t\t\t\t\t\tclassName={ classes }\n\t\t\t\t\t\tstyle={ { height: itemHeight } }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Grid>\n\t);\n};\n\nexport default ColorExamples;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAClE,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SACCC,iBAAiB,EACjBC,8BAA8B,QACxB,yBAAyB;;AAEhC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAYA,MAAMC,aAAa,GAAGA,CAAE;EACvBC,MAAM;EACNC,IAAI;EACJC,eAAe,GAAG,SAAS;EAC3BC,UAAU,GAAG;AACP,CAAC,KAA0B;EACjC,IAAK,CAAEH,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBACCF,IAAA,CAACL,IAAI;IAACS,eAAe,EAAGA,eAAiB;IAACE,MAAM,EAAG,CAAG;IAACC,SAAS,EAAG,EAAI;IAAAC,QAAA,EACpEN,MAAM,CAACO,GAAG,CAAIC,KAAuB,IAAM;MAC5C,MAAMC,SAAS,GACdR,IAAI,KAAK,WAAW,GACjBL,8BAA8B,CAAEY,KAAK,CAACE,IAAK,CAAC,GAC5Cf,iBAAiB,CAAE,kBAAkB,EAAEa,KAAK,CAACE,IAAK,CAAC;MACvD,MAAMC,OAAO,GAAGpB,IAAI,CACnB,qCAAqC,EACrCkB,SACD,CAAC;MAED,oBACCX,IAAA,CAACJ,IAAI;QAEJe,SAAS,EAAGE,OAAS;QACrBC,KAAK,EAAG;UAAEC,MAAM,EAAEV;QAAW;MAAG,GAF1BK,KAAK,CAACE,IAGZ,CAAC;IAEJ,CAAE;EAAC,CACE,CAAC;AAET,CAAC;AAED,eAAeX,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["clsx","__experimentalGrid","Grid","View","getColorClassName","__experimentalGetGradientClass","jsx","_jsx","ColorExamples","colors","type","templateColumns","itemHeight","rowGap","columnGap","children","map","color","className","slug","classes","style","height"],"sources":["@wordpress/edit-site/src/components/style-book/color-examples.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalGrid as Grid } from '@wordpress/components';\nimport { View } from '@wordpress/primitives';\nimport {\n\tgetColorClassName,\n\t__experimentalGetGradientClass,\n\t// @wordpress/block-editor imports are not typed.\n\t// @ts-expect-error\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport type { Color, Gradient, ColorExampleProps } from './types';\n\nconst ColorExamples = ( {\n\tcolors,\n\ttype,\n\ttemplateColumns = '1fr 1fr',\n\titemHeight = '52px',\n}: ColorExampleProps ): JSX.Element | null => {\n\tif ( ! colors ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Grid templateColumns={ templateColumns } rowGap={ 8 } columnGap={ 16 }>\n\t\t\t{ colors.map( ( color: Color | Gradient ) => {\n\t\t\t\tconst className =\n\t\t\t\t\ttype === 'gradients'\n\t\t\t\t\t\t? __experimentalGetGradientClass( color.slug )\n\t\t\t\t\t\t: getColorClassName( 'background-color', color.slug );\n\t\t\t\tconst classes = clsx(\n\t\t\t\t\t'edit-site-style-book__color-example',\n\t\t\t\t\tclassName\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<View\n\t\t\t\t\t\tkey={ color.slug }\n\t\t\t\t\t\tclassName={ classes }\n\t\t\t\t\t\tstyle={ { height: itemHeight } }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Grid>\n\t);\n};\n\nexport default ColorExamples;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAClE,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SACCC,iBAAiB,EACjBC;AACA;AACA;AAAA,OACM,yBAAyB;;AAEhC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAKA,MAAMC,aAAa,GAAGA,CAAE;EACvBC,MAAM;EACNC,IAAI;EACJC,eAAe,GAAG,SAAS;EAC3BC,UAAU,GAAG;AACK,CAAC,KAA0B;EAC7C,IAAK,CAAEH,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBACCF,IAAA,CAACL,IAAI;IAACS,eAAe,EAAGA,eAAiB;IAACE,MAAM,EAAG,CAAG;IAACC,SAAS,EAAG,EAAI;IAAAC,QAAA,EACpEN,MAAM,CAACO,GAAG,CAAIC,KAAuB,IAAM;MAC5C,MAAMC,SAAS,GACdR,IAAI,KAAK,WAAW,GACjBL,8BAA8B,CAAEY,KAAK,CAACE,IAAK,CAAC,GAC5Cf,iBAAiB,CAAE,kBAAkB,EAAEa,KAAK,CAACE,IAAK,CAAC;MACvD,MAAMC,OAAO,GAAGpB,IAAI,CACnB,qCAAqC,EACrCkB,SACD,CAAC;MAED,oBACCX,IAAA,CAACJ,IAAI;QAEJe,SAAS,EAAGE,OAAS;QACrBC,KAAK,EAAG;UAAEC,MAAM,EAAEV;QAAW;MAAG,GAF1BK,KAAK,CAACE,IAGZ,CAAC;IAEJ,CAAE;EAAC,CACE,CAAC;AAET,CAAC;AAED,eAAeX,aAAa","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalGrid","Grid","View","jsx","_jsx","jsxs","_jsxs","DuotoneExamples","duotones","columns","rowGap","columnGap","children","map","duotone","className","alt","slug","src","style","filter","colors","color","backgroundColor"],"sources":["@wordpress/edit-site/src/components/style-book/duotone-examples.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGrid as Grid } from '@wordpress/components';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport type { Duotone } from './types';\n\nconst DuotoneExamples = ( { duotones } ): JSX.Element | null => {\n\tif ( ! duotones ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Grid columns={ 2 } rowGap={ 16 } columnGap={ 16 }>\n\t\t\t{ duotones.map( ( duotone: Duotone ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Grid\n\t\t\t\t\t\tkey={ duotone.slug }\n\t\t\t\t\t\tclassName=\"edit-site-style-book__duotone-example\"\n\t\t\t\t\t\tcolumns={ 2 }\n\t\t\t\t\t\trowGap={ 8 }\n\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View>\n\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\talt={ `Duotone example: ${ duotone.slug }` }\n\t\t\t\t\t\t\t\tsrc=\"https://s.w.org/images/core/5.3/MtBlanc1.jpg\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfilter: `url(#wp-duotone-${ duotone.slug })`,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t{ duotone.colors.map( ( color ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\tkey={ color }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-style-book__color-example\"\n\t\t\t\t\t\t\t\t\tstyle={ { backgroundColor: color } }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Grid>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Grid>\n\t);\n};\n\nexport default DuotoneExamples;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAClE,SAASC,IAAI,QAAQ,uBAAuB;;AAE5C;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKA,MAAMC,eAAe,GAAGA,CAAE;EAAEC;AAAS,CAAC,KAA0B;EAC/D,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,oBACCJ,IAAA,CAACH,IAAI;IAACQ,OAAO,EAAG,CAAG;IAACC,MAAM,EAAG,EAAI;IAACC,SAAS,EAAG,EAAI;IAAAC,QAAA,EAC/CJ,QAAQ,CAACK,GAAG,CAAIC,OAAgB,IAAM;MACvC,oBACCR,KAAA,CAACL,IAAI;QAEJc,SAAS,EAAC,uCAAuC;QACjDN,OAAO,EAAG,CAAG;QACbC,MAAM,EAAG,CAAG;QACZC,SAAS,EAAG,CAAG;QAAAC,QAAA,gBAEfR,IAAA,CAACF,IAAI;UAAAU,QAAA,eACJR,IAAA;YACCY,GAAG,EAAG,oBAAqBF,OAAO,CAACG,IAAI,EAAK;YAC5CC,GAAG,EAAC,8CAA8C;YAClDC,KAAK,EAAG;cACPC,MAAM,EAAE,mBAAoBN,OAAO,CAACG,IAAI;YACzC;UAAG,CACH;QAAC,CACG,CAAC,EACLH,OAAO,CAACO,MAAM,CAACR,GAAG,CAAIS,KAAK,IAAM;UAClC,oBACClB,IAAA,CAACF,IAAI;YAEJa,SAAS,EAAC,qCAAqC;YAC/CI,KAAK,EAAG;cAAEI,eAAe,EAAED;YAAM;UAAG,GAF9BA,KAGN,CAAC;QAEJ,CAAE,CAAC;MAAA,GAvBGR,OAAO,CAACG,IAwBT,CAAC;IAET,CAAE;EAAC,CACE,CAAC;AAET,CAAC;AAED,eAAeV,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["__experimentalGrid","Grid","View","jsx","_jsx","jsxs","_jsxs","DuotoneExamples","duotones","columns","rowGap","columnGap","children","map","duotone","className","alt","slug","src","style","filter","colors","color","backgroundColor"],"sources":["@wordpress/edit-site/src/components/style-book/duotone-examples.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGrid as Grid } from '@wordpress/components';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport type { Duotone } from './types';\n\nconst DuotoneExamples = ( {\n\tduotones,\n}: {\n\tduotones: Duotone[];\n} ): JSX.Element | null => {\n\tif ( ! duotones ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Grid columns={ 2 } rowGap={ 16 } columnGap={ 16 }>\n\t\t\t{ duotones.map( ( duotone: Duotone ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Grid\n\t\t\t\t\t\tkey={ duotone.slug }\n\t\t\t\t\t\tclassName=\"edit-site-style-book__duotone-example\"\n\t\t\t\t\t\tcolumns={ 2 }\n\t\t\t\t\t\trowGap={ 8 }\n\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View>\n\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\talt={ `Duotone example: ${ duotone.slug }` }\n\t\t\t\t\t\t\t\tsrc=\"https://s.w.org/images/core/5.3/MtBlanc1.jpg\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tfilter: `url(#wp-duotone-${ duotone.slug })`,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t{ duotone.colors.map( ( color ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\tkey={ color }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-style-book__color-example\"\n\t\t\t\t\t\t\t\t\tstyle={ { backgroundColor: color } }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Grid>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Grid>\n\t);\n};\n\nexport default DuotoneExamples;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAClE,SAASC,IAAI,QAAQ,uBAAuB;;AAE5C;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKA,MAAMC,eAAe,GAAGA,CAAE;EACzBC;AAGD,CAAC,KAA0B;EAC1B,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,oBACCJ,IAAA,CAACH,IAAI;IAACQ,OAAO,EAAG,CAAG;IAACC,MAAM,EAAG,EAAI;IAACC,SAAS,EAAG,EAAI;IAAAC,QAAA,EAC/CJ,QAAQ,CAACK,GAAG,CAAIC,OAAgB,IAAM;MACvC,oBACCR,KAAA,CAACL,IAAI;QAEJc,SAAS,EAAC,uCAAuC;QACjDN,OAAO,EAAG,CAAG;QACbC,MAAM,EAAG,CAAG;QACZC,SAAS,EAAG,CAAG;QAAAC,QAAA,gBAEfR,IAAA,CAACF,IAAI;UAAAU,QAAA,eACJR,IAAA;YACCY,GAAG,EAAG,oBAAqBF,OAAO,CAACG,IAAI,EAAK;YAC5CC,GAAG,EAAC,8CAA8C;YAClDC,KAAK,EAAG;cACPC,MAAM,EAAE,mBAAoBN,OAAO,CAACG,IAAI;YACzC;UAAG,CACH;QAAC,CACG,CAAC,EACLH,OAAO,CAACO,MAAM,CAACR,GAAG,CAAIS,KAAK,IAAM;UAClC,oBACClB,IAAA,CAACF,IAAI;YAEJa,SAAS,EAAC,qCAAqC;YAC/CI,KAAK,EAAG;cAAEI,eAAe,EAAED;YAAM;UAAG,GAF9BA,KAGN,CAAC;QAEJ,CAAE,CAAC;MAAA,GAvBGR,OAAO,CAACG,IAwBT,CAAC;IAET,CAAE;EAAC,CACE,CAAC;AAET,CAAC;AAED,eAAeV,eAAe","ignoreList":[]}
@@ -3,7 +3,10 @@
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
- import { getBlockType, getBlockTypes, getBlockFromExample, createBlock } from '@wordpress/blocks';
6
+ import { getBlockType, getBlockTypes, getBlockFromExample, createBlock
7
+ // @wordpress/blocks imports are not typed.
8
+ // @ts-expect-error
9
+ } from '@wordpress/blocks';
7
10
 
8
11
  /**
9
12
  * Internal dependencies
@@ -27,8 +30,9 @@ function getColorExamples(colors) {
27
30
  }
28
31
  const examples = [];
29
32
  STYLE_BOOK_COLOR_GROUPS.forEach(group => {
30
- const palette = colors[group.type].find(origin => origin.slug === group.origin);
31
- if (palette?.[group.type]) {
33
+ const palette = colors[group.type];
34
+ const paletteFiltered = Array.isArray(palette) ? palette.find(origin => origin.slug === group.origin) : undefined;
35
+ if (paletteFiltered?.[group.type]) {
32
36
  const example = {
33
37
  name: group.slug,
34
38
  title: group.title,
@@ -36,12 +40,12 @@ function getColorExamples(colors) {
36
40
  };
37
41
  if (group.type === 'duotones') {
38
42
  example.content = /*#__PURE__*/_jsx(DuotoneExamples, {
39
- duotones: palette[group.type]
43
+ duotones: paletteFiltered[group.type]
40
44
  });
41
45
  examples.push(example);
42
46
  } else {
43
47
  example.content = /*#__PURE__*/_jsx(ColorExamples, {
44
- colors: palette[group.type],
48
+ colors: paletteFiltered[group.type],
45
49
  type: group.type
46
50
  });
47
51
  examples.push(example);
@@ -61,7 +65,7 @@ function getOverviewBlockExamples(colors) {
61
65
  const examples = [];
62
66
 
63
67
  // Get theme palette from colors if they exist.
64
- const themePalette = colors?.colors.find(origin => origin.slug === 'theme');
68
+ const themePalette = Array.isArray(colors?.colors) ? colors.colors.find(origin => origin.slug === 'theme') : undefined;
65
69
  if (themePalette) {
66
70
  const themeColorexample = {
67
71
  name: 'theme-colors',
@@ -69,7 +73,7 @@ function getOverviewBlockExamples(colors) {
69
73
  category: 'overview',
70
74
  content: /*#__PURE__*/_jsx(ColorExamples, {
71
75
  colors: themePalette.colors,
72
- type: colors,
76
+ type: "colors",
73
77
  templateColumns: "repeat(auto-fill, minmax( 200px, 1fr ))",
74
78
  itemHeight: "32px"
75
79
  })
@@ -1 +1 @@
1
- {"version":3,"names":["__","sprintf","getBlockType","getBlockTypes","getBlockFromExample","createBlock","ColorExamples","DuotoneExamples","STYLE_BOOK_COLOR_GROUPS","jsx","_jsx","getColorExamples","colors","examples","forEach","group","palette","type","find","origin","slug","example","name","title","category","content","duotones","push","getOverviewBlockExamples","themePalette","themeColorexample","templateColumns","itemHeight","typographyBlockExamples","headingBlock","level","firstParagraphBlock","secondParagraphBlock","groupBlock","layout","columnCount","minimumColumnWidth","style","spacing","blockGap","length","blocks","otherBlockExamples","blockName","blockType","blockExample","attributes","undefined","getExamples","nonHeadingBlockExamples","filter","supports","inserter","map","isHeadingBlockRegistered","headingsExample","colorExamples","overviewBlockExamples"],"sources":["@wordpress/edit-site/src/components/style-book/examples.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tBlock,\n\tBlockExample,\n\tColorOrigin,\n\tMultiOriginPalettes,\n} from './types';\nimport ColorExamples from './color-examples';\nimport DuotoneExamples from './duotone-examples';\nimport { STYLE_BOOK_COLOR_GROUPS } from './constants';\n\n/**\n * Returns examples color examples for each origin\n * e.g. Core (Default), Theme, and User.\n *\n * @param {MultiOriginPalettes} colors Global Styles color palettes per origin.\n * @return {BlockExample[]} An array of color block examples.\n */\nfunction getColorExamples( colors: MultiOriginPalettes ): BlockExample[] {\n\tif ( ! colors ) {\n\t\treturn [];\n\t}\n\n\tconst examples: BlockExample[] = [];\n\n\tSTYLE_BOOK_COLOR_GROUPS.forEach( ( group ) => {\n\t\tconst palette = colors[ group.type ].find(\n\t\t\t( origin: ColorOrigin ) => origin.slug === group.origin\n\t\t);\n\n\t\tif ( palette?.[ group.type ] ) {\n\t\t\tconst example: BlockExample = {\n\t\t\t\tname: group.slug,\n\t\t\t\ttitle: group.title,\n\t\t\t\tcategory: 'colors',\n\t\t\t};\n\t\t\tif ( group.type === 'duotones' ) {\n\t\t\t\texample.content = (\n\t\t\t\t\t<DuotoneExamples duotones={ palette[ group.type ] } />\n\t\t\t\t);\n\t\t\t\texamples.push( example );\n\t\t\t} else {\n\t\t\t\texample.content = (\n\t\t\t\t\t<ColorExamples\n\t\t\t\t\t\tcolors={ palette[ group.type ] }\n\t\t\t\t\t\ttype={ group.type }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t\texamples.push( example );\n\t\t\t}\n\t\t}\n\t} );\n\n\treturn examples;\n}\n\n/**\n * Returns examples for the overview page.\n *\n * @param {MultiOriginPalettes} colors Global Styles color palettes per origin.\n * @return {BlockExample[]} An array of block examples.\n */\nfunction getOverviewBlockExamples(\n\tcolors: MultiOriginPalettes\n): BlockExample[] {\n\tconst examples: BlockExample[] = [];\n\n\t// Get theme palette from colors if they exist.\n\tconst themePalette = colors?.colors.find(\n\t\t( origin: ColorOrigin ) => origin.slug === 'theme'\n\t);\n\n\tif ( themePalette ) {\n\t\tconst themeColorexample: BlockExample = {\n\t\t\tname: 'theme-colors',\n\t\t\ttitle: __( 'Colors' ),\n\t\t\tcategory: 'overview',\n\t\t\tcontent: (\n\t\t\t\t<ColorExamples\n\t\t\t\t\tcolors={ themePalette.colors }\n\t\t\t\t\ttype={ colors }\n\t\t\t\t\ttemplateColumns=\"repeat(auto-fill, minmax( 200px, 1fr ))\"\n\t\t\t\t\titemHeight=\"32px\"\n\t\t\t\t/>\n\t\t\t),\n\t\t};\n\n\t\texamples.push( themeColorexample );\n\t}\n\n\t// Get examples for typography blocks.\n\tconst typographyBlockExamples: Block[] = [];\n\n\tif ( getBlockType( 'core/heading' ) ) {\n\t\tconst headingBlock = createBlock( 'core/heading', {\n\t\t\tcontent: __(\n\t\t\t\t`AaBbCcDdEeFfGgHhiiJjKkLIMmNnOoPpQakRrssTtUuVVWwXxxYyZzOl23356789X{(…)},2!*&:/A@HELFO™`\n\t\t\t),\n\t\t\tlevel: 1,\n\t\t} );\n\t\ttypographyBlockExamples.push( headingBlock );\n\t}\n\n\tif ( getBlockType( 'core/paragraph' ) ) {\n\t\tconst firstParagraphBlock = createBlock( 'core/paragraph', {\n\t\t\tcontent: __(\n\t\t\t\t`A paragraph in a website refers to a distinct block of text that is used to present and organize information. It is a fundamental unit of content in web design and is typically composed of a group of related sentences or thoughts focused on a particular topic or idea. Paragraphs play a crucial role in improving the readability and user experience of a website. They break down the text into smaller, manageable chunks, allowing readers to scan the content more easily.`\n\t\t\t),\n\t\t} );\n\t\tconst secondParagraphBlock = createBlock( 'core/paragraph', {\n\t\t\tcontent: __(\n\t\t\t\t`Additionally, paragraphs help structure the flow of information and provide logical breaks between different concepts or pieces of information. In terms of formatting, paragraphs in websites are commonly denoted by a vertical gap or indentation between each block of text. This visual separation helps visually distinguish one paragraph from another, creating a clear and organized layout that guides the reader through the content smoothly.`\n\t\t\t),\n\t\t} );\n\n\t\tif ( getBlockType( 'core/group' ) ) {\n\t\t\tconst groupBlock = createBlock(\n\t\t\t\t'core/group',\n\t\t\t\t{\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\ttype: 'grid',\n\t\t\t\t\t\tcolumnCount: 2,\n\t\t\t\t\t\tminimumColumnWidth: '12rem',\n\t\t\t\t\t},\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\tblockGap: '1.5rem',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t[ firstParagraphBlock, secondParagraphBlock ]\n\t\t\t);\n\t\t\ttypographyBlockExamples.push( groupBlock );\n\t\t} else {\n\t\t\ttypographyBlockExamples.push( firstParagraphBlock );\n\t\t}\n\t}\n\n\tif ( !! typographyBlockExamples.length ) {\n\t\texamples.push( {\n\t\t\tname: 'typography',\n\t\t\ttitle: __( 'Typography' ),\n\t\t\tcategory: 'overview',\n\t\t\tblocks: typographyBlockExamples,\n\t\t} );\n\t}\n\n\tconst otherBlockExamples = [\n\t\t'core/image',\n\t\t'core/separator',\n\t\t'core/buttons',\n\t\t'core/pullquote',\n\t\t'core/search',\n\t];\n\n\t// Get examples for other blocks and put them in order of above array.\n\totherBlockExamples.forEach( ( blockName ) => {\n\t\tconst blockType = getBlockType( blockName );\n\t\tif ( blockType && blockType.example ) {\n\t\t\tconst blockExample: BlockExample = {\n\t\t\t\tname: blockName,\n\t\t\t\ttitle: blockType.title,\n\t\t\t\tcategory: 'overview',\n\t\t\t\t/*\n\t\t\t\t * CSS generated from style attributes will take precedence over global styles CSS,\n\t\t\t\t * so remove the style attribute from the example to ensure the example\n\t\t\t\t * demonstrates changes to global styles.\n\t\t\t\t */\n\t\t\t\tblocks: getBlockFromExample( blockName, {\n\t\t\t\t\t...blockType.example,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...blockType.example.attributes,\n\t\t\t\t\t\tstyle: undefined,\n\t\t\t\t\t},\n\t\t\t\t} ),\n\t\t\t};\n\t\t\texamples.push( blockExample );\n\t\t}\n\t} );\n\n\treturn examples;\n}\n\n/**\n * Returns a list of examples for registered block types.\n *\n * @param {MultiOriginPalettes} colors Global styles colors grouped by origin e.g. Core, Theme, and User.\n * @return {BlockExample[]} An array of block examples.\n */\nexport function getExamples( colors: MultiOriginPalettes ): BlockExample[] {\n\tconst nonHeadingBlockExamples = getBlockTypes()\n\t\t.filter( ( blockType ) => {\n\t\t\tconst { name, example, supports } = blockType;\n\t\t\treturn (\n\t\t\t\tname !== 'core/heading' &&\n\t\t\t\t!! example &&\n\t\t\t\tsupports?.inserter !== false\n\t\t\t);\n\t\t} )\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\t/*\n\t\t\t * CSS generated from style attributes will take precedence over global styles CSS,\n\t\t\t * so remove the style attribute from the example to ensure the example\n\t\t\t * demonstrates changes to global styles.\n\t\t\t */\n\t\t\tblocks: getBlockFromExample( blockType.name, {\n\t\t\t\t...blockType.example,\n\t\t\t\tattributes: {\n\t\t\t\t\t...blockType.example.attributes,\n\t\t\t\t\tstyle: undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} ) );\n\tconst isHeadingBlockRegistered = !! getBlockType( 'core/heading' );\n\n\tif ( ! isHeadingBlockRegistered ) {\n\t\treturn nonHeadingBlockExamples;\n\t}\n\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [ 1, 2, 3, 4, 5, 6 ].map( ( level ) => {\n\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\tcontent: sprintf(\n\t\t\t\t\t// translators: %d: heading level e.g: \"1\", \"2\", \"3\"\n\t\t\t\t\t__( 'Heading %d' ),\n\t\t\t\t\tlevel\n\t\t\t\t),\n\t\t\t\tlevel,\n\t\t\t} );\n\t\t} ),\n\t};\n\tconst colorExamples = getColorExamples( colors );\n\n\tconst overviewBlockExamples = getOverviewBlockExamples( colors );\n\n\treturn [\n\t\theadingsExample,\n\t\t...colorExamples,\n\t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,CAAE,UAAW,CAAC;IACvBwB,QAAQ,EAAE,MAAM;IAChBsB,MAAM,EAAE,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAACY,GAAG,CAAIvB,KAAK,IAAM;MAC9C,OAAO9B,WAAW,CAAE,cAAc,EAAE;QACnCoB,OAAO,EAAExB,OAAO;QACf;QACAD,EAAE,CAAE,YAAa,CAAC,EAClBmC,KACD,CAAC;QACDA;MACD,CAAE,CAAC;IACJ,CAAE;EACH,CAAC;EACD,MAAM0B,aAAa,GAAGlD,gBAAgB,CAAEC,MAAO,CAAC;EAEhD,MAAMkD,qBAAqB,GAAGlC,wBAAwB,CAAEhB,MAAO,CAAC;EAEhE,OAAO,CACNgD,eAAe,EACf,GAAGC,aAAa,EAChB,GAAGP,uBAAuB,EAC1B,GAAGQ,qBAAqB,CACxB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["__","sprintf","getBlockType","getBlockTypes","getBlockFromExample","createBlock","ColorExamples","DuotoneExamples","STYLE_BOOK_COLOR_GROUPS","jsx","_jsx","getColorExamples","colors","examples","forEach","group","palette","type","paletteFiltered","Array","isArray","find","origin","slug","undefined","example","name","title","category","content","duotones","push","getOverviewBlockExamples","themePalette","themeColorexample","templateColumns","itemHeight","typographyBlockExamples","headingBlock","level","firstParagraphBlock","secondParagraphBlock","groupBlock","layout","columnCount","minimumColumnWidth","style","spacing","blockGap","length","blocks","otherBlockExamples","blockName","blockType","blockExample","attributes","getExamples","nonHeadingBlockExamples","filter","supports","inserter","map","isHeadingBlockRegistered","headingsExample","colorExamples","overviewBlockExamples"],"sources":["@wordpress/edit-site/src/components/style-book/examples.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetBlockType,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n\t// @wordpress/blocks imports are not typed.\n\t// @ts-expect-error\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tBlockExample,\n\tColorOrigin,\n\tMultiOriginPalettes,\n\tBlockType,\n} from './types';\nimport ColorExamples from './color-examples';\nimport DuotoneExamples from './duotone-examples';\nimport { STYLE_BOOK_COLOR_GROUPS } from './constants';\n\n/**\n * Returns examples color examples for each origin\n * e.g. Core (Default), Theme, and User.\n *\n * @param {MultiOriginPalettes} colors Global Styles color palettes per origin.\n * @return {BlockExample[]} An array of color block examples.\n */\nfunction getColorExamples( colors: MultiOriginPalettes ): BlockExample[] {\n\tif ( ! colors ) {\n\t\treturn [];\n\t}\n\n\tconst examples: BlockExample[] = [];\n\n\tSTYLE_BOOK_COLOR_GROUPS.forEach( ( group ) => {\n\t\tconst palette = colors[ group.type as keyof MultiOriginPalettes ];\n\t\tconst paletteFiltered = Array.isArray( palette )\n\t\t\t? palette.find(\n\t\t\t\t\t( origin: ColorOrigin ) => origin.slug === group.origin\n\t\t\t )\n\t\t\t: undefined;\n\n\t\tif ( paletteFiltered?.[ group.type ] ) {\n\t\t\tconst example: BlockExample = {\n\t\t\t\tname: group.slug,\n\t\t\t\ttitle: group.title,\n\t\t\t\tcategory: 'colors',\n\t\t\t};\n\t\t\tif ( group.type === 'duotones' ) {\n\t\t\t\texample.content = (\n\t\t\t\t\t<DuotoneExamples\n\t\t\t\t\t\tduotones={ paletteFiltered[ group.type ] }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t\texamples.push( example );\n\t\t\t} else {\n\t\t\t\texample.content = (\n\t\t\t\t\t<ColorExamples\n\t\t\t\t\t\tcolors={ paletteFiltered[ group.type ] }\n\t\t\t\t\t\ttype={ group.type }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t\texamples.push( example );\n\t\t\t}\n\t\t}\n\t} );\n\n\treturn examples;\n}\n\n/**\n * Returns examples for the overview page.\n *\n * @param {MultiOriginPalettes} colors Global Styles color palettes per origin.\n * @return {BlockExample[]} An array of block examples.\n */\nfunction getOverviewBlockExamples(\n\tcolors: MultiOriginPalettes\n): BlockExample[] {\n\tconst examples: BlockExample[] = [];\n\n\t// Get theme palette from colors if they exist.\n\tconst themePalette = Array.isArray( colors?.colors )\n\t\t? colors.colors.find(\n\t\t\t\t( origin: ColorOrigin ) => origin.slug === 'theme'\n\t\t )\n\t\t: undefined;\n\n\tif ( themePalette ) {\n\t\tconst themeColorexample: BlockExample = {\n\t\t\tname: 'theme-colors',\n\t\t\ttitle: __( 'Colors' ),\n\t\t\tcategory: 'overview',\n\t\t\tcontent: (\n\t\t\t\t<ColorExamples\n\t\t\t\t\tcolors={ themePalette.colors }\n\t\t\t\t\ttype=\"colors\"\n\t\t\t\t\ttemplateColumns=\"repeat(auto-fill, minmax( 200px, 1fr ))\"\n\t\t\t\t\titemHeight=\"32px\"\n\t\t\t\t/>\n\t\t\t),\n\t\t};\n\n\t\texamples.push( themeColorexample );\n\t}\n\n\t// Get examples for typography blocks.\n\tconst typographyBlockExamples: BlockType[] = [];\n\n\tif ( getBlockType( 'core/heading' ) ) {\n\t\tconst headingBlock = createBlock( 'core/heading', {\n\t\t\tcontent: __(\n\t\t\t\t`AaBbCcDdEeFfGgHhiiJjKkLIMmNnOoPpQakRrssTtUuVVWwXxxYyZzOl23356789X{(…)},2!*&:/A@HELFO™`\n\t\t\t),\n\t\t\tlevel: 1,\n\t\t} );\n\t\ttypographyBlockExamples.push( headingBlock );\n\t}\n\n\tif ( getBlockType( 'core/paragraph' ) ) {\n\t\tconst firstParagraphBlock = createBlock( 'core/paragraph', {\n\t\t\tcontent: __(\n\t\t\t\t`A paragraph in a website refers to a distinct block of text that is used to present and organize information. It is a fundamental unit of content in web design and is typically composed of a group of related sentences or thoughts focused on a particular topic or idea. Paragraphs play a crucial role in improving the readability and user experience of a website. They break down the text into smaller, manageable chunks, allowing readers to scan the content more easily.`\n\t\t\t),\n\t\t} );\n\t\tconst secondParagraphBlock = createBlock( 'core/paragraph', {\n\t\t\tcontent: __(\n\t\t\t\t`Additionally, paragraphs help structure the flow of information and provide logical breaks between different concepts or pieces of information. In terms of formatting, paragraphs in websites are commonly denoted by a vertical gap or indentation between each block of text. This visual separation helps visually distinguish one paragraph from another, creating a clear and organized layout that guides the reader through the content smoothly.`\n\t\t\t),\n\t\t} );\n\n\t\tif ( getBlockType( 'core/group' ) ) {\n\t\t\tconst groupBlock = createBlock(\n\t\t\t\t'core/group',\n\t\t\t\t{\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\ttype: 'grid',\n\t\t\t\t\t\tcolumnCount: 2,\n\t\t\t\t\t\tminimumColumnWidth: '12rem',\n\t\t\t\t\t},\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\tblockGap: '1.5rem',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t[ firstParagraphBlock, secondParagraphBlock ]\n\t\t\t);\n\t\t\ttypographyBlockExamples.push( groupBlock );\n\t\t} else {\n\t\t\ttypographyBlockExamples.push( firstParagraphBlock );\n\t\t}\n\t}\n\n\tif ( !! typographyBlockExamples.length ) {\n\t\texamples.push( {\n\t\t\tname: 'typography',\n\t\t\ttitle: __( 'Typography' ),\n\t\t\tcategory: 'overview',\n\t\t\tblocks: typographyBlockExamples,\n\t\t} );\n\t}\n\n\tconst otherBlockExamples = [\n\t\t'core/image',\n\t\t'core/separator',\n\t\t'core/buttons',\n\t\t'core/pullquote',\n\t\t'core/search',\n\t];\n\n\t// Get examples for other blocks and put them in order of above array.\n\totherBlockExamples.forEach( ( blockName ) => {\n\t\tconst blockType = getBlockType( blockName );\n\t\tif ( blockType && blockType.example ) {\n\t\t\tconst blockExample: BlockExample = {\n\t\t\t\tname: blockName,\n\t\t\t\ttitle: blockType.title,\n\t\t\t\tcategory: 'overview',\n\t\t\t\t/*\n\t\t\t\t * CSS generated from style attributes will take precedence over global styles CSS,\n\t\t\t\t * so remove the style attribute from the example to ensure the example\n\t\t\t\t * demonstrates changes to global styles.\n\t\t\t\t */\n\t\t\t\tblocks: getBlockFromExample( blockName, {\n\t\t\t\t\t...blockType.example,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...blockType.example.attributes,\n\t\t\t\t\t\tstyle: undefined,\n\t\t\t\t\t},\n\t\t\t\t} ),\n\t\t\t};\n\t\t\texamples.push( blockExample );\n\t\t}\n\t} );\n\n\treturn examples;\n}\n\n/**\n * Returns a list of examples for registered block types.\n *\n * @param {MultiOriginPalettes} colors Global styles colors grouped by origin e.g. Core, Theme, and User.\n * @return {BlockExample[]} An array of block examples.\n */\nexport function getExamples( colors: MultiOriginPalettes ): BlockExample[] {\n\tconst nonHeadingBlockExamples = getBlockTypes()\n\t\t.filter( ( blockType: BlockType ) => {\n\t\t\tconst { name, example, supports } = blockType;\n\t\t\treturn (\n\t\t\t\tname !== 'core/heading' &&\n\t\t\t\t!! example &&\n\t\t\t\tsupports?.inserter !== false\n\t\t\t);\n\t\t} )\n\t\t.map( ( blockType: BlockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\t/*\n\t\t\t * CSS generated from style attributes will take precedence over global styles CSS,\n\t\t\t * so remove the style attribute from the example to ensure the example\n\t\t\t * demonstrates changes to global styles.\n\t\t\t */\n\t\t\tblocks: getBlockFromExample( blockType.name, {\n\t\t\t\t...blockType.example,\n\t\t\t\tattributes: {\n\t\t\t\t\t...blockType.example.attributes,\n\t\t\t\t\tstyle: undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} ) );\n\tconst isHeadingBlockRegistered = !! getBlockType( 'core/heading' );\n\n\tif ( ! isHeadingBlockRegistered ) {\n\t\treturn nonHeadingBlockExamples;\n\t}\n\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [ 1, 2, 3, 4, 5, 6 ].map( ( level ) => {\n\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\tcontent: sprintf(\n\t\t\t\t\t// translators: %d: heading level e.g: \"1\", \"2\", \"3\"\n\t\t\t\t\t__( 'Heading %d' ),\n\t\t\t\t\tlevel\n\t\t\t\t),\n\t\t\t\tlevel,\n\t\t\t} );\n\t\t} ),\n\t};\n\tconst colorExamples = getColorExamples( colors );\n\n\tconst overviewBlockExamples = getOverviewBlockExamples( colors );\n\n\treturn [\n\t\theadingsExample,\n\t\t...colorExamples,\n\t\t...nonHeadingBlockExamples,\n\t\t...overviewBlockExamples,\n\t];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,YAAY,EACZC,aAAa,EACbC,mBAAmB,EACnBC;AACA;AACA;AAAA,OACM,mBAAmB;;AAE1B;AACA;AACA;;AAOA,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,eAAe,MAAM,oBAAoB;AAChD,SAASC,uBAAuB,QAAQ,aAAa;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AANA,SAAAC,GAAA,IAAAC,IAAA;AAOA,SAASC,gBAAgBA,CAAEC,MAA2B,EAAmB;EACxE,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EAEA,MAAMC,QAAwB,GAAG,EAAE;EAEnCL,uBAAuB,CAACM,OAAO,CAAIC,KAAK,IAAM;IAC7C,MAAMC,OAAO,GAAGJ,MAAM,CAAEG,KAAK,CAACE,IAAI,CAA+B;IACjE,MAAMC,eAAe,GAAGC,KAAK,CAACC,OAAO,CAAEJ,OAAQ,CAAC,GAC7CA,OAAO,CAACK,IAAI,CACVC,MAAmB,IAAMA,MAAM,CAACC,IAAI,KAAKR,KAAK,CAACO,MACjD,CAAC,GACDE,SAAS;IAEZ,IAAKN,eAAe,GAAIH,KAAK,CAACE,IAAI,CAAE,EAAG;MACtC,MAAMQ,OAAqB,GAAG;QAC7BC,IAAI,EAAEX,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BC,QAAQ,EAAEyB,SAAS,CAACzB,QAAQ;IAC5B;AACH;AACA;AACA;AACA;IACGsB,MAAM,EAAE9C,mBAAmB,CAAEiD,SAAS,CAAC3B,IAAI,EAAE;MAC5C,GAAG2B,SAAS,CAAC5B,OAAO;MACpB8B,UAAU,EAAE;QACX,GAAGF,SAAS,CAAC5B,OAAO,CAAC8B,UAAU;QAC/BT,KAAK,EAAEtB;MACR;IACD,CAAE;EACH,CAAC,CAAG,CAAC;EACN,MAAMsC,wBAAwB,GAAG,CAAC,CAAE5D,YAAY,CAAE,cAAe,CAAC;EAElE,IAAK,CAAE4D,wBAAwB,EAAG;IACjC,OAAOL,uBAAuB;EAC/B;;EAEA;EACA;EACA,MAAMM,eAAe,GAAG;IACvBrC,IAAI,EAAE,cAAc;IACpBC,KAAK,EAAE3B,EAAE,CAAE,UAAW,CAAC;IACvB4B,QAAQ,EAAE,MAAM;IAChBsB,MAAM,EAAE,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAACW,GAAG,CAAItB,KAAK,IAAM;MAC9C,OAAOlC,WAAW,CAAE,cAAc,EAAE;QACnCwB,OAAO,EAAE5B,OAAO;QACf;QACAD,EAAE,CAAE,YAAa,CAAC,EAClBuC,KACD,CAAC;QACDA;MACD,CAAE,CAAC;IACJ,CAAE;EACH,CAAC;EACD,MAAMyB,aAAa,GAAGrD,gBAAgB,CAAEC,MAAO,CAAC;EAEhD,MAAMqD,qBAAqB,GAAGjC,wBAAwB,CAAEpB,MAAO,CAAC;EAEhE,OAAO,CACNmD,eAAe,EACf,GAAGC,aAAa,EAChB,GAAGP,uBAAuB,EAC1B,GAAGQ,qBAAqB,CACxB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/edit-site/src/components/style-book/types.ts"],"sourcesContent":["export type Block = {\n\tname: string;\n\tattributes: Record< string, unknown >;\n\tinnerBlocks?: Block[];\n};\n\nexport type StyleBookCategory = {\n\ttitle: string;\n\tslug: string;\n\tblocks?: string[];\n\texclude?: string[];\n\tinclude?: string[];\n\tsubcategories?: StyleBookCategory[];\n};\n\nexport type BlockExample = {\n\tname: string;\n\ttitle: string;\n\tcategory: string;\n\tcontent?: JSX.Element;\n\tblocks?: Block | Block[];\n};\n\nexport type CategoryExamples = {\n\ttitle: string;\n\tslug: string;\n\texamples?: BlockExample[];\n\tsubcategories?: CategoryExamples[];\n};\n\nexport type StyleBookColorGroup = {\n\torigin: string;\n\tslug: string;\n\ttitle: string;\n\ttype: string;\n};\n\nexport type Color = { slug: string };\nexport type Gradient = { slug: string };\nexport type Duotone = {\n\tcolors: string[];\n\tslug: string;\n};\n\nexport type ColorOrigin = {\n\tname: string;\n\tslug: string;\n\tcolors?: Color[];\n\tgradients?: Gradient[];\n\tduotones?: Duotone[];\n};\n\nexport type MultiOriginPalettes = {\n\tdisableCustomColors: boolean;\n\tdisableCustomGradients: boolean;\n\thasColorsOrGradients: boolean;\n\tcolors: Omit< ColorOrigin, 'gradients' | 'duotones' >;\n\tduotones: Omit< ColorOrigin, 'colors' | 'gradients' >;\n\tgradients: Omit< ColorOrigin, 'colors' | 'duotones' >;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/edit-site/src/components/style-book/types.ts"],"sourcesContent":["export type Block = {\n\tname: string;\n\tattributes: Record< string, unknown >;\n\tinnerBlocks?: Block[];\n};\n\nexport type StyleBookCategory = {\n\ttitle: string;\n\tslug: string;\n\tblocks?: string[];\n\texclude?: string[];\n\tinclude?: string[];\n\tsubcategories?: StyleBookCategory[];\n};\n\nexport type BlockExample = {\n\tname: string;\n\ttitle: string;\n\tcategory: string;\n\tcontent?: JSX.Element;\n\tblocks?: Block | Block[];\n};\n\nexport type CategoryExamples = {\n\ttitle: string;\n\tslug: string;\n\texamples?: BlockExample[];\n\tsubcategories?: CategoryExamples[];\n};\n\nexport type StyleBookColorGroup = {\n\torigin: string;\n\tslug: string;\n\ttitle: string;\n\ttype: 'colors' | 'gradients' | 'duotones';\n};\n\nexport type Color = { slug: string };\nexport type Gradient = { slug: string };\nexport type Duotone = {\n\tcolors: string[];\n\tslug: string;\n};\n\nexport type ColorExampleProps = {\n\tcolors: Color[] | Gradient[];\n\ttype: StyleBookColorGroup[ 'type' ];\n\ttemplateColumns?: string | number;\n\titemHeight?: string;\n};\n\nexport type ColorOrigin = {\n\tname: string;\n\tslug: string;\n\tcolors?: Color[];\n\tgradients?: Gradient[];\n\tduotones?: Duotone[];\n};\n\nexport type MultiOriginPalettes = {\n\tdisableCustomColors: boolean;\n\tdisableCustomGradients: boolean;\n\thasColorsOrGradients: boolean;\n\tcolors: Omit< ColorOrigin, 'gradients' | 'duotones' >;\n\tduotones: Omit< ColorOrigin, 'colors' | 'gradients' >;\n\tgradients: Omit< ColorOrigin, 'colors' | 'duotones' >;\n};\n\n/*\n * Typing the items from getBlockTypes from '@wordpress/blocks'\n * to appease the TS linter.\n */\nexport type BlockType = {\n\tname: string;\n\ttitle: string;\n\tcategory: string;\n\texample: BlockType;\n\tattributes: Record< string, unknown >;\n\tsupports: Record< string, unknown >;\n};\n"],"mappings":"","ignoreList":[]}
@@ -137,13 +137,11 @@
137
137
  flex-shrink: 0;
138
138
  position: sticky;
139
139
  right: 0;
140
- transition: padding ease-out 0.1s;
141
140
  }
142
- @media (prefers-reduced-motion: reduce) {
141
+ @media not (prefers-reduced-motion) {
143
142
  .dataviews__view-actions,
144
143
  .dataviews-filters__container {
145
- transition-duration: 0s;
146
- transition-delay: 0s;
144
+ transition: padding ease-out 0.1s;
147
145
  }
148
146
  }
149
147
 
@@ -154,13 +152,11 @@
154
152
  display: flex;
155
153
  align-items: center;
156
154
  justify-content: center;
157
- transition: padding ease-out 0.1s;
158
155
  }
159
- @media (prefers-reduced-motion: reduce) {
156
+ @media not (prefers-reduced-motion) {
160
157
  .dataviews-no-results,
161
158
  .dataviews-loading {
162
- transition-duration: 0s;
163
- transition-delay: 0s;
159
+ transition: padding ease-out 0.1s;
164
160
  }
165
161
  }
166
162
 
@@ -414,7 +410,6 @@
414
410
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
415
411
  padding: 6px 8px;
416
412
  box-shadow: 0 0 0 transparent;
417
- transition: box-shadow 0.1s linear;
418
413
  border-radius: 2px;
419
414
  border: 1px solid #949494;
420
415
  /* Fonts smaller than 16px causes mobile safari to zoom. */
@@ -432,10 +427,9 @@
432
427
  /* Fonts smaller than 16px causes mobile safari to zoom. */
433
428
  font-size: 16px;
434
429
  }
435
- @media (prefers-reduced-motion: reduce) {
430
+ @media not (prefers-reduced-motion) {
436
431
  .dataviews-filters__search-widget-filter-combobox__wrapper .dataviews-filters__search-widget-filter-combobox__input {
437
- transition-duration: 0s;
438
- transition-delay: 0s;
432
+ transition: box-shadow 0.1s linear;
439
433
  }
440
434
  }
441
435
  @media (min-width: 600px) {
@@ -521,13 +515,11 @@
521
515
  padding: 12px 48px;
522
516
  border-top: 1px solid #f0f0f0;
523
517
  flex-shrink: 0;
524
- transition: padding ease-out 0.1s;
525
518
  z-index: 2;
526
519
  }
527
- @media (prefers-reduced-motion: reduce) {
520
+ @media not (prefers-reduced-motion) {
528
521
  .dataviews-footer {
529
- transition-duration: 0s;
530
- transition-delay: 0s;
522
+ transition: padding ease-out 0.1s;
531
523
  }
532
524
  }
533
525
 
@@ -651,7 +643,8 @@
651
643
  }
652
644
 
653
645
  .dataviews-field-control__field:hover .dataviews-field-control__actions,
654
- .dataviews-field-control__field:focus-within .dataviews-field-control__actions {
646
+ .dataviews-field-control__field:focus-within .dataviews-field-control__actions,
647
+ .dataviews-field-control__field.is-interacting .dataviews-field-control__actions {
655
648
  position: unset;
656
649
  top: unset;
657
650
  }
@@ -661,21 +654,31 @@
661
654
  width: 24px;
662
655
  }
663
656
 
664
- .dataviews-field-control__label {
657
+ .dataviews-field-control__label-sub-label-container {
665
658
  flex-grow: 1;
666
659
  }
667
660
 
661
+ .dataviews-field-control__label {
662
+ display: block;
663
+ }
664
+
665
+ .dataviews-field-control__sub-label {
666
+ margin-top: 8px;
667
+ margin-bottom: 0;
668
+ font-size: 11px;
669
+ font-style: normal;
670
+ color: #757575;
671
+ }
672
+
668
673
  .dataviews-view-grid {
669
674
  margin-bottom: auto;
670
675
  grid-template-rows: max-content;
671
676
  padding: 0 48px 24px;
672
- transition: padding ease-out 0.1s;
673
677
  container-type: inline-size;
674
678
  }
675
- @media (prefers-reduced-motion: reduce) {
679
+ @media not (prefers-reduced-motion) {
676
680
  .dataviews-view-grid {
677
- transition-duration: 0s;
678
- transition-delay: 0s;
681
+ transition: padding ease-out 0.1s;
679
682
  }
680
683
  }
681
684
  .dataviews-view-grid .dataviews-view-grid__card {
@@ -1581,7 +1584,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
1581
1584
  contain: content;
1582
1585
  }
1583
1586
 
1584
- @keyframes _15iyx_slide-from-right {
1587
+ @keyframes _u5k8s_slide-from-right {
1585
1588
  from {
1586
1589
  transform: translateX(-50px);
1587
1590
  opacity: 0;
@@ -1591,7 +1594,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
1591
1594
  opacity: 1;
1592
1595
  }
1593
1596
  }
1594
- @keyframes _15iyx_slide-from-left {
1597
+ @keyframes _u5k8s_slide-from-left {
1595
1598
  from {
1596
1599
  transform: translateX(50px);
1597
1600
  opacity: 0;
@@ -1647,10 +1650,10 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
1647
1650
  }
1648
1651
  }
1649
1652
  .edit-site-sidebar__screen-wrapper.slide-from-left {
1650
- animation-name: _15iyx_slide-from-left;
1653
+ animation-name: _u5k8s_slide-from-left;
1651
1654
  }
1652
1655
  .edit-site-sidebar__screen-wrapper.slide-from-right {
1653
- animation-name: _15iyx_slide-from-right;
1656
+ animation-name: _u5k8s_slide-from-right;
1654
1657
  }
1655
1658
 
1656
1659
  .edit-site-site-hub {