@pega/cosmos-react-core 9.36.0 → 9.37.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.
Files changed (81) hide show
  1. package/lib/components/AIRewrite/AIRewrite.d.ts +1 -1
  2. package/lib/components/AIRewrite/AIRewrite.d.ts.map +1 -1
  3. package/lib/components/AIRewrite/AIRewrite.js +7 -3
  4. package/lib/components/AIRewrite/AIRewrite.js.map +1 -1
  5. package/lib/components/AIRewrite/AIRewrite.styles.d.ts +32 -4
  6. package/lib/components/AIRewrite/AIRewrite.styles.d.ts.map +1 -1
  7. package/lib/components/AIRewrite/AIRewrite.styles.js +5 -2
  8. package/lib/components/AIRewrite/AIRewrite.styles.js.map +1 -1
  9. package/lib/components/AIRewrite/AIRewrite.types.d.ts +2 -0
  10. package/lib/components/AIRewrite/AIRewrite.types.d.ts.map +1 -1
  11. package/lib/components/AIRewrite/AIRewrite.types.js.map +1 -1
  12. package/lib/components/AppShell/NavigationListItemWrapper.js +1 -1
  13. package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
  14. package/lib/components/AppShell/TouchAppShell.styles.d.ts +4 -2
  15. package/lib/components/AppShell/TouchAppShell.styles.d.ts.map +1 -1
  16. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  17. package/lib/components/CompositeInput/CompositeInput.js +18 -3
  18. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  19. package/lib/components/DateTime/Input/DateInput.js +1 -1
  20. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  21. package/lib/components/DateTime/Input/DateTimeInput.js +1 -1
  22. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  23. package/lib/components/DateTime/Input/TimeInput.js +1 -1
  24. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  25. package/lib/components/DateTime/Input/WeekInput.js +1 -1
  26. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  27. package/lib/components/Dialog/Dialog.types.d.ts +37 -9
  28. package/lib/components/Dialog/Dialog.types.d.ts.map +1 -1
  29. package/lib/components/Dialog/Dialog.types.js.map +1 -1
  30. package/lib/components/Dialog/FormDialog.d.ts.map +1 -1
  31. package/lib/components/Dialog/FormDialog.js +36 -34
  32. package/lib/components/Dialog/FormDialog.js.map +1 -1
  33. package/lib/components/Dialog/FormDialogWrapper.d.ts +5 -0
  34. package/lib/components/Dialog/FormDialogWrapper.d.ts.map +1 -0
  35. package/lib/components/Dialog/FormDialogWrapper.js +13 -0
  36. package/lib/components/Dialog/FormDialogWrapper.js.map +1 -0
  37. package/lib/components/Dialog/TouchDialog.d.ts +1 -1
  38. package/lib/components/Dialog/TouchDialog.d.ts.map +1 -1
  39. package/lib/components/Dialog/TouchDialog.js +14 -10
  40. package/lib/components/Dialog/TouchDialog.js.map +1 -1
  41. package/lib/components/Dialog/TouchDialog.styles.d.ts +2 -2
  42. package/lib/components/Dialog/TouchDialog.styles.d.ts.map +1 -1
  43. package/lib/components/Dialog/TouchDialog.styles.js +32 -31
  44. package/lib/components/Dialog/TouchDialog.styles.js.map +1 -1
  45. package/lib/components/Dialog/TouchDialog.types.d.ts +13 -6
  46. package/lib/components/Dialog/TouchDialog.types.d.ts.map +1 -1
  47. package/lib/components/Dialog/TouchDialog.types.js.map +1 -1
  48. package/lib/components/Dialog/TouchFormDialog.d.ts +5 -0
  49. package/lib/components/Dialog/TouchFormDialog.d.ts.map +1 -0
  50. package/lib/components/Dialog/TouchFormDialog.js +53 -0
  51. package/lib/components/Dialog/TouchFormDialog.js.map +1 -0
  52. package/lib/components/Dialog/TouchFormDialog.styles.d.ts +7 -0
  53. package/lib/components/Dialog/TouchFormDialog.styles.d.ts.map +1 -0
  54. package/lib/components/Dialog/TouchFormDialog.styles.js +39 -0
  55. package/lib/components/Dialog/TouchFormDialog.styles.js.map +1 -0
  56. package/lib/components/Dialog/TouchInfoDialog.d.ts.map +1 -1
  57. package/lib/components/Dialog/TouchInfoDialog.js +12 -5
  58. package/lib/components/Dialog/TouchInfoDialog.js.map +1 -1
  59. package/lib/components/Dialog/index.d.ts +2 -1
  60. package/lib/components/Dialog/index.d.ts.map +1 -1
  61. package/lib/components/Dialog/index.js +2 -1
  62. package/lib/components/Dialog/index.js.map +1 -1
  63. package/lib/components/InlineEdit/InlineEdit.d.ts +13 -4
  64. package/lib/components/InlineEdit/InlineEdit.d.ts.map +1 -1
  65. package/lib/components/InlineEdit/InlineEdit.js +2 -2
  66. package/lib/components/InlineEdit/InlineEdit.js.map +1 -1
  67. package/lib/components/InlineEdit/InlineEdit.styles.d.ts +32 -4
  68. package/lib/components/InlineEdit/InlineEdit.styles.d.ts.map +1 -1
  69. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  70. package/lib/components/ListToolbar/ListToolbar.js +1 -7
  71. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  72. package/lib/components/ListToolbar/ListToolbar.styles.d.ts +32 -4
  73. package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
  74. package/lib/components/ListToolbar/ListToolbar.styles.js +9 -6
  75. package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
  76. package/lib/components/ListToolbar/PresetMenuPopover.js +1 -1
  77. package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -1
  78. package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
  79. package/lib/components/MenuButton/MenuButton.js +19 -10
  80. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  81. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"WeekInput.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/WeekInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD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AI,EAAC,OAAO,GAAG,GACH,CACrB,EACA,MAAM,IACF,CACR,IACI,CACR,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,8BACE,KAAC,SAAS,IACR,MAAM,EAAE,OAAO,EACf,EAAE,EAAC,UAAU,EACb,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,sBACZ,aAAa,EAC/B,GAAG,EAAE,GAAG,YAEP,IAAI,GACK,EACX,WAAW,IACX,CACJ,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { forwardRef, Fragment, useRef, useState } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../../theme';\nimport type { ForwardRefForwardPropsComponent, OmitStrict } from '../../../types';\nimport {\n useConfiguration,\n useConsolidatedRef,\n useFocusWithin,\n useI18n,\n useOuterEvent,\n useTestIds,\n useUID\n} from '../../../hooks';\nimport { cap, createClassName, isInstance, isTouchDevice, withTestIds } from '../../../utils';\nimport { TouchDialog } from '../../Dialog/TouchDialog';\nimport FormField from '../../FormField';\nimport Icon, { registerIcon } from '../../Icon';\nimport * as calendarIcon from '../../Icon/icons/calendar.icon';\nimport Flex from '../../Flex';\nimport { StyledFormControl } from '../../FormControl';\nimport type { FormControlProps } from '../../FormControl';\nimport DatePicker from '../Picker/DatePicker';\nimport type DateTimeProps from '../DateTime.types';\nimport type { DateTimeCallbackParameter } from '../DateTime.types';\nimport { getWeekInputTestIds } from '../DateTime.test-ids';\nimport HiddenText from '../../HiddenText';\n\nimport {\n parseToDate,\n getWeekYear,\n getWeek,\n generatePickerButtonAriaLabel,\n convertWeekYearToDate,\n buildRawWeekString\n} from './utils';\nimport StyledDateTime, {\n BareInput,\n StyledDatePickerDialog,\n StyledDialogContent,\n StyledInputButton,\n StyledInputContainer\n} from './DateTime.styles';\nimport usePickerButton from './usePickerButton';\nimport PartInput from './PartInput';\nimport useAutoFocusNextInput from './useAutoFocusNextInput';\nimport type { DateParts } from './DateTimeInput.types';\nimport { CALENDAR_TYPES, type CalendarType } from './local';\n\nregisterIcon(calendarIcon);\n\nexport interface WeekInputProps\n extends OmitStrict<FormControlProps, 'value' | 'defaultValue'>,\n DateTimeProps {}\n\ninterface WeekInputComponentProps extends WeekInputProps {\n ref?: Ref<HTMLFieldSetElement>;\n}\n\nexport const StyledWeekInput = styled(StyledDateTime)<WeekInputProps>(props => {\n const {\n theme: { base }\n } = props;\n\n return css`\n padding-inline-end: 0;\n\n ${StyledInputContainer} > ${BareInput}:first-of-type {\n margin-inline-start: ${base.spacing};\n }\n `;\n});\n\nStyledWeekInput.defaultProps = defaultThemeProp;\n\nconst convertToCallbackParameter = (\n date: Date,\n parts: DateParts<string | undefined>,\n calendarType?: CalendarType\n): DateTimeCallbackParameter => {\n if ([parts.week, parts.year].every(Boolean)) {\n const { year, month, day } = convertWeekYearToDate(parts, calendarType) ?? {};\n date.setUTCFullYear(Number(year), Number(month), Number(day));\n return {\n valueAsISOString: date.toISOString(),\n valueAsTimestamp: date.getTime()\n };\n }\n if ([parts.week, parts.year].every(p => !p)) {\n return {\n valueAsISOString: undefined,\n valueAsTimestamp: undefined\n };\n }\n return {\n valueAsISOString: buildRawWeekString(parts.week, parts.year),\n valueAsTimestamp: NaN,\n state: 'incomplete'\n };\n};\n\nconst WeekInput: ForwardRefForwardPropsComponent<WeekInputComponentProps> = forwardRef(\n function WeekInput(\n props: PropsWithoutRef<WeekInputComponentProps>,\n ref: Ref<HTMLFieldSetElement>\n ) {\n const {\n testId,\n value,\n min,\n max,\n id,\n label,\n labelHidden,\n status,\n info,\n required,\n readOnly,\n disabled,\n onChange,\n onFocus,\n onBlur,\n autoFocus,\n additionalInfo,\n className,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getWeekInputTestIds);\n\n const { locale } = useConfiguration();\n const t = useI18n();\n const containerRef = useConsolidatedRef(ref);\n const yearPartId = useUID();\n\n const date = value !== undefined ? parseToDate(value) : undefined;\n const [hasValue, setHasValue] = useState(!!date);\n\n // derive calendarType from locale\n // supporting only (mon=1/sun=7) as of now, support for rest of the days is captured in ENHANCEMENT-1906\n let calendarType: CalendarType = CALENDAR_TYPES.ISO_8601;\n if (locale?.includes('-fw-sun')) calendarType = CALENDAR_TYPES.US;\n else if (locale?.includes('-fw-mon')) calendarType = CALENDAR_TYPES.ISO_8601;\n\n const minYear = min !== undefined ? parseToDate(min).getUTCFullYear() : 1;\n const maxYear = max !== undefined ? parseToDate(max).getUTCFullYear() : 9999;\n\n const [weekInputRef, yearInputRef] = [\n useRef<HTMLInputElement>(null),\n useRef<HTMLInputElement>(null)\n ];\n\n const { description, descriptionID } = useAutoFocusNextInput([weekInputRef, yearInputRef]);\n\n const pickParts = (): DateParts<string | undefined> => {\n return {\n week: weekInputRef.current?.value || undefined,\n year: yearInputRef.current?.value || undefined\n };\n };\n\n const currentlySelectedDate = () => {\n const dateParts = convertWeekYearToDate(pickParts(), calendarType);\n if (dateParts) {\n const year = Number(dateParts.year);\n const month = Number(dateParts.month);\n const day = Number(dateParts.day);\n\n const current = date ?? new Date();\n return new Date(\n current.setUTCFullYear(\n year ?? current.getUTCFullYear(),\n month ?? current.getUTCMonth(),\n day ?? current.getUTCDate()\n )\n );\n }\n };\n\n const inputContainerRef = useRef<HTMLDivElement>(null);\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(\n date ? new Date(date) : new Date(),\n pickParts(),\n calendarType\n );\n if (onFocus && focused) onFocus(callbackParam);\n if (!focused) {\n if (inputContainerRef.current) inputContainerRef.current.scrollTop = 0;\n onBlur?.(callbackParam);\n }\n };\n\n const [open, setOpen, , setPopoverRef, buttonEl, setButtonEl] = usePickerButton();\n\n const onInputChange = () => {\n onChange?.(\n convertToCallbackParameter(date ? new Date(date) : new Date(), pickParts(), calendarType)\n );\n buttonEl?.setAttribute(\n 'aria-label',\n generatePickerButtonAriaLabel(currentlySelectedDate(), 'week', locale, t, open)\n );\n if (weekInputRef.current?.value !== '' && yearInputRef.current?.value !== '') {\n setHasValue(true);\n } else {\n setHasValue(false);\n }\n };\n\n // autoclose picker on focusing out\n useOuterEvent('focusin', [containerRef], e => {\n const { relatedTarget } = e;\n if (\n !isTouchDevice &&\n isInstance(relatedTarget, Node) &&\n containerRef.current?.contains(relatedTarget)\n )\n setOpen(false);\n });\n\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n });\n\n const WeekNumberInput = (\n <PartInput\n data-testid={testIds.controlWeek}\n key='week'\n placeholder={t('week_placeholder')}\n aria-label={displayNames.of('weekOfYear')}\n value={date ? getWeek(date, calendarType, 'UTC') : undefined}\n onChange={onInputChange}\n size={2}\n maxLength={2}\n min={1}\n max={53}\n readOnly={readOnly}\n ref={weekInputRef}\n autoFocus={autoFocus}\n />\n );\n\n const YearInput = (\n <Fragment key='year'>\n <PartInput\n data-testid={testIds.controlYear}\n placeholder={t('year_placeholder')}\n aria-label={displayNames.of('year')}\n aria-describedby={yearPartId}\n value={date ? getWeekYear(date, calendarType, 'UTC') : undefined}\n onChange={onInputChange}\n size={4}\n maxLength={4}\n min={minYear}\n max={maxYear}\n readOnly={readOnly}\n ref={yearInputRef}\n />\n <HiddenText id={yearPartId}>{t('year_input_description')}</HiddenText>\n </Fragment>\n );\n\n useFocusWithin([containerRef], onFocusChange);\n\n const pickerContent = (\n <Flex container={{ direction: 'column' }} as={StyledDialogContent}>\n <DatePicker\n testId={testIds.picker}\n selected={currentlySelectedDate()}\n calendarType={calendarType}\n onChange={selected => {\n const weekInput = weekInputRef.current;\n const yearInput = yearInputRef.current;\n\n if (!weekInput || !yearInput) return;\n\n weekInput.value =\n (selected && getWeek(selected, calendarType, 'UTC').toString().padStart(2, '0')) ||\n '';\n yearInput.value =\n (selected && getWeekYear(selected, calendarType, 'UTC').toString()) || '';\n setOpen(false);\n setTimeout(() => buttonEl?.focus());\n onInputChange();\n }}\n min={min}\n max={max}\n mode='week'\n />\n </Flex>\n );\n\n const Picker = (\n <>\n <StyledInputButton\n data-testid={testIds.openClosePicker}\n variant='simple'\n icon\n ref={setButtonEl}\n onClick={() => setOpen(cur => !cur)}\n aria-label={generatePickerButtonAriaLabel(\n currentlySelectedDate(),\n 'week',\n locale,\n t,\n open\n )}\n readOnly={readOnly}\n disabled={disabled}\n >\n <Icon name='calendar' />\n </StyledInputButton>\n {isTouchDevice ? (\n <TouchDialog\n open={open}\n size='auto'\n ref={setPopoverRef}\n onMouseDown={(e: MouseEvent) => e.stopPropagation()}\n onDismiss={() => setOpen(false)}\n onAfterClose={() => buttonEl?.focus()}\n heading={t('choose_week')}\n aria-label={t('choose_week')}\n >\n {pickerContent}\n </TouchDialog>\n ) : (\n open &&\n buttonEl && (\n <StyledDatePickerDialog\n ref={setPopoverRef}\n target={buttonEl}\n aria-label={t('choose_week')}\n >\n {pickerContent}\n </StyledDatePickerDialog>\n )\n )}\n </>\n );\n\n const Comp = (\n <Flex\n data-testid={label ? undefined : testIds.root}\n as={StyledWeekInput}\n forwardedAs={StyledFormControl}\n container={{ alignItems: 'center', wrap: 'nowrap', justify: 'between' }}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n ref={containerRef}\n onClick={(e: MouseEvent) => {\n if (e.target === containerRef.current) weekInputRef.current?.focus();\n }}\n {...restProps}\n className={createClassName('week-input', className)}\n >\n <Flex\n ref={inputContainerRef}\n as={StyledInputContainer}\n container={{ alignItems: 'center', wrap: 'wrap' }}\n >\n {cap(displayNames.of('weekOfYear') ?? '')} {WeekNumberInput},{YearInput}\n </Flex>\n {!readOnly && (\n <Flex container>\n {hasValue && (\n <StyledInputButton\n data-testid={testIds.clearCurrentWeek}\n aria-label={t('clear_current_date')}\n icon\n onClick={() => {\n const weekInput = weekInputRef.current;\n const yearInput = yearInputRef.current;\n\n if (!weekInput || !yearInput) return;\n\n weekInput.value = '';\n yearInput.value = '';\n setTimeout(() => buttonEl?.focus());\n onInputChange();\n }}\n variant='simple'\n compact\n label={t('clear')}\n >\n <Icon name='times' />\n </StyledInputButton>\n )}\n {Picker}\n </Flex>\n )}\n </Flex>\n );\n\n return label ? (\n <>\n <FormField\n testId={testIds}\n as='fieldset'\n label={label}\n labelHidden={labelHidden}\n id={id}\n info={info}\n readOnly={readOnly}\n status={status}\n required={required}\n disabled={disabled}\n additionalInfo={additionalInfo}\n aria-describedby={descriptionID}\n ref={ref}\n >\n {Comp}\n </FormField>\n {description}\n </>\n ) : (\n Comp\n );\n }\n);\n\nexport default withTestIds(WeekInput, getWeekInputTestIds);\n"]}
