@pega/cosmos-react-core 10.0.0-build.3.2 → 10.0.0-build.4.1

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 (82) hide show
  1. package/lib/components/AIButton/AIButton.d.ts +1 -1
  2. package/lib/components/AIButton/AIButton.d.ts.map +1 -1
  3. package/lib/components/AIButton/AIButton.js +2 -1
  4. package/lib/components/AIButton/AIButton.js.map +1 -1
  5. package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -1
  6. package/lib/components/AppShell/NavigationListItemWrapper.js +9 -6
  7. package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
  8. package/lib/components/ComboBox/ComboBox.js +3 -3
  9. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  10. package/lib/components/ComboBox/ComboBox.types.d.ts +1 -3
  11. package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
  12. package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
  13. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +2 -2
  14. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  15. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +3 -5
  16. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
  17. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
  18. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +2 -2
  19. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  20. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts +3 -5
  21. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts.map +1 -1
  22. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.js.map +1 -1
  23. package/lib/components/Currency/CurrencyInput.js +3 -3
  24. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  25. package/lib/components/DateTime/DateTime.types.d.ts +1 -3
  26. package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
  27. package/lib/components/DateTime/DateTime.types.js.map +1 -1
  28. package/lib/components/DateTime/Input/DateInput.js +3 -3
  29. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  30. package/lib/components/DateTime/Input/DateTimeInput.js +3 -3
  31. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  32. package/lib/components/DateTime/Input/TimeInput.js +3 -3
  33. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  34. package/lib/components/FormControl/FormControl.d.ts +10 -3
  35. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  36. package/lib/components/FormControl/FormControl.js +1 -1
  37. package/lib/components/FormControl/FormControl.js.map +1 -1
  38. package/lib/components/FormField/FormField.d.ts.map +1 -1
  39. package/lib/components/FormField/FormField.js +32 -49
  40. package/lib/components/FormField/FormField.js.map +1 -1
  41. package/lib/components/Icon/Icon.d.ts.map +1 -1
  42. package/lib/components/Icon/Icon.js +2 -0
  43. package/lib/components/Icon/Icon.js.map +1 -1
  44. package/lib/components/Input/Input.js +3 -3
  45. package/lib/components/Input/Input.js.map +1 -1
  46. package/lib/components/Number/NumberInput.js +4 -4
  47. package/lib/components/Number/NumberInput.js.map +1 -1
  48. package/lib/components/Number/NumberInput.types.d.ts +1 -3
  49. package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
  50. package/lib/components/Number/NumberInput.types.js.map +1 -1
  51. package/lib/components/Phone/PhoneInput.js +4 -4
  52. package/lib/components/Phone/PhoneInput.js.map +1 -1
  53. package/lib/components/Progress/Progress.d.ts.map +1 -1
  54. package/lib/components/Progress/Progress.js +39 -7
  55. package/lib/components/Progress/Progress.js.map +1 -1
  56. package/lib/components/Progress/Progress.types.d.ts +10 -4
  57. package/lib/components/Progress/Progress.types.d.ts.map +1 -1
  58. package/lib/components/Progress/Progress.types.js.map +1 -1
  59. package/lib/components/RadioCheck/RadioCheck.d.ts +4 -2
  60. package/lib/components/RadioCheck/RadioCheck.d.ts.map +1 -1
  61. package/lib/components/RadioCheck/RadioCheck.js +63 -27
  62. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  63. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts +1 -1
  64. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
  65. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +2 -2
  66. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  67. package/lib/components/Select/Select.d.ts +2 -3
  68. package/lib/components/Select/Select.d.ts.map +1 -1
  69. package/lib/components/Select/Select.js +11 -6
  70. package/lib/components/Select/Select.js.map +1 -1
  71. package/lib/components/TextArea/TextArea.js +3 -3
  72. package/lib/components/TextArea/TextArea.js.map +1 -1
  73. package/lib/hooks/useI18n.d.ts +13 -1
  74. package/lib/hooks/useI18n.d.ts.map +1 -1
  75. package/lib/i18n/default.d.ts +13 -1
  76. package/lib/i18n/default.d.ts.map +1 -1
  77. package/lib/i18n/default.js +13 -1
  78. package/lib/i18n/default.js.map +1 -1
  79. package/lib/i18n/i18n.d.ts +13 -1
  80. package/lib/i18n/i18n.d.ts.map +1 -1
  81. package/lib/theme/themeOverrides.schema.json +1 -1
  82. package/package.json +1 -1
@@ -54,7 +54,7 @@ export type NumberProps = NoChildrenProp & TestIdProp & {
54
54
  */
55
55
  variant?: 'default' | 'stepper';
56
56
  };
