@canonical/maas-react-components 1.4.0 → 1.4.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as C, jsx as n, Fragment as L } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as I, useState as
|
|
2
|
+
import { useRef as I, useState as T, useEffect as M, useCallback as j, cloneElement as D } from "react";
|
|
3
3
|
import { useListener as O, Link as W, Tooltip as A, Button as S, Icon as $ } from "@canonical/react-components";
|
|
4
|
-
function
|
|
4
|
+
function P(e) {
|
|
5
5
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
6
6
|
}
|
|
7
7
|
var B = { exports: {} };
|
|
@@ -14,34 +14,34 @@ var B = { exports: {} };
|
|
|
14
14
|
(function() {
|
|
15
15
|
var t = {}.hasOwnProperty;
|
|
16
16
|
function a() {
|
|
17
|
-
for (var
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
var p = typeof
|
|
17
|
+
for (var o = [], i = 0; i < arguments.length; i++) {
|
|
18
|
+
var s = arguments[i];
|
|
19
|
+
if (s) {
|
|
20
|
+
var p = typeof s;
|
|
21
21
|
if (p === "string" || p === "number")
|
|
22
|
-
|
|
23
|
-
else if (Array.isArray(
|
|
24
|
-
if (
|
|
25
|
-
var d = a.apply(null,
|
|
26
|
-
d &&
|
|
22
|
+
o.push(s);
|
|
23
|
+
else if (Array.isArray(s)) {
|
|
24
|
+
if (s.length) {
|
|
25
|
+
var d = a.apply(null, s);
|
|
26
|
+
d && o.push(d);
|
|
27
27
|
}
|
|
28
28
|
} else if (p === "object") {
|
|
29
|
-
if (
|
|
30
|
-
|
|
29
|
+
if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]")) {
|
|
30
|
+
o.push(s.toString());
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
|
-
for (var u in
|
|
34
|
-
t.call(
|
|
33
|
+
for (var u in s)
|
|
34
|
+
t.call(s, u) && s[u] && o.push(u);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return o.join(" ");
|
|
39
39
|
}
|
|
40
40
|
e.exports ? (a.default = a, e.exports = a) : window.classNames = a;
|
|
41
41
|
})();
|
|
42
42
|
})(B);
|
|
43
|
-
var
|
|
44
|
-
const c = /* @__PURE__ */ R
|
|
43
|
+
var R = B.exports;
|
|
44
|
+
const c = /* @__PURE__ */ P(R);
|
|
45
45
|
const v = {
|
|
46
46
|
caution: "#F99B11",
|
|
47
47
|
light: "#F7F7F7",
|
|
@@ -56,10 +56,10 @@ const v = {
|
|
|
56
56
|
v.positive,
|
|
57
57
|
v.negative,
|
|
58
58
|
v.caution
|
|
59
|
-
],
|
|
60
|
-
var
|
|
61
|
-
const
|
|
62
|
-
a(
|
|
59
|
+
], z = v.linkFaded, H = v.caution, q = v.light, k = 2, w = 1, x = (e, t, a) => {
|
|
60
|
+
var s, p;
|
|
61
|
+
const o = ((p = (s = e == null ? void 0 : e.current) == null ? void 0 : s.getBoundingClientRect()) == null ? void 0 : p.width) || 0, i = o > t * k ? o / t : k;
|
|
62
|
+
a(i);
|
|
63
63
|
}, _ = {
|
|
64
64
|
bar: "meter-bar",
|
|
65
65
|
container: "meter-container",
|
|
@@ -71,9 +71,9 @@ const v = {
|
|
|
71
71
|
data: e,
|
|
72
72
|
datumWidths: t,
|
|
73
73
|
maximum: a,
|
|
74
|
-
overColor:
|
|
75
|
-
segmentWidth:
|
|
76
|
-
separatorColor:
|
|
74
|
+
overColor: o,
|
|
75
|
+
segmentWidth: i,
|
|
76
|
+
separatorColor: s
|
|
77
77
|
}) => {
|
|
78
78
|
const p = () => e.reduce((g, l) => g + l.value, 0) > a, d = (g, l) => ({
|
|
79
79
|
backgroundColor: g.color,
|
|
@@ -86,9 +86,9 @@ const v = {
|
|
|
86
86
|
background: `repeating-linear-gradient(
|
|
87
87
|
to right,
|
|
88
88
|
transparent 0,
|
|
89
|
-
transparent ${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
89
|
+
transparent ${i - w}px,
|
|
90
|
+
${s} ${i - w}px,
|
|
91
|
+
${s} ${i}px
|
|
92
92
|
)`
|
|
93
93
|
});
|
|
94
94
|
return /* @__PURE__ */ C(L, { children: [
|
|
@@ -97,7 +97,7 @@ const v = {
|
|
|
97
97
|
{
|
|
98
98
|
className: "p-meter__filled",
|
|
99
99
|
"data-testid": _.meteroverflow,
|
|
100
|
-
style: { backgroundColor:
|
|
100
|
+
style: { backgroundColor: o, width: "100%" }
|
|
101
101
|
}
|
|
102
102
|
) : e.map((g, l) => /* @__PURE__ */ n(
|
|
103
103
|
"div",
|
|
@@ -108,7 +108,7 @@ const v = {
|
|
|
108
108
|
},
|
|
109
109
|
`meter-${l}`
|
|
110
110
|
)),
|
|
111
|
-
|
|
111
|
+
i > 0 && /* @__PURE__ */ n(
|
|
112
112
|
"div",
|
|
113
113
|
{
|
|
114
114
|
className: "p-meter__separators",
|
|
@@ -130,17 +130,17 @@ const v = {
|
|
|
130
130
|
), fe = ({
|
|
131
131
|
className: e,
|
|
132
132
|
data: t,
|
|
133
|
-
emptyColor: a =
|
|
134
|
-
label:
|
|
135
|
-
labelClassName:
|
|
136
|
-
max:
|
|
137
|
-
overColor: p =
|
|
133
|
+
emptyColor: a = z,
|
|
134
|
+
label: o,
|
|
135
|
+
labelClassName: i,
|
|
136
|
+
max: s,
|
|
137
|
+
overColor: p = H,
|
|
138
138
|
segmented: d = !1,
|
|
139
139
|
separatorColor: u = q,
|
|
140
140
|
small: g = !1
|
|
141
141
|
}) => {
|
|
142
|
-
const l = I(null), f = t.reduce((b, E) => b + E.value, 0), m =
|
|
143
|
-
|
|
142
|
+
const l = I(null), f = t.reduce((b, E) => b + E.value, 0), m = s || f, h = t.map((b) => b.value / m * 100), [F, N] = T(0);
|
|
143
|
+
M(() => {
|
|
144
144
|
d && x(l, m, N);
|
|
145
145
|
}, [m, d]);
|
|
146
146
|
const y = j(() => {
|
|
@@ -172,7 +172,7 @@ const v = {
|
|
|
172
172
|
)
|
|
173
173
|
}
|
|
174
174
|
),
|
|
175
|
-
|
|
175
|
+
o && /* @__PURE__ */ n(J, { label: o, labelClassName: i })
|
|
176
176
|
]
|
|
177
177
|
}
|
|
178
178
|
);
|
|
@@ -201,8 +201,8 @@ const v = {
|
|
|
201
201
|
"is-dense has-icon is-dark u-no-margin l-navigation-collapse-toggle",
|
|
202
202
|
a
|
|
203
203
|
),
|
|
204
|
-
onClick: (
|
|
205
|
-
t(!e),
|
|
204
|
+
onClick: (o) => {
|
|
205
|
+
t(!e), o.stopPropagation(), o.currentTarget.blur();
|
|
206
206
|
},
|
|
207
207
|
children: /* @__PURE__ */ n($, { light: !0, name: "sidebar-toggle" })
|
|
208
208
|
}
|
|
@@ -217,7 +217,7 @@ const v = {
|
|
|
217
217
|
className: c("p-side-navigation__link", t.className),
|
|
218
218
|
...t
|
|
219
219
|
}
|
|
220
|
-
), oe = ({ children: e, className: t }) => /* @__PURE__ */ n("ul", { className: c("p-side-navigation__list", t), children: e }), se = ({ as: e, children: t, className: a, ...
|
|
220
|
+
), oe = ({ children: e, className: t }) => /* @__PURE__ */ n("ul", { className: c("p-side-navigation__list", t), children: e }), se = ({ as: e, children: t, className: a, ...o }) => /* @__PURE__ */ n(e || "a", { className: c("p-panel__logo", a), ...o, children: /* @__PURE__ */ n("div", { className: "p-navigation__tagged-logo", children: t }) }), re = ({ children: e }) => D(e, { className: "p-panel__logo-icon p-navigation__logo-icon" }), ie = ({ children: e, variant: t = "base" }) => /* @__PURE__ */ n(
|
|
221
221
|
"div",
|
|
222
222
|
{
|
|
223
223
|
className: c("p-panel__logo-name is-fading-when-collapsed", {
|
|
@@ -225,35 +225,52 @@ const v = {
|
|
|
225
225
|
}),
|
|
226
226
|
children: e
|
|
227
227
|
}
|
|
228
|
-
), le = ({ children: e }) => /* @__PURE__ */ n("div", { className: "p-navigation__logo-tag", children: e }), ce = ({ children: e }) => /* @__PURE__ */ n("span", { className: "p-panel__logo-text", children: e }), pe = ({
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
228
|
+
), le = ({ children: e }) => /* @__PURE__ */ n("div", { className: "p-navigation__logo-tag", children: e }), ce = ({ children: e }) => /* @__PURE__ */ n("span", { className: "p-panel__logo-text", children: e }), pe = ({
|
|
229
|
+
children: e,
|
|
230
|
+
className: t,
|
|
231
|
+
onClick: a
|
|
232
|
+
}) => /* @__PURE__ */ n(
|
|
233
|
+
S,
|
|
234
|
+
{
|
|
235
|
+
appearance: "base",
|
|
236
|
+
className: c(
|
|
237
|
+
"p-side-navigation__button--menu has-icon is-dark",
|
|
238
|
+
t
|
|
239
|
+
),
|
|
240
|
+
onClick: (o) => {
|
|
241
|
+
a && a(o), o.stopPropagation(), o.currentTarget.blur();
|
|
242
|
+
},
|
|
243
|
+
children: e
|
|
244
|
+
}
|
|
245
|
+
), de = ({ children: e }) => /* @__PURE__ */ n("span", { className: "p-side-navigation__text", children: e });
|
|
246
|
+
const r = ({ children: e, className: t, isCollapsed: a }) => /* @__PURE__ */ n("header", { "aria-label": "main navigation", className: c("l-navigation is-maas", t, { "is-collapsed": a, "is-pinned": !a }), children: e }), me = ({ children: e, className: t }) => /* @__PURE__ */ n("header", { "aria-label": "navigation", className: "l-navigation-bar", children: /* @__PURE__ */ n("div", { className: c("p-panel is-dark", t), children: e }) });
|
|
247
|
+
r.Header = Z;
|
|
248
|
+
r.Banner = K;
|
|
249
|
+
r.Drawer = X;
|
|
250
|
+
r.Controls = V;
|
|
251
|
+
r.CollapseToggle = Q;
|
|
252
|
+
r.Content = U;
|
|
253
|
+
r.Footer = Y;
|
|
254
|
+
r.List = oe;
|
|
255
|
+
r.Item = te;
|
|
256
|
+
r.Link = ae;
|
|
257
|
+
r.Text = de;
|
|
258
|
+
r.Icon = ee;
|
|
259
|
+
r.Label = ne;
|
|
260
|
+
r.Logo = se;
|
|
261
|
+
r.LogoTag = le;
|
|
262
|
+
r.LogoIcon = re;
|
|
263
|
+
r.LogoName = ie;
|
|
264
|
+
r.LogoText = ce;
|
|
248
265
|
me.MenuButton = pe;
|
|
249
266
|
export {
|
|
250
267
|
he as ExternalLink,
|
|
251
268
|
fe as Meter,
|
|
252
|
-
|
|
269
|
+
r as Navigation,
|
|
253
270
|
me as NavigationBar,
|
|
254
|
-
|
|
271
|
+
z as defaultEmptyColor,
|
|
255
272
|
_e as defaultFilledColors,
|
|
256
|
-
|
|
273
|
+
H as defaultOverColor,
|
|
257
274
|
q as defaultSeparatorColor,
|
|
258
275
|
v as meterColor,
|
|
259
276
|
_ as testIds
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react"),require("@canonical/react-components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@canonical/react-components"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l["@canonical/maas-react-components"]={},l["react/jsx-runtime"],l.React,l["@canonical/react-components"]))})(this,function(l,a,N,f){"use strict";function I(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w={exports:{}};/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var
|
|
5
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var o=[],i=0;i<arguments.length;i++){var s=arguments[i];if(s){var p=typeof s;if(p==="string"||p==="number")o.push(s);else if(Array.isArray(s)){if(s.length){var u=n.apply(null,s);u&&o.push(u)}}else if(p==="object"){if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]")){o.push(s.toString());continue}for(var _ in s)t.call(s,_)&&s[_]&&o.push(_)}}}return o.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(w);var M=w.exports;const c=I(M),le="",g={caution:"#F99B11",light:"#F7F7F7",linkFaded:"#D3E4ED",link:"#0066CC",negative:"#C7162B",positiveFaded:"#B7CCB9",positiveMid:"#4DAB4D",positive:"#0E8420"},x=[g.link,g.positive,g.negative,g.caution],y=g.linkFaded,S=g.caution,F=g.light,B=2,T=1,E=(e,t,n)=>{var s,p;const o=((p=(s=e==null?void 0:e.current)==null?void 0:s.getBoundingClientRect())==null?void 0:p.width)||0,i=o>t*B?o/t:B;n(i)},m={bar:"meter-bar",container:"meter-container",filled:"meter-filled",label:"meter-label",meteroverflow:"meter-overflow",segments:"meter-segments"},O=({data:e,datumWidths:t,maximum:n,overColor:o,segmentWidth:i,separatorColor:s})=>{const p=()=>e.reduce((h,d)=>h+d.value,0)>n,u=(h,d)=>({backgroundColor:h.color,left:`${t.reduce((b,v,C)=>d>C?b+v:b,0)}%`,width:`${t[d]}%`}),_=()=>({background:`repeating-linear-gradient(
|
|
6
6
|
to right,
|
|
7
7
|
transparent 0,
|
|
8
|
-
transparent ${i-
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
)`});return a.jsxs(a.Fragment,{children:[p()?a.jsx("div",{className:"p-meter__filled","data-testid":m.meteroverflow,style:{backgroundColor:
|
|
8
|
+
transparent ${i-T}px,
|
|
9
|
+
${s} ${i-T}px,
|
|
10
|
+
${s} ${i}px
|
|
11
|
+
)`});return a.jsxs(a.Fragment,{children:[p()?a.jsx("div",{className:"p-meter__filled","data-testid":m.meteroverflow,style:{backgroundColor:o,width:"100%"}}):e.map((h,d)=>a.jsx("div",{className:"p-meter__filled","data-testid":m.filled,style:u(h,d)},`meter-${d}`)),i>0&&a.jsx("div",{className:"p-meter__separators","data-testid":m.segments,style:_()})]})},j=({labelClassName:e,label:t})=>a.jsx("div",{className:c("p-meter__label",e),"data-testid":m.label,children:t}),D=({className:e,data:t,emptyColor:n=y,label:o,labelClassName:i,max:s,overColor:p=S,segmented:u=!1,separatorColor:_=F,small:h=!1})=>{const d=N.useRef(null),b=t.reduce((k,re)=>k+re.value,0),v=s||b,C=t.map(k=>k.value/v*100),[oe,L]=N.useState(0);N.useEffect(()=>{u&&E(d,v,L)},[v,u]);const se=N.useCallback(()=>{E(d,v,L)},[d,v,L]);return f.useListener(window,se,"resize",!0,u),a.jsxs("div",{className:c("p-meter",{"p-meter--small":h},e),"data-testid":m.container,ref:d,children:[a.jsx("div",{className:"p-meter__bar","data-testid":m.bar,style:{backgroundColor:n},children:a.jsx(O,{data:t,datumWidths:C,maximum:v,overColor:p,segmentWidth:oe,separatorColor:_})}),o&&a.jsx(j,{label:o,labelClassName:i})]})},P=({children:e,to:t,...n})=>a.jsx(f.Link,{...n,href:t,rel:"noreferrer noopener",target:"_blank",children:e}),W=({children:e})=>a.jsx(a.Fragment,{children:e}),q=({isCollapsed:e,setIsCollapsed:t,className:n})=>a.jsx(f.Tooltip,{className:"p-side-navigation__tooltip-wrapper",message:a.jsxs(a.Fragment,{children:[e?"expand":"collapse","( ",a.jsx("code",{children:"["})," )"]}),position:"right",tooltipClassName:"p-side-navigation__tooltip",children:a.jsx(f.Button,{appearance:"base","aria-label":`${e?"expand":"collapse"} main navigation`,className:c("is-dense has-icon is-dark u-no-margin l-navigation-collapse-toggle",n),onClick:o=>{t(!e),o.stopPropagation(),o.currentTarget.blur()},children:a.jsx(f.Icon,{light:!0,name:"sidebar-toggle"})})}),A=({children:e})=>a.jsx("div",{className:"p-panel__content",children:a.jsx("nav",{className:"p-side-navigation--icons is-dark",children:e})}),z=({children:e})=>a.jsx("div",{className:"p-panel__controls u-no-margin--top",children:e}),H=({children:e})=>a.jsx("div",{className:"l-navigation__drawer",children:a.jsx("div",{className:"p-panel is-dark",children:e})}),G=({children:e})=>a.jsx("div",{className:"p-panel__footer",children:e}),J=({children:e})=>a.jsx("div",{className:"p-panel__header",children:e}),K=({light:e=!0,name:t})=>a.jsx(f.Icon,{className:"p-side-navigation__icon",light:e,name:t}),Q=({children:e,className:t,hasActiveChild:n})=>a.jsx("li",{className:c("p-side-navigation__item",t,{"has-active-child":n}),children:e}),U=({children:e,id:t,variant:n="base"})=>a.jsx("span",{className:c("p-side-navigation__label",{"p-side-navigation__label--group":n==="group"}),id:t,children:e}),V=({as:e,...t})=>{const n=e||"a";return a.jsx(n,{className:c("p-side-navigation__link",t.className),...t})},X=({children:e,className:t})=>a.jsx("ul",{className:c("p-side-navigation__list",t),children:e}),Y=({as:e,children:t,className:n,...o})=>{const i=e||"a";return a.jsx(i,{className:c("p-panel__logo",n),...o,children:a.jsx("div",{className:"p-navigation__tagged-logo",children:t})})},Z=({children:e})=>N.cloneElement(e,{className:"p-panel__logo-icon p-navigation__logo-icon"}),R=({children:e,variant:t="base"})=>a.jsx("div",{className:c("p-panel__logo-name is-fading-when-collapsed",{"p-panel__logo-name--small":t==="small"}),children:e}),ee=({children:e})=>a.jsx("div",{className:"p-navigation__logo-tag",children:e}),ae=({children:e})=>a.jsx("span",{className:"p-panel__logo-text",children:e}),te=({children:e,className:t,onClick:n})=>a.jsx(f.Button,{appearance:"base",className:c("p-side-navigation__button--menu has-icon is-dark",t),onClick:o=>{n&&n(o),o.stopPropagation(),o.currentTarget.blur()},children:e}),ne=({children:e})=>a.jsx("span",{className:"p-side-navigation__text",children:e}),ie="",r=({children:e,className:t,isCollapsed:n})=>a.jsx("header",{"aria-label":"main navigation",className:c("l-navigation is-maas",t,{"is-collapsed":n,"is-pinned":!n}),children:e}),$=({children:e,className:t})=>a.jsx("header",{"aria-label":"navigation",className:"l-navigation-bar",children:a.jsx("div",{className:c("p-panel is-dark",t),children:e})});r.Header=J,r.Banner=W,r.Drawer=H,r.Controls=z,r.CollapseToggle=q,r.Content=A,r.Footer=G,r.List=X,r.Item=Q,r.Link=V,r.Text=ne,r.Icon=K,r.Label=U,r.Logo=Y,r.LogoTag=ee,r.LogoIcon=Z,r.LogoName=R,r.LogoText=ae,$.MenuButton=te,l.ExternalLink=P,l.Meter=D,l.Navigation=r,l.NavigationBar=$,l.defaultEmptyColor=y,l.defaultFilledColors=x,l.defaultOverColor=S,l.defaultSeparatorColor=F,l.meterColor=g,l.testIds=m,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -5,4 +5,4 @@ export interface NavigationMenuButtonProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
onClick: ButtonProps["onClick"];
|
|
7
7
|
}
|
|
8
|
-
export declare const MenuButton: ({ children, className, onClick }: NavigationMenuButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const MenuButton: ({ children, className, onClick, }: NavigationMenuButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -31,5 +31,5 @@ export interface NavigationBarProps {
|
|
|
31
31
|
}
|
|
32
32
|
export declare const NavigationBar: {
|
|
33
33
|
({ children, className }: NavigationBarProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
MenuButton: ({ children, className, onClick }: import("./MenuButton/MenuButton").NavigationMenuButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
MenuButton: ({ children, className, onClick, }: import("./MenuButton/MenuButton").NavigationMenuButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
35
|
};
|
package/package.json
CHANGED