no-frills-ui 0.0.14-rc.1 → 0.0.14-rc.3
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 +446 -225
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.js +9 -8
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Chip/Chip.js +5 -4
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.js +80 -51
- 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/Notification/NotificationManager.js +1 -0
- package/lib-esm/components/Notification/NotificationManager.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 +2 -2
- package/lib-esm/shared/styles.d.ts +4 -0
- package/lib-esm/shared/styles.js +10 -6
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +2 -2
|
@@ -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: "ex87x7i0",
|
|
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: "ex87x7i1",
|
|
17
17
|
label: "StepHeader"
|
|
18
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: "ex87x7i2",
|
|
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: "ex87x7i3",
|
|
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: "ex87x7i4",
|
|
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: "ex87x7i5",
|
|
33
33
|
label: "AccordionBadge"
|
|
34
34
|
})("margin-right:15px;");
|
|
35
35
|
const AccordionStepBody = /*#__PURE__*/ styled("div", {
|
|
36
|
-
target: "
|
|
36
|
+
target: "ex87x7i6",
|
|
37
37
|
label: "AccordionStepBody"
|
|
38
38
|
})("padding:20px 15px;");
|
|
39
39
|
const AccordionStepFooter = /*#__PURE__*/ styled("div", {
|
|
40
|
-
target: "
|
|
40
|
+
target: "ex87x7i7",
|
|
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
|
/**
|
|
@@ -67,6 +67,7 @@ const AccordionStepFooter = /*#__PURE__*/ styled("div", {
|
|
|
67
67
|
completed: completed,
|
|
68
68
|
children: [
|
|
69
69
|
/*#__PURE__*/ jsxs(StepHeader, {
|
|
70
|
+
type: "button",
|
|
70
71
|
open: open,
|
|
71
72
|
disabled: disabled,
|
|
72
73
|
onClick: onStepClick,
|
|
@@ -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 ${(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,CAAMC,IAAI,IAAI,CAAC,yBAAyB,EAAEE,aAAAA,CAAcC,WAAWG,kBAAkB,CAAA,CAAE,CAAC,CAAC,EAAA,GAAA,EAC3F,CAACP,KAAAA,GAAUA,KAAAA,CAAMC,IAAI,IAAI,CAAC,6BAA6B,CAAC,EAAA,GAAA,EAExD,CAACD,KAAAA,GAAUA,KAAAA,CAAMQ,QAAQ,IAAI,CAAC,OAAO,EAAEL,aAAAA,CAAcC,WAAWK,QAAQ,CAAA,CAAE,CAAC,CAAC,CAAA;AAGlF,MAAMC,eAAAA,iBAAkBZ,MAAAA,CAAAA,KAAAA,EAAAA;;;sGAQR,CAACE,KAAAA,GACLA,KAAAA,CAAMC,IAAI,GACJE,aAAAA,CAAcC,WAAWO,OAAO,CAAA,GAChCX,KAAAA,CAAMY,SAAS,GACbT,aAAAA,CAAcC,WAAWS,OAAO,CAAA,GAChCV,aAAAA,CAAcC,UAAAA,CAAWU,UAAU,CAAA,EAAA,aAAA,EAClC,CAACd,KAAAA,GAAWA,K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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;;;;"}
|
|
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 type=\"button\"\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","type","onClick","aria-expanded","aria-controls","id","_jsx","FiberManualRecord","aria-hidden","Ellipsis","inline","BADGE_TYPE","DANGER","ExpandMore","role","aria-labelledby","AccordionStep","React","forwardRef"],"mappings":";;;;;;;;;;AAQA,MAAMA,uBAAOC,MAAAA,CAAOC,IAAAA,E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 @@ 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$
|
|
8
|
-
target: "
|
|
7
|
+
const Container$b = /*#__PURE__*/ styled("span", {
|
|
8
|
+
target: "e3nd8sw0",
|
|
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;");
|
|
11
11
|
const Button$1 = /*#__PURE__*/ styled("button", {
|
|
12
|
-
target: "
|
|
12
|
+
target: "e3nd8sw1",
|
|
13
13
|
label: "Button"
|
|
14
14
|
})("color:", getThemeValue(THEME_NAME.BACKGROUND), ";background-color:", getThemeValue(THEME_NAME.DISABLED), ";border-radius:50%;border:none;padding:4px;display:inline-flex;margin-left:5px;&:focus-within{outline:4px solid ", getThemeValue(THEME_NAME.ERROR_LIGHT), ";}");
|
|
15
15
|
/**
|
|
@@ -29,13 +29,14 @@ const Button$1 = /*#__PURE__*/ styled("button", {
|
|
|
29
29
|
e.stopPropagation();
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
return /*#__PURE__*/ jsxs(Container$
|
|
32
|
+
return /*#__PURE__*/ jsxs(Container$b, {
|
|
33
33
|
...rest,
|
|
34
34
|
ref: ref,
|
|
35
35
|
onKeyUp: keyUpHandler,
|
|
36
36
|
children: [
|
|
37
37
|
label,
|
|
38
38
|
/*#__PURE__*/ jsx(Button$1, {
|
|
39
|
+
type: "button",
|
|
39
40
|
onClick: onCloseClick,
|
|
40
41
|
onKeyDown: buttonKeyDownHandler,
|
|
41
42
|
"aria-label": closeButtonAriaLabel ?? `Remove ${label}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { Close } from '../../icons';\nimport { getThemeValue, THEME_NAME } 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: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n display: inline-flex;\n margin: 5px;\n line-height: 20px;\n align-items: center;\n`;\n\nconst Button = styled.button`\n color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED)};\n border-radius: 50%;\n border: none;\n padding: 4px;\n display: inline-flex;\n margin-left: 5px;\n\n &:focus-within {\n outline: 4px solid ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n`;\n\n/**\n * Chip Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLSpanElement\n */\nfunction ChipComponent(\n props: ChipProps & React.HTMLAttributes<HTMLSpanElement>,\n ref: React.Ref<HTMLSpanElement>,\n) {\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} ref={ref} 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\nconst Chip = React.forwardRef(ChipComponent);\nexport default Chip;\n"],"names":["Container","styled","getThemeValue","THEME_NAME","BORDER_LIGHT_COLOR","Button","BACKGROUND","DISABLED","ERROR_LIGHT","ChipComponent","props","ref","label","onCloseClick","closeButtonAriaLabel","rest","keyUpHandler","e","key","buttonKeyDownHandler","stopPropagation","_jsxs","onKeyUp","_jsx","onClick","onKeyDown","aria-label","Close","height","width","Chip","React","forwardRef"],"mappings":";;;;;;AAcA,MAAMA,WAAAA,iBAAYC,MAAAA,CAAAA,MAAAA,EAAAA;;;AAIMC,CAAAA,CAAAA,CAAAA,oEAAAA,EAAAA,aAAAA,CAAcC,WAAWC,kBAAkB,CAAA,EAAA,sEAAA,CAAA;AAOnE,MAAMC,QAAAA,iBAASJ,MAAAA,CAAAA,QAAAA,EAAAA;;;aACFC,aAAAA,CAAcC,UAAAA,CAAWG,UAAU,CAAA,EAAA,oBAAA,EACxBJ,aAAAA,CAAcC,WAAWI,QAAQ,CAAA,EAAA,kHAAA,EAQ5BL,aAAAA,CAAcC,UAAAA,CAAWK,WAAW,CAAA,EAAA,IAAA,CAAA;AAIjE;;;;AAIC,IACD,SAASC,aAAAA,CACLC,KAAwD,EACxDC,GAA+B,EAAA;IAE/B,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,oBAAoB,EAAE,GAAGC,IAAAA,EAAM,GAAGL,KAAAA;AAE/D,IAAA,MAAMM,eAA4D,CAACC,CAAAA,GAAAA;AAC/D,QAAA,IAAIA,EAAEC,GAAG,KAAK,eAAeD,CAAAA,CAAEC,GAAG,KAAK,QAAA,EAAU;YAC7CL,YAAAA,GAAeI,CAAAA,CAAAA;AACnB,QAAA;AACJ,IAAA,CAAA;AAEA,IAAA,MAAME,uBAAsE,CAACF,CAAAA,GAAAA;;QAEzE,IAAIA,CAAAA,CAAEC,GAAG,KAAK,GAAA,IAAOD,CAAAA,CAAEC,GAAG,KAAK,UAAA,IAAcD,CAAAA,CAAEC,GAAG,KAAK,OAAA,EAAS;AAC5DD,YAAAA,CAAAA,CAAEG,eAAe,EAAA;AACrB,QAAA;AACJ,IAAA,CAAA;AAEA,IAAA,qBACIC,IAAA,CAACrB,WAAAA,EAAAA;AAAW,QAAA,GAAGe,IAAI;QAAEJ,GAAAA,EAAKA,GAAAA;QAAKW,OAAAA,EAASN,YAAAA;;AACnCJ,YAAAA,KAAAA;0BACDW,GAAA,CAAClB,QAAAA,EAAAA;gBACGmB,OAAAA,
|
|
1
|
+
{"version":3,"file":"Chip.js","sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { Close } from '../../icons';\nimport { getThemeValue, THEME_NAME } 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: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n display: inline-flex;\n margin: 5px;\n line-height: 20px;\n align-items: center;\n`;\n\nconst Button = styled.button`\n color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED)};\n border-radius: 50%;\n border: none;\n padding: 4px;\n display: inline-flex;\n margin-left: 5px;\n\n &:focus-within {\n outline: 4px solid ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n`;\n\n/**\n * Chip Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLSpanElement\n */\nfunction ChipComponent(\n props: ChipProps & React.HTMLAttributes<HTMLSpanElement>,\n ref: React.Ref<HTMLSpanElement>,\n) {\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} ref={ref} onKeyUp={keyUpHandler}>\n {label}\n <Button\n type=\"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\nconst Chip = React.forwardRef(ChipComponent);\nexport default Chip;\n"],"names":["Container","styled","getThemeValue","THEME_NAME","BORDER_LIGHT_COLOR","Button","BACKGROUND","DISABLED","ERROR_LIGHT","ChipComponent","props","ref","label","onCloseClick","closeButtonAriaLabel","rest","keyUpHandler","e","key","buttonKeyDownHandler","stopPropagation","_jsxs","onKeyUp","_jsx","type","onClick","onKeyDown","aria-label","Close","height","width","Chip","React","forwardRef"],"mappings":";;;;;;AAcA,MAAMA,WAAAA,iBAAYC,MAAAA,CAAAA,MAAAA,EAAAA;;;AAIMC,CAAAA,CAAAA,CAAAA,oEAAAA,EAAAA,aAAAA,CAAcC,WAAWC,kBAAkB,CAAA,EAAA,sEAAA,CAAA;AAOnE,MAAMC,QAAAA,iBAASJ,MAAAA,CAAAA,QAAAA,EAAAA;;;aACFC,aAAAA,CAAcC,UAAAA,CAAWG,UAAU,CAAA,EAAA,oBAAA,EACxBJ,aAAAA,CAAcC,WAAWI,QAAQ,CAAA,EAAA,kHAAA,EAQ5BL,aAAAA,CAAcC,UAAAA,CAAWK,WAAW,CAAA,EAAA,IAAA,CAAA;AAIjE;;;;AAIC,IACD,SAASC,aAAAA,CACLC,KAAwD,EACxDC,GAA+B,EAAA;IAE/B,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,oBAAoB,EAAE,GAAGC,IAAAA,EAAM,GAAGL,KAAAA;AAE/D,IAAA,MAAMM,eAA4D,CAACC,CAAAA,GAAAA;AAC/D,QAAA,IAAIA,EAAEC,GAAG,KAAK,eAAeD,CAAAA,CAAEC,GAAG,KAAK,QAAA,EAAU;YAC7CL,YAAAA,GAAeI,CAAAA,CAAAA;AACnB,QAAA;AACJ,IAAA,CAAA;AAEA,IAAA,MAAME,uBAAsE,CAACF,CAAAA,GAAAA;;QAEzE,IAAIA,CAAAA,CAAEC,GAAG,KAAK,GAAA,IAAOD,CAAAA,CAAEC,GAAG,KAAK,UAAA,IAAcD,CAAAA,CAAEC,GAAG,KAAK,OAAA,EAAS;AAC5DD,YAAAA,CAAAA,CAAEG,eAAe,EAAA;AACrB,QAAA;AACJ,IAAA,CAAA;AAEA,IAAA,qBACIC,IAAA,CAACrB,WAAAA,EAAAA;AAAW,QAAA,GAAGe,IAAI;QAAEJ,GAAAA,EAAKA,GAAAA;QAAKW,OAAAA,EAASN,YAAAA;;AACnCJ,YAAAA,KAAAA;0BACDW,GAAA,CAAClB,QAAAA,EAAAA;gBACGmB,IAAAA,EAAK,QAAA;gBACLC,OAAAA,EAASZ,YAAAA;gBACTa,SAAAA,EAAWP,oBAAAA;AACXQ,gBAAAA,YAAAA,EAAYb,oBAAAA,IAAwB,CAAC,OAAO,EAAEF,KAAAA,CAAAA,CAAO;AAErD,gBAAA,QAAA,gBAAAW,GAAA,CAACK,KAAAA,EAAAA;oBAAMC,MAAAA,EAAQ,EAAA;oBAAIC,KAAAA,EAAO;;;;;AAI1C;AAEA,MAAMC,IAAAA,iBAAOC,KAAAA,CAAMC,UAAU,CAACxB,aAAAA;;;;"}
|
|
@@ -6,11 +6,16 @@ import Chip from '../Chip/Chip.js';
|
|
|
6
6
|
import DragAndDrop from '../DragAndDrop/DragAndDrop.js';
|
|
7
7
|
import { ORIENTATION } from '../DragAndDrop/types.js';
|
|
8
8
|
|
|
9
|
+
// Container for the ChipInput
|
|
10
|
+
const Container$8 = /*#__PURE__*/ styled("div", {
|
|
11
|
+
target: "e7l19410",
|
|
12
|
+
label: "Container"
|
|
13
|
+
})("margin:10px 5px;");
|
|
9
14
|
// Label component for the ChipInput
|
|
10
15
|
const Label$6 = /*#__PURE__*/ styled("label", {
|
|
11
|
-
target: "
|
|
16
|
+
target: "e7l19411",
|
|
12
17
|
label: "Label"
|
|
13
|
-
})("display:inline-flex;flex-direction:column;flex:1;position:relative;
|
|
18
|
+
})("display:inline-flex;flex-direction:column;flex:1;position:relative;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
19
|
&:has(:invalid) {
|
|
15
20
|
border-color: ${getThemeValue(THEME_NAME.ERROR)};
|
|
16
21
|
}
|
|
@@ -37,13 +42,13 @@ const Label$6 = /*#__PURE__*/ styled("label", {
|
|
|
37
42
|
}
|
|
38
43
|
` : '');
|
|
39
44
|
// Error message container
|
|
40
|
-
const ErrorContainer$
|
|
41
|
-
target: "
|
|
45
|
+
const ErrorContainer$6 = /*#__PURE__*/ styled("div", {
|
|
46
|
+
target: "e7l19412",
|
|
42
47
|
label: "ErrorContainer"
|
|
43
48
|
})("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
|
|
44
49
|
// Visually hidden but accessible to screen readers
|
|
45
50
|
const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
46
|
-
target: "
|
|
51
|
+
target: "e7l19413",
|
|
47
52
|
label: "VisuallyHidden"
|
|
48
53
|
})("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
54
|
/**
|
|
@@ -59,7 +64,7 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
59
64
|
* />
|
|
60
65
|
* ```
|
|
61
66
|
*/ function ChipInputComponent(props, ref) {
|
|
62
|
-
const { value: propValue = [], closeButtonAriaLabel = `Remove {:label}`, addedAnnouncementTemplate = '{:label} was added', removedAnnouncementTemplate = '{:label} was removed' } = props;
|
|
67
|
+
const { value: propValue = [], onChange: onChangeCallback, label, errorText, closeButtonAriaLabel = `Remove {:label}`, addedAnnouncementTemplate = '{:label} was added', removedAnnouncementTemplate = '{:label} was removed', width, ...inputProps } = props;
|
|
63
68
|
const [text, setText] = useState('');
|
|
64
69
|
const [touched, setTouched] = useState(false);
|
|
65
70
|
const [value, setValue] = useState(propValue || []);
|
|
@@ -88,21 +93,28 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
88
93
|
}, [
|
|
89
94
|
propValue
|
|
90
95
|
]);
|
|
96
|
+
useEffect(()=>{
|
|
97
|
+
if (InputRef.current) {
|
|
98
|
+
InputRef.current.setCustomValidity(errorText || '');
|
|
99
|
+
}
|
|
100
|
+
}, [
|
|
101
|
+
errorText
|
|
102
|
+
]);
|
|
91
103
|
/**
|
|
92
104
|
* Update the chip values and notify changes.
|
|
93
105
|
* @param newValue The new array of chip values
|
|
94
106
|
*/ const updateValue = (newValue)=>{
|
|
95
107
|
const deduped = Array.from(new Set(newValue));
|
|
96
108
|
setValue(deduped);
|
|
97
|
-
|
|
109
|
+
onChangeCallback?.(deduped);
|
|
98
110
|
};
|
|
99
111
|
/**
|
|
100
112
|
* Marks the input as touched on focus.
|
|
101
113
|
* @param e React focus event
|
|
102
114
|
*/ const handleFocus = (e)=>{
|
|
103
115
|
setTouched(true);
|
|
104
|
-
if (
|
|
105
|
-
|
|
116
|
+
if (inputProps.onFocus) {
|
|
117
|
+
inputProps.onFocus(e);
|
|
106
118
|
}
|
|
107
119
|
};
|
|
108
120
|
/**
|
|
@@ -114,15 +126,28 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
114
126
|
/**
|
|
115
127
|
* Adds a new chip on Enter key press.
|
|
116
128
|
* @param e React keyboard event
|
|
117
|
-
*/ const
|
|
118
|
-
if (e.key === 'Enter'
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
*/ const handleKeyDown = (e)=>{
|
|
130
|
+
if (e.key === 'Enter') {
|
|
131
|
+
// Check validity against HTML5 constraints only (ignore custom validity from errorText)
|
|
132
|
+
let isValid;
|
|
133
|
+
if (InputRef.current) {
|
|
134
|
+
InputRef.current.setCustomValidity('');
|
|
135
|
+
isValid = InputRef.current.checkValidity();
|
|
136
|
+
InputRef.current.setCustomValidity(errorText || '');
|
|
137
|
+
}
|
|
138
|
+
// Only prevent form submission if we have valid text to add as a chip
|
|
139
|
+
if (text.trim() !== '' && isValid) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
const newValue = [
|
|
143
|
+
...value,
|
|
144
|
+
text.trim()
|
|
145
|
+
];
|
|
146
|
+
updateValue(newValue);
|
|
147
|
+
setText('');
|
|
148
|
+
setAnnouncement(replacePlaceholder(addedAnnouncementTemplate, text.trim()));
|
|
149
|
+
}
|
|
150
|
+
// Otherwise, allow form submission to proceed
|
|
126
151
|
}
|
|
127
152
|
};
|
|
128
153
|
/**
|
|
@@ -152,42 +177,46 @@ const VisuallyHidden$1 = /*#__PURE__*/ styled("ul", {
|
|
|
152
177
|
// Render the component
|
|
153
178
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
154
179
|
children: [
|
|
155
|
-
/*#__PURE__*/ jsxs(
|
|
156
|
-
text: text,
|
|
157
|
-
touched: touched,
|
|
158
|
-
errorText: props.errorText,
|
|
159
|
-
required: props.required,
|
|
160
|
-
width: props.width,
|
|
180
|
+
/*#__PURE__*/ jsxs(Container$8, {
|
|
161
181
|
children: [
|
|
162
|
-
/*#__PURE__*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
/*#__PURE__*/ jsxs(Label$6, {
|
|
183
|
+
text: text,
|
|
184
|
+
touched: touched,
|
|
185
|
+
errorText: errorText,
|
|
186
|
+
required: inputProps.required,
|
|
187
|
+
width: width,
|
|
188
|
+
children: [
|
|
189
|
+
/*#__PURE__*/ jsx("input", {
|
|
190
|
+
...inputProps,
|
|
191
|
+
ref: InputRef,
|
|
192
|
+
value: text,
|
|
193
|
+
onChange: handleChange,
|
|
194
|
+
onFocus: handleFocus,
|
|
195
|
+
onKeyDown: handleKeyDown,
|
|
196
|
+
required: inputProps.required && value.length === 0,
|
|
197
|
+
"aria-required": inputProps.required,
|
|
198
|
+
"aria-invalid": !!errorText,
|
|
199
|
+
"aria-describedby": errorText ? errorId : undefined
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ jsx("div", {
|
|
202
|
+
children: value?.length > 0 && /*#__PURE__*/ jsx(DragAndDrop, {
|
|
203
|
+
orientation: ORIENTATION.HORIZONTAL,
|
|
204
|
+
onDrop: onDrop,
|
|
205
|
+
children: value.map((chip)=>/*#__PURE__*/ jsx(Chip, {
|
|
206
|
+
label: chip,
|
|
207
|
+
onCloseClick: ()=>removeChip(chip),
|
|
208
|
+
closeButtonAriaLabel: replacePlaceholder(closeButtonAriaLabel, chip)
|
|
209
|
+
}, chip))
|
|
210
|
+
})
|
|
211
|
+
}),
|
|
212
|
+
/*#__PURE__*/ jsx("span", {
|
|
213
|
+
children: label
|
|
214
|
+
})
|
|
215
|
+
]
|
|
187
216
|
}),
|
|
188
|
-
|
|
217
|
+
errorText && /*#__PURE__*/ jsx(ErrorContainer$6, {
|
|
189
218
|
id: errorId,
|
|
190
|
-
children:
|
|
219
|
+
children: errorText
|
|
191
220
|
})
|
|
192
221
|
]
|
|
193
222
|
}),
|
|
@@ -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 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 /**\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","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,eAAe,CAAA,EAAA,oBAAA,EACpCR,aAAAA,CAAcC,UAAAA,CAAWQ,mBAAmB,CAAA,EAAA,kCAAA,EAIvDT,aAAAA,CAAcC,UAAAA,CAAWS,QAAQ,CAAA,EAAA,uCAAA,EAK1BV,aAAAA,CAAcC,UAAAA,CAAWU,KAAK,CAAA,EAAA,wBAAA,EACtBX,aAAAA,CAAcC,UAAAA,CAAWW,WAAW,CAAA,EAAA,IAAA,EAG9D,CAACR,KAAAA,GACCA,KAAAA,CAAMS,OAAO,GACP;;0BAEY,EAAEb,aAAAA,C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ImperativeHandle, 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// Container for the ChipInput\nconst Container = styled.div`\n margin: 10px 5px;\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 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 onChange: onChangeCallback,\n label,\n errorText,\n closeButtonAriaLabel = `Remove {:label}`,\n addedAnnouncementTemplate = '{:label} was added',\n removedAnnouncementTemplate = '{:label} was removed',\n width,\n ...inputProps\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(errorText || '');\n }\n }, [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 onChangeCallback?.(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 (inputProps.onFocus) {\n inputProps.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 handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (e) => {\n if (e.key === 'Enter') {\n // Check validity against HTML5 constraints only (ignore custom validity from errorText)\n let isValid;\n if (InputRef.current) {\n InputRef.current.setCustomValidity('');\n isValid = InputRef.current.checkValidity();\n InputRef.current.setCustomValidity(errorText || '');\n }\n\n // Only prevent form submission if we have valid text to add as a chip\n if (text.trim() !== '' && isValid) {\n e.preventDefault();\n e.stopPropagation();\n const newValue = [...value, text.trim()];\n updateValue(newValue);\n setText('');\n setAnnouncement(replacePlaceholder(addedAnnouncementTemplate, text.trim())!);\n }\n // Otherwise, allow form submission to proceed\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 <Container>\n <Label\n text={text}\n touched={touched}\n errorText={errorText}\n required={inputProps.required}\n width={width}\n >\n <input\n {...inputProps}\n ref={InputRef}\n value={text}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n required={inputProps.required && value.length === 0}\n aria-required={inputProps.required}\n aria-invalid={!!errorText}\n aria-describedby={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>{label}</span>\n </Label>\n {errorText && <ErrorContainer id={errorId}>{errorText}</ErrorContainer>}\n </Container>\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":["Container","styled","Label","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","onChange","onChangeCallback","label","closeButtonAriaLabel","addedAnnouncementTemplate","removedAnnouncementTemplate","inputProps","setText","useState","setTouched","setValue","InputRef","React","useRef","announcement","setAnnouncement","errorId","useId","useImperativeHandle","current","replacePlaceholder","template","undefined","replace","prevPropValueRef","useEffect","Array","isArray","prevValue","isEqual","length","every","val","index","setCustomValidity","updateValue","newValue","deduped","from","Set","handleFocus","e","onFocus","handleChange","target","handleKeyDown","key","isValid","checkValidity","trim","preventDefault","stopPropagation","removeChip","chipToRemove","filter","chip","onDrop","start","end","newItems","item","splice","_jsxs","_Fragment","_jsx","input","onKeyDown","aria-required","aria-invalid","aria-describedby","div","DragAndDrop","orientation","ORIENT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AAA,CAACc,MAAAA,EAAAA;AAAM5E,gCAAAA,QAAAA,EAAAA;;;;AAEVX,oBAAAA,SAAAA,kBAAayE,GAAA,CAACtE,gBAAAA,EAAAA;wBAAeqF,EAAAA,EAAI/D,OAAAA;AAAUzB,wBAAAA,QAAAA,EAAAA;;;;0BAEhDyE,GAAA,CAACrE,gBAAAA,EAAAA;gBAAeqF,WAAAA,EAAU,QAAA;gBAASC,aAAAA,EAAY,MAAA;AAC1CnE,gBAAAA,QAAAA,EAAAA;;;;AAIjB;AAEA,MAAMoE,SAAAA,iBAAYtE,KAAAA,CAAMuE,UAAU,CAGhCvF,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$9 = /*#__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$9, {
|
|
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$a = /*#__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$a, {
|
|
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.
|