57
- export type NumberInputProps = WithAttributes<'input', NumberProps & {
57
+ export type NumberInputProps = WithAttributes<'input', NumberProps & Pick<FormControlProps, 'suggestion'> & {
58
58
  /**
59
59
  * CurrencyInput input value.
60
60
  * Requires an onChange handler to update value.
@@ -66,8 +66,6 @@ export type NumberInputProps = WithAttributes<'input', NumberProps & {
66
66
  onFocus?: (value: string) => void;
67
67
  /** Callback fired when the component loses focus. */
68
68
  onBlur?: (value: string) => void;
69
- /** Callback fired when AI suggestion is accepted/rejected */
70
- onResolveSuggestion?: FormControlProps['onResolveSuggestion'];
71
69
  type?: never;
72
70
  defaultValue?: never;
73
71
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/Number/NumberInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1F,MAAM,MAAM,WAAW,GAAG,cAAc,GACtC,UAAU,GAAG;IACX,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9C,6GAA6G;IAC7G,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACpD,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC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,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACtD,wBAAwB;IACxB,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAC3B,CACJ,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,yBAAyB,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.types.js","sourceRoot":"","sources":["../../../src/components/Number/NumberInput.types.ts"],"names":[],"mappings":"AAwHA,qCAAqC;AACrC,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC","sourcesContent":["import type { Ref } from 'react';\n\nimport type { FormControlProps, HandleValue } from '../FormControl';\nimport type { Attributes, NoChildrenProp, TestIdProp, WithAttributes } from '../../types';\n\nexport type NumberProps = NoChildrenProp &\n TestIdProp & {\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Makes the component non-editable and non-clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Button when clicked will show additional information */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** Defines unit of the number, like 'kg', 'miles' or '%'. */\n unit?: string;\n /** Determines whether decimal places should be shown. The value is rounded if true.\n * @default true\n */\n showDecimal?: boolean;\n /** Determines the maximum number of decimal places. The value is rounded to the number of places.\n * @default variable NUMBER_MAX_DECIMAL_PLACES. Recommended minimum: 1.\n */\n numberOfDecimals?: number;\n /** Determines whether group separators should be shown.\n * @default true\n */\n showGroupSeparators?: boolean;\n /** The minimum value to accept for this input.\n * This value must be less than or equal to the value of the max attribute.\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /**\n * The maximum value to accept for this input.\n * This value must be greater than or equal to the value of the min attribute.\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** A stepping interval to use when using up and down arrows to adjust the value.\n * @default 1\n */\n step?: number;\n /**\n * Component variation. Might be rendered as regular input or stepper.\n * @default 'default'\n */\n variant?: 'default' | 'stepper';\n };\n\nexport type NumberInputProps = WithAttributes<\n 'input',\n NumberProps & {\n /**\n * CurrencyInput input value.\n * Requires an onChange handler to update value.\n */\n value?: string;\n /** Callback fired when input value changes. */\n onChange: (value: string) => void;\n /** Callback fired when the component gets focus. */\n onFocus?: (value: string) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: string) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n type?: never;\n defaultValue?: never;\n }\n>;\n\nexport type NumberRangeInputProps = WithAttributes<\n 'fieldset',\n NumberProps &\n Pick<Attributes<'input'>, 'placeholder'> & {\n /** Range as a tuple of start and end. */\n value?: { start?: string; end?: string };\n /** Callback for any modifications to the range */\n onChange: (value: { start: string; end: string }) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: { start: string; end: string }) => void;\n /**\n * The keydown handler for first part of NumberRangeInput.\n * Fired before running default component onKeyDown handler.\n */\n onFromInputKeyDown?: NumberInputProps['onKeyDown'];\n /**\n * The keydown handler for second part of NumberRangeInput.\n * Fired before running default component onKeyDown handler.\n */\n onToInputKeyDown?: NumberInputProps['onKeyDown'];\n /** Callback fired when the component gets focus. */\n onFocus?: (value: { start: string; end: string }) => void;\n /** Pass a string or a fragment with an Icon and string for first part of NumberRangeInput. */\n fromLabel?: FormControlProps['label'];\n /** Pass a string or a fragment with an Icon and string for second part of NumberRangeInput. */\n toLabel?: FormControlProps['label'];\n /** Placeholder for the first (from) input. Overrides `placeholder` for the first input. */\n fromPlaceholder?: string;\n /** Placeholder for the second (to) input. Overrides `placeholder` for the second input. */\n toPlaceholder?: string;\n /** Pass an object with \"heading\" and \"content\" properties to show AdditionalInfo for first part of NumberRangeInput. */\n fromAdditionalInfo?: FormControlProps['additionalInfo'];\n /** Pass an object with \"heading\" and \"content\" properties to show AdditionalInfo for second part of NumberRangeInput. */\n toAdditionalInfo?: FormControlProps['additionalInfo'];\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n }\n>;\n\n/** Maximum fraction digits is 20. */\nexport const NUMBER_MAX_DECIMAL_PLACES = 20;\n"]}
1
+ {"version":3,"file":"NumberInput.types.js","sourceRoot":"","sources":["../../../src/components/Number/NumberInput.types.ts"],"names":[],"mappings":"AAuHA,qCAAqC;AACrC,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC","sourcesContent":["import type { Ref } from 'react';\n\nimport type { FormControlProps, HandleValue } from '../FormControl';\nimport type { Attributes, NoChildrenProp, TestIdProp, WithAttributes } from '../../types';\n\nexport type NumberProps = NoChildrenProp &\n TestIdProp & {\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Makes the component non-editable and non-clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Button when clicked will show additional information */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** Defines unit of the number, like 'kg', 'miles' or '%'. */\n unit?: string;\n /** Determines whether decimal places should be shown. The value is rounded if true.\n * @default true\n */\n showDecimal?: boolean;\n /** Determines the maximum number of decimal places. The value is rounded to the number of places.\n * @default variable NUMBER_MAX_DECIMAL_PLACES. Recommended minimum: 1.\n */\n numberOfDecimals?: number;\n /** Determines whether group separators should be shown.\n * @default true\n */\n showGroupSeparators?: boolean;\n /** The minimum value to accept for this input.\n * This value must be less than or equal to the value of the max attribute.\n * @default Number.MIN_SAFE_INTEGER\n */\n min?: number;\n /**\n * The maximum value to accept for this input.\n * This value must be greater than or equal to the value of the min attribute.\n * @default Number.MAX_SAFE_INTEGER\n */\n max?: number;\n /** A stepping interval to use when using up and down arrows to adjust the value.\n * @default 1\n */\n step?: number;\n /**\n * Component variation. Might be rendered as regular input or stepper.\n * @default 'default'\n */\n variant?: 'default' | 'stepper';\n };\n\nexport type NumberInputProps = WithAttributes<\n 'input',\n NumberProps &\n Pick<FormControlProps, 'suggestion'> & {\n /**\n * CurrencyInput input value.\n * Requires an onChange handler to update value.\n */\n value?: string;\n /** Callback fired when input value changes. */\n onChange: (value: string) => void;\n /** Callback fired when the component gets focus. */\n onFocus?: (value: string) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: string) => void;\n type?: never;\n defaultValue?: never;\n }\n>;\n\nexport type NumberRangeInputProps = WithAttributes<\n 'fieldset',\n NumberProps &\n Pick<Attributes<'input'>, 'placeholder'> & {\n /** Range as a tuple of start and end. */\n value?: { start?: string; end?: string };\n /** Callback for any modifications to the range */\n onChange: (value: { start: string; end: string }) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: { start: string; end: string }) => void;\n /**\n * The keydown handler for first part of NumberRangeInput.\n * Fired before running default component onKeyDown handler.\n */\n onFromInputKeyDown?: NumberInputProps['onKeyDown'];\n /**\n * The keydown handler for second part of NumberRangeInput.\n * Fired before running default component onKeyDown handler.\n */\n onToInputKeyDown?: NumberInputProps['onKeyDown'];\n /** Callback fired when the component gets focus. */\n onFocus?: (value: { start: string; end: string }) => void;\n /** Pass a string or a fragment with an Icon and string for first part of NumberRangeInput. */\n fromLabel?: FormControlProps['label'];\n /** Pass a string or a fragment with an Icon and string for second part of NumberRangeInput. */\n toLabel?: FormControlProps['label'];\n /** Placeholder for the first (from) input. Overrides `placeholder` for the first input. */\n fromPlaceholder?: string;\n /** Placeholder for the second (to) input. Overrides `placeholder` for the second input. */\n toPlaceholder?: string;\n /** Pass an object with \"heading\" and \"content\" properties to show AdditionalInfo for first part of NumberRangeInput. */\n fromAdditionalInfo?: FormControlProps['additionalInfo'];\n /** Pass an object with \"heading\" and \"content\" properties to show AdditionalInfo for second part of NumberRangeInput. */\n toAdditionalInfo?: FormControlProps['additionalInfo'];\n /** Imperative handle */\n handle?: Ref<HandleValue>;\n }\n>;\n\n/** Maximum fraction digits is 20. */\nexport const NUMBER_MAX_DECIMAL_PLACES = 20;\n"]}
@@ -41,7 +41,7 @@ const StyledPhoneInput = styled.div(() => {
41
41
  });
42
42
  StyledPhoneInput.defaultProps = defaultThemeProp;
43
43
  const PhoneInput = forwardRef(function PhoneInput(props, ref) {
44
- const { testId, value, id, label, labelHidden, info, status, required, readOnly, disabled, showCountryCode = false, callingCodesList = callingCodes, onChange, onBlur, onFocus, onResolveSuggestion, additionalInfo, className, autoComplete = '_off', ...restProps } = props;
44
+ const { testId, value, id, label, labelHidden, info, status, required, readOnly, disabled, showCountryCode = false, callingCodesList = callingCodes, onChange, onBlur, onFocus, suggestion, additionalInfo, className, autoComplete = '_off', ...restProps } = props;
45
45
  const testIds = useTestIds(testId, getPhoneInputTestIds);
46
46
  const [selectEl, setSelectEl] = useElement();
47
47
  const [inputEl, setInputEl] = useElement();
@@ -77,10 +77,10 @@ const PhoneInput = forwardRef(function PhoneInput(props, ref) {
77
77
  const codesOptions = (_jsx(_Fragment, { children: callingCodesList.map(code => (_jsx(Option, { value: code, children: code }, code))) }));
78
78
  const Comp = (_jsx(StyledPhoneInput, { "data-testid": testIds.root, as: StyledFormControl, forwardedAs: Flex, container: { alignItems: 'center', wrap: 'nowrap' }, ref: containerRef, status: status, readOnly: readOnly, disabled: disabled, children: _jsxs(_Fragment, { children: [showCountryCode && !readOnly && (_jsxs(_Fragment, { children: [_jsx(Select, { "data-testid": testIds.countryCode, value: countryCode, "aria-label": t('select_country_code'), onChange: onSelectChange, required: required, status: status, readOnly: readOnly, disabled: disabled, autoComplete: autoComplete && autoComplete.endsWith('tel')
79
79
  ? autoComplete.replace('tel', 'tel-country-code')
80
- : autoComplete, ref: setSelectEl, hasSuggestion: status === 'pending' && !!onResolveSuggestion, children: codesOptions }), selectEl && (_jsx(Tooltip, { target: selectEl, describeTarget: false, showDelay: 'none', hideDelay: 'none', children: t('country_code') }))] })), _jsx(Input, { "data-testid": testIds.control, autoComplete: autoComplete && autoComplete.endsWith('tel')
80
+ : autoComplete, ref: setSelectEl, hasSuggestion: status === 'pending' && !!suggestion, children: codesOptions }), selectEl && (_jsx(Tooltip, { target: selectEl, describeTarget: false, showDelay: 'none', hideDelay: 'none', children: t('country_code') }))] })), _jsx(Input, { "data-testid": testIds.control, autoComplete: autoComplete && autoComplete.endsWith('tel')
81
81
  ? autoComplete.replace('tel', 'tel-national')
82
- : autoComplete, ...restProps, inputMode: 'tel', ref: inputRef, value: formatted, "aria-label": t('enter_a_number'), onChange: onInputChange, required: required, status: status, readOnly: readOnly, disabled: disabled, onResolveSuggestion: onResolveSuggestion, className: createClassName('phone-input', className) }), showCountryCode && inputEl && (_jsx(Tooltip, { target: inputEl, describeTarget: false, showDelay: 'none', hideDelay: 'none', children: t('phone_number') }))] }) }));
83
- return label ? (_jsx(FormField, { testId: testIds, as: 'fieldset', additionalInfo: additionalInfo, label: label, labelHidden: labelHidden, id: id, info: info, readOnly: readOnly, status: status, required: required, disabled: disabled, onResolveSuggestion: onResolveSuggestion, children: Comp })) : (Comp);
82
+ : autoComplete, ...restProps, inputMode: 'tel', ref: inputRef, value: formatted, "aria-label": t('enter_a_number'), onChange: onInputChange, required: required, status: status, readOnly: readOnly, disabled: disabled, suggestion: suggestion, className: createClassName('phone-input', className) }), showCountryCode && inputEl && (_jsx(Tooltip, { target: inputEl, describeTarget: false, showDelay: 'none', hideDelay: 'none', children: t('phone_number') }))] }) }));
83
+ return label ? (_jsx(FormField, { testId: testIds, as: 'fieldset', additionalInfo: additionalInfo, label: label, labelHidden: labelHidden, id: id, info: info, readOnly: readOnly, status: status, required: required, disabled: disabled, suggestion: suggestion, children: Comp })) : (Comp);
84
84
  });
