@canonical/maas-react-components 1.4.0 → 1.5.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/dist/@canonical/maas-react-components.es.js +180 -166
- package/dist/@canonical/maas-react-components.umd.js +6 -6
- package/dist/src/lib/elements/Meter/Meter.d.ts +15 -15
- package/dist/src/lib/elements/Meter/Meter.stories.d.ts +19 -1
- package/dist/src/lib/sections/Navigation/MenuButton/MenuButton.d.ts +1 -1
- package/dist/src/lib/sections/Navigation/Navigation.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as I, useState as M, useEffect as T, useCallback as
|
|
3
|
-
import { useListener as
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as h, jsx as t, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as I, useState as M, useEffect as T, useCallback as E, cloneElement as j } from "react";
|
|
3
|
+
import { useListener as D, Link as O, Tooltip as A, Button as x, Icon as B } from "@canonical/react-components";
|
|
4
|
+
function P(e) {
|
|
5
5
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
6
6
|
}
|
|
7
|
-
var
|
|
7
|
+
var $ = { exports: {} };
|
|
8
8
|
/*!
|
|
9
9
|
Copyright (c) 2018 Jed Watson.
|
|
10
10
|
Licensed under the MIT License (MIT), see
|
|
@@ -12,37 +12,37 @@ var B = { exports: {} };
|
|
|
12
12
|
*/
|
|
13
13
|
(function(e) {
|
|
14
14
|
(function() {
|
|
15
|
-
var
|
|
15
|
+
var n = {}.hasOwnProperty;
|
|
16
16
|
function a() {
|
|
17
|
-
for (var
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
var
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
else if (Array.isArray(
|
|
24
|
-
if (
|
|
25
|
-
var
|
|
26
|
-
|
|
17
|
+
for (var o = [], i = 0; i < arguments.length; i++) {
|
|
18
|
+
var s = arguments[i];
|
|
19
|
+
if (s) {
|
|
20
|
+
var m = typeof s;
|
|
21
|
+
if (m === "string" || m === "number")
|
|
22
|
+
o.push(s);
|
|
23
|
+
else if (Array.isArray(s)) {
|
|
24
|
+
if (s.length) {
|
|
25
|
+
var l = a.apply(null, s);
|
|
26
|
+
l && o.push(l);
|
|
27
27
|
}
|
|
28
|
-
} else if (
|
|
29
|
-
if (
|
|
30
|
-
|
|
28
|
+
} else if (m === "object") {
|
|
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
|
|
34
|
-
|
|
33
|
+
for (var c in s)
|
|
34
|
+
n.call(s, c) && s[c] && o.push(c);
|
|
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
|
-
})(
|
|
43
|
-
var
|
|
44
|
-
const
|
|
45
|
-
const
|
|
42
|
+
})($);
|
|
43
|
+
var R = $.exports;
|
|
44
|
+
const p = /* @__PURE__ */ P(R);
|
|
45
|
+
const u = {
|
|
46
46
|
caution: "#F99B11",
|
|
47
47
|
light: "#F7F7F7",
|
|
48
48
|
linkFaded: "#D3E4ED",
|
|
@@ -51,210 +51,224 @@ const v = {
|
|
|
51
51
|
positiveFaded: "#B7CCB9",
|
|
52
52
|
positiveMid: "#4DAB4D",
|
|
53
53
|
positive: "#0E8420"
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
],
|
|
60
|
-
var
|
|
61
|
-
const
|
|
62
|
-
a
|
|
63
|
-
},
|
|
54
|
+
}, ve = [
|
|
55
|
+
u.link,
|
|
56
|
+
u.positive,
|
|
57
|
+
u.negative,
|
|
58
|
+
u.caution
|
|
59
|
+
], z = u.linkFaded, F = u.caution, b = u.light, L = 2, k = 1, w = (e, n) => {
|
|
60
|
+
var i, s;
|
|
61
|
+
const a = ((s = (i = e == null ? void 0 : e.current) == null ? void 0 : i.getBoundingClientRect()) == null ? void 0 : s.width) || 0;
|
|
62
|
+
return a > n * L ? a / n : L;
|
|
63
|
+
}, d = {
|
|
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
|
+
}, H = ({
|
|
71
|
+
className: e,
|
|
72
|
+
children: n,
|
|
73
|
+
data: a,
|
|
74
|
+
max: o,
|
|
75
|
+
variant: i = "regular",
|
|
76
|
+
size: s = "regular",
|
|
77
|
+
...m
|
|
78
|
+
}) => {
|
|
79
|
+
const l = I(null), c = a == null ? void 0 : a.reduce((N, y) => N + y.value, 0), g = o || c, _ = a.map((N) => N.value / g * 100), [f, v] = M(0);
|
|
80
|
+
T(() => {
|
|
81
|
+
v(i === "segmented" ? w(l, g) : 0);
|
|
82
|
+
}, [g, i]);
|
|
83
|
+
const S = E(() => {
|
|
84
|
+
v(w(l, g));
|
|
85
|
+
}, [l, g, v]);
|
|
86
|
+
return D(window, S, "resize", !0, i === "segmented"), /* @__PURE__ */ h(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
className: p("p-meter", e, {
|
|
90
|
+
"p-meter--small": s === "small"
|
|
91
|
+
}),
|
|
92
|
+
"aria-label": m == null ? void 0 : m["aria-label"],
|
|
93
|
+
"data-testid": d.container,
|
|
94
|
+
ref: l,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ t(W, { children: /* @__PURE__ */ t(
|
|
97
|
+
q,
|
|
98
|
+
{
|
|
99
|
+
data: a,
|
|
100
|
+
datumWidths: _,
|
|
101
|
+
maximum: g,
|
|
102
|
+
overColor: F,
|
|
103
|
+
segmentWidth: f,
|
|
104
|
+
separatorColor: b
|
|
105
|
+
}
|
|
106
|
+
) }),
|
|
107
|
+
n
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}, W = ({ children: e }) => /* @__PURE__ */ t(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
className: "p-meter__bar",
|
|
115
|
+
"data-testid": d.bar,
|
|
116
|
+
style: { backgroundColor: z },
|
|
117
|
+
children: e
|
|
118
|
+
}
|
|
119
|
+
), q = ({
|
|
71
120
|
data: e,
|
|
72
|
-
datumWidths:
|
|
121
|
+
datumWidths: n,
|
|
73
122
|
maximum: a,
|
|
74
|
-
|
|
75
|
-
segmentWidth: r,
|
|
76
|
-
separatorColor: o
|
|
123
|
+
segmentWidth: o
|
|
77
124
|
}) => {
|
|
78
|
-
const
|
|
79
|
-
backgroundColor:
|
|
80
|
-
left: `${
|
|
81
|
-
(
|
|
125
|
+
const i = () => (e == null ? void 0 : e.reduce((l, c) => l + c.value, 0)) > a, s = (l, c) => ({
|
|
126
|
+
backgroundColor: l.color,
|
|
127
|
+
left: `${n == null ? void 0 : n.reduce(
|
|
128
|
+
(g, _, f) => c > f ? g + _ : g,
|
|
82
129
|
0
|
|
83
130
|
)}%`,
|
|
84
|
-
width: `${
|
|
85
|
-
}),
|
|
131
|
+
width: `${n[c]}%`
|
|
132
|
+
}), m = () => ({
|
|
86
133
|
background: `repeating-linear-gradient(
|
|
87
134
|
to right,
|
|
88
135
|
transparent 0,
|
|
89
|
-
transparent ${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
136
|
+
transparent ${o - k}px,
|
|
137
|
+
${b} ${o - k}px,
|
|
138
|
+
${b} ${o}px
|
|
92
139
|
)`
|
|
93
140
|
});
|
|
94
|
-
return /* @__PURE__ */ C
|
|
95
|
-
|
|
141
|
+
return /* @__PURE__ */ h(C, { children: [
|
|
142
|
+
i() ? /* @__PURE__ */ t(
|
|
96
143
|
"div",
|
|
97
144
|
{
|
|
98
145
|
className: "p-meter__filled",
|
|
99
|
-
"data-testid":
|
|
100
|
-
style: { backgroundColor:
|
|
146
|
+
"data-testid": d.meteroverflow,
|
|
147
|
+
style: { backgroundColor: F, width: "100%" }
|
|
101
148
|
}
|
|
102
|
-
) : e.map((
|
|
149
|
+
) : e == null ? void 0 : e.map((l, c) => /* @__PURE__ */ t(
|
|
103
150
|
"div",
|
|
104
151
|
{
|
|
105
152
|
className: "p-meter__filled",
|
|
106
|
-
"data-testid":
|
|
107
|
-
style:
|
|
153
|
+
"data-testid": d.filled,
|
|
154
|
+
style: s(l, c)
|
|
108
155
|
},
|
|
109
|
-
`meter-${
|
|
156
|
+
`meter-${c}`
|
|
110
157
|
)),
|
|
111
|
-
|
|
158
|
+
o > 0 && /* @__PURE__ */ t(
|
|
112
159
|
"div",
|
|
113
160
|
{
|
|
114
161
|
className: "p-meter__separators",
|
|
115
|
-
"data-testid":
|
|
116
|
-
style:
|
|
162
|
+
"data-testid": d.segments,
|
|
163
|
+
style: m()
|
|
117
164
|
}
|
|
118
165
|
)
|
|
119
166
|
] });
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}) => /* @__PURE__ */
|
|
167
|
+
}, G = ({
|
|
168
|
+
className: e,
|
|
169
|
+
children: n
|
|
170
|
+
}) => /* @__PURE__ */ t(
|
|
124
171
|
"div",
|
|
125
172
|
{
|
|
126
|
-
className:
|
|
127
|
-
"data-testid":
|
|
128
|
-
children:
|
|
173
|
+
className: p("p-meter__label", e),
|
|
174
|
+
"data-testid": d.label,
|
|
175
|
+
children: n
|
|
129
176
|
}
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
}) => {
|
|
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
|
-
"div",
|
|
151
|
-
{
|
|
152
|
-
className: c("p-meter", { "p-meter--small": g }, e),
|
|
153
|
-
"data-testid": _.container,
|
|
154
|
-
ref: l,
|
|
155
|
-
children: [
|
|
156
|
-
/* @__PURE__ */ n(
|
|
157
|
-
"div",
|
|
158
|
-
{
|
|
159
|
-
className: "p-meter__bar",
|
|
160
|
-
"data-testid": _.bar,
|
|
161
|
-
style: { backgroundColor: a },
|
|
162
|
-
children: /* @__PURE__ */ n(
|
|
163
|
-
G,
|
|
164
|
-
{
|
|
165
|
-
data: t,
|
|
166
|
-
datumWidths: h,
|
|
167
|
-
maximum: m,
|
|
168
|
-
overColor: p,
|
|
169
|
-
segmentWidth: F,
|
|
170
|
-
separatorColor: u
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
),
|
|
175
|
-
s && /* @__PURE__ */ n(J, { label: s, labelClassName: r })
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
);
|
|
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 = ({
|
|
177
|
+
);
|
|
178
|
+
H.Label = G;
|
|
179
|
+
const _e = ({ children: e, to: n, ...a }) => /* @__PURE__ */ t(O, { ...a, href: n, rel: "noreferrer noopener", target: "_blank", children: e }), J = ({ children: e }) => /* @__PURE__ */ t(C, { children: e }), K = ({
|
|
180
180
|
isCollapsed: e,
|
|
181
|
-
setIsCollapsed:
|
|
181
|
+
setIsCollapsed: n,
|
|
182
182
|
className: a
|
|
183
|
-
}) => /* @__PURE__ */
|
|
183
|
+
}) => /* @__PURE__ */ t(
|
|
184
184
|
A,
|
|
185
185
|
{
|
|
186
186
|
className: "p-side-navigation__tooltip-wrapper",
|
|
187
|
-
message: /* @__PURE__ */ C
|
|
187
|
+
message: /* @__PURE__ */ h(C, { children: [
|
|
188
188
|
e ? "expand" : "collapse",
|
|
189
189
|
"( ",
|
|
190
|
-
/* @__PURE__ */
|
|
190
|
+
/* @__PURE__ */ t("code", { children: "[" }),
|
|
191
191
|
" )"
|
|
192
192
|
] }),
|
|
193
193
|
position: "right",
|
|
194
194
|
tooltipClassName: "p-side-navigation__tooltip",
|
|
195
|
-
children: /* @__PURE__ */
|
|
196
|
-
|
|
195
|
+
children: /* @__PURE__ */ t(
|
|
196
|
+
x,
|
|
197
197
|
{
|
|
198
198
|
appearance: "base",
|
|
199
199
|
"aria-label": `${e ? "expand" : "collapse"} main navigation`,
|
|
200
|
-
className:
|
|
200
|
+
className: p(
|
|
201
201
|
"is-dense has-icon is-dark u-no-margin l-navigation-collapse-toggle",
|
|
202
202
|
a
|
|
203
203
|
),
|
|
204
|
-
onClick: (
|
|
205
|
-
|
|
204
|
+
onClick: (o) => {
|
|
205
|
+
n(!e), o.stopPropagation(), o.currentTarget.blur();
|
|
206
206
|
},
|
|
207
|
-
children: /* @__PURE__ */
|
|
207
|
+
children: /* @__PURE__ */ t(B, { light: !0, name: "sidebar-toggle" })
|
|
208
208
|
}
|
|
209
209
|
)
|
|
210
210
|
}
|
|
211
|
-
),
|
|
211
|
+
), Q = ({ children: e }) => /* @__PURE__ */ t("div", { className: "p-panel__content", children: /* @__PURE__ */ t("nav", { className: "p-side-navigation--icons is-dark", children: e }) }), U = ({ children: e }) => /* @__PURE__ */ t("div", { className: "p-panel__controls u-no-margin--top", children: e }), V = ({ children: e }) => /* @__PURE__ */ t("div", { className: "l-navigation__drawer", children: /* @__PURE__ */ t("div", { className: "p-panel is-dark", children: e }) }), X = ({ children: e }) => /* @__PURE__ */ t("div", { className: "p-panel__footer", children: e }), Y = ({ children: e }) => /* @__PURE__ */ t("div", { className: "p-panel__header", children: e }), Z = ({ light: e = !0, name: n }) => /* @__PURE__ */ t(B, { className: "p-side-navigation__icon", light: e, name: n }), ee = ({ children: e, className: n, hasActiveChild: a }) => /* @__PURE__ */ t("li", { className: p("p-side-navigation__item", n, { "has-active-child": a }), children: e }), ne = ({ children: e, id: n, variant: a = "base" }) => /* @__PURE__ */ t("span", { className: p("p-side-navigation__label", { "p-side-navigation__label--group": a === "group" }), id: n, children: e }), te = ({
|
|
212
212
|
as: e,
|
|
213
|
-
...
|
|
214
|
-
}) => /* @__PURE__ */
|
|
213
|
+
...n
|
|
214
|
+
}) => /* @__PURE__ */ t(
|
|
215
215
|
e || "a",
|
|
216
216
|
{
|
|
217
|
-
className:
|
|
218
|
-
...
|
|
217
|
+
className: p("p-side-navigation__link", n.className),
|
|
218
|
+
...n
|
|
219
219
|
}
|
|
220
|
-
),
|
|
220
|
+
), ae = ({ children: e, className: n }) => /* @__PURE__ */ t("ul", { className: p("p-side-navigation__list", n), children: e }), oe = ({ as: e, children: n, className: a, ...o }) => /* @__PURE__ */ t(e || "a", { className: p("p-panel__logo", a), ...o, children: /* @__PURE__ */ t("div", { className: "p-navigation__tagged-logo", children: n }) }), se = ({ children: e }) => j(e, { className: "p-panel__logo-icon p-navigation__logo-icon" }), re = ({ children: e, variant: n = "base" }) => /* @__PURE__ */ t(
|
|
221
221
|
"div",
|
|
222
222
|
{
|
|
223
|
-
className:
|
|
224
|
-
"p-panel__logo-name--small":
|
|
223
|
+
className: p("p-panel__logo-name is-fading-when-collapsed", {
|
|
224
|
+
"p-panel__logo-name--small": n === "small"
|
|
225
225
|
}),
|
|
226
226
|
children: e
|
|
227
227
|
}
|
|
228
|
-
),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
228
|
+
), ie = ({ children: e }) => /* @__PURE__ */ t("div", { className: "p-navigation__logo-tag", children: e }), le = ({ children: e }) => /* @__PURE__ */ t("span", { className: "p-panel__logo-text", children: e }), ce = ({
|
|
229
|
+
children: e,
|
|
230
|
+
className: n,
|
|
231
|
+
onClick: a
|
|
232
|
+
}) => /* @__PURE__ */ t(
|
|
233
|
+
x,
|
|
234
|
+
{
|
|
235
|
+
appearance: "base",
|
|
236
|
+
className: p(
|
|
237
|
+
"p-side-navigation__button--menu has-icon is-dark",
|
|
238
|
+
n
|
|
239
|
+
),
|
|
240
|
+
onClick: (o) => {
|
|
241
|
+
a && a(o), o.stopPropagation(), o.currentTarget.blur();
|
|
242
|
+
},
|
|
243
|
+
children: e
|
|
244
|
+
}
|
|
245
|
+
), pe = ({ children: e }) => /* @__PURE__ */ t("span", { className: "p-side-navigation__text", children: e });
|
|
246
|
+
const r = ({ children: e, className: n, isCollapsed: a }) => /* @__PURE__ */ t("header", { "aria-label": "main navigation", className: p("l-navigation is-maas", n, { "is-collapsed": a, "is-pinned": !a }), children: e }), me = ({ children: e, className: n }) => /* @__PURE__ */ t("header", { "aria-label": "navigation", className: "l-navigation-bar", children: /* @__PURE__ */ t("div", { className: p("p-panel is-dark", n), children: e }) });
|
|
247
|
+
r.Header = Y;
|
|
248
|
+
r.Banner = J;
|
|
249
|
+
r.Drawer = V;
|
|
250
|
+
r.Controls = U;
|
|
251
|
+
r.CollapseToggle = K;
|
|
252
|
+
r.Content = Q;
|
|
253
|
+
r.Footer = X;
|
|
254
|
+
r.List = ae;
|
|
255
|
+
r.Item = ee;
|
|
256
|
+
r.Link = te;
|
|
257
|
+
r.Text = pe;
|
|
258
|
+
r.Icon = Z;
|
|
259
|
+
r.Label = ne;
|
|
260
|
+
r.Logo = oe;
|
|
261
|
+
r.LogoTag = ie;
|
|
262
|
+
r.LogoIcon = se;
|
|
263
|
+
r.LogoName = re;
|
|
264
|
+
r.LogoText = le;
|
|
265
|
+
me.MenuButton = ce;
|
|
249
266
|
export {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
267
|
+
_e as ExternalLink,
|
|
268
|
+
H as Meter,
|
|
269
|
+
r as Navigation,
|
|
253
270
|
me as NavigationBar,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
q as defaultSeparatorColor,
|
|
258
|
-
v as meterColor,
|
|
259
|
-
_ as testIds
|
|
271
|
+
ve as defaultFilledColors,
|
|
272
|
+
u as meterColor,
|
|
273
|
+
d as testIds
|
|
260
274
|
};
|
|
@@ -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,f,m){"use strict";function T(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 n={}.hasOwnProperty;function t(){for(var o=[],i=0;i<arguments.length;i++){var r=arguments[i];if(r){var g=typeof r;if(g==="string"||g==="number")o.push(r);else if(Array.isArray(r)){if(r.length){var c=t.apply(null,r);c&&o.push(c)}}else if(g==="object"){if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]")){o.push(r.toString());continue}for(var d in r)n.call(r,d)&&r[d]&&o.push(d)}}}return o.join(" ")}e.exports?(t.default=t,e.exports=t):window.classNames=t})()})(w);var M=w.exports;const p=T(M),se="",v={caution:"#F99B11",light:"#F7F7F7",linkFaded:"#D3E4ED",link:"#0066CC",negative:"#C7162B",positiveFaded:"#B7CCB9",positiveMid:"#4DAB4D",positive:"#0E8420"},$=[v.link,v.positive,v.negative,v.caution],I=v.linkFaded,C=v.caution,h=v.light,y=2,B=1,F=(e,n)=>{var i,r;const t=((r=(i=e==null?void 0:e.current)==null?void 0:i.getBoundingClientRect())==null?void 0:r.width)||0;return t>n*y?t/n:y},_={bar:"meter-bar",container:"meter-container",filled:"meter-filled",label:"meter-label",meteroverflow:"meter-overflow",segments:"meter-segments"},S=({className:e,children:n,data:t,max:o,variant:i="regular",size:r="regular",...g})=>{const c=f.useRef(null),d=t==null?void 0:t.reduce((k,oe)=>k+oe.value,0),u=o||d,b=t.map(k=>k.value/u*100),[L,N]=f.useState(0);f.useEffect(()=>{N(i==="segmented"?F(c,u):0)},[u,i]);const te=f.useCallback(()=>{N(F(c,u))},[c,u,N]);return m.useListener(window,te,"resize",!0,i==="segmented"),a.jsxs("div",{className:p("p-meter",e,{"p-meter--small":r==="small"}),"aria-label":g==null?void 0:g["aria-label"],"data-testid":_.container,ref:c,children:[a.jsx(E,{children:a.jsx(j,{data:t,datumWidths:b,maximum:u,overColor:C,segmentWidth:L,separatorColor:h})}),n]})},E=({children:e})=>a.jsx("div",{className:"p-meter__bar","data-testid":_.bar,style:{backgroundColor:I},children:e}),j=({data:e,datumWidths:n,maximum:t,segmentWidth:o})=>{const i=()=>(e==null?void 0:e.reduce((c,d)=>c+d.value,0))>t,r=(c,d)=>({backgroundColor:c.color,left:`${n==null?void 0:n.reduce((u,b,L)=>d>L?u+b:u,0)}%`,width:`${n[d]}%`}),g=()=>({background:`repeating-linear-gradient(
|
|
6
6
|
to right,
|
|
7
7
|
transparent 0,
|
|
8
|
-
transparent ${
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
)`});return a.jsxs(a.Fragment,{children:[
|
|
8
|
+
transparent ${o-B}px,
|
|
9
|
+
${h} ${o-B}px,
|
|
10
|
+
${h} ${o}px
|
|
11
|
+
)`});return a.jsxs(a.Fragment,{children:[i()?a.jsx("div",{className:"p-meter__filled","data-testid":_.meteroverflow,style:{backgroundColor:C,width:"100%"}}):e==null?void 0:e.map((c,d)=>a.jsx("div",{className:"p-meter__filled","data-testid":_.filled,style:r(c,d)},`meter-${d}`)),o>0&&a.jsx("div",{className:"p-meter__separators","data-testid":_.segments,style:g()})]})},D=({className:e,children:n})=>a.jsx("div",{className:p("p-meter__label",e),"data-testid":_.label,children:n});S.Label=D;const O=({children:e,to:n,...t})=>a.jsx(m.Link,{...t,href:n,rel:"noreferrer noopener",target:"_blank",children:e}),P=({children:e})=>a.jsx(a.Fragment,{children:e}),q=({isCollapsed:e,setIsCollapsed:n,className:t})=>a.jsx(m.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(m.Button,{appearance:"base","aria-label":`${e?"expand":"collapse"} main navigation`,className:p("is-dense has-icon is-dark u-no-margin l-navigation-collapse-toggle",t),onClick:o=>{n(!e),o.stopPropagation(),o.currentTarget.blur()},children:a.jsx(m.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})}),W=({children:e})=>a.jsx("div",{className:"p-panel__footer",children:e}),G=({children:e})=>a.jsx("div",{className:"p-panel__header",children:e}),J=({light:e=!0,name:n})=>a.jsx(m.Icon,{className:"p-side-navigation__icon",light:e,name:n}),K=({children:e,className:n,hasActiveChild:t})=>a.jsx("li",{className:p("p-side-navigation__item",n,{"has-active-child":t}),children:e}),Q=({children:e,id:n,variant:t="base"})=>a.jsx("span",{className:p("p-side-navigation__label",{"p-side-navigation__label--group":t==="group"}),id:n,children:e}),U=({as:e,...n})=>{const t=e||"a";return a.jsx(t,{className:p("p-side-navigation__link",n.className),...n})},V=({children:e,className:n})=>a.jsx("ul",{className:p("p-side-navigation__list",n),children:e}),X=({as:e,children:n,className:t,...o})=>{const i=e||"a";return a.jsx(i,{className:p("p-panel__logo",t),...o,children:a.jsx("div",{className:"p-navigation__tagged-logo",children:n})})},Y=({children:e})=>f.cloneElement(e,{className:"p-panel__logo-icon p-navigation__logo-icon"}),Z=({children:e,variant:n="base"})=>a.jsx("div",{className:p("p-panel__logo-name is-fading-when-collapsed",{"p-panel__logo-name--small":n==="small"}),children:e}),R=({children:e})=>a.jsx("div",{className:"p-navigation__logo-tag",children:e}),ee=({children:e})=>a.jsx("span",{className:"p-panel__logo-text",children:e}),ae=({children:e,className:n,onClick:t})=>a.jsx(m.Button,{appearance:"base",className:p("p-side-navigation__button--menu has-icon is-dark",n),onClick:o=>{t&&t(o),o.stopPropagation(),o.currentTarget.blur()},children:e}),ne=({children:e})=>a.jsx("span",{className:"p-side-navigation__text",children:e}),re="",s=({children:e,className:n,isCollapsed:t})=>a.jsx("header",{"aria-label":"main navigation",className:p("l-navigation is-maas",n,{"is-collapsed":t,"is-pinned":!t}),children:e}),x=({children:e,className:n})=>a.jsx("header",{"aria-label":"navigation",className:"l-navigation-bar",children:a.jsx("div",{className:p("p-panel is-dark",n),children:e})});s.Header=G,s.Banner=P,s.Drawer=H,s.Controls=z,s.CollapseToggle=q,s.Content=A,s.Footer=W,s.List=V,s.Item=K,s.Link=U,s.Text=ne,s.Icon=J,s.Label=Q,s.Logo=X,s.LogoTag=R,s.LogoIcon=Y,s.LogoName=Z,s.LogoText=ee,x.MenuButton=ae,l.ExternalLink=O,l.Meter=S,l.Navigation=s,l.NavigationBar=x,l.defaultFilledColors=$,l.meterColor=v,l.testIds=_,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
export declare const meterColor: {
|
|
3
3
|
readonly caution: "#F99B11";
|
|
4
4
|
readonly light: "#F7F7F7";
|
|
@@ -10,25 +10,17 @@ export declare const meterColor: {
|
|
|
10
10
|
readonly positive: "#0E8420";
|
|
11
11
|
};
|
|
12
12
|
export declare const defaultFilledColors: ("#F99B11" | "#0066CC" | "#C7162B" | "#0E8420")[];
|
|
13
|
-
export declare const defaultEmptyColor: "#D3E4ED";
|
|
14
|
-
export declare const defaultOverColor: "#F99B11";
|
|
15
|
-
export declare const defaultSeparatorColor: "#F7F7F7";
|
|
16
13
|
type MeterDatum = {
|
|
17
14
|
color?: string;
|
|
18
15
|
value: number;
|
|
19
16
|
};
|
|
20
|
-
|
|
17
|
+
export interface MeterProps extends React.PropsWithChildren, React.ComponentProps<"div"> {
|
|
21
18
|
className?: string;
|
|
22
19
|
data: MeterDatum[];
|
|
23
|
-
emptyColor?: string;
|
|
24
|
-
label?: string | JSX.Element;
|
|
25
|
-
labelClassName?: string;
|
|
26
20
|
max?: number;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
small?: boolean;
|
|
31
|
-
};
|
|
21
|
+
variant?: "regular" | "segmented";
|
|
22
|
+
size?: "regular" | "small";
|
|
23
|
+
}
|
|
32
24
|
export declare const testIds: {
|
|
33
25
|
bar: string;
|
|
34
26
|
container: string;
|
|
@@ -37,5 +29,13 @@ export declare const testIds: {
|
|
|
37
29
|
meteroverflow: string;
|
|
38
30
|
segments: string;
|
|
39
31
|
};
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
declare const Meter: {
|
|
33
|
+
({ className, children, data, max, variant, size, ...props }: MeterProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
Label: ({ className, children, }: React.PropsWithChildren<Pick<MeterProps, "className">>) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
};
|
|
36
|
+
export interface MeterSegmentProps extends Omit<MeterProps, "children"> {
|
|
37
|
+
datumWidths: number[];
|
|
38
|
+
maximum: number;
|
|
39
|
+
segmentWidth: number;
|
|
40
|
+
}
|
|
41
|
+
export { Meter };
|
|
@@ -2,7 +2,7 @@ import type { Meta } from "@storybook/react";
|
|
|
2
2
|
import { Meter } from ".";
|
|
3
3
|
declare const meta: Meta<typeof Meter>;
|
|
4
4
|
export default meta;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const Regular: {
|
|
6
6
|
args: {
|
|
7
7
|
data: {
|
|
8
8
|
value: number;
|
|
@@ -10,6 +10,24 @@ export declare const Example: {
|
|
|
10
10
|
}[];
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
+
export declare const Segmented: {
|
|
14
|
+
args: {
|
|
15
|
+
data: {
|
|
16
|
+
value: number;
|
|
17
|
+
color: string;
|
|
18
|
+
}[];
|
|
19
|
+
variant: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const WithLabel: {
|
|
23
|
+
args: {
|
|
24
|
+
data: {
|
|
25
|
+
value: number;
|
|
26
|
+
color: string;
|
|
27
|
+
}[];
|
|
28
|
+
children: import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
13
31
|
export declare const NoItems: {
|
|
14
32
|
args: {
|
|
15
33
|
data: never[];
|
|
@@ -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