@windstream/react-shared-components 0.2.23 → 0.2.25
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/contentful/index.d.ts +1 -0
- package/dist/contentful/index.esm.js +2 -2
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +2 -2
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/next/index.esm.js +1 -1
- package/dist/next/index.esm.js.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/next/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/brand-button/index.tsx +2 -2
- package/src/components/link/index.test.tsx +42 -4
- package/src/components/link/index.tsx +8 -1
- package/src/contentful/blocks/breadcrumbs/index.tsx +3 -2
- package/src/contentful/blocks/find-kinetic/index.test.tsx +35 -0
- package/src/contentful/blocks/find-kinetic/index.tsx +33 -9
- package/src/contentful/blocks/find-kinetic/types.ts +1 -0
|
@@ -16,6 +16,7 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
|
|
|
16
16
|
title,
|
|
17
17
|
color = "dark",
|
|
18
18
|
maxWidth = true,
|
|
19
|
+
addTrailingSlash = false,
|
|
19
20
|
}) => {
|
|
20
21
|
const bgColorClasses: Record<ThemeKey, string> = {
|
|
21
22
|
blue: "bg-[#07B2E2]",
|
|
@@ -25,12 +26,22 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
|
|
|
25
26
|
white: "bg-white",
|
|
26
27
|
navy: "bg-[#00002D]",
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
// Trim leading/trailing slashes without a regex to avoid ReDoS on long
|
|
30
|
+
// runs of "/" (CodeQL: polynomial regular expression on uncontrolled data).
|
|
31
|
+
const trimSlashes = (value: string) => {
|
|
32
|
+
let start = 0;
|
|
33
|
+
let end = value.length;
|
|
34
|
+
while (start < end && value.charCodeAt(start) === 47 /* "/" */) start += 1;
|
|
35
|
+
while (end > start && value.charCodeAt(end - 1) === 47 /* "/" */) end -= 1;
|
|
36
|
+
return value.slice(start, end);
|
|
37
|
+
};
|
|
38
|
+
const cleanedLocalPathPrefix = trimSlashes(localPathPrefix ?? "");
|
|
39
|
+
const normalizedLocalPathPrefix = cleanedLocalPathPrefix
|
|
40
|
+
? `/${cleanedLocalPathPrefix}`
|
|
30
41
|
: "";
|
|
31
42
|
|
|
32
43
|
const getLocationHref = (code: string) =>
|
|
33
|
-
`${normalizedLocalPathPrefix}/${code.toLowerCase()}`;
|
|
44
|
+
`${normalizedLocalPathPrefix}/${code.toLowerCase()}${addTrailingSlash ? "/" : ""}`;
|
|
34
45
|
|
|
35
46
|
return (
|
|
36
47
|
<div
|
|
@@ -120,16 +131,21 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
|
|
|
120
131
|
key={`item-list-3-${index}`}
|
|
121
132
|
className={`${image ? "" : "w-[172px]"}`}
|
|
122
133
|
>
|
|
123
|
-
<Link
|
|
134
|
+
<Link
|
|
135
|
+
href={getLocationHref(item.code)}
|
|
136
|
+
className="label1"
|
|
137
|
+
>
|
|
124
138
|
{item.name}
|
|
125
139
|
</Link>
|
|
126
140
|
</li>
|
|
127
|
-
) :
|
|
141
|
+
) : (
|
|
142
|
+
<li key={`empty-3-${index}`} aria-hidden="true" />
|
|
143
|
+
)
|
|
128
144
|
);
|
|
129
145
|
})()}
|
|
130
146
|
</ul>
|
|
131
147
|
{!image && (
|
|
132
|
-
<ul className="hidden xl:grid xl:grid-cols-4
|
|
148
|
+
<ul className="hidden gap-x-20 gap-y-5 xl:grid xl:grid-cols-4">
|
|
133
149
|
{(() => {
|
|
134
150
|
const sortedList = [...list].sort((a, b) =>
|
|
135
151
|
a.name.localeCompare(b.name)
|
|
@@ -145,12 +161,20 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
|
|
|
145
161
|
}
|
|
146
162
|
return rearranged.map((item, index: number) =>
|
|
147
163
|
item ? (
|
|
148
|
-
<li
|
|
149
|
-
|
|
164
|
+
<li
|
|
165
|
+
key={`item-list-4-${index}`}
|
|
166
|
+
className="w-[172px]"
|
|
167
|
+
>
|
|
168
|
+
<Link
|
|
169
|
+
href={getLocationHref(item.code)}
|
|
170
|
+
className="label1"
|
|
171
|
+
>
|
|
150
172
|
{item.name}
|
|
151
173
|
</Link>
|
|
152
174
|
</li>
|
|
153
|
-
) :
|
|
175
|
+
) : (
|
|
176
|
+
<li key={`empty-4-${index}`} aria-hidden="true" />
|
|
177
|
+
)
|
|
154
178
|
);
|
|
155
179
|
})()}
|
|
156
180
|
</ul>
|