@wordpress/block-library 9.42.0 → 9.43.1-next.v.202604091042.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.
- package/CHANGELOG.md +2 -0
- package/build/code/edit.cjs +2 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/cover/edit/color-utils.cjs +1 -1
- package/build/cover/edit/color-utils.cjs.map +2 -2
- package/build/cover/edit/index.cjs +31 -25
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +9 -7
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/file/utils/index.cjs +1 -1
- package/build/file/utils/index.cjs.map +2 -2
- package/build/form/view.cjs +1 -1
- package/build/form/view.cjs.map +2 -2
- package/build/form-input/edit.cjs +36 -29
- package/build/form-input/edit.cjs.map +2 -2
- package/build/form-input/variations.cjs +10 -0
- package/build/form-input/variations.cjs.map +2 -2
- package/build/group/block.json +3 -1
- package/build/icon/edit.cjs +1 -3
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/image.cjs +17 -7
- package/build/image/image.cjs.map +2 -2
- package/build/latest-comments/deprecated.cjs +33 -0
- package/build/latest-comments/deprecated.cjs.map +2 -2
- package/build/list-item/block.json +1 -0
- package/build/navigation/edit/index.cjs +123 -119
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
- package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
- package/build/navigation-link/link-ui/page-creator.cjs +1 -1
- package/build/navigation-link/link-ui/page-creator.cjs.map +2 -2
- package/build/navigation-link/shared/update-attributes.cjs +1 -1
- package/build/navigation-link/shared/update-attributes.cjs.map +2 -2
- package/build/navigation-link/shared/use-link-preview.cjs +1 -1
- package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
- package/build/pattern/edit.cjs +1 -1
- package/build/pattern/edit.cjs.map +2 -2
- package/build/search/block.json +0 -4
- package/build/search/edit.cjs +6 -33
- package/build/search/edit.cjs.map +2 -2
- package/build/site-logo/edit.cjs +19 -13
- package/build/site-logo/edit.cjs.map +3 -3
- package/build/site-tagline/deprecated.cjs +2 -1
- package/build/site-tagline/deprecated.cjs.map +2 -2
- package/build/tab/save.cjs +2 -4
- package/build/tab/save.cjs.map +2 -2
- package/build/tabs/save.cjs +2 -4
- package/build/tabs/save.cjs.map +2 -2
- package/build/utils/media-control.cjs +1 -1
- package/build/utils/media-control.cjs.map +2 -2
- package/build-module/code/edit.mjs +2 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/cover/edit/color-utils.mjs +1 -1
- package/build-module/cover/edit/color-utils.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +39 -28
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +8 -6
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/file/utils/index.mjs +1 -1
- package/build-module/file/utils/index.mjs.map +2 -2
- package/build-module/form/view.mjs +1 -1
- package/build-module/form/view.mjs.map +2 -2
- package/build-module/form-input/edit.mjs +36 -29
- package/build-module/form-input/edit.mjs.map +2 -2
- package/build-module/form-input/variations.mjs +10 -0
- package/build-module/form-input/variations.mjs.map +2 -2
- package/build-module/group/block.json +3 -1
- package/build-module/icon/edit.mjs +1 -3
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +17 -7
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/latest-comments/deprecated.mjs +33 -0
- package/build-module/latest-comments/deprecated.mjs.map +2 -2
- package/build-module/list-item/block.json +1 -0
- package/build-module/navigation/edit/index.mjs +123 -119
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
- package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.mjs +1 -1
- package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
- package/build-module/navigation-link/shared/update-attributes.mjs +1 -1
- package/build-module/navigation-link/shared/update-attributes.mjs.map +2 -2
- package/build-module/navigation-link/shared/use-link-preview.mjs +1 -1
- package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
- package/build-module/pattern/edit.mjs +1 -1
- package/build-module/pattern/edit.mjs.map +2 -2
- package/build-module/search/block.json +0 -4
- package/build-module/search/edit.mjs +6 -33
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +21 -14
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/site-tagline/deprecated.mjs +2 -1
- package/build-module/site-tagline/deprecated.mjs.map +2 -2
- package/build-module/tab/save.mjs +2 -4
- package/build-module/tab/save.mjs.map +2 -2
- package/build-module/tabs/save.mjs +2 -4
- package/build-module/tabs/save.mjs.map +2 -2
- package/build-module/utils/media-control.mjs +1 -1
- package/build-module/utils/media-control.mjs.map +2 -2
- package/build-style/code/style-rtl.css +1 -1
- package/build-style/code/style.css +1 -1
- package/build-style/editor-rtl.css +15 -5
- package/build-style/editor.css +15 -5
- package/build-style/form-input/editor-rtl.css +6 -5
- package/build-style/form-input/editor.css +6 -5
- package/build-style/icon/editor-rtl.css +5 -0
- package/build-style/icon/editor.css +5 -0
- package/build-style/image/editor-rtl.css +4 -0
- package/build-style/image/editor.css +4 -0
- package/build-style/navigation/style-rtl.css +4 -1
- package/build-style/navigation/style.css +4 -1
- package/build-style/style-rtl.css +5 -2
- package/build-style/style.css +5 -2
- package/package.json +38 -38
- package/src/code/edit.js +1 -0
- package/src/code/style.scss +1 -1
- package/src/cover/edit/color-utils.js +1 -1
- package/src/cover/edit/index.js +63 -34
- package/src/cover/embed-video-utils.js +10 -8
- package/src/embed/test/index.native.js +3 -2
- package/src/file/utils/index.js +1 -1
- package/src/form/view.js +1 -1
- package/src/form-input/edit.js +19 -15
- package/src/form-input/editor.scss +6 -6
- package/src/form-input/variations.js +10 -0
- package/src/group/block.json +3 -1
- package/src/home-link/index.php +14 -33
- package/src/icon/edit.js +1 -3
- package/src/icon/editor.scss +5 -0
- package/src/image/editor.scss +5 -0
- package/src/image/image.js +24 -7
- package/src/image/index.php +4 -4
- package/src/latest-comments/deprecated.js +33 -0
- package/src/list-item/block.json +1 -0
- package/src/loginout/index.php +13 -0
- package/src/navigation/edit/index.js +134 -130
- package/src/navigation/edit/navigation-menu-selector.js +2 -1
- package/src/navigation/style.scss +5 -3
- package/src/navigation-link/index.php +10 -38
- package/src/navigation-link/link-ui/page-creator.js +1 -1
- package/src/navigation-link/shared/build-css-font-sizes.php +43 -0
- package/src/navigation-link/shared/update-attributes.js +1 -1
- package/src/navigation-link/shared/use-link-preview.js +1 -1
- package/src/navigation-submenu/index.php +10 -38
- package/src/page-list/index.php +14 -41
- package/src/pattern/edit.js +1 -1
- package/src/search/block.json +0 -4
- package/src/search/edit.js +2 -35
- package/src/site-logo/edit.js +24 -13
- package/src/site-tagline/deprecated.js +1 -0
- package/src/tab/save.js +2 -6
- package/src/tabs/save.js +2 -6
- package/src/utils/media-control.js +3 -1
|
@@ -53,7 +53,8 @@ function NavigationMenuSelector({
|
|
|
53
53
|
const [currentTitle] = useEntityProp(
|
|
54
54
|
"postType",
|
|
55
55
|
"wp_navigation",
|
|
56
|
-
"title"
|
|
56
|
+
"title",
|
|
57
|
+
currentMenuId
|
|
57
58
|
);
|
|
58
59
|
const menuChoices = useMemo(() => {
|
|
59
60
|
return navigationMenus?.map(({ id, title, status }, index) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation/edit/navigation-menu-selector.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tMenuItemsChoice,\n\tDropdownMenu,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { useEntityRecords, useEntityProp } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport useNavigationMenu from '../use-navigation-menu';\n\nfunction buildMenuLabel( title, id, status ) {\n\tif ( ! title ) {\n\t\t/* translators: %s: the index of the menu in the list of menus. */\n\t\treturn sprintf( __( '(no title %s)' ), id );\n\t}\n\n\tif ( status === 'publish' ) {\n\t\treturn decodeEntities( title );\n\t}\n\n\treturn sprintf(\n\t\t// translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.).\n\t\t__( '%1$s (%2$s)' ),\n\t\tdecodeEntities( title ),\n\t\tstatus\n\t);\n}\n\nfunction NavigationMenuSelector( {\n\tcurrentMenuId,\n\tonSelectNavigationMenu,\n\tonSelectClassicMenu,\n\tonCreateNew,\n\tactionLabel,\n\tcreateNavigationMenuIsSuccess,\n\tcreateNavigationMenuIsError,\n} ) {\n\t/* translators: %s: The name of a menu. */\n\tconst createActionLabel = __( \"Create from '%s'\" );\n\n\tconst [ isUpdatingMenuRef, setIsUpdatingMenuRef ] = useState( false );\n\n\tactionLabel = actionLabel || createActionLabel;\n\n\tconst { records: classicMenus } = useEntityRecords( 'root', 'menu', {\n\t\tper_page: -1,\n\t\tcontext: 'view',\n\t} );\n\n\tconst {\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tcanUserCreateNavigationMenus,\n\t\tcanSwitchNavigationMenu,\n\t\tisNavigationMenuMissing,\n\t} = useNavigationMenu( currentMenuId );\n\n\tconst [ currentTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t'title'\n\t);\n\n\tconst menuChoices = useMemo( () => {\n\t\treturn (\n\t\t\tnavigationMenus?.map( ( { id, title, status }, index ) => {\n\t\t\t\tconst label = buildMenuLabel(\n\t\t\t\t\ttitle?.rendered,\n\t\t\t\t\tindex + 1,\n\t\t\t\t\tstatus\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tvalue: id,\n\t\t\t\t\tlabel,\n\t\t\t\t\tariaLabel: sprintf( actionLabel, label ),\n\t\t\t\t\tdisabled:\n\t\t\t\t\t\tisUpdatingMenuRef ||\n\t\t\t\t\t\tisResolvingNavigationMenus ||\n\t\t\t\t\t\t! hasResolvedNavigationMenus,\n\t\t\t\t};\n\t\t\t} ) || []\n\t\t);\n\t}, [\n\t\tnavigationMenus,\n\t\tactionLabel,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tisUpdatingMenuRef,\n\t] );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasClassicMenus = !! classicMenus?.length;\n\tconst showNavigationMenus = !! canSwitchNavigationMenu;\n\tconst showClassicMenus = !! canUserCreateNavigationMenus;\n\n\tconst noMenuSelected = hasNavigationMenus && ! currentMenuId;\n\tconst noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;\n\tconst menuUnavailable =\n\t\thasResolvedNavigationMenus && currentMenuId === null;\n\tconst navMenuHasBeenDeleted = currentMenuId && isNavigationMenuMissing;\n\n\tlet selectorLabel = '';\n\n\tif ( isResolvingNavigationMenus ) {\n\t\tselectorLabel = __( 'Loading\u2026' );\n\t} else if (\n\t\tnoMenuSelected ||\n\t\tnoBlockMenus ||\n\t\tmenuUnavailable ||\n\t\tnavMenuHasBeenDeleted\n\t) {\n\t\t// Note: classic Menus may be available.\n\t\tselectorLabel = __( 'Choose or create a Navigation Menu' );\n\t} else {\n\t\t// Current Menu's title.\n\t\tselectorLabel = currentTitle;\n\t}\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisUpdatingMenuRef &&\n\t\t\t( createNavigationMenuIsSuccess || createNavigationMenuIsError )\n\t\t) {\n\t\t\tsetIsUpdatingMenuRef( false );\n\t\t}\n\t}, [\n\t\thasResolvedNavigationMenus,\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcanUserCreateNavigationMenus,\n\t\tcreateNavigationMenuIsError,\n\t\tisUpdatingMenuRef,\n\t\tmenuUnavailable,\n\t\tnoBlockMenus,\n\t\tnoMenuSelected,\n\t] );\n\n\tconst NavigationMenuSelectorDropdown = (\n\t\t<DropdownMenu\n\t\t\tlabel={ selectorLabel }\n\t\t\ticon={ moreVertical }\n\t\t\ttoggleProps={ { size: 'small' } }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t{ showNavigationMenus && hasNavigationMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Menus' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tvalue={ currentMenuId }\n\t\t\t\t\t\t\t\tonSelect={ ( menuId ) => {\n\t\t\t\t\t\t\t\t\tonSelectNavigationMenu( menuId );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tchoices={ menuChoices }\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\t{ showClassicMenus && hasClassicMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Import Classic Menus' ) }>\n\t\t\t\t\t\t\t{ classicMenus?.map( ( menu ) => {\n\t\t\t\t\t\t\t\tconst label = decodeEntities( menu.name );\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\tonClick={ async () => {\n\t\t\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( true );\n\t\t\t\t\t\t\t\t\t\t\tawait onSelectClassicMenu( menu );\n\t\t\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( false );\n\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\tcreateActionLabel,\n\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\t\t\tisUpdatingMenuRef ||\n\t\t\t\t\t\t\t\t\t\t\tisResolvingNavigationMenus ||\n\t\t\t\t\t\t\t\t\t\t\t! hasResolvedNavigationMenus\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ label }\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\n\t\t\t\t\t{ canUserCreateNavigationMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( true );\n\t\t\t\t\t\t\t\t\tawait onCreateNew();\n\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( false );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\tisUpdatingMenuRef ||\n\t\t\t\t\t\t\t\t\tisResolvingNavigationMenus ||\n\t\t\t\t\t\t\t\t\t! hasResolvedNavigationMenus\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create new Menu' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n\n\treturn NavigationMenuSelectorDropdown;\n}\n\nexport default NavigationMenuSelector;\n"],
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAC7B,SAAS,IAAI,eAAe;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,WAAW,SAAS,gBAAgB;AAC7C,SAAS,kBAAkB,qBAAqB;AAKhD,OAAO,uBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tMenuItemsChoice,\n\tDropdownMenu,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { useEntityRecords, useEntityProp } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport useNavigationMenu from '../use-navigation-menu';\n\nfunction buildMenuLabel( title, id, status ) {\n\tif ( ! title ) {\n\t\t/* translators: %s: the index of the menu in the list of menus. */\n\t\treturn sprintf( __( '(no title %s)' ), id );\n\t}\n\n\tif ( status === 'publish' ) {\n\t\treturn decodeEntities( title );\n\t}\n\n\treturn sprintf(\n\t\t// translators: 1: title of the menu. 2: status of the menu (draft, pending, etc.).\n\t\t__( '%1$s (%2$s)' ),\n\t\tdecodeEntities( title ),\n\t\tstatus\n\t);\n}\n\nfunction NavigationMenuSelector( {\n\tcurrentMenuId,\n\tonSelectNavigationMenu,\n\tonSelectClassicMenu,\n\tonCreateNew,\n\tactionLabel,\n\tcreateNavigationMenuIsSuccess,\n\tcreateNavigationMenuIsError,\n} ) {\n\t/* translators: %s: The name of a menu. */\n\tconst createActionLabel = __( \"Create from '%s'\" );\n\n\tconst [ isUpdatingMenuRef, setIsUpdatingMenuRef ] = useState( false );\n\n\tactionLabel = actionLabel || createActionLabel;\n\n\tconst { records: classicMenus } = useEntityRecords( 'root', 'menu', {\n\t\tper_page: -1,\n\t\tcontext: 'view',\n\t} );\n\n\tconst {\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tcanUserCreateNavigationMenus,\n\t\tcanSwitchNavigationMenu,\n\t\tisNavigationMenuMissing,\n\t} = useNavigationMenu( currentMenuId );\n\n\tconst [ currentTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t'title',\n\t\tcurrentMenuId\n\t);\n\n\tconst menuChoices = useMemo( () => {\n\t\treturn (\n\t\t\tnavigationMenus?.map( ( { id, title, status }, index ) => {\n\t\t\t\tconst label = buildMenuLabel(\n\t\t\t\t\ttitle?.rendered,\n\t\t\t\t\tindex + 1,\n\t\t\t\t\tstatus\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tvalue: id,\n\t\t\t\t\tlabel,\n\t\t\t\t\tariaLabel: sprintf( actionLabel, label ),\n\t\t\t\t\tdisabled:\n\t\t\t\t\t\tisUpdatingMenuRef ||\n\t\t\t\t\t\tisResolvingNavigationMenus ||\n\t\t\t\t\t\t! hasResolvedNavigationMenus,\n\t\t\t\t};\n\t\t\t} ) || []\n\t\t);\n\t}, [\n\t\tnavigationMenus,\n\t\tactionLabel,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tisUpdatingMenuRef,\n\t] );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasClassicMenus = !! classicMenus?.length;\n\tconst showNavigationMenus = !! canSwitchNavigationMenu;\n\tconst showClassicMenus = !! canUserCreateNavigationMenus;\n\n\tconst noMenuSelected = hasNavigationMenus && ! currentMenuId;\n\tconst noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;\n\tconst menuUnavailable =\n\t\thasResolvedNavigationMenus && currentMenuId === null;\n\tconst navMenuHasBeenDeleted = currentMenuId && isNavigationMenuMissing;\n\n\tlet selectorLabel = '';\n\n\tif ( isResolvingNavigationMenus ) {\n\t\tselectorLabel = __( 'Loading\u2026' );\n\t} else if (\n\t\tnoMenuSelected ||\n\t\tnoBlockMenus ||\n\t\tmenuUnavailable ||\n\t\tnavMenuHasBeenDeleted\n\t) {\n\t\t// Note: classic Menus may be available.\n\t\tselectorLabel = __( 'Choose or create a Navigation Menu' );\n\t} else {\n\t\t// Current Menu's title.\n\t\tselectorLabel = currentTitle;\n\t}\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisUpdatingMenuRef &&\n\t\t\t( createNavigationMenuIsSuccess || createNavigationMenuIsError )\n\t\t) {\n\t\t\tsetIsUpdatingMenuRef( false );\n\t\t}\n\t}, [\n\t\thasResolvedNavigationMenus,\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcanUserCreateNavigationMenus,\n\t\tcreateNavigationMenuIsError,\n\t\tisUpdatingMenuRef,\n\t\tmenuUnavailable,\n\t\tnoBlockMenus,\n\t\tnoMenuSelected,\n\t] );\n\n\tconst NavigationMenuSelectorDropdown = (\n\t\t<DropdownMenu\n\t\t\tlabel={ selectorLabel }\n\t\t\ticon={ moreVertical }\n\t\t\ttoggleProps={ { size: 'small' } }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t{ showNavigationMenus && hasNavigationMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Menus' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tvalue={ currentMenuId }\n\t\t\t\t\t\t\t\tonSelect={ ( menuId ) => {\n\t\t\t\t\t\t\t\t\tonSelectNavigationMenu( menuId );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tchoices={ menuChoices }\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\t{ showClassicMenus && hasClassicMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Import Classic Menus' ) }>\n\t\t\t\t\t\t\t{ classicMenus?.map( ( menu ) => {\n\t\t\t\t\t\t\t\tconst label = decodeEntities( menu.name );\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\tonClick={ async () => {\n\t\t\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( true );\n\t\t\t\t\t\t\t\t\t\t\tawait onSelectClassicMenu( menu );\n\t\t\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( false );\n\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\tcreateActionLabel,\n\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\t\t\tisUpdatingMenuRef ||\n\t\t\t\t\t\t\t\t\t\t\tisResolvingNavigationMenus ||\n\t\t\t\t\t\t\t\t\t\t\t! hasResolvedNavigationMenus\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ label }\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\n\t\t\t\t\t{ canUserCreateNavigationMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ async () => {\n\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( true );\n\t\t\t\t\t\t\t\t\tawait onCreateNew();\n\t\t\t\t\t\t\t\t\tsetIsUpdatingMenuRef( false );\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\tisUpdatingMenuRef ||\n\t\t\t\t\t\t\t\t\tisResolvingNavigationMenus ||\n\t\t\t\t\t\t\t\t\t! hasResolvedNavigationMenus\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create new Menu' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n\n\treturn NavigationMenuSelectorDropdown;\n}\n\nexport default NavigationMenuSelector;\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAC7B,SAAS,IAAI,eAAe;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,WAAW,SAAS,gBAAgB;AAC7C,SAAS,kBAAkB,qBAAqB;AAKhD,OAAO,uBAAuB;AA0I1B,mBAGG,KAHH;AAxIJ,SAAS,eAAgB,OAAO,IAAI,QAAS;AAC5C,MAAK,CAAE,OAAQ;AAEd,WAAO,QAAS,GAAI,eAAgB,GAAG,EAAG;AAAA,EAC3C;AAEA,MAAK,WAAW,WAAY;AAC3B,WAAO,eAAgB,KAAM;AAAA,EAC9B;AAEA,SAAO;AAAA;AAAA,IAEN,GAAI,aAAc;AAAA,IAClB,eAAgB,KAAM;AAAA,IACtB;AAAA,EACD;AACD;AAEA,SAAS,uBAAwB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AAEH,QAAM,oBAAoB,GAAI,kBAAmB;AAEjD,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAAU,KAAM;AAEpE,gBAAc,eAAe;AAE7B,QAAM,EAAE,SAAS,aAAa,IAAI,iBAAkB,QAAQ,QAAQ;AAAA,IACnE,UAAU;AAAA,IACV,SAAS;AAAA,EACV,CAAE;AAEF,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;A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version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/link-ui/page-creator.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTextControl,\n\tNotice,\n\tCheckboxControl,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DialogWrapper from './dialog-wrapper';\n\n/**\n * Component for creating new pages within the Navigation Link UI.\n *\n * @param {Object} props Component props.\n * @param {string} props.postType The post type to create.\n * @param {Function} props.onBack Callback when user wants to go back.\n * @param {Function} props.onPageCreated Callback when page is successfully created.\n * @param {string} [props.initialTitle] Initial title to pre-fill the form.\n */\nexport function LinkUIPageCreator( {\n\tpostType,\n\tonBack,\n\tonPageCreated,\n\tinitialTitle = '',\n} ) {\n\tconst [ title, setTitle ] = useState( initialTitle );\n\tconst [ shouldPublish, setShouldPublish ] = useState( true );\n\n\t// Check if the title is valid for submission\n\tconst isTitleValid = title.trim().length > 0;\n\n\t// Get the last created entity record (without ID) to track creation state\n\tconst { lastError, isSaving } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlastError: select( coreStore ).getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t\tisSaving: select( coreStore ).isSavingEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t} ),\n\t\t[ postType ]\n\t);\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isSaving || ! isTitleValid ) {\n\t\t\treturn;\n\t\t}\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,\n\t\t\t\t\tstatus: shouldPublish ? 'publish' : 'draft',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\t// Create the page link object from the saved record\n\t\t\t\tconst pageLink = {\n\t\t\t\t\tid: savedRecord.id,\n\t\t\t\t\ttype: postType,\n\t\t\t\t\ttitle: decodeEntities( savedRecord.title.rendered ),\n\t\t\t\t\turl: savedRecord.link,\n\t\t\t\t\tkind: 'post-type',\n\t\t\t\t};\n\n\t\t\t\t// Show success notice\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: the name of the new page being created.\n\t\t\t\t\t\t__( '%s page created successfully.' ),\n\t\t\t\t\t\tdecodeEntities( savedRecord.title.rendered )\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'page-created-success',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tonPageCreated( pageLink );\n\t\t\t}\n\t\t} catch
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,IAAI,eAAe;AAC5B,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,oBAAoB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAKzB,OAAO,mBAAmB;AA4GpB,cAuBA,YAvBA;AAjGC,SAAS,kBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAChB,GAAI;AACH,QAAM,CAAE,OAAO,QAAS,IAAI,SAAU,YAAa;AACnD,QAAM,CAAE,eAAe,gBAAiB,IAAI,SAAU,IAAK;AAG3D,QAAM,eAAe,MAAM,KAAK,EAAE,SAAS;AAG3C,QAAM,EAAE,WAAW,SAAS,IAAI;AAAA,IAC/B,CAAE,YAAc;AAAA,MACf,WAAW,OAAQ,SAAU,EAAE;AAAA,QAC9B;AAAA,QACA;AAAA,MACD;AAAA,MACA,UAAU,OAAQ,SAAU,EAAE;AAAA,QAC7B;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,EAAE,iBAAiB,IAAI,YAAa,SAAU;AACpD,QAAM,EAAE,qBAAqB,kBAAkB,IAC9C,YAAa,YAAa;AAE3B,iBAAe,WAAY,OAAQ;AAClC,UAAM,eAAe;AACrB,QAAK,YAAY,CAAE,cAAe;AACjC;AAAA,IACD;AAEA,QAAI;AACH,YAAM,cAAc,MAAM;AAAA,QACzB;AAAA,QACA;AAAA,QACA;AAAA,UACC;AAAA,UACA,QAAQ,gBAAgB,YAAY;AAAA,QACrC;AAAA,QACA,EAAE,cAAc,KAAK;AAAA,MACtB;AAEA,UAAK,aAAc;AAElB,cAAM,WAAW;AAAA,UAChB,IAAI,YAAY;AAAA,UAChB,MAAM;AAAA,UACN,OAAO,eAAgB,YAAY,MAAM,QAAS;AAAA,UAClD,KAAK,YAAY;AAAA,UACjB,MAAM;AAAA,QACP;AAGA;AAAA,UACC;AAAA;AAAA,YAEC,GAAI,+BAAgC;AAAA,YACpC,eAAgB,YAAY,MAAM,QAAS;AAAA,UAC5C;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,IAAI;AAAA,UACL;AAAA,QACD;AAEA,sBAAe,QAAS;AAAA,MACzB;AAAA,IACD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTextControl,\n\tNotice,\n\tCheckboxControl,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DialogWrapper from './dialog-wrapper';\n\n/**\n * Component for creating new pages within the Navigation Link UI.\n *\n * @param {Object} props Component props.\n * @param {string} props.postType The post type to create.\n * @param {Function} props.onBack Callback when user wants to go back.\n * @param {Function} props.onPageCreated Callback when page is successfully created.\n * @param {string} [props.initialTitle] Initial title to pre-fill the form.\n */\nexport function LinkUIPageCreator( {\n\tpostType,\n\tonBack,\n\tonPageCreated,\n\tinitialTitle = '',\n} ) {\n\tconst [ title, setTitle ] = useState( initialTitle );\n\tconst [ shouldPublish, setShouldPublish ] = useState( true );\n\n\t// Check if the title is valid for submission\n\tconst isTitleValid = title.trim().length > 0;\n\n\t// Get the last created entity record (without ID) to track creation state\n\tconst { lastError, isSaving } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlastError: select( coreStore ).getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t\tisSaving: select( coreStore ).isSavingEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t} ),\n\t\t[ postType ]\n\t);\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isSaving || ! isTitleValid ) {\n\t\t\treturn;\n\t\t}\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,\n\t\t\t\t\tstatus: shouldPublish ? 'publish' : 'draft',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\t// Create the page link object from the saved record\n\t\t\t\tconst pageLink = {\n\t\t\t\t\tid: savedRecord.id,\n\t\t\t\t\ttype: postType,\n\t\t\t\t\ttitle: decodeEntities( savedRecord.title.rendered ),\n\t\t\t\t\turl: savedRecord.link,\n\t\t\t\t\tkind: 'post-type',\n\t\t\t\t};\n\n\t\t\t\t// Show success notice\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: the name of the new page being created.\n\t\t\t\t\t\t__( '%s page created successfully.' ),\n\t\t\t\t\t\tdecodeEntities( savedRecord.title.rendered )\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: 'page-created-success',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tonPageCreated( pageLink );\n\t\t\t}\n\t\t} catch {\n\t\t\t// Show error notice\n\t\t\tcreateErrorNotice(\n\t\t\t\t__( 'Failed to create page. Please try again.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'page-created-error',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\tconst isSubmitDisabled = isSaving || ! isTitleValid;\n\n\treturn (\n\t\t<DialogWrapper\n\t\t\tclassName=\"link-ui-page-creator\"\n\t\t\ttitle={ __( 'Create page' ) }\n\t\t\tdescription={ __( 'Create a new page to add to your Navigation.' ) }\n\t\t\tonBack={ onBack }\n\t\t>\n\t\t\t<VStack className=\"link-ui-page-creator__inner\" spacing={ 4 }>\n\t\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\tlabel={ __( 'Publish' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\"Turn off to save as a draft. Drafts won't appear on your site until published.\"\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tchecked={ shouldPublish }\n\t\t\t\t\t\t\tonChange={ setShouldPublish }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t{ lastError && (\n\t\t\t\t\t\t\t<Notice status=\"error\" isDismissible={ false }>\n\t\t\t\t\t\t\t\t{ lastError.message }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<HStack spacing={ 2 } justify=\"flex-end\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t\t\taria-disabled={ isSubmitDisabled }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</form>\n\t\t\t</VStack>\n\t\t</DialogWrapper>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AA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AAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,QAAS;AAAA,cACT,iBAAgB;AAAA,cAEd,aAAI,aAAc;AAAA;AAAA,UACrB;AAAA,WACD;AAAA,SACD,GACD,GACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ var shouldSeverEntityLink = (originalUrl, newUrl) => {
|
|
|
15
15
|
try {
|
|
16
16
|
const base = baseUrl || (typeof window !== "undefined" ? window.location.origin : "https://wordpress.org");
|
|
17
17
|
return new URL(url, base);
|
|
18
|
-
} catch
|
|
18
|
+
} catch {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/update-attributes.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI, getPath } from '@wordpress/url';\n\n/**\n * Determines if an entity link should be severed based on URL changes.\n *\n * @param {string} originalUrl - The original URL\n * @param {string} newUrl - The new URL\n * @return {boolean} True if the entity link should be severed\n */\nconst shouldSeverEntityLink = ( originalUrl, newUrl ) => {\n\tif ( ! originalUrl || ! newUrl ) {\n\t\treturn false;\n\t}\n\n\tconst normalizePath = ( path ) => {\n\t\tif ( ! path ) {\n\t\t\treturn '';\n\t\t}\n\t\treturn path.replace( /\\/+$/, '' ); // Remove trailing slashes\n\t};\n\n\t// Helper function to create URL objects with proper base handling\n\tconst createUrlObject = ( url, baseUrl = null ) => {\n\t\ttry {\n\t\t\t// Always provide a base URL - it will be ignored for absolute URLs\n\t\t\t// Use window.location.origin in browser, fallback for Node/tests\n\t\t\tconst base =\n\t\t\t\tbaseUrl ||\n\t\t\t\t( typeof window !== 'undefined'\n\t\t\t\t\t? window.location.origin\n\t\t\t\t\t: 'https://wordpress.org' );\n\t\t\treturn new URL( url, base );\n\t\t} catch
|
|
5
|
-
"mappings": ";AAGA,SAAS,kBAAkB;AAC3B,SAAS,eAAe,eAAe;AASvC,IAAM,wBAAwB,CAAE,aAAa,WAAY;AACxD,MAAK,CAAE,eAAe,CAAE,QAAS;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,gBAAgB,CAAE,SAAU;AACjC,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,IACR;AACA,WAAO,KAAK,QAAS,QAAQ,EAAG;AAAA,EACjC;AAGA,QAAM,kBAAkB,CAAE,KAAK,UAAU,SAAU;AAClD,QAAI;AAGH,YAAM,OACL,YACE,OAAO,WAAW,cACjB,OAAO,SAAS,SAChB;AACJ,aAAO,IAAI,IAAK,KAAK,IAAK;AAAA,IAC3B,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { escapeHTML } from '@wordpress/escape-html';\nimport { safeDecodeURI, getPath } from '@wordpress/url';\n\n/**\n * Determines if an entity link should be severed based on URL changes.\n *\n * @param {string} originalUrl - The original URL\n * @param {string} newUrl - The new URL\n * @return {boolean} True if the entity link should be severed\n */\nconst shouldSeverEntityLink = ( originalUrl, newUrl ) => {\n\tif ( ! originalUrl || ! newUrl ) {\n\t\treturn false;\n\t}\n\n\tconst normalizePath = ( path ) => {\n\t\tif ( ! path ) {\n\t\t\treturn '';\n\t\t}\n\t\treturn path.replace( /\\/+$/, '' ); // Remove trailing slashes\n\t};\n\n\t// Helper function to create URL objects with proper base handling\n\tconst createUrlObject = ( url, baseUrl = null ) => {\n\t\ttry {\n\t\t\t// Always provide a base URL - it will be ignored for absolute URLs\n\t\t\t// Use window.location.origin in browser, fallback for Node/tests\n\t\t\tconst base =\n\t\t\t\tbaseUrl ||\n\t\t\t\t( typeof window !== 'undefined'\n\t\t\t\t\t? window.location.origin\n\t\t\t\t\t: 'https://wordpress.org' );\n\t\t\treturn new URL( url, base );\n\t\t} catch {\n\t\t\t// If URL construction still fails, it's likely an invalid URL\n\t\t\t// and we should sever the entity link\n\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst originalUrlObj = createUrlObject( originalUrl );\n\tif ( ! originalUrlObj ) {\n\t\treturn true;\n\t}\n\n\tconst newUrlObj = createUrlObject( newUrl, originalUrl );\n\tif ( ! newUrlObj ) {\n\t\treturn true;\n\t}\n\n\t// Move these declarations here, after the null checks\n\tconst originalHostname = originalUrlObj.hostname;\n\tconst newHostname = newUrlObj.hostname;\n\tconst originalPath = normalizePath( getPath( originalUrlObj.toString() ) );\n\tconst newPath = normalizePath( getPath( newUrlObj.toString() ) );\n\n\t// If hostname or path changed, sever the entity link\n\tif ( originalHostname !== newHostname || originalPath !== newPath ) {\n\t\treturn true;\n\t}\n\n\t// Special handling for plain permalinks (query string post IDs)\n\tconst originalP = originalUrlObj.searchParams.get( 'p' );\n\tconst newP = newUrlObj.searchParams.get( 'p' );\n\n\t// If both are plain permalinks (with ?p= or ?page_id=), compare the IDs\n\tif ( originalP && newP && originalP !== newP ) {\n\t\treturn true;\n\t}\n\n\tconst originalPageId = originalUrlObj.searchParams.get( 'page_id' );\n\tconst newPageId = newUrlObj.searchParams.get( 'page_id' );\n\n\tif ( originalPageId && newPageId && originalPageId !== newPageId ) {\n\t\treturn true;\n\t}\n\t// If switching between ?p= and ?page_id=, or one is missing, sever\n\tif ( ( originalP && newPageId ) || ( originalPageId && newP ) ) {\n\t\treturn true;\n\t}\n\n\t// If only query string or fragment changed, preserve the entity link\n\treturn false;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\tlabel: newLabelFromLabel = '', // alternative to title\n\t\turl: newUrl,\n\t\topensInNewTab,\n\t\tid: newID,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\t// Use title if provided, otherwise fall back to label\n\tconst finalNewLabel = newLabel || newLabelFromLabel;\n\n\tconst newLabelWithoutHttp = finalNewLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl?.replace( /http(s?):\\/\\//gi, '' ) ?? '';\n\n\tconst useNewLabel =\n\t\tfinalNewLabel &&\n\t\tfinalNewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( finalNewLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tconst attributes = {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl !== undefined\n\t\t\t? { url: newUrl ? encodeURI( safeDecodeURI( newUrl ) ) : newUrl }\n\t\t\t: {} ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t};\n\n\t// If the block's id is set then the menu item is linking to an entity.\n\t// Therefore, if the URL is set but a new ID is not provided, check if\n\t// the entity link should be severed based on URL changes.\n\tif ( newUrl && ! newID && blockAttributes.id ) {\n\t\tconst shouldSever = shouldSeverEntityLink(\n\t\t\tblockAttributes.url,\n\t\t\tnewUrl\n\t\t);\n\n\t\tif ( shouldSever ) {\n\t\t\tattributes.id = undefined; // explicitly \"unset\" the ID.\n\t\t\t// When URL is manually changed in a way that severs the entity link,\n\t\t\t// update kind and type to \"custom\" to indicate this is now a custom link.\n\t\t\tattributes.kind = 'custom';\n\t\t\tattributes.type = 'custom';\n\t\t}\n\t} else if ( newID && Number.isInteger( newID ) ) {\n\t\tattributes.id = newID;\n\t} else if ( blockAttributes.id ) {\n\t\t// If we have an existing ID and no URL change, ensure kind and type are preserved\n\t\tattributes.kind = kind;\n\t\tattributes.type = type;\n\t}\n\n\tsetAttributes( attributes );\n\n\t// Return metadata about the final state for binding decisions.\n\t// We need to distinguish between:\n\t// 1. Property not set in attributes (use blockAttributes fallback)\n\t// 2. Property explicitly set to undefined (means \"remove this\")\n\t// Using 'in' operator checks if property exists, even if undefined.\n\t// This is critical for severing: attributes.id = undefined means \"remove the ID\",\n\t// not \"keep the old ID from blockAttributes\".\n\tconst finalId = 'id' in attributes ? attributes.id : blockAttributes.id;\n\tconst finalKind =\n\t\t'kind' in attributes ? attributes.kind : blockAttributes.kind;\n\n\treturn {\n\t\tisEntityLink: !! finalId && finalKind !== 'custom',\n\t\tattributes, // Return the computed attributes object\n\t};\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,kBAAkB;AAC3B,SAAS,eAAe,eAAe;AASvC,IAAM,wBAAwB,CAAE,aAAa,WAAY;AACxD,MAAK,CAAE,eAAe,CAAE,QAAS;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,gBAAgB,CAAE,SAAU;AACjC,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,IACR;AACA,WAAO,KAAK,QAAS,QAAQ,EAAG;AAAA,EACjC;AAGA,QAAM,kBAAkB,CAAE,KAAK,UAAU,SAAU;AAClD,QAAI;AAGH,YAAM,OACL,YACE,OAAO,WAAW,cACjB,OAAO,SAAS,SAChB;AACJ,aAAO,IAAI,IAAK,KAAK,IAAK;AAAA,IAC3B,QAAQ;AAGP,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,iBAAiB,gBAAiB,WAAY;AACpD,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,YAAY,gBAAiB,QAAQ,WAAY;AACvD,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAGA,QAAM,mBAAmB,eAAe;AACxC,QAAM,cAAc,UAAU;AAC9B,QAAM,eAAe,cAAe,QAAS,eAAe,SAAS,CAAE,CAAE;AACzE,QAAM,UAAU,cAAe,QAAS,UAAU,SAAS,CAAE,CAAE;AAG/D,MAA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AAE,WAAW,CAAE,iBAAmB,YAAY;AACjD,QAAM,OAAO,eAAe,WAAW;AAEvC,QAAM,aAAa;AAAA;AAAA,IAElB,GAAK,WAAW,SACb,EAAE,KAAK,SAAS,UAAW,cAAe,MAAO,CAAE,IAAI,OAAO,IAC9D,CAAC;AAAA,IACJ,GAAK,SAAS,EAAE,MAAM;AAAA,IACtB,GAAK,WAAc,iBAAiB,EAAE,cAAc;AAAA,IACpD,GAAK,QAAQ,EAAE,KAAK;AAAA,IACpB,GAAK,QAAQ,SAAS,SAAS,EAAE,KAAK;AAAA,EACvC;AAKA,MAAK,UAAU,CAAE,SAAS,gBAAgB,IAAK;AAC9C,UAAM,cAAc;AAAA,MACnB,gBAAgB;AAAA,MAChB;AAAA,IACD;AAEA,QAAK,aAAc;AAClB,iBAAW,KAAK;AAGhB,iBAAW,OAAO;AAClB,iBAAW,OAAO;AAAA,IACnB;AAAA,EACD,WAAY,SAAS,OAAO,UAAW,KAAM,GAAI;AAChD,eAAW,KAAK;AAAA,EACjB,WAAY,gBAAgB,IAAK;AAEhC,eAAW,OAAO;AAClB,eAAW,OAAO;AAAA,EACnB;AAEA,gBAAe,UAAW;AAS1B,QAAM,UAAU,QAAQ,aAAa,WAAW,KAAK,gBAAgB;AACrE,QAAM,YACL,UAAU,aAAa,WAAW,OAAO,gBAAgB;AAE1D,SAAO;AAAA,IACN,cAAc,CAAC,CAAE,WAAW,cAAc;AAAA,IAC1C;AAAA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/use-link-preview.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useRemoteUrlData, isHashLink, isRelativePath } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Capitalize the first letter of a string.\n *\n * @param {string} str - The string to capitalize\n * @return {string} Capitalized string\n */\nfunction capitalize( str ) {\n\treturn str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n}\n\n/**\n * Check if a URL points to the site homepage.\n * Handles protocol (http/https) and trailing slash variations.\n * Does not match subdomains unless they are the site URL.\n *\n * @param {string} url - The URL to check\n * @param {string} homeUrl - The WordPress site URL\n * @return {boolean} True if url is the homepage\n */\nexport function isHomepage( url, homeUrl ) {\n\tif ( url === '/' ) {\n\t\treturn true;\n\t}\n\tif ( ! url || ! homeUrl ) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tconst urlParsed = new URL( url, homeUrl );\n\t\tconst homeParsed = new URL( homeUrl );\n\n\t\t// Same host, i.e. sub.homepage.com or homepage.com\n\t\tif ( urlParsed.hostname !== homeParsed.hostname ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Path must match site root (normalize trailing slash)\n\t\tconst urlPath = urlParsed.pathname.replace( /\\/$/, '' );\n\t\tconst homePath = homeParsed.pathname.replace( /\\/$/, '' );\n\n\t\treturn urlPath === homePath;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Compute display URL - strips site URL if internal, shows full URL if external.\n *\n * @param {Object} options - Parameters object\n * @param {string} options.linkUrl - The URL to process\n * @param {string} options.homeUrl - The WordPress site URL (required for internal/external detection)\n * @return {Object} Object with displayUrl and isExternal flag\n */\nexport function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {\n\tif ( ! linkUrl ) {\n\t\treturn { displayUrl: '', isExternal: false };\n\t}\n\n\tlet displayUrl = safeDecodeURI( linkUrl );\n\tlet isExternal = false;\n\n\t// Check hash links and relative paths first - these are always internal\n\tif ( isRelativePath( linkUrl ) || isHashLink( linkUrl ) ) {\n\t\treturn { displayUrl, isExternal: false };\n\t}\n\n\t// Try to parse as a full URL to determine if it's actually external\n\t// This must happen before trusting the type attribute\n\ttry {\n\t\tconst parsedUrl = new URL( linkUrl );\n\t\t// Compare by host (not origin) so http/https to same site both count as internal\n\t\tconst siteHost = new URL( homeUrl ).host;\n\n\t\tif ( parsedUrl.host === siteHost ) {\n\t\t\t// Show only the pathname (and search/hash if present)\n\t\t\tlet path = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;\n\t\t\t// Remove trailing slash\n\t\t\tif ( path.endsWith( '/' ) && path.length > 1 ) {\n\t\t\t\tpath = path.slice( 0, -1 );\n\t\t\t}\n\t\t\tdisplayUrl = path;\n\t\t} else {\n\t\t\t// Different host - this is an external link\n\t\t\tisExternal = true;\n\t\t}\n\t} catch
|
|
5
|
-
"mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,8BAA8B;AACtD,SAAS,iBAAiB;AAC1B,SAAS,SAAS,qBAAqB;AAKvC,SAAS,cAAc;AAEvB,IAAM,EAAE,kBAAkB,YAAY,eAAe,IAAI;AAAA,EACxD;AACD;AAQA,SAAS,WAAY,KAAM;AAC1B,SAAO,IAAI,OAAQ,CAAE,EAAE,YAAY,IAAI,IAAI,MAAO,CAAE;AACrD;AAWO,SAAS,WAAY,KAAK,SAAU;AAC1C,MAAK,QAAQ,KAAM;AAClB,WAAO;AAAA,EACR;AACA,MAAK,CAAE,OAAO,CAAE,SAAU;AACzB,WAAO;AAAA,EACR;AACA,MAAI;AACH,UAAM,YAAY,IAAI,IAAK,KAAK,OAAQ;AACxC,UAAM,aAAa,IAAI,IAAK,OAAQ;AAGpC,QAAK,UAAU,aAAa,WAAW,UAAW;AACjD,aAAO;AAAA,IACR;AAGA,UAAM,UAAU,UAAU,SAAS,QAAS,OAAO,EAAG;AACtD,UAAM,WAAW,WAAW,SAAS,QAAS,OAAO,EAAG;AAExD,WAAO,YAAY;AAAA,EACpB,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAUO,SAAS,kBAAmB,EAAE,SAAS,QAAQ,IAAI,CAAC,GAAI;AAC9D,MAAK,CAAE,SAAU;AAChB,WAAO,EAAE,YAAY,IAAI,YAAY,MAAM;AAAA,EAC5C;AAEA,MAAI,aAAa,cAAe,OAAQ;AACxC,MAAI,aAAa;AAGjB,MAAK,eAAgB,OAAQ,KAAK,WAAY,OAAQ,GAAI;AACzD,WAAO,EAAE,YAAY,YAAY,MAAM;AAAA,EACxC;AAIA,MAAI;AACH,UAAM,YAAY,IAAI,IAAK,OAAQ;AAEnC,UAAM,WAAW,IAAI,IAAK,OAAQ,EAAE;AAEpC,QAAK,UAAU,SAAS,UAAW;AAElC,UAAI,OAAO,UAAU,WAAW,UAAU,SAAS,UAAU;AAE7D,UAAK,KAAK,SAAU,GAAI,KAAK,KAAK,SAAS,GAAI;AAC9C,eAAO,KAAK,MAAO,GAAG,EAAG;AAAA,MAC1B;AACA,mBAAa;AAAA,IACd,OAAO;AAEN,mBAAa;AAAA,IACd;AAAA,EACD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useRemoteUrlData, isHashLink, isRelativePath } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Capitalize the first letter of a string.\n *\n * @param {string} str - The string to capitalize\n * @return {string} Capitalized string\n */\nfunction capitalize( str ) {\n\treturn str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n}\n\n/**\n * Check if a URL points to the site homepage.\n * Handles protocol (http/https) and trailing slash variations.\n * Does not match subdomains unless they are the site URL.\n *\n * @param {string} url - The URL to check\n * @param {string} homeUrl - The WordPress site URL\n * @return {boolean} True if url is the homepage\n */\nexport function isHomepage( url, homeUrl ) {\n\tif ( url === '/' ) {\n\t\treturn true;\n\t}\n\tif ( ! url || ! homeUrl ) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tconst urlParsed = new URL( url, homeUrl );\n\t\tconst homeParsed = new URL( homeUrl );\n\n\t\t// Same host, i.e. sub.homepage.com or homepage.com\n\t\tif ( urlParsed.hostname !== homeParsed.hostname ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Path must match site root (normalize trailing slash)\n\t\tconst urlPath = urlParsed.pathname.replace( /\\/$/, '' );\n\t\tconst homePath = homeParsed.pathname.replace( /\\/$/, '' );\n\n\t\treturn urlPath === homePath;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Compute display URL - strips site URL if internal, shows full URL if external.\n *\n * @param {Object} options - Parameters object\n * @param {string} options.linkUrl - The URL to process\n * @param {string} options.homeUrl - The WordPress site URL (required for internal/external detection)\n * @return {Object} Object with displayUrl and isExternal flag\n */\nexport function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {\n\tif ( ! linkUrl ) {\n\t\treturn { displayUrl: '', isExternal: false };\n\t}\n\n\tlet displayUrl = safeDecodeURI( linkUrl );\n\tlet isExternal = false;\n\n\t// Check hash links and relative paths first - these are always internal\n\tif ( isRelativePath( linkUrl ) || isHashLink( linkUrl ) ) {\n\t\treturn { displayUrl, isExternal: false };\n\t}\n\n\t// Try to parse as a full URL to determine if it's actually external\n\t// This must happen before trusting the type attribute\n\ttry {\n\t\tconst parsedUrl = new URL( linkUrl );\n\t\t// Compare by host (not origin) so http/https to same site both count as internal\n\t\tconst siteHost = new URL( homeUrl ).host;\n\n\t\tif ( parsedUrl.host === siteHost ) {\n\t\t\t// Show only the pathname (and search/hash if present)\n\t\t\tlet path = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;\n\t\t\t// Remove trailing slash\n\t\t\tif ( path.endsWith( '/' ) && path.length > 1 ) {\n\t\t\t\tpath = path.slice( 0, -1 );\n\t\t\t}\n\t\t\tdisplayUrl = path;\n\t\t} else {\n\t\t\t// Different host - this is an external link\n\t\t\tisExternal = true;\n\t\t}\n\t} catch {\n\t\t// URL parsing failed - treat as external (e.g. no homeUrl, or URL without protocol)\n\t\tisExternal = true;\n\t}\n\n\treturn { displayUrl, isExternal };\n}\n\n/**\n * Compute badges for the link preview.\n *\n * @param {Object} options - Options object\n * @param {string} options.url - Link URL\n * @param {string} options.homeUrl - WordPress site URL (for homepage detection)\n * @param {string} options.type - Entity type (page, post, etc.)\n * @param {boolean} options.isExternal - Whether link is external\n * @param {string} options.entityStatus - Entity status (publish, draft, etc.)\n * @param {boolean} options.hasBinding - Whether link has entity binding\n * @param {boolean} options.isEntityAvailable - Whether bound entity exists\n * @return {Array} Array of badge objects with label and intent\n */\nexport function computeBadges( {\n\turl,\n\thomeUrl,\n\ttype,\n\tisExternal,\n\tentityStatus,\n\thasBinding,\n\tisEntityAvailable,\n} ) {\n\tconst badges = [];\n\t// Kind badge\n\tif ( url ) {\n\t\tif ( isExternal ) {\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'External link' ),\n\t\t\t\tintent: 'default',\n\t\t\t} );\n\t\t} else if ( isHashLink( url ) ) {\n\t\t\t// Hash links should be detected before type check\n\t\t\t// because they're not entity links even if type is set\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'Internal link' ),\n\t\t\t\tintent: 'default',\n\t\t\t} );\n\t\t} else if ( isHomepage( url, homeUrl ) ) {\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'Homepage' ),\n\t\t\t\tintent: 'default',\n\t\t\t} );\n\t\t} else if ( type && type !== 'custom' ) {\n\t\t\t// Show entity type badge (page, post, category, etc.)\n\t\t\t// but not 'custom' since that's just a manual link\n\t\t\tbadges.push( { label: capitalize( type ), intent: 'default' } );\n\t\t} else {\n\t\t\t// Internal link (not external, not hash, not entity)\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'Page' ),\n\t\t\t\tintent: 'default',\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Status badge\n\tif ( hasBinding && ! isEntityAvailable ) {\n\t\tbadges.push( {\n\t\t\tlabel: sprintf(\n\t\t\t\t/* translators: %s is the entity type (e.g., \"page\", \"post\", \"category\") */\n\t\t\t\t__( 'Missing %s' ),\n\t\t\t\ttype\n\t\t\t),\n\t\t\tintent: 'error',\n\t\t} );\n\t} else if ( ! url ) {\n\t\tbadges.push( { label: __( 'No link selected' ), intent: 'error' } );\n\t} else if ( entityStatus ) {\n\t\tconst statusMap = {\n\t\t\tpublish: { label: __( 'Published' ), intent: 'success' },\n\t\t\tfuture: { label: __( 'Scheduled' ), intent: 'warning' },\n\t\t\tdraft: { label: __( 'Draft' ), intent: 'warning' },\n\t\t\tpending: { label: __( 'Pending' ), intent: 'warning' },\n\t\t\tprivate: { label: __( 'Private' ), intent: 'default' },\n\t\t\ttrash: { label: __( 'Trash' ), intent: 'error' },\n\t\t};\n\t\tconst badge = statusMap[ entityStatus ];\n\t\tif ( badge ) {\n\t\t\tbadges.push( badge );\n\t\t}\n\t}\n\n\treturn badges;\n}\n\n/**\n * Hook to compute link preview data for display.\n *\n * This hook takes raw link data and entity information and computes\n * presentation-ready preview data including formatted title, URL, and badges.\n *\n * @param {Object} options - Options object\n * @param {string} options.url - Link URL\n * @param {string} options.type - Entity type (page, post, etc.)\n * @param {Object} options.entityRecord - Entity record\n * @param {boolean} options.hasBinding - Whether link has entity binding\n * @param {boolean} options.isEntityAvailable - Whether bound entity exists\n * @return {Object} Preview data object with title, url, image, and badges\n */\nexport function useLinkPreview( {\n\turl,\n\tentityRecord,\n\ttype,\n\thasBinding,\n\tisEntityAvailable,\n} ) {\n\t// Get the WordPress homepage URL from settings\n\tconst homeUrl = useSelect( ( select ) => {\n\t\treturn select( coreDataStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t)?.home;\n\t}, [] );\n\n\tconst title =\n\t\tentityRecord?.title?.rendered ||\n\t\tentityRecord?.title ||\n\t\tentityRecord?.name;\n\n\t// Fetch rich URL data if we don't have a title. Internal links should have passed a title.\n\tconst { richData } = useRemoteUrlData( title ? null : url );\n\n\t// Compute display URL and external flag\n\tconst { displayUrl, isExternal } = computeDisplayUrl( {\n\t\tlinkUrl: url,\n\t\thomeUrl,\n\t} );\n\n\tconst image = useSelect(\n\t\t( select ) => {\n\t\t\t// Only fetch for post-type entities with featured media\n\t\t\tif ( ! entityRecord?.featured_media ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst { getEntityRecord } = select( coreDataStore );\n\n\t\t\t// Get the media entity to fetch the image URL\n\t\t\tconst media = getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tentityRecord.featured_media\n\t\t\t);\n\n\t\t\t// Return the thumbnail or medium size URL, fallback to source_url\n\t\t\treturn (\n\t\t\t\tmedia?.media_details?.sizes?.thumbnail?.source_url ||\n\t\t\t\tmedia?.media_details?.sizes?.medium?.source_url ||\n\t\t\t\tmedia?.source_url ||\n\t\t\t\tnull\n\t\t\t);\n\t\t},\n\t\t[ entityRecord?.featured_media ]\n\t);\n\n\t// Compute badges\n\tconst badges = computeBadges( {\n\t\turl,\n\t\thomeUrl,\n\t\ttype,\n\t\tisExternal,\n\t\tentityStatus: entityRecord?.status,\n\t\thasBinding,\n\t\tisEntityAvailable,\n\t} );\n\n\t// Get display title - use provided title, fallback to rich data, or URL\n\tconst displayTitle = url\n\t\t? title || richData?.title || safeDecodeURI( url )\n\t\t: __( 'Add link' );\n\n\treturn {\n\t\ttitle: displayTitle,\n\t\turl: displayUrl,\n\t\timage,\n\t\tbadges,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,eAAe,8BAA8B;AACtD,SAAS,iBAAiB;AAC1B,SAAS,SAAS,qBAAqB;AAKvC,SAAS,cAAc;A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,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,EACD,CAAE;AAGF,QAAM,eAAe,MAClB,SAAS,UAAU,SAAS,cAAe,GAAI,IAC/C,GAAI,UAAW;AAElB,SAAO;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/pattern/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tWarning,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useParsePatternDependencies } from './recursion-detector';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst registry = useRegistry();\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst [ hasRecursionError, setHasRecursionError ] = useState( false );\n\tconst parsePatternDependencies = useParsePatternDependencies();\n\n\t// Duplicated in packages/editor/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( ! hasRecursionError && selectedPattern?.blocks ) {\n\t\t\ttry {\n\t\t\t\tparsePatternDependencies( selectedPattern );\n\t\t\t} catch
|
|
5
|
-
"mappings": ";AAGA,SAAS,kBAAkB;AAC3B,SAAS,WAAW,aAAa,mBAAmB;AACpD,SAAS,UAAU,iBAAiB;AACpC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,eAAe;AAK5B,SAAS,mCAAmC;AAkIxC;AAhIJ,IAAM,cAAc,CAAE,EAAE,YAAY,SAAS,MAAO;AACnD,QAAM,WAAW,YAAY;AAC7B,QAAM,kBAAkB;AAAA,IACvB,CAAE,WACD,OAAQ,gBAAiB,EAAE;AAAA,MAC1B,WAAW;AAAA,IACZ;AAAA,IACD,CAAE,WAAW,IAAK;AAAA,EACnB;AAEA,QAAM,yBAAyB;AAAA,IAC9B,CAAE,WAAY,OAAQ,SAAU,EAAE,gBAAgB,GAAG;AAAA,IACrD,CAAC;AAAA,EACF;AAEA,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,YAAa,gBAAiB;AAClC,QAAM,EAAE,sBAAsB,oBAAoB,IACjD,UAAW,gBAAiB;AAE7B,QAAM,CAAE,mBAAmB,oBAAqB,IAAI,SAAU,KAAM;AACpE,QAAM,2BAA2B,4BAA4B;AAG7D,WAAS,2CAA4C,OAAQ;AAC5D,QACC,MAAM,YAAY;AAAA,MACjB,CAAE,eAAgB,WAAW,SAAS;AAAA,IACvC,GACC;AACD,YAAM,cAAc,MAAM,YAAY,IAAK,CAAE,eAAgB;AAC5D,YACC,WAAW,SAAS,wBACpB,WAAW,WAAW,UAAU,QAC/B;AACD,qBAAW,WAAW,QAAQ;AAAA,QAC/B;AACA,eAAO;AAAA,MACR,CAAE;AAAA,IACH;AAEA,QACC,MAAM,SAAS,wBACf,MAAM,WAAW,UAAU,QAC1B;AACD,YAAM,WAAW,QAAQ;AAAA,IAC1B;AACA,WAAO;AAAA,EACR;AAMA,YAAW,MAAM;AAChB,QAAK,CAAE,qBAAqB,iBAAiB,QAAS;AACrD,UAAI;AACH,iCAA0B,eAAgB;AAAA,MAC3C,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tWarning,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useParsePatternDependencies } from './recursion-detector';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst registry = useRegistry();\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst [ hasRecursionError, setHasRecursionError ] = useState( false );\n\tconst parsePatternDependencies = useParsePatternDependencies();\n\n\t// Duplicated in packages/editor/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( ! hasRecursionError && selectedPattern?.blocks ) {\n\t\t\ttry {\n\t\t\t\tparsePatternDependencies( selectedPattern );\n\t\t\t} catch {\n\t\t\t\tsetHasRecursionError( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\t// If the pattern has a single block and categories, we should add the\n\t\t\t\t// categories of the pattern to the block's metadata.\n\t\t\t\tif (\n\t\t\t\t\tclonedBlocks.length === 1 &&\n\t\t\t\t\tselectedPattern.categories?.length > 0\n\t\t\t\t) {\n\t\t\t\t\tclonedBlocks[ 0 ].attributes = {\n\t\t\t\t\t\t...clonedBlocks[ 0 ].attributes,\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t...clonedBlocks[ 0 ].attributes.metadata,\n\t\t\t\t\t\t\tcategories: selectedPattern.categories,\n\t\t\t\t\t\t\tpatternName: selectedPattern.name,\n\t\t\t\t\t\t\tname:\n\t\t\t\t\t\t\t\tclonedBlocks[ 0 ].attributes.metadata.name ||\n\t\t\t\t\t\t\t\tselectedPattern.title,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\thasRecursionError,\n\t\tselectedPattern,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\tif ( hasRecursionError ) {\n\t\treturn (\n\t\t\t<div { ...props }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: A warning in which %s is the name of a pattern.\n\t\t\t\t\t\t__( 'Pattern \"%s\" cannot be rendered inside itself.' ),\n\t\t\t\t\t\tselectedPattern?.name\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,kBAAkB;AAC3B,SAAS,WAAW,aAAa,mBAAmB;AACpD,SAAS,UAAU,iBAAiB;AACpC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,eAAe;AAK5B,SAAS,mCAAmC;AAkIxC;AAhIJ,IAAM,cAAc,CAAE,EAAE,YAAY,SAAS,MAAO;AACnD,QAAM,WAAW,YAAY;AAC7B,QAAM,kBAAkB;AAAA,IACvB,CAAE,WACD,OAAQ,gBAAiB,EAAE;AAAA,MAC1B,WAAW;AAAA,IACZ;AAAA,IACD,CAAE,WAAW,IAAK;AAAA,EACnB;AAEA,QAAM,yBAAyB;AAAA,IAC9B,CAAE,WAAY,OAAQ,SAAU,EAAE,gBAAgB,GAAG;AAAA,IACrD,C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tC,gBAAgB;AAAA,YAClB;AAAA,UACD;AAAA,QACD;AACA,cAAM,kBAAkB,oBAAqB,YAAa;AAC1D,iBAAS,MAAO,MAAM;AAGrB,kDAAwC;AACxC,8BAAqB,cAAc,SAAU;AAC7C,kDAAwC;AACxC,wBAAe,UAAU,YAAa;AAEtC,kDAAwC;AACxC,8BAAqB,cAAc,eAAgB;AAAA,QACpD,CAAE;AAAA,MACH,CAAE;AAAA,IACH;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,QAAQ,cAAc;AAE5B,MAAK,mBAAoB;AACxB,WACC,oBAAC,SAAM,GAAG,OACT,8BAAC,WACE;AAAA;AAAA,MAED,GAAI,gDAAiD;AAAA,MACrD,iBAAiB;AAAA,IAClB,GACD,GACD;AAAA,EAEF;AAEA,SAAO,oBAAC,SAAM,GAAG,OAAQ;AAC1B;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -57,7 +57,6 @@ function SearchEdit({
|
|
|
57
57
|
buttonText,
|
|
58
58
|
buttonPosition,
|
|
59
59
|
buttonUseIcon,
|
|
60
|
-
isSearchFieldHidden,
|
|
61
60
|
style
|
|
62
61
|
} = attributes;
|
|
63
62
|
const wasJustInsertedIntoNavigationBlock = useSelect(
|
|
@@ -112,27 +111,13 @@ function SearchEdit({
|
|
|
112
111
|
const isButtonPositionOutside = "button-outside" === buttonPosition;
|
|
113
112
|
const hasNoButton = "no-button" === buttonPosition;
|
|
114
113
|
const hasOnlyButton = "button-only" === buttonPosition;
|
|
114
|
+
const isSearchFieldHidden = hasOnlyButton && !isSelected;
|
|
115
115
|
const searchFieldRef = useRef();
|
|
116
116
|
const buttonRef = useRef();
|
|
117
117
|
const units = useCustomUnits({
|
|
118
118
|
availableUnits: ["%", "px"],
|
|
119
119
|
defaultValues: { "%": PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT }
|
|
120
120
|
});
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
if (hasOnlyButton && !isSelected) {
|
|
123
|
-
setAttributes({
|
|
124
|
-
isSearchFieldHidden: true
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}, [hasOnlyButton, isSelected, setAttributes]);
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
if (!hasOnlyButton || !isSelected) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
setAttributes({
|
|
133
|
-
isSearchFieldHidden: false
|
|
134
|
-
});
|
|
135
|
-
}, [hasOnlyButton, isSelected, setAttributes, width]);
|
|
136
121
|
const getBlockClassNames = () => {
|
|
137
122
|
return clsx(
|
|
138
123
|
className,
|
|
@@ -142,7 +127,7 @@ function SearchEdit({
|
|
|
142
127
|
hasOnlyButton ? "wp-block-search__button-only" : void 0,
|
|
143
128
|
!buttonUseIcon && !hasNoButton ? "wp-block-search__text-button" : void 0,
|
|
144
129
|
buttonUseIcon && !hasNoButton ? "wp-block-search__icon-button" : void 0,
|
|
145
|
-
|
|
130
|
+
isSearchFieldHidden ? "wp-block-search__searchfield-hidden" : void 0
|
|
146
131
|
);
|
|
147
132
|
};
|
|
148
133
|
const buttonPositionControls = [
|
|
@@ -223,13 +208,6 @@ function SearchEdit({
|
|
|
223
208
|
borderBottomRightRadius: borderProps.style?.borderBottomRightRadius
|
|
224
209
|
} : borderProps.style
|
|
225
210
|
};
|
|
226
|
-
const handleButtonClick = () => {
|
|
227
|
-
if (hasOnlyButton) {
|
|
228
|
-
setAttributes({
|
|
229
|
-
isSearchFieldHidden: !isSearchFieldHidden
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
211
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
234
212
|
buttonUseIcon && /* @__PURE__ */ jsx(
|
|
235
213
|
"button",
|
|
@@ -238,7 +216,6 @@ function SearchEdit({
|
|
|
238
216
|
className: buttonClasses,
|
|
239
217
|
style: buttonStyles,
|
|
240
218
|
"aria-label": buttonText ? stripHTML(buttonText) : __("Search"),
|
|
241
|
-
onClick: handleButtonClick,
|
|
242
219
|
ref: buttonRef,
|
|
243
220
|
children: /* @__PURE__ */ jsx(Icon, { icon: search })
|
|
244
221
|
}
|
|
@@ -253,8 +230,7 @@ function SearchEdit({
|
|
|
253
230
|
placeholder: __("Add button text\u2026"),
|
|
254
231
|
withoutInteractiveFormatting: true,
|
|
255
232
|
value: buttonText,
|
|
256
|
-
onChange: (html) => setAttributes({ buttonText: html })
|
|
257
|
-
onClick: handleButtonClick
|
|
233
|
+
onChange: (html) => setAttributes({ buttonText: html })
|
|
258
234
|
}
|
|
259
235
|
)
|
|
260
236
|
] });
|
|
@@ -270,8 +246,7 @@ function SearchEdit({
|
|
|
270
246
|
widthUnit: void 0,
|
|
271
247
|
showLabel: true,
|
|
272
248
|
buttonUseIcon: false,
|
|
273
|
-
buttonPosition: "button-outside"
|
|
274
|
-
isSearchFieldHidden: false
|
|
249
|
+
buttonPosition: "button-outside"
|
|
275
250
|
});
|
|
276
251
|
},
|
|
277
252
|
dropdownMenuProps,
|
|
@@ -306,8 +281,7 @@ function SearchEdit({
|
|
|
306
281
|
label: __("Button position"),
|
|
307
282
|
onDeselect: () => {
|
|
308
283
|
setAttributes({
|
|
309
|
-
buttonPosition: "button-outside"
|
|
310
|
-
isSearchFieldHidden: false
|
|
284
|
+
buttonPosition: "button-outside"
|
|
311
285
|
});
|
|
312
286
|
},
|
|
313
287
|
isShownByDefault: true,
|
|
@@ -319,8 +293,7 @@ function SearchEdit({
|
|
|
319
293
|
label: __("Button position"),
|
|
320
294
|
onChange: (value) => {
|
|
321
295
|
setAttributes({
|
|
322
|
-
buttonPosition: value
|
|
323
|
-
isSearchFieldHidden: value === "button-only"
|
|
296
|
+
buttonPosition: value
|
|
324
297
|
});
|
|
325
298
|
},
|
|
326
299
|
options: buttonPositionControls
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/search/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tInspectorControls,\n\tRichText,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n\tuseSettings,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tSelectControl,\n\tToggleControl,\n\tResizableBox,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { Icon, search } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport {\n\tPC_WIDTH_DEFAULT,\n\tPX_WIDTH_DEFAULT,\n\tMIN_WIDTH,\n\tisPercentageUnit,\n} from './utils.js';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n// Used to calculate border radius adjustment to avoid \"fat\" corners when\n// button is placed inside wrapper.\nconst DEFAULT_INNER_PADDING = '4px';\nconst PERCENTAGE_WIDTHS = [ 25, 50, 75, 100 ];\n\nexport default function SearchEdit( {\n\tclassName,\n\tattributes,\n\tsetAttributes,\n\ttoggleSelection,\n\tisSelected,\n\tclientId,\n} ) {\n\tconst {\n\t\tlabel,\n\t\tshowLabel,\n\t\tplaceholder,\n\t\twidth,\n\t\twidthUnit,\n\t\talign,\n\t\tbuttonText,\n\t\tbuttonPosition,\n\t\tbuttonUseIcon,\n\t\tisSearchFieldHidden,\n\t\tstyle,\n\t} = attributes;\n\n\tconst wasJustInsertedIntoNavigationBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParentsByBlockName, wasBlockJustInserted } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\t!! getBlockParentsByBlockName( clientId, 'core/navigation' )\n\t\t\t\t\t?.length && wasBlockJustInserted( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( wasJustInsertedIntoNavigationBlock ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tshowLabel: false,\n\t\t\t\tbuttonUseIcon: true,\n\t\t\t\tbuttonPosition: 'button-inside',\n\t\t\t} );\n\t\t}\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\twasJustInsertedIntoNavigationBlock,\n\t\tsetAttributes,\n\t] );\n\n\tconst borderRadius = style?.border?.radius;\n\tlet borderProps = useBorderProps( attributes );\n\n\t// Check for old deprecated numerical border radius. Done as a separate\n\t// check so that a borderRadius style won't overwrite the longhand\n\t// per-corner styles.\n\tif ( typeof borderRadius === 'number' ) {\n\t\tborderProps = {\n\t\t\t...borderProps,\n\t\t\tstyle: {\n\t\t\t\t...borderProps.style,\n\t\t\t\tborderRadius: `${ borderRadius }px`,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst colorProps = useColorProps( attributes );\n\tconst [ fluidTypographySettings, layout ] = useSettings(\n\t\t'typography.fluid',\n\t\t'layout'\n\t);\n\tconst typographyProps = useTypographyProps( attributes, {\n\t\ttypography: {\n\t\t\tfluid: fluidTypographySettings,\n\t\t},\n\t\tlayout: {\n\t\t\twideSize: layout?.wideSize,\n\t\t},\n\t} );\n\tconst unitControlInstanceId = useInstanceId( UnitControl );\n\tconst unitControlInputId = `wp-block-search__width-${ unitControlInstanceId }`;\n\tconst isButtonPositionInside = 'button-inside' === buttonPosition;\n\tconst isButtonPositionOutside = 'button-outside' === buttonPosition;\n\tconst hasNoButton = 'no-button' === buttonPosition;\n\tconst hasOnlyButton = 'button-only' === buttonPosition;\n\tconst searchFieldRef = useRef();\n\tconst buttonRef = useRef();\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: [ '%', 'px' ],\n\t\tdefaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( hasOnlyButton && ! isSelected ) {\n\t\t\tsetAttributes( {\n\t\t\t\tisSearchFieldHidden: true,\n\t\t\t} );\n\t\t}\n\t}, [ hasOnlyButton, isSelected, setAttributes ] );\n\n\t// Show the search field when width changes.\n\tuseEffect( () => {\n\t\tif ( ! hasOnlyButton || ! isSelected ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tisSearchFieldHidden: false,\n\t\t} );\n\t}, [ hasOnlyButton, isSelected, setAttributes, width ] );\n\n\tconst getBlockClassNames = () => {\n\t\treturn clsx(\n\t\t\tclassName,\n\t\t\tisButtonPositionInside\n\t\t\t\t? 'wp-block-search__button-inside'\n\t\t\t\t: undefined,\n\t\t\tisButtonPositionOutside\n\t\t\t\t? 'wp-block-search__button-outside'\n\t\t\t\t: undefined,\n\t\t\thasNoButton ? 'wp-block-search__no-button' : undefined,\n\t\t\thasOnlyButton ? 'wp-block-search__button-only' : undefined,\n\t\t\t! buttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__text-button'\n\t\t\t\t: undefined,\n\t\t\tbuttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__icon-button'\n\t\t\t\t: undefined,\n\t\t\thasOnlyButton && isSearchFieldHidden\n\t\t\t\t? 'wp-block-search__searchfield-hidden'\n\t\t\t\t: undefined\n\t\t);\n\t};\n\n\tconst buttonPositionControls = [\n\t\t{\n\t\t\tlabel: __( 'Button outside' ),\n\t\t\tvalue: 'button-outside',\n\t\t},\n\t\t{\n\t\t\tlabel: __( 'Button inside' ),\n\t\t\tvalue: 'button-inside',\n\t\t},\n\t\t{\n\t\t\tlabel: __( 'No button' ),\n\t\t\tvalue: 'no-button',\n\t\t},\n\t\t{\n\t\t\tlabel: __( 'Button only' ),\n\t\t\tvalue: 'button-only',\n\t\t},\n\t];\n\n\tconst getResizableSides = () => {\n\t\tif ( hasOnlyButton ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tright: align !== 'right',\n\t\t\tleft: align === 'right',\n\t\t};\n\t};\n\n\tconst renderTextField = () => {\n\t\t// If the input is inside the wrapper, the wrapper gets the border color styles/classes, not the input control.\n\t\tconst textFieldClasses = clsx(\n\t\t\t'wp-block-search__input',\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\ttypographyProps.className\n\t\t);\n\t\tconst textFieldStyles = {\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? {\n\t\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\t\tborderTopLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopLeftRadius,\n\t\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t\t }\n\t\t\t\t: borderProps.style ),\n\t\t\t...typographyProps.style,\n\t\t\ttextDecoration: undefined,\n\t\t};\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\ttype=\"search\"\n\t\t\t\tclassName={ textFieldClasses }\n\t\t\t\tstyle={ textFieldStyles }\n\t\t\t\taria-label={ __( 'Optional placeholder text' ) }\n\t\t\t\t// We hide the placeholder field's placeholder when there is a value. This\n\t\t\t\t// stops screen readers from reading the placeholder field's placeholder\n\t\t\t\t// which is confusing.\n\t\t\t\tplaceholder={\n\t\t\t\t\tplaceholder ? undefined : __( 'Optional placeholder\u2026' )\n\t\t\t\t}\n\t\t\t\tvalue={ placeholder }\n\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\tsetAttributes( { placeholder: event.target.value } )\n\t\t\t\t}\n\t\t\t\tref={ searchFieldRef }\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderButton = () => {\n\t\t// If the button is inside the wrapper, the wrapper gets the border color styles/classes, not the button.\n\t\tconst buttonClasses = clsx(\n\t\t\t'wp-block-search__button',\n\t\t\tcolorProps.className,\n\t\t\ttypographyProps.className,\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\tbuttonUseIcon ? 'has-icon' : undefined,\n\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t);\n\t\tconst buttonStyles = {\n\t\t\t...colorProps.style,\n\t\t\t...typographyProps.style,\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? {\n\t\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\t\tborderTopLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopLeftRadius,\n\t\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t\t }\n\t\t\t\t: borderProps.style ),\n\t\t};\n\t\tconst handleButtonClick = () => {\n\t\t\tif ( hasOnlyButton ) {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tisSearchFieldHidden: ! isSearchFieldHidden,\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{ buttonUseIcon && (\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\tbuttonText\n\t\t\t\t\t\t\t\t? stripHTML( buttonText )\n\t\t\t\t\t\t\t\t: __( 'Search' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClick={ handleButtonClick }\n\t\t\t\t\t\tref={ buttonRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\n\t\t\t\t{ ! buttonUseIcon && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"buttonText\"\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add button text\u2026' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ buttonText }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { buttonText: html } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClick={ handleButtonClick }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst controls = (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\twidthUnit: undefined,\n\t\t\t\t\t\t\tshowLabel: true,\n\t\t\t\t\t\t\tbuttonUseIcon: false,\n\t\t\t\t\t\t\tbuttonPosition: 'button-outside',\n\t\t\t\t\t\t\tisSearchFieldHidden: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowLabel: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowLabel: value,\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</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => buttonPosition !== 'button-outside' }\n\t\t\t\t\t\tlabel={ __( 'Button position' ) }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tbuttonPosition: 'button-outside',\n\t\t\t\t\t\t\t\tisSearchFieldHidden: false,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tvalue={ buttonPosition }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Button position' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tbuttonPosition: value,\n\t\t\t\t\t\t\t\t\tisSearchFieldHidden:\n\t\t\t\t\t\t\t\t\t\tvalue === 'button-only',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\toptions={ buttonPositionControls }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ buttonPosition !== 'no-button' && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! buttonUseIcon }\n\t\t\t\t\t\t\tlabel={ __( 'Use button with icon' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tbuttonUseIcon: false,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tchecked={ buttonUseIcon }\n\t\t\t\t\t\t\t\tlabel={ __( 'Use button with icon' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tbuttonUseIcon: value,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! width }\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\t\twidthUnit: undefined,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<VStack>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\t\t\tid={ unitControlInputId } // Unused, kept for backwards compatibility\n\t\t\t\t\t\t\t\tmin={\n\t\t\t\t\t\t\t\t\tisPercentageUnit( widthUnit )\n\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t: MIN_WIDTH\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\t\tisPercentageUnit( widthUnit )\n\t\t\t\t\t\t\t\t\t\t? 100\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\t\t\tconst parsedNewWidth =\n\t\t\t\t\t\t\t\t\t\tnewWidth === ''\n\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t: parseInt( newWidth, 10 );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\twidth: parsedNewWidth,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonUnitChange={ ( newUnit ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\t'%' === newUnit\n\t\t\t\t\t\t\t\t\t\t\t\t? PC_WIDTH_DEFAULT\n\t\t\t\t\t\t\t\t\t\t\t\t: PX_WIDTH_DEFAULT,\n\t\t\t\t\t\t\t\t\t\twidthUnit: newUnit,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\tvalue={ `${ width }${ widthUnit }` }\n\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Percentage Width' ) }\n\t\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\t\tPERCENTAGE_WIDTHS.includes( width ) &&\n\t\t\t\t\t\t\t\t\twidthUnit === '%'\n\t\t\t\t\t\t\t\t\t\t? width\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\t\t\t\twidthUnit: '%',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ PERCENTAGE_WIDTHS.map( ( widthValue ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ widthValue }\n\t\t\t\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %d: Percentage value. */\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%d%%' ),\n\t\t\t\t\t\t\t\t\t\t\t\twidthValue\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);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst isNonZeroBorderRadius = ( radius ) =>\n\t\tradius !== undefined && parseInt( radius, 10 ) !== 0;\n\n\tconst padBorderRadius = ( radius ) =>\n\t\tisNonZeroBorderRadius( radius )\n\t\t\t? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`\n\t\t\t: undefined;\n\n\tconst getWrapperStyles = () => {\n\t\tconst styles = isButtonPositionInside\n\t\t\t? borderProps.style\n\t\t\t: {\n\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\tborderTopLeftRadius: borderProps.style?.borderTopLeftRadius,\n\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t };\n\n\t\tif ( isButtonPositionInside ) {\n\t\t\t// We have button inside wrapper and a border radius value to apply.\n\t\t\t// Add default padding so we don't get \"fat\" corners.\n\t\t\t//\n\t\t\t// CSS calc() is used here to support non-pixel units. The inline\n\t\t\t// style using calc() will only apply if both values have units.\n\n\t\t\tif ( typeof borderRadius === 'object' ) {\n\t\t\t\t// Individual corner border radii present.\n\t\t\t\tconst {\n\t\t\t\t\tborderTopLeftRadius,\n\t\t\t\t\tborderTopRightRadius,\n\t\t\t\t\tborderBottomLeftRadius,\n\t\t\t\t\tborderBottomRightRadius,\n\t\t\t\t} = borderProps.style;\n\n\t\t\t\treturn {\n\t\t\t\t\t...styles,\n\t\t\t\t\tborderTopLeftRadius: padBorderRadius( borderTopLeftRadius ),\n\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\tpadBorderRadius( borderTopRightRadius ),\n\t\t\t\t\tborderBottomLeftRadius: padBorderRadius(\n\t\t\t\t\t\tborderBottomLeftRadius\n\t\t\t\t\t),\n\t\t\t\t\tborderBottomRightRadius: padBorderRadius(\n\t\t\t\t\t\tborderBottomRightRadius\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// The inline style using calc() will only apply if both values\n\t\t\t// supplied to calc() have units. Deprecated block's may have\n\t\t\t// unitless integer.\n\t\t\tconst radius = Number.isInteger( borderRadius )\n\t\t\t\t? `${ borderRadius }px`\n\t\t\t\t: borderRadius;\n\n\t\t\tstyles.borderRadius = `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`;\n\t\t}\n\n\t\treturn styles;\n\t};\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: getBlockClassNames(),\n\t\tstyle: {\n\t\t\t...typographyProps.style,\n\t\t\t// Input opts out of text decoration.\n\t\t\ttextDecoration: undefined,\n\t\t},\n\t} );\n\n\tconst labelClassnames = clsx(\n\t\t'wp-block-search__label',\n\t\ttypographyProps.className\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ controls }\n\n\t\t\t{ showLabel && (\n\t\t\t\t<RichText\n\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\tclassName={ labelClassnames }\n\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add label\u2026' ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tvalue={ label }\n\t\t\t\t\tonChange={ ( html ) => setAttributes( { label: html } ) }\n\t\t\t\t\tstyle={ typographyProps.style }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\twidth === undefined\n\t\t\t\t\t\t\t? 'auto'\n\t\t\t\t\t\t\t: `${ width }${ widthUnit }`,\n\t\t\t\t\theight: 'auto',\n\t\t\t\t} }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-block-search__inside-wrapper',\n\t\t\t\t\tisButtonPositionInside ? borderProps.className : undefined\n\t\t\t\t) }\n\t\t\t\tstyle={ getWrapperStyles() }\n\t\t\t\tminWidth={ MIN_WIDTH }\n\t\t\t\tenable={ getResizableSides() }\n\t\t\t\tonResizeStart={ ( event, direction, elt ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( elt.offsetWidth, 10 ),\n\t\t\t\t\t\twidthUnit: 'px',\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t>\n\t\t\t\t{ ( isButtonPositionInside ||\n\t\t\t\t\tisButtonPositionOutside ||\n\t\t\t\t\thasOnlyButton ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ renderTextField() }\n\t\t\t\t\t\t{ renderButton() }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t{ hasNoButton && renderTextField() }\n\t\t\t</ResizableBox>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,EAChC,+BAA+B;AAAA,EAC/B,iCAAiC;AAAA,EACjC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,WAAW,cAAc;AAClC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,EAChC,6BAA6B;AAAA,EAC7B,oCAAoC;AAAA,EACpC,0CAA0C;AAAA,EAC1C,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC,wBAAwB;AAAA,OAClB;AACP,SAAS,qBAAqB;AAC9B,SAAS,MAAM,cAAc;AAC7B,SAAS,IAAI,eAAe;AAC5B,SAAS,uBAAuB,iBAAiB;AAKjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sCAAsC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tInspectorControls,\n\tRichText,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n\tuseSettings,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tSelectControl,\n\tToggleControl,\n\tResizableBox,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { Icon, search } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport {\n\tPC_WIDTH_DEFAULT,\n\tPX_WIDTH_DEFAULT,\n\tMIN_WIDTH,\n\tisPercentageUnit,\n} from './utils.js';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n// Used to calculate border radius adjustment to avoid \"fat\" corners when\n// button is placed inside wrapper.\nconst DEFAULT_INNER_PADDING = '4px';\nconst PERCENTAGE_WIDTHS = [ 25, 50, 75, 100 ];\n\nexport default function SearchEdit( {\n\tclassName,\n\tattributes,\n\tsetAttributes,\n\ttoggleSelection,\n\tisSelected,\n\tclientId,\n} ) {\n\tconst {\n\t\tlabel,\n\t\tshowLabel,\n\t\tplaceholder,\n\t\twidth,\n\t\twidthUnit,\n\t\talign,\n\t\tbuttonText,\n\t\tbuttonPosition,\n\t\tbuttonUseIcon,\n\t\tstyle,\n\t} = attributes;\n\n\tconst wasJustInsertedIntoNavigationBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParentsByBlockName, wasBlockJustInserted } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\t!! getBlockParentsByBlockName( clientId, 'core/navigation' )\n\t\t\t\t\t?.length && wasBlockJustInserted( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( wasJustInsertedIntoNavigationBlock ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tshowLabel: false,\n\t\t\t\tbuttonUseIcon: true,\n\t\t\t\tbuttonPosition: 'button-inside',\n\t\t\t} );\n\t\t}\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\twasJustInsertedIntoNavigationBlock,\n\t\tsetAttributes,\n\t] );\n\n\tconst borderRadius = style?.border?.radius;\n\tlet borderProps = useBorderProps( attributes );\n\n\t// Check for old deprecated numerical border radius. Done as a separate\n\t// check so that a borderRadius style won't overwrite the longhand\n\t// per-corner styles.\n\tif ( typeof borderRadius === 'number' ) {\n\t\tborderProps = {\n\t\t\t...borderProps,\n\t\t\tstyle: {\n\t\t\t\t...borderProps.style,\n\t\t\t\tborderRadius: `${ borderRadius }px`,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst colorProps = useColorProps( attributes );\n\tconst [ fluidTypographySettings, layout ] = useSettings(\n\t\t'typography.fluid',\n\t\t'layout'\n\t);\n\tconst typographyProps = useTypographyProps( attributes, {\n\t\ttypography: {\n\t\t\tfluid: fluidTypographySettings,\n\t\t},\n\t\tlayout: {\n\t\t\twideSize: layout?.wideSize,\n\t\t},\n\t} );\n\tconst unitControlInstanceId = useInstanceId( UnitControl );\n\tconst unitControlInputId = `wp-block-search__width-${ unitControlInstanceId }`;\n\tconst isButtonPositionInside = 'button-inside' === buttonPosition;\n\tconst isButtonPositionOutside = 'button-outside' === buttonPosition;\n\tconst hasNoButton = 'no-button' === buttonPosition;\n\tconst hasOnlyButton = 'button-only' === buttonPosition;\n\tconst isSearchFieldHidden = hasOnlyButton && ! isSelected;\n\tconst searchFieldRef = useRef();\n\tconst buttonRef = useRef();\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: [ '%', 'px' ],\n\t\tdefaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },\n\t} );\n\n\tconst getBlockClassNames = () => {\n\t\treturn clsx(\n\t\t\tclassName,\n\t\t\tisButtonPositionInside\n\t\t\t\t? 'wp-block-search__button-inside'\n\t\t\t\t: undefined,\n\t\t\tisButtonPositionOutside\n\t\t\t\t? 'wp-block-search__button-outside'\n\t\t\t\t: undefined,\n\t\t\thasNoButton ? 'wp-block-search__no-button' : undefined,\n\t\t\thasOnlyButton ? 'wp-block-search__button-only' : undefined,\n\t\t\t! buttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__text-button'\n\t\t\t\t: undefined,\n\t\t\tbuttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__icon-button'\n\t\t\t\t: undefined,\n\t\t\tisSearchFieldHidden\n\t\t\t\t? 'wp-block-search__searchfield-hidden'\n\t\t\t\t: undefined\n\t\t);\n\t};\n\n\tconst buttonPositionControls = [\n\t\t{\n\t\t\tlabel: __( 'Button outside' ),\n\t\t\tvalue: 'button-outside',\n\t\t},\n\t\t{\n\t\t\tlabel: __( 'Button inside' ),\n\t\t\tvalue: 'button-inside',\n\t\t},\n\t\t{\n\t\t\tlabel: __( 'No button' ),\n\t\t\tvalue: 'no-button',\n\t\t},\n\t\t{\n\t\t\tlabel: __( 'Button only' ),\n\t\t\tvalue: 'button-only',\n\t\t},\n\t];\n\n\tconst getResizableSides = () => {\n\t\tif ( hasOnlyButton ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tright: align !== 'right',\n\t\t\tleft: align === 'right',\n\t\t};\n\t};\n\n\tconst renderTextField = () => {\n\t\t// If the input is inside the wrapper, the wrapper gets the border color styles/classes, not the input control.\n\t\tconst textFieldClasses = clsx(\n\t\t\t'wp-block-search__input',\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\ttypographyProps.className\n\t\t);\n\t\tconst textFieldStyles = {\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? {\n\t\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\t\tborderTopLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopLeftRadius,\n\t\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t\t }\n\t\t\t\t: borderProps.style ),\n\t\t\t...typographyProps.style,\n\t\t\ttextDecoration: undefined,\n\t\t};\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\ttype=\"search\"\n\t\t\t\tclassName={ textFieldClasses }\n\t\t\t\tstyle={ textFieldStyles }\n\t\t\t\taria-label={ __( 'Optional placeholder text' ) }\n\t\t\t\t// We hide the placeholder field's placeholder when there is a value. This\n\t\t\t\t// stops screen readers from reading the placeholder field's placeholder\n\t\t\t\t// which is confusing.\n\t\t\t\tplaceholder={\n\t\t\t\t\tplaceholder ? undefined : __( 'Optional placeholder\u2026' )\n\t\t\t\t}\n\t\t\t\tvalue={ placeholder }\n\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\tsetAttributes( { placeholder: event.target.value } )\n\t\t\t\t}\n\t\t\t\tref={ searchFieldRef }\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderButton = () => {\n\t\t// If the button is inside the wrapper, the wrapper gets the border color styles/classes, not the button.\n\t\tconst buttonClasses = clsx(\n\t\t\t'wp-block-search__button',\n\t\t\tcolorProps.className,\n\t\t\ttypographyProps.className,\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\tbuttonUseIcon ? 'has-icon' : undefined,\n\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t);\n\t\tconst buttonStyles = {\n\t\t\t...colorProps.style,\n\t\t\t...typographyProps.style,\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? {\n\t\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\t\tborderTopLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopLeftRadius,\n\t\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t\t }\n\t\t\t\t: borderProps.style ),\n\t\t};\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ buttonUseIcon && (\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\tbuttonText\n\t\t\t\t\t\t\t\t? stripHTML( buttonText )\n\t\t\t\t\t\t\t\t: __( 'Search' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tref={ buttonRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\n\t\t\t\t{ ! buttonUseIcon && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tidentifier=\"buttonText\"\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add button text\u2026' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ buttonText }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { buttonText: html } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst controls = (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\twidthUnit: undefined,\n\t\t\t\t\t\t\tshowLabel: true,\n\t\t\t\t\t\t\tbuttonUseIcon: false,\n\t\t\t\t\t\t\tbuttonPosition: 'button-outside',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowLabel: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowLabel: value,\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</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => buttonPosition !== 'button-outside' }\n\t\t\t\t\t\tlabel={ __( 'Button position' ) }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tbuttonPosition: 'button-outside',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tvalue={ buttonPosition }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Button position' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tbuttonPosition: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\toptions={ buttonPositionControls }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ buttonPosition !== 'no-button' && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! buttonUseIcon }\n\t\t\t\t\t\t\tlabel={ __( 'Use button with icon' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tbuttonUseIcon: false,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tchecked={ buttonUseIcon }\n\t\t\t\t\t\t\t\tlabel={ __( 'Use button with icon' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tbuttonUseIcon: value,\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! width }\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\t\twidthUnit: undefined,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<VStack>\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\t\t\tid={ unitControlInputId } // Unused, kept for backwards compatibility\n\t\t\t\t\t\t\t\tmin={\n\t\t\t\t\t\t\t\t\tisPercentageUnit( widthUnit )\n\t\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t\t: MIN_WIDTH\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\t\t\tisPercentageUnit( widthUnit )\n\t\t\t\t\t\t\t\t\t\t? 100\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstep={ 1 }\n\t\t\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\t\t\tconst parsedNewWidth =\n\t\t\t\t\t\t\t\t\t\tnewWidth === ''\n\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t: parseInt( newWidth, 10 );\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\twidth: parsedNewWidth,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonUnitChange={ ( newUnit ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\t'%' === newUnit\n\t\t\t\t\t\t\t\t\t\t\t\t? PC_WIDTH_DEFAULT\n\t\t\t\t\t\t\t\t\t\t\t\t: PX_WIDTH_DEFAULT,\n\t\t\t\t\t\t\t\t\t\twidthUnit: newUnit,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\tvalue={ `${ width }${ widthUnit }` }\n\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Percentage Width' ) }\n\t\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\t\tPERCENTAGE_WIDTHS.includes( width ) &&\n\t\t\t\t\t\t\t\t\twidthUnit === '%'\n\t\t\t\t\t\t\t\t\t\t? width\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\t\t\t\twidthUnit: '%',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ PERCENTAGE_WIDTHS.map( ( widthValue ) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ widthValue }\n\t\t\t\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %d: Percentage value. */\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%d%%' ),\n\t\t\t\t\t\t\t\t\t\t\t\twidthValue\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);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst isNonZeroBorderRadius = ( radius ) =>\n\t\tradius !== undefined && parseInt( radius, 10 ) !== 0;\n\n\tconst padBorderRadius = ( radius ) =>\n\t\tisNonZeroBorderRadius( radius )\n\t\t\t? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`\n\t\t\t: undefined;\n\n\tconst getWrapperStyles = () => {\n\t\tconst styles = isButtonPositionInside\n\t\t\t? borderProps.style\n\t\t\t: {\n\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\tborderTopLeftRadius: borderProps.style?.borderTopLeftRadius,\n\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t };\n\n\t\tif ( isButtonPositionInside ) {\n\t\t\t// We have button inside wrapper and a border radius value to apply.\n\t\t\t// Add default padding so we don't get \"fat\" corners.\n\t\t\t//\n\t\t\t// CSS calc() is used here to support non-pixel units. The inline\n\t\t\t// style using calc() will only apply if both values have units.\n\n\t\t\tif ( typeof borderRadius === 'object' ) {\n\t\t\t\t// Individual corner border radii present.\n\t\t\t\tconst {\n\t\t\t\t\tborderTopLeftRadius,\n\t\t\t\t\tborderTopRightRadius,\n\t\t\t\t\tborderBottomLeftRadius,\n\t\t\t\t\tborderBottomRightRadius,\n\t\t\t\t} = borderProps.style;\n\n\t\t\t\treturn {\n\t\t\t\t\t...styles,\n\t\t\t\t\tborderTopLeftRadius: padBorderRadius( borderTopLeftRadius ),\n\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\tpadBorderRadius( borderTopRightRadius ),\n\t\t\t\t\tborderBottomLeftRadius: padBorderRadius(\n\t\t\t\t\t\tborderBottomLeftRadius\n\t\t\t\t\t),\n\t\t\t\t\tborderBottomRightRadius: padBorderRadius(\n\t\t\t\t\t\tborderBottomRightRadius\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// The inline style using calc() will only apply if both values\n\t\t\t// supplied to calc() have units. Deprecated block's may have\n\t\t\t// unitless integer.\n\t\t\tconst radius = Number.isInteger( borderRadius )\n\t\t\t\t? `${ borderRadius }px`\n\t\t\t\t: borderRadius;\n\n\t\t\tstyles.borderRadius = `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`;\n\t\t}\n\n\t\treturn styles;\n\t};\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: getBlockClassNames(),\n\t\tstyle: {\n\t\t\t...typographyProps.style,\n\t\t\t// Input opts out of text decoration.\n\t\t\ttextDecoration: undefined,\n\t\t},\n\t} );\n\n\tconst labelClassnames = clsx(\n\t\t'wp-block-search__label',\n\t\ttypographyProps.className\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ controls }\n\n\t\t\t{ showLabel && (\n\t\t\t\t<RichText\n\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\tclassName={ labelClassnames }\n\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add label\u2026' ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tvalue={ label }\n\t\t\t\t\tonChange={ ( html ) => setAttributes( { label: html } ) }\n\t\t\t\t\tstyle={ typographyProps.style }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth:\n\t\t\t\t\t\twidth === undefined\n\t\t\t\t\t\t\t? 'auto'\n\t\t\t\t\t\t\t: `${ width }${ widthUnit }`,\n\t\t\t\t\theight: 'auto',\n\t\t\t\t} }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'wp-block-search__inside-wrapper',\n\t\t\t\t\tisButtonPositionInside ? borderProps.className : undefined\n\t\t\t\t) }\n\t\t\t\tstyle={ getWrapperStyles() }\n\t\t\t\tminWidth={ MIN_WIDTH }\n\t\t\t\tenable={ getResizableSides() }\n\t\t\t\tonResizeStart={ ( event, direction, elt ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( elt.offsetWidth, 10 ),\n\t\t\t\t\t\twidthUnit: 'px',\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t>\n\t\t\t\t{ ( isButtonPositionInside ||\n\t\t\t\t\tisButtonPositionOutside ||\n\t\t\t\t\thasOnlyButton ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ renderTextField() }\n\t\t\t\t\t\t{ renderButton() }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t{ hasNoButton && renderTextField() }\n\t\t\t</ResizableBox>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,EAChC,+BAA+B;AAAA,EAC/B,iCAAiC;AAAA,EACjC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,WAAW,cAAc;AAClC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,EAChC,6BAA6B;AAAA,EAC7B,oCAAoC;AAAA,EACpC,0CAA0C;AAAA,EAC1C,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC,wBAAwB;AAAA,OAClB;AACP,SAAS,qBAAqB;AAC9B,SAAS,MAAM,cAAc;AAC7B,SAAS,IAAI,eAAe;AAC5B,SAAS,uBAAuB,iBAAiB;AAKjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sCAAsC;AAqL5C,SAgDA,UAhDA,KAgDA,YAhDA;AAjLH,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB,CAAE,IAAI,IAAI,IAAI,GAAI;AAE7B,SAAR,WAA6B;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,QAAM,qCAAqC;AAAA,IAC1C,CAAE,WAAY;AACb,YAAM,EAAE,4BAA4B,qBAAqB,IACxD,OAA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