@wordpress/components 19.8.0 → 19.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/guide/index.js +14 -8
- package/build/guide/index.js.map +1 -1
- package/build/palette-edit/index.js +2 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build-module/guide/index.js +14 -8
- package/build-module/guide/index.js.map +1 -1
- package/build-module/palette-edit/index.js +3 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-style/style-rtl.css +0 -3
- package/build-style/style.css +0 -3
- package/build-types/input-control/stories/index.d.ts +17 -0
- package/build-types/input-control/stories/index.d.ts.map +1 -0
- package/build-types/text/test/index.d.ts +2 -0
- package/build-types/text/test/index.d.ts.map +1 -0
- package/package.json +17 -17
- package/src/guide/index.js +12 -13
- package/src/guide/style.scss +0 -4
- package/src/palette-edit/index.js +8 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/guide/finish-button.js +0 -44
- package/build/guide/finish-button.js.map +0 -1
- package/build-module/guide/finish-button.js +0 -34
- package/build-module/guide/finish-button.js.map +0 -1
- package/src/guide/finish-button.js +0 -26
- package/src/guide/test/finish-button.js +0 -49
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = FinishButton;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _button = _interopRequireDefault(require("../button"));
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
function FinishButton(props) {
|
|
24
|
-
const ref = (0, _element.useRef)(); // Focus the button on mount if nothing else is focused. This prevents a
|
|
25
|
-
// focus loss when the 'Next' button is swapped out.
|
|
26
|
-
|
|
27
|
-
(0, _element.useLayoutEffect)(() => {
|
|
28
|
-
const {
|
|
29
|
-
ownerDocument
|
|
30
|
-
} = ref.current;
|
|
31
|
-
const {
|
|
32
|
-
activeElement,
|
|
33
|
-
body
|
|
34
|
-
} = ownerDocument;
|
|
35
|
-
|
|
36
|
-
if (!activeElement || activeElement === body) {
|
|
37
|
-
ref.current.focus();
|
|
38
|
-
}
|
|
39
|
-
}, []);
|
|
40
|
-
return (0, _element.createElement)(_button.default, (0, _extends2.default)({}, props, {
|
|
41
|
-
ref: ref
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=finish-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/guide/finish-button.js"],"names":["FinishButton","props","ref","ownerDocument","current","activeElement","body","focus"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,QAAMC,GAAG,GAAG,sBAAZ,CAD6C,CAG7C;AACA;;AACA,gCAAiB,MAAM;AACtB,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,GAAG,CAACE,OAA9B;AACA,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAA0BH,aAAhC;;AAEA,QAAK,CAAEE,aAAF,IAAmBA,aAAa,KAAKC,IAA1C,EAAiD;AAChDJ,MAAAA,GAAG,CAACE,OAAJ,CAAYG,KAAZ;AACA;AACD,GAPD,EAOG,EAPH;AASA,SAAO,4BAAC,eAAD,6BAAaN,KAAb;AAAqB,IAAA,GAAG,EAAGC;AAA3B,KAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\n\nexport default function FinishButton( props ) {\n\tconst ref = useRef();\n\n\t// Focus the button on mount if nothing else is focused. This prevents a\n\t// focus loss when the 'Next' button is swapped out.\n\tuseLayoutEffect( () => {\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\tif ( ! activeElement || activeElement === body ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [] );\n\n\treturn <Button { ...props } ref={ ref } />;\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { createElement } from "@wordpress/element";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* WordPress dependencies
|
|
6
|
-
*/
|
|
7
|
-
import { useRef, useLayoutEffect } from '@wordpress/element';
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import Button from '../button';
|
|
13
|
-
export default function FinishButton(props) {
|
|
14
|
-
const ref = useRef(); // Focus the button on mount if nothing else is focused. This prevents a
|
|
15
|
-
// focus loss when the 'Next' button is swapped out.
|
|
16
|
-
|
|
17
|
-
useLayoutEffect(() => {
|
|
18
|
-
const {
|
|
19
|
-
ownerDocument
|
|
20
|
-
} = ref.current;
|
|
21
|
-
const {
|
|
22
|
-
activeElement,
|
|
23
|
-
body
|
|
24
|
-
} = ownerDocument;
|
|
25
|
-
|
|
26
|
-
if (!activeElement || activeElement === body) {
|
|
27
|
-
ref.current.focus();
|
|
28
|
-
}
|
|
29
|
-
}, []);
|
|
30
|
-
return createElement(Button, _extends({}, props, {
|
|
31
|
-
ref: ref
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=finish-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/guide/finish-button.js"],"names":["useRef","useLayoutEffect","Button","FinishButton","props","ref","ownerDocument","current","activeElement","body","focus"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,eAAjB,QAAwC,oBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AAEA,eAAe,SAASC,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,QAAMC,GAAG,GAAGL,MAAM,EAAlB,CAD6C,CAG7C;AACA;;AACAC,EAAAA,eAAe,CAAE,MAAM;AACtB,UAAM;AAAEK,MAAAA;AAAF,QAAoBD,GAAG,CAACE,OAA9B;AACA,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAA0BH,aAAhC;;AAEA,QAAK,CAAEE,aAAF,IAAmBA,aAAa,KAAKC,IAA1C,EAAiD;AAChDJ,MAAAA,GAAG,CAACE,OAAJ,CAAYG,KAAZ;AACA;AACD,GAPc,EAOZ,EAPY,CAAf;AASA,SAAO,cAAC,MAAD,eAAaN,KAAb;AAAqB,IAAA,GAAG,EAAGC;AAA3B,KAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\n\nexport default function FinishButton( props ) {\n\tconst ref = useRef();\n\n\t// Focus the button on mount if nothing else is focused. This prevents a\n\t// focus loss when the 'Next' button is swapped out.\n\tuseLayoutEffect( () => {\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { activeElement, body } = ownerDocument;\n\n\t\tif ( ! activeElement || activeElement === body ) {\n\t\t\tref.current.focus();\n\t\t}\n\t}, [] );\n\n\treturn <Button { ...props } ref={ ref } />;\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useRef, useLayoutEffect } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import Button from '../button';
|
|
10
|
-
|
|
11
|
-
export default function FinishButton( props ) {
|
|
12
|
-
const ref = useRef();
|
|
13
|
-
|
|
14
|
-
// Focus the button on mount if nothing else is focused. This prevents a
|
|
15
|
-
// focus loss when the 'Next' button is swapped out.
|
|
16
|
-
useLayoutEffect( () => {
|
|
17
|
-
const { ownerDocument } = ref.current;
|
|
18
|
-
const { activeElement, body } = ownerDocument;
|
|
19
|
-
|
|
20
|
-
if ( ! activeElement || activeElement === body ) {
|
|
21
|
-
ref.current.focus();
|
|
22
|
-
}
|
|
23
|
-
}, [] );
|
|
24
|
-
|
|
25
|
-
return <Button { ...props } ref={ ref } />;
|
|
26
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { shallow } from 'enzyme';
|
|
5
|
-
import { create } from 'react-test-renderer';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { Button } from '@wordpress/components';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import FinishButton from '../finish-button';
|
|
16
|
-
|
|
17
|
-
describe( 'FinishButton', () => {
|
|
18
|
-
it( 'renders a button', () => {
|
|
19
|
-
const wrapper = shallow( <FinishButton /> );
|
|
20
|
-
expect( wrapper.find( Button ) ).toHaveLength( 1 );
|
|
21
|
-
} );
|
|
22
|
-
|
|
23
|
-
it( 'calls onClick when the button is clicked', () => {
|
|
24
|
-
const onClick = jest.fn();
|
|
25
|
-
const wrapper = shallow( <FinishButton onClick={ onClick } /> );
|
|
26
|
-
wrapper.find( Button ).prop( 'onClick' )();
|
|
27
|
-
expect( onClick ).toHaveBeenCalled();
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
it( 'receives focus on mount when nothing is focused', () => {
|
|
31
|
-
const focus = jest.fn();
|
|
32
|
-
create( <FinishButton />, {
|
|
33
|
-
createNodeMock: () => ( { focus, ownerDocument: document } ),
|
|
34
|
-
} );
|
|
35
|
-
expect( focus ).toHaveBeenCalled();
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
it( 'does not receive focus on mount when something is already focused', () => {
|
|
39
|
-
const button = document.createElement( 'button' );
|
|
40
|
-
document.body.append( button );
|
|
41
|
-
button.focus();
|
|
42
|
-
|
|
43
|
-
const focus = jest.fn();
|
|
44
|
-
create( <FinishButton />, {
|
|
45
|
-
createNodeMock: () => ( { focus, ownerDocument: document } ),
|
|
46
|
-
} );
|
|
47
|
-
expect( focus ).not.toHaveBeenCalled();
|
|
48
|
-
} );
|
|
49
|
-
} );
|