@canonical/maas-react-components 1.0.1 → 1.2.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 +94 -93
- package/dist/@canonical/maas-react-components.umd.js +6 -6
- package/dist/src/lib/components/NestedFormGroup/NestedFormGroup.d.ts +2 -0
- package/dist/src/lib/components/NestedFormGroup/NestedFormGroup.stories.d.ts +10 -0
- package/dist/src/lib/components/NestedFormGroup/NestedFormGroup.test.d.ts +1 -0
- package/dist/src/lib/components/NestedFormGroup/index.d.ts +1 -0
- package/dist/src/lib/components/index.d.ts +1 -0
- package/dist/src/lib/elements/ExternalLink/ExternalLink.d.ts +7 -0
- package/dist/src/lib/elements/ExternalLink/ExternalLink.stories.d.ts +10 -0
- package/dist/src/lib/elements/ExternalLink/ExternalLink.test.d.ts +1 -0
- package/dist/src/lib/elements/ExternalLink/index.d.ts +1 -0
- package/dist/src/lib/elements/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as _, jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useListener as M } from "@canonical/react-components";
|
|
4
|
-
function
|
|
5
|
-
return
|
|
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) {
|
|
5
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
6
6
|
}
|
|
7
7
|
var y = { exports: {} };
|
|
8
8
|
/*!
|
|
@@ -10,39 +10,39 @@ var y = { exports: {} };
|
|
|
10
10
|
Licensed under the MIT License (MIT), see
|
|
11
11
|
http://jedwatson.github.io/classnames
|
|
12
12
|
*/
|
|
13
|
-
(function(
|
|
13
|
+
(function(e) {
|
|
14
14
|
(function() {
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
for (var
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
var l = typeof
|
|
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
21
|
if (l === "string" || l === "number")
|
|
22
|
-
|
|
23
|
-
else if (Array.isArray(
|
|
24
|
-
if (
|
|
25
|
-
var i =
|
|
26
|
-
i &&
|
|
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);
|
|
27
27
|
}
|
|
28
28
|
} else if (l === "object") {
|
|
29
|
-
if (
|
|
30
|
-
|
|
29
|
+
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) {
|
|
30
|
+
n.push(t.toString());
|
|
31
31
|
continue;
|
|
32
32
|
}
|
|
33
|
-
for (var
|
|
34
|
-
|
|
33
|
+
for (var u in t)
|
|
34
|
+
r.call(t, u) && t[u] && n.push(u);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return n.join(" ");
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
e.exports ? (s.default = s, e.exports = s) : window.classNames = s;
|
|
41
41
|
})();
|
|
42
42
|
})(y);
|
|
43
43
|
var W = y.exports;
|
|
44
|
-
const
|
|
45
|
-
const
|
|
44
|
+
const k = /* @__PURE__ */ L(W);
|
|
45
|
+
const f = {
|
|
46
46
|
caution: "#F99B11",
|
|
47
47
|
light: "#F7F7F7",
|
|
48
48
|
linkFaded: "#D3E4ED",
|
|
@@ -51,15 +51,15 @@ const m = {
|
|
|
51
51
|
positiveFaded: "#B7CCB9",
|
|
52
52
|
positiveMid: "#4DAB4D",
|
|
53
53
|
positive: "#0E8420"
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
], A =
|
|
60
|
-
var
|
|
61
|
-
const
|
|
62
|
-
|
|
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
63
|
}, p = {
|
|
64
64
|
bar: "meter-bar",
|
|
65
65
|
container: "meter-container",
|
|
@@ -67,122 +67,123 @@ const m = {
|
|
|
67
67
|
label: "meter-label",
|
|
68
68
|
meteroverflow: "meter-overflow",
|
|
69
69
|
segments: "meter-segments"
|
|
70
|
-
},
|
|
71
|
-
data:
|
|
72
|
-
datumWidths:
|
|
73
|
-
maximum:
|
|
74
|
-
overColor:
|
|
75
|
-
segmentWidth:
|
|
76
|
-
separatorColor:
|
|
70
|
+
}, I = ({
|
|
71
|
+
data: e,
|
|
72
|
+
datumWidths: r,
|
|
73
|
+
maximum: s,
|
|
74
|
+
overColor: n,
|
|
75
|
+
segmentWidth: o,
|
|
76
|
+
separatorColor: t
|
|
77
77
|
}) => {
|
|
78
|
-
const l = () =>
|
|
79
|
-
backgroundColor:
|
|
80
|
-
left: `${
|
|
81
|
-
(v, c, h) =>
|
|
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,
|
|
82
82
|
0
|
|
83
83
|
)}%`,
|
|
84
|
-
width: `${
|
|
85
|
-
}),
|
|
84
|
+
width: `${r[a]}%`
|
|
85
|
+
}), u = () => ({
|
|
86
86
|
background: `repeating-linear-gradient(
|
|
87
87
|
to right,
|
|
88
88
|
transparent 0,
|
|
89
|
-
transparent ${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
89
|
+
transparent ${o - w}px,
|
|
90
|
+
${t} ${o - w}px,
|
|
91
|
+
${t} ${o}px
|
|
92
92
|
)`
|
|
93
93
|
});
|
|
94
|
-
return /* @__PURE__ */ _(
|
|
95
|
-
l() ? /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ _($, { children: [
|
|
95
|
+
l() ? /* @__PURE__ */ d(
|
|
96
96
|
"div",
|
|
97
97
|
{
|
|
98
98
|
className: "p-meter__filled",
|
|
99
99
|
"data-testid": p.meteroverflow,
|
|
100
|
-
style: { backgroundColor:
|
|
100
|
+
style: { backgroundColor: n, width: "100%" }
|
|
101
101
|
}
|
|
102
|
-
) :
|
|
102
|
+
) : e.map((m, a) => /* @__PURE__ */ d(
|
|
103
103
|
"div",
|
|
104
104
|
{
|
|
105
105
|
className: "p-meter__filled",
|
|
106
106
|
"data-testid": p.filled,
|
|
107
|
-
style: i(
|
|
107
|
+
style: i(m, a)
|
|
108
108
|
},
|
|
109
|
-
`meter-${
|
|
109
|
+
`meter-${a}`
|
|
110
110
|
)),
|
|
111
|
-
|
|
111
|
+
o > 0 && /* @__PURE__ */ d(
|
|
112
112
|
"div",
|
|
113
113
|
{
|
|
114
114
|
className: "p-meter__separators",
|
|
115
115
|
"data-testid": p.segments,
|
|
116
|
-
style:
|
|
116
|
+
style: u()
|
|
117
117
|
}
|
|
118
118
|
)
|
|
119
119
|
] });
|
|
120
|
-
},
|
|
121
|
-
labelClassName:
|
|
122
|
-
label:
|
|
123
|
-
}) => /* @__PURE__ */
|
|
120
|
+
}, P = ({
|
|
121
|
+
labelClassName: e,
|
|
122
|
+
label: r
|
|
123
|
+
}) => /* @__PURE__ */ d(
|
|
124
124
|
"div",
|
|
125
125
|
{
|
|
126
|
-
className:
|
|
126
|
+
className: k("p-meter__label", e),
|
|
127
127
|
"data-testid": p.label,
|
|
128
|
-
children:
|
|
128
|
+
children: r
|
|
129
129
|
}
|
|
130
|
-
),
|
|
131
|
-
className:
|
|
132
|
-
data:
|
|
133
|
-
emptyColor:
|
|
134
|
-
label:
|
|
135
|
-
labelClassName:
|
|
136
|
-
max:
|
|
130
|
+
), K = ({
|
|
131
|
+
className: e,
|
|
132
|
+
data: r,
|
|
133
|
+
emptyColor: s = A,
|
|
134
|
+
label: n,
|
|
135
|
+
labelClassName: o,
|
|
136
|
+
max: t,
|
|
137
137
|
overColor: l = R,
|
|
138
138
|
segmented: i = !1,
|
|
139
|
-
separatorColor:
|
|
140
|
-
small:
|
|
139
|
+
separatorColor: u = z,
|
|
140
|
+
small: m = !1
|
|
141
141
|
}) => {
|
|
142
|
-
const
|
|
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
143
|
O(() => {
|
|
144
|
-
i && S(
|
|
144
|
+
i && S(a, c, b);
|
|
145
145
|
}, [c, i]);
|
|
146
|
-
const
|
|
147
|
-
S(
|
|
148
|
-
}, [
|
|
149
|
-
return M(window,
|
|
146
|
+
const x = B(() => {
|
|
147
|
+
S(a, c, b);
|
|
148
|
+
}, [a, c, b]);
|
|
149
|
+
return M(window, x, "resize", !0, i), /* @__PURE__ */ _(
|
|
150
150
|
"div",
|
|
151
151
|
{
|
|
152
|
-
className:
|
|
152
|
+
className: k("p-meter", { "p-meter--small": m }, e),
|
|
153
153
|
"data-testid": p.container,
|
|
154
|
-
ref:
|
|
154
|
+
ref: a,
|
|
155
155
|
children: [
|
|
156
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ d(
|
|
157
157
|
"div",
|
|
158
158
|
{
|
|
159
159
|
className: "p-meter__bar",
|
|
160
160
|
"data-testid": p.bar,
|
|
161
|
-
style: { backgroundColor:
|
|
162
|
-
children: /* @__PURE__ */
|
|
163
|
-
|
|
161
|
+
style: { backgroundColor: s },
|
|
162
|
+
children: /* @__PURE__ */ d(
|
|
163
|
+
I,
|
|
164
164
|
{
|
|
165
|
-
data:
|
|
165
|
+
data: r,
|
|
166
166
|
datumWidths: h,
|
|
167
167
|
maximum: c,
|
|
168
168
|
overColor: l,
|
|
169
|
-
segmentWidth:
|
|
170
|
-
separatorColor:
|
|
169
|
+
segmentWidth: F,
|
|
170
|
+
separatorColor: u
|
|
171
171
|
}
|
|
172
172
|
)
|
|
173
173
|
}
|
|
174
174
|
),
|
|
175
|
-
|
|
175
|
+
n && /* @__PURE__ */ d(P, { label: n, labelClassName: o })
|
|
176
176
|
]
|
|
177
177
|
}
|
|
178
178
|
);
|
|
179
|
-
};
|
|
179
|
+
}, Q = ({ children: e, to: r, ...s }) => /* @__PURE__ */ d(D, { ...s, href: r, rel: "noreferrer noopener", target: "_blank", children: e });
|
|
180
180
|
export {
|
|
181
|
-
|
|
181
|
+
Q as ExternalLink,
|
|
182
|
+
K as Meter,
|
|
182
183
|
A as defaultEmptyColor,
|
|
183
|
-
|
|
184
|
+
J as defaultFilledColors,
|
|
184
185
|
R as defaultOverColor,
|
|
185
186
|
z as defaultSeparatorColor,
|
|
186
|
-
|
|
187
|
+
f as meterColor,
|
|
187
188
|
p as testIds
|
|
188
189
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(n,
|
|
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:{}};/*!
|
|
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(
|
|
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(
|
|
6
6
|
to right,
|
|
7
7
|
transparent 0,
|
|
8
|
-
transparent ${
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
)`});return
|
|
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"})});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/react";
|
|
2
|
+
import { NestedFormGroup } from ".";
|
|
3
|
+
declare const meta: Meta<typeof NestedFormGroup>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const Example: {
|
|
6
|
+
args: {
|
|
7
|
+
"aria-hidden": boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const ControlledExample: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./NestedFormGroup";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./NestedFormGroup";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LinkProps } from "@canonical/react-components";
|
|
2
|
+
import type { LinkProps as RouterLinkProps } from "react-router-dom";
|
|
3
|
+
type ExternalLinkProps = Pick<LinkProps, "children"> & Omit<RouterLinkProps, "children"> & {
|
|
4
|
+
to: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const ExternalLink: ({ children, to, ...props }: ExternalLinkProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ExternalLink";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/maas-react-components",
|
|
3
3
|
"description": "React components for use in MAAS UI projects.",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/canonical/maas-react-components.git"
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"@types/react-dom": "^17.0.2 || ^18.0.0",
|
|
101
101
|
"react": "18.2.0",
|
|
102
102
|
"react-dom": "18.2.0",
|
|
103
|
+
"react-router-dom": "^6.0.0",
|
|
103
104
|
"vanilla-framework": "^4.3.0"
|
|
104
105
|
}
|
|
105
106
|
}
|