@telia-ace/widget-components-widget-header 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/avatar.d.ts +8 -0
- package/back.d.ts +8 -0
- package/close.d.ts +8 -0
- package/index-c6acaf7f.mjs +76 -0
- package/index-cc8580b8.js +1 -0
- package/index.d.ts +3 -0
- package/index.js +1 -0
- package/index.mjs +7 -0
- package/minimize.d.ts +8 -0
- package/package.json +24 -0
- package/utils.d.ts +10 -0
- package/widget-header-0108235e.mjs +239 -0
- package/widget-header-5e78c0ec.js +80 -0
- package/widget-header-component.d.ts +31 -0
- package/widget-header.d.ts +8 -0
package/avatar.d.ts
ADDED
package/back.d.ts
ADDED
package/close.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createEventSubscriber as b } from "@telia-ace/widget-core";
|
|
2
|
+
import { createReactComponent as g } from "@telia-ace/widget-ui";
|
|
3
|
+
import { removeNullAndUndefinedValues as f } from "@telia-ace/widget-utilities";
|
|
4
|
+
const z = (i, r, s) => {
|
|
5
|
+
if (s !== "center")
|
|
6
|
+
return {};
|
|
7
|
+
const e = (o) => o.reduce((t, a) => {
|
|
8
|
+
const [u] = a.padding.split("px"), [p] = a.size.split("px");
|
|
9
|
+
return t + (+p + +u * 2);
|
|
10
|
+
}, 0), n = e(i), c = e(r), l = n - c;
|
|
11
|
+
return l === 0 ? {} : {
|
|
12
|
+
[n > c ? "right" : "left"]: `${Math.abs(l)}px`
|
|
13
|
+
};
|
|
14
|
+
}, y = (i) => Object.keys(i).reduce(
|
|
15
|
+
(r, s) => {
|
|
16
|
+
const e = i[s];
|
|
17
|
+
if (!e)
|
|
18
|
+
return r;
|
|
19
|
+
const [n, c] = r, l = e.position === "left" ? n : c;
|
|
20
|
+
return i[s].symbol, l.push({
|
|
21
|
+
symbol: e.symbol && typeof e.symbol == "string" ? { type: "Uri", content: e.symbol } : e.symbol,
|
|
22
|
+
type: s,
|
|
23
|
+
padding: e.padding || "10px",
|
|
24
|
+
label: e.label,
|
|
25
|
+
size: e.size || "64px",
|
|
26
|
+
tooltip: e.tooltip,
|
|
27
|
+
order: e.order || 0,
|
|
28
|
+
show: e.show
|
|
29
|
+
}), r;
|
|
30
|
+
},
|
|
31
|
+
[[], []]
|
|
32
|
+
), m = (i) => i.getAsync("router").then((r) => {
|
|
33
|
+
if (!r)
|
|
34
|
+
return !0;
|
|
35
|
+
const s = r.getInitialRoute(), { name: e, params: n } = r.getRouteData();
|
|
36
|
+
return f(n), !((s == null ? void 0 : s.name) !== e || Object.keys(n).length > 0);
|
|
37
|
+
}), v = (i) => g(
|
|
38
|
+
i,
|
|
39
|
+
"widget-header",
|
|
40
|
+
import("./widget-header-0108235e.mjs"),
|
|
41
|
+
(r) => {
|
|
42
|
+
const { events: s } = i.get("$widget"), [e, n] = b(s), {
|
|
43
|
+
actions: c = {},
|
|
44
|
+
tooltipBackLabel: l = "",
|
|
45
|
+
tooltipMinimizeLabel: d = ""
|
|
46
|
+
} = r.properties();
|
|
47
|
+
if (r.actions.create("close", (o, t) => t.preventDefault ? void 0 : i.get("$widget").invoke("close")), r.actions.create("back", (o, t) => {
|
|
48
|
+
if (!t.preventDefault)
|
|
49
|
+
return i.getAsync("router").then((a) => {
|
|
50
|
+
a.goBack();
|
|
51
|
+
});
|
|
52
|
+
}), r.properties((o) => {
|
|
53
|
+
const { actions: t = {} } = o;
|
|
54
|
+
if (t != null && t.back && (t.back.tooltip = t.back.tooltip ? t.back.tooltip : l), t != null && t.minimize && (t.minimize.tooltip = t.minimize.tooltip ? t.minimize.tooltip : d), !!t.back)
|
|
55
|
+
return Object.keys(t).forEach((a) => {
|
|
56
|
+
const u = t[a];
|
|
57
|
+
a === "back" && (u.show = o.showBack);
|
|
58
|
+
}), { actions: t };
|
|
59
|
+
}), r.actions.create("show-back", (o) => {
|
|
60
|
+
r.writeProperties({ showBack: o });
|
|
61
|
+
}), c.back) {
|
|
62
|
+
const o = () => m(i).then(
|
|
63
|
+
(t) => r.actions.dispatch("show-back", !t)
|
|
64
|
+
);
|
|
65
|
+
o(), e("router:changed", o);
|
|
66
|
+
}
|
|
67
|
+
return r.actions.create("minimize", (o, t) => t.preventDefault ? void 0 : i.get("$widget").invoke("hide", { focusTrigger: !0 })), () => {
|
|
68
|
+
n();
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
export {
|
|
73
|
+
v as W,
|
|
74
|
+
z as a,
|
|
75
|
+
y as c
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const b=require("@telia-ace/widget-core"),p=require("@telia-ace/widget-ui"),f=require("@telia-ace/widget-utilities"),h=(r,i,o)=>{if(o!=="center")return{};const t=s=>s.reduce((e,c)=>{const[u]=c.padding.split("px"),[g]=c.size.split("px");return e+(+g+ +u*2)},0),n=t(r),a=t(i),l=n-a;return l===0?{}:{[n>a?"right":"left"]:`${Math.abs(l)}px`}},w=r=>Object.keys(r).reduce((i,o)=>{const t=r[o];if(!t)return i;const[n,a]=i,l=t.position==="left"?n:a;return r[o].symbol,l.push({symbol:t.symbol&&typeof t.symbol=="string"?{type:"Uri",content:t.symbol}:t.symbol,type:o,padding:t.padding||"10px",label:t.label,size:t.size||"64px",tooltip:t.tooltip,order:t.order||0,show:t.show}),i},[[],[]]),m=r=>r.getAsync("router").then(i=>{if(!i)return!0;const o=i.getInitialRoute(),{name:t,params:n}=i.getRouteData();return f.removeNullAndUndefinedValues(n),!((o==null?void 0:o.name)!==t||Object.keys(n).length>0)}),k=r=>p.createReactComponent(r,"widget-header",Promise.resolve().then(()=>require("./widget-header-5e78c0ec.js")),i=>{const{events:o}=r.get("$widget"),[t,n]=b.createEventSubscriber(o),{actions:a={},tooltipBackLabel:l="",tooltipMinimizeLabel:d=""}=i.properties();if(i.actions.create("close",(s,e)=>e.preventDefault?void 0:r.get("$widget").invoke("close")),i.actions.create("back",(s,e)=>{if(!e.preventDefault)return r.getAsync("router").then(c=>{c.goBack()})}),i.properties(s=>{const{actions:e={}}=s;if(e!=null&&e.back&&(e.back.tooltip=e.back.tooltip?e.back.tooltip:l),e!=null&&e.minimize&&(e.minimize.tooltip=e.minimize.tooltip?e.minimize.tooltip:d),!!e.back)return Object.keys(e).forEach(c=>{const u=e[c];c==="back"&&(u.show=s.showBack)}),{actions:e}}),i.actions.create("show-back",s=>{i.writeProperties({showBack:s})}),a.back){const s=()=>m(r).then(e=>i.actions.dispatch("show-back",!e));s(),t("router:changed",s)}return i.actions.create("minimize",(s,e)=>e.preventDefault?void 0:r.get("$widget").invoke("hide",{focusTrigger:!0})),()=>{n()}});exports.WidgetHeaderComponent=k;exports.calculateMargin=h;exports.createNodes=w;
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./index-cc8580b8.js");require("@telia-ace/widget-core");require("@telia-ace/widget-ui");require("@telia-ace/widget-utilities");module.exports=e.WidgetHeaderComponent;
|
package/index.mjs
ADDED
package/minimize.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/widget-components-widget-header",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./index.mjs",
|
|
9
|
+
"require": "./index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@telia-ace/widget-core": "*",
|
|
14
|
+
"@telia-ace/widget-routing": "*",
|
|
15
|
+
"@telia-ace/widget-ui": "*",
|
|
16
|
+
"@telia-ace/widget-utilities": "*",
|
|
17
|
+
"@webprovisions/platform": "^1.1.4"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@emotion/react": "11.11.1",
|
|
21
|
+
"@emotion/styled": "11.11.0",
|
|
22
|
+
"react": "18.2.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import { ActionNode } from './widget-header-component';
|
|
3
|
+
|
|
4
|
+
export declare const calculateMargin: (leftNodes: ActionNode[], rightNodes: ActionNode[], textAlign: string) => {
|
|
5
|
+
[x: string]: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const createNodes: (actions: {
|
|
8
|
+
[key: string]: ActionNode;
|
|
9
|
+
}) => [ActionNode[], ActionNode[]];
|
|
10
|
+
export declare const isOnInitialRoute: (container: Container) => Promise<boolean>;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { jsx as i, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { css as y } from "@emotion/react";
|
|
3
|
+
import c from "@emotion/styled";
|
|
4
|
+
import { SymbolBadge as h, borderTabStyle as z, useDispatch as k, TransitionComponent as N, useProperties as S, Typography as f, headingElement as v, Link as w, linkTabStyle as C } from "@telia-ace/widget-ui";
|
|
5
|
+
import { appendClassNames as T } from "@telia-ace/widget-utilities";
|
|
6
|
+
import { c as A, a as W } from "./index-c6acaf7f.mjs";
|
|
7
|
+
import "@telia-ace/widget-core";
|
|
8
|
+
const B = ({ node: e }) => {
|
|
9
|
+
if (!e.symbol)
|
|
10
|
+
return null;
|
|
11
|
+
let t;
|
|
12
|
+
const r = e.symbol.type === "Svg";
|
|
13
|
+
if (e.symbol.type === "Svg") {
|
|
14
|
+
const s = parseInt(e.size, 10);
|
|
15
|
+
isNaN(s) || (t = s);
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ i(
|
|
18
|
+
I,
|
|
19
|
+
{
|
|
20
|
+
symbol: e.symbol,
|
|
21
|
+
svg: r,
|
|
22
|
+
size: t,
|
|
23
|
+
backgroundSize: "cover"
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}, I = c(({ svg: e, ...t }) => /* @__PURE__ */ i(h, { ...t }))`
|
|
27
|
+
color: ${(e) => {
|
|
28
|
+
var t;
|
|
29
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
30
|
+
}};
|
|
31
|
+
${(e) => !e.svg && y`
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
`}
|
|
35
|
+
`, M = ({ node: e }) => {
|
|
36
|
+
const t = e.symbol || { type: "Svg", content: "back" };
|
|
37
|
+
return /* @__PURE__ */ i(h, { size: 20, symbol: t });
|
|
38
|
+
}, j = ({ node: e }) => {
|
|
39
|
+
const t = e.symbol || { type: "Svg", content: "close" }, r = parseInt(e == null ? void 0 : e.size, 10) || 14;
|
|
40
|
+
return /* @__PURE__ */ i(h, { size: r, symbol: t });
|
|
41
|
+
}, q = ({ node: e }) => {
|
|
42
|
+
const t = e.symbol || { type: "Svg", content: "minimize" }, r = parseInt(e == null ? void 0 : e.size, 10) || 20;
|
|
43
|
+
return /* @__PURE__ */ i(h, { size: r, symbol: t });
|
|
44
|
+
}, x = ({ className: e = "", ...t }) => {
|
|
45
|
+
const r = k(), { size: s, padding: m, type: n, tooltip: a, show: g = !0 } = t;
|
|
46
|
+
return n === "back" ? /* @__PURE__ */ i($, { size: s || "64px", padding: m || "10px", children: /* @__PURE__ */ i(
|
|
47
|
+
N,
|
|
48
|
+
{
|
|
49
|
+
in: g,
|
|
50
|
+
timeout: 300,
|
|
51
|
+
transitions: {
|
|
52
|
+
enter: {
|
|
53
|
+
type: "scale",
|
|
54
|
+
easing: "cubic-bezier(.08,.84,.74,1.84)"
|
|
55
|
+
},
|
|
56
|
+
exit: {
|
|
57
|
+
type: "scale",
|
|
58
|
+
easing: "ease-out"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
children: (d, p) => /* @__PURE__ */ i(
|
|
62
|
+
b,
|
|
63
|
+
{
|
|
64
|
+
"data-testid": "back-button",
|
|
65
|
+
title: a,
|
|
66
|
+
"aria-label": a,
|
|
67
|
+
animationCss: p,
|
|
68
|
+
onClick: () => {
|
|
69
|
+
r("back");
|
|
70
|
+
},
|
|
71
|
+
children: /* @__PURE__ */ i(M, { node: t })
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
) }) : g ? /* @__PURE__ */ u(
|
|
76
|
+
$,
|
|
77
|
+
{
|
|
78
|
+
size: s || "64px",
|
|
79
|
+
padding: m || "10px",
|
|
80
|
+
squareRatio: n === "avatar",
|
|
81
|
+
children: [
|
|
82
|
+
n === "avatar" && /* @__PURE__ */ i(B, { node: t }),
|
|
83
|
+
n === "close" && /* @__PURE__ */ i(
|
|
84
|
+
b,
|
|
85
|
+
{
|
|
86
|
+
title: a,
|
|
87
|
+
"aria-label": a,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
r("close");
|
|
90
|
+
},
|
|
91
|
+
children: /* @__PURE__ */ i(j, { node: t })
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
n === "minimize" && /* @__PURE__ */ i(
|
|
95
|
+
b,
|
|
96
|
+
{
|
|
97
|
+
title: a,
|
|
98
|
+
"aria-label": a,
|
|
99
|
+
onClick: () => {
|
|
100
|
+
r("minimize");
|
|
101
|
+
},
|
|
102
|
+
children: /* @__PURE__ */ i(q, { node: t })
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
) : null;
|
|
108
|
+
}, $ = c.div`
|
|
109
|
+
flex: 1;
|
|
110
|
+
max-width: ${(e) => e.size};
|
|
111
|
+
${(e) => e.squareRatio && `max-height: ${e.size};`}
|
|
112
|
+
text-align: center;
|
|
113
|
+
padding: 0 ${(e) => e.padding};
|
|
114
|
+
&& {
|
|
115
|
+
box-sizing: content-box;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
svg {
|
|
119
|
+
vertical-align: middle;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
i {
|
|
123
|
+
color: ${(e) => {
|
|
124
|
+
var t;
|
|
125
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
126
|
+
}};
|
|
127
|
+
font-size: ${(e) => e.size};
|
|
128
|
+
min-width: 1em;
|
|
129
|
+
min-height: 1em;
|
|
130
|
+
display: inline-block;
|
|
131
|
+
}
|
|
132
|
+
`, b = c.button`
|
|
133
|
+
${(e) => !!e.animationCss && e.animationCss};
|
|
134
|
+
background: none;
|
|
135
|
+
border: none;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
padding: 0;
|
|
138
|
+
&:focus-visible {
|
|
139
|
+
${z};
|
|
140
|
+
border-color: ${(e) => {
|
|
141
|
+
var t, r;
|
|
142
|
+
return (r = (t = e.theme.accessibility) == null ? void 0 : t.colors) == null ? void 0 : r.inactiveText;
|
|
143
|
+
}};
|
|
144
|
+
}
|
|
145
|
+
`, O = ({ className: e, ...t }) => {
|
|
146
|
+
const {
|
|
147
|
+
header: r,
|
|
148
|
+
tagline: s,
|
|
149
|
+
route: m,
|
|
150
|
+
tooltip: n = "",
|
|
151
|
+
actions: a = {},
|
|
152
|
+
textAlign: g = "center"
|
|
153
|
+
} = S(), [d, p] = A(a);
|
|
154
|
+
return d.sort((o, l) => (o.order || 0) - (l.order || 0)), p.sort((o, l) => (o.order || 0) - (l.order || 0)), /* @__PURE__ */ u(
|
|
155
|
+
L,
|
|
156
|
+
{
|
|
157
|
+
...t,
|
|
158
|
+
className: T(e, "humany-widget-header"),
|
|
159
|
+
children: [
|
|
160
|
+
d.map((o, l) => /* @__PURE__ */ i(x, { ...o }, `${o.type}+_${l}`)),
|
|
161
|
+
/* @__PURE__ */ u(
|
|
162
|
+
_,
|
|
163
|
+
{
|
|
164
|
+
textAlign: g,
|
|
165
|
+
margin: W(d, p, g),
|
|
166
|
+
children: [
|
|
167
|
+
m ? /* @__PURE__ */ i(D, { routeName: m, title: n, "aria-label": n, children: /* @__PURE__ */ i(f, { variant: "h1", children: r }) }) : /* @__PURE__ */ i(f, { variant: "h1", children: r }),
|
|
168
|
+
s && /* @__PURE__ */ i(R, { children: s })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
p.map((o, l) => /* @__PURE__ */ i(x, { ...o }, `${o.type}+_${l}`))
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}, L = c.div`
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: row;
|
|
179
|
+
align-items: center;
|
|
180
|
+
|
|
181
|
+
${(e) => {
|
|
182
|
+
var t, r;
|
|
183
|
+
return v(e)(
|
|
184
|
+
"h1",
|
|
185
|
+
y`
|
|
186
|
+
font-size: ${(t = e.theme.fonts) == null ? void 0 : t.huge};
|
|
187
|
+
margin: 0;
|
|
188
|
+
font-weight: 300;
|
|
189
|
+
color: ${(r = e.theme.colors) == null ? void 0 : r.text};
|
|
190
|
+
`
|
|
191
|
+
);
|
|
192
|
+
}}
|
|
193
|
+
|
|
194
|
+
p {
|
|
195
|
+
color: ${(e) => {
|
|
196
|
+
var t;
|
|
197
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
198
|
+
}};
|
|
199
|
+
margin: 0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
svg {
|
|
203
|
+
line,
|
|
204
|
+
path,
|
|
205
|
+
circle {
|
|
206
|
+
stroke: ${(e) => {
|
|
207
|
+
var t;
|
|
208
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
209
|
+
}};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
`, R = c.p`
|
|
213
|
+
font-size: ${(e) => {
|
|
214
|
+
var t;
|
|
215
|
+
return (t = e.theme.fonts) == null ? void 0 : t.normal;
|
|
216
|
+
}};
|
|
217
|
+
font-weight: 300;
|
|
218
|
+
`, _ = c.div`
|
|
219
|
+
flex: 1;
|
|
220
|
+
text-align: ${(e) => e.textAlign};
|
|
221
|
+
overflow: auto;
|
|
222
|
+
max-height: 100%;
|
|
223
|
+
margin-right: ${(e) => e.margin.right || 0};
|
|
224
|
+
margin-left: ${(e) => e.margin.left || 0};
|
|
225
|
+
`, D = c(w)`
|
|
226
|
+
text-decoration: none;
|
|
227
|
+
&:focus-visible {
|
|
228
|
+
${(e) => v(e)(
|
|
229
|
+
"h1",
|
|
230
|
+
y`
|
|
231
|
+
${C(e)}
|
|
232
|
+
display: inline-block;
|
|
233
|
+
`
|
|
234
|
+
)}
|
|
235
|
+
}
|
|
236
|
+
`;
|
|
237
|
+
export {
|
|
238
|
+
O as default
|
|
239
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),p=require("@emotion/react"),m=require("@emotion/styled"),r=require("@telia-ace/widget-ui"),$=require("@telia-ace/widget-utilities"),b=require("./index-cc8580b8.js");require("@telia-ace/widget-core");const f=({node:e})=>{if(!e.symbol)return null;let t;const s=e.symbol.type==="Svg";if(e.symbol.type==="Svg"){const o=parseInt(e.size,10);isNaN(o)||(t=o)}return i.jsx(j,{symbol:e.symbol,svg:s,size:t,backgroundSize:"cover"})},j=m(({svg:e,...t})=>i.jsx(r.SymbolBadge,{...t}))`
|
|
2
|
+
color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
3
|
+
${e=>!e.svg&&p.css`
|
|
4
|
+
border-radius: 50%;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
`}
|
|
7
|
+
`,z=({node:e})=>{const t=e.symbol||{type:"Svg",content:"back"};return i.jsx(r.SymbolBadge,{size:20,symbol:t})},k=({node:e})=>{const t=e.symbol||{type:"Svg",content:"close"},s=parseInt(e==null?void 0:e.size,10)||14;return i.jsx(r.SymbolBadge,{size:s,symbol:t})},S=({node:e})=>{const t=e.symbol||{type:"Svg",content:"minimize"},s=parseInt(e==null?void 0:e.size,10)||20;return i.jsx(r.SymbolBadge,{size:s,symbol:t})},y=({className:e="",...t})=>{const s=r.useDispatch(),{size:o,padding:g,type:a,tooltip:l,show:d=!0}=t;return a==="back"?i.jsx(v,{size:o||"64px",padding:g||"10px",children:i.jsx(r.TransitionComponent,{in:d,timeout:300,transitions:{enter:{type:"scale",easing:"cubic-bezier(.08,.84,.74,1.84)"},exit:{type:"scale",easing:"ease-out"}},children:(x,h)=>i.jsx(u,{"data-testid":"back-button",title:l,"aria-label":l,animationCss:h,onClick:()=>{s("back")},children:i.jsx(z,{node:t})})})}):d?i.jsxs(v,{size:o||"64px",padding:g||"10px",squareRatio:a==="avatar",children:[a==="avatar"&&i.jsx(f,{node:t}),a==="close"&&i.jsx(u,{title:l,"aria-label":l,onClick:()=>{s("close")},children:i.jsx(k,{node:t})}),a==="minimize"&&i.jsx(u,{title:l,"aria-label":l,onClick:()=>{s("minimize")},children:i.jsx(S,{node:t})})]}):null},v=m.div`
|
|
8
|
+
flex: 1;
|
|
9
|
+
max-width: ${e=>e.size};
|
|
10
|
+
${e=>e.squareRatio&&`max-height: ${e.size};`}
|
|
11
|
+
text-align: center;
|
|
12
|
+
padding: 0 ${e=>e.padding};
|
|
13
|
+
&& {
|
|
14
|
+
box-sizing: content-box;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
svg {
|
|
18
|
+
vertical-align: middle;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
i {
|
|
22
|
+
color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
23
|
+
font-size: ${e=>e.size};
|
|
24
|
+
min-width: 1em;
|
|
25
|
+
min-height: 1em;
|
|
26
|
+
display: inline-block;
|
|
27
|
+
}
|
|
28
|
+
`,u=m.button`
|
|
29
|
+
${e=>!!e.animationCss&&e.animationCss};
|
|
30
|
+
background: none;
|
|
31
|
+
border: none;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
padding: 0;
|
|
34
|
+
&:focus-visible {
|
|
35
|
+
${r.borderTabStyle};
|
|
36
|
+
border-color: ${e=>{var t,s;return(s=(t=e.theme.accessibility)==null?void 0:t.colors)==null?void 0:s.inactiveText}};
|
|
37
|
+
}
|
|
38
|
+
`,N=({className:e,...t})=>{const{header:s,tagline:o,route:g,tooltip:a="",actions:l={},textAlign:d="center"}=r.useProperties(),[x,h]=b.createNodes(l);return x.sort((n,c)=>(n.order||0)-(c.order||0)),h.sort((n,c)=>(n.order||0)-(c.order||0)),i.jsxs(w,{...t,className:$.appendClassNames(e,"humany-widget-header"),children:[x.map((n,c)=>i.jsx(y,{...n},`${n.type}+_${c}`)),i.jsxs(C,{textAlign:d,margin:b.calculateMargin(x,h,d),children:[g?i.jsx(T,{routeName:g,title:a,"aria-label":a,children:i.jsx(r.Typography,{variant:"h1",children:s})}):i.jsx(r.Typography,{variant:"h1",children:s}),o&&i.jsx(q,{children:o})]}),h.map((n,c)=>i.jsx(y,{...n},`${n.type}+_${c}`))]})},w=m.div`
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
align-items: center;
|
|
42
|
+
|
|
43
|
+
${e=>{var t,s;return r.headingElement(e)("h1",p.css`
|
|
44
|
+
font-size: ${(t=e.theme.fonts)==null?void 0:t.huge};
|
|
45
|
+
margin: 0;
|
|
46
|
+
font-weight: 300;
|
|
47
|
+
color: ${(s=e.theme.colors)==null?void 0:s.text};
|
|
48
|
+
`)}}
|
|
49
|
+
|
|
50
|
+
p {
|
|
51
|
+
color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
52
|
+
margin: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
svg {
|
|
56
|
+
line,
|
|
57
|
+
path,
|
|
58
|
+
circle {
|
|
59
|
+
stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`,q=m.p`
|
|
63
|
+
font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
|
|
64
|
+
font-weight: 300;
|
|
65
|
+
`,C=m.div`
|
|
66
|
+
flex: 1;
|
|
67
|
+
text-align: ${e=>e.textAlign};
|
|
68
|
+
overflow: auto;
|
|
69
|
+
max-height: 100%;
|
|
70
|
+
margin-right: ${e=>e.margin.right||0};
|
|
71
|
+
margin-left: ${e=>e.margin.left||0};
|
|
72
|
+
`,T=m(r.Link)`
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
&:focus-visible {
|
|
75
|
+
${e=>r.headingElement(e)("h1",p.css`
|
|
76
|
+
${r.linkTabStyle(e)}
|
|
77
|
+
display: inline-block;
|
|
78
|
+
`)}
|
|
79
|
+
}
|
|
80
|
+
`;exports.default=N;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
|
|
3
|
+
export type Symbol = {
|
|
4
|
+
type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
7
|
+
export type ActionNode = {
|
|
8
|
+
type: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
position?: 'right' | 'left';
|
|
11
|
+
symbol?: Symbol;
|
|
12
|
+
size: string;
|
|
13
|
+
padding: string;
|
|
14
|
+
tooltip?: string;
|
|
15
|
+
order?: number;
|
|
16
|
+
show?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type WidgetHeaderComponentProps = {
|
|
19
|
+
header: string;
|
|
20
|
+
tagline: string;
|
|
21
|
+
textAlign?: string;
|
|
22
|
+
actions?: {
|
|
23
|
+
[key: string]: ActionNode;
|
|
24
|
+
};
|
|
25
|
+
tooltip?: string;
|
|
26
|
+
tooltipBackLabel?: string;
|
|
27
|
+
tooltipMinimizeLabel?: string;
|
|
28
|
+
route?: string;
|
|
29
|
+
};
|
|
30
|
+
declare const WidgetHeaderComponent: (container: Container) => Promise<void>;
|
|
31
|
+
export default WidgetHeaderComponent;
|