@stokr/components-library 4.2.3 → 4.2.4
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/components/Checkbox/Checkbox.styles.d.ts +1 -0
- package/dist/components/FAQ/FAQ.d.ts +29 -0
- package/dist/components/FAQ/FAQ.js +18 -18
- package/dist/components/FAQ/FAQ.styles.d.ts +38 -0
- package/dist/components/FAQ/FAQ.styles.js +58 -1
- package/dist/components/Input/Input.d.ts +3 -0
- package/dist/components/Input/Input.js +5 -2
- package/dist/components/Input/Input.styles.d.ts +4 -0
- package/dist/components/Input/Input.styles.js +57 -0
- package/dist/components/Input/Select.d.ts +57 -0
- package/dist/components/Input/Select.js +71 -94
- package/dist/components/Input/Select.styles.d.ts +79 -0
- package/dist/components/Input/Select.styles.js +68 -1
- package/dist/components/StepSidebar/MobileStepProgress.d.ts +12 -0
- package/dist/components/StepSidebar/MobileStepProgress.js +14 -0
- package/dist/components/StepSidebar/MobileStepProgress.styles.d.ts +15 -0
- package/dist/components/StepSidebar/MobileStepProgress.styles.js +42 -0
- package/dist/components/StepSidebar/StepProgress.d.ts +14 -0
- package/dist/components/StepSidebar/StepProgress.js +14 -0
- package/dist/components/StepSidebar/StepProgress.styles.d.ts +30 -0
- package/dist/components/StepSidebar/StepProgress.styles.js +103 -0
- package/dist/components/StepSidebar/StepSidebar.d.ts +34 -0
- package/dist/components/StepSidebar/StepSidebar.js +56 -0
- package/dist/components/StepSidebar/StepSidebar.styles.d.ts +54 -0
- package/dist/components/StepSidebar/StepSidebar.styles.js +171 -0
- package/dist/index.d.ts +21 -5
- package/dist/index.js +6 -0
- package/dist/styles/borderedField.d.ts +11 -0
- package/dist/styles/borderedField.js +56 -0
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ export declare const Label: import('styled-components/dist/types').IStyledCompon
|
|
|
10
10
|
isUp?: boolean;
|
|
11
11
|
active?: boolean;
|
|
12
12
|
error?: boolean;
|
|
13
|
+
$variant?: import('../..').FieldVariant;
|
|
13
14
|
}>, "as" | "forwardedAs"> & {
|
|
14
15
|
as?: import('styled-components').WebTarget;
|
|
15
16
|
forwardedAs?: import('styled-components').WebTarget;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { FieldVariant } from '../../styles/borderedField';
|
|
3
|
+
import { FaqItems, FaqItem, FaqTitle, FaqContent, FaqText, FaqDropdownIcon } from './FAQ.styles';
|
|
4
|
+
export interface FAQEntry {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
/** A string or JSX, or an array of strings rendered as a bullet list. */
|
|
7
|
+
content: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface FAQProps {
|
|
10
|
+
items: readonly FAQEntry[];
|
|
11
|
+
/** Do not scroll the opened item into view. */
|
|
12
|
+
noScroll?: boolean;
|
|
13
|
+
/** Ref to a custom scrollbar (in a modal); scrolled to the bottom when an item opens. */
|
|
14
|
+
scrollRef?: RefObject<{
|
|
15
|
+
scrollToBottom: () => void;
|
|
16
|
+
} | null>;
|
|
17
|
+
/** Title style used inside the "view more" modal. */
|
|
18
|
+
modalViewMore?: boolean;
|
|
19
|
+
/** Smaller, indented text for answers given as a list of strings. */
|
|
20
|
+
withTextStyling?: boolean;
|
|
21
|
+
/** Prefix for data-cy: `{prefix}-accordion`, `{prefix}-item-{slug}-toggle`, etc. */
|
|
22
|
+
dataCyPrefix?: string;
|
|
23
|
+
/** `bordered`: each item is a card (sign-up redesign). Default keeps the plain list. */
|
|
24
|
+
variant?: FieldVariant;
|
|
25
|
+
}
|
|
26
|
+
/** Accordion of questions and answers; one item is open at a time. */
|
|
27
|
+
export declare const FAQ: (props: FAQProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export { FaqItems, FaqItem, FaqTitle, FaqContent, FaqText, FaqDropdownIcon };
|
|
29
|
+
export default FAQ;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { Text } from "../Text/Text.styles.js";
|
|
4
2
|
import { useState } from "react";
|
|
3
|
+
import { Text } from "../Text/Text.styles.js";
|
|
5
4
|
import { scrollToElement } from "../../utils/scrollUtils.js";
|
|
6
5
|
import { FaqItems, FaqItem, FaqTitle, FaqDropdownIcon, FaqContent, FaqText } from "./FAQ.styles.js";
|
|
7
6
|
function slugFromTitle(title) {
|
|
@@ -10,8 +9,17 @@ function slugFromTitle(title) {
|
|
|
10
9
|
return raw.toLowerCase().trim().slice(0, 48).replace(/\s+/g, "-").replace(/[^a-z0-9_-]/g, "");
|
|
11
10
|
}
|
|
12
11
|
const FAQ = (props) => {
|
|
13
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
items,
|
|
14
|
+
noScroll,
|
|
15
|
+
scrollRef,
|
|
16
|
+
modalViewMore,
|
|
17
|
+
withTextStyling,
|
|
18
|
+
dataCyPrefix = "faq",
|
|
19
|
+
variant = "default"
|
|
20
|
+
} = props;
|
|
14
21
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
22
|
+
const bordered = variant === "bordered";
|
|
15
23
|
const onTitleClick = (e, index) => {
|
|
16
24
|
e.persist();
|
|
17
25
|
const newActiveIndex = activeIndex === index ? null : index;
|
|
@@ -19,7 +27,7 @@ const FAQ = (props) => {
|
|
|
19
27
|
if (!noScroll && newActiveIndex !== null) {
|
|
20
28
|
if (scrollRef?.current) {
|
|
21
29
|
setTimeout(() => {
|
|
22
|
-
scrollRef?.current
|
|
30
|
+
scrollRef?.current?.scrollToBottom();
|
|
23
31
|
}, 0);
|
|
24
32
|
} else {
|
|
25
33
|
scrollToElement(e.target.parentElement, { offset: 20 });
|
|
@@ -35,9 +43,10 @@ const FAQ = (props) => {
|
|
|
35
43
|
return /* @__PURE__ */ jsx(FaqItems, { "data-cy": `${dataCyPrefix}-accordion`, children: items.map((item, index) => {
|
|
36
44
|
const titleSlug = slugFromTitle(item.title);
|
|
37
45
|
const itemCy = titleSlug ? `${dataCyPrefix}-item-${titleSlug}` : `${dataCyPrefix}-item-${index}`;
|
|
46
|
+
const list = Array.isArray(item.content) ? item.content : null;
|
|
38
47
|
return (
|
|
39
48
|
// eslint-disable-next-line @eslint-react/no-array-index-key -- FAQ order is content-defined
|
|
40
|
-
/* @__PURE__ */ jsxs(FaqItem, { "data-cy": `${itemCy}-wrap`, children: [
|
|
49
|
+
/* @__PURE__ */ jsxs(FaqItem, { "data-cy": `${itemCy}-wrap`, $variant: variant, children: [
|
|
41
50
|
/* @__PURE__ */ jsxs(
|
|
42
51
|
FaqTitle,
|
|
43
52
|
{
|
|
@@ -47,30 +56,21 @@ const FAQ = (props) => {
|
|
|
47
56
|
isActive: activeIndex === index,
|
|
48
57
|
onClick: (e) => onTitleClick(e, index),
|
|
49
58
|
modalViewMore,
|
|
59
|
+
$variant: variant,
|
|
50
60
|
children: [
|
|
51
61
|
item.title,
|
|
52
|
-
/* @__PURE__ */ jsx(FaqDropdownIcon, {})
|
|
62
|
+
/* @__PURE__ */ jsx(FaqDropdownIcon, { $variant: variant })
|
|
53
63
|
]
|
|
54
64
|
}
|
|
55
65
|
),
|
|
56
|
-
/* @__PURE__ */ jsx(FaqContent, { "data-cy": `${itemCy}-panel`, isOpened: activeIndex === index, children: !
|
|
66
|
+
/* @__PURE__ */ jsx(FaqContent, { "data-cy": `${itemCy}-panel`, isOpened: activeIndex === index, children: !list ? /* @__PURE__ */ jsx(FaqText, { $variant: variant, children: item.content }) : bordered ? /* @__PURE__ */ jsx(FaqText, { $variant: variant, children: /* @__PURE__ */ jsx("ul", { children: list.map((answer) => /* @__PURE__ */ jsx("li", { children: answer }, answer)) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
67
|
/* @__PURE__ */ jsx("br", {}),
|
|
58
|
-
/* @__PURE__ */ jsx(Text, { style: withTextStyling ? textStyling : {}, children: /* @__PURE__ */ jsx("ul", { children:
|
|
68
|
+
/* @__PURE__ */ jsx(Text, { style: withTextStyling ? textStyling : {}, children: /* @__PURE__ */ jsx("ul", { children: list.map((answer) => /* @__PURE__ */ jsx("li", { children: answer }, answer)) }) })
|
|
59
69
|
] }) })
|
|
60
70
|
] }, index)
|
|
61
71
|
);
|
|
62
72
|
}) });
|
|
63
73
|
};
|
|
64
|
-
FAQ.propTypes = {
|
|
65
|
-
items: PropTypes.arrayOf(
|
|
66
|
-
PropTypes.shape({
|
|
67
|
-
title: PropTypes.node.isRequired,
|
|
68
|
-
content: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.node]).isRequired
|
|
69
|
-
})
|
|
70
|
-
).isRequired,
|
|
71
|
-
/** Prefix for data-cy: `{prefix}-accordion`, `{prefix}-item-{slug}-toggle`, etc. */
|
|
72
|
-
dataCyPrefix: PropTypes.string
|
|
73
|
-
};
|
|
74
74
|
export {
|
|
75
75
|
FAQ,
|
|
76
76
|
FaqContent,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FieldVariant } from '../../styles/borderedField';
|
|
2
|
+
export declare const FaqItems: import('styled-components/dist/types').IStyledComponentBase<"web", Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
3
|
+
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
4
|
+
}> & string;
|
|
5
|
+
export declare const FaqDropdownIcon: import('styled-components/dist/types').IStyledComponentBase<"web", Omit<import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
6
|
+
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
7
|
+
}, {
|
|
8
|
+
$variant?: FieldVariant;
|
|
9
|
+
}>, "children"> & Partial<Pick<import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
10
|
+
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
11
|
+
}, {
|
|
12
|
+
$variant?: FieldVariant;
|
|
13
|
+
}>, "children">>> & string;
|
|
14
|
+
export declare const FaqItem: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
15
|
+
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
16
|
+
}, {
|
|
17
|
+
center?: boolean;
|
|
18
|
+
customContainerStyle?: string;
|
|
19
|
+
$variant?: FieldVariant;
|
|
20
|
+
}>> & string;
|
|
21
|
+
export declare const FaqTitle: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "style"> & {
|
|
22
|
+
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
23
|
+
}, {
|
|
24
|
+
uppercase?: boolean;
|
|
25
|
+
white?: boolean;
|
|
26
|
+
center?: boolean;
|
|
27
|
+
hideIcon?: boolean;
|
|
28
|
+
isActive?: boolean;
|
|
29
|
+
modalViewMore?: boolean;
|
|
30
|
+
$variant?: FieldVariant;
|
|
31
|
+
}>> & string;
|
|
32
|
+
export declare const FaqContent: any;
|
|
33
|
+
export declare const FaqText: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
34
|
+
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
35
|
+
}, {
|
|
36
|
+
largeSpacing?: boolean;
|
|
37
|
+
$variant?: FieldVariant;
|
|
38
|
+
}>> & string;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
2
|
import { Collapse } from "react-collapse";
|
|
3
3
|
import theme from "../../styles/theme.js";
|
|
4
|
+
import { colors } from "../../styles/colors.js";
|
|
5
|
+
import { BORDERED_BORDER } from "../../styles/borderedField.js";
|
|
6
|
+
import { space, radius } from "../../styles/spacing.js";
|
|
7
|
+
import { elevation } from "../../styles/elevation.js";
|
|
8
|
+
import { typography } from "../../styles/typography.js";
|
|
4
9
|
import { glyph } from "../MaterialIcon/glyph.js";
|
|
5
10
|
const FaqItems = styled.div`
|
|
6
11
|
position: relative;
|
|
@@ -20,6 +25,15 @@ const FaqDropdownIcon = styled.span.attrs({
|
|
|
20
25
|
margin-top: -10px;
|
|
21
26
|
transform: rotate(0);
|
|
22
27
|
transition: 0.3s transform;
|
|
28
|
+
|
|
29
|
+
${(props) => props.$variant === "bordered" && css`
|
|
30
|
+
width: 16px;
|
|
31
|
+
height: 16px;
|
|
32
|
+
font-size: 16px;
|
|
33
|
+
top: 22px;
|
|
34
|
+
right: ${space[5]};
|
|
35
|
+
margin-top: 0;
|
|
36
|
+
`}
|
|
23
37
|
`;
|
|
24
38
|
const FaqItem = styled.div.withConfig({
|
|
25
39
|
shouldForwardProp: (props) => !["center", "customContainerStyle"].includes(props)
|
|
@@ -28,6 +42,22 @@ const FaqItem = styled.div.withConfig({
|
|
|
28
42
|
margin-top: 30px;
|
|
29
43
|
}
|
|
30
44
|
|
|
45
|
+
${(props) => props.$variant === "bordered" && css`
|
|
46
|
+
padding: 0;
|
|
47
|
+
border: ${BORDERED_BORDER};
|
|
48
|
+
border-radius: ${radius.lg};
|
|
49
|
+
background: ${colors.white};
|
|
50
|
+
box-shadow: ${elevation.xs};
|
|
51
|
+
|
|
52
|
+
.ReactCollapse--collapse {
|
|
53
|
+
transition: height 0.3s ease;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
& + & {
|
|
57
|
+
margin-top: ${space[2]};
|
|
58
|
+
}
|
|
59
|
+
`}
|
|
60
|
+
|
|
31
61
|
${(props) => props.center && `
|
|
32
62
|
text-align:center;
|
|
33
63
|
`}
|
|
@@ -59,6 +89,19 @@ const FaqTitle = styled.button.withConfig({
|
|
|
59
89
|
color: inherit;
|
|
60
90
|
}
|
|
61
91
|
|
|
92
|
+
${(props) => props.$variant === "bordered" && css`
|
|
93
|
+
${typography.bodyMdCallout}
|
|
94
|
+
padding: ${space[5]} 52px ${space[5]} ${space[5]};
|
|
95
|
+
border-radius: ${radius.lg};
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
transition: padding-bottom 0.3s ease;
|
|
98
|
+
${props.isActive && `padding-bottom: ${space[3]};`}
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
color: ${theme.cBlack};
|
|
102
|
+
}
|
|
103
|
+
`}
|
|
104
|
+
|
|
62
105
|
${(props) => props.uppercase && `
|
|
63
106
|
text-transform:uppercase;
|
|
64
107
|
font-weight:700;
|
|
@@ -121,6 +164,20 @@ const FaqText = styled.div.withConfig({
|
|
|
121
164
|
padding-bottom: 30px;
|
|
122
165
|
|
|
123
166
|
`}
|
|
167
|
+
|
|
168
|
+
${(props) => props.$variant === "bordered" && css`
|
|
169
|
+
padding: 0 ${space[5]} ${space[5]};
|
|
170
|
+
font-size: 14px;
|
|
171
|
+
line-height: 20px;
|
|
172
|
+
font-weight: 400;
|
|
173
|
+
color: ${theme.cBlack};
|
|
174
|
+
|
|
175
|
+
ul {
|
|
176
|
+
margin: 0;
|
|
177
|
+
padding-left: 20px;
|
|
178
|
+
list-style: disc;
|
|
179
|
+
}
|
|
180
|
+
`}
|
|
124
181
|
`;
|
|
125
182
|
export {
|
|
126
183
|
FaqContent,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { Wrapper, Label, InputWrap } from './Input.styles';
|
|
3
|
+
import { FieldVariant } from '../../styles/borderedField';
|
|
3
4
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value'> {
|
|
4
5
|
id: string;
|
|
5
6
|
name?: string;
|
|
@@ -17,6 +18,8 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
17
18
|
autoHeightLabel?: boolean;
|
|
18
19
|
inputWrapStyle?: CSSProperties;
|
|
19
20
|
wrapperStyle?: CSSProperties;
|
|
21
|
+
/** `bordered`: boxed field with a static label above (sign-up redesign). Default keeps the floating-label look. */
|
|
22
|
+
variant?: FieldVariant;
|
|
20
23
|
}
|
|
21
24
|
/** Text input with a floating label, built for Formik (`onChange`/`onBlur` receive the event). */
|
|
22
25
|
declare const Input: (props: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,6 +18,7 @@ const Input = (props) => {
|
|
|
18
18
|
inputWrapStyle,
|
|
19
19
|
wrapperStyle,
|
|
20
20
|
autoHeightLabel,
|
|
21
|
+
variant = "default",
|
|
21
22
|
// Destructure these so they don't get spread to the input
|
|
22
23
|
onChange: onChangeProp,
|
|
23
24
|
onBlur: onBlurProp,
|
|
@@ -49,7 +50,7 @@ const Input = (props) => {
|
|
|
49
50
|
onFocusProp?.(e);
|
|
50
51
|
checkLabel(true);
|
|
51
52
|
};
|
|
52
|
-
return /* @__PURE__ */ jsxs(Wrapper, { inverted, style: wrapperStyle, children: [
|
|
53
|
+
return /* @__PURE__ */ jsxs(Wrapper, { inverted, style: wrapperStyle, $variant: variant, children: [
|
|
53
54
|
label && /* @__PURE__ */ jsx(
|
|
54
55
|
Label,
|
|
55
56
|
{
|
|
@@ -58,6 +59,7 @@ const Input = (props) => {
|
|
|
58
59
|
error: Boolean(error && touched),
|
|
59
60
|
htmlFor: id,
|
|
60
61
|
autoHeightLabel,
|
|
62
|
+
$variant: variant,
|
|
61
63
|
children: label
|
|
62
64
|
}
|
|
63
65
|
),
|
|
@@ -69,6 +71,7 @@ const Input = (props) => {
|
|
|
69
71
|
disabled,
|
|
70
72
|
style: inputWrapStyle,
|
|
71
73
|
autoHeightLabel,
|
|
74
|
+
$variant: variant,
|
|
72
75
|
children: /* @__PURE__ */ jsx(
|
|
73
76
|
"input",
|
|
74
77
|
{
|
|
@@ -82,7 +85,7 @@ const Input = (props) => {
|
|
|
82
85
|
readOnly,
|
|
83
86
|
placeholder,
|
|
84
87
|
disabled,
|
|
85
|
-
style: { WebkitAppearance: "none", WebkitBorderRadius: 0 },
|
|
88
|
+
style: variant === "bordered" ? { WebkitAppearance: "none" } : { WebkitAppearance: "none", WebkitBorderRadius: 0 },
|
|
86
89
|
...restProps
|
|
87
90
|
}
|
|
88
91
|
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FieldVariant } from '../../styles/borderedField';
|
|
1
2
|
export declare const Label: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "style"> & {
|
|
2
3
|
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
3
4
|
}, {
|
|
@@ -5,6 +6,7 @@ export declare const Label: import('styled-components/dist/types').IStyledCompon
|
|
|
5
6
|
isUp?: boolean;
|
|
6
7
|
active?: boolean;
|
|
7
8
|
error?: boolean;
|
|
9
|
+
$variant?: FieldVariant;
|
|
8
10
|
}>> & string;
|
|
9
11
|
export declare const InputWrap: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
10
12
|
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
@@ -13,9 +15,11 @@ export declare const InputWrap: import('styled-components/dist/types').IStyledCo
|
|
|
13
15
|
disabled?: boolean;
|
|
14
16
|
dashboard?: boolean;
|
|
15
17
|
error?: boolean;
|
|
18
|
+
$variant?: FieldVariant;
|
|
16
19
|
}>> & string;
|
|
17
20
|
export declare const Wrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Merged<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
18
21
|
style?: import('react').CSSProperties | import('styled-components/dist/types').CSSPropertiesWithVars;
|
|
19
22
|
}, {
|
|
20
23
|
inverted?: boolean;
|
|
24
|
+
$variant?: FieldVariant;
|
|
21
25
|
}>> & string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import theme from "../../styles/theme.js";
|
|
3
|
+
import { borderedFieldLabel, borderedFieldBox, borderedFieldText, borderedFieldPlaceholder, borderedFieldFocus, borderedFieldError, borderedFieldDisabled, BORDERED_BORDER } from "../../styles/borderedField.js";
|
|
4
|
+
import { radius } from "../../styles/spacing.js";
|
|
3
5
|
const Label = styled.label.withConfig({
|
|
4
6
|
shouldForwardProp: (props) => !["autoHeightLabel", "isUp", "active", "error"].includes(props)
|
|
5
7
|
})`
|
|
@@ -38,6 +40,18 @@ const Label = styled.label.withConfig({
|
|
|
38
40
|
${(props) => props.error && `
|
|
39
41
|
color: ${theme.cWarning};
|
|
40
42
|
`}
|
|
43
|
+
|
|
44
|
+
${(props) => props.$variant === "bordered" && css`
|
|
45
|
+
position: static;
|
|
46
|
+
z-index: auto;
|
|
47
|
+
top: auto;
|
|
48
|
+
left: auto;
|
|
49
|
+
height: auto;
|
|
50
|
+
transform: none;
|
|
51
|
+
pointer-events: auto;
|
|
52
|
+
${borderedFieldLabel}
|
|
53
|
+
color: ${props.error ? theme.cWarning : theme.cBlack};
|
|
54
|
+
`}
|
|
41
55
|
`;
|
|
42
56
|
const InputWrap = styled.div.withConfig({
|
|
43
57
|
shouldForwardProp: (props) => !["autoHeightLabel", "disabled", "dashboard", "error"].includes(props)
|
|
@@ -115,6 +129,42 @@ const InputWrap = styled.div.withConfig({
|
|
|
115
129
|
${(props) => props.error && `
|
|
116
130
|
color: ${theme.cWarning};
|
|
117
131
|
`}
|
|
132
|
+
|
|
133
|
+
${(props) => props.$variant === "bordered" && css`
|
|
134
|
+
& > input {
|
|
135
|
+
${borderedFieldBox}
|
|
136
|
+
${borderedFieldText}
|
|
137
|
+
height: 44px;
|
|
138
|
+
|
|
139
|
+
&::placeholder {
|
|
140
|
+
${borderedFieldPlaceholder}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&:hover {
|
|
144
|
+
border-color: ${theme.cLightGrey};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&:focus {
|
|
148
|
+
${borderedFieldFocus}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
${props.error && css`
|
|
152
|
+
&,
|
|
153
|
+
&:hover,
|
|
154
|
+
&:focus {
|
|
155
|
+
${borderedFieldError}
|
|
156
|
+
}
|
|
157
|
+
`}
|
|
158
|
+
|
|
159
|
+
${props.disabled && css`
|
|
160
|
+
&,
|
|
161
|
+
&:hover,
|
|
162
|
+
&:focus {
|
|
163
|
+
${borderedFieldDisabled}
|
|
164
|
+
}
|
|
165
|
+
`}
|
|
166
|
+
}
|
|
167
|
+
`}
|
|
118
168
|
`;
|
|
119
169
|
const Wrapper = styled.div.withConfig({
|
|
120
170
|
shouldForwardProp: (props) => !["inverted"].includes(props)
|
|
@@ -146,6 +196,13 @@ const Wrapper = styled.div.withConfig({
|
|
|
146
196
|
}
|
|
147
197
|
}
|
|
148
198
|
`}
|
|
199
|
+
|
|
200
|
+
${(props) => props.$variant === "bordered" && css`
|
|
201
|
+
input:-webkit-autofill {
|
|
202
|
+
border: ${BORDERED_BORDER};
|
|
203
|
+
border-radius: ${radius.lg};
|
|
204
|
+
}
|
|
205
|
+
`}
|
|
149
206
|
`;
|
|
150
207
|
export {
|
|
151
208
|
InputWrap,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { GroupBase, Props as ReactSelectProps } from 'react-select';
|
|
3
|
+
import { FieldVariant } from '../../styles/borderedField';
|
|
4
|
+
import { SelectIcon, SelectMenu, SelectOption, SelectControl, SelectWrapper, SelectMenuList, SelectContainer, SelectValueContainer } from './Select.styles';
|
|
5
|
+
export type SelectValue = string | number;
|
|
6
|
+
export interface SelectOptionItem {
|
|
7
|
+
key?: string;
|
|
8
|
+
value: SelectValue;
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
/** URL string (rendered as <img>) or a React node (e.g. an SVG flag) shown left of the label. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** What `onChange` / `onBlur` / `onFocus` receive. `value` is the option value, or an array of values in `multiple` mode. */
|
|
14
|
+
export interface SelectChange {
|
|
15
|
+
name: string;
|
|
16
|
+
value: any;
|
|
17
|
+
}
|
|
18
|
+
type PassthroughProps = ReactSelectProps<any, boolean, GroupBase<any>>;
|
|
19
|
+
type OwnPropKeys = 'id' | 'name' | 'value' | 'options' | 'placeholder' | 'onChange' | 'onBlur' | 'onFocus' | 'formatCreateLabel' | 'dataCy' | 'variant';
|
|
20
|
+
export interface SelectProps extends Omit<PassthroughProps, OwnPropKeys> {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
/** string|number for single mode, array for multi mode. */
|
|
25
|
+
value?: SelectValue | readonly SelectValue[];
|
|
26
|
+
options: readonly SelectOptionItem[];
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Shown as an error state once `touched` is true. */
|
|
29
|
+
error?: boolean;
|
|
30
|
+
touched?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** Lets the user type to filter the options. */
|
|
33
|
+
search?: boolean;
|
|
34
|
+
/** Lets the user add a value that is not in `options`. */
|
|
35
|
+
creatable?: boolean;
|
|
36
|
+
/** Multi-select: checkbox options + chips list rendered below the field. */
|
|
37
|
+
multiple?: boolean;
|
|
38
|
+
/** Multi mode: values that cannot be removed (chip ✕ disabled, can't be deselected). */
|
|
39
|
+
lockedValues?: readonly SelectValue[];
|
|
40
|
+
/** Max menu height in px. */
|
|
41
|
+
menuHeight?: number;
|
|
42
|
+
/** Heading shown above the chips list in multi mode (default: "Selected"). */
|
|
43
|
+
selectedLabel?: string;
|
|
44
|
+
/** Input-like floating label behavior: label starts in-field, moves up on focus/value. Ignored when `bordered`. */
|
|
45
|
+
floatingLabel?: boolean;
|
|
46
|
+
formatCreateLabel?: (input: string) => ReactNode;
|
|
47
|
+
onChange?(field: SelectChange): void;
|
|
48
|
+
onBlur?(field: SelectChange): void;
|
|
49
|
+
onFocus?(field: SelectChange): void;
|
|
50
|
+
/** Playwright / autocapture: `data-cy` selector on the react-select control. */
|
|
51
|
+
dataCy?: string;
|
|
52
|
+
/** `bordered`: boxed control with a static label above (sign-up redesign). Default keeps the underline look. */
|
|
53
|
+
variant?: FieldVariant;
|
|
54
|
+
}
|
|
55
|
+
/** Dropdown with a floating label on react-select: single, searchable, multiple (checkboxes + chips) or creatable. */
|
|
56
|
+
declare const Select: (props: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export { Select, SelectControl, SelectMenu, SelectMenuList, SelectOption, SelectContainer, SelectValueContainer, SelectIcon, SelectWrapper, };
|