@lifesg/react-design-system 3.5.0-canary.4 → 3.5.0-canary.6
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/cjs/data-table/data-table.js +1 -1
- package/cjs/data-table/data-table.js.map +1 -1
- package/cjs/data-table/data-table.styles.js +14 -12
- package/cjs/data-table/data-table.styles.js.map +1 -1
- package/cjs/error-display/error-display-data.js +1 -1
- package/cjs/error-display/error-display-data.js.map +1 -1
- package/cjs/navbar/navbar-items.js +1 -1
- package/cjs/navbar/navbar-items.js.map +1 -1
- package/cjs/navbar/navbar-items.styles.js +11 -7
- package/cjs/navbar/navbar-items.styles.js.map +1 -1
- package/cjs/toggle/toggle.js +1 -1
- package/cjs/toggle/toggle.js.map +1 -1
- package/cjs/toggle/toggle.styles.js +42 -20
- package/cjs/toggle/toggle.styles.js.map +1 -1
- package/codemods/data.ts +1 -33
- package/codemods/index.ts +55 -140
- package/data-table/data-table.d.ts +1 -1
- package/data-table/data-table.js +1 -1
- package/data-table/data-table.js.map +1 -1
- package/data-table/data-table.styles.d.ts +1 -0
- package/data-table/data-table.styles.js +22 -20
- package/data-table/data-table.styles.js.map +1 -1
- package/data-table/types.d.ts +9 -0
- package/error-display/error-display-data.js +1 -1
- package/error-display/error-display-data.js.map +1 -1
- package/navbar/navbar-items.js +1 -1
- package/navbar/navbar-items.js.map +1 -1
- package/navbar/navbar-items.styles.d.ts +20 -4
- package/navbar/navbar-items.styles.js +13 -9
- package/navbar/navbar-items.styles.js.map +1 -1
- package/package.json +1 -1
- package/toggle/toggle.js +1 -1
- package/toggle/toggle.js.map +1 -1
- package/toggle/toggle.styles.d.ts +1 -0
- package/toggle/toggle.styles.js +65 -43
- package/toggle/toggle.styles.js.map +1 -1
package/toggle/toggle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","sources":["../../src/toggle/toggle.tsx"],"sourcesContent":["import { ChevronDownIcon } from \"@lifesg/react-icons/chevron-down\";\nimport { ChevronUpIcon } from \"@lifesg/react-icons/chevron-up\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { ToggleIconType } from \"../shared/toggle-icon/toggle-icon\";\nimport { useId } from \"../util\";\nimport {\n AlertContainer,\n Children,\n Container,\n ErrorContainer,\n ErrorList,\n ErrorText,\n ExpandButton,\n HeaderContainer,\n IndicatorLabelContainer,\n Input,\n InputContainer,\n Label,\n RemoveButton,\n StyledToggleIcon,\n SubLabel,\n TextContainer,\n} from \"./toggle.styles\";\nimport { ToggleProps } from \"./types\";\n\nexport const Toggle = ({\n type = \"checkbox\",\n indicator,\n checked,\n styleType = \"default\",\n children,\n childrenMaxLines,\n subLabel,\n disabled,\n error,\n name,\n id,\n className,\n compositeSection,\n removable,\n focusableWhenDisabled,\n useContentWidth,\n onRemove,\n onChange,\n \"data-testid\": testId,\n \"aria-describedby\": ariaDescribedBy,\n ...otherProps\n}: ToggleProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const {\n collapsible = true,\n errors,\n children: compositeSectionChildren,\n initialExpanded,\n } = compositeSection || {};\n const [selected, setSelected] = useState<boolean | undefined>(checked);\n const [expanded, setExpanded] = useState<boolean>(!!initialExpanded);\n const hasCompositeSectionError = useMemo(() => {\n const hasErrorList = Array.isArray(errors) && errors?.length > 0;\n const hasErrorElement = !Array.isArray(errors) && !!errors;\n return hasErrorList || hasErrorElement;\n }, [errors]);\n const uniqueId = useId();\n const generatedId = id ? `${id}` : `tg-${uniqueId}`;\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const isFocusableWhenDisabled = !!disabled && !!focusableWhenDisabled;\n const isNativeDisabled = !!disabled && !focusableWhenDisabled;\n const isInteractionBlocked = !!disabled;\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n setSelected(checked);\n }, [checked]);\n\n useEffect(() => {\n if (selected) {\n setExpanded(initialExpanded ?? true);\n }\n }, [selected]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (isInteractionBlocked) {\n event.preventDefault();\n return;\n }\n\n if (onChange) {\n onChange(event);\n return;\n }\n\n switch (type) {\n case \"checkbox\":\n setSelected((prevSelected) => {\n return !prevSelected;\n });\n break;\n case \"radio\":\n case \"yes\":\n case \"no\":\n if (!selected) {\n setSelected(true);\n }\n break;\n }\n };\n\n const handleExpandCollapseClick = () => {\n if (!disabled) {\n setExpanded(!expanded);\n }\n };\n\n const handleOnRemove = () => {\n if (!disabled) {\n if (onRemove) {\n onRemove();\n return;\n }\n }\n };\n\n const handleContainerClick = () => {\n inputRef?.current?.click();\n };\n\n const handleInputClick = (e: React.MouseEvent<HTMLInputElement>) => {\n e.stopPropagation();\n };\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderIndicator = () => {\n let toggleIconType: ToggleIconType;\n\n switch (type) {\n case \"yes\":\n toggleIconType = \"tick\";\n break;\n case \"no\":\n toggleIconType = \"cross\";\n break;\n case \"checkbox\":\n case \"radio\":\n toggleIconType = type;\n break;\n }\n\n return (\n <StyledToggleIcon\n type={toggleIconType}\n active={selected}\n disabled={disabled}\n $selected={selected}\n $disabled={disabled}\n />\n );\n };\n\n const renderSubLabel = () => {\n if (!subLabel) {\n return null;\n }\n\n let component: string | JSX.Element;\n\n if (typeof subLabel === \"function\") {\n component = subLabel();\n } else {\n component = subLabel;\n }\n\n // Hide sublabel from screen readers as the main input already has aria-describedby that points to the sublabel\n return (\n <SubLabel\n data-id=\"toggle-sublabel\"\n id={`${generatedId}-sublabel`}\n aria-hidden\n >\n {component}\n </SubLabel>\n );\n };\n\n const renderCompositeChildren = () => {\n return (\n (!collapsible || expanded) && (\n <Children\n data-id=\"toggle-composite-children\"\n $isFinalItem={!collapsible}\n $disabled={disabled}\n >\n {compositeSectionChildren}\n </Children>\n )\n );\n };\n\n const renderExpandButton = () => {\n const collapsedWithoutErrors = !expanded && !hasCompositeSectionError;\n\n return (\n collapsible && (\n <ExpandButton\n $paddingTopRequired={collapsedWithoutErrors}\n disabled={disabled}\n onClick={handleExpandCollapseClick}\n data-testid={expanded ? \"collapse-button\" : \"expand-button\"}\n >\n {expanded ? \"Show less\" : \"Show more\"}\n {expanded ? (\n <ChevronUpIcon aria-hidden />\n ) : (\n <ChevronDownIcon aria-hidden />\n )}\n </ExpandButton>\n )\n );\n };\n\n const renderToggleWithRemoveButton = () => {\n const ariaDescriptions =\n [\n typeof subLabel === \"string\" ? `${generatedId}-sublabel` : null,\n ariaDescribedBy,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n return (\n <HeaderContainer\n id={`${generatedId}-header-container`}\n $disabled={disabled}\n $error={error}\n $selected={selected}\n $indicator={indicator}\n $styleType={styleType}\n >\n <IndicatorLabelContainer $addPadding={removable}>\n <InputContainer\n id={`${generatedId}-input-container`}\n onClick={handleContainerClick}\n >\n <Input\n ref={inputRef}\n name={name}\n id={`${generatedId}-input`}\n type={type === \"checkbox\" ? \"checkbox\" : \"radio\"}\n data-testid=\"toggle-input\"\n disabled={isNativeDisabled}\n aria-disabled={isFocusableWhenDisabled}\n $disabledVisual={disabled}\n onChange={handleOnChange}\n onClick={handleInputClick}\n checked={selected}\n tabIndex={isFocusableWhenDisabled ? 0 : undefined}\n aria-describedby={ariaDescriptions}\n {...otherProps}\n />\n {indicator && renderIndicator()}\n <TextContainer\n $selected={selected}\n $disabled={disabled}\n >\n <Label\n htmlFor={`${generatedId}-input`}\n data-testid={`toggle-label`}\n id={`${generatedId}-label`}\n $maxLines={childrenMaxLines}\n $selected={selected}\n >\n {children}\n </Label>\n {subLabel && renderSubLabel()}\n </TextContainer>\n </InputContainer>\n </IndicatorLabelContainer>\n\n {removable && (\n <RemoveButton\n type=\"button\"\n $disabled={disabled}\n onClick={handleOnRemove}\n id={`${generatedId}-remove-button`}\n >\n Remove\n </RemoveButton>\n )}\n </HeaderContainer>\n );\n };\n\n const renderErrorList = (errors: string[]) => {\n return (\n <>\n <ErrorText weight=\"semibold\" $disabled={disabled}>\n Error\n </ErrorText>\n <ErrorList $disabled={disabled}>\n {errors?.map((item, index) => {\n return (\n <li\n key={index}\n id={`${generatedId}-error-list-item-${index}`}\n >\n <ErrorText\n weight=\"semibold\"\n $disabled={disabled}\n >\n {item}\n </ErrorText>\n </li>\n );\n })}\n </ErrorList>\n </>\n );\n };\n\n const renderError = () => {\n return (\n collapsible &&\n !expanded &&\n hasCompositeSectionError && (\n <ErrorContainer\n $disabled={disabled}\n onClick={handleExpandCollapseClick}\n id={`${generatedId}-error-alert`}\n >\n <AlertContainer\n type={disabled ? \"description\" : \"error\"}\n className={className}\n showIcon\n >\n {Array.isArray(errors)\n ? renderErrorList(errors)\n : errors}\n </AlertContainer>\n </ErrorContainer>\n )\n );\n };\n\n const renderCompositeSection = () => {\n return (\n compositeSectionChildren && (\n <div>\n {renderCompositeChildren()}\n {renderError()}\n {renderExpandButton()}\n </div>\n )\n );\n };\n\n return (\n <Container\n $selected={selected}\n $disabled={disabled}\n className={className}\n $styleType={styleType}\n $error={error}\n $indicator={indicator}\n $useContentWidth={useContentWidth}\n id={id}\n data-testid={testId}\n >\n {renderToggleWithRemoveButton()}\n {renderCompositeSection()}\n </Container>\n );\n};\n"],"names":["Toggle","_a","type","indicator","checked","styleType","children","childrenMaxLines","subLabel","disabled","error","name","id","className","compositeSection","removable","focusableWhenDisabled","useContentWidth","onRemove","onChange","testId","ariaDescribedBy","otherProps","__rest","collapsible","errors","compositeSectionChildren","initialExpanded","selected","setSelected","useState","expanded","setExpanded","hasCompositeSectionError","useMemo","hasErrorList","Array","isArray","length","hasErrorElement","uniqueId","useId","generatedId","inputRef","useRef","isFocusableWhenDisabled","isNativeDisabled","isInteractionBlocked","useEffect","handleOnChange","event","preventDefault","prevSelected","handleExpandCollapseClick","handleOnRemove","handleContainerClick","current","click","handleInputClick","e","stopPropagation","renderIndicator","toggleIconType","_jsx","StyledToggleIcon","active","$selected","$disabled","renderSubLabel","component","SubLabel","renderErrorList","_jsxs","_Fragment","ErrorText","weight","ErrorList","map","item","index","Container","$styleType","$indicator","$useContentWidth","ariaDescriptions","filter","Boolean","join","undefined","HeaderContainer","IndicatorLabelContainer","InputContainer","onClick","Input","ref","tabIndex","TextContainer","Label","htmlFor","$maxLines","RemoveButton","renderToggleWithRemoveButton","Children","$isFinalItem","ErrorContainer","AlertContainer","showIcon","ExpandButton","$paddingTopRequired","ChevronUpIcon","ChevronDownIcon"],"mappings":"s1BAyBO,MAAMA,EAAUC,QAAAC,KACnBA,EAAO,WAAUC,UACjBA,EAASC,QACTA,EAAOC,UACPA,EAAY,UAASC,SACrBA,EAAQC,iBACRA,EAAgBC,SAChBA,EAAQC,SACRA,EAAQC,MACRA,EAAKC,KACLA,EAAIC,GACJA,EAAEC,UACFA,EAASC,iBACTA,EAAgBC,UAChBA,EAASC,sBACTA,EAAqBC,gBACrBA,EAAeC,SACfA,EAAQC,SACRA,EACA,cAAeC,EACf,mBAAoBC,KACjBC,EAAUC,EAAAtB,EArBM,CAAA,OAAA,YAAA,UAAA,YAAA,WAAA,mBAAA,WAAA,WAAA,QAAA,OAAA,KAAA,YAAA,mBAAA,YAAA,wBAAA,kBAAA,WAAA,WAAA,cAAA,qBA0BnB,MAAMuB,YACFA,GAAc,EAAIC,OAClBA,EACAnB,SAAUoB,EAAwBC,gBAClCA,GACAb,GAAoB,CAAA,GACjBc,EAAUC,IAAeC,EAA8B1B,IACvD2B,GAAUC,IAAeF,IAAoBH,GAC9CM,GAA2BC,GAAQ,KACrC,MAAMC,EAAeC,MAAMC,QAAQZ,KAAWA,aAAM,EAANA,EAAQa,QAAS,EACzDC,GAAmBH,MAAMC,QAAQZ,MAAaA,EACpD,OAAOU,GAAgBI,CAAe,GACvC,CAACd,IACEe,GAAWC,IACXC,GAAc9B,EAAK,GAAGA,IAAO,MAAM4B,KAEnCG,GAAWC,EAAyB,MAEpCC,KAA4BpC,KAAcO,EAC1C8B,KAAqBrC,IAAaO,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EViB,IAiITF,IACCO,IACDE,IACI8B,EAACyC,EAAc,CAAArC,UACA1D,EACXmF,QAASvC,GACTzC,GAAI,GAAG8B,iBAAyBpC,SAEhCyD,EAAC0C,EAAc,CACXvG,KAAMO,EAAW,cAAgB,QACjCI,UAAWA,EACX6F,UAAQ,EAAApG,SAEP8B,MAAMC,QAAQZ,GACT8C,GAAgB9C,GAChBA,MAtIlBD,GACIgD,EAACmC,EAAY,CAAAC,qBAJW7E,KAAaE,GAMjCxB,SAAUA,EACVmF,QAASvC,GAAyB,cACrBtB,GAAW,kBAAoB,gBAAezB,SAAA,CAE1DyB,GAAW,YAAc,YAEtBgC,EADHhC,GACI8E,EAEAC,EAFa,CAAA,eAAA,YA8JlB"}
|
|
1
|
+
{"version":3,"file":"toggle.js","sources":["../../src/toggle/toggle.tsx"],"sourcesContent":["import { ChevronDownIcon } from \"@lifesg/react-icons/chevron-down\";\nimport { ChevronUpIcon } from \"@lifesg/react-icons/chevron-up\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { ToggleIconType } from \"../shared/toggle-icon/toggle-icon\";\nimport { useId } from \"../util\";\nimport {\n AlertContainer,\n Children,\n Container,\n ErrorContainer,\n ErrorList,\n ErrorText,\n ExpandButton,\n HeaderContainer,\n IndicatorLabelContainer,\n Input,\n InputContainer,\n Label,\n RemoveButton,\n StyledToggleIcon,\n SubLabel,\n TextContainer,\n} from \"./toggle.styles\";\nimport { ToggleProps } from \"./types\";\n\nexport const Toggle = ({\n type = \"checkbox\",\n indicator,\n checked,\n styleType = \"default\",\n children,\n childrenMaxLines,\n subLabel,\n disabled,\n error,\n name,\n id,\n className,\n compositeSection,\n removable,\n focusableWhenDisabled,\n useContentWidth,\n onRemove,\n onChange,\n \"data-testid\": testId,\n \"aria-describedby\": ariaDescribedBy,\n ...otherProps\n}: ToggleProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const {\n collapsible = true,\n errors,\n children: compositeSectionChildren,\n initialExpanded,\n } = compositeSection || {};\n const [selected, setSelected] = useState<boolean | undefined>(checked);\n const [expanded, setExpanded] = useState<boolean>(!!initialExpanded);\n const hasCompositeSectionError = useMemo(() => {\n const hasErrorList = Array.isArray(errors) && errors?.length > 0;\n const hasErrorElement = !Array.isArray(errors) && !!errors;\n return hasErrorList || hasErrorElement;\n }, [errors]);\n const uniqueId = useId();\n const generatedId = id ? `${id}` : `tg-${uniqueId}`;\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const isFocusableWhenDisabled = !!disabled && !!focusableWhenDisabled;\n const isNativeDisabled = !!disabled && !focusableWhenDisabled;\n const isInteractionBlocked = !!disabled;\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n setSelected(checked);\n }, [checked]);\n\n useEffect(() => {\n if (selected) {\n setExpanded(initialExpanded ?? true);\n }\n }, [selected]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (isInteractionBlocked) {\n event.preventDefault();\n return;\n }\n\n if (onChange) {\n onChange(event);\n return;\n }\n\n switch (type) {\n case \"checkbox\":\n setSelected((prevSelected) => {\n return !prevSelected;\n });\n break;\n case \"radio\":\n case \"yes\":\n case \"no\":\n if (!selected) {\n setSelected(true);\n }\n break;\n }\n };\n\n const handleExpandCollapseClick = () => {\n if (!disabled) {\n setExpanded(!expanded);\n }\n };\n\n const handleOnRemove = () => {\n if (!disabled) {\n if (onRemove) {\n onRemove();\n return;\n }\n }\n };\n\n const handleContainerClick = () => {\n inputRef?.current?.click();\n };\n\n const handleInputClick = (e: React.MouseEvent<HTMLInputElement>) => {\n e.stopPropagation();\n };\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderIndicator = () => {\n let toggleIconType: ToggleIconType;\n\n switch (type) {\n case \"yes\":\n toggleIconType = \"tick\";\n break;\n case \"no\":\n toggleIconType = \"cross\";\n break;\n case \"checkbox\":\n case \"radio\":\n toggleIconType = type;\n break;\n }\n\n return (\n <StyledToggleIcon\n type={toggleIconType}\n active={selected}\n disabled={disabled}\n $selected={selected}\n $disabled={disabled}\n $error={error}\n />\n );\n };\n\n const renderSubLabel = () => {\n if (!subLabel) {\n return null;\n }\n\n let component: string | JSX.Element;\n\n if (typeof subLabel === \"function\") {\n component = subLabel();\n } else {\n component = subLabel;\n }\n\n // Hide sublabel from screen readers as the main input already has aria-describedby that points to the sublabel\n return (\n <SubLabel\n data-id=\"toggle-sublabel\"\n id={`${generatedId}-sublabel`}\n aria-hidden\n >\n {component}\n </SubLabel>\n );\n };\n\n const renderCompositeChildren = () => {\n return (\n (!collapsible || expanded) && (\n <Children\n data-id=\"toggle-composite-children\"\n $isFinalItem={!collapsible}\n $disabled={disabled}\n >\n {compositeSectionChildren}\n </Children>\n )\n );\n };\n\n const renderExpandButton = () => {\n const collapsedWithoutErrors = !expanded && !hasCompositeSectionError;\n\n return (\n collapsible && (\n <ExpandButton\n $paddingTopRequired={collapsedWithoutErrors}\n disabled={disabled}\n onClick={handleExpandCollapseClick}\n data-testid={expanded ? \"collapse-button\" : \"expand-button\"}\n >\n {expanded ? \"Show less\" : \"Show more\"}\n {expanded ? (\n <ChevronUpIcon aria-hidden />\n ) : (\n <ChevronDownIcon aria-hidden />\n )}\n </ExpandButton>\n )\n );\n };\n\n const renderToggleWithRemoveButton = () => {\n const ariaDescriptions =\n [\n typeof subLabel === \"string\" ? `${generatedId}-sublabel` : null,\n ariaDescribedBy,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n return (\n <HeaderContainer\n id={`${generatedId}-header-container`}\n $disabled={disabled}\n $error={error}\n $selected={selected}\n $indicator={indicator}\n $styleType={styleType}\n >\n <IndicatorLabelContainer $addPadding={removable}>\n <InputContainer\n id={`${generatedId}-input-container`}\n onClick={handleContainerClick}\n >\n <Input\n ref={inputRef}\n name={name}\n id={`${generatedId}-input`}\n type={type === \"checkbox\" ? \"checkbox\" : \"radio\"}\n data-testid=\"toggle-input\"\n disabled={isNativeDisabled}\n aria-disabled={isFocusableWhenDisabled}\n $disabledVisual={disabled}\n onChange={handleOnChange}\n onClick={handleInputClick}\n checked={selected}\n tabIndex={isFocusableWhenDisabled ? 0 : undefined}\n aria-describedby={ariaDescriptions}\n {...otherProps}\n />\n {indicator && renderIndicator()}\n <TextContainer\n $selected={selected}\n $disabled={disabled}\n $error={error}\n >\n <Label\n htmlFor={`${generatedId}-input`}\n data-testid={`toggle-label`}\n id={`${generatedId}-label`}\n $maxLines={childrenMaxLines}\n $selected={selected}\n >\n {children}\n </Label>\n {subLabel && renderSubLabel()}\n </TextContainer>\n </InputContainer>\n </IndicatorLabelContainer>\n\n {removable && (\n <RemoveButton\n type=\"button\"\n $disabled={disabled}\n onClick={handleOnRemove}\n id={`${generatedId}-remove-button`}\n >\n Remove\n </RemoveButton>\n )}\n </HeaderContainer>\n );\n };\n\n const renderErrorList = (errors: string[]) => {\n return (\n <>\n <ErrorText weight=\"semibold\" $disabled={disabled}>\n Error\n </ErrorText>\n <ErrorList $disabled={disabled}>\n {errors?.map((item, index) => {\n return (\n <li\n key={index}\n id={`${generatedId}-error-list-item-${index}`}\n >\n <ErrorText\n weight=\"semibold\"\n $disabled={disabled}\n >\n {item}\n </ErrorText>\n </li>\n );\n })}\n </ErrorList>\n </>\n );\n };\n\n const renderError = () => {\n return (\n collapsible &&\n !expanded &&\n hasCompositeSectionError && (\n <ErrorContainer\n $disabled={disabled}\n onClick={handleExpandCollapseClick}\n id={`${generatedId}-error-alert`}\n >\n <AlertContainer\n type={disabled ? \"description\" : \"error\"}\n className={className}\n showIcon\n >\n {Array.isArray(errors)\n ? renderErrorList(errors)\n : errors}\n </AlertContainer>\n </ErrorContainer>\n )\n );\n };\n\n const renderCompositeSection = () => {\n return (\n compositeSectionChildren && (\n <div>\n {renderCompositeChildren()}\n {renderError()}\n {renderExpandButton()}\n </div>\n )\n );\n };\n\n return (\n <Container\n $selected={selected}\n $disabled={disabled}\n className={className}\n $styleType={styleType}\n $error={error}\n $indicator={indicator}\n $useContentWidth={useContentWidth}\n id={id}\n data-testid={testId}\n >\n {renderToggleWithRemoveButton()}\n {renderCompositeSection()}\n </Container>\n );\n};\n"],"names":["Toggle","_a","type","indicator","checked","styleType","children","childrenMaxLines","subLabel","disabled","error","name","id","className","compositeSection","removable","focusableWhenDisabled","useContentWidth","onRemove","onChange","testId","ariaDescribedBy","otherProps","__rest","collapsible","errors","compositeSectionChildren","initialExpanded","selected","setSelected","useState","expanded","setExpanded","hasCompositeSectionError","useMemo","hasErrorList","Array","isArray","length","hasErrorElement","uniqueId","useId","generatedId","inputRef","useRef","isFocusableWhenDisabled","isNativeDisabled","isInteractionBlocked","useEffect","handleOnChange","event","preventDefault","prevSelected","handleExpandCollapseClick","handleOnRemove","handleContainerClick","current","click","handleInputClick","e","stopPropagation","renderIndicator","toggleIconType","_jsx","StyledToggleIcon","active","$selected","$disabled","$error","renderSubLabel","component","SubLabel","renderErrorList","_jsxs","_Fragment","ErrorText","weight","ErrorList","map","item","index","Container","$styleType","$indicator","$useContentWidth","ariaDescriptions","filter","Boolean","join","undefined","HeaderContainer","IndicatorLabelContainer","InputContainer","onClick","Input","ref","$disabledVisual","tabIndex","TextContainer","Label","htmlFor","$maxLines","RemoveButton","renderToggleWithRemoveButton","Children","$isFinalItem","ErrorContainer","AlertContainer","showIcon","ExpandButton","$paddingTopRequired","ChevronUpIcon","ChevronDownIcon"],"mappings":"s1BAyBO,MAAMA,EAAUC,QAAAC,KACnBA,EAAO,WAAUC,UACjBA,EAASC,QACTA,EAAOC,UACPA,EAAY,UAASC,SACrBA,EAAQC,iBACRA,EAAgBC,SAChBA,EAAQC,SACRA,EAAQC,MACRA,EAAKC,KACLA,EAAIC,GACJA,EAAEC,UACFA,EAASC,iBACTA,EAAgBC,UAChBA,EAASC,sBACTA,EAAqBC,gBACrBA,EAAeC,SACfA,EAAQC,SACRA,EACA,cAAeC,EACf,mBAAoBC,KACjBC,EAAUC,EAAAtB,EArBM,CAAA,OAAA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Ae,aAATA,EAAsB,WAAa,sBAC7B,eACZO,SAAUqC,mBACKD,GAAuBmD,gBACrBvF,EACjBU,SAAU8B,GACV4C,QAASnC,GACTtD,QAASwB,EACTqE,SAAUpD,GAA0B,OAAI4C,EAAS,mBAC/BJ,GACd/D,IAEPnB,GAAa0D,KACdY,EAACyB,EAAa,CAAAhC,UACCtC,YACAnB,EAAQ2D,OACX1D,EAAKJ,SAAA,CAEbyD,EAACoC,EAAK,CACFC,QAAS,GAAG1D,WAAmB,cAClB,eACb9B,GAAI,GAAG8B,WAAmB2D,UACf9F,YACAqB,EAAQtB,SAElBA,IAEJE,GAAY6D,aAKxBtD,GACGgD,EAACuC,EAAY,CACTpG,KAAK,mBACMO,EACXoF,QAASvC,GACT1C,GAAI,GAAG8B,yCAKD,EA+EjB6D,GAtBD7E,GACI+C,EAAA,MAAA,CAAAnE,SAAA,GAjKFkB,GAAeO,KACbgC,EAACyC,aACW,4BAA2BC,cACpBjF,EAAW2C,UACf1D,WAEViB,IAkITF,IACCO,IACDE,IACI8B,EAAC2C,EAAc,CAAAvC,UACA1D,EACXoF,QAASxC,GACTzC,GAAI,GAAG8B,iBAAyBpC,SAEhCyD,EAAC4C,EAAc,CACXzG,KAAMO,EAAW,cAAgB,QACjCI,UAAWA,EACX+F,UAAQ,EAAAtG,SAEP8B,MAAMC,QAAQZ,GACT+C,GAAgB/C,GAChBA,MAvIlBD,GACIiD,EAACoC,EAAY,CAAAC,qBAJW/E,KAAaE,GAMjCxB,SAAUA,EACVoF,QAASxC,GAAyB,cACrBtB,GAAW,kBAAoB,gBAAezB,SAAA,CAE1DyB,GAAW,YAAc,YAEtBgC,EADHhC,GACIgF,EAEAC,EAFa,CAAA,eAAA,YA+JlB"}
|
package/toggle/toggle.styles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e,{css as
|
|
1
|
+
import e,{css as r}from"styled-components";import{Alert as o}from"../alert/alert.js";import{applyHtmlContentStyle as d}from"../shared/html-content/html-content.js";import{ToggleIcon as t}from"../shared/toggle-icon/toggle-icon.js";import{TextList as i}from"../text-list/index.js";import{Radius as l,Colour as n,Font as a,MediaQuery as s}from"../theme/index.js";import{Typography as b}from"../typography/typography.js";const c=e.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
min-width: 10.375rem;
|
|
@@ -15,32 +15,41 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
15
15
|
outline-offset: 0;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
${e=>{if(!e.$indicator)return
|
|
18
|
+
${e=>{if(!e.$indicator)return r`
|
|
19
19
|
justify-content: center;
|
|
20
20
|
`}}
|
|
21
21
|
|
|
22
22
|
// Container min width to fit content
|
|
23
|
-
${e=>{if(e.$useContentWidth)return
|
|
23
|
+
${e=>{if(e.$useContentWidth)return r`
|
|
24
24
|
min-width: unset;
|
|
25
25
|
`}}
|
|
26
26
|
|
|
27
27
|
// apply container border and header background color
|
|
28
|
-
${e=>"no-border"===e.$styleType?e.$error?e.$disabled?
|
|
29
|
-
border-color: ${n["border-error"]};
|
|
30
|
-
`:o`
|
|
28
|
+
${e=>"no-border"===e.$styleType?e.$error?e.$disabled?r`
|
|
31
29
|
border-color: ${n["border-error"]};
|
|
30
|
+
`:e.$selected?r`
|
|
31
|
+
border-color: transparent;
|
|
32
|
+
background: ${n["bg-error"]};
|
|
32
33
|
|
|
33
34
|
&:has(${h}:hover) {
|
|
34
35
|
@media (pointer: fine) {
|
|
35
|
-
background: ${n["bg-hover
|
|
36
|
+
background: ${n["bg-error-hover"]};
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
`:
|
|
39
|
+
`:r`
|
|
40
|
+
border-color: ${n["border-error"]};
|
|
41
|
+
|
|
42
|
+
&:has(${h}:hover) {
|
|
43
|
+
@media (pointer: fine) {
|
|
44
|
+
background: ${n["bg-hover-subtle"]};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`:e.$disabled?e.$selected?r`
|
|
39
48
|
border: none;
|
|
40
49
|
background: ${n["bg-selected-disabled"]};
|
|
41
|
-
`:
|
|
50
|
+
`:r`
|
|
42
51
|
border: none;
|
|
43
|
-
`:e.$selected?
|
|
52
|
+
`:e.$selected?r`
|
|
44
53
|
border: none;
|
|
45
54
|
background: ${n["bg-selected"]};
|
|
46
55
|
|
|
@@ -57,7 +66,7 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
|
-
`:
|
|
69
|
+
`:r`
|
|
61
70
|
border: none;
|
|
62
71
|
|
|
63
72
|
&:has(${h}:hover) {
|
|
@@ -65,23 +74,32 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
65
74
|
background: ${n["bg-hover-subtle"]};
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
|
-
`:e.$error?e.$disabled?
|
|
77
|
+
`:e.$error?e.$disabled?r`
|
|
69
78
|
border-color: ${n["border-error"]};
|
|
70
|
-
`:
|
|
79
|
+
`:e.$selected?r`
|
|
71
80
|
border-color: ${n["border-error"]};
|
|
81
|
+
background: ${n["bg-error"]};
|
|
72
82
|
|
|
73
83
|
&:has(${h}:hover) {
|
|
74
84
|
@media (pointer: fine) {
|
|
75
|
-
background: ${n["bg-hover
|
|
85
|
+
background: ${n["bg-error-hover"]};
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
|
-
`:
|
|
88
|
+
`:r`
|
|
89
|
+
border-color: ${n["border-error"]};
|
|
90
|
+
|
|
91
|
+
&:has(${h}:hover) {
|
|
92
|
+
@media (pointer: fine) {
|
|
93
|
+
background: ${n["bg-hover-subtle"]};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`:e.$disabled?e.$selected?r`
|
|
79
97
|
border-color: ${n["border-selected-disabled"]};
|
|
80
98
|
background: ${n["bg-selected-disabled"]};
|
|
81
|
-
`:
|
|
99
|
+
`:r`
|
|
82
100
|
border-color: ${n["border-disabled"]};
|
|
83
101
|
background: ${n["bg-disabled"]};
|
|
84
|
-
`:e.$selected?
|
|
102
|
+
`:e.$selected?r`
|
|
85
103
|
border-color: ${n["border-selected"]};
|
|
86
104
|
background: ${n["bg-selected"]};
|
|
87
105
|
|
|
@@ -98,7 +116,7 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
98
116
|
}
|
|
99
117
|
}
|
|
100
118
|
}
|
|
101
|
-
`:
|
|
119
|
+
`:r`
|
|
102
120
|
border-color: ${n.border};
|
|
103
121
|
|
|
104
122
|
&:has(${h}:hover) {
|
|
@@ -130,30 +148,32 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
130
148
|
overflow: hidden;
|
|
131
149
|
|
|
132
150
|
// apply header container text color
|
|
133
|
-
${e=>e.$
|
|
151
|
+
${e=>e.$selected?e.$disabled?r`
|
|
134
152
|
color: ${n["text-selected-disabled"]};
|
|
135
|
-
`:
|
|
136
|
-
color: ${n["text-
|
|
137
|
-
`:
|
|
153
|
+
`:e.$error?r`
|
|
154
|
+
color: ${n["text-error"]};
|
|
155
|
+
`:r`
|
|
138
156
|
color: ${n["text-selected"]};
|
|
139
|
-
`:
|
|
157
|
+
`:e.$disabled?r`
|
|
158
|
+
color: ${n["text-disabled"]};
|
|
159
|
+
`:r`
|
|
140
160
|
color: ${n.text};
|
|
141
161
|
`}
|
|
142
|
-
`,
|
|
162
|
+
`,g=e.label`
|
|
143
163
|
${e=>e.$selected?a["body-baseline-semibold"]:a["body-baseline-regular"]};
|
|
144
164
|
overflow: hidden;
|
|
145
165
|
display: -webkit-box;
|
|
146
166
|
text-overflow: ellipsis;
|
|
147
167
|
-webkit-box-orient: vertical;
|
|
148
168
|
overflow-wrap: break-word;
|
|
149
|
-
-webkit-line-clamp: ${e=>{var o
|
|
169
|
+
-webkit-line-clamp: ${e=>{var r,o;return null!==(o=null===(r=e.$maxLines)||void 0===r?void 0:r.desktop)&&void 0!==o?o:"none"}};
|
|
150
170
|
${s.MaxWidth.lg} {
|
|
151
|
-
-webkit-line-clamp: ${e=>{var o
|
|
171
|
+
-webkit-line-clamp: ${e=>{var r,o;return null!==(o=null===(r=e.$maxLines)||void 0===r?void 0:r.tablet)&&void 0!==o?o:"none"}};
|
|
152
172
|
}
|
|
153
173
|
${s.MaxWidth.sm} {
|
|
154
|
-
-webkit-line-clamp: ${e=>{var o
|
|
174
|
+
-webkit-line-clamp: ${e=>{var r,o;return null!==(o=null===(r=e.$maxLines)||void 0===r?void 0:r.mobile)&&void 0!==o?o:"none"}};
|
|
155
175
|
}
|
|
156
|
-
`,
|
|
176
|
+
`,u=e.div`
|
|
157
177
|
${a["body-md-regular"]}
|
|
158
178
|
margin-top: 0.5rem;
|
|
159
179
|
|
|
@@ -174,7 +194,7 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
174
194
|
width: 100%;
|
|
175
195
|
position: relative;
|
|
176
196
|
padding: ${e=>e.$addPadding?"0.6875rem 0rem 0.6875rem 1rem":"0.6875rem 1rem"};
|
|
177
|
-
`,
|
|
197
|
+
`,f=e.button`
|
|
178
198
|
color: ${e=>e.$disabled?n["text-disabled"]:n["text-error"]};
|
|
179
199
|
white-space: nowrap;
|
|
180
200
|
${a["body-md-semibold"]}
|
|
@@ -184,7 +204,7 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
184
204
|
background: none;
|
|
185
205
|
|
|
186
206
|
cursor: ${e=>e.$disabled?"not-allowed":"pointer"};
|
|
187
|
-
`,
|
|
207
|
+
`,x=e.button`
|
|
188
208
|
color: ${e=>e.disabled?n["text-disabled"]:n["text-primary"]};
|
|
189
209
|
${a["body-baseline-semibold"]}
|
|
190
210
|
display: flex;
|
|
@@ -209,36 +229,38 @@ import e,{css as o}from"styled-components";import{Alert as r}from"../alert/alert
|
|
|
209
229
|
background: ${n.bg};
|
|
210
230
|
cursor: ${e=>e.$disabled?"not-allowed":"pointer"};
|
|
211
231
|
padding: 0.6875rem 1rem 0.5rem 1rem;
|
|
212
|
-
`,
|
|
232
|
+
`,k=e(o)`
|
|
213
233
|
width: 100%;
|
|
214
234
|
user-select: none;
|
|
215
|
-
`,
|
|
235
|
+
`,y=e.div`
|
|
216
236
|
padding: 0 1rem;
|
|
217
237
|
padding-top: 0.6875rem;
|
|
218
238
|
padding-bottom: ${e=>e.$isFinalItem?"0.6875rem":"0.5rem"};
|
|
219
239
|
background-color: ${n.bg};
|
|
220
240
|
${d({textSize:"body-md"})}
|
|
221
241
|
|
|
222
|
-
${e=>e.$disabled?
|
|
242
|
+
${e=>e.$disabled?r`
|
|
223
243
|
color: ${n["text-disabled"]};
|
|
224
|
-
`:e.$selected?
|
|
244
|
+
`:e.$selected?r`
|
|
225
245
|
color: ${n["text-selected"]};
|
|
226
|
-
`:
|
|
227
|
-
|
|
228
|
-
|
|
246
|
+
`:r`
|
|
247
|
+
color: ${n.text};
|
|
248
|
+
`}
|
|
229
249
|
`,j=e(b.BodyMD)`
|
|
230
250
|
color: ${e=>e.$disabled?n["text-disabled"]:n["text-error"]};
|
|
231
251
|
`,L=e(i.Ul)`
|
|
232
252
|
color: ${e=>e.$disabled?n["text-disabled"]:n["text-error"]};
|
|
233
253
|
`,M=e(t)`
|
|
234
|
-
${e=>e.$
|
|
254
|
+
${e=>e.$selected?e.$disabled?r`
|
|
235
255
|
color: ${n["icon-selected-disabled"]};
|
|
236
|
-
`:
|
|
237
|
-
color: ${n["icon-
|
|
238
|
-
`:
|
|
256
|
+
`:e.$error?r`
|
|
257
|
+
color: ${n["icon-error-strong"]};
|
|
258
|
+
`:r`
|
|
239
259
|
color: ${n["icon-selected"]};
|
|
240
|
-
`:
|
|
260
|
+
`:e.$disabled?r`
|
|
261
|
+
color: ${n["icon-disabled-subtle"]};
|
|
262
|
+
`:r`
|
|
241
263
|
color: ${n["icon-subtle"]};
|
|
242
264
|
`};
|
|
243
|
-
`;export{
|
|
265
|
+
`;export{k as AlertContainer,y as Children,c as Container,w as ErrorContainer,L as ErrorList,j as ErrorText,x as ExpandButton,h as HeaderContainer,v as IndicatorLabelContainer,$ as Input,m as InputContainer,g as Label,f as RemoveButton,M as StyledToggleIcon,u as SubLabel,p as TextContainer};
|
|
244
266
|
//# sourceMappingURL=toggle.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.styles.js","sources":["../../src/toggle/toggle.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Alert } from \"../alert\";\nimport { applyHtmlContentStyle } from \"../shared/html-content/html-content\";\nimport { ToggleIcon } from \"../shared/toggle-icon/toggle-icon\";\nimport { TextList } from \"../text-list\";\nimport { Colour, Font, MediaQuery, Radius } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { ToggleStyleType } from \"./types\";\n\n// =============================================================================\n// STYLE INTERFACES, transient props are denoted with $\n// See more https://styled-components.com/docs/api#transient-props\n// =============================================================================\ninterface StyleProps {\n $selected?: boolean;\n $disabled?: boolean;\n $indicator?: boolean;\n}\n\ninterface ContainerStyleProps extends StyleProps {\n $styleType?: ToggleStyleType;\n $error?: boolean;\n $useContentWidth?: boolean;\n}\n\ninterface IndicatorLabelContainerStyleProps {\n $addPadding?: boolean;\n}\n\ninterface LabelStyleProps {\n $maxLines?: { desktop?: number; mobile?: number; tablet?: number };\n}\n\ninterface ExpandButtonStyleProps extends StyleProps {\n $paddingTopRequired?: boolean;\n}\n\ninterface ChildrenStyleProps extends StyleProps {\n $isFinalItem?: boolean;\n}\n\ninterface InteractiveStyleProps {\n $disabledVisual?: boolean;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\n\nexport const Container = styled.div<ContainerStyleProps>`\n position: relative;\n display: inline-flex;\n min-width: 10.375rem;\n border-radius: ${Radius[\"sm\"]};\n border-width: 1px;\n border-style: solid;\n overflow: hidden;\n flex-direction: column;\n height: fit-content;\n background: ${Colour.bg};\n\n &:has(input:focus-visible) {\n outline: 2px solid ${Colour[\"focus-ring\"]};\n outline-offset: 0;\n }\n\n ${(props) => {\n if (!props.$indicator) {\n return css`\n justify-content: center;\n `;\n }\n }}\n\n // Container min width to fit content\n ${(props) => {\n if (props.$useContentWidth) {\n return css`\n min-width: unset;\n `;\n }\n }}\n\n // apply container border and header background color\n ${(props) => {\n switch (props.$styleType) {\n case \"no-border\": {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border: none;\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border: none;\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n default: {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected-disabled\"]};\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-disabled\"]};\n background: ${Colour[\"bg-disabled\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected\"]};\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour.border};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n }}\n`;\n\nexport const Input = styled.input<InteractiveStyleProps>`\n position: absolute;\n height: 100%;\n width: 100%;\n cursor: ${(props) => (props.$disabledVisual ? \"not-allowed\" : \"pointer\")};\n top: 0;\n left: 0;\n opacity: 0;\n\n /* Hide appearance but keep it focusable using keyboard interactions */\n appearance: none;\n background: transparent;\n border: none;\n`;\n\nexport const InputContainer = styled.div`\n display: flex;\n`;\n\nexport const TextContainer = styled.div<StyleProps>`\n display: flex;\n flex-direction: column;\n overflow-wrap: anywhere;\n width: 100%;\n overflow: hidden;\n\n // apply header container text color\n ${(props) => {\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected-disabled\"]};\n `;\n } else {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n }\n\n return css`\n color: ${Colour.text};\n `;\n }}\n`;\n\nexport const Label = styled.label<LabelStyleProps & { $selected?: boolean }>`\n ${(props) =>\n props.$selected\n ? Font[\"body-baseline-semibold\"]\n : Font[\"body-baseline-regular\"]};\n overflow: hidden;\n display: -webkit-box;\n text-overflow: ellipsis;\n -webkit-box-orient: vertical;\n overflow-wrap: break-word;\n -webkit-line-clamp: ${(props) => props.$maxLines?.desktop ?? \"none\"};\n ${MediaQuery.MaxWidth.lg} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.tablet ?? \"none\"};\n }\n ${MediaQuery.MaxWidth.sm} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.mobile ?? \"none\"};\n }\n`;\n\nexport const SubLabel = styled.div`\n ${Font[\"body-md-regular\"]}\n margin-top: 0.5rem;\n\n z-index: 1; // forces sublabel to render above the input\n pointer-events: none; // to allow click events to be passed to the input\n\n strong,\n b {\n ${Font[\"body-md-semibold\"]}\n }\n`;\n\nexport const HeaderContainer = styled.div<ContainerStyleProps>`\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n`;\n\nexport const IndicatorLabelContainer = styled.div<IndicatorLabelContainerStyleProps>`\n display: flex;\n height: 100%;\n width: 100%;\n position: relative;\n padding: ${(props) =>\n props.$addPadding ? \"0.6875rem 0rem 0.6875rem 1rem\" : \"0.6875rem 1rem\"};\n`;\n\nexport const RemoveButton = styled.button<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n white-space: nowrap;\n ${Font[\"body-md-semibold\"]}\n height: fit-content;\n padding: 0.6875rem 1rem 0.6875rem 0.5rem;\n border: none;\n background: none;\n\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n`;\n\nexport const ExpandButton = styled.button<ExpandButtonStyleProps>`\n color: ${(props) =>\n props.disabled ? Colour[\"text-disabled\"] : Colour[\"text-primary\"]};\n ${Font[\"body-baseline-semibold\"]}\n display: flex;\n align-items: center;\n justify-content: flex-end;\n border: none;\n background-color: ${Colour.bg};\n cursor: ${(props) => (props.disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0 1rem 0.6875rem 1rem;\n padding-top: ${(props) =>\n props.$paddingTopRequired ? \"0.6875rem\" : \"0rem\"};\n width: 100%;\n\n svg {\n width: 1em;\n height: 1em;\n margin-left: 0.5rem;\n }\n`;\n\nexport const ErrorContainer = styled.div<StyleProps>`\n width: 100%;\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n border: none;\n background: ${Colour.bg};\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0.6875rem 1rem 0.5rem 1rem;\n`;\n\nexport const AlertContainer = styled(Alert)`\n width: 100%;\n user-select: none;\n`;\n\nexport const Children = styled.div<ChildrenStyleProps>`\n padding: 0 1rem;\n padding-top: 0.6875rem;\n padding-bottom: ${(props) => (props.$isFinalItem ? \"0.6875rem\" : \"0.5rem\")};\n background-color: ${Colour.bg};\n ${applyHtmlContentStyle({ textSize: \"body-md\" })}\n\n ${(props) => {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n } else if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n } else {\n return css`\n color: ${Colour.text};\n `;\n }\n }}\n`;\n\nexport const ErrorText = styled(Typography.BodyMD)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const ErrorList = styled(TextList.Ul)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const StyledToggleIcon = styled(ToggleIcon)<StyleProps>`\n ${(props) => {\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n color: ${Colour[\"icon-selected-disabled\"]};\n `;\n } else {\n return css`\n color: ${Colour[\"icon-disabled-subtle\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n color: ${Colour[\"icon-selected\"]};\n `;\n }\n return css`\n color: ${Colour[\"icon-subtle\"]};\n `;\n }};\n`;\n"],"names":["Container","styled","div","Radius","Colour","bg","props","$indicator","css","$useContentWidth","$styleType","$error","$disabled","HeaderContainer","$selected","TextContainer","StyledToggleIcon","border","Input","input","$disabledVisual","InputContainer","text","Label","label","Font","_a","_b","$maxLines","desktop","MediaQuery","MaxWidth","lg","tablet","sm","mobile","SubLabel","IndicatorLabelContainer","$addPadding","RemoveButton","button","ExpandButton","disabled","$paddingTopRequired","ErrorContainer","AlertContainer","Alert","Children","$isFinalItem","applyHtmlContentStyle","textSize","ErrorText","Typography","BodyMD","ErrorList","TextList","Ul","ToggleIcon"],"mappings":"iaAiDO,MAAMA,EAAYC,EAAOC,GAAwB;;;;qBAInCC,EAAW;;;;;;kBAMdC,EAAOC;;;6BAGID,EAAO;;;;MAI7BE,IACC,IAAKA,EAAMC,WACP,OAAOC,CAAG;;aAGd;;;MAIDF,IACC,GAAIA,EAAMG,iBACN,OAAOD,CAAG;;aAGd;;;MAIDF,GAEU,cADDA,EAAMI,WAEFJ,EAAMK,OACFL,EAAMM,UACCJ,CAAG;4CACUJ,EAAO;0BAGpBI,CAAG;4CACUJ,EAAO;;oCAEfS;;kDAEcT,EAAO;;;0BAOrCE,EAAMM,UACFN,EAAMQ,UACCN,CAAG;;0CAEQJ,EAAO;0BAGlBI,CAAG;;0BAMdF,EAAMQ,UACCN,CAAG;;sCAEQJ,EAAO;;gCAEbS;;8CAEcT,EAAO;;oCAEjBW;6CACSX,EAAO;;;oCAGhBY;6CACSZ,EAAO;;;;sBAO7BI,CAAG;;;4BAGEK;;0CAEcT,EAAO;;;kBAO7BE,EAAMK,OACFL,EAAMM,UACCJ,CAAG;4CACUJ,EAAO;0BAGpBI,CAAG;4CACUJ,EAAO;;oCAEfS;;kDAEcT,EAAO;;;0BAOrCE,EAAMM,UACFN,EAAMQ,UACCN,CAAG;4CACUJ,EAAO;0CACTA,EAAO;0BAGlBI,CAAG;4CACUJ,EAAO;0CACTA,EAAO;0BAK7BE,EAAMQ,UACCN,CAAG;wCACUJ,EAAO;sCACTA,EAAO;;gCAEbS;;8CAEcT,EAAO;;oCAEjBW;6CACSX,EAAO;;;oCAGhBY;6CACSZ,EAAO;;;;sBAO7BI,CAAG;oCACUJ,EAAOa;;4BAEfJ;;0CAEcT,EAAO;;;;EASpCc,EAAQjB,EAAOkB,KAA4B;;;;cAIzCb,GA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,EAAO,iBAAmBA,EAAO;MACpDqB,EAAK;;;;;wBAKarB,EAAOC;cAChBC,GAAWA,EAAMoC,SAAW,cAAgB;;mBAEvCpC,GACZA,EAAMqC,oBAAsB,YAAc;;;;;;;;EAUrCC,EAAiB3C,EAAOC,GAAe;;aAEtCI,GACNA,EAAMM,UAAYR,EAAO,iBAAmBA,EAAO;;kBAEzCA,EAAOC;cACVC,GAAWA,EAAMM,UAAY,cAAgB;;EAI/CiC,EAAiB5C,EAAO6C,EAAM;;;EAK9BC,EAAW9C,EAAOC,GAAuB;;;sBAG/BI,GAAWA,EAAM0C,aAAe,YAAc;wBAC7C5C,EAAOC;MACzB4C,EAAsB,CAAEC,SAAU;;MAEjC5C,GACKA,EAAMM,UACCJ,CAAG;yBACGJ,EAAO;cAEbE,EAAMQ,UACNN,CAAG;yBACGJ,EAAO;cAGbI,CAAG;yBACGJ,EAAOkB;;EAMnB6B,EAAYlD,EAAOmD,EAAWC,OAAmB;aAChD/C,GACNA,EAAMM,UAAYR,EAAO,iBAAmBA,EAAO;EAG9CkD,EAAYrD,EAAOsD,EAASC,GAAe;aAC1ClD,GACNA,EAAMM,UAAYR,EAAO,iBAAmBA,EAAO;EAG9CY,EAAmBf,EAAOwD,EAAuB;MACvDnD,GACKA,EAAMM,UACFN,EAAMQ,UACCN,CAAG;6BACGJ,EAAO;kBAGbI,CAAG;6BACGJ,EAAO;kBAKxBE,EAAMQ,UACCN,CAAG;yBACGJ,EAAO;cAGjBI,CAAG;qBACGJ,EAAO;;"}
|
|
1
|
+
{"version":3,"file":"toggle.styles.js","sources":["../../src/toggle/toggle.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Alert } from \"../alert\";\nimport { applyHtmlContentStyle } from \"../shared/html-content/html-content\";\nimport { ToggleIcon } from \"../shared/toggle-icon/toggle-icon\";\nimport { TextList } from \"../text-list\";\nimport { Colour, Font, MediaQuery, Radius } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { ToggleStyleType } from \"./types\";\n\n// =============================================================================\n// STYLE INTERFACES, transient props are denoted with $\n// See more https://styled-components.com/docs/api#transient-props\n// =============================================================================\ninterface StyleProps {\n $error?: boolean;\n $selected?: boolean;\n $disabled?: boolean;\n $indicator?: boolean;\n}\n\ninterface ContainerStyleProps extends StyleProps {\n $styleType?: ToggleStyleType;\n $error?: boolean;\n $useContentWidth?: boolean;\n}\n\ninterface IndicatorLabelContainerStyleProps {\n $addPadding?: boolean;\n}\n\ninterface LabelStyleProps {\n $maxLines?: { desktop?: number; mobile?: number; tablet?: number };\n}\n\ninterface ExpandButtonStyleProps extends StyleProps {\n $paddingTopRequired?: boolean;\n}\n\ninterface ChildrenStyleProps extends StyleProps {\n $isFinalItem?: boolean;\n}\n\ninterface InteractiveStyleProps {\n $disabledVisual?: boolean;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\n\nexport const Container = styled.div<ContainerStyleProps>`\n position: relative;\n display: inline-flex;\n min-width: 10.375rem;\n border-radius: ${Radius[\"sm\"]};\n border-width: 1px;\n border-style: solid;\n overflow: hidden;\n flex-direction: column;\n height: fit-content;\n background: ${Colour.bg};\n\n &:has(input:focus-visible) {\n outline: 2px solid ${Colour[\"focus-ring\"]};\n outline-offset: 0;\n }\n\n ${(props) => {\n if (!props.$indicator) {\n return css`\n justify-content: center;\n `;\n }\n }}\n\n // Container min width to fit content\n ${(props) => {\n if (props.$useContentWidth) {\n return css`\n min-width: unset;\n `;\n }\n }}\n\n // apply container border and header background color\n ${(props) => {\n switch (props.$styleType) {\n case \"no-border\": {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n }\n\n if (props.$selected) {\n return css`\n border-color: transparent;\n background: ${Colour[\"bg-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-error-hover\"]};\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border: none;\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border: none;\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n default: {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n }\n\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n background: ${Colour[\"bg-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-error-hover\"]};\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected-disabled\"]};\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-disabled\"]};\n background: ${Colour[\"bg-disabled\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected\"]};\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour.border};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n }}\n`;\n\nexport const Input = styled.input<InteractiveStyleProps>`\n position: absolute;\n height: 100%;\n width: 100%;\n cursor: ${(props) => (props.$disabledVisual ? \"not-allowed\" : \"pointer\")};\n top: 0;\n left: 0;\n opacity: 0;\n\n /* Hide appearance but keep it focusable using keyboard interactions */\n appearance: none;\n background: transparent;\n border: none;\n`;\n\nexport const InputContainer = styled.div`\n display: flex;\n`;\n\nexport const TextContainer = styled.div<StyleProps>`\n display: flex;\n flex-direction: column;\n overflow-wrap: anywhere;\n width: 100%;\n overflow: hidden;\n\n // apply header container text color\n ${(props) => {\n if (props.$selected) {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-selected-disabled\"]};\n `;\n }\n\n if (props.$error) {\n return css`\n color: ${Colour[\"text-error\"]};\n `;\n }\n\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n }\n\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n\n return css`\n color: ${Colour.text};\n `;\n }}\n`;\n\nexport const Label = styled.label<LabelStyleProps & { $selected?: boolean }>`\n ${(props) =>\n props.$selected\n ? Font[\"body-baseline-semibold\"]\n : Font[\"body-baseline-regular\"]};\n overflow: hidden;\n display: -webkit-box;\n text-overflow: ellipsis;\n -webkit-box-orient: vertical;\n overflow-wrap: break-word;\n -webkit-line-clamp: ${(props) => props.$maxLines?.desktop ?? \"none\"};\n ${MediaQuery.MaxWidth.lg} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.tablet ?? \"none\"};\n }\n ${MediaQuery.MaxWidth.sm} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.mobile ?? \"none\"};\n }\n`;\n\nexport const SubLabel = styled.div`\n ${Font[\"body-md-regular\"]}\n margin-top: 0.5rem;\n\n z-index: 1; // forces sublabel to render above the input\n pointer-events: none; // to allow click events to be passed to the input\n\n strong,\n b {\n ${Font[\"body-md-semibold\"]}\n }\n`;\n\nexport const HeaderContainer = styled.div<ContainerStyleProps>`\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n`;\n\nexport const IndicatorLabelContainer = styled.div<IndicatorLabelContainerStyleProps>`\n display: flex;\n height: 100%;\n width: 100%;\n position: relative;\n padding: ${(props) =>\n props.$addPadding ? \"0.6875rem 0rem 0.6875rem 1rem\" : \"0.6875rem 1rem\"};\n`;\n\nexport const RemoveButton = styled.button<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n white-space: nowrap;\n ${Font[\"body-md-semibold\"]}\n height: fit-content;\n padding: 0.6875rem 1rem 0.6875rem 0.5rem;\n border: none;\n background: none;\n\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n`;\n\nexport const ExpandButton = styled.button<ExpandButtonStyleProps>`\n color: ${(props) =>\n props.disabled ? Colour[\"text-disabled\"] : Colour[\"text-primary\"]};\n ${Font[\"body-baseline-semibold\"]}\n display: flex;\n align-items: center;\n justify-content: flex-end;\n border: none;\n background-color: ${Colour.bg};\n cursor: ${(props) => (props.disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0 1rem 0.6875rem 1rem;\n padding-top: ${(props) =>\n props.$paddingTopRequired ? \"0.6875rem\" : \"0rem\"};\n width: 100%;\n\n svg {\n width: 1em;\n height: 1em;\n margin-left: 0.5rem;\n }\n`;\n\nexport const ErrorContainer = styled.div<StyleProps>`\n width: 100%;\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n border: none;\n background: ${Colour.bg};\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0.6875rem 1rem 0.5rem 1rem;\n`;\n\nexport const AlertContainer = styled(Alert)`\n width: 100%;\n user-select: none;\n`;\n\nexport const Children = styled.div<ChildrenStyleProps>`\n padding: 0 1rem;\n padding-top: 0.6875rem;\n padding-bottom: ${(props) => (props.$isFinalItem ? \"0.6875rem\" : \"0.5rem\")};\n background-color: ${Colour.bg};\n ${applyHtmlContentStyle({ textSize: \"body-md\" })}\n\n ${(props) => {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n\n if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n }\n\n return css`\n color: ${Colour.text};\n `;\n }}\n`;\n\nexport const ErrorText = styled(Typography.BodyMD)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const ErrorList = styled(TextList.Ul)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const StyledToggleIcon = styled(ToggleIcon)<StyleProps>`\n ${(props) => {\n if (props.$selected) {\n if (props.$disabled)\n return css`\n color: ${Colour[\"icon-selected-disabled\"]};\n `;\n\n if (props.$error)\n return css`\n color: ${Colour[\"icon-error-strong\"]};\n `;\n\n return css`\n color: ${Colour[\"icon-selected\"]};\n `;\n }\n\n if (props.$disabled)\n return css`\n color: ${Colour[\"icon-disabled-subtle\"]};\n `;\n\n return css`\n color: ${Colour[\"icon-subtle\"]};\n `;\n }};\n`;\n"],"names":["Container","styled","div","Radius","Colour","bg","props","$indicator","css","$useContentWidth","$styleType","$error","$disabled","$selected","HeaderContainer","TextContainer","StyledToggleIcon","border","Input","input","$disabledVisual","InputContainer","text","Label","label","Font","_a","_b","$maxLines","desktop","MediaQuery","MaxWidth","lg","tablet","sm","mobile","SubLabel","IndicatorLabelContainer","$addPadding","RemoveButton","button","ExpandButton","disabled","$paddingTopRequired","ErrorContainer","AlertContainer","Alert","Children","$isFinalItem","applyHtmlContentStyle","textSize","ErrorText","Typography","Body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