1
+ {"version":3,"file":"WeekInput.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/WeekInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,aAAa,EACb,UAAU,EACV,MAAM,EACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAA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AAQ,EAClB,cAAc,EAAE,cAAc,sBACZ,aAAa,EAC/B,GAAG,EAAE,GAAG,YAEP,IAAI,GACK,EACX,WAAW,IACX,CACJ,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { forwardRef, Fragment, useRef, useState } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../../theme';\nimport type { ForwardRefForwardPropsComponent, OmitStrict } from '../../../types';\nimport {\n useConfiguration,\n useConsolidatedRef,\n useFocusWithin,\n useI18n,\n useOuterEvent,\n useTestIds,\n useUID\n} from '../../../hooks';\nimport { cap, createClassName, isInstance, isTouchDevice, withTestIds } from '../../../utils';\nimport TouchDialog from '../../Dialog/TouchDialog';\nimport FormField from '../../FormField';\nimport Icon, { registerIcon } from '../../Icon';\nimport * as calendarIcon from '../../Icon/icons/calendar.icon';\nimport Flex from '../../Flex';\nimport { StyledFormControl } from '../../FormControl';\nimport type { FormControlProps } from '../../FormControl';\nimport DatePicker from '../Picker/DatePicker';\nimport type DateTimeProps from '../DateTime.types';\nimport type { DateTimeCallbackParameter } from '../DateTime.types';\nimport { getWeekInputTestIds } from '../DateTime.test-ids';\nimport HiddenText from '../../HiddenText';\n\nimport {\n parseToDate,\n getWeekYear,\n getWeek,\n generatePickerButtonAriaLabel,\n convertWeekYearToDate,\n buildRawWeekString\n} from './utils';\nimport StyledDateTime, {\n BareInput,\n StyledDatePickerDialog,\n StyledDialogContent,\n StyledInputButton,\n StyledInputContainer\n} from './DateTime.styles';\nimport usePickerButton from './usePickerButton';\nimport PartInput from './PartInput';\nimport useAutoFocusNextInput from './useAutoFocusNextInput';\nimport type { DateParts } from './DateTimeInput.types';\nimport { CALENDAR_TYPES, type CalendarType } from './local';\n\nregisterIcon(calendarIcon);\n\nexport interface WeekInputProps\n extends OmitStrict<FormControlProps, 'value' | 'defaultValue'>,\n DateTimeProps {}\n\ninterface WeekInputComponentProps extends WeekInputProps {\n ref?: Ref<HTMLFieldSetElement>;\n}\n\nexport const StyledWeekInput = styled(StyledDateTime)<WeekInputProps>(props => {\n const {\n theme: { base }\n } = props;\n\n return css`\n padding-inline-end: 0;\n\n ${StyledInputContainer} > ${BareInput}:first-of-type {\n margin-inline-start: ${base.spacing};\n }\n `;\n});\n\nStyledWeekInput.defaultProps = defaultThemeProp;\n\nconst convertToCallbackParameter = (\n date: Date,\n parts: DateParts<string | undefined>,\n calendarType?: CalendarType\n): DateTimeCallbackParameter => {\n if ([parts.week, parts.year].every(Boolean)) {\n const { year, month, day } = convertWeekYearToDate(parts, calendarType) ?? {};\n date.setUTCFullYear(Number(year), Number(month), Number(day));\n return {\n valueAsISOString: date.toISOString(),\n valueAsTimestamp: date.getTime()\n };\n }\n if ([parts.week, parts.year].every(p => !p)) {\n return {\n valueAsISOString: undefined,\n valueAsTimestamp: undefined\n };\n }\n return {\n valueAsISOString: buildRawWeekString(parts.week, parts.year),\n valueAsTimestamp: NaN,\n state: 'incomplete'\n };\n};\n\nconst WeekInput: ForwardRefForwardPropsComponent<WeekInputComponentProps> = forwardRef(\n function WeekInput(\n props: PropsWithoutRef<WeekInputComponentProps>,\n ref: Ref<HTMLFieldSetElement>\n ) {\n const {\n testId,\n value,\n min,\n max,\n id,\n label,\n labelHidden,\n status,\n info,\n required,\n readOnly,\n disabled,\n onChange,\n onFocus,\n onBlur,\n autoFocus,\n additionalInfo,\n className,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getWeekInputTestIds);\n\n const { locale } = useConfiguration();\n const t = useI18n();\n const containerRef = useConsolidatedRef(ref);\n const yearPartId = useUID();\n\n const date = value !== undefined ? parseToDate(value) : undefined;\n const [hasValue, setHasValue] = useState(!!date);\n\n // derive calendarType from locale\n // supporting only (mon=1/sun=7) as of now, support for rest of the days is captured in ENHANCEMENT-1906\n let calendarType: CalendarType = CALENDAR_TYPES.ISO_8601;\n if (locale?.includes('-fw-sun')) calendarType = CALENDAR_TYPES.US;\n else if (locale?.includes('-fw-mon')) calendarType = CALENDAR_TYPES.ISO_8601;\n\n const minYear = min !== undefined ? parseToDate(min).getUTCFullYear() : 1;\n const maxYear = max !== undefined ? parseToDate(max).getUTCFullYear() : 9999;\n\n const [weekInputRef, yearInputRef] = [\n useRef<HTMLInputElement>(null),\n useRef<HTMLInputElement>(null)\n ];\n\n const { description, descriptionID } = useAutoFocusNextInput([weekInputRef, yearInputRef]);\n\n const pickParts = (): DateParts<string | undefined> => {\n return {\n week: weekInputRef.current?.value || undefined,\n year: yearInputRef.current?.value || undefined\n };\n };\n\n const currentlySelectedDate = () => {\n const dateParts = convertWeekYearToDate(pickParts(), calendarType);\n if (dateParts) {\n const year = Number(dateParts.year);\n const month = Number(dateParts.month);\n const day = Number(dateParts.day);\n\n const current = date ?? new Date();\n return new Date(\n current.setUTCFullYear(\n year ?? current.getUTCFullYear(),\n month ?? current.getUTCMonth(),\n day ?? current.getUTCDate()\n )\n );\n }\n };\n\n const inputContainerRef = useRef<HTMLDivElement>(null);\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(\n date ? new Date(date) : new Date(),\n pickParts(),\n calendarType\n );\n if (onFocus && focused) onFocus(callbackParam);\n if (!focused) {\n if (inputContainerRef.current) inputContainerRef.current.scrollTop = 0;\n onBlur?.(callbackParam);\n }\n };\n\n const [open, setOpen, , setPopoverRef, buttonEl, setButtonEl] = usePickerButton();\n\n const onInputChange = () => {\n onChange?.(\n convertToCallbackParameter(date ? new Date(date) : new Date(), pickParts(), calendarType)\n );\n buttonEl?.setAttribute(\n 'aria-label',\n generatePickerButtonAriaLabel(currentlySelectedDate(), 'week', locale, t, open)\n );\n if (weekInputRef.current?.value !== '' && yearInputRef.current?.value !== '') {\n setHasValue(true);\n } else {\n setHasValue(false);\n }\n };\n\n // autoclose picker on focusing out\n useOuterEvent('focusin', [containerRef], e => {\n const { relatedTarget } = e;\n if (\n !isTouchDevice &&\n isInstance(relatedTarget, Node) &&\n containerRef.current?.contains(relatedTarget)\n )\n setOpen(false);\n });\n\n const displayNames = new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n });\n\n const WeekNumberInput = (\n <PartInput\n data-testid={testIds.controlWeek}\n key='week'\n placeholder={t('week_placeholder')}\n aria-label={displayNames.of('weekOfYear')}\n value={date ? getWeek(date, calendarType, 'UTC') : undefined}\n onChange={onInputChange}\n size={2}\n maxLength={2}\n min={1}\n max={53}\n readOnly={readOnly}\n ref={weekInputRef}\n autoFocus={autoFocus}\n />\n );\n\n const YearInput = (\n <Fragment key='year'>\n <PartInput\n data-testid={testIds.controlYear}\n placeholder={t('year_placeholder')}\n aria-label={displayNames.of('year')}\n aria-describedby={yearPartId}\n value={date ? getWeekYear(date, calendarType, 'UTC') : undefined}\n onChange={onInputChange}\n size={4}\n maxLength={4}\n min={minYear}\n max={maxYear}\n readOnly={readOnly}\n ref={yearInputRef}\n />\n <HiddenText id={yearPartId}>{t('year_input_description')}</HiddenText>\n </Fragment>\n );\n\n useFocusWithin([containerRef], onFocusChange);\n\n const pickerContent = (\n <Flex container={{ direction: 'column' }} as={StyledDialogContent}>\n <DatePicker\n testId={testIds.picker}\n selected={currentlySelectedDate()}\n calendarType={calendarType}\n onChange={selected => {\n const weekInput = weekInputRef.current;\n const yearInput = yearInputRef.current;\n\n if (!weekInput || !yearInput) return;\n\n weekInput.value =\n (selected && getWeek(selected, calendarType, 'UTC').toString().padStart(2, '0')) ||\n '';\n yearInput.value =\n (selected && getWeekYear(selected, calendarType, 'UTC').toString()) || '';\n setOpen(false);\n setTimeout(() => buttonEl?.focus());\n onInputChange();\n }}\n min={min}\n max={max}\n mode='week'\n />\n </Flex>\n );\n\n const Picker = (\n <>\n <StyledInputButton\n data-testid={testIds.openClosePicker}\n variant='simple'\n icon\n ref={setButtonEl}\n onClick={() => setOpen(cur => !cur)}\n aria-label={generatePickerButtonAriaLabel(\n currentlySelectedDate(),\n 'week',\n locale,\n t,\n open\n )}\n readOnly={readOnly}\n disabled={disabled}\n >\n <Icon name='calendar' />\n </StyledInputButton>\n {isTouchDevice ? (\n <TouchDialog\n open={open}\n size='auto'\n ref={setPopoverRef}\n onMouseDown={(e: MouseEvent) => e.stopPropagation()}\n onDismiss={() => setOpen(false)}\n onAfterClose={() => buttonEl?.focus()}\n heading={t('choose_week')}\n aria-label={t('choose_week')}\n >\n {pickerContent}\n </TouchDialog>\n ) : (\n open &&\n buttonEl && (\n <StyledDatePickerDialog\n ref={setPopoverRef}\n target={buttonEl}\n aria-label={t('choose_week')}\n >\n {pickerContent}\n </StyledDatePickerDialog>\n )\n )}\n </>\n );\n\n const Comp = (\n <Flex\n data-testid={label ? undefined : testIds.root}\n as={StyledWeekInput}\n forwardedAs={StyledFormControl}\n container={{ alignItems: 'center', wrap: 'nowrap', justify: 'between' }}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n ref={containerRef}\n onClick={(e: MouseEvent) => {\n if (e.target === containerRef.current) weekInputRef.current?.focus();\n }}\n {...restProps}\n className={createClassName('week-input', className)}\n >\n <Flex\n ref={inputContainerRef}\n as={StyledInputContainer}\n container={{ alignItems: 'center', wrap: 'wrap' }}\n >\n {cap(displayNames.of('weekOfYear') ?? '')} {WeekNumberInput},{YearInput}\n </Flex>\n {!readOnly && (\n <Flex container>\n {hasValue && (\n <StyledInputButton\n data-testid={testIds.clearCurrentWeek}\n aria-label={t('clear_current_date')}\n icon\n onClick={() => {\n const weekInput = weekInputRef.current;\n const yearInput = yearInputRef.current;\n\n if (!weekInput || !yearInput) return;\n\n weekInput.value = '';\n yearInput.value = '';\n setTimeout(() => buttonEl?.focus());\n onInputChange();\n }}\n variant='simple'\n compact\n label={t('clear')}\n >\n <Icon name='times' />\n </StyledInputButton>\n )}\n {Picker}\n </Flex>\n )}\n </Flex>\n );\n\n return label ? (\n <>\n <FormField\n testId={testIds}\n as='fieldset'\n label={label}\n labelHidden={labelHidden}\n id={id}\n info={info}\n readOnly={readOnly}\n status={status}\n required={required}\n disabled={disabled}\n additionalInfo={additionalInfo}\n aria-describedby={descriptionID}\n ref={ref}\n >\n {Comp}\n </FormField>\n {description}\n </>\n ) : (\n Comp\n );\n }\n);\n\nexport default withTestIds(WeekInput, getWeekInputTestIds);\n"]}
@@ -37,24 +37,22 @@ export interface BaseDialogProps {
37
37
  ref?: PopoverProps['ref'];
38
38
  }
