@wordpress/block-library 8.17.1 → 8.18.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/cover/edit/index.js +3 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/shared.js +26 -21
- package/build/cover/shared.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +0 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/query/edit/inspector-controls/index.js +28 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -1
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +9 -2
- package/build/query/index.js.map +1 -1
- package/build/query/view.js +75 -0
- package/build/query/view.js.map +1 -0
- package/build/query-pagination-next/index.js +1 -1
- package/build/query-pagination-numbers/edit.js +50 -5
- package/build/query-pagination-numbers/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +7 -1
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/query-pagination-previous/index.js +1 -1
- package/build/search/edit.js +3 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/utils.js +2 -4
- package/build/search/utils.js.map +1 -1
- package/build/social-link/edit.native.js +1 -3
- package/build/social-link/edit.native.js.map +1 -1
- package/build-module/cover/edit/index.js +3 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/shared.js +26 -21
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +0 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/query/edit/inspector-controls/index.js +29 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -1
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +9 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/view.js +72 -0
- package/build-module/query/view.js.map +1 -0
- package/build-module/query-pagination-next/index.js +1 -1
- package/build-module/query-pagination-numbers/edit.js +51 -6
- package/build-module/query-pagination-numbers/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +7 -1
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/query-pagination-previous/index.js +1 -1
- package/build-module/search/edit.js +4 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/utils.js +0 -1
- package/build-module/search/utils.js.map +1 -1
- package/build-module/social-link/edit.native.js +1 -3
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-style/query/style-rtl.css +140 -0
- package/build-style/query/style.css +140 -0
- package/build-style/site-logo/style-rtl.css +1 -0
- package/build-style/site-logo/style.css +1 -0
- package/build-style/style-rtl.css +1 -0
- package/build-style/style.css +1 -0
- package/package.json +32 -32
- package/src/audio/test/__snapshots__/edit.native.js.snap +106 -78
- package/src/cover/edit/index.js +3 -1
- package/src/cover/shared.js +25 -20
- package/src/cover/test/edit.native.js +1 -5
- package/src/embed/embed-link-settings.native.js +0 -1
- package/src/embed/test/index.native.js +9 -9
- package/src/file/test/__snapshots__/edit.native.js.snap +218 -162
- package/src/image/index.php +5 -0
- package/src/post-content/edit.js +2 -2
- package/src/post-content/index.php +0 -6
- package/src/post-featured-image/index.php +0 -6
- package/src/post-template/block.json +2 -1
- package/src/post-template/index.php +19 -4
- package/src/query/block.json +9 -2
- package/src/query/edit/inspector-controls/index.js +46 -3
- package/src/query/edit/query-content.js +1 -0
- package/src/query/index.php +94 -1
- package/src/query/style.scss +63 -0
- package/src/query/view.js +82 -0
- package/src/query-no-results/index.php +1 -5
- package/src/query-pagination-next/block.json +7 -1
- package/src/query-pagination-next/index.php +20 -3
- package/src/query-pagination-numbers/block.json +7 -1
- package/src/query-pagination-numbers/edit.js +64 -16
- package/src/query-pagination-numbers/index.php +27 -4
- package/src/query-pagination-previous/block.json +7 -1
- package/src/query-pagination-previous/index.php +19 -2
- package/src/search/edit.js +8 -2
- package/src/search/test/__snapshots__/edit.native.js.snap +363 -265
- package/src/search/utils.js +0 -1
- package/src/site-logo/style.scss +1 -0
- package/src/social-link/edit.native.js +1 -1
- package/src/social-link/editor.native.scss +0 -4
- package/src/social-links/test/edit.native.js +30 -0
- package/src/social-link/test/index.native.js +0 -132
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PanelBody","TextControl","SelectControl","RangeControl","ToggleControl","Notice","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","InspectorControls","privateApis","blockEditorPrivateApis","debounce","useEffect","useState","useCallback","OrderControl","AuthorControl","ParentControl","TaxonomyControls","StickyControl","CreateNewPostLink","unlock","usePostTypes","useIsPostTypeHierarchical","useAllowedControls","isControlAllowed","useTaxonomies","BlockInfo","QueryInspectorControls","props","attributes","setQuery","setDisplayLayout","query","displayLayout","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomies","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","showOrderControl","showStickyControl","showSettingsPanel","showTaxControl","showAuthorControl","showSearchControl","showParentControl","showFiltersPanel","createElement","Fragment","title","__nextHasNoMarginBottom","label","help","checked","onChange","value","options","columns","min","max","Math","status","isDismissible","className","resetAll","hasValue","values","some","onDeselect"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport CreateNewPostLink from './create-new-post-link';\nimport { unlock } from '../../../lock-unlock';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n\tuseTaxonomies,\n} from '../../utils';\n\nconst { BlockInfo } = unlock( blockEditorPrivateApis );\n\nexport default function QueryInspectorControls( props ) {\n\tconst { attributes, setQuery, setDisplayLayout } = props;\n\tconst { query, displayLayout } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomies = useTaxonomies( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = false;\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\tconst showTaxControl =\n\t\t!! taxonomies?.length &&\n\t\tisControlAllowed( allowedControls, 'taxQuery' );\n\tconst showAuthorControl = isControlAllowed( allowedControls, 'author' );\n\tconst showSearchControl = isControlAllowed( allowedControls, 'search' );\n\tconst showParentControl =\n\t\tisControlAllowed( allowedControls, 'parents' ) &&\n\t\tisPostTypeHierarchical;\n\n\tconst showFiltersPanel =\n\t\tshowTaxControl ||\n\t\tshowAuthorControl ||\n\t\tshowSearchControl ||\n\t\tshowParentControl;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockInfo>\n\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t</BlockInfo>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! 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\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\t\t\tcolumns: value,\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\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: 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</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && showFiltersPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTaxControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\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\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\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<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showAuthorControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showSearchControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showParentControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,wBAAwB,IAAIC,U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C5E,cAAc;IACd8F,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAE9D,SAAW;IAC/BgD,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBgG,UAAU,EAAGA,CAAA,KAAMxE,QAAQ,CAAE;MAAEM,MAAM,EAAE;IAAG,CAAE;EAAG,GAE/C6C,aAAA,CAAClE,aAAa;IACb0E,KAAK,EAAGpD,SAAW;IACnBmD,QAAQ,EAAG1D;EAAU,CACrB,CACc,CAChB,EACCgD,iBAAiB,IAClBG,aAAA,CAAC5E,cAAc;IACd8F,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAElC,WAAa;IACjCoB,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBgG,UAAU,EAAGA,CAAA,KAAMpC,cAAc,CAAE,EAAG;EAAG,GAEzCe,aAAA,CAACpF,WAAW;IACXuF,uBAAuB;IACvBC,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBmF,KAAK,EAAGxB,WAAa;IACrBuB,QAAQ,EAAGtB;EAAgB,CAC3B,CACc,CAChB,EACCa,iBAAiB,IAClBE,aAAA,CAAC5E,cAAc;IACd8F,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEzD,OAAO,EAAEqB,MAAQ;IACrCsB,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBgG,UAAU,EAAGA,CAAA,KAAMxE,QAAQ,CAAE;MAAEY,OAAO,EAAE;IAAG,CAAE;EAAG,GAEhDuC,aAAA,CAACjE,aAAa;IACb0B,OAAO,EAAGA,OAAS;IACnBJ,QAAQ,EAAGA,QAAU;IACrBkD,QAAQ,EAAG1D;EAAU,CACrB,CACc,CAEN,CACM,CAEnB,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["PanelBody","TextControl","SelectControl","RangeControl","ToggleControl","Notice","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","InspectorControls","privateApis","blockEditorPrivateApis","debounce","useEffect","useState","useCallback","useRef","speak","OrderControl","AuthorControl","ParentControl","TaxonomyControls","StickyControl","CreateNewPostLink","unlock","usePostTypes","useIsPostTypeHierarchical","useAllowedControls","isControlAllowed","useTaxonomies","BlockInfo","QueryInspectorControls","props","attributes","setQuery","setDisplayLayout","setAttributes","query","displayLayout","enhancedPagination","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomies","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","showOrderControl","showStickyControl","showSettingsPanel","showTaxControl","showAuthorControl","showSearchControl","showParentControl","enhancedPaginationNotice","isFirstRender","current","showFiltersPanel","createElement","Fragment","title","__nextHasNoMarginBottom","label","help","checked","onChange","value","options","columns","min","max","Math","status","isDismissible","className","resetAll","hasValue","values","some","onDeselect","initialOpen","spokenMessage"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport CreateNewPostLink from './create-new-post-link';\nimport { unlock } from '../../../lock-unlock';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n\tuseTaxonomies,\n} from '../../utils';\n\nconst { BlockInfo } = unlock( blockEditorPrivateApis );\n\nexport default function QueryInspectorControls( props ) {\n\tconst { attributes, setQuery, setDisplayLayout, setAttributes } = props;\n\tconst { query, displayLayout, enhancedPagination } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomies = useTaxonomies( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = false;\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\tconst showTaxControl =\n\t\t!! taxonomies?.length &&\n\t\tisControlAllowed( allowedControls, 'taxQuery' );\n\tconst showAuthorControl = isControlAllowed( allowedControls, 'author' );\n\tconst showSearchControl = isControlAllowed( allowedControls, 'search' );\n\tconst showParentControl =\n\t\tisControlAllowed( allowedControls, 'parents' ) &&\n\t\tisPostTypeHierarchical;\n\n\tconst enhancedPaginationNotice = __(\n\t\t'Enhanced Pagination might cause interactive blocks within the Post Template to stop working. Disable it if you experience any issues.'\n\t);\n\n\tconst isFirstRender = useRef( true ); // Don't speak on first render.\n\tuseEffect( () => {\n\t\tif ( ! isFirstRender.current && enhancedPagination ) {\n\t\t\tspeak( enhancedPaginationNotice );\n\t\t}\n\t\tisFirstRender.current = false;\n\t}, [ enhancedPagination, enhancedPaginationNotice ] );\n\n\tconst showFiltersPanel =\n\t\tshowTaxControl ||\n\t\tshowAuthorControl ||\n\t\tshowSearchControl ||\n\t\tshowParentControl;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockInfo>\n\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t</BlockInfo>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! 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\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\t\t\tcolumns: value,\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\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: 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</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && showFiltersPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTaxControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\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\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\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<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showAuthorControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showSearchControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showParentControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'User Experience' ) }\n\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\"Don't refresh the page when paginating to another page.\"\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t{ enhancedPagination && (\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tspokenMessage={ null }\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ enhancedPaginationNotice }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AAC7E,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,iBAAiB,MAAM,wBAAwB;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AAG,CAAC,CAAEzD,kBAAoB;IACjC0D,QAAQ,EAAKC,KAAK,IACjB9D,aAAa,CAAE;MACdG,kBAAkB,EAAE,CAAC,CAAE2D;IACxB,CAAE;EACF,CACD,CAAC,EACA3D,kBAAkB,IACnBmD,aAAA,cACCA,aAAA,CAACvF,MAAM;IACN8G,aAAa,EAAG,IAAM;IACtBT,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG;EAAO,GAErBnB,wBACK,CACJ,CAEI,CACO,CAClB,CAAC;AAEL"}
|
|
@@ -109,7 +109,8 @@ export default function QueryContent({
|
|
|
109
109
|
return createElement(Fragment, null, createElement(QueryInspectorControls, {
|
|
110
110
|
attributes: attributes,
|
|
111
111
|
setQuery: updateQuery,
|
|
112
|
-
setDisplayLayout: updateDisplayLayout
|
|
112
|
+
setDisplayLayout: updateDisplayLayout,
|
|
113
|
+
setAttributes: setAttributes
|
|
113
114
|
}), createElement(BlockControls, null, createElement(QueryToolbar, {
|
|
114
115
|
name: name,
|
|
115
116
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","QueryToolbar","QueryInspectorControls","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","inherit","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","canUser","settingPerPage","posts_per_page","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","createElement","Fragment","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, canUser } = select( coreStore );\n\t\tconst settingPerPage = canUser( 'read', 'settings' )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\t\treturn {\n\t\t\tpostsPerPage: settingPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage, postsPerPage, inherit ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t};\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASJ,KAAK,IAAIK,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,sBAAsB,MAAM,sBAAsB;AAEzD,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,QAAQ,GAAG,CAAE,CAAE,oBAAoB,CAAE,CAAE;AAC7C,eAAe,SAASC,YAAYA,CAAE;EACrCC,UAAU;EACVC,aAAa;EACbC,y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MAC7CO,QAAQ,CAACC,OAAO,GAAGR,YAAY;IAChC;IACA,IAAK,CAAC,CAAES,MAAM,CAACC,IAAI,CAAEH,QAAS,CAAC,CAACI,MAAM,EAAG;MACxChB,uCAAuC,CAAC,CAAC;MACzCiB,WAAW,CAAEL,QAAS,CAAC;IACxB;EACD,CAAC,EAAE,CAAEjB,KAAK,CAACkB,OAAO,EAAER,YAAY,EAAEN,OAAO,CAAG,CAAC;EAC7C;EACA;EACAzB,SAAS,CAAE,MAAM;IAChB,IAAK,CAAE4C,MAAM,CAACC,QAAQ,CAAEzB,OAAQ,CAAC,EAAG;MACnCM,uCAAuC,CAAC,CAAC;MACzCV,aAAa,CAAE;QAAEI,OAAO,EAAEO;MAAW,CAAE,CAAC;IACzC;EACD,CAAC,EAAE,CAAEP,OAAO,EAAEO,UAAU,CAAG,CAAC;EAC5B,MAAMgB,WAAW,GAAKL,QAAQ,IAC7BtB,aAAa,CAAE;IAAEK,KAAK,EAAE;MAAE,GAAGA,KAAK;MAAE,GAAGiB;IAAS;EAAE,CAAE,CAAC;EACtD,MAAMQ,mBAAmB,GAAKC,gBAAgB,IAC7C/B,aAAa,CAAE;IACdM,aAAa,EAAE;MAAE,GAAGA,aAAa;MAAE,GAAGyB;IAAiB;EACxD,CAAE,CAAC;EACJ,MAAMC,mBAAmB,GAAG;IAC3BC,IAAI,EAAEzC,EAAE,CACP,mFACD,CAAC;IACD0C,OAAO,EAAE1C,EAAE,CACV,kIACD,CAAC;IACD2C,KAAK,EAAE3C,EAAE,CACR,uIACD;EACD,CAAC;EACD,OACC4C,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACzC,sBAAsB;IACtBI,UAAU,EAAGA,UAAY;IACzBuC,QAAQ,EAAGX,WAAa;IACxBY,gBAAgB,EAAGT;
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","QueryToolbar","QueryInspectorControls","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","inherit","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","canUser","settingPerPage","posts_per_page","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","createElement","Fragment","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, canUser } = select( coreStore );\n\t\tconst settingPerPage = canUser( 'read', 'settings' )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\t\treturn {\n\t\t\tpostsPerPage: settingPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage, postsPerPage, inherit ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t};\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,oBAA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B4B,aAAA,CAAC5B,OAAO;IAAA,GAAMK;EAAgB,CAAI,CACjC,CAAC;AAEL"}
|
|
@@ -43,19 +43,26 @@ const metadata = {
|
|
|
43
43
|
},
|
|
44
44
|
namespace: {
|
|
45
45
|
type: "string"
|
|
46
|
+
},
|
|
47
|
+
enhancedPagination: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
"default": false
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
52
|
providesContext: {
|
|
49
53
|
queryId: "queryId",
|
|
50
54
|
query: "query",
|
|
51
|
-
displayLayout: "displayLayout"
|
|
55
|
+
displayLayout: "displayLayout",
|
|
56
|
+
enhancedPagination: "enhancedPagination"
|
|
52
57
|
},
|
|
53
58
|
supports: {
|
|
54
59
|
align: ["wide", "full"],
|
|
55
60
|
html: false,
|
|
56
61
|
layout: true
|
|
57
62
|
},
|
|
58
|
-
editorStyle: "wp-block-query-editor"
|
|
63
|
+
editorStyle: "wp-block-query-editor",
|
|
64
|
+
style: "wp-block-query",
|
|
65
|
+
viewScript: "file:./view.min.js"
|
|
59
66
|
};
|
|
60
67
|
import edit from './edit';
|
|
61
68
|
import save from './save';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["loop","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","queryId","type","query","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","tagName","namespace","providesContext","displayLayout","supports","align","html","layout","editorStyle","edit","save","variations","deprecated","settings","init"],"sources":["@wordpress/block-library/src/query/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { loop as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport variations from './variations';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tvariations,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAI,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;IAAA;IAAAC,KAAA;MAAAD,IAAA;MAAA;QAAAE,OAAA;QAAAC,KAAA;QAAAC,MAAA;QAAAC,QAAA;QAAAC,KAAA;QAAAC,OAAA;QAAAC,MAAA;QAAAC,MAAA;QAAAC,OAAA;QAAAC,MAAA;QAAAC,OAAA;QAAAC,QAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,OAAA;MAAAf,IAAA;MAAA;IAAA;IAAAgB,SAAA;MAAAhB,IAAA;IAAA;EAAA;
|
|
1
|
+
{"version":3,"names":["loop","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","queryId","type","query","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","tagName","namespace","enhancedPagination","providesContext","displayLayout","supports","align","html","layout","editorStyle","style","viewScript","edit","save","variations","deprecated","settings","init"],"sources":["@wordpress/block-library/src/query/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { loop as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport variations from './variations';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tvariations,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAI,QAAQ,kBAAk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*/
|
|
4
|
+
import { store, navigate, prefetch } from '@wordpress/interactivity';
|
|
5
|
+
const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
|
|
6
|
+
const isValidEvent = event => event.button === 0 &&
|
|
7
|
+
// left clicks only
|
|
8
|
+
!event.metaKey &&
|
|
9
|
+
// open in new tab (mac)
|
|
10
|
+
!event.ctrlKey &&
|
|
11
|
+
// open in new tab (windows)
|
|
12
|
+
!event.altKey &&
|
|
13
|
+
// download
|
|
14
|
+
!event.shiftKey && !event.defaultPrevented;
|
|
15
|
+
store({
|
|
16
|
+
selectors: {
|
|
17
|
+
core: {
|
|
18
|
+
query: {
|
|
19
|
+
startAnimation: ({
|
|
20
|
+
context
|
|
21
|
+
}) => context.core.query.animation === 'start',
|
|
22
|
+
finishAnimation: ({
|
|
23
|
+
context
|
|
24
|
+
}) => context.core.query.animation === 'finish'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
actions: {
|
|
29
|
+
core: {
|
|
30
|
+
query: {
|
|
31
|
+
navigate: async ({
|
|
32
|
+
event,
|
|
33
|
+
ref,
|
|
34
|
+
context,
|
|
35
|
+
state
|
|
36
|
+
}) => {
|
|
37
|
+
if (isValidLink(ref) && isValidEvent(event)) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
const id = ref.closest('[data-wp-navigation-id]').dataset.wpNavigationId;
|
|
40
|
+
|
|
41
|
+
// Don't announce the navigation immediately, wait 300 ms.
|
|
42
|
+
const timeout = setTimeout(() => {
|
|
43
|
+
context.core.query.message = state.core.query.loadingText;
|
|
44
|
+
context.core.query.animation = 'start';
|
|
45
|
+
}, 300);
|
|
46
|
+
await navigate(ref.href);
|
|
47
|
+
|
|
48
|
+
// Dismiss loading message if it hasn't been added yet.
|
|
49
|
+
clearTimeout(timeout);
|
|
50
|
+
|
|
51
|
+
// Announce that the page has been loaded. If the message is the
|
|
52
|
+
// same, we use a no-break space similar to the @wordpress/a11y
|
|
53
|
+
// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
|
|
54
|
+
context.core.query.message = state.core.query.loadedText + (context.core.query.message === state.core.query.loadedText ? '\u00A0' : '');
|
|
55
|
+
context.core.query.animation = 'finish';
|
|
56
|
+
|
|
57
|
+
// Focus the first anchor of the Query block.
|
|
58
|
+
document.querySelector(`[data-wp-navigation-id=${id}] a[href]`)?.focus();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
prefetch: async ({
|
|
62
|
+
ref
|
|
63
|
+
}) => {
|
|
64
|
+
if (isValidLink(ref)) {
|
|
65
|
+
await prefetch(ref.href);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["store","navigate","prefetch","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","state","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","document","querySelector","focus"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context, state } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tstate.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 300 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tstate.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tstate.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tdocument\n\t\t\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t\t\t`[data-wp-navigation-id=${ id }] a[href]`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,0BAA0B;AAEpE,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAAG,CAACK,MAAM,KAAKJ,MAAM,CAACK,QAAQ,CAACD,MAAM;AAEtC,MAAME,YAAY,GAAKC,KAAK,IAC3BA,KAAK,CAACC,MAAM,KAAK,CAAC;AAAI;AACtB,CAAED,KAAK,CAACE,OAAO;AAAI;AACnB,CAAEF,KAAK,CAACG,OAAO;AAAI;AACnB,CAAEH,KAAK,CAACI,MAAM;AAAI;AAClB,CAAEJ,KAAK,CAACK,QAAQ,IAChB,CAAEL,KAAK,CAACM,gBAAgB;AAEzBlB,KAAK,CAAE;EACNmB,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,KAAK,EAAE;QACNC,cAAc,EAAEA,CAAE;UAAEC;QAAQ,CAAC,KAC5BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK,OAAO;QACzCC,eAAe,EAAEA,CAAE;UAAEF;QAAQ,CAAC,KAC7BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK;MACnC;IACD;EACD,CAAC;EACDE,OAAO,EAAE;IACRN,IAAI,EAAE;MACLC,KAAK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AC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
|
|
@@ -21,7 +21,7 @@ const metadata = {
|
|
|
21
21
|
type: "string"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
usesContext: ["queryId", "query", "paginationArrow", "showLabel"],
|
|
24
|
+
usesContext: ["queryId", "query", "paginationArrow", "showLabel", "enhancedPagination"],
|
|
25
25
|
supports: {
|
|
26
26
|
reusable: false,
|
|
27
27
|
html: false,
|
|
@@ -2,15 +2,60 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
2
2
|
/**
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
|
7
|
+
import { PanelBody, RangeControl } from '@wordpress/components';
|
|
6
8
|
const createPaginationItem = (content, Tag = 'a', extraClass = '') => createElement(Tag, {
|
|
9
|
+
key: content,
|
|
7
10
|
className: `page-numbers ${extraClass}`
|
|
8
11
|
}, content);
|
|
9
|
-
const previewPaginationNumbers =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const previewPaginationNumbers = midSize => {
|
|
13
|
+
const paginationItems = [];
|
|
14
|
+
|
|
15
|
+
// First set of pagination items.
|
|
16
|
+
for (let i = 1; i <= midSize; i++) {
|
|
17
|
+
paginationItems.push(createPaginationItem(i));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Current pagination item.
|
|
21
|
+
paginationItems.push(createPaginationItem(midSize + 1, 'span', 'current'));
|
|
22
|
+
|
|
23
|
+
// Second set of pagination items.
|
|
24
|
+
for (let i = 1; i <= midSize; i++) {
|
|
25
|
+
paginationItems.push(createPaginationItem(midSize + 1 + i));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Dots.
|
|
29
|
+
paginationItems.push(createPaginationItem('...', 'span', 'dots'));
|
|
30
|
+
|
|
31
|
+
// Last pagination item.
|
|
32
|
+
paginationItems.push(createPaginationItem(midSize * 2 + 3));
|
|
33
|
+
return createElement(Fragment, null, paginationItems);
|
|
34
|
+
};
|
|
35
|
+
export default function QueryPaginationNumbersEdit({
|
|
36
|
+
attributes,
|
|
37
|
+
setAttributes
|
|
38
|
+
}) {
|
|
39
|
+
const {
|
|
40
|
+
midSize
|
|
41
|
+
} = attributes;
|
|
42
|
+
const paginationNumbers = previewPaginationNumbers(parseInt(midSize, 10));
|
|
43
|
+
return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
|
|
44
|
+
title: __('Settings')
|
|
45
|
+
}, createElement(RangeControl, {
|
|
46
|
+
label: __('Number of links'),
|
|
47
|
+
help: __('Specify how many links can appear before and after the current page number. Links to the first, current and last page are always visible.'),
|
|
48
|
+
value: midSize,
|
|
49
|
+
onChange: value => {
|
|
50
|
+
setAttributes({
|
|
51
|
+
midSize: parseInt(value, 10)
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
min: 0,
|
|
55
|
+
max: 5,
|
|
56
|
+
withInputField: false
|
|
57
|
+
}))), createElement("div", {
|
|
13
58
|
...useBlockProps()
|
|
14
|
-
}, paginationNumbers);
|
|
59
|
+
}, paginationNumbers));
|
|
15
60
|
}
|
|
16
61
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useBlockProps","createPaginationItem","content","Tag","extraClass","createElement","className","previewPaginationNumbers","Fragment","QueryPaginationNumbersEdit","paginationNumbers"],"sources":["@wordpress/block-library/src/query-pagination-numbers/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\n\nconst createPaginationItem = ( content, Tag = 'a', extraClass = '' ) => (\n\t<Tag className={ `page-numbers ${ extraClass }` }
|
|
1
|
+
{"version":3,"names":["__","InspectorControls","useBlockProps","PanelBody","RangeControl","createPaginationItem","content","Tag","extraClass","createElement","key","className","previewPaginationNumbers","midSize","paginationItems","i","push","Fragment","QueryPaginationNumbersEdit","attributes","setAttributes","paginationNumbers","parseInt","title","label","help","value","onChange","min","max","withInputField"],"sources":["@wordpress/block-library/src/query-pagination-numbers/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport { PanelBody, RangeControl } from '@wordpress/components';\n\nconst createPaginationItem = ( content, Tag = 'a', extraClass = '' ) => (\n\t<Tag key={ content } className={ `page-numbers ${ extraClass }` }>\n\t\t{ content }\n\t</Tag>\n);\n\nconst previewPaginationNumbers = ( midSize ) => {\n\tconst paginationItems = [];\n\n\t// First set of pagination items.\n\tfor ( let i = 1; i <= midSize; i++ ) {\n\t\tpaginationItems.push( createPaginationItem( i ) );\n\t}\n\n\t// Current pagination item.\n\tpaginationItems.push(\n\t\tcreatePaginationItem( midSize + 1, 'span', 'current' )\n\t);\n\n\t// Second set of pagination items.\n\tfor ( let i = 1; i <= midSize; i++ ) {\n\t\tpaginationItems.push( createPaginationItem( midSize + 1 + i ) );\n\t}\n\n\t// Dots.\n\tpaginationItems.push( createPaginationItem( '...', 'span', 'dots' ) );\n\n\t// Last pagination item.\n\tpaginationItems.push( createPaginationItem( midSize * 2 + 3 ) );\n\n\treturn <>{ paginationItems }</>;\n};\n\nexport default function QueryPaginationNumbersEdit( {\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst { midSize } = attributes;\n\tconst paginationNumbers = previewPaginationNumbers(\n\t\tparseInt( midSize, 10 )\n\t);\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Number of links' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Specify how many links can appear before and after the current page number. Links to the first, current and last page are always visible.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ midSize }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tmidSize: parseInt( value, 10 ),\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ 5 }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...useBlockProps() }>{ paginationNumbers }</div>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,yBAAyB;AAC1E,SAASC,SAAS,EAAEC,YAAY,QAAQ,uBAAuB;AAE/D,MAAMC,oBAAoB,GAAGA,CAAEC,OAAO,EAAEC,GAAG,GAAG,GAAG,EAAEC,UAAU,GAAG,EAAE,KACjEC,aAAA,CAACF,GAAG;EAACG,GAAG,EAAGJ,OAAS;EAACK,SAAS,EAAI,gBAAgBH,UAAY;AAAG,GAC9DF,OACE,CACL;AAED,MAAMM,wBAAwB,GAAKC,OAAO,IAAM;EAC/C,MAAMC,eAAe,GAAG,EAAE;;EAE1B;EACA,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,IAAIF,OAAO,EAAEE,CAAC,EAAE,EAAG;IACpCD,eAAe,CAACE,IAAI,CAAEX,oBAAoB,CAAEU,CAAE,CAAE,CAAC;EAClD;;EAEA;EACAD,eAAe,CAACE,IAAI,CACnBX,oBAAoB,CAAEQ,OAAO,GAAG,CAAC,EAAE,MAAM,EAAE,SAAU,CACtD,CAAC;;EAED;EACA,KAAM,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,IAAIF,OAAO,EAAEE,CAAC,EAAE,EAAG;IACpCD,eAAe,CAACE,IAAI,CAAEX,oBAAoB,CAAEQ,OAAO,GAAG,CAAC,GAAGE,CAAE,CAAE,CAAC;EAChE;;EAEA;EACAD,eAAe,CAACE,IAAI,CAAEX,oBAAoB,CAAE,KAAK,EAAE,MAAM,EAAE,MAAO,CAAE,CAAC;;EAErE;EACAS,eAAe,CAACE,IAAI,CAAEX,oBAAoB,CAAEQ,OAAO,GAAG,CAAC,GAAG,CAAE,CAAE,CAAC;EAE/D,OAAOJ,aAAA,CAAAQ,QAAA,QAAIH,eAAmB,CAAC;AAChC,CAAC;AAED,eAAe,SAASI,0BAA0BA,CAAE;EACnDC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,MAAM;IAAEP;EAAQ,CAAC,GAAGM,UAAU;EAC9B,MAAME,iBAAiB,GAAGT,wBAAwB,CACjDU,QAAQ,CAAET,OAAO,EAAE,EAAG,CACvB,CAAC;EACD,OACCJ,aAAA,CAAAQ,QAAA,QACCR,aAAA,CAACR,iBAAiB,QACjBQ,aAAA,CAACN,SAAS;IAACoB,KAAK,EAAGvB,EAAE,CAAE,UAAW;EAAG,GACpCS,aAAA,CAACL,YAAY;IACZoB,KAAK,EAAGxB,EAAE,CAAE,iBAAkB,CAAG;IACjCyB,IAAI,EAAGzB,EAAE,CACR,2IACD,CAAG;IACH0B,KAAK,EAAGb,OAAS;IACjBc,QAAQ,EAAKD,KAAK,IAAM;MACvBN,aAAa,CAAE;QACdP,OAAO,EAAES,QAAQ,CAAEI,KAAK,EAAE,EAAG;MAC9B,CAAE,CAAC;IACJ,CAAG;IACHE,GAAG,EAAG,CAAG;IACTC,GAAG,EAAG,CAAG;IACTC,cAAc,EAAG;EAAO,CACxB,CACS,CACO,CAAC,EACpBrB,aAAA;IAAA,GAAUP,aAAa,CAAC;EAAC,GAAKmB,iBAAwB,CACrD,CAAC;AAEL"}
|
|
@@ -16,7 +16,13 @@ const metadata = {
|
|
|
16
16
|
parent: ["core/query-pagination"],
|
|
17
17
|
description: "Displays a list of page numbers for pagination",
|
|
18
18
|
textdomain: "default",
|
|
19
|
-
|
|
19
|
+
attributes: {
|
|
20
|
+
midSize: {
|
|
21
|
+
type: "number",
|
|
22
|
+
"default": 2
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
usesContext: ["queryId", "query", "enhancedPagination"],
|
|
20
26
|
supports: {
|
|
21
27
|
reusable: false,
|
|
22
28
|
html: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["queryPaginationNumbers","icon","initBlock","metadata","$schema","apiVersion","name","title","category","parent","description","textdomain","usesContext","supports","reusable","html","color","gradients","text","__experimentalDefaultControls","background","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","editorStyle","edit","settings","init"],"sources":["@wordpress/block-library/src/query-pagination-numbers/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { queryPaginationNumbers as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,IAAI,QAAQ,kBAAkB;;AAEjE;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,MAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,QAAA;IAAAC,QAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAV,6BAAA;QAAAG,QAAA;MAAA;IAAA;EAAA;EAAAQ,WAAA;AAAA;AAE5C,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;
|
|
1
|
+
{"version":3,"names":["queryPaginationNumbers","icon","initBlock","metadata","$schema","apiVersion","name","title","category","parent","description","textdomain","attributes","midSize","type","usesContext","supports","reusable","html","color","gradients","text","__experimentalDefaultControls","background","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","editorStyle","edit","settings","init"],"sources":["@wordpress/block-library/src/query-pagination-numbers/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { queryPaginationNumbers as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,IAAI,QAAQ,kBAAkB;;AAEjE;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,MAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAA;IAAA;EAAA;EAAAC,WAAA;EAAAC,QAAA;IAAAC,QAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAV,6BAAA;QAAAG,QAAA;MAAA;IAAA;EAAA;EAAAQ,WAAA;AAAA;AAE5C,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAE5B;AAAK,CAAC,GAAGH,QAAQ;AACzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM6B,QAAQ,GAAG;EACvBlC,IAAI;EACJiC;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMlC,SAAS,CAAE;EAAEI,IAAI;EAAEH,QAAQ;EAAEgC;AAAS,CAAE,CAAC"}
|
|
@@ -21,7 +21,7 @@ const metadata = {
|
|
|
21
21
|
type: "string"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
usesContext: ["queryId", "query", "paginationArrow", "showLabel"],
|
|
24
|
+
usesContext: ["queryId", "query", "paginationArrow", "showLabel", "enhancedPagination"],
|
|
25
25
|
supports: {
|
|
26
26
|
reusable: false,
|
|
27
27
|
html: false,
|
|
@@ -20,7 +20,7 @@ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
|
20
20
|
* Internal dependencies
|
|
21
21
|
*/
|
|
22
22
|
import { buttonOnly, buttonOutside, buttonInside, noButton, buttonWithIcon, toggleLabel } from './icons';
|
|
23
|
-
import { PC_WIDTH_DEFAULT, PX_WIDTH_DEFAULT, MIN_WIDTH,
|
|
23
|
+
import { PC_WIDTH_DEFAULT, PX_WIDTH_DEFAULT, MIN_WIDTH, isPercentageUnit } from './utils.js';
|
|
24
24
|
|
|
25
25
|
// Used to calculate border radius adjustment to avoid "fat" corners when
|
|
26
26
|
// button is placed inside wrapper.
|
|
@@ -283,7 +283,9 @@ export default function SearchEdit({
|
|
|
283
283
|
id: unitControlInputId
|
|
284
284
|
}, createElement(UnitControl, {
|
|
285
285
|
id: unitControlInputId,
|
|
286
|
-
min:
|
|
286
|
+
min: isPercentageUnit(widthUnit) ? 0 : MIN_WIDTH,
|
|
287
|
+
max: isPercentageUnit(widthUnit) ? 100 : undefined,
|
|
288
|
+
step: 1,
|
|
287
289
|
onChange: newWidth => {
|
|
288
290
|
const filteredWidth = widthUnit === '%' && parseInt(newWidth, 10) > 100 ? 100 : newWidth;
|
|
289
291
|
setAttributes({
|