revdev-components 0.81.0 → 0.83.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 +25 -2
- package/build/navigator/index.d.ts +4 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -5237,13 +5237,36 @@ function getNavOption(mapper, part) {
|
|
|
5237
5237
|
return undefined;
|
|
5238
5238
|
}
|
|
5239
5239
|
var AlfaNavigator = function (_a) {
|
|
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;
|
|
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, onChange = _a.onChange;
|
|
5241
|
+
var isMount = useDidMount();
|
|
5242
|
+
React.useEffect(function () {
|
|
5243
|
+
if (isMount) {
|
|
5244
|
+
var parts = [];
|
|
5245
|
+
var rootPath = root;
|
|
5246
|
+
if (typeof rootPath === "string") {
|
|
5247
|
+
parts.push(rootPath);
|
|
5248
|
+
}
|
|
5249
|
+
else if (Array.isArray(rootPath)) {
|
|
5250
|
+
parts.push(rootPath[0]);
|
|
5251
|
+
}
|
|
5252
|
+
for (var _i = 0, _a = path || []; _i < _a.length; _i++) {
|
|
5253
|
+
var item = _a[_i];
|
|
5254
|
+
if (typeof item === "string") {
|
|
5255
|
+
parts.push(item);
|
|
5256
|
+
}
|
|
5257
|
+
else if (Array.isArray(item)) {
|
|
5258
|
+
parts.push(item[0]);
|
|
5259
|
+
}
|
|
5260
|
+
}
|
|
5261
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({ path: parts });
|
|
5262
|
+
}
|
|
5263
|
+
}, [isMount, root, path, onChange]);
|
|
5241
5264
|
var innerOptions = React.useMemo(function () {
|
|
5242
5265
|
var result = [];
|
|
5243
5266
|
if (root) {
|
|
5244
5267
|
var rootPath = root;
|
|
5245
5268
|
var rootOption = root;
|
|
5246
|
-
if (typeof rootPath || (Array.isArray(rootPath) && mapper)) {
|
|
5269
|
+
if (typeof rootPath === "string" || (Array.isArray(rootPath) && mapper)) {
|
|
5247
5270
|
var navOption = getNavOption(mapper, rootPath);
|
|
5248
5271
|
if (navOption) {
|
|
5249
5272
|
result.push(navOption);
|
|
@@ -6,6 +6,9 @@ export interface AlfaNavigatorOption {
|
|
|
6
6
|
export type AlfaNavigatorMapper = Record<string, AlfaNavigatorOption | ((param: any) => AlfaNavigatorOption)>;
|
|
7
7
|
export type AlfaNavigatorPathPart<TKey extends string = string> = TKey | [TKey, any];
|
|
8
8
|
export type AlfaNavigatorPath<TKey extends string = string> = AlfaNavigatorPathPart<TKey>[];
|
|
9
|
+
export interface AlfaNavigatorChangeEvent {
|
|
10
|
+
path?: string[];
|
|
11
|
+
}
|
|
9
12
|
interface Props {
|
|
10
13
|
root?: AlfaNavigatorOption | AlfaNavigatorPathPart;
|
|
11
14
|
options?: AlfaNavigatorOption[];
|
|
@@ -14,6 +17,7 @@ interface Props {
|
|
|
14
17
|
isMobile?: boolean;
|
|
15
18
|
mapper?: AlfaNavigatorMapper;
|
|
16
19
|
path?: AlfaNavigatorPath;
|
|
20
|
+
onChange?: (e: AlfaNavigatorChangeEvent) => void;
|
|
17
21
|
}
|
|
18
22
|
export declare const AlfaNavigator: React.FC<Props>;
|
|
19
23
|
export {};
|