@wordpress/nux 5.8.0 → 5.11.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,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.11.0 (2022-07-13)
6
+
7
+ ## 5.10.0 (2022-06-29)
8
+
9
+ ## 5.9.0 (2022-06-15)
10
+
5
11
  ## 5.8.0 (2022-06-01)
6
12
 
7
13
  ## 5.7.0 (2022-05-18)
@@ -11,8 +11,6 @@ exports.isTipVisible = isTipVisible;
11
11
 
12
12
  var _rememo = _interopRequireDefault(require("rememo"));
13
13
 
14
- var _lodash = require("lodash");
15
-
16
14
  /**
17
15
  * External dependencies
18
16
  */
@@ -37,8 +35,8 @@ var _lodash = require("lodash");
37
35
  */
38
36
  const getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
39
37
  for (const tipIds of state.guides) {
40
- if ((0, _lodash.includes)(tipIds, tipId)) {
41
- const nonDismissedTips = (0, _lodash.difference)(tipIds, (0, _lodash.keys)(state.preferences.dismissedTips));
38
+ if (tipIds.includes(tipId)) {
39
+ const nonDismissedTips = tipIds.filter(tId => !Object.keys(state.preferences.dismissedTips).includes(tId));
42
40
  const [currentTipId = null, nextTipId = null] = nonDismissedTips;
43
41
  return {
44
42
  tipIds,
@@ -64,11 +62,13 @@ const getAssociatedGuide = (0, _rememo.default)((state, tipId) => {
64
62
  exports.getAssociatedGuide = getAssociatedGuide;
65
63
 
66
64
  function isTipVisible(state, tipId) {
65
+ var _state$preferences$di;
66
+
67
67
  if (!state.preferences.areTipsEnabled) {
68
68
  return false;
69
69
  }
70
70
 
71
- if ((0, _lodash.has)(state.preferences.dismissedTips, [tipId])) {
71
+ if ((_state$preferences$di = state.preferences.dismissedTips) !== null && _state$preferences$di !== void 0 && _state$preferences$di.hasOwnProperty(tipId)) {
72
72
  return false;
73
73
  }
74
74
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/selectors.js"],"names":["getAssociatedGuide","state","tipId","tipIds","guides","nonDismissedTips","preferences","dismissedTips","currentTipId","nextTipId","isTipVisible","areTipsEnabled","associatedGuide"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;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,QAAK,sBAAUD,MAAV,EAAkBD,KAAlB,CAAL,EAAiC;AAChC,YAAMG,gBAAgB,GAAG,wBACxBF,MADwB,EAExB,kBAAMF,KAAK,CAACK,WAAN,CAAkBC,aAAxB,CAFwB,CAAzB;AAIA,YAAM,CACLC,YAAY,GAAG,IADV,EAELC,SAAS,GAAG,IAFP,IAGFJ,gBAHJ;AAIA,aAAO;AAAEF,QAAAA,MAAF;AAAUK,QAAAA,YAAV;AAAwBC,QAAAA;AAAxB,OAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA,CAjBgC,EAkB/BR,KAAF,IAAa,CAAEA,KAAK,CAACG,MAAR,EAAgBH,KAAK,CAACK,WAAN,CAAkBC,aAAlC,CAlBoB,CAA3B;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASG,YAAT,CAAuBT,KAAvB,EAA8BC,KAA9B,EAAsC;AAC5C,MAAK,CAAED,KAAK,CAACK,WAAN,CAAkBK,cAAzB,EAA0C;AACzC,WAAO,KAAP;AACA;;AAED,MAAK,iBAAKV,KAAK,CAACK,WAAN,CAAkBC,aAAvB,EAAsC,CAAEL,KAAF,CAAtC,CAAL,EAAyD;AACxD,WAAO,KAAP;AACA;;AAED,QAAMU,eAAe,GAAGZ,kBAAkB,CAAEC,KAAF,EAASC,KAAT,CAA1C;;AACA,MAAKU,eAAe,IAAIA,eAAe,CAACJ,YAAhB,KAAiCN,KAAzD,EAAiE;AAChE,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASS,cAAT,CAAyBV,KAAzB,EAAiC;AACvC,SAAOA,KAAK,CAACK,WAAN,CAAkBK,cAAzB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { includes, difference, keys, has } from 'lodash';\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 ( includes( tipIds, tipId ) ) {\n\t\t\t\tconst nonDismissedTips = difference(\n\t\t\t\t\ttipIds,\n\t\t\t\t\tkeys( state.preferences.dismissedTips )\n\t\t\t\t);\n\t\t\t\tconst [\n\t\t\t\t\tcurrentTipId = null,\n\t\t\t\t\tnextTipId = null,\n\t\t\t\t] = nonDismissedTips;\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 ( has( state.preferences.dismissedTips, [ 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,"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;AAAA;;AAC5C,MAAK,CAAED,KAAK,CAACU,WAAN,CAAkBK,cAAzB,EAA0C;AACzC,WAAO,KAAP;AACA;;AAED,+BAAKf,KAAK,CAACU,WAAN,CAAkBC,aAAvB,kDAAK,sBAAiCK,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"]}
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { includes, difference, keys, has } from 'lodash';
6
5
  /**
7
6
  * An object containing information about a guide.
8
7
  *
@@ -24,8 +23,8 @@ import { includes, difference, keys, has } from 'lodash';
24
23
 
25
24
  export const getAssociatedGuide = createSelector((state, tipId) => {
26
25
  for (const tipIds of state.guides) {
27
- if (includes(tipIds, tipId)) {
28
- const nonDismissedTips = difference(tipIds, keys(state.preferences.dismissedTips));
26
+ if (tipIds.includes(tipId)) {
27
+ const nonDismissedTips = tipIds.filter(tId => !Object.keys(state.preferences.dismissedTips).includes(tId));
29
28
  const [currentTipId = null, nextTipId = null] = nonDismissedTips;
30
29
  return {
31
30
  tipIds,
@@ -49,11 +48,13 @@ export const getAssociatedGuide = createSelector((state, tipId) => {
49
48
  */
50
49
 
51
50
  export function isTipVisible(state, tipId) {
51
+ var _state$preferences$di;
52
+
52
53
  if (!state.preferences.areTipsEnabled) {
53
54
  return false;
54
55
  }
55
56
 
56
- if (has(state.preferences.dismissedTips, [tipId])) {
57
+ if ((_state$preferences$di = state.preferences.dismissedTips) !== null && _state$preferences$di !== void 0 && _state$preferences$di.hasOwnProperty(tipId)) {
57
58
  return false;
58
59
  }
59
60
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/nux/src/store/selectors.js"],"names":["createSelector","includes","difference","keys","has","getAssociatedGuide","state","tipId","tipIds","guides","nonDismissedTips","preferences","dismissedTips","currentTipId","nextTipId","isTipVisible","areTipsEnabled","associatedGuide"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AACA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,EAAqCC,GAArC,QAAgD,QAAhD;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAGL,cAAc,CAC/C,CAAEM,KAAF,EAASC,KAAT,KAAoB;AACnB,OAAM,MAAMC,MAAZ,IAAsBF,KAAK,CAACG,MAA5B,EAAqC;AACpC,QAAKR,QAAQ,CAAEO,MAAF,EAAUD,KAAV,CAAb,EAAiC;AAChC,YAAMG,gBAAgB,GAAGR,UAAU,CAClCM,MADkC,EAElCL,IAAI,CAAEG,KAAK,CAACK,WAAN,CAAkBC,aAApB,CAF8B,CAAnC;AAIA,YAAM,CACLC,YAAY,GAAG,IADV,EAELC,SAAS,GAAG,IAFP,IAGFJ,gBAHJ;AAIA,aAAO;AAAEF,QAAAA,MAAF;AAAUK,QAAAA,YAAV;AAAwBC,QAAAA;AAAxB,OAAP;AACA;AACD;;AAED,SAAO,IAAP;AACA,CAjB8C,EAkB7CR,KAAF,IAAa,CAAEA,KAAK,CAACG,MAAR,EAAgBH,KAAK,CAACK,WAAN,CAAkBC,aAAlC,CAlBkC,CAAzC;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,YAAT,CAAuBT,KAAvB,EAA8BC,KAA9B,EAAsC;AAC5C,MAAK,CAAED,KAAK,CAACK,WAAN,CAAkBK,cAAzB,EAA0C;AACzC,WAAO,KAAP;AACA;;AAED,MAAKZ,GAAG,CAAEE,KAAK,CAACK,WAAN,CAAkBC,aAApB,EAAmC,CAAEL,KAAF,CAAnC,CAAR,EAAyD;AACxD,WAAO,KAAP;AACA;;AAED,QAAMU,eAAe,GAAGZ,kBAAkB,CAAEC,KAAF,EAASC,KAAT,CAA1C;;AACA,MAAKU,eAAe,IAAIA,eAAe,CAACJ,YAAhB,KAAiCN,KAAzD,EAAiE;AAChE,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASS,cAAT,CAAyBV,KAAzB,EAAiC;AACvC,SAAOA,KAAK,CAACK,WAAN,CAAkBK,cAAzB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { includes, difference, keys, has } from 'lodash';\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 ( includes( tipIds, tipId ) ) {\n\t\t\t\tconst nonDismissedTips = difference(\n\t\t\t\t\ttipIds,\n\t\t\t\t\tkeys( state.preferences.dismissedTips )\n\t\t\t\t);\n\t\t\t\tconst [\n\t\t\t\t\tcurrentTipId = null,\n\t\t\t\t\tnextTipId = null,\n\t\t\t\t] = nonDismissedTips;\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 ( has( state.preferences.dismissedTips, [ 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,"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;AAAA;;AAC5C,MAAK,CAAED,KAAK,CAACU,WAAN,CAAkBK,cAAzB,EAA0C;AACzC,WAAO,KAAP;AACA;;AAED,+BAAKf,KAAK,CAACU,WAAN,CAAkBC,aAAvB,kDAAK,sBAAiCK,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/nux",
3
- "version": "5.8.0",
3
+ "version": "5.11.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,14 +31,13 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/components": "^19.12.0",
35
- "@wordpress/compose": "^5.8.0",
36
- "@wordpress/data": "^6.10.0",
37
- "@wordpress/deprecated": "^3.10.0",
38
- "@wordpress/element": "^4.8.0",
39
- "@wordpress/i18n": "^4.10.0",
40
- "@wordpress/icons": "^9.1.0",
41
- "lodash": "^4.17.21",
34
+ "@wordpress/components": "^19.15.0",
35
+ "@wordpress/compose": "^5.11.0",
36
+ "@wordpress/data": "^6.13.0",
37
+ "@wordpress/deprecated": "^3.13.0",
38
+ "@wordpress/element": "^4.11.0",
39
+ "@wordpress/i18n": "^4.13.0",
40
+ "@wordpress/icons": "^9.4.0",
42
41
  "rememo": "^4.0.0"
43
42
  },
44
43
  "peerDependencies": {
@@ -48,5 +47,5 @@
48
47
  "publishConfig": {
49
48
  "access": "public"
50
49
  },
51
- "gitHead": "a3e0b62091e8a8bdf5e2518e42d60d7098af48cc"
50
+ "gitHead": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
52
51
  }
@@ -2,13 +2,14 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { shallow } from 'enzyme';
5
- import { noop } from 'lodash';
6
5
 
7
6
  /**
8
7
  * Internal dependencies
9
8
  */
10
9
  import { DotTip } from '..';
11
10
 
11
+ const noop = () => {};
12
+
12
13
  describe( 'DotTip', () => {
13
14
  it( 'should not render anything if invisible', () => {
14
15
  const wrapper = shallow(
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { includes, difference, keys, has } from 'lodash';
6
5
 
7
6
  /**
8
7
  * An object containing information about a guide.
@@ -25,15 +24,15 @@ import { includes, difference, keys, has } from 'lodash';
25
24
  export const getAssociatedGuide = createSelector(
26
25
  ( state, tipId ) => {
27
26
  for ( const tipIds of state.guides ) {
28
- if ( includes( tipIds, tipId ) ) {
29
- const nonDismissedTips = difference(
30
- tipIds,
31
- keys( state.preferences.dismissedTips )
27
+ if ( tipIds.includes( tipId ) ) {
28
+ const nonDismissedTips = tipIds.filter(
29
+ ( tId ) =>
30
+ ! Object.keys(
31
+ state.preferences.dismissedTips
32
+ ).includes( tId )
32
33
  );
33
- const [
34
- currentTipId = null,
35
- nextTipId = null,
36
- ] = nonDismissedTips;
34
+ const [ currentTipId = null, nextTipId = null ] =
35
+ nonDismissedTips;
37
36
  return { tipIds, currentTipId, nextTipId };
38
37
  }
39
38
  }
@@ -58,7 +57,7 @@ export function isTipVisible( state, tipId ) {
58
57
  return false;
59
58
  }
60
59
 
61
- if ( has( state.preferences.dismissedTips, [ tipId ] ) ) {
60
+ if ( state.preferences.dismissedTips?.hasOwnProperty( tipId ) ) {
62
61
  return false;
63
62
  }
64
63