@mrshmllw/smores-react 16.10.6 → 16.10.8
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/ActionDropdown/ActionDropdown.js +52 -9
- package/dist/ActionDropdown/ActionDropdown.js.map +1 -1
- package/dist/ActionDropdown/List.d.ts +12 -3
- package/dist/ActionDropdown/List.js +16 -6
- package/dist/ActionDropdown/List.js.map +1 -1
- package/dist/ActionDropdown/index.d.ts +2 -0
- package/dist/ActionDropdown/index.js.map +1 -1
- package/dist/Textarea/Textarea.js +12 -5
- package/dist/Textarea/Textarea.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,64 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useId, useRef, useState } from 'react';
|
|
3
3
|
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
5
|
import { Text } from '../Text';
|
|
6
|
-
import {
|
|
6
|
+
import { ListContainer, ListItems } from './List';
|
|
7
7
|
import { resolveToThemeColor } from '../ThemeProvider/utils/colourMap';
|
|
8
|
-
import { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/
|
|
8
|
+
import { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/solid';
|
|
9
9
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
10
|
import { IconContainer } from '../sharedStyles/shared.styles';
|
|
11
|
-
|
|
11
|
+
import { FloatingFocusManager, useClick, useDismiss, useFloating, useInteractions, useListNavigation, useRole, } from '@floating-ui/react';
|
|
12
|
+
import { focusOutlineStyle } from '../utils/focusOutline';
|
|
13
|
+
export const ActionDropdown = ({ id: idProp, className = '', label, value, list, onSelect, ...marginProps }) => {
|
|
12
14
|
const [open, setOpen] = useState(false);
|
|
15
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
16
|
+
const listRef = useRef([]);
|
|
17
|
+
const generatedId = useId();
|
|
18
|
+
const id = idProp ?? generatedId;
|
|
19
|
+
const buttonId = `${id}-button`;
|
|
13
20
|
const theme = useTheme();
|
|
14
21
|
const resolvedBgColor = resolveToThemeColor(value.bgColor ?? 'color.background.100', theme);
|
|
15
22
|
const resolvedTextColor = resolveToThemeColor(value.textColor ?? 'color.text.base', theme);
|
|
16
|
-
|
|
23
|
+
const { refs, context } = useFloating({
|
|
24
|
+
open,
|
|
25
|
+
onOpenChange: (nextOpen) => {
|
|
26
|
+
setOpen(nextOpen);
|
|
27
|
+
if (!nextOpen)
|
|
28
|
+
setActiveIndex(null);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const click = useClick(context);
|
|
32
|
+
const dismiss = useDismiss(context);
|
|
33
|
+
const role = useRole(context, { role: 'listbox' });
|
|
34
|
+
const listNavigation = useListNavigation(context, {
|
|
35
|
+
listRef,
|
|
36
|
+
activeIndex,
|
|
37
|
+
selectedIndex: list.findIndex((item) => item.value === value.value),
|
|
38
|
+
onNavigate: setActiveIndex,
|
|
39
|
+
loop: true,
|
|
40
|
+
});
|
|
41
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([click, dismiss, role, listNavigation]);
|
|
42
|
+
const selectOption = (option) => {
|
|
43
|
+
onSelect(option);
|
|
44
|
+
setOpen(false);
|
|
45
|
+
setActiveIndex(null);
|
|
46
|
+
};
|
|
47
|
+
const handleListKeyDown = (event) => {
|
|
48
|
+
if ((event.key === 'Enter' || event.key === ' ') && activeIndex !== null) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
selectOption(list[activeIndex]);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return (_jsxs(Container, { id: idProp, className: className, ...marginProps, children: [label && (_jsx(Text, { tag: "label", htmlFor: buttonId, color: "sesame", typo: "label", children: label })), _jsxs(Label, { ref: refs.setReference, id: buttonId, type: "button", "aria-label": label ? undefined : 'Select an option', $text: resolvedTextColor, $bg: resolvedBgColor, ...getReferenceProps(), children: [_jsx(SelectedOption, { children: value.label }), _jsx(IconContainer, { $size: 20, style: {
|
|
17
54
|
rotate: open ? '180deg' : '0deg',
|
|
18
|
-
}, children: _jsx(FontAwesomeIcon, { icon: faChevronDown, color: resolvedTextColor }) })] }), _jsx(OuterContainer, { open: open, children: _jsx(
|
|
55
|
+
}, children: _jsx(FontAwesomeIcon, { icon: faChevronDown, color: resolvedTextColor }) })] }), _jsx(OuterContainer, { open: open, children: open && (_jsx(FloatingFocusManager, { context: context, modal: false, returnFocus: true, children: _jsx(ListContainer
|
|
56
|
+
// oxlint-disable-next-line react/react-compiler
|
|
57
|
+
, {
|
|
58
|
+
// oxlint-disable-next-line react/react-compiler
|
|
59
|
+
ref: refs.setFloating, ...getFloatingProps({ onKeyDown: handleListKeyDown }), children: _jsx(ListItems, { options: list, selectedValue: value.value, activeIndex: activeIndex, listRef: listRef, getItemProps: getItemProps, onSelect: selectOption }) }) })) })] }));
|
|
19
60
|
};
|
|
20
|
-
const Label = styled.
|
|
61
|
+
const Label = styled.button(({ $text, $bg }) => css `
|
|
21
62
|
color: ${$text};
|
|
22
63
|
background-color: ${$bg};
|
|
23
64
|
position: relative;
|
|
@@ -27,10 +68,14 @@ const Label = styled.div(({ $text, $bg }) => css `
|
|
|
27
68
|
align-items: center;
|
|
28
69
|
justify-content: space-between;
|
|
29
70
|
text-align: center;
|
|
71
|
+
border: 0;
|
|
30
72
|
border-radius: 100px;
|
|
31
73
|
padding: 16px 16px 14px;
|
|
32
74
|
box-sizing: border-box;
|
|
75
|
+
font: inherit;
|
|
76
|
+
cursor: pointer;
|
|
33
77
|
user-select: none;
|
|
78
|
+
${focusOutlineStyle}
|
|
34
79
|
`);
|
|
35
80
|
const SelectedOption = styled.span `
|
|
36
81
|
font-size: 14px;
|
|
@@ -44,8 +89,6 @@ const Container = styled(Box) `
|
|
|
44
89
|
width: 210px;
|
|
45
90
|
height: 48px;
|
|
46
91
|
text-align: center;
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
outline: none;
|
|
49
92
|
border-radius: 8px;
|
|
50
93
|
`;
|
|
51
94
|
const OuterContainer = styled.div(({ open }) => css `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionDropdown.js","sourceRoot":"","sources":["../../src/ActionDropdown/ActionDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAkB,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAe7D,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,EACtD,EAAE,EACF,SAAS,GAAG,EAAE,EACd,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,GAAG,WAAW,EACf,EAAE,EAAE;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEvC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,eAAe,GAAG,mBAAmB,CACzC,KAAK,CAAC,OAAO,IAAI,sBAAsB,EACvC,KAAK,CACN,CAAA;IACD,MAAM,iBAAiB,GAAG,mBAAmB,CAC3C,KAAK,CAAC,SAAS,IAAI,iBAAiB,EACpC,KAAK,CACN,CAAA;IAED,OAAO,CACL,MAAC,SAAS,IACR,EAAE,EAAE,EAA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AAC,KAAK,CAAC,GAAG,CAAC;eAClC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;kBACpB,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;wBACjB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;kBAClD,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;;;GAGvC,CACF,CAAA","sourcesContent":["import { FC, useState } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { ActionListItem, List } from './List'\n\nimport { MarginProps } from '../utils/space'\nimport { resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\nimport { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/regular'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { IconContainer } from '../sharedStyles/shared.styles'\n\nexport type ActionDropdownProps = {\n id?: string\n className?: string\n /** label displayed above the dropdown */\n label?: string\n /** value */\n value: ActionListItem\n /** list of items for the dropdown list */\n list: ActionListItem[]\n /** onSelect handler */\n onSelect: (action: ActionListItem) => void\n} & MarginProps\n\nexport const ActionDropdown: FC<ActionDropdownProps> = ({\n id,\n className = '',\n label,\n value,\n list,\n onSelect,\n ...marginProps\n}) => {\n const [open, setOpen] = useState(false)\n\n const theme = useTheme()\n\n const resolvedBgColor = resolveToThemeColor(\n value.bgColor ?? 'color.background.100',\n theme,\n )\n const resolvedTextColor = resolveToThemeColor(\n value.textColor ?? 'color.text.base',\n theme,\n )\n\n return (\n <Container\n id={id}\n className={className}\n onClick={() => setOpen((currentOpen) => !currentOpen)}\n {...marginProps}\n >\n {label && (\n <Text tag=\"label\" color=\"sesame\" typo=\"label\">\n {label}\n </Text>\n )}\n\n <Label $text={resolvedTextColor} $bg={resolvedBgColor}>\n <SelectedOption>{value.label}</SelectedOption>\n <IconContainer\n $size={20}\n style={{\n rotate: open ? '180deg' : '0deg',\n }}\n >\n <FontAwesomeIcon icon={faChevronDown} color={resolvedTextColor} />\n </IconContainer>\n </Label>\n <OuterContainer open={open}>\n <List options={list} selectOption={onSelect} />\n </OuterContainer>\n </Container>\n )\n}\n\ninterface ISelected {\n $text: string\n $bg: string\n}\n\nconst Label = styled.div<ISelected>(\n ({ $text, $bg }) => css`\n color: ${$text};\n background-color: ${$bg};\n position: relative;\n width: 100%;\n height: 48px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n text-align: center;\n border-radius: 100px;\n padding: 16px 16px 14px;\n box-sizing: border-box;\n user-select: none;\n `,\n)\n\nconst SelectedOption = styled.span`\n font-size: 14px;\n font-weight: bold;\n white-space: nowrap;\n text-overflow: ellipsis;\n`\n\nconst Container = styled(Box)`\n position: relative;\n display: block;\n width: 210px;\n height: 48px;\n text-align: center;\n cursor: pointer;\n outline: none;\n border-radius: 8px;\n`\n\ninterface IOpen {\n open: boolean\n}\n\nconst OuterContainer = styled.div<IOpen>(\n ({ open }) => css`\n position: absolute;\n width: 100%;\n border-radius: 12px;\n margin-top: ${({ theme }) => theme.space[100]};\n display: ${open ? 'block' : 'none'};\n max-height: ${open ? '235px' : '48px'};\n background-color: ${({ theme }) => theme.color.surface.base[300]};\n overflow-y: ${open ? 'auto' : 'hidden'};\n z-index: 4;\n transition: all 0.2s ease-in-out;\n `,\n)\n"]}
|
|
1
|
+
{"version":3,"file":"ActionDropdown.js","sourceRoot":"","sources":["../../src/ActionDropdown/ActionDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE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xB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,YAAY,GACtB,GACY,GACK,CACxB,GACc,IACP,CACb,CAAA;AACH,CAAC,CAAA;AAOD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;aACZ,KAAK;wBACM,GAAG;;;;;;;;;;;;;;;MAerB,iBAAiB;GACpB,CACF,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;CAKjC,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;;;;CAO5B,CAAA;AAMD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAC/B,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;;kBAID,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;eAClC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;kBACpB,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;wBACjB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;kBAClD,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;;;GAGvC,CACF,CAAA","sourcesContent":["import { FC, KeyboardEvent, useId, useRef, useState } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { ActionListItem, ListContainer, ListItems } from './List'\n\nimport { MarginProps } from '../utils/space'\nimport { resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\nimport { faChevronDown } from '@awesome.me/kit-46ca99185c/icons/classic/solid'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport {\n FloatingFocusManager,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useListNavigation,\n useRole,\n} from '@floating-ui/react'\nimport { focusOutlineStyle } from '../utils/focusOutline'\n\nexport type ActionDropdownProps = {\n id?: string\n className?: string\n /** label displayed above the dropdown */\n label?: string\n /** value */\n value: ActionListItem\n /** list of items for the dropdown list */\n list: ActionListItem[]\n /** onSelect handler */\n onSelect: (action: ActionListItem) => void\n} & MarginProps\n\nexport const ActionDropdown: FC<ActionDropdownProps> = ({\n id: idProp,\n className = '',\n label,\n value,\n list,\n onSelect,\n ...marginProps\n}) => {\n const [open, setOpen] = useState(false)\n const [activeIndex, setActiveIndex] = useState<number | null>(null)\n const listRef = useRef<Array<HTMLElement | null>>([])\n\n const generatedId = useId()\n const id = idProp ?? generatedId\n const buttonId = `${id}-button`\n\n const theme = useTheme()\n\n const resolvedBgColor = resolveToThemeColor(\n value.bgColor ?? 'color.background.100',\n theme,\n )\n const resolvedTextColor = resolveToThemeColor(\n value.textColor ?? 'color.text.base',\n theme,\n )\n\n const { refs, context } = useFloating({\n open,\n onOpenChange: (nextOpen) => {\n setOpen(nextOpen)\n if (!nextOpen) setActiveIndex(null)\n },\n })\n\n const click = useClick(context)\n const dismiss = useDismiss(context)\n const role = useRole(context, { role: 'listbox' })\n const listNavigation = useListNavigation(context, {\n listRef,\n activeIndex,\n selectedIndex: list.findIndex((item) => item.value === value.value),\n onNavigate: setActiveIndex,\n loop: true,\n })\n\n const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions(\n [click, dismiss, role, listNavigation],\n )\n\n const selectOption = (option: ActionListItem) => {\n onSelect(option)\n setOpen(false)\n setActiveIndex(null)\n }\n\n const handleListKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if ((event.key === 'Enter' || event.key === ' ') && activeIndex !== null) {\n event.preventDefault()\n selectOption(list[activeIndex])\n }\n }\n\n return (\n <Container id={idProp} className={className} {...marginProps}>\n {label && (\n <Text tag=\"label\" htmlFor={buttonId} color=\"sesame\" typo=\"label\">\n {label}\n </Text>\n )}\n\n <Label\n ref={refs.setReference}\n id={buttonId}\n type=\"button\"\n aria-label={label ? undefined : 'Select an option'}\n $text={resolvedTextColor}\n $bg={resolvedBgColor}\n {...getReferenceProps()}\n >\n <SelectedOption>{value.label}</SelectedOption>\n <IconContainer\n $size={20}\n style={{\n rotate: open ? '180deg' : '0deg',\n }}\n >\n <FontAwesomeIcon icon={faChevronDown} color={resolvedTextColor} />\n </IconContainer>\n </Label>\n <OuterContainer open={open}>\n {open && (\n <FloatingFocusManager context={context} modal={false} returnFocus>\n <ListContainer\n // oxlint-disable-next-line react/react-compiler\n ref={refs.setFloating}\n {...getFloatingProps({ onKeyDown: handleListKeyDown })}\n >\n <ListItems\n options={list}\n selectedValue={value.value}\n activeIndex={activeIndex}\n listRef={listRef}\n getItemProps={getItemProps}\n onSelect={selectOption}\n />\n </ListContainer>\n </FloatingFocusManager>\n )}\n </OuterContainer>\n </Container>\n )\n}\n\ninterface ISelected {\n $text: string\n $bg: string\n}\n\nconst Label = styled.button<ISelected>(\n ({ $text, $bg }) => css`\n color: ${$text};\n background-color: ${$bg};\n position: relative;\n width: 100%;\n height: 48px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n text-align: center;\n border: 0;\n border-radius: 100px;\n padding: 16px 16px 14px;\n box-sizing: border-box;\n font: inherit;\n cursor: pointer;\n user-select: none;\n ${focusOutlineStyle}\n `,\n)\n\nconst SelectedOption = styled.span`\n font-size: 14px;\n font-weight: bold;\n white-space: nowrap;\n text-overflow: ellipsis;\n`\n\nconst Container = styled(Box)`\n position: relative;\n display: block;\n width: 210px;\n height: 48px;\n text-align: center;\n border-radius: 8px;\n`\n\ninterface IOpen {\n open: boolean\n}\n\nconst OuterContainer = styled.div<IOpen>(\n ({ open }) => css`\n position: absolute;\n width: 100%;\n border-radius: 12px;\n margin-top: ${({ theme }) => theme.space[100]};\n display: ${open ? 'block' : 'none'};\n max-height: ${open ? '235px' : '48px'};\n background-color: ${({ theme }) => theme.color.surface.base[300]};\n overflow-y: ${open ? 'auto' : 'hidden'};\n z-index: 4;\n transition: all 0.2s ease-in-out;\n `,\n)\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, MutableRefObject } from 'react';
|
|
2
|
+
import type { useInteractions } from '@floating-ui/react';
|
|
2
3
|
import { ColorTypes } from '../ThemeProvider/utils/colourMap';
|
|
3
4
|
export type ActionListItem = {
|
|
4
5
|
label: string;
|
|
@@ -6,9 +7,17 @@ export type ActionListItem = {
|
|
|
6
7
|
bgColor?: ColorTypes;
|
|
7
8
|
textColor?: ColorTypes;
|
|
8
9
|
};
|
|
10
|
+
type Interactions = ReturnType<typeof useInteractions>;
|
|
9
11
|
type Props = {
|
|
10
12
|
options: ActionListItem[];
|
|
11
|
-
|
|
13
|
+
selectedValue: string;
|
|
14
|
+
activeIndex: number | null;
|
|
15
|
+
listRef: MutableRefObject<Array<HTMLElement | null>>;
|
|
16
|
+
getItemProps: Interactions['getItemProps'];
|
|
17
|
+
onSelect: (option: ActionListItem) => void;
|
|
12
18
|
};
|
|
13
|
-
export declare const
|
|
19
|
+
export declare const ListItems: FC<Props>;
|
|
20
|
+
export declare const ListContainer: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "style"> & {
|
|
21
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
22
|
+
}> & string;
|
|
14
23
|
export {};
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { darken } from 'polished';
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
import { fontStyleMapping } from '../Text/fontMapping';
|
|
5
|
+
export const ListItems = ({ options, selectedValue, activeIndex, listRef, getItemProps, onSelect, }) => options.map((option, index) => (_jsx(ListItem, { ref: (node) => {
|
|
6
|
+
listRef.current[index] = node;
|
|
7
|
+
}, role: "option", "aria-selected": option.value === selectedValue, tabIndex: activeIndex === index ? 0 : -1, ...getItemProps({ onClick: () => onSelect(option) }), children: option.label }, option.value)));
|
|
8
|
+
export const ListContainer = styled.ul `
|
|
6
9
|
padding: 0;
|
|
7
10
|
margin: 0;
|
|
8
|
-
max-height:
|
|
11
|
+
max-height: 192px;
|
|
12
|
+
list-style: none;
|
|
13
|
+
outline: none;
|
|
9
14
|
`;
|
|
10
15
|
const ListItem = styled.li `
|
|
11
|
-
padding:
|
|
16
|
+
padding: 14px 24px;
|
|
12
17
|
text-align: left;
|
|
13
18
|
overflow: hidden;
|
|
14
19
|
white-space: nowrap;
|
|
15
20
|
text-overflow: ellipsis;
|
|
16
21
|
box-sizing: border-box;
|
|
17
|
-
|
|
22
|
+
${fontStyleMapping['body-small']};
|
|
18
23
|
cursor: pointer;
|
|
19
24
|
color: ${({ theme }) => theme.color.surface.base[900]};
|
|
20
25
|
|
|
21
|
-
&:hover
|
|
26
|
+
&:hover,
|
|
27
|
+
&:focus-visible {
|
|
22
28
|
background-color: ${({ theme }) => darken(0.1, theme.color.surface.base[300])};
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
&:focus-visible {
|
|
32
|
+
outline: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
&:last-child {
|
|
26
36
|
border-bottom: none;
|
|
27
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/ActionDropdown/List.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../src/ActionDropdown/List.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CA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ject } from 'react'\nimport styled from 'styled-components'\nimport type { useInteractions } from '@floating-ui/react'\n\nimport { darken } from 'polished'\nimport { ColorTypes } from '../ThemeProvider/utils/colourMap'\nimport { fontStyleMapping } from '../Text/fontMapping'\n\nexport type ActionListItem = {\n label: string\n value: string\n bgColor?: ColorTypes\n textColor?: ColorTypes\n}\n\ntype Interactions = ReturnType<typeof useInteractions>\n\ntype Props = {\n options: ActionListItem[]\n selectedValue: string\n activeIndex: number | null\n listRef: MutableRefObject<Array<HTMLElement | null>>\n getItemProps: Interactions['getItemProps']\n onSelect: (option: ActionListItem) => void\n}\n\nexport const ListItems: FC<Props> = ({\n options,\n selectedValue,\n activeIndex,\n listRef,\n getItemProps,\n onSelect,\n}) =>\n options.map((option, index) => (\n <ListItem\n key={option.value}\n ref={(node) => {\n listRef.current[index] = node\n }}\n role=\"option\"\n aria-selected={option.value === selectedValue}\n tabIndex={activeIndex === index ? 0 : -1}\n {...getItemProps({ onClick: () => onSelect(option) })}\n >\n {option.label}\n </ListItem>\n ))\n\nexport const ListContainer = styled.ul`\n padding: 0;\n margin: 0;\n max-height: 192px;\n list-style: none;\n outline: none;\n`\n\nconst ListItem = styled.li`\n padding: 14px 24px;\n text-align: left;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n box-sizing: border-box;\n ${fontStyleMapping['body-small']};\n cursor: pointer;\n color: ${({ theme }) => theme.color.surface.base[900]};\n\n &:hover,\n &:focus-visible {\n background-color: ${({ theme }) =>\n darken(0.1, theme.color.surface.base[300])};\n }\n\n &:focus-visible {\n outline: none;\n }\n\n &:last-child {\n border-bottom: none;\n }\n`\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ActionDropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export { ActionDropdown } from './ActionDropdown'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ActionDropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export { ActionDropdown } from './ActionDropdown'\nexport type { ActionDropdownProps } from './ActionDropdown'\nexport type { ActionListItem } from './List'\n"]}
|
|
@@ -4,6 +4,7 @@ import styled from 'styled-components';
|
|
|
4
4
|
import { Field } from '../fields/Field';
|
|
5
5
|
import { useUniqueId } from '../utils/id';
|
|
6
6
|
import { getFieldAria } from '../fields/fieldAria';
|
|
7
|
+
import { fieldFocusAttrs, fieldFocusRing, fieldHoverBorderColor, } from '../fields/components/fieldStyles';
|
|
7
8
|
export const Textarea = forwardRef(function Textarea({ id: idProp, name, value, onChange, onInputChange, resize = 'none', error = false, placeholder, disabled = false, maxLength, onBlur, rows = 4, fallbackStyle, ...fieldProps }, ref) {
|
|
8
9
|
const id = useUniqueId(idProp);
|
|
9
10
|
const { assistiveTextId, errorMsgId, controlAria } = getFieldAria(id, {
|
|
@@ -15,7 +16,7 @@ export const Textarea = forwardRef(function Textarea({ id: idProp, name, value,
|
|
|
15
16
|
onInputChange?.(e);
|
|
16
17
|
}, maxLength: maxLength, onBlur: onBlur, rows: rows, ...controlAria }) }));
|
|
17
18
|
});
|
|
18
|
-
const StyledTextArea = styled.textarea `
|
|
19
|
+
const StyledTextArea = styled.textarea.attrs(fieldFocusAttrs) `
|
|
19
20
|
font-size: 16px;
|
|
20
21
|
font: inherit;
|
|
21
22
|
line-height: 20px;
|
|
@@ -34,10 +35,16 @@ const StyledTextArea = styled.textarea `
|
|
|
34
35
|
border-color: ${({ $error, theme }) => $error ? theme.color.feedback.negative[200] : theme.color.border.subtle};
|
|
35
36
|
outline: none;
|
|
36
37
|
|
|
37
|
-
&:hover
|
|
38
|
-
|
|
39
|
-
&:focus-visible {
|
|
40
|
-
border-color: ${({ $error, theme }) => $error ? theme.color.feedback.negative[200] : theme.color.border.base};
|
|
38
|
+
&:hover:not(:disabled):not(:focus) {
|
|
39
|
+
border-color: ${({ $error, theme }) => fieldHoverBorderColor(theme, $error)};
|
|
41
40
|
}
|
|
41
|
+
|
|
42
|
+
&:focus {
|
|
43
|
+
border-color: ${({ $error, theme }) => $error
|
|
44
|
+
? theme.color.feedback.negative[200]
|
|
45
|
+
: theme.color.border.contrast};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
${fieldFocusRing}
|
|
42
49
|
`;
|
|
43
50
|
//# sourceMappingURL=Textarea.js.map
|
|
@@ -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;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA+
|
|
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;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EACL,eAAe,EACf,cAAc,EACd,qBAAqB,GACtB,MAAM,kCAAkC,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,GA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AK,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;sBACf,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;;;;;WAKnD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;YACnC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO;YACxB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;aACpD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;kBACrC,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,MAAM;;;;oBAIvD,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC;;;;oBAI3D,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CACpC,MAAM;IACJ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;IACpC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ;;;IAGjC,cAAc;CACjB,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 { getFieldAria } from '../fields/fieldAria'\nimport {\n fieldFocusAttrs,\n fieldFocusRing,\n fieldHoverBorderColor,\n} from '../fields/components/fieldStyles'\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 const { assistiveTextId, errorMsgId, controlAria } = getFieldAria(id, {\n ...fieldProps,\n error,\n })\n return (\n <Field\n {...fieldProps}\n htmlFor={id}\n error={error}\n assistiveTextId={assistiveTextId}\n errorMsgId={errorMsgId}\n >\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 {...controlAria}\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.attrs(fieldFocusAttrs)<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: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`\n"]}
|