@equinor/cpl-generic-pages-react 0.0.1
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/LICENCE +21 -0
- package/README.md +9 -0
- package/dist/index.d.mts +69 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +231 -0
- package/dist/index.mjs +205 -0
- package/package.json +45 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Equinor ASA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SVGAttributes, ReactNode } from 'react';
|
|
3
|
+
import { ButtonProps, IconProps } from '@equinor/eds-core-react';
|
|
4
|
+
|
|
5
|
+
interface AuthButtonProps extends Omit<ButtonProps, 'onClick' | 'href'> {
|
|
6
|
+
/**
|
|
7
|
+
* Here you can pass either a `string` and `URL` object or a callback function.
|
|
8
|
+
*
|
|
9
|
+
* If you pass a `string` or `URL`, the button will be rendered as an anchor `<a />` element,
|
|
10
|
+
* while passing a `function` will result in a `<button />` element with an `onClick` handler.
|
|
11
|
+
*/
|
|
12
|
+
action: string | URL | (() => void);
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface EquinorLogoProps {
|
|
17
|
+
/**
|
|
18
|
+
* Value in `px`
|
|
19
|
+
*
|
|
20
|
+
* @default 24
|
|
21
|
+
*/
|
|
22
|
+
size?: IconProps['size'];
|
|
23
|
+
/**
|
|
24
|
+
* Override fill color if wanted
|
|
25
|
+
*
|
|
26
|
+
* @default tokens.colors.infographic.primary__energy_red_100.rgba
|
|
27
|
+
*/
|
|
28
|
+
fillColor?: SVGAttributes<unknown>['fill'];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type AuthPageProps = {
|
|
32
|
+
appName: string;
|
|
33
|
+
/**
|
|
34
|
+
* If omitted, it falls back to Equinor Logo if not defined will be used.
|
|
35
|
+
*/
|
|
36
|
+
customLogo?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Custom props for the default Equinor logo. Overrides the default props.
|
|
39
|
+
*
|
|
40
|
+
* A use case could be to set the `fillColor` when using other color schemes.
|
|
41
|
+
*/
|
|
42
|
+
defaultLogoProps?: Partial<EquinorLogoProps>;
|
|
43
|
+
/**
|
|
44
|
+
* Used to display information such as "You have been logged out".
|
|
45
|
+
*/
|
|
46
|
+
description?: string;
|
|
47
|
+
/**
|
|
48
|
+
* E.g. `Sign in`
|
|
49
|
+
*/
|
|
50
|
+
buttonText: string;
|
|
51
|
+
isLoading?: boolean;
|
|
52
|
+
buttonProps?: Omit<AuthButtonProps, 'isLoading' | 'action' | 'children'>;
|
|
53
|
+
} & Pick<AuthButtonProps, 'action'>;
|
|
54
|
+
/**
|
|
55
|
+
* Generic component for building auth related pages. Used as base element for the `LoginPage`,
|
|
56
|
+
* `LogoutPage` components.
|
|
57
|
+
*/
|
|
58
|
+
declare function AuthPage({ appName, customLogo, action, defaultLogoProps, buttonProps, buttonText, description, isLoading, }: AuthPageProps): react_jsx_runtime.JSX.Element;
|
|
59
|
+
|
|
60
|
+
type LoginPageProps = Partial<AuthPageProps> & Pick<AuthPageProps, 'appName' | 'action'> & {
|
|
61
|
+
/**
|
|
62
|
+
* This sets the default description text (unless the `description` field is explicitly set)
|
|
63
|
+
*/
|
|
64
|
+
showDefaultSignedOutText?: boolean;
|
|
65
|
+
};
|
|
66
|
+
declare const DEFAULT_SIGNED_OUT_TEXT = "You have been logged out";
|
|
67
|
+
declare function LoginPage({ appName, action, buttonText, buttonProps, customLogo, defaultLogoProps, description, showDefaultSignedOutText, }: LoginPageProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
|
|
69
|
+
export { AuthPage, type AuthPageProps, DEFAULT_SIGNED_OUT_TEXT, LoginPage, type LoginPageProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SVGAttributes, ReactNode } from 'react';
|
|
3
|
+
import { ButtonProps, IconProps } from '@equinor/eds-core-react';
|
|
4
|
+
|
|
5
|
+
interface AuthButtonProps extends Omit<ButtonProps, 'onClick' | 'href'> {
|
|
6
|
+
/**
|
|
7
|
+
* Here you can pass either a `string` and `URL` object or a callback function.
|
|
8
|
+
*
|
|
9
|
+
* If you pass a `string` or `URL`, the button will be rendered as an anchor `<a />` element,
|
|
10
|
+
* while passing a `function` will result in a `<button />` element with an `onClick` handler.
|
|
11
|
+
*/
|
|
12
|
+
action: string | URL | (() => void);
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface EquinorLogoProps {
|
|
17
|
+
/**
|
|
18
|
+
* Value in `px`
|
|
19
|
+
*
|
|
20
|
+
* @default 24
|
|
21
|
+
*/
|
|
22
|
+
size?: IconProps['size'];
|
|
23
|
+
/**
|
|
24
|
+
* Override fill color if wanted
|
|
25
|
+
*
|
|
26
|
+
* @default tokens.colors.infographic.primary__energy_red_100.rgba
|
|
27
|
+
*/
|
|
28
|
+
fillColor?: SVGAttributes<unknown>['fill'];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type AuthPageProps = {
|
|
32
|
+
appName: string;
|
|
33
|
+
/**
|
|
34
|
+
* If omitted, it falls back to Equinor Logo if not defined will be used.
|
|
35
|
+
*/
|
|
36
|
+
customLogo?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Custom props for the default Equinor logo. Overrides the default props.
|
|
39
|
+
*
|
|
40
|
+
* A use case could be to set the `fillColor` when using other color schemes.
|
|
41
|
+
*/
|
|
42
|
+
defaultLogoProps?: Partial<EquinorLogoProps>;
|
|
43
|
+
/**
|
|
44
|
+
* Used to display information such as "You have been logged out".
|
|
45
|
+
*/
|
|
46
|
+
description?: string;
|
|
47
|
+
/**
|
|
48
|
+
* E.g. `Sign in`
|
|
49
|
+
*/
|
|
50
|
+
buttonText: string;
|
|
51
|
+
isLoading?: boolean;
|
|
52
|
+
buttonProps?: Omit<AuthButtonProps, 'isLoading' | 'action' | 'children'>;
|
|
53
|
+
} & Pick<AuthButtonProps, 'action'>;
|
|
54
|
+
/**
|
|
55
|
+
* Generic component for building auth related pages. Used as base element for the `LoginPage`,
|
|
56
|
+
* `LogoutPage` components.
|
|
57
|
+
*/
|
|
58
|
+
declare function AuthPage({ appName, customLogo, action, defaultLogoProps, buttonProps, buttonText, description, isLoading, }: AuthPageProps): react_jsx_runtime.JSX.Element;
|
|
59
|
+
|
|
60
|
+
type LoginPageProps = Partial<AuthPageProps> & Pick<AuthPageProps, 'appName' | 'action'> & {
|
|
61
|
+
/**
|
|
62
|
+
* This sets the default description text (unless the `description` field is explicitly set)
|
|
63
|
+
*/
|
|
64
|
+
showDefaultSignedOutText?: boolean;
|
|
65
|
+
};
|
|
66
|
+
declare const DEFAULT_SIGNED_OUT_TEXT = "You have been logged out";
|
|
67
|
+
declare function LoginPage({ appName, action, buttonText, buttonProps, customLogo, defaultLogoProps, description, showDefaultSignedOutText, }: LoginPageProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
|
|
69
|
+
export { AuthPage, type AuthPageProps, DEFAULT_SIGNED_OUT_TEXT, LoginPage, type LoginPageProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
|
|
49
|
+
// src/index.ts
|
|
50
|
+
var index_exports = {};
|
|
51
|
+
__export(index_exports, {
|
|
52
|
+
AuthPage: () => AuthPage,
|
|
53
|
+
DEFAULT_SIGNED_OUT_TEXT: () => DEFAULT_SIGNED_OUT_TEXT,
|
|
54
|
+
LoginPage: () => LoginPage
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(index_exports);
|
|
57
|
+
|
|
58
|
+
// src/auth/AuthPage/AuthPage.tsx
|
|
59
|
+
var import_eds_core_react2 = require("@equinor/eds-core-react");
|
|
60
|
+
var import_eds_tokens2 = require("@equinor/eds-tokens");
|
|
61
|
+
var import_styled_components2 = require("styled-components");
|
|
62
|
+
|
|
63
|
+
// src/auth/AuthButton.tsx
|
|
64
|
+
var import_eds_core_react = require("@equinor/eds-core-react");
|
|
65
|
+
var import_styled_components = require("styled-components");
|
|
66
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
67
|
+
function AuthButton(_a) {
|
|
68
|
+
var _b = _a, {
|
|
69
|
+
action,
|
|
70
|
+
isLoading = false,
|
|
71
|
+
children
|
|
72
|
+
} = _b, buttonProps = __objRest(_b, [
|
|
73
|
+
"action",
|
|
74
|
+
"isLoading",
|
|
75
|
+
"children"
|
|
76
|
+
]);
|
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
78
|
+
StyledButton,
|
|
79
|
+
__spreadProps(__spreadValues({
|
|
80
|
+
onClick: typeof action === "function" ? action : void 0,
|
|
81
|
+
href: typeof action === "function" ? void 0 : action.toString()
|
|
82
|
+
}, buttonProps), {
|
|
83
|
+
children: [
|
|
84
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_eds_core_react.DotProgress, {}) }),
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(InnerText, { isLoading, children })
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
var InnerText = import_styled_components.styled.span`
|
|
91
|
+
all: inherit;
|
|
92
|
+
opacity: ${({ isLoading }) => isLoading ? 0 : 1};
|
|
93
|
+
`;
|
|
94
|
+
var LoadingWrapper = import_styled_components.styled.div`
|
|
95
|
+
background: inherit;
|
|
96
|
+
position: absolute;
|
|
97
|
+
z-index: 1;
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 100%;
|
|
100
|
+
top: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
display: flex;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
align-items: center;
|
|
105
|
+
`;
|
|
106
|
+
var StyledButton = (0, import_styled_components.styled)(import_eds_core_react.Button)`
|
|
107
|
+
padding-left: 2rem;
|
|
108
|
+
padding-right: 2rem;
|
|
109
|
+
|
|
110
|
+
position: relative;
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
// src/auth/EquinorLogo.tsx
|
|
114
|
+
var import_eds_tokens = require("@equinor/eds-tokens");
|
|
115
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
116
|
+
function EquinorLogo({
|
|
117
|
+
size = 24,
|
|
118
|
+
fillColor = import_eds_tokens.tokens.colors.infographic.primary__energy_red_100.rgba
|
|
119
|
+
}) {
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
121
|
+
"svg",
|
|
122
|
+
{
|
|
123
|
+
width: size,
|
|
124
|
+
height: size,
|
|
125
|
+
viewBox: "0 0 42 48",
|
|
126
|
+
fill: "none",
|
|
127
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
128
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
129
|
+
"path",
|
|
130
|
+
{
|
|
131
|
+
d: "M5.333 10.204v12.892c0 .382.192.735.523.926l11.17 6.435c.474.273 1.079-.069 1.079-.616V16.95c0-.382-.204-.735-.535-.926L6.4 9.589a.712.712 0 0 0-1.067.615ZM39.74.138 23.657 9.403c-.476.275-.77.783-.769 1.333v18.56c0 .787.87 1.279 1.553.886l16.082-9.264a1.52 1.52 0 0 0 .751-1.333V1.025c0-.788-.852-1.28-1.535-.887ZM17.68 39.612l-4.47 2.575a.428.428 0 0 0-.214.37v5.158c0 .22.242.356.432.247l4.469-2.575a.422.422 0 0 0 .209-.37v-5.158a.285.285 0 0 0-.427-.247Zm-2.605-4.759L8.38 30.98a.642.642 0 0 0-.64 0l-6.694 3.873a.427.427 0 0 0 0 .739l6.693 3.872a.638.638 0 0 0 .641 0l6.694-3.872a.427.427 0 0 0 0-.739Zm10.775.698 2.974 1.72a.568.568 0 0 0 .57 0l2.973-1.72a.38.38 0 0 0 0-.657l-2.974-1.72a.568.568 0 0 0-.57 0l-2.973 1.72a.38.38 0 0 0 0 .657Zm-2.392 4.141 2.977 1.715a.57.57 0 0 1 .285.494l-.004 3.435a.38.38 0 0 1-.569.329L23.17 43.95a.567.567 0 0 1-.28-.494l-.001-3.435a.38.38 0 0 1 .569-.329Z",
|
|
132
|
+
fill: fillColor
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/auth/AuthPage/AuthPage.tsx
|
|
140
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
141
|
+
function AuthPage({
|
|
142
|
+
appName,
|
|
143
|
+
customLogo,
|
|
144
|
+
action,
|
|
145
|
+
defaultLogoProps,
|
|
146
|
+
buttonProps,
|
|
147
|
+
buttonText,
|
|
148
|
+
description,
|
|
149
|
+
isLoading
|
|
150
|
+
}) {
|
|
151
|
+
if (action === void 0) {
|
|
152
|
+
throw new Error("Missing prop 'action'");
|
|
153
|
+
}
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PageWrapper, { children: [
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(HeaderWrapper, { children: [
|
|
156
|
+
customLogo != null ? customLogo : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EquinorLogo, __spreadValues({ size: 48 }, defaultLogoProps)),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledHeading, { variant: "h3", as: "h1", children: appName })
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ContentWrapper, { children: [
|
|
160
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledDescription, { variant: "h6", as: "p", children: description }),
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthButton, __spreadProps(__spreadValues({ action, isLoading }, buttonProps), { children: buttonText }))
|
|
162
|
+
] })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
var ContentWrapper = import_styled_components2.styled.div`
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
align-items: center;
|
|
169
|
+
|
|
170
|
+
gap: 16px;
|
|
171
|
+
`;
|
|
172
|
+
var PageWrapper = import_styled_components2.styled.div`
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: column;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
|
|
178
|
+
gap: 32px;
|
|
179
|
+
|
|
180
|
+
height: 100%;
|
|
181
|
+
padding: 16px;
|
|
182
|
+
`;
|
|
183
|
+
var HeaderWrapper = import_styled_components2.styled.div`
|
|
184
|
+
display: flex;
|
|
185
|
+
flex-direction: column;
|
|
186
|
+
align-items: center;
|
|
187
|
+
|
|
188
|
+
gap: 10px;
|
|
189
|
+
`;
|
|
190
|
+
var StyledHeading = (0, import_styled_components2.styled)(import_eds_core_react2.Typography)`
|
|
191
|
+
color: ${import_eds_tokens2.tokens.colors.text.static_icons__default.rgba};
|
|
192
|
+
margin: 0;
|
|
193
|
+
font-weight: 500;
|
|
194
|
+
`;
|
|
195
|
+
var StyledDescription = (0, import_styled_components2.styled)(import_eds_core_react2.Typography)`
|
|
196
|
+
color: ${import_eds_tokens2.tokens.colors.text.static_icons__default.rgba};
|
|
197
|
+
margin: 0;
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
// src/auth/LoginPage/LoginPage.tsx
|
|
201
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
202
|
+
var DEFAULT_SIGNED_OUT_TEXT = "You have been logged out";
|
|
203
|
+
function LoginPage({
|
|
204
|
+
appName,
|
|
205
|
+
action,
|
|
206
|
+
buttonText = "Sign in",
|
|
207
|
+
buttonProps,
|
|
208
|
+
customLogo,
|
|
209
|
+
defaultLogoProps,
|
|
210
|
+
description,
|
|
211
|
+
showDefaultSignedOutText
|
|
212
|
+
}) {
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
214
|
+
AuthPage,
|
|
215
|
+
{
|
|
216
|
+
appName,
|
|
217
|
+
action,
|
|
218
|
+
buttonText,
|
|
219
|
+
buttonProps,
|
|
220
|
+
customLogo,
|
|
221
|
+
defaultLogoProps,
|
|
222
|
+
description: typeof description === "string" ? description : showDefaultSignedOutText ? DEFAULT_SIGNED_OUT_TEXT : description
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
227
|
+
0 && (module.exports = {
|
|
228
|
+
AuthPage,
|
|
229
|
+
DEFAULT_SIGNED_OUT_TEXT,
|
|
230
|
+
LoginPage
|
|
231
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/auth/AuthPage/AuthPage.tsx
|
|
34
|
+
import { Typography } from "@equinor/eds-core-react";
|
|
35
|
+
import { tokens as tokens2 } from "@equinor/eds-tokens";
|
|
36
|
+
import { styled as styled2 } from "styled-components";
|
|
37
|
+
|
|
38
|
+
// src/auth/AuthButton.tsx
|
|
39
|
+
import { Button, DotProgress } from "@equinor/eds-core-react";
|
|
40
|
+
import { styled } from "styled-components";
|
|
41
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
42
|
+
function AuthButton(_a) {
|
|
43
|
+
var _b = _a, {
|
|
44
|
+
action,
|
|
45
|
+
isLoading = false,
|
|
46
|
+
children
|
|
47
|
+
} = _b, buttonProps = __objRest(_b, [
|
|
48
|
+
"action",
|
|
49
|
+
"isLoading",
|
|
50
|
+
"children"
|
|
51
|
+
]);
|
|
52
|
+
return /* @__PURE__ */ jsxs(
|
|
53
|
+
StyledButton,
|
|
54
|
+
__spreadProps(__spreadValues({
|
|
55
|
+
onClick: typeof action === "function" ? action : void 0,
|
|
56
|
+
href: typeof action === "function" ? void 0 : action.toString()
|
|
57
|
+
}, buttonProps), {
|
|
58
|
+
children: [
|
|
59
|
+
isLoading && /* @__PURE__ */ jsx(LoadingWrapper, { children: /* @__PURE__ */ jsx(DotProgress, {}) }),
|
|
60
|
+
/* @__PURE__ */ jsx(InnerText, { isLoading, children })
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
var InnerText = styled.span`
|
|
66
|
+
all: inherit;
|
|
67
|
+
opacity: ${({ isLoading }) => isLoading ? 0 : 1};
|
|
68
|
+
`;
|
|
69
|
+
var LoadingWrapper = styled.div`
|
|
70
|
+
background: inherit;
|
|
71
|
+
position: absolute;
|
|
72
|
+
z-index: 1;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
top: 0;
|
|
76
|
+
left: 0;
|
|
77
|
+
display: flex;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
align-items: center;
|
|
80
|
+
`;
|
|
81
|
+
var StyledButton = styled(Button)`
|
|
82
|
+
padding-left: 2rem;
|
|
83
|
+
padding-right: 2rem;
|
|
84
|
+
|
|
85
|
+
position: relative;
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
// src/auth/EquinorLogo.tsx
|
|
89
|
+
import { tokens } from "@equinor/eds-tokens";
|
|
90
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
91
|
+
function EquinorLogo({
|
|
92
|
+
size = 24,
|
|
93
|
+
fillColor = tokens.colors.infographic.primary__energy_red_100.rgba
|
|
94
|
+
}) {
|
|
95
|
+
return /* @__PURE__ */ jsx2(
|
|
96
|
+
"svg",
|
|
97
|
+
{
|
|
98
|
+
width: size,
|
|
99
|
+
height: size,
|
|
100
|
+
viewBox: "0 0 42 48",
|
|
101
|
+
fill: "none",
|
|
102
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
103
|
+
children: /* @__PURE__ */ jsx2(
|
|
104
|
+
"path",
|
|
105
|
+
{
|
|
106
|
+
d: "M5.333 10.204v12.892c0 .382.192.735.523.926l11.17 6.435c.474.273 1.079-.069 1.079-.616V16.95c0-.382-.204-.735-.535-.926L6.4 9.589a.712.712 0 0 0-1.067.615ZM39.74.138 23.657 9.403c-.476.275-.77.783-.769 1.333v18.56c0 .787.87 1.279 1.553.886l16.082-9.264a1.52 1.52 0 0 0 .751-1.333V1.025c0-.788-.852-1.28-1.535-.887ZM17.68 39.612l-4.47 2.575a.428.428 0 0 0-.214.37v5.158c0 .22.242.356.432.247l4.469-2.575a.422.422 0 0 0 .209-.37v-5.158a.285.285 0 0 0-.427-.247Zm-2.605-4.759L8.38 30.98a.642.642 0 0 0-.64 0l-6.694 3.873a.427.427 0 0 0 0 .739l6.693 3.872a.638.638 0 0 0 .641 0l6.694-3.872a.427.427 0 0 0 0-.739Zm10.775.698 2.974 1.72a.568.568 0 0 0 .57 0l2.973-1.72a.38.38 0 0 0 0-.657l-2.974-1.72a.568.568 0 0 0-.57 0l-2.973 1.72a.38.38 0 0 0 0 .657Zm-2.392 4.141 2.977 1.715a.57.57 0 0 1 .285.494l-.004 3.435a.38.38 0 0 1-.569.329L23.17 43.95a.567.567 0 0 1-.28-.494l-.001-3.435a.38.38 0 0 1 .569-.329Z",
|
|
107
|
+
fill: fillColor
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/auth/AuthPage/AuthPage.tsx
|
|
115
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
116
|
+
function AuthPage({
|
|
117
|
+
appName,
|
|
118
|
+
customLogo,
|
|
119
|
+
action,
|
|
120
|
+
defaultLogoProps,
|
|
121
|
+
buttonProps,
|
|
122
|
+
buttonText,
|
|
123
|
+
description,
|
|
124
|
+
isLoading
|
|
125
|
+
}) {
|
|
126
|
+
if (action === void 0) {
|
|
127
|
+
throw new Error("Missing prop 'action'");
|
|
128
|
+
}
|
|
129
|
+
return /* @__PURE__ */ jsxs2(PageWrapper, { children: [
|
|
130
|
+
/* @__PURE__ */ jsxs2(HeaderWrapper, { children: [
|
|
131
|
+
customLogo != null ? customLogo : /* @__PURE__ */ jsx3(EquinorLogo, __spreadValues({ size: 48 }, defaultLogoProps)),
|
|
132
|
+
/* @__PURE__ */ jsx3(StyledHeading, { variant: "h3", as: "h1", children: appName })
|
|
133
|
+
] }),
|
|
134
|
+
/* @__PURE__ */ jsxs2(ContentWrapper, { children: [
|
|
135
|
+
description && /* @__PURE__ */ jsx3(StyledDescription, { variant: "h6", as: "p", children: description }),
|
|
136
|
+
/* @__PURE__ */ jsx3(AuthButton, __spreadProps(__spreadValues({ action, isLoading }, buttonProps), { children: buttonText }))
|
|
137
|
+
] })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
var ContentWrapper = styled2.div`
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
align-items: center;
|
|
144
|
+
|
|
145
|
+
gap: 16px;
|
|
146
|
+
`;
|
|
147
|
+
var PageWrapper = styled2.div`
|
|
148
|
+
display: flex;
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
align-items: center;
|
|
151
|
+
justify-content: center;
|
|
152
|
+
|
|
153
|
+
gap: 32px;
|
|
154
|
+
|
|
155
|
+
height: 100%;
|
|
156
|
+
padding: 16px;
|
|
157
|
+
`;
|
|
158
|
+
var HeaderWrapper = styled2.div`
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-direction: column;
|
|
161
|
+
align-items: center;
|
|
162
|
+
|
|
163
|
+
gap: 10px;
|
|
164
|
+
`;
|
|
165
|
+
var StyledHeading = styled2(Typography)`
|
|
166
|
+
color: ${tokens2.colors.text.static_icons__default.rgba};
|
|
167
|
+
margin: 0;
|
|
168
|
+
font-weight: 500;
|
|
169
|
+
`;
|
|
170
|
+
var StyledDescription = styled2(Typography)`
|
|
171
|
+
color: ${tokens2.colors.text.static_icons__default.rgba};
|
|
172
|
+
margin: 0;
|
|
173
|
+
`;
|
|
174
|
+
|
|
175
|
+
// src/auth/LoginPage/LoginPage.tsx
|
|
176
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
177
|
+
var DEFAULT_SIGNED_OUT_TEXT = "You have been logged out";
|
|
178
|
+
function LoginPage({
|
|
179
|
+
appName,
|
|
180
|
+
action,
|
|
181
|
+
buttonText = "Sign in",
|
|
182
|
+
buttonProps,
|
|
183
|
+
customLogo,
|
|
184
|
+
defaultLogoProps,
|
|
185
|
+
description,
|
|
186
|
+
showDefaultSignedOutText
|
|
187
|
+
}) {
|
|
188
|
+
return /* @__PURE__ */ jsx4(
|
|
189
|
+
AuthPage,
|
|
190
|
+
{
|
|
191
|
+
appName,
|
|
192
|
+
action,
|
|
193
|
+
buttonText,
|
|
194
|
+
buttonProps,
|
|
195
|
+
customLogo,
|
|
196
|
+
defaultLogoProps,
|
|
197
|
+
description: typeof description === "string" ? description : showDefaultSignedOutText ? DEFAULT_SIGNED_OUT_TEXT : description
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
export {
|
|
202
|
+
AuthPage,
|
|
203
|
+
DEFAULT_SIGNED_OUT_TEXT,
|
|
204
|
+
LoginPage
|
|
205
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@equinor/cpl-generic-pages-react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/**"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@equinor/eds-icons": "^0.21.0",
|
|
13
|
+
"@equinor/eds-tokens": "^0.9.2"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@equinor/eds-core-react": "^0.42.5",
|
|
17
|
+
"@storybook/react": "^8.5.2",
|
|
18
|
+
"@storybook/test": "^8.5.2",
|
|
19
|
+
"@types/react": "^18.3.18",
|
|
20
|
+
"@types/react-dom": "^18.3.5",
|
|
21
|
+
"@types/styled-components": "^5.1.34",
|
|
22
|
+
"eslint": "^8.57.1",
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-dom": "^18.2.0",
|
|
25
|
+
"styled-components": "^6.1.14",
|
|
26
|
+
"tsup": "^8.3.6",
|
|
27
|
+
"eslint-config-custom": "0.0.6",
|
|
28
|
+
"tsconfig": "0.0.1"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@equinor/eds-core-react": ">=0.42.1",
|
|
32
|
+
"react": ">=18.2.0",
|
|
33
|
+
"react-dom": ">=18.2.0",
|
|
34
|
+
"styled-components": ">=5.3.11"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react",
|
|
41
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
42
|
+
"dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
|
|
43
|
+
"lint": "TIMING=1 eslint . --fix"
|
|
44
|
+
}
|
|
45
|
+
}
|