85
85
  export default withTestIds(PhoneInput, getPhoneInputTestIds);
86
86
  //# sourceMappingURL=PhoneInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,OAAO,EACP,iBAAiB,EACjB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,0BAA0B,EAC1B,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA4BxD,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAA8B,GAAG,EAAE;IACpE,OAAO,GAAG,CAAA;;;QAGJ,YAAY;;;;;;;QAOZ,YAAY,MAAM,WAAW;;;;;MAK/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f,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,SAAS,gBACJ,CAAC,CAAC,gBAAgB,CAAC,EAC/B,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,mBAAmB,EACxC,SAAS,EAAE,eAAe,CAAC,aAAa,EAAE,SAAS,CAAC,GACpD,EACD,eAAe,IAAI,OAAO,IAAI,CAC7B,KAAC,OAAO,IAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,YAC/E,CAAC,CAAC,cAAc,CAAC,GACV,CACX,IACA,GACc,CACpB,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,IACR,MAAM,EAAE,OAAO,EACf,EAAE,EAAC,UAAU,EACb,cAAc,EAAE,cAAc,EAC9B,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,mBAAmB,EAAE,mBAAmB,YAEvC,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useRef } from 'react';\nimport type { ChangeEvent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useElement,\n useFocusWithin,\n useI18n,\n useInputFormatter,\n useTestIds\n} from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport StyledInput from '../Input/Input.styles';\nimport Select, { Option } from '../Select';\nimport Input from '../Input';\nimport { StyledSelect } from '../Select/Select';\nimport Flex from '../Flex';\nimport { withTestIds, createClassName } from '../../utils';\nimport Tooltip from '../Tooltip';\n\nimport callingCodes from './callingCodes';\nimport {\n convertToCallbackParameter,\n formatPhone,\n formatPhoneNumber,\n getPhoneNumberParts\n} from './utils';\nimport { getPhoneInputTestIds } from './Phone.test-ids';\n\ntype AutoFillTel =\n | AutoFillBase\n | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<AutoFillAddressKind>}${OptionalPrefixToken<AutoFillContactKind>}tel`;\n\nexport interface PhoneInputProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /**\n * Display select with countries calling codes\n * @default false\n */\n showCountryCode?: boolean;\n /** Changes lists of countries calling codes */\n callingCodesList?: string[];\n /** Callback fired on input value change */\n onChange?: (value: string) => void;\n /** Callback fired when the component loses focus */\n onBlur?: (value: string) => void;\n /** CCallback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLInputElement>;\n /** Flag defining autocompletion behavior. */\n autoComplete?: AutoFillTel;\n}\n\ntype PhoneInputPropsWithDefaults = PropsWithDefaults<PhoneInputProps>;\n\nconst StyledPhoneInput = styled.div<PhoneInputPropsWithDefaults>(() => {\n return css`\n border: 0;\n\n > ${StyledSelect} {\n max-width: max-content;\n border-inline-end: none;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n\n > ${StyledSelect} + ${StyledInput} {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n\n ${StyledSelect},\n ${StyledInput} {\n &:focus {\n z-index: 1;\n }\n }\n `;\n});\n\nStyledPhoneInput.defaultProps = defaultThemeProp;\n\nconst PhoneInput: ForwardRefForwardPropsComponent<PhoneInputProps> = forwardRef(function PhoneInput(\n props: PropsWithoutRef<PhoneInputProps>,\n ref: PhoneInputProps['ref']\n) {\n const {\n testId,\n value,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n readOnly,\n disabled,\n showCountryCode = false,\n callingCodesList = callingCodes,\n onChange,\n onBlur,\n onFocus,\n onResolveSuggestion,\n additionalInfo,\n className,\n autoComplete = '_off',\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getPhoneInputTestIds);\n const [selectEl, setSelectEl] = useElement<HTMLSelectElement>();\n const [inputEl, setInputEl] = useElement<HTMLInputElement>();\n\n const t = useI18n();\n\n const [countryCode = callingCodesList[0], subscriberNumber = ''] = value\n ? getPhoneNumberParts(value, callingCodesList)\n : [];\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(countryCode, subscriberNumber);\n if (focused) onFocus?.(callbackParam);\n else onBlur?.(callbackParam);\n };\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(convertToCallbackParameter(countryCode, e.target.value));\n };\n\n const onSelectChange = (e: ChangeEvent<HTMLSelectElement>) => {\n onChange?.(convertToCallbackParameter(e.target.value, subscriberNumber));\n };\n\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref, setInputEl);\n const containerRef = useRef<HTMLDivElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n const formatter = useCallback(\n (number: string) => {\n if (value && readOnly && showCountryCode) {\n const temp = formatPhone(value, { nationalFormat: !readOnly });\n if (temp) return temp;\n }\n return formatPhoneNumber(number.replace(/\\D+/g, ''), countryCode, showCountryCode);\n },\n [readOnly, countryCode, showCountryCode]\n );\n\n const formatted = useInputFormatter(inputRef, subscriberNumber, formatter);\n\n const codesOptions = (\n <>\n {callingCodesList.map(code => (\n <Option key={code} value={code}>\n {code}\n </Option>\n ))}\n </>\n );\n\n const Comp = (\n <StyledPhoneInput\n data-testid={testIds.root}\n as={StyledFormControl}\n forwardedAs={Flex}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n ref={containerRef}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n <>\n {showCountryCode && !readOnly && (\n <>\n <Select\n data-testid={testIds.countryCode}\n value={countryCode}\n aria-label={t('select_country_code')}\n onChange={onSelectChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n autoComplete={\n autoComplete && autoComplete.endsWith('tel')\n ? (autoComplete.replace('tel', 'tel-country-code') as AutoFillTel)\n : autoComplete\n }\n ref={setSelectEl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n >\n {codesOptions}\n </Select>\n {selectEl && (\n <Tooltip target={selectEl} describeTarget={false} showDelay='none' hideDelay='none'>\n {t('country_code')}\n </Tooltip>\n )}\n </>\n )}\n <Input\n data-testid={testIds.control}\n autoComplete={\n autoComplete && autoComplete.endsWith('tel')\n ? (autoComplete.replace('tel', 'tel-national') as AutoFillTel)\n : autoComplete\n }\n {...restProps}\n inputMode='tel'\n ref={inputRef}\n value={formatted}\n aria-label={t('enter_a_number')}\n onChange={onInputChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n className={createClassName('phone-input', className)}\n />\n {showCountryCode && inputEl && (\n <Tooltip target={inputEl} describeTarget={false} showDelay='none' hideDelay='none'>\n {t('phone_number')}\n </Tooltip>\n )}\n </>\n </StyledPhoneInput>\n );\n\n return label ? (\n <FormField\n testId={testIds}\n as='fieldset'\n additionalInfo={additionalInfo}\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 onResolveSuggestion={onResolveSuggestion}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n});\n\nexport default withTestIds(PhoneInput, getPhoneInputTestIds);\n"]}
