no-frills-ui 0.0.14-rc.0 → 0.0.14-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.js +389 -195
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.js +10 -1
- package/lib-esm/components/Accordion/Accordion.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.js +9 -9
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Card/Card.js +2 -2
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.js +2 -2
- package/lib-esm/components/ChipInput/ChipInput.d.ts +1 -1
- package/lib-esm/components/ChipInput/ChipInput.js +14 -6
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +2 -2
- package/lib-esm/components/DragAndDrop/DragItem.js +2 -2
- package/lib-esm/components/Drawer/Drawer.d.ts +1 -1
- package/lib-esm/components/Drawer/Drawer.js +2 -3
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Groups/Group.js +3 -3
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +2 -0
- package/lib-esm/components/Input/Checkbox.js +54 -23
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +2 -0
- package/lib-esm/components/Input/Dropdown.js +123 -59
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.js +17 -8
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts +2 -0
- package/lib-esm/components/Input/Radio.js +22 -10
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts +2 -0
- package/lib-esm/components/Input/RadioButton.js +21 -9
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.js +21 -11
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.js +17 -8
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts +2 -0
- package/lib-esm/components/Input/Toggle.js +45 -15
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Input/index.d.ts +1 -0
- package/lib-esm/components/Menu/MenuItem.d.ts +1 -1
- package/lib-esm/components/Menu/MenuItem.js +1 -1
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +1 -1
- package/lib-esm/components/Modal/Modal.js +1 -2
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +1 -1
- package/lib-esm/components/Popover/Popover.js +3 -3
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.js +14 -5
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/shared/LayerManager.js +3 -15
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +5 -1
- package/lib-esm/shared/styles.js +11 -7
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { jsx, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { useState, Children, isValidElement, cloneElement } from 'react';
|
|
2
|
+
import { useState, useRef, useEffect, Children, isValidElement, cloneElement } from 'react';
|
|
3
3
|
|
|
4
4
|
function Accordion(props) {
|
|
5
5
|
const [active, setActive] = useState(props.active);
|
|
6
|
+
const prevActive = useRef(props.active);
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
if (props.active !== undefined && props.active !== prevActive.current) {
|
|
9
|
+
setActive(props.active);
|
|
10
|
+
prevActive.current = props.active;
|
|
11
|
+
}
|
|
12
|
+
}, [
|
|
13
|
+
props.active
|
|
14
|
+
]);
|
|
6
15
|
const onStepClick = (index, disabled)=>()=>{
|
|
7
16
|
if (disabled) {
|
|
8
17
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../../src/components/Accordion/Accordion.tsx"],"sourcesContent":["import {\n useState,\n Children,\n cloneElement,\n PropsWithChildren,\n isValidElement,\n useEffect,\n useRef,\n} from 'react';\n\nfunction Accordion(props: PropsWithChildren<AccordionProps>) {\n const [active, setActive] = useState(props.active);\n const prevActive = useRef(props.active);\n\n useEffect(() => {\n if (props.active !== undefined && props.active !== prevActive.current) {\n setActive(props.active);\n prevActive.current = props.active;\n }\n }, [props.active]);\n\n const onStepClick = (index: number, disabled: boolean) => () => {\n if (disabled) {\n return;\n }\n\n const newIndex = index !== active ? index : -1;\n if (props.onStepClick) {\n props.onStepClick(newIndex);\n } else {\n setActive(newIndex);\n }\n };\n\n return (\n <>\n {Children.map(props.children, (child, index) => {\n if (!isValidElement(child)) {\n return child;\n }\n const reactElement = child as React.ReactElement<{\n disabled?: boolean;\n open?: boolean;\n onStepClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n }>;\n return cloneElement(reactElement, {\n open: active === index,\n onStepClick: onStepClick(index, reactElement.props.disabled || false),\n });\n })}\n </>\n );\n}\n\ntype AccordionProps = {\n /**\n * Currently opened step\n * @default -1\n */\n active?: number;\n /** Handler for click event on a step */\n onStepClick?: (index: number) => void;\n};\n\nexport default Accordion;\n"],"names":["Accordion","props","active","setActive","useState","prevActive","useRef","useEffect","undefined","current","onStepClick","index","disabled","newIndex","_jsx","_Fragment","Children","map","children","child","isValidElement","reactElement","cloneElement","open"],"mappings":";;;AAUA,SAASA,UAAUC,KAAwC,EAAA;AACvD,IAAA,MAAM,CAACC,MAAAA,EAAQC,SAAAA,CAAU,G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,CAAapB,KAAK,CAACW,QAAQ,IAAI,KAAA;AACnE,aAAA,CAAA;AACJ,QAAA,CAAA;;AAGZ;;;;"}
|
|
@@ -9,35 +9,35 @@ import ExpandMore from '../../icons/ExpandMore.js';
|
|
|
9
9
|
import Card from '../Card/Card.js';
|
|
10
10
|
|
|
11
11
|
const Step$1 = /*#__PURE__*/ styled(Card, {
|
|
12
|
-
target: "
|
|
12
|
+
target: "e1l2mhfb0",
|
|
13
13
|
label: "Step"
|
|
14
14
|
})("transition:all 0.6s ease;overflow:visible;", (props)=>props.open && `margin: 20px 5px;`);
|
|
15
15
|
const StepHeader = /*#__PURE__*/ styled("button", {
|
|
16
|
-
target: "
|
|
16
|
+
target: "e1l2mhfb1",
|
|
17
17
|
label: "StepHeader"
|
|
18
|
-
})("padding:20px 15px;display:flex;justify-content:space-between;background:none;border:none;border-radius:10px;width:100%;font-size:inherit;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:focus-visible{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}& input{appearance:none;margin:0;}", (props)=>props.open && `border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};`, " ", (props)=>props.disabled && `color: ${getThemeValue(THEME_NAME.DISABLED)};`);
|
|
18
|
+
})("padding:20px 15px;display:flex;justify-content:space-between;background:none;border:none;border-radius:10px;width:100%;font-size:inherit;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:focus-visible{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}& input{appearance:none;margin:0;}", (props)=>props.open && `border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};`, " ", (props)=>props.open && `border-radius: 10px 10px 0 0;`, " ", (props)=>props.disabled && `color: ${getThemeValue(THEME_NAME.DISABLED)};`);
|
|
19
19
|
const HeaderContainer = /*#__PURE__*/ styled("div", {
|
|
20
|
-
target: "
|
|
20
|
+
target: "e1l2mhfb2",
|
|
21
21
|
label: "HeaderContainer"
|
|
22
22
|
})("display:flex;align-items:center;min-width:40px;& svg{vertical-align:top;margin-right:10px;fill:", (props)=>props.open ? getThemeValue(THEME_NAME.PRIMARY) : props.completed ? getThemeValue(THEME_NAME.SUCCESS) : getThemeValue(THEME_NAME.LIGHT_GREY), ";transform:", (props)=>props.open ? 'scale(0.8)' : 'scale(0.6)', ";transition:all 0.3s ease;min-width:24px;}");
|
|
23
23
|
const ExpandContainer = /*#__PURE__*/ styled("div", {
|
|
24
|
-
target: "
|
|
24
|
+
target: "e1l2mhfb3",
|
|
25
25
|
label: "ExpandContainer"
|
|
26
26
|
})("display:flex;align-items:center;& svg{vertical-align:top;margin-right:10px;transition:all 0.6s ease;fill:currentColor;}", (props)=>props.open ? `& svg { transform: rotate(180deg); }` : '');
|
|
27
27
|
const StepBody = /*#__PURE__*/ styled("div", {
|
|
28
|
-
target: "
|
|
28
|
+
target: "e1l2mhfb4",
|
|
29
29
|
label: "StepBody"
|
|
30
30
|
})("transition:all 0.6s ease;overflow:hidden;height:", (props)=>props.height || 0, "px;");
|
|
31
31
|
const AccordionBadge = /*#__PURE__*/ styled(Badge, {
|
|
32
|
-
target: "
|
|
32
|
+
target: "e1l2mhfb5",
|
|
33
33
|
label: "AccordionBadge"
|
|
34
34
|
})("margin-right:15px;");
|
|
35
35
|
const AccordionStepBody = /*#__PURE__*/ styled("div", {
|
|
36
|
-
target: "
|
|
36
|
+
target: "e1l2mhfb6",
|
|
37
37
|
label: "AccordionStepBody"
|
|
38
38
|
})("padding:20px 15px;");
|
|
39
39
|
const AccordionStepFooter = /*#__PURE__*/ styled("div", {
|
|
40
|
-
target: "
|
|
40
|
+
target: "e1l2mhfb7",
|
|
41
41
|
label: "AccordionStepFooter"
|
|
42
42
|
})("display:flex;justify-content:flex-end;padding:10px 15px;border-top:1px solid ", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";");
|
|
43
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionStep.js","sources":["../../../src/components/Accordion/AccordionStep.tsx"],"sourcesContent":["import React, { useState, useId, useRef, useEffect } from 'react';\nimport styled from '@emotion/styled';\nimport { FiberManualRecord, ExpandMore } from '../../icons';\nimport { THEME_NAME, getThemeValue } from '../../shared/constants';\nimport { Ellipsis } from '../../shared/styles';\nimport { Badge, BADGE_TYPE } from '../Badge';\nimport { Card } from '../Card';\n\nconst Step = styled(Card)<{ open?: boolean; completed?: boolean }>`\n transition: all 0.6s ease;\n overflow: visible;\n\n ${(props) => props.open && `margin: 20px 5px;`}\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 color: ${getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};\n\n &:focus-visible {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n & input {\n appearance: none;\n margin: 0;\n }\n\n ${(props) =>\n props.open && `border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};`}\n\n ${(props) => props.disabled && `color: ${getThemeValue(THEME_NAME.DISABLED)};`}\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 ? getThemeValue(THEME_NAME.PRIMARY)\n : props.completed\n ? getThemeValue(THEME_NAME.SUCCESS)\n : getThemeValue(THEME_NAME.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) => (props.open ? `& svg { transform: rotate(180deg); }` : '')}\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\nconst AccordionBadge = styled(Badge)`\n margin-right: 15px;\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 ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n`;\n\n/** Props for `AccordionStep` component */\ninterface AccordionStepProps {\n /**\n * If the step has been marked as completed\n * @default false\n */\n completed?: boolean;\n /** If the step is disabled\n * @default false\n */\n disabled?: boolean;\n /** Header content for the step */\n header: React.ReactNode;\n /** Error text to display as a badge in the header */\n errorText?: React.ReactNode;\n /** If the step is expanded */\n open?: boolean;\n /** Click handler for the step header */\n onStepClick?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\n/**\n * AccordionStep Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLDivElement\n */\nfunction AccordionStepComponent(\n props: React.PropsWithChildren<AccordionStepProps> & React.HTMLAttributes<HTMLDivElement>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const [height, setHeight] = useState(0);\n const {\n open,\n disabled = false,\n header,\n errorText,\n completed = false,\n onStepClick,\n children,\n ...restProps\n } = props;\n\n // Generate unique IDs for ARIA relationships\n const headerId = useId();\n const regionId = useId();\n\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n // Measure content height when `open` or children change.\n useEffect(() => {\n const el = contentRef.current;\n setHeight(el?.scrollHeight || 0);\n }, [open, children]);\n\n return (\n <Step {...restProps} ref={ref} open={open} elevated={open} completed={completed}>\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 <AccordionBadge inline type={BADGE_TYPE.DANGER}>\n {errorText}\n </AccordionBadge>\n )}\n <ExpandMore aria-hidden=\"true\" />\n </ExpandContainer>\n </StepHeader>\n <StepBody\n ref={contentRef}\n height={open ? height : 0}\n role=\"region\"\n id={regionId}\n aria-labelledby={headerId}\n aria-hidden={open ? 'false' : 'true'}\n >\n {open && children}\n </StepBody>\n </Step>\n );\n}\n\nconst AccordionStep = React.forwardRef<\n HTMLDivElement,\n React.PropsWithChildren<AccordionStepProps> & React.HTMLAttributes<HTMLDivElement>\n>(AccordionStepComponent);\n\nexport default AccordionStep;\n"],"names":["Step","styled","Card","props","open","StepHeader","getThemeValue","THEME_NAME","TEXT_COLOR_DARK","PRIMARY_LIGHT","BORDER_LIGHT_COLOR","disabled","DISABLED","HeaderContainer","PRIMARY","completed","SUCCESS","LIGHT_GREY","ExpandContainer","StepBody","height","AccordionBadge","Badge","AccordionStepBody","AccordionStepFooter","AccordionStepComponent","ref","setHeight","useState","header","errorText","onStepClick","children","restProps","headerId","useId","regionId","contentRef","useRef","useEffect","el","current","scrollHeight","_jsxs","elevated","onClick","aria-expanded","aria-controls","id","_jsx","FiberManualRecord","aria-hidden","Ellipsis","inline","type","BADGE_TYPE","DANGER","ExpandMore","role","aria-labelledby","AccordionStep","React","forwardRef"],"mappings":";;;;;;;;;;AAQA,MAAMA,uBAAOC,MAAAA,CAAOC,IAAAA,EAAAA;;;AAId,CAAA,CAAA,CAAA,4CAAA,EAAA,CAACC,QAAUA,KAAAA,CAAMC,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAA;AAGlD,MAAMC,UAAAA,iBAAaJ,MAAAA,CAAAA,QAAAA,EAAAA;;;
|
|
1
|
+
{"version":3,"file":"AccordionStep.js","sources":["../../../src/components/Accordion/AccordionStep.tsx"],"sourcesContent":["import React, { useState, useId, useRef, useEffect } from 'react';\nimport styled from '@emotion/styled';\nimport { FiberManualRecord, ExpandMore } from '../../icons';\nimport { THEME_NAME, getThemeValue } from '../../shared/constants';\nimport { Ellipsis } from '../../shared/styles';\nimport { Badge, BADGE_TYPE } from '../Badge';\nimport { Card } from '../Card';\n\nconst Step = styled(Card)<{ open?: boolean; completed?: boolean }>`\n transition: all 0.6s ease;\n overflow: visible;\n\n ${(props) => props.open && `margin: 20px 5px;`}\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 color: ${getThemeValue(THEME_NAME.TEXT_COLOR_DARK)};\n\n &:focus-visible {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n & input {\n appearance: none;\n margin: 0;\n }\n\n ${(props) =>\n props.open && `border-bottom: 1px solid ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};`}\n ${(props) => props.open && `border-radius: 10px 10px 0 0;`}\n\n ${(props) => props.disabled && `color: ${getThemeValue(THEME_NAME.DISABLED)};`}\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 ? getThemeValue(THEME_NAME.PRIMARY)\n : props.completed\n ? getThemeValue(THEME_NAME.SUCCESS)\n : getThemeValue(THEME_NAME.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) => (props.open ? `& svg { transform: rotate(180deg); }` : '')}\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\nconst AccordionBadge = styled(Badge)`\n margin-right: 15px;\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 ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n`;\n\n/** Props for `AccordionStep` component */\ninterface AccordionStepProps {\n /**\n * If the step has been marked as completed\n * @default false\n */\n completed?: boolean;\n /** If the step is disabled\n * @default false\n */\n disabled?: boolean;\n /** Header content for the step */\n header: React.ReactNode;\n /** Error text to display as a badge in the header */\n errorText?: React.ReactNode;\n /** If the step is expanded */\n open?: boolean;\n /** Click handler for the step header */\n onStepClick?: React.MouseEventHandler<HTMLButtonElement>;\n}\n\n/**\n * AccordionStep Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLDivElement\n */\nfunction AccordionStepComponent(\n props: React.PropsWithChildren<AccordionStepProps> & React.HTMLAttributes<HTMLDivElement>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const [height, setHeight] = useState(0);\n const {\n open,\n disabled = false,\n header,\n errorText,\n completed = false,\n onStepClick,\n children,\n ...restProps\n } = props;\n\n // Generate unique IDs for ARIA relationships\n const headerId = useId();\n const regionId = useId();\n\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n // Measure content height when `open` or children change.\n useEffect(() => {\n const el = contentRef.current;\n setHeight(el?.scrollHeight || 0);\n }, [open, children]);\n\n return (\n <Step {...restProps} ref={ref} open={open} elevated={open} completed={completed}>\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 <AccordionBadge inline type={BADGE_TYPE.DANGER}>\n {errorText}\n </AccordionBadge>\n )}\n <ExpandMore aria-hidden=\"true\" />\n </ExpandContainer>\n </StepHeader>\n <StepBody\n ref={contentRef}\n height={open ? height : 0}\n role=\"region\"\n id={regionId}\n aria-labelledby={headerId}\n aria-hidden={open ? 'false' : 'true'}\n >\n {open && children}\n </StepBody>\n </Step>\n );\n}\n\nconst AccordionStep = React.forwardRef<\n HTMLDivElement,\n React.PropsWithChildren<AccordionStepProps> & React.HTMLAttributes<HTMLDivElement>\n>(AccordionStepComponent);\n\nexport default AccordionStep;\n"],"names":["Step","styled","Card","props","open","StepHeader","getThemeValue","THEME_NAME","TEXT_COLOR_DARK","PRIMARY_LIGHT","BORDER_LIGHT_COLOR","disabled","DISABLED","HeaderContainer","PRIMARY","completed","SUCCESS","LIGHT_GREY","ExpandContainer","StepBody","height","AccordionBadge","Badge","AccordionStepBody","AccordionStepFooter","AccordionStepComponent","ref","setHeight","useState","header","errorText","onStepClick","children","restProps","headerId","useId","regionId","contentRef","useRef","useEffect","el","current","scrollHeight","_jsxs","elevated","onClick","aria-expanded","aria-controls","id","_jsx","FiberManualRecord","aria-hidden","Ellipsis","inline","type","BADGE_TYPE","DANGER","ExpandMore","role","aria-labelledby","AccordionStep","React","forwardRef"],"mappings":";;;;;;;;;;AAQA,MAAMA,uBAAOC,MAAAA,CAAOC,IAAAA,EAAAA;;;AAId,CAAA,CAAA,CAAA,4CAAA,EAAA,CAACC,QAAUA,KAAAA,CAAMC,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAA;AAGlD,MAAMC,UAAAA,iBAAaJ,MAAAA,CAAAA,QAAAA,EAAAA;;;sJASNK,aAAAA,CAAcC,UAAAA,CAAWC,eAAe,CAAA,EAAA,wCAAA,EAGrBF,aAAAA,CAAcC,WAAWE,aAAa,CAAA,EAAA,sCAAA,EAQhE,CAACN,KAAAA,GACCA,KAAAA,CA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,IAAAA;wBAAMW,SAAAA,EAAWA,SAAAA;;0CACpCkC,GAAA,CAACC,iBAAAA,EAAAA;gCAAkBC,aAAAA,EAAY;;0CAC/BF,GAAA,CAACG,QAAAA,EAAAA;AAAUvB,gCAAAA,QAAAA,EAAAA;;;;kCAEfc,IAAA,CAACzB,eAAAA,EAAAA;wBAAgBd,IAAAA,EAAMA,IAAAA;;AAClB0B,4BAAAA,SAAAA,kBACGmB,GAAA,CAAC5B,cAAAA,EAAAA;gCAAegC,MAAM,EAAA,IAAA;AAACC,gCAAAA,IAAAA,EAAMC,WAAWC,MAAM;AACzC1B,gCAAAA,QAAAA,EAAAA;;0CAGTmB,GAAA,CAACQ,UAAAA,EAAAA;gCAAWN,aAAAA,EAAY;;;;;;0BAGhCF,GAAA,CAAC9B,QAAAA,EAAAA;gBACGO,GAAAA,EAAKW,UAAAA;AACLjB,gBAAAA,MAAAA,EAAQhB,OAAOgB,MAAAA,GAAS,CAAA;gBACxBsC,IAAAA,EAAK,QAAA;gBACLV,EAAAA,EAAIZ,QAAAA;gBACJuB,iBAAAA,EAAiBzB,QAAAA;AACjBiB,gBAAAA,aAAAA,EAAa/C,OAAO,OAAA,GAAU,MAAA;0BAE7BA,IAAAA,IAAQ4B;;;;AAIzB;AAEA,MAAM4B,aAAAA,iBAAgBC,KAAAA,CAAMC,UAAU,CAGpCrC,sBAAAA;;;;"}
|
|
@@ -4,13 +4,13 @@ import styled from '@emotion/styled';
|
|
|
4
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
5
5
|
|
|
6
6
|
const StyledCard = /*#__PURE__*/ styled("div", {
|
|
7
|
-
target: "
|
|
7
|
+
target: "e9lfq9w0",
|
|
8
8
|
label: "StyledCard"
|
|
9
9
|
})("border-radius:10px;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";", (props)=>props.elevated ? `box-shadow: ${getThemeValue(THEME_NAME.MODAL_SHADOW)};` : `box-shadow: ${getThemeValue(THEME_NAME.SHADOW)};`, " margin:5px;overflow:auto;position:relative;");
|
|
10
10
|
/**
|
|
11
11
|
* Card Component
|
|
12
12
|
* @param props - Component props
|
|
13
|
-
* @param ref - Ref forwarded to the underlying
|
|
13
|
+
* @param ref - Ref forwarded to the underlying HTMLAr
|
|
14
14
|
*/ function CardComponent(props, ref) {
|
|
15
15
|
return /*#__PURE__*/ jsx(StyledCard, {
|
|
16
16
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { THEME_NAME, getThemeValue } from '../../shared/constants';\n\ntype CardProps = {\n /** Shows a shadow around the card to show elevation */\n elevated?: boolean;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nconst StyledCard = styled.div<CardProps>`\n border-radius: 10px;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n ${(props) =>\n props.elevated\n ? `box-shadow: ${getThemeValue(THEME_NAME.MODAL_SHADOW)};`\n : `box-shadow: ${getThemeValue(THEME_NAME.SHADOW)};`}\n margin: 5px;\n overflow: auto;\n position: relative;\n`;\n\n/**\n * Card Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying
|
|
1
|
+
{"version":3,"file":"Card.js","sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { THEME_NAME, getThemeValue } from '../../shared/constants';\n\ntype CardProps = {\n /** Shows a shadow around the card to show elevation */\n elevated?: boolean;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nconst StyledCard = styled.div<CardProps>`\n border-radius: 10px;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n ${(props) =>\n props.elevated\n ? `box-shadow: ${getThemeValue(THEME_NAME.MODAL_SHADOW)};`\n : `box-shadow: ${getThemeValue(THEME_NAME.SHADOW)};`}\n margin: 5px;\n overflow: auto;\n position: relative;\n`;\n\n/**\n * Card Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLAr\n */\nfunction CardComponent(props: CardProps, ref: React.Ref<HTMLDivElement>) {\n return <StyledCard {...props} ref={ref} />;\n}\n\nconst Card = React.forwardRef<HTMLDivElement, CardProps>(CardComponent);\nexport default Card;\n"],"names":["StyledCard","styled","getThemeValue","THEME_NAME","BACKGROUND","props","elevated","MODAL_SHADOW","SHADOW","CardComponent","ref","_jsx","Card","React","forwardRef"],"mappings":";;;;;AASA,MAAMA,UAAAA,iBAAaC,MAAAA,CAAAA,KAAAA,EAAAA;;;2CAEKC,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA,GAAA,EACrD,CAACC,KAAAA,GACCA,KAAAA,CAAMC,QAAQ,GACR,CAAC,YAAY,EAAEJ,aAAAA,CAAcC,UAAAA,CAAWI,YAAY,CAAA,CAAE,CAAC,CAAC,GACxD,CAAC,YAAY,EAAEL,aAAAA,CAAcC,UAAAA,CAAWK,MAAM,CAAA,CAAE,CAAC,CAAC,EAAA,iDAAA,CAAA;AAMhE;;;;AAIC,IACD,SAASC,aAAAA,CAAcJ,KAAgB,EAAEK,GAA8B,EAAA;AACnE,IAAA,qBAAOC,GAAA,CAACX,UAAAA,EAAAA;AAAY,QAAA,GAAGK,KAAK;QAAEK,GAAAA,EAAKA;;AACvC;AAEA,MAAME,IAAAA,iBAAOC,KAAAA,CAAMC,UAAU,CAA4BL,aAAAA;;;;"}
|
|
@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
|
|
|
4
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
5
5
|
import Close from '../../icons/Close.js';
|
|
6
6
|
|
|
7
|
-
const Container$
|
|
7
|
+
const Container$a = /*#__PURE__*/ styled("span", {
|
|
8
8
|
target: "eg8hsap0",
|
|
9
9
|
label: "Container"
|
|
10
10
|
})("padding:5px;padding-left:15px;border-radius:16px;background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";display:inline-flex;margin:5px;line-height:20px;align-items:center;");
|
|
@@ -29,7 +29,7 @@ const Button$1 = /*#__PURE__*/ styled("button", {
|
|
|
29
29
|
e.stopPropagation();
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
return /*#__PURE__*/ jsxs(Container$
|
|
32
|
+
return /*#__PURE__*/ jsxs(Container$a, {
|
|
33
33
|
...rest,
|
|
34
34
|
ref: ref,
|
|
35
35
|
onKeyUp: keyUpHandler,
|
|
@@ -27,5 +27,5 @@ interface ChipInputProps {
|
|
|
27
27
|
*/
|
|
28
28
|
removedAnnouncementTemplate?: string;
|
|
29
29
|
}
|
|
30
|
-
declare const ChipInput: React.ForwardRefExoticComponent<ChipInputProps & React.AllHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
|
|
30
|
+
declare const ChipInput: React.ForwardRefExoticComponent<ChipInputProps & Omit<React.AllHTMLAttributes<HTMLInputElement>, "onChange" | "value"> & React.RefAttributes<HTMLInputElement>>;
|
|
31
31
|
export default ChipInput;
|
|
@@ -8,9 +8,9 @@ import { ORIENTATION } from '../DragAndDrop/types.js';
|
|
|
8
8
|
|
|
9
9
|
// Label component for the ChipInput
|
|
10
10
|
const Label$6 = /*#__PURE__*/ styled("label", {
|
|
11
|
-
target: "
|
|
11
|
+
target: "e1pr4bi70",
|
|
12
12
|
label: "Label"
|
|
13
|
-
})("display:inline-flex;flex-direction:column;flex:1;position:relative;margin:10px 5px;color:inherit;padding:0 8px;
|
|
13
|
+
})("display:inline-flex;flex-direction:column;flex:1;position:relative;margin:10px 5px;color:inherit;padding:0 8px;border-radius:3px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";width:", (props)=>typeof props.width === 'number' ? `${props.width}px` : props.width || '250px', ";max-width:100%;&:has(:focus),&:has(:active){border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:has(:focus) > span,&:has(:active) > span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:has(:disabled){border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:has(:disabled) > span{color:", getThemeValue(THEME_NAME.DISABLED), ";}&:has(:focus:invalid){border-color:", getThemeValue(THEME_NAME.ERROR), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.ERROR_LIGHT), ";}", (props)=>props.touched ? `
|
|
14
14
|
&:has(:invalid) {
|
|
15
15
|
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
16
16
|
}
|
|
@@ -37,13 +37,13 @@ const Label$6 = /*#__PURE__*/ styled("label", {
|
|
|
37
37
|
}
|
|
38
38
|
` : '');
|
|
39
39
|
// Error message container
|
|
40
|
-
const ErrorContainer$
|
|
41
|
-
target: "
|
|
40
|
+
const ErrorContainer$6 = /*#__PURE__*/ styled("div", {
|
|
41
|
+
target: "e1pr4bi71",
|
|
42
42
|
label: "ErrorContainer"
|
|
43
43
|
})("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
|
|
44
44
|
// Visually hidden but accessible to screen readers
|
|
45
45
|
const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
46
|
-
target: "
|
|
46
|
+
target: "e1pr4bi72",
|
|
47
47
|
label: "VisuallyHidden"
|
|
48
48
|
})("position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;& li{list-style:none;}");
|
|
49
49
|
/**
|
|
@@ -88,6 +88,13 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
88
88
|
}, [
|
|
89
89
|
propValue
|
|
90
90
|
]);
|
|
91
|
+
useEffect(()=>{
|
|
92
|
+
if (InputRef.current) {
|
|
93
|
+
InputRef.current.setCustomValidity(props.errorText || '');
|
|
94
|
+
}
|
|
95
|
+
}, [
|
|
96
|
+
props.errorText
|
|
97
|
+
]);
|
|
91
98
|
/**
|
|
92
99
|
* Update the chip values and notify changes.
|
|
93
100
|
* @param newValue The new array of chip values
|
|
@@ -157,6 +164,7 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
157
164
|
touched: touched,
|
|
158
165
|
errorText: props.errorText,
|
|
159
166
|
required: props.required,
|
|
167
|
+
width: props.width,
|
|
160
168
|
children: [
|
|
161
169
|
/*#__PURE__*/ jsx("input", {
|
|
162
170
|
...props,
|
|
@@ -184,7 +192,7 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
184
192
|
/*#__PURE__*/ jsx("span", {
|
|
185
193
|
children: props.label
|
|
186
194
|
}),
|
|
187
|
-
props.errorText && /*#__PURE__*/ jsx(ErrorContainer$
|
|
195
|
+
props.errorText && /*#__PURE__*/ jsx(ErrorContainer$6, {
|
|
188
196
|
id: errorId,
|
|
189
197
|
children: props.errorText
|
|
190
198
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipInput.js","sources":["../../../src/components/ChipInput/ChipInput.tsx"],"sourcesContent":["import React, { useImperativeHandle, useEffect, useId, useState } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport Chip from '../Chip/Chip';\nimport { DragAndDrop, ORIENTATION } from '../DragAndDrop';\n\n// Prop types definition\ninterface ChipInputProps {\n /** Label for the field */\n label: string;\n /** Error message for the field */\n errorText?: string;\n /**\n * Values to display as chips\n * @default []\n */\n value?: string[];\n /** Callback when chips change */\n onChange?: (newValue: string[]) => void;\n /**\n * Aria label for the close button on chip. Defaults to \"Remove {:label}\"\n * @default \"Remove {:label}\"\n */\n closeButtonAriaLabel?: string;\n /**\n * Announcement text when a chip is added. Defaults to \"{:label} was added\"\n * @default \"{:label} was added\"\n */\n addedAnnouncementTemplate?: string;\n /**\n * Announcement text when a chip is removed. Defaults to \"{:label} was removed\"\n * @default \"{:label} was removed\"\n */\n removedAnnouncementTemplate?: string;\n}\n\n// Label component for the ChipInput\nconst Label = styled.label<{\n text: string;\n touched?: boolean;\n errorText?: string;\n required?: boolean;\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 ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n\n /** Focused */\n &:has(:focus),\n &:has(:active) {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:has(:focus) > span,\n &:has(:active) > span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:has(:disabled) {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:has(:disabled) > span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:has(:focus:invalid) {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:has(:invalid) {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n \n &:has(:invalid) > span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & > span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n ${(props) =>\n props.required\n ? `& > span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }`\n : ''}\n \n\n & > input {\n border: none;\n outline: none;\n line-height: 30px;\n min-height: 30px;\n max-width: 95%;\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: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n\n ${(props) =>\n props.text !== ''\n ? `\n & > span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n`;\n\n// Error message container\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.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 */\nfunction ChipInputComponent(\n props: ChipInputProps & React.AllHTMLAttributes<HTMLInputElement>,\n ref: React.Ref<HTMLInputElement | null>,\n) {\n const {\n value: propValue = [],\n closeButtonAriaLabel = `Remove {:label}`,\n addedAnnouncementTemplate = '{:label} was added',\n removedAnnouncementTemplate = '{:label} was removed',\n } = props;\n\n const [text, setText] = useState('');\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState<string[]>(propValue || []);\n const InputRef = React.useRef<HTMLInputElement>(null);\n const [announcement, setAnnouncement] = useState('');\n const errorId = useId();\n\n // Forward the underlying input element.\n useImperativeHandle(ref, () => InputRef.current as HTMLInputElement);\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 const prevPropValueRef = React.useRef<string[]>(undefined);\n\n // Sync internal value with props.value\n useEffect(() => {\n if (Array.isArray(propValue)) {\n const prevValue = prevPropValueRef.current;\n const isEqual =\n prevValue &&\n propValue.length === prevValue.length &&\n propValue.every((val, index) => val === prevValue[index]);\n if (!isEqual) {\n setValue(propValue);\n prevPropValueRef.current = propValue;\n }\n }\n }, [propValue]);\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() !== '' && InputRef.current?.validity.valid) {\n const newValue = [...value, text.trim()];\n updateValue(newValue);\n setText('');\n setAnnouncement(replacePlaceholder(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(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\n text={text}\n touched={touched}\n errorText={props.errorText}\n required={props.required}\n >\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 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\nconst ChipInput = React.forwardRef<\n HTMLInputElement,\n ChipInputProps & React.AllHTMLAttributes<HTMLInputElement>\n>(ChipInputComponent);\n\nexport default ChipInput;\n"],"names":["Label","styled","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","required","text","ErrorContainer","VisuallyHidden","ChipInputComponent","ref","value","propValue","closeButtonAriaLabel","addedAnnouncementTemplate","removedAnnouncementTemplate","setText","useState","setTouched","setValue","InputRef","React","useRef","announcement","setAnnouncement","errorId","useId","useImperativeHandle","current","replacePlaceholder","template","label","undefined","replace","prevPropValueRef","useEffect","Array","isArray","prevValue","isEqual","length","every","val","index","updateValue","newValue","deduped","from","Set","onChange","handleFocus","e","onFocus","handleChange","target","handleKeyUp","key","trim","validity","valid","removeChip","chipToRemove","filter","chip","onDrop","start","end","newItems","item","splice","_jsxs","_Fragment","_jsx","input","onKeyUp","aria-required","aria-invalid","aria-describedby","div","DragAndDrop","orientation","ORIENTATION","HORIZONTAL","map","Chip","onCloseClick","span","id","aria-live","aria-atomic","ChipInput","forwardRef"],"mappings":";;;;;;;;AAoCA;AACA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;qKAeUC,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,oBAAA,EACrCF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,6CAAA,EAKnCH,cAAcC,UAAAA,CAAWG,OAAO,6BACxBJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,qDAAA,EAKrDL,aAAAA,CAAcC,WAAWG,OAAO,CAAA,EAAA,kCAAA,EAKzBJ,cAAcC,UAAAA,CAAWK,eAAe,yBACpCN,aAAAA,CAAcC,UAAAA,CAAWM,mBAAmB,CAAA,EAAA,kCAAA,EAIvDP,aAAAA,CAAcC,WAAWO,QAAQ,CAAA,EAAA,uCAAA,EAK1BR,cAAcC,UAAAA,CAAWQ,KAAK,6BACtBT,aAAAA,CAAcC,UAAAA,CAAWS,WAAW,CAAA,EAAA,IAAA,EAG9D,CAACC,QACCA,KAAAA,CAAMC,OAAO,GACP;;0BAEY,EAAEZ,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA,CAAE;;;;mBAIzC,EAAET,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA,CAAE;;AAE7C,QAAA,CAAC,GACK,EAAA,EAAA,YAAA,EAGR,CAACE,QACCA,KAAAA,CAAME,SAAS,GACT;sBACQ,EAAEb,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA,CAAE;;;mBAGrC,EAAET,aAAAA,CAAcC,UAAAA,CAAW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aC,YAAYC,UAAU;4BAAElB,MAAAA,EAAQA,MAAAA;AACrDrD,4BAAAA,QAAAA,EAAAA,KAAAA,CAAMwE,GAAG,CAAC,CAACpB,IAAAA,iBACRS,GAAA,CAACY,IAAAA,EAAAA;oCAEGrD,KAAAA,EAAOgC,IAAAA;AACPsB,oCAAAA,YAAAA,EAAc,IAAMzB,UAAAA,CAAWG,IAAAA,CAAAA;AAC/BlD,oCAAAA,oBAAAA,EAAsBgB,mBAClBhB,oBAAAA,EACAkD,IAAAA;AALCA,iCAAAA,EAAAA,IAAAA,CAAAA;;;kCAYzBS,GAAA,CAACc,MAAAA,EAAAA;AAAMpF,wBAAAA,QAAAA,EAAAA,KAAAA,CAAM6B;;oBACZ7B,KAAAA,CAAME,SAAS,kBAAIoE,GAAA,CAACjE,gBAAAA,EAAAA;wBAAegF,EAAAA,EAAI9D,OAAAA;AAAUvB,wBAAAA,QAAAA,EAAAA,KAAAA,CAAME;;;;0BAE5DoE,GAAA,CAAChE,gBAAAA,EAAAA;gBAAegF,WAAAA,EAAU,QAAA;gBAASC,aAAAA,EAAY,MAAA;AAC1ClE,gBAAAA,QAAAA,EAAAA;;;;AAIjB;AAEA,MAAMmE,SAAAA,iBAAYrE,KAAAA,CAAMsE,UAAU,CAGhClF,kBAAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"ChipInput.js","sources":["../../../src/components/ChipInput/ChipInput.tsx"],"sourcesContent":["import React, { useImperativeHandle, useEffect, useId, useState } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport Chip from '../Chip/Chip';\nimport { DragAndDrop, ORIENTATION } from '../DragAndDrop';\n\n// Prop types definition\ninterface ChipInputProps {\n /** Label for the field */\n label: string;\n /** Error message for the field */\n errorText?: string;\n /**\n * Values to display as chips\n * @default []\n */\n value?: string[];\n /** Callback when chips change */\n onChange?: (newValue: string[]) => void;\n /**\n * Aria label for the close button on chip. Defaults to \"Remove {:label}\"\n * @default \"Remove {:label}\"\n */\n closeButtonAriaLabel?: string;\n /**\n * Announcement text when a chip is added. Defaults to \"{:label} was added\"\n * @default \"{:label} was added\"\n */\n addedAnnouncementTemplate?: string;\n /**\n * Announcement text when a chip is removed. Defaults to \"{:label} was removed\"\n * @default \"{:label} was removed\"\n */\n removedAnnouncementTemplate?: string;\n}\n\n// Label component for the ChipInput\nconst Label = styled.label<{\n text: string;\n touched?: boolean;\n errorText?: string;\n required?: boolean;\n width?: string | number;\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 border-radius: 3px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n width: ${(props) =>\n typeof props.width === 'number' ? `${props.width}px` : props.width || '250px'};\n max-width: 100%;\n\n /** Focused */\n &:has(:focus),\n &:has(:active) {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:has(:focus) > span,\n &:has(:active) > span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:has(:disabled) {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:has(:disabled) > span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:has(:focus:invalid) {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:has(:invalid) {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n \n &:has(:invalid) > span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & > span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n ${(props) =>\n props.required\n ? `& > span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }`\n : ''}\n \n\n & > input {\n border: none;\n outline: none;\n line-height: 30px;\n min-height: 30px;\n max-width: 95%;\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: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n\n ${(props) =>\n props.text !== ''\n ? `\n & > span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n`;\n\n// Error message container\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.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 */\nfunction ChipInputComponent(\n props: ChipInputProps & Omit<React.AllHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'>,\n ref: React.Ref<HTMLInputElement | null>,\n) {\n const {\n value: propValue = [],\n closeButtonAriaLabel = `Remove {:label}`,\n addedAnnouncementTemplate = '{:label} was added',\n removedAnnouncementTemplate = '{:label} was removed',\n } = props;\n\n const [text, setText] = useState('');\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState<string[]>(propValue || []);\n const InputRef = React.useRef<HTMLInputElement>(null);\n const [announcement, setAnnouncement] = useState('');\n const errorId = useId();\n\n // Forward the underlying input element.\n useImperativeHandle(ref, () => InputRef.current as HTMLInputElement);\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 const prevPropValueRef = React.useRef<string[]>(undefined);\n\n // Sync internal value with props.value\n useEffect(() => {\n if (Array.isArray(propValue)) {\n const prevValue = prevPropValueRef.current;\n const isEqual =\n prevValue &&\n propValue.length === prevValue.length &&\n propValue.every((val, index) => val === prevValue[index]);\n if (!isEqual) {\n setValue(propValue);\n prevPropValueRef.current = propValue;\n }\n }\n }, [propValue]);\n\n useEffect(() => {\n if (InputRef.current) {\n InputRef.current.setCustomValidity(props.errorText || '');\n }\n }, [props.errorText]);\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() !== '' && InputRef.current?.validity.valid) {\n const newValue = [...value, text.trim()];\n updateValue(newValue);\n setText('');\n setAnnouncement(replacePlaceholder(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(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\n text={text}\n touched={touched}\n errorText={props.errorText}\n required={props.required}\n width={props.width}\n >\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 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\nconst ChipInput = React.forwardRef<\n HTMLInputElement,\n ChipInputProps & Omit<React.AllHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'>\n>(ChipInputComponent);\n\nexport default ChipInput;\n"],"names":["Label","styled","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","props","width","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","touched","errorText","required","text","ErrorContainer","VisuallyHidden","ChipInputComponent","ref","value","propValue","closeButtonAriaLabel","addedAnnouncementTemplate","removedAnnouncementTemplate","setText","useState","setTouched","setValue","InputRef","React","useRef","announcement","setAnnouncement","errorId","useId","useImperativeHandle","current","replacePlaceholder","template","label","undefined","replace","prevPropValueRef","useEffect","Array","isArray","prevValue","isEqual","length","every","val","index","setCustomValidity","updateValue","newValue","deduped","from","Set","onChange","handleFocus","e","onFocus","handleChange","target","handleKeyUp","key","trim","validity","valid","removeChip","chipToRemove","filter","chip","onDrop","start","end","newItems","item","splice","_jsxs","_Fragment","_jsx","input","onKeyUp","aria-required","aria-invalid","aria-describedby","div","DragAndDrop","orientation","ORIENTATION","HORIZONTAL","map","Chip","onCloseClick","span","id","aria-live","aria-atomic","ChipInput","forwardRef"],"mappings":";;;;;;;;AAoCA;AACA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;AAeUC,CAAAA,CAAAA,CAAAA,oJAAAA,EAAAA,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,oBAAA,EACrCF,aAAAA,CAAcC,UAAAA,CAAWE,UAAU,CAAA,EAAA,SAAA,EAC9C,CAACC,KAAAA,GACN,OAAOA,KAAAA,CAAMC,KAAK,KAAK,QAAA,GAAW,CAAA,EAAGD,KAAAA,CAAMC,KAAK,CAAC,EAAE,CAAC,GAAGD,KAAAA,CAAMC,KAAK,IAAI,OAAA,EAAA,4DAAA,EAMtDL,aAAAA,CAAcC,UAAAA,CAAWK,OAAO,6BACxBN,aAAAA,CAAcC,UAAAA,CAAWM,aAAa,CAAA,EAAA,qDAAA,EAKrDP,aAAAA,CAAcC,UAAAA,CAAWK,OAAO,CAAA,EAAA,kCAAA,EAKzBN,aAAAA,CAAcC,UAAAA,CAAWO,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oBAAAA,EACAmD,IAAAA;AALCA,iCAAAA,EAAAA,IAAAA,CAAAA;;;kCAYzBS,GAAA,CAACc,MAAAA,EAAAA;AAAM7F,wBAAAA,QAAAA,EAAAA,KAAAA,CAAMqC;;oBACZrC,KAAAA,CAAMU,SAAS,kBAAIqE,GAAA,CAAClE,gBAAAA,EAAAA;wBAAeiF,EAAAA,EAAI/D,OAAAA;AAAU/B,wBAAAA,QAAAA,EAAAA,KAAAA,CAAMU;;;;0BAE5DqE,GAAA,CAACjE,gBAAAA,EAAAA;gBAAeiF,WAAAA,EAAU,QAAA;gBAASC,aAAAA,EAAY,MAAA;AAC1CnE,gBAAAA,QAAAA,EAAAA;;;;AAIjB;AAEA,MAAMoE,SAAAA,iBAAYtE,KAAAA,CAAMuE,UAAU,CAGhCnF,kBAAAA;;;;"}
|
|
@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
|
|
|
4
4
|
import DragItem from './DragItem.js';
|
|
5
5
|
import { ORIENTATION, DragContext } from './types.js';
|
|
6
6
|
|
|
7
|
-
/** Container Component */ const Container$
|
|
7
|
+
/** Container Component */ const Container$8 = /*#__PURE__*/ styled("div", {
|
|
8
8
|
target: "e18d6tqk0",
|
|
9
9
|
label: "Container"
|
|
10
10
|
})("flex:1;display:flex;position:relative;flex-wrap:wrap;flex-direction:", (props)=>props.orientation === ORIENTATION.HORIZONTAL ? 'row' : 'column', ";");
|
|
@@ -107,7 +107,7 @@ import { ORIENTATION, DragContext } from './types.js';
|
|
|
107
107
|
setDragOver,
|
|
108
108
|
i18n
|
|
109
109
|
},
|
|
110
|
-
children: /*#__PURE__*/ jsx(Container$
|
|
110
|
+
children: /*#__PURE__*/ jsx(Container$8, {
|
|
111
111
|
...rest,
|
|
112
112
|
ref: ref,
|
|
113
113
|
orientation: orientation,
|
|
@@ -13,7 +13,7 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
13
13
|
target: "ertl9d71",
|
|
14
14
|
label: "DragKnob"
|
|
15
15
|
})("padding-top:8px;cursor:move;touch-action:none;color:", getThemeValue(THEME_NAME.DISABLED), ";");
|
|
16
|
-
/** Container for the children */ const Container$
|
|
16
|
+
/** Container for the children */ const Container$9 = /*#__PURE__*/ styled("div", {
|
|
17
17
|
target: "ertl9d72",
|
|
18
18
|
label: "Container"
|
|
19
19
|
})("flex:1;");
|
|
@@ -255,7 +255,7 @@ import CheckCircle from '../../icons/DragIndicator.js';
|
|
|
255
255
|
tabIndex: -1,
|
|
256
256
|
children: /*#__PURE__*/ jsx(CheckCircle, {})
|
|
257
257
|
}),
|
|
258
|
-
/*#__PURE__*/ jsx(Container$
|
|
258
|
+
/*#__PURE__*/ jsx(Container$9, {
|
|
259
259
|
children: children
|
|
260
260
|
})
|
|
261
261
|
]
|
|
@@ -102,7 +102,7 @@ export default class Drawer extends React.Component<React.PropsWithChildren<Draw
|
|
|
102
102
|
* Lifecycle method to handle Drawer updates.
|
|
103
103
|
* Manages opening/closing logic via LayerManager and focus preservation.
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
componentDidUpdate(prevProps: DrawerProps): void;
|
|
106
106
|
/**
|
|
107
107
|
* Sets the ref prop passed to the Drawer Container component.
|
|
108
108
|
* @param node
|
|
@@ -32,7 +32,7 @@ const positionStyle$1 = (size)=>({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const DrawerDiv = /*#__PURE__*/ styled("div", {
|
|
35
|
-
target: "
|
|
35
|
+
target: "e1qyfyr80",
|
|
36
36
|
label: "DrawerDiv"
|
|
37
37
|
})("display:flex;flex-direction:column;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";transition:transform 0.3s ease;box-shadow:", getThemeValue(THEME_NAME.MODAL_SHADOW), ";", (props)=>positionStyle$1(props.size)[props.position].before, " .nf-layer-enter &{transform:translateX(0%);", (props)=>positionStyle$1(props.size)[props.position].after, "}");
|
|
38
38
|
const positionMap$1 = {
|
|
@@ -70,7 +70,7 @@ class Drawer extends React.Component {
|
|
|
70
70
|
/**
|
|
71
71
|
* Lifecycle method to handle Drawer updates.
|
|
72
72
|
* Manages opening/closing logic via LayerManager and focus preservation.
|
|
73
|
-
*/
|
|
73
|
+
*/ componentDidUpdate(prevProps) {
|
|
74
74
|
const { open } = this.props;
|
|
75
75
|
if (prevProps.open && !open) {
|
|
76
76
|
this.closeCallback?.();
|
|
@@ -81,7 +81,6 @@ class Drawer extends React.Component {
|
|
|
81
81
|
this.lastFocusedElement = document.activeElement;
|
|
82
82
|
this.handleOpen();
|
|
83
83
|
}
|
|
84
|
-
return null;
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
87
86
|
* Renders the Drawer component via the LayerManager portal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport LayerManager, { LAYER_POSITION } from '../../shared/LayerManager';\n\nexport {\n Header as DrawerHeader,\n Body as DrawerBody,\n Footer as DrawerFooter,\n} from '../../shared/styles';\n\nexport enum DRAWER_POSITION {\n LEFT = 'LEFT',\n RIGHT = 'RIGHT',\n BOTTOM = 'BOTTOM',\n}\n\nconst positionStyle = (size?: string) => ({\n [DRAWER_POSITION.LEFT]: {\n before: `height: 100vh; min-width: ${size || '300px'}; transform: translateX(-100%);`,\n after: 'transform: translateX(0%);',\n },\n [DRAWER_POSITION.RIGHT]: {\n before: `height: 100vh; min-width: ${size || '300px'}; transform: translateX(100%);`,\n after: 'transform: translateX(0%);',\n },\n [DRAWER_POSITION.BOTTOM]: {\n before: `\n position: absolute;\n bottom: 0;\n width: 100%;\n height: ${size || '90vh'};\n transform: translateY(100%);\n border-radius: 15px 15px 0 0; \n `,\n after: 'transform: translateX(0%);',\n },\n});\n\nconst DrawerDiv = styled.div<{ position: DRAWER_POSITION; size?: string }>`\n display: flex;\n flex-direction: column;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n transition: transform 0.3s ease;\n box-shadow: ${getThemeValue(THEME_NAME.MODAL_SHADOW)};\n ${(props) => positionStyle(props.size)[props.position].before}\n\n .nf-layer-enter & {\n transform: translateX(0%);\n ${(props) => positionStyle(props.size)[props.position].after}\n }\n`;\n\ntype DrawerProps = {\n /** Opens the drawer */\n open: boolean;\n /** position of the drawer */\n position: DRAWER_POSITION;\n /** size of the drawer */\n size?: string;\n /** Shows an overlay behind the drawer. */\n overlay?: boolean;\n /** Closes the drawer on esc */\n closeOnEsc?: boolean;\n /** Closes the drawer on overlay click */\n closeOnOverlayClick?: boolean;\n /** Call back function called when the drawer closes. */\n onClose?: () => void;\n /** Ref forwarded to the underlying HTMLDivElement of the drawer container */\n forwardRef?: React.Ref<HTMLDivElement> | React.MutableRefObject<HTMLDivElement | null>;\n};\n\ninterface DrawerState {\n open: boolean;\n}\n\nconst positionMap = {\n [DRAWER_POSITION.LEFT]: LAYER_POSITION.TOP_LEFT,\n [DRAWER_POSITION.RIGHT]: LAYER_POSITION.TOP_RIGHT,\n [DRAWER_POSITION.BOTTOM]: LAYER_POSITION.BOTTOM_LEFT,\n};\n\n/**\n * Drawer component\n *\n * A panel that slides in from the edge of the screen.\n * It sits on top of the application content and is often used for navigation or details.\n *\n * Accessibility:\n * - Implements ARIA `role=\"dialog\"` and `aria-modal=\"true\"`.\n * - Traps focus effectively within the drawer while open.\n * - Restores focus to the triggering element upon closure.\n * - Supports closing via ESC key and overlay click.\n */\nexport default class Drawer extends React.Component<\n React.PropsWithChildren<DrawerProps>,\n DrawerState\n> {\n state = {\n open: false,\n };\n\n static defaultProps = {\n overlay: true,\n position: DRAWER_POSITION.LEFT,\n closeOnEsc: true,\n closeOnOverlayClick: true,\n };\n\n /**\n * Syncs state with props.\n */\n static getDerivedStateFromProps(props: DrawerProps) {\n if (props.open) {\n return {\n open: true,\n };\n }\n return null;\n }\n\n private layer?: ReturnType<typeof LayerManager.renderLayer>;\n\n private closeCallback?: (resp?: unknown) => void;\n\n /**\n * Internal close handler.\n * Restores focus and calls the external onClose callback.\n */\n private onClose = () => {\n this.restoreFocus();\n this.setState({\n open: false,\n });\n this.props.onClose?.();\n this.closeCallback = undefined;\n this.layer = undefined;\n };\n\n private lastFocusedElement: HTMLElement | null = null;\n private drawerRef = React.createRef<HTMLDivElement>();\n\n /**\n * Retrieves all focusable elements within the drawer.\n */\n private getFocusableElements = (): HTMLElement[] => {\n if (!this.drawerRef.current) return [];\n return Array.from(\n this.drawerRef.current.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n ),\n ) as HTMLElement[];\n };\n\n /**\n * Handles keydown events to implement the focus trap.\n * Traps Tab and Shift+Tab within the drawer.\n */\n private handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Tab') {\n const focusableElements = this.getFocusableElements();\n if (focusableElements.length === 0) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n if (e.shiftKey) {\n if (document.activeElement === firstElement) {\n lastElement.focus();\n e.preventDefault();\n }\n } else {\n if (document.activeElement === lastElement) {\n firstElement.focus();\n e.preventDefault();\n }\n }\n }\n };\n\n /**\n * Lifecycle method to save the currently focused element when the drawer mounts while open.\n */\n componentDidMount() {\n if (this.props.open) {\n this.lastFocusedElement = document.activeElement as HTMLElement;\n // Handle initial open state\n this.handleOpen();\n }\n }\n\n /**\n * Handles opening the drawer by creating the layer.\n */\n private handleOpen = () => {\n const { closeOnEsc, closeOnOverlayClick, position, size, overlay, children, ...rest } =\n this.props;\n\n this.layer = LayerManager.renderLayer({\n overlay,\n exitDelay: 300,\n position: positionMap[position],\n closeCallback: this.onClose,\n closeOnEsc,\n closeOnOverlayClick,\n component: (\n <DrawerDiv\n {...rest}\n ref={this.setDrawerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n onKeyDown={this.handleKeyDown}\n position={position}\n size={size}\n onClick={(e) => e.stopPropagation()}\n >\n {children}\n </DrawerDiv>\n ),\n });\n this.closeCallback = this.layer[1];\n this.forceUpdate();\n };\n\n /**\n * Lifecycle method to restore focus when the drawer unmounts.\n */\n componentWillUnmount() {\n if (this.props.open) {\n this.restoreFocus();\n }\n }\n\n /**\n * Restores focus to the element that was focused before the drawer opened.\n */\n private restoreFocus = () => {\n if (this.lastFocusedElement) {\n // Check if the element is still in the document\n const elementToBeFocused = this.lastFocusedElement;\n this.lastFocusedElement = null;\n setTimeout(() => {\n if (document.body.contains(elementToBeFocused)) {\n elementToBeFocused.focus();\n }\n }, 100);\n }\n };\n\n /**\n * Callback ref to capture the Drawer DOM element.\n * Triggers initial focus setting when the element mounts.\n */\n private setDrawerRef = (node: HTMLDivElement | null) => {\n // Update ref\n (this.drawerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n\n if (node) {\n // Set initial focus when the node is mounted\n this.setInitialFocus(node);\n }\n };\n\n /**\n * Sets initial focus within the drawer.\n * Tries to focus the header first, then the first interactive element, or falls back to the container.\n */\n private setInitialFocus = (root: HTMLElement) => {\n // Try to find the header (assumed to be the first child)\n const firstChild = root.firstElementChild as HTMLElement;\n if (firstChild) {\n // Ensure it's focusable\n if (firstChild.getAttribute('tabindex') === null) {\n firstChild.setAttribute('tabindex', '-1');\n }\n firstChild.focus();\n return;\n }\n\n // Fallback to focusable elements\n const focusableElements = this.getFocusableElements();\n if (focusableElements.length > 0) {\n focusableElements[0].focus();\n } else {\n // Fallback to container\n root.focus();\n }\n };\n\n /**\n * Lifecycle method to handle Drawer updates.\n * Manages opening/closing logic via LayerManager and focus preservation.\n */\n getSnapshotBeforeUpdate(prevProps: DrawerProps) {\n const { open } = this.props;\n\n if (prevProps.open && !open) {\n this.closeCallback?.();\n this.restoreFocus();\n }\n\n if (!prevProps.open && open) {\n // Save current focus\n this.lastFocusedElement = document.activeElement as HTMLElement;\n this.handleOpen();\n }\n\n return null;\n }\n\n /**\n * Sets the ref prop passed to the Drawer Container component.\n * @param node\n */\n setRefProp = (node: HTMLDivElement | null) => {\n if (this.props.forwardRef && typeof this.props.forwardRef === 'function') {\n this.props.forwardRef(node);\n } else if (this.props.forwardRef && typeof this.props.forwardRef === 'object') {\n (this.props.forwardRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n };\n\n /**\n * Renders the Drawer component via the LayerManager portal.\n */\n render() {\n if (this.state.open && this.layer) {\n const [Component] = this.layer;\n return <Component ref={this.setRefProp} />;\n }\n\n return null;\n }\n}\n"],"names":["DRAWER_POSITION","positionStyle","size","before","after","DrawerDiv","styled","getThemeValue","THEME_NAME","BACKGROUND","MODAL_SHADOW","props","position","positionMap","LAYER_POSITION","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","Drawer","React","Component","getDerivedStateFromProps","open","componentDidMount","lastFocusedElement","document","activeElement","handleOpen","componentWillUnmount","restoreFocus","getSnapshotBeforeUpdate","prevProps","closeCallback","render","state","layer","_jsx","ref","setRefProp","onClose","setState","undefined","drawerRef","createRef","getFocusableElements","current","Array","from","querySelectorAll","handleKeyDown","e","key","focusableElements","length","firstElement","lastElement","shiftKey","focus","preventDefault","closeOnEsc","closeOnOverlayClick","overlay","children","rest","LayerManager","renderLayer","exitDelay","component","setDrawerRef","role","aria-modal","tabIndex","onKeyDown","onClick","stopPropagation","forceUpdate","elementToBeFocused","setTimeout","body","contains","node","setInitialFocus","root","firstChild","firstElementChild","getAttribute","setAttribute","forwardRef","defaultProps"],"mappings":";;;;;;AAWO,IAAA,eAAKA,iBAAAA,SAAAA,eAAAA,EAAAA;;;;AAAAA,IAAAA,OAAAA,eAAAA;AAIX,CAAA,CAAA,EAAA;AAED,MAAMC,eAAAA,GAAgB,CAACC,IAAAA,IAAmB;AACtC,QAAA,CAAA,MAAA,GAAwB;AACpBC,YAAAA,MAAAA,EAAQ,CAAC,0BAA0B,EAAED,IAAAA,IAAQ,OAAA,CAAQ,+BAA+B,CAAC;YACrFE,KAAAA,EAAO;AACX,SAAA;AACA,QAAA,CAAA,OAAA,GAAyB;AACrBD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AAA,EAAY;AACtE,gBAAA,IAAI,CAAC5E,KAAK,CAAC4E,UAAU,CAACP,IAAAA,CAAAA;AAC1B,YAAA,CAAA,MAAO,IAAI,IAAI,CAACrE,KAAK,CAAC4E,UAAU,IAAI,OAAO,IAAI,CAAC5E,KAAK,CAAC4E,UAAU,KAAK,QAAA,EAAU;AAC1E,gBAAA,IAAI,CAAC5E,KAAK,CAAC4E,UAAU,CAAmD1C,OAAO,GAAGmC,IAAAA;AACvF,YAAA;AACJ,QAAA,CAAA;;AAaJ;AAhPqB9D,MAAAA,CAQVsE,YAAAA,GAAe;IAClB3B,OAAAA,EAAS,IAAA;IACTjD,QAAQ,EAAA,MAAA;IACR+C,UAAAA,EAAY,IAAA;IACZC,mBAAAA,EAAqB;AACzB,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\nimport LayerManager, { LAYER_POSITION } from '../../shared/LayerManager';\n\nexport {\n Header as DrawerHeader,\n Body as DrawerBody,\n Footer as DrawerFooter,\n} from '../../shared/styles';\n\nexport enum DRAWER_POSITION {\n LEFT = 'LEFT',\n RIGHT = 'RIGHT',\n BOTTOM = 'BOTTOM',\n}\n\nconst positionStyle = (size?: string) => ({\n [DRAWER_POSITION.LEFT]: {\n before: `height: 100vh; min-width: ${size || '300px'}; transform: translateX(-100%);`,\n after: 'transform: translateX(0%);',\n },\n [DRAWER_POSITION.RIGHT]: {\n before: `height: 100vh; min-width: ${size || '300px'}; transform: translateX(100%);`,\n after: 'transform: translateX(0%);',\n },\n [DRAWER_POSITION.BOTTOM]: {\n before: `\n position: absolute;\n bottom: 0;\n width: 100%;\n height: ${size || '90vh'};\n transform: translateY(100%);\n border-radius: 15px 15px 0 0; \n `,\n after: 'transform: translateX(0%);',\n },\n});\n\nconst DrawerDiv = styled.div<{ position: DRAWER_POSITION; size?: string }>`\n display: flex;\n flex-direction: column;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n transition: transform 0.3s ease;\n box-shadow: ${getThemeValue(THEME_NAME.MODAL_SHADOW)};\n ${(props) => positionStyle(props.size)[props.position].before}\n\n .nf-layer-enter & {\n transform: translateX(0%);\n ${(props) => positionStyle(props.size)[props.position].after}\n }\n`;\n\ntype DrawerProps = {\n /** Opens the drawer */\n open: boolean;\n /** position of the drawer */\n position: DRAWER_POSITION;\n /** size of the drawer */\n size?: string;\n /** Shows an overlay behind the drawer. */\n overlay?: boolean;\n /** Closes the drawer on esc */\n closeOnEsc?: boolean;\n /** Closes the drawer on overlay click */\n closeOnOverlayClick?: boolean;\n /** Call back function called when the drawer closes. */\n onClose?: () => void;\n /** Ref forwarded to the underlying HTMLDivElement of the drawer container */\n forwardRef?: React.Ref<HTMLDivElement> | React.MutableRefObject<HTMLDivElement | null>;\n};\n\ninterface DrawerState {\n open: boolean;\n}\n\nconst positionMap = {\n [DRAWER_POSITION.LEFT]: LAYER_POSITION.TOP_LEFT,\n [DRAWER_POSITION.RIGHT]: LAYER_POSITION.TOP_RIGHT,\n [DRAWER_POSITION.BOTTOM]: LAYER_POSITION.BOTTOM_LEFT,\n};\n\n/**\n * Drawer component\n *\n * A panel that slides in from the edge of the screen.\n * It sits on top of the application content and is often used for navigation or details.\n *\n * Accessibility:\n * - Implements ARIA `role=\"dialog\"` and `aria-modal=\"true\"`.\n * - Traps focus effectively within the drawer while open.\n * - Restores focus to the triggering element upon closure.\n * - Supports closing via ESC key and overlay click.\n */\nexport default class Drawer extends React.Component<\n React.PropsWithChildren<DrawerProps>,\n DrawerState\n> {\n state = {\n open: false,\n };\n\n static defaultProps = {\n overlay: true,\n position: DRAWER_POSITION.LEFT,\n closeOnEsc: true,\n closeOnOverlayClick: true,\n };\n\n /**\n * Syncs state with props.\n */\n static getDerivedStateFromProps(props: DrawerProps) {\n if (props.open) {\n return {\n open: true,\n };\n }\n return null;\n }\n\n private layer?: ReturnType<typeof LayerManager.renderLayer>;\n\n private closeCallback?: (resp?: unknown) => void;\n\n /**\n * Internal close handler.\n * Restores focus and calls the external onClose callback.\n */\n private onClose = () => {\n this.restoreFocus();\n this.setState({\n open: false,\n });\n this.props.onClose?.();\n this.closeCallback = undefined;\n this.layer = undefined;\n };\n\n private lastFocusedElement: HTMLElement | null = null;\n private drawerRef = React.createRef<HTMLDivElement>();\n\n /**\n * Retrieves all focusable elements within the drawer.\n */\n private getFocusableElements = (): HTMLElement[] => {\n if (!this.drawerRef.current) return [];\n return Array.from(\n this.drawerRef.current.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n ),\n ) as HTMLElement[];\n };\n\n /**\n * Handles keydown events to implement the focus trap.\n * Traps Tab and Shift+Tab within the drawer.\n */\n private handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Tab') {\n const focusableElements = this.getFocusableElements();\n if (focusableElements.length === 0) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n if (e.shiftKey) {\n if (document.activeElement === firstElement) {\n lastElement.focus();\n e.preventDefault();\n }\n } else {\n if (document.activeElement === lastElement) {\n firstElement.focus();\n e.preventDefault();\n }\n }\n }\n };\n\n /**\n * Lifecycle method to save the currently focused element when the drawer mounts while open.\n */\n componentDidMount() {\n if (this.props.open) {\n this.lastFocusedElement = document.activeElement as HTMLElement;\n // Handle initial open state\n this.handleOpen();\n }\n }\n\n /**\n * Handles opening the drawer by creating the layer.\n */\n private handleOpen = () => {\n const { closeOnEsc, closeOnOverlayClick, position, size, overlay, children, ...rest } =\n this.props;\n\n this.layer = LayerManager.renderLayer({\n overlay,\n exitDelay: 300,\n position: positionMap[position],\n closeCallback: this.onClose,\n closeOnEsc,\n closeOnOverlayClick,\n component: (\n <DrawerDiv\n {...rest}\n ref={this.setDrawerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n tabIndex={-1}\n onKeyDown={this.handleKeyDown}\n position={position}\n size={size}\n onClick={(e) => e.stopPropagation()}\n >\n {children}\n </DrawerDiv>\n ),\n });\n this.closeCallback = this.layer[1];\n this.forceUpdate();\n };\n\n /**\n * Lifecycle method to restore focus when the drawer unmounts.\n */\n componentWillUnmount() {\n if (this.props.open) {\n this.restoreFocus();\n }\n }\n\n /**\n * Restores focus to the element that was focused before the drawer opened.\n */\n private restoreFocus = () => {\n if (this.lastFocusedElement) {\n // Check if the element is still in the document\n const elementToBeFocused = this.lastFocusedElement;\n this.lastFocusedElement = null;\n setTimeout(() => {\n if (document.body.contains(elementToBeFocused)) {\n elementToBeFocused.focus();\n }\n }, 100);\n }\n };\n\n /**\n * Callback ref to capture the Drawer DOM element.\n * Triggers initial focus setting when the element mounts.\n */\n private setDrawerRef = (node: HTMLDivElement | null) => {\n // Update ref\n (this.drawerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n\n if (node) {\n // Set initial focus when the node is mounted\n this.setInitialFocus(node);\n }\n };\n\n /**\n * Sets initial focus within the drawer.\n * Tries to focus the header first, then the first interactive element, or falls back to the container.\n */\n private setInitialFocus = (root: HTMLElement) => {\n // Try to find the header (assumed to be the first child)\n const firstChild = root.firstElementChild as HTMLElement;\n if (firstChild) {\n // Ensure it's focusable\n if (firstChild.getAttribute('tabindex') === null) {\n firstChild.setAttribute('tabindex', '-1');\n }\n firstChild.focus();\n return;\n }\n\n // Fallback to focusable elements\n const focusableElements = this.getFocusableElements();\n if (focusableElements.length > 0) {\n focusableElements[0].focus();\n } else {\n // Fallback to container\n root.focus();\n }\n };\n\n /**\n * Lifecycle method to handle Drawer updates.\n * Manages opening/closing logic via LayerManager and focus preservation.\n */\n componentDidUpdate(prevProps: DrawerProps) {\n const { open } = this.props;\n\n if (prevProps.open && !open) {\n this.closeCallback?.();\n this.restoreFocus();\n }\n\n if (!prevProps.open && open) {\n // Save current focus\n this.lastFocusedElement = document.activeElement as HTMLElement;\n this.handleOpen();\n }\n }\n\n /**\n * Sets the ref prop passed to the Drawer Container component.\n * @param node\n */\n setRefProp = (node: HTMLDivElement | null) => {\n if (this.props.forwardRef && typeof this.props.forwardRef === 'function') {\n this.props.forwardRef(node);\n } else if (this.props.forwardRef && typeof this.props.forwardRef === 'object') {\n (this.props.forwardRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n };\n\n /**\n * Renders the Drawer component via the LayerManager portal.\n */\n render() {\n if (this.state.open && this.layer) {\n const [Component] = this.layer;\n return <Component ref={this.setRefProp} />;\n }\n\n return null;\n }\n}\n"],"names":["DRAWER_POSITION","positionStyle","size","before","after","DrawerDiv","styled","getThemeValue","THEME_NAME","BACKGROUND","MODAL_SHADOW","props","position","positionMap","LAYER_POSITION","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","Drawer","React","Component","getDerivedStateFromProps","open","componentDidMount","lastFocusedElement","document","activeElement","handleOpen","componentWillUnmount","restoreFocus","componentDidUpdate","prevProps","closeCallback","render","state","layer","_jsx","ref","setRefProp","onClose","setState","undefined","drawerRef","createRef","getFocusableElements","current","Array","from","querySelectorAll","handleKeyDown","e","key","focusableElements","length","firstElement","lastElement","shiftKey","focus","preventDefault","closeOnEsc","closeOnOverlayClick","overlay","children","rest","LayerManager","renderLayer","exitDelay","component","setDrawerRef","role","aria-modal","tabIndex","onKeyDown","onClick","stopPropagation","forceUpdate","elementToBeFocused","setTimeout","body","contains","node","setInitialFocus","root","firstChild","firstElementChild","getAttribute","setAttribute","forwardRef","defaultProps"],"mappings":";;;;;;AAWO,IAAA,eAAKA,iBAAAA,SAAAA,eAAAA,EAAAA;;;;AAAAA,IAAAA,OAAAA,eAAAA;AAIX,CAAA,CAAA,EAAA;AAED,MAAMC,eAAAA,GAAgB,CAACC,IAAAA,IAAmB;AACtC,QAAA,CAAA,MAAA,GAAwB;AACpBC,YAAAA,MAAAA,EAAQ,CAAC,0BAA0B,EAAED,IAAAA,IAAQ,OAAA,CAAQ,+BAA+B,CAAC;YACrFE,KAAAA,EAAO;AACX,SAAA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AC4E,UAAU,KAAK,UAAA,EAAY;AACtE,gBAAA,IAAI,CAAC5E,KAAK,CAAC4E,UAAU,CAACP,IAAAA,CAAAA;AAC1B,YAAA,CAAA,MAAO,IAAI,IAAI,CAACrE,KAAK,CAAC4E,UAAU,IAAI,OAAO,IAAI,CAAC5E,KAAK,CAAC4E,UAAU,KAAK,QAAA,EAAU;AAC1E,gBAAA,IAAI,CAAC5E,KAAK,CAAC4E,UAAU,CAAmD1C,OAAO,GAAGmC,IAAAA;AACvF,YAAA;AACJ,QAAA,CAAA;;AAaJ;AA9OqB9D,MAAAA,CAQVsE,YAAAA,GAAe;IAClB3B,OAAAA,EAAS,IAAA;IACTjD,QAAQ,EAAA,MAAA;IACR+C,UAAAA,EAAY,IAAA;IACZC,mBAAAA,EAAqB;AACzB,CAAA;;;;"}
|
|
@@ -4,9 +4,9 @@ import styled from '@emotion/styled';
|
|
|
4
4
|
import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
|
|
5
5
|
|
|
6
6
|
const Container$3 = /*#__PURE__*/ styled("div", {
|
|
7
|
-
target: "
|
|
7
|
+
target: "e1m58trk0",
|
|
8
8
|
label: "Container"
|
|
9
|
-
})("display:inline-flex;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";border-radius:3px;margin:5px;& button,& label{margin:0;border:none;border-radius:0;border-left:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";box-shadow:none;height:32px;}& > div button{border-left:none;}& input,& select{border:none;height:32px;}& input,& select{border-radius:0;}& input:active,& select:active{box-shadow:none;}& > div > span{top:8px;}& > *:first-
|
|
9
|
+
})("display:inline-flex;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";border-radius:3px;margin:5px;& button,& label{margin:0;border:none;border-radius:0;border-left:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";box-shadow:none;height:32px;}& > div button{border-left:none;}& input,& select{border:none;height:32px;}& input,& select{border-radius:0;}& input:active,& select:active{box-shadow:none;}& > div > span{top:8px;}& > *:first-of-type,& > label:first-of-type input,& > label:first-of-type select,& > *:first-of-type label,& > *:first-of-type input{border-left:none;border-radius:2px 0 0 2px;}& > *:last-child,& > label:last-child input,& > label:last-child select,& > *:last-child label,& > *:last-child input{border-radius:0 2px 2px 0;}& *:focus,& *:focus + span{z-index:1;}&:focus-within,&:hover{box-shadow:", getThemeValue(THEME_NAME.HOVER_SHADOW), ";}", (props)=>props.errorText ? `
|
|
10
10
|
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
11
11
|
|
|
12
12
|
& > button, & > label {
|
|
@@ -14,7 +14,7 @@ const Container$3 = /*#__PURE__*/ styled("div", {
|
|
|
14
14
|
}
|
|
15
15
|
` : '');
|
|
16
16
|
const ErrorContainer = /*#__PURE__*/ styled("div", {
|
|
17
|
-
target: "
|
|
17
|
+
target: "e1m58trk1",
|
|
18
18
|
label: "ErrorContainer"
|
|
19
19
|
})("color:", getThemeValue(THEME_NAME.ERROR), ";margin-left:8px;font-size:12px;");
|
|
20
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.js","sources":["../../../src/components/Groups/Group.tsx"],"sourcesContent":["import React, { useId } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Container = styled.div<GroupProps>`\n display: inline-flex;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n border-radius: 3px;\n margin: 5px;\n\n /* overrides */\n & button,\n & label {\n margin: 0;\n border: none;\n border-radius: 0;\n border-left: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n box-shadow: none;\n height: 32px;\n }\n\n & > div button {\n border-left: none;\n }\n\n & input,\n & select {\n border: none;\n height: 32px;\n }\n\n & input,\n & select {\n border-radius: 0;\n }\n\n & input:active,\n & select:active {\n box-shadow: none;\n }\n\n & > div > span {\n top: 8px;\n }\n\n /* Handling for first and last child */\n & > *:first-
|
|
1
|
+
{"version":3,"file":"Group.js","sources":["../../../src/components/Groups/Group.tsx"],"sourcesContent":["import React, { useId } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Container = styled.div<GroupProps>`\n display: inline-flex;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n border-radius: 3px;\n margin: 5px;\n\n /* overrides */\n & button,\n & label {\n margin: 0;\n border: none;\n border-radius: 0;\n border-left: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n box-shadow: none;\n height: 32px;\n }\n\n & > div button {\n border-left: none;\n }\n\n & input,\n & select {\n border: none;\n height: 32px;\n }\n\n & input,\n & select {\n border-radius: 0;\n }\n\n & input:active,\n & select:active {\n box-shadow: none;\n }\n\n & > div > span {\n top: 8px;\n }\n\n /* Handling for first and last child */\n & > *:first-of-type,\n & > label:first-of-type input,\n & > label:first-of-type select,\n & > *:first-of-type label,\n & > *:first-of-type input {\n border-left: none;\n border-radius: 2px 0 0 2px;\n }\n\n & > *:last-child,\n & > label:last-child input,\n & > label:last-child select,\n & > *:last-child label,\n & > *:last-child input {\n border-radius: 0 2px 2px 0;\n }\n\n /* focus */\n & *:focus,\n & *:focus + span {\n z-index: 1;\n }\n\n &:focus-within,\n &:hover {\n box-shadow: ${getThemeValue(THEME_NAME.HOVER_SHADOW)};\n }\n\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & > button, & > label {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n margin-left: 8px;\n font-size: 12px;\n`;\n\ntype GroupProps = React.PropsWithChildren<{\n /** Error Message for the group */\n errorText?: string;\n}>;\n\n/**\n * Group Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLDivElement\n */\nfunction GroupComponent(\n props: React.PropsWithChildren<GroupProps>,\n ref: React.Ref<HTMLDivElement>,\n) {\n const errorId = useId();\n\n return (\n <>\n <Container\n {...props}\n ref={ref}\n aria-describedby={props.errorText ? errorId : undefined}\n >\n {props.children}\n </Container>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </>\n );\n}\n\nconst Group = React.forwardRef<HTMLDivElement, GroupProps>(GroupComponent);\nexport default Group;\n"],"names":["Container","styled","getThemeValue","THEME_NAME","BORDER_COLOR","HOVER_SHADOW","props","errorText","ERROR","ErrorContainer","GroupComponent","ref","errorId","useId","_jsxs","_Fragment","_jsx","aria-describedby","undefined","children","id","Group","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,WAAAA,iBAAYC,MAAAA,CAAAA,KAAAA,EAAAA;;;AAEMC,CAAAA,CAAAA,CAAAA,uCAAAA,EAAAA,aAAAA,CAAcC,WAAWC,YAAY,CAAA,EAAA,4GAAA,EAU5BF,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,+lBAAA,EAuDhDF,aAAAA,CAAcC,UAAAA,CAAWE,YAAY,SAGrD,CAACC,KAAAA,GACCA,KAAAA,CAAMC,SAAS,GACT;sBACQ,EAAEL,aAAAA,CAAcC,UAAAA,CAAWK,KAAK,CAAA,CAAE;;;0BAG9B,EAAEN,aAAAA,CAAcC,UAAAA,CAAWK,KAAK,CAAA,CAAE;;AAExD,IAAA,CAAC,GACS,EAAA,CAAA;AAGd,MAAMC,cAAAA,iBAAiBR,MAAAA,CAAAA,KAAAA,EAAAA;;;AACVC,CAAAA,CAAAA,CAAAA,QAAAA,EAAAA,aAAAA,CAAcC,WAAWK,KAAK,CAAA,EAAA,kCAAA,CAAA;AAU3C;;;;AAIC,IACD,SAASE,cAAAA,CACLJ,KAA0C,EAC1CK,GAA8B,EAAA;AAE9B,IAAA,MAAMC,OAAAA,GAAUC,KAAAA,EAAAA;IAEhB,qBACIC,IAAA,CAAAC,QAAA,EAAA;;0BACIC,GAAA,CAAChB,WAAAA,EAAAA;AACI,gBAAA,GAAGM,KAAK;gBACTK,GAAAA,EAAKA,GAAAA;gBACLM,kBAAAA,EAAkBX,KAAAA,CAAMC,SAAS,GAAGK,OAAAA,GAAUM,SAAAA;AAE7CZ,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMa;;YAEVb,KAAAA,CAAMC,SAAS,kBAAIS,GAAA,CAACP,cAAAA,EAAAA;gBAAeW,EAAAA,EAAIR,OAAAA;AAAUN,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMC;;;;AAGpE;AAEA,MAAMc,KAAAA,iBAAQC,KAAAA,CAAMC,UAAU,CAA6Bb,cAAAA;;;;"}
|
|
@@ -10,5 +10,7 @@ declare const Checkbox: React.ForwardRefExoticComponent<{
|
|
|
10
10
|
* @default false
|
|
11
11
|
*/
|
|
12
12
|
indeterminate?: boolean;
|
|
13
|
+
/** Error text to be shown below the field */
|
|
14
|
+
errorText?: string;
|
|
13
15
|
} & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
|
|
14
16
|
export default Checkbox;
|