@wordpress/nux 8.12.0 → 8.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/dot-tip/index.js +1 -2
- package/build/components/dot-tip/index.js.map +1 -1
- package/build/store/index.js +3 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +1 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -2
- package/build/store/selectors.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -65,7 +65,7 @@ function DotTip({
|
|
|
65
65
|
onClick: onDisable
|
|
66
66
|
}));
|
|
67
67
|
}
|
|
68
|
-
var _default = (0, _compose.compose)((0, _data.withSelect)((select, {
|
|
68
|
+
var _default = exports.default = (0, _compose.compose)((0, _data.withSelect)((select, {
|
|
69
69
|
tipId
|
|
70
70
|
}) => {
|
|
71
71
|
const {
|
|
@@ -93,5 +93,4 @@ var _default = (0, _compose.compose)((0, _data.withSelect)((select, {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
}))(DotTip);
|
|
96
|
-
exports.default = _default;
|
|
97
96
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_components","_i18n","_data","_element","_icons","_store","onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","useRef","onFocusOutsideCallback","useCallback","current","contains","relatedTarget","_react","createElement","Popover","className","focusOnMount","role","__","onFocusOutside","Button","variant","icon","close","label","_default","compose","withSelect","select","tipId","isTipVisible","getAssociatedGuide","nuxStore","associatedGuide","nextTipId","withDispatch","dispatch","dismissTip","disableTips"
|
|
1
|
+
{"version":3,"names":["_compose","require","_components","_i18n","_data","_element","_icons","_store","onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","useRef","onFocusOutsideCallback","useCallback","current","contains","relatedTarget","_react","createElement","Popover","className","focusOnMount","role","__","onFocusOutside","Button","variant","icon","close","label","_default","exports","default","compose","withSelect","select","tipId","isTipVisible","getAssociatedGuide","nuxStore","associatedGuide","nextTipId","withDispatch","dispatch","dismissTip","disableTips"],"sources":["@wordpress/nux/src/components/dot-tip/index.js"],"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\tfocusOnMount\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"],"mappings":"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"}
|
package/build/store/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var _data = require("@wordpress/data");
|
|
|
9
9
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
10
10
|
var actions = _interopRequireWildcard(require("./actions"));
|
|
11
11
|
var selectors = _interopRequireWildcard(require("./selectors"));
|
|
12
|
-
function _getRequireWildcardCache(
|
|
13
|
-
function _interopRequireWildcard(
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
/**
|
|
15
15
|
* WordPress dependencies
|
|
16
16
|
*/
|
|
@@ -28,7 +28,7 @@ const STORE_NAME = 'core/nux';
|
|
|
28
28
|
*
|
|
29
29
|
* @type {Object}
|
|
30
30
|
*/
|
|
31
|
-
const store = (0, _data.createReduxStore)(STORE_NAME, {
|
|
31
|
+
const store = exports.store = (0, _data.createReduxStore)(STORE_NAME, {
|
|
32
32
|
reducer: _reducer.default,
|
|
33
33
|
actions,
|
|
34
34
|
selectors,
|
|
@@ -37,7 +37,6 @@ const store = (0, _data.createReduxStore)(STORE_NAME, {
|
|
|
37
37
|
|
|
38
38
|
// Once we build a more generic persistence plugin that works across types of stores
|
|
39
39
|
// we'd be able to replace this with a register call.
|
|
40
|
-
exports.store = store;
|
|
41
40
|
(0, _data.registerStore)(STORE_NAME, {
|
|
42
41
|
reducer: _reducer.default,
|
|
43
42
|
actions,
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_reducer","_interopRequireDefault","actions","_interopRequireWildcard","selectors","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"names":["_data","require","_reducer","_interopRequireDefault","actions","_interopRequireWildcard","selectors","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","STORE_NAME","store","exports","createReduxStore","reducer","persist","registerStore"],"sources":["@wordpress/nux/src/store/index.js"],"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"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,uBAAA,CAAAJ,OAAA;AAAyC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAVzC;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAMY,UAAU,GAAG,UAAU;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG,IAAAE,sBAAgB,EAAEH,UAAU,EAAE;EAClDI,OAAO,EAAPA,gBAAO;EACP5B,OAAO;EACPE,SAAS;EACT2B,OAAO,EAAE,CAAE,aAAa;AACzB,CAAE,CAAC;;AAEH;AACA;AACA,IAAAC,mBAAa,EAAEN,UAAU,EAAE;EAC1BI,OAAO,EAAPA,gBAAO;EACP5B,OAAO;EACPE,SAAS;EACT2B,OAAO,EAAE,CAAE,aAAa;AACzB,CAAE,CAAC"}
|
package/build/store/reducer.js
CHANGED
|
@@ -72,9 +72,8 @@ const preferences = (0, _data.combineReducers)({
|
|
|
72
72
|
areTipsEnabled,
|
|
73
73
|
dismissedTips
|
|
74
74
|
});
|
|
75
|
-
var _default = (0, _data.combineReducers)({
|
|
75
|
+
var _default = exports.default = (0, _data.combineReducers)({
|
|
76
76
|
guides,
|
|
77
77
|
preferences
|
|
78
78
|
});
|
|
79
|
-
exports.default = _default;
|
|
80
79
|
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences","combineReducers","_default","exports","default"],"sources":["@wordpress/nux/src/store/reducer.js"],"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"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,MAAMA,CAAEC,KAAK,GAAG,EAAE,EAAEC,MAAM,EAAG;EAC5C,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,eAAe;MACnB,OAAO,CAAE,GAAGF,KAAK,EAAEC,MAAM,CAACE,MAAM,CAAE;EACpC;EAEA,OAAOH,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAEJ,KAAK,GAAG,IAAI,EAAEC,MAAM,EAAG;EACtD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,cAAc;MAClB,OAAO,KAAK;IAEb,KAAK,aAAa;MACjB,OAAO,IAAI;EACb;EAEA,OAAOF,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,aAAaA,CAAEL,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACnD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,aAAa;MACjB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACK,EAAE,GAAI;MAChB,CAAC;IAEF,KAAK,aAAa;MACjB,OAAO,CAAC,CAAC;EACX;EAEA,OAAON,KAAK;AACb;AAEA,MAAMO,WAAW,GAAG,IAAAC,qBAAe,EAAE;EAAEJ,cAAc;EAAEC;AAAc,CAAE,CAAC;AAAC,IAAAI,QAAA,GAE1D,
|
|
1
|
+
{"version":3,"names":["_data","require","guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences","combineReducers","_default","exports","default"],"sources":["@wordpress/nux/src/store/reducer.js"],"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"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,MAAMA,CAAEC,KAAK,GAAG,EAAE,EAAEC,MAAM,EAAG;EAC5C,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,eAAe;MACnB,OAAO,CAAE,GAAGF,KAAK,EAAEC,MAAM,CAACE,MAAM,CAAE;EACpC;EAEA,OAAOH,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAEJ,KAAK,GAAG,IAAI,EAAEC,MAAM,EAAG;EACtD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,cAAc;MAClB,OAAO,KAAK;IAEb,KAAK,aAAa;MACjB,OAAO,IAAI;EACb;EAEA,OAAOF,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,aAAaA,CAAEL,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACnD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,aAAa;MACjB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACK,EAAE,GAAI;MAChB,CAAC;IAEF,KAAK,aAAa;MACjB,OAAO,CAAC,CAAC;EACX;EAEA,OAAON,KAAK;AACb;AAEA,MAAMO,WAAW,GAAG,IAAAC,qBAAe,EAAE;EAAEJ,cAAc;EAAEC;AAAc,CAAE,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE1D,IAAAH,qBAAe,EAAE;EAAET,MAAM;EAAEQ;AAAY,CAAE,CAAC"}
|
package/build/store/selectors.js
CHANGED
|
@@ -30,7 +30,7 @@ var _rememo = _interopRequireDefault(require("rememo"));
|
|
|
30
30
|
*
|
|
31
31
|
* @return {?NUXGuideInfo} Information about the associated guide.
|
|
32
32
|
*/
|
|
33
|
-
const getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
|
|
33
|
+
const getAssociatedGuide = exports.getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
|
|
34
34
|
for (const tipIds of state.guides) {
|
|
35
35
|
if (tipIds.includes(tipId)) {
|
|
36
36
|
const nonDismissedTips = tipIds.filter(tId => !Object.keys(state.preferences.dismissedTips).includes(tId));
|
|
@@ -55,7 +55,6 @@ const getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
|
|
|
55
55
|
*
|
|
56
56
|
* @return {boolean} Whether or not the given tip is showing.
|
|
57
57
|
*/
|
|
58
|
-
exports.getAssociatedGuide = getAssociatedGuide;
|
|
59
58
|
function isTipVisible(state, tipId) {
|
|
60
59
|
if (!state.preferences.areTipsEnabled) {
|
|
61
60
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_rememo","_interopRequireDefault","require","getAssociatedGuide","createSelector","state","tipId","tipIds","guides","includes","nonDismissedTips","filter","tId","Object","keys","preferences","dismissedTips","currentTipId","nextTipId","
|
|
1
|
+
{"version":3,"names":["_rememo","_interopRequireDefault","require","getAssociatedGuide","exports","createSelector","state","tipId","tipIds","guides","includes","nonDismissedTips","filter","tId","Object","keys","preferences","dismissedTips","currentTipId","nextTipId","isTipVisible","areTipsEnabled","hasOwnProperty","associatedGuide"],"sources":["@wordpress/nux/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * An object containing information about a guide.\n *\n * @typedef {Object} NUXGuideInfo\n * @property {string[]} tipIds Which tips the guide contains.\n * @property {?string} currentTipId The guide's currently showing tip.\n * @property {?string} nextTipId The guide's next tip to show.\n */\n\n/**\n * Returns an object describing the guide, if any, that the given tip is a part\n * of.\n *\n * @param {Object} state Global application state.\n * @param {string} tipId The tip to query.\n *\n * @return {?NUXGuideInfo} Information about the associated guide.\n */\nexport const getAssociatedGuide = createSelector(\n\t( state, tipId ) => {\n\t\tfor ( const tipIds of state.guides ) {\n\t\t\tif ( tipIds.includes( tipId ) ) {\n\t\t\t\tconst nonDismissedTips = tipIds.filter(\n\t\t\t\t\t( tId ) =>\n\t\t\t\t\t\t! Object.keys(\n\t\t\t\t\t\t\tstate.preferences.dismissedTips\n\t\t\t\t\t\t).includes( tId )\n\t\t\t\t);\n\t\t\t\tconst [ currentTipId = null, nextTipId = null ] =\n\t\t\t\t\tnonDismissedTips;\n\t\t\t\treturn { tipIds, currentTipId, nextTipId };\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t},\n\t( state ) => [ state.guides, state.preferences.dismissedTips ]\n);\n\n/**\n * Determines whether or not the given tip is showing. Tips are hidden if they\n * are disabled, have been dismissed, or are not the current tip in any\n * guide that they have been added to.\n *\n * @param {Object} state Global application state.\n * @param {string} tipId The tip to query.\n *\n * @return {boolean} Whether or not the given tip is showing.\n */\nexport function isTipVisible( state, tipId ) {\n\tif ( ! state.preferences.areTipsEnabled ) {\n\t\treturn false;\n\t}\n\n\tif ( state.preferences.dismissedTips?.hasOwnProperty( tipId ) ) {\n\t\treturn false;\n\t}\n\n\tconst associatedGuide = getAssociatedGuide( state, tipId );\n\tif ( associatedGuide && associatedGuide.currentTipId !== tipId ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns whether or not tips are globally enabled.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether tips are globally enabled.\n */\nexport function areTipsEnabled( state ) {\n\treturn state.preferences.areTipsEnabled;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAAE,eAAc,EAC/C,CAAEC,KAAK,EAAEC,KAAK,KAAM;EACnB,KAAM,MAAMC,MAAM,IAAIF,KAAK,CAACG,MAAM,EAAG;IACpC,IAAKD,MAAM,CAACE,QAAQ,CAAEH,KAAM,CAAC,EAAG;MAC/B,MAAMI,gBAAgB,GAAGH,MAAM,CAACI,MAAM,CACnCC,GAAG,IACJ,CAAEC,MAAM,CAACC,IAAI,CACZT,KAAK,CAACU,WAAW,CAACC,aACnB,CAAC,CAACP,QAAQ,CAAEG,GAAI,CAClB,CAAC;MACD,MAAM,CAAEK,YAAY,GAAG,IAAI,EAAEC,SAAS,GAAG,IAAI,CAAE,GAC9CR,gBAAgB;MACjB,OAAO;QAAEH,MAAM;QAAEU,YAAY;QAAEC;MAAU,CAAC;IAC3C;EACD;EAEA,OAAO,IAAI;AACZ,CAAC,EACCb,KAAK,IAAM,CAAEA,KAAK,CAACG,MAAM,EAAEH,KAAK,CAACU,WAAW,CAACC,aAAa,CAC7D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAAEd,KAAK,EAAEC,KAAK,EAAG;EAC5C,IAAK,CAAED,KAAK,CAACU,WAAW,CAACK,cAAc,EAAG;IACzC,OAAO,KAAK;EACb;EAEA,IAAKf,KAAK,CAACU,WAAW,CAACC,aAAa,EAAEK,cAAc,CAAEf,KAAM,CAAC,EAAG;IAC/D,OAAO,KAAK;EACb;EAEA,MAAMgB,eAAe,GAAGpB,kBAAkB,CAAEG,KAAK,EAAEC,KAAM,CAAC;EAC1D,IAAKgB,eAAe,IAAIA,eAAe,CAACL,YAAY,KAAKX,KAAK,EAAG;IAChE,OAAO,KAAK;EACb;EAEA,OAAO,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,cAAcA,CAAEf,KAAK,EAAG;EACvC,OAAOA,KAAK,CAACU,WAAW,CAACK,cAAc;AACxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/nux",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.13.0",
|
|
4
4
|
"description": "NUX (New User eXperience) module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/components": "^
|
|
35
|
-
"@wordpress/compose": "^6.
|
|
36
|
-
"@wordpress/data": "^9.
|
|
37
|
-
"@wordpress/deprecated": "^3.
|
|
38
|
-
"@wordpress/element": "^5.
|
|
39
|
-
"@wordpress/i18n": "^4.
|
|
40
|
-
"@wordpress/icons": "^9.
|
|
34
|
+
"@wordpress/components": "^26.0.0",
|
|
35
|
+
"@wordpress/compose": "^6.28.0",
|
|
36
|
+
"@wordpress/data": "^9.21.0",
|
|
37
|
+
"@wordpress/deprecated": "^3.51.0",
|
|
38
|
+
"@wordpress/element": "^5.28.0",
|
|
39
|
+
"@wordpress/i18n": "^4.51.0",
|
|
40
|
+
"@wordpress/icons": "^9.42.0",
|
|
41
41
|
"rememo": "^4.0.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "eb796371e9630636a4a8837033807b0c4a06ed67"
|
|
51
51
|
}
|