1
+ {"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],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,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,eAAe,CAAC,aAAa,EAAE,SAAS,CAAC,GACpD,EACD,eAAe,IAAI,OAAO,IAAI,CAC7B,KAAC,OAAO,IAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,YAC/E,CAAC,CAAC,cAAc,CAAC,GACV,CACX,IACA,GACc,CACpB,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,IACR,MAAM,EAAE,OAAO,EACf,EAAE,EAAC,UAAU,EACb,cAAc,EAAE,cAAc,EAC9B,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,UAAU,EAAE,UAAU,YAErB,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useRef } from 'react';\nimport type { ChangeEvent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useElement,\n useFocusWithin,\n useI18n,\n useInputFormatter,\n useTestIds\n} from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport StyledInput from '../Input/Input.styles';\nimport Select, { Option } from '../Select';\nimport Input from '../Input';\nimport { StyledSelect } from '../Select/Select';\nimport Flex from '../Flex';\nimport { withTestIds, createClassName } from '../../utils';\nimport Tooltip from '../Tooltip';\n\nimport callingCodes from './callingCodes';\nimport {\n convertToCallbackParameter,\n formatPhone,\n formatPhoneNumber,\n getPhoneNumberParts\n} from './utils';\nimport { getPhoneInputTestIds } from './Phone.test-ids';\n\ntype AutoFillTel =\n | AutoFillBase\n | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<AutoFillAddressKind>}${OptionalPrefixToken<AutoFillContactKind>}tel`;\n\nexport interface PhoneInputProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /**\n * Display select with countries calling codes\n * @default false\n */\n showCountryCode?: boolean;\n /** Changes lists of countries calling codes */\n callingCodesList?: string[];\n /** Callback fired on input value change */\n onChange?: (value: string) => void;\n /** Callback fired when the component loses focus */\n onBlur?: (value: string) => void;\n /** CCallback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLInputElement>;\n /** Flag defining autocompletion behavior. */\n autoComplete?: AutoFillTel;\n}\n\ntype PhoneInputPropsWithDefaults = PropsWithDefaults<PhoneInputProps>;\n\nconst StyledPhoneInput = styled.div<PhoneInputPropsWithDefaults>(() => {\n return css`\n border: 0;\n\n > ${StyledSelect} {\n max-width: max-content;\n border-inline-end: none;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n\n > ${StyledSelect} + ${StyledInput} {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n\n ${StyledSelect},\n ${StyledInput} {\n &:focus {\n z-index: 1;\n }\n }\n `;\n});\n\nStyledPhoneInput.defaultProps = defaultThemeProp;\n\nconst PhoneInput: ForwardRefForwardPropsComponent<PhoneInputProps> = forwardRef(function PhoneInput(\n props: PropsWithoutRef<PhoneInputProps>,\n ref: PhoneInputProps['ref']\n) {\n const {\n testId,\n value,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n readOnly,\n disabled,\n showCountryCode = false,\n callingCodesList = callingCodes,\n onChange,\n onBlur,\n onFocus,\n suggestion,\n additionalInfo,\n className,\n autoComplete = '_off',\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getPhoneInputTestIds);\n const [selectEl, setSelectEl] = useElement<HTMLSelectElement>();\n const [inputEl, setInputEl] = useElement<HTMLInputElement>();\n\n const t = useI18n();\n\n const [countryCode = callingCodesList[0], subscriberNumber = ''] = value\n ? getPhoneNumberParts(value, callingCodesList)\n : [];\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(countryCode, subscriberNumber);\n if (focused) onFocus?.(callbackParam);\n else onBlur?.(callbackParam);\n };\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(convertToCallbackParameter(countryCode, e.target.value));\n };\n\n const onSelectChange = (e: ChangeEvent<HTMLSelectElement>) => {\n onChange?.(convertToCallbackParameter(e.target.value, subscriberNumber));\n };\n\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref, setInputEl);\n const containerRef = useRef<HTMLDivElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n const formatter = useCallback(\n (number: string) => {\n if (value && readOnly && showCountryCode) {\n const temp = formatPhone(value, { nationalFormat: !readOnly });\n if (temp) return temp;\n }\n return formatPhoneNumber(number.replace(/\\D+/g, ''), countryCode, showCountryCode);\n },\n [readOnly, countryCode, showCountryCode]\n );\n\n const formatted = useInputFormatter(inputRef, subscriberNumber, formatter);\n\n const codesOptions = (\n <>\n {callingCodesList.map(code => (\n <Option key={code} value={code}>\n {code}\n </Option>\n ))}\n </>\n );\n\n const Comp = (\n <StyledPhoneInput\n data-testid={testIds.root}\n as={StyledFormControl}\n forwardedAs={Flex}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n ref={containerRef}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n <>\n {showCountryCode && !readOnly && (\n <>\n <Select\n data-testid={testIds.countryCode}\n value={countryCode}\n aria-label={t('select_country_code')}\n onChange={onSelectChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n autoComplete={\n autoComplete && autoComplete.endsWith('tel')\n ? (autoComplete.replace('tel', 'tel-country-code') as AutoFillTel)\n : autoComplete\n }\n ref={setSelectEl}\n hasSuggestion={status === 'pending' && !!suggestion}\n >\n {codesOptions}\n </Select>\n {selectEl && (\n <Tooltip target={selectEl} describeTarget={false} showDelay='none' hideDelay='none'>\n {t('country_code')}\n </Tooltip>\n )}\n </>\n )}\n <Input\n data-testid={testIds.control}\n autoComplete={\n autoComplete && autoComplete.endsWith('tel')\n ? (autoComplete.replace('tel', 'tel-national') as AutoFillTel)\n : autoComplete\n }\n {...restProps}\n inputMode='tel'\n ref={inputRef}\n value={formatted}\n aria-label={t('enter_a_number')}\n onChange={onInputChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n suggestion={suggestion}\n className={createClassName('phone-input', className)}\n />\n {showCountryCode && inputEl && (\n <Tooltip target={inputEl} describeTarget={false} showDelay='none' hideDelay='none'>\n {t('phone_number')}\n </Tooltip>\n )}\n </>\n </StyledPhoneInput>\n );\n\n return label ? (\n <FormField\n testId={testIds}\n as='fieldset'\n additionalInfo={additionalInfo}\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 suggestion={suggestion}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n});\n\nexport default withTestIds(PhoneInput, getPhoneInputTestIds);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAKnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAetD,QAAA,MAAM,QAAQ,EAAE,+BAA+B,CAAC,aAAa,CAuL3D,CAAC;AAEH,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAKnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAetD,QAAA,MAAM,QAAQ,EAAE,+BAA+B,CAAC,aAAa,CAgO3D,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useState, useEffect, useRef } from 'react';
2
+ import { forwardRef, useState, useEffect, useRef, useLayoutEffect } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { getLuminance } from 'polished';
5
5
  import Text from '../Text';
@@ -14,14 +14,16 @@ const variantMap = {
14
14
  bar: Bar,
15
15
  ellipsis: Ellipsis
16
16
  };
17
- const delayDuration = 100;
17
+ const defaultDelayDuration = 100;
18
18
  const minVisibleDuration = 1000;
19
- const Progress = forwardRef(function Progress({ variant = 'ring', placement = 'global', visible: visibleProp = true, focusOnVisible = false, delay = false, onTransitionStartIn, onTransitionEndIn, onTransitionStartOut, onTransitionEndOut, value, message, liveConfig, ...restProps }, ref) {
19
+ const Progress = forwardRef(function Progress({ variant = 'ring', placement = 'global', visible: visibleProp = true, focusOnVisible = false, delay = false, onTransitionStartIn, onTransitionEndIn, onTransitionStartOut, onTransitionEndOut, value, message, liveConfig, offsetContainer, ...restProps }, ref) {
20
20
  const t = useI18n();
21
21
  const { portalTarget } = useConfiguration();
22
22
  const { announcePolite } = useLiveLog();
23
23
  const theme = useTheme();
24
24
  const progressEl = useConsolidatedRef(ref);
25
+ const backdropRef = useRef(null);
26
+ const [indicatorOffsetTop, setIndicatorOffsetTop] = useState();
25
27
  // Rendering states. Both are needed due to Backdrop's transition phase where isVisibleState is false but nullRender is true until onAfterTransitionOut.
26
28
  const [isVisibleState, setIsVisibleState] = useState(delay ? false : visibleProp);
27
29
  const [nullRender, setNullRender] = useState(!isVisibleState);
@@ -33,6 +35,7 @@ const Progress = forwardRef(function Progress({ variant = 'ring', placement = 'g
33
35
  const hasBackdrop = placement === 'global' || placement === 'local';
34
36
  const valString = typeof value === 'number' ? `${value}%` : undefined;
35
37
  const label = message && valString ? `${message} - ${valString}` : message || valString;
38
+ const hasOffsetContainer = !!offsetContainer;
36
39
  const renderVisible = () => {
37
40
  setIsVisibleState(true);
38
41
  setNullRender(false);
@@ -44,12 +47,30 @@ const Progress = forwardRef(function Progress({ variant = 'ring', placement = 'g
44
47
  setNullRender(true);
45
48
  }
46
49
  };
50
+ useLayoutEffect(() => {
51
+ if (!isVisibleState || nullRender || !backdropRef.current || !offsetContainer?.current) {
52
+ return;
53
+ }
54
+ const backdropRect = backdropRef.current.getBoundingClientRect();
55
+ const refRect = offsetContainer.current.getBoundingClientRect();
56
+ const viewportHeight = document.documentElement.clientHeight;
57
+ // Visible portion of the reference element within the viewport
58
+ const visibleTop = Math.max(refRect.top, 0);
59
+ const visibleBottom = Math.min(refRect.bottom, viewportHeight);
60
+ if (visibleBottom <= visibleTop) {
61
+ setIndicatorOffsetTop(NaN);
62
+ return;
63
+ }
64
+ // Center of the visible portion, relative to the backdrop
65
+ setIndicatorOffsetTop((visibleTop + visibleBottom) / 2 - backdropRect.top);
66
+ }, [isVisibleState, nullRender, offsetContainer]);
47
67
  // Handle render and visible state.
48
68
  useEffect(() => {
49
69
  if (visibleProp) {
50
70
  // Capture a timestamp for additional timers.
51
71
  timeBeforeVisibleRender.current = Date.now();
52
72
  if (delay) {
73
+ const delayDuration = typeof delay === 'number' ? delay : defaultDelayDuration;
53
74
  delayTimer.current = window.setTimeout(renderVisible, delayDuration);
54
75
  }
55
76
  else {
@@ -99,23 +120,34 @@ const Progress = forwardRef(function Progress({ variant = 'ring', placement = 'g
99
120
  if (!nullRender && isVisibleState) {
100
121
  // After a visible render set a timestamp for timers above.
101
122
  timeAfterVisibleRender.current = Date.now();
102
- if (focusOnVisible)
123
+ // If there is no offsetContainer focus immediately.
124
+ // Otherwise wait until a render has applied offset to avoid the indicator being pulled out of view.
125
+ if ((focusOnVisible && !hasOffsetContainer) || indicatorOffsetTop) {
103
126
  progressEl.current?.focus();
127
+ }
104
128
  }
105
129
  },
106
130
  // nullRender is the only triggerable dependency. Others values will be captured.
107
- [nullRender]);
131
+ [nullRender, hasOffsetContainer, indicatorOffsetTop]);
108
132
  if (nullRender)
109
133
  return null;
110
134
  const CompVariant = variantMap[variant];
111
135
  let indicator = (_jsx(CompVariant, { "aria-label": typeof value !== 'number' && label ? label : t('loading'), as: placement === 'inline' ? 'span' : undefined, ...restProps, placement: placement, value: value, "aria-valuetext": typeof value === 'number' ? label : undefined, ref: progressEl, tabIndex: -1 }));
112
136
  if (placement !== 'inline') {
113
- indicator = (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', gap: 0.5 }, as: StyledProgress, placement: placement, children: [indicator, message && (_jsx(Text, { as: StyledMessage, variant: 'secondary', "aria-hidden": true, children: message }))] }));
137
+ indicator = (_jsxs(Flex, { container: { direction: 'column', alignItems: 'center', gap: 0.5 }, as: StyledProgress, placement: placement,
138
+ /*
139
+ Inline style justification:
140
+ Highly variable values will generate new classes every time.
141
+ Not using CSS var since can not conditionally set property, only value.
142
+ marginTop is used vs logical property since value is based on client rect which is not logical.
143
+ */
144
+ style: indicatorOffsetTop ? { marginTop: `${indicatorOffsetTop}px` } : undefined, children: [indicator, message && (_jsx(Text, { as: StyledMessage, variant: 'secondary', "aria-hidden": true, children: message }))] }));
114
145
  }
115
146
  // generate background variant based on theme text color
116
147
  const progressBackdropVariant = getLuminance(theme.base.palette['foreground-color']) > 0.5 ? 'dark' : 'light';
117
- const content = hasBackdrop ? (_jsx(StyledProgressBackdrop, { open: isVisibleState, container: { direction: 'column' }, position: placement === 'global' ? 'fixed' : 'absolute', variant: progressBackdropVariant, alpha: 0.6, onBeforeTransitionIn: onTransitionStartIn, onAfterTransitionIn: onTransitionEndIn, onBeforeTransitionOut: onTransitionStartOut, onAfterTransitionOut: () => {
148
+ const content = hasBackdrop ? (_jsx(StyledProgressBackdrop, { ref: backdropRef, open: isVisibleState, container: { direction: 'column', justify: indicatorOffsetTop ? 'start' : 'center' }, position: placement === 'global' ? 'fixed' : 'absolute', variant: progressBackdropVariant, alpha: 0.6, onBeforeTransitionIn: onTransitionStartIn, onAfterTransitionIn: onTransitionEndIn, onBeforeTransitionOut: onTransitionStartOut, onAfterTransitionOut: () => {
118
149
  setNullRender(true);
150
+ setIndicatorOffsetTop(undefined);
119
151
  onTransitionEndOut?.();
120
152
  }, children: indicator })) : (indicator);
121
153
  return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE1F,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,GAAG;IACR,QAAQ,EAAE,QAAQ;CACV,CAAC;AAEX,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,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,CAAC,YAEA,SAAS,GACa,CAC1B,CAAC,CAAC,CAAC,CACF,SAAS,CACV,CAAC;IAEF,OAAO,SAAS,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChG,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { getLuminance } from 'polished';\n\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Text from '../Text';\nimport { useConfiguration, useConsolidatedRef, useI18n, useLiveLog, useTheme } from '../../hooks';\nimport Flex from '../Flex';\n\nimport type { ProgressProps } from './Progress.types';\nimport Bar from './Bar';\nimport Ellipsis from './Ellipsis';\nimport Ring from './Ring';\nimport { StyledMessage, StyledProgress, StyledProgressBackdrop } from './Progress.styles';\n\nconst variantMap = {\n ring: Ring,\n bar: Bar,\n ellipsis: Ellipsis\n} as const;\n\nconst delayDuration = 100;\nconst minVisibleDuration = 1000;\n\nconst Progress: ForwardRefForwardPropsComponent<ProgressProps> = forwardRef(function Progress(\n {\n variant = 'ring',\n placement = 'global',\n visible: visibleProp = true,\n focusOnVisible = false,\n delay = false,\n onTransitionStartIn,\n onTransitionEndIn,\n onTransitionStartOut,\n onTransitionEndOut,\n value,\n message,\n liveConfig,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n) {\n const t = useI18n();\n const { portalTarget } = useConfiguration();\n const { announcePolite } = useLiveLog();\n const theme = useTheme();\n const progressEl = useConsolidatedRef<HTMLDivElement>(ref);\n\n // Rendering states. Both are needed due to Backdrop's transition phase where isVisibleState is false but nullRender is true until onAfterTransitionOut.\n const [isVisibleState, setIsVisibleState] = useState(delay ? false : visibleProp);\n const [nullRender, setNullRender] = useState(!isVisibleState);\n\n // Refs for timestamps and timeout ids.\n const timeBeforeVisibleRender = useRef<number>();\n const timeAfterVisibleRender = useRef<number>();\n const delayTimer = useRef<number>();\n const minVisibleTimer = useRef<number>();\n\n const hasBackdrop = placement === 'global' || placement === 'local';\n const valString = typeof value === 'number' ? `${value}%` : undefined;\n const label = message && valString ? `${message} - ${valString}` : message || valString;\n\n const renderVisible = () => {\n setIsVisibleState(true);\n setNullRender(false);\n };\n\n const renderNotVisible = () => {\n setIsVisibleState(false);\n // With a transition, setNullRender needs to be called in Backdrop's onAfterTransitionOut.\n if (!hasBackdrop) {\n setNullRender(true);\n }\n };\n\n // Handle render and visible state.\n useEffect(\n () => {\n if (visibleProp) {\n // Capture a timestamp for additional timers.\n timeBeforeVisibleRender.current = Date.now();\n\n if (delay) {\n delayTimer.current = window.setTimeout(renderVisible, delayDuration);\n } else {\n renderVisible();\n }\n } else if (\n // A timer was started to render visible either avoid it or render null.\n delayTimer.current !== undefined\n ) {\n // If a timeout has started to render visible, clear it.\n clearTimeout(delayTimer.current);\n\n // If the indicator has already rendered visible.\n if (timeAfterVisibleRender.current !== undefined) {\n const timeElapsedSinceLastVisibleRender = Date.now() - timeAfterVisibleRender.current;\n\n // If the indicator has been visible for long enough we can remove it.\n if (timeElapsedSinceLastVisibleRender >= minVisibleDuration) {\n renderNotVisible();\n } else {\n // Hold off removing until we hit the minimum visible time.\n minVisibleTimer.current = window.setTimeout(\n renderNotVisible,\n minVisibleDuration - timeElapsedSinceLastVisibleRender\n );\n }\n } else {\n renderNotVisible();\n }\n } else {\n renderNotVisible();\n }\n },\n // visibleProp is the only triggerable dependency. Others values will be captured.\n [visibleProp]\n );\n\n // Live announcement\n useEffect(\n () => {\n if (liveConfig?.contextualLabel && isVisibleState) {\n announcePolite({\n message: `${liveConfig.contextualLabel}, ${label ?? t('loading')}`,\n type: 'status'\n });\n }\n },\n // isVisibleState is the only triggerable dependency. Others values will be captured.\n [isVisibleState]\n );\n\n // Auto focusing and render timestamping.\n useEffect(\n () => {\n if (!nullRender && isVisibleState) {\n // After a visible render set a timestamp for timers above.\n timeAfterVisibleRender.current = Date.now();\n\n if (focusOnVisible) progressEl.current?.focus();\n }\n },\n // nullRender is the only triggerable dependency. Others values will be captured.\n [nullRender]\n );\n\n if (nullRender) return null;\n\n const CompVariant = variantMap[variant];\n\n let indicator = (\n <CompVariant\n aria-label={typeof value !== 'number' && label ? label : t('loading')}\n as={placement === 'inline' ? 'span' : undefined}\n {...restProps}\n placement={placement}\n value={value}\n aria-valuetext={typeof value === 'number' ? label : undefined}\n ref={progressEl}\n tabIndex={-1}\n />\n );\n\n if (placement !== 'inline') {\n indicator = (\n <Flex\n container={{ direction: 'column', alignItems: 'center', gap: 0.5 }}\n as={StyledProgress}\n placement={placement}\n >\n {indicator}\n {message && (\n <Text as={StyledMessage} variant='secondary' aria-hidden>\n {message}\n </Text>\n )}\n </Flex>\n );\n }\n\n // generate background variant based on theme text color\n const progressBackdropVariant =\n getLuminance(theme.base.palette['foreground-color']) > 0.5 ? 'dark' : 'light';\n\n const content = hasBackdrop ? (\n <StyledProgressBackdrop\n open={isVisibleState}\n container={{ direction: 'column' }}\n position={placement === 'global' ? 'fixed' : 'absolute'}\n variant={progressBackdropVariant}\n alpha={0.6}\n onBeforeTransitionIn={onTransitionStartIn}\n onAfterTransitionIn={onTransitionEndIn}\n onBeforeTransitionOut={onTransitionStartOut}\n onAfterTransitionOut={() => {\n setNullRender(true);\n onTransitionEndOut?.();\n }}\n >\n {indicator}\n </StyledProgressBackdrop>\n ) : (\n indicator\n );\n\n return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;\n});\n\nexport default Progress;\n"]}
1
+ {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC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AE,EAAE,aAAa,EAAE,OAAO,EAAC,WAAW,iCACzC,OAAO,GACH,CACR,IACI,CACR,CAAC;IACJ,CAAC;IAED,wDAAwD;IACxD,MAAM,uBAAuB,GAC3B,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAEhF,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAC5B,KAAC,sBAAsB,IACrB,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,EACpF,QAAQ,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EACvD,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,GAAG,EACV,oBAAoB,EAAE,mBAAmB,EACzC,mBAAmB,EAAE,iBAAiB,EACtC,qBAAqB,EAAE,oBAAoB,EAC3C,oBAAoB,EAAE,GAAG,EAAE;YACzB,aAAa,CAAC,IAAI,CAAC,CAAC;YACpB,qBAAqB,CAAC,SAAS,CAAC,CAAC;YACjC,kBAAkB,EAAE,EAAE,CAAC;QACzB,CAAC,YAEA,SAAS,GACa,CAC1B,CAAC,CAAC,CAAC,CACF,SAAS,CACV,CAAC;IAEF,OAAO,SAAS,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChG,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useRef, useLayoutEffect } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { getLuminance } from 'polished';\n\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Text from '../Text';\nimport { useConfiguration, useConsolidatedRef, useI18n, useLiveLog, useTheme } from '../../hooks';\nimport Flex from '../Flex';\n\nimport type { ProgressProps } from './Progress.types';\nimport Bar from './Bar';\nimport Ellipsis from './Ellipsis';\nimport Ring from './Ring';\nimport { StyledMessage, StyledProgress, StyledProgressBackdrop } from './Progress.styles';\n\nconst variantMap = {\n ring: Ring,\n bar: Bar,\n ellipsis: Ellipsis\n} as const;\n\nconst defaultDelayDuration = 100;\nconst minVisibleDuration = 1000;\n\nconst Progress: ForwardRefForwardPropsComponent<ProgressProps> = forwardRef(function Progress(\n {\n variant = 'ring',\n placement = 'global',\n visible: visibleProp = true,\n focusOnVisible = false,\n delay = false,\n onTransitionStartIn,\n onTransitionEndIn,\n onTransitionStartOut,\n onTransitionEndOut,\n value,\n message,\n liveConfig,\n offsetContainer,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n) {\n const t = useI18n();\n const { portalTarget } = useConfiguration();\n const { announcePolite } = useLiveLog();\n const theme = useTheme();\n const progressEl = useConsolidatedRef<HTMLDivElement>(ref);\n const backdropRef = useRef<HTMLDivElement>(null);\n const [indicatorOffsetTop, setIndicatorOffsetTop] = useState<number | undefined>();\n\n // Rendering states. Both are needed due to Backdrop's transition phase where isVisibleState is false but nullRender is true until onAfterTransitionOut.\n const [isVisibleState, setIsVisibleState] = useState(delay ? false : visibleProp);\n const [nullRender, setNullRender] = useState(!isVisibleState);\n\n // Refs for timestamps and timeout ids.\n const timeBeforeVisibleRender = useRef<number>();\n const timeAfterVisibleRender = useRef<number>();\n const delayTimer = useRef<number>();\n const minVisibleTimer = useRef<number>();\n\n const hasBackdrop = placement === 'global' || placement === 'local';\n const valString = typeof value === 'number' ? `${value}%` : undefined;\n const label = message && valString ? `${message} - ${valString}` : message || valString;\n\n const hasOffsetContainer = !!offsetContainer;\n\n const renderVisible = () => {\n setIsVisibleState(true);\n setNullRender(false);\n };\n\n const renderNotVisible = () => {\n setIsVisibleState(false);\n // With a transition, setNullRender needs to be called in Backdrop's onAfterTransitionOut.\n if (!hasBackdrop) {\n setNullRender(true);\n }\n };\n\n useLayoutEffect(() => {\n if (!isVisibleState || nullRender || !backdropRef.current || !offsetContainer?.current) {\n return;\n }\n\n const backdropRect = backdropRef.current.getBoundingClientRect();\n const refRect = offsetContainer.current.getBoundingClientRect();\n const viewportHeight = document.documentElement.clientHeight;\n\n // Visible portion of the reference element within the viewport\n const visibleTop = Math.max(refRect.top, 0);\n const visibleBottom = Math.min(refRect.bottom, viewportHeight);\n\n if (visibleBottom <= visibleTop) {\n setIndicatorOffsetTop(NaN);\n return;\n }\n\n // Center of the visible portion, relative to the backdrop\n setIndicatorOffsetTop((visibleTop + visibleBottom) / 2 - backdropRect.top);\n }, [isVisibleState, nullRender, offsetContainer]);\n\n // Handle render and visible state.\n useEffect(\n () => {\n if (visibleProp) {\n // Capture a timestamp for additional timers.\n timeBeforeVisibleRender.current = Date.now();\n\n if (delay) {\n const delayDuration = typeof delay === 'number' ? delay : defaultDelayDuration;\n delayTimer.current = window.setTimeout(renderVisible, delayDuration);\n } else {\n renderVisible();\n }\n } else if (\n // A timer was started to render visible either avoid it or render null.\n delayTimer.current !== undefined\n ) {\n // If a timeout has started to render visible, clear it.\n clearTimeout(delayTimer.current);\n\n // If the indicator has already rendered visible.\n if (timeAfterVisibleRender.current !== undefined) {\n const timeElapsedSinceLastVisibleRender = Date.now() - timeAfterVisibleRender.current;\n\n // If the indicator has been visible for long enough we can remove it.\n if (timeElapsedSinceLastVisibleRender >= minVisibleDuration) {\n renderNotVisible();\n } else {\n // Hold off removing until we hit the minimum visible time.\n minVisibleTimer.current = window.setTimeout(\n renderNotVisible,\n minVisibleDuration - timeElapsedSinceLastVisibleRender\n );\n }\n } else {\n renderNotVisible();\n }\n } else {\n renderNotVisible();\n }\n },\n // visibleProp is the only triggerable dependency. Others values will be captured.\n [visibleProp]\n );\n\n // Live announcement\n useEffect(\n () => {\n if (liveConfig?.contextualLabel && isVisibleState) {\n announcePolite({\n message: `${liveConfig.contextualLabel}, ${label ?? t('loading')}`,\n type: 'status'\n });\n }\n },\n // isVisibleState is the only triggerable dependency. Others values will be captured.\n [isVisibleState]\n );\n\n // Auto focusing and render timestamping.\n useEffect(\n () => {\n if (!nullRender && isVisibleState) {\n // After a visible render set a timestamp for timers above.\n timeAfterVisibleRender.current = Date.now();\n\n // If there is no offsetContainer focus immediately.\n // Otherwise wait until a render has applied offset to avoid the indicator being pulled out of view.\n if ((focusOnVisible && !hasOffsetContainer) || indicatorOffsetTop) {\n progressEl.current?.focus();\n }\n }\n },\n // nullRender is the only triggerable dependency. Others values will be captured.\n [nullRender, hasOffsetContainer, indicatorOffsetTop]\n );\n\n if (nullRender) return null;\n\n const CompVariant = variantMap[variant];\n\n let indicator = (\n <CompVariant\n aria-label={typeof value !== 'number' && label ? label : t('loading')}\n as={placement === 'inline' ? 'span' : undefined}\n {...restProps}\n placement={placement}\n value={value}\n aria-valuetext={typeof value === 'number' ? label : undefined}\n ref={progressEl}\n tabIndex={-1}\n />\n );\n\n if (placement !== 'inline') {\n indicator = (\n <Flex\n container={{ direction: 'column', alignItems: 'center', gap: 0.5 }}\n as={StyledProgress}\n placement={placement}\n /*\n Inline style justification:\n Highly variable values will generate new classes every time.\n Not using CSS var since can not conditionally set property, only value.\n marginTop is used vs logical property since value is based on client rect which is not logical.\n */\n style={indicatorOffsetTop ? { marginTop: `${indicatorOffsetTop}px` } : undefined}\n >\n {indicator}\n {message && (\n <Text as={StyledMessage} variant='secondary' aria-hidden>\n {message}\n </Text>\n )}\n </Flex>\n );\n }\n\n // generate background variant based on theme text color\n const progressBackdropVariant =\n getLuminance(theme.base.palette['foreground-color']) > 0.5 ? 'dark' : 'light';\n\n const content = hasBackdrop ? (\n <StyledProgressBackdrop\n ref={backdropRef}\n open={isVisibleState}\n container={{ direction: 'column', justify: indicatorOffsetTop ? 'start' : 'center' }}\n position={placement === 'global' ? 'fixed' : 'absolute'}\n variant={progressBackdropVariant}\n alpha={0.6}\n onBeforeTransitionIn={onTransitionStartIn}\n onAfterTransitionIn={onTransitionEndIn}\n onBeforeTransitionOut={onTransitionStartOut}\n onAfterTransitionOut={() => {\n setNullRender(true);\n setIndicatorOffsetTop(undefined);\n onTransitionEndOut?.();\n }}\n >\n {indicator}\n </StyledProgressBackdrop>\n ) : (\n indicator\n );\n\n return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;\n});\n\nexport default Progress;\n"]}
@@ -1,4 +1,4 @@
1
- import type { Ref } from 'react';
1
+ import type { Ref, RefObject } from 'react';
2
2
  import type { BaseProps, NoChildrenProp } from '../../types';
3
3
  import type { BackdropProps } from '../Backdrop/Backdrop';
4
4
  export interface ProgressProps extends BaseProps, NoChildrenProp {
@@ -40,11 +40,11 @@ export interface ProgressProps extends BaseProps, NoChildrenProp {
40
40
  */
41
41
  focusOnVisible?: boolean;
42
42
  /**
43
- * If true, the indicator will not render as visible until 1sec after the visible prop is set to true.
44
- * This is a best estimate to avoid visual flicker where progress is resolved within 1sec.
43
+ * If true, render is delayed to avoid unwanted flickering.
44
+ * Pass a number to customize the delay.
45
45
  * @default false
46
46
  */
47
- delay?: boolean;
47
+ delay?: boolean | number;
48
48
  /** Called when the css transition starts on the way in. */
49
49
  onTransitionStartIn?: BackdropProps['onBeforeTransitionIn'];
50
50
  /** Called when the css transition starts on the way out. */
@@ -58,6 +58,12 @@ export interface ProgressProps extends BaseProps, NoChildrenProp {
58
58
  /** Distinguishes the source of the update on the page. */
59
59
  contextualLabel: string;
60
60
  };
61
+ /**
62
+ * For use with "local" placement only.
63
+ * Reference to the relative container element for the locally placed backdrop.
64
+ * Enables dynamic offset of the visual indicator.
65
+ */
66
+ offsetContainer?: RefObject<Element>;
61
67
  /** Ref to the visual indicator element, currently a role of progressbar. */
62
68
  ref?: Ref<HTMLDivElement>;
63
69
  }
@@ -1 +1 @@
1
- {"version":3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ACtE,UAAU,CAAC,EAAE;QACX,0DAA0D;QAC1D,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF;;;;OAIG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,4EAA4E;IAC5E,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.types.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps, NoChildrenProp } from '../../types';\nimport type { BackdropProps } from '../Backdrop/Backdrop';\n\nexport interface ProgressProps extends BaseProps, NoChildrenProp {\n /**\n * Determines which variant should be rendered.\n * @default 'ring'\n */\n variant?: 'ring' | 'bar' | 'ellipsis';\n /**\n * Minimum possible value.\n * @default 0\n */\n minValue?: number;\n /**\n * Maximum possible value.\n * @default 100\n */\n maxValue?: number;\n /** Current progress value within the range specified, or the default range of 0-100. */\n value?: number;\n /** Provides a message to the user along with the component. */\n message?: string;\n /**\n * Determines the placement of the component.\n * @default 'global'\n */\n placement?: 'global' | 'local' | 'block' | 'inline';\n /**\n * When true, fade in occurs when component mounts.\n * When false, mounted component fades out then re-renders self and returns null, removing itself from the DOM.\n * This is technically not the same as unmounting via parent.\n * Applicable for all placements but the fade effect is only applicable to 'global' | 'local' placement.\n * @default true\n */\n visible?: boolean;\n /**\n * If true, upon visible render the indicator element will take focus.\n * @default false\n */\n focusOnVisible?: boolean;\n /**\n * If true, the indicator will not render as visible until 1sec after the visible prop is set to true.\n * This is a best estimate to avoid visual flicker where progress is resolved within 1sec.\n * @default false\n */\n delay?: boolean;\n /** Called when the css transition starts on the way in. */\n onTransitionStartIn?: BackdropProps['onBeforeTransitionIn'];\n /** Called when the css transition starts on the way out. */\n onTransitionStartOut?: BackdropProps['onBeforeTransitionOut'];\n /** Called when the css transition ends on the way in. */\n onTransitionEndIn?: BackdropProps['onAfterTransitionIn'];\n /** Called when the css transition ends on the way out...A good time to unmount! */\n onTransitionEndOut?: BackdropProps['onAfterTransitionOut'];\n /** Triggers live announcement on show and value or message change. */\n liveConfig?: {\n /** Distinguishes the source of the update on the page. */\n contextualLabel: string;\n };\n /** Ref to the visual indicator element, currently a role of progressbar. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
1
+ {"version":3,"file":"Progress.types.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref, RefObject } from 'react';\n\nimport type { BaseProps, NoChildrenProp } from '../../types';\nimport type { BackdropProps } from '../Backdrop/Backdrop';\n\nexport interface ProgressProps extends BaseProps, NoChildrenProp {\n /**\n * Determines which variant should be rendered.\n * @default 'ring'\n */\n variant?: 'ring' | 'bar' | 'ellipsis';\n /**\n * Minimum possible value.\n * @default 0\n */\n minValue?: number;\n /**\n * Maximum possible value.\n * @default 100\n */\n maxValue?: number;\n /** Current progress value within the range specified, or the default range of 0-100. */\n value?: number;\n /** Provides a message to the user along with the component. */\n message?: string;\n /**\n * Determines the placement of the component.\n * @default 'global'\n */\n placement?: 'global' | 'local' | 'block' | 'inline';\n /**\n * When true, fade in occurs when component mounts.\n * When false, mounted component fades out then re-renders self and returns null, removing itself from the DOM.\n * This is technically not the same as unmounting via parent.\n * Applicable for all placements but the fade effect is only applicable to 'global' | 'local' placement.\n * @default true\n */\n visible?: boolean;\n /**\n * If true, upon visible render the indicator element will take focus.\n * @default false\n */\n focusOnVisible?: boolean;\n /**\n * If true, render is delayed to avoid unwanted flickering.\n * Pass a number to customize the delay.\n * @default false\n */\n delay?: boolean | number;\n /** Called when the css transition starts on the way in. */\n onTransitionStartIn?: BackdropProps['onBeforeTransitionIn'];\n /** Called when the css transition starts on the way out. */\n onTransitionStartOut?: BackdropProps['onBeforeTransitionOut'];\n /** Called when the css transition ends on the way in. */\n onTransitionEndIn?: BackdropProps['onAfterTransitionIn'];\n /** Called when the css transition ends on the way out...A good time to unmount! */\n onTransitionEndOut?: BackdropProps['onAfterTransitionOut'];\n /** Triggers live announcement on show and value or message change. */\n liveConfig?: {\n /** Distinguishes the source of the update on the page. */\n contextualLabel: string;\n };\n /**\n * For use with \"local\" placement only.\n * Reference to the relative container element for the locally placed backdrop.\n * Enables dynamic offset of the visual indicator.\n */\n offsetContainer?: RefObject<Element>;\n /** Ref to the visual indicator element, currently a role of progressbar. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
@@ -3,7 +3,7 @@ import type { FormFieldProps } from '../FormField';
3
3
  import type { FormControlProps } from '../FormControl';
4
4
  import type { NoChildrenProp, WithAttributes, TestIdProp } from '../../types';
5
5
  import type { elements } from '../FormField/FormField.test-ids';
6
- export type RadioCheckProps = WithAttributes<'input', NoChildrenProp & TestIdProp<typeof elements> & {
6
+ export type RadioCheckProps = WithAttributes<'input', NoChildrenProp & TestIdProp<typeof elements> & Pick<FormControlProps, 'suggestion'> & {
7
7
  /** Pass a string or a fragment with an Icon and string. */
8
8
  label?: FormControlProps['label'];
9
9
  /** Set visual state based on a validation state. */
@@ -39,7 +39,9 @@ export declare const StyledPseudoRadioCheck: import("styled-components/dist/type
39
39
  $labelEmpty?: boolean;
40
40
  }>> & string;
41
41
  export declare const StyledRadioCheckInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
42
- export declare const StyledRadioCheck: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<RadioCheckProps, "disabled" | "readOnly">>> & string;
42
+ export declare const StyledRadioCheck: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<RadioCheckProps, "disabled" | "readOnly"> & {
43
+ hasSuggestion?: boolean;
44
+ }>> & string;
43
45
  export declare const StyledRadioCheckCard: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, Pick<RadioCheckProps, "disabled" | "readOnly" | "status">>> & string;
44
46
  declare const _default: import("react").ForwardRefExoticComponent<Omit<RadioCheckProps, "ref"> & import("react").RefAttributes<HTMLInputElement>> & {
45
47
  getTestIds: (testIdProp?: TestIdProp["testId"]) => import("../../types").TestIdsRecord<readonly ["control", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioCheck.d.ts","sourceRoot":"","sources":["../../../src/components/RadioCheck/RadioCheck.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8C,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAK5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAK1F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAIhE,MAAM,MAAM,eAAe,GAAG,cAAc,CAC1C,OAAO,EACP,cAAc,GACZ,UAAU,CAAC,OAAO,QAAQ,CAAC,GAAG;IAC5B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,8BAA8B;IAC9B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CA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AG;IACrC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,8BAA8B;IAC9B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACpD,iDAAiD;IACjD,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAChD,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAC;CACjE,CACJ,CAAC;AAEF,eAAO,MAAM,sBAAsB;kBAC8B,OAAO;YAuCtE,CAAC;AAIH,eAAO,MAAM,qBAAqB,sOAuGhC,CAAC;AAIH,eAAO,MAAM,gBAAgB;oBACwC,OAAO;YA4F1E,CAAC;AAIH,eAAO,MAAM,oBAAoB,uSAyD/B,CAAC;;;;AA0IH,wBAA6D"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { hideVisually } from 'polished';
4
+ import { hideVisually, mix, rgba } from 'polished';
5
5
  import FormField, { StyledFormFieldInfo } from '../FormField';
6
6
  import { StyledFormControl } from '../FormControl';
7
7
  import { defaultThemeProp } from '../../theme';
@@ -124,38 +124,74 @@ export const StyledRadioCheckInput = styled.input(({ theme, disabled, readOnly }
124
124
  `;
125
125
  });
126
126
  StyledRadioCheckInput.defaultProps = defaultThemeProp;
127
- export const StyledRadioCheck = styled.div(({ theme, disabled, readOnly }) => {
128
- const { base, components: { 'radio-check': { label: { color: labelColor, 'font-weight': labelFontWeight } }, 'form-control': { ':hover': { 'border-color': hoverBorderColor } } } } = theme;
127
+ export const StyledRadioCheck = styled.div(({ theme, disabled, readOnly, hasSuggestion }) => {
128
+ const { base, components: { 'radio-check': { label: { color: labelColor, 'font-weight': labelFontWeight } }, 'form-control': { ':hover': { 'border-color': hoverBorderColor }, 'border-radius': radius, 'background-color': background }, 'form-field': formField } } = theme;
129
129
  const fontSize = calculateFontSize(base['font-size'], base['font-scale']);
130
+ const suggestionBorderColor = getReadableStatusColor(theme, 'pending');
130
131
  return css `
131
- > ${StyledLabel} {
132
- cursor: pointer;
133
- display: flex;
134
- align-items: center;
135
- font-weight: ${labelFontWeight};
136
- word-break: break-word;
137
- font-size: ${fontSize.s};
138
- color: ${labelColor};
139
- margin: 0;
140
- min-height: ${base['hit-area']['mouse-min']};
141
-
142
- @media (pointer: coarse) {
143
- min-height: ${base['hit-area']['finger-min']};
144
- }
145
- }
132
+ > ${StyledLabel} {
133
+ cursor: pointer;
134
+ display: flex;
135
+ align-items: center;
136
+ font-weight: ${labelFontWeight};
137
+ word-break: break-word;
138
+ font-size: ${fontSize.s};
139
+ color: ${labelColor};
140
+ margin: 0;
141
+ min-height: ${base['hit-area']['mouse-min']};
146
142
 
147
- > ${StyledFormFieldInfo} {
148
- margin: 0;
149
- padding-inline-start: calc(${base.spacing} / 4);
143
+ @media (pointer: coarse) {
144
+ min-height: ${base['hit-area']['finger-min']};
150
145
  }
146
+ }
151
147
 
152
- ${!(disabled || readOnly) &&
148
+ > ${StyledFormFieldInfo} {
149
+ margin: 0;
150
+ padding-inline-start: calc(${base.spacing} / 4);
151
+ }
152
+
153
+ ${!(disabled || readOnly) &&
153
154
  css `
154
- &:not(:focus-within) > ${StyledLabel}:hover ${StyledPseudoRadioCheck} {
155
- border-color: ${hoverBorderColor};
155
+ &:not(:focus-within) > ${StyledLabel}:hover ${StyledPseudoRadioCheck} {
156
+ border-color: ${hoverBorderColor};
157
+ }
158
+
159
+ ${hasSuggestion &&
160
+ css `
161
+ > ${StyledRadioCheckInput}:not(:focus) {
162
+ &:checked + ${StyledLabel} {
163
+ &:not(:hover) ${StyledPseudoRadioCheck} {
164
+ background-color: ${suggestionBorderColor};
165
+ border-color: ${suggestionBorderColor};
166
+
167
+ &::after {
168
+ border-color: ${mix(0.1, formField.pending['status-color'], base.palette['primary-background'])};
169
+ }
170
+ }
171
+
172
+ &:hover ${StyledPseudoRadioCheck} {
173
+ background-color: ${suggestionBorderColor};
174
+ border-color: ${suggestionBorderColor};
175
+ box-shadow: 0 0 0 0.125rem ${rgba(suggestionBorderColor, 0.2)};
176
+ }
177
+ }
178
+
179
+ &:not(:checked) + ${StyledLabel} {
180
+ ${StyledPseudoRadioCheck} {
181
+ border-color: ${suggestionBorderColor};
182
+ border-inline-start-width: calc(${base['border-radius']} * ${radius});
183
+ background-color: ${mix(0.1, formField.pending['status-color'], base.palette['primary-background'])};
184
+ }
185
+
186
+ &:hover ${StyledPseudoRadioCheck} {
187
+ background-color: ${background};
188
+ box-shadow: 0 0 0 0.125rem ${rgba(suggestionBorderColor, 0.2)};
189
+ }
190
+ }
156
191
  }
157
192
  `}
158
- `;
193
+ `}
194
+ `;
159
195
  });
160
196
  StyledRadioCheck.defaultProps = defaultThemeProp;
161
197
  export const StyledRadioCheckCard = styled.label(({ theme, disabled, readOnly, status }) => {
@@ -206,7 +242,7 @@ StyledRadioCheckCard.defaultProps = defaultThemeProp;
206
242
  const RadioCheck = forwardRef(function RadioCheck(props, ref) {
207
243
  const uid = useUID();
208
244
  const t = useI18n();
209
- const { testId, type, id = uid, label, 'aria-labelledby': ariaLabelledBy, required = false, disabled = false, readOnly = false, indeterminate = false, checked, defaultChecked, variant = 'simple', onClick, onKeyDown, onChange, status, info, additionalInfo, ariaDescribedby, suppressAnnouncements, className, ...restProps } = props;
245
+ const { testId, type, id = uid, label, 'aria-labelledby': ariaLabelledBy, required = false, disabled = false, readOnly = false, indeterminate = false, checked, defaultChecked, variant = 'simple', onClick, onKeyDown, onChange, status, info, additionalInfo, ariaDescribedby, suppressAnnouncements, className, suggestion, ...restProps } = props;
210
246
  const testIds = useTestIds(testId, getRadioCheckTestIds);
211
247
  const isRadio = type === 'radio';
212
248
  const card = variant === 'card';
@@ -234,7 +270,7 @@ const RadioCheck = forwardRef(function RadioCheck(props, ref) {
234
270
  };
235
271
  }, []);
236
272
  const labelEmpty = label === null || label === undefined || label === '';
237
- return (_jsx(FormField, { testId: testIds, as: card ? StyledRadioCheckCard : StyledRadioCheck, label: _jsxs(_Fragment, { children: [_jsx(StyledPseudoRadioCheck, { status: status, as: StyledFormControl, required: required, disabled: disabled, readOnly: readOnly, "$labelEmpty": labelEmpty }), label, readOnly && _jsx(HiddenText, { id: readonlyDescId, children: t('read_only') })] }), labelAs: card || ariaLabelledBy ? 'div' : undefined, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, info: info, isRadioCheck: true, inline: true, labelAfter: true, additionalInfo: additionalInfo, suppressAnnouncements: suppressAnnouncements, children: _jsx(StyledRadioCheckInput, { "data-testid": testIds.control, ...restProps, className: createClassName('radio-check', className, {
273
+ return (_jsx(FormField, { testId: testIds, as: card ? StyledRadioCheckCard : StyledRadioCheck, label: _jsxs(_Fragment, { children: [_jsx(StyledPseudoRadioCheck, { status: status, as: StyledFormControl, required: required, disabled: disabled, readOnly: readOnly, "$labelEmpty": labelEmpty }), label, readOnly && _jsx(HiddenText, { id: readonlyDescId, children: t('read_only') })] }), labelAs: card || ariaLabelledBy ? 'div' : undefined, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, info: info, isRadioCheck: true, inline: true, labelAfter: true, additionalInfo: additionalInfo, suppressAnnouncements: suppressAnnouncements, suggestion: suggestion, hasSuggestion: status === 'pending' && !!suggestion, children: _jsx(StyledRadioCheckInput, { "data-testid": testIds.control, ...restProps, className: createClassName('radio-check', className, {
238
274
  variant,
239
275
  type
240
276
  }), id: id, "aria-labelledby": ariaLabelledBy, type: type, required: required, checked: checked, defaultChecked: defaultChecked, "aria-describedby": readOnly ? `${ariaDescribedby} ${readonlyDescId}` : ariaDescribedby, disabled: disabled, readOnly: readOnly, onChange: onChange, onClick: (e) => {