@mrshmllw/smores-react 16.7.1 → 16.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ButtonContainer/ButtonContainer.d.ts +32 -0
- package/dist/ButtonContainer/ButtonContainer.js +131 -0
- package/dist/ButtonContainer/ButtonContainer.js.map +1 -0
- package/dist/ButtonContainer/index.d.ts +2 -0
- package/dist/ButtonContainer/index.js +2 -0
- package/dist/ButtonContainer/index.js.map +1 -0
- package/dist/Dropdown/Dropdown.js +4 -4
- package/dist/Dropdown/Dropdown.js.map +1 -1
- package/dist/Textarea/Textarea.js +1 -1
- package/dist/Textarea/Textarea.js.map +1 -1
- package/dist/fields/components/CommonInput.d.ts +4 -2
- package/dist/fields/components/CommonInput.js +26 -21
- package/dist/fields/components/CommonInput.js.map +1 -1
- package/dist/fields/components/fieldStyles.d.ts +2 -0
- package/dist/fields/components/fieldStyles.js +1 -0
- package/dist/fields/components/fieldStyles.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FC, ReactElement } from 'react';
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
type ButtonElement = ReactElement<{
|
|
4
|
+
'aria-describedby'?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type ButtonContainerOrientation = 'vertical' | 'horizontal';
|
|
7
|
+
export type ButtonContainerSupportingMessage = {
|
|
8
|
+
/** Short plain text, e.g. reassurance copy. Required, so an icon never shows on its own */
|
|
9
|
+
text: string;
|
|
10
|
+
/** Optional decorative icon shown before the text */
|
|
11
|
+
icon?: IconDefinition;
|
|
12
|
+
};
|
|
13
|
+
export type ButtonContainerProps = {
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Main action. Shown first when vertical, last (right) when horizontal */
|
|
16
|
+
primaryButton: ButtonElement;
|
|
17
|
+
/** Optional supporting action */
|
|
18
|
+
secondaryButton?: ButtonElement;
|
|
19
|
+
/** Optional low-emphasis action. Shown last when vertical, first (left) when horizontal */
|
|
20
|
+
tertiaryButton?: ButtonElement;
|
|
21
|
+
/** Stack the buttons vertically or lay them out side by side */
|
|
22
|
+
orientation?: ButtonContainerOrientation;
|
|
23
|
+
/** Optional message shown below the buttons, e.g. reassurance copy */
|
|
24
|
+
supportingMessage?: ButtonContainerSupportingMessage;
|
|
25
|
+
/**
|
|
26
|
+
* Pin the container to the bottom of the viewport on mobile.
|
|
27
|
+
* On larger screens it always sits in the page flow.
|
|
28
|
+
*/
|
|
29
|
+
pinned?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare const ButtonContainer: FC<ButtonContainerProps>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, cloneElement, useEffect, useId, useRef, useState, } from 'react';
|
|
3
|
+
import styled, { css, useTheme } from 'styled-components';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
export const ButtonContainer = ({ className, primaryButton, secondaryButton, tertiaryButton, orientation = 'vertical', supportingMessage, pinned = true, }) => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const supportingTextId = useId();
|
|
8
|
+
const containerRef = useRef(null);
|
|
9
|
+
const [containerHeight, setContainerHeight] = useState(0);
|
|
10
|
+
// Reserve the pinned container's height in the page flow so it never covers content
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const element = containerRef.current;
|
|
13
|
+
if (!pinned || !element || typeof ResizeObserver === 'undefined')
|
|
14
|
+
return;
|
|
15
|
+
const observer = new ResizeObserver(() => {
|
|
16
|
+
setContainerHeight(element.getBoundingClientRect().height);
|
|
17
|
+
});
|
|
18
|
+
observer.observe(element);
|
|
19
|
+
return () => observer.disconnect();
|
|
20
|
+
}, [pinned]);
|
|
21
|
+
const hasSupportingMessage = Boolean(supportingMessage?.text?.trim());
|
|
22
|
+
const describedPrimaryButton = hasSupportingMessage
|
|
23
|
+
? cloneElement(primaryButton, {
|
|
24
|
+
'aria-describedby': [
|
|
25
|
+
primaryButton.props['aria-describedby'],
|
|
26
|
+
supportingTextId,
|
|
27
|
+
]
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.join(' '),
|
|
30
|
+
})
|
|
31
|
+
: primaryButton;
|
|
32
|
+
// DOM order follows the visual order so keyboard focus moves the way the buttons read
|
|
33
|
+
const buttons = orientation === 'horizontal'
|
|
34
|
+
? [tertiaryButton, secondaryButton, describedPrimaryButton]
|
|
35
|
+
: [describedPrimaryButton, secondaryButton, tertiaryButton];
|
|
36
|
+
return (_jsxs(_Fragment, { children: [pinned && _jsx(Spacer, { "aria-hidden": "true", $height: containerHeight }), _jsxs(Container, { ref: containerRef, className: className, $pinned: pinned, children: [_jsx(ButtonGroup, { $orientation: orientation, children: buttons.map((button, index) => button && _jsx(Fragment, { children: button }, index)) }), supportingMessage && hasSupportingMessage && (_jsxs(SupportingText, { id: supportingTextId, children: [supportingMessage.icon && (_jsx(SupportingIconContainer, { children: _jsx(FontAwesomeIcon, { icon: supportingMessage.icon, color: theme.color.icon.subtle }) })), supportingMessage.text] }))] })] }));
|
|
37
|
+
};
|
|
38
|
+
const desktopMediaQuery = '@media (min-width: 768px)';
|
|
39
|
+
const desktopVerticalButtonMaxWidth = '400px';
|
|
40
|
+
const desktopHorizontalButtonMinWidth = '160px';
|
|
41
|
+
const Spacer = styled.div(({ $height }) => css `
|
|
42
|
+
height: ${$height}px;
|
|
43
|
+
|
|
44
|
+
${desktopMediaQuery} {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
`);
|
|
48
|
+
const Container = styled.div(({ theme, $pinned }) => css `
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: ${theme.space[150]};
|
|
52
|
+
width: 100%;
|
|
53
|
+
// The library ships no CSS reset, so keep the pinned padding inside the viewport width
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
|
|
56
|
+
${$pinned &&
|
|
57
|
+
css `
|
|
58
|
+
position: fixed;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
left: 0;
|
|
61
|
+
right: 0;
|
|
62
|
+
z-index: ${theme.elevation.floating};
|
|
63
|
+
padding: ${theme.space[200]};
|
|
64
|
+
padding-bottom: calc(
|
|
65
|
+
${theme.space[200]} + env(safe-area-inset-bottom, 0px)
|
|
66
|
+
);
|
|
67
|
+
background-color: ${theme.color.surface.base[200]};
|
|
68
|
+
border-radius: ${theme.radius[200]} ${theme.radius[200]} 0 0;
|
|
69
|
+
|
|
70
|
+
${desktopMediaQuery} {
|
|
71
|
+
position: static;
|
|
72
|
+
z-index: auto;
|
|
73
|
+
padding: 0;
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
border-radius: 0;
|
|
76
|
+
}
|
|
77
|
+
`}
|
|
78
|
+
`);
|
|
79
|
+
// On desktop, horizontal buttons all match the width of the longest label
|
|
80
|
+
const ButtonGroup = styled.div(({ theme, $orientation }) => css `
|
|
81
|
+
display: grid;
|
|
82
|
+
gap: ${theme.space[150]};
|
|
83
|
+
|
|
84
|
+
${$orientation === 'vertical' &&
|
|
85
|
+
css `
|
|
86
|
+
${desktopMediaQuery} {
|
|
87
|
+
grid-template-columns: minmax(0, ${desktopVerticalButtonMaxWidth});
|
|
88
|
+
justify-content: center;
|
|
89
|
+
}
|
|
90
|
+
`}
|
|
91
|
+
|
|
92
|
+
${$orientation === 'horizontal' &&
|
|
93
|
+
css `
|
|
94
|
+
grid-auto-flow: column;
|
|
95
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
96
|
+
|
|
97
|
+
// On desktop the buttons share the width of the longest label, centred
|
|
98
|
+
${desktopMediaQuery} {
|
|
99
|
+
grid-auto-columns: minmax(${desktopHorizontalButtonMinWidth}, 1fr);
|
|
100
|
+
width: fit-content;
|
|
101
|
+
max-width: 100%;
|
|
102
|
+
margin: 0 auto;
|
|
103
|
+
}
|
|
104
|
+
`}
|
|
105
|
+
`);
|
|
106
|
+
// Figma icons use Font Awesome's square "full" bounding box (640 units),
|
|
107
|
+
// in which the glyph's 512 unit em height takes up 80% of the box
|
|
108
|
+
const SupportingIconContainer = styled.span(({ theme }) => css `
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
width: 20px;
|
|
113
|
+
height: 20px;
|
|
114
|
+
margin-right: ${theme.space['050']};
|
|
115
|
+
vertical-align: top;
|
|
116
|
+
|
|
117
|
+
svg {
|
|
118
|
+
width: 100%;
|
|
119
|
+
height: 80%;
|
|
120
|
+
overflow: visible;
|
|
121
|
+
}
|
|
122
|
+
`);
|
|
123
|
+
const SupportingText = styled.p(({ theme }) => css `
|
|
124
|
+
margin: 0;
|
|
125
|
+
font-size: ${theme.font.body[200].fontSize};
|
|
126
|
+
font-weight: ${theme.font.body[200].fontWeight};
|
|
127
|
+
line-height: ${theme.font.body[200].lineHeight};
|
|
128
|
+
color: ${theme.color.text.subtle};
|
|
129
|
+
text-align: center;
|
|
130
|
+
`);
|
|
131
|
+
//# sourceMappingURL=ButtonContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonContainer.js","sourceRoot":"","sources":["../../src/ButtonContainer/ButtonContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,QAAQ,EAER,YAAY,EACZ,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAgChE,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,EACxD,SAAS,EACT,aAAa,EACb,eAAe,EACf,c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C,GAAG,CAAC,CAAC,UAAU;aACrC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;;GAEjC,CACF,CAAA","sourcesContent":["import {\n FC,\n Fragment,\n ReactElement,\n cloneElement,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react'\nimport styled, { css, useTheme } from 'styled-components'\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\n\ntype ButtonElement = ReactElement<{ 'aria-describedby'?: string }>\n\nexport type ButtonContainerOrientation = 'vertical' | 'horizontal'\n\nexport type ButtonContainerSupportingMessage = {\n /** Short plain text, e.g. reassurance copy. Required, so an icon never shows on its own */\n text: string\n /** Optional decorative icon shown before the text */\n icon?: IconDefinition\n}\n\nexport type ButtonContainerProps = {\n className?: string\n /** Main action. Shown first when vertical, last (right) when horizontal */\n primaryButton: ButtonElement\n /** Optional supporting action */\n secondaryButton?: ButtonElement\n /** Optional low-emphasis action. Shown last when vertical, first (left) when horizontal */\n tertiaryButton?: ButtonElement\n /** Stack the buttons vertically or lay them out side by side */\n orientation?: ButtonContainerOrientation\n /** Optional message shown below the buttons, e.g. reassurance copy */\n supportingMessage?: ButtonContainerSupportingMessage\n /**\n * Pin the container to the bottom of the viewport on mobile.\n * On larger screens it always sits in the page flow.\n */\n pinned?: boolean\n}\n\nexport const ButtonContainer: FC<ButtonContainerProps> = ({\n className,\n primaryButton,\n secondaryButton,\n tertiaryButton,\n orientation = 'vertical',\n supportingMessage,\n pinned = true,\n}) => {\n const theme = useTheme()\n const supportingTextId = useId()\n const containerRef = useRef<HTMLDivElement>(null)\n const [containerHeight, setContainerHeight] = useState(0)\n\n // Reserve the pinned container's height in the page flow so it never covers content\n useEffect(() => {\n const element = containerRef.current\n if (!pinned || !element || typeof ResizeObserver === 'undefined') return\n\n const observer = new ResizeObserver(() => {\n setContainerHeight(element.getBoundingClientRect().height)\n })\n observer.observe(element)\n\n return () => observer.disconnect()\n }, [pinned])\n\n const hasSupportingMessage = Boolean(supportingMessage?.text?.trim())\n\n const describedPrimaryButton = hasSupportingMessage\n ? cloneElement(primaryButton, {\n 'aria-describedby': [\n primaryButton.props['aria-describedby'],\n supportingTextId,\n ]\n .filter(Boolean)\n .join(' '),\n })\n : primaryButton\n\n // DOM order follows the visual order so keyboard focus moves the way the buttons read\n const buttons =\n orientation === 'horizontal'\n ? [tertiaryButton, secondaryButton, describedPrimaryButton]\n : [describedPrimaryButton, secondaryButton, tertiaryButton]\n\n return (\n <>\n {pinned && <Spacer aria-hidden=\"true\" $height={containerHeight} />}\n <Container ref={containerRef} className={className} $pinned={pinned}>\n <ButtonGroup $orientation={orientation}>\n {buttons.map(\n (button, index) =>\n button && <Fragment key={index}>{button}</Fragment>,\n )}\n </ButtonGroup>\n {supportingMessage && hasSupportingMessage && (\n <SupportingText id={supportingTextId}>\n {supportingMessage.icon && (\n <SupportingIconContainer>\n <FontAwesomeIcon\n icon={supportingMessage.icon}\n color={theme.color.icon.subtle}\n />\n </SupportingIconContainer>\n )}\n {supportingMessage.text}\n </SupportingText>\n )}\n </Container>\n </>\n )\n}\n\nconst desktopMediaQuery = '@media (min-width: 768px)'\nconst desktopVerticalButtonMaxWidth = '400px'\nconst desktopHorizontalButtonMinWidth = '160px'\n\nconst Spacer = styled.div<{ $height: number }>(\n ({ $height }) => css`\n height: ${$height}px;\n\n ${desktopMediaQuery} {\n display: none;\n }\n `,\n)\n\nconst Container = styled.div<{ $pinned: boolean }>(\n ({ theme, $pinned }) => css`\n display: flex;\n flex-direction: column;\n gap: ${theme.space[150]};\n width: 100%;\n // The library ships no CSS reset, so keep the pinned padding inside the viewport width\n box-sizing: border-box;\n\n ${\n $pinned &&\n css`\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n z-index: ${theme.elevation.floating};\n padding: ${theme.space[200]};\n padding-bottom: calc(\n ${theme.space[200]} + env(safe-area-inset-bottom, 0px)\n );\n background-color: ${theme.color.surface.base[200]};\n border-radius: ${theme.radius[200]} ${theme.radius[200]} 0 0;\n\n ${desktopMediaQuery} {\n position: static;\n z-index: auto;\n padding: 0;\n background-color: transparent;\n border-radius: 0;\n }\n `\n }\n `,\n)\n\n// On desktop, horizontal buttons all match the width of the longest label\nconst ButtonGroup = styled.div<{ $orientation: ButtonContainerOrientation }>(\n ({ theme, $orientation }) => css`\n display: grid;\n gap: ${theme.space[150]};\n\n ${\n $orientation === 'vertical' &&\n css`\n ${desktopMediaQuery} {\n grid-template-columns: minmax(0, ${desktopVerticalButtonMaxWidth});\n justify-content: center;\n }\n `\n }\n\n ${\n $orientation === 'horizontal' &&\n css`\n grid-auto-flow: column;\n grid-auto-columns: minmax(0, 1fr);\n\n // On desktop the buttons share the width of the longest label, centred\n ${desktopMediaQuery} {\n grid-auto-columns: minmax(${desktopHorizontalButtonMinWidth}, 1fr);\n width: fit-content;\n max-width: 100%;\n margin: 0 auto;\n }\n `\n }\n `,\n)\n\n// Figma icons use Font Awesome's square \"full\" bounding box (640 units),\n// in which the glyph's 512 unit em height takes up 80% of the box\nconst SupportingIconContainer = styled.span(\n ({ theme }) => css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n margin-right: ${theme.space['050']};\n vertical-align: top;\n\n svg {\n width: 100%;\n height: 80%;\n overflow: visible;\n }\n `,\n)\n\nconst SupportingText = styled.p(\n ({ theme }) => css`\n margin: 0;\n font-size: ${theme.font.body[200].fontSize};\n font-weight: ${theme.font.body[200].fontWeight};\n line-height: ${theme.font.body[200].lineHeight};\n color: ${theme.color.text.subtle};\n text-align: center;\n `,\n)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ButtonContainer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA","sourcesContent":["export { ButtonContainer } from './ButtonContainer'\nexport type {\n ButtonContainerOrientation,\n ButtonContainerProps,\n ButtonContainerSupportingMessage,\n} from './ButtonContainer'\n"]}
|
|
@@ -4,7 +4,7 @@ import styled, { css, useTheme } from 'styled-components';
|
|
|
4
4
|
import { Box } from '../Box';
|
|
5
5
|
import { Field } from '../fields/Field';
|
|
6
6
|
import { InputLeadingIconContainer, StyledFrontIcon, } from '../fields/components/CommonInput';
|
|
7
|
-
import { fieldDisabledStyle, fieldFocusAttrs, fieldFocusRing, } from '../fields/components/fieldStyles';
|
|
7
|
+
import { fieldDisabledStyle, fieldFocusAttrs, fieldFocusRing, fieldHoverBorderColor, } from '../fields/components/fieldStyles';
|
|
8
8
|
import { useUniqueId } from '../utils/id';
|
|
9
9
|
import { useControllableState } from '../utils/useControlledState';
|
|
10
10
|
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
@@ -54,7 +54,7 @@ export const Dropdown = forwardRef(function Dropdown({ id: idProp, placeholder,
|
|
|
54
54
|
}, $error: error, ref: ref, onBlur: onBlur, name: name, autoComplete: autoComplete, "aria-label": ariaLabel, "aria-invalid": error || undefined, "aria-required": required || undefined, "aria-describedby": describedBy, $frontIcon: !!iconToRender, $fallbackStyle: fallbackStyle, value: value ?? '', children: [_jsx("option", { value: "", hidden: !showDefaultOption, disabled: true, children: defaultOptionLabel() }), dropdownItemsGroups.map((groupItems, i) => hasOptGroups ? (_jsx("optgroup", { label: groupItems[0].optionGroupLabel ?? 'Other', children: groupItems.map((el, j) => (_jsx("option", { value: el.value, children: el.label }, `${i}-${j}`))) }, i)) : (groupItems.map((el, j) => (_jsx("option", { value: el.value, children: el.label }, j)))))] }), _jsx(Caret, { children: _jsx(IconContainer, { $size: CHEVRON_SIZE, children: _jsx(FontAwesomeIcon, { icon: faChevronDown, color: theme.color.icon.subtle }) }) })] }) }));
|
|
55
55
|
});
|
|
56
56
|
const CHEVRON_SIZE = 16;
|
|
57
|
-
const CHEVRON_INSET =
|
|
57
|
+
const CHEVRON_INSET = 16;
|
|
58
58
|
const CHEVRON_TEXT_GAP = 4;
|
|
59
59
|
const TEXT_PADDING_RIGHT = CHEVRON_INSET + CHEVRON_SIZE + CHEVRON_TEXT_GAP;
|
|
60
60
|
const StyledSelect = styled.select.attrs(fieldFocusAttrs)(({ theme, $error, $frontIcon, $fallbackStyle, value }) => {
|
|
@@ -74,7 +74,7 @@ const StyledSelect = styled.select.attrs(fieldFocusAttrs)(({ theme, $error, $fro
|
|
|
74
74
|
font-family: inherit;
|
|
75
75
|
font-size: 16px;
|
|
76
76
|
line-height: 20px;
|
|
77
|
-
text-overflow:
|
|
77
|
+
text-overflow: clip;
|
|
78
78
|
cursor: pointer;
|
|
79
79
|
outline: none;
|
|
80
80
|
|
|
@@ -86,7 +86,7 @@ const StyledSelect = styled.select.attrs(fieldFocusAttrs)(({ theme, $error, $fro
|
|
|
86
86
|
// Hover mustn't override the focus border while the pointer is over a
|
|
87
87
|
// focused field.
|
|
88
88
|
&:hover:not(:disabled):not(:focus) {
|
|
89
|
-
border-color: ${
|
|
89
|
+
border-color: ${fieldHoverBorderColor(theme, $error)};
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
&:focus {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,UAAU,EAEV,OAAO,GACR,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAG5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EACL,yBAAyB,EACzB,eAAe,GAChB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,cAAc,GACf,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE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AAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/B,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAClC;eACS,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;;;;;;;;;;iBAU5D,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;;;;;;wBAMd,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;;;;wBAIpC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;;;QAGxD,cAAc;QACd,kBAAkB;KACrB,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAA;;;WAGb,aAAa;;;CAGvB,CAAA","sourcesContent":["import {\n FocusEvent,\n FormEvent,\n ForwardedRef,\n forwardRef,\n ReactNode,\n useMemo,\n} from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Icons } from '../Icon'\n\nimport { Field } from '../fields/Field'\nimport { CommonFieldProps } from '../fields/commonFieldTypes'\nimport {\n InputLeadingIconContainer,\n StyledFrontIcon,\n} from '../fields/components/CommonInput'\nimport {\n fieldDisabledStyle,\n fieldFocusAttrs,\n fieldFocusRing,\n} from '../fields/components/fieldStyles'\nimport { useUniqueId } from '../utils/id'\nimport { useControllableState } from '../utils/useControlledState'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/solid'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\n\nexport type DropdownItem = {\n optionGroupLabel?: string\n label: string\n value: string\n}\n\nexport interface Props extends CommonFieldProps {\n placeholder?: string\n showDefaultOption?: boolean\n customDefaultOption?: string\n name?: string\n value?: string | null\n defaultValue?: string\n disabled?: boolean\n list: DropdownItem[]\n frontIcon?: Icons\n iconComponent?: ReactNode\n fallbackStyle?: boolean\n /** Accessible name, for when there is no visible `label` */\n 'aria-label'?: string\n /** Lets the browser autofill the field, e.g. `honorific-prefix` */\n autoComplete?: string\n onSelect?: (element: string) => void\n onBlur?: (e: FocusEvent<HTMLSelectElement>) => void\n}\n\ntype TruncateProps =\n | {\n onSelect: (e: string) => void\n onInputChange?: (e: FormEvent<HTMLSelectElement>) => void\n }\n | {\n onSelect?: (e: string) => void\n onInputChange: (e: FormEvent<HTMLSelectElement>) => void\n }\n\nexport type DropdownProps = Props & TruncateProps\n\nexport const Dropdown = forwardRef(function Dropdown(\n {\n id: idProp,\n placeholder,\n showDefaultOption = false,\n customDefaultOption,\n name,\n value: valueProp,\n defaultValue,\n disabled = false,\n list,\n onSelect,\n error = false,\n onInputChange,\n onBlur,\n frontIcon,\n iconComponent,\n fallbackStyle,\n required,\n 'aria-label': ariaLabel,\n autoComplete,\n ...fieldProps\n }: DropdownProps,\n ref: ForwardedRef<HTMLSelectElement>,\n) {\n const theme = useTheme()\n const [value, setValue] = useControllableState({\n initialState: defaultValue,\n stateProp: valueProp,\n })\n const id = useUniqueId(idProp)\n const assistiveTextId = `${id}-assistive-text`\n const errorMsgId = `${id}-error`\n const hasOptGroups = list.findIndex((item) => !!item.optionGroupLabel) !== -1\n\n const dropdownItemsGroups = useMemo(() => {\n const itemsPerGroupLabel = new Map<string, DropdownItem[]>()\n\n list.forEach((item) => {\n const key = item.optionGroupLabel ?? ''\n const group = itemsPerGroupLabel.get(key) ?? []\n\n group.push(item)\n itemsPerGroupLabel.set(key, group)\n })\n\n return Array.from(itemsPerGroupLabel.values())\n }, [list])\n\n const defaultOptionLabel = () => {\n if (!showDefaultOption) {\n return placeholder\n }\n return customDefaultOption ?? 'Select an option'\n }\n\n // Only reference messages that the field actually renders.\n const describedBy =\n [\n fieldProps.assistiveText &&\n (!fieldProps.renderAsTitle || fieldProps.label) &&\n assistiveTextId,\n error && fieldProps.errorMsg && errorMsgId,\n ]\n .filter(Boolean)\n .join(' ') || undefined\n\n const iconToRender = iconComponent ? (\n <InputLeadingIconContainer $size={16} $iconColor={theme.color.text.base}>\n {iconComponent}\n </InputLeadingIconContainer>\n ) : frontIcon ? (\n <StyledFrontIcon render={frontIcon} color=\"color.icon.subtle\" />\n ) : null\n\n return (\n <Field\n {...fieldProps}\n htmlFor={id}\n error={error}\n required={required}\n assistiveTextId={assistiveTextId}\n errorMsgId={errorMsgId}\n >\n <Box flex alignItems=\"center\" style={{ position: 'relative' }}>\n {iconToRender}\n <StyledSelect\n id={id}\n disabled={disabled || list.length < 1}\n onChange={(event) => {\n const value = event.currentTarget.value\n\n onSelect?.(value)\n onInputChange?.(event)\n setValue(value)\n }}\n $error={error}\n ref={ref}\n onBlur={onBlur}\n name={name}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-invalid={error || undefined}\n aria-required={required || undefined}\n aria-describedby={describedBy}\n $frontIcon={!!iconToRender}\n $fallbackStyle={fallbackStyle}\n value={value ?? ''}\n >\n <option value=\"\" hidden={!showDefaultOption} disabled>\n {defaultOptionLabel()}\n </option>\n\n {dropdownItemsGroups.map((groupItems, i) =>\n hasOptGroups ? (\n <optgroup\n key={i}\n label={groupItems[0].optionGroupLabel ?? 'Other'}\n >\n {groupItems.map((el, j) => (\n <option key={`${i}-${j}`} value={el.value}>\n {el.label}\n </option>\n ))}\n </optgroup>\n ) : (\n groupItems.map((el, j) => (\n <option key={j} value={el.value}>\n {el.label}\n </option>\n ))\n ),\n )}\n </StyledSelect>\n <Caret>\n <IconContainer $size={CHEVRON_SIZE}>\n <FontAwesomeIcon\n icon={faChevronDown}\n color={theme.color.icon.subtle}\n />\n </IconContainer>\n </Caret>\n </Box>\n </Field>\n )\n})\n\ninterface SSelect {\n $error: boolean\n $frontIcon: boolean\n $fallbackStyle?: boolean\n value?: string | null\n}\n\nconst CHEVRON_SIZE = 16\nconst CHEVRON_INSET = 20\nconst CHEVRON_TEXT_GAP = 4\nconst TEXT_PADDING_RIGHT = CHEVRON_INSET + CHEVRON_SIZE + CHEVRON_TEXT_GAP\n\nconst StyledSelect = styled.select.attrs(fieldFocusAttrs)<SSelect>(\n ({ theme, $error, $frontIcon, $fallbackStyle, value }) => {\n const borderColor = (color: string) =>\n $error ? theme.color.feedback.negative[200] : color\n\n return css`\n appearance: none;\n width: 100%;\n height: 48px;\n margin: 0;\n padding: 12px ${TEXT_PADDING_RIGHT}px 12px ${$frontIcon ? '42px' : '12px'};\n border: 2px solid ${borderColor(theme.color.border.subtle)};\n border-radius: 12px;\n background-color: ${\n $fallbackStyle\n ? theme.color.surface.base[300]\n : theme.color.background['000']\n };\n color: ${value === '' ? theme.color.text.subtle : theme.color.text.base};\n font-family: inherit;\n font-size: 16px;\n line-height: 20px;\n text-overflow: ellipsis;\n cursor: pointer;\n outline: none;\n\n option,\n optgroup {\n color: ${theme.color.text.base};\n }\n\n // Hover mustn't override the focus border while the pointer is over a\n // focused field.\n &:hover:not(:disabled):not(:focus) {\n border-color: ${borderColor(theme.color.border.base)};\n }\n\n &:focus {\n border-color: ${borderColor(theme.color.border.contrast)};\n }\n\n ${fieldFocusRing}\n ${fieldDisabledStyle}\n `\n },\n)\n\nconst Caret = styled.div`\n position: absolute;\n z-index: 1;\n right: ${CHEVRON_INSET}px;\n display: flex;\n pointer-events: none;\n`\n"]}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../src/Dropdown/Dropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,UAAU,EAEV,OAAO,GACR,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAG5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;A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AAC,CAAC,CAAC,KAAK,CAAA;IAErD,OAAO,GAAG,CAAA;;;;;sBAKQ,kBAAkB,WAAW,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;0BACrD,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;;0BAGxD,cAAc;QACZ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/B,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAClC;eACS,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;;;;;;;;;;iBAU5D,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;;;;;;wBAMd,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC;;;;wBAIpC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;;;QAGxD,cAAc;QACd,kBAAkB;KACrB,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAA;;;WAGb,aAAa;;;CAGvB,CAAA","sourcesContent":["import {\n FocusEvent,\n FormEvent,\n ForwardedRef,\n forwardRef,\n ReactNode,\n useMemo,\n} from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Icons } from '../Icon'\n\nimport { Field } from '../fields/Field'\nimport { CommonFieldProps } from '../fields/commonFieldTypes'\nimport {\n InputLeadingIconContainer,\n StyledFrontIcon,\n} from '../fields/components/CommonInput'\nimport {\n fieldDisabledStyle,\n fieldFocusAttrs,\n fieldFocusRing,\n fieldHoverBorderColor,\n} from '../fields/components/fieldStyles'\nimport { useUniqueId } from '../utils/id'\nimport { useControllableState } from '../utils/useControlledState'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/solid'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\n\nexport type DropdownItem = {\n optionGroupLabel?: string\n label: string\n value: string\n}\n\nexport interface Props extends CommonFieldProps {\n placeholder?: string\n showDefaultOption?: boolean\n customDefaultOption?: string\n name?: string\n value?: string | null\n defaultValue?: string\n disabled?: boolean\n list: DropdownItem[]\n frontIcon?: Icons\n iconComponent?: ReactNode\n fallbackStyle?: boolean\n /** Accessible name, for when there is no visible `label` */\n 'aria-label'?: string\n /** Lets the browser autofill the field, e.g. `honorific-prefix` */\n autoComplete?: string\n onSelect?: (element: string) => void\n onBlur?: (e: FocusEvent<HTMLSelectElement>) => void\n}\n\ntype TruncateProps =\n | {\n onSelect: (e: string) => void\n onInputChange?: (e: FormEvent<HTMLSelectElement>) => void\n }\n | {\n onSelect?: (e: string) => void\n onInputChange: (e: FormEvent<HTMLSelectElement>) => void\n }\n\nexport type DropdownProps = Props & TruncateProps\n\nexport const Dropdown = forwardRef(function Dropdown(\n {\n id: idProp,\n placeholder,\n showDefaultOption = false,\n customDefaultOption,\n name,\n value: valueProp,\n defaultValue,\n disabled = false,\n list,\n onSelect,\n error = false,\n onInputChange,\n onBlur,\n frontIcon,\n iconComponent,\n fallbackStyle,\n required,\n 'aria-label': ariaLabel,\n autoComplete,\n ...fieldProps\n }: DropdownProps,\n ref: ForwardedRef<HTMLSelectElement>,\n) {\n const theme = useTheme()\n const [value, setValue] = useControllableState({\n initialState: defaultValue,\n stateProp: valueProp,\n })\n const id = useUniqueId(idProp)\n const assistiveTextId = `${id}-assistive-text`\n const errorMsgId = `${id}-error`\n const hasOptGroups = list.findIndex((item) => !!item.optionGroupLabel) !== -1\n\n const dropdownItemsGroups = useMemo(() => {\n const itemsPerGroupLabel = new Map<string, DropdownItem[]>()\n\n list.forEach((item) => {\n const key = item.optionGroupLabel ?? ''\n const group = itemsPerGroupLabel.get(key) ?? []\n\n group.push(item)\n itemsPerGroupLabel.set(key, group)\n })\n\n return Array.from(itemsPerGroupLabel.values())\n }, [list])\n\n const defaultOptionLabel = () => {\n if (!showDefaultOption) {\n return placeholder\n }\n return customDefaultOption ?? 'Select an option'\n }\n\n // Only reference messages that the field actually renders.\n const describedBy =\n [\n fieldProps.assistiveText &&\n (!fieldProps.renderAsTitle || fieldProps.label) &&\n assistiveTextId,\n error && fieldProps.errorMsg && errorMsgId,\n ]\n .filter(Boolean)\n .join(' ') || undefined\n\n const iconToRender = iconComponent ? (\n <InputLeadingIconContainer $size={16} $iconColor={theme.color.text.base}>\n {iconComponent}\n </InputLeadingIconContainer>\n ) : frontIcon ? (\n <StyledFrontIcon render={frontIcon} color=\"color.icon.subtle\" />\n ) : null\n\n return (\n <Field\n {...fieldProps}\n htmlFor={id}\n error={error}\n required={required}\n assistiveTextId={assistiveTextId}\n errorMsgId={errorMsgId}\n >\n <Box flex alignItems=\"center\" style={{ position: 'relative' }}>\n {iconToRender}\n <StyledSelect\n id={id}\n disabled={disabled || list.length < 1}\n onChange={(event) => {\n const value = event.currentTarget.value\n\n onSelect?.(value)\n onInputChange?.(event)\n setValue(value)\n }}\n $error={error}\n ref={ref}\n onBlur={onBlur}\n name={name}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-invalid={error || undefined}\n aria-required={required || undefined}\n aria-describedby={describedBy}\n $frontIcon={!!iconToRender}\n $fallbackStyle={fallbackStyle}\n value={value ?? ''}\n >\n <option value=\"\" hidden={!showDefaultOption} disabled>\n {defaultOptionLabel()}\n </option>\n\n {dropdownItemsGroups.map((groupItems, i) =>\n hasOptGroups ? (\n <optgroup\n key={i}\n label={groupItems[0].optionGroupLabel ?? 'Other'}\n >\n {groupItems.map((el, j) => (\n <option key={`${i}-${j}`} value={el.value}>\n {el.label}\n </option>\n ))}\n </optgroup>\n ) : (\n groupItems.map((el, j) => (\n <option key={j} value={el.value}>\n {el.label}\n </option>\n ))\n ),\n )}\n </StyledSelect>\n <Caret>\n <IconContainer $size={CHEVRON_SIZE}>\n <FontAwesomeIcon\n icon={faChevronDown}\n color={theme.color.icon.subtle}\n />\n </IconContainer>\n </Caret>\n </Box>\n </Field>\n )\n})\n\ninterface SSelect {\n $error: boolean\n $frontIcon: boolean\n $fallbackStyle?: boolean\n value?: string | null\n}\n\nconst CHEVRON_SIZE = 16\nconst CHEVRON_INSET = 16\nconst CHEVRON_TEXT_GAP = 4\nconst TEXT_PADDING_RIGHT = CHEVRON_INSET + CHEVRON_SIZE + CHEVRON_TEXT_GAP\n\nconst StyledSelect = styled.select.attrs(fieldFocusAttrs)<SSelect>(\n ({ theme, $error, $frontIcon, $fallbackStyle, value }) => {\n const borderColor = (color: string) =>\n $error ? theme.color.feedback.negative[200] : color\n\n return css`\n appearance: none;\n width: 100%;\n height: 48px;\n margin: 0;\n padding: 12px ${TEXT_PADDING_RIGHT}px 12px ${$frontIcon ? '42px' : '12px'};\n border: 2px solid ${borderColor(theme.color.border.subtle)};\n border-radius: 12px;\n background-color: ${\n $fallbackStyle\n ? theme.color.surface.base[300]\n : theme.color.background['000']\n };\n color: ${value === '' ? theme.color.text.subtle : theme.color.text.base};\n font-family: inherit;\n font-size: 16px;\n line-height: 20px;\n text-overflow: clip;\n cursor: pointer;\n outline: none;\n\n option,\n optgroup {\n color: ${theme.color.text.base};\n }\n\n // Hover mustn't override the focus border while the pointer is over a\n // focused field.\n &:hover:not(:disabled):not(:focus) {\n border-color: ${fieldHoverBorderColor(theme, $error)};\n }\n\n &:focus {\n border-color: ${borderColor(theme.color.border.contrast)};\n }\n\n ${fieldFocusRing}\n ${fieldDisabledStyle}\n `\n },\n)\n\nconst Caret = styled.div`\n position: absolute;\n z-index: 1;\n right: ${CHEVRON_INSET}px;\n display: flex;\n pointer-events: none;\n`\n"]}
|
|
@@ -21,7 +21,7 @@ const StyledTextArea = styled.textarea `
|
|
|
21
21
|
box-sizing: border-box;
|
|
22
22
|
border-radius: 12px;
|
|
23
23
|
width: 100%;
|
|
24
|
-
padding:
|
|
24
|
+
padding: 12px;
|
|
25
25
|
color: ${({ theme }) => theme.color.text.base};
|
|
26
26
|
resize: ${({ $resize }) => $resize};
|
|
27
27
|
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'text')};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/Textarea/Textarea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuC,UAAU,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA+BzC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,QAAQ,CAClD,EACE,EAAE,EAAE,MAAM,EACV,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,aAAa,EACb,MAAM,GAAG,MAAM,EACf,KAAK,GAAG,KAAK,EACb,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,MAAM,EACN,IAAI,GAAG,CAAC,EACR,aAAa,EACb,GAAG,UAAU,EACC,EAChB,GAAsC;IAEtC,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAC9B,OAAO,CACL,KAAC,KAAK,OAAK,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,YAC9C,KAAC,cAAc,IACb,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,KAAK,EACb,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,aAAa,EAC7B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAiC,EAAE,EAAE;gBAC9C,QAAQ,EAAE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pC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI;;CAE1E,CAAA","sourcesContent":["import { FocusEvent, FormEvent, ForwardedRef, forwardRef } from 'react'\nimport styled from 'styled-components'\n\nimport { Field } from '../fields/Field'\nimport { CommonFieldProps } from '../fields/commonFieldTypes'\nimport { useUniqueId } from '../utils/id'\nimport { MarginProps } from '../utils/space'\n\ntype BaseProps = {\n id?: string\n placeholder?: string\n name?: string\n value: string\n error?: boolean\n errorMsg?: string\n resize?: 'none' | 'both'\n disabled?: boolean\n maxLength?: number\n onBlur?: (e: FocusEvent<HTMLTextAreaElement>) => void\n rows?: number\n fallbackStyle?: boolean\n} & CommonFieldProps &\n MarginProps\n\ntype TruncateProps =\n | {\n onChange: (e: string) => void\n onInputChange?: (e: FormEvent<HTMLTextAreaElement>) => void\n }\n | {\n onChange?: (e: string) => void\n onInputChange: (e: FormEvent<HTMLTextAreaElement>) => void\n }\n\nexport type TextareaProps = BaseProps & TruncateProps\n\nexport const Textarea = forwardRef(function Textarea(\n {\n id: idProp,\n name,\n value,\n onChange,\n onInputChange,\n resize = 'none',\n error = false,\n placeholder,\n disabled = false,\n maxLength,\n onBlur,\n rows = 4,\n fallbackStyle,\n ...fieldProps\n }: TextareaProps,\n ref: ForwardedRef<HTMLTextAreaElement>,\n) {\n const id = useUniqueId(idProp)\n return (\n <Field {...fieldProps} htmlFor={id} error={error}>\n <StyledTextArea\n ref={ref}\n $error={error}\n id={id}\n name={name}\n disabled={disabled}\n $resize={resize}\n $fallbackStyle={fallbackStyle}\n placeholder={placeholder}\n value={value}\n onChange={(e: FormEvent<HTMLTextAreaElement>) => {\n onChange?.(e.currentTarget.value)\n onInputChange?.(e)\n }}\n maxLength={maxLength}\n onBlur={onBlur}\n rows={rows}\n />\n </Field>\n )\n})\n\ninterface TextArea {\n $resize: 'none' | 'both'\n disabled: boolean\n $error: boolean\n $fallbackStyle?: boolean\n}\n\nconst StyledTextArea = styled.textarea<TextArea>`\n font-size: 16px;\n font: inherit;\n line-height: 20px;\n background: ${({ $fallbackStyle, theme }) =>\n $fallbackStyle\n ? theme.color.surface.base[300]\n : theme.color.background['000']};\n border: 2px solid ${({ theme }) => theme.color.border.subtle};\n box-sizing: border-box;\n border-radius: 12px;\n width: 100%;\n padding:
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/Textarea/Textarea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuC,UAAU,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA+BzC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,QAAQ,CAClD,EACE,EAAE,EAAE,MAAM,EACV,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,aAAa,EACb,MAAM,GAAG,MAAM,EACf,KAAK,GAAG,KAAK,EACb,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,MAAM,EACN,IAAI,GAAG,CAAC,EACR,aAAa,EACb,GAAG,UAAU,EACC,EAChB,GAAsC;IAEtC,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAC9B,OAAO,CACL,KAAC,KAAK,OAAK,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,YAC9C,KAAC,cAAc,IACb,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,KAAK,EACb,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,aAAa,EAC7B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE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,MAAM;;;;;;oBAMvD,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CACpC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI;;CAE1E,CAAA","sourcesContent":["import { FocusEvent, FormEvent, ForwardedRef, forwardRef } from 'react'\nimport styled from 'styled-components'\n\nimport { Field } from '../fields/Field'\nimport { CommonFieldProps } from '../fields/commonFieldTypes'\nimport { useUniqueId } from '../utils/id'\nimport { MarginProps } from '../utils/space'\n\ntype BaseProps = {\n id?: string\n placeholder?: string\n name?: string\n value: string\n error?: boolean\n errorMsg?: string\n resize?: 'none' | 'both'\n disabled?: boolean\n maxLength?: number\n onBlur?: (e: FocusEvent<HTMLTextAreaElement>) => void\n rows?: number\n fallbackStyle?: boolean\n} & CommonFieldProps &\n MarginProps\n\ntype TruncateProps =\n | {\n onChange: (e: string) => void\n onInputChange?: (e: FormEvent<HTMLTextAreaElement>) => void\n }\n | {\n onChange?: (e: string) => void\n onInputChange: (e: FormEvent<HTMLTextAreaElement>) => void\n }\n\nexport type TextareaProps = BaseProps & TruncateProps\n\nexport const Textarea = forwardRef(function Textarea(\n {\n id: idProp,\n name,\n value,\n onChange,\n onInputChange,\n resize = 'none',\n error = false,\n placeholder,\n disabled = false,\n maxLength,\n onBlur,\n rows = 4,\n fallbackStyle,\n ...fieldProps\n }: TextareaProps,\n ref: ForwardedRef<HTMLTextAreaElement>,\n) {\n const id = useUniqueId(idProp)\n return (\n <Field {...fieldProps} htmlFor={id} error={error}>\n <StyledTextArea\n ref={ref}\n $error={error}\n id={id}\n name={name}\n disabled={disabled}\n $resize={resize}\n $fallbackStyle={fallbackStyle}\n placeholder={placeholder}\n value={value}\n onChange={(e: FormEvent<HTMLTextAreaElement>) => {\n onChange?.(e.currentTarget.value)\n onInputChange?.(e)\n }}\n maxLength={maxLength}\n onBlur={onBlur}\n rows={rows}\n />\n </Field>\n )\n})\n\ninterface TextArea {\n $resize: 'none' | 'both'\n disabled: boolean\n $error: boolean\n $fallbackStyle?: boolean\n}\n\nconst StyledTextArea = styled.textarea<TextArea>`\n font-size: 16px;\n font: inherit;\n line-height: 20px;\n background: ${({ $fallbackStyle, theme }) =>\n $fallbackStyle\n ? theme.color.surface.base[300]\n : theme.color.background['000']};\n border: 2px solid ${({ theme }) => theme.color.border.subtle};\n box-sizing: border-box;\n border-radius: 12px;\n width: 100%;\n padding: 12px;\n color: ${({ theme }) => theme.color.text.base};\n resize: ${({ $resize }) => $resize};\n cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'text')};\n opacity: ${({ disabled }) => (disabled ? '0.5' : '1')};\n border-color: ${({ $error, theme }) =>\n $error ? theme.color.feedback.negative[200] : theme.color.border.subtle};\n outline: none;\n\n &:hover,\n &:focus,\n &:focus-visible {\n border-color: ${({ $error, theme }) =>\n $error ? theme.color.feedback.negative[200] : theme.color.border.base};\n }\n`\n"]}
|
|
@@ -12,9 +12,11 @@ interface IInput {
|
|
|
12
12
|
interface SIcon {
|
|
13
13
|
$disabled?: boolean;
|
|
14
14
|
}
|
|
15
|
-
export declare const Input: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "style"> & {
|
|
15
|
+
export declare const Input: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "style"> & {
|
|
16
16
|
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
17
|
-
}, IInput
|
|
17
|
+
}, IInput>, "onBlurCapture" | "onPointerDown"> & Partial<Pick<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "style"> & {
|
|
18
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
19
|
+
}, IInput>, "onBlurCapture" | "onPointerDown">>> & string;
|
|
18
20
|
export declare const InputLeadingIconContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("styled-components").FastOmit<import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "style"> & {
|
|
19
21
|
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
20
22
|
}, {
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import styled
|
|
1
|
+
import styled from 'styled-components';
|
|
2
2
|
import { Icon } from '../../Icon';
|
|
3
3
|
import { IconContainer } from '../../sharedStyles/shared.styles';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
font-size: 16px;
|
|
4
|
+
import { fieldDisabledStyle, fieldFocusAttrs, fieldFocusRing, fieldHoverBorderColor, } from './fieldStyles';
|
|
5
|
+
export const Input = styled.input.attrs(fieldFocusAttrs) `
|
|
6
|
+
box-sizing: border-box;
|
|
8
7
|
width: 100%;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
height: 48px;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 12px;
|
|
11
|
+
border: 2px solid
|
|
12
|
+
${({ $error, theme }) => $error ? theme.color.feedback.negative[200] : theme.color.border.subtle};
|
|
13
|
+
border-radius: 12px;
|
|
13
14
|
background-color: ${({ $fallbackStyle, theme }) => $fallbackStyle
|
|
14
15
|
? theme.color.surface.base[300]
|
|
15
16
|
: theme.color.background['000']};
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
color: ${({ $error, theme }) => $error ? theme.color.feedback.negative[200] : theme.color.text.base};
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
font-size: 16px;
|
|
20
|
+
line-height: 20px;
|
|
21
|
+
outline: none;
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
&:hover,
|
|
23
|
-
&:focus-within {
|
|
24
|
-
border-color: ${theme.color.border.base};
|
|
25
|
-
}
|
|
26
|
-
`}
|
|
23
|
+
&:hover:not(:disabled):not(:focus) {
|
|
24
|
+
border-color: ${({ $error, theme }) => fieldHoverBorderColor(theme, $error)};
|
|
25
|
+
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
&:focus {
|
|
28
|
+
border-color: ${({ $error, theme }) => $error
|
|
29
|
+
? theme.color.feedback.negative[200]
|
|
30
|
+
: theme.color.border.contrast};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
${fieldFocusRing}
|
|
34
|
+
${fieldDisabledStyle}
|
|
30
35
|
|
|
31
36
|
${({ $frontIcon }) => $frontIcon &&
|
|
32
37
|
`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonInput.js","sourceRoot":"","sources":["../../../src/fields/components/CommonInput.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"CommonInput.js","sourceRoot":"","sources":["../../../src/fields/components/CommonInput.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,IAAI,EAAS,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAChE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,qBAAqB,GACtB,MAAM,eAAe,CAAA;AAiBtB,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAQ;;;;;;;MAO1D,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CACtB,MAAM,CA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{ IconContainer } from '../../sharedStyles/shared.styles'\nimport {\n fieldDisabledStyle,\n fieldFocusAttrs,\n fieldFocusRing,\n fieldHoverBorderColor,\n} from './fieldStyles'\n\ninterface IInput {\n $error?: boolean\n disabled?: boolean\n selected?: boolean\n step?: number\n value?: string\n $frontIcon?: boolean\n $trailingIcon?: Icons\n $fallbackStyle?: boolean\n}\n\ninterface SIcon {\n $disabled?: boolean\n}\n\nexport const Input = styled.input.attrs(fieldFocusAttrs)<IInput>`\n box-sizing: border-box;\n width: 100%;\n height: 48px;\n margin: 0;\n padding: 12px;\n border: 2px solid\n ${({ $error, theme }) =>\n $error ? theme.color.feedback.negative[200] : theme.color.border.subtle};\n border-radius: 12px;\n background-color: ${({ $fallbackStyle, theme }) =>\n $fallbackStyle\n ? theme.color.surface.base[300]\n : theme.color.background['000']};\n color: ${({ $error, theme }) =>\n $error ? theme.color.feedback.negative[200] : theme.color.text.base};\n font-family: inherit;\n font-size: 16px;\n line-height: 20px;\n outline: none;\n\n &:hover:not(:disabled):not(:focus) {\n border-color: ${({ $error, theme }) => fieldHoverBorderColor(theme, $error)};\n }\n\n &:focus {\n border-color: ${({ $error, theme }) =>\n $error\n ? theme.color.feedback.negative[200]\n : theme.color.border.contrast};\n }\n\n ${fieldFocusRing}\n ${fieldDisabledStyle}\n\n ${({ $frontIcon }) =>\n $frontIcon &&\n `\n padding-left: 42px;\n `}\n\n ${({ $trailingIcon }) =>\n $trailingIcon &&\n `\n padding-right: 42px;\n `}\n\n /* Remove the spinner on Firefox and Webkit browsers */\n -moz-appearance: textfield;\n\n &::-webkit-outer-spin-button,\n &::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n &::placeholder {\n color: ${({ theme }) => theme.color.text.subtle};\n }\n\n &:-webkit-autofill {\n animation-name: onAutoFillStart;\n animation-duration: 2s;\n }\n\n @keyframes onAutoFillStart {\n from {\n background-color: inherit;\n }\n to {\n background-color: inherit;\n }\n }\n`\n\nexport const InputLeadingIconContainer = styled(IconContainer)<SIcon>`\n position: relative;\n left: 36px;\n margin-left: ${({ $size }) => -$size}px;\n z-index: 1;\n opacity: ${({ $disabled }) => ($disabled ? '0.5' : '1')};\n color: ${({ theme }) => theme.color.text.base};\n`\n\nexport const StyledFrontIcon = styled(Icon)<SIcon>`\n position: relative;\n left: 36px;\n margin-left: -24px;\n z-index: 1;\n opacity: ${({ $disabled }) => ($disabled ? '0.5' : '1')};\n color: ${({ theme }) => theme.color.text.base};\n`\n\nexport const StyledTrailingIcon = styled(Icon)<SIcon>`\n position: relative;\n right: 36px;\n margin-right: -36px;\n opacity: ${({ $disabled }) => ($disabled ? '0.5' : '1')};\n color: ${({ theme }) => theme.color.text.base};\n`\n\nexport const InputTrailingIconContainer = styled(IconContainer)<SIcon>`\n position: relative;\n right: 36px;\n margin-right: -36px;\n opacity: ${({ $disabled }) => ($disabled ? '0.5' : '1')};\n color: ${({ theme }) => theme.color.text.base};\n`\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FocusEvent, FocusEventHandler, PointerEvent, PointerEventHandler } from 'react';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
2
3
|
/**
|
|
3
4
|
* Browsers treat text fields as `:focus-visible` even when they are clicked,
|
|
4
5
|
* so fields flag focus that comes from a pointer and only show the focus ring
|
|
@@ -15,3 +16,4 @@ export declare const fieldFocusAttrs: <T extends HTMLElement>({ onPointerDown, o
|
|
|
15
16
|
};
|
|
16
17
|
export declare const fieldFocusRing: import("styled-components").RuleSet<object>;
|
|
17
18
|
export declare const fieldDisabledStyle: import("styled-components").RuleSet<object>;
|
|
19
|
+
export declare const fieldHoverBorderColor: (theme: DefaultTheme, error?: boolean) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldStyles.js","sourceRoot":"","sources":["../../../src/fields/components/fieldStyles.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"fieldStyles.js","sour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;CAMlD,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAmB,EAAE,KAAe,EAAE,EAAE,CAC5E,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA","sourcesContent":["import {\n FocusEvent,\n FocusEventHandler,\n PointerEvent,\n PointerEventHandler,\n} from 'react'\nimport { css, DefaultTheme } from 'styled-components'\n\n/**\n * Browsers treat text fields as `:focus-visible` even when they are clicked,\n * so fields flag focus that comes from a pointer and only show the focus ring\n * for keyboard focus.\n */\nexport const markPointerFocus = (element: HTMLElement | null) => {\n if (element) element.dataset.pointerFocus = ''\n}\n\n/** Pass to styled-components `.attrs`. Callers' own handlers still run. */\nexport const fieldFocusAttrs = <T extends HTMLElement>({\n onPointerDown,\n onBlurCapture,\n}: {\n onPointerDown?: PointerEventHandler<T>\n onBlurCapture?: FocusEventHandler<T>\n}) => ({\n onPointerDown: (event: PointerEvent<T>) => {\n markPointerFocus(event.currentTarget)\n onPointerDown?.(event)\n },\n onBlurCapture: (event: FocusEvent<T>) => {\n delete event.currentTarget.dataset.pointerFocus\n onBlurCapture?.(event)\n },\n})\n\nexport const fieldFocusRing = css`\n &:focus-visible:not([data-pointer-focus]) {\n outline: 2px solid ${({ theme }) => theme.color.focus.onLight};\n outline-offset: 2px;\n }\n`\n\nexport const fieldDisabledStyle = css`\n &:disabled {\n border-color: ${({ theme }) => theme.color.feedback.inactive[100]};\n background-color: ${({ theme }) => theme.color.feedback.inactive[50]};\n color: ${({ theme }) => theme.color.text.subtle};\n cursor: not-allowed;\n /* Safari fades disabled fields on top of these colours */\n opacity: 1;\n -webkit-text-fill-color: currentColor;\n }\n`\n\nexport const fieldHoverBorderColor = (theme: DefaultTheme, error?: boolean) =>\n error ? theme.color.feedback.negative[300] : theme.color.border.base\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,0CAA0C,CAAA;AACxD,cAAc,gDAAgD,CAAA;AAC9D,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,8BAA8B,CAAA","sourcesContent":["export * from './Accordion'\nexport * from './ActionDropdown'\nexport * from './Badge'\nexport * from './Alert'\nexport * from './BadgeList'\nexport * from './Banner'\nexport * from './Box'\nexport * from './Button'\nexport * from './Card'\nexport * from './CheckBox'\nexport * from './CheckBoxGroup'\nexport * from './Chip'\nexport * from './CurrencyInput'\nexport * from './Datepicker'\nexport * from './Divider'\nexport * from './Dropdown'\nexport * from './fields/Field'\nexport * from './fields/Fieldset'\nexport * from './fontStyle'\nexport * from './hooks'\nexport * from './Icon'\nexport * from './IconStrict'\nexport * from './IconWrapper'\nexport * from './LabelledText'\nexport * from './Link'\nexport * from './Loader'\nexport * from './Logo'\nexport * from './Modal'\nexport * from './NumberInput'\nexport * from './Pagination'\nexport * from './ProgressIndicator'\nexport * from './PromoCard'\nexport * from './RadioGroup'\nexport * from './RichText'\nexport * from './RichTextEditor'\nexport * from './Row'\nexport * from './SearchInput'\nexport * from './SegmentedControl'\nexport * from './SliderInput'\nexport * from './Snackbar'\nexport * from './SupportMessage'\nexport * from './Table'\nexport * from './Tag'\nexport * from './Text'\nexport * from './Textarea'\nexport * from './TextDateOfBirthInput'\nexport * from './TextInput'\nexport * from './theme'\nexport * from './Toggle'\nexport * from './Tooltip'\nexport * from './utils/dateOfBirth/dateOfBirthValidator'\nexport * from './utils/dateOfBirth/dateOfBirthValidator.utils'\nexport * from './utils/dateOfBirth/schema'\nexport * from './utils/utilTypes'\nexport * from './utils/space'\nexport * from './ThemeProvider'\nexport * from './styled'\nexport * from './sharedStyles/shared.styles'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,0CAA0C,CAAA;AACxD,cAAc,gDAAgD,CAAA;AAC9D,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,8BAA8B,CAAA","sourcesContent":["export * from './Accordion'\nexport * from './ActionDropdown'\nexport * from './Badge'\nexport * from './Alert'\nexport * from './BadgeList'\nexport * from './Banner'\nexport * from './Box'\nexport * from './Button'\nexport * from './ButtonContainer'\nexport * from './Card'\nexport * from './CheckBox'\nexport * from './CheckBoxGroup'\nexport * from './Chip'\nexport * from './CurrencyInput'\nexport * from './Datepicker'\nexport * from './Divider'\nexport * from './Dropdown'\nexport * from './fields/Field'\nexport * from './fields/Fieldset'\nexport * from './fontStyle'\nexport * from './hooks'\nexport * from './Icon'\nexport * from './IconStrict'\nexport * from './IconWrapper'\nexport * from './LabelledText'\nexport * from './Link'\nexport * from './Loader'\nexport * from './Logo'\nexport * from './Modal'\nexport * from './NumberInput'\nexport * from './Pagination'\nexport * from './ProgressIndicator'\nexport * from './PromoCard'\nexport * from './RadioGroup'\nexport * from './RichText'\nexport * from './RichTextEditor'\nexport * from './Row'\nexport * from './SearchInput'\nexport * from './SegmentedControl'\nexport * from './SliderInput'\nexport * from './Snackbar'\nexport * from './SupportMessage'\nexport * from './Table'\nexport * from './Tag'\nexport * from './Text'\nexport * from './Textarea'\nexport * from './TextDateOfBirthInput'\nexport * from './TextInput'\nexport * from './theme'\nexport * from './Toggle'\nexport * from './Tooltip'\nexport * from './utils/dateOfBirth/dateOfBirthValidator'\nexport * from './utils/dateOfBirth/dateOfBirthValidator.utils'\nexport * from './utils/dateOfBirth/schema'\nexport * from './utils/utilTypes'\nexport * from './utils/space'\nexport * from './ThemeProvider'\nexport * from './styled'\nexport * from './sharedStyles/shared.styles'\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrshmllw/smores-react",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.9.0",
|
|
4
4
|
"description": "Collection of React components used by Marshmallow Technology",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"eslint-plugin-prettier": "^5.5.6",
|
|
87
87
|
"husky": "^9.1.7",
|
|
88
88
|
"jest-styled-components": "^7.4.0",
|
|
89
|
-
"jsdom": "^30.1.
|
|
89
|
+
"jsdom": "^30.1.2",
|
|
90
90
|
"lint-staged": "^17.6.0",
|
|
91
91
|
"oxlint": "^1.78.0",
|
|
92
92
|
"oxlint-tsgolint": "^7.0.2003",
|