@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.
- package/README.md +12 -0
- package/dist/@canonical/maas-react-components.es.js +178 -107
- package/dist/@canonical/maas-react-components.umd.js +6 -6
- package/dist/src/lib/components/NestedFormGroup/NestedFormGroup.stories.d.ts +10 -1
- package/dist/src/lib/elements/Meter/Meter.d.ts +1 -0
- package/dist/src/lib/index.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Banner/Banner.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Banner/Banner.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Banner/Banner.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/CollapseToggle/CollapseToggle.d.ts +6 -0
- package/dist/src/lib/sections/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +10 -0
- package/dist/src/lib/sections/Navigation/CollapseToggle/CollapseToggle.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Content/Content.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Content/Content.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Content/Content.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Controls/Controls.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Controls/Controls.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Controls/Controls.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Drawer/Drawer.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Drawer/Drawer.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Drawer/Drawer.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Footer/Footer.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Footer/Footer.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Footer/Footer.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Header/Header.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Header/Header.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Header/Header.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Icon/Icon.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Icon/Icon.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Icon/Icon.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Item/Item.d.ts +7 -0
- package/dist/src/lib/sections/Navigation/Item/Item.stories.d.ts +16 -0
- package/dist/src/lib/sections/Navigation/Item/Item.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Label/Label.d.ts +7 -0
- package/dist/src/lib/sections/Navigation/Label/Label.stories.d.ts +10 -0
- package/dist/src/lib/sections/Navigation/Label/Label.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Link/Link.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Link/Link.stories.d.ts +20 -0
- package/dist/src/lib/sections/Navigation/Link/Link.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/List/List.d.ts +6 -0
- package/dist/src/lib/sections/Navigation/List/List.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/List/List.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Logo/Logo.d.ts +6 -0
- package/dist/src/lib/sections/Navigation/Logo/Logo.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Logo/Logo.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/LogoIcon/LogoIcon.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/LogoIcon/LogoIcon.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/LogoIcon/LogoIcon.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/LogoName/LogoName.d.ts +6 -0
- package/dist/src/lib/sections/Navigation/LogoName/LogoName.stories.d.ts +16 -0
- package/dist/src/lib/sections/Navigation/LogoName/LogoName.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/LogoTag/LogoTag.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/LogoTag/LogoTag.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/LogoTag/LogoTag.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/LogoText/LogoText.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/LogoText/LogoText.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.d.ts +8 -0
- package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.stories.d.ts +10 -0
- package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Navigation.d.ts +35 -0
- package/dist/src/lib/sections/Navigation/Navigation.stories.d.ts +9 -0
- package/dist/src/lib/sections/Navigation/Navigation.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/NavigationBar.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/Text/Text.d.ts +5 -0
- package/dist/src/lib/sections/Navigation/Text/Text.test.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/index.d.ts +1 -0
- package/dist/src/lib/sections/Navigation/types.d.ts +4 -0
- package/dist/src/lib/sections/index.d.ts +1 -0
- package/dist/style.css +1 -1
- 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
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useListener as
|
|
4
|
-
function
|
|
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
|
|
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
|
|
16
|
-
function
|
|
17
|
-
for (var
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
var
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
else if (Array.isArray(
|
|
24
|
-
if (
|
|
25
|
-
var
|
|
26
|
-
|
|
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 (
|
|
29
|
-
if (
|
|
30
|
-
|
|
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
|
|
34
|
-
|
|
33
|
+
for (var u in o)
|
|
34
|
+
t.call(o, u) && o[u] && s.push(u);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return s.join(" ");
|
|
39
39
|
}
|
|
40
|
-
e.exports ? (
|
|
40
|
+
e.exports ? (a.default = a, e.exports = a) : window.classNames = a;
|
|
41
41
|
})();
|
|
42
|
-
})(
|
|
43
|
-
var
|
|
44
|
-
const
|
|
45
|
-
const
|
|
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
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
],
|
|
60
|
-
var
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
},
|
|
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
|
-
},
|
|
70
|
+
}, G = ({
|
|
71
71
|
data: e,
|
|
72
|
-
datumWidths:
|
|
73
|
-
maximum:
|
|
74
|
-
overColor:
|
|
75
|
-
segmentWidth:
|
|
76
|
-
separatorColor:
|
|
72
|
+
datumWidths: t,
|
|
73
|
+
maximum: a,
|
|
74
|
+
overColor: s,
|
|
75
|
+
segmentWidth: r,
|
|
76
|
+
separatorColor: o
|
|
77
77
|
}) => {
|
|
78
|
-
const
|
|
79
|
-
backgroundColor:
|
|
80
|
-
left: `${
|
|
81
|
-
(
|
|
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: `${
|
|
84
|
+
width: `${t[l]}%`
|
|
85
85
|
}), u = () => ({
|
|
86
86
|
background: `repeating-linear-gradient(
|
|
87
87
|
to right,
|
|
88
88
|
transparent 0,
|
|
89
|
-
transparent ${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
89
|
+
transparent ${r - w}px,
|
|
90
|
+
${o} ${r - w}px,
|
|
91
|
+
${o} ${r}px
|
|
92
92
|
)`
|
|
93
93
|
});
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
|
|
94
|
+
return /* @__PURE__ */ C(L, { children: [
|
|
95
|
+
p() ? /* @__PURE__ */ n(
|
|
96
96
|
"div",
|
|
97
97
|
{
|
|
98
98
|
className: "p-meter__filled",
|
|
99
|
-
"data-testid":
|
|
100
|
-
style: { backgroundColor:
|
|
99
|
+
"data-testid": _.meteroverflow,
|
|
100
|
+
style: { backgroundColor: s, width: "100%" }
|
|
101
101
|
}
|
|
102
|
-
) : e.map((
|
|
102
|
+
) : e.map((g, l) => /* @__PURE__ */ n(
|
|
103
103
|
"div",
|
|
104
104
|
{
|
|
105
105
|
className: "p-meter__filled",
|
|
106
|
-
"data-testid":
|
|
107
|
-
style:
|
|
106
|
+
"data-testid": _.filled,
|
|
107
|
+
style: d(g, l)
|
|
108
108
|
},
|
|
109
|
-
`meter-${
|
|
109
|
+
`meter-${l}`
|
|
110
110
|
)),
|
|
111
|
-
|
|
111
|
+
r > 0 && /* @__PURE__ */ n(
|
|
112
112
|
"div",
|
|
113
113
|
{
|
|
114
114
|
className: "p-meter__separators",
|
|
115
|
-
"data-testid":
|
|
115
|
+
"data-testid": _.segments,
|
|
116
116
|
style: u()
|
|
117
117
|
}
|
|
118
118
|
)
|
|
119
119
|
] });
|
|
120
|
-
},
|
|
120
|
+
}, J = ({
|
|
121
121
|
labelClassName: e,
|
|
122
|
-
label:
|
|
123
|
-
}) => /* @__PURE__ */
|
|
122
|
+
label: t
|
|
123
|
+
}) => /* @__PURE__ */ n(
|
|
124
124
|
"div",
|
|
125
125
|
{
|
|
126
|
-
className:
|
|
127
|
-
"data-testid":
|
|
128
|
-
children:
|
|
126
|
+
className: c("p-meter__label", e),
|
|
127
|
+
"data-testid": _.label,
|
|
128
|
+
children: t
|
|
129
129
|
}
|
|
130
|
-
),
|
|
130
|
+
), fe = ({
|
|
131
131
|
className: e,
|
|
132
|
-
data:
|
|
133
|
-
emptyColor:
|
|
134
|
-
label:
|
|
135
|
-
labelClassName:
|
|
136
|
-
max:
|
|
137
|
-
overColor:
|
|
138
|
-
segmented:
|
|
139
|
-
separatorColor: u =
|
|
140
|
-
small:
|
|
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
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}, [
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
}, [
|
|
149
|
-
return
|
|
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:
|
|
153
|
-
"data-testid":
|
|
154
|
-
ref:
|
|
152
|
+
className: c("p-meter", { "p-meter--small": g }, e),
|
|
153
|
+
"data-testid": _.container,
|
|
154
|
+
ref: l,
|
|
155
155
|
children: [
|
|
156
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ n(
|
|
157
157
|
"div",
|
|
158
158
|
{
|
|
159
159
|
className: "p-meter__bar",
|
|
160
|
-
"data-testid":
|
|
161
|
-
style: { backgroundColor:
|
|
162
|
-
children: /* @__PURE__ */
|
|
163
|
-
|
|
160
|
+
"data-testid": _.bar,
|
|
161
|
+
style: { backgroundColor: a },
|
|
162
|
+
children: /* @__PURE__ */ n(
|
|
163
|
+
G,
|
|
164
164
|
{
|
|
165
|
-
data:
|
|
165
|
+
data: t,
|
|
166
166
|
datumWidths: h,
|
|
167
|
-
maximum:
|
|
168
|
-
overColor:
|
|
167
|
+
maximum: m,
|
|
168
|
+
overColor: p,
|
|
169
169
|
segmentWidth: F,
|
|
170
170
|
separatorColor: u
|
|
171
171
|
}
|
|
172
172
|
)
|
|
173
173
|
}
|
|
174
174
|
),
|
|
175
|
-
|
|
175
|
+
s && /* @__PURE__ */ n(J, { label: s, labelClassName: r })
|
|
176
176
|
]
|
|
177
177
|
}
|
|
178
178
|
);
|
|
179
|
-
},
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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(
|
|
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
|
|
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 ${
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
)`});return
|
|
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:
|
|
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
|
+
};
|
package/dist/src/lib/index.d.ts
CHANGED
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|