@canonical/maas-react-components 1.2.0 → 1.4.0

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.
Files changed (70) hide show
  1. package/README.md +12 -0
  2. package/dist/@canonical/maas-react-components.es.js +178 -107
  3. package/dist/@canonical/maas-react-components.umd.js +6 -6
  4. package/dist/src/lib/components/NestedFormGroup/NestedFormGroup.stories.d.ts +10 -1
  5. package/dist/src/lib/elements/Meter/Meter.d.ts +1 -0
  6. package/dist/src/lib/index.d.ts +1 -0
  7. package/dist/src/lib/sections/Navigation/Banner/Banner.d.ts +5 -0
  8. package/dist/src/lib/sections/Navigation/Banner/Banner.stories.d.ts +9 -0
  9. package/dist/src/lib/sections/Navigation/Banner/Banner.test.d.ts +1 -0
  10. package/dist/src/lib/sections/Navigation/CollapseToggle/CollapseToggle.d.ts +6 -0
  11. package/dist/src/lib/sections/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +10 -0
  12. package/dist/src/lib/sections/Navigation/CollapseToggle/CollapseToggle.test.d.ts +1 -0
  13. package/dist/src/lib/sections/Navigation/Content/Content.d.ts +5 -0
  14. package/dist/src/lib/sections/Navigation/Content/Content.stories.d.ts +9 -0
  15. package/dist/src/lib/sections/Navigation/Content/Content.test.d.ts +1 -0
  16. package/dist/src/lib/sections/Navigation/Controls/Controls.d.ts +5 -0
  17. package/dist/src/lib/sections/Navigation/Controls/Controls.stories.d.ts +9 -0
  18. package/dist/src/lib/sections/Navigation/Controls/Controls.test.d.ts +1 -0
  19. package/dist/src/lib/sections/Navigation/Drawer/Drawer.d.ts +5 -0
  20. package/dist/src/lib/sections/Navigation/Drawer/Drawer.stories.d.ts +9 -0
  21. package/dist/src/lib/sections/Navigation/Drawer/Drawer.test.d.ts +1 -0
  22. package/dist/src/lib/sections/Navigation/Footer/Footer.d.ts +5 -0
  23. package/dist/src/lib/sections/Navigation/Footer/Footer.stories.d.ts +9 -0
  24. package/dist/src/lib/sections/Navigation/Footer/Footer.test.d.ts +1 -0
  25. package/dist/src/lib/sections/Navigation/Header/Header.d.ts +5 -0
  26. package/dist/src/lib/sections/Navigation/Header/Header.stories.d.ts +9 -0
  27. package/dist/src/lib/sections/Navigation/Header/Header.test.d.ts +1 -0
  28. package/dist/src/lib/sections/Navigation/Icon/Icon.d.ts +5 -0
  29. package/dist/src/lib/sections/Navigation/Icon/Icon.stories.d.ts +9 -0
  30. package/dist/src/lib/sections/Navigation/Icon/Icon.test.d.ts +1 -0
  31. package/dist/src/lib/sections/Navigation/Item/Item.d.ts +7 -0
  32. package/dist/src/lib/sections/Navigation/Item/Item.stories.d.ts +16 -0
  33. package/dist/src/lib/sections/Navigation/Item/Item.test.d.ts +1 -0
  34. package/dist/src/lib/sections/Navigation/Label/Label.d.ts +7 -0
  35. package/dist/src/lib/sections/Navigation/Label/Label.stories.d.ts +10 -0
  36. package/dist/src/lib/sections/Navigation/Label/Label.test.d.ts +1 -0
  37. package/dist/src/lib/sections/Navigation/Link/Link.d.ts +5 -0
  38. package/dist/src/lib/sections/Navigation/Link/Link.stories.d.ts +20 -0
  39. package/dist/src/lib/sections/Navigation/Link/Link.test.d.ts +1 -0
  40. package/dist/src/lib/sections/Navigation/List/List.d.ts +6 -0
  41. package/dist/src/lib/sections/Navigation/List/List.stories.d.ts +9 -0
  42. package/dist/src/lib/sections/Navigation/List/List.test.d.ts +1 -0
  43. package/dist/src/lib/sections/Navigation/Logo/Logo.d.ts +6 -0
  44. package/dist/src/lib/sections/Navigation/Logo/Logo.stories.d.ts +9 -0
  45. package/dist/src/lib/sections/Navigation/Logo/Logo.test.d.ts +1 -0
  46. package/dist/src/lib/sections/Navigation/LogoIcon/LogoIcon.d.ts +5 -0
  47. package/dist/src/lib/sections/Navigation/LogoIcon/LogoIcon.stories.d.ts +9 -0
  48. package/dist/src/lib/sections/Navigation/LogoIcon/LogoIcon.test.d.ts +1 -0
  49. package/dist/src/lib/sections/Navigation/LogoName/LogoName.d.ts +6 -0
  50. package/dist/src/lib/sections/Navigation/LogoName/LogoName.stories.d.ts +16 -0
  51. package/dist/src/lib/sections/Navigation/LogoName/LogoName.test.d.ts +1 -0
  52. package/dist/src/lib/sections/Navigation/LogoTag/LogoTag.d.ts +5 -0
  53. package/dist/src/lib/sections/Navigation/LogoTag/LogoTag.stories.d.ts +9 -0
  54. package/dist/src/lib/sections/Navigation/LogoTag/LogoTag.test.d.ts +1 -0
  55. package/dist/src/lib/sections/Navigation/LogoText/LogoText.d.ts +5 -0
  56. package/dist/src/lib/sections/Navigation/LogoText/LogoText.test.d.ts +1 -0
  57. package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.d.ts +8 -0
  58. package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.stories.d.ts +10 -0
  59. package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.test.d.ts +1 -0
  60. package/dist/src/lib/sections/Navigation/Navigation.d.ts +35 -0
  61. package/dist/src/lib/sections/Navigation/Navigation.stories.d.ts +9 -0
  62. package/dist/src/lib/sections/Navigation/Navigation.test.d.ts +1 -0
  63. package/dist/src/lib/sections/Navigation/NavigationBar.test.d.ts +1 -0
  64. package/dist/src/lib/sections/Navigation/Text/Text.d.ts +5 -0
  65. package/dist/src/lib/sections/Navigation/Text/Text.test.d.ts +1 -0
  66. package/dist/src/lib/sections/Navigation/index.d.ts +1 -0
  67. package/dist/src/lib/sections/Navigation/types.d.ts +4 -0
  68. package/dist/src/lib/sections/index.d.ts +1 -0
  69. package/dist/style.css +1 -1
  70. package/package.json +10 -8
