@wordpress/nux 5.0.2 → 5.0.6
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/README.md +1 -1
- package/build/components/dot-tip/index.js +17 -14
- package/build/components/dot-tip/index.js.map +1 -1
- package/build/index.js +4 -4
- package/build/store/actions.js +2 -2
- package/build/store/index.js +4 -2
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +14 -5
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build-module/components/dot-tip/index.js +17 -14
- package/build-module/components/dot-tip/index.js.map +1 -1
- package/build-module/store/reducer.js +12 -3
- package/build-module/store/reducer.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Install the module
|
|
|
14
14
|
npm install @wordpress/nux --save
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for
|
|
17
|
+
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._
|
|
18
18
|
|
|
19
19
|
## DotTip
|
|
20
20
|
|
|
@@ -33,14 +33,15 @@ function onClick(event) {
|
|
|
33
33
|
event.stopPropagation();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function DotTip({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
function DotTip(_ref) {
|
|
37
|
+
let {
|
|
38
|
+
position = 'middle right',
|
|
39
|
+
children,
|
|
40
|
+
isVisible,
|
|
41
|
+
hasNextTip,
|
|
42
|
+
onDismiss,
|
|
43
|
+
onDisable
|
|
44
|
+
} = _ref;
|
|
44
45
|
const anchorParent = (0, _element.useRef)(null);
|
|
45
46
|
const onFocusOutsideCallback = (0, _element.useCallback)(event => {
|
|
46
47
|
if (!anchorParent.current) {
|
|
@@ -79,9 +80,10 @@ function DotTip({
|
|
|
79
80
|
}));
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
var _default = (0, _compose.compose)((0, _data.withSelect)((select, {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
var _default = (0, _compose.compose)((0, _data.withSelect)((select, _ref2) => {
|
|
84
|
+
let {
|
|
85
|
+
tipId
|
|
86
|
+
} = _ref2;
|
|
85
87
|
const {
|
|
86
88
|
isTipVisible,
|
|
87
89
|
getAssociatedGuide
|
|
@@ -91,9 +93,10 @@ var _default = (0, _compose.compose)((0, _data.withSelect)((select, {
|
|
|
91
93
|
isVisible: isTipVisible(tipId),
|
|
92
94
|
hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
|
|
93
95
|
};
|
|
94
|
-
}), (0, _data.withDispatch)((dispatch, {
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
}), (0, _data.withDispatch)((dispatch, _ref3) => {
|
|
97
|
+
let {
|
|
98
|
+
tipId
|
|
99
|
+
} = _ref3;
|
|
97
100
|
const {
|
|
98
101
|
dismissTip,
|
|
99
102
|
disableTips
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/nux/src/components/dot-tip/index.js"],"names":["onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","onFocusOutsideCallback","current","contains","relatedTarget","close","select","tipId","isTipVisible","getAssociatedGuide","nuxStore","associatedGuide","nextTipId","dispatch","dismissTip","disableTips"],"mappings":";;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGA,SAASA,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACAA,EAAAA,KAAK,CAACC,eAAN;AACA;;AAEM,SAASC,MAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/nux/src/components/dot-tip/index.js"],"names":["onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","onFocusOutsideCallback","current","contains","relatedTarget","close","select","tipId","isTipVisible","getAssociatedGuide","nuxStore","associatedGuide","nextTipId","dispatch","dismissTip","disableTips"],"mappings":";;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGA,SAASA,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACAA,EAAAA,KAAK,CAACC,eAAN;AACA;;AAEM,SAASC,MAAT,OAOH;AAAA,MAPoB;AACvBC,IAAAA,QAAQ,GAAG,cADY;AAEvBC,IAAAA,QAFuB;AAGvBC,IAAAA,SAHuB;AAIvBC,IAAAA,UAJuB;AAKvBC,IAAAA,SALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAG,qBAAQ,IAAR,CAArB;AACA,QAAMC,sBAAsB,GAAG,0BAC5BV,KAAF,IAAa;AACZ,QAAK,CAAES,YAAY,CAACE,OAApB,EAA8B;AAC7B;AACA;;AACD,QAAKF,YAAY,CAACE,OAAb,CAAqBC,QAArB,CAA+BZ,KAAK,CAACa,aAArC,CAAL,EAA4D;AAC3D;AACA;;AACDL,IAAAA,SAAS;AACT,GAT6B,EAU9B,CAAEA,SAAF,EAAaC,YAAb,CAV8B,CAA/B;;AAYA,MAAK,CAAEJ,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAC,aADX;AAEC,IAAA,QAAQ,EAAGF,QAFZ;AAGC,IAAA,OAAO,MAHR;AAIC,IAAA,YAAY,EAAC,WAJd;AAKC,IAAA,0BAA0B,MAL3B;AAMC,IAAA,IAAI,EAAC,QANN;AAOC,kBAAa,cAAI,aAAJ,CAPd;AAQC,IAAA,OAAO,EAAGJ,OARX;AASC,IAAA,cAAc,EAAGW;AATlB,KAWC,uCAAKN,QAAL,CAXD,EAYC,uCACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,MAAhB;AAAuB,IAAA,OAAO,EAAGG;AAAjC,KACGD,UAAU,GAAG,cAAI,cAAJ,CAAH,GAA0B,cAAI,QAAJ,CADvC,CADD,CAZD,EAiBC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,sBADX;AAEC,IAAA,IAAI,EAAGQ,YAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,OAAO,EAAGN;AAJX,IAjBD,CADD;AA0BA;;eAEc,sBACd,sBAAY,CAAEO,MAAF,YAAyB;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpC,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAuCH,MAAM,CAAEI,YAAF,CAAnD;AACA,QAAMC,eAAe,GAAGF,kBAAkB,CAAEF,KAAF,CAA1C;AACA,SAAO;AACNX,IAAAA,SAAS,EAAEY,YAAY,CAAED,KAAF,CADjB;AAENV,IAAAA,UAAU,EAAE,CAAC,EAAIc,eAAe,IAAIA,eAAe,CAACC,SAAvC;AAFP,GAAP;AAIA,CAPD,CADc,EASd,wBAAc,CAAEC,QAAF,YAA2B;AAAA,MAAf;AAAEN,IAAAA;AAAF,GAAe;AACxC,QAAM;AAAEO,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA8BF,QAAQ,CAAEH,YAAF,CAA5C;AACA,SAAO;AACNZ,IAAAA,SAAS,GAAG;AACXgB,MAAAA,UAAU,CAAEP,KAAF,CAAV;AACA,KAHK;;AAINR,IAAAA,SAAS,GAAG;AACXgB,MAAAA,WAAW;AACX;;AANK,GAAP;AAQA,CAVD,CATc,EAoBZtB,MApBY,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as nuxStore } from '../../store';\n\nfunction onClick( event ) {\n\t// Tips are often nested within buttons. We stop propagation so that clicking\n\t// on a tip doesn't result in the button being clicked.\n\tevent.stopPropagation();\n}\n\nexport function DotTip( {\n\tposition = 'middle right',\n\tchildren,\n\tisVisible,\n\thasNextTip,\n\tonDismiss,\n\tonDisable,\n} ) {\n\tconst anchorParent = useRef( null );\n\tconst onFocusOutsideCallback = useCallback(\n\t\t( event ) => {\n\t\t\tif ( ! anchorParent.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( anchorParent.current.contains( event.relatedTarget ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonDisable();\n\t\t},\n\t\t[ onDisable, anchorParent ]\n\t);\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"nux-dot-tip\"\n\t\t\tposition={ position }\n\t\t\tnoArrow\n\t\t\tfocusOnMount=\"container\"\n\t\t\tshouldAnchorIncludePadding\n\t\t\trole=\"dialog\"\n\t\t\taria-label={ __( 'Editor tips' ) }\n\t\t\tonClick={ onClick }\n\t\t\tonFocusOutside={ onFocusOutsideCallback }\n\t\t>\n\t\t\t<p>{ children }</p>\n\t\t\t<p>\n\t\t\t\t<Button variant=\"link\" onClick={ onDismiss }>\n\t\t\t\t\t{ hasNextTip ? __( 'See next tip' ) : __( 'Got it' ) }\n\t\t\t\t</Button>\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tclassName=\"nux-dot-tip__disable\"\n\t\t\t\ticon={ close }\n\t\t\t\tlabel={ __( 'Disable tips' ) }\n\t\t\t\tonClick={ onDisable }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select, { tipId } ) => {\n\t\tconst { isTipVisible, getAssociatedGuide } = select( nuxStore );\n\t\tconst associatedGuide = getAssociatedGuide( tipId );\n\t\treturn {\n\t\t\tisVisible: isTipVisible( tipId ),\n\t\t\thasNextTip: !! ( associatedGuide && associatedGuide.nextTipId ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { tipId } ) => {\n\t\tconst { dismissTip, disableTips } = dispatch( nuxStore );\n\t\treturn {\n\t\t\tonDismiss() {\n\t\t\t\tdismissTip( tipId );\n\t\t\t},\n\t\t\tonDisable() {\n\t\t\t\tdisableTips();\n\t\t\t},\n\t\t};\n\t} )\n)( DotTip );\n"]}
|
package/build/index.js
CHANGED
|
@@ -5,16 +5,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "DotTip", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
11
|
-
return
|
|
11
|
+
return _dotTip.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "store", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function () {
|
|
17
|
-
return
|
|
17
|
+
return _store.store;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
|
package/build/store/actions.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.triggerGuide = triggerGuide;
|
|
7
|
-
exports.dismissTip = dismissTip;
|
|
8
6
|
exports.disableTips = disableTips;
|
|
7
|
+
exports.dismissTip = dismissTip;
|
|
9
8
|
exports.enableTips = enableTips;
|
|
9
|
+
exports.triggerGuide = triggerGuide;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Returns an action object that, when dispatched, presents a guide that takes
|
package/build/store/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -17,6 +15,10 @@ var actions = _interopRequireWildcard(require("./actions"));
|
|
|
17
15
|
|
|
18
16
|
var selectors = _interopRequireWildcard(require("./selectors"));
|
|
19
17
|
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* WordPress dependencies
|
|
22
24
|
*/
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/nux/src/store/index.js"],"names":["STORE_NAME","store","reducer","actions","selectors","persist"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/nux/src/store/index.js"],"names":["STORE_NAME","store","reducer","actions","selectors","persist"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,UAAU,GAAG,UAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,KAAK,GAAG,4BAAkBD,UAAlB,EAA8B;AAClDE,EAAAA,OAAO,EAAPA,gBADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA,SAHkD;AAIlDC,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJyC,CAA9B,CAAd,C,CAOP;AACA;;;AACA,yBAAeL,UAAf,EAA2B;AAC1BE,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BC,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJiB,CAA3B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/nux';\n\n/**\n * Store definition for the nux namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'preferences' ],\n} );\n\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregisterStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'preferences' ],\n} );\n"]}
|
package/build/store/reducer.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.guides = guides;
|
|
7
6
|
exports.areTipsEnabled = areTipsEnabled;
|
|
8
|
-
exports.dismissedTips = dismissedTips;
|
|
9
7
|
exports.default = void 0;
|
|
8
|
+
exports.dismissedTips = dismissedTips;
|
|
9
|
+
exports.guides = guides;
|
|
10
10
|
|
|
11
11
|
var _data = require("@wordpress/data");
|
|
12
12
|
|
|
@@ -23,7 +23,10 @@ var _data = require("@wordpress/data");
|
|
|
23
23
|
*
|
|
24
24
|
* @return {Array} Updated state.
|
|
25
25
|
*/
|
|
26
|
-
function guides(
|
|
26
|
+
function guides() {
|
|
27
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
28
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
29
|
+
|
|
27
30
|
switch (action.type) {
|
|
28
31
|
case 'TRIGGER_GUIDE':
|
|
29
32
|
return [...state, action.tipIds];
|
|
@@ -41,7 +44,10 @@ function guides(state = [], action) {
|
|
|
41
44
|
*/
|
|
42
45
|
|
|
43
46
|
|
|
44
|
-
function areTipsEnabled(
|
|
47
|
+
function areTipsEnabled() {
|
|
48
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
49
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
50
|
+
|
|
45
51
|
switch (action.type) {
|
|
46
52
|
case 'DISABLE_TIPS':
|
|
47
53
|
return false;
|
|
@@ -63,7 +69,10 @@ function areTipsEnabled(state = true, action) {
|
|
|
63
69
|
*/
|
|
64
70
|
|
|
65
71
|
|
|
66
|
-
function dismissedTips(
|
|
72
|
+
function dismissedTips() {
|
|
73
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
74
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
75
|
+
|
|
67
76
|
switch (action.type) {
|
|
68
77
|
case 'DISMISS_TIP':
|
|
69
78
|
return { ...state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/nux/src/store/reducer.js"],"names":["guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences"],"mappings":";;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/nux/src/store/reducer.js"],"names":["guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences"],"mappings":";;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAT,GAAsC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC5C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,aAAO,CAAE,GAAGF,KAAL,EAAYC,MAAM,CAACE,MAAnB,CAAP;AAFF;;AAKA,SAAOH,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,cAAT,GAAgD;AAAA,MAAvBJ,KAAuB,uEAAf,IAAe;AAAA,MAATC,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,cAAL;AACC,aAAO,KAAP;;AAED,SAAK,aAAL;AACC,aAAO,IAAP;AALF;;AAQA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,aAAT,GAA6C;AAAA,MAArBL,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AACnD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,aAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACK,EAAT,GAAe;AAFT,OAAP;;AAKD,SAAK,aAAL;AACC,aAAO,EAAP;AARF;;AAWA,SAAON,KAAP;AACA;;AAED,MAAMO,WAAW,GAAG,2BAAiB;AAAEH,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAAjB,CAApB;;eAEe,2BAAiB;AAAEN,EAAAA,MAAF;AAAUQ,EAAAA;AAAV,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer that tracks which tips are in a guide. Each guide is represented by\n * an array which contains the tip identifiers contained within that guide.\n *\n * @param {Array} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Array} Updated state.\n */\nexport function guides( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'TRIGGER_GUIDE':\n\t\t\treturn [ ...state, action.tipIds ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer that tracks whether or not tips are globally enabled.\n *\n * @param {boolean} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function areTipsEnabled( state = true, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'DISABLE_TIPS':\n\t\t\treturn false;\n\n\t\tcase 'ENABLE_TIPS':\n\t\t\treturn true;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer that tracks which tips have been dismissed. If the state object\n * contains a tip identifier, then that tip is dismissed.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function dismissedTips( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'DISMISS_TIP':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.id ]: true,\n\t\t\t};\n\n\t\tcase 'ENABLE_TIPS':\n\t\t\treturn {};\n\t}\n\n\treturn state;\n}\n\nconst preferences = combineReducers( { areTipsEnabled, dismissedTips } );\n\nexport default combineReducers( { guides, preferences } );\n"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -5,9 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.isTipVisible = isTipVisible;
|
|
9
8
|
exports.areTipsEnabled = areTipsEnabled;
|
|
10
9
|
exports.getAssociatedGuide = void 0;
|
|
10
|
+
exports.isTipVisible = isTipVisible;
|
|
11
11
|
|
|
12
12
|
var _rememo = _interopRequireDefault(require("rememo"));
|
|
13
13
|
|
|
@@ -21,14 +21,15 @@ function onClick(event) {
|
|
|
21
21
|
event.stopPropagation();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function DotTip({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
export function DotTip(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
position = 'middle right',
|
|
27
|
+
children,
|
|
28
|
+
isVisible,
|
|
29
|
+
hasNextTip,
|
|
30
|
+
onDismiss,
|
|
31
|
+
onDisable
|
|
32
|
+
} = _ref;
|
|
32
33
|
const anchorParent = useRef(null);
|
|
33
34
|
const onFocusOutsideCallback = useCallback(event => {
|
|
34
35
|
if (!anchorParent.current) {
|
|
@@ -66,9 +67,10 @@ export function DotTip({
|
|
|
66
67
|
onClick: onDisable
|
|
67
68
|
}));
|
|
68
69
|
}
|
|
69
|
-
export default compose(withSelect((select, {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
export default compose(withSelect((select, _ref2) => {
|
|
71
|
+
let {
|
|
72
|
+
tipId
|
|
73
|
+
} = _ref2;
|
|
72
74
|
const {
|
|
73
75
|
isTipVisible,
|
|
74
76
|
getAssociatedGuide
|
|
@@ -78,9 +80,10 @@ export default compose(withSelect((select, {
|
|
|
78
80
|
isVisible: isTipVisible(tipId),
|
|
79
81
|
hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
|
|
80
82
|
};
|
|
81
|
-
}), withDispatch((dispatch, {
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
}), withDispatch((dispatch, _ref3) => {
|
|
84
|
+
let {
|
|
85
|
+
tipId
|
|
86
|
+
} = _ref3;
|
|
84
87
|
const {
|
|
85
88
|
dismissTip,
|
|
86
89
|
disableTips
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/nux/src/components/dot-tip/index.js"],"names":["compose","Popover","Button","__","withSelect","withDispatch","useCallback","useRef","close","store","nuxStore","onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","onFocusOutsideCallback","current","contains","relatedTarget","select","tipId","isTipVisible","getAssociatedGuide","associatedGuide","nextTipId","dispatch","dismissTip","disableTips"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,QAAlB,QAAkC,aAAlC;;AAEA,SAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACAA,EAAAA,KAAK,CAACC,eAAN;AACA;;AAED,OAAO,SAASC,MAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/nux/src/components/dot-tip/index.js"],"names":["compose","Popover","Button","__","withSelect","withDispatch","useCallback","useRef","close","store","nuxStore","onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","onFocusOutsideCallback","current","contains","relatedTarget","select","tipId","isTipVisible","getAssociatedGuide","associatedGuide","nextTipId","dispatch","dismissTip","disableTips"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,uBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,QAAlB,QAAkC,aAAlC;;AAEA,SAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACAA,EAAAA,KAAK,CAACC,eAAN;AACA;;AAED,OAAO,SAASC,MAAT,OAOH;AAAA,MAPoB;AACvBC,IAAAA,QAAQ,GAAG,cADY;AAEvBC,IAAAA,QAFuB;AAGvBC,IAAAA,SAHuB;AAIvBC,IAAAA,UAJuB;AAKvBC,IAAAA,SALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAGd,MAAM,CAAE,IAAF,CAA3B;AACA,QAAMe,sBAAsB,GAAGhB,WAAW,CACvCM,KAAF,IAAa;AACZ,QAAK,CAAES,YAAY,CAACE,OAApB,EAA8B;AAC7B;AACA;;AACD,QAAKF,YAAY,CAACE,OAAb,CAAqBC,QAArB,CAA+BZ,KAAK,CAACa,aAArC,CAAL,EAA4D;AAC3D;AACA;;AACDL,IAAAA,SAAS;AACT,GATwC,EAUzC,CAAEA,SAAF,EAAaC,YAAb,CAVyC,CAA1C;;AAYA,MAAK,CAAEJ,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,SAAS,EAAC,aADX;AAEC,IAAA,QAAQ,EAAGF,QAFZ;AAGC,IAAA,OAAO,MAHR;AAIC,IAAA,YAAY,EAAC,WAJd;AAKC,IAAA,0BAA0B,MAL3B;AAMC,IAAA,IAAI,EAAC,QANN;AAOC,kBAAaZ,EAAE,CAAE,aAAF,CAPhB;AAQC,IAAA,OAAO,EAAGQ,OARX;AASC,IAAA,cAAc,EAAGW;AATlB,KAWC,yBAAKN,QAAL,CAXD,EAYC,yBACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,MAAhB;AAAuB,IAAA,OAAO,EAAGG;AAAjC,KACGD,UAAU,GAAGf,EAAE,CAAE,cAAF,CAAL,GAA0BA,EAAE,CAAE,QAAF,CADzC,CADD,CAZD,EAiBC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,sBADX;AAEC,IAAA,IAAI,EAAGK,KAFR;AAGC,IAAA,KAAK,EAAGL,EAAE,CAAE,cAAF,CAHX;AAIC,IAAA,OAAO,EAAGiB;AAJX,IAjBD,CADD;AA0BA;AAED,eAAepB,OAAO,CACrBI,UAAU,CAAE,CAAEsB,MAAF,YAAyB;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACpC,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAuCH,MAAM,CAAEhB,QAAF,CAAnD;AACA,QAAMoB,eAAe,GAAGD,kBAAkB,CAAEF,KAAF,CAA1C;AACA,SAAO;AACNV,IAAAA,SAAS,EAAEW,YAAY,CAAED,KAAF,CADjB;AAENT,IAAAA,UAAU,EAAE,CAAC,EAAIY,eAAe,IAAIA,eAAe,CAACC,SAAvC;AAFP,GAAP;AAIA,CAPS,CADW,EASrB1B,YAAY,CAAE,CAAE2B,QAAF,YAA2B;AAAA,MAAf;AAAEL,IAAAA;AAAF,GAAe;AACxC,QAAM;AAAEM,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA8BF,QAAQ,CAAEtB,QAAF,CAA5C;AACA,SAAO;AACNS,IAAAA,SAAS,GAAG;AACXc,MAAAA,UAAU,CAAEN,KAAF,CAAV;AACA,KAHK;;AAINP,IAAAA,SAAS,GAAG;AACXc,MAAAA,WAAW;AACX;;AANK,GAAP;AAQA,CAVW,CATS,CAAP,CAoBZpB,MApBY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { Popover, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as nuxStore } from '../../store';\n\nfunction onClick( event ) {\n\t// Tips are often nested within buttons. We stop propagation so that clicking\n\t// on a tip doesn't result in the button being clicked.\n\tevent.stopPropagation();\n}\n\nexport function DotTip( {\n\tposition = 'middle right',\n\tchildren,\n\tisVisible,\n\thasNextTip,\n\tonDismiss,\n\tonDisable,\n} ) {\n\tconst anchorParent = useRef( null );\n\tconst onFocusOutsideCallback = useCallback(\n\t\t( event ) => {\n\t\t\tif ( ! anchorParent.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( anchorParent.current.contains( event.relatedTarget ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonDisable();\n\t\t},\n\t\t[ onDisable, anchorParent ]\n\t);\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tclassName=\"nux-dot-tip\"\n\t\t\tposition={ position }\n\t\t\tnoArrow\n\t\t\tfocusOnMount=\"container\"\n\t\t\tshouldAnchorIncludePadding\n\t\t\trole=\"dialog\"\n\t\t\taria-label={ __( 'Editor tips' ) }\n\t\t\tonClick={ onClick }\n\t\t\tonFocusOutside={ onFocusOutsideCallback }\n\t\t>\n\t\t\t<p>{ children }</p>\n\t\t\t<p>\n\t\t\t\t<Button variant=\"link\" onClick={ onDismiss }>\n\t\t\t\t\t{ hasNextTip ? __( 'See next tip' ) : __( 'Got it' ) }\n\t\t\t\t</Button>\n\t\t\t</p>\n\t\t\t<Button\n\t\t\t\tclassName=\"nux-dot-tip__disable\"\n\t\t\t\ticon={ close }\n\t\t\t\tlabel={ __( 'Disable tips' ) }\n\t\t\t\tonClick={ onDisable }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select, { tipId } ) => {\n\t\tconst { isTipVisible, getAssociatedGuide } = select( nuxStore );\n\t\tconst associatedGuide = getAssociatedGuide( tipId );\n\t\treturn {\n\t\t\tisVisible: isTipVisible( tipId ),\n\t\t\thasNextTip: !! ( associatedGuide && associatedGuide.nextTipId ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, { tipId } ) => {\n\t\tconst { dismissTip, disableTips } = dispatch( nuxStore );\n\t\treturn {\n\t\t\tonDismiss() {\n\t\t\t\tdismissTip( tipId );\n\t\t\t},\n\t\t\tonDisable() {\n\t\t\t\tdisableTips();\n\t\t\t},\n\t\t};\n\t} )\n)( DotTip );\n"]}
|
|
@@ -12,7 +12,10 @@ import { combineReducers } from '@wordpress/data';
|
|
|
12
12
|
* @return {Array} Updated state.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
export function guides(
|
|
15
|
+
export function guides() {
|
|
16
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
17
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
18
|
+
|
|
16
19
|
switch (action.type) {
|
|
17
20
|
case 'TRIGGER_GUIDE':
|
|
18
21
|
return [...state, action.tipIds];
|
|
@@ -29,7 +32,10 @@ export function guides(state = [], action) {
|
|
|
29
32
|
* @return {boolean} Updated state.
|
|
30
33
|
*/
|
|
31
34
|
|
|
32
|
-
export function areTipsEnabled(
|
|
35
|
+
export function areTipsEnabled() {
|
|
36
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
37
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
38
|
+
|
|
33
39
|
switch (action.type) {
|
|
34
40
|
case 'DISABLE_TIPS':
|
|
35
41
|
return false;
|
|
@@ -50,7 +56,10 @@ export function areTipsEnabled(state = true, action) {
|
|
|
50
56
|
* @return {Object} Updated state.
|
|
51
57
|
*/
|
|
52
58
|
|
|
53
|
-
export function dismissedTips(
|
|
59
|
+
export function dismissedTips() {
|
|
60
|
+
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
61
|
+
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
62
|
+
|
|
54
63
|
switch (action.type) {
|
|
55
64
|
case 'DISMISS_TIP':
|
|
56
65
|
return { ...state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/nux/src/store/reducer.js"],"names":["combineReducers","guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,MAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/nux/src/store/reducer.js"],"names":["combineReducers","guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,iBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,MAAT,GAAsC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC5C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,eAAL;AACC,aAAO,CAAE,GAAGF,KAAL,EAAYC,MAAM,CAACE,MAAnB,CAAP;AAFF;;AAKA,SAAOH,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,cAAT,GAAgD;AAAA,MAAvBJ,KAAuB,uEAAf,IAAe;AAAA,MAATC,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,cAAL;AACC,aAAO,KAAP;;AAED,SAAK,aAAL;AACC,aAAO,IAAP;AALF;;AAQA,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,aAAT,GAA6C;AAAA,MAArBL,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AACnD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,aAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACK,EAAT,GAAe;AAFT,OAAP;;AAKD,SAAK,aAAL;AACC,aAAO,EAAP;AARF;;AAWA,SAAON,KAAP;AACA;AAED,MAAMO,WAAW,GAAGT,eAAe,CAAE;AAAEM,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAAF,CAAnC;AAEA,eAAeP,eAAe,CAAE;AAAEC,EAAAA,MAAF;AAAUQ,EAAAA;AAAV,CAAF,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer that tracks which tips are in a guide. Each guide is represented by\n * an array which contains the tip identifiers contained within that guide.\n *\n * @param {Array} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Array} Updated state.\n */\nexport function guides( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'TRIGGER_GUIDE':\n\t\t\treturn [ ...state, action.tipIds ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer that tracks whether or not tips are globally enabled.\n *\n * @param {boolean} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function areTipsEnabled( state = true, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'DISABLE_TIPS':\n\t\t\treturn false;\n\n\t\tcase 'ENABLE_TIPS':\n\t\t\treturn true;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer that tracks which tips have been dismissed. If the state object\n * contains a tip identifier, then that tip is dismissed.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function dismissedTips( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'DISMISS_TIP':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.id ]: true,\n\t\t\t};\n\n\t\tcase 'ENABLE_TIPS':\n\t\t\treturn {};\n\t}\n\n\treturn state;\n}\n\nconst preferences = combineReducers( { areTipsEnabled, dismissedTips } );\n\nexport default combineReducers( { guides, preferences } );\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/nux",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "NUX (New User eXperience) module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"{src,build,build-module}/{index.js,store/index.js}"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@babel/runtime": "^7.
|
|
34
|
-
"@wordpress/components": "^
|
|
35
|
-
"@wordpress/compose": "^5.0.
|
|
36
|
-
"@wordpress/data": "^6.1.
|
|
37
|
-
"@wordpress/deprecated": "^3.2.
|
|
38
|
-
"@wordpress/element": "^4.0.
|
|
39
|
-
"@wordpress/i18n": "^4.2.
|
|
40
|
-
"@wordpress/icons": "^
|
|
33
|
+
"@babel/runtime": "^7.16.0",
|
|
34
|
+
"@wordpress/components": "^19.0.2",
|
|
35
|
+
"@wordpress/compose": "^5.0.6",
|
|
36
|
+
"@wordpress/data": "^6.1.4",
|
|
37
|
+
"@wordpress/deprecated": "^3.2.3",
|
|
38
|
+
"@wordpress/element": "^4.0.4",
|
|
39
|
+
"@wordpress/i18n": "^4.2.4",
|
|
40
|
+
"@wordpress/icons": "^6.1.1",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"rememo": "^3.0.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "9a1dd3474d937468e4cf9caf9886ad61ef0a8f50"
|
|
48
48
|
}
|