@wordpress/block-library 6.0.25 → 6.0.28
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.
- package/build/gallery/constants.js +5 -1
- package/build/gallery/constants.js.map +1 -1
- package/build/gallery/transforms.js +8 -2
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/utils.js +4 -3
- package/build/gallery/utils.js.map +1 -1
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/page-list/edit.js +37 -10
- package/build/page-list/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +50 -30
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +4 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/site-logo/edit.js +0 -25
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/social-links/edit.js +1 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/controls.js +111 -0
- package/build/spacer/controls.js.map +1 -0
- package/build/spacer/controls.native.js +95 -0
- package/build/spacer/controls.native.js.map +1 -0
- package/build/spacer/deprecated.js +53 -0
- package/build/spacer/deprecated.js.map +1 -0
- package/build/spacer/edit.js +111 -82
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/edit.native.js +76 -0
- package/build/spacer/edit.native.js.map +1 -0
- package/build/spacer/index.js +7 -4
- package/build/spacer/index.js.map +1 -1
- package/build/spacer/save.js +6 -3
- package/build/spacer/save.js.map +1 -1
- package/build/table/deprecated.js +1 -1
- package/build/table/deprecated.js.map +1 -1
- package/build-module/gallery/constants.js +2 -0
- package/build-module/gallery/constants.js.map +1 -1
- package/build-module/gallery/transforms.js +8 -2
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/utils.js +5 -4
- package/build-module/gallery/utils.js.map +1 -1
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/page-list/edit.js +38 -11
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +52 -29
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +4 -2
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +0 -25
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/social-links/edit.js +1 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/controls.js +101 -0
- package/build-module/spacer/controls.js.map +1 -0
- package/build-module/spacer/controls.native.js +82 -0
- package/build-module/spacer/controls.native.js.map +1 -0
- package/build-module/spacer/deprecated.js +44 -0
- package/build-module/spacer/deprecated.js.map +1 -0
- package/build-module/spacer/edit.js +108 -82
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +61 -0
- package/build-module/spacer/edit.native.js.map +1 -0
- package/build-module/spacer/index.js +6 -4
- package/build-module/spacer/index.js.map +1 -1
- package/build-module/spacer/save.js +6 -3
- package/build-module/spacer/save.js.map +1 -1
- package/build-module/table/deprecated.js +1 -1
- package/build-module/table/deprecated.js.map +1 -1
- package/build-style/common-rtl.css +8 -0
- package/build-style/common.css +8 -0
- package/build-style/cover/style-rtl.css +67 -5
- package/build-style/cover/style.css +67 -5
- package/build-style/editor-rtl.css +8 -7
- package/build-style/editor.css +8 -7
- package/build-style/gallery/style-rtl.css +2 -1
- package/build-style/gallery/style.css +2 -1
- package/build-style/page-list/editor-rtl.css +4 -0
- package/build-style/page-list/editor.css +4 -0
- package/build-style/post-featured-image/editor-rtl.css +0 -7
- package/build-style/post-featured-image/editor.css +0 -7
- package/build-style/post-template/style-rtl.css +4 -0
- package/build-style/post-template/style.css +4 -0
- package/build-style/spacer/editor-rtl.css +4 -0
- package/build-style/spacer/editor.css +4 -0
- package/build-style/style-rtl.css +81 -6
- package/build-style/style.css +81 -6
- package/package.json +9 -9
- package/src/archives/index.php +1 -1
- package/src/common.scss +8 -0
- package/src/cover/style.scss +19 -3
- package/src/gallery/constants.js +2 -0
- package/src/gallery/style.scss +4 -1
- package/src/gallery/transforms.js +7 -1
- package/src/gallery/utils.js +7 -3
- package/src/heading/edit.js +18 -5
- package/src/navigation/index.php +4 -4
- package/src/page-list/edit.js +47 -9
- package/src/page-list/editor.scss +4 -0
- package/src/page-list/index.php +5 -0
- package/src/post-featured-image/dimension-controls.js +75 -50
- package/src/post-featured-image/edit.js +6 -4
- package/src/post-featured-image/editor.scss +0 -8
- package/src/post-template/style.scss +5 -0
- package/src/search/index.php +12 -7
- package/src/site-logo/edit.js +1 -32
- package/src/site-logo/index.php +1 -1
- package/src/site-title/index.php +0 -1
- package/src/social-links/deprecated.js +0 -59
- package/src/social-links/edit.js +1 -1
- package/src/spacer/block.json +3 -3
- package/src/spacer/controls.js +108 -0
- package/src/spacer/controls.native.js +82 -0
- package/src/spacer/deprecated.js +41 -0
- package/src/spacer/edit.js +127 -113
- package/src/spacer/edit.native.js +68 -0
- package/src/spacer/editor.scss +6 -0
- package/src/spacer/index.js +2 -0
- package/src/spacer/save.js +5 -2
- package/src/table/deprecated.js +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/social-links/edit.js"],"names":["classNames","getBlockSupport","Fragment","useEffect","BlockControls","useInnerBlocksProps","useBlockProps","InspectorControls","ContrastChecker","PanelColorSettings","withColors","MenuGroup","MenuItem","PanelBody","ToggleControl","ToolbarDropdownMenu","__","check","ALLOWED_BLOCKS","sizeOptions","name","value","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","SocialLinksEdit","props","attributes","iconBackgroundColor","iconColor","isSelected","setAttributes","setIconBackgroundColor","setIconColor","iconBackgroundColorValue","iconColorValue","openInNewTab","size","layout","usedLayout","logosOnly","className","indexOf","undefined","customIconBackgroundColor","SocialPlaceholder","SelectedSocialPlaceholder","color","blockProps","innerBlocksProps","allowedBlocks","placeholder","templateLock","__experimentalAppenderTagName","__experimentalLayout","POPOVER_PROPS","position","onClose","map","entry","onChange","colorValue","label","textColor","backgroundColor","iconColorAttributes"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SACCC,aADD,EAECC,mBAFD,EAGCC,aAHD,EAICC,iBAJD,EAKCC,eALD,EAMCC,kBAND,EAOCC,UAPD,QAQO,yBARP;AASA,SACCC,SADD,EAECC,QAFD,EAGCC,SAHD,EAICC,aAJD,EAKCC,mBALD,QAMO,uBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA,MAAMC,cAAc,GAAG,CAAE,kBAAF,CAAvB;AAEA,MAAMC,WAAW,GAAG,CACnB;AAAEC,EAAAA,IAAI,EAAEJ,EAAE,CAAE,OAAF,CAAV;AAAuBK,EAAAA,KAAK,EAAE;AAA9B,CADmB,EAEnB;AAAED,EAAAA,IAAI,EAAEJ,EAAE,CAAE,QAAF,CAAV;AAAwBK,EAAAA,KAAK,EAAE;AAA/B,CAFmB,EAGnB;AAAED,EAAAA,IAAI,EAAEJ,EAAE,CAAE,OAAF,CAAV;AAAuBK,EAAAA,KAAK,EAAE;AAA9B,CAHmB,EAInB;AAAED,EAAAA,IAAI,EAAEJ,EAAE,CAAE,MAAF,CAAV;AAAsBK,EAAAA,KAAK,EAAE;AAA7B,CAJmB,CAApB;;AAOA,MAAMC,qBAAqB,GAAKC,eAAF,IAAuB;AACpD,QAAMC,wBAAwB,GAAGvB,eAAe,CAC/CsB,eAD+C,EAE/C,sBAF+C,CAAhD;AAIA,SAAOC,wBAAP,aAAOA,wBAAP,uBAAOA,wBAAwB,CAAEC,OAAjC;AACA,CAND;;AAQA,OAAO,SAASC,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AAAA,KAAK,EAAE/C,EAAE,CAAE,uBAAF;AAZK,KAXA;AAJjB,IAVD,EAyCG,CAAEyB,SAAF,IACD,cAAC,eAAD;AAEEuB,IAAAA,SAAS,EAAE5B,cAFb;AAGE6B,IAAAA,eAAe,EAAE9B,wBAHnB;AAKC,IAAA,WAAW,EAAG;AALf,IA1CF,CAtCD,EAyFC,oBAASe,gBAAT,CAzFD,CADD;AA6FA;AAED,MAAMgB,mBAAmB,GAAG;AAC3BpC,EAAAA,SAAS,EAAE,YADgB;AAE3BD,EAAAA,mBAAmB,EAAE;AAFM,CAA5B;AAKA,eAAenB,UAAU,CAAEwD,mBAAF,CAAV,CAAmCxC,eAAnC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { Fragment, useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\tPanelColorSettings,\n\twithColors,\n} from '@wordpress/block-editor';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tPanelBody,\n\tToggleControl,\n\tToolbarDropdownMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nconst ALLOWED_BLOCKS = [ 'core/social-link' ];\n\nconst sizeOptions = [\n\t{ name: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ name: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ name: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ name: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tname,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tsize,\n\t\tlayout,\n\t} = attributes;\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\n\t// Remove icon background color if logos only style selected.\n\tconst logosOnly =\n\t\tattributes.className?.indexOf( 'is-style-logos-only' ) >= 0;\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tsetAttributes( {\n\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\tconst SocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-placeholder\">\n\t\t\t<div className=\"wp-social-link\"></div>\n\t\t\t<div className=\"wp-block-social-links__social-placeholder-icons\">\n\t\t\t\t<div className=\"wp-social-link wp-social-link-twitter\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-facebook\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-instagram\"></div>\n\t\t\t</div>\n\t\t</li>\n\t);\n\n\tconst SelectedSocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-prompt\">\n\t\t\t{ __( 'Click plus to add' ) }\n\t\t</li>\n\t);\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = classNames( size, {\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tplaceholder: isSelected ? SelectedSocialPlaceholder : SocialPlaceholder,\n\t\ttemplateLock: false,\n\t\t__experimentalAppenderTagName: 'li',\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\tconst POPOVER_PROPS = {\n\t\tposition: 'bottom right',\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\ttext={ __( 'Size' ) }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ sizeOptions.map( ( entry ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t( size === entry.value ||\n\t\t\t\t\t\t\t\t\t\t\t\t( ! size &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tentry.value ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'has-normal-icon-size' ) ) &&\n\t\t\t\t\t\t\t\t\t\t\tcheck\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisSelected={ size === entry.value }\n\t\t\t\t\t\t\t\t\t\tkey={ entry.value }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tsize: entry.value,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ entry.name }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarDropdownMenu>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: ! openInNewTab } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelColorSettings\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\t\tcolorSettings={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t\t\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\t\t\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\t\t\t\t\tonChange: ( colorValue ) => {\n\t\t\t\t\t\t\t\tsetIconColor( colorValue );\n\t\t\t\t\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabel: __( 'Icon color' ),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t! logosOnly && {\n\t\t\t\t\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t\t\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\t\t\t\t\tvalue:\n\t\t\t\t\t\t\t\ticonBackgroundColor.color ||\n\t\t\t\t\t\t\t\ticonBackgroundColorValue,\n\t\t\t\t\t\t\tonChange: ( colorValue ) => {\n\t\t\t\t\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabel: __( 'Icon background color' ),\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</Fragment>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/social-links/edit.js"],"names":["classNames","getBlockSupport","Fragment","useEffect","BlockControls","useInnerBlocksProps","useBlockProps","InspectorControls","ContrastChecker","PanelColorSettings","withColors","MenuGroup","MenuItem","PanelBody","ToggleControl","ToolbarDropdownMenu","__","check","ALLOWED_BLOCKS","sizeOptions","name","value","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","SocialLinksEdit","props","attributes","iconBackgroundColor","iconColor","isSelected","setAttributes","setIconBackgroundColor","setIconColor","iconBackgroundColorValue","iconColorValue","openInNewTab","size","layout","usedLayout","logosOnly","className","indexOf","undefined","customIconBackgroundColor","SocialPlaceholder","SelectedSocialPlaceholder","color","blockProps","innerBlocksProps","allowedBlocks","placeholder","templateLock","__experimentalAppenderTagName","__experimentalLayout","POPOVER_PROPS","position","onClose","map","entry","onChange","colorValue","label","textColor","backgroundColor","iconColorAttributes"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QA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oBAASe,gBAAT,CAzFD,CADD;AA6FA;AAED,MAAMgB,mBAAmB,GAAG;AAC3BpC,EAAAA,SAAS,EAAE,YADgB;AAE3BD,EAAAA,mBAAmB,EAAE;AAFM,CAA5B;AAKA,eAAenB,UAAU,CAAEwD,mBAAF,CAAV,CAAmCxC,eAAnC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { Fragment, useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\tPanelColorSettings,\n\twithColors,\n} from '@wordpress/block-editor';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tPanelBody,\n\tToggleControl,\n\tToolbarDropdownMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nconst ALLOWED_BLOCKS = [ 'core/social-link' ];\n\nconst sizeOptions = [\n\t{ name: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ name: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ name: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ name: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tname,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tsize,\n\t\tlayout,\n\t} = attributes;\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\n\t// Remove icon background color if logos only style selected.\n\tconst logosOnly =\n\t\tattributes.className?.indexOf( 'is-style-logos-only' ) >= 0;\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tsetAttributes( {\n\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\tconst SocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-placeholder\">\n\t\t\t<div className=\"wp-social-link\"></div>\n\t\t\t<div className=\"wp-block-social-links__social-placeholder-icons\">\n\t\t\t\t<div className=\"wp-social-link wp-social-link-twitter\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-facebook\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-instagram\"></div>\n\t\t\t</div>\n\t\t</li>\n\t);\n\n\tconst SelectedSocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-prompt\">\n\t\t\t{ __( 'Click plus to add' ) }\n\t\t</li>\n\t);\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = classNames( size, {\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tplaceholder: isSelected ? SelectedSocialPlaceholder : SocialPlaceholder,\n\t\ttemplateLock: false,\n\t\t__experimentalAppenderTagName: 'li',\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\tconst POPOVER_PROPS = {\n\t\tposition: 'bottom right',\n\t};\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\ttext={ __( 'Size' ) }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ sizeOptions.map( ( entry ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t( size === entry.value ||\n\t\t\t\t\t\t\t\t\t\t\t\t( ! size &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tentry.value ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'has-normal-icon-size' ) ) &&\n\t\t\t\t\t\t\t\t\t\t\tcheck\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisSelected={ size === entry.value }\n\t\t\t\t\t\t\t\t\t\tkey={ entry.value }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tsize: entry.value,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ entry.name }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarDropdownMenu>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: ! openInNewTab } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelColorSettings\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\t\tcolorSettings={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t\t\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\t\t\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\t\t\t\t\tonChange: ( colorValue ) => {\n\t\t\t\t\t\t\t\tsetIconColor( colorValue );\n\t\t\t\t\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabel: __( 'Icon color' ),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t! logosOnly && {\n\t\t\t\t\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t\t\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\t\t\t\t\tvalue:\n\t\t\t\t\t\t\t\ticonBackgroundColor.color ||\n\t\t\t\t\t\t\t\ticonBackgroundColorValue,\n\t\t\t\t\t\t\tonChange: ( colorValue ) => {\n\t\t\t\t\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabel: __( 'Icon background' ),\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</Fragment>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { InspectorControls, useSetting } from '@wordpress/block-editor';
|
|
8
|
+
import { BaseControl, PanelBody, __experimentalUseCustomUnits as useCustomUnits, __experimentalUnitControl as UnitControl } from '@wordpress/components';
|
|
9
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
10
|
+
import { useState } from '@wordpress/element';
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { MAX_SPACER_SIZE } from './edit';
|
|
16
|
+
|
|
17
|
+
function DimensionInput(_ref) {
|
|
18
|
+
var _ref2;
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
label,
|
|
22
|
+
onChange,
|
|
23
|
+
isResizing,
|
|
24
|
+
value = ''
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [temporaryInput, setTemporaryInput] = useState(null);
|
|
27
|
+
const inputId = useInstanceId(UnitControl, 'block-spacer-height-input'); // In most contexts the spacer size cannot meaningfully be set to a
|
|
28
|
+
// percentage, since this is relative to the parent container. This
|
|
29
|
+
// unit is disabled from the UI.
|
|
30
|
+
|
|
31
|
+
const availableUnitSettings = (_ref2 = useSetting('spacing.units') || undefined) === null || _ref2 === void 0 ? void 0 : _ref2.filter(availableUnit => availableUnit !== '%');
|
|
32
|
+
const units = useCustomUnits({
|
|
33
|
+
availableUnits: availableUnitSettings || ['px', 'em', 'rem', 'vw', 'vh'],
|
|
34
|
+
defaultValues: {
|
|
35
|
+
px: '100',
|
|
36
|
+
em: '10',
|
|
37
|
+
rem: '10',
|
|
38
|
+
vw: '10',
|
|
39
|
+
vh: '25'
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const handleOnChange = unprocessedValue => {
|
|
44
|
+
setTemporaryInput(null);
|
|
45
|
+
onChange(unprocessedValue);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleOnBlur = () => {
|
|
49
|
+
if (temporaryInput !== null) {
|
|
50
|
+
setTemporaryInput(null);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const inputValue = temporaryInput !== null ? temporaryInput : value;
|
|
55
|
+
return createElement(BaseControl, {
|
|
56
|
+
label: label,
|
|
57
|
+
id: inputId
|
|
58
|
+
}, createElement(UnitControl, {
|
|
59
|
+
id: inputId,
|
|
60
|
+
isResetValueOnUnitChange: true,
|
|
61
|
+
min: 0,
|
|
62
|
+
max: MAX_SPACER_SIZE,
|
|
63
|
+
onBlur: handleOnBlur,
|
|
64
|
+
onChange: handleOnChange,
|
|
65
|
+
style: {
|
|
66
|
+
maxWidth: 80
|
|
67
|
+
},
|
|
68
|
+
value: inputValue,
|
|
69
|
+
units: units // Force the unit to update to `px` when the Spacer is being resized.
|
|
70
|
+
,
|
|
71
|
+
unit: isResizing ? 'px' : undefined
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default function SpacerControls(_ref3) {
|
|
76
|
+
let {
|
|
77
|
+
setAttributes,
|
|
78
|
+
orientation,
|
|
79
|
+
height,
|
|
80
|
+
width,
|
|
81
|
+
isResizing
|
|
82
|
+
} = _ref3;
|
|
83
|
+
return createElement(InspectorControls, null, createElement(PanelBody, {
|
|
84
|
+
title: __('Spacer settings')
|
|
85
|
+
}, orientation === 'horizontal' && createElement(DimensionInput, {
|
|
86
|
+
label: __('Width'),
|
|
87
|
+
value: width,
|
|
88
|
+
onChange: nextWidth => setAttributes({
|
|
89
|
+
width: nextWidth
|
|
90
|
+
}),
|
|
91
|
+
isResizing: isResizing
|
|
92
|
+
}), orientation !== 'horizontal' && createElement(DimensionInput, {
|
|
93
|
+
label: __('Height'),
|
|
94
|
+
value: height,
|
|
95
|
+
onChange: nextHeight => setAttributes({
|
|
96
|
+
height: nextHeight
|
|
97
|
+
}),
|
|
98
|
+
isResizing: isResizing
|
|
99
|
+
})));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["__","InspectorControls","useSetting","BaseControl","PanelBody","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","useInstanceId","useState","MAX_SPACER_SIZE","DimensionInput","label","onChange","isResizing","value","temporaryInput","setTemporaryInput","inputId","availableUnitSettings","undefined","filter","availableUnit","units","availableUnits","defaultValues","px","em","rem","vw","vh","handleOnChange","unprocessedValue","handleOnBlur","inputValue","maxWidth","SpacerControls","setAttributes","orientation","height","width","nextWidth","nextHeight"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,EAA4BC,UAA5B,QAA8C,yBAA9C;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,4BAA4B,IAAIC,cAHjC,EAICC,yBAAyB,IAAIC,WAJ9B,QAKO,uBALP;AAMA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,QAAhC;;AAEA,SAASC,cAAT,OAAuE;AAAA;;AAAA,MAA9C;AAAEC,IAAAA,KAAF;AAASC,IAA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Setting } from '@wordpress/block-editor';\nimport {\n\tBaseControl,\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { MAX_SPACER_SIZE } from './edit';\n\nfunction DimensionInput( { label, onChange, isResizing, value = '' } ) {\n\tconst [ temporaryInput, setTemporaryInput ] = useState( null );\n\n\tconst inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );\n\n\t// In most contexts the spacer size cannot meaningfully be set to a\n\t// percentage, since this is relative to the parent container. This\n\t// unit is disabled from the UI.\n\tconst availableUnitSettings = (\n\t\tuseSetting( 'spacing.units' ) || undefined\n\t)?.filter( ( availableUnit ) => availableUnit !== '%' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnitSettings || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: '100', em: '10', rem: '10', vw: '10', vh: '25' },\n\t} );\n\n\tconst handleOnChange = ( unprocessedValue ) => {\n\t\tsetTemporaryInput( null );\n\t\tonChange( unprocessedValue );\n\t};\n\n\tconst handleOnBlur = () => {\n\t\tif ( temporaryInput !== null ) {\n\t\t\tsetTemporaryInput( null );\n\t\t}\n\t};\n\n\tconst inputValue = temporaryInput !== null ? temporaryInput : value;\n\n\treturn (\n\t\t<BaseControl label={ label } id={ inputId }>\n\t\t\t<UnitControl\n\t\t\t\tid={ inputId }\n\t\t\t\tisResetValueOnUnitChange\n\t\t\t\tmin={ 0 }\n\t\t\t\tmax={ MAX_SPACER_SIZE }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tonChange={ handleOnChange }\n\t\t\t\tstyle={ { maxWidth: 80 } }\n\t\t\t\tvalue={ inputValue }\n\t\t\t\tunits={ units }\n\t\t\t\t// Force the unit to update to `px` when the Spacer is being resized.\n\t\t\t\tunit={ isResizing ? 'px' : undefined }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\nexport default function SpacerControls( {\n\tsetAttributes,\n\torientation,\n\theight,\n\twidth,\n\tisResizing,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Spacer settings' ) }>\n\t\t\t\t{ orientation === 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: nextWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ orientation !== 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\t\tvalue={ height }\n\t\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\t\tsetAttributes( { height: nextHeight } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { PanelBody, UnitControl, getValueAndUnit, __experimentalUseCustomUnits as useCustomUnits } from '@wordpress/components';
|
|
7
|
+
import { useCallback } from '@wordpress/element';
|
|
8
|
+
import { useSetting } from '@wordpress/block-editor';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import styles from './style.scss';
|
|
15
|
+
const DEFAULT_VALUES = {
|
|
16
|
+
px: '100',
|
|
17
|
+
em: '10',
|
|
18
|
+
rem: '10',
|
|
19
|
+
vw: '10',
|
|
20
|
+
vh: '25'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function Controls(_ref) {
|
|
24
|
+
let {
|
|
25
|
+
attributes,
|
|
26
|
+
context,
|
|
27
|
+
setAttributes
|
|
28
|
+
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
orientation
|
|
31
|
+
} = context;
|
|
32
|
+
const label = orientation !== 'horizontal' ? __('Height') : __('Width');
|
|
33
|
+
const {
|
|
34
|
+
height,
|
|
35
|
+
width
|
|
36
|
+
} = attributes;
|
|
37
|
+
const {
|
|
38
|
+
valueToConvert,
|
|
39
|
+
valueUnit: unit
|
|
40
|
+
} = getValueAndUnit(orientation !== 'horizontal' ? height : width) || {};
|
|
41
|
+
const value = Number(valueToConvert);
|
|
42
|
+
|
|
43
|
+
const setNewDimensions = (nextValue, nextUnit) => {
|
|
44
|
+
const valueWithUnit = `${nextValue}${nextUnit}`;
|
|
45
|
+
|
|
46
|
+
if (orientation === 'horizontal') {
|
|
47
|
+
setAttributes({
|
|
48
|
+
width: valueWithUnit
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
setAttributes({
|
|
52
|
+
height: valueWithUnit
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleChange = useCallback(nextValue => {
|
|
58
|
+
setNewDimensions(nextValue, unit);
|
|
59
|
+
}, [height, width]);
|
|
60
|
+
const handleUnitChange = useCallback(nextUnit => {
|
|
61
|
+
setNewDimensions(value, nextUnit);
|
|
62
|
+
}, [height, width]);
|
|
63
|
+
const units = useCustomUnits({
|
|
64
|
+
availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem', 'vw', 'vh'],
|
|
65
|
+
defaultValues: DEFAULT_VALUES
|
|
66
|
+
});
|
|
67
|
+
return createElement(Fragment, null, createElement(PanelBody, {
|
|
68
|
+
title: __('Dimensions')
|
|
69
|
+
}, createElement(UnitControl, {
|
|
70
|
+
label: label,
|
|
71
|
+
min: 1,
|
|
72
|
+
value: value,
|
|
73
|
+
onChange: handleChange,
|
|
74
|
+
onUnitChange: handleUnitChange,
|
|
75
|
+
units: units,
|
|
76
|
+
unit: unit,
|
|
77
|
+
style: styles.rangeCellContainer
|
|
78
|
+
})));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default Controls;
|
|
82
|
+
//# sourceMappingURL=controls.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.native.js"],"names":["PanelBody","UnitControl","getValueAndUnit","__experimentalUseCustomUnits","useCustomUnits","useCallback","useSetting","__","styles","DEFAULT_VALUES","px","em","rem","vw","vh","Controls","attributes","context","setAttributes","orientation","label","height","width","valueToConvert","valueUnit","unit","value","Number","setNewDimensions","nextValue","nextUnit","valueWithUnit","handleChange","handleUnitChange","units","availableUnits","defaultValues","rangeCellContainer"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,WAFD,EAGCC,eAHD,EAICC,4BAA4B,IAAIC,cAJjC,QAKO,uBALP;AAMA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,UAAT,QAA2B,yBAA3B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,cAAc,GAAG;AAAEC,EAAAA,EAAE,EAAE,KAAN;AAAaC,EAAAA,EAAE,EAAE,IAAjB;AAAuBC,EAAAA,GAAG,EAAE,IAA5B;AAAkCC,EAAAA,EAAE,EAAE,IAAtC;AAA4CC,EAAAA,EAAE,EAAE;AAAhD,CAAvB;;AAEA,SAASC,QAAT,OAA4D;AAAA,MAAzC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,OAAd;AAAuBC,IAAAA;AAAvB,GAAyC;AAC3D,QAA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,IAFgD,EAGhD,KAHgD,EAIhD,IAJgD,EAKhD,IALgD,CADpB;AAQ7B8B,IAAAA,aAAa,EAAE3B;AARc,GAAF,CAA5B;AAWA,SACC,8BACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGF,EAAE,CAAE,YAAF;AAArB,KACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGa,KADT;AAEC,IAAA,GAAG,EAAG,CAFP;AAGC,IAAA,KAAK,EAAGM,KAHT;AAIC,IAAA,QAAQ,EAAGM,YAJZ;AAKC,IAAA,YAAY,EAAGC,gBALhB;AAMC,IAAA,KAAK,EAAGC,KANT;AAOC,IAAA,IAAI,EAAGT,IAPR;AAQC,IAAA,KAAK,EAAGjB,MAAM,CAAC6B;AARhB,IADD,CADD,CADD;AAgBA;;AAED,eAAetB,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tUnitControl,\n\tgetValueAndUnit,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { useSetting } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst DEFAULT_VALUES = { px: '100', em: '10', rem: '10', vw: '10', vh: '25' };\n\nfunction Controls( { attributes, context, setAttributes } ) {\n\tconst { orientation } = context;\n\tconst label = orientation !== 'horizontal' ? __( 'Height' ) : __( 'Width' );\n\n\tconst { height, width } = attributes;\n\tconst { valueToConvert, valueUnit: unit } =\n\t\tgetValueAndUnit( orientation !== 'horizontal' ? height : width ) || {};\n\tconst value = Number( valueToConvert );\n\n\tconst setNewDimensions = ( nextValue, nextUnit ) => {\n\t\tconst valueWithUnit = `${ nextValue }${ nextUnit }`;\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tsetAttributes( { width: valueWithUnit } );\n\t\t} else {\n\t\t\tsetAttributes( { height: valueWithUnit } );\n\t\t}\n\t};\n\n\tconst handleChange = useCallback(\n\t\t( nextValue ) => {\n\t\t\tsetNewDimensions( nextValue, unit );\n\t\t},\n\t\t[ height, width ]\n\t);\n\n\tconst handleUnitChange = useCallback(\n\t\t( nextUnit ) => {\n\t\t\tsetNewDimensions( value, nextUnit );\n\t\t},\n\t\t[ height, width ]\n\t);\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: DEFAULT_VALUES,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Dimensions' ) }>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tmin={ 1 }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tunit={ unit }\n\t\t\t\t\tstyle={ styles.rangeCellContainer }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</>\n\t);\n}\n\nexport default Controls;\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
7
|
+
const deprecated = [{
|
|
8
|
+
attributes: {
|
|
9
|
+
height: {
|
|
10
|
+
type: 'number',
|
|
11
|
+
default: 100
|
|
12
|
+
},
|
|
13
|
+
width: {
|
|
14
|
+
type: 'number'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
migrate(attributes) {
|
|
19
|
+
const {
|
|
20
|
+
height,
|
|
21
|
+
width
|
|
22
|
+
} = attributes;
|
|
23
|
+
return { ...attributes,
|
|
24
|
+
width: width !== undefined ? `${width}px` : undefined,
|
|
25
|
+
height: height !== undefined ? `${height}px` : undefined
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
save(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
attributes
|
|
32
|
+
} = _ref;
|
|
33
|
+
return createElement("div", useBlockProps.save({
|
|
34
|
+
style: {
|
|
35
|
+
height: attributes.height,
|
|
36
|
+
width: attributes.width
|
|
37
|
+
},
|
|
38
|
+
'aria-hidden': true
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}];
|
|
43
|
+
export default deprecated;
|
|
44
|
+
//# sourceMappingURL=deprecated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/deprecated.js"],"names":["useBlockProps","deprecated","attributes","height","type","default","width","migrate","undefined","save","style"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,yBAA9B;AAEA,MAAMC,UAAU,GAAG,CAClB;AACCC,EAAAA,UAAU,EAAE;AACXC,IAAAA,MAAM,EAAE;AACPC,MAAAA,IAAI,EAAE,QADC;AAEPC,MAAAA,OAAO,EAAE;AAFF,KADG;AAKXC,IAAAA,KAAK,EAAE;AACNF,MAAAA,IAAI,EAAE;AADA;AALI,GADb;;AAUCG,EAAAA,OAAO,CAAEL,UAAF,EAAe;AACrB,UAAM;AAAEC,MAAAA,MAAF;AAAUG,MAAAA;AAAV,QAAoBJ,UAA1B;AACA,WAAO,EACN,GAAGA,UADG;AAENI,MAAAA,KAAK,EAAEA,KAAK,KAAKE,SAAV,GAAuB,GAAGF,KAAO,IAAjC,GAAuCE,SAFxC;AAGNL,MAAAA,MAAM,EAAEA,MAAM,KAAKK,SAAX,GAAwB,GAAGL,MAAQ,IAAnC,GAAyCK;AAH3C,KAAP;AAKA,GAjBF;;AAkBCC,EAAAA,IAAI,OAAmB;AAAA,QAAjB;AAAEP,MAAAA;AAAF,KAAiB;AACtB,WACC,qBACMF,aAAa,CAACS,IAAd,CAAoB;AACxBC,MAAAA,KAAK,EAAE;AACNP,QAAAA,MAAM,EAAED,UAAU,CAACC,MADb;AAENG,QAAAA,KAAK,EAAEJ,UAAU,CAACI;AAFZ,OADiB;AAKxB,qBAAe;AALS,KAApB,CADN,CADD;AAWA;;AA9BF,CADkB,CAAnB;AAmCA,eAAeL,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\n\nconst deprecated = [\n\t{\n\t\tattributes: {\n\t\t\theight: {\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 100,\n\t\t\t},\n\t\t\twidth: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\tconst { height, width } = attributes;\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\twidth: width !== undefined ? `${ width }px` : undefined,\n\t\t\t\theight: height !== undefined ? `${ height }px` : undefined,\n\t\t\t};\n\t\t},\n\t\tsave( { attributes } ) {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\t{ ...useBlockProps.save( {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\theight: attributes.height,\n\t\t\t\t\t\t\twidth: attributes.width,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'aria-hidden': true,\n\t\t\t\t\t} ) }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t},\n];\n\nexport default deprecated;\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -8,19 +9,74 @@ import classnames from 'classnames';
|
|
|
8
9
|
* WordPress dependencies
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';
|
|
12
|
+
import { useBlockProps, store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
|
+
import { ResizableBox } from '@wordpress/components';
|
|
14
14
|
import { compose, withInstanceId } from '@wordpress/compose';
|
|
15
15
|
import { withDispatch } from '@wordpress/data';
|
|
16
16
|
import { useState, useEffect } from '@wordpress/element';
|
|
17
17
|
import { View } from '@wordpress/primitives';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import SpacerControls from './controls';
|
|
23
|
+
export const MIN_SPACER_SIZE = 1;
|
|
24
|
+
export const MAX_SPACER_SIZE = 500;
|
|
25
|
+
|
|
26
|
+
const ResizableSpacer = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
orientation,
|
|
29
|
+
onResizeStart,
|
|
30
|
+
onResize,
|
|
31
|
+
onResizeStop,
|
|
32
|
+
isSelected,
|
|
33
|
+
isResizing,
|
|
34
|
+
setIsResizing,
|
|
35
|
+
...props
|
|
36
|
+
} = _ref;
|
|
37
|
+
|
|
38
|
+
const getCurrentSize = elt => {
|
|
39
|
+
return orientation === 'horizontal' ? elt.clientWidth : elt.clientHeight;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getNextVal = elt => {
|
|
43
|
+
return `${getCurrentSize(elt)}px`;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return createElement(ResizableBox, _extends({
|
|
47
|
+
className: classnames('block-library-spacer__resize-container', {
|
|
48
|
+
'resize-horizontal': orientation === 'horizontal',
|
|
49
|
+
'is-resizing': isResizing,
|
|
50
|
+
'is-selected': isSelected
|
|
51
|
+
}),
|
|
52
|
+
onResizeStart: (_event, _direction, elt) => {
|
|
53
|
+
const nextVal = getNextVal(elt);
|
|
54
|
+
onResizeStart(nextVal);
|
|
55
|
+
onResize(nextVal);
|
|
56
|
+
},
|
|
57
|
+
onResize: (_event, _direction, elt) => {
|
|
58
|
+
onResize(getNextVal(elt));
|
|
59
|
+
|
|
60
|
+
if (!isResizing) {
|
|
61
|
+
setIsResizing(true);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
onResizeStop: (_event, _direction, elt) => {
|
|
65
|
+
const nextVal = Math.min(MAX_SPACER_SIZE, getCurrentSize(elt));
|
|
66
|
+
onResizeStop(`${nextVal}px`);
|
|
67
|
+
setIsResizing(false);
|
|
68
|
+
},
|
|
69
|
+
__experimentalShowTooltip: true,
|
|
70
|
+
__experimentalTooltipProps: {
|
|
71
|
+
axis: orientation === 'horizontal' ? 'x' : 'y',
|
|
72
|
+
position: 'corner',
|
|
73
|
+
isVisible: isResizing
|
|
74
|
+
},
|
|
75
|
+
showHandle: isSelected
|
|
76
|
+
}, props));
|
|
77
|
+
};
|
|
22
78
|
|
|
23
|
-
const SpacerEdit =
|
|
79
|
+
const SpacerEdit = _ref2 => {
|
|
24
80
|
let {
|
|
25
81
|
attributes,
|
|
26
82
|
isSelected,
|
|
@@ -28,58 +84,43 @@ const SpacerEdit = _ref => {
|
|
|
28
84
|
onResizeStart,
|
|
29
85
|
onResizeStop,
|
|
30
86
|
context
|
|
31
|
-
} =
|
|
87
|
+
} = _ref2;
|
|
32
88
|
const {
|
|
33
89
|
orientation
|
|
34
90
|
} = context;
|
|
35
|
-
const [isResizing, setIsResizing] = useState(false);
|
|
36
91
|
const {
|
|
37
92
|
height,
|
|
38
93
|
width
|
|
39
94
|
} = attributes;
|
|
95
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
96
|
+
const [temporaryHeight, setTemporaryHeight] = useState(null);
|
|
97
|
+
const [temporaryWidth, setTemporaryWidth] = useState(null);
|
|
40
98
|
|
|
41
|
-
const
|
|
99
|
+
const handleOnVerticalResizeStop = newHeight => {
|
|
100
|
+
onResizeStop();
|
|
42
101
|
setAttributes({
|
|
43
|
-
height:
|
|
102
|
+
height: newHeight
|
|
44
103
|
});
|
|
104
|
+
setTemporaryHeight(null);
|
|
45
105
|
};
|
|
46
106
|
|
|
47
|
-
const
|
|
107
|
+
const handleOnHorizontalResizeStop = newWidth => {
|
|
108
|
+
onResizeStop();
|
|
48
109
|
setAttributes({
|
|
49
|
-
width:
|
|
110
|
+
width: newWidth
|
|
50
111
|
});
|
|
112
|
+
setTemporaryWidth(null);
|
|
51
113
|
};
|
|
52
114
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const handleOnVerticalResizeStop = (event, direction, elt, delta) => {
|
|
59
|
-
onResizeStop();
|
|
60
|
-
const spacerHeight = Math.min(parseInt(height + delta.height, 10), MAX_SPACER_HEIGHT);
|
|
61
|
-
updateHeight(spacerHeight);
|
|
62
|
-
setIsResizing(false);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const handleOnHorizontalResizeStop = (event, direction, elt, delta) => {
|
|
66
|
-
onResizeStop();
|
|
67
|
-
const spacerWidth = Math.min(parseInt(width + delta.width, 10), MAX_SPACER_WIDTH);
|
|
68
|
-
updateWidth(spacerWidth);
|
|
69
|
-
setIsResizing(false);
|
|
115
|
+
const style = {
|
|
116
|
+
height: orientation === 'horizontal' ? 24 : temporaryHeight || height || undefined,
|
|
117
|
+
width: orientation === 'horizontal' ? temporaryWidth || width || undefined : undefined
|
|
70
118
|
};
|
|
71
119
|
|
|
72
120
|
const resizableBoxWithOrientation = blockOrientation => {
|
|
73
121
|
if (blockOrientation === 'horizontal') {
|
|
74
|
-
return createElement(
|
|
75
|
-
|
|
76
|
-
'is-selected': isSelected
|
|
77
|
-
}),
|
|
78
|
-
size: {
|
|
79
|
-
width,
|
|
80
|
-
height: 24
|
|
81
|
-
},
|
|
82
|
-
minWidth: MIN_SPACER_WIDTH,
|
|
122
|
+
return createElement(ResizableSpacer, {
|
|
123
|
+
minWidth: MIN_SPACER_SIZE,
|
|
83
124
|
enable: {
|
|
84
125
|
top: false,
|
|
85
126
|
right: true,
|
|
@@ -90,26 +131,17 @@ const SpacerEdit = _ref => {
|
|
|
90
131
|
bottomLeft: false,
|
|
91
132
|
topLeft: false
|
|
92
133
|
},
|
|
93
|
-
|
|
134
|
+
orientation: blockOrientation,
|
|
135
|
+
onResizeStart: onResizeStart,
|
|
136
|
+
onResize: setTemporaryWidth,
|
|
94
137
|
onResizeStop: handleOnHorizontalResizeStop,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
axis: 'x',
|
|
99
|
-
position: 'corner',
|
|
100
|
-
isVisible: isResizing
|
|
101
|
-
}
|
|
138
|
+
isSelected: isSelected,
|
|
139
|
+
isResizing: isResizing,
|
|
140
|
+
setIsResizing: setIsResizing
|
|
102
141
|
});
|
|
103
142
|
}
|
|
104
143
|
|
|
105
|
-
return createElement(
|
|
106
|
-
className: classnames('block-library-spacer__resize-container', {
|
|
107
|
-
'is-selected': isSelected
|
|
108
|
-
}),
|
|
109
|
-
size: {
|
|
110
|
-
height
|
|
111
|
-
},
|
|
112
|
-
minHeight: MIN_SPACER_HEIGHT,
|
|
144
|
+
return createElement(Fragment, null, createElement(ResizableSpacer, {
|
|
113
145
|
enable: {
|
|
114
146
|
top: false,
|
|
115
147
|
right: false,
|
|
@@ -120,39 +152,33 @@ const SpacerEdit = _ref => {
|
|
|
120
152
|
bottomLeft: false,
|
|
121
153
|
topLeft: false
|
|
122
154
|
},
|
|
123
|
-
|
|
155
|
+
orientation: blockOrientation,
|
|
156
|
+
onResizeStart: onResizeStart,
|
|
157
|
+
onResize: setTemporaryHeight,
|
|
124
158
|
onResizeStop: handleOnVerticalResizeStop,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
position: 'bottom',
|
|
130
|
-
isVisible: isResizing
|
|
131
|
-
}
|
|
132
|
-
});
|
|
159
|
+
isSelected: isSelected,
|
|
160
|
+
isResizing: isResizing,
|
|
161
|
+
setIsResizing: setIsResizing
|
|
162
|
+
}));
|
|
133
163
|
};
|
|
134
164
|
|
|
135
165
|
useEffect(() => {
|
|
136
166
|
if (orientation === 'horizontal' && !width) {
|
|
137
|
-
|
|
138
|
-
|
|
167
|
+
setAttributes({
|
|
168
|
+
height: '0px',
|
|
169
|
+
width: '72px'
|
|
170
|
+
});
|
|
139
171
|
}
|
|
140
172
|
}, []);
|
|
141
|
-
return createElement(Fragment, null, createElement(View, useBlockProps(
|
|
142
|
-
|
|
143
|
-
}, orientation
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
150
|
-
label: __('Height in pixels'),
|
|
151
|
-
min: MIN_SPACER_HEIGHT,
|
|
152
|
-
max: Math.max(MAX_SPACER_HEIGHT, height),
|
|
153
|
-
value: height,
|
|
154
|
-
onChange: updateHeight
|
|
155
|
-
}))));
|
|
173
|
+
return createElement(Fragment, null, createElement(View, useBlockProps({
|
|
174
|
+
style
|
|
175
|
+
}), resizableBoxWithOrientation(orientation)), createElement(SpacerControls, {
|
|
176
|
+
setAttributes: setAttributes,
|
|
177
|
+
height: temporaryHeight || height,
|
|
178
|
+
width: temporaryWidth || width,
|
|
179
|
+
orientation: orientation,
|
|
180
|
+
isResizing: isResizing
|
|
181
|
+
}));
|
|
156
182
|
};
|
|
157
183
|
|
|
158
184
|
export default compose([withDispatch(dispatch => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["classnames","__","InspectorControls","useBlockProps","store","blockEditorStore","PanelBody","ResizableBox","RangeControl","compose","withInstanceId","withDispatch","useState","useEffect","View","MIN_SPACER_HEIGHT","MAX_SPACER_HEIGHT","MIN_SPACER_WIDTH","MAX_SPACER_WIDTH","SpacerEdit","attributes","isSelected","setAttributes","onResizeStart","onResizeStop","context","orientation","isResizing","setIsResizing","height","width","updateHeight","value","updateWidth","handleOnResizeStart","handleOnVerticalResizeStop","event","direction","elt","delta","spacerHeight","Math","min","parseInt","handleOnHorizontalResizeStop","spacerWidth","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","axis","position","isVisible","max","dispatch","toggleSelection"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,aAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,YAAlC,QAAsD,uBAAtD;AACA,SAASC,OAAT,EAAkBC,cAAlB,QAAwC,oBAAxC;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,IAAT,QAAqB,uBAArB;AAEA,MAAMC,iBAAiB,GAAG,CAA1B;AACA,MAAMC,iBAAiB,GAAG,GAA1B;AAEA,MAAMC,gBAAgB,GAAG,CAAzB;AACA,MAAMC,gBAAgB,GAAG,GAAzB;;AAEA,MAAMC,UAAU,GAAG,QAOZ;AAAA,MAPc;AACpBC,IAAAA,UADoB;AAEpBC,IAAAA,UAFoB;AAGpBC,IAAAA,aAHoB;AAIpBC,IAAAA,aAJoB;AAKpBC,IAAAA,YALoB;AAMpBC,IAAAA;AANoB,GAOd;AACN,QAAM;AAAEC,IAAAA;AAAF,MAAkBD,OAAxB;AACA,QAAM,CAAEE,UAAF,EAAcC,aAAd,IAAgChB,QAAQ,CAAE,KAAF,CAA9C;AACA,QAAM;AAAEiB,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBV,UAA1B;;AACA,QAAMW,YAAY,GAAKC,KAAF,IAAa;AACjCV,IAAAA,aAAa,CAAE;AACdO,MAAAA,MAAM,EAAEG;AADM,KAAF,CAAb;AAGA,GAJD;;AAKA,QAAMC,WAAW,GAAKD,KAAF,IAAa;AAChCV,IAAAA,aAAa,CAAE;AACdQ,MAAAA,KAAK,EAAEE;AADO,KAAF,CAAb;AAGA,GAJD;;AAMA,QA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MAAMqC,eAAe,CAAE,IAAF;AAF7B,GAAP;AAIA,CAPW,CADW,EASvBnD,cATuB,CAAF,CAAP,CAUVS,UAVU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody, ResizableBox, RangeControl } from '@wordpress/components';\nimport { compose, withInstanceId } from '@wordpress/compose';\nimport { withDispatch } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\nconst MIN_SPACER_HEIGHT = 1;\nconst MAX_SPACER_HEIGHT = 500;\n\nconst MIN_SPACER_WIDTH = 1;\nconst MAX_SPACER_WIDTH = 500;\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tonResizeStart,\n\tonResizeStop,\n\tcontext,\n} ) => {\n\tconst { orientation } = context;\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst { height, width } = attributes;\n\tconst updateHeight = ( value ) => {\n\t\tsetAttributes( {\n\t\t\theight: value,\n\t\t} );\n\t};\n\tconst updateWidth = ( value ) => {\n\t\tsetAttributes( {\n\t\t\twidth: value,\n\t\t} );\n\t};\n\n\tconst handleOnResizeStart = ( ...args ) => {\n\t\tonResizeStart( ...args );\n\t\tsetIsResizing( true );\n\t};\n\n\tconst handleOnVerticalResizeStop = ( event, direction, elt, delta ) => {\n\t\tonResizeStop();\n\t\tconst spacerHeight = Math.min(\n\t\t\tparseInt( height + delta.height, 10 ),\n\t\t\tMAX_SPACER_HEIGHT\n\t\t);\n\t\tupdateHeight( spacerHeight );\n\t\tsetIsResizing( false );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( event, direction, elt, delta ) => {\n\t\tonResizeStop();\n\t\tconst spacerWidth = Math.min(\n\t\t\tparseInt( width + delta.width, 10 ),\n\t\t\tMAX_SPACER_WIDTH\n\t\t);\n\t\tupdateWidth( spacerWidth );\n\t\tsetIsResizing( false );\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableBox\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-library-spacer__resize-container',\n\t\t\t\t\t\t'resize-horizontal',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tsize={ {\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\theight: 24,\n\t\t\t\t\t} }\n\t\t\t\t\tminWidth={ MIN_SPACER_WIDTH }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\tonResizeStart={ handleOnResizeStart }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t__experimentalShowTooltip={ true }\n\t\t\t\t\t__experimentalTooltipProps={ {\n\t\t\t\t\t\taxis: 'x',\n\t\t\t\t\t\tposition: 'corner',\n\t\t\t\t\t\tisVisible: isResizing,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<ResizableBox\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-library-spacer__resize-container',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tsize={ {\n\t\t\t\t\theight,\n\t\t\t\t} }\n\t\t\t\tminHeight={ MIN_SPACER_HEIGHT }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: false,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: false,\n\t\t\t\t\ttopRight: false,\n\t\t\t\t\tbottomRight: false,\n\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\ttopLeft: false,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ handleOnResizeStart }\n\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t__experimentalShowTooltip={ true }\n\t\t\t\t__experimentalTooltipProps={ {\n\t\t\t\t\taxis: 'y',\n\t\t\t\t\tposition: 'bottom',\n\t\t\t\t\tisVisible: isResizing,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( orientation === 'horizontal' && ! width ) {\n\t\t\tupdateWidth( 72 );\n\t\t\tupdateHeight( 0 );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View { ...useBlockProps() }>\n\t\t\t\t{ resizableBoxWithOrientation( orientation ) }\n\t\t\t</View>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Spacer settings' ) }>\n\t\t\t\t\t{ orientation === 'horizontal' && (\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Width in pixels' ) }\n\t\t\t\t\t\t\tmin={ MIN_SPACER_WIDTH }\n\t\t\t\t\t\t\tmax={ Math.max( MAX_SPACER_WIDTH, width ) }\n\t\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\t\tonChange={ updateWidth }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ orientation !== 'horizontal' && (\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Height in pixels' ) }\n\t\t\t\t\t\t\tmin={ MIN_SPACER_HEIGHT }\n\t\t\t\t\t\t\tmax={ Math.max( MAX_SPACER_HEIGHT, height ) }\n\t\t\t\t\t\t\tvalue={ height }\n\t\t\t\t\t\t\tonChange={ updateHeight }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n};\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { toggleSelection } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonResizeStart: () => toggleSelection( false ),\n\t\t\tonResizeStop: () => toggleSelection( true ),\n\t\t};\n\t} ),\n\twithInstanceId,\n] )( SpacerEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["classnames","useBlockProps","store","blockEditorStore","ResizableBox","compose","withInstanceId","withDispatch","useState","useEffect","View","SpacerControls","MIN_SPACER_SIZE","MAX_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","Math","min","axis","position","isVisible","SpacerEdit","attributes","setAttributes","context","height","width","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","style","undefined","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","dispatch","toggleSelection"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,OAAT,EAAkBC,cAAlB,QAAwC,oBAAxC;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,IAAT,QAAqB,uBAArB;AAEA;AACA;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,CAAE,KAAF,CAD9B;AAEN7C,IAAAA,YAAY,EAAE,MAAM6C,eAAe,CAAE,IAAF;AAF7B,GAAP;AAIA,CAPW,CADW,EASvBzD,cATuB,CAAF,CAAP,CAUV8B,UAVU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { compose, withInstanceId } from '@wordpress/compose';\nimport { withDispatch } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\n\nexport const MIN_SPACER_SIZE = 1;\nexport const MAX_SPACER_SIZE = 500;\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = Math.min(\n\t\t\t\t\tMAX_SPACER_SIZE,\n\t\t\t\t\tgetCurrentSize( elt )\n\t\t\t\t);\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tonResizeStart,\n\tonResizeStop,\n\tcontext,\n} ) => {\n\tconst { orientation } = context;\n\tconst { height, width } = attributes;\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst style = {\n\t\theight:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: temporaryHeight || height || undefined,\n\t\twidth:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? temporaryWidth || width || undefined\n\t\t\t\t: undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( orientation === 'horizontal' && ! width ) {\n\t\t\tsetAttributes( {\n\t\t\t\theight: '0px',\n\t\t\t\twidth: '72px',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View { ...useBlockProps( { style } ) }>\n\t\t\t\t{ resizableBoxWithOrientation( orientation ) }\n\t\t\t</View>\n\t\t\t<SpacerControls\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\torientation={ orientation }\n\t\t\t\tisResizing={ isResizing }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default compose( [\n\twithDispatch( ( dispatch ) => {\n\t\tconst { toggleSelection } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tonResizeStart: () => toggleSelection( false ),\n\t\t\tonResizeStop: () => toggleSelection( true ),\n\t\t};\n\t} ),\n\twithInstanceId,\n] )( SpacerEdit );\n"]}
|