39
39
  export type DialogProps = WithAttributes<'div', BaseDialogProps>;
40
- /** A simple callback or an object to customize a subset button properties. */
41
- export type FormAction = (() => void) | {
40
+ /**
41
+ * A simple callback or an object to customize a subset button properties.
42
+ * The callback should return true or Promise resolving to true value to indicate whether the dialog should close.
43
+ */
44
+ export type FormAction = (() => void | boolean | Promise<void | boolean>) | {
42
45
  text?: string;
43
46
  disabled?: boolean;
44
- handler: () => void;
47
+ handler: () => void | boolean | Promise<void | boolean>;
45
48
  };
46
49
  export type FormDialogProps = WithAttributes<'div', BaseDialogProps & {
47
50
  /** Called when the user presses escape or clicks away. */
48
51
  onDismiss?: () => void;
49
- /**
50
- * Renders a standard design system cancel button.
51
- * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.
52
- * Invocation of this indicates the user wishes to cancel any changes and close the dialog.
53
- */
54
- onCancel: FormAction;
55
52
  /**
56
53
  * Renders a standard design system submit button.
57
54
  * Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.
55
+ * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.
58
56
  */
59
57
  onSubmit: FormAction;
60
58
  } & ({
@@ -68,6 +66,36 @@ export type FormDialogProps = WithAttributes<'div', BaseDialogProps & {
68
66
  /** Provide a contextually sufficient aria label if a visible heading is not provided. */
69
67
  'aria-label': string;
70
68
  additionalInfo?: never;
69
+ }) & ({
70
+ /**
71
+ * Called after the dialog has completely closed and safe to unmount.
72
+ * It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.
73
+ */
74
+ onAfterClose?: () => void;
75
+ /**
76
+ * Renders a standard design system cancel button.
77
+ * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.
78
+ * Invocation of this indicates the user wishes to cancel any changes and close the dialog.
79
+ * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.
80
+ *
81
+ * @default () => true
82
+ */
83
+ onCancel: FormAction | undefined;
84
+ } | {
85
+ /**
86
+ * Called after the dialog has completely closed and safe to unmount.
87
+ * It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.
88
+ */
89
+ onAfterClose: () => void;
90
+ /**
91
+ * Renders a standard design system cancel button.
92
+ * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.
93
+ * Invocation of this indicates the user wishes to cancel any changes and close the dialog.
94
+ * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.
95
+ *
96
+ * @default () => true
97
+ */
98
+ onCancel?: FormAction;
71
99
  })>;
72
100
  export type InfoDialogProps = WithAttributes<'div', OmitStrict<BaseDialogProps, 'arrow'> & {
73
101
  /** A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property. */
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.types.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,CAAC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AI,CAAC;IAE1B;;;;;;;OAOG;IAEH,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;CAClC,GACD;IACE;;;OAGG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IAEzB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CACJ,CACJ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,CAC1C,KAAK,EACL,UAAU,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG;IACrC,6JAA6J;IAC7J,OAAO,CAAC,EACJ,MAAM,GACN;QACE,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,CAAC;IAEN,2IAA2I;IAC3I,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { OmitStrict, WithAttributes } from '../../types';\nimport type { PopoverProps } from '../Popover';\nimport type { ProgressProps } from '../Progress';\nimport type { AdditionalInfoProps } from '../AdditionalInfo';\n\nexport interface BaseDialogProps {\n /**\n * Certain uses of dialogs require a linear edge with an input like control.\n * There an arrow is not desired.\n * @default true\n */\n arrow?: PopoverProps['arrow'];\n\n /**\n * An element the dialog is contextually and visually associated with. Normally a triggering button.\n * Components rendering Dialog should mount and unmount instances based on this value.\n */\n target: HTMLElement;\n\n /** Content for the dialog. Avoid form control buttons within as those should be rendered by way of onCancel and onSubmit with FormDialog. */\n children: PopoverProps['children'];\n\n /** If there is a progress state either on opening, or after submit, you must indicate as such. A custom message is supported as well. */\n progress?: boolean | ProgressProps['message'];\n\n /** Optionally render the dialog element at the end of the body or within a specified element. */\n portal?: PopoverProps['portal'];\n\n /** Positioning strategy for solving rendering scenarios. */\n strategy?: PopoverProps['strategy'];\n\n /**\n * Intended positioning placement for the dialog element.\n * Placement may auto adjust based on screen position and other layout variables.\n */\n placement?: PopoverProps['placement'];\n /**\n * Optionally determines whether to trap the focus inside the dialog, preventing it from being moved outside until the dialog is closed.\n * @default false\n */\n focusTrap?: boolean;\n\n /** Reference to the dialog's root element. */\n ref?: PopoverProps['ref'];\n}\n\nexport type DialogProps = WithAttributes<'div', BaseDialogProps>;\n\n/** A simple callback or an object to customize a subset button properties. */\nexport type FormAction =\n | (() => void)\n | {\n text?: string;\n disabled?: boolean;\n handler: () => void;\n };\n\nexport type FormDialogProps = WithAttributes<\n 'div',\n BaseDialogProps & {\n /** Called when the user presses escape or clicks away. */\n onDismiss?: () => void;\n\n /**\n * Renders a standard design system cancel button.\n * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.\n * Invocation of this indicates the user wishes to cancel any changes and close the dialog.\n */\n onCancel: FormAction;\n\n /**\n * Renders a standard design system submit button.\n * Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.\n */\n onSubmit: FormAction;\n } & (\n | {\n /** A string to indicate context for the dialog. The dialog will be labelled by this value. */\n heading: string;\n /** Show additional info in form dialog header. */\n additionalInfo?: AdditionalInfoProps;\n 'aria-label'?: never;\n }\n | {\n heading?: never;\n /** Provide a contextually sufficient aria label if a visible heading is not provided. */\n 'aria-label': string;\n additionalInfo?: never;\n }\n )\n>;\n\nexport type InfoDialogProps = WithAttributes<\n 'div',\n OmitStrict<BaseDialogProps, 'arrow'> & {\n /** A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property. */\n heading?:\n | string\n | {\n primary: string;\n secondary?: string;\n visual?: ReactNode;\n };\n\n /** Renders a standard design system dismiss button to close the dialog when the user clicks this button, presses escape or clicks away. */\n onDismiss: () => void;\n }\n>;\n\n/**\n * Components which render Dialog internally may need to offer some control to consuming components.\n * Use this interface to offer an imperative handle for shared control.\n */\nexport interface DialogHandleValue {\n open: () => void;\n close: () => void;\n}\n"]}
1
+ {"version":3,"file":"Dialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { OmitStrict, WithAttributes } from '../../types';\nimport type { PopoverProps } from '../Popover';\nimport type { ProgressProps } from '../Progress';\nimport type { AdditionalInfoProps } from '../AdditionalInfo';\n\nexport interface BaseDialogProps {\n /**\n * Certain uses of dialogs require a linear edge with an input like control.\n * There an arrow is not desired.\n * @default true\n */\n arrow?: PopoverProps['arrow'];\n\n /**\n * An element the dialog is contextually and visually associated with. Normally a triggering button.\n * Components rendering Dialog should mount and unmount instances based on this value.\n */\n target: HTMLElement;\n\n /** Content for the dialog. Avoid form control buttons within as those should be rendered by way of onCancel and onSubmit with FormDialog. */\n children: PopoverProps['children'];\n\n /** If there is a progress state either on opening, or after submit, you must indicate as such. A custom message is supported as well. */\n progress?: boolean | ProgressProps['message'];\n\n /** Optionally render the dialog element at the end of the body or within a specified element. */\n portal?: PopoverProps['portal'];\n\n /** Positioning strategy for solving rendering scenarios. */\n strategy?: PopoverProps['strategy'];\n\n /**\n * Intended positioning placement for the dialog element.\n * Placement may auto adjust based on screen position and other layout variables.\n */\n placement?: PopoverProps['placement'];\n /**\n * Optionally determines whether to trap the focus inside the dialog, preventing it from being moved outside until the dialog is closed.\n * @default false\n */\n focusTrap?: boolean;\n\n /** Reference to the dialog's root element. */\n ref?: PopoverProps['ref'];\n}\n\nexport type DialogProps = WithAttributes<'div', BaseDialogProps>;\n\n/**\n * A simple callback or an object to customize a subset button properties.\n * The callback should return true or Promise resolving to true value to indicate whether the dialog should close.\n */\nexport type FormAction =\n | (() => void | boolean | Promise<void | boolean>)\n | {\n text?: string;\n disabled?: boolean;\n handler: () => void | boolean | Promise<void | boolean>;\n };\n\nexport type FormDialogProps = WithAttributes<\n 'div',\n BaseDialogProps & {\n /** Called when the user presses escape or clicks away. */\n onDismiss?: () => void;\n\n /**\n * Renders a standard design system submit button.\n * Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.\n * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.\n */\n onSubmit: FormAction;\n } & (\n | {\n /** A string to indicate context for the dialog. The dialog will be labelled by this value. */\n heading: string;\n /** Show additional info in form dialog header. */\n additionalInfo?: AdditionalInfoProps;\n 'aria-label'?: never;\n }\n | {\n heading?: never;\n /** Provide a contextually sufficient aria label if a visible heading is not provided. */\n 'aria-label': string;\n additionalInfo?: never;\n }\n ) &\n (\n | {\n /**\n * Called after the dialog has completely closed and safe to unmount.\n * It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.\n */\n onAfterClose?: () => void;\n\n /**\n * Renders a standard design system cancel button.\n * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.\n * Invocation of this indicates the user wishes to cancel any changes and close the dialog.\n * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.\n *\n * @default () => true\n */\n // Required key accepting undefined: forwarding an optional prop is allowed, omitting it requires onAfterClose.\n onCancel: FormAction | undefined;\n }\n | {\n /**\n * Called after the dialog has completely closed and safe to unmount.\n * It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.\n */\n onAfterClose: () => void;\n\n /**\n * Renders a standard design system cancel button.\n * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.\n * Invocation of this indicates the user wishes to cancel any changes and close the dialog.\n * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.\n *\n * @default () => true\n */\n onCancel?: FormAction;\n }\n )\n>;\n\nexport type InfoDialogProps = WithAttributes<\n 'div',\n OmitStrict<BaseDialogProps, 'arrow'> & {\n /** A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property. */\n heading?:\n | string\n | {\n primary: string;\n secondary?: string;\n visual?: ReactNode;\n };\n\n /** Renders a standard design system dismiss button to close the dialog when the user clicks this button, presses escape or clicks away. */\n onDismiss: () => void;\n }\n>;\n\n/**\n * Components which render Dialog internally may need to offer some control to consuming components.\n * Use this interface to offer an imperative handle for shared control.\n */\nexport interface DialogHandleValue {\n open: () => void;\n close: () => void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAyB7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,eAAO,MAAM,gBAAgB;;uNAAmB,CAAC;AAEjD,QAAA,MAAM,UAAU,6HAwKf,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FormDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AA0B7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,eAAO,MAAM,gBAAgB;;uNAAmB,CAAC;AAEjD,QAAA,MAAM,UAAU,6HA8Kf,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';
2
+ import { forwardRef, useCallback, useEffect, useLayoutEffect, useRef } from 'react';
3
3
  import styled from 'styled-components';
4
- import { useConsolidatedRef, useContentTabIndex, useEscape, useI18n, useOuterEvent, useUID } from '../../hooks';
4
+ import { useConsolidatedRef, useContentTabIndex, useEscape, useEvent, useI18n, useOuterEvent, useUID } from '../../hooks';
5
5
  import { getActiveElement, focusNonInteractiveElement } from '../../utils';
6
6
  import Button from '../Button';
7
7
  import Text from '../Text';
@@ -11,7 +11,7 @@ import Flex from '../Flex';
11
11
  import { StyledChildrenWrap, StyledDialogContent, StyledDialogFooter, StyledDialogHeader } from './Dialog.styles';
12
12
  import Dialog from './Dialog';
13
13
  export const StyledFormDialog = styled(Dialog) ``;
14
- const FormDialog = forwardRef(function FormDialog({ arrow = true, target, heading, 'aria-label': ariaLabel, children, progress, onDismiss, onCancel, onSubmit, additionalInfo, ...restProps }, ref) {
14
+ const FormDialog = forwardRef(function FormDialog({ arrow = true, target, heading, 'aria-label': ariaLabel, children, progress, onDismiss, onCancel = () => true, onSubmit, onAfterClose, additionalInfo, ...restProps }, ref) {
15
15
  const t = useI18n();
16
16
  const headingId = useUID();
17
17
  const headingRef = useRef(null);
@@ -29,28 +29,36 @@ const FormDialog = forwardRef(function FormDialog({ arrow = true, target, headin
29
29
  }
30
30
  };
31
31
  const onCancelHandler = typeof onCancel === 'function' ? onCancel : onCancel.handler;
32
- useEscape(e => {
32
+ const closeDialog = useCallback(async () => {
33
33
  if (onDismiss) {
34
34
  onDismiss();
35
+ onAfterClose?.();
35
36
  }
36
37
  else {
37
- onCancelHandler();
38
+ const result = await onCancelHandler();
39
+ if (result !== false) {
40
+ onAfterClose?.();
41
+ }
38
42
  }
43
+ }, [onDismiss, onCancelHandler, onAfterClose]);
44
+ useEscape(e => {
45
+ closeDialog();
39
46
  e.stopPropagation();
40
- }, dialogRef, [onDismiss, onCancelHandler]);
47
+ }, dialogRef, [closeDialog]);
41
48
  useOuterEvent('mousedown', [target, dialogRef], () => {
42
- if (onDismiss) {
43
- onDismiss();
44
- }
45
- else {
46
- onCancelHandler();
47
- }
49
+ closeDialog();
48
50
  });
49
51
  // Using layout effect to capture the focused element prior to dialog elements taking focus.
50
52
  useLayoutEffect(() => {
51
53
  const initiatorElement = getActiveElement();
52
54
  return () => {
53
- if (initiatorElement instanceof HTMLElement && initiatorElement.isConnected) {
55
+ const activeElement = getActiveElement();
56
+ if (initiatorElement instanceof HTMLElement &&
57
+ initiatorElement.isConnected &&
58
+ // Do not steal focus from an element the user moved to before an async close.
59
+ (!activeElement ||
60
+ activeElement === document.body ||
61
+ dialogRef.current?.contains(activeElement))) {
54
62
  initiatorElement.focus();
55
63
  }
56
64
  };
@@ -60,33 +68,27 @@ const FormDialog = forwardRef(function FormDialog({ arrow = true, target, headin
60
68
  setFocus();
61
69
  }
62
70
  }, [progress]);
63
- useEffect(() => {
64
- const closeDialog = () => {
65
- setTimeout(() => {
66
- if (onDismiss) {
67
- onDismiss();
68
- }
69
- else {
70
- onCancelHandler();
71
- }
72
- // The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.
73
- }, 0);
74
- };
75
- target.addEventListener('click', closeDialog);
76
- return () => {
77
- target.removeEventListener('click', closeDialog);
78
- };
79
- }, []);
71
+ // The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.
72
+ useEvent('click', () => setTimeout(closeDialog, 0), {
73
+ target,
74
+ dependencies: [target, closeDialog]
75
+ });
80
76
  return (_jsxs(StyledFormDialog, { ...restProps, ...(heading === undefined
81
77
  ? { 'aria-label': ariaLabel }
82
78
  : { 'aria-labelledby': headingId }), arrow: arrow, target: target, progress: progress, ref: dialogRef, children: [heading !== undefined && (_jsxs(Flex, { container: {
83
79
  alignItems: 'center',
84
80
  gap: additionalInfo?.heading ? 1 : undefined,
85
81
  pad: [2, 2, 1]
86
- }, item: { shrink: 0 }, as: StyledDialogHeader, children: [_jsx(Text, { ref: headingRef, id: headingId, variant: 'h2', children: heading }), additionalInfo?.heading && (_jsx(AdditionalInfo, { heading: additionalInfo.heading, children: additionalInfo.children }))] })), _jsxs(Flex, { item: { grow: 1 }, as: StyledDialogContent, ref: dialogContentRef, tabIndex: contentTabIndex, children: [children && (_jsx(StyledChildrenWrap, { inert: progress ? '' : undefined, children: children })), _jsx(Progress, { visible: !!progress, focusOnVisible: true, placement: 'local', message: typeof progress === 'string' ? progress : undefined })] }), _jsxs(Flex, { container: { alignItems: 'center', justify: 'between', pad: 2 }, item: { shrink: 0 }, as: StyledDialogFooter, children: [_jsx(Button, { onClick: () => {
87
- onCancelHandler();
88
- }, disabled: typeof onCancel !== 'function' ? onCancel.disabled : undefined, children: typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel') }), _jsx(Button, { variant: 'primary', onClick: () => {
89
- (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();
82
+ }, item: { shrink: 0 }, as: StyledDialogHeader, children: [_jsx(Text, { ref: headingRef, id: headingId, variant: 'h2', children: heading }), additionalInfo?.heading && (_jsx(AdditionalInfo, { heading: additionalInfo.heading, children: additionalInfo.children }))] })), _jsxs(Flex, { item: { grow: 1 }, as: StyledDialogContent, ref: dialogContentRef, tabIndex: contentTabIndex, children: [children && (_jsx(StyledChildrenWrap, { inert: progress ? '' : undefined, children: children })), _jsx(Progress, { visible: !!progress, focusOnVisible: true, placement: 'local', message: typeof progress === 'string' ? progress : undefined })] }), _jsxs(Flex, { container: { alignItems: 'center', justify: 'between', pad: 2 }, item: { shrink: 0 }, as: StyledDialogFooter, children: [_jsx(Button, { onClick: async () => {
83
+ const result = await onCancelHandler();
84
+ if (result !== false) {
85
+ onAfterClose?.();
86
+ }
87
+ }, disabled: typeof onCancel !== 'function' ? onCancel.disabled : undefined, children: typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel') }), _jsx(Button, { variant: 'primary', onClick: async () => {
88
+ const result = await (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();
89
+ if (result !== false) {
90
+ onAfterClose?.();
91
+ }
90
92
  }, disabled: typeof onSubmit !== 'function' ? onSubmit.disabled : undefined, children: typeof onSubmit !== 'function' && onSubmit.text ? onSubmit.text : t('submit') })] })] }));
91
93
  });
92
94
  export default FormDialog;
@@ -1 +1 @@
1
- {"version":3,"file":"FormDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.t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,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACvE,EAET,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE;4BACZ,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACnE,CAAC,EACD,QAAQ,EAAE,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAEvE,OAAO,QAAQ,KAAK,UAAU,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACvE,IACJ,IACU,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useContentTabIndex,\n useEscape,\n useI18n,\n useOuterEvent,\n useUID\n} from '../../hooks';\nimport { getActiveElement, focusNonInteractiveElement } from '../../utils';\nimport Button from '../Button';\nimport Text from '../Text';\nimport Progress from '../Progress';\nimport AdditionalInfo from '../AdditionalInfo';\nimport type { RefElement } from '../../types';\nimport Flex from '../Flex';\n\nimport {\n StyledChildrenWrap,\n StyledDialogContent,\n StyledDialogFooter,\n StyledDialogHeader\n} from './Dialog.styles';\nimport type { FormDialogProps } from './Dialog.types';\nimport Dialog from './Dialog';\n\nexport const StyledFormDialog = styled(Dialog)``;\n\nconst FormDialog = forwardRef<RefElement<FormDialogProps>, PropsWithoutRef<FormDialogProps>>(\n function FormDialog(\n {\n arrow = true,\n target,\n heading,\n 'aria-label': ariaLabel,\n children,\n progress,\n onDismiss,\n onCancel,\n onSubmit,\n additionalInfo,\n ...restProps\n },\n ref\n ) {\n const t = useI18n();\n const headingId = useUID();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const dialogRef = useConsolidatedRef(ref);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n const contentTabIndex = useContentTabIndex(dialogRef, dialogContentRef, [], [progress]);\n\n const setFocus = () => {\n if (progress || !dialogRef.current) return;\n if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, heading ?? ariaLabel);\n } else {\n focusNonInteractiveElement(dialogRef.current, heading ?? ariaLabel);\n }\n };\n\n const onCancelHandler = typeof onCancel === 'function' ? onCancel : onCancel.handler;\n\n useEscape(\n e => {\n if (onDismiss) {\n onDismiss();\n } else {\n onCancelHandler();\n }\n e.stopPropagation();\n },\n dialogRef,\n [onDismiss, onCancelHandler]\n );\n\n useOuterEvent('mousedown', [target, dialogRef], () => {\n if (onDismiss) {\n onDismiss();\n } else {\n onCancelHandler();\n }\n });\n\n // Using layout effect to capture the focused element prior to dialog elements taking focus.\n useLayoutEffect(() => {\n const initiatorElement = getActiveElement();\n\n return () => {\n if (initiatorElement instanceof HTMLElement && initiatorElement.isConnected) {\n initiatorElement.focus();\n }\n };\n }, []);\n\n useEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n useEffect(() => {\n const closeDialog = () => {\n setTimeout(() => {\n if (onDismiss) {\n onDismiss();\n } else {\n onCancelHandler();\n }\n // The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.\n }, 0);\n };\n\n target.addEventListener('click', closeDialog);\n\n return () => {\n target.removeEventListener('click', closeDialog);\n };\n }, []);\n\n return (\n <StyledFormDialog\n {...restProps}\n {...(heading === undefined\n ? { 'aria-label': ariaLabel }\n : { 'aria-labelledby': headingId })}\n arrow={arrow}\n target={target}\n progress={progress}\n ref={dialogRef}\n >\n {heading !== undefined && (\n <Flex\n container={{\n alignItems: 'center',\n gap: additionalInfo?.heading ? 1 : undefined,\n pad: [2, 2, 1]\n }}\n item={{ shrink: 0 }}\n as={StyledDialogHeader}\n >\n <Text ref={headingRef} id={headingId} variant='h2'>\n {heading}\n </Text>\n {additionalInfo?.heading && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.children}\n </AdditionalInfo>\n )}\n </Flex>\n )}\n\n <Flex\n item={{ grow: 1 }}\n as={StyledDialogContent}\n ref={dialogContentRef}\n tabIndex={contentTabIndex}\n >\n {children && (\n <StyledChildrenWrap inert={progress ? '' : undefined}>{children}</StyledChildrenWrap>\n )}\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Flex>\n\n <Flex\n container={{ alignItems: 'center', justify: 'between', pad: 2 }}\n item={{ shrink: 0 }}\n as={StyledDialogFooter}\n >\n <Button\n onClick={() => {\n onCancelHandler();\n }}\n disabled={typeof onCancel !== 'function' ? onCancel.disabled : undefined}\n >\n {typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel')}\n </Button>\n\n <Button\n variant='primary'\n onClick={() => {\n (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();\n }}\n disabled={typeof onSubmit !== 'function' ? onSubmit.disabled : undefined}\n >\n {typeof onSubmit !== 'function' && onSubmit.text ? onSubmit.text : t('submit')}\n </Button>\n </Flex>\n </StyledFormDialog>\n );\n }\n);\n\nexport default FormDialog;\n"]}
1
+ {"version":3,"file":"FormDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,aAAa,EACb,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAA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GACvE,EAET,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,KAAK,IAAI,EAAE;4BAClB,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;4BACtF,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;gCACrB,YAAY,EAAE,EAAE,CAAC;4BACnB,CAAC;wBACH,CAAC,EACD,QAAQ,EAAE,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAEvE,OAAO,QAAQ,KAAK,UAAU,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GACvE,IACJ,IACU,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useContentTabIndex,\n useEscape,\n useEvent,\n useI18n,\n useOuterEvent,\n useUID\n} from '../../hooks';\nimport { getActiveElement, focusNonInteractiveElement } from '../../utils';\nimport Button from '../Button';\nimport Text from '../Text';\nimport Progress from '../Progress';\nimport AdditionalInfo from '../AdditionalInfo';\nimport type { RefElement } from '../../types';\nimport Flex from '../Flex';\n\nimport {\n StyledChildrenWrap,\n StyledDialogContent,\n StyledDialogFooter,\n StyledDialogHeader\n} from './Dialog.styles';\nimport type { FormDialogProps } from './Dialog.types';\nimport Dialog from './Dialog';\n\nexport const StyledFormDialog = styled(Dialog)``;\n\nconst FormDialog = forwardRef<RefElement<FormDialogProps>, PropsWithoutRef<FormDialogProps>>(\n function FormDialog(\n {\n arrow = true,\n target,\n heading,\n 'aria-label': ariaLabel,\n children,\n progress,\n onDismiss,\n onCancel = () => true,\n onSubmit,\n onAfterClose,\n additionalInfo,\n ...restProps\n },\n ref\n ) {\n const t = useI18n();\n const headingId = useUID();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const dialogRef = useConsolidatedRef(ref);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n const contentTabIndex = useContentTabIndex(dialogRef, dialogContentRef, [], [progress]);\n\n const setFocus = () => {\n if (progress || !dialogRef.current) return;\n if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, heading ?? ariaLabel);\n } else {\n focusNonInteractiveElement(dialogRef.current, heading ?? ariaLabel);\n }\n };\n\n const onCancelHandler = typeof onCancel === 'function' ? onCancel : onCancel.handler;\n\n const closeDialog = useCallback(async () => {\n if (onDismiss) {\n onDismiss();\n onAfterClose?.();\n } else {\n const result = await onCancelHandler();\n if (result !== false) {\n onAfterClose?.();\n }\n }\n }, [onDismiss, onCancelHandler, onAfterClose]);\n\n useEscape(\n e => {\n closeDialog();\n e.stopPropagation();\n },\n dialogRef,\n [closeDialog]\n );\n\n useOuterEvent('mousedown', [target, dialogRef], () => {\n closeDialog();\n });\n\n // Using layout effect to capture the focused element prior to dialog elements taking focus.\n useLayoutEffect(() => {\n const initiatorElement = getActiveElement();\n\n return () => {\n const activeElement = getActiveElement();\n if (\n initiatorElement instanceof HTMLElement &&\n initiatorElement.isConnected &&\n // Do not steal focus from an element the user moved to before an async close.\n (!activeElement ||\n activeElement === document.body ||\n dialogRef.current?.contains(activeElement))\n ) {\n initiatorElement.focus();\n }\n };\n }, []);\n\n useEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n // The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.\n useEvent('click', () => setTimeout(closeDialog, 0), {\n target,\n dependencies: [target, closeDialog]\n });\n\n return (\n <StyledFormDialog\n {...restProps}\n {...(heading === undefined\n ? { 'aria-label': ariaLabel }\n : { 'aria-labelledby': headingId })}\n arrow={arrow}\n target={target}\n progress={progress}\n ref={dialogRef}\n >\n {heading !== undefined && (\n <Flex\n container={{\n alignItems: 'center',\n gap: additionalInfo?.heading ? 1 : undefined,\n pad: [2, 2, 1]\n }}\n item={{ shrink: 0 }}\n as={StyledDialogHeader}\n >\n <Text ref={headingRef} id={headingId} variant='h2'>\n {heading}\n </Text>\n {additionalInfo?.heading && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.children}\n </AdditionalInfo>\n )}\n </Flex>\n )}\n\n <Flex\n item={{ grow: 1 }}\n as={StyledDialogContent}\n ref={dialogContentRef}\n tabIndex={contentTabIndex}\n >\n {children && (\n <StyledChildrenWrap inert={progress ? '' : undefined}>{children}</StyledChildrenWrap>\n )}\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Flex>\n\n <Flex\n container={{ alignItems: 'center', justify: 'between', pad: 2 }}\n item={{ shrink: 0 }}\n as={StyledDialogFooter}\n >\n <Button\n onClick={async () => {\n const result = await onCancelHandler();\n if (result !== false) {\n onAfterClose?.();\n }\n }}\n disabled={typeof onCancel !== 'function' ? onCancel.disabled : undefined}\n >\n {typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel')}\n </Button>\n\n <Button\n variant='primary'\n onClick={async () => {\n const result = await (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();\n if (result !== false) {\n onAfterClose?.();\n }\n }}\n disabled={typeof onSubmit !== 'function' ? onSubmit.disabled : undefined}\n >\n {typeof onSubmit !== 'function' && onSubmit.text ? onSubmit.text : t('submit')}\n </Button>\n </Flex>\n </StyledFormDialog>\n );\n }\n);\n\nexport default FormDialog;\n"]}
@@ -0,0 +1,5 @@
1
+ import type { PropsWithoutRef } from 'react';
2
+ import type { FormDialogProps } from './Dialog.types';
3
+ declare const FormDialogWrapper: import("react").ForwardRefExoticComponent<PropsWithoutRef<FormDialogProps> & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default FormDialogWrapper;
5
+ //# sourceMappingURL=FormDialogWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormDialogWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialogWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,QAAA,MAAM,iBAAiB,6HAQtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { isTouchDevice } from '../../utils';
4
+ import FormDialog from './FormDialog';
5
+ import TouchFormDialog from './TouchFormDialog';
6
+ const FormDialogWrapper = forwardRef(function FormDialogWrapper(props, ref) {
7
+ if (isTouchDevice) {
8
+ return _jsx(TouchFormDialog, { ...props, ref: ref });
9
+ }
10
+ return _jsx(FormDialog, { ...props, ref: ref });
11
+ });
12
+ export default FormDialogWrapper;
13
+ //# sourceMappingURL=FormDialogWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormDialogWrapper.js","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialogWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,iBAAiB,GAAG,UAAU,CAClC,SAAS,iBAAiB,CAAC,KAAK,EAAE,GAAG;IACnC,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,KAAC,eAAe,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;IAClD,CAAC;IAED,OAAO,KAAC,UAAU,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AAC7C,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport type { RefElement } from '../../types';\nimport { isTouchDevice } from '../../utils';\n\nimport type { FormDialogProps } from './Dialog.types';\nimport FormDialog from './FormDialog';\nimport TouchFormDialog from './TouchFormDialog';\n\nconst FormDialogWrapper = forwardRef<RefElement<FormDialogProps>, PropsWithoutRef<FormDialogProps>>(\n function FormDialogWrapper(props, ref) {\n if (isTouchDevice) {\n return <TouchFormDialog {...props} ref={ref} />;\n }\n\n return <FormDialog {...props} ref={ref} />;\n }\n);\n\nexport default FormDialogWrapper;\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { ForwardRefForwardPropsComponent } from '../../types';
2
2
  import type { TouchDialogProps } from './TouchDialog.types';
3
- export declare const TouchDialog: ForwardRefForwardPropsComponent<TouchDialogProps>;
3
+ declare const TouchDialog: ForwardRefForwardPropsComponent<TouchDialogProps>;
4
4
  export default TouchDialog;
5
5
  //# sourceMappingURL=TouchDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TouchDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAkBnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAY5D,eAAO,MAAM,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,CAoNzE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"TouchDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAkBnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAY5D,QAAA,MAAM,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,CAgPlE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { useConsolidatedRef, useConfiguration, useFocusTrap, useI18n, useTestIds, useEscape, useUID, useEvent } from '../../hooks';
@@ -12,7 +12,7 @@ import { focusNonInteractiveElement, getActiveElement, isInstance } from '../../
12
12
  import Progress from '../Progress';
13
13
  import { StyledTouchDialogContent, StyledTouchDialogHeader, StyledTouchDialog, StyledTouchDialogBackdrop, StyledExpandCollapse } from './TouchDialog.styles';
14
14
  import { getTouchDialogTestIds } from './TouchDialog.test-ids';
15
- import { StyledChildrenWrap } from './Dialog.styles';
15
+ import { StyledChildrenWrap, StyledDialogFooter } from './Dialog.styles';
16
16
  registerIcon(caretUp, timesIcon);
17
17
  const drawerSizeMapping = {
18
18
  auto: 'auto',
@@ -20,12 +20,13 @@ const drawerSizeMapping = {
20
20
  half: '50dvh',
21
21
  full: '90dvh'
22
22
  };
23
- export const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismissProp, children, size = 'half', onBeforeOpen, onAfterOpen: onAfterOpenProp, onBeforeClose, onAfterClose, heading, progress: progressProp, outerClickAction = 'close', testId, ...restProps }, ref) {
23
+ const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismissProp, children, footer, size = 'half', onBeforeOpen, onAfterOpen: onAfterOpenProp, onBeforeClose, onAfterClose, heading, 'aria-label': ariaLabel, progress: progressProp, outerClickAction = 'close', testId, ...restProps }, ref) {
24
24
  const dialogRef = useConsolidatedRef(ref);
25
25
  const backdropRef = useRef(null);
26
26
  const t = useI18n();
27
27
  const { portalTarget } = useConfiguration();
28
28
  const headingRef = useRef(null);
29
+ const headingWrapperRef = useRef(null);
29
30
  const isFullCompact = size === 'full-compact';
30
31
  const [drawerSize, setDrawerSize] = useState(isFullCompact ? 'full' : size);
31
32
  const headingId = useUID();
@@ -44,13 +45,16 @@ export const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: on
44
45
  const setFocus = useCallback(() => {
45
46
  if (progressProp || !drawerOpen || dialogRef.current?.contains(getActiveElement()))
46
47
  return;
47
- if (headingRef.current) {
48
- focusNonInteractiveElement(headingRef.current, heading);
48
+ if (headingWrapperRef.current) {
49
+ focusNonInteractiveElement(headingWrapperRef.current.querySelector('h2') ?? headingWrapperRef.current, ariaLabel);
50
+ }
51
+ else if (headingRef.current) {
52
+ focusNonInteractiveElement(headingRef.current, ariaLabel);
49
53
  }
50
54
  else if (dialogRef.current) {
51
- focusNonInteractiveElement(dialogRef.current, heading);
55
+ focusNonInteractiveElement(dialogRef.current, ariaLabel);
52
56
  }
53
- }, [progressProp, drawerOpen, heading]);
57
+ }, [progressProp, drawerOpen, heading, ariaLabel]);
54
58
  const onDismiss = useCallback(() => {
55
59
  setDrawerOpen(false);
56
60
  onDismissProp?.();
@@ -74,12 +78,12 @@ export const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: on
74
78
  }
75
79
  }, [progressProp, setFocus]);
76
80
  useEscape(e => {
77
- onDismiss?.();
81
+ onDismiss();
78
82
  e.stopPropagation();
79
83
  }, dialogRef, [onDismiss]);
80
84
  const progress = (_jsx(Progress, { visible: !!progressProp, focusOnVisible: true, placement: 'local', message: typeof progressProp === 'string' ? progressProp : undefined }));
81
85
  const isCompact = isFullCompact && drawerSize === 'compact';
82
- const hasContent = children !== undefined || progressProp !== undefined;
86
+ const hasContent = children !== undefined || footer !== undefined || progressProp !== undefined;
83
87
  const dismissButton = (_jsx(Button, { "data-testid": testIds.dismiss, variant: 'simple', icon: true, label: t('dismiss'), onClick: onDismiss, children: _jsx(Icon, { name: 'times' }) }));
84
88
  useEvent('click', e => {
85
89
  if (open && e.target === backdropRef.current) {
@@ -101,7 +105,7 @@ export const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: on
101
105
  returnRef.current.focus();
102
106
  }
103
107
  onAfterClose?.();
104
- }, children: _jsxs(StyledTouchDialog, { "data-testid": testIds.root, ...restProps, ref: dialogRef, open: drawerOpen, placement: 'bottom', position: 'fixed', size: drawerSizeMapping[drawerSize], shadow: true, onAfterOpen: onAfterOpen, onBeforeClose: onBeforeClose, role: 'dialog', "aria-modal": shouldTrapFocus ? 'true' : undefined, "aria-labelledby": heading ? headingId : undefined, "aria-busy": !!progressProp, children: [_jsxs(Flex, { container: { direction: 'row', justify: 'between', alignItems: 'center' }, as: StyledTouchDialogHeader, children: [heading && (_jsx(Text, { variant: 'h2', ref: headingRef, id: headingId, children: heading })), dismissButton] }), hasContent && (_jsxs(Flex, { as: StyledTouchDialogContent, container: { gap: 1, direction: 'column' }, hidden: isCompact && !progressProp, children: [children && (_jsx(StyledChildrenWrap, { inert: progressProp || isCompact ? '' : undefined, hidden: isCompact, children: children })), progress] })), (!isAutoSize || isFullCompact) && (_jsx(StyledExpandCollapse, { onToggle: () => {
108
+ }, children: _jsxs(StyledTouchDialog, { "data-testid": testIds.root, "aria-labelledby": heading ? headingId : undefined, "aria-label": ariaLabel, ...restProps, ref: dialogRef, open: drawerOpen, placement: 'bottom', position: 'fixed', size: drawerSizeMapping[drawerSize], shadow: true, onAfterOpen: onAfterOpen, onBeforeClose: onBeforeClose, role: 'dialog', "aria-modal": shouldTrapFocus ? 'true' : undefined, "aria-busy": !!progressProp, children: [_jsxs(Flex, { container: { direction: 'row', justify: 'between', alignItems: 'center' }, as: StyledTouchDialogHeader, children: [typeof heading === 'string' ? (_jsx(Text, { variant: 'h2', ref: headingRef, id: headingId, children: heading })) : (heading && (_jsx(Flex, { item: { grow: 1 }, ref: headingWrapperRef, id: headingId, children: heading }))), dismissButton] }), hasContent && (_jsxs(_Fragment, { children: [_jsxs(Flex, { as: StyledTouchDialogContent, container: { gap: 1, direction: 'column' }, hidden: isCompact && !progressProp, children: [children && (_jsx(StyledChildrenWrap, { inert: progressProp || isCompact ? '' : undefined, hidden: isCompact, children: children })), progress] }), footer && (_jsx(Flex, { container: { alignItems: 'center', justify: 'between', pad: [0, 1, 1] }, item: { shrink: 0 }, as: StyledDialogFooter, hidden: isCompact, inert: isCompact ? '' : undefined, children: footer }))] })), (!isAutoSize || isFullCompact) && (_jsx(StyledExpandCollapse, { onToggle: () => {
105
109
  setDrawerSize(prev => {
106
110
  if (isFullCompact)
107
111
  return prev === 'compact' ? 'full' : 'compact';