@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 M, useEffect as T, useCallback as j, cloneElement as D } from "react";
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 R(e) {
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 s = [], r = 0; r < arguments.length; r++) {
18
- var o = arguments[r];
19
- if (o) {
20
- var p = typeof o;
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
- s.push(o);
23
- else if (Array.isArray(o)) {
24
- if (o.length) {
25
- var d = a.apply(null, o);
26
- d && s.push(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 (o.toString !== Object.prototype.toString && !o.toString.toString().includes("[native code]")) {
30
- s.push(o.toString());
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 o)
34
- t.call(o, u) && o[u] && s.push(u);
33
+ for (var u in s)
34
+ t.call(s, u) && s[u] && o.push(u);
35
35
  }
36
36
  }
37
37
  }
38
- return s.join(" ");
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 z = B.exports;
44
- const c = /* @__PURE__ */ R(z);
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
- ], H = v.linkFaded, P = v.caution, q = v.light, k = 2, w = 1, x = (e, t, a) => {
60
- var o, p;
61
- const s = ((p = (o = e == null ? void 0 : e.current) == null ? void 0 : o.getBoundingClientRect()) == null ? void 0 : p.width) || 0, r = s > t * k ? s / t : k;
62
- a(r);
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: s,
75
- segmentWidth: r,
76
- separatorColor: o
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 ${r - w}px,
90
- ${o} ${r - w}px,
91
- ${o} ${r}px
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: s, width: "100%" }
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
- r > 0 && /* @__PURE__ */ n(
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 = H,
134
- label: s,
135
- labelClassName: r,
136
- max: o,
137
- overColor: p = 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 = o || f, h = t.map((b) => b.value / m * 100), [F, N] = M(0);
143
- T(() => {
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
- s && /* @__PURE__ */ n(J, { label: s, labelClassName: r })
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: (s) => {
205
- t(!e), s.stopPropagation(), s.currentTarget.blur();
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, ...s }) => /* @__PURE__ */ n(e || "a", { className: c("p-panel__logo", a), ...s, children: /* @__PURE__ */ n("div", { className: "p-navigation__tagged-logo", children: t }) }), ie = ({ children: e }) => D(e, { className: "p-panel__logo-icon p-navigation__logo-icon" }), re = ({ children: e, variant: t = "base" }) => /* @__PURE__ */ n(
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 = ({ children: e, className: t, onClick: a }) => /* @__PURE__ */ n(S, { appearance: "base", className: c("p-side-navigation__button--menu has-icon is-dark", t), onClick: a, children: e }), de = ({ children: e }) => /* @__PURE__ */ n("span", { className: "p-side-navigation__text", children: e });
229
- const i = ({ 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 }) });
230
- i.Header = Z;
231
- i.Banner = K;
232
- i.Drawer = X;
233
- i.Controls = V;
234
- i.CollapseToggle = Q;
235
- i.Content = U;
236
- i.Footer = Y;
237
- i.List = oe;
238
- i.Item = te;
239
- i.Link = ae;
240
- i.Text = de;
241
- i.Icon = ee;
242
- i.Label = ne;
243
- i.Logo = se;
244
- i.LogoTag = le;
245
- i.LogoIcon = ie;
246
- i.LogoName = re;
247
- i.LogoText = ce;
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
- i as Navigation,
269
+ r as Navigation,
253
270
  me as NavigationBar,
254
- H as defaultEmptyColor,
271
+ z as defaultEmptyColor,
255
272
  _e as defaultFilledColors,
256
- P as defaultOverColor,
273
+ H as defaultOverColor,
257
274
  q as defaultSeparatorColor,
258
275
  v as meterColor,
259
276
  _ as testIds
@@ -1,11 +1,11 @@
1
- (function(r,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):(r=typeof globalThis<"u"?globalThis:r||self,a(r["@canonical/maas-react-components"]={},r["react/jsx-runtime"],r.React,r["@canonical/react-components"]))})(this,function(r,a,N,f){"use strict";function I(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w={exports:{}};/*!
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 l=[],i=0;i<arguments.length;i++){var o=arguments[i];if(o){var p=typeof o;if(p==="string"||p==="number")l.push(o);else if(Array.isArray(o)){if(o.length){var u=n.apply(null,o);u&&l.push(u)}}else if(p==="object"){if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]")){l.push(o.toString());continue}for(var _ in o)t.call(o,_)&&o[_]&&l.push(_)}}}return l.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,E=1,T=(e,t,n)=>{var o,p;const l=((p=(o=e==null?void 0:e.current)==null?void 0:o.getBoundingClientRect())==null?void 0:p.width)||0,i=l>t*B?l/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:l,segmentWidth:i,separatorColor:o})=>{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(
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-E}px,
9
- ${o} ${i-E}px,
10
- ${o} ${i}px
11
- )`});return a.jsxs(a.Fragment,{children:[p()?a.jsx("div",{className:"p-meter__filled","data-testid":m.meteroverflow,style:{backgroundColor:l,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:l,labelClassName:i,max:o,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=o||b,C=t.map(k=>k.value/v*100),[oe,L]=N.useState(0);N.useEffect(()=>{u&&T(d,v,L)},[v,u]);const se=N.useCallback(()=>{T(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:_})}),l&&a.jsx(j,{label:l,labelClassName:i})]})},W=({children:e,to:t,...n})=>a.jsx(f.Link,{...n,href:t,rel:"noreferrer noopener",target:"_blank",children:e}),q=({children:e})=>a.jsx(a.Fragment,{children:e}),A=({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:l=>{t(!e),l.stopPropagation(),l.currentTarget.blur()},children:a.jsx(f.Icon,{light:!0,name:"sidebar-toggle"})})}),P=({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,...l})=>{const i=e||"a";return a.jsx(i,{className:c("p-panel__logo",n),...l,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:n,children:e}),ne=({children:e})=>a.jsx("span",{className:"p-side-navigation__text",children:e}),ie="",s=({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})});s.Header=J,s.Banner=q,s.Drawer=H,s.Controls=z,s.CollapseToggle=A,s.Content=P,s.Footer=G,s.List=X,s.Item=Q,s.Link=V,s.Text=ne,s.Icon=K,s.Label=U,s.Logo=Y,s.LogoTag=ee,s.LogoIcon=Z,s.LogoName=R,s.LogoText=ae,$.MenuButton=te,r.ExternalLink=W,r.Meter=D,r.Navigation=s,r.NavigationBar=$,r.defaultEmptyColor=y,r.defaultFilledColors=x,r.defaultOverColor=S,r.defaultSeparatorColor=F,r.meterColor=g,r.testIds=m,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/maas-react-components",
3
3
  "description": "React components for use in MAAS UI projects.",
4
- "version": "1.4.0",
4
+ "version": "1.4.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/canonical/maas-react-components.git"