@pega/cosmos-react-core 9.11.0 → 9.12.0
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/lib/components/MultiStepForm/FormProgress.styles.d.ts +25 -1
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.js +168 -5
- package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts +2 -2
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js +47 -21
- package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.js +2 -2
- package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts +5 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.js.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts +2 -2
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.js +45 -20
- package/lib/components/MultiStepForm/VerticalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.js +17 -9
- package/lib/components/MultiStepForm/useFormProgressOverflow.js.map +1 -1
- package/lib/components/SummaryList/SummaryList.d.ts.map +1 -1
- package/lib/components/SummaryList/SummaryList.js +8 -4
- package/lib/components/SummaryList/SummaryList.js.map +1 -1
- package/lib/theme/theme.d.ts +36 -0
- package/lib/theme/theme.d.ts.map +1 -1
- package/lib/theme/themeDefinition.json +18 -0
- package/lib/theme/themeOverrides.schema.json +28 -0
- package/lib/theme/themes/aurigaDarkTheme.json +6 -0
- package/lib/theme/themes/aurigaTheme.json +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiStepForm.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAGrD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CACnC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAA;YACF,UAAU;;;UAGZ,OAAO;QACT,GAAG,CAAA;wCAC6B,KAAK,CAAC,IA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AAQ,EACnB,cAAc,QACd,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAC5D,IACG,EACN,WAAW,CAAC,OAAO,IAAI,CACtB,KAAC,iBAAiB,IAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,GAAI,CACvF,IACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, useRef, useEffect } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useAfterInitialEffect,\n useUID,\n useI18n,\n usePrevious,\n useBreakpoint,\n useTheme,\n useConsolidatedRef,\n useConfiguration\n} from '../../hooks';\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport { focusNonInteractiveElement, isInstance } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport Text from '../Text';\nimport HTML from '../HTML';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Grid, { StyledGrid } from '../Grid';\nimport { defaultThemeProp } from '../../theme';\nimport Progress from '../Progress';\nimport ResponsiveActions from '../ResponsiveActions';\n\nimport type { MultiStepFormProps } from './MultiStepForm.types';\nimport VerticalFormProgress from './VerticalFormProgress';\nimport HorizontalFormProgress from './HorizontalFormProgress';\n\nexport const StyledForm = styled.form<{ actions?: boolean; heading?: boolean }>(\n ({ actions, heading, theme }) => {\n return css`\n & > ${StyledGrid} {\n position: relative;\n\n ${actions &&\n css`\n padding-block-end: calc(2 * ${theme.base.spacing});\n `}\n\n ${heading &&\n css`\n padding-block-start: calc(2 * ${theme.base.spacing});\n `}\n }\n\n &:focus-visible {\n outline: none;\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n }\n);\n\nStyledForm.defaultProps = defaultThemeProp;\n\nexport const StyledFormContent = styled.div``;\n\nexport const StyledInstructionText = styled(Grid)`\n /* Prevent instruction text from contributing to modal width calculation */\n width: 0;\n min-width: 100%;\n`;\n\nexport const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n palette: { urgent }\n }\n } = theme;\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n font-size: ${infoFontSize};\n font-style: italic;\n\n &::before {\n display: 'inline';\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledRequiredFieldLegend.defaultProps = defaultThemeProp;\n\nconst MultiStepForm: ForwardRefForwardPropsComponent<MultiStepFormProps> = forwardRef(\n function MultiStepForm(\n {\n currentStepId,\n steps,\n heading,\n progress,\n stepIndicator: stepIndicatorProp,\n showStepNames = false,\n ...restProps\n }: PropsWithoutRef<MultiStepFormProps>,\n ref: MultiStepFormProps['ref']\n ) {\n const showHorizontalStepNames = stepIndicatorProp === 'horizontal' ? showStepNames : undefined;\n\n const multiStepRef = useConsolidatedRef<HTMLFormElement>(ref);\n const headingRef = useRef<HTMLHeadingElement>(null);\n const progressIndicatorRef = useRef<HTMLDivElement>(null);\n const multiStepFormContentRef = useRef<HTMLDivElement>(null);\n const multiStepActionsRef = useRef<HTMLDivElement>(null);\n\n const { loadedRef } = useConfiguration();\n const previousId = usePrevious(currentStepId);\n const currentStep = steps.find(step => step.id === currentStepId)!;\n const headingId = useUID();\n const descriptionId = useUID();\n const t = useI18n();\n const {\n base: { 'content-width': contentWidth }\n } = useTheme();\n\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: multiStepRef });\n\n const stepIndicator = (() => {\n if (stepIndicatorProp === 'none' || steps.length < 2) return 'none';\n\n if (!isSmallOrAbove) return 'horizontal';\n\n return stepIndicatorProp ?? 'horizontal';\n })();\n\n const setFocus = () => {\n if (!loadedRef.current) {\n loadedRef.current = true;\n return;\n }\n\n if (progress) return;\n\n if (stepIndicator !== 'none' && progressIndicatorRef.current) {\n const focusables = [\n ...progressIndicatorRef.current.querySelectorAll(`[id=\"${currentStepId}\"]`)\n ] as HTMLElement[];\n focusables[0]?.focus();\n } else if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current);\n } else if (multiStepRef.current) {\n const containerEl = multiStepRef.current.closest('[data-focusable-form-container]');\n const headingEl = containerEl?.querySelector('[data-focusable-form-heading]');\n if (isInstance(headingEl, HTMLElement)) {\n focusNonInteractiveElement(headingEl);\n } else {\n let label: string | undefined;\n if (heading && currentStep.name) {\n label = `${heading} - ${currentStep.name}`;\n } else if (currentStep.name) {\n label = currentStep.name;\n } else if (heading) {\n label = heading;\n }\n\n focusNonInteractiveElement(multiStepRef.current, label);\n }\n }\n };\n\n // Set focus if the current step id updates\n useEffect(() => {\n if (previousId !== currentStepId) {\n setFocus();\n }\n }, [currentStepId, previousId]);\n\n // Set focus if the form content updates while focus is within the actions region of the form\n useAfterInitialEffect(() => {\n if (\n multiStepActionsRef.current &&\n multiStepActionsRef.current.contains(document.activeElement)\n ) {\n setFocus();\n }\n }, [currentStep.content]);\n\n // Set focus if a progress state resolves\n useAfterInitialEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n let areaDef = '';\n let rowDef = '';\n let colDef = '';\n switch (stepIndicator) {\n case 'horizontal':\n areaDef += '\"stepIndicator\" ';\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n colDef = 'minmax(0, 1fr)';\n break;\n case 'vertical':\n if (currentStep.banners) {\n areaDef += '\"banners stepIndicator\" ';\n rowDef += 'auto ';\n }\n if (currentStep.description) {\n areaDef += '\"description stepIndicator\" ';\n rowDef += 'auto ';\n }\n areaDef += '\"content stepIndicator\"';\n rowDef += 'minmax(0px, 1fr)';\n colDef = `2fr minmax(${contentWidth.xs}, 1fr)`;\n break;\n case 'vertical-start':\n if (currentStep.banners) areaDef += '\"stepIndicator banners\" ';\n if (currentStep.description) areaDef += '\"stepIndicator description\" ';\n areaDef += '\"stepIndicator content\"';\n colDef = 'fit-content(clamp(10ch, calc(100% / 3), 40ch)) 2fr';\n break;\n default:\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n colDef = 'minmax(0, 1fr)';\n }\n\n return (\n <StyledForm\n ref={multiStepRef}\n {...restProps}\n aria-labelledby={heading ? headingId : undefined}\n aria-describedby={currentStep.description ? descriptionId : undefined}\n heading={!!heading}\n actions={!!currentStep.actions}\n >\n {heading && (\n <Text ref={headingRef} id={headingId} variant='h3'>\n {heading}\n </Text>\n )}\n\n <Grid\n container={{\n cols: colDef,\n rows: rowDef,\n areas: areaDef,\n rowGap: 2,\n colGap: stepIndicator.startsWith('vertical') ? 4 : 2\n }}\n inert={progress ? '' : undefined}\n >\n {steps.length > 1 && (\n <Grid ref={progressIndicatorRef} item={{ area: 'stepIndicator' }}>\n {stepIndicator === 'horizontal' && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={HorizontalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n showStepNames={showHorizontalStepNames}\n />\n )}\n {stepIndicator.startsWith('vertical') && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={VerticalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n />\n )}\n <VisuallyHiddenText aria-live='polite'>\n {previousId !== undefined && previousId !== currentStepId\n ? t('step_changed_to_name', [currentStep.name])\n : ''}\n </VisuallyHiddenText>\n </Grid>\n )}\n\n {currentStep.banners && <Grid item={{ area: 'banners' }}>{currentStep.banners}</Grid>}\n\n {currentStep.description && (\n <StyledInstructionText item={{ area: 'description' }}>\n <HTML id={descriptionId} as='p' content={currentStep.description} />\n </StyledInstructionText>\n )}\n\n <Grid item={{ area: 'content' }} as={StyledFormContent} ref={multiStepFormContentRef}>\n {currentStep.content}\n </Grid>\n\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Grid>\n {currentStep.actions && (\n <ResponsiveActions actionsRef={multiStepActionsRef} actionsEl={currentStep.actions} />\n )}\n </StyledForm>\n );\n }\n);\n\nexport default MultiStepForm;\n"]}
|
|
1
|
+
{"version":3,"file":"MultiStepForm.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAGrD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CACnC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IAC9B,OAAO,GAAG,CAAA;YACF,UAAU;;;UAGZ,OAAO;QACT,GAAG,CAAA;wCAC6B,KAAK,CAAC,IAAI,CAAC,OAAO;SACjD;;UAEC,O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AC,QAAQ,IACP,OAAO,EAAE,CAAC,CAAC,QAAQ,EACnB,cAAc,QACd,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAC5D,IACG,EACN,WAAW,CAAC,OAAO,IAAI,CACtB,KAAC,iBAAiB,IAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,GAAI,CACvF,IACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, useRef, useEffect } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useAfterInitialEffect,\n useUID,\n useI18n,\n usePrevious,\n useBreakpoint,\n useTheme,\n useConsolidatedRef,\n useConfiguration\n} from '../../hooks';\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport { focusNonInteractiveElement, isInstance } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport Text from '../Text';\nimport HTML from '../HTML';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Grid, { StyledGrid } from '../Grid';\nimport { defaultThemeProp } from '../../theme';\nimport Progress from '../Progress';\nimport ResponsiveActions from '../ResponsiveActions';\n\nimport type { MultiStepFormProps } from './MultiStepForm.types';\nimport VerticalFormProgress from './VerticalFormProgress';\nimport HorizontalFormProgress from './HorizontalFormProgress';\n\nexport const StyledForm = styled.form<{ actions?: boolean; heading?: boolean }>(\n ({ actions, heading, theme }) => {\n return css`\n & > ${StyledGrid} {\n position: relative;\n\n ${actions &&\n css`\n padding-block-end: calc(2 * ${theme.base.spacing});\n `}\n\n ${heading &&\n css`\n padding-block-start: calc(2 * ${theme.base.spacing});\n `}\n }\n\n &:focus-visible {\n outline: none;\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n }\n);\n\nStyledForm.defaultProps = defaultThemeProp;\n\nexport const StyledFormContent = styled.div``;\n\nexport const StyledInstructionText = styled(Grid)`\n /* Prevent instruction text from contributing to modal width calculation */\n width: 0;\n min-width: 100%;\n`;\n\nexport const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n palette: { urgent }\n }\n } = theme;\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n font-size: ${infoFontSize};\n font-style: italic;\n\n &::before {\n display: 'inline';\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledRequiredFieldLegend.defaultProps = defaultThemeProp;\n\nconst MultiStepForm: ForwardRefForwardPropsComponent<MultiStepFormProps> = forwardRef(\n function MultiStepForm(\n {\n currentStepId,\n steps,\n heading,\n progress,\n stepIndicator: stepIndicatorProp,\n showStepNames = false,\n variant = 'dot',\n ...restProps\n }: PropsWithoutRef<MultiStepFormProps>,\n ref: MultiStepFormProps['ref']\n ) {\n const showHorizontalStepNames = stepIndicatorProp === 'horizontal' ? showStepNames : undefined;\n\n const multiStepRef = useConsolidatedRef<HTMLFormElement>(ref);\n const headingRef = useRef<HTMLHeadingElement>(null);\n const progressIndicatorRef = useRef<HTMLDivElement>(null);\n const multiStepFormContentRef = useRef<HTMLDivElement>(null);\n const multiStepActionsRef = useRef<HTMLDivElement>(null);\n\n const { loadedRef } = useConfiguration();\n const previousId = usePrevious(currentStepId);\n const currentStep = steps.find(step => step.id === currentStepId)!;\n const headingId = useUID();\n const descriptionId = useUID();\n const t = useI18n();\n const {\n base: { 'content-width': contentWidth }\n } = useTheme();\n\n const isSmallOrAbove = useBreakpoint('sm', { breakpointRef: multiStepRef });\n\n const stepIndicator = (() => {\n if (stepIndicatorProp === 'none' || steps.length < 2) return 'none';\n\n if (!isSmallOrAbove) return 'horizontal';\n\n return stepIndicatorProp ?? 'horizontal';\n })();\n\n const setFocus = () => {\n if (!loadedRef.current) {\n loadedRef.current = true;\n return;\n }\n\n if (progress) return;\n\n if (stepIndicator !== 'none' && progressIndicatorRef.current) {\n const focusables = [\n ...progressIndicatorRef.current.querySelectorAll(`[id=\"${currentStepId}\"]`)\n ] as HTMLElement[];\n focusables[0]?.focus();\n } else if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current);\n } else if (multiStepRef.current) {\n const containerEl = multiStepRef.current.closest('[data-focusable-form-container]');\n const headingEl = containerEl?.querySelector('[data-focusable-form-heading]');\n if (isInstance(headingEl, HTMLElement)) {\n focusNonInteractiveElement(headingEl);\n } else {\n let label: string | undefined;\n if (heading && currentStep.name) {\n label = `${heading} - ${currentStep.name}`;\n } else if (currentStep.name) {\n label = currentStep.name;\n } else if (heading) {\n label = heading;\n }\n\n focusNonInteractiveElement(multiStepRef.current, label);\n }\n }\n };\n\n // Set focus if the current step id updates\n useEffect(() => {\n if (previousId !== currentStepId) {\n setFocus();\n }\n }, [currentStepId, previousId]);\n\n // Set focus if the form content updates while focus is within the actions region of the form\n useAfterInitialEffect(() => {\n if (\n multiStepActionsRef.current &&\n multiStepActionsRef.current.contains(document.activeElement)\n ) {\n setFocus();\n }\n }, [currentStep.content]);\n\n // Set focus if a progress state resolves\n useAfterInitialEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n let areaDef = '';\n let rowDef = '';\n let colDef = '';\n switch (stepIndicator) {\n case 'horizontal':\n areaDef += '\"stepIndicator\" ';\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n colDef = 'minmax(0, 1fr)';\n break;\n case 'vertical':\n if (currentStep.banners) {\n areaDef += '\"banners stepIndicator\" ';\n rowDef += 'auto ';\n }\n if (currentStep.description) {\n areaDef += '\"description stepIndicator\" ';\n rowDef += 'auto ';\n }\n areaDef += '\"content stepIndicator\"';\n rowDef += 'minmax(0px, 1fr)';\n colDef = `2fr minmax(${contentWidth.xs}, 1fr)`;\n break;\n case 'vertical-start':\n if (currentStep.banners) areaDef += '\"stepIndicator banners\" ';\n if (currentStep.description) areaDef += '\"stepIndicator description\" ';\n areaDef += '\"stepIndicator content\"';\n colDef = 'fit-content(clamp(10ch, calc(100% / 3), 40ch)) 2fr';\n break;\n default:\n if (currentStep.banners) areaDef += '\"banners\" ';\n if (currentStep.description) areaDef += '\"description\" ';\n areaDef += '\"content\"';\n colDef = 'minmax(0, 1fr)';\n }\n\n return (\n <StyledForm\n ref={multiStepRef}\n {...restProps}\n aria-labelledby={heading ? headingId : undefined}\n aria-describedby={currentStep.description ? descriptionId : undefined}\n heading={!!heading}\n actions={!!currentStep.actions}\n >\n {heading && (\n <Text ref={headingRef} id={headingId} variant='h3'>\n {heading}\n </Text>\n )}\n\n <Grid\n container={{\n cols: colDef,\n rows: rowDef,\n areas: areaDef,\n rowGap: 2,\n colGap: stepIndicator.startsWith('vertical') ? 4 : 2\n }}\n inert={progress ? '' : undefined}\n >\n {steps.length > 1 && (\n <Grid ref={progressIndicatorRef} item={{ area: 'stepIndicator' }}>\n {stepIndicator === 'horizontal' && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={HorizontalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n showStepNames={showHorizontalStepNames}\n variant={variant}\n />\n )}\n {stepIndicator.startsWith('vertical') && (\n <Grid\n item={{ area: 'stepIndicator' }}\n as={VerticalFormProgress}\n steps={steps}\n currentStepId={currentStepId}\n variant={variant}\n />\n )}\n <VisuallyHiddenText aria-live='polite'>\n {previousId !== undefined && previousId !== currentStepId\n ? t('step_changed_to_name', [currentStep.name])\n : ''}\n </VisuallyHiddenText>\n </Grid>\n )}\n\n {currentStep.banners && <Grid item={{ area: 'banners' }}>{currentStep.banners}</Grid>}\n\n {currentStep.description && (\n <StyledInstructionText item={{ area: 'description' }}>\n <HTML id={descriptionId} as='p' content={currentStep.description} />\n </StyledInstructionText>\n )}\n\n <Grid item={{ area: 'content' }} as={StyledFormContent} ref={multiStepFormContentRef}>\n {currentStep.content}\n </Grid>\n\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Grid>\n {currentStep.actions && (\n <ResponsiveActions actionsRef={multiStepActionsRef} actionsEl={currentStep.actions} />\n )}\n </StyledForm>\n );\n }\n);\n\nexport default MultiStepForm;\n"]}
|
|
@@ -52,6 +52,11 @@ interface BaseMultiStepFormProps {
|
|
|
52
52
|
progress?: BaseFormProps['progress'];
|
|
53
53
|
/** The heading of the form. */
|
|
54
54
|
heading?: BaseFormProps['heading'];
|
|
55
|
+
/**
|
|
56
|
+
* The visual style of the step indicator.
|
|
57
|
+
* @default 'dot'
|
|
58
|
+
*/
|
|
59
|
+
variant?: 'dot' | 'bar';
|
|
55
60
|
/** Ref forwarded to the form element. */
|
|
56
61
|
ref?: BaseFormProps['ref'];
|
|
57
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiStepForm.types.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,4BAA4B;IAC5B,OAAO,EAAE,SAAS,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,sIAAsI;IACtI,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAC9C,yCAAyC;IACzC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,GAAG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+
{"version":3,"file":"MultiStepForm.types.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,4BAA4B;IAC5B,OAAO,EAAE,SAAS,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,sIAAsI;IACtI,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAC9C,yCAAyC;IACzC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,IAAI;IACnB,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,qCAAqC;IACrC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,sCAAsC;IACtC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,oEAAoE;IACpE,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC3C,sEAAsE;IACtE,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,UAAU,sBAAsB;IAC9B,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,mCAAmC;IACnC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACrC,+BAA+B;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACxB,yCAAyC;IACzC,GAAG,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GACrD,CACI;IACE,qDAAqD;IACrD,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACD;IACE,wCAAwC;IACxC,aAAa,EAAE,UAAU,GAAG,gBAAgB,GAAG,MAAM,CAAC;IACtD,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB,CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiStepForm.types.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode, Ref, MouseEventHandler } from 'react';\n\nimport type { BaseProps } from '../../types';\nimport type { ProgressProps } from '../Progress';\n\nexport interface BaseFormProps extends BaseProps {\n /** Primary content area. */\n content: ReactNode;\n /** Region for Form Actions. */\n actions?: ReactNode;\n /** If there is a progress state either on load, or after submit, you must indicate as such. A custom message is supported as well. */\n progress?: boolean | ProgressProps['message'];\n /** Region for Banners above the Form. */\n banners?: ReactNode;\n /** A description of the form to be displayed above the controls. */\n description?: string;\n /** The heading of the form. */\n heading?: string;\n /** Ref forwarded to the form element. */\n ref?: Ref<HTMLFormElement>;\n}\n\nexport interface Step {\n /** The id that is referenced by the Multi Step currentStepId prop. */\n id: string;\n /** The displayed name of the step. */\n name: string;\n /** A set of Action Buttons to render for the step. */\n actions?: BaseFormProps['actions'];\n /** Banners to render for the step */\n banners?: BaseFormProps['banners'];\n /** Content to render for the step. */\n content?: BaseFormProps['content'];\n /**\n * Indicates whether the step has been completed\n * @default false\n */\n completed?: boolean;\n /**\n * Determines the size of the step indicator. Depth 0 is larger than depth 1.\n * @default 0\n */\n depth?: 0 | 1;\n /** A description of the form to be displayed above the controls. */\n description?: BaseFormProps['description'];\n /** Callback function that is called when a step marker is clicked. */\n onMarkerClick?: MouseEventHandler;\n}\n\ninterface BaseMultiStepFormProps {\n /** Sets the current step. */\n currentStepId: string;\n /** Flat array of objects describing each step. */\n steps: Step[];\n /** Progress state for the form. */\n progress?: BaseFormProps['progress'];\n /** The heading of the form. */\n heading?: BaseFormProps['heading'];\n /** Ref forwarded to the form element. */\n ref?: BaseFormProps['ref'];\n}\n\nexport type MultiStepFormProps = BaseMultiStepFormProps &\n (\n | {\n /** MultiStepForm step indicator type - horizontal */\n stepIndicator?: 'horizontal';\n /**\n * Whether to show all step names in the horizontal step indicator.\n * @default false\n */\n showStepNames?: boolean;\n }\n | {\n /** MultiStepForm step indicator type */\n stepIndicator: 'vertical' | 'vertical-start' | 'none';\n showStepNames?: never;\n }\n );\n"]}
|
|
1
|
+
{"version":3,"file":"MultiStepForm.types.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode, Ref, MouseEventHandler } from 'react';\n\nimport type { BaseProps } from '../../types';\nimport type { ProgressProps } from '../Progress';\n\nexport interface BaseFormProps extends BaseProps {\n /** Primary content area. */\n content: ReactNode;\n /** Region for Form Actions. */\n actions?: ReactNode;\n /** If there is a progress state either on load, or after submit, you must indicate as such. A custom message is supported as well. */\n progress?: boolean | ProgressProps['message'];\n /** Region for Banners above the Form. */\n banners?: ReactNode;\n /** A description of the form to be displayed above the controls. */\n description?: string;\n /** The heading of the form. */\n heading?: string;\n /** Ref forwarded to the form element. */\n ref?: Ref<HTMLFormElement>;\n}\n\nexport interface Step {\n /** The id that is referenced by the Multi Step currentStepId prop. */\n id: string;\n /** The displayed name of the step. */\n name: string;\n /** A set of Action Buttons to render for the step. */\n actions?: BaseFormProps['actions'];\n /** Banners to render for the step */\n banners?: BaseFormProps['banners'];\n /** Content to render for the step. */\n content?: BaseFormProps['content'];\n /**\n * Indicates whether the step has been completed\n * @default false\n */\n completed?: boolean;\n /**\n * Determines the size of the step indicator. Depth 0 is larger than depth 1.\n * @default 0\n */\n depth?: 0 | 1;\n /** A description of the form to be displayed above the controls. */\n description?: BaseFormProps['description'];\n /** Callback function that is called when a step marker is clicked. */\n onMarkerClick?: MouseEventHandler;\n}\n\ninterface BaseMultiStepFormProps {\n /** Sets the current step. */\n currentStepId: string;\n /** Flat array of objects describing each step. */\n steps: Step[];\n /** Progress state for the form. */\n progress?: BaseFormProps['progress'];\n /** The heading of the form. */\n heading?: BaseFormProps['heading'];\n /**\n * The visual style of the step indicator.\n * @default 'dot'\n */\n variant?: 'dot' | 'bar';\n /** Ref forwarded to the form element. */\n ref?: BaseFormProps['ref'];\n}\n\nexport type MultiStepFormProps = BaseMultiStepFormProps &\n (\n | {\n /** MultiStepForm step indicator type - horizontal */\n stepIndicator?: 'horizontal';\n /**\n * Whether to show all step names in the horizontal step indicator.\n * @default false\n */\n showStepNames?: boolean;\n }\n | {\n /** MultiStepForm step indicator type */\n stepIndicator: 'vertical' | 'vertical-start' | 'none';\n showStepNames?: never;\n }\n );\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { FunctionComponent } from 'react';
|
|
2
1
|
import type { ForwardProps } from '../../types';
|
|
3
2
|
import type { MultiStepFormProps } from './MultiStepForm.types';
|
|
4
3
|
interface FormProgressProps {
|
|
5
4
|
steps: MultiStepFormProps['steps'];
|
|
6
5
|
currentStepId: MultiStepFormProps['currentStepId'];
|
|
6
|
+
variant?: MultiStepFormProps['variant'];
|
|
7
7
|
}
|
|
8
|
-
declare const VerticalFormProgress:
|
|
8
|
+
declare const VerticalFormProgress: ({ steps, currentStepId, variant, ...restProps }: FormProgressProps & ForwardProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export default VerticalFormProgress;
|
|
10
10
|
//# sourceMappingURL=VerticalFormProgress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalFormProgress.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/VerticalFormProgress.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VerticalFormProgress.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/VerticalFormProgress.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAehD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,UAAU,iBAAiB;IACzB,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACzC;AAED,QAAA,MAAM,oBAAoB,GAAI,iDAK3B,iBAAiB,GAAG,YAAY,4CA+HlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -5,14 +5,56 @@ import Text from '../Text';
|
|
|
5
5
|
import { useArrows, useElement, useI18n } from '../../hooks';
|
|
6
6
|
import Button from '../Button';
|
|
7
7
|
import Flex from '../Flex';
|
|
8
|
-
import { StepMarker, StyledBulletWrapper, StyledStepText, StyledVerticalStepMarkers } from './FormProgress.styles';
|
|
9
|
-
const VerticalFormProgress = ({ steps, currentStepId, ...restProps }) => {
|
|
8
|
+
import { StepMarker, StyledBulletWrapper, StyledStepText, StyledVerticalBarSegment, StyledVerticalBarWrapper, StyledVerticalStepMarkers } from './FormProgress.styles';
|
|
9
|
+
const VerticalFormProgress = ({ steps, currentStepId, variant = 'dot', ...restProps }) => {
|
|
10
10
|
const t = useI18n();
|
|
11
|
+
const isBarsMode = variant === 'bar';
|
|
11
12
|
const curIdx = steps.findIndex(step => step.id === currentStepId);
|
|
12
13
|
const curStep = steps[curIdx];
|
|
13
14
|
const [currentStepEl, setCurrentStepEl] = useElement();
|
|
14
15
|
const [stepEls, setStepEls] = useState({});
|
|
15
16
|
const stepsRef = useRef(null);
|
|
17
|
+
const setStepElement = (stepId) => (el) => {
|
|
18
|
+
setStepEls(curr => {
|
|
19
|
+
const newEls = { ...curr };
|
|
20
|
+
if (!el && newEls[stepId]) {
|
|
21
|
+
delete newEls[stepId];
|
|
22
|
+
return newEls;
|
|
23
|
+
}
|
|
24
|
+
if (el)
|
|
25
|
+
return { ...newEls, [stepId]: el };
|
|
26
|
+
return newEls;
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const renderStepName = ({ isCurrent, stepName, onMarkerClick }) => {
|
|
30
|
+
if (!!onMarkerClick && !isCurrent) {
|
|
31
|
+
return (_jsx(Button, { variant: 'link', onClick: onMarkerClick, as: StyledStepText, tabIndex: -1, children: stepName }));
|
|
32
|
+
}
|
|
33
|
+
return (_jsx(Text, { variant: isCurrent ? 'h3' : undefined, as: StyledStepText, children: stepName }));
|
|
34
|
+
};
|
|
35
|
+
const renderStepItem = (step, index) => {
|
|
36
|
+
const isCurrent = index === curIdx;
|
|
37
|
+
const isPrior = index < curIdx;
|
|
38
|
+
const commonMarkerProps = {
|
|
39
|
+
ref: setStepElement(step.id),
|
|
40
|
+
id: step.id,
|
|
41
|
+
'aria-label': `${step.name} - ${t('step_num', [index + 1, steps.length])}`,
|
|
42
|
+
'aria-current': isCurrent ? 'step' : undefined,
|
|
43
|
+
tabIndex: isCurrent ? 0 : -1,
|
|
44
|
+
current: isCurrent,
|
|
45
|
+
completed: step.completed,
|
|
46
|
+
onClick: step.onMarkerClick,
|
|
47
|
+
clickable: !!step.onMarkerClick && !isCurrent
|
|
48
|
+
};
|
|
49
|
+
return (_jsxs(Grid, { as: 'li', container: {
|
|
50
|
+
cols: '2rem minmax(0, 1fr)',
|
|
51
|
+
colGap: 1
|
|
52
|
+
}, children: [isBarsMode ? (_jsx(Flex, { container: { direction: 'column', alignItems: 'center' }, as: StyledVerticalBarWrapper, children: _jsx(StyledVerticalBarSegment, { ...commonMarkerProps }) })) : (_jsx(Flex, { container: { alignItems: 'center', justify: 'center' }, as: StyledBulletWrapper, hasNext: index !== steps.length - 1, prior: isPrior, children: _jsx(StepMarker, { prior: isPrior, depth: step.depth, ...commonMarkerProps }) })), renderStepName({
|
|
53
|
+
isCurrent,
|
|
54
|
+
stepName: step.name,
|
|
55
|
+
onMarkerClick: step.onMarkerClick
|
|
56
|
+
})] }, step.id));
|
|
57
|
+
};
|
|
16
58
|
useArrows(stepsRef, {
|
|
17
59
|
selector: 'button[aria-label]',
|
|
18
60
|
cycle: false,
|
|
@@ -30,24 +72,7 @@ const VerticalFormProgress = ({ steps, currentStepId, ...restProps }) => {
|
|
|
30
72
|
setCurrentStepEl(stepEls[curStep.id]);
|
|
31
73
|
}
|
|
32
74
|
}, [Object.keys(stepEls), curStep]);
|
|
33
|
-
return (_jsx(StyledVerticalStepMarkers, { ref: stepsRef, ...restProps, children: steps.map(
|
|
34
|
-
const isCurrent = index === curIdx;
|
|
35
|
-
return (_jsxs(Grid, { as: 'li', container: {
|
|
36
|
-
cols: '2rem minmax(0, 1fr)',
|
|
37
|
-
colGap: 1
|
|
38
|
-
}, children: [_jsx(Flex, { container: { alignItems: 'center', justify: 'center' }, as: StyledBulletWrapper, hasNext: index !== steps.length - 1, prior: index < curIdx, children: _jsx(StepMarker, { ref: (el) => {
|
|
39
|
-
setStepEls(curr => {
|
|
40
|
-
const newEls = { ...curr };
|
|
41
|
-
if (!el && newEls[step.id]) {
|
|
42
|
-
delete newEls[step.id];
|
|
43
|
-
return newEls;
|
|
44
|
-
}
|
|
45
|
-
if (el)
|
|
46
|
-
return { ...newEls, [step.id]: el };
|
|
47
|
-
return newEls;
|
|
48
|
-
});
|
|
49
|
-
}, id: step.id, "aria-label": `${step.name} - ${t('step_num', [index + 1, steps.length])}`, "aria-current": isCurrent ? 'step' : undefined, tabIndex: isCurrent ? 0 : -1, current: isCurrent, completed: step.completed, prior: index < curIdx, depth: step.depth, onClick: step.onMarkerClick, clickable: !!step.onMarkerClick && !isCurrent }) }), !!step.onMarkerClick && !isCurrent ? (_jsx(Button, { variant: 'link', onClick: step.onMarkerClick, as: StyledStepText, tabIndex: -1, children: step.name })) : (_jsx(Text, { variant: isCurrent ? 'h3' : undefined, as: StyledStepText, children: step.name }))] }, step.id));
|
|
50
|
-
}) }));
|
|
75
|
+
return (_jsx(StyledVerticalStepMarkers, { ref: stepsRef, ...restProps, children: steps.map(renderStepItem) }));
|
|
51
76
|
};
|
|
52
77
|
export default VerticalFormProgress;
|
|
53
78
|
//# sourceMappingURL=VerticalFormProgress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerticalFormProgress.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/VerticalFormProgress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"VerticalFormProgress.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/VerticalFormProgress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,I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AAC,KAAK,aAAa,EAAE,CAAC;YACjE,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,KAAC,yBAAyB,IAAC,GAAG,EAAE,QAAQ,KAAM,SAAS,YACpD,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,GACA,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { ForwardProps } from '../../types';\nimport Grid from '../Grid';\nimport Text from '../Text';\nimport { useArrows, useElement, useI18n } from '../../hooks';\nimport Button from '../Button';\nimport Flex from '../Flex';\n\nimport {\n StepMarker,\n StyledBulletWrapper,\n StyledStepText,\n StyledVerticalBarSegment,\n StyledVerticalBarWrapper,\n StyledVerticalStepMarkers\n} from './FormProgress.styles';\nimport type { MultiStepFormProps } from './MultiStepForm.types';\n\ninterface FormProgressProps {\n steps: MultiStepFormProps['steps'];\n currentStepId: MultiStepFormProps['currentStepId'];\n variant?: MultiStepFormProps['variant'];\n}\n\nconst VerticalFormProgress = ({\n steps,\n currentStepId,\n variant = 'dot',\n ...restProps\n}: FormProgressProps & ForwardProps) => {\n const t = useI18n();\n const isBarsMode = variant === 'bar';\n\n const curIdx = steps.findIndex(step => step.id === currentStepId);\n const curStep = steps[curIdx];\n\n const [currentStepEl, setCurrentStepEl] = useElement();\n const [stepEls, setStepEls] = useState<Record<string, HTMLElement>>({});\n const stepsRef = useRef(null);\n\n const setStepElement = (stepId: string) => (el: HTMLElement | null) => {\n setStepEls(curr => {\n const newEls = { ...curr };\n\n if (!el && newEls[stepId]) {\n delete newEls[stepId];\n return newEls;\n }\n\n if (el) return { ...newEls, [stepId]: el };\n\n return newEls;\n });\n };\n\n const renderStepName = ({\n isCurrent,\n stepName,\n onMarkerClick\n }: {\n isCurrent: boolean;\n stepName: string;\n onMarkerClick?: MultiStepFormProps['steps'][number]['onMarkerClick'];\n }) => {\n if (!!onMarkerClick && !isCurrent) {\n return (\n <Button variant='link' onClick={onMarkerClick} as={StyledStepText} tabIndex={-1}>\n {stepName}\n </Button>\n );\n }\n\n return (\n <Text variant={isCurrent ? 'h3' : undefined} as={StyledStepText}>\n {stepName}\n </Text>\n );\n };\n\n const renderStepItem = (step: MultiStepFormProps['steps'][number], index: number) => {\n const isCurrent = index === curIdx;\n const isPrior = index < curIdx;\n\n const commonMarkerProps = {\n ref: setStepElement(step.id),\n id: step.id,\n 'aria-label': `${step.name} - ${t('step_num', [index + 1, steps.length])}`,\n 'aria-current': isCurrent ? ('step' as const) : undefined,\n tabIndex: isCurrent ? 0 : -1,\n current: isCurrent,\n completed: step.completed,\n onClick: step.onMarkerClick,\n clickable: !!step.onMarkerClick && !isCurrent\n };\n\n return (\n <Grid\n key={step.id}\n as='li'\n container={{\n cols: '2rem minmax(0, 1fr)',\n colGap: 1\n }}\n >\n {isBarsMode ? (\n <Flex\n container={{ direction: 'column', alignItems: 'center' }}\n as={StyledVerticalBarWrapper}\n >\n <StyledVerticalBarSegment {...commonMarkerProps} />\n </Flex>\n ) : (\n <Flex\n container={{ alignItems: 'center', justify: 'center' }}\n as={StyledBulletWrapper}\n hasNext={index !== steps.length - 1}\n prior={isPrior}\n >\n <StepMarker prior={isPrior} depth={step.depth} {...commonMarkerProps} />\n </Flex>\n )}\n\n {renderStepName({\n isCurrent,\n stepName: step.name,\n onMarkerClick: step.onMarkerClick\n })}\n </Grid>\n );\n };\n\n useArrows(stepsRef, {\n selector: 'button[aria-label]',\n cycle: false,\n dir: 'left-right',\n initialFocusElement: currentStepEl\n });\n\n useArrows(stepsRef, {\n selector: 'button[aria-label]',\n cycle: false,\n dir: 'up-down',\n initialFocusElement: currentStepEl\n });\n\n useEffect(() => {\n if (stepEls[curStep.id] && stepEls[curStep.id] !== currentStepEl) {\n setCurrentStepEl(stepEls[curStep.id]);\n }\n }, [Object.keys(stepEls), curStep]);\n\n return (\n <StyledVerticalStepMarkers ref={stepsRef} {...restProps}>\n {steps.map(renderStepItem)}\n </StyledVerticalStepMarkers>\n );\n};\n\nexport default VerticalFormProgress;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const useFormProgressOverflow: (numberOfSteps: number, withLabels?: boolean) => {
|
|
1
|
+
export declare const useFormProgressOverflow: (numberOfSteps: number, withLabels?: boolean, barMode?: boolean) => {
|
|
2
2
|
ref: import("react").RefObject<HTMLOListElement>;
|
|
3
3
|
state: boolean | undefined;
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormProgressOverflow.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/useFormProgressOverflow.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"useFormProgressOverflow.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/useFormProgressOverflow.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB,GAClC,eAAe,MAAM,EACrB,aAAa,OAAO,EACpB,UAAU,OAAO;;;CAoDlB,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -2,14 +2,14 @@ import { useLayoutEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { remToPx, stripUnit } from 'polished';
|
|
3
3
|
import { useChToPxConversionFactor, useTheme } from '../../hooks';
|
|
4
4
|
import { tryCatch } from '../../utils';
|
|
5
|
-
import { stepItemMinWidth, stepMarkerMinWidth } from './FormProgress.styles';
|
|
6
|
-
export const useFormProgressOverflow = (numberOfSteps, withLabels) => {
|
|
5
|
+
import { stepBarMinWidth, stepItemMinWidth, stepMarkerMinWidth } from './FormProgress.styles';
|
|
6
|
+
export const useFormProgressOverflow = (numberOfSteps, withLabels, barMode) => {
|
|
7
7
|
const ref = useRef(null);
|
|
8
8
|
const [state, setState] = useState(undefined);
|
|
9
9
|
const chToPxConversionFactor = useChToPxConversionFactor();
|
|
10
10
|
const itemWidth = withLabels
|
|
11
11
|
? chToPxConversionFactor * stepItemMinWidth
|
|
12
|
-
: chToPxConversionFactor * stepMarkerMinWidth;
|
|
12
|
+
: chToPxConversionFactor * (barMode ? stepBarMinWidth : stepMarkerMinWidth);
|
|
13
13
|
const theme = useTheme();
|
|
14
14
|
const itemSpacing = Number(stripUnit(tryCatch(() => remToPx(theme.base.spacing), () => '16px')));
|
|
15
15
|
useLayoutEffect(() => {
|
|
@@ -18,17 +18,25 @@ export const useFormProgressOverflow = (numberOfSteps, withLabels) => {
|
|
|
18
18
|
return;
|
|
19
19
|
const ro = new ResizeObserver(() => {
|
|
20
20
|
const olWidth = ol.offsetWidth ?? 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
let maxVisibleItems;
|
|
22
|
+
if (barMode) {
|
|
23
|
+
// All bar segments are equal size; gap is the spacing between them.
|
|
24
|
+
// Min total width = N * minWidth + (N-1) * gap
|
|
25
|
+
// Overflow when N > (olWidth + gap) / (minWidth + gap)
|
|
26
|
+
maxVisibleItems = Math.floor((olWidth + itemSpacing) / (itemWidth + itemSpacing));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Adding 1 to maxVisibleItems to account for the fact that the first and last item are half size,
|
|
30
|
+
// so their overall width is equal to itemWidth, but need to be counted as 2 items
|
|
31
|
+
maxVisibleItems = Math.floor(olWidth / (itemWidth + itemSpacing) + 1);
|
|
32
|
+
}
|
|
33
|
+
setState(numberOfSteps > maxVisibleItems);
|
|
26
34
|
});
|
|
27
35
|
ro.observe(ol);
|
|
28
36
|
return () => {
|
|
29
37
|
ro.disconnect();
|
|
30
38
|
};
|
|
31
|
-
}, [itemWidth, itemSpacing, numberOfSteps]);
|
|
39
|
+
}, [itemWidth, itemSpacing, numberOfSteps, barMode]);
|
|
32
40
|
return { ref, state };
|
|
33
41
|
};
|
|
34
42
|
export default useFormProgressOverflow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormProgressOverflow.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/useFormProgressOverflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useFormProgressOverflow.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/useFormProgressOverflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,aAAqB,EACrB,UAAoB,EACpB,OAAiB,EACjB,EAAE;IACF,MAAM,GAAG,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB,SAAS,CAAC,CAAC;IAEnE,MAAM,sBAAsB,GAAG,yBAAyB,EAAE,CAAC;IAC3D,MAAM,SAAS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AE,CAAC,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAErD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC","sourcesContent":["import { useLayoutEffect, useRef, useState } from 'react';\nimport { remToPx, stripUnit } from 'polished';\n\nimport { useChToPxConversionFactor, useTheme } from '../../hooks';\nimport { tryCatch } from '../../utils';\n\nimport { stepBarMinWidth, stepItemMinWidth, stepMarkerMinWidth } from './FormProgress.styles';\n\nexport const useFormProgressOverflow = (\n numberOfSteps: number,\n withLabels?: boolean,\n barMode?: boolean\n) => {\n const ref = useRef<HTMLOListElement>(null);\n const [state, setState] = useState<boolean | undefined>(undefined);\n\n const chToPxConversionFactor = useChToPxConversionFactor();\n const itemWidth = withLabels\n ? chToPxConversionFactor * stepItemMinWidth\n : chToPxConversionFactor * (barMode ? stepBarMinWidth : stepMarkerMinWidth);\n\n const theme = useTheme();\n\n const itemSpacing = Number(\n stripUnit(\n tryCatch(\n () => remToPx(theme.base.spacing),\n () => '16px'\n )\n )\n );\n\n useLayoutEffect(() => {\n const ol = ref.current;\n if (!ol) return;\n\n const ro = new ResizeObserver(() => {\n const olWidth = ol.offsetWidth ?? 0;\n let maxVisibleItems: number;\n\n if (barMode) {\n // All bar segments are equal size; gap is the spacing between them.\n // Min total width = N * minWidth + (N-1) * gap\n // Overflow when N > (olWidth + gap) / (minWidth + gap)\n\n maxVisibleItems = Math.floor((olWidth + itemSpacing) / (itemWidth + itemSpacing));\n } else {\n // Adding 1 to maxVisibleItems to account for the fact that the first and last item are half size,\n // so their overall width is equal to itemWidth, but need to be counted as 2 items\n maxVisibleItems = Math.floor(olWidth / (itemWidth + itemSpacing) + 1);\n }\n\n setState(numberOfSteps > maxVisibleItems);\n });\n\n ro.observe(ol);\n\n return () => {\n ro.disconnect();\n };\n }, [itemWidth, itemSpacing, numberOfSteps, barMode]);\n\n return { ref, state };\n};\n\nexport default useFormProgressOverflow;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SummaryList.d.ts","sourceRoot":"","sources":["../../../src/components/SummaryList/SummaryList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAa,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,+BAA+B,EAC/B,cAAc,EACd,UAAU,EACV,MAAM,EACN,UAAU,EACX,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,uGAAuG;IACvG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iDAAiD;IACjD,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACrC,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wHAAwH;IACxH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,qKAAqK;IACrK,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,4KAA4K;IAC5K,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACzC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,eAAe,CAAC,SA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EAAE,MAAM,CAAC;IACX,oIAAoI;IACpI,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;CAClC;AAED,eAAO,MAAM,uBAAuB;;6IAMnC,CAAC;AAIF,eAAO,MAAM,wBAAwB;cACzB,OAAO,GAAG,MAAM;wJAoB3B,CAAC;AAIF,eAAO,MAAM,qBAAqB;;;;iDAmBjC,CAAC;AAIF,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,CAAC,4CAqCzF,CAAC;AAEF,QAAA,MAAM,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,CAsHlE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -11,7 +11,7 @@ import EmptyState from '../EmptyState';
|
|
|
11
11
|
import { omitProps } from '../../styles';
|
|
12
12
|
import { useI18n, usePrevious, useRefMap } from '../../hooks';
|
|
13
13
|
import { defaultThemeProp } from '../../theme';
|
|
14
|
-
import SummaryItem from '../SummaryItem';
|
|
14
|
+
import SummaryItem, { StyledSecondary } from '../SummaryItem';
|
|
15
15
|
import Progress from '../Progress';
|
|
16
16
|
import Button from '../Button';
|
|
17
17
|
import ErrorState from '../ErrorState';
|
|
@@ -41,11 +41,15 @@ export const StyledSummaryListContent = styled(CardContent).withConfig(omitProps
|
|
|
41
41
|
}
|
|
42
42
|
`);
|
|
43
43
|
StyledSummaryListContent.defaultProps = defaultThemeProp;
|
|
44
|
-
export const StyledSummaryListItem = styled(SummaryItem)(({ theme }) => css `
|
|
45
|
-
padding-block: ${
|
|
44
|
+
export const StyledSummaryListItem = styled(SummaryItem)(({ theme: { base: { spacing, palette }, components: { 'summary-item': { 'vertical-gap': verticalGap } } } }) => css `
|
|
45
|
+
padding-block: ${spacing};
|
|
46
|
+
|
|
47
|
+
${StyledSecondary} {
|
|
48
|
+
margin-block-start: ${verticalGap};
|
|
49
|
+
}
|
|
46
50
|
|
|
47
51
|
&:not(:last-child) {
|
|
48
|
-
border-block-end: 0.0625rem solid ${
|
|
52
|
+
border-block-end: 0.0625rem solid ${palette['border-line']};
|
|
49
53
|
}
|
|
50
54
|
`);
|
|
51
55
|
StyledSummaryListItem.defaultProps = defaultThemeProp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SummaryList.js","sourceRoot":"","sources":["../../../src/components/SummaryList/SummaryList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,IAAI,EAAE,EAAkB,MAAM,SAAS,CAAC;AAC/C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,UAAU,MAAM,eAAe,CAAC;AAUvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,UAAU,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAwDtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,UA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AAI,OAAK,IAAI,GAAI,CAAC,EAC9E,IAAI,IAAI,KAAC,IAAI,IAAC,OAAO,EAAE,UAAU,YAAG,IAAI,GAAQ,EAChD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAC,KAAK,cAAE,KAAK,GAAS,IAC/C,EACN,OAAO,IAAI,KAAC,OAAO,IAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,GAAI,IAC7D,CAC3B,EAED,KAAC,wBAAwB,IAAC,OAAO,EAAE,OAAO,YAAG,OAAO,GAA4B,EAE/E,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,SAAS,IAAI,CAC3E,KAAC,UAAU,IAAC,OAAO,EAAC,QAAQ,YAC1B,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,gBACF,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAC3E,OAAO,EAAE,SAAS,YAEjB,CAAC,CAAC,UAAU,CAAC,GACP,GACE,CACd,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, useEffect, useMemo, useRef } from 'react';\nimport type { PropsWithoutRef, Ref, RefObject } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Actions from '../Actions';\nimport type { ActionsProps } from '../Actions';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Count from '../Badges/Count';\nimport Icon, { type IconProps } from '../Icon';\nimport Card, { CardHeader, CardContent, CardFooter, StyledCard } from '../Card';\nimport EmptyState from '../EmptyState';\nimport type { EmptyStateProps } from '../EmptyState';\nimport type {\n ForwardProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n Action,\n HeadingTag\n} from '../../types';\nimport { omitProps } from '../../styles';\nimport { useI18n, usePrevious, useRefMap } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport SummaryItem from '../SummaryItem';\nimport type { SummaryItemProps } from '../SummaryItem';\nimport Progress from '../Progress';\nimport Button from '../Button';\nimport ErrorState from '../ErrorState';\nimport type { ErrorStateProps } from '../ErrorState';\nimport { StyledCardFooter } from '../Card/CardFooter';\n\nexport interface SummaryListProps extends NoChildrenProp {\n /** Name of the utility to be used as its heading along with associated actions and aria attributes. */\n name?: string;\n /**\n * The heading tag to render the provided name as with.\n * @default 'h2'\n */\n headingTag?: HeadingTag;\n /**\n * Hides the header while still allowing 'name' prop to supply aria attributes\n * @default false\n */\n hideHeader?: boolean;\n /** Identifier for the icon within Pega icons. */\n icon?: IconProps['name'] | IconProps;\n /** Integer representing the total count of items for a list utility dataset. */\n count?: number;\n /** Top level actions for the utility. If more than one action is passed a consolidated ActionMenu will be generated. */\n actions?: Action[];\n /** If the utility is in a state of fetching data. */\n loading?: boolean | string;\n /** An array of SummaryListItem objects to render. Pass an appropriately limited length array with a desired sort order based on design system defaults or config. */\n items: SummaryListItem[];\n /** User click initiated callback for when to show view all modal. List lengths less than the count prop will display a \"View all\" button with this function is bound to. */\n onViewAll?: (callback: Function) => void;\n /** A simple message to display when there are no items. */\n noItemsText?: EmptyStateProps['message'];\n /**\n * Indicate an error occurred while acquiring data for the list.\n * The default error state may be overridden with custom props.\n */\n error?: boolean | ErrorStateProps;\n /** ID of the item that was just deleted. Setting this triggers post-delete focus management. */\n deletedItemId?: string;\n /** Called after focus has been managed post-delete so the consumer can clear deletedItemId. */\n onDeleteFocusComplete?: () => void;\n /** Ref to the fallback element (e.g. Add button) to focus when the list becomes empty after deletion. */\n fallbackFocusRef?: RefObject<HTMLElement | null>;\n /** Ref for the SummaryList's root element. */\n ref?: Ref<HTMLElement>;\n}\n\nexport interface SummaryListItem\n extends OmitStrict<SummaryItemProps, 'actions'>,\n Pick<ActionsProps, 'contextualLabel'>,\n ForwardProps {\n /** A unique id to represent the item. */\n id: string;\n /** A set of Actions to render alongside the item. If more than one action is passed a consolidated ActionMenu will be generated. */\n actions?: Action[];\n /** Ref for the action menu button element. */\n actionsRef?: ActionsProps['ref'];\n}\n\nexport const StyledSummaryListHeader = styled(CardHeader)(\n ({ theme }) => css`\n &:not(${StyledCard} ${StyledCard} > &) {\n padding-block-end: calc(${theme.base.spacing} / 2);\n }\n `\n);\n\nStyledSummaryListHeader.defaultProps = defaultThemeProp;\n\nexport const StyledSummaryListContent = styled(CardContent).withConfig(omitProps('loading'))<{\n loading?: boolean | string;\n}>(\n ({ theme, loading }) => css`\n ${loading &&\n css`\n min-height: 4rem;\n `}\n\n &:not(:last-child) > ul > li:last-child {\n border-block-end: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n\n &:not(${StyledCard} ${StyledCard} > &) {\n padding-block-end: calc(${theme.base.spacing} / 2);\n\n & + ${StyledCardFooter} {\n padding-block-start: ${theme.base.spacing};\n }\n }\n `\n);\n\nStyledSummaryListContent.defaultProps = defaultThemeProp;\n\nexport const StyledSummaryListItem = styled(SummaryItem)(\n ({ theme }) => css`\n padding-block: ${theme.base.spacing};\n\n &:not(:last-child) {\n border-block-end: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n `\n);\n\nStyledSummaryListItem.defaultProps = defaultThemeProp;\n\nexport const SummaryListItems = ({ name, items }: Pick<SummaryListProps, 'items' | 'name'>) => {\n const t = useI18n();\n return (\n <ul>\n {items.map(\n ({\n id,\n actions: itemActions,\n actionsRef,\n contextualLabel,\n iconColor,\n ...restItemProps\n }) => {\n return (\n <StyledSummaryListItem\n key={id}\n {...restItemProps}\n forwardedAs='li'\n actions={\n itemActions && (\n <Actions\n ref={actionsRef}\n items={itemActions}\n contextualLabel={\n name && contextualLabel\n ? t('action_from_summarylist_heading', [contextualLabel, name])\n : contextualLabel\n }\n />\n )\n }\n />\n );\n }\n )}\n </ul>\n );\n};\n\nconst SummaryList: ForwardRefForwardPropsComponent<SummaryListProps> = forwardRef(\n function SummaryList(\n {\n icon,\n name,\n headingTag = 'h2',\n hideHeader,\n count,\n actions,\n items,\n onViewAll,\n loading,\n noItemsText,\n error,\n deletedItemId,\n onDeleteFocusComplete,\n fallbackFocusRef,\n ...restProps\n }: PropsWithoutRef<SummaryListProps>,\n ref: SummaryListProps['ref']\n ) {\n const t = useI18n();\n\n // Delete focus management\n const [actionRefMap, getActionRefCb] = useRefMap<HTMLButtonElement>();\n const prevItems = usePrevious(items);\n const hasProcessedDeleteRef = useRef(false);\n const headerActionsRef = useRef<HTMLButtonElement>(null);\n\n const processedItems = useMemo(() => {\n return items.map(item => {\n const refCb = getActionRefCb(item.id);\n return {\n ...item,\n actionsRef(el: HTMLButtonElement | null) {\n refCb(el);\n if (typeof item.actionsRef === 'function') item.actionsRef(el);\n }\n };\n });\n }, [items]);\n\n useEffect(() => {\n if (!deletedItemId) {\n hasProcessedDeleteRef.current = false;\n return;\n }\n if (hasProcessedDeleteRef.current) return;\n\n const stillPresent = items.some(item => item.id === deletedItemId);\n if (stillPresent) return;\n\n hasProcessedDeleteRef.current = true;\n\n if (items.length === 0) {\n const fallbackEl = fallbackFocusRef?.current ?? headerActionsRef.current;\n fallbackEl?.focus();\n } else {\n const prevIndex = prevItems?.findIndex(item => item.id === deletedItemId) ?? -1;\n let targetIndex = Math.min(prevIndex, items.length - 1);\n if (targetIndex < 0) targetIndex = 0;\n\n const targetId = items[targetIndex]?.id;\n if (targetId) {\n actionRefMap.get(targetId)?.focus();\n }\n }\n\n onDeleteFocusComplete?.();\n }, [deletedItemId, items]);\n\n const content = useMemo(() => {\n if (loading) {\n return (\n <Progress placement='local' message={typeof loading === 'string' ? loading : undefined} />\n );\n }\n\n if (error) {\n return <ErrorState {...(error === true ? {} : error)} />;\n }\n\n return items.length > 0 ? (\n <SummaryListItems name={name} items={processedItems} />\n ) : (\n <EmptyState message={noItemsText} />\n );\n }, [loading, items, processedItems, noItemsText, error]);\n\n return (\n <Card ref={ref} {...restProps}>\n {!hideHeader && (icon || name || typeof count === 'number' || actions) && (\n <StyledSummaryListHeader>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n {icon && (typeof icon === 'string' ? <Icon name={icon} /> : <Icon {...icon} />)}\n {name && <Text variant={headingTag}>{name}</Text>}\n {typeof count === 'number' && <Count>{count}</Count>}\n </Flex>\n {actions && <Actions ref={headerActionsRef} items={actions} contextualLabel={name} />}\n </StyledSummaryListHeader>\n )}\n\n <StyledSummaryListContent loading={loading}>{content}</StyledSummaryListContent>\n\n {!error && typeof count === 'number' && count > items.length && onViewAll && (\n <CardFooter justify='center'>\n <Button\n variant='link'\n aria-label={name ? t('view_all_noun', [name.toLowerCase()]) : t('view_all')}\n onClick={onViewAll}\n >\n {t('view_all')}\n </Button>\n </CardFooter>\n )}\n </Card>\n );\n }\n);\n\nexport default SummaryList;\n"]}
|
|
1
|
+
{"version":3,"file":"SummaryList.js","sourceRoot":"","sources":["../../../src/components/SummaryList/SummaryList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,IAAI,EAAE,EAAkB,MAAM,SAAS,CAAC;AAC/C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,UAAU,MAAM,eAAe,CAAC;AAUvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,C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ACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, useEffect, useMemo, useRef } from 'react';\nimport type { PropsWithoutRef, Ref, RefObject } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Actions from '../Actions';\nimport type { ActionsProps } from '../Actions';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Count from '../Badges/Count';\nimport Icon, { type IconProps } from '../Icon';\nimport Card, { CardHeader, CardContent, CardFooter, StyledCard } from '../Card';\nimport EmptyState from '../EmptyState';\nimport type { EmptyStateProps } from '../EmptyState';\nimport type {\n ForwardProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n Action,\n HeadingTag\n} from '../../types';\nimport { omitProps } from '../../styles';\nimport { useI18n, usePrevious, useRefMap } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport SummaryItem, { StyledSecondary } from '../SummaryItem';\nimport type { SummaryItemProps } from '../SummaryItem';\nimport Progress from '../Progress';\nimport Button from '../Button';\nimport ErrorState from '../ErrorState';\nimport type { ErrorStateProps } from '../ErrorState';\nimport { StyledCardFooter } from '../Card/CardFooter';\n\nexport interface SummaryListProps extends NoChildrenProp {\n /** Name of the utility to be used as its heading along with associated actions and aria attributes. */\n name?: string;\n /**\n * The heading tag to render the provided name as with.\n * @default 'h2'\n */\n headingTag?: HeadingTag;\n /**\n * Hides the header while still allowing 'name' prop to supply aria attributes\n * @default false\n */\n hideHeader?: boolean;\n /** Identifier for the icon within Pega icons. */\n icon?: IconProps['name'] | IconProps;\n /** Integer representing the total count of items for a list utility dataset. */\n count?: number;\n /** Top level actions for the utility. If more than one action is passed a consolidated ActionMenu will be generated. */\n actions?: Action[];\n /** If the utility is in a state of fetching data. */\n loading?: boolean | string;\n /** An array of SummaryListItem objects to render. Pass an appropriately limited length array with a desired sort order based on design system defaults or config. */\n items: SummaryListItem[];\n /** User click initiated callback for when to show view all modal. List lengths less than the count prop will display a \"View all\" button with this function is bound to. */\n onViewAll?: (callback: Function) => void;\n /** A simple message to display when there are no items. */\n noItemsText?: EmptyStateProps['message'];\n /**\n * Indicate an error occurred while acquiring data for the list.\n * The default error state may be overridden with custom props.\n */\n error?: boolean | ErrorStateProps;\n /** ID of the item that was just deleted. Setting this triggers post-delete focus management. */\n deletedItemId?: string;\n /** Called after focus has been managed post-delete so the consumer can clear deletedItemId. */\n onDeleteFocusComplete?: () => void;\n /** Ref to the fallback element (e.g. Add button) to focus when the list becomes empty after deletion. */\n fallbackFocusRef?: RefObject<HTMLElement | null>;\n /** Ref for the SummaryList's root element. */\n ref?: Ref<HTMLElement>;\n}\n\nexport interface SummaryListItem\n extends OmitStrict<SummaryItemProps, 'actions'>,\n Pick<ActionsProps, 'contextualLabel'>,\n ForwardProps {\n /** A unique id to represent the item. */\n id: string;\n /** A set of Actions to render alongside the item. If more than one action is passed a consolidated ActionMenu will be generated. */\n actions?: Action[];\n /** Ref for the action menu button element. */\n actionsRef?: ActionsProps['ref'];\n}\n\nexport const StyledSummaryListHeader = styled(CardHeader)(\n ({ theme }) => css`\n &:not(${StyledCard} ${StyledCard} > &) {\n padding-block-end: calc(${theme.base.spacing} / 2);\n }\n `\n);\n\nStyledSummaryListHeader.defaultProps = defaultThemeProp;\n\nexport const StyledSummaryListContent = styled(CardContent).withConfig(omitProps('loading'))<{\n loading?: boolean | string;\n}>(\n ({ theme, loading }) => css`\n ${loading &&\n css`\n min-height: 4rem;\n `}\n\n &:not(:last-child) > ul > li:last-child {\n border-block-end: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n\n &:not(${StyledCard} ${StyledCard} > &) {\n padding-block-end: calc(${theme.base.spacing} / 2);\n\n & + ${StyledCardFooter} {\n padding-block-start: ${theme.base.spacing};\n }\n }\n `\n);\n\nStyledSummaryListContent.defaultProps = defaultThemeProp;\n\nexport const StyledSummaryListItem = styled(SummaryItem)(\n ({\n theme: {\n base: { spacing, palette },\n components: {\n 'summary-item': { 'vertical-gap': verticalGap }\n }\n }\n }) => css`\n padding-block: ${spacing};\n\n ${StyledSecondary} {\n margin-block-start: ${verticalGap};\n }\n\n &:not(:last-child) {\n border-block-end: 0.0625rem solid ${palette['border-line']};\n }\n `\n);\n\nStyledSummaryListItem.defaultProps = defaultThemeProp;\n\nexport const SummaryListItems = ({ name, items }: Pick<SummaryListProps, 'items' | 'name'>) => {\n const t = useI18n();\n return (\n <ul>\n {items.map(\n ({\n id,\n actions: itemActions,\n actionsRef,\n contextualLabel,\n iconColor,\n ...restItemProps\n }) => {\n return (\n <StyledSummaryListItem\n key={id}\n {...restItemProps}\n forwardedAs='li'\n actions={\n itemActions && (\n <Actions\n ref={actionsRef}\n items={itemActions}\n contextualLabel={\n name && contextualLabel\n ? t('action_from_summarylist_heading', [contextualLabel, name])\n : contextualLabel\n }\n />\n )\n }\n />\n );\n }\n )}\n </ul>\n );\n};\n\nconst SummaryList: ForwardRefForwardPropsComponent<SummaryListProps> = forwardRef(\n function SummaryList(\n {\n icon,\n name,\n headingTag = 'h2',\n hideHeader,\n count,\n actions,\n items,\n onViewAll,\n loading,\n noItemsText,\n error,\n deletedItemId,\n onDeleteFocusComplete,\n fallbackFocusRef,\n ...restProps\n }: PropsWithoutRef<SummaryListProps>,\n ref: SummaryListProps['ref']\n ) {\n const t = useI18n();\n\n // Delete focus management\n const [actionRefMap, getActionRefCb] = useRefMap<HTMLButtonElement>();\n const prevItems = usePrevious(items);\n const hasProcessedDeleteRef = useRef(false);\n const headerActionsRef = useRef<HTMLButtonElement>(null);\n\n const processedItems = useMemo(() => {\n return items.map(item => {\n const refCb = getActionRefCb(item.id);\n return {\n ...item,\n actionsRef(el: HTMLButtonElement | null) {\n refCb(el);\n if (typeof item.actionsRef === 'function') item.actionsRef(el);\n }\n };\n });\n }, [items]);\n\n useEffect(() => {\n if (!deletedItemId) {\n hasProcessedDeleteRef.current = false;\n return;\n }\n if (hasProcessedDeleteRef.current) return;\n\n const stillPresent = items.some(item => item.id === deletedItemId);\n if (stillPresent) return;\n\n hasProcessedDeleteRef.current = true;\n\n if (items.length === 0) {\n const fallbackEl = fallbackFocusRef?.current ?? headerActionsRef.current;\n fallbackEl?.focus();\n } else {\n const prevIndex = prevItems?.findIndex(item => item.id === deletedItemId) ?? -1;\n let targetIndex = Math.min(prevIndex, items.length - 1);\n if (targetIndex < 0) targetIndex = 0;\n\n const targetId = items[targetIndex]?.id;\n if (targetId) {\n actionRefMap.get(targetId)?.focus();\n }\n }\n\n onDeleteFocusComplete?.();\n }, [deletedItemId, items]);\n\n const content = useMemo(() => {\n if (loading) {\n return (\n <Progress placement='local' message={typeof loading === 'string' ? loading : undefined} />\n );\n }\n\n if (error) {\n return <ErrorState {...(error === true ? {} : error)} />;\n }\n\n return items.length > 0 ? (\n <SummaryListItems name={name} items={processedItems} />\n ) : (\n <EmptyState message={noItemsText} />\n );\n }, [loading, items, processedItems, noItemsText, error]);\n\n return (\n <Card ref={ref} {...restProps}>\n {!hideHeader && (icon || name || typeof count === 'number' || actions) && (\n <StyledSummaryListHeader>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n {icon && (typeof icon === 'string' ? <Icon name={icon} /> : <Icon {...icon} />)}\n {name && <Text variant={headingTag}>{name}</Text>}\n {typeof count === 'number' && <Count>{count}</Count>}\n </Flex>\n {actions && <Actions ref={headerActionsRef} items={actions} contextualLabel={name} />}\n </StyledSummaryListHeader>\n )}\n\n <StyledSummaryListContent loading={loading}>{content}</StyledSummaryListContent>\n\n {!error && typeof count === 'number' && count > items.length && onViewAll && (\n <CardFooter justify='center'>\n <Button\n variant='link'\n aria-label={name ? t('view_all_noun', [name.toLowerCase()]) : t('view_all')}\n onClick={onViewAll}\n >\n {t('view_all')}\n </Button>\n </CardFooter>\n )}\n </Card>\n );\n }\n);\n\nexport default SummaryList;\n"]}
|
package/lib/theme/theme.d.ts
CHANGED
|
@@ -1438,6 +1438,12 @@ export declare const BaseThemeMachine: ThemeMachine<{
|
|
|
1438
1438
|
$value: string;
|
|
1439
1439
|
};
|
|
1440
1440
|
};
|
|
1441
|
+
"multi-step-form": {
|
|
1442
|
+
"bar-indicator-border-radius": {
|
|
1443
|
+
$type: string;
|
|
1444
|
+
$value: string;
|
|
1445
|
+
};
|
|
1446
|
+
};
|
|
1441
1447
|
progress: {
|
|
1442
1448
|
"progress-color": {
|
|
1443
1449
|
$type: string;
|
|
@@ -1562,6 +1568,12 @@ export declare const BaseThemeMachine: ThemeMachine<{
|
|
|
1562
1568
|
};
|
|
1563
1569
|
};
|
|
1564
1570
|
};
|
|
1571
|
+
"summary-item": {
|
|
1572
|
+
"vertical-gap": {
|
|
1573
|
+
$type: string;
|
|
1574
|
+
$value: string;
|
|
1575
|
+
};
|
|
1576
|
+
};
|
|
1565
1577
|
switch: {
|
|
1566
1578
|
height: {
|
|
1567
1579
|
$type: string;
|
|
@@ -1798,6 +1810,12 @@ export declare const BaseThemeMachine: ThemeMachine<{
|
|
|
1798
1810
|
};
|
|
1799
1811
|
};
|
|
1800
1812
|
};
|
|
1813
|
+
tasks: {
|
|
1814
|
+
"button-style": {
|
|
1815
|
+
$type: string;
|
|
1816
|
+
$value: string;
|
|
1817
|
+
};
|
|
1818
|
+
};
|
|
1801
1819
|
text: {
|
|
1802
1820
|
primary: {
|
|
1803
1821
|
"font-size": {
|
|
@@ -2545,6 +2563,9 @@ export declare const WorkTheme: {
|
|
|
2545
2563
|
readonly "background-color": string;
|
|
2546
2564
|
readonly "font-weight": string;
|
|
2547
2565
|
};
|
|
2566
|
+
readonly "multi-step-form": {
|
|
2567
|
+
readonly "bar-indicator-border-radius": string;
|
|
2568
|
+
};
|
|
2548
2569
|
readonly progress: {
|
|
2549
2570
|
readonly "progress-color": string;
|
|
2550
2571
|
};
|
|
@@ -2597,6 +2618,9 @@ export declare const WorkTheme: {
|
|
|
2597
2618
|
readonly foreground: string;
|
|
2598
2619
|
};
|
|
2599
2620
|
};
|
|
2621
|
+
readonly "summary-item": {
|
|
2622
|
+
readonly "vertical-gap": string;
|
|
2623
|
+
};
|
|
2600
2624
|
readonly switch: {
|
|
2601
2625
|
readonly height: string;
|
|
2602
2626
|
readonly width: string;
|
|
@@ -2686,6 +2710,9 @@ export declare const WorkTheme: {
|
|
|
2686
2710
|
};
|
|
2687
2711
|
};
|
|
2688
2712
|
};
|
|
2713
|
+
readonly tasks: {
|
|
2714
|
+
readonly "button-style": string;
|
|
2715
|
+
};
|
|
2689
2716
|
readonly text: {
|
|
2690
2717
|
readonly primary: {
|
|
2691
2718
|
readonly "font-size": string;
|
|
@@ -3288,6 +3315,9 @@ export declare const defaultThemeProp: Readonly<{
|
|
|
3288
3315
|
readonly "background-color": string;
|
|
3289
3316
|
readonly "font-weight": string;
|
|
3290
3317
|
};
|
|
3318
|
+
readonly "multi-step-form": {
|
|
3319
|
+
readonly "bar-indicator-border-radius": string;
|
|
3320
|
+
};
|
|
3291
3321
|
readonly progress: {
|
|
3292
3322
|
readonly "progress-color": string;
|
|
3293
3323
|
};
|
|
@@ -3340,6 +3370,9 @@ export declare const defaultThemeProp: Readonly<{
|
|
|
3340
3370
|
readonly foreground: string;
|
|
3341
3371
|
};
|
|
3342
3372
|
};
|
|
3373
|
+
readonly "summary-item": {
|
|
3374
|
+
readonly "vertical-gap": string;
|
|
3375
|
+
};
|
|
3343
3376
|
readonly switch: {
|
|
3344
3377
|
readonly height: string;
|
|
3345
3378
|
readonly width: string;
|
|
@@ -3429,6 +3462,9 @@ export declare const defaultThemeProp: Readonly<{
|
|
|
3429
3462
|
};
|
|
3430
3463
|
};
|
|
3431
3464
|
};
|
|
3465
|
+
readonly tasks: {
|
|
3466
|
+
readonly "button-style": string;
|
|
3467
|
+
};
|
|
3432
3468
|
readonly text: {
|
|
3433
3469
|
readonly primary: {
|
|
3434
3470
|
readonly "font-size": string;
|