| 1 |
var wp; |
| 2 |
(wp ||= {}).nux = (() => { |
| 3 |
var __create = Object.create; |
| 4 |
var __defProp = Object.defineProperty; |
| 5 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 6 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 7 |
var __getProtoOf = Object.getPrototypeOf; |
| 8 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 9 |
var __commonJS = (cb, mod) => function __require() { |
| 10 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| 11 |
}; |
| 12 |
var __export = (target, all) => { |
| 13 |
for (var name in all) |
| 14 |
__defProp(target, name, { get: all[name], enumerable: true }); |
| 15 |
}; |
| 16 |
var __copyProps = (to, from, except, desc) => { |
| 17 |
if (from && typeof from === "object" || typeof from === "function") { |
| 18 |
for (let key of __getOwnPropNames(from)) |
| 19 |
if (!__hasOwnProp.call(to, key) && key !== except) |
| 20 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 21 |
} |
| 22 |
return to; |
| 23 |
}; |
| 24 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 25 |
// If the importer is in node compatibility mode or this is not an ESM |
| 26 |
// file that has been converted to a CommonJS file using a Babel- |
| 27 |
// compatible transform (i.e. "__esModule" has not been set), then set |
| 28 |
// "default" to the CommonJS "module.exports" for node compatibility. |
| 29 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 30 |
mod |
| 31 |
)); |
| 32 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 33 |
|
| 34 |
// package-external:@wordpress/deprecated |
| 35 |
var require_deprecated = __commonJS({ |
| 36 |
"package-external:@wordpress/deprecated"(exports, module) { |
| 37 |
module.exports = window.wp.deprecated; |
| 38 |
} |
| 39 |
}); |
| 40 |
|
| 41 |
// package-external:@wordpress/data |
| 42 |
var require_data = __commonJS({ |
| 43 |
"package-external:@wordpress/data"(exports, module) { |
| 44 |
module.exports = window.wp.data; |
| 45 |
} |
| 46 |
}); |
| 47 |
|
| 48 |
// package-external:@wordpress/compose |
| 49 |
var require_compose = __commonJS({ |
| 50 |
"package-external:@wordpress/compose"(exports, module) { |
| 51 |
module.exports = window.wp.compose; |
| 52 |
} |
| 53 |
}); |
| 54 |
|
| 55 |
// package-external:@wordpress/components |
| 56 |
var require_components = __commonJS({ |
| 57 |
"package-external:@wordpress/components"(exports, module) { |
| 58 |
module.exports = window.wp.components; |
| 59 |
} |
| 60 |
}); |
| 61 |
|
| 62 |
// package-external:@wordpress/i18n |
| 63 |
var require_i18n = __commonJS({ |
| 64 |
"package-external:@wordpress/i18n"(exports, module) { |
| 65 |
module.exports = window.wp.i18n; |
| 66 |
} |
| 67 |
}); |
| 68 |
|
| 69 |
// package-external:@wordpress/element |
| 70 |
var require_element = __commonJS({ |
| 71 |
"package-external:@wordpress/element"(exports, module) { |
| 72 |
module.exports = window.wp.element; |
| 73 |
} |
| 74 |
}); |
| 75 |
|
| 76 |
// package-external:@wordpress/primitives |
| 77 |
var require_primitives = __commonJS({ |
| 78 |
"package-external:@wordpress/primitives"(exports, module) { |
| 79 |
module.exports = window.wp.primitives; |
| 80 |
} |
| 81 |
}); |
| 82 |
|
| 83 |
// vendor-external:react/jsx-runtime |
| 84 |
var require_jsx_runtime = __commonJS({ |
| 85 |
"vendor-external:react/jsx-runtime"(exports, module) { |
| 86 |
module.exports = window.ReactJSXRuntime; |
| 87 |
} |
| 88 |
}); |
| 89 |
|
| 90 |
// packages/nux/build-module/index.mjs |
| 91 |
var index_exports = {}; |
| 92 |
__export(index_exports, { |
| 93 |
DotTip: () => dot_tip_default, |
| 94 |
store: () => store |
| 95 |
}); |
| 96 |
var import_deprecated = __toESM(require_deprecated(), 1); |
| 97 |
|
| 98 |
// packages/nux/build-module/store/index.mjs |
| 99 |
var import_data3 = __toESM(require_data(), 1); |
| 100 |
|
| 101 |
// packages/nux/build-module/store/reducer.mjs |
| 102 |
var import_data = __toESM(require_data(), 1); |
| 103 |
function guides(state = [], action) { |
| 104 |
switch (action.type) { |
| 105 |
case "TRIGGER_GUIDE": |
| 106 |
return [...state, action.tipIds]; |
| 107 |
} |
| 108 |
return state; |
| 109 |
} |
| 110 |
function areTipsEnabled(state = true, action) { |
| 111 |
switch (action.type) { |
| 112 |
case "DISABLE_TIPS": |
| 113 |
return false; |
| 114 |
case "ENABLE_TIPS": |
| 115 |
return true; |
| 116 |
} |
| 117 |
return state; |
| 118 |
} |
| 119 |
function dismissedTips(state = {}, action) { |
| 120 |
switch (action.type) { |
| 121 |
case "DISMISS_TIP": |
| 122 |
return { |
| 123 |
...state, |
| 124 |
[action.id]: true |
| 125 |
}; |
| 126 |
case "ENABLE_TIPS": |
| 127 |
return {}; |
| 128 |
} |
| 129 |
return state; |
| 130 |
} |
| 131 |
var preferences = (0, import_data.combineReducers)({ areTipsEnabled, dismissedTips }); |
| 132 |
var reducer_default = (0, import_data.combineReducers)({ guides, preferences }); |
| 133 |
|
| 134 |
// packages/nux/build-module/store/actions.mjs |
| 135 |
var actions_exports = {}; |
| 136 |
__export(actions_exports, { |
| 137 |
disableTips: () => disableTips, |
| 138 |
dismissTip: () => dismissTip, |
| 139 |
enableTips: () => enableTips, |
| 140 |
triggerGuide: () => triggerGuide |
| 141 |
}); |
| 142 |
function triggerGuide(tipIds) { |
| 143 |
return { |
| 144 |
type: "TRIGGER_GUIDE", |
| 145 |
tipIds |
| 146 |
}; |
| 147 |
} |
| 148 |
function dismissTip(id) { |
| 149 |
return { |
| 150 |
type: "DISMISS_TIP", |
| 151 |
id |
| 152 |
}; |
| 153 |
} |
| 154 |
function disableTips() { |
| 155 |
return { |
| 156 |
type: "DISABLE_TIPS" |
| 157 |
}; |
| 158 |
} |
| 159 |
function enableTips() { |
| 160 |
return { |
| 161 |
type: "ENABLE_TIPS" |
| 162 |
}; |
| 163 |
} |
| 164 |
|
| 165 |
// packages/nux/build-module/store/selectors.mjs |
| 166 |
var selectors_exports = {}; |
| 167 |
__export(selectors_exports, { |
| 168 |
areTipsEnabled: () => areTipsEnabled2, |
| 169 |
getAssociatedGuide: () => getAssociatedGuide, |
| 170 |
isTipVisible: () => isTipVisible |
| 171 |
}); |
| 172 |
var import_data2 = __toESM(require_data(), 1); |
| 173 |
var getAssociatedGuide = (0, import_data2.createSelector)( |
| 174 |
(state, tipId) => { |
| 175 |
for (const tipIds of state.guides) { |
| 176 |
if (tipIds.includes(tipId)) { |
| 177 |
const nonDismissedTips = tipIds.filter( |
| 178 |
(tId) => !Object.keys( |
| 179 |
state.preferences.dismissedTips |
| 180 |
).includes(tId) |
| 181 |
); |
| 182 |
const [currentTipId = null, nextTipId = null] = nonDismissedTips; |
| 183 |
return { tipIds, currentTipId, nextTipId }; |
| 184 |
} |
| 185 |
} |
| 186 |
return null; |
| 187 |
}, |
| 188 |
(state) => [state.guides, state.preferences.dismissedTips] |
| 189 |
); |
| 190 |
function isTipVisible(state, tipId) { |
| 191 |
if (!state.preferences.areTipsEnabled) { |
| 192 |
return false; |
| 193 |
} |
| 194 |
if (state.preferences.dismissedTips?.hasOwnProperty(tipId)) { |
| 195 |
return false; |
| 196 |
} |
| 197 |
const associatedGuide = getAssociatedGuide(state, tipId); |
| 198 |
if (associatedGuide && associatedGuide.currentTipId !== tipId) { |
| 199 |
return false; |
| 200 |
} |
| 201 |
return true; |
| 202 |
} |
| 203 |
function areTipsEnabled2(state) { |
| 204 |
return state.preferences.areTipsEnabled; |
| 205 |
} |
| 206 |
|
| 207 |
// packages/nux/build-module/store/index.mjs |
| 208 |
var STORE_NAME = "core/nux"; |
| 209 |
var store = (0, import_data3.createReduxStore)(STORE_NAME, { |
| 210 |
reducer: reducer_default, |
| 211 |
actions: actions_exports, |
| 212 |
selectors: selectors_exports, |
| 213 |
persist: ["preferences"] |
| 214 |
}); |
| 215 |
(0, import_data3.registerStore)(STORE_NAME, { |
| 216 |
reducer: reducer_default, |
| 217 |
actions: actions_exports, |
| 218 |
selectors: selectors_exports, |
| 219 |
persist: ["preferences"] |
| 220 |
}); |
| 221 |
|
| 222 |
// packages/nux/build-module/components/dot-tip/index.mjs |
| 223 |
var import_compose = __toESM(require_compose(), 1); |
| 224 |
var import_components = __toESM(require_components(), 1); |
| 225 |
var import_i18n = __toESM(require_i18n(), 1); |
| 226 |
var import_data4 = __toESM(require_data(), 1); |
| 227 |
var import_element = __toESM(require_element(), 1); |
| 228 |
|
| 229 |
// packages/icons/build-module/library/close.mjs |
| 230 |
var import_primitives = __toESM(require_primitives(), 1); |
| 231 |
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); |
| 232 |
var close_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" }) }); |
| 233 |
|
| 234 |
// packages/nux/build-module/components/dot-tip/index.mjs |
| 235 |
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); |
| 236 |
function onClick(event) { |
| 237 |
event.stopPropagation(); |
| 238 |
} |
| 239 |
function DotTip({ |
| 240 |
position = "middle right", |
| 241 |
children, |
| 242 |
isVisible, |
| 243 |
hasNextTip, |
| 244 |
onDismiss, |
| 245 |
onDisable |
| 246 |
}) { |
| 247 |
const anchorParent = (0, import_element.useRef)(null); |
| 248 |
const onFocusOutsideCallback = (0, import_element.useCallback)( |
| 249 |
(event) => { |
| 250 |
if (!anchorParent.current) { |
| 251 |
return; |
| 252 |
} |
| 253 |
if (anchorParent.current.contains(event.relatedTarget)) { |
| 254 |
return; |
| 255 |
} |
| 256 |
onDisable(); |
| 257 |
}, |
| 258 |
[onDisable, anchorParent] |
| 259 |
); |
| 260 |
if (!isVisible) { |
| 261 |
return null; |
| 262 |
} |
| 263 |
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( |
| 264 |
import_components.Popover, |
| 265 |
{ |
| 266 |
className: "nux-dot-tip", |
| 267 |
position, |
| 268 |
focusOnMount: true, |
| 269 |
role: "dialog", |
| 270 |
"aria-label": (0, import_i18n.__)("Editor tips"), |
| 271 |
onClick, |
| 272 |
onFocusOutside: onFocusOutsideCallback, |
| 273 |
children: [ |
| 274 |
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children }), |
| 275 |
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( |
| 276 |
import_components.Button, |
| 277 |
{ |
| 278 |
__next40pxDefaultSize: true, |
| 279 |
variant: "link", |
| 280 |
onClick: onDismiss, |
| 281 |
children: hasNextTip ? (0, import_i18n.__)("See next tip") : (0, import_i18n.__)("Got it") |
| 282 |
} |
| 283 |
) }), |
| 284 |
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)( |
| 285 |
import_components.Button, |
| 286 |
{ |
| 287 |
size: "small", |
| 288 |
className: "nux-dot-tip__disable", |
| 289 |
icon: close_default, |
| 290 |
label: (0, import_i18n.__)("Disable tips"), |
| 291 |
onClick: onDisable |
| 292 |
} |
| 293 |
) |
| 294 |
] |
| 295 |
} |
| 296 |
); |
| 297 |
} |
| 298 |
var dot_tip_default = (0, import_compose.compose)( |
| 299 |
(0, import_data4.withSelect)((select, { tipId }) => { |
| 300 |
const { isTipVisible: isTipVisible2, getAssociatedGuide: getAssociatedGuide2 } = select(store); |
| 301 |
const associatedGuide = getAssociatedGuide2(tipId); |
| 302 |
return { |
| 303 |
isVisible: isTipVisible2(tipId), |
| 304 |
hasNextTip: !!(associatedGuide && associatedGuide.nextTipId) |
| 305 |
}; |
| 306 |
}), |
| 307 |
(0, import_data4.withDispatch)((dispatch, { tipId }) => { |
| 308 |
const { dismissTip: dismissTip2, disableTips: disableTips2 } = dispatch(store); |
| 309 |
return { |
| 310 |
onDismiss() { |
| 311 |
dismissTip2(tipId); |
| 312 |
}, |
| 313 |
onDisable() { |
| 314 |
disableTips2(); |
| 315 |
} |
| 316 |
}; |
| 317 |
}) |
| 318 |
)(DotTip); |
| 319 |
|
| 320 |
// packages/nux/build-module/index.mjs |
| 321 |
(0, import_deprecated.default)("wp.nux", { |
| 322 |
since: "5.4", |
| 323 |
hint: "wp.components.Guide can be used to show a user guide.", |
| 324 |
version: "6.2" |
| 325 |
}); |
| 326 |
return __toCommonJS(index_exports); |
| 327 |
})(); |
| 328 |
//# sourceMappingURL=index.js.map |
| 329 |
|