@cakemail-org/ui-components-v2 2.2.127 → 2.2.129
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/dist/cjs/index.js +42 -2
- package/dist/cjs/models/contentCatalog/types.d.ts +4 -0
- package/dist/cjs/services/contentCatalog/types.d.ts +3 -4
- package/dist/esm/index.js +42 -2
- package/dist/esm/models/contentCatalog/types.d.ts +4 -0
- package/dist/esm/services/contentCatalog/types.d.ts +3 -4
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -20146,14 +20146,54 @@ function SideMenuItem(_a) {
|
|
|
20146
20146
|
variant === "subSection" && React.createElement(Typography, { variant: "body2S", className: "uppercase" }, item.text)));
|
|
20147
20147
|
}
|
|
20148
20148
|
|
|
20149
|
+
function normalizePath(path) {
|
|
20150
|
+
var normalized = path.replace(/^#/, "").replace(/\/$/, "");
|
|
20151
|
+
return normalized || "/";
|
|
20152
|
+
}
|
|
20153
|
+
function pathMatches(currentPath, targetPath) {
|
|
20154
|
+
return currentPath === targetPath || currentPath.startsWith("".concat(targetPath, "/"));
|
|
20155
|
+
}
|
|
20156
|
+
function collectMenuPaths(menuItems) {
|
|
20157
|
+
var paths = [];
|
|
20158
|
+
menuItems.forEach(function (item) {
|
|
20159
|
+
var _a;
|
|
20160
|
+
if ("divider" in item) {
|
|
20161
|
+
return;
|
|
20162
|
+
}
|
|
20163
|
+
if (item.path) {
|
|
20164
|
+
paths.push(normalizePath(item.path));
|
|
20165
|
+
}
|
|
20166
|
+
(_a = item.subItems) === null || _a === void 0 ? void 0 : _a.forEach(function (subItem) {
|
|
20167
|
+
if (subItem.path) {
|
|
20168
|
+
paths.push(normalizePath(subItem.path));
|
|
20169
|
+
}
|
|
20170
|
+
});
|
|
20171
|
+
});
|
|
20172
|
+
return paths;
|
|
20173
|
+
}
|
|
20174
|
+
function getLongestMatchingPath(currentPath, menuPaths) {
|
|
20175
|
+
var longestMatch = null;
|
|
20176
|
+
menuPaths.forEach(function (targetPath) {
|
|
20177
|
+
if (!pathMatches(currentPath, targetPath)) {
|
|
20178
|
+
return;
|
|
20179
|
+
}
|
|
20180
|
+
if (!longestMatch || targetPath.length > longestMatch.length) {
|
|
20181
|
+
longestMatch = targetPath;
|
|
20182
|
+
}
|
|
20183
|
+
});
|
|
20184
|
+
return longestMatch;
|
|
20185
|
+
}
|
|
20149
20186
|
function SideMenuContainer(_a) {
|
|
20150
20187
|
var menuItems = _a.menuItems, menuItemClick = _a.menuItemClick, forcedLocationPath = _a.forcedLocationPath, className = _a.className;
|
|
20151
20188
|
var location = reactRouterDom.useLocation();
|
|
20152
20189
|
var _b = React.useState([]), openedItems = _b[0], setOpenedItems = _b[1];
|
|
20190
|
+
var currentPath = normalizePath(forcedLocationPath !== null && forcedLocationPath !== void 0 ? forcedLocationPath : (location.hash || location.pathname));
|
|
20191
|
+
var longestMatchingPath = React.useMemo(function () { return getLongestMatchingPath(currentPath, collectMenuPaths(menuItems)); }, [currentPath, menuItems]);
|
|
20153
20192
|
function isSelected(value) {
|
|
20154
|
-
if (!value)
|
|
20193
|
+
if (!value || !longestMatchingPath) {
|
|
20155
20194
|
return false;
|
|
20156
|
-
|
|
20195
|
+
}
|
|
20196
|
+
return normalizePath(value) === longestMatchingPath;
|
|
20157
20197
|
}
|
|
20158
20198
|
function handleMenuItemClick(event) {
|
|
20159
20199
|
menuItemClick && menuItemClick(event);
|
|
@@ -75,6 +75,10 @@ export interface TBeeTemplateListFacets {
|
|
|
75
75
|
designers: TBeeDesignerFacet[];
|
|
76
76
|
tags: TBeeTagFacet[];
|
|
77
77
|
}
|
|
78
|
+
export interface TBeeFreeListParams {
|
|
79
|
+
page?: number;
|
|
80
|
+
pagesize?: number;
|
|
81
|
+
}
|
|
78
82
|
export interface TBeeFreeList<T> {
|
|
79
83
|
count: number;
|
|
80
84
|
next: string | null;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { TBeeFreeListParams } from "../../models/contentCatalog/types";
|
|
2
|
+
export interface TTemplateListParams extends TBeeFreeListParams {
|
|
2
3
|
search?: string;
|
|
3
4
|
category?: string;
|
|
4
5
|
collection?: string;
|
|
5
6
|
designer?: string;
|
|
6
7
|
tag?: string;
|
|
7
8
|
template_type?: string;
|
|
8
|
-
pagesize?: number;
|
|
9
9
|
published_after?: string;
|
|
10
10
|
published_before?: string;
|
|
11
11
|
}
|
|
12
|
-
export interface TPageSizeParam {
|
|
13
|
-
pagesize?: number;
|
|
12
|
+
export interface TPageSizeParam extends TBeeFreeListParams {
|
|
14
13
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -20126,14 +20126,54 @@ function SideMenuItem(_a) {
|
|
|
20126
20126
|
variant === "subSection" && React__default.createElement(Typography, { variant: "body2S", className: "uppercase" }, item.text)));
|
|
20127
20127
|
}
|
|
20128
20128
|
|
|
20129
|
+
function normalizePath(path) {
|
|
20130
|
+
var normalized = path.replace(/^#/, "").replace(/\/$/, "");
|
|
20131
|
+
return normalized || "/";
|
|
20132
|
+
}
|
|
20133
|
+
function pathMatches(currentPath, targetPath) {
|
|
20134
|
+
return currentPath === targetPath || currentPath.startsWith("".concat(targetPath, "/"));
|
|
20135
|
+
}
|
|
20136
|
+
function collectMenuPaths(menuItems) {
|
|
20137
|
+
var paths = [];
|
|
20138
|
+
menuItems.forEach(function (item) {
|
|
20139
|
+
var _a;
|
|
20140
|
+
if ("divider" in item) {
|
|
20141
|
+
return;
|
|
20142
|
+
}
|
|
20143
|
+
if (item.path) {
|
|
20144
|
+
paths.push(normalizePath(item.path));
|
|
20145
|
+
}
|
|
20146
|
+
(_a = item.subItems) === null || _a === void 0 ? void 0 : _a.forEach(function (subItem) {
|
|
20147
|
+
if (subItem.path) {
|
|
20148
|
+
paths.push(normalizePath(subItem.path));
|
|
20149
|
+
}
|
|
20150
|
+
});
|
|
20151
|
+
});
|
|
20152
|
+
return paths;
|
|
20153
|
+
}
|
|
20154
|
+
function getLongestMatchingPath(currentPath, menuPaths) {
|
|
20155
|
+
var longestMatch = null;
|
|
20156
|
+
menuPaths.forEach(function (targetPath) {
|
|
20157
|
+
if (!pathMatches(currentPath, targetPath)) {
|
|
20158
|
+
return;
|
|
20159
|
+
}
|
|
20160
|
+
if (!longestMatch || targetPath.length > longestMatch.length) {
|
|
20161
|
+
longestMatch = targetPath;
|
|
20162
|
+
}
|
|
20163
|
+
});
|
|
20164
|
+
return longestMatch;
|
|
20165
|
+
}
|
|
20129
20166
|
function SideMenuContainer(_a) {
|
|
20130
20167
|
var menuItems = _a.menuItems, menuItemClick = _a.menuItemClick, forcedLocationPath = _a.forcedLocationPath, className = _a.className;
|
|
20131
20168
|
var location = useLocation();
|
|
20132
20169
|
var _b = useState([]), openedItems = _b[0], setOpenedItems = _b[1];
|
|
20170
|
+
var currentPath = normalizePath(forcedLocationPath !== null && forcedLocationPath !== void 0 ? forcedLocationPath : (location.hash || location.pathname));
|
|
20171
|
+
var longestMatchingPath = useMemo(function () { return getLongestMatchingPath(currentPath, collectMenuPaths(menuItems)); }, [currentPath, menuItems]);
|
|
20133
20172
|
function isSelected(value) {
|
|
20134
|
-
if (!value)
|
|
20173
|
+
if (!value || !longestMatchingPath) {
|
|
20135
20174
|
return false;
|
|
20136
|
-
|
|
20175
|
+
}
|
|
20176
|
+
return normalizePath(value) === longestMatchingPath;
|
|
20137
20177
|
}
|
|
20138
20178
|
function handleMenuItemClick(event) {
|
|
20139
20179
|
menuItemClick && menuItemClick(event);
|
|
@@ -75,6 +75,10 @@ export interface TBeeTemplateListFacets {
|
|
|
75
75
|
designers: TBeeDesignerFacet[];
|
|
76
76
|
tags: TBeeTagFacet[];
|
|
77
77
|
}
|
|
78
|
+
export interface TBeeFreeListParams {
|
|
79
|
+
page?: number;
|
|
80
|
+
pagesize?: number;
|
|
81
|
+
}
|
|
78
82
|
export interface TBeeFreeList<T> {
|
|
79
83
|
count: number;
|
|
80
84
|
next: string | null;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { TBeeFreeListParams } from "../../models/contentCatalog/types";
|
|
2
|
+
export interface TTemplateListParams extends TBeeFreeListParams {
|
|
2
3
|
search?: string;
|
|
3
4
|
category?: string;
|
|
4
5
|
collection?: string;
|
|
5
6
|
designer?: string;
|
|
6
7
|
tag?: string;
|
|
7
8
|
template_type?: string;
|
|
8
|
-
pagesize?: number;
|
|
9
9
|
published_after?: string;
|
|
10
10
|
published_before?: string;
|
|
11
11
|
}
|
|
12
|
-
export interface TPageSizeParam {
|
|
13
|
-
pagesize?: number;
|
|
12
|
+
export interface TPageSizeParam extends TBeeFreeListParams {
|
|
14
13
|
}
|