revdev-components 0.120.0 → 0.122.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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { BackSidebarProps } from "src/backSidebar";
3
- interface Props {
3
+ export interface BackLayoutProps {
4
4
  loading?: boolean;
5
5
  contentLoading?: boolean;
6
6
  header?: React.ReactNode;
@@ -14,5 +14,4 @@ interface Props {
14
14
  loadingClassName?: string;
15
15
  sidebarProps: Omit<BackSidebarProps, "shortMode">;
16
16
  }
17
- export declare const BackLayout: React.FC<Props>;
18
- export {};
17
+ export declare const BackLayout: React.FC<BackLayoutProps>;
@@ -1,2 +1 @@
1
- import { BackSidebarSubOption } from "./interfaces";
2
- export declare function useIsOptionActive(activePath: string, options: BackSidebarSubOption[]): boolean;
1
+ export declare function useIsOptionActive(activePath: string, keys: string[]): boolean;
@@ -1,12 +1,14 @@
1
1
  import React from "react";
2
2
  import { BackSidebarOption } from "./interfaces";
3
+ import { AlfaNavigatorMapper } from "..";
3
4
  export * from "./interfaces";
4
5
  export interface BackSidebarProps {
5
6
  className?: string;
6
7
  options: BackSidebarOption[];
8
+ mapper: AlfaNavigatorMapper;
7
9
  top?: React.ReactNode;
8
10
  shortMode?: boolean;
9
- activePath?: string;
10
- defaultPath?: string;
11
+ activePathKey?: string;
12
+ defaultPathKey?: string;
11
13
  }
12
14
  export declare const BackSidebar: React.FC<BackSidebarProps>;
@@ -1,12 +1,6 @@
1
- import { PagePath } from "page-path";
2
1
  import { RegularIconName } from "src/icon";
3
- export interface BackSidebarSubOption {
2
+ export interface BackSidebarOption<TKey extends string = string> {
4
3
  label: string;
5
4
  icon?: RegularIconName;
6
- path: PagePath;
7
- }
8
- export interface BackSidebarOption {
9
- label: string;
10
- icon?: RegularIconName;
11
- options?: BackSidebarSubOption[];
5
+ keys?: TKey[];
12
6
  }
@@ -1,8 +1,10 @@
1
1
  import React from "react";
2
2
  import { BackSidebarOption } from "../interfaces";
3
+ import { AlfaNavigatorMapper } from "src/interfaces";
3
4
  interface Props {
4
5
  option: BackSidebarOption;
5
- activePath?: string;
6
+ activePathKey?: string;
7
+ mapper: AlfaNavigatorMapper;
6
8
  }
7
9
  export declare const BackSidebarMenuItem: React.FC<Props>;
8
10
  export {};
@@ -1,8 +1,10 @@
1
1
  import React from "react";
2
2
  import { BackSidebarOption } from "../interfaces";
3
+ import { AlfaNavigatorMapper } from "src/index";
3
4
  interface Props {
4
5
  option: BackSidebarOption;
5
- activePath?: string;
6
+ activePathKey?: string;
7
+ mapper: AlfaNavigatorMapper;
6
8
  }
7
9
  export declare const BackSidebarShortMenuItem: React.FC<Props>;
8
10
  export {};
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { BackSidebarSubOption } from "../interfaces";
2
+ import { AlfaNavigatorOption } from "src/interfaces";
3
3
  interface Props {
4
- option: BackSidebarSubOption;
5
- activePath?: string;
4
+ option: AlfaNavigatorOption;
5
+ isActive: boolean;
6
6
  }
7
7
  export declare const BackSidebarSubMenuItem: React.FC<Props>;
8
8
  export {};
package/build/index.js CHANGED
@@ -5088,28 +5088,27 @@ var s$f = {"root":"index-module_root__AZ9HE","root__active":"index-module_root__
5088
5088
 
5089
5089
  var BackSidebarSubMenuItem = function (_a) {
5090
5090
  var _b;
5091
- var _c = _a.activePath, activePath = _c === void 0 ? "" : _c, option = _a.option;
5091
+ var isActive = _a.isActive, option = _a.option;
5092
5092
  var icon = option.icon, label = option.label, path = option.path;
5093
- var isActive = path.isActive(activePath);
5094
- return (React.createElement(AppLink, { className: classNames(s$f.root, (_b = {}, _b[s$f.root__active] = isActive, _b)), href: path.build() },
5093
+ return (React.createElement(AppLink, { className: classNames(s$f.root, (_b = {}, _b[s$f.root__active] = isActive, _b)), href: path },
5095
5094
  icon && React.createElement(RegularIcon, { name: icon }),
5096
5095
  React.createElement("span", null, label)));
5097
5096
  };
5098
5097
 
5099
- function useIsOptionActive(activePath, options) {
5098
+ function useIsOptionActive(activePath, keys) {
5100
5099
  if (activePath === void 0) { activePath = ""; }
5101
5100
  return React.useMemo(function () {
5102
- return !!options.find(function (x) {
5103
- return x.path.isActive(activePath);
5101
+ return !!keys.find(function (x) {
5102
+ return x === activePath;
5104
5103
  });
5105
- }, [activePath, options]);
5104
+ }, [activePath, keys]);
5106
5105
  }
5107
5106
 
5108
5107
  var BackSidebarMenuItem = function (_a) {
5109
5108
  var _b, _c;
5110
- var option = _a.option, activePath = _a.activePath;
5111
- var icon = option.icon, label = option.label, _d = option.options, options = _d === void 0 ? [] : _d;
5112
- var isActive = useIsOptionActive(activePath, options);
5109
+ var option = _a.option, activePathKey = _a.activePathKey, mapper = _a.mapper;
5110
+ var icon = option.icon, label = option.label, _d = option.keys, keys = _d === void 0 ? [] : _d;
5111
+ var isActive = useIsOptionActive(activePathKey, keys);
5113
5112
  var _e = React.useState(isActive), open = _e[0], setOpen = _e[1];
5114
5113
  React.useEffect(function () {
5115
5114
  if (isActive) {
@@ -5124,8 +5123,11 @@ var BackSidebarMenuItem = function (_a) {
5124
5123
  icon && React.createElement(RegularIcon, { name: icon }),
5125
5124
  React.createElement("span", { className: s$g.title__label }, label),
5126
5125
  React.createElement(RegularIcon, { name: open ? "keyboard-arrow-down" : "keyboard-arrow-right" })),
5127
- React.createElement("div", { className: classNames(s$g.list, (_c = {}, _c[s$g.list__open] = open, _c)) }, options.map(function (x, i) {
5128
- return React.createElement(BackSidebarSubMenuItem, { key: i, option: x, activePath: activePath });
5126
+ React.createElement("div", { className: classNames(s$g.list, (_c = {}, _c[s$g.list__open] = open, _c)) }, keys.map(function (x) {
5127
+ var option = mapper[x];
5128
+ if (typeof option === "object") {
5129
+ return React.createElement(BackSidebarSubMenuItem, { key: x, option: option, isActive: x === activePathKey });
5130
+ }
5129
5131
  }))));
5130
5132
  };
5131
5133
 
@@ -5133,9 +5135,9 @@ var s$e = {"root":"index-module_root__yMCtx","list":"index-module_list__Xr6Z5","
5133
5135
 
5134
5136
  var BackSidebarShortMenuItem = function (_a) {
5135
5137
  var _b;
5136
- var option = _a.option, activePath = _a.activePath;
5137
- var icon = option.icon, _c = option.options, options = _c === void 0 ? [] : _c;
5138
- var isActive = useIsOptionActive(activePath, options);
5138
+ var option = _a.option, activePathKey = _a.activePathKey, mapper = _a.mapper;
5139
+ var icon = option.icon, _c = option.keys, keys = _c === void 0 ? [] : _c;
5140
+ var isActive = useIsOptionActive(activePathKey, keys);
5139
5141
  var _d = React.useState(isActive), open = _d[0], setOpen = _d[1];
5140
5142
  React.useEffect(function () {
5141
5143
  if (isActive) {
@@ -5147,8 +5149,11 @@ var BackSidebarShortMenuItem = function (_a) {
5147
5149
  }, [open]);
5148
5150
  return (React.createElement("div", { className: s$e.root },
5149
5151
  React.createElement("div", { className: classNames(s$e.master, (_b = {}, _b[s$e.master__active] = isActive, _b)), onClick: handleClick }, icon && React.createElement(RegularIcon, { name: icon })),
5150
- React.createElement("div", { className: classNames(s$e.list) }, options.map(function (x, i) {
5151
- return React.createElement(BackSidebarSubMenuItem, { key: i, option: x });
5152
+ React.createElement("div", { className: classNames(s$e.list) }, keys.map(function (x) {
5153
+ var option = mapper[x];
5154
+ if (typeof option === "object") {
5155
+ return React.createElement(BackSidebarSubMenuItem, { key: x, option: option, isActive: x === activePathKey });
5156
+ }
5152
5157
  }))));
5153
5158
  };
5154
5159
 
@@ -5156,12 +5161,11 @@ var s$d = {"root":"index-module_root__r4Egx"};
5156
5161
 
5157
5162
  // https://www.einfosoft.com/templates/admin/spice/source/edit_booking.html#
5158
5163
  var BackSidebar = function (_a) {
5159
- var className = _a.className, options = _a.options, top = _a.top, shortMode = _a.shortMode, activePath = _a.activePath, defaultPath = _a.defaultPath;
5160
- var path = (activePath || "").replace("/", "") ? activePath : defaultPath;
5164
+ var className = _a.className, options = _a.options, mapper = _a.mapper, top = _a.top, shortMode = _a.shortMode, activePathKey = _a.activePathKey, defaultPathKey = _a.defaultPathKey;
5161
5165
  return (React.createElement("div", { className: classNames(s$d.root, className) },
5162
5166
  top ? React.createElement("div", { className: classNames(s$d.top) }, top) : null,
5163
5167
  React.createElement("div", { className: s$d.menu }, options.map(function (option, i) {
5164
- return shortMode ? (React.createElement(BackSidebarShortMenuItem, { key: i, option: option, activePath: path })) : (React.createElement(BackSidebarMenuItem, { key: i, option: option, activePath: path }));
5168
+ return shortMode ? (React.createElement(BackSidebarShortMenuItem, { key: i, mapper: mapper, option: option, activePathKey: activePathKey || defaultPathKey })) : (React.createElement(BackSidebarMenuItem, { key: i, mapper: mapper, option: option, activePathKey: activePathKey || defaultPathKey }));
5165
5169
  }))));
5166
5170
  };
5167
5171
 
@@ -5432,7 +5436,7 @@ var AlfaNavigator = function (_a) {
5432
5436
  return result;
5433
5437
  }, [root, options, isMobile, mapper, path]);
5434
5438
  return innerOptions.length ? (React.createElement("div", { className: classNames(s$3.root, className) }, innerOptions.map(function (_a, index) {
5435
- var href = _a.href, label = _a.label;
5439
+ var href = _a.path, label = _a.label;
5436
5440
  return (React.createElement(React.Fragment, { key: index },
5437
5441
  index > 0 ? React.createElement("span", null, "\u203A") : null,
5438
5442
  React.createElement(AppLink, { className: classNames(s$3.step, stepClassName), href: href }, label)));
@@ -1,3 +1,4 @@
1
1
  export * from "./form";
2
2
  export * from "./option";
3
3
  export * from "./control";
4
+ export * from "./nav";
@@ -0,0 +1,9 @@
1
+ import { RegularIconName } from "src/icon";
2
+ export interface AlfaNavigatorOption {
3
+ path: string;
4
+ label: string;
5
+ icon?: RegularIconName;
6
+ }
7
+ export type AlfaNavigatorMapper = Record<string, AlfaNavigatorOption | ((param: any) => AlfaNavigatorOption)>;
8
+ export type AlfaNavigatorPathPart<TKey extends string = string> = TKey | [TKey, any];
9
+ export type AlfaNavigatorPath<TKey extends string = string> = AlfaNavigatorPathPart<TKey>[];
@@ -1,11 +1,5 @@
1
1
  import React from "react";
2
- export interface AlfaNavigatorOption {
3
- href: string;
4
- label: string;
5
- }
6
- export type AlfaNavigatorMapper = Record<string, AlfaNavigatorOption | ((param: any) => AlfaNavigatorOption)>;
7
- export type AlfaNavigatorPathPart<TKey extends string = string> = TKey | [TKey, any];
8
- export type AlfaNavigatorPath<TKey extends string = string> = AlfaNavigatorPathPart<TKey>[];
2
+ import { AlfaNavigatorMapper, AlfaNavigatorOption, AlfaNavigatorPath, AlfaNavigatorPathPart } from "src/interfaces";
9
3
  export interface AlfaNavigatorChangeEvent {
10
4
  path?: string[];
11
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revdev-components",
3
- "version": "0.120.0",
3
+ "version": "0.122.0",
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.esm.js",
6
6
  "scripts": {