techsbcn-storybook 2.12.0 → 2.14.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/dist/components/tables/SearchComponent/SearchComponent.d.ts +1 -0
- package/dist/helpers/PermissionHelpers.d.ts +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/index.js +37 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasPermission: (permission: string) => boolean;
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -139,15 +139,17 @@ var SearchComponent = (props) => {
|
|
|
139
139
|
setAnchorEl(null);
|
|
140
140
|
};
|
|
141
141
|
const randId = Math.random().toString(36).substring(7);
|
|
142
|
+
const inlineExtraActions = !!props.extraActions && !!props.inlineExtraActions;
|
|
143
|
+
const extraActions = props.extraActions && /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: "extra-actions", sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: inlineExtraActions ? 0 : 2 } }, props.extraActions.map((action, i) => /* @__PURE__ */ React10__default.default.createElement(React10__default.default.Fragment, { key: i }, action.action)));
|
|
142
144
|
return /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: `search-component ${props.className}` }, /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { mb: props.divider ? 2 : 0, px: 2 } }, /* @__PURE__ */ React10__default.default.createElement(material.Grid, { container: true, sx: { alignItems: "center" } }, /* @__PURE__ */ React10__default.default.createElement(
|
|
143
145
|
material.Grid,
|
|
144
146
|
{
|
|
145
147
|
size: {
|
|
146
148
|
xs: props.actions ? 8 : 12,
|
|
147
|
-
md: props.actions && props.searchBar ? 4 : props.searchBar ? 7 : props.actions ? 6 : 12
|
|
149
|
+
md: inlineExtraActions ? "grow" : props.actions && props.searchBar ? 4 : props.searchBar ? 7 : props.actions ? 6 : 12
|
|
148
150
|
}
|
|
149
151
|
},
|
|
150
|
-
/* @__PURE__ */ React10__default.default.createElement(
|
|
152
|
+
/* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 2 } }, /* @__PURE__ */ React10__default.default.createElement(
|
|
151
153
|
material.Box,
|
|
152
154
|
{
|
|
153
155
|
sx: {
|
|
@@ -158,7 +160,7 @@ var SearchComponent = (props) => {
|
|
|
158
160
|
className: `${props.enableAfter ? "main-background-color-after" : ""} title`
|
|
159
161
|
},
|
|
160
162
|
props.title
|
|
161
|
-
)
|
|
163
|
+
), inlineExtraActions && extraActions)
|
|
162
164
|
), props.actions && /* @__PURE__ */ React10__default.default.createElement(material.Grid, { size: { xs: props.title ? 4 : 12 }, sx: { display: { xs: "block", md: "none" } } }, /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { display: { xs: "none", md: "flex" } } }, ActionsList(props.actions)), /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { display: { xs: "flex", md: "none" } } }, props.actions.length > 1 ? /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { ml: "auto" } }, /* @__PURE__ */ React10__default.default.createElement(
|
|
163
165
|
material.IconButton,
|
|
164
166
|
{
|
|
@@ -185,27 +187,36 @@ var SearchComponent = (props) => {
|
|
|
185
187
|
className: "search-menu-actions"
|
|
186
188
|
},
|
|
187
189
|
props.actions.map((action, i) => /* @__PURE__ */ React10__default.default.createElement(material.MenuItem, { key: i, className: "wrapper-actions" }, /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: "btn-action main-color", sx: { color: "primary.main" } }, action.action)))
|
|
188
|
-
)) : /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { ml: "auto" }, className: `wrapper-actions ${props.title ? "min-action-width" : ""}` }, ActionsList(props.actions)))), (props.searchBar || props.filters || props.actions) && /* @__PURE__ */ React10__default.default.createElement(
|
|
189
|
-
material.
|
|
190
|
+
)) : /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { ml: "auto" }, className: `wrapper-actions ${props.title ? "min-action-width" : ""}` }, ActionsList(props.actions)))), (props.searchBar || props.filters || props.actions) && /* @__PURE__ */ React10__default.default.createElement(
|
|
191
|
+
material.Grid,
|
|
190
192
|
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
width: "100%",
|
|
195
|
-
...(props.searchBar || props.filters) && { mt: { xs: 2, md: 0 } }
|
|
193
|
+
size: {
|
|
194
|
+
xs: 12,
|
|
195
|
+
md: inlineExtraActions ? "auto" : props.actions && props.searchBar ? 8 : props.actions ? 6 : 5
|
|
196
196
|
}
|
|
197
197
|
},
|
|
198
|
-
|
|
199
|
-
!!props.fixedOpen || props.filters && props.searchBar && /* @__PURE__ */ React10__default.default.createElement(
|
|
198
|
+
/* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React10__default.default.createElement(
|
|
200
199
|
material.Box,
|
|
201
200
|
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
sx: {
|
|
202
|
+
ml: "auto",
|
|
203
|
+
display: "flex",
|
|
204
|
+
width: "100%",
|
|
205
|
+
...(props.searchBar || props.filters) && { mt: { xs: 2, md: 0 } }
|
|
206
|
+
}
|
|
205
207
|
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
props.searchBar,
|
|
209
|
+
!!props.fixedOpen || props.filters && props.searchBar && /* @__PURE__ */ React10__default.default.createElement(
|
|
210
|
+
material.Box,
|
|
211
|
+
{
|
|
212
|
+
onClick: () => setIsOpen(!isOpen),
|
|
213
|
+
className: "tune-btn main-background-color",
|
|
214
|
+
sx: { bgcolor: "primary.main", color: "primary.contrastText", "&:hover": { boxShadow: 4 } }
|
|
215
|
+
},
|
|
216
|
+
/* @__PURE__ */ React10__default.default.createElement(material.Badge, { badgeContent: props.activeFiltersCount, color: "error" }, /* @__PURE__ */ React10__default.default.createElement(iconsMaterial.Tune, null))
|
|
217
|
+
)
|
|
218
|
+
), props.actions && /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { display: { xs: "none", md: "block" } }, className: "wrapper-actions" }, ActionsList(props.actions)))
|
|
219
|
+
)), !inlineExtraActions && extraActions), props.divider && /* @__PURE__ */ React10__default.default.createElement(material.Divider, null), /* @__PURE__ */ React10__default.default.createElement(material.Collapse, { in: isOpen }, /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: "filters", sx: { px: 2, mt: 2, mb: props.divider ? 0 : 1 } }, /* @__PURE__ */ React10__default.default.createElement(material.Grid, { container: true, spacing: 3, sx: { justifyContent: "end" } }, props.filters && props.filters.length > 0 && props.filters.map((filter, i) => /* @__PURE__ */ React10__default.default.createElement(material.Grid, { key: i, size: { xs: 12, sm: props.filtersSize ?? 6, xl: props.filtersSize ?? 4 } }, filter.doubleFilter ? DoubleFilter(filter.doubleFilter) : filter.singleFilter))))));
|
|
209
220
|
};
|
|
210
221
|
|
|
211
222
|
// src/components/wrappers/LinearProgressComponent/LinearProgressComponent.scss
|
|
@@ -759,6 +770,9 @@ var addNotification = ({
|
|
|
759
770
|
action: duration === null ? (key) => /* @__PURE__ */ React10__default.default.createElement(material.IconButton, { size: "small", color: "inherit", "aria-label": "close", onClick: () => notistack.closeSnackbar(key) }, /* @__PURE__ */ React10__default.default.createElement(CloseIcon__default.default, { fontSize: "small" })) : void 0
|
|
760
771
|
});
|
|
761
772
|
var removeNotification = (id) => notistack.closeSnackbar(id);
|
|
773
|
+
|
|
774
|
+
// src/helpers/PermissionHelpers.tsx
|
|
775
|
+
var hasPermission = (permission) => getSession()?.role.includes(permission) ?? false;
|
|
762
776
|
var Spinner = () => /* @__PURE__ */ React10__default.default.createElement(material.Box, { sx: { textAlign: "center" } }, /* @__PURE__ */ React10__default.default.createElement(material.CircularProgress, { color: "primary", size: 20 }));
|
|
763
777
|
|
|
764
778
|
// src/components/tables/ImageTableComponent/ImageTableComponent.tsx
|
|
@@ -1605,11 +1619,11 @@ var NavIcon = (props) => {
|
|
|
1605
1619
|
// src/components/navigation/VerticalNav/VerticalNavItem.tsx
|
|
1606
1620
|
var VerticalNavItem = (props) => {
|
|
1607
1621
|
const { pathname } = reactRouter.useLocation();
|
|
1608
|
-
const
|
|
1622
|
+
const hasPermission2 = React10.useMemo(
|
|
1609
1623
|
() => checkPermission(props.item.persmisionAvailable, props.userPermisions),
|
|
1610
1624
|
[props.item.persmisionAvailable, props.userPermisions]
|
|
1611
1625
|
);
|
|
1612
|
-
if (!
|
|
1626
|
+
if (!hasPermission2) {
|
|
1613
1627
|
return null;
|
|
1614
1628
|
}
|
|
1615
1629
|
const isActive = !!reactRouter.matchPath({ path: props.item.end ? props.item.route || "" : `${props.item.route}/*` }, pathname);
|
|
@@ -1669,11 +1683,11 @@ var VerticalNavItemCollapse = (props) => {
|
|
|
1669
1683
|
const handleClick = () => {
|
|
1670
1684
|
setOpen(!open);
|
|
1671
1685
|
};
|
|
1672
|
-
const
|
|
1686
|
+
const hasPermission2 = React10.useMemo(
|
|
1673
1687
|
() => checkPermission(props.item.persmisionAvailable, props.userPermisions),
|
|
1674
1688
|
[props.item.persmisionAvailable, props.userPermisions]
|
|
1675
1689
|
);
|
|
1676
|
-
if (!
|
|
1690
|
+
if (!hasPermission2) {
|
|
1677
1691
|
return null;
|
|
1678
1692
|
}
|
|
1679
1693
|
return /* @__PURE__ */ React10__default.default.createElement(material.Box, { className: "nav-item-collapse" }, /* @__PURE__ */ React10__default.default.createElement(
|
|
@@ -3009,6 +3023,7 @@ exports.getImageByBase64 = getImageByBase64;
|
|
|
3009
3023
|
exports.getImageByBlob = getImageByBlob;
|
|
3010
3024
|
exports.getJwtToken = getJwtToken;
|
|
3011
3025
|
exports.getSession = getSession;
|
|
3026
|
+
exports.hasPermission = hasPermission;
|
|
3012
3027
|
exports.logout = logout;
|
|
3013
3028
|
exports.readFileAsBase64 = readFileAsBase64;
|
|
3014
3029
|
exports.redirectDownload = redirectDownload;
|