@pega/cosmos-react-core 4.0.0-dev.6.0 → 4.0.0-dev.7.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 (145) hide show
  1. package/lib/components/Card/Card.d.ts +4 -7
  2. package/lib/components/Card/Card.d.ts.map +1 -1
  3. package/lib/components/Card/Card.js +2 -9
  4. package/lib/components/Card/Card.js.map +1 -1
  5. package/lib/components/Configuration/Configuration.d.ts +2 -0
  6. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  7. package/lib/components/Configuration/Configuration.js.map +1 -1
  8. package/lib/components/DateTime/DateTime.types.d.ts +4 -1
  9. package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
  10. package/lib/components/DateTime/DateTime.types.js.map +1 -1
  11. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  12. package/lib/components/DateTime/Input/DateInput.js +12 -1
  13. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  14. package/lib/components/DateTime/Input/DateRangeInput.d.ts +4 -2
  15. package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
  16. package/lib/components/DateTime/Input/DateRangeInput.js +71 -34
  17. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  18. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  19. package/lib/components/DateTime/Input/DateTimeInput.js +19 -2
  20. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  21. package/lib/components/DateTime/Input/PartInput.d.ts.map +1 -1
  22. package/lib/components/DateTime/Input/PartInput.js +2 -2
  23. package/lib/components/DateTime/Input/PartInput.js.map +1 -1
  24. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  25. package/lib/components/DateTime/Input/TimeInput.js +13 -2
  26. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  27. package/lib/components/DateTime/Input/TimeRangeInput.d.ts +4 -2
  28. package/lib/components/DateTime/Input/TimeRangeInput.d.ts.map +1 -1
  29. package/lib/components/DateTime/Input/TimeRangeInput.js +70 -27
  30. package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -1
  31. package/lib/components/FormControl/FormControl.d.ts +4 -0
  32. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  33. package/lib/components/FormControl/FormControl.js.map +1 -1
  34. package/lib/components/FormControl/index.d.ts +1 -0
  35. package/lib/components/FormControl/index.d.ts.map +1 -1
  36. package/lib/components/FormControl/index.js.map +1 -1
  37. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  38. package/lib/components/ListToolbar/ListToolbar.js +5 -3
  39. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  40. package/lib/components/LiveLog/Context.d.ts +3 -0
  41. package/lib/components/LiveLog/Context.d.ts.map +1 -0
  42. package/lib/components/LiveLog/Context.js +9 -0
  43. package/lib/components/LiveLog/Context.js.map +1 -0
  44. package/lib/components/LiveLog/LiveLog.d.ts +10 -0
  45. package/lib/components/LiveLog/LiveLog.d.ts.map +1 -0
  46. package/lib/components/LiveLog/LiveLog.js +93 -0
  47. package/lib/components/LiveLog/LiveLog.js.map +1 -0
  48. package/lib/components/LiveLog/LiveLog.styles.d.ts +3 -0
  49. package/lib/components/LiveLog/LiveLog.styles.d.ts.map +1 -0
  50. package/lib/components/LiveLog/LiveLog.styles.js +9 -0
  51. package/lib/components/LiveLog/LiveLog.styles.js.map +1 -0
  52. package/lib/components/LiveLog/LiveLog.types.d.ts +93 -0
  53. package/lib/components/LiveLog/LiveLog.types.d.ts.map +1 -0
  54. package/lib/components/LiveLog/LiveLog.types.js +2 -0
  55. package/lib/components/LiveLog/LiveLog.types.js.map +1 -0
  56. package/lib/components/LiveLog/index.d.ts +3 -0
  57. package/lib/components/LiveLog/index.d.ts.map +1 -0
  58. package/lib/components/LiveLog/index.js +2 -0
  59. package/lib/components/LiveLog/index.js.map +1 -0
  60. package/lib/components/Menu/Menu.d.ts.map +1 -1
  61. package/lib/components/Menu/Menu.js +2 -0
  62. package/lib/components/Menu/Menu.js.map +1 -1
  63. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  64. package/lib/components/Menu/MenuList.js +4 -3
  65. package/lib/components/Menu/MenuList.js.map +1 -1
  66. package/lib/components/Modal/Modal.types.d.ts +1 -0
  67. package/lib/components/Modal/Modal.types.d.ts.map +1 -1
  68. package/lib/components/Modal/Modal.types.js.map +1 -1
  69. package/lib/components/Number/NumberInput.types.d.ts +3 -1
  70. package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
  71. package/lib/components/Number/NumberInput.types.js.map +1 -1
  72. package/lib/components/Number/NumberRangeInput.d.ts.map +1 -1
  73. package/lib/components/Number/NumberRangeInput.js +71 -4
  74. package/lib/components/Number/NumberRangeInput.js.map +1 -1
  75. package/lib/components/Popover/Popover.d.ts.map +1 -1
  76. package/lib/components/Popover/Popover.js +2 -5
  77. package/lib/components/Popover/Popover.js.map +1 -1
  78. package/lib/components/Popover/Popover.styles.d.ts +0 -1
  79. package/lib/components/Popover/Popover.styles.d.ts.map +1 -1
  80. package/lib/components/Popover/Popover.styles.js +0 -6
  81. package/lib/components/Popover/Popover.styles.js.map +1 -1
  82. package/lib/components/Popover/modifiers.d.ts +0 -2
  83. package/lib/components/Popover/modifiers.d.ts.map +1 -1
  84. package/lib/components/Popover/modifiers.js +1 -32
  85. package/lib/components/Popover/modifiers.js.map +1 -1
  86. package/lib/components/Progress/Progress.d.ts.map +1 -1
  87. package/lib/components/Progress/Progress.js +15 -4
  88. package/lib/components/Progress/Progress.js.map +1 -1
  89. package/lib/components/Progress/Progress.types.d.ts +5 -0
  90. package/lib/components/Progress/Progress.types.d.ts.map +1 -1
  91. package/lib/components/Progress/Progress.types.js.map +1 -1
  92. package/lib/components/QRCode/QRCode.d.ts +13 -0
  93. package/lib/components/QRCode/QRCode.d.ts.map +1 -0
  94. package/lib/components/QRCode/QRCode.js +17 -0
  95. package/lib/components/QRCode/QRCode.js.map +1 -0
  96. package/lib/components/QRCode/index.d.ts +3 -0
  97. package/lib/components/QRCode/index.d.ts.map +1 -0
  98. package/lib/components/QRCode/index.js +2 -0
  99. package/lib/components/QRCode/index.js.map +1 -0
  100. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  101. package/lib/components/SearchInput/SearchInput.js +27 -7
  102. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  103. package/lib/components/Tabs/Tabs.d.ts.map +1 -1
  104. package/lib/components/Tabs/Tabs.js +6 -0
  105. package/lib/components/Tabs/Tabs.js.map +1 -1
  106. package/lib/components/Toaster/Context.d.ts +1 -0
  107. package/lib/components/Toaster/Context.d.ts.map +1 -1
  108. package/lib/components/Toaster/Context.js.map +1 -1
  109. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  110. package/lib/components/Toaster/Toaster.js +5 -1
  111. package/lib/components/Toaster/Toaster.js.map +1 -1
  112. package/lib/hooks/index.d.ts +1 -0
  113. package/lib/hooks/index.d.ts.map +1 -1
  114. package/lib/hooks/index.js +1 -0
  115. package/lib/hooks/index.js.map +1 -1
  116. package/lib/hooks/useBreakpoint.d.ts.map +1 -1
  117. package/lib/hooks/useBreakpoint.js +3 -2
  118. package/lib/hooks/useBreakpoint.js.map +1 -1
  119. package/lib/hooks/useI18n.d.ts +43 -0
  120. package/lib/hooks/useI18n.d.ts.map +1 -1
  121. package/lib/hooks/useLiveLog.d.ts +8 -0
  122. package/lib/hooks/useLiveLog.d.ts.map +1 -0
  123. package/lib/hooks/useLiveLog.js +16 -0
  124. package/lib/hooks/useLiveLog.js.map +1 -0
  125. package/lib/i18n/default.d.ts +43 -0
  126. package/lib/i18n/default.d.ts.map +1 -1
  127. package/lib/i18n/default.js +44 -0
  128. package/lib/i18n/default.js.map +1 -1
  129. package/lib/i18n/i18n.d.ts +43 -0
  130. package/lib/i18n/i18n.d.ts.map +1 -1
  131. package/lib/index.d.ts +4 -0
  132. package/lib/index.d.ts.map +1 -1
  133. package/lib/index.js +4 -0
  134. package/lib/index.js.map +1 -1
  135. package/lib/register-contexts.js +2 -0
  136. package/lib/register-contexts.js.map +1 -1
  137. package/lib/theme/theme.d.ts +12 -0
  138. package/lib/theme/theme.d.ts.map +1 -1
  139. package/lib/theme/themeDefinition.json +8 -0
  140. package/lib/theme/themes/darkTheme.json +3 -1
  141. package/package.json +3 -1
  142. package/lib/components/ListToolbar/QueryOptionPopover.d.ts +0 -12
  143. package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +0 -1
  144. package/lib/components/ListToolbar/QueryOptionPopover.js +0 -36
  145. package/lib/components/ListToolbar/QueryOptionPopover.js.map +0 -1
