@wordpress/nux 8.1.0 → 8.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.2.0 (2023-08-16)
6
+
5
7
  ## 8.1.0 (2023-08-10)
6
8
 
7
9
  ## 8.0.0 (2023-07-20)
@@ -5,21 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.DotTip = DotTip;
7
7
  exports.default = void 0;
8
-
9
8
  var _element = require("@wordpress/element");
10
-
11
9
  var _compose = require("@wordpress/compose");
12
-
13
10
  var _components = require("@wordpress/components");
14
-
15
11
  var _i18n = require("@wordpress/i18n");
16
-
17
12
  var _data = require("@wordpress/data");
18
-
19
13
  var _icons = require("@wordpress/icons");
20
-
21
14
  var _store = require("../../store");
22
-
23
15
  /**
24
16
  * WordPress dependencies
25
17
  */
@@ -27,12 +19,12 @@ var _store = require("../../store");
27
19
  /**
28
20
  * Internal dependencies
29
21
  */
22
+
30
23
  function onClick(event) {
31
24
  // Tips are often nested within buttons. We stop propagation so that clicking
32
25
  // on a tip doesn't result in the button being clicked.
33
26
  event.stopPropagation();
34
27
  }
35
-
36
28
  function DotTip({
37
29
  position = 'middle right',
38
30
  children,
@@ -46,18 +38,14 @@ function DotTip({
46
38
  if (!anchorParent.current) {
47
39
  return;
48
40
  }
49
-
50
41
  if (anchorParent.current.contains(event.relatedTarget)) {
51
42
  return;
52
43
  }
53
-
54
44
  onDisable();
55
45
  }, [onDisable, anchorParent]);
56
-
57
46
  if (!isVisible) {
58
47
  return null;
59
48
  }
60
-
61
49
  return (0, _element.createElement)(_components.Popover, {
62
50
  className: "nux-dot-tip",
63
51
  position: position,
@@ -76,7 +64,6 @@ function DotTip({
76
64
  onClick: onDisable
77
65
  }));
78
66
  }
79
-
80
67
  var _default = (0, _compose.compose)((0, _data.withSelect)((select, {
81
68
  tipId
82
69
  }) => {
@@ -100,13 +87,10 @@ var _default = (0, _compose.compose)((0, _data.withSelect)((select, {
100
87
  onDismiss() {
101
88
  dismissTip(tipId);
102
89
  },
103
-
104
90
  onDisable() {
105
91
  disableTips();
106
92
  }
107
-
108
93
  };
109
94
  }))(DotTip);
110
-
111
95
  exports.default = _default;
112
96
  //# sourceMappingURL=index.js.map
@@ -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,CAAiB;AACvBC,EAAAA,QAAQ,GAAG,cADY;AAEvBC,EAAAA,QAFuB;AAGvBC,EAAAA,SAHuB;AAIvBC,EAAAA,UAJuB;AAKvBC,EAAAA,SALuB;AAMvBC,EAAAA;AANuB,CAAjB,EAOH;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,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,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\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"]}
1
+ {"version":3,"names":["_element","require","_compose","_components","_i18n","_data","_icons","_store","onClick","event","stopPropagation","DotTip","position","children","isVisible","hasNextTip","onDismiss","onDisable","anchorParent","useRef","onFocusOutsideCallback","useCallback","current","contains","relatedTarget","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","exports","default"],"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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AAf,QAAA"}
package/build/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -17,16 +16,13 @@ Object.defineProperty(exports, "store", {
17
16
  return _store.store;
18
17
  }
19
18
  });
20
-
21
19
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
22
-
23
20
  var _store = require("./store");
24
-
25
21
  var _dotTip = _interopRequireDefault(require("./components/dot-tip"));
26
-
27
22
  /**
28
23
  * WordPress dependencies
29
24
  */
25
+
30
26
  (0, _deprecated.default)('wp.nux', {
31
27
  since: '5.4',
32
28
  hint: 'wp.components.Guide can be used to show a user guide.',
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/index.js"],"names":["since","hint","version"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AAEA;;AACA;;AANA;AACA;AACA;AAMA,yBAAY,QAAZ,EAAsB;AACrBA,EAAAA,KAAK,EAAE,KADc;AAErBC,EAAAA,IAAI,EAAE,uDAFe;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nexport { store } from './store';\nexport { default as DotTip } from './components/dot-tip';\n\ndeprecated( 'wp.nux', {\n\tsince: '5.4',\n\thint: 'wp.components.Guide can be used to show a user guide.',\n\tversion: '6.2',\n} );\n"]}
1
+ {"version":3,"names":["_deprecated","_interopRequireDefault","require","_store","_dotTip","deprecated","since","hint","version"],"sources":["@wordpress/nux/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nexport { store } from './store';\nexport { default as DotTip } from './components/dot-tip';\n\ndeprecated( 'wp.nux', {\n\tsince: '5.4',\n\thint: 'wp.components.Guide can be used to show a user guide.',\n\tversion: '6.2',\n} );\n"],"mappings":";;;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMA,IAAAG,mBAAU,EAAE,QAAQ,EAAE;EACrBC,KAAK,EAAE,KAAK;EACZC,IAAI,EAAE,uDAAuD;EAC7DC,OAAO,EAAE;AACV,CAAE,CAAC"}
@@ -7,7 +7,6 @@ exports.disableTips = disableTips;
7
7
  exports.dismissTip = dismissTip;
8
8
  exports.enableTips = enableTips;
9
9
  exports.triggerGuide = triggerGuide;
10
-
11
10
  /**
12
11
  * Returns an action object that, when dispatched, presents a guide that takes
13
12
  * the user through a series of tips step by step.
@@ -22,6 +21,7 @@ function triggerGuide(tipIds) {
22
21
  tipIds
23
22
  };
24
23
  }
24
+
25
25
  /**
26
26
  * Returns an action object that, when dispatched, dismisses the given tip. A
27
27
  * dismissed tip will not show again.
@@ -30,34 +30,30 @@ function triggerGuide(tipIds) {
30
30
  *
31
31
  * @return {Object} Action object.
32
32
  */
33
-
34
-
35
33
  function dismissTip(id) {
36
34
  return {
37
35
  type: 'DISMISS_TIP',
38
36
  id
39
37
  };
40
38
  }
39
+
41
40
  /**
42
41
  * Returns an action object that, when dispatched, prevents all tips from
43
42
  * showing again.
44
43
  *
45
44
  * @return {Object} Action object.
46
45
  */
47
-
48
-
49
46
  function disableTips() {
50
47
  return {
51
48
  type: 'DISABLE_TIPS'
52
49
  };
53
50
  }
51
+
54
52
  /**
55
53
  * Returns an action object that, when dispatched, makes all tips show again.
56
54
  *
57
55
  * @return {Object} Action object.
58
56
  */
59
-
60
-
61
57
  function enableTips() {
62
58
  return {
63
59
  type: 'ENABLE_TIPS'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/actions.js"],"names":["triggerGuide","tipIds","type","dismissTip","id","disableTips","enableTips"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CAAuBC,MAAvB,EAAgC;AACtC,SAAO;AACNC,IAAAA,IAAI,EAAE,eADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,UAAT,CAAqBC,EAArB,EAA0B;AAChC,SAAO;AACNF,IAAAA,IAAI,EAAE,aADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,GAAuB;AAC7B,SAAO;AACNH,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASI,UAAT,GAAsB;AAC5B,SAAO;AACNJ,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","sourcesContent":["/**\n * Returns an action object that, when dispatched, presents a guide that takes\n * the user through a series of tips step by step.\n *\n * @param {string[]} tipIds Which tips to show in the guide.\n *\n * @return {Object} Action object.\n */\nexport function triggerGuide( tipIds ) {\n\treturn {\n\t\ttype: 'TRIGGER_GUIDE',\n\t\ttipIds,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, dismisses the given tip. A\n * dismissed tip will not show again.\n *\n * @param {string} id The tip to dismiss.\n *\n * @return {Object} Action object.\n */\nexport function dismissTip( id ) {\n\treturn {\n\t\ttype: 'DISMISS_TIP',\n\t\tid,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, prevents all tips from\n * showing again.\n *\n * @return {Object} Action object.\n */\nexport function disableTips() {\n\treturn {\n\t\ttype: 'DISABLE_TIPS',\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, makes all tips show again.\n *\n * @return {Object} Action object.\n */\nexport function enableTips() {\n\treturn {\n\t\ttype: 'ENABLE_TIPS',\n\t};\n}\n"]}
1
+ {"version":3,"names":["triggerGuide","tipIds","type","dismissTip","id","disableTips","enableTips"],"sources":["@wordpress/nux/src/store/actions.js"],"sourcesContent":["/**\n * Returns an action object that, when dispatched, presents a guide that takes\n * the user through a series of tips step by step.\n *\n * @param {string[]} tipIds Which tips to show in the guide.\n *\n * @return {Object} Action object.\n */\nexport function triggerGuide( tipIds ) {\n\treturn {\n\t\ttype: 'TRIGGER_GUIDE',\n\t\ttipIds,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, dismisses the given tip. A\n * dismissed tip will not show again.\n *\n * @param {string} id The tip to dismiss.\n *\n * @return {Object} Action object.\n */\nexport function dismissTip( id ) {\n\treturn {\n\t\ttype: 'DISMISS_TIP',\n\t\tid,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, prevents all tips from\n * showing again.\n *\n * @return {Object} Action object.\n */\nexport function disableTips() {\n\treturn {\n\t\ttype: 'DISABLE_TIPS',\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, makes all tips show again.\n *\n * @return {Object} Action object.\n */\nexport function enableTips() {\n\treturn {\n\t\ttype: 'ENABLE_TIPS',\n\t};\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAAEC,MAAM,EAAG;EACtC,OAAO;IACNC,IAAI,EAAE,eAAe;IACrBD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAAEC,EAAE,EAAG;EAChC,OAAO;IACNF,IAAI,EAAE,aAAa;IACnBE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,WAAWA,CAAA,EAAG;EAC7B,OAAO;IACNH,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAAA,EAAG;EAC5B,OAAO;IACNJ,IAAI,EAAE;EACP,CAAC;AACF"}
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.store = void 0;
9
-
10
8
  var _data = require("@wordpress/data");
11
-
12
9
  var _reducer = _interopRequireDefault(require("./reducer"));
13
-
14
10
  var actions = _interopRequireWildcard(require("./actions"));
15
-
16
11
  var selectors = _interopRequireWildcard(require("./selectors"));
17
-
18
12
  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
13
  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
-
22
14
  /**
23
15
  * WordPress dependencies
24
16
  */
@@ -26,7 +18,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
26
18
  /**
27
19
  * Internal dependencies
28
20
  */
21
+
29
22
  const STORE_NAME = 'core/nux';
23
+
30
24
  /**
31
25
  * Store definition for the nux namespace.
32
26
  *
@@ -34,15 +28,15 @@ const STORE_NAME = 'core/nux';
34
28
  *
35
29
  * @type {Object}
36
30
  */
37
-
38
31
  const store = (0, _data.createReduxStore)(STORE_NAME, {
39
32
  reducer: _reducer.default,
40
33
  actions,
41
34
  selectors,
42
35
  persist: ['preferences']
43
- }); // Once we build a more generic persistence plugin that works across types of stores
44
- // we'd be able to replace this with a register call.
36
+ });
45
37
 
38
+ // Once we build a more generic persistence plugin that works across types of stores
39
+ // we'd be able to replace this with a register call.
46
40
  exports.store = store;
47
41
  (0, _data.registerStore)(STORE_NAME, {
48
42
  reducer: _reducer.default,
@@ -1 +1 @@
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"]}
1
+ {"version":3,"names":["_data","require","_reducer","_interopRequireDefault","actions","_interopRequireWildcard","selectors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","STORE_NAME","store","createReduxStore","reducer","persist","exports","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,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CA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T2B,OAAO,EAAE,CAAE,aAAa;AACzB,CAAE,CAAC"}
@@ -7,9 +7,7 @@ exports.areTipsEnabled = areTipsEnabled;
7
7
  exports.default = void 0;
8
8
  exports.dismissedTips = dismissedTips;
9
9
  exports.guides = guides;
10
-
11
10
  var _data = require("@wordpress/data");
12
-
13
11
  /**
14
12
  * WordPress dependencies
15
13
  */
@@ -28,9 +26,9 @@ function guides(state = [], action) {
28
26
  case 'TRIGGER_GUIDE':
29
27
  return [...state, action.tipIds];
30
28
  }
31
-
32
29
  return state;
33
30
  }
31
+
34
32
  /**
35
33
  * Reducer that tracks whether or not tips are globally enabled.
36
34
  *
@@ -39,19 +37,16 @@ function guides(state = [], action) {
39
37
  *
40
38
  * @return {boolean} Updated state.
41
39
  */
42
-
43
-
44
40
  function areTipsEnabled(state = true, action) {
45
41
  switch (action.type) {
46
42
  case 'DISABLE_TIPS':
47
43
  return false;
48
-
49
44
  case 'ENABLE_TIPS':
50
45
  return true;
51
46
  }
52
-
53
47
  return state;
54
48
  }
49
+
55
50
  /**
56
51
  * Reducer that tracks which tips have been dismissed. If the state object
57
52
  * contains a tip identifier, then that tip is dismissed.
@@ -61,31 +56,25 @@ function areTipsEnabled(state = true, action) {
61
56
  *
62
57
  * @return {Object} Updated state.
63
58
  */
64
-
65
-
66
59
  function dismissedTips(state = {}, action) {
67
60
  switch (action.type) {
68
61
  case 'DISMISS_TIP':
69
- return { ...state,
62
+ return {
63
+ ...state,
70
64
  [action.id]: true
71
65
  };
72
-
73
66
  case 'ENABLE_TIPS':
74
67
  return {};
75
68
  }
76
-
77
69
  return state;
78
70
  }
79
-
80
71
  const preferences = (0, _data.combineReducers)({
81
72
  areTipsEnabled,
82
73
  dismissedTips
83
74
  });
84
-
85
75
  var _default = (0, _data.combineReducers)({
86
76
  guides,
87
77
  preferences
88
78
  });
89
-
90
79
  exports.default = _default;
91
80
  //# sourceMappingURL=reducer.js.map
@@ -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,CAAiBC,KAAK,GAAG,EAAzB,EAA6BC,MAA7B,EAAsC;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,CAAyBJ,KAAK,GAAG,IAAjC,EAAuCC,MAAvC,EAAgD;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,CAAwBL,KAAK,GAAG,EAAhC,EAAoCC,MAApC,EAA6C;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"]}
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,IAAAD,qBAAe,EAAE;EAAET,MAAM;EAAEQ;AAAY,CAAE,CAAC;AAAAG,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.areTipsEnabled = areTipsEnabled;
9
8
  exports.getAssociatedGuide = void 0;
10
9
  exports.isTipVisible = isTipVisible;
11
-
12
10
  var _rememo = _interopRequireDefault(require("rememo"));
13
-
14
11
  /**
15
12
  * External dependencies
16
13
  */
@@ -45,9 +42,9 @@ const getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
45
42
  };
46
43
  }
47
44
  }
48
-
49
45
  return null;
50
46
  }, state => [state.guides, state.preferences.dismissedTips]);
47
+
51
48
  /**
52
49
  * Determines whether or not the given tip is showing. Tips are hidden if they
53
50
  * are disabled, have been dismissed, or are not the current tip in any
@@ -58,26 +55,21 @@ const getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
58
55
  *
59
56
  * @return {boolean} Whether or not the given tip is showing.
60
57
  */
61
-
62
58
  exports.getAssociatedGuide = getAssociatedGuide;
63
-
64
59
  function isTipVisible(state, tipId) {
65
60
  if (!state.preferences.areTipsEnabled) {
66
61
  return false;
67
62
  }
68
-
69
63
  if (state.preferences.dismissedTips?.hasOwnProperty(tipId)) {
70
64
  return false;
71
65
  }
72
-
73
66
  const associatedGuide = getAssociatedGuide(state, tipId);
74
-
75
67
  if (associatedGuide && associatedGuide.currentTipId !== tipId) {
76
68
  return false;
77
69
  }
78
-
79
70
  return true;
80
71
  }
72
+
81
73
  /**
82
74
  * Returns whether or not tips are globally enabled.
83
75
  *
@@ -85,8 +77,6 @@ function isTipVisible(state, tipId) {
85
77
  *
86
78
  * @return {boolean} Whether tips are globally enabled.
87
79
  */
88
-
89
-
90
80
  function areTipsEnabled(state) {
91
81
  return state.preferences.areTipsEnabled;
92
82
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/selectors.js"],"names":["getAssociatedGuide","state","tipId","tipIds","guides","includes","nonDismissedTips","filter","tId","Object","keys","preferences","dismissedTips","currentTipId","nextTipId","isTipVisible","areTipsEnabled","hasOwnProperty","associatedGuide"],"mappings":";;;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAG,qBACjC,CAAEC,KAAF,EAASC,KAAT,KAAoB;AACnB,OAAM,MAAMC,MAAZ,IAAsBF,KAAK,CAACG,MAA5B,EAAqC;AACpC,QAAKD,MAAM,CAACE,QAAP,CAAiBH,KAAjB,CAAL,EAAgC;AAC/B,YAAMI,gBAAgB,GAAGH,MAAM,CAACI,MAAP,CACtBC,GAAF,IACC,CAAEC,MAAM,CAACC,IAAP,CACDT,KAAK,CAACU,WAAN,CAAkBC,aADjB,EAEAP,QAFA,CAEUG,GAFV,CAFqB,CAAzB;AAMA,YAAM,CAAEK,YAAY,GAAG,IAAjB,EAAuBC,SAAS,GAAG,IAAnC,IACLR,gBADD;AAEA,aAAO;AAAEH,QAAAA,MAAF;AAAUU,QAAAA,YAAV;AAAwBC,QAAAA;AAAxB,OAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA,CAjBgC,EAkB/Bb,KAAF,IAAa,CAAEA,KAAK,CAACG,MAAR,EAAgBH,KAAK,CAACU,WAAN,CAAkBC,aAAlC,CAlBoB,CAA3B;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASG,YAAT,CAAuBd,KAAvB,EAA8BC,KAA9B,EAAsC;AAC5C,MAAK,CAAED,KAAK,CAACU,WAAN,CAAkBK,cAAzB,EAA0C;AACzC,WAAO,KAAP;AACA;;AAED,MAAKf,KAAK,CAACU,WAAN,CAAkBC,aAAlB,EAAiCK,cAAjC,CAAiDf,KAAjD,CAAL,EAAgE;AAC/D,WAAO,KAAP;AACA;;AAED,QAAMgB,eAAe,GAAGlB,kBAAkB,CAAEC,KAAF,EAASC,KAAT,CAA1C;;AACA,MAAKgB,eAAe,IAAIA,eAAe,CAACL,YAAhB,KAAiCX,KAAzD,EAAiE;AAChE,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASc,cAAT,CAAyBf,KAAzB,EAAiC;AACvC,SAAOA,KAAK,CAACU,WAAN,CAAkBK,cAAzB;AACA","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"]}
1
+ {"version":3,"names":["_rememo","_interopRequireDefault","require","getAssociatedGuide","createSelector","state","tipId","tipIds","guides","includes","nonDismissedTips","filter","tId","Object","keys","preferences","dismissedTips","currentTipId","nextTipId","exports","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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KAAK,EAAG;EACvC,OAAOA,KAAK,CAACU,WAAW,CAACM,cAAc;AACxC"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -9,18 +8,16 @@ import { __ } from '@wordpress/i18n';
9
8
  import { withSelect, withDispatch } from '@wordpress/data';
10
9
  import { useCallback, useRef } from '@wordpress/element';
11
10
  import { close } from '@wordpress/icons';
11
+
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
-
16
15
  import { store as nuxStore } from '../../store';
17
-
18
16
  function onClick(event) {
19
17
  // Tips are often nested within buttons. We stop propagation so that clicking
20
18
  // on a tip doesn't result in the button being clicked.
21
19
  event.stopPropagation();
22
20
  }
23
-
24
21
  export function DotTip({
25
22
  position = 'middle right',
26
23
  children,
@@ -34,18 +31,14 @@ export function DotTip({
34
31
  if (!anchorParent.current) {
35
32
  return;
36
33
  }
37
-
38
34
  if (anchorParent.current.contains(event.relatedTarget)) {
39
35
  return;
40
36
  }
41
-
42
37
  onDisable();
43
38
  }, [onDisable, anchorParent]);
44
-
45
39
  if (!isVisible) {
46
40
  return null;
47
41
  }
48
-
49
42
  return createElement(Popover, {
50
43
  className: "nux-dot-tip",
51
44
  position: position,
@@ -87,11 +80,9 @@ export default compose(withSelect((select, {
87
80
  onDismiss() {
88
81
  dismissTip(tipId);
89
82
  },
90
-
91
83
  onDisable() {
92
84
  disableTips();
93
85
  }
94
-
95
86
  };
96
87
  }))(DotTip);
97
88
  //# sourceMappingURL=index.js.map
@@ -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"],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W;AAPlB,KASC,yBAAKN,QAAL,CATD,EAUC,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,CAVD,EAeC,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,IAfD,CADD;AAwBA;AAED,eAAepB,OAAO,CACrBI,UAAU,CAAE,CAAEsB,MAAF,EAAU;AAAEC,EAAAA;AAAF,CAAV,KAAyB;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,EAAY;AAAEL,EAAAA;AAAF,CAAZ,KAA2B;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\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"]}
1
+ {"version":3,"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","createElement","className","focusOnMount","role","onFocusOutside","variant","icon","label","select","tipId","isTipVisible","getAssociatedGuide","associatedGuide","nextTipId","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":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,OAAO,EAAEC,MAAM,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,EAAEC,YAAY,QAAQ,iB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,EAAC,sBAAsB;IAChCK,IAAI,EAAGxB,KAAO;IACdyB,KAAK,EAAG9B,EAAE,CAAE,cAAe,CAAG;IAC9BQ,OAAO,EAAGS;EAAW,CACrB,CACO,CAAC;AAEZ;AAEA,eAAepB,OAAO,CACrBI,UAAU,CAAE,CAAE8B,MAAM,EAAE;EAAEC;AAAM,CAAC,KAAM;EACpC,MAAM;IAAEC,YAAY;IAAEC;EAAmB,CAAC,GAAGH,MAAM,CAAExB,QAAS,CAAC;EAC/D,MAAM4B,eAAe,GAAGD,kBAAkB,CAAEF,KAAM,CAAC;EACnD,OAAO;IACNlB,SAAS,EAAEmB,YAAY,CAAED,KAAM,CAAC;IAChCjB,UAAU,EAAE,CAAC,EAAIoB,eAAe,IAAIA,eAAe,CAACC,SAAS;EAC9D,CAAC;AACF,CAAE,CAAC,EACHlC,YAAY,CAAE,CAAEmC,QAAQ,EAAE;EAAEL;AAAM,CAAC,KAAM;EACxC,MAAM;IAAEM,UAAU;IAAEC;EAAY,CAAC,GAAGF,QAAQ,CAAE9B,QAAS,CAAC;EACxD,OAAO;IACNS,SAASA,CAAA,EAAG;MACXsB,UAAU,CAAEN,KAAM,CAAC;IACpB,CAAC;IACDf,SAASA,CAAA,EAAG;MACXsB,WAAW,CAAC,CAAC;IACd;EACD,CAAC;AACF,CAAE,CACH,CAAC,CAAE5B,MAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/index.js"],"names":["deprecated","store","default","DotTip","since","hint","version"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,OAAO,IAAIC,MAApB,QAAkC,sBAAlC;AAEAH,UAAU,CAAE,QAAF,EAAY;AACrBI,EAAAA,KAAK,EAAE,KADc;AAErBC,EAAAA,IAAI,EAAE,uDAFe;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAZ,CAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nexport { store } from './store';\nexport { default as DotTip } from './components/dot-tip';\n\ndeprecated( 'wp.nux', {\n\tsince: '5.4',\n\thint: 'wp.components.Guide can be used to show a user guide.',\n\tversion: '6.2',\n} );\n"]}
1
+ {"version":3,"names":["deprecated","store","default","DotTip","since","hint","version"],"sources":["@wordpress/nux/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nexport { store } from './store';\nexport { default as DotTip } from './components/dot-tip';\n\ndeprecated( 'wp.nux', {\n\tsince: '5.4',\n\thint: 'wp.components.Guide can be used to show a user guide.',\n\tversion: '6.2',\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;AAE9C,SAASC,KAAK,QAAQ,SAAS;AAC/B,SAASC,OAAO,IAAIC,MAAM,QAAQ,sBAAsB;AAExDH,UAAU,CAAE,QAAQ,EAAE;EACrBI,KAAK,EAAE,KAAK;EACZC,IAAI,EAAE,uDAAuD;EAC7DC,OAAO,EAAE;AACV,CAAE,CAAC"}
@@ -12,6 +12,7 @@ export function triggerGuide(tipIds) {
12
12
  tipIds
13
13
  };
14
14
  }
15
+
15
16
  /**
16
17
  * Returns an action object that, when dispatched, dismisses the given tip. A
17
18
  * dismissed tip will not show again.
@@ -20,31 +21,30 @@ export function triggerGuide(tipIds) {
20
21
  *
21
22
  * @return {Object} Action object.
22
23
  */
23
-
24
24
  export function dismissTip(id) {
25
25
  return {
26
26
  type: 'DISMISS_TIP',
27
27
  id
28
28
  };
29
29
  }
30
+
30
31
  /**
31
32
  * Returns an action object that, when dispatched, prevents all tips from
32
33
  * showing again.
33
34
  *
34
35
  * @return {Object} Action object.
35
36
  */
36
-
37
37
  export function disableTips() {
38
38
  return {
39
39
  type: 'DISABLE_TIPS'
40
40
  };
41
41
  }
42
+
42
43
  /**
43
44
  * Returns an action object that, when dispatched, makes all tips show again.
44
45
  *
45
46
  * @return {Object} Action object.
46
47
  */
47
-
48
48
  export function enableTips() {
49
49
  return {
50
50
  type: 'ENABLE_TIPS'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/actions.js"],"names":["triggerGuide","tipIds","type","dismissTip","id","disableTips","enableTips"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,CAAuBC,MAAvB,EAAgC;AACtC,SAAO;AACNC,IAAAA,IAAI,EAAE,eADA;AAEND,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,UAAT,CAAqBC,EAArB,EAA0B;AAChC,SAAO;AACNF,IAAAA,IAAI,EAAE,aADA;AAENE,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,GAAuB;AAC7B,SAAO;AACNH,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,UAAT,GAAsB;AAC5B,SAAO;AACNJ,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","sourcesContent":["/**\n * Returns an action object that, when dispatched, presents a guide that takes\n * the user through a series of tips step by step.\n *\n * @param {string[]} tipIds Which tips to show in the guide.\n *\n * @return {Object} Action object.\n */\nexport function triggerGuide( tipIds ) {\n\treturn {\n\t\ttype: 'TRIGGER_GUIDE',\n\t\ttipIds,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, dismisses the given tip. A\n * dismissed tip will not show again.\n *\n * @param {string} id The tip to dismiss.\n *\n * @return {Object} Action object.\n */\nexport function dismissTip( id ) {\n\treturn {\n\t\ttype: 'DISMISS_TIP',\n\t\tid,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, prevents all tips from\n * showing again.\n *\n * @return {Object} Action object.\n */\nexport function disableTips() {\n\treturn {\n\t\ttype: 'DISABLE_TIPS',\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, makes all tips show again.\n *\n * @return {Object} Action object.\n */\nexport function enableTips() {\n\treturn {\n\t\ttype: 'ENABLE_TIPS',\n\t};\n}\n"]}
1
+ {"version":3,"names":["triggerGuide","tipIds","type","dismissTip","id","disableTips","enableTips"],"sources":["@wordpress/nux/src/store/actions.js"],"sourcesContent":["/**\n * Returns an action object that, when dispatched, presents a guide that takes\n * the user through a series of tips step by step.\n *\n * @param {string[]} tipIds Which tips to show in the guide.\n *\n * @return {Object} Action object.\n */\nexport function triggerGuide( tipIds ) {\n\treturn {\n\t\ttype: 'TRIGGER_GUIDE',\n\t\ttipIds,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, dismisses the given tip. A\n * dismissed tip will not show again.\n *\n * @param {string} id The tip to dismiss.\n *\n * @return {Object} Action object.\n */\nexport function dismissTip( id ) {\n\treturn {\n\t\ttype: 'DISMISS_TIP',\n\t\tid,\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, prevents all tips from\n * showing again.\n *\n * @return {Object} Action object.\n */\nexport function disableTips() {\n\treturn {\n\t\ttype: 'DISABLE_TIPS',\n\t};\n}\n\n/**\n * Returns an action object that, when dispatched, makes all tips show again.\n *\n * @return {Object} Action object.\n */\nexport function enableTips() {\n\treturn {\n\t\ttype: 'ENABLE_TIPS',\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAAEC,MAAM,EAAG;EACtC,OAAO;IACNC,IAAI,EAAE,eAAe;IACrBD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,UAAUA,CAAEC,EAAE,EAAG;EAChC,OAAO;IACNF,IAAI,EAAE,aAAa;IACnBE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAA,EAAG;EAC7B,OAAO;IACNH,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,UAAUA,CAAA,EAAG;EAC5B,OAAO;IACNJ,IAAI,EAAE;EACP,CAAC;AACF"}
@@ -2,14 +2,15 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createReduxStore, registerStore } from '@wordpress/data';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import reducer from './reducer';
10
10
  import * as actions from './actions';
11
11
  import * as selectors from './selectors';
12
12
  const STORE_NAME = 'core/nux';
13
+
13
14
  /**
14
15
  * Store definition for the nux namespace.
15
16
  *
@@ -17,15 +18,15 @@ const STORE_NAME = 'core/nux';
17
18
  *
18
19
  * @type {Object}
19
20
  */
20
-
21
21
  export const store = createReduxStore(STORE_NAME, {
22
22
  reducer,
23
23
  actions,
24
24
  selectors,
25
25
  persist: ['preferences']
26
- }); // Once we build a more generic persistence plugin that works across types of stores
27
- // we'd be able to replace this with a register call.
26
+ });
28
27
 
28
+ // Once we build a more generic persistence plugin that works across types of stores
29
+ // we'd be able to replace this with a register call.
29
30
  registerStore(STORE_NAME, {
30
31
  reducer,
31
32
  actions,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/index.js"],"names":["createReduxStore","registerStore","reducer","actions","selectors","STORE_NAME","store","persist"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AAEA,MAAMC,UAAU,GAAG,UAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAF,EAAc;AAClDH,EAAAA,OADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA,SAHkD;AAIlDG,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJyC,CAAd,CAA9B,C,CAOP;AACA;;AACAN,aAAa,CAAEI,UAAF,EAAc;AAC1BH,EAAAA,OAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BG,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJiB,CAAd,CAAb","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"]}
1
+ {"version":3,"names":["createReduxStore","registerStore","reducer","actions","selectors","STORE_NAME","store","persist"],"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":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,aAAa,QAAQ,iBAAiB;;AAEjE;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AAExC,MAAMC,UAAU,GAAG,UAAU;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAU,EAAE;EAClDH,OAAO;EACPC,OAAO;EACPC,SAAS;EACTG,OAAO,EAAE,CAAE,aAAa;AACzB,CAAE,CAAC;;AAEH;AACA;AACAN,aAAa,CAAEI,UAAU,EAAE;EAC1BH,OAAO;EACPC,OAAO;EACPC,SAAS;EACTG,OAAO,EAAE,CAAE,aAAa;AACzB,CAAE,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { combineReducers } from '@wordpress/data';
5
+
5
6
  /**
6
7
  * Reducer that tracks which tips are in a guide. Each guide is represented by
7
8
  * an array which contains the tip identifiers contained within that guide.
@@ -11,15 +12,14 @@ import { combineReducers } from '@wordpress/data';
11
12
  *
12
13
  * @return {Array} Updated state.
13
14
  */
14
-
15
15
  export function guides(state = [], action) {
16
16
  switch (action.type) {
17
17
  case 'TRIGGER_GUIDE':
18
18
  return [...state, action.tipIds];
19
19
  }
20
-
21
20
  return state;
22
21
  }
22
+
23
23
  /**
24
24
  * Reducer that tracks whether or not tips are globally enabled.
25
25
  *
@@ -28,18 +28,16 @@ export function guides(state = [], action) {
28
28
  *
29
29
  * @return {boolean} Updated state.
30
30
  */
31
-
32
31
  export function areTipsEnabled(state = true, action) {
33
32
  switch (action.type) {
34
33
  case 'DISABLE_TIPS':
35
34
  return false;
36
-
37
35
  case 'ENABLE_TIPS':
38
36
  return true;
39
37
  }
40
-
41
38
  return state;
42
39
  }
40
+
43
41
  /**
44
42
  * Reducer that tracks which tips have been dismissed. If the state object
45
43
  * contains a tip identifier, then that tip is dismissed.
@@ -49,18 +47,16 @@ export function areTipsEnabled(state = true, action) {
49
47
  *
50
48
  * @return {Object} Updated state.
51
49
  */
52
-
53
50
  export function dismissedTips(state = {}, action) {
54
51
  switch (action.type) {
55
52
  case 'DISMISS_TIP':
56
- return { ...state,
53
+ return {
54
+ ...state,
57
55
  [action.id]: true
58
56
  };
59
-
60
57
  case 'ENABLE_TIPS':
61
58
  return {};
62
59
  }
63
-
64
60
  return state;
65
61
  }
66
62
  const preferences = combineReducers({
@@ -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,CAAiBC,KAAK,GAAG,EAAzB,EAA6BC,MAA7B,EAAsC;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,CAAyBJ,KAAK,GAAG,IAAjC,EAAuCC,MAAvC,EAAgD;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,CAAwBL,KAAK,GAAG,EAAhC,EAAoCC,MAApC,EAA6C;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"]}
1
+ {"version":3,"names":["combineReducers","guides","state","action","type","tipIds","areTipsEnabled","dismissedTips","id","preferences"],"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":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,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;AACA,OAAO,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;AACA,OAAO,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,GAAGT,eAAe,CAAE;EAAEM,cAAc;EAAEC;AAAc,CAAE,CAAC;AAExE,eAAeP,eAAe,CAAE;EAAEC,MAAM;EAAEQ;AAAY,CAAE,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
+
5
6
  /**
6
7
  * An object containing information about a guide.
7
8
  *
@@ -20,7 +21,6 @@ import createSelector from 'rememo';
20
21
  *
21
22
  * @return {?NUXGuideInfo} Information about the associated guide.
22
23
  */
23
-
24
24
  export const getAssociatedGuide = createSelector((state, tipId) => {
25
25
  for (const tipIds of state.guides) {
26
26
  if (tipIds.includes(tipId)) {
@@ -33,9 +33,9 @@ export const getAssociatedGuide = createSelector((state, tipId) => {
33
33
  };
34
34
  }
35
35
  }
36
-
37
36
  return null;
38
37
  }, state => [state.guides, state.preferences.dismissedTips]);
38
+
39
39
  /**
40
40
  * Determines whether or not the given tip is showing. Tips are hidden if they
41
41
  * are disabled, have been dismissed, or are not the current tip in any
@@ -46,24 +46,20 @@ export const getAssociatedGuide = createSelector((state, tipId) => {
46
46
  *
47
47
  * @return {boolean} Whether or not the given tip is showing.
48
48
  */
49
-
50
49
  export function isTipVisible(state, tipId) {
51
50
  if (!state.preferences.areTipsEnabled) {
52
51
  return false;
53
52
  }
54
-
55
53
  if (state.preferences.dismissedTips?.hasOwnProperty(tipId)) {
56
54
  return false;
57
55
  }
58
-
59
56
  const associatedGuide = getAssociatedGuide(state, tipId);
60
-
61
57
  if (associatedGuide && associatedGuide.currentTipId !== tipId) {
62
58
  return false;
63
59
  }
64
-
65
60
  return true;
66
61
  }
62
+
67
63
  /**
68
64
  * Returns whether or not tips are globally enabled.
69
65
  *
@@ -71,7 +67,6 @@ export function isTipVisible(state, tipId) {
71
67
  *
72
68
  * @return {boolean} Whether tips are globally enabled.
73
69
  */
74
-
75
70
  export function areTipsEnabled(state) {
76
71
  return state.preferences.areTipsEnabled;
77
72
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/selectors.js"],"names":["createSelector","getAssociatedGuide","state","tipId","tipIds","guides","includes","nonDismissedTips","filter","tId","Object","keys","preferences","dismissedTips","currentTipId","nextTipId","isTipVisible","areTipsEnabled","hasOwnProperty","associatedGuide"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAGD,cAAc,CAC/C,CAAEE,KAAF,EAASC,KAAT,KAAoB;AACnB,OAAM,MAAMC,MAAZ,IAAsBF,KAAK,CAACG,MAA5B,EAAqC;AACpC,QAAKD,MAAM,CAACE,QAAP,CAAiBH,KAAjB,CAAL,EAAgC;AAC/B,YAAMI,gBAAgB,GAAGH,MAAM,CAACI,MAAP,CACtBC,GAAF,IACC,CAAEC,MAAM,CAACC,IAAP,CACDT,KAAK,CAACU,WAAN,CAAkBC,aADjB,EAEAP,QAFA,CAEUG,GAFV,CAFqB,CAAzB;AAMA,YAAM,CAAEK,YAAY,GAAG,IAAjB,EAAuBC,SAAS,GAAG,IAAnC,IACLR,gBADD;AAEA,aAAO;AAAEH,QAAAA,MAAF;AAAUU,QAAAA,YAAV;AAAwBC,QAAAA;AAAxB,OAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA,CAjB8C,EAkB7Cb,KAAF,IAAa,CAAEA,KAAK,CAACG,MAAR,EAAgBH,KAAK,CAACU,WAAN,CAAkBC,aAAlC,CAlBkC,CAAzC;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,YAAT,CAAuBd,KAAvB,EAA8BC,KAA9B,EAAsC;AAC5C,MAAK,CAAED,KAAK,CAACU,WAAN,CAAkBK,cAAzB,EAA0C;AACzC,WAAO,KAAP;AACA;;AAED,MAAKf,KAAK,CAACU,WAAN,CAAkBC,aAAlB,EAAiCK,cAAjC,CAAiDf,KAAjD,CAAL,EAAgE;AAC/D,WAAO,KAAP;AACA;;AAED,QAAMgB,eAAe,GAAGlB,kBAAkB,CAAEC,KAAF,EAASC,KAAT,CAA1C;;AACA,MAAKgB,eAAe,IAAIA,eAAe,CAACL,YAAhB,KAAiCX,KAAzD,EAAiE;AAChE,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASc,cAAT,CAAyBf,KAAzB,EAAiC;AACvC,SAAOA,KAAK,CAACU,WAAN,CAAkBK,cAAzB;AACA","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"]}
1
+ {"version":3,"names":["createSelector","getAssociatedGuide","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":"AAAA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,QAAQ;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGD,cAAc,CAC/C,CAAEE,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;AACA,OAAO,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,GAAGlB,kBAAkB,CAAEC,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;AACA,OAAO,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.1.0",
3
+ "version": "8.2.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": "^25.5.0",
35
- "@wordpress/compose": "^6.16.0",
36
- "@wordpress/data": "^9.9.0",
37
- "@wordpress/deprecated": "^3.39.0",
38
- "@wordpress/element": "^5.16.0",
39
- "@wordpress/i18n": "^4.39.0",
40
- "@wordpress/icons": "^9.30.0",
34
+ "@wordpress/components": "^25.6.0",
35
+ "@wordpress/compose": "^6.17.0",
36
+ "@wordpress/data": "^9.10.0",
37
+ "@wordpress/deprecated": "^3.40.0",
38
+ "@wordpress/element": "^5.17.0",
39
+ "@wordpress/i18n": "^4.40.0",
40
+ "@wordpress/icons": "^9.31.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": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
50
+ "gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
51
51
  }