@wordpress/block-library 7.1.1 → 7.2.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 +11 -0
- package/build/avatar/edit.js +205 -0
- package/build/avatar/edit.js.map +1 -0
- package/build/avatar/hooks.js +111 -0
- package/build/avatar/hooks.js.map +1 -0
- package/build/avatar/index.js +83 -0
- package/build/avatar/index.js.map +1 -0
- package/build/avatar/user-control.js +63 -0
- package/build/avatar/user-control.js.map +1 -0
- package/build/column/index.js +2 -1
- package/build/column/index.js.map +1 -1
- package/build/comment-author-avatar/index.js +1 -0
- package/build/comment-author-avatar/index.js.map +1 -1
- package/build/comment-date/edit.js +10 -25
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-template/edit.js +79 -52
- package/build/comment-template/edit.js.map +1 -1
- package/build/cover/edit.js +23 -33
- package/build/cover/edit.js.map +1 -1
- package/build/embed/variations.js +2 -2
- package/build/embed/variations.js.map +1 -1
- package/build/gallery/edit.js +18 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gap-styles.js +29 -0
- package/build/gallery/gap-styles.js.map +1 -0
- package/build/gallery/index.js +17 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +3 -1
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +1 -2
- package/build/group/variations.js.map +1 -1
- package/build/image/image.js +3 -1
- package/build/image/image.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/list/index.js +5 -7
- package/build/list/index.js.map +1 -1
- package/build/list/v2/edit.js +85 -0
- package/build/list/v2/edit.js.map +1 -0
- package/build/list/v2/index.js +33 -0
- package/build/list/v2/index.js.map +1 -0
- package/build/list/v2/save.js +34 -0
- package/build/list/v2/save.js.map +1 -0
- package/build/list/v2/transforms.js +121 -0
- package/build/list/v2/transforms.js.map +1 -0
- package/build/list-item/edit.js +47 -0
- package/build/list-item/edit.js.map +1 -0
- package/build/list-item/index.js +67 -0
- package/build/list-item/index.js.map +1 -0
- package/build/list-item/save.js +23 -0
- package/build/list-item/save.js.map +1 -0
- package/build/media-text/edit.js +3 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +26 -54
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation-link/edit.js +88 -34
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-date/edit.js +31 -37
- package/build/post-date/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/pullquote/edit.js +5 -3
- package/build/pullquote/edit.js.map +1 -1
- package/build/query/variations.js +4 -4
- package/build/query/variations.js.map +1 -1
- package/build/query-no-results/edit.js +28 -0
- package/build/query-no-results/edit.js.map +1 -0
- package/build/query-no-results/index.js +54 -0
- package/build/query-no-results/index.js.map +1 -0
- package/build/query-no-results/save.js +18 -0
- package/build/query-no-results/save.js.map +1 -0
- package/build/search/edit.js +2 -3
- package/build/search/edit.js.map +1 -1
- package/build/separator/deprecated.js +83 -0
- package/build/separator/deprecated.js.map +1 -0
- package/build/separator/edit.js +31 -23
- package/build/separator/edit.js.map +1 -1
- package/build/separator/index.js +17 -7
- package/build/separator/index.js.map +1 -1
- package/build/separator/save.js +18 -13
- package/build/separator/save.js.map +1 -1
- package/build/separator/use-deprecated-opacity.js +39 -0
- package/build/separator/use-deprecated-opacity.js.map +1 -0
- package/build/social-links/edit.js +14 -3
- package/build/social-links/edit.js.map +1 -1
- package/build/social-links/index.js +1 -1
- package/build/spacer/controls.js +6 -16
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +3 -1
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +4 -5
- package/build/spacer/edit.js.map +1 -1
- package/build/table/deprecated.js +1 -1
- package/build/table/deprecated.js.map +1 -1
- package/build/tag-cloud/edit.js +58 -2
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/tag-cloud/index.js +8 -0
- package/build/tag-cloud/index.js.map +1 -1
- package/build-module/avatar/edit.js +190 -0
- package/build-module/avatar/edit.js.map +1 -0
- package/build-module/avatar/hooks.js +99 -0
- package/build-module/avatar/hooks.js.map +1 -0
- package/build-module/avatar/index.js +70 -0
- package/build-module/avatar/index.js.map +1 -0
- package/build-module/avatar/user-control.js +52 -0
- package/build-module/avatar/user-control.js.map +1 -0
- package/build-module/column/index.js +2 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/comment-author-avatar/index.js +1 -0
- package/build-module/comment-author-avatar/index.js.map +1 -1
- package/build-module/comment-date/edit.js +13 -30
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +79 -52
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/cover/edit.js +23 -34
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/embed/variations.js +2 -2
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/gallery/edit.js +17 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +1 -1
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gap-styles.js +22 -0
- package/build-module/gallery/gap-styles.js.map +1 -0
- package/build-module/gallery/index.js +17 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +3 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +1 -2
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/image.js +3 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +5 -2
- package/build-module/index.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/v2/edit.js +69 -0
- package/build-module/list/v2/edit.js.map +1 -0
- package/build-module/list/v2/index.js +19 -0
- package/build-module/list/v2/index.js.map +1 -0
- package/build-module/list/v2/save.js +23 -0
- package/build-module/list/v2/save.js.map +1 -0
- package/build-module/list/v2/transforms.js +111 -0
- package/build-module/list/v2/transforms.js.map +1 -0
- package/build-module/list-item/edit.js +37 -0
- package/build-module/list-item/edit.js.map +1 -0
- package/build-module/list-item/index.js +53 -0
- package/build-module/list-item/index.js.map +1 -0
- package/build-module/list-item/save.js +15 -0
- package/build-module/list-item/save.js.map +1 -0
- package/build-module/media-text/edit.js +3 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +27 -54
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation-link/edit.js +88 -33
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-date/edit.js +32 -43
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/pullquote/edit.js +6 -3
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/query/variations.js +4 -4
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query-no-results/edit.js +18 -0
- package/build-module/query-no-results/edit.js.map +1 -0
- package/build-module/query-no-results/index.js +40 -0
- package/build-module/query-no-results/index.js.map +1 -0
- package/build-module/query-no-results/save.js +10 -0
- package/build-module/query-no-results/save.js.map +1 -0
- package/build-module/search/edit.js +2 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/separator/deprecated.js +70 -0
- package/build-module/separator/deprecated.js.map +1 -0
- package/build-module/separator/edit.js +31 -22
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/separator/index.js +16 -7
- package/build-module/separator/index.js.map +1 -1
- package/build-module/separator/save.js +19 -14
- package/build-module/separator/save.js.map +1 -1
- package/build-module/separator/use-deprecated-opacity.js +30 -0
- package/build-module/separator/use-deprecated-opacity.js.map +1 -0
- package/build-module/social-links/edit.js +15 -4
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/social-links/index.js +1 -1
- package/build-module/spacer/controls.js +8 -19
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +2 -1
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +3 -3
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table/deprecated.js +1 -1
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/tag-cloud/edit.js +60 -4
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/tag-cloud/index.js +8 -0
- package/build-module/tag-cloud/index.js.map +1 -1
- package/build-style/avatar/editor-rtl.css +79 -0
- package/build-style/avatar/editor.css +79 -0
- package/build-style/editor-rtl.css +23 -2
- package/build-style/editor.css +23 -2
- package/build-style/gallery/editor-rtl.css +0 -1
- package/build-style/gallery/editor.css +0 -1
- package/build-style/gallery/style-rtl.css +102 -169
- package/build-style/gallery/style.css +102 -169
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation-link/editor-rtl.css +13 -0
- package/build-style/navigation-link/editor.css +13 -0
- package/build-style/pullquote/style-rtl.css +0 -4
- package/build-style/pullquote/style.css +0 -4
- package/build-style/separator/editor-rtl.css +3 -0
- package/build-style/separator/editor.css +3 -0
- package/build-style/separator/theme-rtl.css +7 -1
- package/build-style/separator/theme.css +7 -1
- package/build-style/site-logo/editor-rtl.css +3 -1
- package/build-style/site-logo/editor.css +3 -1
- package/build-style/style-rtl.css +104 -173
- package/build-style/style.css +104 -173
- package/build-style/theme-rtl.css +7 -1
- package/build-style/theme.css +7 -1
- package/package.json +28 -28
- package/src/avatar/block.json +53 -0
- package/src/avatar/edit.js +222 -0
- package/src/avatar/editor.scss +3 -0
- package/src/avatar/hooks.js +96 -0
- package/src/avatar/index.js +18 -0
- package/src/avatar/index.php +146 -0
- package/src/avatar/user-control.js +56 -0
- package/src/column/block.json +2 -1
- package/src/comment-author-avatar/block.json +1 -0
- package/src/comment-date/edit.js +20 -30
- package/src/comment-template/edit.js +65 -44
- package/src/cover/edit.js +26 -31
- package/src/editor.scss +1 -0
- package/src/embed/variations.js +2 -2
- package/src/gallery/block.json +17 -1
- package/src/gallery/deprecated.scss +2 -2
- package/src/gallery/edit.js +15 -8
- package/src/gallery/editor.scss +0 -1
- package/src/gallery/gallery.js +8 -7
- package/src/gallery/gap-styles.js +21 -0
- package/src/gallery/index.php +42 -1
- package/src/gallery/style.scss +11 -44
- package/src/group/block.json +3 -1
- package/src/group/variations.js +1 -1
- package/src/image/image.js +4 -1
- package/src/image/style.scss +3 -0
- package/src/index.js +6 -1
- package/src/list/index.js +6 -1
- package/src/list/v2/edit.js +77 -0
- package/src/list/v2/index.js +20 -0
- package/src/list/v2/save.js +18 -0
- package/src/list/v2/transforms.js +116 -0
- package/src/list-item/block.json +26 -0
- package/src/list-item/edit.js +47 -0
- package/src/list-item/index.js +27 -0
- package/src/list-item/save.js +13 -0
- package/src/media-text/edit.js +1 -1
- package/src/navigation/index.php +22 -2
- package/src/navigation/use-navigation-entities.js +37 -73
- package/src/navigation-link/edit.js +145 -61
- package/src/navigation-link/editor.scss +11 -0
- package/src/post-date/edit.js +63 -52
- package/src/post-date/index.php +1 -1
- package/src/post-date/test/edit.js +17 -0
- package/src/post-featured-image/edit.js +9 -1
- package/src/post-featured-image/index.php +2 -1
- package/src/pullquote/edit.js +4 -3
- package/src/pullquote/style.scss +0 -5
- package/src/query/variations.js +4 -0
- package/src/query-no-results/block.json +20 -0
- package/src/query-no-results/edit.js +28 -0
- package/src/query-no-results/index.js +20 -0
- package/src/query-no-results/index.php +59 -0
- package/src/query-no-results/save.js +8 -0
- package/src/search/edit.js +1 -2
- package/src/separator/block.json +13 -6
- package/src/separator/deprecated.js +57 -0
- package/src/separator/deprecated.scss +6 -0
- package/src/separator/edit.js +36 -14
- package/src/separator/editor.scss +6 -0
- package/src/separator/index.js +2 -0
- package/src/separator/save.js +22 -14
- package/src/separator/test/edit.js +113 -0
- package/src/separator/theme.scss +7 -1
- package/src/separator/use-deprecated-opacity.js +41 -0
- package/src/site-logo/editor.scss +3 -1
- package/src/social-links/block.json +1 -1
- package/src/social-links/edit.js +15 -5
- package/src/spacer/controls.js +12 -18
- package/src/spacer/controls.native.js +2 -1
- package/src/spacer/edit.js +3 -6
- package/src/table/deprecated.js +5 -1
- package/src/tag-cloud/block.json +8 -0
- package/src/tag-cloud/edit.js +82 -2
- package/src/tag-cloud/index.php +6 -0
- package/build/separator/separator-settings.js +0 -36
- package/build/separator/separator-settings.js.map +0 -1
- package/build-module/separator/separator-settings.js +0 -27
- package/build-module/separator/separator-settings.js.map +0 -1
- package/src/separator/separator-settings.js +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/separator/edit.js"],"names":["SeparatorEdit","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/separator/edit.js"],"names":["SeparatorEdit","attributes","setAttributes","backgroundColor","opacity","style","colorProps","currentColor","hasCustomColor","color","background","colorClass","className","classname","styles","undefined"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AASA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,aAAT,OAAwD;AAAA;;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AACtE,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,OAAnB;AAA4BC,IAAAA;AAA5B,MAAsCJ,UAA5C;AACA,QAAMK,UAAU,GAAG,8CAAeL,UAAf,CAAnB;AACA,QAAMM,YAAY,GAAGD,UAAH,aAAGA,UAAH,4CAAGA,UAAU,CAAED,KAAf,sDAAG,kBAAmBF,eAAxC;AACA,QAAMK,cAAc,GAAG,CAAC,EAAEH,KAAF,aAAEA,KAAF,+BAAEA,KAAK,CAAEI,KAAT,yCAAE,aAAcC,UAAhB,CAAxB;AAEA,qCAAsBN,OAAtB,EAA+BG,YAA/B,EAA6CL,aAA7C,EANsE,CAQtE;AACA;;AACA,QAAMS,UAAU,GAAG,oCAAmB,OAAnB,EAA4BR,eAA5B,CAAnB;AAEA,QAAMS,SAAS,GAAG,yBACjB;AACC,sBAAkBT,eAAe,IAAII,YADtC;AAEC,KAAEI,UAAF,GAAgBA,UAFjB;AAGC,uBAAmBP,OAAO,KAAK,KAHhC;AAIC,iCAA6BA,OAAO,KAAK;AAJ1C,GADiB,EAOjBE,UAAU,CAACO,SAPM,CAAlB;AAUA,QAAMC,MAAM,GAAG;AACdL,IAAAA,KAAK,EAAEF,YADO;AAEdJ,IAAAA,eAAe,EAAEI;AAFH,GAAf;AAKA,SACC,qDACC,4BAAC,0BAAD,EACM,gCAAe;AACnBK,IAAAA,SADmB;AAEnBP,IAAAA,KAAK,EAAEG,cAAc,GAAGM,MAAH,GAAYC;AAFd,GAAf,CADN,CADD,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { HorizontalRule } from '@wordpress/components';\nimport {\n\tuseBlockProps,\n\tgetColorClassName,\n\t__experimentalUseColorProps as useColorProps,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useDeprecatedOpacity from './use-deprecated-opacity';\n\nexport default function SeparatorEdit( { attributes, setAttributes } ) {\n\tconst { backgroundColor, opacity, style } = attributes;\n\tconst colorProps = useColorProps( attributes );\n\tconst currentColor = colorProps?.style?.backgroundColor;\n\tconst hasCustomColor = !! style?.color?.background;\n\n\tuseDeprecatedOpacity( opacity, currentColor, setAttributes );\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = classnames(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || currentColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.classname\n\t);\n\n\tconst styles = {\n\t\tcolor: currentColor,\n\t\tbackgroundColor: currentColor,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<HorizontalRule\n\t\t\t\t{ ...useBlockProps( {\n\t\t\t\t\tclassName,\n\t\t\t\t\tstyle: hasCustomColor ? styles : undefined,\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
package/build/separator/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var _save = _interopRequireDefault(require("./save"));
|
|
|
15
15
|
|
|
16
16
|
var _transforms = _interopRequireDefault(require("./transforms"));
|
|
17
17
|
|
|
18
|
+
var _deprecated = _interopRequireDefault(require("./deprecated"));
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* WordPress dependencies
|
|
20
22
|
*/
|
|
@@ -32,16 +34,23 @@ const metadata = {
|
|
|
32
34
|
keywords: ["horizontal-line", "hr", "divider"],
|
|
33
35
|
textdomain: "default",
|
|
34
36
|
attributes: {
|
|
35
|
-
|
|
36
|
-
type: "string"
|
|
37
|
-
|
|
38
|
-
customColor: {
|
|
39
|
-
type: "string"
|
|
37
|
+
opacity: {
|
|
38
|
+
type: "string",
|
|
39
|
+
"default": "alpha-channel"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
supports: {
|
|
43
43
|
anchor: true,
|
|
44
|
-
align: ["center", "wide", "full"]
|
|
44
|
+
align: ["center", "wide", "full"],
|
|
45
|
+
color: {
|
|
46
|
+
__experimentalSkipSerialization: true,
|
|
47
|
+
gradients: true,
|
|
48
|
+
background: true,
|
|
49
|
+
text: false,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
background: true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
45
54
|
},
|
|
46
55
|
styles: [{
|
|
47
56
|
name: "default",
|
|
@@ -72,7 +81,8 @@ const settings = {
|
|
|
72
81
|
},
|
|
73
82
|
transforms: _transforms.default,
|
|
74
83
|
edit: _edit.default,
|
|
75
|
-
save: _save.default
|
|
84
|
+
save: _save.default,
|
|
85
|
+
deprecated: _deprecated.default
|
|
76
86
|
};
|
|
77
87
|
exports.settings = settings;
|
|
78
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/separator/index.js"],"names":["name","metadata","settings","icon","example","attributes","customColor","className","transforms","edit","save"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/separator/index.js"],"names":["name","metadata","settings","icon","example","attributes","customColor","className","transforms","edit","save","deprecated"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,gBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,WAAW,EAAE,SADF;AAEXC,MAAAA,SAAS,EAAE;AAFA;AADJ,GAFc;AAQvBC,EAAAA,UAAU,EAAVA,mBARuB;AASvBC,EAAAA,IAAI,EAAJA,aATuB;AAUvBC,EAAAA,IAAI,EAAJA,aAVuB;AAWvBC,EAAAA,UAAU,EAAVA;AAXuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { separator as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomColor: '#065174',\n\t\t\tclassName: 'is-style-wide',\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
|
package/build/separator/save.js
CHANGED
|
@@ -21,31 +21,36 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
21
21
|
* WordPress dependencies
|
|
22
22
|
*/
|
|
23
23
|
function separatorSave(_ref) {
|
|
24
|
+
var _style$color, _colorProps$style;
|
|
25
|
+
|
|
24
26
|
let {
|
|
25
27
|
attributes
|
|
26
28
|
} = _ref;
|
|
27
29
|
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
backgroundColor,
|
|
31
|
+
style,
|
|
32
|
+
opacity
|
|
33
|
+
} = attributes;
|
|
34
|
+
const customColor = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.background;
|
|
35
|
+
const colorProps = (0, _blockEditor.__experimentalGetColorClassesAndStyles)(attributes); // The hr support changing color using border-color, since border-color
|
|
31
36
|
// is not yet supported in the color palette, we use background-color.
|
|
32
|
-
|
|
33
|
-
const backgroundClass = (0, _blockEditor.getColorClassName)('background-color', color); // The dots styles uses text for the dots, to change those dots color is
|
|
37
|
+
// The dots styles uses text for the dots, to change those dots color is
|
|
34
38
|
// using color, not backgroundColor.
|
|
35
39
|
|
|
36
|
-
const colorClass = (0, _blockEditor.getColorClassName)('color',
|
|
40
|
+
const colorClass = (0, _blockEditor.getColorClassName)('color', backgroundColor);
|
|
37
41
|
const className = (0, _classnames.default)({
|
|
38
|
-
'has-text-color
|
|
39
|
-
[
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
'has-text-color': backgroundColor || customColor,
|
|
43
|
+
[colorClass]: colorClass,
|
|
44
|
+
'has-css-opacity': opacity === 'css',
|
|
45
|
+
'has-alpha-channel-opacity': opacity === 'alpha-channel'
|
|
46
|
+
}, colorProps.className);
|
|
47
|
+
const styles = {
|
|
48
|
+
backgroundColor: colorProps === null || colorProps === void 0 ? void 0 : (_colorProps$style = colorProps.style) === null || _colorProps$style === void 0 ? void 0 : _colorProps$style.backgroundColor,
|
|
44
49
|
color: colorClass ? undefined : customColor
|
|
45
50
|
};
|
|
46
51
|
return (0, _element.createElement)("hr", _blockEditor.useBlockProps.save({
|
|
47
52
|
className,
|
|
48
|
-
style
|
|
53
|
+
style: styles
|
|
49
54
|
}));
|
|
50
55
|
}
|
|
51
56
|
//# sourceMappingURL=save.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/separator/save.js"],"names":["separatorSave","attributes","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/separator/save.js"],"names":["separatorSave","attributes","backgroundColor","style","opacity","customColor","color","background","colorProps","colorClass","className","styles","undefined","useBlockProps","save"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAOe,SAASA,aAAT,OAAyC;AAAA;;AAAA,MAAjB;AAAEC,IAAAA;AAAF,GAAiB;AACvD,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,KAAnB;AAA0BC,IAAAA;AAA1B,MAAsCH,UAA5C;AACA,QAAMI,WAAW,GAAGF,KAAH,aAAGA,KAAH,uCAAGA,KAAK,CAAEG,KAAV,iDAAG,aAAcC,UAAlC;AACA,QAAMC,UAAU,GAAG,yDAA0BP,UAA1B,CAAnB,CAHuD,CAIvD;AACA;AAEA;AACA;;AACA,QAAMQ,UAAU,GAAG,oCAAmB,OAAnB,EAA4BP,eAA5B,CAAnB;AAEA,QAAMQ,SAAS,GAAG,yBACjB;AACC,sBAAkBR,eAAe,IAAIG,WADtC;AAEC,KAAEI,UAAF,GAAgBA,UAFjB;AAGC,uBAAmBL,OAAO,KAAK,KAHhC;AAIC,iCAA6BA,OAAO,KAAK;AAJ1C,GADiB,EAOjBI,UAAU,CAACE,SAPM,CAAlB;AAUA,QAAMC,MAAM,GAAG;AACdT,IAAAA,eAAe,EAAEM,UAAF,aAAEA,UAAF,4CAAEA,UAAU,CAAEL,KAAd,sDAAE,kBAAmBD,eADtB;AAEdI,IAAAA,KAAK,EAAEG,UAAU,GAAGG,SAAH,GAAeP;AAFlB,GAAf;AAIA,SAAO,kCAASQ,2BAAcC,IAAd,CAAoB;AAAEJ,IAAAA,SAAF;AAAaP,IAAAA,KAAK,EAAEQ;AAApB,GAApB,CAAT,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tgetColorClassName,\n\tuseBlockProps,\n\t__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,\n} from '@wordpress/block-editor';\n\nexport default function separatorSave( { attributes } ) {\n\tconst { backgroundColor, style, opacity } = attributes;\n\tconst customColor = style?.color?.background;\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\t// The hr support changing color using border-color, since border-color\n\t// is not yet supported in the color palette, we use background-color.\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = classnames(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || customColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.className\n\t);\n\n\tconst styles = {\n\t\tbackgroundColor: colorProps?.style?.backgroundColor,\n\t\tcolor: colorClass ? undefined : customColor,\n\t};\n\treturn <hr { ...useBlockProps.save( { className, style: styles } ) } />;\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDeprecatedOpacity;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _compose = require("@wordpress/compose");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
function useDeprecatedOpacity(opacity, currentColor, setAttributes) {
|
|
16
|
+
const [deprecatedOpacityWithNoColor, setDeprecatedOpacityWithNoColor] = (0, _element.useState)(false);
|
|
17
|
+
const previousColor = (0, _compose.usePrevious)(currentColor); // A separator with no color set will always have previousColor set to undefined,
|
|
18
|
+
// and we need to differentiate these from those with color set that will return
|
|
19
|
+
// previousColor as undefined on the first render.
|
|
20
|
+
|
|
21
|
+
(0, _element.useEffect)(() => {
|
|
22
|
+
if (opacity === 'css' && !currentColor && !previousColor) {
|
|
23
|
+
setDeprecatedOpacityWithNoColor(true);
|
|
24
|
+
}
|
|
25
|
+
}, [currentColor, previousColor, opacity]); // For deprecated blocks, that have a default 0.4 css opacity set, we
|
|
26
|
+
// need to remove this if the current color is changed, or a color is added.
|
|
27
|
+
// In these instances the opacity attribute is set back to the default of
|
|
28
|
+
// alpha-channel which allows a new custom opacity to be set via the color picker.
|
|
29
|
+
|
|
30
|
+
(0, _element.useEffect)(() => {
|
|
31
|
+
if (opacity === 'css' && (deprecatedOpacityWithNoColor && currentColor || previousColor && currentColor !== previousColor)) {
|
|
32
|
+
setAttributes({
|
|
33
|
+
opacity: 'alpha-channel'
|
|
34
|
+
});
|
|
35
|
+
setDeprecatedOpacityWithNoColor(false);
|
|
36
|
+
}
|
|
37
|
+
}, [deprecatedOpacityWithNoColor, currentColor, previousColor]);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=use-deprecated-opacity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/separator/use-deprecated-opacity.js"],"names":["useDeprecatedOpacity","opacity","currentColor","setAttributes","deprecatedOpacityWithNoColor","setDeprecatedOpacityWithNoColor","previousColor"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,oBAAT,CACdC,OADc,EAEdC,YAFc,EAGdC,aAHc,EAIb;AACD,QAAM,CACLC,4BADK,EAELC,+BAFK,IAGF,uBAAU,KAAV,CAHJ;AAIA,QAAMC,aAAa,GAAG,0BAAaJ,YAAb,CAAtB,CALC,CAOD;AACA;AACA;;AACA,0BAAW,MAAM;AAChB,QAAKD,OAAO,KAAK,KAAZ,IAAqB,CAAEC,YAAvB,IAAuC,CAAEI,aAA9C,EAA8D;AAC7DD,MAAAA,+BAA+B,CAAE,IAAF,CAA/B;AACA;AACD,GAJD,EAIG,CAAEH,YAAF,EAAgBI,aAAhB,EAA+BL,OAA/B,CAJH,EAVC,CAgBD;AACA;AACA;AACA;;AACA,0BAAW,MAAM;AAChB,QACCA,OAAO,KAAK,KAAZ,KACIG,4BAA4B,IAAIF,YAAlC,IACCI,aAAa,IAAIJ,YAAY,KAAKI,aAFrC,CADD,EAIE;AACDH,MAAAA,aAAa,CAAE;AAAEF,QAAAA,OAAO,EAAE;AAAX,OAAF,CAAb;AACAI,MAAAA,+BAA+B,CAAE,KAAF,CAA/B;AACA;AACD,GATD,EASG,CAAED,4BAAF,EAAgCF,YAAhC,EAA8CI,aAA9C,CATH;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\nexport default function useDeprecatedOpacity(\n\topacity,\n\tcurrentColor,\n\tsetAttributes\n) {\n\tconst [\n\t\tdeprecatedOpacityWithNoColor,\n\t\tsetDeprecatedOpacityWithNoColor,\n\t] = useState( false );\n\tconst previousColor = usePrevious( currentColor );\n\n\t// A separator with no color set will always have previousColor set to undefined,\n\t// and we need to differentiate these from those with color set that will return\n\t// previousColor as undefined on the first render.\n\tuseEffect( () => {\n\t\tif ( opacity === 'css' && ! currentColor && ! previousColor ) {\n\t\t\tsetDeprecatedOpacityWithNoColor( true );\n\t\t}\n\t}, [ currentColor, previousColor, opacity ] );\n\n\t// For deprecated blocks, that have a default 0.4 css opacity set, we\n\t// need to remove this if the current color is changed, or a color is added.\n\t// In these instances the opacity attribute is set back to the default of\n\t// alpha-channel which allows a new custom opacity to be set via the color picker.\n\tuseEffect( () => {\n\t\tif (\n\t\t\topacity === 'css' &&\n\t\t\t( ( deprecatedOpacityWithNoColor && currentColor ) ||\n\t\t\t\t( previousColor && currentColor !== previousColor ) )\n\t\t) {\n\t\t\tsetAttributes( { opacity: 'alpha-channel' } );\n\t\t\tsetDeprecatedOpacityWithNoColor( false );\n\t\t}\n\t}, [ deprecatedOpacityWithNoColor, currentColor, previousColor ] );\n}\n"]}
|
|
@@ -64,24 +64,35 @@ function SocialLinksEdit(props) {
|
|
|
64
64
|
} = props;
|
|
65
65
|
const {
|
|
66
66
|
iconBackgroundColorValue,
|
|
67
|
+
customIconBackgroundColor,
|
|
67
68
|
iconColorValue,
|
|
68
69
|
openInNewTab,
|
|
69
70
|
showLabels,
|
|
70
71
|
size,
|
|
71
72
|
layout
|
|
72
73
|
} = attributes;
|
|
73
|
-
const usedLayout = layout || getDefaultBlockLayout(name);
|
|
74
|
+
const usedLayout = layout || getDefaultBlockLayout(name);
|
|
75
|
+
const logosOnly = (_attributes$className = attributes.className) === null || _attributes$className === void 0 ? void 0 : _attributes$className.includes('is-style-logos-only'); // Remove icon background color when logos only style is selected or
|
|
76
|
+
// restore it when any other style is selected.
|
|
74
77
|
|
|
75
|
-
const
|
|
78
|
+
const backgroundBackup = (0, _element.useRef)({});
|
|
76
79
|
(0, _element.useEffect)(() => {
|
|
77
80
|
if (logosOnly) {
|
|
81
|
+
backgroundBackup.current = {
|
|
82
|
+
iconBackgroundColor,
|
|
83
|
+
iconBackgroundColorValue,
|
|
84
|
+
customIconBackgroundColor
|
|
85
|
+
};
|
|
78
86
|
setAttributes({
|
|
79
87
|
iconBackgroundColor: undefined,
|
|
80
88
|
customIconBackgroundColor: undefined,
|
|
81
89
|
iconBackgroundColorValue: undefined
|
|
82
90
|
});
|
|
91
|
+
} else {
|
|
92
|
+
setAttributes({ ...backgroundBackup.current
|
|
93
|
+
});
|
|
83
94
|
}
|
|
84
|
-
}, [logosOnly
|
|
95
|
+
}, [logosOnly]);
|
|
85
96
|
const SocialPlaceholder = (0, _element.createElement)("li", {
|
|
86
97
|
className: "wp-block-social-links__social-placeholder"
|
|
87
98
|
}, (0, _element.createElement)("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/social-links/edit.js"],"names":["ALLOWED_BLOCKS","sizeOptions","name","value","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","SocialLinksEdit","props","attributes","iconBackgroundColor","iconColor","isSelected","setAttributes","setIconBackgroundColor","setIconColor","iconBackgroundColorValue","iconColorValue","openInNewTab","showLabels","size","layout","usedLayout","logosOnly","className","indexOf","undefined","customIconBackgroundColor","SocialPlaceholder","SelectedSocialPlaceholder","color","blockProps","innerBlocksProps","allowedBlocks","placeholder","templateLock","__experimentalAppenderTagName","__experimentalLayout","POPOVER_PROPS","position","colorSettings","onChange","colorValue","label","push","onClose","map","entry","check","textColor","backgroundColor","iconColorAttributes"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AASA;;AAOA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;AAsBA,MAAMA,cAAc,GAAG,CAAE,kBAAF,CAAvB;AAEA,MAAMC,WAAW,GAAG,CACnB;AAAEC,EAAAA,IAAI,EAAE,cAAI,OAAJ,CAAR;AAAuBC,EAAAA,KAAK,EAAE;AAA9B,CADmB,EAEnB;AAAED,EAAAA,IAAI,EAAE,cAAI,QAAJ,CAAR;AAAwBC,EAAAA,KAAK,EAAE;AAA/B,CAFmB,EAGnB;AAAED,EAAAA,IAAI,EAAE,cAAI,OAAJ,CAAR;AAAuBC,EAAAA,KAAK,EAAE;AAA9B,CAHmB,EAInB;AAAED,EAAAA,IAAI,EAAE,cAAI,MAAJ,CAAR;AAAsBC,EAAAA,KAAK,EAAE;AAA7B,CAJmB,CAApB;;AAOA,MAAMC,qBAAqB,GAAKC,eAAF,IAAuB;AACpD,QAAMC,wBAAwB,GAAG,6BAChCD,eADgC,EAEhC,sBAFgC,CAAjC;AAIA,SAAOC,wBAAP,aAAOA,wBAAP,uBAAOA,w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AAI,aAAJ,CADT;AAEC,IAAA,OAAO,EAAGC,UAFX;AAGC,IAAA,QAAQ,EAAG,MACVN,aAAa,CAAE;AAAEM,MAAAA,UAAU,EAAE,CAAEA;AAAhB,KAAF;AAJf,IARD,CADD,EAiBC,4BAAC,+BAAD;AACC,IAAA,gCAAgC,MADjC;AAEC,IAAA,iCAAiC,MAFlC;AAGC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,IAAA,aAAa,EAAGqB;AAJjB,IAjBD,EAuBG,CAAEjB,SAAF,IACD,4BAAC,4BAAD;AAEE0B,IAAAA,SAAS,EAAEhC,cAFb;AAGEiC,IAAAA,eAAe,EAAElC,wBAHnB;AAKC,IAAA,WAAW,EAAG;AALf,IAxBF,CAtCD,EAuEC,kCAASgB,gBAAT,CAvED,CADD;AA2EA;;AAED,MAAMmB,mBAAmB,GAAG;AAC3BxC,EAAAA,SAAS,EAAE,YADgB;AAE3BD,EAAAA,mBAAmB,EAAE;AAFM,CAA5B;;eAKe,6BAAYyC,mBAAZ,EAAmC5C,eAAnC,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { Fragment, useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\tPanelColorSettings,\n\twithColors,\n} from '@wordpress/block-editor';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tPanelBody,\n\tToggleControl,\n\tToolbarDropdownMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nconst ALLOWED_BLOCKS = [ 'core/social-link' ];\n\nconst sizeOptions = [\n\t{ name: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ name: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ name: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ name: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tname,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t\tlayout,\n\t} = attributes;\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\n\t// Remove icon background color if logos only style selected.\n\tconst logosOnly =\n\t\tattributes.className?.indexOf( 'is-style-logos-only' ) >= 0;\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tsetAttributes( {\n\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ logosOnly, setAttributes ] );\n\n\tconst SocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-placeholder\">\n\t\t\t<div className=\"wp-block-social-links__social-placeholder-icons\">\n\t\t\t\t<div className=\"wp-social-link wp-social-link-twitter\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-facebook\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-instagram\"></div>\n\t\t\t</div>\n\t\t</li>\n\t);\n\n\tconst SelectedSocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-prompt\">\n\t\t\t{ __( 'Click plus to add' ) }\n\t\t</li>\n\t);\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = classNames( size, {\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tplaceholder: isSelected ? SelectedSocialPlaceholder : SocialPlaceholder,\n\t\ttemplateLock: false,\n\t\t__experimentalAppenderTagName: 'li',\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\tconst POPOVER_PROPS = {\n\t\tposition: 'bottom right',\n\t};\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\ttext={ __( 'Size' ) }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ sizeOptions.map( ( entry ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t( size === entry.value ||\n\t\t\t\t\t\t\t\t\t\t\t\t( ! size &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tentry.value ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'has-normal-icon-size' ) ) &&\n\t\t\t\t\t\t\t\t\t\t\tcheck\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisSelected={ size === entry.value }\n\t\t\t\t\t\t\t\t\t\tkey={ entry.value }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tsize: entry.value,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ entry.name }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarDropdownMenu>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: ! openInNewTab } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show labels' ) }\n\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelColorSettings\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\t\tcolorSettings={ colorSettings }\n\t\t\t\t/>\n\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</Fragment>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/social-links/edit.js"],"names":["ALLOWED_BLOCKS","sizeOptions","name","value","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","SocialLinksEdit","props","attributes","iconBackgroundColor","iconColor","isSelected","setAttributes","setIconBackgroundColor","setIconColor","iconBackgroundColorValue","customIconBackgroundColor","iconColorValue","openInNewTab","showLabels","size","layout","usedLayout","logosOnly","className","includes","backgroundBackup","current","undefined","SocialPlaceholder","SelectedSocialPlaceholder","color","blockProps","innerBlocksProps","allowedBlocks","placeholder","templateLock","__experimentalAppenderTagName","__experimentalLayout","POPOVER_PROPS","position","colorSettings","onChange","colorValue","label","push","onClose","map","entry","check","textColor","backgroundColor","iconColorAttributes"],"mappings":";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J,CAHT;AAIC,IAAA,aAAa,EAAGsB;AAJjB,IAjBD,EAuBG,CAAElB,SAAF,IACD,4BAAC,4BAAD;AAEE2B,IAAAA,SAAS,EAAEjC,cAFb;AAGEkC,IAAAA,eAAe,EAAEpC,wBAHnB;AAKC,IAAA,WAAW,EAAG;AALf,IAxBF,CAtCD,EAuEC,kCAASkB,gBAAT,CAvED,CADD;AA2EA;;AAED,MAAMmB,mBAAmB,GAAG;AAC3B1C,EAAAA,SAAS,EAAE,YADgB;AAE3BD,EAAAA,mBAAmB,EAAE;AAFM,CAA5B;;eAKe,6BAAY2C,mBAAZ,EAAmC9C,eAAnC,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { Fragment, useEffect, useRef } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\tPanelColorSettings,\n\twithColors,\n} from '@wordpress/block-editor';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tPanelBody,\n\tToggleControl,\n\tToolbarDropdownMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nconst ALLOWED_BLOCKS = [ 'core/social-link' ];\n\nconst sizeOptions = [\n\t{ name: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ name: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ name: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ name: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tname,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\tcustomIconBackgroundColor,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t\tlayout,\n\t} = attributes;\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tconst backgroundBackup = useRef( {} );\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tbackgroundBackup.current = {\n\t\t\t\ticonBackgroundColor,\n\t\t\t\ticonBackgroundColorValue,\n\t\t\t\tcustomIconBackgroundColor,\n\t\t\t};\n\t\t\tsetAttributes( {\n\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( { ...backgroundBackup.current } );\n\t\t}\n\t}, [ logosOnly ] );\n\n\tconst SocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-placeholder\">\n\t\t\t<div className=\"wp-block-social-links__social-placeholder-icons\">\n\t\t\t\t<div className=\"wp-social-link wp-social-link-twitter\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-facebook\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-instagram\"></div>\n\t\t\t</div>\n\t\t</li>\n\t);\n\n\tconst SelectedSocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-prompt\">\n\t\t\t{ __( 'Click plus to add' ) }\n\t\t</li>\n\t);\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = classNames( size, {\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tplaceholder: isSelected ? SelectedSocialPlaceholder : SocialPlaceholder,\n\t\ttemplateLock: false,\n\t\t__experimentalAppenderTagName: 'li',\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\tconst POPOVER_PROPS = {\n\t\tposition: 'bottom right',\n\t};\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\ttext={ __( 'Size' ) }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ sizeOptions.map( ( entry ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t( size === entry.value ||\n\t\t\t\t\t\t\t\t\t\t\t\t( ! size &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tentry.value ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'has-normal-icon-size' ) ) &&\n\t\t\t\t\t\t\t\t\t\t\tcheck\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisSelected={ size === entry.value }\n\t\t\t\t\t\t\t\t\t\tkey={ entry.value }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tsize: entry.value,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ entry.name }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarDropdownMenu>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: ! openInNewTab } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show labels' ) }\n\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelColorSettings\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\t\tcolorSettings={ colorSettings }\n\t\t\t\t/>\n\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</Fragment>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"]}
|
package/build/spacer/controls.js
CHANGED
|
@@ -33,7 +33,6 @@ function DimensionInput(_ref) {
|
|
|
33
33
|
isResizing,
|
|
34
34
|
value = ''
|
|
35
35
|
} = _ref;
|
|
36
|
-
const [temporaryInput, setTemporaryInput] = (0, _element.useState)(null);
|
|
37
36
|
const inputId = (0, _compose.useInstanceId)(_components.__experimentalUnitControl, 'block-spacer-height-input'); // In most contexts the spacer size cannot meaningfully be set to a
|
|
38
37
|
// percentage, since this is relative to the parent container. This
|
|
39
38
|
// unit is disabled from the UI.
|
|
@@ -51,34 +50,25 @@ function DimensionInput(_ref) {
|
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
const handleOnChange = unprocessedValue => {
|
|
54
|
-
setTemporaryInput(null);
|
|
55
53
|
onChange(unprocessedValue);
|
|
56
|
-
};
|
|
54
|
+
}; // Force the unit to update to `px` when the Spacer is being resized.
|
|
57
55
|
|
|
58
|
-
const handleOnBlur = () => {
|
|
59
|
-
if (temporaryInput !== null) {
|
|
60
|
-
setTemporaryInput(null);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
56
|
|
|
64
|
-
const
|
|
57
|
+
const [parsedQuantity, parsedUnit] = (0, _components.__experimentalParseQuantityAndUnitFromRawValue)(value);
|
|
58
|
+
const computedValue = [parsedQuantity, isResizing ? 'px' : parsedUnit].join('');
|
|
65
59
|
return (0, _element.createElement)(_components.BaseControl, {
|
|
66
60
|
label: label,
|
|
67
61
|
id: inputId
|
|
68
62
|
}, (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
69
63
|
id: inputId,
|
|
70
64
|
isResetValueOnUnitChange: true,
|
|
71
|
-
min:
|
|
72
|
-
max: _edit.MAX_SPACER_SIZE,
|
|
73
|
-
onBlur: handleOnBlur,
|
|
65
|
+
min: _edit.MIN_SPACER_SIZE,
|
|
74
66
|
onChange: handleOnChange,
|
|
75
67
|
style: {
|
|
76
68
|
maxWidth: 80
|
|
77
69
|
},
|
|
78
|
-
value:
|
|
79
|
-
units: units
|
|
80
|
-
,
|
|
81
|
-
unit: isResizing ? 'px' : undefined
|
|
70
|
+
value: computedValue,
|
|
71
|
+
units: units
|
|
82
72
|
}));
|
|
83
73
|
}
|
|
84
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["DimensionInput","label","onChange","isResizing","value","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["DimensionInput","label","onChange","isResizing","value","inputId","UnitControl","availableUnitSettings","undefined","filter","availableUnit","units","availableUnits","defaultValues","px","em","rem","vw","vh","handleOnChange","unprocessedValue","parsedQuantity","parsedUnit","computedValue","join","MIN_SPACER_SIZE","maxWidth","SpacerControls","setAttributes","orientation","height","width","nextWidth","nextHeight"],"mappings":";;;;;;;;;AAGA;;AACA;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C,IAAA,wBAAwB,MAFzB;AAGC,IAAA,GAAG,EAAGoB,qBAHP;AAIC,IAAA,QAAQ,EAAGN,cAJZ;AAKC,IAAA,KAAK,EAAG;AAAEO,MAAAA,QAAQ,EAAE;AAAZ,KALT;AAMC,IAAA,KAAK,EAAGH,aANT;AAOC,IAAA,KAAK,EAAGZ;AAPT,IADD,CADD;AAaA;;AAEc,SAASgB,cAAT,QAMX;AAAA,MANoC;AACvCC,IAAAA,aADuC;AAEvCC,IAAAA,WAFuC;AAGvCC,IAAAA,MAHuC;AAIvCC,IAAAA,KAJuC;AAKvC5B,IAAAA;AALuC,GAMpC;AACH,SACC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,iBAAJ;AAAnB,KACG0B,WAAW,KAAK,YAAhB,IACD,4BAAC,cAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,KAAK,EAAGE,KAFT;AAGC,IAAA,QAAQ,EAAKC,SAAF,IACVJ,aAAa,CAAE;AAAEG,MAAAA,KAAK,EAAEC;AAAT,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG7B;AANd,IAFF,EAWG0B,WAAW,KAAK,YAAhB,IACD,4BAAC,cAAD;AACC,IAAA,KAAK,EAAG,cAAI,QAAJ,CADT;AAEC,IAAA,KAAK,EAAGC,MAFT;AAGC,IAAA,QAAQ,EAAKG,UAAF,IACVL,aAAa,CAAE;AAAEE,MAAAA,MAAM,EAAEG;AAAV,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG9B;AANd,IAZF,CADD,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useSetting } from '@wordpress/block-editor';\nimport {\n\tBaseControl,\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { MIN_SPACER_SIZE } from './edit';\n\nfunction DimensionInput( { label, onChange, isResizing, value = '' } ) {\n\tconst inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );\n\n\t// In most contexts the spacer size cannot meaningfully be set to a\n\t// percentage, since this is relative to the parent container. This\n\t// unit is disabled from the UI.\n\tconst availableUnitSettings = (\n\t\tuseSetting( 'spacing.units' ) || undefined\n\t)?.filter( ( availableUnit ) => availableUnit !== '%' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnitSettings || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 100, em: 10, rem: 10, vw: 10, vh: 25 },\n\t} );\n\n\tconst handleOnChange = ( unprocessedValue ) => {\n\t\tonChange( unprocessedValue );\n\t};\n\n\t// Force the unit to update to `px` when the Spacer is being resized.\n\tconst [ parsedQuantity, parsedUnit ] = parseQuantityAndUnitFromRawValue(\n\t\tvalue\n\t);\n\tconst computedValue = [\n\t\tparsedQuantity,\n\t\tisResizing ? 'px' : parsedUnit,\n\t].join( '' );\n\n\treturn (\n\t\t<BaseControl label={ label } id={ inputId }>\n\t\t\t<UnitControl\n\t\t\t\tid={ inputId }\n\t\t\t\tisResetValueOnUnitChange\n\t\t\t\tmin={ MIN_SPACER_SIZE }\n\t\t\t\tonChange={ handleOnChange }\n\t\t\t\tstyle={ { maxWidth: 80 } }\n\t\t\t\tvalue={ computedValue }\n\t\t\t\tunits={ units }\n\t\t\t/>\n\t\t</BaseControl>\n\t);\n}\n\nexport default function SpacerControls( {\n\tsetAttributes,\n\torientation,\n\theight,\n\twidth,\n\tisResizing,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Spacer settings' ) }>\n\t\t\t\t{ orientation === 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: nextWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ orientation !== 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\t\tvalue={ height }\n\t\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\t\tsetAttributes( { height: nextHeight } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -15,6 +15,8 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
15
15
|
|
|
16
16
|
var _i18n = require("@wordpress/i18n");
|
|
17
17
|
|
|
18
|
+
var _edit = require("./edit");
|
|
19
|
+
|
|
18
20
|
var _style = _interopRequireDefault(require("./style.scss"));
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -80,7 +82,7 @@ function Controls(_ref) {
|
|
|
80
82
|
title: (0, _i18n.__)('Dimensions')
|
|
81
83
|
}, (0, _element.createElement)(_components.UnitControl, {
|
|
82
84
|
label: label,
|
|
83
|
-
min:
|
|
85
|
+
min: _edit.MIN_SPACER_SIZE,
|
|
84
86
|
value: value,
|
|
85
87
|
onChange: handleChange,
|
|
86
88
|
onUnitChange: handleUnitChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.native.js"],"names":["DEFAULT_VALUES","px","em","rem","vw","vh","Controls","attributes","context","setAttributes","orientation","label","height","width","valueToConvert","valueUnit","unit","value","Number","setNewDimensions","nextValue","nextUnit","valueWithUnit","handleChange","handleUnitChange","units","availableUnits","defaultValues","styles","rangeCellContainer"],"mappings":";;;;;;;;;AASA;;AANA;;AAOA;;AACA;;AAKA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.native.js"],"names":["DEFAULT_VALUES","px","em","rem","vw","vh","Controls","attributes","context","setAttributes","orientation","label","height","width","valueToConvert","valueUnit","unit","value","Number","setNewDimensions","nextValue","nextUnit","valueWithUnit","handleChange","handleUnitChange","units","availableUnits","defaultValues","MIN_SPACER_SIZE","styles","rangeCellContainer"],"mappings":";;;;;;;;;AASA;;AANA;;AAOA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIA,MAAMA,cAAc,GAAG;AAAEC,EAAAA,EAAE,EAAE,GAAN;AAAWC,EAAAA,EAAE,EAAE,EAAf;AAAmBC,EAAAA,GAAG,EAAE,EAAxB;AAA4BC,EAAAA,EAAE,EAAE,EAAhC;AAAoCC,EAAAA,EAAE,EAAE;AAAxC,CAAvB;;AAEA,SAASC,QAAT,OAA4D;AAAA,MAAzC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,OAAd;AAAuBC,IAAAA;AAAvB,GAAyC;AAC3D,QAAM;AAAEC,IAAAA;AAAF,MAAkBF,OAAxB;AACA,QAAMG,KAAK,GAAGD,WAAW,KAAK,YAAhB,GAA+B,cAAI,QAAJ,CAA/B,GAAgD,cAAI,OAAJ,CAA9D;AAEA,QAAM;AAAEE,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBN,UAA1B;AACA,QAAM;AAAEO,IAAAA,cAAF;AAAkBC,IAAAA,SAAS,EAAEC;AAA7B,MACL,iCAAiBN,WAAW,KAAK,YAAhB,GAA+BE,MAA/B,GAAwCC,KAAzD,KAAoE,EADrE;AAEA,QAAMI,KAAK,GAAGC,MAAM,CAAEJ,cAAF,CAApB;;AAEA,QAAMK,gBAAgB,GAAG,CAAEC,SAAF,EAAaC,QAAb,KAA2B;AACnD,UAAMC,aAAa,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Control,\n\tgetValueAndUnit,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useCallback } from '@wordpress/element';\nimport { useSetting } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { MIN_SPACER_SIZE } from './edit';\nimport styles from './style.scss';\n\nconst DEFAULT_VALUES = { px: 100, em: 10, rem: 10, vw: 10, vh: 25 };\n\nfunction Controls( { attributes, context, setAttributes } ) {\n\tconst { orientation } = context;\n\tconst label = orientation !== 'horizontal' ? __( 'Height' ) : __( 'Width' );\n\n\tconst { height, width } = attributes;\n\tconst { valueToConvert, valueUnit: unit } =\n\t\tgetValueAndUnit( orientation !== 'horizontal' ? height : width ) || {};\n\tconst value = Number( valueToConvert );\n\n\tconst setNewDimensions = ( nextValue, nextUnit ) => {\n\t\tconst valueWithUnit = `${ nextValue }${ nextUnit }`;\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tsetAttributes( { width: valueWithUnit } );\n\t\t} else {\n\t\t\tsetAttributes( { height: valueWithUnit } );\n\t\t}\n\t};\n\n\tconst handleChange = useCallback(\n\t\t( nextValue ) => {\n\t\t\tsetNewDimensions( nextValue, unit );\n\t\t},\n\t\t[ height, width ]\n\t);\n\n\tconst handleUnitChange = useCallback(\n\t\t( nextUnit ) => {\n\t\t\tsetNewDimensions( value, nextUnit );\n\t\t},\n\t\t[ height, width ]\n\t);\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: DEFAULT_VALUES,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Dimensions' ) }>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tmin={ MIN_SPACER_SIZE }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tunit={ unit }\n\t\t\t\t\tstyle={ styles.rangeCellContainer }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</>\n\t);\n}\n\nexport default Controls;\n"]}
|
package/build/spacer/edit.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = exports.MIN_SPACER_SIZE =
|
|
8
|
+
exports.default = exports.MIN_SPACER_SIZE = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -32,10 +32,8 @@ var _controls = _interopRequireDefault(require("./controls"));
|
|
|
32
32
|
/**
|
|
33
33
|
* Internal dependencies
|
|
34
34
|
*/
|
|
35
|
-
const MIN_SPACER_SIZE =
|
|
35
|
+
const MIN_SPACER_SIZE = 0;
|
|
36
36
|
exports.MIN_SPACER_SIZE = MIN_SPACER_SIZE;
|
|
37
|
-
const MAX_SPACER_SIZE = 500;
|
|
38
|
-
exports.MAX_SPACER_SIZE = MAX_SPACER_SIZE;
|
|
39
37
|
|
|
40
38
|
const ResizableSpacer = _ref => {
|
|
41
39
|
let {
|
|
@@ -76,7 +74,7 @@ const ResizableSpacer = _ref => {
|
|
|
76
74
|
}
|
|
77
75
|
},
|
|
78
76
|
onResizeStop: (_event, _direction, elt) => {
|
|
79
|
-
const nextVal =
|
|
77
|
+
const nextVal = getCurrentSize(elt);
|
|
80
78
|
onResizeStop(`${nextVal}px`);
|
|
81
79
|
setIsResizing(false);
|
|
82
80
|
},
|
|
@@ -159,6 +157,7 @@ const SpacerEdit = _ref2 => {
|
|
|
159
157
|
}
|
|
160
158
|
|
|
161
159
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(ResizableSpacer, {
|
|
160
|
+
minHeight: MIN_SPACER_SIZE,
|
|
162
161
|
enable: {
|
|
163
162
|
top: false,
|
|
164
163
|
right: false,
|
package/build/spacer/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["MIN_SPACER_SIZE","MAX_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","Math","min","axis","position","isVisible","SpacerEdit","attributes","setAttributes","toggleSelection","context","height","width","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","style","undefined","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGO,MAAMA,eAAe,GAAG,CAAxB;;AACA,MAAMC,eAAe,GAAG,GAAxB;;;AAEP,MAAMC,eAAe,GAAG,QASjB;AAAA,MATmB;AACzBC,IAAAA,WADyB;AAEzBC,IAAAA,aAFyB;AAGzBC,IAAAA,QAHyB;AAIzBC,IAAAA,YAJyB;AAKzBC,IAAAA,UALyB;AAMzBC,IAAAA,UANyB;AAOzBC,IAAAA,aAPyB;AAQzB,OAAGC;AARsB,GASnB;;AACN,QAAMC,cAAc,GAAKC,GAAF,IAAW;AACjC,WAAOT,WAAW,KAAK,YAAhB,GACJS,GAAG,CAACC,WADA,GAEJD,GAAG,CAACE,YAFP;AAGA,GAJD;;AAMA,QAAMC,UAAU,GAAKH,GAAF,IAAW;AAC7B,WAAQ,GAAGD,cAAc,CAAEC,GAAF,CAAS,IAAlC;AACA,GAFD;;AAIA,SACC,4BAAC,wBAAD;AACC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,EAA+C;AAC9CJ,MAAAA,aAAa,CAAE;AACdG,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE;AAFO,OAAF,CAAb;AAIA;AACD,GAPD,EAOG,EAPH;AASA,SACC,qDACC,4BAAC,gBAAD,EAAW,gCAAe;AAAES,IAAAA;AAAF,GAAf,CAAX,EACGE,2BAA2B,CAAEtC,WAAF,CAD9B,CADD,EAIC,4BAAC,iBAAD;AACC,IAAA,aAAa,EAAGuB,aADjB;AAEC,IAAA,MAAM,EAAGK,eAAe,IAAIF,MAF7B;AAGC,IAAA,KAAK,EAAGI,cAAc,IAAIH,KAH3B;AAIC,IAAA,WAAW,EAAG3B,WAJf;AAKC,IAAA,UAAU,EAAGK;AALd,IAJD,CADD;AAcA,CAnHD;;eAqHegB,U","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\n\nexport const MIN_SPACER_SIZE = 1;\nexport const MAX_SPACER_SIZE = 500;\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = Math.min(\n\t\t\t\t\tMAX_SPACER_SIZE,\n\t\t\t\t\tgetCurrentSize( elt )\n\t\t\t\t);\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\ttoggleSelection,\n\tcontext,\n} ) => {\n\tconst { orientation } = context;\n\tconst { height, width } = attributes;\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst onResizeStart = () => toggleSelection( false );\n\tconst onResizeStop = () => toggleSelection( true );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst style = {\n\t\theight:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: temporaryHeight || height || undefined,\n\t\twidth:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? temporaryWidth || width || undefined\n\t\t\t\t: undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( orientation === 'horizontal' && ! width ) {\n\t\t\tsetAttributes( {\n\t\t\t\theight: '0px',\n\t\t\t\twidth: '72px',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View { ...useBlockProps( { style } ) }>\n\t\t\t\t{ resizableBoxWithOrientation( orientation ) }\n\t\t\t</View>\n\t\t\t<SpacerControls\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\torientation={ orientation }\n\t\t\t\tisResizing={ isResizing }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default SpacerEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["MIN_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","axis","position","isVisible","SpacerEdit","attributes","setAttributes","toggleSelection","context","height","width","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","style","undefined","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGO,MAAMA,eAAe,GAAG,CAAxB;;;AAEP,MAAMC,eAAe,GAAG,QASjB;AAAA,MATmB;AACzBC,IAAAA,WADyB;AAEzBC,IAAAA,aAFyB;AAGzBC,IAAAA,QAHyB;AAIzBC,IAAAA,YAJyB;AAKzBC,IAAAA,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A,WAAW,EAAGR,gBAZf;AAaC,MAAA,aAAa,EAAGpC,aAbjB;AAcC,MAAA,QAAQ,EAAG0B,kBAdZ;AAeC,MAAA,YAAY,EAAGG,0BAfhB;AAgBC,MAAA,UAAU,EAAG1B,UAhBd;AAiBC,MAAA,UAAU,EAAGC,UAjBd;AAkBC,MAAA,aAAa,EAAGC;AAlBjB,MADD,CADD;AAwBA,GAlDD;;AAoDA,0BAAW,MAAM;AAChB,QAAKN,WAAW,KAAK,YAAhB,IAAgC,CAAEyB,KAAvC,EAA+C;AAC9CJ,MAAAA,aAAa,CAAE;AACdG,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE;AAFO,OAAF,CAAb;AAIA;AACD,GAPD,EAOG,EAPH;AASA,SACC,qDACC,4BAAC,gBAAD,EAAW,gCAAe;AAAES,IAAAA;AAAF,GAAf,CAAX,EACGE,2BAA2B,CAAEpC,WAAF,CAD9B,CADD,EAIC,4BAAC,iBAAD;AACC,IAAA,aAAa,EAAGqB,aADjB;AAEC,IAAA,MAAM,EAAGK,eAAe,IAAIF,MAF7B;AAGC,IAAA,KAAK,EAAGI,cAAc,IAAIH,KAH3B;AAIC,IAAA,WAAW,EAAGzB,WAJf;AAKC,IAAA,UAAU,EAAGK;AALd,IAJD,CADD;AAcA,CApHD;;eAsHec,U","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\n\nexport const MIN_SPACER_SIZE = 0;\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getCurrentSize( elt );\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\ttoggleSelection,\n\tcontext,\n} ) => {\n\tconst { orientation } = context;\n\tconst { height, width } = attributes;\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst onResizeStart = () => toggleSelection( false );\n\tconst onResizeStop = () => toggleSelection( true );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst style = {\n\t\theight:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: temporaryHeight || height || undefined,\n\t\twidth:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? temporaryWidth || width || undefined\n\t\t\t\t: undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminHeight={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( orientation === 'horizontal' && ! width ) {\n\t\t\tsetAttributes( {\n\t\t\t\theight: '0px',\n\t\t\t\twidth: '72px',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View { ...useBlockProps( { style } ) }>\n\t\t\t\t{ resizableBoxWithOrientation( orientation ) }\n\t\t\t</View>\n\t\t\t<SpacerControls\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\torientation={ orientation }\n\t\t\t\tisResizing={ isResizing }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default SpacerEdit;\n"]}
|
|
@@ -240,7 +240,7 @@ const deprecated = [// Deprecation migrating table block to use colors block sup
|
|
|
240
240
|
}));
|
|
241
241
|
},
|
|
242
242
|
isEligible: attributes => {
|
|
243
|
-
return attributes.backgroundColor && !attributes.style;
|
|
243
|
+
return attributes.backgroundColor && attributes.backgroundColor in oldColors && !attributes.style;
|
|
244
244
|
},
|
|
245
245
|
// This version is the first to introduce the style attribute to the
|
|
246
246
|
// table block. As a result, we'll explicitly override that.
|