package/README.md CHANGED
@@ -62,3 +62,15 @@ To see the changes you make to `maas-react-components` reflected in a consuming
62
62
  ```
63
63
 
64
64
  4. As you make changes to `maas-react-components` they will be automatically built and reflected in the consuming app.
65
+
66
+ ### Creating a new component
67
+
68
+ Make sure to read our **[React Components Guidelines](GUIDELINES.md)** before you proceed.
69
+
70
+ Run the following command from the root of the project:
71
+
72
+ `npm run create-component`
73
+
74
+ The script will prompt you to enter details of the new component.
75
+
76
+ It will create a new directory and files based on the details you provided. New files will contain a basic setup for your new component, including a basic test and a storybook story.
@@ -1,10 +1,10 @@
1
- import { jsxs as _, jsx as d, Fragment as $ } from "react/jsx-runtime";
2
- import { useRef as E, useState as j, useEffect as O, useCallback as B } from "react";
3
- import { useListener as M, Link as D } from "@canonical/react-components";
4
- function L(e) {
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";
3
+ import { useListener as O, Link as W, Tooltip as A, Button as S, Icon as $ } from "@canonical/react-components";
4
+ function R(e) {
5
5
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
6
  }
7
- var y = { exports: {} };
7
+ var B = { exports: {} };
8
8
  /*!
9
9
  Copyright (c) 2018 Jed Watson.
10
10
  Licensed under the MIT License (MIT), see
@@ -12,37 +12,37 @@ var y = { exports: {} };
12
12
  */
13
13
  (function(e) {
14
14
  (function() {
15
- var r = {}.hasOwnProperty;
16
- function s() {
17
- for (var n = [], o = 0; o < arguments.length; o++) {
18
- var t = arguments[o];
19
- if (t) {
20
- var l = typeof t;
21
- if (l === "string" || l === "number")
22
- n.push(t);
23
- else if (Array.isArray(t)) {
24
- if (t.length) {
25
- var i = s.apply(null, t);
26
- i && n.push(i);
15
+ var t = {}.hasOwnProperty;
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;
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);
27
27
  }
28
- } else if (l === "object") {
29
- if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) {
30
- n.push(t.toString());
28
+ } else if (p === "object") {
29
+ if (o.toString !== Object.prototype.toString && !o.toString.toString().includes("[native code]")) {
30
+ s.push(o.toString());
31
31
  continue;
32
32
  }
33
- for (var u in t)
34
- r.call(t, u) && t[u] && n.push(u);
33
+ for (var u in o)
34
+ t.call(o, u) && o[u] && s.push(u);
35
35
  }
36
36
  }
37
37
  }
38
- return n.join(" ");
38
+ return s.join(" ");
39
39
  }
40
- e.exports ? (s.default = s, e.exports = s) : window.classNames = s;
40
+ e.exports ? (a.default = a, e.exports = a) : window.classNames = a;
41
41
  })();
42
- })(y);
43
- var W = y.exports;
44
- const k = /* @__PURE__ */ L(W);
45
- const f = {
42
+ })(B);
43
+ var z = B.exports;
44
+ const c = /* @__PURE__ */ R(z);
45
+ const v = {
46
46
  caution: "#F99B11",
47
47
  light: "#F7F7F7",
48
48
  linkFaded: "#D3E4ED",
@@ -51,139 +51,210 @@ const f = {
51
51
  positiveFaded: "#B7CCB9",
52
52
  positiveMid: "#4DAB4D",
53
53
  positive: "#0E8420"
54
- }, J = [
55
- f.link,
56
- f.positive,
57
- f.negative,
58
- f.caution
59
- ], A = f.linkFaded, R = f.caution, z = f.light, C = 2, w = 1, S = (e, r, s) => {
60
- var t, l;
61
- const n = ((l = (t = e == null ? void 0 : e.current) == null ? void 0 : t.getBoundingClientRect()) == null ? void 0 : l.width) || 0, o = n > r * C ? n / r : C;
62
- s(o);
63
- }, p = {
54
+ }, _e = [
55
+ v.link,
56
+ v.positive,
57
+ v.negative,
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);
63
+ }, _ = {
64
64
  bar: "meter-bar",
65
65
  container: "meter-container",
66
66
  filled: "meter-filled",
67
67
  label: "meter-label",
68
68
  meteroverflow: "meter-overflow",
69
69
  segments: "meter-segments"
70
- }, I = ({
70
+ }, G = ({
71
71
  data: e,
72
- datumWidths: r,
73
- maximum: s,
74
- overColor: n,
75
- segmentWidth: o,
76
- separatorColor: t
72
+ datumWidths: t,
73
+ maximum: a,
74
+ overColor: s,
75
+ segmentWidth: r,
76
+ separatorColor: o
77
77
  }) => {
78
- const l = () => e.reduce((m, a) => m + a.value, 0) > s, i = (m, a) => ({
79
- backgroundColor: m.color,
80
- left: `${r.reduce(
81
- (v, c, h) => a > h ? v + c : v,
78
+ const p = () => e.reduce((g, l) => g + l.value, 0) > a, d = (g, l) => ({
79
+ backgroundColor: g.color,
80
+ left: `${t.reduce(
81
+ (f, m, h) => l > h ? f + m : f,
82
82
  0
83
83
  )}%`,
84
- width: `${r[a]}%`
84
+ width: `${t[l]}%`
85
85
  }), u = () => ({
86
86
  background: `repeating-linear-gradient(
87
87
  to right,
88
88
  transparent 0,
89
- transparent ${o - w}px,
90
- ${t} ${o - w}px,
91
- ${t} ${o}px
89
+ transparent ${r - w}px,
90
+ ${o} ${r - w}px,
91
+ ${o} ${r}px
92
92
  )`
93
93
  });
94
- return /* @__PURE__ */ _($, { children: [
95
- l() ? /* @__PURE__ */ d(
94
+ return /* @__PURE__ */ C(L, { children: [
95
+ p() ? /* @__PURE__ */ n(
96
96
  "div",
97
97
  {
98
98
  className: "p-meter__filled",
99
- "data-testid": p.meteroverflow,
100
- style: { backgroundColor: n, width: "100%" }
99
+ "data-testid": _.meteroverflow,
100
+ style: { backgroundColor: s, width: "100%" }
101
101
  }
102
- ) : e.map((m, a) => /* @__PURE__ */ d(
102
+ ) : e.map((g, l) => /* @__PURE__ */ n(
103
103
  "div",
104
104
  {
105
105
  className: "p-meter__filled",
106
- "data-testid": p.filled,
107
- style: i(m, a)
106
+ "data-testid": _.filled,
107
+ style: d(g, l)
108
108
  },
109
- `meter-${a}`
109
+ `meter-${l}`
110
110
  )),
111
- o > 0 && /* @__PURE__ */ d(
111
+ r > 0 && /* @__PURE__ */ n(
112
112
  "div",
113
113
  {
114
114
  className: "p-meter__separators",
115
- "data-testid": p.segments,
115
+ "data-testid": _.segments,
116
116
  style: u()
117
117
  }
118
118
  )
119
119
  ] });
120
- }, P = ({
120
+ }, J = ({
121
121
  labelClassName: e,
122
- label: r
123
- }) => /* @__PURE__ */ d(
122
+ label: t
123
+ }) => /* @__PURE__ */ n(
124
124
  "div",
125
125
  {
126
- className: k("p-meter__label", e),
127
- "data-testid": p.label,
128
- children: r
126
+ className: c("p-meter__label", e),
127
+ "data-testid": _.label,
128
+ children: t
129
129
  }
130
- ), K = ({
130
+ ), fe = ({
131
131
  className: e,
132
- data: r,
133
- emptyColor: s = A,
134
- label: n,
135
- labelClassName: o,
136
- max: t,
137
- overColor: l = R,
138
- segmented: i = !1,
139
- separatorColor: u = z,
140
- small: m = !1
132
+ data: t,
133
+ emptyColor: a = H,
134
+ label: s,
135
+ labelClassName: r,
136
+ max: o,
137
+ overColor: p = P,
138
+ segmented: d = !1,
139
+ separatorColor: u = q,
140
+ small: g = !1
141
141
  }) => {
142
- const a = E(null), v = r.reduce((g, N) => g + N.value, 0), c = t || v, h = r.map((g) => g.value / c * 100), [F, b] = j(0);
143
- O(() => {
144
- i && S(a, c, b);
145
- }, [c, i]);
146
- const x = B(() => {
147
- S(a, c, b);
148
- }, [a, c, b]);
149
- return M(window, x, "resize", !0, i), /* @__PURE__ */ _(
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(() => {
144
+ d && x(l, m, N);
145
+ }, [m, d]);
146
+ const y = j(() => {
147
+ x(l, m, N);
148
+ }, [l, m, N]);
149
+ return O(window, y, "resize", !0, d), /* @__PURE__ */ C(
150
150
  "div",
151
151
  {
152
- className: k("p-meter", { "p-meter--small": m }, e),
153
- "data-testid": p.container,
154
- ref: a,
152
+ className: c("p-meter", { "p-meter--small": g }, e),
153
+ "data-testid": _.container,
154
+ ref: l,
155
155
  children: [
156
- /* @__PURE__ */ d(
156
+ /* @__PURE__ */ n(
157
157
  "div",
158
158
  {
159
159
  className: "p-meter__bar",
160
- "data-testid": p.bar,
161
- style: { backgroundColor: s },
162
- children: /* @__PURE__ */ d(
163
- I,
160
+ "data-testid": _.bar,
161
+ style: { backgroundColor: a },
162
+ children: /* @__PURE__ */ n(
163
+ G,
164
164
  {
165
- data: r,
165
+ data: t,
166
166
  datumWidths: h,
167
- maximum: c,
168
- overColor: l,
167
+ maximum: m,
168
+ overColor: p,
169
169
  segmentWidth: F,
170
170
  separatorColor: u
171
171
  }
172
172
  )
173
173
  }
174
174
  ),
175
- n && /* @__PURE__ */ d(P, { label: n, labelClassName: o })
175
+ s && /* @__PURE__ */ n(J, { label: s, labelClassName: r })
176
176
  ]
177
177
  }
178
178
  );
179
- }, Q = ({ children: e, to: r, ...s }) => /* @__PURE__ */ d(D, { ...s, href: r, rel: "noreferrer noopener", target: "_blank", children: e });
179
+ }, he = ({ children: e, to: t, ...a }) => /* @__PURE__ */ n(W, { ...a, href: t, rel: "noreferrer noopener", target: "_blank", children: e }), K = ({ children: e }) => /* @__PURE__ */ n(L, { children: e }), Q = ({
180
+ isCollapsed: e,
181
+ setIsCollapsed: t,
182
+ className: a
183
+ }) => /* @__PURE__ */ n(
184
+ A,
185
+ {
186
+ className: "p-side-navigation__tooltip-wrapper",
187
+ message: /* @__PURE__ */ C(L, { children: [
188
+ e ? "expand" : "collapse",
189
+ "( ",
190
+ /* @__PURE__ */ n("code", { children: "[" }),
191
+ " )"
192
+ ] }),
193
+ position: "right",
194
+ tooltipClassName: "p-side-navigation__tooltip",
195
+ children: /* @__PURE__ */ n(
196
+ S,
197
+ {
198
+ appearance: "base",
199
+ "aria-label": `${e ? "expand" : "collapse"} main navigation`,
200
+ className: c(
201
+ "is-dense has-icon is-dark u-no-margin l-navigation-collapse-toggle",
202
+ a
203
+ ),
204
+ onClick: (s) => {
205
+ t(!e), s.stopPropagation(), s.currentTarget.blur();
206
+ },
207
+ children: /* @__PURE__ */ n($, { light: !0, name: "sidebar-toggle" })
208
+ }
209
+ )
210
+ }
211
+ ), U = ({ children: e }) => /* @__PURE__ */ n("div", { className: "p-panel__content", children: /* @__PURE__ */ n("nav", { className: "p-side-navigation--icons is-dark", children: e }) }), V = ({ children: e }) => /* @__PURE__ */ n("div", { className: "p-panel__controls u-no-margin--top", children: e }), X = ({ children: e }) => /* @__PURE__ */ n("div", { className: "l-navigation__drawer", children: /* @__PURE__ */ n("div", { className: "p-panel is-dark", children: e }) }), Y = ({ children: e }) => /* @__PURE__ */ n("div", { className: "p-panel__footer", children: e }), Z = ({ children: e }) => /* @__PURE__ */ n("div", { className: "p-panel__header", children: e }), ee = ({ light: e = !0, name: t }) => /* @__PURE__ */ n($, { className: "p-side-navigation__icon", light: e, name: t }), te = ({ children: e, className: t, hasActiveChild: a }) => /* @__PURE__ */ n("li", { className: c("p-side-navigation__item", t, { "has-active-child": a }), children: e }), ne = ({ children: e, id: t, variant: a = "base" }) => /* @__PURE__ */ n("span", { className: c("p-side-navigation__label", { "p-side-navigation__label--group": a === "group" }), id: t, children: e }), ae = ({
212
+ as: e,
213
+ ...t
214
+ }) => /* @__PURE__ */ n(
215
+ e || "a",
216
+ {
217
+ className: c("p-side-navigation__link", t.className),
218
+ ...t
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(
221
+ "div",
222
+ {
223
+ className: c("p-panel__logo-name is-fading-when-collapsed", {
224
+ "p-panel__logo-name--small": t === "small"
225
+ }),
226
+ children: e
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;
248
+ me.MenuButton = pe;
180
249
  export {
181
- Q as ExternalLink,
182
- K as Meter,
183
- A as defaultEmptyColor,
184
- J as defaultFilledColors,
185
- R as defaultOverColor,
186
- z as defaultSeparatorColor,
187
- f as meterColor,
188
- p as testIds
250
+ he as ExternalLink,
251
+ fe as Meter,
252
+ i as Navigation,
253
+ me as NavigationBar,
254
+ H as defaultEmptyColor,
255
+ _e as defaultFilledColors,
256
+ P as defaultOverColor,
257
+ q as defaultSeparatorColor,
258
+ v as meterColor,
259
+ _ as testIds
189
260
  };
@@ -1,11 +1,11 @@
1
- (function(n,r){typeof exports=="object"&&typeof module<"u"?r(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"],r):(n=typeof globalThis<"u"?globalThis:n||self,r(n["@canonical/maas-react-components"]={},n["react/jsx-runtime"],n.React,n["@canonical/react-components"]))})(this,function(n,r,h,S){"use strict";function $(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w={exports:{}};/*!
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:{}};/*!
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 s={}.hasOwnProperty;function o(){for(var a=[],l=0;l<arguments.length;l++){var t=arguments[l];if(t){var c=typeof t;if(c==="string"||c==="number")a.push(t);else if(Array.isArray(t)){if(t.length){var u=o.apply(null,t);u&&a.push(u)}}else if(c==="object"){if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]")){a.push(t.toString());continue}for(var m in t)s.call(t,m)&&t[m]&&a.push(m)}}}return a.join(" ")}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(w);var M=w.exports;const _=$(M),I="",d={caution:"#F99B11",light:"#F7F7F7",linkFaded:"#D3E4ED",link:"#0066CC",negative:"#C7162B",positiveFaded:"#B7CCB9",positiveMid:"#4DAB4D",positive:"#0E8420"},B=[d.link,d.positive,d.negative,d.caution],k=d.linkFaded,F=d.caution,j=d.light,E=2,N=1,O=(e,s,o)=>{var t,c;const a=((c=(t=e==null?void 0:e.current)==null?void 0:t.getBoundingClientRect())==null?void 0:c.width)||0,l=a>s*E?a/s:E;o(l)},p={bar:"meter-bar",container:"meter-container",filled:"meter-filled",label:"meter-label",meteroverflow:"meter-overflow",segments:"meter-segments"},x=({data:e,datumWidths:s,maximum:o,overColor:a,segmentWidth:l,separatorColor:t})=>{const c=()=>e.reduce((v,i)=>v+i.value,0)>o,u=(v,i)=>({backgroundColor:v.color,left:`${s.reduce((b,f,C)=>i>C?b+f:b,0)}%`,width:`${s[i]}%`}),m=()=>({background:`repeating-linear-gradient(
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(
6
6
  to right,
7
7
  transparent 0,
8
- transparent ${l-N}px,
9
- ${t} ${l-N}px,
10
- ${t} ${l}px
11
- )`});return r.jsxs(r.Fragment,{children:[c()?r.jsx("div",{className:"p-meter__filled","data-testid":p.meteroverflow,style:{backgroundColor:a,width:"100%"}}):e.map((v,i)=>r.jsx("div",{className:"p-meter__filled","data-testid":p.filled,style:u(v,i)},`meter-${i}`)),l>0&&r.jsx("div",{className:"p-meter__separators","data-testid":p.segments,style:m()})]})},D=({labelClassName:e,label:s})=>r.jsx("div",{className:_("p-meter__label",e),"data-testid":p.label,children:s}),L=({className:e,data:s,emptyColor:o=k,label:a,labelClassName:l,max:t,overColor:c=F,segmented:u=!1,separatorColor:m=j,small:v=!1})=>{const i=h.useRef(null),b=s.reduce((y,z)=>y+z.value,0),f=t||b,C=s.map(y=>y.value/f*100),[q,g]=h.useState(0);h.useEffect(()=>{u&&O(i,f,g)},[f,u]);const A=h.useCallback(()=>{O(i,f,g)},[i,f,g]);return S.useListener(window,A,"resize",!0,u),r.jsxs("div",{className:_("p-meter",{"p-meter--small":v},e),"data-testid":p.container,ref:i,children:[r.jsx("div",{className:"p-meter__bar","data-testid":p.bar,style:{backgroundColor:o},children:r.jsx(x,{data:s,datumWidths:C,maximum:f,overColor:c,segmentWidth:q,separatorColor:m})}),a&&r.jsx(D,{label:a,labelClassName:l})]})},W=({children:e,to:s,...o})=>r.jsx(S.Link,{...o,href:s,rel:"noreferrer noopener",target:"_blank",children:e});n.ExternalLink=W,n.Meter=L,n.defaultEmptyColor=k,n.defaultFilledColors=B,n.defaultOverColor=F,n.defaultSeparatorColor=j,n.meterColor=d,n.testIds=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
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"})});
@@ -7,4 +7,13 @@ export declare const Example: {
7
7
  "aria-hidden": boolean;
8
8
  };
9
9
  };
10
- export declare const ControlledExample: () => import("react/jsx-runtime").JSX.Element;
10
+ export declare const ControlledExample: {
11
+ render: () => import("react/jsx-runtime").JSX.Element;
12
+ parameters: {
13
+ docs: {
14
+ source: {
15
+ code: null;
16
+ };
17
+ };
18
+ };
19
+ };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const meterColor: {
2
3
  readonly caution: "#F99B11";
3
4
  readonly light: "#F7F7F7";
@@ -1 +1,2 @@
1
1
  export * from "./elements";
2
+ export * from "./sections";
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ export interface NavigationBannerProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const Banner: ({ children }: NavigationBannerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Banner>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ children: import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ };
@@ -0,0 +1,6 @@
1
+ export interface NavigationCollapseToggleProps {
2
+ isCollapsed: boolean;
3
+ setIsCollapsed: (isCollapsed: boolean) => void;
4
+ className?: string;
5
+ }
6
+ export declare const CollapseToggle: ({ isCollapsed, setIsCollapsed, className, }: NavigationCollapseToggleProps) => JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.CollapseToggle>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ isCollapsed: boolean;
8
+ setIsCollapsed: () => void;
9
+ };
10
+ };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ export interface NavigationContentProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const Content: ({ children }: NavigationContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Content>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ children: import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ export interface NavigationPanelControlsProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const Controls: ({ children }: NavigationPanelControlsProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Controls>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ children: import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ export interface NavigationDrawerProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const Drawer: ({ children }: NavigationDrawerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Drawer>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ children: import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ export interface NavigationFooterProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const Footer: ({ children }: NavigationFooterProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Footer>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ children: import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ export interface NavigationHeaderProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const Header: ({ children }: NavigationHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Header>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ children: import("react/jsx-runtime").JSX.Element;
8
+ };
9
+ };
@@ -0,0 +1,5 @@
1
+ export interface NavigationIconProps {
2
+ light?: boolean;
3
+ name: string;
4
+ }
5
+ export declare const Icon: ({ light, name }: NavigationIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Navigation } from '../../../../lib/sections/Navigation/Navigation';
3
+ declare const meta: Meta<typeof Navigation.Icon>;
4
+ export default meta;
5
+ export declare const Example: {
6
+ args: {
7
+ name: string;
8
+ };
9
+ };