no-frills-ui 0.0.14-alpha.3 → 0.0.14-alpha.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/index.js +313 -72
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.js +18 -11
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.js +2 -2
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts +2 -2
- package/lib-esm/components/Button/Button.d.ts.map +1 -1
- package/lib-esm/components/Button/Button.js +6 -2
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.js +1 -1
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.js +1 -1
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +5 -2
- package/lib-esm/components/Chip/Chip.d.ts.map +1 -1
- package/lib-esm/components/Chip/Chip.js +14 -8
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +9 -0
- package/lib-esm/components/ChipInput/ChipInput.d.ts.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.js +43 -4
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.js +1 -1
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +6 -1
- package/lib-esm/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +24 -0
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +85 -3
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +4 -0
- package/lib-esm/components/DragAndDrop/DragItem.d.ts.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.js +86 -6
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +19 -0
- package/lib-esm/components/DragAndDrop/types.d.ts.map +1 -1
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts.map +1 -1
- package/lib-esm/components/Input/Checkbox.js +1 -1
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts.map +1 -1
- package/lib-esm/components/Input/Input.js +0 -1
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts.map +1 -1
- package/lib-esm/components/Input/Select.js +0 -1
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts.map +1 -1
- package/lib-esm/components/Input/TextArea.js +0 -1
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +9 -7
- package/lib-esm/components/Notification/Notification.d.ts.map +1 -1
- package/lib-esm/components/Notification/Notification.js +51 -24
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/shared/constants.js +7 -7
- package/lib-esm/shared/constants.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionStep.d.ts","sourceRoot":"","sources":["../../../src/components/Accordion/AccordionStep.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AccordionStep.d.ts","sourceRoot":"","sources":["../../../src/components/Accordion/AccordionStep.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AAuGnC,eAAO,MAAM,iBAAiB;;SAnFE,MAAO,WAAW;qFAqFjD,CAAC;AAEF,eAAO,MAAM,mBAAmB;;SAvFA,MAAO,WAAW;qFA4FjD,CAAC;AAEF,iBAAwB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,oDAmDvF;kBAnDuB,aAAa;;QAsDjC,+BAA+B;;QAE/B,8BAA8B;;QAE9B,4CAA4C;;QAE5C,8BAA8B;;;;;;;;eA5DV,aAAa;AAqErC,KAAK,kBAAkB,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,SAAS,CAAC,GAAG;IAC7E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useState, useId } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import styled from '@emotion/styled';
|
|
@@ -10,18 +10,26 @@ import { Badge, BADGE_TYPE } from '../Badge';
|
|
|
10
10
|
import { Card } from '../Card';
|
|
11
11
|
const Step = styled(Card) `
|
|
12
12
|
transition: all 0.6s ease;
|
|
13
|
+
overflow: visible;
|
|
13
14
|
|
|
14
15
|
${(props) => props.open &&
|
|
15
16
|
`
|
|
16
17
|
margin: 20px 5px;
|
|
17
18
|
`}
|
|
18
|
-
|
|
19
|
-
${(props) => props.focused && `box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});`}
|
|
20
19
|
`;
|
|
21
|
-
const StepHeader = styled.
|
|
20
|
+
const StepHeader = styled.button `
|
|
22
21
|
padding: 20px 15px;
|
|
23
22
|
display: flex;
|
|
24
23
|
justify-content: space-between;
|
|
24
|
+
background: none;
|
|
25
|
+
border: none;
|
|
26
|
+
border-radius: 10px;
|
|
27
|
+
width: 100%;
|
|
28
|
+
font-size: inherit;
|
|
29
|
+
|
|
30
|
+
&:focus-visible {
|
|
31
|
+
box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});
|
|
32
|
+
}
|
|
25
33
|
|
|
26
34
|
& input {
|
|
27
35
|
appearance: none;
|
|
@@ -36,7 +44,7 @@ const StepHeader = styled.div `
|
|
|
36
44
|
|
|
37
45
|
${(props) => props.disabled
|
|
38
46
|
? `
|
|
39
|
-
color: ${constants.
|
|
47
|
+
color: ${constants.DISABLED};
|
|
40
48
|
`
|
|
41
49
|
: `
|
|
42
50
|
cursor: pointer;
|
|
@@ -95,15 +103,14 @@ export const AccordionStepFooter = styled.div `
|
|
|
95
103
|
`;
|
|
96
104
|
export default function AccordionStep(props) {
|
|
97
105
|
const [height, setHeight] = useState(0);
|
|
98
|
-
const [focused, setFocused] = useState(false);
|
|
99
106
|
const { open, disabled, header, errorText, completed, onStepClick } = props;
|
|
107
|
+
// Generate unique IDs for ARIA relationships
|
|
108
|
+
const headerId = useId();
|
|
109
|
+
const regionId = useId();
|
|
100
110
|
const ref = (el) => setHeight((el === null || el === void 0 ? void 0 : el.scrollHeight) || 0);
|
|
101
|
-
|
|
102
|
-
setFocused(!focused);
|
|
103
|
-
};
|
|
104
|
-
return (_jsxs(Step, Object.assign({}, props, { focused: focused, elevated: props.open, children: [_jsxs(StepHeader, { open: open, disabled: disabled, onClick: onStepClick, children: [_jsxs(HeaderContainer, { open: open, completed: completed, children: [_jsx("input", { type: "checkbox", checked: open, disabled: disabled, onFocus: toggleFocus, onBlur: toggleFocus }), _jsx(FiberManualRecord, {}), _jsx(Ellipsis, { children: header })] }), _jsxs(ExpandContainer, { open: open, children: [errorText && (_jsx(Badge, { css: css `
|
|
111
|
+
return (_jsxs(Step, Object.assign({}, props, { elevated: props.open, children: [_jsxs(StepHeader, { open: open, disabled: disabled, onClick: onStepClick, "aria-expanded": open ? 'true' : 'false', "aria-controls": regionId, id: headerId, children: [_jsxs(HeaderContainer, { open: open, completed: completed, children: [_jsx(FiberManualRecord, { "aria-hidden": "true" }), _jsx(Ellipsis, { children: header })] }), _jsxs(ExpandContainer, { open: open, children: [errorText && (_jsx(Badge, { css: css `
|
|
105
112
|
margin-right: 15px;
|
|
106
|
-
`, inline: true, type: BADGE_TYPE.DANGER, children: errorText })), _jsx(ExpandMore, {})] })] }), _jsx(StepBody, { ref: ref, height: open ? height : 0, children: open && props.children })] })));
|
|
113
|
+
`, inline: true, type: BADGE_TYPE.DANGER, children: errorText })), _jsx(ExpandMore, { "aria-hidden": "true" })] })] }), _jsx(StepBody, { ref: ref, height: open ? height : 0, role: "region", id: regionId, "aria-labelledby": headerId, "aria-hidden": open ? 'false' : 'true', children: open && props.children })] })));
|
|
107
114
|
}
|
|
108
115
|
AccordionStep.propTypes = {
|
|
109
116
|
/** Header text for the step */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionStep.js","sourceRoot":"","sources":["../../../src/components/Accordion/AccordionStep.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AccordionStep.js","sourceRoot":"","sources":["../../../src/components/Accordion/AccordionStep.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,UAA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AK,IACF,GAAG,EAAE,GAAG,CAAA;;6BAEP,EACD,MAAM,QACN,IAAI,EAAE,UAAU,CAAC,MAAM,YAEtB,SAAS,GACN,CACX,EACD,KAAC,UAAU,mBAAa,MAAM,GAAG,IACnB,IACT,EACb,KAAC,QAAQ,IACL,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACzB,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,QAAQ,qBACK,QAAQ,iBACZ,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,YAEnC,IAAI,IAAI,KAAK,CAAC,QAAQ,GAChB,KACR,CACV,CAAC;AACN,CAAC;AAED,aAAa,CAAC,SAAS,GAAG;IACtB,+BAA+B;IAC/B,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IACnC,8BAA8B;IAC9B,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,4CAA4C;IAC5C,SAAS,EAAE,SAAS,CAAC,IAAI;IACzB,8BAA8B;IAC9B,QAAQ,EAAE,SAAS,CAAC,IAAI;CAC3B,CAAC;AAEF,aAAa,CAAC,YAAY,GAAG;IACzB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,KAAK;CAClB,CAAC","sourcesContent":["import React, { useState, useId } from 'react';\nimport PropTypes from 'prop-types';\nimport { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { FiberManualRecord, ExpandMore } from '../../icons';\nimport constants from '../../shared/constants';\nimport { Ellipsis } from '../../shared/styles';\nimport { Badge, BADGE_TYPE } from '../Badge';\nimport { Card } from '../Card';\n\nconst Step = styled(Card)<AccordionStepProps>`\n transition: all 0.6s ease;\n overflow: visible;\n\n ${(props) =>\n props.open &&\n `\n margin: 20px 5px;\n `}\n`;\n\nconst StepHeader = styled.button<{ open: boolean; disabled: boolean }>`\n padding: 20px 15px;\n display: flex;\n justify-content: space-between;\n background: none;\n border: none;\n border-radius: 10px;\n width: 100%;\n font-size: inherit;\n\n &:focus-visible {\n box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});\n }\n\n & input {\n appearance: none;\n margin: 0;\n }\n\n ${(props) =>\n props.open\n ? `\n border-bottom: 1px solid var(--border-light-color, ${constants.BORDER_LIGHT_COLOR});\n `\n : ''}\n\n ${(props) =>\n props.disabled\n ? `\n color: ${constants.DISABLED};\n `\n : `\n cursor: pointer;\n `}\n`;\n\nconst HeaderContainer = styled.div<{ open: boolean; completed: boolean }>`\n display: flex;\n align-items: center;\n min-width: 40px;\n\n & svg {\n vertical-align: top;\n margin-right: 10px;\n fill: ${(props) =>\n props.open\n ? `var(--primary, ${constants.PRIMARY})`\n : props.completed\n ? `var(--success, ${constants.SUCCESS})`\n : constants.LIGHT_GREY};\n transform: ${(props) => (props.open ? 'scale(0.8)' : 'scale(0.6)')};\n transition: all 0.3s ease;\n min-width: 24px;\n }\n`;\n\nconst ExpandContainer = styled.div<{ open: boolean }>`\n display: flex;\n align-items: center;\n\n & svg {\n vertical-align: top;\n margin-right: 10px;\n transition: all 0.6s ease;\n fill: currentColor;\n }\n\n ${(props) =>\n props.open\n ? `\n & svg {\n transform: rotate(180deg);\n }\n `\n : ''}\n`;\n\nconst StepBody = styled.div<{ height: number }>`\n transition: all 0.6s ease;\n overflow: hidden;\n height: ${(props) => props.height || 0}px;\n`;\n\nexport const AccordionStepBody = styled.div`\n padding: 20px 15px;\n`;\n\nexport const AccordionStepFooter = styled.div`\n display: flex;\n justify-content: flex-end;\n padding: 10px 15px;\n border-top: 1px solid var(--border-light-color, ${constants.BORDER_LIGHT_COLOR});\n`;\n\nexport default function AccordionStep(props: React.PropsWithChildren<AccordionStepProps>) {\n const [height, setHeight] = useState(0);\n const { open, disabled, header, errorText, completed, onStepClick } = props;\n\n // Generate unique IDs for ARIA relationships\n const headerId = useId();\n const regionId = useId();\n\n const ref = (el?: HTMLDivElement) => setHeight(el?.scrollHeight || 0);\n\n return (\n <Step {...props} elevated={props.open}>\n <StepHeader\n open={open}\n disabled={disabled}\n onClick={onStepClick}\n aria-expanded={open ? 'true' : 'false'}\n aria-controls={regionId}\n id={headerId}\n >\n <HeaderContainer open={open} completed={completed}>\n <FiberManualRecord aria-hidden=\"true\" />\n <Ellipsis>{header}</Ellipsis>\n </HeaderContainer>\n <ExpandContainer open={open}>\n {errorText && (\n <Badge\n css={css`\n margin-right: 15px;\n `}\n inline\n type={BADGE_TYPE.DANGER}\n >\n {errorText}\n </Badge>\n )}\n <ExpandMore aria-hidden=\"true\" />\n </ExpandContainer>\n </StepHeader>\n <StepBody\n ref={ref}\n height={open ? height : 0}\n role=\"region\"\n id={regionId}\n aria-labelledby={headerId}\n aria-hidden={open ? 'false' : 'true'}\n >\n {open && props.children}\n </StepBody>\n </Step>\n );\n}\n\nAccordionStep.propTypes = {\n /** Header text for the step */\n header: PropTypes.string.isRequired,\n /** Error text for the step */\n errorText: PropTypes.string,\n /** If steps has been marked as completed */\n completed: PropTypes.bool,\n /** If the step is disabled */\n disabled: PropTypes.bool,\n};\n\nAccordionStep.defaultProps = {\n completed: false,\n disabled: false,\n};\n\ntype AccordionStepProps = PropTypes.InferProps<typeof AccordionStep.propTypes> & {\n open?: boolean;\n completed: boolean;\n onStepClick?: () => void;\n};\n"]}
|
|
@@ -33,8 +33,8 @@ export default styled.button `
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
&:disabled {
|
|
36
|
-
border: 1px solid ${constants.
|
|
37
|
-
background-color: var(--border-light-color, ${constants.
|
|
36
|
+
border: 1px solid ${constants.BORDER_LIGHT_COLOR};
|
|
37
|
+
background-color: var(--border-light-color, ${constants.DISABLED_BACKGROUND});
|
|
38
38
|
color: var(--disabled, ${constants.DISABLED});
|
|
39
39
|
}
|
|
40
40
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.js","sourceRoot":"","sources":["../../../src/components/Button/ActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,eAAe,MAAM,CAAC,MAAM,CAAA;uCACW,SAAS,CAAC,OAAO;uCACjB,SAAS,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;0CAuBd,SAAS,CAAC,YAAY;;;;qDAIX,SAAS,CAAC,aAAa;;;;4BAIhD,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"ActionButton.js","sourceRoot":"","sources":["../../../src/components/Button/ActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,eAAe,MAAM,CAAC,MAAM,CAAA;uCACW,SAAS,CAAC,OAAO;uCACjB,SAAS,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;0CAuBd,SAAS,CAAC,YAAY;;;;qDAIX,SAAS,CAAC,aAAa;;;;4BAIhD,SAAS,CAAC,kBAAkB;sDACF,SAAS,CAAC,mBAAmB;iCAClD,SAAS,CAAC,QAAQ;;CAElD,CAAC","sourcesContent":["import styled from '@emotion/styled';\nimport constants from '../../shared/constants';\n\nexport default styled.button`\n border: 1px solid var(--primary, ${constants.PRIMARY});\n background-color: var(--primary, ${constants.PRIMARY});\n color: #fff;\n border-radius: 5px;\n height: 32px;\n min-width: 100px;\n font-size: 14px;\n text-align: center;\n padding: 0 12px;\n cursor: pointer;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: 5px;\n position: relative;\n\n & svg {\n vertical-align: middle;\n height: 24px;\n width: 24px;\n fill: currentColor;\n margin-left: -6px;\n }\n\n &:enabled:hover {\n box-shadow: var(--hover-shadow, ${constants.HOVER_SHADOW});\n }\n\n &:focus {\n box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});\n }\n\n &:disabled {\n border: 1px solid ${constants.BORDER_LIGHT_COLOR};\n background-color: var(--border-light-color, ${constants.DISABLED_BACKGROUND});\n color: var(--disabled, ${constants.DISABLED});\n }\n`;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const StyledButton: import("@emotion/styled").StyledComponent<{
|
|
2
2
|
theme?: import("@emotion/react").Theme;
|
|
3
3
|
as?: React.ElementType;
|
|
4
4
|
}, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
|
|
5
|
-
export default
|
|
5
|
+
export default StyledButton;
|
|
6
6
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,YAAY;;SAoBV,MAAE,WAAW;qHAmBpB,CAAC;AAMF,eAAe,YAAY,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import constants from '../../shared/constants';
|
|
3
|
-
|
|
3
|
+
const StyledButton = styled.button `
|
|
4
4
|
border: 1px solid var(--border-color, ${constants.BORDER_COLOR});
|
|
5
5
|
border-radius: 5px;
|
|
6
6
|
height: 32px;
|
|
@@ -35,9 +35,13 @@ export default styled.button `
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
&:disabled {
|
|
38
|
-
background-color: var(--border-light-color, ${constants.
|
|
38
|
+
background-color: var(--border-light-color, ${constants.DISABLED_BACKGROUND});
|
|
39
39
|
border-color: var(--light-grey, ${constants.LIGHT_GREY});
|
|
40
40
|
color: var(--disabled, ${constants.DISABLED});
|
|
41
41
|
}
|
|
42
42
|
`;
|
|
43
|
+
StyledButton.defaultProps = {
|
|
44
|
+
type: 'button',
|
|
45
|
+
};
|
|
46
|
+
export default StyledButton;
|
|
43
47
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAA;4CACU,SAAS,CAAC,YAAY;;;;;;;;;0CASxB,SAAS,CAAC,UAAU;;;;;;;;;;;;;;;uCAevB,SAAS,CAAC,OAAO;gCACxB,SAAS,CAAC,OAAO;;;;uCAIV,SAAS,CAAC,OAAO;qDACH,SAAS,CAAC,aAAa;;;;sDAItB,SAAS,CAAC,mBAAmB;0CACzC,SAAS,CAAC,UAAU;iCAC7B,SAAS,CAAC,QAAQ;;CAElD,CAAC;AAEF,YAAY,CAAC,YAAY,GAAG;IACxB,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import styled from '@emotion/styled';\nimport constants from '../../shared/constants';\n\nconst StyledButton = styled.button`\n border: 1px solid var(--border-color, ${constants.BORDER_COLOR});\n border-radius: 5px;\n height: 32px;\n min-width: 100px;\n font-size: 14px;\n text-align: center;\n padding: 0 12px;\n cursor: pointer;\n color: inherit;\n background-color: var(--background, ${constants.BACKGROUND});\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: 5px;\n position: relative;\n\n & svg {\n vertical-align: middle;\n height: 24px;\n width: 24px;\n margin-left: -6px;\n fill: currentColor;\n }\n\n &:enabled:hover {\n border-color: var(--primary, ${constants.PRIMARY});\n color: var(--primary, ${constants.PRIMARY});\n }\n\n &:focus {\n border-color: var(--primary, ${constants.PRIMARY});\n box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});\n }\n\n &:disabled {\n background-color: var(--border-light-color, ${constants.DISABLED_BACKGROUND});\n border-color: var(--light-grey, ${constants.LIGHT_GREY});\n color: var(--disabled, ${constants.DISABLED});\n }\n`;\n\nStyledButton.defaultProps = {\n type: 'button',\n};\n\nexport default StyledButton;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../src/components/Button/LinkButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,eAAe,MAAM,CAAC,MAAM,CAAA;;;;;;;;4BAQA,SAAS,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;wBAqBrB,SAAS,CAAC,YAAY;iBAC7B,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../src/components/Button/LinkButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,eAAe,MAAM,CAAC,MAAM,CAAA;;;;;;;;4BAQA,SAAS,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;wBAqBrB,SAAS,CAAC,YAAY;iBAC7B,SAAS,CAAC,QAAQ;;CAElC,CAAC","sourcesContent":["import styled from '@emotion/styled';\nimport constants from '../../shared/constants';\n\nexport default styled.button`\n min-width: 100px;\n font-size: 14px;\n text-align: center;\n height: 32px;\n cursor: pointer;\n background-color: transparent;\n border: none;\n color: var(--primary, ${constants.PRIMARY});\n padding: 0 12px;\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: 5px;\n position: relative;\n\n & svg {\n vertical-align: middle;\n height: 24px;\n width: 24px;\n fill: currentColor;\n margin-left: -6px;\n }\n\n &:enabled:hover,\n &:focus {\n text-decoration: underline;\n }\n\n &:disabled {\n border-color: ${constants.BORDER_COLOR};\n color: ${constants.DISABLED};\n }\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RaisedButton.js","sourceRoot":"","sources":["../../../src/components/Button/RaisedButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,eAAe,MAAM,CAAC,MAAM,CAAA;4CACgB,SAAS,CAAC,YAAY;;;;;;;;;0CASxB,SAAS,CAAC,UAAU;;sCAExB,SAAS,CAAC,YAAY;;;;;;;;;;;;;;;uCAerB,SAAS,CAAC,OAAO;gCACxB,SAAS,CAAC,OAAO;;;;uCAIV,SAAS,CAAC,OAAO;;;;4BAI5B,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"RaisedButton.js","sourceRoot":"","sources":["../../../src/components/Button/RaisedButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,eAAe,MAAM,CAAC,MAAM,CAAA;4CACgB,SAAS,CAAC,YAAY;;;;;;;;;0CASxB,SAAS,CAAC,UAAU;;sCAExB,SAAS,CAAC,YAAY;;;;;;;;;;;;;;;uCAerB,SAAS,CAAC,OAAO;gCACxB,SAAS,CAAC,OAAO;;;;uCAIV,SAAS,CAAC,OAAO;;;;4BAI5B,SAAS,CAAC,mBAAmB;wBACjC,SAAS,CAAC,UAAU;iBAC3B,SAAS,CAAC,QAAQ;;;;;oCAKC,SAAS,CAAC,MAAM;;CAEnD,CAAC","sourcesContent":["import styled from '@emotion/styled';\nimport constants from '../../shared/constants';\n\nexport default styled.button`\n border: 1px solid var(--border-color, ${constants.BORDER_COLOR});\n border-radius: 5px;\n height: 32px;\n min-width: 100px;\n font-size: 14px;\n text-align: center;\n padding: 0 12px;\n cursor: pointer;\n color: inherit;\n background-color: var(--background, ${constants.BACKGROUND});\n transform: translateY(-2px);\n box-shadow: var(--hover-shadow, ${constants.HOVER_SHADOW});\n text-overflow: ellipsis;\n white-space: nowrap;\n margin: 5px;\n position: relative;\n\n & svg {\n vertical-align: middle;\n height: 24px;\n width: 24px;\n margin-left: -6px;\n fill: currentColor;\n }\n\n &:enabled:hover {\n border-color: var(--primary, ${constants.PRIMARY});\n color: var(--primary, ${constants.PRIMARY});\n }\n\n &:focus {\n border-color: var(--primary, ${constants.PRIMARY});\n }\n\n &:disabled {\n background-color: ${constants.DISABLED_BACKGROUND};\n border-color: ${constants.LIGHT_GREY};\n color: ${constants.DISABLED};\n }\n\n &:active {\n transform: translateY(0);\n box-shadow: var(--shadow, ${constants.SHADOW});\n }\n`;\n"]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
interface ChipProps {
|
|
2
3
|
/** Label for the chip */
|
|
3
4
|
label: string;
|
|
4
5
|
/** Callback when the close button is clicked */
|
|
5
|
-
onCloseClick?: () => void;
|
|
6
|
+
onCloseClick?: (e: React.KeyboardEvent | React.MouseEvent) => void;
|
|
7
|
+
/** Aria label for the close button. Defaults to "Remove {label}" */
|
|
8
|
+
closeButtonAriaLabel?: string;
|
|
6
9
|
}
|
|
7
|
-
export default function Chip(props: ChipProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function Chip(props: ChipProps & React.HTMLAttributes<HTMLSpanElement>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
11
|
export {};
|
|
9
12
|
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,UAAU,SAAS;IACf,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACnE,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AA2BD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,oDA4BpF"}
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
13
13
|
import styled from '@emotion/styled';
|
|
14
14
|
import { Close } from '../../icons';
|
|
15
15
|
import constants from '../../shared/constants';
|
|
16
|
-
const Container = styled.
|
|
16
|
+
const Container = styled.span `
|
|
17
17
|
padding: 5px;
|
|
18
18
|
padding-left: 15px;
|
|
19
19
|
border-radius: 16px;
|
|
@@ -28,21 +28,27 @@ const Container = styled.div `
|
|
|
28
28
|
}
|
|
29
29
|
`;
|
|
30
30
|
const Button = styled.button `
|
|
31
|
-
color:
|
|
32
|
-
background-color: var(--
|
|
31
|
+
color: var(--background-color, ${constants.BACKGROUND});
|
|
32
|
+
background-color: var(--border-color, ${constants.DISABLED});
|
|
33
33
|
border-radius: 50%;
|
|
34
34
|
border: none;
|
|
35
|
-
padding:
|
|
35
|
+
padding: 4px;
|
|
36
36
|
display: inline-flex;
|
|
37
37
|
margin-left: 5px;
|
|
38
38
|
`;
|
|
39
39
|
export default function Chip(props) {
|
|
40
|
-
const { label, onCloseClick } = props, rest = __rest(props, ["label", "onCloseClick"]);
|
|
40
|
+
const { label, onCloseClick, closeButtonAriaLabel } = props, rest = __rest(props, ["label", "onCloseClick", "closeButtonAriaLabel"]);
|
|
41
41
|
const keyUpHandler = (e) => {
|
|
42
|
-
if (e.
|
|
43
|
-
onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
|
|
42
|
+
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
43
|
+
onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick(e);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
const buttonKeyDownHandler = (e) => {
|
|
47
|
+
// Stop propagation to prevent DragAndDrop from capturing Space/Enter
|
|
48
|
+
if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'Enter') {
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return (_jsxs(Container, Object.assign({}, rest, { onKeyUp: keyUpHandler, children: [label, _jsx(Button, { onClick: onCloseClick, onKeyDown: buttonKeyDownHandler, "aria-label": closeButtonAriaLabel !== null && closeButtonAriaLabel !== void 0 ? closeButtonAriaLabel : `Remove ${label}`, children: _jsx(Close, { height: 16, width: 16 }) })] })));
|
|
47
53
|
}
|
|
48
54
|
//# sourceMappingURL=Chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../src/components/Chip/Chip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,SAAS,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../src/components/Chip/Chip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAW/C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAA;;;;kDAIqB,SAAS,CAAC,kBAAkB;;;;;;;kDAO5B,SAAS,CAAC,aAAa;;CAExE,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;qCACS,SAAS,CAAC,UAAU;4CACb,SAAS,CAAC,QAAQ;;;;;;CAM7D,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,KAAwD;IACjF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,oBAAoB,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA9D,iDAAsD,CAAQ,CAAC;IAErE,MAAM,YAAY,GAAgD,CAAC,CAAC,EAAE,EAAE;QACpE,IAAI,CAAC,CAAC,GAAG,KAAK,WAAW,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC9C,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,CAAC,CAAC,CAAC;QACtB,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAkD,CAAC,CAAC,EAAE,EAAE;QAC9E,qEAAqE;QACrE,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,KAAK,UAAU,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YAC7D,CAAC,CAAC,eAAe,EAAE,CAAC;QACxB,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACH,MAAC,SAAS,oBAAK,IAAI,IAAE,OAAO,EAAE,YAAY,aACrC,KAAK,EACN,KAAC,MAAM,IACH,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,oBAAoB,gBACnB,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,UAAU,KAAK,EAAE,YAErD,KAAC,KAAK,IAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,GAAI,GAC3B,KACD,CACf,CAAC;AACN,CAAC","sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { Close } from '../../icons';\nimport constants from '../../shared/constants';\n\ninterface ChipProps {\n /** Label for the chip */\n label: string;\n /** Callback when the close button is clicked */\n onCloseClick?: (e: React.KeyboardEvent | React.MouseEvent) => void;\n /** Aria label for the close button. Defaults to \"Remove {label}\" */\n closeButtonAriaLabel?: string;\n}\n\nconst Container = styled.span`\n padding: 5px;\n padding-left: 15px;\n border-radius: 16px;\n background-color: var(--border-light-color, ${constants.BORDER_LIGHT_COLOR});\n display: inline-flex;\n margin: 5px;\n line-height: 20px;\n align-items: center;\n\n &:focus-within {\n outline: 2px solid var(--primary-light, ${constants.PRIMARY_LIGHT});\n }\n`;\n\nconst Button = styled.button`\n color: var(--background-color, ${constants.BACKGROUND});\n background-color: var(--border-color, ${constants.DISABLED});\n border-radius: 50%;\n border: none;\n padding: 4px;\n display: inline-flex;\n margin-left: 5px;\n`;\n\nexport default function Chip(props: ChipProps & React.HTMLAttributes<HTMLSpanElement>) {\n const { label, onCloseClick, closeButtonAriaLabel, ...rest } = props;\n\n const keyUpHandler: React.KeyboardEventHandler<HTMLSpanElement> = (e) => {\n if (e.key === 'Backspace' || e.key === 'Delete') {\n onCloseClick?.(e);\n }\n };\n\n const buttonKeyDownHandler: React.KeyboardEventHandler<HTMLButtonElement> = (e) => {\n // Stop propagation to prevent DragAndDrop from capturing Space/Enter\n if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'Enter') {\n e.stopPropagation();\n }\n };\n\n return (\n <Container {...rest} onKeyUp={keyUpHandler}>\n {label}\n <Button\n onClick={onCloseClick}\n onKeyDown={buttonKeyDownHandler}\n aria-label={closeButtonAriaLabel ?? `Remove ${label}`}\n >\n <Close height={16} width={16} />\n </Button>\n </Container>\n );\n}\n"]}
|
|
@@ -25,9 +25,18 @@ declare namespace ChipInput {
|
|
|
25
25
|
value: PropTypes.Requireable<string[]>;
|
|
26
26
|
/** Callback when chips change */
|
|
27
27
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
+
/** Aria label for the close button on chip. Defaults to "Remove {label}" */
|
|
29
|
+
closeButtonAriaLabel: PropTypes.Requireable<string>;
|
|
30
|
+
/** Announcement text when a chip is added. Defaults to "{label} was added" */
|
|
31
|
+
addedAnnouncementTemplate: PropTypes.Requireable<string>;
|
|
32
|
+
/** Announcement text when a chip is removed. Defaults to "{label} was removed" */
|
|
33
|
+
removedAnnouncementTemplate: PropTypes.Requireable<string>;
|
|
28
34
|
};
|
|
29
35
|
var defaultProps: {
|
|
30
36
|
value: any[];
|
|
37
|
+
closeButtonAriaLabel: string;
|
|
38
|
+
addedAnnouncementTemplate: string;
|
|
39
|
+
removedAnnouncementTemplate: string;
|
|
31
40
|
};
|
|
32
41
|
}
|
|
33
42
|
export default ChipInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipInput.d.ts","sourceRoot":"","sources":["../../../src/components/ChipInput/ChipInput.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChipInput.d.ts","sourceRoot":"","sources":["../../../src/components/ChipInput/ChipInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,SAAS,MAAM,YAAY,CAAC;AAOnC,KAAK,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;AAkJvE;;;;;;;;;;;;GAYG;AACH,iBAAwB,SAAS,CAC7B,KAAK,EAAE,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,oDAwIpE;kBAzIuB,SAAS;;QA4I7B,0BAA0B;;QAE1B,kCAAkC;;QAElC,iCAAiC;;QAEjC,iCAAiC;;QAEjC,4EAA4E;;QAE5E,8EAA8E;;QAE9E,kFAAkF;;;;;;;;;;eAxJ9D,SAAS"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useId, useState } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
5
|
import constants from '../../shared/constants';
|
|
@@ -123,6 +123,22 @@ const ErrorContainer = styled.div `
|
|
|
123
123
|
line-height: 14px;
|
|
124
124
|
margin-left: 3px;
|
|
125
125
|
`;
|
|
126
|
+
// Visually hidden but accessible to screen readers
|
|
127
|
+
const VisuallyHidden = styled.ul `
|
|
128
|
+
position: absolute;
|
|
129
|
+
width: 1px;
|
|
130
|
+
height: 1px;
|
|
131
|
+
padding: 0;
|
|
132
|
+
margin: -1px;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
clip: rect(0, 0, 0, 0);
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
border-width: 0;
|
|
137
|
+
|
|
138
|
+
& li {
|
|
139
|
+
list-style: none;
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
126
142
|
/**
|
|
127
143
|
* A chip input component that allows users to add and remove chips (tags) by typing and pressing Enter.
|
|
128
144
|
* @component
|
|
@@ -141,9 +157,21 @@ export default function ChipInput(props) {
|
|
|
141
157
|
const [touched, setTouched] = useState(false);
|
|
142
158
|
const [value, setValue] = useState(props.value);
|
|
143
159
|
const InputRef = React.useRef(null);
|
|
160
|
+
const [announcement, setAnnouncement] = useState('');
|
|
161
|
+
const errorId = useId();
|
|
162
|
+
/**
|
|
163
|
+
* Replace {:label} placeholder in template string
|
|
164
|
+
*/
|
|
165
|
+
const replacePlaceholder = (template, label) => {
|
|
166
|
+
if (!template)
|
|
167
|
+
return undefined;
|
|
168
|
+
return template.replace(/\{:label\}/g, label);
|
|
169
|
+
};
|
|
144
170
|
// Sync internal value with props.value
|
|
145
171
|
useEffect(() => {
|
|
146
|
-
|
|
172
|
+
if (Array.isArray(props.value)) {
|
|
173
|
+
setValue(props.value);
|
|
174
|
+
}
|
|
147
175
|
}, [props.value]);
|
|
148
176
|
/**
|
|
149
177
|
* Update the chip values and notify changes.
|
|
@@ -181,6 +209,7 @@ export default function ChipInput(props) {
|
|
|
181
209
|
const newValue = [...value, text.trim()];
|
|
182
210
|
updateValue(newValue);
|
|
183
211
|
setText('');
|
|
212
|
+
setAnnouncement(replacePlaceholder(props.addedAnnouncementTemplate, text.trim()));
|
|
184
213
|
}
|
|
185
214
|
};
|
|
186
215
|
/**
|
|
@@ -190,6 +219,7 @@ export default function ChipInput(props) {
|
|
|
190
219
|
const removeChip = (chipToRemove) => {
|
|
191
220
|
const newValue = value.filter((chip) => chip !== chipToRemove);
|
|
192
221
|
updateValue(newValue);
|
|
222
|
+
setAnnouncement(replacePlaceholder(props.removedAnnouncementTemplate, chipToRemove));
|
|
193
223
|
};
|
|
194
224
|
/**
|
|
195
225
|
* Moves a chip from one position to another.
|
|
@@ -207,7 +237,7 @@ export default function ChipInput(props) {
|
|
|
207
237
|
updateValue(newItems);
|
|
208
238
|
};
|
|
209
239
|
// Render the component
|
|
210
|
-
return (_jsxs(Label, { text: text, touched: touched, errorText: props.errorText, children: [_jsx("input", Object.assign({}, props, { ref: InputRef,
|
|
240
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Label, { text: text, touched: touched, errorText: props.errorText, children: [_jsx("input", Object.assign({}, props, { ref: InputRef, value: text, onChange: handleChange, onFocus: handleFocus, onKeyUp: handleKeyUp, required: props.required && value.length === 0, "aria-required": props.required, "aria-invalid": !!props.errorText, "aria-describedby": props.errorText ? errorId : undefined })), _jsx("div", { children: (value === null || value === void 0 ? void 0 : value.length) > 0 && (_jsx(DragAndDrop, { orientation: ORIENTATION.HORIZONTAL, onDrop: onDrop, children: value.map((chip) => (_jsx(Chip, { label: chip, onCloseClick: () => removeChip(chip), closeButtonAriaLabel: replacePlaceholder(props.closeButtonAriaLabel, chip) }, chip))) })) }), _jsx("span", { children: props.label }), props.errorText && _jsx(ErrorContainer, { id: errorId, children: props.errorText })] }), _jsx(VisuallyHidden, { "aria-live": "polite", "aria-atomic": "true", children: announcement })] }));
|
|
211
241
|
}
|
|
212
242
|
ChipInput.propTypes = {
|
|
213
243
|
/** Label for the field */
|
|
@@ -218,8 +248,17 @@ ChipInput.propTypes = {
|
|
|
218
248
|
value: PropTypes.arrayOf(PropTypes.string),
|
|
219
249
|
/** Callback when chips change */
|
|
220
250
|
onChange: PropTypes.func,
|
|
251
|
+
/** Aria label for the close button on chip. Defaults to "Remove {label}" */
|
|
252
|
+
closeButtonAriaLabel: PropTypes.string,
|
|
253
|
+
/** Announcement text when a chip is added. Defaults to "{label} was added" */
|
|
254
|
+
addedAnnouncementTemplate: PropTypes.string,
|
|
255
|
+
/** Announcement text when a chip is removed. Defaults to "{label} was removed" */
|
|
256
|
+
removedAnnouncementTemplate: PropTypes.string,
|
|
221
257
|
};
|
|
222
258
|
ChipInput.defaultProps = {
|
|
223
259
|
value: [],
|
|
260
|
+
closeButtonAriaLabel: 'Remove {:label}',
|
|
261
|
+
addedAnnouncementTemplate: '{:label} was added',
|
|
262
|
+
removedAnnouncementTemplate: '{:label} was removed',
|
|
224
263
|
};
|
|
225
264
|
//# sourceMappingURL=ChipInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipInput.js","sourceRoot":"","sources":["../../../src/components/ChipInput/ChipInput.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK1D,oCAAoC;AACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAIxB;;;;;;;;;;4CAU0C,SAAS,CAAC,YAAY;0CACxB,SAAS,CAAC,UAAU;;;;;uCAKvB,SAAS,CAAC,OAAO;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C,IAAI,CAAC,IAAvD,IAAI,CAAuD,CACzE,CAAC,GACQ,CACjB,GACC,EACN,yBAAO,KAAK,CAAC,KAAK,GAAQ,EACzB,KAAK,CAAC,SAAS,IAAI,KAAC,cAAc,cAAE,KAAK,CAAC,SAAS,GAAkB,IAClE,CACX,CAAC;AACN,CAAC;AAED,SAAS,CAAC,SAAS,GAAG;IAClB,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;IAClC,kCAAkC;IAClC,SAAS,EAAE,SAAS,CAAC,MAAM;IAC3B,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;IAC1C,iCAAiC;IACjC,QAAQ,EAAE,SAAS,CAAC,IAAI;CAC3B,CAAC;AAEF,SAAS,CAAC,YAAY,GAAG;IACrB,KAAK,EAAE,EAAE;CACZ,CAAC","sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport constants from '../../shared/constants';\nimport Chip from '../Chip/Chip';\nimport { DragAndDrop, ORIENTATION } from '../DragAndDrop';\n\n// Prop types definition\ntype ChipInputProps = PropTypes.InferProps<typeof ChipInput.propTypes>;\n\n// Label component for the ChipInput\nconst Label = styled.label<{\n text: string;\n touched?: boolean;\n errorText?: string;\n}>`\n display: inline-flex;\n flex-direction: column;\n flex: 1;\n position: relative;\n margin: 10px 5px;\n color: inherit;\n padding: 0 8px;\n width: 250px;\n border-radius: 3px;\n border: 1px solid var(--border-color, ${constants.BORDER_COLOR});\n background-color: var(--background, ${constants.BACKGROUND});\n\n /** Focused */\n &:has(:focus),\n &:has(:active) {\n border-color: var(--primary, ${constants.PRIMARY});\n box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});\n }\n\n &:has(:focus) > span,\n &:has(:active) > span {\n color: var(--primary, ${constants.PRIMARY});\n }\n\n /** Disabled */\n &:has(:disabled) {\n border-color: var(--disabled-border, ${constants.DISABLED_BORDER});\n background-color: var(--disabled-background, ${constants.DISABLED_BACKGROUND});\n }\n\n &:has(:disabled) > span {\n color: #777;\n }\n\n /** Invalid */\n &:has(:focus:invalid) {\n border-color: var(--error, ${constants.ERROR});\n box-shadow: 0 0 0 4px var(--error-light, ${constants.ERROR_LIGHT});\n }\n\n ${(props) =>\n props.touched\n ? `\n &:has(:invalid) {\n border-color: var(--error, ${constants.ERROR});\n }\n \n &:has(:invalid) > span {\n color: var(--error, ${constants.ERROR});\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: var(--error, ${constants.ERROR});\n\n & > span {\n color: var(--error, ${constants.ERROR});\n }\n `\n : ''}\n\n /** Required */\n &:has(:required) > span:after {\n content: '*';\n margin-left: 2px;\n color: var(--error, ${constants.ERROR});\n }\n\n & > input {\n border: none;\n outline: none;\n width: 100%;\n line-height: 30px;\n min-height: 30px;\n }\n\n /** Label Animation */\n & > span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n &:has(:focus) > span,\n &:has(:placeholder-shown) > span {\n top: -8px;\n background: var(--background, ${constants.BACKGROUND});\n font-size: 12px;\n line-height: 14px;\n }\n\n ${(props) =>\n props.text !== ''\n ? `\n & > span {\n top: -8px;\n background: var(--background, ${constants.BACKGROUND});\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n`;\n\n// Error message container\nconst ErrorContainer = styled.div`\n color: var(--error, ${constants.ERROR});\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\n/**\n * A chip input component that allows users to add and remove chips (tags) by typing and pressing Enter.\n * @component\n * @example\n * ```tsx\n * <ChipInput\n * value={['tag1', 'tag2']}\n * onChange={(newTags) => console.log(newTags)}\n * label=\"Add tags\"\n * errorText=\"At least one tag is required\"\n * />\n * ```\n */\nexport default function ChipInput(\n props: ChipInputProps & React.AllHTMLAttributes<HTMLInputElement>,\n) {\n const [text, setText] = useState('');\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState<string[]>(props.value);\n const InputRef = React.useRef<HTMLInputElement>(null);\n\n // Sync internal value with props.value\n useEffect(() => {\n setValue(props.value);\n }, [props.value]);\n\n /**\n * Update the chip values and notify changes.\n * @param newValue The new array of chip values\n */\n const updateValue = (newValue: string[]) => {\n const deduped = Array.from(new Set(newValue));\n setValue(deduped);\n props.onChange?.(deduped);\n };\n\n /**\n * Marks the input as touched on focus.\n * @param e React focus event\n */\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n /**\n * Change handler for the input field.\n * @param e React change event\n */\n const handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n setText(e.target.value);\n };\n\n /**\n * Adds a new chip on Enter key press.\n * @param e React keyboard event\n */\n const handleKeyUp: React.KeyboardEventHandler<HTMLInputElement> = (e) => {\n if (e.key === 'Enter' && text.trim() !== '') {\n const newValue = [...value, text.trim()];\n updateValue(newValue);\n setText('');\n }\n };\n\n /**\n * Removes a chip from the list.\n * @param chipToRemove The chip value to remove\n */\n const removeChip = (chipToRemove: string) => {\n const newValue = value.filter((chip) => chip !== chipToRemove);\n updateValue(newValue);\n };\n\n /**\n * Moves a chip from one position to another.\n * @param start The starting index of the item to move\n * @param end The ending index where the item should be placed\n */\n const onDrop = (start: number, end: number) => {\n // Clone existing elements\n const newItems = [...value];\n // Remove the element to be moved\n const item = newItems.splice(start, 1);\n // Add it back at the required position\n newItems.splice(end, 0, item[0]);\n // Update\n updateValue(newItems);\n };\n\n // Render the component\n return (\n <Label text={text} touched={touched} errorText={props.errorText}>\n <input\n {...props}\n ref={InputRef}\n type=\"text\"\n value={text}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n required={props.required && value.length === 0}\n />\n <div>\n {value?.length > 0 && (\n <DragAndDrop orientation={ORIENTATION.HORIZONTAL} onDrop={onDrop}>\n {value.map((chip) => (\n <Chip key={chip} label={chip} onCloseClick={() => removeChip(chip)} />\n ))}\n </DragAndDrop>\n )}\n </div>\n <span>{props.label}</span>\n {props.errorText && <ErrorContainer>{props.errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nChipInput.propTypes = {\n /** Label for the field */\n label: PropTypes.string.isRequired,\n /** Error message for the field */\n errorText: PropTypes.string,\n /** Values to display as chips */\n value: PropTypes.arrayOf(PropTypes.string),\n /** Callback when chips change */\n onChange: PropTypes.func,\n};\n\nChipInput.defaultProps = {\n value: [],\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ChipInput.js","sourceRoot":"","sources":["../../../src/components/ChipInput/ChipInput.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK1D,oCAAoC;AACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAIxB;;;;;;;;;;4CAU0C,SAAS,CAAC,YAAY;0CACxB,SAAS,CAAC,UAAU;;;;;uCAKvB,SAAS,CAAC,OAAO;qDACH,SAAS,CAAC,aAAa;;;;;gCAK5C,SAAS,CAAC,OAAO;;;;;+CAKF,SAAS,CAAC,eAAe;uDACjB,SAAS,CAAC,mBAAmB;;;;;;;;;qCAS/C,SAAS,CAAC,KAAK;mDACD,SAAS,CAAC,WAAW;;;MAGlE,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,OAAO;IACT,CAAC,CAAC;;yCAE2B,SAAS,CAAC,KAAK;;;;kCAItB,SAAS,CAAC,KAAK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AAE,SAAS,CAAC,MAAM;IAC3C,kFAAkF;IAClF,2BAA2B,EAAE,SAAS,CAAC,MAAM;CAChD,CAAC;AAEF,SAAS,CAAC,YAAY,GAAG;IACrB,KAAK,EAAE,EAAE;IACT,oBAAoB,EAAE,iBAAiB;IACvC,yBAAyB,EAAE,oBAAoB;IAC/C,2BAA2B,EAAE,sBAAsB;CACtD,CAAC","sourcesContent":["import React, { useEffect, useId, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport constants from '../../shared/constants';\nimport Chip from '../Chip/Chip';\nimport { DragAndDrop, ORIENTATION } from '../DragAndDrop';\n\n// Prop types definition\ntype ChipInputProps = PropTypes.InferProps<typeof ChipInput.propTypes>;\n\n// Label component for the ChipInput\nconst Label = styled.label<{\n text: string;\n touched?: boolean;\n errorText?: string;\n}>`\n display: inline-flex;\n flex-direction: column;\n flex: 1;\n position: relative;\n margin: 10px 5px;\n color: inherit;\n padding: 0 8px;\n width: 250px;\n border-radius: 3px;\n border: 1px solid var(--border-color, ${constants.BORDER_COLOR});\n background-color: var(--background, ${constants.BACKGROUND});\n\n /** Focused */\n &:has(:focus),\n &:has(:active) {\n border-color: var(--primary, ${constants.PRIMARY});\n box-shadow: 0 0 0 4px var(--primary-light, ${constants.PRIMARY_LIGHT});\n }\n\n &:has(:focus) > span,\n &:has(:active) > span {\n color: var(--primary, ${constants.PRIMARY});\n }\n\n /** Disabled */\n &:has(:disabled) {\n border-color: var(--disabled-border, ${constants.DISABLED_BORDER});\n background-color: var(--disabled-background, ${constants.DISABLED_BACKGROUND});\n }\n\n &:has(:disabled) > span {\n color: #777;\n }\n\n /** Invalid */\n &:has(:focus:invalid) {\n border-color: var(--error, ${constants.ERROR});\n box-shadow: 0 0 0 4px var(--error-light, ${constants.ERROR_LIGHT});\n }\n\n ${(props) =>\n props.touched\n ? `\n &:has(:invalid) {\n border-color: var(--error, ${constants.ERROR});\n }\n \n &:has(:invalid) > span {\n color: var(--error, ${constants.ERROR});\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: var(--error, ${constants.ERROR});\n\n & > span {\n color: var(--error, ${constants.ERROR});\n }\n `\n : ''}\n\n /** Required */\n &:has(:required) > span:after {\n content: '*';\n margin-left: 2px;\n color: var(--error, ${constants.ERROR});\n }\n\n & > input {\n border: none;\n outline: none;\n width: 100%;\n line-height: 30px;\n min-height: 30px;\n }\n\n /** Label Animation */\n & > span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n &:has(:focus) > span,\n &:has(:placeholder-shown) > span {\n top: -8px;\n background: var(--background, ${constants.BACKGROUND});\n font-size: 12px;\n line-height: 14px;\n }\n\n ${(props) =>\n props.text !== ''\n ? `\n & > span {\n top: -8px;\n background: var(--background, ${constants.BACKGROUND});\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n`;\n\n// Error message container\nconst ErrorContainer = styled.div`\n color: var(--error, ${constants.ERROR});\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\n// Visually hidden but accessible to screen readers\nconst VisuallyHidden = styled.ul`\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n\n & li {\n list-style: none;\n }\n`;\n\n/**\n * A chip input component that allows users to add and remove chips (tags) by typing and pressing Enter.\n * @component\n * @example\n * ```tsx\n * <ChipInput\n * value={['tag1', 'tag2']}\n * onChange={(newTags) => console.log(newTags)}\n * label=\"Add tags\"\n * errorText=\"At least one tag is required\"\n * />\n * ```\n */\nexport default function ChipInput(\n props: ChipInputProps & React.AllHTMLAttributes<HTMLInputElement>,\n) {\n const [text, setText] = useState('');\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState<string[]>(props.value);\n const InputRef = React.useRef<HTMLInputElement>(null);\n const [announcement, setAnnouncement] = useState('');\n const errorId = useId();\n\n /**\n * Replace {:label} placeholder in template string\n */\n const replacePlaceholder = (\n template: string | undefined,\n label: string,\n ): string | undefined => {\n if (!template) return undefined;\n return template.replace(/\\{:label\\}/g, label);\n };\n\n // Sync internal value with props.value\n useEffect(() => {\n if (Array.isArray(props.value)) {\n setValue(props.value);\n }\n }, [props.value]);\n\n /**\n * Update the chip values and notify changes.\n * @param newValue The new array of chip values\n */\n const updateValue = (newValue: string[]) => {\n const deduped = Array.from(new Set(newValue));\n setValue(deduped);\n props.onChange?.(deduped);\n };\n\n /**\n * Marks the input as touched on focus.\n * @param e React focus event\n */\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n /**\n * Change handler for the input field.\n * @param e React change event\n */\n const handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n setText(e.target.value);\n };\n\n /**\n * Adds a new chip on Enter key press.\n * @param e React keyboard event\n */\n const handleKeyUp: React.KeyboardEventHandler<HTMLInputElement> = (e) => {\n if (e.key === 'Enter' && text.trim() !== '') {\n const newValue = [...value, text.trim()];\n updateValue(newValue);\n setText('');\n setAnnouncement(replacePlaceholder(props.addedAnnouncementTemplate, text.trim())!);\n }\n };\n\n /**\n * Removes a chip from the list.\n * @param chipToRemove The chip value to remove\n */\n const removeChip = (chipToRemove: string) => {\n const newValue = value.filter((chip) => chip !== chipToRemove);\n updateValue(newValue);\n setAnnouncement(replacePlaceholder(props.removedAnnouncementTemplate, chipToRemove)!);\n };\n\n /**\n * Moves a chip from one position to another.\n * @param start The starting index of the item to move\n * @param end The ending index where the item should be placed\n */\n const onDrop = (start: number, end: number) => {\n // Clone existing elements\n const newItems = [...value];\n // Remove the element to be moved\n const item = newItems.splice(start, 1);\n // Add it back at the required position\n newItems.splice(end, 0, item[0]);\n // Update\n updateValue(newItems);\n };\n\n // Render the component\n return (\n <>\n <Label text={text} touched={touched} errorText={props.errorText}>\n <input\n {...props}\n ref={InputRef}\n value={text}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n required={props.required && value.length === 0}\n aria-required={props.required}\n aria-invalid={!!props.errorText}\n aria-describedby={props.errorText ? errorId : undefined}\n />\n <div>\n {value?.length > 0 && (\n <DragAndDrop orientation={ORIENTATION.HORIZONTAL} onDrop={onDrop}>\n {value.map((chip) => (\n <Chip\n key={chip}\n label={chip}\n onCloseClick={() => removeChip(chip)}\n closeButtonAriaLabel={replacePlaceholder(\n props.closeButtonAriaLabel,\n chip,\n )}\n />\n ))}\n </DragAndDrop>\n )}\n </div>\n <span>{props.label}</span>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </Label>\n <VisuallyHidden aria-live=\"polite\" aria-atomic=\"true\">\n {announcement}\n </VisuallyHidden>\n </>\n );\n}\n\nChipInput.propTypes = {\n /** Label for the field */\n label: PropTypes.string.isRequired,\n /** Error message for the field */\n errorText: PropTypes.string,\n /** Values to display as chips */\n value: PropTypes.arrayOf(PropTypes.string),\n /** Callback when chips change */\n onChange: PropTypes.func,\n /** Aria label for the close button on chip. Defaults to \"Remove {label}\" */\n closeButtonAriaLabel: PropTypes.string,\n /** Announcement text when a chip is added. Defaults to \"{label} was added\" */\n addedAnnouncementTemplate: PropTypes.string,\n /** Announcement text when a chip is removed. Defaults to \"{label} was removed\" */\n removedAnnouncementTemplate: PropTypes.string,\n};\n\nChipInput.defaultProps = {\n value: [],\n closeButtonAriaLabel: 'Remove {:label}',\n addedAnnouncementTemplate: '{:label} was added',\n removedAnnouncementTemplate: '{:label} was removed',\n};\n"]}
|
|
@@ -16,7 +16,7 @@ class AlertDialog extends React.Component {
|
|
|
16
16
|
this.close = () => this.dialog.current.close();
|
|
17
17
|
}
|
|
18
18
|
render() {
|
|
19
|
-
return (_jsxs(Dialog, Object.assign({}, this.props.dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick:
|
|
19
|
+
return (_jsxs(Dialog, Object.assign({}, this.props.dialogProps, { ref: this.dialog, closeOnEsc: false, closeOnOverlayClick: false, children: [this.props.header && _jsx(DialogHeader, { children: this.props.header }), _jsx(DialogBody, { children: this.props.body }), _jsx(DialogFooter, { children: _jsx(Button, { onClick: this.close, children: this.props.buttonText }) })] })));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
AlertDialog.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/AlertDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,MAAM,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI1E,MAAqB,WAAY,SAAQ,KAAK,CAAC,SAAsB;IAArE;;QACY,WAAM,GAAG,SAAS,EAAU,CAAC;QAiB9B,SAAI,GAAG,GAAG,EAAE;YACf,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QAEM,UAAK,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAkBtD,CAAC;IAhBG,MAAM;QACF,OAAO,CACH,MAAC,MAAM,oBACC,IAAI,CAAC,KAAK,CAAC,WAAW,IAC1B,GAAG,EAAE,IAAI,CAAC,MAAM,EAChB,UAAU,EAAE,KAAK,EACjB,mBAAmB,EAAE,
|
|
1
|
+
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CAAC;IACN,CAAC;;AAvCM,qBAAS,GAAG;IACf,oCAAoC;IACpC,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,4BAA4B;IAC5B,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,UAAU;IAC9B,gDAAgD;IAChD,UAAU,EAAE,SAAS,CAAC,MAAM;IAC5B,2BAA2B;IAC3B,WAAW,EAAE,SAAS,CAAC,MAAM;CAChC,AATe,CASd;AAEK,wBAAY,GAAG;IAClB,UAAU,EAAE,IAAI;CACnB,AAFkB,CAEjB;eAhBe,WAAW","sourcesContent":["import React, { createRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { Button } from '../Button';\nimport Dialog, { DialogBody, DialogFooter, DialogHeader } from './Dialog';\n\ntype AlertOption = PropTypes.InferProps<typeof AlertDialog.propTypes>;\n\nexport default class AlertDialog extends React.Component<AlertOption> {\n private dialog = createRef<Dialog>();\n\n static propTypes = {\n /** Shown as header of the dialog */\n header: PropTypes.string,\n /** Rendered in the body. */\n body: PropTypes.any.isRequired,\n /** Accept button text, default value is `OK` */\n buttonText: PropTypes.string,\n /** props for the dialog */\n dialogProps: PropTypes.object,\n };\n\n static defaultProps = {\n buttonText: 'OK',\n };\n\n public show = () => {\n return new Promise((resolve) => {\n const onClose = () => resolve(null);\n this.dialog.current.open(onClose);\n });\n };\n\n private close = () => this.dialog.current.close();\n\n render() {\n return (\n <Dialog\n {...this.props.dialogProps}\n ref={this.dialog}\n closeOnEsc={false}\n closeOnOverlayClick={false}\n >\n {this.props.header && <DialogHeader>{this.props.header}</DialogHeader>}\n <DialogBody>{this.props.body}</DialogBody>\n <DialogFooter>\n <Button onClick={this.close}>{this.props.buttonText}</Button>\n </DialogFooter>\n </Dialog>\n );\n }\n}\n"]}
|
|
@@ -7,7 +7,12 @@ export declare const DialogContainer: import("@emotion/styled").StyledComponent<
|
|
|
7
7
|
theme?: import("@emotion/react").Theme;
|
|
8
8
|
}, {}, {}>;
|
|
9
9
|
export { Header as DialogHeader, Body as DialogBody, Footer as DialogFooter, } from '../../shared/styles';
|
|
10
|
-
|
|
10
|
+
interface DialogOptions {
|
|
11
|
+
/** Flag to close dialog on `esc` click. Default value is true. */
|
|
12
|
+
closeOnEsc?: boolean;
|
|
13
|
+
/** Close layer overlay is clicked. Default value is true. */
|
|
14
|
+
closeOnOverlayClick?: boolean;
|
|
15
|
+
}
|
|
11
16
|
interface DialogState {
|
|
12
17
|
show: boolean;
|
|
13
18
|
LayerComponent?: () => React.ReactPortal | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAKnC,eAAO,MAAM,eAAe;;SAqBL,MACrB,WAAW;;;UANZ,CAAC;AAEF,OAAO,EACH,MAAM,IAAI,YAAY,EACtB,IAAI,IAAI,UAAU,EAClB,MAAM,IAAI,YAAY,GACzB,MAAM,qBAAqB,CAAC;AAE7B,
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AAKnC,eAAO,MAAM,eAAe;;SAqBL,MACrB,WAAW;;;UANZ,CAAC;AAEF,OAAO,EACH,MAAM,IAAI,YAAY,EACtB,IAAI,IAAI,UAAU,EAClB,MAAM,IAAI,YAAY,GACzB,MAAM,qBAAqB,CAAC;AAE7B,UAAU,aAAa;IACnB,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,UAAU,WAAW;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;CACnD;AAED,cAAM,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC;IACrF,MAAM,CAAC,SAAS;QACZ,kEAAkE;;QAElE,6DAA6D;;MAE/D;IAEF,MAAM,CAAC,YAAY;;;MAGjB;IAEF,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,SAAS,CAA2B;IAE5C,KAAK,EAAE,WAAW,CAGhB;IAEF,qBAAqB,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW;IAI/D,IAAI,mBAAoB,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,UAwBpD;IAEK,KAAK,UAAW,OAAO,UAE5B;IAEF,OAAO,CAAC,aAAa,CAMnB;IAEF,MAAM;CAST;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,YAAY,EAAE,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;;;;;;;;;;;;CAgB1C,CAAC;AAEF,OAAO,EACH,MAAM,IAAI,YAAY,EACtB,IAAI,IAAI,UAAU,EAClB,MAAM,IAAI,YAAY,GACzB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,MA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Ac,EAAE,SAAS;aAC5B,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC;QACnC,CAAC,CAAC;QAEK,UAAK,GAAG,CAAC,IAAc,EAAE,EAAE;;YAC9B,MAAA,IAAI,CAAC,WAAW,qDAAG,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC;QAEM,kBAAa,GAAG,CAAC,IAAc,EAAE,EAAE;;YACvC,IAAI,CAAC,QAAQ,CAAC;gBACV,IAAI,EAAE,KAAK;gBACX,cAAc,EAAE,SAAS;aAC5B,CAAC,CAAC;YACH,MAAA,IAAI,CAAC,SAAS,qDAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC;IAWN,CAAC;IAnDG,qBAAqB,CAAC,SAAwB,EAAE,SAAsB;QAClE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC;IAC9C,CAAC;IAwCD,MAAM;QACF,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEtC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAc,EAAE,CAAC;YACpC,OAAO,KAAC,cAAc,KAAG,CAAC;QAC9B,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;;AAtEM,gBAAS,GAAG;IACf,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,6DAA6D;IAC7D,mBAAmB,EAAE,SAAS,CAAC,IAAI;CACtC,AALe,CAKd;AAEK,mBAAY,GAAG;IAClB,UAAU,EAAE,IAAI;IAChB,mBAAmB,EAAE,IAAI;CAC5B,AAHkB,CAGjB;AA+DN,eAAe,MAAM,CAAC","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport LayerManager, { LAYER_POSITION } from '../../shared/LayerManager';\nimport { Card } from '../Card';\n\nexport const DialogContainer = styled(Card)`\n max-width: 768px;\n max-height: 80vh;\n transform: scale(0);\n opacity: 0;\n transition: all 0.3s ease;\n\n .nf-layer-enter & {\n opacity: 1;\n transform: scale(1);\n }\n\n .nf-layer-exit & {\n opacity: 0;\n transform: scale(0);\n }\n`;\n\nexport {\n Header as DialogHeader,\n Body as DialogBody,\n Footer as DialogFooter,\n} from '../../shared/styles';\n\ninterface DialogOptions {\n /** Flag to close dialog on `esc` click. Default value is true. */\n closeOnEsc?: boolean;\n /** Close layer overlay is clicked. Default value is true. */\n closeOnOverlayClick?: boolean;\n}\n\ninterface DialogState {\n show: boolean;\n LayerComponent?: () => React.ReactPortal | null;\n}\n\nclass Dialog extends React.Component<React.PropsWithChildren<DialogOptions>, DialogState> {\n static propTypes = {\n /** Flag to close dialog on `esc` click. Default value is true. */\n closeOnEsc: PropTypes.bool,\n /** Close layer overlay is clicked. Default value is true. */\n closeOnOverlayClick: PropTypes.bool,\n };\n\n static defaultProps = {\n closeOnEsc: true,\n closeOnOverlayClick: true,\n };\n\n private closeDialog: (resp?: unknown) => void;\n private onCloseFn: (resp?: unknown) => void;\n\n state: DialogState = {\n show: false,\n LayerComponent: undefined,\n };\n\n shouldComponentUpdate(nextProps: DialogOptions, nextState: DialogState) {\n return this.state.show !== nextState.show;\n }\n\n public open = (closeCallback?: (resp: unknown) => void) => {\n const { closeOnEsc, closeOnOverlayClick, children, ...rest } = this.props;\n\n const [Component, closeFn] = LayerManager.renderLayer({\n exitDelay: 300,\n overlay: true,\n closeOnEsc,\n closeCallback: this.closeCallback,\n closeOnOverlayClick,\n position: LAYER_POSITION.DIALOG,\n component: (\n <DialogContainer {...rest} onClick={(e) => e.stopPropagation()} elevated>\n {children}\n </DialogContainer>\n ),\n });\n\n this.closeDialog = closeFn;\n\n this.setState({\n show: true,\n LayerComponent: Component,\n });\n this.onCloseFn = closeCallback;\n };\n\n public close = (resp?: unknown) => {\n this.closeDialog?.(resp);\n };\n\n private closeCallback = (resp?: unknown) => {\n this.setState({\n show: false,\n LayerComponent: undefined,\n });\n this.onCloseFn?.(resp);\n };\n\n render() {\n const { LayerComponent } = this.state;\n\n if (this.state.show && LayerComponent) {\n return <LayerComponent />;\n } else {\n return null;\n }\n }\n}\n\nexport default Dialog;\n"]}
|