revdev-components 0.76.0 → 0.78.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/build/index.js CHANGED
@@ -5226,29 +5226,42 @@ var HeaderActionPanel = function (_a) {
5226
5226
 
5227
5227
  var s$2 = {"root":"index-module_root__t3gxi"};
5228
5228
 
5229
+ function getNavOption(mapper, part) {
5230
+ var _a = Array.isArray(part) ? part : [part, undefined], key = _a[0], param = _a[1];
5231
+ if (mapper) {
5232
+ var o = mapper[key];
5233
+ if (o) {
5234
+ return typeof o === "function" ? o((param === null || param === void 0 ? void 0 : param.toString()) || "") : o;
5235
+ }
5236
+ }
5237
+ return undefined;
5238
+ }
5229
5239
  var AlfaNavigator = function (_a) {
5230
- var className = _a.className, stepClassName = _a.stepClassName, rootOption = _a.rootOption, _b = _a.options, options = _b === void 0 ? [] : _b, isMobile = _a.isMobile, mapper = _a.mapper, path = _a.path;
5240
+ var className = _a.className, stepClassName = _a.stepClassName, root = _a.root, _b = _a.options, options = _b === void 0 ? [] : _b, isMobile = _a.isMobile, mapper = _a.mapper, path = _a.path;
5231
5241
  var innerOptions = React.useMemo(function () {
5232
5242
  var result = [];
5233
- if (mapper && Array.isArray(path)) {
5234
- result = path
5235
- .map(function (p) {
5236
- var _a = Array.isArray(p) ? p : [p, undefined], key = _a[0], param = _a[1];
5237
- var o = mapper[key];
5238
- if (o) {
5239
- return typeof o === "function" ? o((param === null || param === void 0 ? void 0 : param.toString()) || "") : o;
5243
+ if (root) {
5244
+ var rootPath = root;
5245
+ var rootOption = root;
5246
+ if (typeof rootPath || (Array.isArray(rootPath) && mapper)) {
5247
+ var navOption = getNavOption(mapper, rootPath);
5248
+ if (navOption) {
5249
+ result.push(navOption);
5240
5250
  }
5241
- return undefined;
5242
- })
5243
- .filter(function (x) { return x; });
5251
+ }
5252
+ else if (typeof rootOption === "object") {
5253
+ result.push(rootOption);
5254
+ }
5255
+ }
5256
+ if (mapper && Array.isArray(path)) {
5257
+ result.push.apply(result, path.map(function (p) { return getNavOption(mapper, p); }).filter(function (x) { return x; }));
5244
5258
  }
5245
5259
  else {
5246
- result = options;
5260
+ result.push.apply(result, options);
5247
5261
  }
5248
- result = rootOption ? __spreadArray([rootOption], result, true) : result;
5249
5262
  result = isMobile ? result.slice(options.length - 1) : result;
5250
5263
  return result;
5251
- }, [rootOption, options, isMobile, mapper, path]);
5264
+ }, [root, options, isMobile, mapper, path]);
5252
5265
  return innerOptions.length ? (React.createElement("div", { className: classNames(s$2.root, className) }, innerOptions.map(function (_a, index) {
5253
5266
  var href = _a.href, label = _a.label;
5254
5267
  return (React.createElement(React.Fragment, { key: index },
@@ -5,15 +5,15 @@ export interface AlfaNavigatorOption {
5
5
  }
6
6
  export type AlfaNavigatorMapper = Record<string, AlfaNavigatorOption | ((param: string) => AlfaNavigatorOption)>;
7
7
  export type AlfaNavigatorPathPart<TKey extends string = string> = TKey | [TKey, string | number];
8
- export type AlfaNavigatorPart<TKey extends string = string> = AlfaNavigatorPathPart<TKey>[];
8
+ export type AlfaNavigatorPath<TKey extends string = string> = AlfaNavigatorPathPart<TKey>[];
9
9
  interface Props {
10
- rootOption?: AlfaNavigatorOption;
10
+ root?: AlfaNavigatorOption | AlfaNavigatorPathPart;
11
11
  options?: AlfaNavigatorOption[];
12
12
  className?: string;
13
13
  stepClassName?: string;
14
14
  isMobile?: boolean;
15
15
  mapper?: AlfaNavigatorMapper;
16
- path?: AlfaNavigatorPart;
16
+ path?: AlfaNavigatorPath;
17
17
  }
18
18
  export declare const AlfaNavigator: React.FC<Props>;
19
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revdev-components",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.esm.js",
6
6
  "scripts": {