@wordpress/block-library 9.38.1-next.v.0 → 9.39.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/button/index.cjs +3 -0
- package/build/button/index.cjs.map +2 -2
- package/build/comments-title/block.json +1 -3
- package/build/comments-title/deprecated.cjs +148 -24
- package/build/comments-title/deprecated.cjs.map +3 -3
- package/build/comments-title/edit.cjs +17 -31
- package/build/comments-title/edit.cjs.map +3 -3
- package/build/cover/edit/block-controls.cjs +10 -2
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +6 -2
- package/build/cover/edit/embed-video-url-input.cjs.map +2 -2
- package/build/details/index.cjs +3 -0
- package/build/details/index.cjs.map +2 -2
- package/build/heading/index.cjs +3 -0
- package/build/heading/index.cjs.map +2 -2
- package/build/image/index.cjs +1 -1
- package/build/image/index.cjs.map +2 -2
- package/build/index.cjs +6 -0
- package/build/index.cjs.map +2 -2
- package/build/list-item/index.cjs +3 -0
- package/build/list-item/index.cjs.map +2 -2
- package/build/more/index.cjs +1 -1
- package/build/more/index.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +23 -2
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation-submenu/index.cjs +2 -2
- package/build/navigation-submenu/index.cjs.map +2 -2
- package/build/paragraph/index.cjs +1 -1
- package/build/paragraph/index.cjs.map +2 -2
- package/build/post-excerpt/edit.cjs +1 -1
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/tab/add-tab-toolbar-control.cjs +31 -9
- package/build/tab/add-tab-toolbar-control.cjs.map +2 -2
- package/build/tab/block.json +18 -4
- package/build/tab/controls.cjs +4 -8
- package/build/tab/controls.cjs.map +3 -3
- package/build/tab/edit.cjs +46 -118
- package/build/tab/edit.cjs.map +3 -3
- package/build/tab/remove-tab-toolbar-control.cjs +91 -0
- package/build/tab/remove-tab-toolbar-control.cjs.map +7 -0
- package/build/tab/save.cjs +2 -2
- package/build/tab/save.cjs.map +2 -2
- package/build/tab-panels/block.json +70 -0
- package/build/tab-panels/edit.cjs +63 -0
- package/build/tab-panels/edit.cjs.map +7 -0
- package/build/tab-panels/icon.cjs +29 -0
- package/build/tab-panels/icon.cjs.map +7 -0
- package/build/tab-panels/index.cjs +58 -0
- package/build/tab-panels/index.cjs.map +7 -0
- package/build/tab-panels/save.cjs +33 -0
- package/build/tab-panels/save.cjs.map +7 -0
- package/build/tabs/block.json +61 -90
- package/build/tabs/controls.cjs +19 -221
- package/build/tabs/controls.cjs.map +3 -3
- package/build/tabs/deprecated.cjs +179 -0
- package/build/tabs/deprecated.cjs.map +7 -0
- package/build/tabs/edit.cjs +84 -62
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/index.cjs +3 -1
- package/build/tabs/index.cjs.map +3 -3
- package/build/tabs/save.cjs +6 -9
- package/build/tabs/save.cjs.map +2 -2
- package/build/tabs-menu/block.json +77 -0
- package/build/tabs-menu/edit.cjs +204 -0
- package/build/tabs-menu/edit.cjs.map +7 -0
- package/build/tabs-menu/icon.cjs +29 -0
- package/build/tabs-menu/icon.cjs.map +7 -0
- package/build/tabs-menu/index.cjs +58 -0
- package/build/tabs-menu/index.cjs.map +7 -0
- package/build/tabs-menu/save.cjs +35 -0
- package/build/tabs-menu/save.cjs.map +7 -0
- package/build/tabs-menu-item/block.json +98 -0
- package/build/tabs-menu-item/controls.cjs +247 -0
- package/build/tabs-menu-item/controls.cjs.map +7 -0
- package/build/tabs-menu-item/edit.cjs +272 -0
- package/build/tabs-menu-item/edit.cjs.map +7 -0
- package/build/tabs-menu-item/icon.cjs +29 -0
- package/build/tabs-menu-item/icon.cjs.map +7 -0
- package/build/tabs-menu-item/index.cjs +58 -0
- package/build/tabs-menu-item/index.cjs.map +7 -0
- package/build/tabs-menu-item/save.cjs +50 -0
- package/build/tabs-menu-item/save.cjs.map +7 -0
- package/build/template-part/edit/index.cjs +1 -1
- package/build/template-part/edit/index.cjs.map +2 -2
- package/build/utils/caption.cjs +4 -6
- package/build/utils/caption.cjs.map +3 -3
- package/build/video/edit.cjs +4 -2
- package/build/video/edit.cjs.map +2 -2
- package/build-module/button/index.mjs +3 -0
- package/build-module/button/index.mjs.map +2 -2
- package/build-module/comments-title/block.json +1 -3
- package/build-module/comments-title/deprecated.mjs +148 -24
- package/build-module/comments-title/deprecated.mjs.map +2 -2
- package/build-module/comments-title/edit.mjs +17 -32
- package/build-module/comments-title/edit.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +11 -3
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +6 -2
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/details/index.mjs +3 -0
- package/build-module/details/index.mjs.map +2 -2
- package/build-module/heading/index.mjs +3 -0
- package/build-module/heading/index.mjs.map +2 -2
- package/build-module/image/index.mjs +1 -1
- package/build-module/image/index.mjs.map +2 -2
- package/build-module/index.mjs +6 -0
- package/build-module/index.mjs.map +2 -2
- package/build-module/list-item/index.mjs +3 -0
- package/build-module/list-item/index.mjs.map +2 -2
- package/build-module/more/index.mjs +1 -1
- package/build-module/more/index.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +23 -2
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation-submenu/index.mjs +2 -2
- package/build-module/navigation-submenu/index.mjs.map +2 -2
- package/build-module/paragraph/index.mjs +1 -1
- package/build-module/paragraph/index.mjs.map +2 -2
- package/build-module/post-excerpt/edit.mjs +1 -1
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/tab/add-tab-toolbar-control.mjs +32 -10
- package/build-module/tab/add-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab/block.json +18 -4
- package/build-module/tab/controls.mjs +4 -8
- package/build-module/tab/controls.mjs.map +2 -2
- package/build-module/tab/edit.mjs +48 -128
- package/build-module/tab/edit.mjs.map +2 -2
- package/build-module/tab/remove-tab-toolbar-control.mjs +73 -0
- package/build-module/tab/remove-tab-toolbar-control.mjs.map +7 -0
- package/build-module/tab/save.mjs +2 -2
- package/build-module/tab/save.mjs.map +2 -2
- package/build-module/tab-panels/block.json +70 -0
- package/build-module/tab-panels/edit.mjs +36 -0
- package/build-module/tab-panels/edit.mjs.map +7 -0
- package/build-module/tab-panels/icon.mjs +8 -0
- package/build-module/tab-panels/icon.mjs.map +7 -0
- package/build-module/tab-panels/index.mjs +20 -0
- package/build-module/tab-panels/index.mjs.map +7 -0
- package/build-module/tab-panels/save.mjs +12 -0
- package/build-module/tab-panels/save.mjs.map +7 -0
- package/build-module/tabs/block.json +61 -90
- package/build-module/tabs/controls.mjs +21 -228
- package/build-module/tabs/controls.mjs.map +2 -2
- package/build-module/tabs/deprecated.mjs +158 -0
- package/build-module/tabs/deprecated.mjs.map +7 -0
- package/build-module/tabs/edit.mjs +87 -64
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/index.mjs +3 -1
- package/build-module/tabs/index.mjs.map +2 -2
- package/build-module/tabs/save.mjs +7 -10
- package/build-module/tabs/save.mjs.map +2 -2
- package/build-module/tabs-menu/block.json +77 -0
- package/build-module/tabs-menu/edit.mjs +186 -0
- package/build-module/tabs-menu/edit.mjs.map +7 -0
- package/build-module/tabs-menu/icon.mjs +8 -0
- package/build-module/tabs-menu/icon.mjs.map +7 -0
- package/build-module/tabs-menu/index.mjs +20 -0
- package/build-module/tabs-menu/index.mjs.map +7 -0
- package/build-module/tabs-menu/save.mjs +14 -0
- package/build-module/tabs-menu/save.mjs.map +7 -0
- package/build-module/tabs-menu-item/block.json +98 -0
- package/build-module/tabs-menu-item/controls.mjs +227 -0
- package/build-module/tabs-menu-item/controls.mjs.map +7 -0
- package/build-module/tabs-menu-item/edit.mjs +253 -0
- package/build-module/tabs-menu-item/edit.mjs.map +7 -0
- package/build-module/tabs-menu-item/icon.mjs +8 -0
- package/build-module/tabs-menu-item/icon.mjs.map +7 -0
- package/build-module/tabs-menu-item/index.mjs +20 -0
- package/build-module/tabs-menu-item/index.mjs.map +7 -0
- package/build-module/tabs-menu-item/save.mjs +29 -0
- package/build-module/tabs-menu-item/save.mjs.map +7 -0
- package/build-module/template-part/edit/index.mjs +1 -1
- package/build-module/template-part/edit/index.mjs.map +2 -2
- package/build-module/utils/caption.mjs +1 -3
- package/build-module/utils/caption.mjs.map +2 -2
- package/build-module/video/edit.mjs +4 -2
- package/build-module/video/edit.mjs.map +2 -2
- package/build-style/editor-rtl.css +16 -21
- package/build-style/editor.css +16 -21
- package/build-style/gallery/style-rtl.css +1 -1
- package/build-style/gallery/style.css +1 -1
- package/build-style/style-rtl.css +42 -153
- package/build-style/style.css +42 -153
- package/build-style/tab/style-rtl.css +7 -1
- package/build-style/tab/style.css +7 -1
- package/build-style/tab-panels/style-rtl.css +4 -0
- package/build-style/tab-panels/style.css +4 -0
- package/build-style/tabs/style-rtl.css +1 -167
- package/build-style/tabs/style.css +1 -167
- package/build-style/tabs-menu/editor-rtl.css +4 -0
- package/build-style/tabs-menu/editor.css +4 -0
- package/build-style/tabs-menu/style-rtl.css +8 -0
- package/build-style/tabs-menu/style.css +8 -0
- package/build-style/tabs-menu-item/editor-rtl.css +16 -0
- package/build-style/tabs-menu-item/editor.css +16 -0
- package/build-style/tabs-menu-item/style-rtl.css +34 -0
- package/build-style/tabs-menu-item/style.css +34 -0
- package/package.json +37 -37
- package/src/button/index.js +4 -0
- package/src/comments-title/block.json +1 -3
- package/src/comments-title/deprecated.js +153 -23
- package/src/comments-title/edit.js +9 -25
- package/src/cover/edit/block-controls.js +14 -3
- package/src/cover/edit/embed-video-url-input.js +6 -2
- package/src/details/index.js +4 -0
- package/src/editor.scss +2 -1
- package/src/gallery/style.scss +1 -1
- package/src/heading/index.js +4 -0
- package/src/image/index.js +4 -1
- package/src/index.js +6 -0
- package/src/list-item/index.js +4 -0
- package/src/more/index.js +4 -1
- package/src/navigation/edit/index.js +28 -4
- package/src/navigation-submenu/index.js +6 -3
- package/src/paragraph/index.js +4 -1
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-excerpt/index.php +39 -16
- package/src/style.scss +3 -0
- package/src/tab/add-tab-toolbar-control.js +36 -11
- package/src/tab/block.json +18 -4
- package/src/tab/controls.js +4 -5
- package/src/tab/edit.js +75 -150
- package/src/tab/index.php +5 -63
- package/src/tab/remove-tab-toolbar-control.js +103 -0
- package/src/tab/save.js +1 -3
- package/src/tab/style.scss +8 -1
- package/src/tab-panels/block.json +70 -0
- package/src/tab-panels/edit.js +44 -0
- package/src/tab-panels/icon.js +10 -0
- package/src/tab-panels/index.js +21 -0
- package/src/tab-panels/save.js +11 -0
- package/src/tab-panels/style.scss +4 -0
- package/src/tabs/block.json +61 -90
- package/src/tabs/controls.js +7 -221
- package/src/tabs/deprecated.js +214 -0
- package/src/tabs/edit.js +108 -68
- package/src/tabs/index.js +2 -0
- package/src/tabs/index.php +86 -191
- package/src/tabs/save.js +6 -13
- package/src/tabs/style.scss +1 -187
- package/src/tabs-menu/block.json +77 -0
- package/src/tabs-menu/edit.js +251 -0
- package/src/tabs-menu/editor.scss +6 -0
- package/src/tabs-menu/icon.js +10 -0
- package/src/tabs-menu/index.js +21 -0
- package/src/tabs-menu/index.php +74 -0
- package/src/tabs-menu/save.js +18 -0
- package/src/tabs-menu/style.scss +8 -0
- package/src/tabs-menu-item/block.json +98 -0
- package/src/tabs-menu-item/controls.js +262 -0
- package/src/tabs-menu-item/edit.js +322 -0
- package/src/tabs-menu-item/editor.scss +20 -0
- package/src/tabs-menu-item/icon.js +10 -0
- package/src/tabs-menu-item/index.js +21 -0
- package/src/tabs-menu-item/index.php +82 -0
- package/src/tabs-menu-item/save.js +44 -0
- package/src/tabs-menu-item/style.scss +42 -0
- package/src/template-part/edit/index.js +1 -3
- package/src/utils/caption.js +1 -7
- package/src/video/edit.js +4 -2
- package/build/tab/tabs-list.cjs +0 -132
- package/build/tab/tabs-list.cjs.map +0 -7
- package/build/tabs/style-engine.cjs +0 -119
- package/build/tabs/style-engine.cjs.map +0 -7
- package/build-module/tab/tabs-list.mjs +0 -101
- package/build-module/tab/tabs-list.mjs.map +0 -7
- package/build-module/tabs/style-engine.mjs +0 -101
- package/build-module/tabs/style-engine.mjs.map +0 -7
- package/build-style/tabs/editor-rtl.css +0 -26
- package/build-style/tabs/editor.css +0 -26
- package/src/tab/tabs-list.js +0 -122
- package/src/tabs/editor.scss +0 -30
- package/src/tabs/style-engine.js +0 -164
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
6
|
+
|
|
7
|
+
export default function save( { attributes } ) {
|
|
8
|
+
// Build CSS custom properties for active/hover colors
|
|
9
|
+
const customColorStyles = {};
|
|
10
|
+
|
|
11
|
+
// Active/hover colors from custom attributes
|
|
12
|
+
if ( attributes.customActiveBackgroundColor ) {
|
|
13
|
+
customColorStyles[ '--custom-tab-active-color' ] =
|
|
14
|
+
attributes.customActiveBackgroundColor;
|
|
15
|
+
}
|
|
16
|
+
if ( attributes.customActiveTextColor ) {
|
|
17
|
+
customColorStyles[ '--custom-tab-active-text-color' ] =
|
|
18
|
+
attributes.customActiveTextColor;
|
|
19
|
+
}
|
|
20
|
+
if ( attributes.customHoverBackgroundColor ) {
|
|
21
|
+
customColorStyles[ '--custom-tab-hover-color' ] =
|
|
22
|
+
attributes.customHoverBackgroundColor;
|
|
23
|
+
}
|
|
24
|
+
if ( attributes.customHoverTextColor ) {
|
|
25
|
+
customColorStyles[ '--custom-tab-hover-text-color' ] =
|
|
26
|
+
attributes.customHoverTextColor;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// useBlockProps.save includes all core style engine classes and styles
|
|
30
|
+
// We add our custom classes and the hidden attribute for PHP template extraction
|
|
31
|
+
const blockProps = useBlockProps.save( {
|
|
32
|
+
className: 'wp-block-tabs-menu-item__template',
|
|
33
|
+
style: customColorStyles,
|
|
34
|
+
hidden: true,
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<a { ...blockProps }>
|
|
39
|
+
<span className="screen-reader-text">
|
|
40
|
+
{ __( 'Tab menu item' ) }
|
|
41
|
+
</span>
|
|
42
|
+
</a>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.wp-block-tabs-menu-item {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: block;
|
|
4
|
+
width: max-content;
|
|
5
|
+
text-decoration: none;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
flex-basis: inherit !important;
|
|
8
|
+
flex-grow: inherit !important;
|
|
9
|
+
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding-block: var(--tab-padding-block, var(--wp--preset--spacing--20, 0.5em));
|
|
12
|
+
padding-inline: var(--tab-padding-inline, var(--wp--preset--spacing--30, 1em));
|
|
13
|
+
|
|
14
|
+
// Inherit typography from parent
|
|
15
|
+
font-size: inherit;
|
|
16
|
+
font-family: inherit;
|
|
17
|
+
font-weight: inherit;
|
|
18
|
+
line-height: inherit;
|
|
19
|
+
letter-spacing: inherit;
|
|
20
|
+
text-transform: inherit;
|
|
21
|
+
text-align: inherit;
|
|
22
|
+
|
|
23
|
+
&:focus {
|
|
24
|
+
outline: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:focus-visible {
|
|
28
|
+
outline: 2px solid var(--tab-border-color-active, #000);
|
|
29
|
+
outline-offset: 2px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background-color: var(--custom-tab-hover-color, #eaeaea) !important;
|
|
34
|
+
color: var(--custom-tab-hover-text-color, #000) !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&[aria-selected="true"],
|
|
38
|
+
&.is-active {
|
|
39
|
+
background-color: var(--custom-tab-active-color, #000) !important;
|
|
40
|
+
color: var(--custom-tab-active-text-color, #fff) !important;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -264,9 +264,7 @@ export default function TemplatePartEdit( {
|
|
|
264
264
|
} );
|
|
265
265
|
} }
|
|
266
266
|
>
|
|
267
|
-
{
|
|
268
|
-
? __( 'Edit section' )
|
|
269
|
-
: __( 'Edit' ) }
|
|
267
|
+
{ __( 'Edit section' ) }
|
|
270
268
|
</ToolbarButton>
|
|
271
269
|
</BlockControls>
|
|
272
270
|
) }
|
package/src/utils/caption.js
CHANGED
|
@@ -12,17 +12,12 @@ import { __ } from '@wordpress/i18n';
|
|
|
12
12
|
import {
|
|
13
13
|
BlockControls,
|
|
14
14
|
__experimentalGetElementClassName,
|
|
15
|
-
|
|
15
|
+
RichText,
|
|
16
16
|
} from '@wordpress/block-editor';
|
|
17
17
|
import { ToolbarButton } from '@wordpress/components';
|
|
18
18
|
import { caption as captionIcon } from '@wordpress/icons';
|
|
19
19
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Internal dependencies
|
|
23
|
-
*/
|
|
24
|
-
import { unlock } from '../lock-unlock';
|
|
25
|
-
|
|
26
21
|
export function Caption( {
|
|
27
22
|
attributeKey = 'caption',
|
|
28
23
|
attributes,
|
|
@@ -43,7 +38,6 @@ export function Caption( {
|
|
|
43
38
|
} ) {
|
|
44
39
|
const caption = attributes[ attributeKey ];
|
|
45
40
|
const prevCaption = usePrevious( caption );
|
|
46
|
-
const { PrivateRichText: RichText } = unlock( blockEditorPrivateApis );
|
|
47
41
|
const isCaptionEmpty = RichText.isEmpty( caption );
|
|
48
42
|
const isPrevCaptionEmpty = RichText.isEmpty( prevCaption );
|
|
49
43
|
const [ showCaption, setShowCaption ] = useState( ! isCaptionEmpty );
|
package/src/video/edit.js
CHANGED
|
@@ -27,6 +27,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
27
27
|
import { useDispatch } from '@wordpress/data';
|
|
28
28
|
import { video as icon } from '@wordpress/icons';
|
|
29
29
|
import { store as noticesStore } from '@wordpress/notices';
|
|
30
|
+
import { prependHTTPS } from '@wordpress/url';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Internal dependencies
|
|
@@ -110,9 +111,10 @@ function VideoEdit( {
|
|
|
110
111
|
|
|
111
112
|
function onSelectURL( newSrc ) {
|
|
112
113
|
if ( newSrc !== src ) {
|
|
114
|
+
const url = prependHTTPS( newSrc );
|
|
113
115
|
// Check if there's an embed block that handles this URL.
|
|
114
116
|
const embedBlock = createUpgradedEmbedBlock( {
|
|
115
|
-
attributes: { url
|
|
117
|
+
attributes: { url },
|
|
116
118
|
} );
|
|
117
119
|
if ( undefined !== embedBlock && onReplace ) {
|
|
118
120
|
onReplace( embedBlock );
|
|
@@ -120,7 +122,7 @@ function VideoEdit( {
|
|
|
120
122
|
}
|
|
121
123
|
setAttributes( {
|
|
122
124
|
blob: undefined,
|
|
123
|
-
src:
|
|
125
|
+
src: url,
|
|
124
126
|
id: undefined,
|
|
125
127
|
poster: undefined,
|
|
126
128
|
} );
|
package/build/tab/tabs-list.cjs
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/block-library/src/tab/tabs-list.js
|
|
31
|
-
var tabs_list_exports = {};
|
|
32
|
-
__export(tabs_list_exports, {
|
|
33
|
-
default: () => TabsList
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(tabs_list_exports);
|
|
36
|
-
var import_clsx = __toESM(require("clsx"));
|
|
37
|
-
var import_i18n = require("@wordpress/i18n");
|
|
38
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
39
|
-
var import_html_entities = require("@wordpress/html-entities");
|
|
40
|
-
var import_element = require("@wordpress/element");
|
|
41
|
-
var import_slug_from_label = __toESM(require("./slug-from-label.cjs"));
|
|
42
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
-
function StaticLabel({ label, index }) {
|
|
44
|
-
if (label) {
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.RawHTML, { children: (0, import_html_entities.decodeEntities)(label) }) });
|
|
46
|
-
}
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (0, import_i18n.sprintf)(
|
|
48
|
-
/* translators: %d is the tab index + 1 */
|
|
49
|
-
(0, import_i18n.__)("Tab %d"),
|
|
50
|
-
index + 1
|
|
51
|
-
) });
|
|
52
|
-
}
|
|
53
|
-
function TabsList({
|
|
54
|
-
siblingTabs,
|
|
55
|
-
currentClientId,
|
|
56
|
-
currentBlockIndex,
|
|
57
|
-
currentLabel,
|
|
58
|
-
tabItemColorProps,
|
|
59
|
-
onSelectTab,
|
|
60
|
-
onLabelChange,
|
|
61
|
-
labelRef,
|
|
62
|
-
focusRef,
|
|
63
|
-
labelElementRef
|
|
64
|
-
}) {
|
|
65
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "tablist", className: "tabs__list", children: siblingTabs.map((tab, index) => {
|
|
66
|
-
const isCurrentTab = tab.clientId === currentClientId;
|
|
67
|
-
const isSiblingTabActive = index === currentBlockIndex;
|
|
68
|
-
const tabAttributes = tab.attributes || {};
|
|
69
|
-
const siblingLabel = tabAttributes.label || "";
|
|
70
|
-
const siblingAnchor = tabAttributes.anchor || (0, import_slug_from_label.default)(siblingLabel, index);
|
|
71
|
-
const siblingTabPanelId = siblingAnchor;
|
|
72
|
-
const siblingTabLabelId = `${siblingTabPanelId}--tab`;
|
|
73
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
-
"button",
|
|
75
|
-
{
|
|
76
|
-
"aria-controls": siblingTabPanelId,
|
|
77
|
-
"aria-selected": isSiblingTabActive,
|
|
78
|
-
id: siblingTabLabelId,
|
|
79
|
-
role: "tab",
|
|
80
|
-
className: (0, import_clsx.default)(
|
|
81
|
-
"tabs__tab-label",
|
|
82
|
-
tabItemColorProps.className
|
|
83
|
-
),
|
|
84
|
-
style: {
|
|
85
|
-
...tabItemColorProps.style
|
|
86
|
-
},
|
|
87
|
-
tabIndex: isSiblingTabActive ? 0 : -1,
|
|
88
|
-
onClick: (event) => {
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
onSelectTab(tab.clientId);
|
|
91
|
-
},
|
|
92
|
-
onKeyDown: (event) => {
|
|
93
|
-
if (event.key === "Enter" && !event.shiftKey) {
|
|
94
|
-
event.preventDefault();
|
|
95
|
-
onSelectTab(tab.clientId);
|
|
96
|
-
if (isCurrentTab) {
|
|
97
|
-
const { requestAnimationFrame } = window;
|
|
98
|
-
focusRef.current = requestAnimationFrame(
|
|
99
|
-
() => {
|
|
100
|
-
labelElementRef.current?.focus();
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
children: isCurrentTab ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
-
import_block_editor.RichText,
|
|
108
|
-
{
|
|
109
|
-
ref: labelRef,
|
|
110
|
-
tagName: "span",
|
|
111
|
-
withoutInteractiveFormatting: true,
|
|
112
|
-
placeholder: (0, import_i18n.sprintf)(
|
|
113
|
-
/* translators: %d is the tab index + 1 */
|
|
114
|
-
(0, import_i18n.__)("Tab %d\u2026"),
|
|
115
|
-
currentBlockIndex + 1
|
|
116
|
-
),
|
|
117
|
-
value: (0, import_html_entities.decodeEntities)(currentLabel),
|
|
118
|
-
onChange: onLabelChange
|
|
119
|
-
}
|
|
120
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
|
-
StaticLabel,
|
|
122
|
-
{
|
|
123
|
-
label: siblingLabel,
|
|
124
|
-
index
|
|
125
|
-
}
|
|
126
|
-
)
|
|
127
|
-
},
|
|
128
|
-
tab.clientId
|
|
129
|
-
);
|
|
130
|
-
}) });
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=tabs-list.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/tab/tabs-list.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { RichText } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { RawHTML } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport slugFromLabel from './slug-from-label';\n\nfunction StaticLabel( { label, index } ) {\n\tif ( label ) {\n\t\treturn (\n\t\t\t<span>\n\t\t\t\t<RawHTML>{ decodeEntities( label ) }</RawHTML>\n\t\t\t</span>\n\t\t);\n\t}\n\treturn (\n\t\t<span>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d is the tab index + 1 */\n\t\t\t\t__( 'Tab %d' ),\n\t\t\t\tindex + 1\n\t\t\t) }\n\t\t</span>\n\t);\n}\n\nexport default function TabsList( {\n\tsiblingTabs,\n\tcurrentClientId,\n\tcurrentBlockIndex,\n\tcurrentLabel,\n\ttabItemColorProps,\n\tonSelectTab,\n\tonLabelChange,\n\tlabelRef,\n\tfocusRef,\n\tlabelElementRef,\n} ) {\n\treturn (\n\t\t<div role=\"tablist\" className=\"tabs__list\">\n\t\t\t{ siblingTabs.map( ( tab, index ) => {\n\t\t\t\tconst isCurrentTab = tab.clientId === currentClientId;\n\t\t\t\tconst isSiblingTabActive = index === currentBlockIndex;\n\t\t\t\tconst tabAttributes = tab.attributes || {};\n\t\t\t\tconst siblingLabel = tabAttributes.label || '';\n\t\t\t\tconst siblingAnchor =\n\t\t\t\t\ttabAttributes.anchor ||\n\t\t\t\t\tslugFromLabel( siblingLabel, index );\n\t\t\t\tconst siblingTabPanelId = siblingAnchor;\n\t\t\t\tconst siblingTabLabelId = `${ siblingTabPanelId }--tab`;\n\n\t\t\t\treturn (\n\t\t\t\t\t<button\n\t\t\t\t\t\tkey={ tab.clientId }\n\t\t\t\t\t\taria-controls={ siblingTabPanelId }\n\t\t\t\t\t\taria-selected={ isSiblingTabActive }\n\t\t\t\t\t\tid={ siblingTabLabelId }\n\t\t\t\t\t\trole=\"tab\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'tabs__tab-label',\n\t\t\t\t\t\t\ttabItemColorProps.className\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t...tabItemColorProps.style,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttabIndex={ isSiblingTabActive ? 0 : -1 }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonSelectTab( tab.clientId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t// If shift is also pressed, do not select the block.\n\t\t\t\t\t\t\tif ( event.key === 'Enter' && ! event.shiftKey ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tonSelectTab( tab.clientId );\n\t\t\t\t\t\t\t\tif ( isCurrentTab ) {\n\t\t\t\t\t\t\t\t\tconst { requestAnimationFrame } = window;\n\t\t\t\t\t\t\t\t\tfocusRef.current = requestAnimationFrame(\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tlabelElementRef.current?.focus();\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}\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isCurrentTab ? (\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tref={ labelRef }\n\t\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d is the tab index + 1 */\n\t\t\t\t\t\t\t\t\t__( 'Tab %d\u2026' ),\n\t\t\t\t\t\t\t\t\tcurrentBlockIndex + 1\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvalue={ decodeEntities( currentLabel ) }\n\t\t\t\t\t\t\t\tonChange={ onLabelChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<StaticLabel\n\t\t\t\t\t\t\t\tlabel={ siblingLabel }\n\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA4B;AAC5B,0BAAyB;AACzB,2BAA+B;AAC/B,qBAAwB;AAKxB,6BAA0B;AAMtB;AAJJ,SAAS,YAAa,EAAE,OAAO,MAAM,GAAI;AACxC,MAAK,OAAQ;AACZ,WACC,4CAAC,UACA,sDAAC,0BAAU,mDAAgB,KAAM,GAAG,GACrC;AAAA,EAEF;AACA,SACC,4CAAC,UACE;AAAA;AAAA,QAED,gBAAI,QAAS;AAAA,IACb,QAAQ;AAAA,EACT,GACD;AAEF;AAEe,SAAR,SAA2B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,4CAAC,SAAI,MAAK,WAAU,WAAU,cAC3B,sBAAY,IAAK,CAAE,KAAK,UAAW;AACpC,UAAM,eAAe,IAAI,aAAa;AACtC,UAAM,qBAAqB,UAAU;AACrC,UAAM,gBAAgB,IAAI,cAAc,CAAC;AACzC,UAAM,eAAe,cAAc,SAAS;AAC5C,UAAM,gBACL,cAAc,cACd,uBAAAA,SAAe,cAAc,KAAM;AACpC,UAAM,oBAAoB;AAC1B,UAAM,oBAAoB,GAAI,iBAAkB;AAEhD,WACC;AAAA,MAAC;AAAA;AAAA,QAEA,iBAAgB;AAAA,QAChB,iBAAgB;AAAA,QAChB,IAAK;AAAA,QACL,MAAK;AAAA,QACL,eAAY,YAAAC;AAAA,UACX;AAAA,UACA,kBAAkB;AAAA,QACnB;AAAA,QACA,OAAQ;AAAA,UACP,GAAG,kBAAkB;AAAA,QACtB;AAAA,QACA,UAAW,qBAAqB,IAAI;AAAA,QACpC,SAAU,CAAE,UAAW;AACtB,gBAAM,eAAe;AACrB,sBAAa,IAAI,QAAS;AAAA,QAC3B;AAAA,QACA,WAAY,CAAE,UAAW;AAExB,cAAK,MAAM,QAAQ,WAAW,CAAE,MAAM,UAAW;AAChD,kBAAM,eAAe;AACrB,wBAAa,IAAI,QAAS;AAC1B,gBAAK,cAAe;AACnB,oBAAM,EAAE,sBAAsB,IAAI;AAClC,uBAAS,UAAU;AAAA,gBAClB,MAAM;AACL,kCAAgB,SAAS,MAAM;AAAA,gBAChC;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,QAEE,yBACD;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,SAAQ;AAAA,YACR,8BAA4B;AAAA,YAC5B,iBAAc;AAAA;AAAA,kBAEb,gBAAI,cAAU;AAAA,cACd,oBAAoB;AAAA,YACrB;AAAA,YACA,WAAQ,qCAAgB,YAAa;AAAA,YACrC,UAAW;AAAA;AAAA,QACZ,IAEA;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ;AAAA,YACR;AAAA;AAAA,QACD;AAAA;AAAA,MAlDK,IAAI;AAAA,IAoDX;AAAA,EAEF,CAAE,GACH;AAEF;",
|
|
6
|
-
"names": ["slugFromLabel", "clsx"]
|
|
7
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/block-library/src/tabs/style-engine.js
|
|
21
|
-
var style_engine_exports = {};
|
|
22
|
-
__export(style_engine_exports, {
|
|
23
|
-
default: () => StyleEngine
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(style_engine_exports);
|
|
26
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
27
|
-
function getGapStyles({ attributes }) {
|
|
28
|
-
const { style, orientation } = attributes || {};
|
|
29
|
-
const { spacing } = style || {};
|
|
30
|
-
const { blockGap } = spacing || {};
|
|
31
|
-
const fallbackValue = `var( --wp--style--tabs-gap-default, var( --wp--style--block-gap, 0.5em ) )`;
|
|
32
|
-
let listGapValue = fallbackValue;
|
|
33
|
-
let gapValue = fallbackValue;
|
|
34
|
-
if (!!blockGap) {
|
|
35
|
-
listGapValue = typeof blockGap === "string" ? (0, import_block_editor.__experimentalGetGapCSSValue)(blockGap) : (0, import_block_editor.__experimentalGetGapCSSValue)(blockGap?.left) || fallbackValue;
|
|
36
|
-
gapValue = typeof blockGap === "string" ? (0, import_block_editor.__experimentalGetGapCSSValue)(blockGap) : (0, import_block_editor.__experimentalGetGapCSSValue)(blockGap?.top) || fallbackValue;
|
|
37
|
-
}
|
|
38
|
-
if (orientation === "vertical") {
|
|
39
|
-
const _listGapValue = listGapValue;
|
|
40
|
-
const _gapValue = gapValue;
|
|
41
|
-
listGapValue = _gapValue;
|
|
42
|
-
gapValue = _listGapValue;
|
|
43
|
-
}
|
|
44
|
-
const gapMap = {
|
|
45
|
-
"--wp--style--unstable-tabs-list-gap": listGapValue === "0" ? "0px" : listGapValue,
|
|
46
|
-
"--wp--style--unstable-tabs-gap": gapValue
|
|
47
|
-
};
|
|
48
|
-
return gapMap;
|
|
49
|
-
}
|
|
50
|
-
function getColorStyles({ attributes }) {
|
|
51
|
-
const {
|
|
52
|
-
customTabInactiveColor,
|
|
53
|
-
customTabHoverColor,
|
|
54
|
-
customTabActiveColor,
|
|
55
|
-
customTabTextColor,
|
|
56
|
-
customTabActiveTextColor,
|
|
57
|
-
customTabHoverTextColor
|
|
58
|
-
} = attributes || {};
|
|
59
|
-
function getColorValue(color) {
|
|
60
|
-
if (!color) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
if (typeof color === "object" && color.slug) {
|
|
64
|
-
return `var(--wp--preset--color--${color.slug})`;
|
|
65
|
-
}
|
|
66
|
-
return color;
|
|
67
|
-
}
|
|
68
|
-
const colorVarMap = {
|
|
69
|
-
"--custom-tab-inactive-color": getColorValue(customTabInactiveColor),
|
|
70
|
-
"--custom-tab-active-color": getColorValue(customTabActiveColor),
|
|
71
|
-
"--custom-tab-hover-color": getColorValue(customTabHoverColor),
|
|
72
|
-
"--custom-tab-text-color": getColorValue(customTabTextColor),
|
|
73
|
-
"--custom-tab-active-text-color": getColorValue(
|
|
74
|
-
customTabActiveTextColor
|
|
75
|
-
),
|
|
76
|
-
"--custom-tab-hover-text-color": getColorValue(
|
|
77
|
-
customTabHoverTextColor
|
|
78
|
-
)
|
|
79
|
-
};
|
|
80
|
-
return colorVarMap;
|
|
81
|
-
}
|
|
82
|
-
function getBorderStyles({ attributes }) {
|
|
83
|
-
const { radius } = attributes?.style?.border || {};
|
|
84
|
-
if (!radius) {
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
let radiusValue = radius;
|
|
88
|
-
if (typeof radius === "object") {
|
|
89
|
-
const {
|
|
90
|
-
topLeft = "0",
|
|
91
|
-
topRight = "0",
|
|
92
|
-
bottomRight = "0",
|
|
93
|
-
bottomLeft = "0"
|
|
94
|
-
} = radius;
|
|
95
|
-
radiusValue = `${topLeft} ${topRight} ${bottomRight} ${bottomLeft}`;
|
|
96
|
-
}
|
|
97
|
-
const borderMap = {
|
|
98
|
-
"--tab-border-radius": radiusValue
|
|
99
|
-
};
|
|
100
|
-
return borderMap;
|
|
101
|
-
}
|
|
102
|
-
function StyleEngine({ attributes, clientId }) {
|
|
103
|
-
const gapVarMap = getGapStyles({ attributes });
|
|
104
|
-
const colorVarMap = getColorStyles({ attributes });
|
|
105
|
-
const borderVarMap = getBorderStyles({ attributes });
|
|
106
|
-
const styleVarMap = {
|
|
107
|
-
...gapVarMap,
|
|
108
|
-
...colorVarMap,
|
|
109
|
-
...borderVarMap
|
|
110
|
-
};
|
|
111
|
-
const declarations = Object.entries(styleVarMap).filter(([, value]) => !!value).map(([name, value]) => ` ${name}: ${value};`).join("\n");
|
|
112
|
-
(0, import_block_editor.useStyleOverride)({
|
|
113
|
-
css: clientId ? `#block-${clientId} {
|
|
114
|
-
${declarations}
|
|
115
|
-
}` : ""
|
|
116
|
-
});
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=style-engine.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/tabs/style-engine.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalGetGapCSSValue as getGapCSSValue,\n\tuseStyleOverride,\n} from '@wordpress/block-editor';\n\n/**\n * Gets the gap styles for the tab block.\n * @param {Object} props\n * @param {Object} props.attributes Block attributes\n * @return {Object} CSS custom properties for gap styles\n */\nfunction getGapStyles( { attributes } ) {\n\tconst { style, orientation } = attributes || {};\n\tconst { spacing } = style || {};\n\tconst { blockGap } = spacing || {};\n\t//--wp--style--tabs-list-gap-default should be used by themes that want to set a default\n\t// gap on the tabs list.\n\tconst fallbackValue = `var( --wp--style--tabs-gap-default, var( --wp--style--block-gap, 0.5em ) )`;\n\tlet listGapValue = fallbackValue;\n\tlet gapValue = fallbackValue;\n\n\t// Check for a value.\n\tif ( !! blockGap ) {\n\t\tlistGapValue =\n\t\t\ttypeof blockGap === 'string'\n\t\t\t\t? getGapCSSValue( blockGap )\n\t\t\t\t: getGapCSSValue( blockGap?.left ) || fallbackValue;\n\t\tgapValue =\n\t\t\ttypeof blockGap === 'string'\n\t\t\t\t? getGapCSSValue( blockGap )\n\t\t\t\t: getGapCSSValue( blockGap?.top ) || fallbackValue;\n\t}\n\n\tif ( orientation === 'vertical' ) {\n\t\tconst _listGapValue = listGapValue;\n\t\tconst _gapValue = gapValue;\n\t\tlistGapValue = _gapValue;\n\t\tgapValue = _listGapValue;\n\t}\n\n\t// The unstable tabs list gap calculation requires a real value (such as `0px`) and not `0`.\n\tconst gapMap = {\n\t\t'--wp--style--unstable-tabs-list-gap':\n\t\t\tlistGapValue === '0' ? '0px' : listGapValue,\n\t\t'--wp--style--unstable-tabs-gap': gapValue,\n\t};\n\n\treturn gapMap;\n}\n\n/**\n * Gets the color styles for the tab block.\n *\n * @param {Object} props\n * @param {Object} props.attributes Block attributes\n * @return {Object} CSS custom properties for color styles\n */\nfunction getColorStyles( { attributes } ) {\n\tconst {\n\t\tcustomTabInactiveColor,\n\t\tcustomTabHoverColor,\n\t\tcustomTabActiveColor,\n\t\tcustomTabTextColor,\n\t\tcustomTabActiveTextColor,\n\t\tcustomTabHoverTextColor,\n\t} = attributes || {};\n\n\t// Helper to normalize color objects (preset { slug } vs direct value).\n\tfunction getColorValue( color ) {\n\t\tif ( ! color ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( typeof color === 'object' && color.slug ) {\n\t\t\treturn `var(--wp--preset--color--${ color.slug })`;\n\t\t}\n\t\treturn color;\n\t}\n\n\tconst colorVarMap = {\n\t\t'--custom-tab-inactive-color': getColorValue( customTabInactiveColor ),\n\t\t'--custom-tab-active-color': getColorValue( customTabActiveColor ),\n\t\t'--custom-tab-hover-color': getColorValue( customTabHoverColor ),\n\t\t'--custom-tab-text-color': getColorValue( customTabTextColor ),\n\t\t'--custom-tab-active-text-color': getColorValue(\n\t\t\tcustomTabActiveTextColor\n\t\t),\n\t\t'--custom-tab-hover-text-color': getColorValue(\n\t\t\tcustomTabHoverTextColor\n\t\t),\n\t};\n\n\treturn colorVarMap;\n}\n\n/**\n * Gets the border styles for the tab block.\n *\n * @param {Object} props\n * @param {Object} props.attributes Block attributes\n * @return {Object} CSS custom properties for border styles\n */\nfunction getBorderStyles( { attributes } ) {\n\tconst { radius } = attributes?.style?.border || {};\n\n\tif ( ! radius ) {\n\t\treturn {};\n\t}\n\n\tlet radiusValue = radius;\n\n\tif ( typeof radius === 'object' ) {\n\t\tconst {\n\t\t\ttopLeft = '0',\n\t\t\ttopRight = '0',\n\t\t\tbottomRight = '0',\n\t\t\tbottomLeft = '0',\n\t\t} = radius;\n\t\tradiusValue = `${ topLeft } ${ topRight } ${ bottomRight } ${ bottomLeft }`;\n\t}\n\n\tconst borderMap = {\n\t\t'--tab-border-radius': radiusValue,\n\t};\n\n\treturn borderMap;\n}\n\n/**\n * Injects color CSS custom properties for the tabs block, mirroring the pattern\n * used by gap-styles (scoped to `#block-{ clientId }`). This replaces the prior\n * inline-style object return value approach so that these values participate in\n * style engine cascade like other dynamic style overrides.\n *\n * @param {Object} props\n * @param {Object} props.attributes Block attributes\n * @param {string} props.clientId Block client ID\n * @return {null} No UI output\n */\nexport default function StyleEngine( { attributes, clientId } ) {\n\tconst gapVarMap = getGapStyles( { attributes } );\n\tconst colorVarMap = getColorStyles( { attributes } );\n\tconst borderVarMap = getBorderStyles( { attributes } );\n\n\tconst styleVarMap = {\n\t\t...gapVarMap,\n\t\t...colorVarMap,\n\t\t...borderVarMap,\n\t};\n\n\t// Build scoped CSS only for defined values to avoid unnecessary empty declarations.\n\tconst declarations = Object.entries( styleVarMap )\n\t\t.filter( ( [ , value ] ) => !! value )\n\t\t.map( ( [ name, value ] ) => `\\t${ name }: ${ value };` )\n\t\t.join( '\\n' );\n\n\tuseStyleOverride( {\n\t\tcss: clientId ? `#block-${ clientId } {\\n${ declarations }\\n}` : '',\n\t} );\n\n\treturn null;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAGO;AAQP,SAAS,aAAc,EAAE,WAAW,GAAI;AACvC,QAAM,EAAE,OAAO,YAAY,IAAI,cAAc,CAAC;AAC9C,QAAM,EAAE,QAAQ,IAAI,SAAS,CAAC;AAC9B,QAAM,EAAE,SAAS,IAAI,WAAW,CAAC;AAGjC,QAAM,gBAAgB;AACtB,MAAI,eAAe;AACnB,MAAI,WAAW;AAGf,MAAK,CAAC,CAAE,UAAW;AAClB,mBACC,OAAO,aAAa,eACjB,oBAAAA,8BAAgB,QAAS,QACzB,oBAAAA,8BAAgB,UAAU,IAAK,KAAK;AACxC,eACC,OAAO,aAAa,eACjB,oBAAAA,8BAAgB,QAAS,QACzB,oBAAAA,8BAAgB,UAAU,GAAI,KAAK;AAAA,EACxC;AAEA,MAAK,gBAAgB,YAAa;AACjC,UAAM,gBAAgB;AACtB,UAAM,YAAY;AAClB,mBAAe;AACf,eAAW;AAAA,EACZ;AAGA,QAAM,SAAS;AAAA,IACd,uCACC,iBAAiB,MAAM,QAAQ;AAAA,IAChC,kCAAkC;AAAA,EACnC;AAEA,SAAO;AACR;AASA,SAAS,eAAgB,EAAE,WAAW,GAAI;AACzC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,cAAc,CAAC;AAGnB,WAAS,cAAe,OAAQ;AAC/B,QAAK,CAAE,OAAQ;AACd,aAAO;AAAA,IACR;AACA,QAAK,OAAO,UAAU,YAAY,MAAM,MAAO;AAC9C,aAAO,4BAA6B,MAAM,IAAK;AAAA,IAChD;AACA,WAAO;AAAA,EACR;AAEA,QAAM,cAAc;AAAA,IACnB,+BAA+B,cAAe,sBAAuB;AAAA,IACrE,6BAA6B,cAAe,oBAAqB;AAAA,IACjE,4BAA4B,cAAe,mBAAoB;AAAA,IAC/D,2BAA2B,cAAe,kBAAmB;AAAA,IAC7D,kCAAkC;AAAA,MACjC;AAAA,IACD;AAAA,IACA,iCAAiC;AAAA,MAChC;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AASA,SAAS,gBAAiB,EAAE,WAAW,GAAI;AAC1C,QAAM,EAAE,OAAO,IAAI,YAAY,OAAO,UAAU,CAAC;AAEjD,MAAK,CAAE,QAAS;AACf,WAAO,CAAC;AAAA,EACT;AAEA,MAAI,cAAc;AAElB,MAAK,OAAO,WAAW,UAAW;AACjC,UAAM;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,cAAc;AAAA,MACd,aAAa;AAAA,IACd,IAAI;AACJ,kBAAc,GAAI,OAAQ,IAAK,QAAS,IAAK,WAAY,IAAK,UAAW;AAAA,EAC1E;AAEA,QAAM,YAAY;AAAA,IACjB,uBAAuB;AAAA,EACxB;AAEA,SAAO;AACR;AAae,SAAR,YAA8B,EAAE,YAAY,SAAS,GAAI;AAC/D,QAAM,YAAY,aAAc,EAAE,WAAW,CAAE;AAC/C,QAAM,cAAc,eAAgB,EAAE,WAAW,CAAE;AACnD,QAAM,eAAe,gBAAiB,EAAE,WAAW,CAAE;AAErD,QAAM,cAAc;AAAA,IACnB,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AAGA,QAAM,eAAe,OAAO,QAAS,WAAY,EAC/C,OAAQ,CAAE,CAAE,EAAE,KAAM,MAAO,CAAC,CAAE,KAAM,EACpC,IAAK,CAAE,CAAE,MAAM,KAAM,MAAO,IAAM,IAAK,KAAM,KAAM,GAAI,EACvD,KAAM,IAAK;AAEb,4CAAkB;AAAA,IACjB,KAAK,WAAW,UAAW,QAAS;AAAA,EAAQ,YAAa;AAAA,KAAQ;AAAA,EAClE,CAAE;AAEF,SAAO;AACR;",
|
|
6
|
-
"names": ["getGapCSSValue"]
|
|
7
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// packages/block-library/src/tab/tabs-list.js
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import { __, sprintf } from "@wordpress/i18n";
|
|
4
|
-
import { RichText } from "@wordpress/block-editor";
|
|
5
|
-
import { decodeEntities } from "@wordpress/html-entities";
|
|
6
|
-
import { RawHTML } from "@wordpress/element";
|
|
7
|
-
import slugFromLabel from "./slug-from-label.mjs";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
function StaticLabel({ label, index }) {
|
|
10
|
-
if (label) {
|
|
11
|
-
return /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(RawHTML, { children: decodeEntities(label) }) });
|
|
12
|
-
}
|
|
13
|
-
return /* @__PURE__ */ jsx("span", { children: sprintf(
|
|
14
|
-
/* translators: %d is the tab index + 1 */
|
|
15
|
-
__("Tab %d"),
|
|
16
|
-
index + 1
|
|
17
|
-
) });
|
|
18
|
-
}
|
|
19
|
-
function TabsList({
|
|
20
|
-
siblingTabs,
|
|
21
|
-
currentClientId,
|
|
22
|
-
currentBlockIndex,
|
|
23
|
-
currentLabel,
|
|
24
|
-
tabItemColorProps,
|
|
25
|
-
onSelectTab,
|
|
26
|
-
onLabelChange,
|
|
27
|
-
labelRef,
|
|
28
|
-
focusRef,
|
|
29
|
-
labelElementRef
|
|
30
|
-
}) {
|
|
31
|
-
return /* @__PURE__ */ jsx("div", { role: "tablist", className: "tabs__list", children: siblingTabs.map((tab, index) => {
|
|
32
|
-
const isCurrentTab = tab.clientId === currentClientId;
|
|
33
|
-
const isSiblingTabActive = index === currentBlockIndex;
|
|
34
|
-
const tabAttributes = tab.attributes || {};
|
|
35
|
-
const siblingLabel = tabAttributes.label || "";
|
|
36
|
-
const siblingAnchor = tabAttributes.anchor || slugFromLabel(siblingLabel, index);
|
|
37
|
-
const siblingTabPanelId = siblingAnchor;
|
|
38
|
-
const siblingTabLabelId = `${siblingTabPanelId}--tab`;
|
|
39
|
-
return /* @__PURE__ */ jsx(
|
|
40
|
-
"button",
|
|
41
|
-
{
|
|
42
|
-
"aria-controls": siblingTabPanelId,
|
|
43
|
-
"aria-selected": isSiblingTabActive,
|
|
44
|
-
id: siblingTabLabelId,
|
|
45
|
-
role: "tab",
|
|
46
|
-
className: clsx(
|
|
47
|
-
"tabs__tab-label",
|
|
48
|
-
tabItemColorProps.className
|
|
49
|
-
),
|
|
50
|
-
style: {
|
|
51
|
-
...tabItemColorProps.style
|
|
52
|
-
},
|
|
53
|
-
tabIndex: isSiblingTabActive ? 0 : -1,
|
|
54
|
-
onClick: (event) => {
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
onSelectTab(tab.clientId);
|
|
57
|
-
},
|
|
58
|
-
onKeyDown: (event) => {
|
|
59
|
-
if (event.key === "Enter" && !event.shiftKey) {
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
onSelectTab(tab.clientId);
|
|
62
|
-
if (isCurrentTab) {
|
|
63
|
-
const { requestAnimationFrame } = window;
|
|
64
|
-
focusRef.current = requestAnimationFrame(
|
|
65
|
-
() => {
|
|
66
|
-
labelElementRef.current?.focus();
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
children: isCurrentTab ? /* @__PURE__ */ jsx(
|
|
73
|
-
RichText,
|
|
74
|
-
{
|
|
75
|
-
ref: labelRef,
|
|
76
|
-
tagName: "span",
|
|
77
|
-
withoutInteractiveFormatting: true,
|
|
78
|
-
placeholder: sprintf(
|
|
79
|
-
/* translators: %d is the tab index + 1 */
|
|
80
|
-
__("Tab %d\u2026"),
|
|
81
|
-
currentBlockIndex + 1
|
|
82
|
-
),
|
|
83
|
-
value: decodeEntities(currentLabel),
|
|
84
|
-
onChange: onLabelChange
|
|
85
|
-
}
|
|
86
|
-
) : /* @__PURE__ */ jsx(
|
|
87
|
-
StaticLabel,
|
|
88
|
-
{
|
|
89
|
-
label: siblingLabel,
|
|
90
|
-
index
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
},
|
|
94
|
-
tab.clientId
|
|
95
|
-
);
|
|
96
|
-
}) });
|
|
97
|
-
}
|
|
98
|
-
export {
|
|
99
|
-
TabsList as default
|
|
100
|
-
};
|
|
101
|
-
//# sourceMappingURL=tabs-list.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/tab/tabs-list.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { RichText } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { RawHTML } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport slugFromLabel from './slug-from-label';\n\nfunction StaticLabel( { label, index } ) {\n\tif ( label ) {\n\t\treturn (\n\t\t\t<span>\n\t\t\t\t<RawHTML>{ decodeEntities( label ) }</RawHTML>\n\t\t\t</span>\n\t\t);\n\t}\n\treturn (\n\t\t<span>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d is the tab index + 1 */\n\t\t\t\t__( 'Tab %d' ),\n\t\t\t\tindex + 1\n\t\t\t) }\n\t\t</span>\n\t);\n}\n\nexport default function TabsList( {\n\tsiblingTabs,\n\tcurrentClientId,\n\tcurrentBlockIndex,\n\tcurrentLabel,\n\ttabItemColorProps,\n\tonSelectTab,\n\tonLabelChange,\n\tlabelRef,\n\tfocusRef,\n\tlabelElementRef,\n} ) {\n\treturn (\n\t\t<div role=\"tablist\" className=\"tabs__list\">\n\t\t\t{ siblingTabs.map( ( tab, index ) => {\n\t\t\t\tconst isCurrentTab = tab.clientId === currentClientId;\n\t\t\t\tconst isSiblingTabActive = index === currentBlockIndex;\n\t\t\t\tconst tabAttributes = tab.attributes || {};\n\t\t\t\tconst siblingLabel = tabAttributes.label || '';\n\t\t\t\tconst siblingAnchor =\n\t\t\t\t\ttabAttributes.anchor ||\n\t\t\t\t\tslugFromLabel( siblingLabel, index );\n\t\t\t\tconst siblingTabPanelId = siblingAnchor;\n\t\t\t\tconst siblingTabLabelId = `${ siblingTabPanelId }--tab`;\n\n\t\t\t\treturn (\n\t\t\t\t\t<button\n\t\t\t\t\t\tkey={ tab.clientId }\n\t\t\t\t\t\taria-controls={ siblingTabPanelId }\n\t\t\t\t\t\taria-selected={ isSiblingTabActive }\n\t\t\t\t\t\tid={ siblingTabLabelId }\n\t\t\t\t\t\trole=\"tab\"\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'tabs__tab-label',\n\t\t\t\t\t\t\ttabItemColorProps.className\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t...tabItemColorProps.style,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttabIndex={ isSiblingTabActive ? 0 : -1 }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonSelectTab( tab.clientId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t// If shift is also pressed, do not select the block.\n\t\t\t\t\t\t\tif ( event.key === 'Enter' && ! event.shiftKey ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tonSelectTab( tab.clientId );\n\t\t\t\t\t\t\t\tif ( isCurrentTab ) {\n\t\t\t\t\t\t\t\t\tconst { requestAnimationFrame } = window;\n\t\t\t\t\t\t\t\t\tfocusRef.current = requestAnimationFrame(\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tlabelElementRef.current?.focus();\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}\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isCurrentTab ? (\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tref={ labelRef }\n\t\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tplaceholder={ sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d is the tab index + 1 */\n\t\t\t\t\t\t\t\t\t__( 'Tab %d\u2026' ),\n\t\t\t\t\t\t\t\t\tcurrentBlockIndex + 1\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tvalue={ decodeEntities( currentLabel ) }\n\t\t\t\t\t\t\t\tonChange={ onLabelChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<StaticLabel\n\t\t\t\t\t\t\t\tlabel={ siblingLabel }\n\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,eAAe;AAC5B,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAKxB,OAAO,mBAAmB;AAMtB;AAJJ,SAAS,YAAa,EAAE,OAAO,MAAM,GAAI;AACxC,MAAK,OAAQ;AACZ,WACC,oBAAC,UACA,8BAAC,WAAU,yBAAgB,KAAM,GAAG,GACrC;AAAA,EAEF;AACA,SACC,oBAAC,UACE;AAAA;AAAA,IAED,GAAI,QAAS;AAAA,IACb,QAAQ;AAAA,EACT,GACD;AAEF;AAEe,SAAR,SAA2B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,oBAAC,SAAI,MAAK,WAAU,WAAU,cAC3B,sBAAY,IAAK,CAAE,KAAK,UAAW;AACpC,UAAM,eAAe,IAAI,aAAa;AACtC,UAAM,qBAAqB,UAAU;AACrC,UAAM,gBAAgB,IAAI,cAAc,CAAC;AACzC,UAAM,eAAe,cAAc,SAAS;AAC5C,UAAM,gBACL,cAAc,UACd,cAAe,cAAc,KAAM;AACpC,UAAM,oBAAoB;AAC1B,UAAM,oBAAoB,GAAI,iBAAkB;AAEhD,WACC;AAAA,MAAC;AAAA;AAAA,QAEA,iBAAgB;AAAA,QAChB,iBAAgB;AAAA,QAChB,IAAK;AAAA,QACL,MAAK;AAAA,QACL,WAAY;AAAA,UACX;AAAA,UACA,kBAAkB;AAAA,QACnB;AAAA,QACA,OAAQ;AAAA,UACP,GAAG,kBAAkB;AAAA,QACtB;AAAA,QACA,UAAW,qBAAqB,IAAI;AAAA,QACpC,SAAU,CAAE,UAAW;AACtB,gBAAM,eAAe;AACrB,sBAAa,IAAI,QAAS;AAAA,QAC3B;AAAA,QACA,WAAY,CAAE,UAAW;AAExB,cAAK,MAAM,QAAQ,WAAW,CAAE,MAAM,UAAW;AAChD,kBAAM,eAAe;AACrB,wBAAa,IAAI,QAAS;AAC1B,gBAAK,cAAe;AACnB,oBAAM,EAAE,sBAAsB,IAAI;AAClC,uBAAS,UAAU;AAAA,gBAClB,MAAM;AACL,kCAAgB,SAAS,MAAM;AAAA,gBAChC;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,QAEE,yBACD;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,SAAQ;AAAA,YACR,8BAA4B;AAAA,YAC5B,aAAc;AAAA;AAAA,cAEb,GAAI,cAAU;AAAA,cACd,oBAAoB;AAAA,YACrB;AAAA,YACA,OAAQ,eAAgB,YAAa;AAAA,YACrC,UAAW;AAAA;AAAA,QACZ,IAEA;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ;AAAA,YACR;AAAA;AAAA,QACD;AAAA;AAAA,MAlDK,IAAI;AAAA,IAoDX;AAAA,EAEF,CAAE,GACH;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// packages/block-library/src/tabs/style-engine.js
|
|
2
|
-
import {
|
|
3
|
-
__experimentalGetGapCSSValue as getGapCSSValue,
|
|
4
|
-
useStyleOverride
|
|
5
|
-
} from "@wordpress/block-editor";
|
|
6
|
-
function getGapStyles({ attributes }) {
|
|
7
|
-
const { style, orientation } = attributes || {};
|
|
8
|
-
const { spacing } = style || {};
|
|
9
|
-
const { blockGap } = spacing || {};
|
|
10
|
-
const fallbackValue = `var( --wp--style--tabs-gap-default, var( --wp--style--block-gap, 0.5em ) )`;
|
|
11
|
-
let listGapValue = fallbackValue;
|
|
12
|
-
let gapValue = fallbackValue;
|
|
13
|
-
if (!!blockGap) {
|
|
14
|
-
listGapValue = typeof blockGap === "string" ? getGapCSSValue(blockGap) : getGapCSSValue(blockGap?.left) || fallbackValue;
|
|
15
|
-
gapValue = typeof blockGap === "string" ? getGapCSSValue(blockGap) : getGapCSSValue(blockGap?.top) || fallbackValue;
|
|
16
|
-
}
|
|
17
|
-
if (orientation === "vertical") {
|
|
18
|
-
const _listGapValue = listGapValue;
|
|
19
|
-
const _gapValue = gapValue;
|
|
20
|
-
listGapValue = _gapValue;
|
|
21
|
-
gapValue = _listGapValue;
|
|
22
|
-
}
|
|
23
|
-
const gapMap = {
|
|
24
|
-
"--wp--style--unstable-tabs-list-gap": listGapValue === "0" ? "0px" : listGapValue,
|
|
25
|
-
"--wp--style--unstable-tabs-gap": gapValue
|
|
26
|
-
};
|
|
27
|
-
return gapMap;
|
|
28
|
-
}
|
|
29
|
-
function getColorStyles({ attributes }) {
|
|
30
|
-
const {
|
|
31
|
-
customTabInactiveColor,
|
|
32
|
-
customTabHoverColor,
|
|
33
|
-
customTabActiveColor,
|
|
34
|
-
customTabTextColor,
|
|
35
|
-
customTabActiveTextColor,
|
|
36
|
-
customTabHoverTextColor
|
|
37
|
-
} = attributes || {};
|
|
38
|
-
function getColorValue(color) {
|
|
39
|
-
if (!color) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
if (typeof color === "object" && color.slug) {
|
|
43
|
-
return `var(--wp--preset--color--${color.slug})`;
|
|
44
|
-
}
|
|
45
|
-
return color;
|
|
46
|
-
}
|
|
47
|
-
const colorVarMap = {
|
|
48
|
-
"--custom-tab-inactive-color": getColorValue(customTabInactiveColor),
|
|
49
|
-
"--custom-tab-active-color": getColorValue(customTabActiveColor),
|
|
50
|
-
"--custom-tab-hover-color": getColorValue(customTabHoverColor),
|
|
51
|
-
"--custom-tab-text-color": getColorValue(customTabTextColor),
|
|
52
|
-
"--custom-tab-active-text-color": getColorValue(
|
|
53
|
-
customTabActiveTextColor
|
|
54
|
-
),
|
|
55
|
-
"--custom-tab-hover-text-color": getColorValue(
|
|
56
|
-
customTabHoverTextColor
|
|
57
|
-
)
|
|
58
|
-
};
|
|
59
|
-
return colorVarMap;
|
|
60
|
-
}
|
|
61
|
-
function getBorderStyles({ attributes }) {
|
|
62
|
-
const { radius } = attributes?.style?.border || {};
|
|
63
|
-
if (!radius) {
|
|
64
|
-
return {};
|
|
65
|
-
}
|
|
66
|
-
let radiusValue = radius;
|
|
67
|
-
if (typeof radius === "object") {
|
|
68
|
-
const {
|
|
69
|
-
topLeft = "0",
|
|
70
|
-
topRight = "0",
|
|
71
|
-
bottomRight = "0",
|
|
72
|
-
bottomLeft = "0"
|
|
73
|
-
} = radius;
|
|
74
|
-
radiusValue = `${topLeft} ${topRight} ${bottomRight} ${bottomLeft}`;
|
|
75
|
-
}
|
|
76
|
-
const borderMap = {
|
|
77
|
-
"--tab-border-radius": radiusValue
|
|
78
|
-
};
|
|
79
|
-
return borderMap;
|
|
80
|
-
}
|
|
81
|
-
function StyleEngine({ attributes, clientId }) {
|
|
82
|
-
const gapVarMap = getGapStyles({ attributes });
|
|
83
|
-
const colorVarMap = getColorStyles({ attributes });
|
|
84
|
-
const borderVarMap = getBorderStyles({ attributes });
|
|
85
|
-
const styleVarMap = {
|
|
86
|
-
...gapVarMap,
|
|
87
|
-
...colorVarMap,
|
|
88
|
-
...borderVarMap
|
|
89
|
-
};
|
|
90
|
-
const declarations = Object.entries(styleVarMap).filter(([, value]) => !!value).map(([name, value]) => ` ${name}: ${value};`).join("\n");
|
|
91
|
-
useStyleOverride({
|
|
92
|
-
css: clientId ? `#block-${clientId} {
|
|
93
|
-
${declarations}
|
|
94
|
-
}` : ""
|
|
95
|
-
});
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
export {
|
|
99
|
-
StyleEngine as default
|
|
100
|
-
};
|
|
101
|
-
//# sourceMappingURL=style-engine.mjs.map
|