@@ -1,18 +1,53 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useCallback } from 'react';
2
+ import { forwardRef, useCallback, useImperativeHandle, useReducer, useRef } from 'react';
3
3
  import { useConsolidatedRef, useI18n, useFocusWithin } from '../../hooks';
4
4
  import { StyledRangeInputContainer } from '../Input/Input.styles';
5
5
  import FormField from '../FormField';
6
6
  import Flex from '../Flex';
7
7
  import NumberInput from './NumberInput';
8
- const NumberRangeInput = forwardRef(({ value = {}, onChange, onBlur, onFocus, label, fromLabel, toLabel, labelHidden, placeholder, disabled, readOnly, required, unit, showDecimal, numberOfDecimals, showGroupSeparators, min, max, step, variant, fromAdditionalInfo, toAdditionalInfo, autoFocus, ...restProps }, ref) => {
8
+ const reducer = (prevState, { type, value }) => {
9
+ switch (type) {
10
+ case 'start': {
11
+ return { ...prevState, start: value };
12
+ }
13
+ case 'end': {
14
+ return { ...prevState, end: value };
15
+ }
16
+ default:
17
+ return prevState;
18
+ }
19
+ };
20
+ const NumberRangeInput = forwardRef(({ value = {}, onChange, onBlur, onFocus, label, fromLabel, toLabel, labelHidden, placeholder, disabled, readOnly, required, status, unit, showDecimal, numberOfDecimals, showGroupSeparators, min, max, step, variant, fromAdditionalInfo, toAdditionalInfo, autoFocus, handle, ...restProps }, ref) => {
9
21
  const t = useI18n();
22
+ const startValueInputRef = useRef(null);
23
+ const endValueInputRef = useRef(null);
24
+ const [state, dispatch] = useReducer(reducer, {
25
+ start: value.start ?? '',
26
+ end: value.end ?? ''
27
+ });
28
+ // Need to keep the value in ref also, to be able to call onBlur with newest value
29
+ const startValueRef = useRef(state.start);
30
+ const endValueRef = useRef(state.end);
10
31
  const onFocusChange = useCallback((focused) => {
11
- (focused ? onFocus : onBlur)?.({ start: value.start ?? '', end: value.end ?? '' });
32
+ (focused ? onFocus : onBlur)?.({ start: startValueRef.current, end: endValueRef.current });
12
33
  }, [onBlur, value.start, value.end]);
13
34
  const containerRef = useConsolidatedRef(ref);
14
35
  useFocusWithin([containerRef], onFocusChange);
36
+ useImperativeHandle(handle, () => ({
37
+ clear: () => {
38
+ if (startValueInputRef.current)
39
+ startValueInputRef.current.value = '';
40
+ if (endValueInputRef.current)
41
+ endValueInputRef.current.value = '';
42
+ startValueRef.current = '';
43
+ endValueRef.current = '';
44
+ dispatch({ type: 'start', value: '' });
45
+ dispatch({ type: 'end', value: '' });
46
+ onChange({ start: '', end: '' });
47
+ }
48
+ }), [onChange]);
15
49
  const commonProps = {
50
+ status,
16
51
  placeholder,
17
52
  readOnly,
18
53
  required,
@@ -24,7 +59,39 @@ const NumberRangeInput = forwardRef(({ value = {}, onChange, onBlur, onFocus, la
24
59
  max,
25
60
  variant
26
61
  };
27
- return (_jsx(FormField, { as: 'fieldset', ...restProps, ref: containerRef, container: { wrap: 'nowrap' }, labelHidden: labelHidden, labelAs: 'legend', label: label, disabled: disabled, required: required, readOnly: readOnly, children: _jsxs(Flex, { container: true, as: StyledRangeInputContainer, children: [_jsx(NumberInput, { ...commonProps, value: value.start, onChange: fromValue => onChange({ start: fromValue, end: value.end ?? '' }), label: fromLabel, "aria-label": `${t('range_from_numeric') + (label ? ` - ${label}` : '')}`, additionalInfo: fromAdditionalInfo, autoFocus: autoFocus }), _jsx(NumberInput, { ...commonProps, value: value.end, onChange: toValue => onChange({ start: value.start ?? '', end: toValue }), label: toLabel, "aria-label": `${t('range_to_numeric') + (label ? ` - ${label}` : '')}`, additionalInfo: toAdditionalInfo })] }) }));
62
+ return (_jsx(FormField, { as: 'fieldset', ...restProps, ref: containerRef, container: { wrap: 'nowrap' }, labelHidden: labelHidden, labelAs: 'legend', label: label, disabled: disabled, required: required, readOnly: readOnly, status: status, children: _jsxs(Flex, { container: true, as: StyledRangeInputContainer, children: [_jsx(NumberInput, { ...commonProps, value: state.start, onChange: fromValue => {
63
+ onChange({ start: fromValue, end: value.end ?? '' });
64
+ dispatch({
65
+ type: 'start',
66
+ value: fromValue ?? ''
67
+ });
68
+ }, onBlur: changedValue => {
69
+ dispatch({
70
+ type: 'start',
71
+ value: changedValue ?? ''
72
+ });
73
+ startValueRef.current = changedValue ?? '';
74
+ onChange({
75
+ start: changedValue ?? '',
76
+ end: state.end
77
+ });
78
+ }, label: fromLabel, "aria-label": `${t('range_from_numeric') + (label ? ` - ${label}` : '')}`, additionalInfo: fromAdditionalInfo, autoFocus: autoFocus, ref: startValueInputRef }), _jsx(NumberInput, { ...commonProps, value: state.end, onChange: toValue => {
79
+ onChange({ start: value.start ?? '', end: toValue });
80
+ dispatch({
81
+ type: 'end',
82
+ value: toValue ?? ''
83
+ });
84
+ }, onBlur: changedValue => {
85
+ dispatch({
86
+ type: 'end',
87
+ value: changedValue ?? ''
88
+ });
89
+ endValueRef.current = changedValue ?? '';
90
+ onChange({
91
+ start: state.start,
92
+ end: changedValue ?? ''
93
+ });
94
+ }, label: toLabel, "aria-label": `${t('range_to_numeric') + (label ? ` - ${label}` : '')}`, additionalInfo: toAdditionalInfo, ref: endValueInputRef })] }) }));
28
95
  });
29
96
  export default NumberRangeInput;
30
97
  //# sourceMappingURL=NumberRangeInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberRangeInput.js","sourceRoot":"","sources":["../../../src/components/Number/NumberRangeInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA0B,WAAW,EAAE,MAAM,OAAO,CAAC;AAGxE,OAAO,EAAE,kB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EF,eAAe,gBAAgB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, useCallback } from 'react';\n\nimport type { ForwardProps } from '../../types';\nimport { useConsolidatedRef, useI18n, useFocusWithin } from '../../hooks';\nimport { StyledRangeInputContainer } from '../Input/Input.styles';\nimport FormField from '../FormField';\nimport Flex from '../Flex';\n\nimport NumberInput from './NumberInput';\nimport type { NumberRangeInputProps } from './NumberInput.types';\n\nconst NumberRangeInput: FunctionComponent<NumberRangeInputProps & ForwardProps> = forwardRef(\n (\n {\n value = {},\n onChange,\n onBlur,\n onFocus,\n label,\n fromLabel,\n toLabel,\n labelHidden,\n placeholder,\n disabled,\n readOnly,\n required,\n unit,\n showDecimal,\n numberOfDecimals,\n showGroupSeparators,\n min,\n max,\n step,\n variant,\n fromAdditionalInfo,\n toAdditionalInfo,\n autoFocus,\n ...restProps\n }: NumberRangeInputProps,\n ref: Ref<HTMLDivElement>\n ) => {\n const t = useI18n();\n\n const onFocusChange = useCallback(\n (focused: boolean) => {\n (focused ? onFocus : onBlur)?.({ start: value.start ?? '', end: value.end ?? '' });\n },\n [onBlur, value.start, value.end]\n );\n\n const containerRef = useConsolidatedRef(ref);\n useFocusWithin([containerRef], onFocusChange);\n\n const commonProps = {\n placeholder,\n readOnly,\n required,\n unit,\n showDecimal,\n numberOfDecimals,\n showGroupSeparators,\n min,\n max,\n variant\n };\n\n return (\n <FormField\n as='fieldset'\n {...restProps}\n ref={containerRef}\n container={{ wrap: 'nowrap' }}\n labelHidden={labelHidden}\n labelAs='legend'\n label={label}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n >\n <Flex container as={StyledRangeInputContainer}>\n <NumberInput\n {...commonProps}\n value={value.start}\n onChange={fromValue => onChange({ start: fromValue, end: value.end ?? '' })}\n label={fromLabel}\n aria-label={`${t('range_from_numeric') + (label ? ` - ${label}` : '')}`}\n additionalInfo={fromAdditionalInfo}\n autoFocus={autoFocus}\n />\n <NumberInput\n {...commonProps}\n value={value.end}\n onChange={toValue => onChange({ start: value.start ?? '', end: toValue })}\n label={toLabel}\n aria-label={`${t('range_to_numeric') + (label ? ` - ${label}` : '')}`}\n additionalInfo={toAdditionalInfo}\n />\n </Flex>\n </FormField>\n );\n }\n);\n\nexport default NumberRangeInput;\n"]}
1
+ {"version":3,"file":"NumberRangeInput.js","sourceRoot":"","sources":["../../../src/components/Number/NumberRangeInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,MAAM,EACP,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,WAAW,MAAM,eAAe,CAAC;AAMxC,MAAM,OAAO,GAAG,CAAC,SAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,EAAmB,EAAS,EAAE;IAC5E,QAAQ,IAAI,EAAE;QACZ,KAAK,OAAO,CAAC,CAAC;YACZ,OAAO,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;SACvC;QACD,KAAK,KAAK,CAAC,CAAC;YACV,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;SACrC;QACD;YACE,OAAO,SAAS,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAA4D,UAAU,CAC1F,CACE,EACE,KAAK,GAAG,EAAE,EACV,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,EACL,SAAS,EACT,OAAO,EACP,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,GAAG,EACH,GAAG,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AAK,CAAC,KAAK;4BAClB,GAAG,EAAE,YAAY,IAAI,EAAE;yBACxB,CAAC,CAAC;oBACL,CAAC,EACD,KAAK,EAAE,OAAO,gBACF,GAAG,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EACrE,cAAc,EAAE,gBAAgB,EAChC,GAAG,EAAE,gBAAgB,GACrB,IACG,GACG,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n Ref,\n useCallback,\n useImperativeHandle,\n useReducer,\n useRef\n} from 'react';\n\nimport type { ForwardProps } from '../../types';\nimport { useConsolidatedRef, useI18n, useFocusWithin } from '../../hooks';\nimport { StyledRangeInputContainer } from '../Input/Input.styles';\nimport FormField from '../FormField';\nimport Flex from '../Flex';\n\nimport NumberInput from './NumberInput';\nimport type { NumberRangeInputProps } from './NumberInput.types';\n\ntype DateRangeAction = { type: 'start' | 'end'; value: string };\ntype State = { start: string; end: string };\n\nconst reducer = (prevState: State, { type, value }: DateRangeAction): State => {\n switch (type) {\n case 'start': {\n return { ...prevState, start: value };\n }\n case 'end': {\n return { ...prevState, end: value };\n }\n default:\n return prevState;\n }\n};\n\nconst NumberRangeInput: FunctionComponent<NumberRangeInputProps & ForwardProps> = forwardRef(\n (\n {\n value = {},\n onChange,\n onBlur,\n onFocus,\n label,\n fromLabel,\n toLabel,\n labelHidden,\n placeholder,\n disabled,\n readOnly,\n required,\n status,\n unit,\n showDecimal,\n numberOfDecimals,\n showGroupSeparators,\n min,\n max,\n step,\n variant,\n fromAdditionalInfo,\n toAdditionalInfo,\n autoFocus,\n handle,\n ...restProps\n }: NumberRangeInputProps,\n ref: Ref<HTMLDivElement>\n ) => {\n const t = useI18n();\n\n const startValueInputRef = useRef<HTMLInputElement>(null);\n const endValueInputRef = useRef<HTMLInputElement>(null);\n\n const [state, dispatch] = useReducer(reducer, {\n start: value.start ?? '',\n end: value.end ?? ''\n });\n\n // Need to keep the value in ref also, to be able to call onBlur with newest value\n const startValueRef = useRef(state.start);\n const endValueRef = useRef(state.end);\n\n const onFocusChange = useCallback(\n (focused: boolean) => {\n (focused ? onFocus : onBlur)?.({ start: startValueRef.current, end: endValueRef.current });\n },\n [onBlur, value.start, value.end]\n );\n\n const containerRef = useConsolidatedRef(ref);\n useFocusWithin([containerRef], onFocusChange);\n\n useImperativeHandle(\n handle,\n () => ({\n clear: () => {\n if (startValueInputRef.current) startValueInputRef.current.value = '';\n if (endValueInputRef.current) endValueInputRef.current.value = '';\n startValueRef.current = '';\n endValueRef.current = '';\n dispatch({ type: 'start', value: '' });\n dispatch({ type: 'end', value: '' });\n onChange({ start: '', end: '' });\n }\n }),\n [onChange]\n );\n\n const commonProps = {\n status,\n placeholder,\n readOnly,\n required,\n unit,\n showDecimal,\n numberOfDecimals,\n showGroupSeparators,\n min,\n max,\n variant\n };\n\n return (\n <FormField\n as='fieldset'\n {...restProps}\n ref={containerRef}\n container={{ wrap: 'nowrap' }}\n labelHidden={labelHidden}\n labelAs='legend'\n label={label}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n status={status}\n >\n <Flex container as={StyledRangeInputContainer}>\n <NumberInput\n {...commonProps}\n value={state.start}\n onChange={fromValue => {\n onChange({ start: fromValue, end: value.end ?? '' });\n dispatch({\n type: 'start',\n value: fromValue ?? ''\n });\n }}\n onBlur={changedValue => {\n dispatch({\n type: 'start',\n value: changedValue ?? ''\n });\n startValueRef.current = changedValue ?? '';\n onChange({\n start: changedValue ?? '',\n end: state.end\n });\n }}\n label={fromLabel}\n aria-label={`${t('range_from_numeric') + (label ? ` - ${label}` : '')}`}\n additionalInfo={fromAdditionalInfo}\n autoFocus={autoFocus}\n ref={startValueInputRef}\n />\n <NumberInput\n {...commonProps}\n value={state.end}\n onChange={toValue => {\n onChange({ start: value.start ?? '', end: toValue });\n dispatch({\n type: 'end',\n value: toValue ?? ''\n });\n }}\n onBlur={changedValue => {\n dispatch({\n type: 'end',\n value: changedValue ?? ''\n });\n endValueRef.current = changedValue ?? '';\n onChange({\n start: state.start,\n end: changedValue ?? ''\n });\n }}\n label={toLabel}\n aria-label={`${t('range_to_numeric') + (label ? ` - ${label}` : '')}`}\n additionalInfo={toAdditionalInfo}\n ref={endValueInputRef}\n />\n </Flex>\n </FormField>\n );\n }\n);\n\nexport default NumberRangeInput;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,GAAG,EAEH,YAAY,EAEZ,SAAS,EAIV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAa,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAStD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAMtD,oBAAY,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAC9C,MAAM,WAAW,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS;IAChF,2IAA2I;IAC3I,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACtD;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;IAChD;;;OAGG;IACH,QA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AAI,CAAC;IACxC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACtD;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;IAC9C;;;OAGG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;IAChD;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yGAAyG;IACzG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,uCAAuC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAQD,QAAA,MAAM,OAAO,EAAE,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EAC/C,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,KAC1C,YAAY,GAAG,IAwInB,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -5,8 +5,7 @@ import { usePopper } from 'react-popper';
5
5
  import { useAfterInitialEffect, useConfiguration, useConsolidatedRef, useElement, useUID } from '../../hooks';
6
6
  import { windowIsAvailable } from '../../utils';
7
7
  import { PopoverManagerContext } from './PopoverContext';
8
- import { StyledPopover, StyledPopoverContent, StyledPopoverArrow } from './Popover.styles';
9
- import { applyMaxSize, maxSize } from './modifiers';
8
+ import { StyledPopover, StyledPopoverArrow } from './Popover.styles';
10
9
  const delays = {
11
10
  none: 0,
12
11
  short: 500,
@@ -44,8 +43,6 @@ const Popover = forwardRef(({ show = true, portal = false, target, placement, st
44
43
  tether: !modifiers.find(m => m.name === 'sameWidth')
45
44
  }
46
45
  },
47
- maxSize,
48
- applyMaxSize,
49
46
  ...modifiers
50
47
  ], [modifiers, arrow, hideOnTargetHidden]);
51
48
  const offset = useMemo(() => {
@@ -102,7 +99,7 @@ const Popover = forwardRef(({ show = true, portal = false, target, placement, st
102
99
  setShowPopover(false);
103
100
  }
104
101
  }, [groupId ? popovers[groupId] : undefined]);
105
- const content = (_jsxs(StyledPopover, { ...restProps, offset: offset, ref: popperRef, style: { ...style, ...styles.popper }, ...attributes.popper, children: [arrow && _jsx(StyledPopoverArrow, { ref: arrowRef, style: { ...styles.arrow } }), _jsx(StyledPopoverContent, { children: children })] }));
102
+ const content = (_jsxs(StyledPopover, { ...restProps, offset: offset, ref: popperRef, style: { ...style, ...styles.popper }, ...attributes.popper, children: [arrow && _jsx(StyledPopoverArrow, { ref: arrowRef, style: { ...styles.arrow } }), children] }));
106
103
  if (!target || !showPopover || (groupId && !checkActive(uid, groupId)))
107
104
  return null;
108
105
  return portal && portalTarget ? createPortal(content, portalTarget) : content;
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAKtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,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CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChF,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport {\n useAfterInitialEffect,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useUID\n} from '../../hooks';\nimport { windowIsAvailable } from '../../utils';\nimport { ConfigurationProps } from '../Configuration';\n\nimport { PopoverManagerContext } from './PopoverContext';\nimport { StyledPopover, StyledPopoverContent, StyledPopoverArrow } from './Popover.styles';\nimport { applyMaxSize, maxSize } from './modifiers';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean | ConfigurationProps['portalTarget'];\n /**\n * Delay on showing the Popover.\n * @default \"none\"\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default \"none\"\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default \"absolute\"\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** Callback that runs when the popover is hidden */\n onHide?: () => void;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(\n (\n {\n show = true,\n portal = false,\n target,\n placement,\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n onHide,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n ) => {\n const { portalTarget: configurationPortal } = useConfiguration();\n const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);\n const [, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;\n\n const memoedModifiers = useMemo(\n () => [\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration: false\n }\n },\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n {\n name: 'preventOverflow',\n options: {\n tether: !modifiers.find(m => m.name === 'sameWidth')\n }\n },\n maxSize,\n applyMaxSize,\n ...modifiers\n ],\n [modifiers, arrow, hideOnTargetHidden]\n );\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperRef.current, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n forceUpdateRef.current?.();\n });\n\n if (popperRef.current) observer.observe(popperRef.current);\n if (target instanceof Element) observer.observe(target);\n\n return () => {\n observer.disconnect();\n };\n }, [forceUpdate, popperRef.current, target]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n useAfterInitialEffect(() => {\n if (!showPopover) {\n onHide?.();\n }\n }, [showPopover]);\n\n useEffect(() => {\n if (groupId && popovers[groupId] && popovers[groupId] !== uid) {\n setShowPopover(false);\n }\n }, [groupId ? popovers[groupId] : undefined]);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n <StyledPopoverContent>{children}</StyledPopoverContent>\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Popover;\n"]}
1
+ {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAKtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AA4DrE,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,OAAO,GAEc,UAAU,CACnC,CACE,EACE,IAAI,GAAG,IAAI,EACX,MAAM,GAAG,KAAK,EACd,MAAM,EACN,SAAS,EACT,QAAQ,GAAG,OAAO,EAClB,KAAK,EACL,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,KAAK,EACb,OAAO,EACP,SAAS,GAAG,MAAM,EAClB,SAAS,GAAG,MAAM,EAClB,kBAAkB,GAAG,KAAK,EAC1B,QAAQ,EACR,MAAM,EACN,GAAG,SAAS,EAC8C,EAC5D,GAAwB,EACxB,EAAE;IACF,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACjE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;IAC/E,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,UAAU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AAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAI,EAC1E,QAAQ,IACK,CACjB,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpF,OAAO,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChF,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport {\n useAfterInitialEffect,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useUID\n} from '../../hooks';\nimport { windowIsAvailable } from '../../utils';\nimport { ConfigurationProps } from '../Configuration';\n\nimport { PopoverManagerContext } from './PopoverContext';\nimport { StyledPopover, StyledPopoverArrow } from './Popover.styles';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean | ConfigurationProps['portalTarget'];\n /**\n * Delay on showing the Popover.\n * @default \"none\"\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default \"none\"\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default \"absolute\"\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** Callback that runs when the popover is hidden */\n onHide?: () => void;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(\n (\n {\n show = true,\n portal = false,\n target,\n placement,\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n onHide,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n ) => {\n const { portalTarget: configurationPortal } = useConfiguration();\n const { checkActive, setActive, popovers } = useContext(PopoverManagerContext);\n const [, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const portalTarget = typeof portal === 'boolean' ? configurationPortal : portal;\n\n const memoedModifiers = useMemo(\n () => [\n {\n name: 'computeStyles',\n options: {\n gpuAcceleration: false\n }\n },\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n {\n name: 'preventOverflow',\n options: {\n tether: !modifiers.find(m => m.name === 'sameWidth')\n }\n },\n ...modifiers\n ],\n [modifiers, arrow, hideOnTargetHidden]\n );\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperRef.current, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n forceUpdateRef.current?.();\n });\n\n if (popperRef.current) observer.observe(popperRef.current);\n if (target instanceof Element) observer.observe(target);\n\n return () => {\n observer.disconnect();\n };\n }, [forceUpdate, popperRef.current, target]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n useAfterInitialEffect(() => {\n if (!showPopover) {\n onHide?.();\n }\n }, [showPopover]);\n\n useEffect(() => {\n if (groupId && popovers[groupId] && popovers[groupId] !== uid) {\n setShowPopover(false);\n }\n }, [groupId ? popovers[groupId] : undefined]);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Popover;\n"]}
@@ -1,5 +1,4 @@
1
1
  export declare const StyledPopoverArrow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
- export declare const StyledPopoverContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
2
  export declare const StyledPopover: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
4
3
  offset?: number | undefined;
5
4
  }, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,yGAW9B,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAKhC,CAAC;AAEF,eAAO,MAAM,aAAa;;SA4GzB,CAAC"}
1
+ {"version":3,"file":"Popover.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,yGAW9B,CAAC;AAIF,eAAO,MAAM,aAAa;;SA4GzB,CAAC"}
@@ -13,12 +13,6 @@ export const StyledPopoverArrow = styled.div `
13
13
  }
14
14
  `;
15
15
  StyledPopoverArrow.defaultProps = defaultThemeProp;
16
- export const StyledPopoverContent = styled.div `
17
- max-width: inherit;
18
- max-height: inherit;
19
- border-radius: inherit;
20
- overflow: auto;
21
- `;
22
16
  export const StyledPopover = styled.div(({ theme: { base: { 'border-radius': borderRadius, 'z-index': { popover: zIndex }, shadow: { low } }, components: { card: { background }, 'form-control': { 'border-radius': formControlBorderRadius } } }, offset }) => {
23
17
  return css `
24
18
  /*
@@ -1 +1 @@
1
- {"version":3,"file":"Popover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ent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\n\nexport const StyledPopoverArrow = styled.div`\n background-color: inherit;\n\n ::before {\n content: '';\n display: block;\n position: absolute;\n inset: -0.25rem;\n background-color: inherit;\n transform: rotate(45deg);\n }\n`;\n\nStyledPopoverArrow.defaultProps = defaultThemeProp;\n\nexport const StyledPopoverContent = styled.div`\n max-width: inherit;\n max-height: inherit;\n border-radius: inherit;\n overflow: auto;\n`;\n\nexport const StyledPopover = styled.div<{ offset?: number }>(\n ({\n theme: {\n base: {\n 'border-radius': borderRadius,\n 'z-index': { popover: zIndex },\n shadow: { low }\n },\n components: {\n card: { background },\n 'form-control': { 'border-radius': formControlBorderRadius }\n }\n },\n offset\n }) => {\n return css`\n /*\n Margin should never be used with Popper.\n https://popper.js.org/docs/v2/migration-guide/#4-remove-all-css-margins\n */\n margin: 0 !important;\n z-index: ${zIndex};\n background-color: ${background};\n border-radius: calc(${formControlBorderRadius} * ${borderRadius});\n box-shadow: ${low};\n\n &[data-popper-reference-hidden='true'] {\n visibility: hidden;\n pointer-events: none;\n }\n\n &[data-popper-placement^='top'] {\n > ${StyledPopoverArrow} {\n top: calc(100%);\n\n ::before {\n border-bottom-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n bottom: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='bottom'] {\n > ${StyledPopoverArrow} {\n bottom: calc(100%);\n\n ::before {\n border-top-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n top: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='right'] {\n > ${StyledPopoverArrow} {\n right: calc(100%);\n\n ::before {\n border-bottom-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n left: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n\n &[data-popper-placement^='left'] {\n > ${StyledPopoverArrow} {\n left: calc(100%);\n\n ::before {\n border-top-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n right: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n `;\n }\n);\n\nStyledPopover.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"Popover.styles.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;CAW3C,CAAC;AAEF,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CACrC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,eAAe,EAAE,YAAY,EAC7B,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC9B,MAAM,EAAE,EAAE,GAAG,EAAE,EAChB,EACD,UAAU,EAAE,EACV,IAAI,EAAE,EAAE,UAAU,EAAE,EACpB,cAAc,EAAE,EAAE,eAAe,EAAE,uBAAuB,EAAE,EAC7D,EACF,EACD,MAAM,EACP,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;;;;;iBAMG,MAAM;0BACG,UAAU;4BACR,uBAAuB,MAAM,YAAY;oBACjD,GAAG;;;;;;;;YAQX,kBAAkB;;;;+CAIiB,YAAY;;;;;;;oBAOvC,MAAM;qBACL,MAAM;;;;;;;YAOf,kBAAkB;;;;2CAIa,YAAY;;;;;;;oBAOnC,MAAM;kBACR,MAAM;;;;;;;YAOZ,kBAAkB;;;;8CAIgB,YAAY;;;;;;;mBAOvC,MAAM;mBACN,MAAM;;;;;;;YAOb,kBAAkB;;;;4CAIc,YAAY;;;;;;;mBAOrC,MAAM;oBACL,MAAM;;;;;KAKrB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\n\nexport const StyledPopoverArrow = styled.div`\n background-color: inherit;\n\n ::before {\n content: '';\n display: block;\n position: absolute;\n inset: -0.25rem;\n background-color: inherit;\n transform: rotate(45deg);\n }\n`;\n\nStyledPopoverArrow.defaultProps = defaultThemeProp;\n\nexport const StyledPopover = styled.div<{ offset?: number }>(\n ({\n theme: {\n base: {\n 'border-radius': borderRadius,\n 'z-index': { popover: zIndex },\n shadow: { low }\n },\n components: {\n card: { background },\n 'form-control': { 'border-radius': formControlBorderRadius }\n }\n },\n offset\n }) => {\n return css`\n /*\n Margin should never be used with Popper.\n https://popper.js.org/docs/v2/migration-guide/#4-remove-all-css-margins\n */\n margin: 0 !important;\n z-index: ${zIndex};\n background-color: ${background};\n border-radius: calc(${formControlBorderRadius} * ${borderRadius});\n box-shadow: ${low};\n\n &[data-popper-reference-hidden='true'] {\n visibility: hidden;\n pointer-events: none;\n }\n\n &[data-popper-placement^='top'] {\n > ${StyledPopoverArrow} {\n top: calc(100%);\n\n ::before {\n border-bottom-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n bottom: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='bottom'] {\n > ${StyledPopoverArrow} {\n bottom: calc(100%);\n\n ::before {\n border-top-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n top: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='right'] {\n > ${StyledPopoverArrow} {\n right: calc(100%);\n\n ::before {\n border-bottom-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n left: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n\n &[data-popper-placement^='left'] {\n > ${StyledPopoverArrow} {\n left: calc(100%);\n\n ::before {\n border-top-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n right: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n `;\n }\n);\n\nStyledPopover.defaultProps = defaultThemeProp;\n"]}
@@ -1,5 +1,3 @@
1
1
  import { Modifier } from '@popperjs/core';
2
2
  export declare const sameWidth: Modifier<'sameWidth', object>;
3
- export declare const maxSize: Modifier<'maxSize', object>;
4
- export declare const applyMaxSize: Modifier<'applyMaxSize', object>;
5
3
  //# sourceMappingURL=modifiers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1D,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAQlD,CAAC;AAGH,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAmB9C,CAAC;AAGH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CASxD,CAAC"}
1
+ {"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAQlD,CAAC"}
@@ -1,5 +1,4 @@
1
- import { detectOverflow } from '@popperjs/core';
2
- // taken from https://codesandbox.io/s/bitter-sky-pe3z9?file=/src/index.js
1
+ // eslint-disable-next-line import/prefer-default-export
3
2
  export const sameWidth = Object.freeze({
4
3
  name: 'sameWidth',
5
4
  enabled: true,
@@ -9,34 +8,4 @@ export const sameWidth = Object.freeze({
9
8
  },
10
9
  requires: ['computeStyles']
11
10
  });
12
- // taken from https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js
13
- export const maxSize = Object.freeze({
14
- name: 'maxSize',
15
- enabled: true,
16
- phase: 'main',
17
- requiresIfExists: ['offset', 'preventOverflow', 'flip'],
18
- fn({ state, name, options }) {
19
- const overflow = detectOverflow(state, options);
20
- const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };
21
- const { width, height } = state.rects.popper;
22
- const [basePlacement] = state.placement.split('-');
23
- const widthProp = basePlacement === 'left' ? 'left' : 'right';
24
- const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
25
- state.modifiersData[name] = {
26
- width: width - overflow[widthProp] - x,
27
- height: height - overflow[heightProp] - y
28
- };
29
- }
30
- });
31
- // taken from https://codesandbox.io/s/great-tesla-3roz7?file=/src/index.js
32
- export const applyMaxSize = Object.freeze({
33
- name: 'applyMaxSize',
34
- enabled: true,
35
- phase: 'beforeWrite',
36
- requires: ['maxSize'],
37
- fn({ state }) {
38
- const { height } = state.modifiersData.maxSize;
39
- state.styles.popper.maxHeight = `${height}px`;
40
- }
41
- });
42
11
  //# sourceMappingURL=modifiers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,gBAAgB,CAAC;AAE1D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,SAAS,GAAkC,MAAM,CAAC,MAAM,CAAC;IACpE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,aAAa;IACpB,EAAE,CAAC,EAAE,KAAK,EAAE;QACV,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,KAAK,CAAC,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AAY,GAAqC,MAAM,CAAC,MAAM,CAAC;IAC1E,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,KAAK,EAAE;QACV,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;QAC/C,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,GAAG,MAAM,IAAI,CAAC;IAChD,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { detectOverflow, Modifier } from '@popperjs/core';\n\n// taken from https://codesandbox.io/s/bitter-sky-pe3z9?file=/src/index.js\nexport const sameWidth: Modifier<'sameWidth', object> = Object.freeze({\n name: 'sameWidth',\n enabled: true,\n phase: 'beforeWrite',\n fn({ state }) {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n requires: ['computeStyles']\n});\n\n// taken from https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js\nexport const maxSize: Modifier<'maxSize', object> = Object.freeze({\n name: 'maxSize',\n enabled: true,\n phase: 'main',\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n fn({ state, name, options }) {\n const overflow = detectOverflow(state, options);\n const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };\n const { width, height } = state.rects.popper;\n const [basePlacement] = state.placement.split('-');\n\n const widthProp = basePlacement === 'left' ? 'left' : 'right';\n const heightProp = basePlacement === 'top' ? 'top' : 'bottom';\n\n state.modifiersData[name] = {\n width: width - overflow[widthProp] - x,\n height: height - overflow[heightProp] - y\n };\n }\n});\n\n// taken from https://codesandbox.io/s/great-tesla-3roz7?file=/src/index.js\nexport const applyMaxSize: Modifier<'applyMaxSize', object> = Object.freeze({\n name: 'applyMaxSize',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['maxSize'],\n fn({ state }) {\n const { height } = state.modifiersData.maxSize;\n state.styles.popper.maxHeight = `${height}px`;\n }\n});\n"]}
1
+ {"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../../src/components/Popover/modifiers.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAkC,MAAM,CAAC,MAAM,CAAC;IACpE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,aAAa;IACpB,EAAE,CAAC,EAAE,KAAK,EAAE;QACV,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACjE,CAAC;IACD,QAAQ,EAAE,CAAC,eAAe,CAAC;CAC5B,CAAC,CAAC","sourcesContent":["import { Modifier } from '@popperjs/core';\n\n// eslint-disable-next-line import/prefer-default-export\nexport const sameWidth: Modifier<'sameWidth', object> = Object.freeze({\n name: 'sameWidth',\n enabled: true,\n phase: 'beforeWrite',\n fn({ state }) {\n state.styles.popper.width = `${state.rects.reference.width}px`;\n },\n requires: ['computeStyles']\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,EAAE,EAKH,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CA4H9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,EAAE,EAKH,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CAyI9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -3,17 +3,18 @@ import { forwardRef, useState, useEffect, useImperativeHandle, useRef } from 're
3
3
  import { createPortal } from 'react-dom';
4
4
  import Backdrop from '../Backdrop';
5
5
  import Text from '../Text';
6
- import { useConfiguration, useConsolidatedRef, useI18n } from '../../hooks';
6
+ import { useConfiguration, useConsolidatedRef, useI18n, useLiveLog } from '../../hooks';
7
7
  import Flex from '../Flex';
8
8
  import Bar from './Bar';
9
9
  import Ellipsis from './Ellipsis';
10
10
  import Ring from './Ring';
11
11
  import { StyledMessage, StyledProgress } from './Progress.styles';
12
- const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible = true, onTransitionEndIn, onTransitionEndOut, value, message, handle, ...restProps }, ref) => {
12
+ const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible = true, onTransitionEndIn, onTransitionEndOut, value, message, handle, liveConfig, ...restProps }, ref) => {
13
13
  const t = useI18n();
14
14
  const [isVisible, setIsVisible] = useState(visible);
15
15
  const [isNull, setIsNull] = useState(!visible);
16
16
  const { portalTarget } = useConfiguration();
17
+ const { announcePolite } = useLiveLog();
17
18
  const progressEl = useConsolidatedRef(ref);
18
19
  const showTime = useRef();
19
20
  const showTimeout = useRef();
@@ -23,6 +24,8 @@ const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible =
23
24
  Comp = Bar;
24
25
  else if (variant === 'ellipsis')
25
26
  Comp = Ellipsis;
27
+ const valString = typeof value === 'number' ? `${value}%` : undefined;
28
+ const label = message && valString ? `${message} - ${valString}` : message || valString;
26
29
  const onBackdropTransitionEnd = () => {
27
30
  setIsNull(true);
28
31
  onTransitionEndOut?.();
@@ -32,6 +35,16 @@ const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible =
32
35
  progressEl.current?.focus();
33
36
  }
34
37
  }));
38
+ // Live announcement
39
+ useEffect(() => {
40
+ if (liveConfig?.contextualLabel && isVisible) {
41
+ announcePolite({
42
+ message: `${liveConfig.contextualLabel}, ${label ?? t('loading')}`,
43
+ type: 'status'
44
+ });
45
+ }
46
+ }, [isVisible, label, liveConfig?.contextualLabel]);
47
+ // Manage show / hide
35
48
  useEffect(() => {
36
49
  if (visible) {
37
50
  clearTimeout(hideTimeout.current);
@@ -66,8 +79,6 @@ const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible =
66
79
  }, []);
67
80
  if (isNull)
68
81
  return null;
69
- const valString = typeof value === 'number' ? `${value}%` : undefined;
70
- const label = message && valString ? `${message} - ${valString}` : message || valString;
71
82
  let indicator = (_jsx(Comp, { "aria-label": typeof value !== 'number' ? label : t('loading'), ...restProps, placement: placement, value: value, "aria-valuetext": typeof value === 'number' ? label : undefined, ref: progressEl, tabIndex: -1 }));
72
83
  if (placement !== 'inline') {
73
84
  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 }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,MAAM,EACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,IAAI,MA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AAiB,EACtC,oBAAoB,EAAE,uBAAuB,YAE5C,SAAS,GACD,CACZ,CAAC;IAEJ,OAAO,SAAS,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChG,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n PropsWithoutRef,\n FC,\n useState,\n useEffect,\n useImperativeHandle,\n useRef\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { ForwardProps } from '../../types';\nimport Backdrop from '../Backdrop';\nimport Text from '../Text';\nimport { useConfiguration, useConsolidatedRef, useI18n } from '../../hooks';\nimport Flex from '../Flex';\n\nimport { ProgressProps } from './Progress.types';\nimport Bar from './Bar';\nimport Ellipsis from './Ellipsis';\nimport Ring from './Ring';\nimport { StyledMessage, StyledProgress } from './Progress.styles';\n\nconst Progress: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'ring',\n placement = 'global',\n visible = true,\n onTransitionEndIn,\n onTransitionEndOut,\n value,\n message,\n handle,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n const t = useI18n();\n const [isVisible, setIsVisible] = useState(visible);\n const [isNull, setIsNull] = useState(!visible);\n const { portalTarget } = useConfiguration();\n const progressEl = useConsolidatedRef<HTMLDivElement>(ref);\n const showTime = useRef<number>();\n const showTimeout = useRef<number>();\n const hideTimeout = useRef<number>();\n\n let Comp = Ring;\n if (variant === 'bar') Comp = Bar;\n else if (variant === 'ellipsis') Comp = Ellipsis;\n\n const onBackdropTransitionEnd = () => {\n setIsNull(true);\n onTransitionEndOut?.();\n };\n\n useImperativeHandle(handle, () => ({\n focus: () => {\n progressEl.current?.focus();\n }\n }));\n\n useEffect(() => {\n if (visible) {\n clearTimeout(hideTimeout.current);\n showTime.current = Date.now();\n showTimeout.current = window.setTimeout(() => {\n setIsVisible(true);\n setIsNull(false);\n }, 100);\n } else {\n clearTimeout(showTimeout.current);\n\n if (typeof showTime.current === 'number') {\n const minimumDuration = 1000;\n const timeElapsed = Date.now() - showTime.current;\n\n if (timeElapsed > minimumDuration) setIsVisible(false);\n else {\n hideTimeout.current = window.setTimeout(() => {\n setIsVisible(false);\n }, minimumDuration - timeElapsed);\n }\n } else setIsVisible(false);\n }\n }, [visible]);\n\n useEffect(() => {\n return () => {\n clearTimeout(showTimeout.current);\n clearTimeout(hideTimeout.current);\n };\n }, []);\n\n if (isNull) return null;\n\n const valString = typeof value === 'number' ? `${value}%` : undefined;\n const label = message && valString ? `${message} - ${valString}` : message || valString;\n\n let indicator = (\n <Comp\n aria-label={typeof value !== 'number' ? label : t('loading')}\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='true'>\n {message}\n </Text>\n )}\n </Flex>\n );\n }\n\n const content =\n placement === 'block' || placement === 'inline' ? (\n indicator\n ) : (\n <Backdrop\n open={isVisible}\n container={{ direction: 'column' }}\n position={placement === 'global' ? 'fixed' : 'absolute'}\n variant='light'\n alpha={0.5}\n onAfterTransitionIn={onTransitionEndIn}\n onAfterTransitionOut={onBackdropTransitionEnd}\n >\n {indicator}\n </Backdrop>\n );\n\n return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Progress;\n"]}
1
+ {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,MAAM,EACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,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;IAEF,IAAI,SAAS,KAAK,QAAQ,EAAE;QAC1B,SAAS,GAAG,CACV,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAClE,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,SAAS,aAEnB,SAAS,EACT,OAAO,IAAI,CACV,KAAC,IAAI,IAAC,EAAE,EAAE,aAAa,EAAE,OAAO,EAAC,WAAW,iBAAa,MAAM,YAC5D,OAAO,GACH,CACR,IACI,CACR,CAAC;KACH;IAED,MAAM,OAAO,GACX,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAChD,SAAS,CACV,CAAC,CAAC,CAAC,CACF,KAAC,QAAQ,IACP,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,QAAQ,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EACvD,OAAO,EAAC,OAAO,EACf,KAAK,EAAE,GAAG,EACV,mBAAmB,EAAE,iBAAiB,EACtC,oBAAoB,EAAE,uBAAuB,YAE5C,SAAS,GACD,CACZ,CAAC;IAEJ,OAAO,SAAS,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChG,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n PropsWithoutRef,\n FC,\n useState,\n useEffect,\n useImperativeHandle,\n useRef\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { ForwardProps } from '../../types';\nimport Backdrop from '../Backdrop';\nimport Text from '../Text';\nimport { useConfiguration, useConsolidatedRef, useI18n, useLiveLog } from '../../hooks';\nimport Flex from '../Flex';\n\nimport { ProgressProps } from './Progress.types';\nimport Bar from './Bar';\nimport Ellipsis from './Ellipsis';\nimport Ring from './Ring';\nimport { StyledMessage, StyledProgress } from './Progress.styles';\n\nconst Progress: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'ring',\n placement = 'global',\n visible = true,\n onTransitionEndIn,\n onTransitionEndOut,\n value,\n message,\n handle,\n liveConfig,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n const t = useI18n();\n const [isVisible, setIsVisible] = useState(visible);\n const [isNull, setIsNull] = useState(!visible);\n const { portalTarget } = useConfiguration();\n const { announcePolite } = useLiveLog();\n const progressEl = useConsolidatedRef<HTMLDivElement>(ref);\n const showTime = useRef<number>();\n const showTimeout = useRef<number>();\n const hideTimeout = useRef<number>();\n\n let Comp = Ring;\n if (variant === 'bar') Comp = Bar;\n else if (variant === 'ellipsis') Comp = Ellipsis;\n\n const valString = typeof value === 'number' ? `${value}%` : undefined;\n const label = message && valString ? `${message} - ${valString}` : message || valString;\n\n const onBackdropTransitionEnd = () => {\n setIsNull(true);\n onTransitionEndOut?.();\n };\n\n useImperativeHandle(handle, () => ({\n focus: () => {\n progressEl.current?.focus();\n }\n }));\n\n // Live announcement\n useEffect(() => {\n if (liveConfig?.contextualLabel && isVisible) {\n announcePolite({\n message: `${liveConfig.contextualLabel}, ${label ?? t('loading')}`,\n type: 'status'\n });\n }\n }, [isVisible, label, liveConfig?.contextualLabel]);\n\n // Manage show / hide\n useEffect(() => {\n if (visible) {\n clearTimeout(hideTimeout.current);\n showTime.current = Date.now();\n showTimeout.current = window.setTimeout(() => {\n setIsVisible(true);\n setIsNull(false);\n }, 100);\n } else {\n clearTimeout(showTimeout.current);\n\n if (typeof showTime.current === 'number') {\n const minimumDuration = 1000;\n const timeElapsed = Date.now() - showTime.current;\n\n if (timeElapsed > minimumDuration) setIsVisible(false);\n else {\n hideTimeout.current = window.setTimeout(() => {\n setIsVisible(false);\n }, minimumDuration - timeElapsed);\n }\n } else setIsVisible(false);\n }\n }, [visible]);\n\n useEffect(() => {\n return () => {\n clearTimeout(showTimeout.current);\n clearTimeout(hideTimeout.current);\n };\n }, []);\n\n if (isNull) return null;\n\n let indicator = (\n <Comp\n aria-label={typeof value !== 'number' ? label : t('loading')}\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='true'>\n {message}\n </Text>\n )}\n </Flex>\n );\n }\n\n const content =\n placement === 'block' || placement === 'inline' ? (\n indicator\n ) : (\n <Backdrop\n open={isVisible}\n container={{ direction: 'column' }}\n position={placement === 'global' ? 'fixed' : 'absolute'}\n variant='light'\n alpha={0.5}\n onAfterTransitionIn={onTransitionEndIn}\n onAfterTransitionOut={onBackdropTransitionEnd}\n >\n {indicator}\n </Backdrop>\n );\n\n return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Progress;\n"]}
@@ -44,5 +44,10 @@ export interface ProgressProps extends BaseProps, NoChildrenProp {
44
44
  ref?: Ref<HTMLDivElement>;
45
45
  /** Imperative handle */
46
46
  handle?: Ref<ProgressHandleValue>;
47
+ /** Triggers live announcement on show and value or message change. */
48
+ liveConfig?: {
49
+ /** Distinguishes the source of the update on the page. */
50
+ contextualLabel: string;
51
+ };
47
52
  }
48
53
  //# sourceMappingURL=Progress.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.types.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,E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9D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACzD,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAC3D,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,wBAAwB;IACxB,MAAM,CAAC,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAClC,sEAAsE;IACtE,UAAU,CAAC,EAAE;QACX,0DAA0D;QAC1D,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.types.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport { BaseProps, NoChildrenProp } from '../../types';\nimport { BackdropProps } from '../Backdrop/Backdrop';\n\nexport interface ProgressHandleValue {\n focus: () => void;\n}\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 * @default true\n */\n visible?: boolean;\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 /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /** Imperative handle */\n handle?: Ref<ProgressHandleValue>;\n}\n"]}
1
+ {"version":3,"file":"Progress.types.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Ref } from 'react';\n\nimport { BaseProps, NoChildrenProp } from '../../types';\nimport { BackdropProps } from '../Backdrop/Backdrop';\n\nexport interface ProgressHandleValue {\n focus: () => void;\n}\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 * @default true\n */\n visible?: boolean;\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 /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /** Imperative handle */\n handle?: Ref<ProgressHandleValue>;\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"]}
@@ -0,0 +1,13 @@
1
+ import { FunctionComponent, Ref } from 'react';
2
+ import { BaseProps, ForwardProps } from '../../types';
3
+ export interface QRCodeProps extends BaseProps {
4
+ /** Text that need to be encoded into QR code. */
5
+ value: string;
6
+ /** The HTML alt attribute for the image. */
7
+ label?: string;
8
+ /** Ref for the wrapping element. */
9
+ ref?: Ref<HTMLImageElement>;
10
+ }
11
+ declare const QRCode: FunctionComponent<QRCodeProps & ForwardProps>;
12
+ export default QRCode;
13
+ //# sourceMappingURL=QRCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRCode.d.ts","sourceRoot":"","sources":["../../../src/components/QRCode/QRCode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAuB,MAAM,OAAO,CAAC;AAIjG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,GAAG,YAAY,CAiBzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useState } from 'react';
3
+ import * as QRCodeLib from 'qrcode';
4
+ import Image from '../Image';
5
+ const QRCode = forwardRef(({ value, label = value, ...restProps }, ref) => {
6
+ const [dataURL, setDataURL] = useState('');
7
+ useEffect(() => {
8
+ QRCodeLib.toDataURL(value)
9
+ .then(setDataURL)
10
+ .catch(() => {
11
+ setDataURL('');
12
+ });
13
+ }, [value]);
14
+ return dataURL ? _jsx(Image, { ...restProps, ref: ref, src: dataURL, alt: label }) : null;
15
+ });
16
+ export default QRCode;
17
+ //# sourceMappingURL=QRCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRCode.js","sourceRoot":"","sources":["../../../src/components/QRCode/QRCode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjG,OAAO,KAAK,SAAS,MAAM,QAAQ,CAAC;AAEpC,OAAO,KAAK,MAAM,UAAU,CAAC;AAY7B,MAAM,MAAM,GAAkD,UAAU,CACtE,CACE,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,SAAS,EAAgC,EACpE,GAAuB,EACvB,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;aACvB,IAAI,CAAC,UAAU,CAAC;aAChB,KAAK,CAAC,GAAG,EAAE;YACV,UAAU,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,OAAO,CAAC,CAAC,CAAC,KAAC,KAAK,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useEffect, useState } from 'react';\nimport * as QRCodeLib from 'qrcode';\n\nimport Image from '../Image';\nimport { BaseProps, ForwardProps } from '../../types';\n\nexport interface QRCodeProps extends BaseProps {\n /** Text that need to be encoded into QR code. */\n value: string;\n /** The HTML alt attribute for the image. */\n label?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLImageElement>;\n}\n\nconst QRCode: FunctionComponent<QRCodeProps & ForwardProps> = forwardRef(\n (\n { value, label = value, ...restProps }: PropsWithoutRef<QRCodeProps>,\n ref: QRCodeProps['ref']\n ) => {\n const [dataURL, setDataURL] = useState('');\n\n useEffect(() => {\n QRCodeLib.toDataURL(value)\n .then(setDataURL)\n .catch(() => {\n setDataURL('');\n });\n }, [value]);\n\n return dataURL ? <Image {...restProps} ref={ref} src={dataURL} alt={label} /> : null;\n }\n);\n\nexport default QRCode;\n"]}
@@ -0,0 +1,3 @@
1
+ export { default } from './QRCode';
2
+ export { QRCodeProps } from './QRCode';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/QRCode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './QRCode';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/QRCode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { default } from './QRCode';\nexport { QRCodeProps } from './QRCode';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SearchInput.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/SearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAWlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,U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