@plasmicapp/react-web 0.2.229 → 0.2.231
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/all.d.ts +1 -0
- package/dist/auth/PlasmicPageGuard.d.ts +1 -0
- package/dist/index.cjs.js +14 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/prepass/index.d.ts +1 -0
- package/dist/react-web.esm.js +14 -2
- package/dist/react-web.esm.js.map +1 -1
- package/lib/prepass/index.cjs.js +17 -0
- package/lib/prepass/index.cjs.js.map +1 -0
- package/lib/prepass/index.d.ts +1 -0
- package/lib/prepass/index.js +2 -0
- package/lib/prepass/index.js.map +1 -0
- package/package.json +9 -3
- package/skinny/dist/auth/PlasmicPageGuard.d.ts +1 -0
- package/skinny/dist/index.js +14 -2
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/prepass/index.d.ts +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var prepass = require('@plasmicapp/prepass');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(prepass).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return prepass[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@plasmicapp/prepass";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/react-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.231",
|
|
4
4
|
"description": "plasmic library for rendering in the presentational style",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,6 +41,11 @@
|
|
|
41
41
|
"import": "./lib/query/index.js",
|
|
42
42
|
"require": "./lib/query/index.cjs.js"
|
|
43
43
|
},
|
|
44
|
+
"./lib/prepass": {
|
|
45
|
+
"types": "./lib/prepass/index.d.ts",
|
|
46
|
+
"import": "./lib/prepass/index.js",
|
|
47
|
+
"require": "./lib/prepass/index.cjs.js"
|
|
48
|
+
},
|
|
44
49
|
"./lib/plasmic.css": "./lib/plasmic.css",
|
|
45
50
|
"./skinny": {
|
|
46
51
|
"import": "./skinny/dist/index.js"
|
|
@@ -75,9 +80,10 @@
|
|
|
75
80
|
},
|
|
76
81
|
"prettier": {},
|
|
77
82
|
"dependencies": {
|
|
78
|
-
"@plasmicapp/data-sources": "0.1.
|
|
83
|
+
"@plasmicapp/data-sources": "0.1.94",
|
|
79
84
|
"@plasmicapp/data-sources-context": "0.1.11",
|
|
80
85
|
"@plasmicapp/host": "1.0.149",
|
|
86
|
+
"@plasmicapp/prepass": "1.0.1",
|
|
81
87
|
"@plasmicapp/query": "0.1.67",
|
|
82
88
|
"@react-aria/checkbox": "^3.5.0",
|
|
83
89
|
"@react-aria/focus": "^3.7.0",
|
|
@@ -143,5 +149,5 @@
|
|
|
143
149
|
"react": ">=16.8.0",
|
|
144
150
|
"react-dom": ">=16.8.0"
|
|
145
151
|
},
|
|
146
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "dc2ad8008e43ddf96d46c346afd43dc36c34e8d5"
|
|
147
153
|
}
|
|
@@ -5,6 +5,7 @@ interface PlasmicPageGuardProps {
|
|
|
5
5
|
minRole?: string;
|
|
6
6
|
canTriggerLogin: boolean;
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
unauthorizedComp?: React.ReactNode;
|
|
8
9
|
}
|
|
9
10
|
export declare function PlasmicPageGuard(props: PlasmicPageGuardProps): JSX.Element | null;
|
|
10
11
|
export declare function withPlasmicPageGuard<P extends object>(WrappedComponent: React.ComponentType<P>, options: Omit<PlasmicPageGuardProps, "children">): React.FC<P>;
|
package/skinny/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function triggerLogin(appId, authorizeEndpoint, redirectUri) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function PlasmicPageGuard(props) {
|
|
81
|
-
var appId = props.appId, authorizeEndpoint = props.authorizeEndpoint, minRole = props.minRole, canTriggerLogin = props.canTriggerLogin, children = props.children;
|
|
81
|
+
var appId = props.appId, authorizeEndpoint = props.authorizeEndpoint, minRole = props.minRole, canTriggerLogin = props.canTriggerLogin, children = props.children, unauthorizedComp = props.unauthorizedComp;
|
|
82
82
|
var dataSourceCtxValue = usePlasmicDataSourceContext();
|
|
83
83
|
React__default.useEffect(function () {
|
|
84
84
|
if (canTriggerLogin) {
|
|
@@ -109,12 +109,24 @@ function PlasmicPageGuard(props) {
|
|
|
109
109
|
}
|
|
110
110
|
return dataSourceCtxValue.user.roleIds.includes(minRole);
|
|
111
111
|
}
|
|
112
|
+
/*
|
|
113
|
+
PlasmicPageGuard has three cases:
|
|
114
|
+
1. No value of dataSourceCtxValue, user is loading or a trigger login should be performed.
|
|
115
|
+
In this case, we don't want to render the children or the access denied message.
|
|
116
|
+
While the user is loading we look to see if don't have a user value as we can be in a
|
|
117
|
+
revalidate state.
|
|
118
|
+
2. The user doesn't have access to the page in which we show an access denied message.
|
|
119
|
+
3. The user has access to the page in which we render the children.
|
|
120
|
+
*/
|
|
112
121
|
if (!dataSourceCtxValue ||
|
|
113
|
-
dataSourceCtxValue.isUserLoading ||
|
|
122
|
+
(dataSourceCtxValue.isUserLoading && !dataSourceCtxValue.user) ||
|
|
114
123
|
(!dataSourceCtxValue.user && minRole && canTriggerLogin)) {
|
|
115
124
|
return null;
|
|
116
125
|
}
|
|
117
126
|
if (!canUserViewPage()) {
|
|
127
|
+
if (unauthorizedComp) {
|
|
128
|
+
return React__default.createElement(React__default.Fragment, null, unauthorizedComp);
|
|
129
|
+
}
|
|
118
130
|
return React__default.createElement("div", null, "You don't have access to this page");
|
|
119
131
|
}
|
|
120
132
|
return React__default.createElement(React__default.Fragment, null, children);
|