@hashicorp/mds-react 0.9.4 → 0.9.5
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/components/badge/style.module.scss +8 -6
- package/components/badge-count/style.module.scss +7 -6
- package/components/breadcrumbs/truncation-button/index.js +6 -6
- package/components/breadcrumbs/truncation-button/index.js.map +1 -1
- package/components/button/button-primitive.d.ts +5 -0
- package/components/button/button-primitive.js +59 -0
- package/components/button/button-primitive.js.map +1 -0
- package/components/button/index.d.ts +2 -4
- package/components/button/index.js +21 -71
- package/components/button/index.js.map +1 -1
- package/components/card/index.js +9 -9
- package/components/card/index.js.map +1 -1
- package/components/form/error/index.js +7 -7
- package/components/form/error/index.js.map +1 -1
- package/components/form/fieldset/index.d.ts +1 -2
- package/components/form/fieldset/index.js.map +1 -1
- package/components/form/file-input/form-file-input.module.scss +2 -2
- package/components/form/radio/index.d.ts +3 -5
- package/components/form/radio/index.js.map +1 -1
- package/components/form/radio-card/RadioCardStory.css +21 -0
- package/components/icon-tile/style.module.scss +12 -10
- package/components/inline-link/index.js +12 -11
- package/components/inline-link/index.js.map +1 -1
- package/components/modal/modal.module.css +5 -0
- package/components/tabs/index.js +63 -65
- package/components/tabs/index.js.map +1 -1
- package/package.json +1 -1
- package/patterns/card/person-card/index.js +37 -35
- package/patterns/card/person-card/index.js.map +1 -1
- package/patterns/card/primitives.js +16 -16
- package/patterns/card/primitives.js.map +1 -1
- package/style.css +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.doc-radio-card-list-demo {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
color: #3b3d45;
|
|
5
|
+
|
|
6
|
+
& li {
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 8px 0 8px 24px;
|
|
9
|
+
list-style: none;
|
|
10
|
+
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.78 5.22a.75.75 0 010 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-2-2a.75.75 0 011.06-1.06l1.47 1.47 3.97-3.97a.75.75 0 011.06 0z' fill='%233b3d45'/%3E%3Cpath d='M0 8a8 8 0 1116 0A8 8 0 010 8zm8-6.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13z' fill='%233b3d45'/%3E%3C/svg%3E");
|
|
11
|
+
background-repeat: no-repeat;
|
|
12
|
+
background-position: left 9px;
|
|
13
|
+
background-size: 16px;
|
|
14
|
+
border-bottom: 1px solid #ddd;
|
|
15
|
+
font-family: var(--mds-typography-font-stack-text);
|
|
16
|
+
|
|
17
|
+
&:last-child {
|
|
18
|
+
border-bottom: none;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
|
|
1
3
|
$hds-icon-tile-sizes: ('small', 'medium', 'large');
|
|
2
4
|
$hds-icon-tile-colors-products: (
|
|
3
5
|
'boundary',
|
|
@@ -78,24 +80,24 @@ $size-props: (
|
|
|
78
80
|
|
|
79
81
|
@each $size in $hds-icon-tile-sizes {
|
|
80
82
|
.size-#{$size} {
|
|
81
|
-
width: map
|
|
82
|
-
height: map
|
|
83
|
-
border-radius: map
|
|
83
|
+
width: map.get($size-props, $size, 'size');
|
|
84
|
+
height: map.get($size-props, $size, 'size');
|
|
85
|
+
border-radius: map.get($size-props, $size, 'border-radius');
|
|
84
86
|
|
|
85
87
|
.icon {
|
|
86
|
-
width: map
|
|
87
|
-
height: map
|
|
88
|
+
width: map.get($size-props, $size, 'icon-size');
|
|
89
|
+
height: map.get($size-props, $size, 'icon-size');
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
.logo {
|
|
91
|
-
width: map
|
|
92
|
-
height: map
|
|
93
|
+
width: map.get($size-props, $size, 'logo-size');
|
|
94
|
+
height: map.get($size-props, $size, 'logo-size');
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
.extra {
|
|
96
|
-
width: map
|
|
97
|
-
height: map
|
|
98
|
-
border-radius: map
|
|
98
|
+
width: map.get($size-props, $size, 'extra-size');
|
|
99
|
+
height: map.get($size-props, $size, 'extra-size');
|
|
100
|
+
border-radius: map.get($size-props, $size, 'extra-border-radius');
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { jsxs as c, jsx as p } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { Interactive as
|
|
2
|
+
import I from "classnames";
|
|
3
|
+
import { Interactive as d } from "../interactive/index.js";
|
|
4
4
|
import i from "./inline-link.module.css.js";
|
|
5
|
-
import { FlightIcon as
|
|
5
|
+
import { FlightIcon as f } from "../flight-icon/index.js";
|
|
6
6
|
const g = ({
|
|
7
|
-
text:
|
|
8
|
-
color:
|
|
7
|
+
text: o,
|
|
8
|
+
color: s = "primary",
|
|
9
9
|
icon: r,
|
|
10
10
|
iconPosition: e = "trailing",
|
|
11
|
-
className:
|
|
12
|
-
isHrefExternal:
|
|
11
|
+
className: t,
|
|
12
|
+
isHrefExternal: l,
|
|
13
13
|
...a
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
15
|
+
const m = r || !l ? r : "external-link", n = m && /* @__PURE__ */ p(f, { name: m, size: 16, className: i.icon });
|
|
16
16
|
return /* @__PURE__ */ c(
|
|
17
|
-
|
|
17
|
+
d,
|
|
18
18
|
{
|
|
19
|
-
className:
|
|
19
|
+
className: I(i["link-inline"], i[`color-${s}`], t),
|
|
20
|
+
isHrefExternal: l,
|
|
20
21
|
...a,
|
|
21
22
|
children: [
|
|
22
23
|
n && e === "leading" && n,
|
|
23
|
-
|
|
24
|
+
o,
|
|
24
25
|
n && e === "trailing" && n
|
|
25
26
|
]
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/inline-link/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { Interactive } from '../interactive'\nimport s from './inline-link.module.css'\nimport type { FlightIconName } from '../flight-icon'\nimport { FlightIcon } from '../flight-icon'\n\ninterface InlineLinkProps {\n\t/**\n\t * There are two available colors for an `<InlineLink />`: primary and secondary.\n\t */\n\tcolor?: 'primary' | 'secondary'\n\t/**\n\t * Use this parameter to show an icon.\n\t */\n\ticon?: FlightIconName\n\t/**\n\t * Positions the icon before or after the text.\n\t */\n\ticonPosition?: 'leading' | 'trailing'\n\t/**\n\t * URL parameter that’s passed down to the `<a>` element.\n\t */\n\thref: string\n\t/**\n\t * Controls if the <a> link is external. For security reasons, we add the target=\"_blank\" and rel=\"noopener noreferrer\" attributes to it by default.\n\t * default: `false`\n\t */\n\tisHrefExternal?: boolean\n\t/**\n\t * The content of the <a> HTML element.\n\t */\n\ttext: string\n\t/**\n\t * Optional class name to add to the component.\n\t */\n\tclassName?: string\n\tprefetch?: boolean\n\tlocale?: string\n}\n\nconst InlineLink = ({\n\ttext,\n\tcolor = 'primary',\n\ticon,\n\ticonPosition = 'trailing',\n\tclassName,\n\tisHrefExternal,\n\t...props\n}: InlineLinkProps) => {\n\tconst resolvedIcon = icon || !isHrefExternal ? icon : 'external-link'\n\tconst iconElement = resolvedIcon && (\n\t\t<FlightIcon name={resolvedIcon} size={16} className={s.icon} />\n\t)\n\n\treturn (\n\t\t<Interactive\n\t\t\tclassName={classNames(s['link-inline'], s[`color-${color}`], className)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{iconElement && iconPosition === 'leading' && iconElement}\n\t\t\t{text}\n\t\t\t{iconElement && iconPosition === 'trailing' && iconElement}\n\t\t</Interactive>\n\t)\n}\n\nInlineLink.displayName = 'InlineLink'\n\nexport type { InlineLinkProps }\nexport { InlineLink }\n"],"names":["InlineLink","text","color","icon","iconPosition","className","isHrefExternal","props","resolvedIcon","iconElement","jsx","FlightIcon","s","jsxs","Interactive","classNames"],"mappings":";;;;;AAwCA,MAAMA,IAAa,CAAC;AAAA,EACnB,MAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,GAAGC;AACJ,MAAuB;AACtB,QAAMC,IAAeL,KAAQ,CAACG,IAAiBH,IAAO,iBAChDM,IAAcD,KACnB,gBAAAE,EAACC,GAAA,EAAW,MAAMH,GAAc,MAAM,IAAI,WAAWI,EAAE,KAAA,CAAM;AAG9D,SACC,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,WAAWC,EAAWH,EAAE,aAAa,GAAGA,EAAE,SAASV,CAAK,EAAE,GAAGG,CAAS;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/inline-link/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { Interactive } from '../interactive'\nimport s from './inline-link.module.css'\nimport type { FlightIconName } from '../flight-icon'\nimport { FlightIcon } from '../flight-icon'\n\ninterface InlineLinkProps {\n\t/**\n\t * There are two available colors for an `<InlineLink />`: primary and secondary.\n\t */\n\tcolor?: 'primary' | 'secondary'\n\t/**\n\t * Use this parameter to show an icon.\n\t */\n\ticon?: FlightIconName\n\t/**\n\t * Positions the icon before or after the text.\n\t */\n\ticonPosition?: 'leading' | 'trailing'\n\t/**\n\t * URL parameter that’s passed down to the `<a>` element.\n\t */\n\thref: string\n\t/**\n\t * Controls if the <a> link is external. For security reasons, we add the target=\"_blank\" and rel=\"noopener noreferrer\" attributes to it by default.\n\t * default: `false`\n\t */\n\tisHrefExternal?: boolean\n\t/**\n\t * The content of the <a> HTML element.\n\t */\n\ttext: string\n\t/**\n\t * Optional class name to add to the component.\n\t */\n\tclassName?: string\n\tprefetch?: boolean\n\tlocale?: string\n}\n\nconst InlineLink = ({\n\ttext,\n\tcolor = 'primary',\n\ticon,\n\ticonPosition = 'trailing',\n\tclassName,\n\tisHrefExternal,\n\t...props\n}: InlineLinkProps) => {\n\tconst resolvedIcon = icon || !isHrefExternal ? icon : 'external-link'\n\tconst iconElement = resolvedIcon && (\n\t\t<FlightIcon name={resolvedIcon} size={16} className={s.icon} />\n\t)\n\n\treturn (\n\t\t<Interactive\n\t\t\tclassName={classNames(s['link-inline'], s[`color-${color}`], className)}\n\t\t\tisHrefExternal={isHrefExternal}\n\t\t\t{...props}\n\t\t>\n\t\t\t{iconElement && iconPosition === 'leading' && iconElement}\n\t\t\t{text}\n\t\t\t{iconElement && iconPosition === 'trailing' && iconElement}\n\t\t</Interactive>\n\t)\n}\n\nInlineLink.displayName = 'InlineLink'\n\nexport type { InlineLinkProps }\nexport { InlineLink }\n"],"names":["InlineLink","text","color","icon","iconPosition","className","isHrefExternal","props","resolvedIcon","iconElement","jsx","FlightIcon","s","jsxs","Interactive","classNames"],"mappings":";;;;;AAwCA,MAAMA,IAAa,CAAC;AAAA,EACnB,MAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,GAAGC;AACJ,MAAuB;AACtB,QAAMC,IAAeL,KAAQ,CAACG,IAAiBH,IAAO,iBAChDM,IAAcD,KACnB,gBAAAE,EAACC,GAAA,EAAW,MAAMH,GAAc,MAAM,IAAI,WAAWI,EAAE,KAAA,CAAM;AAG9D,SACC,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,WAAWC,EAAWH,EAAE,aAAa,GAAGA,EAAE,SAASV,CAAK,EAAE,GAAGG,CAAS;AAAA,MACtE,gBAAAC;AAAA,MACC,GAAGC;AAAA,MAEH,UAAA;AAAA,QAAAE,KAAeL,MAAiB,aAAaK;AAAA,QAC7CR;AAAA,QACAQ,KAAeL,MAAiB,cAAcK;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlD;AAEAT,EAAW,cAAc;"}
|
package/components/tabs/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import
|
|
4
|
-
import { useState as
|
|
2
|
+
import { jsx as u, jsxs as M } from "react/jsx-runtime";
|
|
3
|
+
import x from "classnames";
|
|
4
|
+
import { useState as a, useRef as T, useCallback as f, useEffect as d, useMemo as O } from "react";
|
|
5
5
|
import { TabPanel as S } from "./tab-panel.js";
|
|
6
6
|
import { Tab as U } from "./tab.js";
|
|
7
7
|
import { useTabsContext as q, TabsContext as B } from "./use-tabs-context.js";
|
|
8
|
-
import
|
|
8
|
+
import m from "./tabs.module.scss.js";
|
|
9
9
|
const F = ({
|
|
10
|
-
children:
|
|
11
|
-
onClickTab:
|
|
12
|
-
initialSelectedTabIndex:
|
|
13
|
-
size:
|
|
14
|
-
className:
|
|
10
|
+
children: p,
|
|
11
|
+
onClickTab: r,
|
|
12
|
+
initialSelectedTabIndex: n = 0,
|
|
13
|
+
size: w = "medium",
|
|
14
|
+
className: I,
|
|
15
15
|
...k
|
|
16
16
|
}) => {
|
|
17
|
-
const [
|
|
18
|
-
|
|
19
|
-
), s =
|
|
17
|
+
const [i, b] = a(
|
|
18
|
+
n
|
|
19
|
+
), s = T([]), l = T([]), [o, A] = a([]), [L, E] = a([]), [R, W] = a(0), [C, K] = a(0), c = T(null), h = f((t) => {
|
|
20
20
|
const e = s.current[t]?.parentNode;
|
|
21
21
|
e && e.scrollIntoView({
|
|
22
22
|
behavior: "smooth",
|
|
@@ -24,91 +24,89 @@ const F = ({
|
|
|
24
24
|
inline: "nearest"
|
|
25
25
|
});
|
|
26
26
|
}, []);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, [
|
|
30
|
-
const t = s.current[
|
|
31
|
-
if (t &&
|
|
32
|
-
const e = t.offsetLeft,
|
|
33
|
-
|
|
27
|
+
d(() => {
|
|
28
|
+
b(n);
|
|
29
|
+
}, [n]), d(() => {
|
|
30
|
+
const t = s.current[i]?.parentElement;
|
|
31
|
+
if (t && c.current) {
|
|
32
|
+
const e = t.offsetLeft, v = t.offsetWidth;
|
|
33
|
+
K(e), W(v), c.current.scrollTo({
|
|
34
34
|
left: e,
|
|
35
35
|
behavior: "smooth"
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
}, [s,
|
|
39
|
-
A(s.current.map((
|
|
40
|
-
let t = 0
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
|
|
48
|
-
}, [d]);
|
|
49
|
-
const P = m(
|
|
38
|
+
}, [s, i, h, c]), d(() => {
|
|
39
|
+
A(s.current.map((e) => e.id));
|
|
40
|
+
let t = 0;
|
|
41
|
+
s.current.forEach((e) => {
|
|
42
|
+
e.hasAttribute("data-is-selected") && t++;
|
|
43
|
+
}), t > 1 && console.error("Only one tab may use isSelected argument");
|
|
44
|
+
}, [s]), d(() => {
|
|
45
|
+
E(l.current.map((t) => t.id));
|
|
46
|
+
}, [l]);
|
|
47
|
+
const P = f(
|
|
50
48
|
(t, e) => {
|
|
51
|
-
|
|
49
|
+
b(t), h(t), typeof r == "function" && r(e, t);
|
|
52
50
|
},
|
|
53
|
-
[
|
|
54
|
-
),
|
|
51
|
+
[r, h]
|
|
52
|
+
), y = f(
|
|
55
53
|
(t, e) => {
|
|
56
54
|
e.preventDefault(), s.current[t].focus();
|
|
57
55
|
},
|
|
58
56
|
[]
|
|
59
|
-
), g =
|
|
57
|
+
), g = f(
|
|
60
58
|
(t, e) => {
|
|
61
|
-
const
|
|
62
|
-
if (e.key ===
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
} else if (e.key ===
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
} else (e.key === $ || e.key === D) &&
|
|
59
|
+
const v = "ArrowLeft", j = "ArrowRight", $ = "Enter", D = " ";
|
|
60
|
+
if (e.key === j) {
|
|
61
|
+
const N = (t + 1) % o.length;
|
|
62
|
+
y(N, e);
|
|
63
|
+
} else if (e.key === v) {
|
|
64
|
+
const N = (t + o.length - 1) % o.length;
|
|
65
|
+
y(N, e);
|
|
66
|
+
} else (e.key === $ || e.key === D) && b(t);
|
|
69
67
|
},
|
|
70
|
-
[
|
|
71
|
-
),
|
|
68
|
+
[y, o.length]
|
|
69
|
+
), V = O(
|
|
72
70
|
() => ({
|
|
73
71
|
tabNodes: s,
|
|
74
|
-
tabIds:
|
|
75
|
-
panelNodes:
|
|
72
|
+
tabIds: o,
|
|
73
|
+
panelNodes: l,
|
|
76
74
|
panelIds: L,
|
|
77
|
-
selectedTabIndex:
|
|
75
|
+
selectedTabIndex: i,
|
|
78
76
|
onClick: P,
|
|
79
77
|
onKeyUp: g,
|
|
80
|
-
size:
|
|
81
|
-
tabsListRef:
|
|
78
|
+
size: w,
|
|
79
|
+
tabsListRef: c
|
|
82
80
|
}),
|
|
83
81
|
[
|
|
84
82
|
s,
|
|
85
|
-
|
|
86
|
-
d,
|
|
87
|
-
L,
|
|
83
|
+
o,
|
|
88
84
|
l,
|
|
85
|
+
L,
|
|
86
|
+
i,
|
|
89
87
|
P,
|
|
90
88
|
g,
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
w,
|
|
90
|
+
c
|
|
93
91
|
]
|
|
94
92
|
);
|
|
95
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ u(B.Provider, { value: V, children: /* @__PURE__ */ u(
|
|
96
94
|
"div",
|
|
97
95
|
{
|
|
98
|
-
className:
|
|
96
|
+
className: x(m.tabs, I),
|
|
99
97
|
...k,
|
|
100
98
|
style: {
|
|
101
|
-
"--indicator-left-pos": `${
|
|
102
|
-
"--indicator-width": `${
|
|
99
|
+
"--indicator-left-pos": `${C}px`,
|
|
100
|
+
"--indicator-width": `${R}px`
|
|
103
101
|
},
|
|
104
|
-
children:
|
|
102
|
+
children: p
|
|
105
103
|
}
|
|
106
104
|
) });
|
|
107
|
-
}, G = ({ children:
|
|
108
|
-
const { tabsListRef:
|
|
109
|
-
return /* @__PURE__ */
|
|
110
|
-
|
|
111
|
-
/* @__PURE__ */
|
|
105
|
+
}, G = ({ children: p, className: r }) => {
|
|
106
|
+
const { tabsListRef: n } = q();
|
|
107
|
+
return /* @__PURE__ */ u("div", { className: x(m["tablist-wrapper"], r), children: /* @__PURE__ */ M("ul", { className: m.tablist, role: "tablist", ref: n, children: [
|
|
108
|
+
p,
|
|
109
|
+
/* @__PURE__ */ u("li", { className: m.indicator, role: "presentation" })
|
|
112
110
|
] }) });
|
|
113
111
|
}, z = { Provider: F, TabList: G, Panel: S, Tab: U };
|
|
114
112
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/tabs/index.tsx"],"sourcesContent":["'use client'\n\nimport classNames from 'classnames'\nimport {\n\ttype ReactNode,\n\ttype HTMLAttributes,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n} from 'react'\nimport { TabPanel } from './tab-panel'\nimport { Tab } from './tab'\nimport { TabsContext, useTabsContext } from './use-tabs-context'\nimport s from './tabs.module.scss'\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n\tonClickTab?: (event: MouseEvent<HTMLButtonElement>, tabIndex: number) => void\n\tinitialSelectedTabIndex?: number\n\tsize?: 'medium' | 'large'\n}\n\nconst Provider = ({\n\tchildren,\n\tonClickTab,\n\tinitialSelectedTabIndex = 0,\n\tsize = 'medium',\n\tclassName,\n\t...rest\n}: TabsProps) => {\n\tconst [selectedTabIndex, setSelectedTabIndex] = useState(\n\t\tinitialSelectedTabIndex\n\t)\n\tconst tabNodes = useRef<Array<HTMLButtonElement>>([])\n\tconst panelNodes = useRef<Array<HTMLDivElement>>([])\n\tconst [tabIds, setTabIds] = useState<Array<string>>([])\n\tconst [panelIds, setPanelIds] = useState<Array<string>>([])\n\tconst [indicatorWidth, setIndicatorWidth] = useState(0)\n\tconst [indicatorLeftPosition, setIndicatorLeftPosition] = useState(0)\n\tconst tabsListRef = useRef<HTMLUListElement | null>(null)\n\n\tconst scrollIntoView = useCallback((tabIndex: number) => {\n\t\t// Scroll Tab into view if it's out of view\n\t\tconst parentNode = tabNodes.current[tabIndex]\n\t\t\t?.parentNode as HTMLElement | null\n\t\tif (parentNode) {\n\t\t\tparentNode.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'nearest',\n\t\t\t})\n\t\t}\n\t}, [])\n\n\tuseEffect(() => {\n\t\tsetSelectedTabIndex(initialSelectedTabIndex)\n\t}, [initialSelectedTabIndex])\n\n\tuseEffect(() => {\n\t\tconst tabElem = tabNodes.current[selectedTabIndex]?.parentElement\n\t\tif (tabElem && tabsListRef.current) {\n\t\t\tconst tabLeftPos = tabElem.offsetLeft\n\t\t\tconst tabWidth = tabElem.offsetWidth\n\t\t\tsetIndicatorLeftPosition(tabLeftPos)\n\t\t\tsetIndicatorWidth(tabWidth)\n\t\t\ttabsListRef.current.scrollTo({\n\t\t\t\tleft: tabLeftPos,\n\t\t\t\tbehavior: 'smooth',\n\t\t\t})\n\t\t}\n\t}, [tabNodes, selectedTabIndex, scrollIntoView, tabsListRef])\n\n\tuseEffect(() => {\n\t\tsetTabIds(tabNodes.current.map((tab) => tab.id))\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/tabs/index.tsx"],"sourcesContent":["'use client'\n\nimport classNames from 'classnames'\nimport {\n\ttype ReactNode,\n\ttype HTMLAttributes,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n} from 'react'\nimport { TabPanel } from './tab-panel'\nimport { Tab } from './tab'\nimport { TabsContext, useTabsContext } from './use-tabs-context'\nimport s from './tabs.module.scss'\n\nexport interface TabsProps extends HTMLAttributes<HTMLDivElement> {\n\tonClickTab?: (event: MouseEvent<HTMLButtonElement>, tabIndex: number) => void\n\tinitialSelectedTabIndex?: number\n\tsize?: 'medium' | 'large'\n}\n\nconst Provider = ({\n\tchildren,\n\tonClickTab,\n\tinitialSelectedTabIndex = 0,\n\tsize = 'medium',\n\tclassName,\n\t...rest\n}: TabsProps) => {\n\tconst [selectedTabIndex, setSelectedTabIndex] = useState(\n\t\tinitialSelectedTabIndex\n\t)\n\tconst tabNodes = useRef<Array<HTMLButtonElement>>([])\n\tconst panelNodes = useRef<Array<HTMLDivElement>>([])\n\tconst [tabIds, setTabIds] = useState<Array<string>>([])\n\tconst [panelIds, setPanelIds] = useState<Array<string>>([])\n\tconst [indicatorWidth, setIndicatorWidth] = useState(0)\n\tconst [indicatorLeftPosition, setIndicatorLeftPosition] = useState(0)\n\tconst tabsListRef = useRef<HTMLUListElement | null>(null)\n\n\tconst scrollIntoView = useCallback((tabIndex: number) => {\n\t\t// Scroll Tab into view if it's out of view\n\t\tconst parentNode = tabNodes.current[tabIndex]\n\t\t\t?.parentNode as HTMLElement | null\n\t\tif (parentNode) {\n\t\t\tparentNode.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t\tinline: 'nearest',\n\t\t\t})\n\t\t}\n\t}, [])\n\n\tuseEffect(() => {\n\t\tsetSelectedTabIndex(initialSelectedTabIndex)\n\t}, [initialSelectedTabIndex])\n\n\tuseEffect(() => {\n\t\tconst tabElem = tabNodes.current[selectedTabIndex]?.parentElement\n\t\tif (tabElem && tabsListRef.current) {\n\t\t\tconst tabLeftPos = tabElem.offsetLeft\n\t\t\tconst tabWidth = tabElem.offsetWidth\n\t\t\tsetIndicatorLeftPosition(tabLeftPos)\n\t\t\tsetIndicatorWidth(tabWidth)\n\t\t\ttabsListRef.current.scrollTo({\n\t\t\t\tleft: tabLeftPos,\n\t\t\t\tbehavior: 'smooth',\n\t\t\t})\n\t\t}\n\t}, [tabNodes, selectedTabIndex, scrollIntoView, tabsListRef])\n\n\tuseEffect(() => {\n\t\tsetTabIds(tabNodes.current.map((tab) => tab.id))\n\n\t\tlet selectedCount = 0\n\n\t\ttabNodes.current.forEach((tabElement) => {\n\t\t\tif (tabElement.hasAttribute('data-is-selected')) {\n\t\t\t\tselectedCount++\n\t\t\t}\n\t\t})\n\n\t\tif (selectedCount > 1) {\n\t\t\tconsole.error('Only one tab may use isSelected argument')\n\t\t}\n\t}, [tabNodes])\n\n\tuseEffect(() => {\n\t\tsetPanelIds(panelNodes.current.map((tab) => tab.id))\n\t}, [panelNodes])\n\n\tconst onClick = useCallback(\n\t\t(tabIndex: number, event: MouseEvent<HTMLButtonElement>) => {\n\t\t\tsetSelectedTabIndex(tabIndex)\n\n\t\t\tscrollIntoView(tabIndex)\n\n\t\t\t// invoke the callback function if it's provided as argument\n\t\t\tif (typeof onClickTab === 'function') {\n\t\t\t\tonClickTab(event, tabIndex)\n\t\t\t}\n\t\t},\n\t\t[onClickTab, scrollIntoView]\n\t)\n\n\t// Focus tab for keyboard & mouse navigation:\n\tconst focusTab = useCallback(\n\t\t(tabIndex: number, e: KeyboardEvent<HTMLButtonElement>) => {\n\t\t\te.preventDefault()\n\t\t\ttabNodes.current[tabIndex].focus()\n\t\t},\n\t\t[]\n\t)\n\n\tconst onKeyUp = useCallback(\n\t\t(tabIndex: number, e: KeyboardEvent<HTMLButtonElement>) => {\n\t\t\tconst leftArrow = 'ArrowLeft'\n\t\t\tconst rightArrow = 'ArrowRight'\n\t\t\tconst enterKey = 'Enter'\n\t\t\tconst spaceKey = ' '\n\n\t\t\tif (e.key === rightArrow) {\n\t\t\t\tconst nextTabIndex = (tabIndex + 1) % tabIds.length\n\t\t\t\tfocusTab(nextTabIndex, e)\n\t\t\t} else if (e.key === leftArrow) {\n\t\t\t\tconst prevTabIndex = (tabIndex + tabIds.length - 1) % tabIds.length\n\t\t\t\tfocusTab(prevTabIndex, e)\n\t\t\t} else if (e.key === enterKey || e.key === spaceKey) {\n\t\t\t\tsetSelectedTabIndex(tabIndex)\n\t\t\t}\n\t\t},\n\t\t[focusTab, tabIds.length]\n\t)\n\n\tconst contextValue = useMemo(\n\t\t() => ({\n\t\t\ttabNodes,\n\t\t\ttabIds,\n\t\t\tpanelNodes,\n\t\t\tpanelIds,\n\t\t\tselectedTabIndex,\n\t\t\tonClick,\n\t\t\tonKeyUp,\n\t\t\tsize,\n\t\t\ttabsListRef,\n\t\t}),\n\t\t[\n\t\t\ttabNodes,\n\t\t\ttabIds,\n\t\t\tpanelNodes,\n\t\t\tpanelIds,\n\t\t\tselectedTabIndex,\n\t\t\tonClick,\n\t\t\tonKeyUp,\n\t\t\tsize,\n\t\t\ttabsListRef,\n\t\t]\n\t)\n\n\treturn (\n\t\t<TabsContext.Provider value={contextValue}>\n\t\t\t<div\n\t\t\t\tclassName={classNames(s.tabs, className)}\n\t\t\t\t{...rest}\n\t\t\t\tstyle={{\n\t\t\t\t\t['--indicator-left-pos' as string]: `${indicatorLeftPosition}px`,\n\t\t\t\t\t['--indicator-width' as string]: `${indicatorWidth}px`,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</TabsContext.Provider>\n\t)\n}\n\ninterface TabsListProps {\n\t/**\n\t * `<Tabs.Tab />` as children\n\t */\n\tchildren: ReactNode\n\tclassName?: string\n}\n\nconst TabList = ({ children, className }: TabsListProps) => {\n\tconst { tabsListRef } = useTabsContext()\n\treturn (\n\t\t<div className={classNames(s['tablist-wrapper'], className)}>\n\t\t\t<ul className={s.tablist} role=\"tablist\" ref={tabsListRef}>\n\t\t\t\t{children}\n\t\t\t\t<li className={s.indicator} role=\"presentation\"></li>\n\t\t\t</ul>\n\t\t</div>\n\t)\n}\n\nconst Tabs = { Provider, TabList, Panel: TabPanel, Tab }\n\nexport type { TabsListProps }\nexport { Tabs }\n"],"names":["Provider","children","onClickTab","initialSelectedTabIndex","size","className","rest","selectedTabIndex","setSelectedTabIndex","useState","tabNodes","useRef","panelNodes","tabIds","setTabIds","panelIds","setPanelIds","indicatorWidth","setIndicatorWidth","indicatorLeftPosition","tabsListRef","scrollIntoView","useCallback","tabIndex","parentNode","useEffect","tabElem","tabLeftPos","tabWidth","setIndicatorLeftPosition","tab","selectedCount","onClick","event","focusTab","onKeyUp","leftArrow","rightArrow","enterKey","spaceKey","nextTabIndex","prevTabIndex","contextValue","useMemo","jsx","TabsContext","classNames","s","jsxs"],"mappings":";;;;;;;;AAyBkB,MACjBA,IAAA,CAAA;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,yBAAAC,IAAO;AAAA,EACP,MAAAC,IAAA;AAAA,EACA,WAAAC;AAAA,EACD,GAAAC;AACC;AAAgD,QAC/C,CAAAC,GAAAC,CAAA,IAAAC;AAAA,IACDN;AAAA,EACA,GACMO,IAAAC,EAAa,CAAA,CAA8B,GAC3CC,IAASD,EAAS,CAAA,CAAI,GACtB,CAACE,GAAAC,CAAU,IAAWL,EAAI,CAAA,CAAA,GAC1B,CAACM,GAAAC,CAAgB,IAAAP,EAAiB,CAAA,CAAA,GAClC,CAACQ,GAAAC,CAAuB,IAAAT,EAAA,CAAwB,GAChD,CAAAU,IAAkD,IAAAV,EAAA,CAAA,GAElDW,IAAAT,SAELU,IAAmBC,SAChB;AACH,cAAgBZ,EAAA,QAAAa,CAAA,GAAA;AACf,IAAAC,KAA0BA,iBACf;AAAA,MACV,UAAO;AAAA,MACP,OAAA;AAAA,MACA,QAAA;AAAA,IACF,CAAA;AAAA,EAGD,GAAA,CAAA,CAAA;AACC,EAAAC,EAAA,MAAA;AACD,IAAAjB,EAAIL,CAAwB;AAAA,EAE5B,GAAA,CAAAA,CAAgB,CAAA,GACfsB,EAAM,MAAA;AACN,UAAIC,IAAWhB,EAAA,SAAqB,GAAA;AACnC,QAAAgB,KAAMN,EAAa,SAAQ;AAC3B,YAAMO,IAAWD,EAAQ,YACzBE,IAAAF,EAAyB;AACzB,MAAAG,EAAkBF,CAAQ,GAC1BT,EAAYU,IAAiBR,EACtB,QAAA,SAAA;AAAA,QACN;QACA,UAAA;AAAA,MACF,CAAA;AAAA;E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;AAAA,MACA,QAAAG;AAAA,MACA,YAAAD;AAAA,MACA,UAAAG;AAAA,MACA,kBAAAR;AAAA,MACA,SAAAyB;AAAA,MACA,SAAAG;AAAA,MACA,MAAA/B;AAAA,MACD,aAAAgB;AAAA,IACA;AAAA,IAAA;AAAA,MAECV;AAAA,MACAG;AAAA,MACAD;AAAA,MACAG;AAAA,MACAR;AAAA,MACAyB;AAAA,MACAG;AAAA,MACA/B;AAAA,MAAAgB;AAAA,IAEF;AAAA,EAEA;AAEE,SAAC,gBAAAwB,EAAAC,EAAA,UAAA,EAAA,OAAAH,GAAA,UAAA,gBAAAE;AAAA,IAAA;AAAA,IAAA;AAAA,MAEC,WAAGE,EAAAC,EAAA,MAAA1C,CAAA;AAAA,MACJ;MAAO;QAEL,wBAAmC,GAAAc,CAAc;AAAA,QACnD,qBAAA,GAAAF,CAAA;AAAA,MAEC;AAAA,MAAA,UAAAhB;AAAA;EAIL,EAAA,CAAA;AAUA,OACS,CAAA,EAAA,UAAAA,sBAA+B;AACvC;AAGI,SAAA,gBAAA2C,EAAA,OAAA,EAAA,WAAAE,EAAAC,EAAA,iBAAA,GAAA1C,CAAA,GAAA,UAAA,gBAAA2C,EAAA,MAAA,EAAA,WAAAD,EAAA,SAAA,MAAA,WAAA,KAAA3B,GAAA,UAAA;AAAA,IAAAnB;AAAA,IAGH,gBAAA2C,EAAA,MAAA,EAAA,WAAAG,EAAA,WAAA,MAAA,eAAA,CAAA;AAAA,EAEF,EAAA,CAAA,EAAA,CAAA;AAEA;"}
|
package/package.json
CHANGED
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { memo as
|
|
3
|
-
import { Text as
|
|
4
|
-
import {
|
|
5
|
-
import { IconTwitter16 as h } from "@hashicorp/flight-icons/svg-react/twitter-16";
|
|
6
|
-
import { IconLinkedin16 as u } from "@hashicorp/flight-icons/svg-react/linkedin-16";
|
|
7
|
-
import { IconLink16 as f } from "@hashicorp/flight-icons/svg-react/link-16";
|
|
8
|
-
import { IconMail16 as w } from "@hashicorp/flight-icons/svg-react/mail-16";
|
|
1
|
+
import { jsxs as a, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { memo as d } from "react";
|
|
3
|
+
import { Text as p } from "../../../components/text/index.js";
|
|
4
|
+
import { FlightIcon as o } from "../../../components/flight-icon/index.js";
|
|
9
5
|
import { CardPrimitives as i } from "../primitives.js";
|
|
10
|
-
import
|
|
11
|
-
const
|
|
6
|
+
import s from "./style.module.css.js";
|
|
7
|
+
const h = /* @__PURE__ */ new Map([
|
|
12
8
|
// null signals that we don't want to render any icon
|
|
13
9
|
["hashicorp.com", null],
|
|
14
10
|
[
|
|
15
11
|
"twitter.com",
|
|
16
|
-
/* @__PURE__ */ o
|
|
12
|
+
/* @__PURE__ */ n(o, { name: "twitter", "data-testid": "wpl-personcard-twitter-icon" })
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"github.com",
|
|
16
|
+
/* @__PURE__ */ n(o, { name: "github", "data-testid": "wpl-personcard-github-icon" })
|
|
17
17
|
],
|
|
18
|
-
["github.com", /* @__PURE__ */ o(p, { "data-testid": "wpl-personcard-github-icon" })],
|
|
19
18
|
[
|
|
20
19
|
"linkedin.com",
|
|
21
|
-
/* @__PURE__ */ o
|
|
20
|
+
/* @__PURE__ */ n(o, { name: "linkedin", "data-testid": "wpl-personcard-linkedin-icon" })
|
|
22
21
|
],
|
|
23
|
-
[
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
[
|
|
23
|
+
"mailto:",
|
|
24
|
+
/* @__PURE__ */ n(o, { name: "mail", "data-testid": "wpl-personcard-mail-icon" })
|
|
25
|
+
]
|
|
26
|
+
]), u = d(function({ url: c }) {
|
|
27
|
+
const { protocol: r, host: e } = new URL(c), t = h.get(r === "mailto:" ? "mailto:" : e);
|
|
28
|
+
return t === null ? null : /* @__PURE__ */ n("div", { className: s.thumbnailIcon, children: t ?? /* @__PURE__ */ n(o, { name: "link", "data-testid": "wpl-personcard-link-icon" }) });
|
|
29
|
+
}), w = ({
|
|
28
30
|
link: l,
|
|
29
|
-
thumbnail:
|
|
30
|
-
name:
|
|
31
|
-
location:
|
|
32
|
-
bio:
|
|
33
|
-
productBadges:
|
|
34
|
-
}) => /* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
/* @__PURE__ */
|
|
31
|
+
thumbnail: c,
|
|
32
|
+
name: r,
|
|
33
|
+
location: e,
|
|
34
|
+
bio: t,
|
|
35
|
+
productBadges: m
|
|
36
|
+
}) => /* @__PURE__ */ a(i.Root, { link: l, withArrow: !1, "aria-label": r, children: [
|
|
37
|
+
/* @__PURE__ */ a("div", { className: s.thumbnailContainer, children: [
|
|
38
|
+
/* @__PURE__ */ n(i.PersonThumbnail, { ...c }),
|
|
39
|
+
/* @__PURE__ */ n(u, { url: l })
|
|
38
40
|
] }),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
|
|
41
|
+
/* @__PURE__ */ a(i.Content, { children: [
|
|
42
|
+
/* @__PURE__ */ a("div", { children: [
|
|
43
|
+
/* @__PURE__ */ n(i.Heading, { children: r }),
|
|
44
|
+
e ? /* @__PURE__ */ n(p.Body, { tag: "p", size: "200", className: s.location, children: e }) : null
|
|
43
45
|
] }),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
t ? /* @__PURE__ */ n(i.Description, { children: t }) : null,
|
|
47
|
+
m && m?.length > 0 ? /* @__PURE__ */ n(i.ProductBadges, { badges: m }) : null
|
|
46
48
|
] })
|
|
47
49
|
] });
|
|
48
|
-
|
|
50
|
+
w.displayName = "PersonCard";
|
|
49
51
|
export {
|
|
50
|
-
|
|
52
|
+
w as PersonCard
|
|
51
53
|
};
|
|
52
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/patterns/card/person-card/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react'\nimport { Text } from '../../../components/text'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/patterns/card/person-card/index.tsx"],"sourcesContent":["import { memo, type ReactNode } from 'react'\nimport { Text } from '../../../components/text'\nimport { FlightIcon } from '../../../components/flight-icon'\nimport type { ProductBadgesProps, ThumbnailProps } from '../types'\nimport { CardPrimitives } from '../primitives'\nimport s from './style.module.css'\n\ninterface PersonCardProps {\n\tthumbnail: ThumbnailProps\n\tlink: string\n\tname: string\n\tlocation?: string\n\tbio?: string\n\tproductBadges?: ProductBadgesProps['badges']\n}\n\n// Map of hostnames to icons.\n/* eslint-disable react/jsx-key */\nconst iconMap = new Map<string, ReactNode>([\n\t// null signals that we don't want to render any icon\n\t['hashicorp.com', null],\n\t[\n\t\t'twitter.com',\n\t\t<FlightIcon name=\"twitter\" data-testid={'wpl-personcard-twitter-icon'} />,\n\t],\n\t[\n\t\t'github.com',\n\t\t<FlightIcon name=\"github\" data-testid={'wpl-personcard-github-icon'} />,\n\t],\n\t[\n\t\t'linkedin.com',\n\t\t<FlightIcon name=\"linkedin\" data-testid={'wpl-personcard-linkedin-icon'} />,\n\t],\n\t[\n\t\t'mailto:',\n\t\t<FlightIcon name=\"mail\" data-testid={'wpl-personcard-mail-icon'} />,\n\t],\n])\n/* eslint-enable react/jsx-key */\n\nconst Icon = memo(function Icon({ url }: { url: string }) {\n\tconst { protocol, host } = new URL(url)\n\tconst icon = iconMap.get(protocol === 'mailto:' ? 'mailto:' : host)\n\n\t// If the icon value is null, don't render an icon\n\tif (icon === null) {\n\t\treturn null\n\t}\n\n\t// Render the icon or the default icon if the icon value is undefined\n\treturn (\n\t\t<div className={s.thumbnailIcon}>\n\t\t\t{icon ?? (\n\t\t\t\t<FlightIcon name=\"link\" data-testid={'wpl-personcard-link-icon'} />\n\t\t\t)}\n\t\t</div>\n\t)\n})\n\nconst PersonCard = ({\n\tlink,\n\tthumbnail,\n\tname,\n\tlocation,\n\tbio,\n\tproductBadges,\n}: PersonCardProps) => {\n\treturn (\n\t\t<CardPrimitives.Root link={link} withArrow={false} aria-label={name}>\n\t\t\t<div className={s.thumbnailContainer}>\n\t\t\t\t<CardPrimitives.PersonThumbnail {...thumbnail} />\n\t\t\t\t<Icon url={link} />\n\t\t\t</div>\n\t\t\t<CardPrimitives.Content>\n\t\t\t\t<div>\n\t\t\t\t\t<CardPrimitives.Heading>{name}</CardPrimitives.Heading>\n\t\t\t\t\t{location ? (\n\t\t\t\t\t\t<Text.Body tag=\"p\" size=\"200\" className={s.location}>\n\t\t\t\t\t\t\t{location}\n\t\t\t\t\t\t</Text.Body>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t\t{bio ? (\n\t\t\t\t\t<CardPrimitives.Description>{bio}</CardPrimitives.Description>\n\t\t\t\t) : null}\n\t\t\t\t{productBadges && productBadges?.length > 0 ? (\n\t\t\t\t\t<CardPrimitives.ProductBadges badges={productBadges} />\n\t\t\t\t) : null}\n\t\t\t</CardPrimitives.Content>\n\t\t</CardPrimitives.Root>\n\t)\n}\n\nPersonCard.displayName = 'PersonCard'\n\nexport type { PersonCardProps }\nexport { PersonCard }\n"],"names":["iconMap","jsx","FlightIcon","Icon","memo","url","protocol","host","icon","PersonCard","link","thumbnail","name","location","bio","productBadges","jsxs","CardPrimitives","Text"],"mappings":";;;;;;AAkBA,MAAMA,wBAAc,IAAuB;AAAA;AAAA,EAE1C,CAAC,iBAAiB,IAAI;AAAA,EACtB;AAAA,IACC;AAAA,IACA,gBAAAC,EAACC,GAAA,EAAW,MAAK,WAAU,eAAa,8BAAA,CAA+B;AAAA,EAAA;AAAA,EAExE;AAAA,IACC;AAAA,IACA,gBAAAD,EAACC,GAAA,EAAW,MAAK,UAAS,eAAa,6BAAA,CAA8B;AAAA,EAAA;AAAA,EAEtE;AAAA,IACC;AAAA,IACA,gBAAAD,EAACC,GAA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A,gBAAAb,EAACgB,EAAe,aAAf,EAA4B,aAAI,IAC9B;AAAA,IACHF,KAAiBA,GAAe,SAAS,IACzC,gBAAAd,EAACgB,EAAe,eAAf,EAA6B,QAAQF,EAAA,CAAe,IAClD;AAAA,EAAA,EAAA,CACL;AAAA,GACD;AAIFN,EAAW,cAAc;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as o, jsx as
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as y } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as v } from "react";
|
|
3
3
|
import { Card as w } from "../../components/card/index.js";
|
|
4
4
|
import { Text as n } from "../../components/text/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { FlightIcon as C } from "../../components/flight-icon/index.js";
|
|
6
6
|
import { ProductBadge as x } from "../product-badge/index.js";
|
|
7
7
|
import { LogoThumbnail as P, PersonThumbnail as B, Thumbnail as D } from "./thumbnails/index.js";
|
|
8
|
-
import
|
|
8
|
+
import r from "./style.module.css.js";
|
|
9
9
|
import L from "classnames";
|
|
10
10
|
const d = v((a, t) => {
|
|
11
11
|
const {
|
|
@@ -20,7 +20,7 @@ const d = v((a, t) => {
|
|
|
20
20
|
return /* @__PURE__ */ o(
|
|
21
21
|
w,
|
|
22
22
|
{
|
|
23
|
-
className: L(
|
|
23
|
+
className: L(r.card, f),
|
|
24
24
|
href: s,
|
|
25
25
|
onClickCapture: h,
|
|
26
26
|
isExternal: N,
|
|
@@ -28,26 +28,26 @@ const d = v((a, t) => {
|
|
|
28
28
|
"aria-label": b,
|
|
29
29
|
children: [
|
|
30
30
|
g,
|
|
31
|
-
/* @__PURE__ */
|
|
31
|
+
/* @__PURE__ */ e("div", { className: r.cta, children: i ? /* @__PURE__ */ e(C, { name: "arrow-right", size: 24 }) : null })
|
|
32
32
|
]
|
|
33
33
|
}
|
|
34
34
|
);
|
|
35
35
|
});
|
|
36
36
|
d.displayName = "CardPrimitives.Root";
|
|
37
|
-
const
|
|
37
|
+
const l = ({ items: a }) => /* @__PURE__ */ e("div", { className: r.meta, "data-testid": "wpl-card-meta", children: /* @__PURE__ */ e(n.Label, { children: a.map((t, i) => {
|
|
38
38
|
const s = i === a.length - 1;
|
|
39
39
|
return /* @__PURE__ */ o(y, { children: [
|
|
40
40
|
t,
|
|
41
|
-
s ? null : /* @__PURE__ */
|
|
41
|
+
s ? null : /* @__PURE__ */ e("span", { className: r.metaSeparator, "aria-hidden": !0, children: "|" })
|
|
42
42
|
] });
|
|
43
43
|
}) }) });
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const m = ({ as: a = "h2", children: t }) => /* @__PURE__ */
|
|
44
|
+
l.displayName = "Meta";
|
|
45
|
+
const c = ({ children: a }) => /* @__PURE__ */ e("div", { className: r.content, "data-testid": "wpl-card-content", children: a });
|
|
46
|
+
c.displayName = "Content";
|
|
47
|
+
const m = ({ as: a = "h2", children: t }) => /* @__PURE__ */ e(n.DisplayExpressive, { tag: a, size: "200", className: r.heading, children: t });
|
|
48
48
|
m.displayName = "Heading";
|
|
49
|
-
const p = ({ badges: a, children: t }) => /* @__PURE__ */ o("div", { className:
|
|
50
|
-
a.map((i, s) => /* @__PURE__ */
|
|
49
|
+
const p = ({ badges: a, children: t }) => /* @__PURE__ */ o("div", { className: r.productBadges, "data-testid": "wpl-card-badges", children: [
|
|
50
|
+
a.map((i, s) => /* @__PURE__ */ e(
|
|
51
51
|
x,
|
|
52
52
|
{
|
|
53
53
|
productName: i,
|
|
@@ -58,15 +58,15 @@ const p = ({ badges: a, children: t }) => /* @__PURE__ */ o("div", { className:
|
|
|
58
58
|
t
|
|
59
59
|
] });
|
|
60
60
|
p.displayName = "ProductBadges";
|
|
61
|
-
const u = ({ children: a }) => /* @__PURE__ */
|
|
61
|
+
const u = ({ children: a }) => /* @__PURE__ */ e(n.Body, { tag: "p", size: "200", className: r.description, children: a });
|
|
62
62
|
u.displayName = "Description";
|
|
63
63
|
const M = {
|
|
64
64
|
Root: d,
|
|
65
65
|
Thumbnail: D,
|
|
66
66
|
PersonThumbnail: B,
|
|
67
67
|
LogoThumbnail: P,
|
|
68
|
-
Meta:
|
|
69
|
-
Content:
|
|
68
|
+
Meta: l,
|
|
69
|
+
Content: c,
|
|
70
70
|
Heading: m,
|
|
71
71
|
Description: u,
|
|
72
72
|
ProductBadges: p
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sources":["../../../src/patterns/card/primitives.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Card as MDSCard } from '../../components/card'\nimport { Text } from '../../components/text'\nimport {
|
|
1
|
+
{"version":3,"file":"primitives.js","sources":["../../../src/patterns/card/primitives.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Card as MDSCard } from '../../components/card'\nimport { Text } from '../../components/text'\nimport { FlightIcon } from '../../components/flight-icon'\nimport { ProductBadge } from '../product-badge'\nimport { Thumbnail, PersonThumbnail, LogoThumbnail } from './thumbnails'\nimport type {\n\tCardPrimitiveProps,\n\tMetaProps,\n\tContentProps,\n\tHeadingProps,\n\tProductBadgesProps,\n\tDescriptionProps,\n} from './types'\nimport s from './style.module.css'\nimport classNames from 'classnames'\n\nconst Root = forwardRef<HTMLDivElement, CardPrimitiveProps>((props, ref) => {\n\tconst {\n\t\twithArrow = true,\n\t\tlink,\n\t\tclickHandler,\n\t\tisExternal,\n\t\tchildren,\n\t\tclassName,\n\t\t'aria-label': ariaLabel,\n\t} = props\n\n\treturn (\n\t\t<MDSCard\n\t\t\tclassName={classNames(s.card, className)}\n\t\t\thref={link}\n\t\t\tonClickCapture={clickHandler}\n\t\t\tisExternal={isExternal}\n\t\t\tref={ref}\n\t\t\taria-label={ariaLabel}\n\t\t>\n\t\t\t{children}\n\t\t\t<div className={s.cta}>\n\t\t\t\t{withArrow ? <FlightIcon name=\"arrow-right\" size={24} /> : null}\n\t\t\t</div>\n\t\t</MDSCard>\n\t)\n})\n\nRoot.displayName = 'CardPrimitives.Root'\n\nconst Meta = ({ items }: MetaProps) => {\n\treturn (\n\t\t<div className={s.meta} data-testid=\"wpl-card-meta\">\n\t\t\t<Text.Label>\n\t\t\t\t{items.map((item, stableIdx) => {\n\t\t\t\t\tconst isLastItem = stableIdx === items.length - 1\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{item}\n\t\t\t\t\t\t\t{!isLastItem ? (\n\t\t\t\t\t\t\t\t<span className={s.metaSeparator} aria-hidden={true}>\n\t\t\t\t\t\t\t\t\t|\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</Text.Label>\n\t\t</div>\n\t)\n}\n\nMeta.displayName = 'Meta'\n\nconst Content = ({ children }: ContentProps) => {\n\treturn (\n\t\t<div className={s.content} data-testid=\"wpl-card-content\">\n\t\t\t{children}\n\t\t</div>\n\t)\n}\n\nContent.displayName = 'Content'\n\nconst Heading = ({ as = 'h2', children }: HeadingProps) => {\n\treturn (\n\t\t<Text.DisplayExpressive tag={as} size=\"200\" className={s.heading}>\n\t\t\t{children}\n\t\t</Text.DisplayExpressive>\n\t)\n}\n\nHeading.displayName = 'Heading'\n\nconst ProductBadges = ({ badges, children }: ProductBadgesProps) => {\n\treturn (\n\t\t<div className={s.productBadges} data-testid=\"wpl-card-badges\">\n\t\t\t{badges.map((badge, stableIdx) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ProductBadge\n\t\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\t\tkey={`product-badge-${stableIdx}`}\n\t\t\t\t\t\tproductName={badge}\n\t\t\t\t\t\thasDot={true}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t})}\n\t\t\t{children}\n\t\t</div>\n\t)\n}\n\nProductBadges.displayName = 'ProductBadges'\n\nconst Description = ({ children }: DescriptionProps) => {\n\treturn (\n\t\t<Text.Body tag=\"p\" size=\"200\" className={s.description}>\n\t\t\t{children}\n\t\t</Text.Body>\n\t)\n}\n\nDescription.displayName = 'Description'\n\nconst CardPrimitives = {\n\tRoot,\n\tThumbnail,\n\tPersonThumbnail,\n\tLogoThumbnail,\n\tMeta,\n\tContent,\n\tHeading,\n\tDescription,\n\tProductBadges,\n}\n\nexport { CardPrimitives }\n"],"names":["Root","forwardRef","props","ref","withArrow","link","clickHandler","isExternal","children","className","ariaLabel","jsxs","MDSCard","classNames","s","jsx","FlightIcon","Meta","items","Text","item","stableIdx","isLastItem","Fragment","Content","Heading","as","ProductBadges","badges","badge","ProductBadge","Description","CardPrimitives","Thumbnail","PersonThumbnail","LogoThumbnail"],"mappings":";;;;;;;;;AAiBA,MAAMA,IAAOC,EAA+C,CAACC,GAAOC,MAAQ;AAC3E,QAAM;AAAA,IACL,WAAAC,IAAY;AAAA,IACZ,MAAAC;AAAA,IACA,cAAAC;AAAA,IACA,YAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAcC;AAAA,EAAA,IACXR;AAEJ,SACC,gBAAAS;AAAA,IAACC;AAAAA,IAAA;AAAA,MACA,WAAWC,EAAWC,EAAE,MAAML,CAAS;AAAA,MACvC,MAAMJ;AAAA,MACN,gBAAgBC;AAAA,MAChB,YAAAC;AAAA,MACA,KAAAJ;AAAA,MACA,cAAYO;AAAA,MAEX,UAAA;AAAA,QAAAF;AAAA,QACD,gBAAAO,EAAC,OAAA,EAAI,WAAWD,EAAE,KAChB,UAAAV,IAAY,gBAAAW,EAACC,GAAA,EAAW,MAAK,eAAc,MAAM,GAAA,CAAI,IAAK,KAAA,CAC5D;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGH,CAAC;AAEDhB,EAAK,cAAc;AAEnB,MAAMiB,IAAO,CAAC,EAAE,OAAAC,QAEd,gBAAAH,EAAC,OAAA,EAAI,WAAWD,EAAE,MAAM,eAAY,iBACnC,UAAA,gBAAAC,EAACI,EAAK,OAAL,EACC,UAAAD,EA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