@stokr/components-library 4.1.0 → 4.1.2

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.
@@ -3,7 +3,7 @@ import { Fragment } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { InfoIcon } from "../InfoIcon/InfoIcon.js";
5
5
  import { Text } from "../Text/Text.styles.js";
6
- import stdin_default, { CheckboxPropTypes } from "../Checkbox/Checkbox.js";
6
+ import { Checkbox } from "../Checkbox/Checkbox.js";
7
7
  import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
8
8
  import { Container, InfoBox } from "./AgreementItem.styles.js";
9
9
  const AgreementItem = ({ title = "", text, checkbox, info = "" }) => /* @__PURE__ */ jsxs(Container, { children: [
@@ -12,7 +12,7 @@ const AgreementItem = ({ title = "", text, checkbox, info = "" }) => /* @__PURE_
12
12
  text && /* @__PURE__ */ jsx("p", { children: text })
13
13
  ] }),
14
14
  checkbox && /* @__PURE__ */ jsx(ComponentWrapper, { noPaddingHorizontal: true, noPaddingBottom: true, children: /* @__PURE__ */ jsx(
15
- stdin_default,
15
+ Checkbox,
16
16
  {
17
17
  id: checkbox.id,
18
18
  name: checkbox.name || checkbox.id,
@@ -32,7 +32,16 @@ AgreementItem.propTypes = {
32
32
  title: PropTypes.string,
33
33
  text: PropTypes.string.isRequired,
34
34
  info: PropTypes.string,
35
- checkbox: PropTypes.shape(CheckboxPropTypes).isRequired
35
+ checkbox: PropTypes.shape({
36
+ id: PropTypes.string.isRequired,
37
+ name: PropTypes.string,
38
+ text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
39
+ value: PropTypes.string,
40
+ checked: PropTypes.bool,
41
+ onChange: PropTypes.func,
42
+ onBlur: PropTypes.func,
43
+ onClick: PropTypes.func
44
+ }).isRequired
36
45
  };
37
46
  export {
38
47
  AgreementItem
@@ -2,13 +2,16 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { useNavigate } from "react-router-dom";
5
+ import { safeUrl } from "../../utils/safeUrl.js";
5
6
  import { StyledBackButtonExternal, BackButtonIcon, StyledBackButton, StyledWindowBackButton } from "./BackButton.styles.js";
6
7
  const BackButton = ({ children, to, href }) => {
7
8
  const navigate = useNavigate();
8
- return href ? /* @__PURE__ */ jsxs(StyledBackButtonExternal, { href, children: [
9
+ const safeHref = safeUrl(href);
10
+ const safeTo = typeof to === "string" ? safeUrl(to) : to;
11
+ return safeHref ? /* @__PURE__ */ jsxs(StyledBackButtonExternal, { href: safeHref, children: [
9
12
  /* @__PURE__ */ jsx(BackButtonIcon, {}),
10
13
  children
11
- ] }) : to ? /* @__PURE__ */ jsxs(StyledBackButton, { to, children: [
14
+ ] }) : safeTo ? /* @__PURE__ */ jsxs(StyledBackButton, { to: safeTo, children: [
12
15
  /* @__PURE__ */ jsx(BackButtonIcon, {}),
13
16
  children
14
17
  ] }) : /* @__PURE__ */ jsxs(StyledWindowBackButton, { onClick: () => navigate(-1), children: [
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useState, useRef, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
+ import { safeUrl } from "../../utils/safeUrl.js";
4
5
  import { Container, ImageWrapper, LoaderWrapper, LoaderImage, Image, Content, Category, TextWrapper, BottomRow, StyledButton } from "./BlogPost.styles.js";
5
6
  import { loaderGif } from "../StokrLoader/StokrLoader.js";
6
7
  import { Breakdown } from "../breakdown/Breakdown.js";
@@ -73,7 +74,7 @@ const BlogPost = ({
73
74
  StyledButton,
74
75
  {
75
76
  onClick: () => {
76
- if (link && !onClick) window.location.href = link;
77
+ if (safeUrl(link) && !onClick) window.location.href = link;
77
78
  if (onClick) onClick();
78
79
  },
79
80
  children: CTAText
@@ -0,0 +1,16 @@
1
+ import { CSSProperties, InputHTMLAttributes, ReactNode } from 'react';
2
+ export declare const CheckBoxCaption: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultChecked'> {
4
+ id: string;
5
+ text?: ReactNode;
6
+ /** Heading above the checkbox. */
7
+ label?: string;
8
+ value?: string | number | boolean;
9
+ large?: boolean;
10
+ error?: boolean;
11
+ touched?: boolean;
12
+ textStyle?: CSSProperties;
13
+ marginTop?: boolean;
14
+ }
15
+ export declare const Checkbox: ({ id, name, text, label, value, checked, large, error, touched, onChange, onBlur, onFocus, textStyle, disabled, onClick, marginTop, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
16
+ export default Checkbox;
@@ -1,7 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import "react";
3
2
  import styled from "styled-components";
4
- import PropTypes from "prop-types";
5
3
  import { MaterialIcon } from "../MaterialIcon/MaterialIcon.js";
6
4
  import { Wrapper, Label, Input } from "./Checkbox.styles.js";
7
5
  const CheckBoxCaption = styled.div`
@@ -32,9 +30,9 @@ const Checkbox = ({
32
30
  },
33
31
  marginTop,
34
32
  ...props
35
- }) => /* @__PURE__ */ jsxs(Wrapper, { marginTop, children: [
33
+ }) => /* @__PURE__ */ jsxs(Wrapper, { $marginTop: marginTop, children: [
36
34
  label && /* @__PURE__ */ jsx(Label, { error: error && touched, htmlFor: id, children: label }),
37
- /* @__PURE__ */ jsxs(Input, { error, large, disabled, children: [
35
+ /* @__PURE__ */ jsxs(Input, { $error: error, $large: large, $disabled: disabled, children: [
38
36
  /* @__PURE__ */ jsx(
39
37
  "input",
40
38
  {
@@ -52,33 +50,13 @@ const Checkbox = ({
52
50
  }
53
51
  ),
54
52
  /* @__PURE__ */ jsxs("label", { htmlFor: id, style: textStyle, children: [
55
- /* @__PURE__ */ jsx(MaterialIcon, { name: "check", size: 18 }),
53
+ /* @__PURE__ */ jsx(MaterialIcon, { name: "check", weight: 600, size: 18 }),
56
54
  text
57
55
  ] })
58
56
  ] })
59
57
  ] });
60
- const CheckboxPropTypes = {
61
- id: PropTypes.string.isRequired,
62
- name: PropTypes.string,
63
- text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
64
- label: PropTypes.string,
65
- value: PropTypes.string,
66
- checked: PropTypes.bool,
67
- large: PropTypes.bool,
68
- error: PropTypes.bool,
69
- touched: PropTypes.bool,
70
- onChange: PropTypes.func,
71
- onBlur: PropTypes.func,
72
- onFocus: PropTypes.func,
73
- onClick: PropTypes.func,
74
- textStyle: PropTypes.object,
75
- defaultChecked: PropTypes.bool
76
- };
77
- Checkbox.propTypes = CheckboxPropTypes;
78
- var stdin_default = Checkbox;
79
58
  export {
80
59
  CheckBoxCaption,
81
60
  Checkbox,
82
- CheckboxPropTypes,
83
- stdin_default as default
61
+ Checkbox as default
84
62
  };
@@ -0,0 +1,14 @@
1
+ export declare const Wrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
2
+ $marginTop?: boolean;
3
+ }>> & string;
4
+ export declare const Label: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "active" | "autoHeightLabel" | "isUp" | "error"> & {
5
+ autoHeightLabel?: boolean;
6
+ isUp?: boolean;
7
+ active?: boolean;
8
+ error?: boolean;
9
+ }, never>> & string;
10
+ export declare const Input: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
11
+ $error?: boolean;
12
+ $large?: boolean;
13
+ $disabled?: boolean;
14
+ }>> & string;
@@ -1,12 +1,10 @@
1
1
  import styled from "styled-components";
2
2
  import { Label as Label$1 } from "../Input/Input.styles.js";
3
3
  import theme from "../../styles/theme.js";
4
- const Wrapper = styled.div.withConfig({
5
- shouldForwardProp: (props) => !["marginTop"].includes(props)
6
- })`
4
+ const Wrapper = styled.div`
7
5
  position: relative;
8
6
  display: block;
9
- margin-top: ${({ marginTop }) => marginTop && "7px"};
7
+ margin-top: ${({ $marginTop }) => $marginTop && "7px"};
10
8
  `;
11
9
  const Label = styled(Label$1)`
12
10
  position: relative;
@@ -15,9 +13,7 @@ const Label = styled(Label$1)`
15
13
  font-size: 10px;
16
14
  margin-bottom: 5px;
17
15
  `;
18
- const Input = styled.div.withConfig({
19
- shouldForwardProp: (props) => !["error", "large", "disabled"].includes(props)
20
- })`
16
+ const Input = styled.div`
21
17
  position: relative;
22
18
 
23
19
  & > input {
@@ -45,39 +41,33 @@ const Input = styled.div.withConfig({
45
41
 
46
42
  p {
47
43
  margin: 0;
48
- }
49
-
50
- ${(props) => props.error && `color: ${theme.cWarning}`};
51
-
52
- p {
53
44
  font-size: 12px;
54
45
  }
55
46
 
56
- &:before {
57
- display: block;
58
- position: absolute;
59
- }
47
+ ${(props) => props.$error && `color: ${theme.cWarning}`};
60
48
 
61
49
  &:before {
62
50
  content: '';
51
+ display: block;
52
+ position: absolute;
63
53
  top: 0;
64
54
  left: 0;
65
55
  width: 16px;
66
56
  height: 16px;
67
57
  border-radius: 3px;
68
58
  border: 1px solid #9b9b9b;
59
+ background-color: transparent;
69
60
  box-shadow: none;
70
- transition: border-color 0.2s;
61
+ transition:
62
+ background-color 0.2s ease,
63
+ border-color 0.2s ease;
71
64
 
72
- ${(props) => props.large && `
65
+ ${(props) => props.$large && `
73
66
  width: 20px;
74
67
  height: 20px;
75
68
  border-radius: 4px;
76
69
  `}
77
- ${(props) => props.disabled && `
78
- background-color: #9b9b9b30;
79
-
80
- `}
70
+ ${(props) => props.$disabled && `background-color: #9b9b9b30;`}
81
71
  }
82
72
 
83
73
  > [data-icon] {
@@ -86,11 +76,14 @@ const Input = styled.div.withConfig({
86
76
  left: -1px;
87
77
  width: 18px;
88
78
  height: 18px;
89
- color: transparent;
79
+ color: #fff;
80
+ opacity: 0;
81
+ clip-path: inset(0 100% 0 0);
82
+ transition:
83
+ clip-path 0.15s ease-in,
84
+ opacity 0.15s ease-in;
90
85
 
91
- ${(props) => props.large && `
92
- top: -1px;
93
- left: -1px;
86
+ ${(props) => props.$large && `
94
87
  width: 22px;
95
88
  height: 22px;
96
89
  `};
@@ -100,13 +93,36 @@ const Input = styled.div.withConfig({
100
93
  &:focus + label,
101
94
  &:hover + label {
102
95
  &:before {
103
- border-color: ${(props) => props.disabled ? "none" : theme.cPrimary};
96
+ border-color: ${(props) => props.$disabled ? "none" : theme.cPrimary};
104
97
  }
105
98
  }
106
99
 
100
+ &:focus-visible + label:before {
101
+ box-shadow:
102
+ 0 0 0 2px ${theme.cWhite},
103
+ 0 0 0 4px ${theme.cPrimary};
104
+ }
105
+
107
106
  &:checked + label {
107
+ &:before {
108
+ background-color: ${(props) => props.$disabled ? "#9b9b9b" : theme.cPrimary};
109
+ border-color: ${(props) => props.$disabled ? "#9b9b9b" : theme.cPrimary};
110
+ }
111
+
108
112
  > [data-icon] {
109
- color: ${() => theme.cPrimary};
113
+ opacity: 1;
114
+ clip-path: inset(0 0 0 0);
115
+ transition:
116
+ clip-path 0.25s ease-out 0.08s,
117
+ opacity 0.1s ease-out 0.08s;
118
+ }
119
+ }
120
+
121
+ @media (prefers-reduced-motion: reduce) {
122
+ & + label,
123
+ & + label:before,
124
+ & + label > [data-icon] {
125
+ transition: none !important;
110
126
  }
111
127
  }
112
128
  }
@@ -4,11 +4,13 @@ import PropTypes from "prop-types";
4
4
  import { MaterialIcon } from "../MaterialIcon/MaterialIcon.js";
5
5
  import { CardContainer, IconBlock, IconCopy, CardTitle, CardDescription } from "./ChecklistCard.styles.js";
6
6
  import { colors } from "../../styles/colors.js";
7
+ import { safeUrl } from "../../utils/safeUrl.js";
7
8
  import SvgWarningFilled from "../../static/images/warning-filled.svg.js";
8
9
  import { Link } from "react-router-dom";
9
10
  const ICON_MAP = {
10
11
  done: {
11
12
  material: "check",
13
+ weight: 600,
12
14
  color: colors.freshGreen
13
15
  },
14
16
  missing: {
@@ -31,8 +33,8 @@ const ChecklistCard = ({
31
33
  isClickable = true,
32
34
  ...rest
33
35
  }) => {
34
- const { icon, material, color } = ICON_MAP[iconState] || ICON_MAP["missing"];
35
- const iconElement = material ? /* @__PURE__ */ jsx(MaterialIcon, { name: material, size: 20, color }) : /* @__PURE__ */ jsx("span", { style: { display: "inline-flex", width: 20, height: 20, color }, children: icon });
36
+ const { icon, material, weight, color } = ICON_MAP[iconState] || ICON_MAP["missing"];
37
+ const iconElement = material ? /* @__PURE__ */ jsx(MaterialIcon, { name: material, size: 20, color, weight }) : /* @__PURE__ */ jsx("span", { style: { display: "inline-flex", width: 20, height: 20, color }, children: icon });
36
38
  const content = /* @__PURE__ */ jsxs(
37
39
  CardContainer,
38
40
  {
@@ -51,7 +53,7 @@ const ChecklistCard = ({
51
53
  ]
52
54
  }
53
55
  );
54
- if (link && !onClick && !disabled) {
56
+ if (link && (typeof link !== "string" || safeUrl(link)) && !onClick && !disabled) {
55
57
  return /* @__PURE__ */ jsx(Link, { to: link, tabIndex: 0, "aria-disabled": disabled, style: { textDecoration: "none", color: "inherit" }, children: content });
56
58
  }
57
59
  return content;
@@ -2,4 +2,4 @@
2
2
  * The Material Symbols (`<variant>/<name>[-fill]`) the library's own components draw. The host registers them with
3
3
  * `registerMaterialIcons`; a component whose icon is not registered renders it empty.
4
4
  */
5
- export declare const requiredMaterialIcons: readonly ["outlined/add_circle", "outlined/cancel-fill", "outlined/check", "outlined/check_circle-fill", "outlined/chevron_left", "outlined/chevron_right", "outlined/close", "outlined/content_copy", "outlined/edit", "outlined/info", "outlined/info-fill", "outlined/keyboard_arrow_down", "outlined/search_activity", "outlined/visibility", "outlined/visibility_off", "outlined/warning"];
5
+ export declare const requiredMaterialIcons: readonly ["outlined/add_circle", "outlined/cancel-fill", "outlined/check", "outlined/check@600", "outlined/check_circle-fill", "outlined/chevron_left", "outlined/chevron_right", "outlined/close", "outlined/content_copy", "outlined/edit", "outlined/info", "outlined/info-fill", "outlined/keyboard_arrow_down", "outlined/search_activity", "outlined/visibility", "outlined/visibility_off", "outlined/warning"];
@@ -2,6 +2,7 @@ const requiredMaterialIcons = [
2
2
  "outlined/add_circle",
3
3
  "outlined/cancel-fill",
4
4
  "outlined/check",
5
+ "outlined/check@600",
5
6
  "outlined/check_circle-fill",
6
7
  "outlined/chevron_left",
7
8
  "outlined/chevron_right",
@@ -2,6 +2,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
3
  import styled from "styled-components";
4
4
  import { colors } from "../../styles/colors.js";
5
+ import { safeUrl } from "../../utils/safeUrl.js";
5
6
  import { InfoIcon } from "../InfoIcon/InfoIcon.js";
6
7
  import { ArrowSimple } from "../icons/ArrowSimple.js";
7
8
  import { getCurrencyConfig, getCurrencyIcon, formatAmountForDisplay } from "../../utils/formatCurrencyValue.js";
@@ -227,7 +228,7 @@ const DetailItem = ({ label, value, tooltip, placeholder, isCustom, href, target
227
228
  if (isCustom && value) {
228
229
  return value;
229
230
  }
230
- if (href) {
231
+ if (safeUrl(href)) {
231
232
  return /* @__PURE__ */ jsxs(ExternalLink, { href, target: target || "_blank", rel: "noopener noreferrer", children: [
232
233
  /* @__PURE__ */ jsx(ExternalLinkIconImg, { src: externalLinkIcon, alt: "" }),
233
234
  value || placeholder || "-"
@@ -3,6 +3,7 @@ import "react";
3
3
  import styled, { keyframes } from "styled-components";
4
4
  import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
5
5
  import { colors } from "../../styles/colors.js";
6
+ import { safeUrl } from "../../utils/safeUrl.js";
6
7
  import { Button } from "../Button/Button.styles.js";
7
8
  import { DetailRows } from "./DetailRows.js";
8
9
  import { CodeWrapper } from "./PaymentDisplay.js";
@@ -85,7 +86,7 @@ const PaymentPendingCard = ({
85
86
  Button,
86
87
  {
87
88
  as: actionHref ? "a" : "button",
88
- href: actionHref,
89
+ href: safeUrl(actionHref),
89
90
  target: actionHref ? "_blank" : void 0,
90
91
  rel: actionHref ? "noopener noreferrer" : void 0,
91
92
  onClick: onActionClick,
@@ -3,6 +3,7 @@ import "react";
3
3
  import styled from "styled-components";
4
4
  import { ComponentWrapper } from "../ComponentWrapper/ComponentWrapper.styles.js";
5
5
  import { colors } from "../../styles/colors.js";
6
+ import { safeUrl } from "../../utils/safeUrl.js";
6
7
  import { Button } from "../Button/Button.styles.js";
7
8
  import { CodeWrapper, AmountIcon, AmountValue, AmountCurrency } from "./PaymentDisplay.js";
8
9
  import { DetailsToggle } from "./DetailsToggle.js";
@@ -115,7 +116,7 @@ const PaymentSuccessCard = ({
115
116
  ActionButton,
116
117
  {
117
118
  as: secondaryActionHref ? "a" : "button",
118
- href: secondaryActionHref,
119
+ href: safeUrl(secondaryActionHref),
119
120
  target: secondaryActionHref ? "_blank" : void 0,
120
121
  rel: secondaryActionHref ? "noopener noreferrer" : void 0,
121
122
  onClick: onSecondaryActionClick,
@@ -126,7 +127,7 @@ const PaymentSuccessCard = ({
126
127
  ]
127
128
  }
128
129
  ),
129
- primaryActionLabel && /* @__PURE__ */ jsx(ActionButton, { as: primaryActionHref ? "a" : "button", href: primaryActionHref, onClick: onPrimaryActionClick, children: primaryActionLabel })
130
+ primaryActionLabel && /* @__PURE__ */ jsx(ActionButton, { as: primaryActionHref ? "a" : "button", href: safeUrl(primaryActionHref), onClick: onPrimaryActionClick, children: primaryActionLabel })
130
131
  ] }),
131
132
  children
132
133
  ] }) });
@@ -2,11 +2,15 @@ import { jsx } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { Link } from "react-router-dom";
5
+ import { safeUrl } from "../../utils/safeUrl.js";
5
6
  const isExternalUrl = (to) => {
6
7
  if (typeof to !== "string" || to === "") return false;
7
8
  return /^([a-z][a-z0-9+.-]*:|\/\/)/i.test(to);
8
9
  };
9
10
  const SmartLink = ({ to, children, ...rest }) => {
11
+ if (typeof to === "string" && to && !safeUrl(to)) {
12
+ return /* @__PURE__ */ jsx("a", { ...rest, children });
13
+ }
10
14
  if (isExternalUrl(to)) {
11
15
  return /* @__PURE__ */ jsx("a", { href: to, ...rest, children });
12
16
  }
package/dist/index.d.ts CHANGED
@@ -188,7 +188,8 @@ export declare const Background: AnyComponent
188
188
  export declare const HeroVideoBlock: AnyComponent
189
189
  export declare const BasicTable: AnyComponent
190
190
  export declare const ChartLegend: AnyComponent
191
- export declare const Checkbox: AnyComponent, CheckBoxCaption: AnyComponent
191
+ export { Checkbox, CheckBoxCaption } from './components/Checkbox/Checkbox'
192
+ export type { CheckboxProps } from './components/Checkbox/Checkbox'
192
193
  export declare const ComponentScroll: AnyComponent
193
194
  export declare const MemoCryptoAddress: AnyComponent, CryptoAddress: AnyComponent
194
195
  export declare const CryptoAddressWrapper: AnyComponent
@@ -240,6 +241,7 @@ export declare const StepControllerProvider: AnyComponent, StepControllerContext
240
241
  export declare const StepControllerConsumer: AnyComponent
241
242
  export declare const SmartLink: AnyComponent
242
243
  export declare const isExternalUrl: (url: unknown) => boolean
244
+ export { safeUrl } from './utils/safeUrl'
243
245
  export declare const Switch: AnyComponent
244
246
  export declare const Tabs: AnyComponent, Tab: AnyComponent
245
247
  export declare const Breakdown: AnyComponent
package/dist/index.js CHANGED
@@ -65,6 +65,7 @@ import { SectionTitle } from "./components/SectionTitle/SectionTitle.styles.js";
65
65
  import { StepController } from "./components/StepController/StepController.js";
66
66
  import { StepControllerConsumer, StepControllerContext, StepControllerProvider } from "./components/StepController/StepControllerContext.js";
67
67
  import { SmartLink, isExternalUrl } from "./components/SmartLink/SmartLink.js";
68
+ import { safeUrl } from "./utils/safeUrl.js";
68
69
  import { Switch } from "./components/Switch/Switch.js";
69
70
  import { Tabs } from "./components/Tabs/Tabs.js";
70
71
  import { Text } from "./components/Text/Text.styles.js";
@@ -420,6 +421,7 @@ export {
420
421
  roundTo,
421
422
  default4 as rwd,
422
423
  rwdMax,
424
+ safeUrl,
423
425
  sanitizeAmountInput,
424
426
  saveAs,
425
427
  scrollToElement,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The URL when it is safe to put in an `href` or navigate to, otherwise `undefined`. Allows http(s), mailto, tel,
3
+ * protocol-relative and relative URLs; blocks every other scheme (`javascript:`, `data:`, `vbscript:`, `blob:`, ...),
4
+ * including ones hidden with spaces or control characters, which browsers ignore when parsing.
5
+ */
6
+ export declare const safeUrl: (url: unknown) => string | undefined;
@@ -0,0 +1,10 @@
1
+ const ALLOWED_SCHEMES = ["http:", "https:", "mailto:", "tel:"];
2
+ const safeUrl = (url) => {
3
+ if (typeof url !== "string" || url === "") return void 0;
4
+ const scheme = url.replace(/[\u0000- \u007f]/g, "").match(/^[a-z][a-z0-9+.-]*:/i);
5
+ if (scheme && !ALLOWED_SCHEMES.includes(scheme[0].toLowerCase())) return void 0;
6
+ return url;
7
+ };
8
+ export {
9
+ safeUrl
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",
@@ -22,7 +22,8 @@
22
22
  },
23
23
  "sideEffects": [
24
24
  "**/*.css",
25
- "./dist/styles/global.js"
25
+ "./dist/styles/global.js",
26
+ "./src/storybook/materialIcons.ts"
26
27
  ],
27
28
  "repository": {
28
29
  "type": "git",