@pega/cosmos-react-core 6.1.2 → 6.2.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.
@@ -58,5 +58,5 @@ export type DateRangeCallbackParameter = {
58
58
  };
59
59
  export type AbsoluteVariant = 'date' | 'datetime' | 'time' | 'week' | 'month' | 'year' | 'monthyear' | 'quarteryear';
60
60
  export type DateTimeVariant = AbsoluteVariant | 'relative';
61
- export type DateTimeFormat = 'short' | 'long' | 'numeric';
61
+ export type DateTimeFormat = 'short' | 'medium' | 'long' | 'numeric';
62
62
  //# sourceMappingURL=DateTime.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.types.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,4HAA4H;IAC5H,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7B,4HAA4H;IAC5H,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5B,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,uCAAuC;IACvC,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,C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.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NoChildrenProp, TestIdProp } from '../../types';\nimport type { FormControlProps } from '../FormControl';\n\nexport interface DateTimeProperties extends TestIdProp {\n /** Date as ISO8601 string, timestamp or native Date object. Defines minimum available value that can be set by the user. */\n min?: string | number | Date;\n /** Date as ISO8601 string, timestamp or native Date object. Defines maximum available value that can be set by the user. */\n max?: string | number | Date;\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\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 /** Visually hides the label region. */\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 /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n}\n\nexport type DateTimeValueErrorState = 'incomplete' | 'invalid';\n\nexport type DateTimeCallbackParameter = {\n valueAsISOString: string | undefined;\n valueAsTimestamp: number | undefined;\n state?: DateTimeValueErrorState;\n};\n\nexport interface DateTimeCallbacks {\n /** Callback fired when input value changes. */\n onChange?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when the component gets focused. */\n onFocus?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n}\n\nexport default interface DateTimeProps\n extends DateTimeProperties,\n DateTimeCallbacks,\n NoChildrenProp {\n /**\n * Date as ISO8601 string, timestamp or native Date object.\n * Requires onChange prop to update value for controlled inputs.\n */\n value?: string | number | Date;\n}\n\nexport type DateRangeCallbackParameter = {\n start: DateTimeCallbackParameter;\n end: DateTimeCallbackParameter;\n};\n\nexport type AbsoluteVariant =\n | 'date'\n | 'datetime'\n | 'time'\n | 'week'\n | 'month'\n | 'year'\n | 'monthyear'\n | 'quarteryear';\nexport type DateTimeVariant = AbsoluteVariant | 'relative';\nexport type DateTimeFormat = 'short' | 'long' | 'numeric';\n"]}
1
+ {"version":3,"file":"DateTime.types.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NoChildrenProp, TestIdProp } from '../../types';\nimport type { FormControlProps } from '../FormControl';\n\nexport interface DateTimeProperties extends TestIdProp {\n /** Date as ISO8601 string, timestamp or native Date object. Defines minimum available value that can be set by the user. */\n min?: string | number | Date;\n /** Date as ISO8601 string, timestamp or native Date object. Defines maximum available value that can be set by the user. */\n max?: string | number | Date;\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\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 /** Visually hides the label region. */\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 /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n}\n\nexport type DateTimeValueErrorState = 'incomplete' | 'invalid';\n\nexport type DateTimeCallbackParameter = {\n valueAsISOString: string | undefined;\n valueAsTimestamp: number | undefined;\n state?: DateTimeValueErrorState;\n};\n\nexport interface DateTimeCallbacks {\n /** Callback fired when input value changes. */\n onChange?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when the component gets focused. */\n onFocus?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n}\n\nexport default interface DateTimeProps\n extends DateTimeProperties,\n DateTimeCallbacks,\n NoChildrenProp {\n /**\n * Date as ISO8601 string, timestamp or native Date object.\n * Requires onChange prop to update value for controlled inputs.\n */\n value?: string | number | Date;\n}\n\nexport type DateRangeCallbackParameter = {\n start: DateTimeCallbackParameter;\n end: DateTimeCallbackParameter;\n};\n\nexport type AbsoluteVariant =\n | 'date'\n | 'datetime'\n | 'time'\n | 'week'\n | 'month'\n | 'year'\n | 'monthyear'\n | 'quarteryear';\nexport type DateTimeVariant = AbsoluteVariant | 'relative';\nexport type DateTimeFormat = 'short' | 'medium' | 'long' | 'numeric';\n"]}
@@ -9,7 +9,7 @@ export interface DateTimeDisplayProps extends BaseProps {
9
9
  variant: DateTimeVariant;
10
10
  /**
11
11
  * Controls display format.
12
- * @default 'short'
12
+ * @default 'medium'
13
13
  */
14
14
  format?: DateTimeFormat;
15
15
  /** Defines clock format that overrides locale based format */
@@ -7,7 +7,7 @@ import { parseToDate } from './Input/utils';
7
7
  import { isValidDate } from './Picker/utils';
8
8
  import { formatDateTime } from './utils';
9
9
  export const StyledDateTimeDisplay = styled.span ``;
10
- const DateTimeDisplay = forwardRef(function DateTimeDisplay({ value, variant, format = 'short', clockFormat, ...restProps }, ref) {
10
+ const DateTimeDisplay = forwardRef(function DateTimeDisplay({ value, variant, format = 'medium', clockFormat, ...restProps }, ref) {
11
11
  const { locale } = useConfiguration();
12
12
  const t = useI18n();
13
13
  return (_jsx(StyledDateTimeDisplay, { ref: ref, ...restProps, children: (value || value === 0) && isValidDate(parseToDate(value)) ? (formatDateTime(parseToDate(value), {
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeDisplay.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTimeDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAkBzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAA,EAAE,CAAC;AAEnD,MAAM,eAAe,GAA2D,UAAU,CACxF,SAAS,eAAe,CACtB,EACE,KAAK,EACL,OAAO,EACP,MAAM,GAAG,OAAO,EAChB,WAAW,EACX,GAAG,SAAS,EAC0B,EACxC,GAAgC;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,KAAC,qBAAqB,IAAC,GAAG,EAAE,GAAG,KAAM,SAAS,YAC3C,CAAC,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3D,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;YACjC,CAAC;YACD,MAAM;YACN,MAAM;YACN,OAAO;YACP,WAAW;YACX,QAAQ,EAAE,KAAK;SAChB,CAAC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,OAAO,KAAG,CACZ,GACqB,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled from 'styled-components';\n\nimport type { BaseProps, ForwardProps } from '../../types';\nimport { useConfiguration, useI18n } from '../../hooks';\nimport NoValue from '../NoValue/NoValue';\n\nimport type { DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport { parseToDate } from './Input/utils';\nimport type { ClockFormat } from './Input/utils';\nimport { isValidDate } from './Picker/utils';\nimport { formatDateTime } from './utils';\n\nexport interface DateTimeDisplayProps extends BaseProps {\n /** Date as ISO8601 string, timestamp or native Date object. */\n value?: Date | string | number;\n /** Controls date time variant. */\n variant: DateTimeVariant;\n /**\n * Controls display format.\n * @default 'short'\n */\n format?: DateTimeFormat;\n /** Defines clock format that overrides locale based format */\n clockFormat?: ClockFormat;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLSpanElement>;\n}\n\nexport const StyledDateTimeDisplay = styled.span``;\n\nconst DateTimeDisplay: FunctionComponent<DateTimeDisplayProps & ForwardProps> = forwardRef(\n function DateTimeDisplay(\n {\n value,\n variant,\n format = 'short',\n clockFormat,\n ...restProps\n }: PropsWithoutRef<DateTimeDisplayProps>,\n ref: DateTimeDisplayProps['ref']\n ) {\n const { locale } = useConfiguration();\n const t = useI18n();\n\n return (\n <StyledDateTimeDisplay ref={ref} {...restProps}>\n {(value || value === 0) && isValidDate(parseToDate(value)) ? (\n formatDateTime(parseToDate(value), {\n t,\n locale,\n format,\n variant,\n clockFormat,\n timeZone: 'UTC'\n })\n ) : (\n <NoValue />\n )}\n </StyledDateTimeDisplay>\n );\n }\n);\n\nexport default DateTimeDisplay;\n"]}
1
+ {"version":3,"file":"DateTimeDisplay.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTimeDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAkBzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAA,EAAE,CAAC;AAEnD,MAAM,eAAe,GAA2D,UAAU,CACxF,SAAS,eAAe,CACtB,EACE,KAAK,EACL,OAAO,EACP,MAAM,GAAG,QAAQ,EACjB,WAAW,EACX,GAAG,SAAS,EAC0B,EACxC,GAAgC;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,KAAC,qBAAqB,IAAC,GAAG,EAAE,GAAG,KAAM,SAAS,YAC3C,CAAC,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3D,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;YACjC,CAAC;YACD,MAAM;YACN,MAAM;YACN,OAAO;YACP,WAAW;YACX,QAAQ,EAAE,KAAK;SAChB,CAAC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,OAAO,KAAG,CACZ,GACqB,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled from 'styled-components';\n\nimport type { BaseProps, ForwardProps } from '../../types';\nimport { useConfiguration, useI18n } from '../../hooks';\nimport NoValue from '../NoValue/NoValue';\n\nimport type { DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport { parseToDate } from './Input/utils';\nimport type { ClockFormat } from './Input/utils';\nimport { isValidDate } from './Picker/utils';\nimport { formatDateTime } from './utils';\n\nexport interface DateTimeDisplayProps extends BaseProps {\n /** Date as ISO8601 string, timestamp or native Date object. */\n value?: Date | string | number;\n /** Controls date time variant. */\n variant: DateTimeVariant;\n /**\n * Controls display format.\n * @default 'medium'\n */\n format?: DateTimeFormat;\n /** Defines clock format that overrides locale based format */\n clockFormat?: ClockFormat;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLSpanElement>;\n}\n\nexport const StyledDateTimeDisplay = styled.span``;\n\nconst DateTimeDisplay: FunctionComponent<DateTimeDisplayProps & ForwardProps> = forwardRef(\n function DateTimeDisplay(\n {\n value,\n variant,\n format = 'medium',\n clockFormat,\n ...restProps\n }: PropsWithoutRef<DateTimeDisplayProps>,\n ref: DateTimeDisplayProps['ref']\n ) {\n const { locale } = useConfiguration();\n const t = useI18n();\n\n return (\n <StyledDateTimeDisplay ref={ref} {...restProps}>\n {(value || value === 0) && isValidDate(parseToDate(value)) ? (\n formatDateTime(parseToDate(value), {\n t,\n locale,\n format,\n variant,\n clockFormat,\n timeZone: 'UTC'\n })\n ) : (\n <NoValue />\n )}\n </StyledDateTimeDisplay>\n );\n }\n);\n\nexport default DateTimeDisplay;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAmB,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAajD,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;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B,EAAE,qBAAqB,UAgCzB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAO,IAIzC,CAAC"}
@@ -9,88 +9,119 @@ const unitsInMs = {
9
9
  minute: 60 * 1000,
10
10
  second: 1000
11
11
  };
12
+ const dateShort = {
13
+ dateStyle: 'short'
14
+ };
15
+ const dateMedium = {
16
+ dateStyle: 'medium'
17
+ };
18
+ const dateLong = {
19
+ dateStyle: 'long'
20
+ };
21
+ const dateNumeric = {
22
+ year: 'numeric',
23
+ month: 'numeric',
24
+ day: 'numeric'
25
+ };
12
26
  const timeShort = {
27
+ timeStyle: 'short'
28
+ };
29
+ const timeMedium = {
30
+ timeStyle: 'medium'
31
+ };
32
+ const timeLong = {
33
+ timeStyle: 'medium'
34
+ };
35
+ const timeNumeric = {
13
36
  hour: 'numeric',
14
37
  minute: 'numeric'
15
38
  };
16
- const timeShort12 = {
17
- ...timeShort,
18
- hour12: true
39
+ const dateTimeShort = {
40
+ ...dateShort,
41
+ ...timeShort
19
42
  };
20
- const timeShort24 = {
21
- ...timeShort,
22
- hour12: false
23
- };
24
- const timeLong = {
25
- ...timeShort,
26
- second: 'numeric'
43
+ const dateTimeMedium = {
44
+ ...dateMedium,
45
+ ...timeShort
27
46
  };
28
- const timeLong12 = {
29
- ...timeShort12,
30
- second: 'numeric'
47
+ const dateTimeLong = {
48
+ ...dateLong,
49
+ ...timeMedium
31
50
  };
32
- const timeLong24 = {
33
- ...timeShort24,
34
- second: 'numeric'
51
+ const dateTimeNumeric = {
52
+ ...dateNumeric,
53
+ ...timeNumeric
35
54
  };
36
55
  const formatMapping = {
37
56
  date: {
38
- short: { year: 'numeric', month: 'short', day: 'numeric' },
39
- long: { year: 'numeric', month: 'long', day: 'numeric' },
40
- numeric: { year: 'numeric', month: 'numeric', day: 'numeric' }
57
+ short: dateShort,
58
+ medium: dateMedium,
59
+ long: dateLong,
60
+ numeric: dateNumeric
41
61
  },
42
62
  datetime: {
43
- short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort },
44
- long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong },
45
- numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort }
63
+ short: dateTimeShort,
64
+ medium: dateTimeMedium,
65
+ long: dateTimeLong,
66
+ numeric: dateTimeNumeric
46
67
  },
47
68
  datetime12: {
48
- short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort12 },
49
- long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong12 },
50
- numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort12 }
69
+ short: { ...dateTimeShort, hour12: true },
70
+ medium: { ...dateTimeMedium, hour12: true },
71
+ long: { ...dateTimeLong, hour12: true },
72
+ numeric: { ...dateTimeNumeric, hour12: true }
51
73
  },
52
74
  datetime24: {
53
- short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort24 },
54
- long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong24 },
55
- numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort24 }
75
+ short: { ...dateTimeShort, hour12: false },
76
+ medium: { ...dateTimeMedium, hour12: false },
77
+ long: { ...dateTimeLong, hour12: false },
78
+ numeric: { ...dateTimeNumeric, hour12: false }
56
79
  },
57
80
  time: {
58
81
  short: timeShort,
82
+ medium: timeMedium,
59
83
  long: timeLong,
60
- numeric: timeShort
84
+ numeric: timeNumeric
61
85
  },
62
86
  time12: {
63
- short: timeShort12,
64
- long: timeLong12,
65
- numeric: timeShort12
87
+ short: { ...timeShort, hour12: true },
88
+ medium: { ...timeMedium, hour12: true },
89
+ long: { ...timeLong, hour12: true },
90
+ numeric: { ...timeNumeric, hour12: true }
66
91
  },
67
92
  time24: {
68
- short: timeShort24,
69
- long: timeLong24,
70
- numeric: timeShort24
93
+ short: { ...timeShort, hour12: false },
94
+ medium: { ...timeMedium, hour12: false },
95
+ long: { ...timeLong, hour12: false },
96
+ numeric: { ...timeNumeric, hour12: false }
71
97
  },
72
98
  month: {
73
99
  short: { month: 'short' },
100
+ medium: { month: 'short' },
74
101
  long: { month: 'long' },
75
102
  numeric: { month: 'numeric' }
76
103
  },
77
104
  monthyear: {
78
105
  short: { year: 'numeric', month: 'short' },
106
+ medium: { year: 'numeric', month: 'short' },
79
107
  long: { year: 'numeric', month: 'long' },
80
108
  numeric: { year: 'numeric', month: 'numeric' }
81
109
  },
82
110
  week: {
83
111
  short: { month: 'short', day: 'numeric' },
112
+ medium: { month: 'short', day: 'numeric' },
84
113
  long: { month: 'long', day: 'numeric' },
85
114
  numeric: { month: 'numeric', day: 'numeric' }
86
115
  },
87
116
  year: {
88
117
  short: { year: 'numeric' },
118
+ medium: { year: 'numeric' },
89
119
  long: { year: 'numeric' },
90
120
  numeric: { year: '2-digit' }
91
121
  },
92
122
  relative: {
93
123
  short: { style: 'long', numeric: 'auto' },
124
+ medium: { style: 'long', numeric: 'auto' },
94
125
  long: { style: 'long', numeric: 'auto' },
95
126
  numeric: { style: 'short', numeric: 'auto' }
96
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG/F,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG;IAC/B,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE;IACvC,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IACxB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACpB,MAAM,EAAE,EAAE,GAA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AgB,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACpF,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAEzC,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;YAC/D,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACvC,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;gBAC7E,KAAK,EAAE,MAAM;gBACb,IAAI;gBACJ,WAAW;aACZ,CAAC,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;SACzE;QACD,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY;YAAE,MAAM;KACnD;IACD,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAS,EAAE;IAC/C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC","sourcesContent":["import type { TranslationFunction, TranslationPack } from '../../i18n';\nimport type { ExcludeStrict } from '../../types';\nimport { cap } from '../../utils';\n\nimport type { AbsoluteVariant, DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport { CALENDAR_TYPES } from './Input/local';\nimport { getEndOfWeek, getQuarter, getStartOfWeek, getWeek, getWeekYear } from './Input/utils';\nimport type { ClockFormat } from './Input/utils';\n\nconst unitsInMs = {\n year: 24 * 60 * 60 * 1000 * 365,\n month: (24 * 60 * 60 * 1000 * 365) / 12,\n day: 24 * 60 * 60 * 1000,\n hour: 60 * 60 * 1000,\n minute: 60 * 1000,\n second: 1000\n} satisfies Partial<Record<Intl.RelativeTimeFormatUnit, number>>;\n\ntype TimeUnit = keyof typeof unitsInMs;\n\ntype DateTimeFormatOptions = {\n locale: string;\n format: DateTimeFormat;\n timeZone?: string;\n clockFormat?: ClockFormat;\n calendarType?: string;\n} & (\n | {\n variant: ExcludeStrict<DateTimeVariant, 'quarteryear'>;\n t?: TranslationFunction<TranslationPack>;\n }\n | { variant: 'quarteryear'; t: TranslationFunction<TranslationPack> }\n);\n\ntype TimeOptions = Pick<Intl.DateTimeFormatOptions, 'hour' | 'minute' | 'second' | 'hour12'>;\n\nconst timeShort = {\n hour: 'numeric',\n minute: 'numeric'\n} satisfies TimeOptions;\n\nconst timeShort12 = {\n ...timeShort,\n hour12: true\n} satisfies TimeOptions;\n\nconst timeShort24 = {\n ...timeShort,\n hour12: false\n} satisfies TimeOptions;\n\nconst timeLong = {\n ...timeShort,\n second: 'numeric'\n} satisfies TimeOptions;\n\nconst timeLong12 = {\n ...timeShort12,\n second: 'numeric'\n} satisfies TimeOptions;\n\nconst timeLong24 = {\n ...timeShort24,\n second: 'numeric'\n} satisfies TimeOptions;\n\ntype AddClockFormatToTimeKeys<Key extends DateTimeVariant> = Key extends `${string}time`\n ? `${Key}${'' | 12 | 24}`\n : Key;\n\nconst formatMapping = {\n date: {\n short: { year: 'numeric', month: 'short', day: 'numeric' },\n long: { year: 'numeric', month: 'long', day: 'numeric' },\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric' }\n },\n datetime: {\n short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort },\n long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong },\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort }\n },\n datetime12: {\n short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort12 },\n long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong12 },\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort12 }\n },\n datetime24: {\n short: { year: 'numeric', month: 'short', day: 'numeric', ...timeShort24 },\n long: { year: 'numeric', month: 'long', day: 'numeric', ...timeLong24 },\n numeric: { year: 'numeric', month: 'numeric', day: 'numeric', ...timeShort24 }\n },\n time: {\n short: timeShort,\n long: timeLong,\n numeric: timeShort\n },\n time12: {\n short: timeShort12,\n long: timeLong12,\n numeric: timeShort12\n },\n time24: {\n short: timeShort24,\n long: timeLong24,\n numeric: timeShort24\n },\n month: {\n short: { month: 'short' },\n long: { month: 'long' },\n numeric: { month: 'numeric' }\n },\n monthyear: {\n short: { year: 'numeric', month: 'short' },\n long: { year: 'numeric', month: 'long' },\n numeric: { year: 'numeric', month: 'numeric' }\n },\n week: {\n short: { month: 'short', day: 'numeric' },\n long: { month: 'long', day: 'numeric' },\n numeric: { month: 'numeric', day: 'numeric' }\n },\n year: {\n short: { year: 'numeric' },\n long: { year: 'numeric' },\n numeric: { year: '2-digit' }\n },\n relative: {\n short: { style: 'long', numeric: 'auto' },\n long: { style: 'long', numeric: 'auto' },\n numeric: { style: 'short', numeric: 'auto' }\n }\n} satisfies Record<\n AddClockFormatToTimeKeys<ExcludeStrict<AbsoluteVariant, 'quarteryear'>>,\n Record<DateTimeFormat, Intl.DateTimeFormatOptions>\n> &\n Record<'relative', Record<DateTimeFormat, Intl.RelativeTimeFormatOptions>>;\n\nconst dateTimeFormatCache: Record<\n // locale\n string,\n Record<\n // timeZone\n string,\n Map<Intl.DateTimeFormatOptions, Intl.DateTimeFormat>\n >\n> = {};\n\nconst relativeTimeFormatCache: Record<\n // locale\n string,\n Map<Intl.RelativeTimeFormatOptions, Intl.RelativeTimeFormat>\n> = {};\n\nconst displayNamesCache: Record<\n // locale\n string,\n Intl.DateTimeDisplayNames\n> = {};\n\nexport function formatDateTime(\n value: Date,\n {\n t,\n locale,\n format,\n variant,\n clockFormat,\n calendarType = CALENDAR_TYPES.ISO_8601,\n timeZone\n }: DateTimeFormatOptions\n) {\n const getFormattedDate = (\n date: Date,\n dateVariant: ExcludeStrict<AbsoluteVariant, 'quarteryear'>,\n overrideTimeZone?: string\n ) => {\n const resolvedVariant: AddClockFormatToTimeKeys<typeof dateVariant> =\n dateVariant === 'time' || dateVariant === 'datetime'\n ? `${dateVariant}${clockFormat ?? ''}`\n : dateVariant;\n const resolvedTimeZone = overrideTimeZone ?? timeZone;\n const resolvedOptions = formatMapping[resolvedVariant][format];\n\n dateTimeFormatCache[locale] ??= {};\n dateTimeFormatCache[locale][`${resolvedTimeZone}`] ??= new Map();\n\n const map = dateTimeFormatCache[locale][`${resolvedTimeZone}`];\n\n if (!map.has(resolvedOptions)) {\n map.set(\n resolvedOptions,\n new Intl.DateTimeFormat(locale, {\n ...resolvedOptions,\n timeZone: resolvedTimeZone\n })\n );\n }\n\n return map.get(resolvedOptions)!.format(date);\n };\n\n const relativeTimeFormatter = (relativeValue: number, unit: TimeUnit) => {\n const resolvedOptions = formatMapping.relative[format];\n\n relativeTimeFormatCache[locale] ??= new Map();\n const map = relativeTimeFormatCache[locale];\n\n if (!map.has(resolvedOptions)) {\n map.set(resolvedOptions, new Intl.RelativeTimeFormat(locale, resolvedOptions));\n }\n\n return map.get(resolvedOptions)!.format(relativeValue, unit);\n };\n\n const getUnitsElapsed = (date: Date, unit: TimeUnit): number => {\n let amount: number;\n const now = new Date();\n\n switch (unit) {\n case 'year':\n amount = date.getUTCFullYear() - now.getUTCFullYear();\n break;\n case 'month':\n if (date.getUTCFullYear() === now.getUTCFullYear()) {\n amount = date.getUTCMonth() - now.getUTCMonth();\n } else if (date < now) {\n amount = (11 - date.getUTCMonth() + now.getUTCMonth() + 1) * -1;\n } else {\n amount = 11 - now.getUTCMonth() + date.getUTCMonth() + 1;\n }\n break;\n case 'day':\n if (date.getUTCMonth() === now.getUTCMonth()) {\n amount = date.getUTCDate() - now.getUTCDate();\n } else if (date < now) {\n const maximalDayOfMonth = new Date(\n Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)\n ).getUTCDate();\n amount = (maximalDayOfMonth - date.getUTCDate() + now.getUTCDate()) * -1;\n } else {\n const maximalDayOfMonth = new Date(\n Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 0)\n ).getUTCDate();\n amount = maximalDayOfMonth - now.getUTCDate() + date.getUTCDate() + 1;\n }\n break;\n case 'hour':\n if (date.getUTCDate() === now.getUTCDate()) {\n amount = date.getUTCHours() - now.getUTCHours();\n } else if (date < now) {\n amount = (23 - date.getUTCHours() + now.getUTCHours() + 1) * -1;\n } else {\n amount = 23 - now.getUTCHours() + date.getUTCHours() + 1;\n }\n break;\n case 'minute':\n if (date.getUTCHours() === now.getUTCHours()) {\n amount = date.getUTCMinutes() - now.getUTCMinutes();\n } else if (date < now) {\n amount = (59 - date.getUTCMinutes() + now.getUTCMinutes() + 1) * -1;\n } else {\n amount = 59 - now.getUTCMinutes() + date.getUTCMinutes() + 1;\n }\n break;\n default:\n amount = 0;\n break;\n }\n return amount;\n };\n\n const getRelativeTime = (date: Date) => {\n let elapsed = date.getTime() - Date.now();\n // Deliberately reduce precision to 1 minute\n if (Math.abs(elapsed) < 60000) elapsed = 0;\n const unit = (Object.keys(unitsInMs).find(u => Math.abs(elapsed) >= unitsInMs[u as TimeUnit]) ||\n 'second') as TimeUnit;\n const amount = getUnitsElapsed(date, unit);\n\n return relativeTimeFormatter(amount, unit);\n };\n\n const getFormattedWeek = (date: Date) => {\n displayNamesCache[locale] ??= new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n\n const displayNames = displayNamesCache[locale];\n const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n const startDate = getFormattedDate(\n getStartOfWeek(adjustedUTCDate, calendarType),\n 'week',\n 'UTC'\n );\n const endDate = getFormattedDate(getEndOfWeek(adjustedUTCDate, calendarType), 'week', 'UTC');\n return `${cap(displayNames.of('weekOfYear'))} ${getWeek(\n adjustedUTCDate,\n calendarType\n )}, ${getWeekYear(adjustedUTCDate, calendarType)} (${startDate} - ${endDate})`;\n };\n\n const getFormattedQuarterYear = (date: Date) => {\n const formattedYear = getFormattedDate(date, 'year');\n const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n const quarterNumber = getQuarter(adjustedUTCDate);\n return `${t!(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n };\n\n switch (variant) {\n case 'relative':\n return getRelativeTime(value);\n case 'week':\n return getFormattedWeek(value);\n case 'quarteryear':\n return getFormattedQuarterYear(value);\n default:\n return getFormattedDate(value, variant);\n }\n}\n\nconst dayInMs = 24 * 60 * 60 * 1000;\nconst hourInMs = 60 * 60 * 1000;\nconst minuteInMs = 60 * 1000;\nconst secondInMs = 1000;\n\ninterface DurationFormatOptions {\n /** Locale to be used - en_US, jp_JP, fr_FR etc */\n locale: string;\n /** Determines maximum number of units to be displayed. */\n significantUnits: 5 | 4 | 3 | 2 | 1;\n /**\n * Unit formatting style\n * @default \"narrow\"\n */\n unitDisplay?: Intl.NumberFormatOptions['unitDisplay'];\n /**\n * Unit of maximum precision\n * @default \"second\"\n */\n maxPrecision?: 'day' | 'hour' | 'minute' | 'second' | 'millisecond';\n}\n\nconst numberFormatCache: Record<\n // locale\n string,\n Record<\n // unit\n string,\n Record<\n // unitDisplay\n string,\n Intl.NumberFormat\n >\n >\n> = {};\n\nexport function formatDuration(\n valueInMs: number,\n {\n locale,\n significantUnits,\n unitDisplay = 'narrow',\n maxPrecision = 'second'\n }: DurationFormatOptions\n) {\n numberFormatCache[locale] ??= {};\n\n const sign = valueInMs < 0 ? '-' : '';\n const absMs = Math.abs(valueInMs);\n\n const durationParts = [\n { unit: 'day', value: Math.floor(absMs / dayInMs) },\n { unit: 'hour', value: Math.floor((absMs % dayInMs) / hourInMs) },\n { unit: 'minute', value: Math.floor((absMs % hourInMs) / minuteInMs) },\n { unit: 'second', value: Math.floor((absMs % minuteInMs) / secondInMs) },\n { unit: 'millisecond', value: absMs % secondInMs }\n ];\n\n const result = [];\n for (let i = 0; result.length < significantUnits && i < durationParts.length; i += 1) {\n const { value, unit } = durationParts[i];\n\n if (value > 0 || (unit === maxPrecision && result.length === 0)) {\n numberFormatCache[locale][unit] ??= {};\n numberFormatCache[locale][unit][unitDisplay] ??= new Intl.NumberFormat(locale, {\n style: 'unit',\n unit,\n unitDisplay\n });\n\n result.push(numberFormatCache[locale][unit][unitDisplay].format(value));\n }\n if (durationParts[i].unit === maxPrecision) break;\n }\n return `${sign}${result.join(' ')}`;\n}\n\n/**\n * @returns Current date and time value adjusted for local time zone.\n */\nexport const getAdjustedUTCDateTime = (): Date => {\n const now = new Date();\n now.setTime(now.getTime() - now.getTimezoneOffset() * 60000);\n return now;\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG/F,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG;IAC/B,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE;IACvC,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IACxB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAC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I,KAAK,YAAY;YAAE,MAAM;KACnD;IACD,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAS,EAAE;IAC/C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC","sourcesContent":["import type { TranslationFunction, TranslationPack } from '../../i18n';\nimport type { ExcludeStrict } from '../../types';\nimport { cap } from '../../utils';\n\nimport type { AbsoluteVariant, DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport { CALENDAR_TYPES } from './Input/local';\nimport { getEndOfWeek, getQuarter, getStartOfWeek, getWeek, getWeekYear } from './Input/utils';\nimport type { ClockFormat } from './Input/utils';\n\nconst unitsInMs = {\n year: 24 * 60 * 60 * 1000 * 365,\n month: (24 * 60 * 60 * 1000 * 365) / 12,\n day: 24 * 60 * 60 * 1000,\n hour: 60 * 60 * 1000,\n minute: 60 * 1000,\n second: 1000\n} satisfies Partial<Record<Intl.RelativeTimeFormatUnit, number>>;\n\ntype TimeUnit = keyof typeof unitsInMs;\n\ntype DateTimeFormatOptions = {\n locale: string;\n format: DateTimeFormat;\n timeZone?: string;\n clockFormat?: ClockFormat;\n calendarType?: string;\n} & (\n | {\n variant: ExcludeStrict<DateTimeVariant, 'quarteryear'>;\n t?: TranslationFunction<TranslationPack>;\n }\n | { variant: 'quarteryear'; t: TranslationFunction<TranslationPack> }\n);\n\ntype DateOptions = Pick<Intl.DateTimeFormatOptions, 'year' | 'month' | 'day'>;\ntype TimeOptions = Pick<Intl.DateTimeFormatOptions, 'hour' | 'minute' | 'second'>;\ntype DateStyle = Pick<Intl.DateTimeFormatOptions, 'dateStyle'>;\ntype TimeStyle = Pick<Intl.DateTimeFormatOptions, 'timeStyle'>;\n\nconst dateShort = {\n dateStyle: 'short'\n} satisfies DateStyle;\n\nconst dateMedium = {\n dateStyle: 'medium'\n} satisfies DateStyle;\n\nconst dateLong = {\n dateStyle: 'long'\n} satisfies DateStyle;\n\nconst dateNumeric = {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric'\n} satisfies DateOptions;\n\nconst timeShort = {\n timeStyle: 'short'\n} satisfies TimeStyle;\n\nconst timeMedium = {\n timeStyle: 'medium'\n} satisfies TimeStyle;\n\nconst timeLong = {\n timeStyle: 'medium'\n} satisfies TimeStyle;\n\nconst timeNumeric = {\n hour: 'numeric',\n minute: 'numeric'\n} satisfies TimeOptions;\n\nconst dateTimeShort = {\n ...dateShort,\n ...timeShort\n} satisfies DateStyle & TimeStyle;\n\nconst dateTimeMedium = {\n ...dateMedium,\n ...timeShort\n} satisfies DateStyle & TimeStyle;\n\nconst dateTimeLong = {\n ...dateLong,\n ...timeMedium\n} satisfies DateStyle & TimeStyle;\n\nconst dateTimeNumeric = {\n ...dateNumeric,\n ...timeNumeric\n} satisfies DateOptions & TimeOptions;\n\ntype AddClockFormatToTimeKeys<Key extends DateTimeVariant> = Key extends `${string}time`\n ? `${Key}${'' | 12 | 24}`\n : Key;\n\nconst formatMapping = {\n date: {\n short: dateShort,\n medium: dateMedium,\n long: dateLong,\n numeric: dateNumeric\n },\n datetime: {\n short: dateTimeShort,\n medium: dateTimeMedium,\n long: dateTimeLong,\n numeric: dateTimeNumeric\n },\n datetime12: {\n short: { ...dateTimeShort, hour12: true },\n medium: { ...dateTimeMedium, hour12: true },\n long: { ...dateTimeLong, hour12: true },\n numeric: { ...dateTimeNumeric, hour12: true }\n },\n datetime24: {\n short: { ...dateTimeShort, hour12: false },\n medium: { ...dateTimeMedium, hour12: false },\n long: { ...dateTimeLong, hour12: false },\n numeric: { ...dateTimeNumeric, hour12: false }\n },\n time: {\n short: timeShort,\n medium: timeMedium,\n long: timeLong,\n numeric: timeNumeric\n },\n time12: {\n short: { ...timeShort, hour12: true },\n medium: { ...timeMedium, hour12: true },\n long: { ...timeLong, hour12: true },\n numeric: { ...timeNumeric, hour12: true }\n },\n time24: {\n short: { ...timeShort, hour12: false },\n medium: { ...timeMedium, hour12: false },\n long: { ...timeLong, hour12: false },\n numeric: { ...timeNumeric, hour12: false }\n },\n month: {\n short: { month: 'short' },\n medium: { month: 'short' },\n long: { month: 'long' },\n numeric: { month: 'numeric' }\n },\n monthyear: {\n short: { year: 'numeric', month: 'short' },\n medium: { year: 'numeric', month: 'short' },\n long: { year: 'numeric', month: 'long' },\n numeric: { year: 'numeric', month: 'numeric' }\n },\n week: {\n short: { month: 'short', day: 'numeric' },\n medium: { month: 'short', day: 'numeric' },\n long: { month: 'long', day: 'numeric' },\n numeric: { month: 'numeric', day: 'numeric' }\n },\n year: {\n short: { year: 'numeric' },\n medium: { year: 'numeric' },\n long: { year: 'numeric' },\n numeric: { year: '2-digit' }\n },\n relative: {\n short: { style: 'long', numeric: 'auto' },\n medium: { style: 'long', numeric: 'auto' },\n long: { style: 'long', numeric: 'auto' },\n numeric: { style: 'short', numeric: 'auto' }\n }\n} satisfies Record<\n AddClockFormatToTimeKeys<ExcludeStrict<AbsoluteVariant, 'quarteryear'>>,\n Record<DateTimeFormat, Intl.DateTimeFormatOptions>\n> &\n Record<'relative', Record<DateTimeFormat, Intl.RelativeTimeFormatOptions>>;\n\nconst dateTimeFormatCache: Record<\n // locale\n string,\n Record<\n // timeZone\n string,\n Map<Intl.DateTimeFormatOptions, Intl.DateTimeFormat>\n >\n> = {};\n\nconst relativeTimeFormatCache: Record<\n // locale\n string,\n Map<Intl.RelativeTimeFormatOptions, Intl.RelativeTimeFormat>\n> = {};\n\nconst displayNamesCache: Record<\n // locale\n string,\n Intl.DateTimeDisplayNames\n> = {};\n\nexport function formatDateTime(\n value: Date,\n {\n t,\n locale,\n format,\n variant,\n clockFormat,\n calendarType = CALENDAR_TYPES.ISO_8601,\n timeZone\n }: DateTimeFormatOptions\n) {\n const getFormattedDate = (\n date: Date,\n dateVariant: ExcludeStrict<AbsoluteVariant, 'quarteryear'>,\n overrideTimeZone?: string\n ) => {\n const resolvedVariant: AddClockFormatToTimeKeys<typeof dateVariant> =\n dateVariant === 'time' || dateVariant === 'datetime'\n ? `${dateVariant}${clockFormat ?? ''}`\n : dateVariant;\n const resolvedTimeZone = overrideTimeZone ?? timeZone;\n const resolvedOptions = formatMapping[resolvedVariant][format];\n\n dateTimeFormatCache[locale] ??= {};\n dateTimeFormatCache[locale][`${resolvedTimeZone}`] ??= new Map();\n\n const map = dateTimeFormatCache[locale][`${resolvedTimeZone}`];\n\n if (!map.has(resolvedOptions)) {\n map.set(\n resolvedOptions,\n new Intl.DateTimeFormat(locale, {\n ...resolvedOptions,\n timeZone: resolvedTimeZone\n })\n );\n }\n\n return map.get(resolvedOptions)!.format(date);\n };\n\n const relativeTimeFormatter = (relativeValue: number, unit: TimeUnit) => {\n const resolvedOptions = formatMapping.relative[format];\n\n relativeTimeFormatCache[locale] ??= new Map();\n const map = relativeTimeFormatCache[locale];\n\n if (!map.has(resolvedOptions)) {\n map.set(resolvedOptions, new Intl.RelativeTimeFormat(locale, resolvedOptions));\n }\n\n return map.get(resolvedOptions)!.format(relativeValue, unit);\n };\n\n const getUnitsElapsed = (date: Date, unit: TimeUnit): number => {\n let amount: number;\n const now = new Date();\n\n switch (unit) {\n case 'year':\n amount = date.getUTCFullYear() - now.getUTCFullYear();\n break;\n case 'month':\n if (date.getUTCFullYear() === now.getUTCFullYear()) {\n amount = date.getUTCMonth() - now.getUTCMonth();\n } else if (date < now) {\n amount = (11 - date.getUTCMonth() + now.getUTCMonth() + 1) * -1;\n } else {\n amount = 11 - now.getUTCMonth() + date.getUTCMonth() + 1;\n }\n break;\n case 'day':\n if (date.getUTCMonth() === now.getUTCMonth()) {\n amount = date.getUTCDate() - now.getUTCDate();\n } else if (date < now) {\n const maximalDayOfMonth = new Date(\n Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)\n ).getUTCDate();\n amount = (maximalDayOfMonth - date.getUTCDate() + now.getUTCDate()) * -1;\n } else {\n const maximalDayOfMonth = new Date(\n Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 0)\n ).getUTCDate();\n amount = maximalDayOfMonth - now.getUTCDate() + date.getUTCDate() + 1;\n }\n break;\n case 'hour':\n if (date.getUTCDate() === now.getUTCDate()) {\n amount = date.getUTCHours() - now.getUTCHours();\n } else if (date < now) {\n amount = (23 - date.getUTCHours() + now.getUTCHours() + 1) * -1;\n } else {\n amount = 23 - now.getUTCHours() + date.getUTCHours() + 1;\n }\n break;\n case 'minute':\n if (date.getUTCHours() === now.getUTCHours()) {\n amount = date.getUTCMinutes() - now.getUTCMinutes();\n } else if (date < now) {\n amount = (59 - date.getUTCMinutes() + now.getUTCMinutes() + 1) * -1;\n } else {\n amount = 59 - now.getUTCMinutes() + date.getUTCMinutes() + 1;\n }\n break;\n default:\n amount = 0;\n break;\n }\n return amount;\n };\n\n const getRelativeTime = (date: Date) => {\n let elapsed = date.getTime() - Date.now();\n // Deliberately reduce precision to 1 minute\n if (Math.abs(elapsed) < 60000) elapsed = 0;\n const unit = (Object.keys(unitsInMs).find(u => Math.abs(elapsed) >= unitsInMs[u as TimeUnit]) ||\n 'second') as TimeUnit;\n const amount = getUnitsElapsed(date, unit);\n\n return relativeTimeFormatter(amount, unit);\n };\n\n const getFormattedWeek = (date: Date) => {\n displayNamesCache[locale] ??= new Intl.DisplayNames(locale, {\n style: 'long',\n type: 'dateTimeField'\n }) as Intl.DateTimeDisplayNames;\n\n const displayNames = displayNamesCache[locale];\n const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n const startDate = getFormattedDate(\n getStartOfWeek(adjustedUTCDate, calendarType),\n 'week',\n 'UTC'\n );\n const endDate = getFormattedDate(getEndOfWeek(adjustedUTCDate, calendarType), 'week', 'UTC');\n return `${cap(displayNames.of('weekOfYear'))} ${getWeek(\n adjustedUTCDate,\n calendarType\n )}, ${getWeekYear(adjustedUTCDate, calendarType)} (${startDate} - ${endDate})`;\n };\n\n const getFormattedQuarterYear = (date: Date) => {\n const formattedYear = getFormattedDate(date, 'year');\n const adjustedUTCDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);\n const quarterNumber = getQuarter(adjustedUTCDate);\n return `${t!(`date_quarter_q${quarterNumber}`, [formattedYear])}`;\n };\n\n switch (variant) {\n case 'relative':\n return getRelativeTime(value);\n case 'week':\n return getFormattedWeek(value);\n case 'quarteryear':\n return getFormattedQuarterYear(value);\n default:\n return getFormattedDate(value, variant);\n }\n}\n\nconst dayInMs = 24 * 60 * 60 * 1000;\nconst hourInMs = 60 * 60 * 1000;\nconst minuteInMs = 60 * 1000;\nconst secondInMs = 1000;\n\ninterface DurationFormatOptions {\n /** Locale to be used - en_US, jp_JP, fr_FR etc */\n locale: string;\n /** Determines maximum number of units to be displayed. */\n significantUnits: 5 | 4 | 3 | 2 | 1;\n /**\n * Unit formatting style\n * @default \"narrow\"\n */\n unitDisplay?: Intl.NumberFormatOptions['unitDisplay'];\n /**\n * Unit of maximum precision\n * @default \"second\"\n */\n maxPrecision?: 'day' | 'hour' | 'minute' | 'second' | 'millisecond';\n}\n\nconst numberFormatCache: Record<\n // locale\n string,\n Record<\n // unit\n string,\n Record<\n // unitDisplay\n string,\n Intl.NumberFormat\n >\n >\n> = {};\n\nexport function formatDuration(\n valueInMs: number,\n {\n locale,\n significantUnits,\n unitDisplay = 'narrow',\n maxPrecision = 'second'\n }: DurationFormatOptions\n) {\n numberFormatCache[locale] ??= {};\n\n const sign = valueInMs < 0 ? '-' : '';\n const absMs = Math.abs(valueInMs);\n\n const durationParts = [\n { unit: 'day', value: Math.floor(absMs / dayInMs) },\n { unit: 'hour', value: Math.floor((absMs % dayInMs) / hourInMs) },\n { unit: 'minute', value: Math.floor((absMs % hourInMs) / minuteInMs) },\n { unit: 'second', value: Math.floor((absMs % minuteInMs) / secondInMs) },\n { unit: 'millisecond', value: absMs % secondInMs }\n ];\n\n const result = [];\n for (let i = 0; result.length < significantUnits && i < durationParts.length; i += 1) {\n const { value, unit } = durationParts[i];\n\n if (value > 0 || (unit === maxPrecision && result.length === 0)) {\n numberFormatCache[locale][unit] ??= {};\n numberFormatCache[locale][unit][unitDisplay] ??= new Intl.NumberFormat(locale, {\n style: 'unit',\n unit,\n unitDisplay\n });\n\n result.push(numberFormatCache[locale][unit][unitDisplay].format(value));\n }\n if (durationParts[i].unit === maxPrecision) break;\n }\n return `${sign}${result.join(' ')}`;\n}\n\n/**\n * @returns Current date and time value adjusted for local time zone.\n */\nexport const getAdjustedUTCDateTime = (): Date => {\n const now = new Date();\n now.setTime(now.getTime() - now.getTimezoneOffset() * 60000);\n return now;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAK3F,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAuCxD,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,qBAAqB,CAAC;;;;AA6a7B,wBAA+D"}
1
+ {"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAK3F,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAwCxD,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,qBAAqB,CAAC;;;;AAub7B,wBAA+D"}
@@ -3,7 +3,7 @@ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'r
3
3
  import VisuallyHiddenText from '../VisuallyHiddenText';
4
4
  import Actions from '../Actions';
5
5
  import Button from '../Button';
6
- import { useBreakpoint, useConfiguration, useConsolidatedRef, useEscape, useI18n, useTestIds, useUID } from '../../hooks';
6
+ import { useBreakpoint, useConfiguration, useConsolidatedRef, useElement, useEscape, useI18n, useTestIds, useUID } from '../../hooks';
7
7
  import Flex from '../Flex';
8
8
  import SearchInput from '../SearchInput';
9
9
  import Icon, { registerIcon } from '../Icon';
@@ -17,8 +17,9 @@ import { formatNumber } from '../Number';
17
17
  import MenuButton from '../MenuButton';
18
18
  import Avatar from '../Avatar';
19
19
  import AdditionalInfo from '../AdditionalInfo';
20
+ import Tooltip from '../Tooltip';
20
21
  import PresetMenuPopover from './PresetMenuPopover';
21
- import { StyledViewSelector, StyledSearchForm, StyledListToolbar, StyledHeadingText, StyledCountMeta, StyledContainer, StyledListToolbarContent, StyledListToolbarDialog, StyledErrorIcon, StyledInfo, StyledSearchContainer } from './ListToolbar.styles';
22
+ import { StyledViewSelector, StyledSearchForm, StyledListToolbar, StyledHeadingText, StyledCountMeta, StyledListToolbarContent, StyledListToolbarDialog, StyledErrorIcon, StyledInfo, StyledSearchContainer } from './ListToolbar.styles';
22
23
  import helpers from './helpers';
23
24
  import { getListToolbarTestIds } from './ListToolbar.test-ids';
24
25
  registerIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);
@@ -50,6 +51,7 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
50
51
  const toolbarContentRef = useRef(null);
51
52
  const searchInputRef = useRef(null);
52
53
  const searchButtonRef = useRef(null);
54
+ const [labelEl, setLabelEl] = useElement();
53
55
  const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);
54
56
  const onSearchEscape = () => {
55
57
  if (!search?.value) {
@@ -168,42 +170,42 @@ const ListToolbar = forwardRef(function ListToolbar({ testId, name, headingTag =
168
170
  }
169
171
  }
170
172
  return (_jsxs(Flex, { "data-testid": testIds.root, container: true, ...restProps, as: StyledListToolbar, ref: ref, children: [_jsxs(StyledListToolbarContent, { container: { direction: 'column' }, ref: toolbarContentRef, item: { grow: 1 }, children: [_jsxs(Flex, { container: {
171
- alignItems: 'start',
173
+ alignItems: 'center',
172
174
  justify: 'between',
173
175
  gap: 0.5
174
- }, children: [_jsxs(StyledContainer, { container: {
176
+ }, children: [_jsxs(Flex, { container: {
175
177
  alignItems: 'center',
176
178
  gap: 1
177
- }, children: [_jsxs(StyledHeadingText, { "data-testid": testIds.heading, variant: headingTag, required: formControlProps?.required, "aria-describedby": formControlProps?.info ? `${uid}-info` : undefined, children: [formControlProps?.info && formControlProps.status === 'error' && (_jsxs(_Fragment, { children: [_jsx(StyledErrorIcon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: ` ${t('error')} ` })] })), !viewSelector || viewSelector.views.length <= 1 ? (labelText) : (_jsx(MenuButton, { variant: 'text', text: labelText, as: StyledViewSelector, menu: {
178
- mode: 'single-select',
179
- items: viewSelector.views.map(view => {
180
- if (hasProp(view, 'items')) {
181
- return {
182
- id: view.text,
183
- label: view.text,
184
- items: view.items.map(groupedView => {
179
+ }, item: { grow: 1 }, children: [_jsxs(StyledHeadingText, { "data-testid": testIds.heading, variant: headingTag, required: formControlProps?.required, "aria-describedby": formControlProps?.info ? `${uid}-info` : undefined, children: [formControlProps?.info && formControlProps.status === 'error' && (_jsxs(_Fragment, { children: [_jsx(StyledErrorIcon, { name: 'warn-solid' }), _jsx(VisuallyHiddenText, { children: ` ${t('error')} ` })] })), !viewSelector || viewSelector.views.length <= 1 ? (labelText) : (_jsxs(_Fragment, { children: [_jsx(MenuButton, { ref: setLabelEl, "data-testid": testIds.viewSelector, variant: 'text', text: labelText, as: StyledViewSelector, menu: {
180
+ mode: 'single-select',
181
+ items: viewSelector.views.map(view => {
182
+ if (hasProp(view, 'items')) {
185
183
  return {
186
- ...groupedView,
187
- primary: generateViewName(groupedView, { default: t('default'), appDefault: t('app_default') }, {
188
- defaultId: viewSelector.defaultId,
189
- appDefaultId: viewSelector.appDefaultId
190
- }),
191
- visual: groupedView.visual ? (_jsx(Avatar, { ...groupedView.visual })) : undefined
184
+ id: view.text,
185
+ label: view.text,
186
+ items: view.items.map(groupedView => {
187
+ return {
188
+ ...groupedView,
189
+ primary: generateViewName(groupedView, { default: t('default'), appDefault: t('app_default') }, {
190
+ defaultId: viewSelector.defaultId,
191
+ appDefaultId: viewSelector.appDefaultId
192
+ }),
193
+ visual: groupedView.visual ? (_jsx(Avatar, { ...groupedView.visual })) : undefined
194
+ };
195
+ })
192
196
  };
193
- })
194
- };
195
- }
196
- return {
197
- ...view,
198
- primary: generateViewName(view, { default: t('default'), appDefault: t('app_default') }, {
199
- defaultId: viewSelector.defaultId,
200
- appDefaultId: viewSelector.appDefaultId
197
+ }
198
+ return {
199
+ ...view,
200
+ primary: generateViewName(view, { default: t('default'), appDefault: t('app_default') }, {
201
+ defaultId: viewSelector.defaultId,
202
+ appDefaultId: viewSelector.appDefaultId
203
+ }),
204
+ visual: view.visual ? _jsx(Avatar, { ...view.visual }) : undefined
205
+ };
201
206
  }),
202
- visual: view.visual ? _jsx(Avatar, { ...view.visual }) : undefined
203
- };
204
- }),
205
- onItemClick: viewSelector.onViewSelect
206
- }, testId: testIds.viewSelector }))] }), formControlProps?.additionalInfo && (_jsx(AdditionalInfo, { heading: formControlProps.additionalInfo.heading, contextualLabel: labelText, children: formControlProps.additionalInfo.content })), isSmallOrAbove && count && _jsx(CountMeta, { "data-testid": testIds.count, count: count })] }), _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, children: [isSmallOrAbove && additionalActions, search && isSmallOrAbove && expandableSearch, isSmallOrAbove && createNewButton, isSmallOrAbove && basicModeActions && (_jsx(Actions, { items: basicModeActions.map(({ icon, ...restActionProps }) => ({
207
+ onItemClick: viewSelector.onViewSelect
208
+ } }), labelEl && (_jsx(Tooltip, { target: labelEl, describeTarget: false, hideDelay: 'none', smart: true, children: labelText }))] }))] }), formControlProps?.additionalInfo && (_jsx(AdditionalInfo, { heading: formControlProps.additionalInfo.heading, contextualLabel: labelText, children: formControlProps.additionalInfo.content })), isSmallOrAbove && count && _jsx(CountMeta, { "data-testid": testIds.count, count: count })] }), _jsxs(_Fragment, { children: [isSmallOrAbove && additionalActions, search && isSmallOrAbove && expandableSearch, isSmallOrAbove && createNewButton, isSmallOrAbove && basicModeActions && (_jsx(Actions, { items: basicModeActions.map(({ icon, ...restActionProps }) => ({
207
209
  ...restActionProps,
208
210
  visual: icon && _jsx(Icon, { name: icon })
209
211
  })), menuAt: 1, ref: consolidatedActionsButtonRef })), !isSmallOrAbove && count && _jsx(CountMeta, { "data-testid": testIds.count, count: count })] })] }), !isSmallOrAbove && (_jsxs(_Fragment, { children: [!!count?.selected && additionalActions, _jsxs(StyledSearchContainer, { container: { alignItems: 'start', justify: 'between', gap: 1 }, children: [_jsx(Flex, { as: StyledSearchForm, container: { alignItems: 'center', wrap: 'wrap', gap: 1 }, item: { grow: 1 }, children: search && searchInput }), createNewButton, basicModeActions && (_jsx(Actions, { items: basicModeActions.map(({ icon, ...restActionProps }) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC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AI,EAAE,GAAG,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;4CAC7D,GAAG,eAAe;4CAClB,MAAM,EAAE,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI;yCACrC,CAAC,CAAC,EACH,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,4BAA4B,GACjC,CACH,IACqB,IACvB,CACJ,EACA,gBAAgB,EAAE,IAAI,IAAI,CACzB,KAAC,UAAU,IACT,IAAI,EACF,gBAAgB,CAAC,MAAM,KAAK,OAAO,IAAI,gBAAgB,CAAC,MAAM,KAAK,SAAS;4BAC1E,CAAC,CAAC,OAAO;4BACT,CAAC,CAAC,SAAS,EAEf,EAAE,EAAE,GAAG,GAAG,OAAO,iBACJ,OAAO,CAAC,IAAI,EACzB,MAAM,EAAE,gBAAgB,CAAC,MAAM,YAE9B,gBAAgB,CAAC,IAAI,GACX,CACd,IACwB,EAE1B,kBAAkB,EAEnB,KAAC,iBAAiB,IAChB,SAAS,EAAE,4BAA4B,EACvC,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAC1C,IAAI,EAAE,wBAAwB,EAAE,IAAI,EACpC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAC7C,IACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { FunctionComponent, KeyboardEvent, PropsWithoutRef, MouseEvent } from 'react';\n\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Actions from '../Actions';\nimport Button from '../Button';\nimport type { Action, ForwardProps } from '../../types';\nimport {\n useBreakpoint,\n useConfiguration,\n useConsolidatedRef,\n useEscape,\n useI18n,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp, withTestIds } from '../../utils';\nimport { formatNumber } from '../Number';\nimport MenuButton from '../MenuButton';\nimport Avatar from '../Avatar';\nimport AdditionalInfo from '../AdditionalInfo';\n\nimport PresetMenuPopover from './PresetMenuPopover';\nimport type { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport {\n StyledViewSelector,\n StyledSearchForm,\n StyledListToolbar,\n StyledHeadingText,\n StyledCountMeta,\n StyledContainer,\n StyledListToolbarContent,\n StyledListToolbarDialog,\n StyledErrorIcon,\n StyledInfo,\n StyledSearchContainer\n} from './ListToolbar.styles';\nimport type {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionId,\n ViewProps,\n ViewSelectorProps\n} from './ListToolbar.types';\nimport helpers from './helpers';\nimport { getListToolbarTestIds } from './ListToolbar.test-ids';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({\n count,\n ...restProps\n}: { count: NonNullable<ListToolbarProps['count']> } & ForwardProps) => {\n const { locale } = useConfiguration();\n const t = useI18n();\n const totalFormattedValue = formatNumber(count.total ?? 0, {\n locale,\n options: {\n useGrouping: true\n }\n });\n return (\n <StyledCountMeta variant='secondary' {...restProps}>\n {count.selected\n ? t(\n 'selected_count',\n [formatNumber(count.selected, { locale, options: { useGrouping: true } })],\n { count: count.selected }\n )\n : count.total !== undefined &&\n t(\n 'results_count',\n [count.totalHasMore ? `${totalFormattedValue}+` : totalFormattedValue],\n {\n count: count.total\n }\n )}\n </StyledCountMeta>\n );\n};\n\nconst generateViewName = (\n view: ViewProps,\n texts: { default: string; appDefault: string },\n options: {\n defaultId?: ViewSelectorProps['defaultId'];\n appDefaultId?: ViewSelectorProps['appDefaultId'];\n }\n) => {\n return `${view.text} ${view.id === options.defaultId ? `(${texts.default})` : ''} ${\n view.id === options.appDefaultId ? `(${texts.appDefault})` : ''\n }`;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n function ListToolbar(\n {\n testId,\n name,\n headingTag = 'h3',\n viewSelector,\n formControlProps,\n createNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n ...restProps\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) {\n const uid = useUID();\n const t = useI18n();\n const testIds = useTestIds(testId, getListToolbarTestIds);\n\n const isSmallOrAbove = useBreakpoint('sm');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n const toolbarContentRef = useRef<HTMLDivElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const searchButtonRef = useRef<HTMLButtonElement>(null);\n const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);\n\n const onSearchEscape = () => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n setTimeout(() => searchButtonRef.current?.focus());\n };\n\n useEffect(() => {\n if (search?.value) {\n setIsSearchOpen(true);\n }\n }, [search?.value]);\n\n const [currentQueryOptionId, setCurrentQueryOptionId] = useState<QueryOptionId | null>(null);\n const queryOptionPopoverTarget = useRef<HTMLButtonElement>();\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!createNew?.onClick) return null;\n const text = createNew.label ?? t('create_new');\n\n return (\n <Button variant='simple' icon label={text} aria-label={text} onClick={createNew.onClick}>\n <Icon name='plus' />\n </Button>\n );\n }, [t, createNew, isSmallOrAbove]);\n\n useEscape(onSearchEscape, searchInputRef);\n const searchInput = useMemo(\n () => (\n <SearchInput\n {...search}\n onSearchSubmit={(value: string) => {\n search?.onSearchSubmit?.(value);\n onSearchEscape();\n }}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n onBlur={() => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n }}\n ref={searchInputRef}\n />\n ),\n [search, onSearchEscape]\n );\n\n const searchLabel = t('search');\n const expandableSearch = useMemo(() => {\n return isSearchOpen ? (\n searchInput\n ) : (\n <Button\n variant='simple'\n icon\n label={searchLabel}\n onClick={() => {\n setIsSearchOpen(true);\n setTimeout(() => searchInputRef.current?.focus());\n }}\n onKeyDown={(e: KeyboardEvent<HTMLElement>) => {\n if (e.target !== searchInputRef.current && (e.key === 'Enter' || e.key === ' ')) {\n setIsSearchOpen(true);\n setTimeout(() => {\n searchInputRef.current?.focus();\n searchInputRef.current?.select();\n });\n }\n }}\n ref={searchButtonRef}\n >\n <Icon name='search' />\n </Button>\n );\n }, [searchLabel, setIsSearchOpen, isSearchOpen, searchInput]);\n\n let queryOptionPopover = null;\n if (currentQueryOptionId) {\n const queryOptionProps = { filter, sort, group }[currentQueryOptionId];\n if (\n queryOptionProps &&\n hasProp(queryOptionProps, 'renderer') &&\n queryOptionPopoverTarget.current\n ) {\n queryOptionPopover = (\n <StyledListToolbarDialog\n target={queryOptionPopoverTarget.current}\n heading={t(currentQueryOptionId)}\n placement='bottom-end'\n onCancel={() => {\n if (queryOptionProps.onCancel() === false) return;\n setCurrentQueryOptionId(null);\n }}\n onSubmit={() => {\n if (queryOptionProps.onSubmit() === false) return;\n setCurrentQueryOptionId(null);\n }}\n >\n <queryOptionProps.renderer />\n </StyledListToolbarDialog>\n );\n }\n }\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setCurrentQueryOptionId(id);\n queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(id),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n let labelText = name;\n\n if (viewSelector) {\n const viewItems = helpers.getViews(viewSelector.views);\n\n if (viewItems.length > 1) {\n const selectedViewName =\n helpers.getSelectedView(viewSelector.views)?.text ?? viewItems[0].text;\n\n labelText = `${name}: ${selectedViewName}`;\n }\n }\n\n return (\n <Flex data-testid={testIds.root} container {...restProps} as={StyledListToolbar} ref={ref}>\n <StyledListToolbarContent\n container={{ direction: 'column' }}\n ref={toolbarContentRef}\n item={{ grow: 1 }}\n >\n <Flex\n container={{\n alignItems: 'start',\n justify: 'between',\n gap: 0.5\n }}\n >\n <StyledContainer\n container={{\n alignItems: 'center',\n gap: 1\n }}\n >\n <StyledHeadingText\n data-testid={testIds.heading}\n variant={headingTag}\n required={formControlProps?.required}\n aria-describedby={formControlProps?.info ? `${uid}-info` : undefined}\n >\n {formControlProps?.info && formControlProps.status === 'error' && (\n <>\n <StyledErrorIcon name='warn-solid' />\n <VisuallyHiddenText>{` ${t('error')} `}</VisuallyHiddenText>\n </>\n )}\n {!viewSelector || viewSelector.views.length <= 1 ? (\n labelText\n ) : (\n <MenuButton\n variant='text'\n text={labelText}\n as={StyledViewSelector}\n menu={{\n mode: 'single-select',\n items: viewSelector.views.map(view => {\n if (hasProp(view, 'items')) {\n return {\n id: view.text,\n label: view.text,\n items: view.items.map(groupedView => {\n return {\n ...groupedView,\n primary: generateViewName(\n groupedView,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: groupedView.visual ? (\n <Avatar {...groupedView.visual} />\n ) : undefined\n };\n })\n };\n }\n\n return {\n ...view,\n primary: generateViewName(\n view,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: view.visual ? <Avatar {...view.visual} /> : undefined\n };\n }),\n onItemClick: viewSelector.onViewSelect\n }}\n testId={testIds.viewSelector}\n />\n )}\n </StyledHeadingText>\n {formControlProps?.additionalInfo && (\n <AdditionalInfo\n heading={formControlProps.additionalInfo.heading}\n contextualLabel={labelText}\n >\n {formControlProps.additionalInfo.content}\n </AdditionalInfo>\n )}\n {isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </StyledContainer>\n <Flex container={{ alignItems: 'center', gap: 1 }}>\n {isSmallOrAbove && additionalActions}\n {search && isSmallOrAbove && expandableSearch}\n {isSmallOrAbove && createNewButton}\n {isSmallOrAbove && basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n {!isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </Flex>\n </Flex>\n {!isSmallOrAbove && (\n <>\n {!!count?.selected && additionalActions}\n <StyledSearchContainer\n container={{ alignItems: 'start', justify: 'between', gap: 1 }}\n >\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 1 }}\n item={{ grow: 1 }}\n >\n {search && searchInput}\n </Flex>\n {createNewButton}\n {basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n </StyledSearchContainer>\n </>\n )}\n {formControlProps?.info && (\n <StyledInfo\n role={\n formControlProps.status === 'error' || formControlProps.status === 'warning'\n ? 'alert'\n : undefined\n }\n id={`${uid}-info`}\n data-testid={testIds.info}\n status={formControlProps.status}\n >\n {formControlProps.info}\n </StyledInfo>\n )}\n </StyledListToolbarContent>\n\n {queryOptionPopover}\n\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n </Flex>\n );\n }\n);\n\nexport default withTestIds(ListToolbar, getListToolbarTestIds);\n"]}
1
+ {"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,OAAO,EACP,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,IAAI,EAAE,EAAE,Y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useMemo, useRef, useState } from 'react';\nimport type { FunctionComponent, KeyboardEvent, PropsWithoutRef, MouseEvent } from 'react';\n\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport Actions from '../Actions';\nimport Button from '../Button';\nimport type { Action, ForwardProps } from '../../types';\nimport {\n useBreakpoint,\n useConfiguration,\n useConsolidatedRef,\n useElement,\n useEscape,\n useI18n,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp, withTestIds } from '../../utils';\nimport { formatNumber } from '../Number';\nimport MenuButton from '../MenuButton';\nimport Avatar from '../Avatar';\nimport AdditionalInfo from '../AdditionalInfo';\nimport Tooltip from '../Tooltip';\n\nimport PresetMenuPopover from './PresetMenuPopover';\nimport type { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport {\n StyledViewSelector,\n StyledSearchForm,\n StyledListToolbar,\n StyledHeadingText,\n StyledCountMeta,\n StyledListToolbarContent,\n StyledListToolbarDialog,\n StyledErrorIcon,\n StyledInfo,\n StyledSearchContainer\n} from './ListToolbar.styles';\nimport type {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionId,\n ViewProps,\n ViewSelectorProps\n} from './ListToolbar.types';\nimport helpers from './helpers';\nimport { getListToolbarTestIds } from './ListToolbar.test-ids';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({\n count,\n ...restProps\n}: { count: NonNullable<ListToolbarProps['count']> } & ForwardProps) => {\n const { locale } = useConfiguration();\n const t = useI18n();\n const totalFormattedValue = formatNumber(count.total ?? 0, {\n locale,\n options: {\n useGrouping: true\n }\n });\n return (\n <StyledCountMeta variant='secondary' {...restProps}>\n {count.selected\n ? t(\n 'selected_count',\n [formatNumber(count.selected, { locale, options: { useGrouping: true } })],\n { count: count.selected }\n )\n : count.total !== undefined &&\n t(\n 'results_count',\n [count.totalHasMore ? `${totalFormattedValue}+` : totalFormattedValue],\n {\n count: count.total\n }\n )}\n </StyledCountMeta>\n );\n};\n\nconst generateViewName = (\n view: ViewProps,\n texts: { default: string; appDefault: string },\n options: {\n defaultId?: ViewSelectorProps['defaultId'];\n appDefaultId?: ViewSelectorProps['appDefaultId'];\n }\n) => {\n return `${view.text} ${view.id === options.defaultId ? `(${texts.default})` : ''} ${\n view.id === options.appDefaultId ? `(${texts.appDefault})` : ''\n }`;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n function ListToolbar(\n {\n testId,\n name,\n headingTag = 'h3',\n viewSelector,\n formControlProps,\n createNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n ...restProps\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) {\n const uid = useUID();\n const t = useI18n();\n const testIds = useTestIds(testId, getListToolbarTestIds);\n\n const isSmallOrAbove = useBreakpoint('sm');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n const toolbarContentRef = useRef<HTMLDivElement>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const searchButtonRef = useRef<HTMLButtonElement>(null);\n const [labelEl, setLabelEl] = useElement<HTMLButtonElement>();\n const [isSearchOpen, setIsSearchOpen] = useState(!!search?.value);\n\n const onSearchEscape = () => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n setTimeout(() => searchButtonRef.current?.focus());\n };\n\n useEffect(() => {\n if (search?.value) {\n setIsSearchOpen(true);\n }\n }, [search?.value]);\n\n const [currentQueryOptionId, setCurrentQueryOptionId] = useState<QueryOptionId | null>(null);\n const queryOptionPopoverTarget = useRef<HTMLButtonElement>();\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!createNew?.onClick) return null;\n const text = createNew.label ?? t('create_new');\n\n return (\n <Button variant='simple' icon label={text} aria-label={text} onClick={createNew.onClick}>\n <Icon name='plus' />\n </Button>\n );\n }, [t, createNew, isSmallOrAbove]);\n\n useEscape(onSearchEscape, searchInputRef);\n const searchInput = useMemo(\n () => (\n <SearchInput\n {...search}\n onSearchSubmit={(value: string) => {\n search?.onSearchSubmit?.(value);\n onSearchEscape();\n }}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n onBlur={() => {\n if (!search?.value) {\n setIsSearchOpen(false);\n }\n }}\n ref={searchInputRef}\n />\n ),\n [search, onSearchEscape]\n );\n\n const searchLabel = t('search');\n const expandableSearch = useMemo(() => {\n return isSearchOpen ? (\n searchInput\n ) : (\n <Button\n variant='simple'\n icon\n label={searchLabel}\n onClick={() => {\n setIsSearchOpen(true);\n setTimeout(() => searchInputRef.current?.focus());\n }}\n onKeyDown={(e: KeyboardEvent<HTMLElement>) => {\n if (e.target !== searchInputRef.current && (e.key === 'Enter' || e.key === ' ')) {\n setIsSearchOpen(true);\n setTimeout(() => {\n searchInputRef.current?.focus();\n searchInputRef.current?.select();\n });\n }\n }}\n ref={searchButtonRef}\n >\n <Icon name='search' />\n </Button>\n );\n }, [searchLabel, setIsSearchOpen, isSearchOpen, searchInput]);\n\n let queryOptionPopover = null;\n if (currentQueryOptionId) {\n const queryOptionProps = { filter, sort, group }[currentQueryOptionId];\n if (\n queryOptionProps &&\n hasProp(queryOptionProps, 'renderer') &&\n queryOptionPopoverTarget.current\n ) {\n queryOptionPopover = (\n <StyledListToolbarDialog\n target={queryOptionPopoverTarget.current}\n heading={t(currentQueryOptionId)}\n placement='bottom-end'\n onCancel={() => {\n if (queryOptionProps.onCancel() === false) return;\n setCurrentQueryOptionId(null);\n }}\n onSubmit={() => {\n if (queryOptionProps.onSubmit() === false) return;\n setCurrentQueryOptionId(null);\n }}\n >\n <queryOptionProps.renderer />\n </StyledListToolbarDialog>\n );\n }\n }\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setCurrentQueryOptionId(id);\n queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(id),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n let labelText = name;\n\n if (viewSelector) {\n const viewItems = helpers.getViews(viewSelector.views);\n\n if (viewItems.length > 1) {\n const selectedViewName =\n helpers.getSelectedView(viewSelector.views)?.text ?? viewItems[0].text;\n\n labelText = `${name}: ${selectedViewName}`;\n }\n }\n\n return (\n <Flex data-testid={testIds.root} container {...restProps} as={StyledListToolbar} ref={ref}>\n <StyledListToolbarContent\n container={{ direction: 'column' }}\n ref={toolbarContentRef}\n item={{ grow: 1 }}\n >\n <Flex\n container={{\n alignItems: 'center',\n justify: 'between',\n gap: 0.5\n }}\n >\n <Flex\n container={{\n alignItems: 'center',\n gap: 1\n }}\n item={{ grow: 1 }}\n >\n <StyledHeadingText\n data-testid={testIds.heading}\n variant={headingTag}\n required={formControlProps?.required}\n aria-describedby={formControlProps?.info ? `${uid}-info` : undefined}\n >\n {formControlProps?.info && formControlProps.status === 'error' && (\n <>\n <StyledErrorIcon name='warn-solid' />\n <VisuallyHiddenText>{` ${t('error')} `}</VisuallyHiddenText>\n </>\n )}\n {!viewSelector || viewSelector.views.length <= 1 ? (\n labelText\n ) : (\n <>\n <MenuButton\n ref={setLabelEl}\n data-testid={testIds.viewSelector}\n variant='text'\n text={labelText}\n as={StyledViewSelector}\n menu={{\n mode: 'single-select',\n items: viewSelector.views.map(view => {\n if (hasProp(view, 'items')) {\n return {\n id: view.text,\n label: view.text,\n items: view.items.map(groupedView => {\n return {\n ...groupedView,\n primary: generateViewName(\n groupedView,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: groupedView.visual ? (\n <Avatar {...groupedView.visual} />\n ) : undefined\n };\n })\n };\n }\n\n return {\n ...view,\n primary: generateViewName(\n view,\n { default: t('default'), appDefault: t('app_default') },\n {\n defaultId: viewSelector.defaultId,\n appDefaultId: viewSelector.appDefaultId\n }\n ),\n visual: view.visual ? <Avatar {...view.visual} /> : undefined\n };\n }),\n onItemClick: viewSelector.onViewSelect\n }}\n />\n {labelEl && (\n <Tooltip target={labelEl} describeTarget={false} hideDelay='none' smart>\n {labelText}\n </Tooltip>\n )}\n </>\n )}\n </StyledHeadingText>\n {formControlProps?.additionalInfo && (\n <AdditionalInfo\n heading={formControlProps.additionalInfo.heading}\n contextualLabel={labelText}\n >\n {formControlProps.additionalInfo.content}\n </AdditionalInfo>\n )}\n {isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </Flex>\n <>\n {isSmallOrAbove && additionalActions}\n {search && isSmallOrAbove && expandableSearch}\n {isSmallOrAbove && createNewButton}\n {isSmallOrAbove && basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n {!isSmallOrAbove && count && <CountMeta data-testid={testIds.count} count={count} />}\n </>\n </Flex>\n {!isSmallOrAbove && (\n <>\n {!!count?.selected && additionalActions}\n <StyledSearchContainer\n container={{ alignItems: 'start', justify: 'between', gap: 1 }}\n >\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 1 }}\n item={{ grow: 1 }}\n >\n {search && searchInput}\n </Flex>\n {createNewButton}\n {basicModeActions && (\n <Actions\n items={basicModeActions.map(({ icon, ...restActionProps }) => ({\n ...restActionProps,\n visual: icon && <Icon name={icon} />\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n </StyledSearchContainer>\n </>\n )}\n {formControlProps?.info && (\n <StyledInfo\n role={\n formControlProps.status === 'error' || formControlProps.status === 'warning'\n ? 'alert'\n : undefined\n }\n id={`${uid}-info`}\n data-testid={testIds.info}\n status={formControlProps.status}\n >\n {formControlProps.info}\n </StyledInfo>\n )}\n </StyledListToolbarContent>\n\n {queryOptionPopover}\n\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n </Flex>\n );\n }\n);\n\nexport default withTestIds(ListToolbar, getListToolbarTestIds);\n"]}
@@ -11,7 +11,6 @@ export declare const StyledHeadingText: import("styled-components").StyledCompon
11
11
  required?: boolean | undefined;
12
12
  }, never>;
13
13
  export declare const StyledCountMeta: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Text").TextProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
14
- export declare const StyledContainer: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Flex").FlexProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
15
14
  export declare const StyledInfo: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Pick<FormControlProps, "status">, never>;
16
15
  export declare const StyledSearchContainer: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Flex").FlexProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
17
16
  //# sourceMappingURL=ListToolbar.styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAWvD,eAAO,MAAM,gBAAgB,yGAK5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;cAA6B,OAAO;SA0BjE,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAI9C,eAAO,MAAM,uBAAuB,uuJAKlC,CAAC;AAIH,eAAO,MAAM,wBAAwB,iMAQnC,CAAC;AAIH,eAAO,MAAM,eAAe,0KAI3B,CAAC;AAIF,eAAO,MAAM,iBAAiB;;SAgC5B,CAAC;AAIH,eAAO,MAAM,eAAe,iMAW1B,CAAC;AAIH,eAAO,MAAM,eAAe,iMAc1B,CAAC;AAIH,eAAO,MAAM,UAAU,uIAatB,CAAC;AAIF,eAAO,MAAM,qBAAqB,iMASjC,CAAC"}
1
+ {"version":3,"file":"ListToolbar.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAWvD,eAAO,MAAM,gBAAgB,yGAK5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;cAA6B,OAAO;SA6BjE,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAE7B,CAAC;AAIF,eAAO,MAAM,uBAAuB,uuJAKlC,CAAC;AAIH,eAAO,MAAM,wBAAwB,iMAQnC,CAAC;AAIH,eAAO,MAAM,eAAe,0KAI3B,CAAC;AAIF,eAAO,MAAM,iBAAiB;;SAiC5B,CAAC;AAIH,eAAO,MAAM,eAAe,iMAa1B,CAAC;AAIH,eAAO,MAAM,UAAU,uIAatB,CAAC;AAIF,eAAO,MAAM,qBAAqB,iMASjC,CAAC"}
@@ -21,7 +21,10 @@ export const StyledViewSelector = styled.button(({ theme, required }) => {
21
21
  return css `
22
22
  flex-shrink: initial;
23
23
  white-space: initial;
24
+ max-width: 100%;
25
+
24
26
  ${StyledText} {
27
+ white-space: nowrap;
25
28
  font-size: ${fontSizes[theme.components.text.h3['font-size']]};
26
29
  font-weight: ${theme.components.text.h3['font-weight']};
27
30
  line-height: ${hitAreaMouse};
@@ -40,7 +43,9 @@ export const StyledViewSelector = styled.button(({ theme, required }) => {
40
43
  `;
41
44
  });
42
45
  StyledViewSelector.defaultProps = defaultThemeProp;
43
- export const StyledListToolbar = styled.div ``;
46
+ export const StyledListToolbar = styled.div `
47
+ width: 100%;
48
+ `;
44
49
  StyledListToolbar.defaultProps = defaultThemeProp;
45
50
  export const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {
46
51
  return css `
@@ -68,6 +73,7 @@ export const StyledHeadingText = styled(Text)(({ theme, required }) => {
68
73
  const hitAreaMouse = theme.base['hit-area']['mouse-min'];
69
74
  const hitAreaFinger = theme.base['hit-area']['finger-min'];
70
75
  return css `
76
+ min-width: 0;
71
77
  position: relative;
72
78
  line-height: ${hitAreaMouse};
73
79
  word-break: break-word;
@@ -101,6 +107,8 @@ export const StyledCountMeta = styled(Text)(({ theme }) => {
101
107
  const hitAreaFinger = theme.base['hit-area']['finger-min'];
102
108
  return css `
103
109
  line-height: ${hitAreaMouse};
110
+ white-space: nowrap;
111
+ margin-inline-end: ${theme.base.spacing};
104
112
 
105
113
  @media (pointer: coarse) {
106
114
  line-height: ${hitAreaFinger};
@@ -108,22 +116,6 @@ export const StyledCountMeta = styled(Text)(({ theme }) => {
108
116
  `;
109
117
  });
110
118
  StyledCountMeta.defaultProps = defaultThemeProp;
111
- export const StyledContainer = styled(Flex)(({ theme }) => {
112
- return css `
113
- margin-block-end: ${theme.base.spacing};
114
-
115
- @media (pointer: coarse) {
116
- overflow: hidden;
117
-
118
- ${StyledHeadingText}, ${StyledViewSelector} ${StyledText} {
119
- white-space: nowrap;
120
- overflow: hidden;
121
- text-overflow: ellipsis;
122
- }
123
- }
124
- `;
125
- });
126
- StyledContainer.defaultProps = defaultThemeProp;
127
119
  export const StyledInfo = styled.div(({ status, theme: { components: { 'form-field': formField } } }) => css `
128
120
  ${status &&
129
121
  formField[status] &&
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,iBAAiB;;;;CAIpB,CAAC;AAEF,MAAM,CAAC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,EAAE,KAAK,EAAE,EAAE,EAAE,CACZ,GAAG,CAAA;sBACe,KAAK,CAAC,IAAI,CAAC,OAAO;;QAEhC,iBAAiB;;;KAGpB,CACJ,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport type { FormControlProps } from '../FormControl';\nimport Icon from '../Icon';\nimport Flex from '../Flex';\nimport { StyledSearchInput } from '../SearchInput';\nimport Text, { StyledText } from '../Text';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport { StyledButton } from '../Button';\nimport FormDialog from '../Dialog/FormDialog';\n\nexport const StyledSearchForm = styled.div`\n ${StyledSearchInput} {\n flex-grow: 1;\n max-width: min(100%, 40ch);\n }\n`;\n\nexport const StyledViewSelector = styled.button<{ required: boolean }>(({ theme, required }) => {\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n flex-shrink: initial;\n white-space: initial;\n ${StyledText} {\n font-size: ${fontSizes[theme.components.text.h3['font-size'] as FontSize]};\n font-weight: ${theme.components.text.h3['font-weight']};\n line-height: ${hitAreaMouse};\n word-break: break-word;\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n }\n\n ${StyledText}::after {\n display: ${required ? 'inline-block' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledViewSelector.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbar = styled.div``;\n\nStyledListToolbar.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {\n return css`\n min-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));\n max-width: calc(100vw - 4 * ${theme.base.spacing});\n `;\n});\n\nStyledListToolbarDialog.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarContent = styled(Flex)(({ theme }) => {\n return css`\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n margin-block-start: ${theme.base.spacing};\n `;\n});\n\nStyledListToolbarContent.defaultProps = defaultThemeProp;\n\nexport const StyledErrorIcon = styled(Icon)(\n ({ theme }) => css`\n color: ${theme.base.palette.urgent};\n `\n);\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledHeadingText = styled(Text)<{ required?: boolean }>(({ theme, required }) => {\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n position: relative;\n line-height: ${hitAreaMouse};\n word-break: break-word;\n display: flex;\n align-items: center;\n ${required &&\n css`\n padding-inline-end: calc(1.5 * ${theme.base.spacing});\n `}\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n position: absolute;\n inset-inline-end: 0;\n inset-block-start: 0;\n }\n\n ${StyledErrorIcon} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledHeadingText.defaultProps = defaultThemeProp;\n\nexport const StyledCountMeta = styled(Text)(({ theme }) => {\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n line-height: ${hitAreaMouse};\n\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n `;\n});\n\nStyledCountMeta.defaultProps = defaultThemeProp;\n\nexport const StyledContainer = styled(Flex)(({ theme }) => {\n return css`\n margin-block-end: ${theme.base.spacing};\n\n @media (pointer: coarse) {\n overflow: hidden;\n\n ${StyledHeadingText}, ${StyledViewSelector} ${StyledText} {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n `;\n});\n\nStyledContainer.defaultProps = defaultThemeProp;\n\nexport const StyledInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n components: { 'form-field': formField }\n }\n }) => css`\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `\n);\n\nStyledInfo.defaultProps = defaultThemeProp;\n\nexport const StyledSearchContainer = styled(Flex)(\n ({ theme }) =>\n css`\n margin-block: ${theme.base.spacing};\n\n ${StyledSearchInput} {\n max-width: 100%;\n }\n `\n);\n\nStyledSearchContainer.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,iBAAiB;;;;CAIpB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAwB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7F,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,C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,EAAE,EAAE,EAAE;IACxD,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC;IAE3D,OAAO,GAAG,CAAA;mBACO,YAAY;;yBAEN,KAAK,CAAC,IAAI,CAAC,OAAO;;;qBAGtB,aAAa;;GAE/B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAClC,CAAC,EACC,MAAM,EACN,KAAK,EAAE,EACL,UAAU,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,EACxC,EACF,EAAE,EAAE,CAAC,GAAG,CAAA;MACL,MAAM;IACR,SAAS,CAAC,MAAM,CAAC;IACjB,GAAG,CAAA;eACQ,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;KAC3C;GACF,CACF,CAAC;AAEF,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,CAC/C,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACZ,GAAG,CAAA;sBACe,KAAK,CAAC,IAAI,CAAC,OAAO;;QAEhC,iBAAiB;;;KAGpB,CACJ,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport type { FormControlProps } from '../FormControl';\nimport Icon from '../Icon';\nimport Flex from '../Flex';\nimport { StyledSearchInput } from '../SearchInput';\nimport Text, { StyledText } from '../Text';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport { StyledButton } from '../Button';\nimport FormDialog from '../Dialog/FormDialog';\n\nexport const StyledSearchForm = styled.div`\n ${StyledSearchInput} {\n flex-grow: 1;\n max-width: min(100%, 40ch);\n }\n`;\n\nexport const StyledViewSelector = styled.button<{ required: boolean }>(({ theme, required }) => {\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n flex-shrink: initial;\n white-space: initial;\n max-width: 100%;\n\n ${StyledText} {\n white-space: nowrap;\n font-size: ${fontSizes[theme.components.text.h3['font-size'] as FontSize]};\n font-weight: ${theme.components.text.h3['font-weight']};\n line-height: ${hitAreaMouse};\n word-break: break-word;\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n }\n\n ${StyledText}::after {\n display: ${required ? 'inline-block' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledViewSelector.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbar = styled.div`\n width: 100%;\n`;\n\nStyledListToolbar.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {\n return css`\n min-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));\n max-width: calc(100vw - 4 * ${theme.base.spacing});\n `;\n});\n\nStyledListToolbarDialog.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarContent = styled(Flex)(({ theme }) => {\n return css`\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n margin-block-start: ${theme.base.spacing};\n `;\n});\n\nStyledListToolbarContent.defaultProps = defaultThemeProp;\n\nexport const StyledErrorIcon = styled(Icon)(\n ({ theme }) => css`\n color: ${theme.base.palette.urgent};\n `\n);\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledHeadingText = styled(Text)<{ required?: boolean }>(({ theme, required }) => {\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n min-width: 0;\n position: relative;\n line-height: ${hitAreaMouse};\n word-break: break-word;\n display: flex;\n align-items: center;\n ${required &&\n css`\n padding-inline-end: calc(1.5 * ${theme.base.spacing});\n `}\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n position: absolute;\n inset-inline-end: 0;\n inset-block-start: 0;\n }\n\n ${StyledErrorIcon} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledHeadingText.defaultProps = defaultThemeProp;\n\nexport const StyledCountMeta = styled(Text)(({ theme }) => {\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n line-height: ${hitAreaMouse};\n white-space: nowrap;\n margin-inline-end: ${theme.base.spacing};\n\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n `;\n});\n\nStyledCountMeta.defaultProps = defaultThemeProp;\n\nexport const StyledInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n components: { 'form-field': formField }\n }\n }) => css`\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `\n);\n\nStyledInfo.defaultProps = defaultThemeProp;\n\nexport const StyledSearchContainer = styled(Flex)(\n ({ theme }) =>\n css`\n margin-block: ${theme.base.spacing};\n\n ${StyledSearchInput} {\n max-width: 100%;\n }\n `\n);\n\nStyledSearchContainer.defaultProps = defaultThemeProp;\n"]}
@@ -32,7 +32,7 @@ export interface TooltipProps extends BaseProps, TestIdProp {
32
32
  */
33
33
  placement?: PopoverProps['placement'];
34
34
  /**
35
- * Conditionally renders a tooltip only if the associated element's text content is truncated.
35
+ * Conditionally renders a tooltip only if the associated element's (or its descendants) text content is truncated.
36
36
  * To work, the associated element must be be displayed as a CSS "block box" i.e. block, inline-block, etc...
37
37
  * @default false
38
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvE,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAOtD,MAAM,WAAW,YAAa,SAAQ,SAAS,EAAE,UAAU;IACzD,oCAAoC;IACpC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,gDAAgD;IAChD,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,aAAa,yGAaxB,CAAC;;;;AA2IH,wBAAuD"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvE,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAOtD,MAAM,WAAW,YAAa,SAAQ,SAAS,EAAE,UAAU;IACzD,oCAAoC;IACpC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,gDAAgD;IAChD,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,aAAa,yGAaxB,CAAC;;;;AAwJH,wBAAuD"}
@@ -5,7 +5,7 @@ import { defaultThemeProp } from '../../theme';
5
5
  import Popover from '../Popover';
6
6
  import { useConsolidatedRef, useTestIds, useUID } from '../../hooks';
7
7
  import { calculateFontSize } from '../../styles';
8
- import { getActiveElement, mouseState, withTestIds } from '../../utils';
8
+ import { getActiveElement, mouseState, testElForOverflow, withTestIds } from '../../utils';
9
9
  import { getTooltipTestIds } from './Tooltip.test-ids';
10
10
  export const StyledTooltip = styled.div(({ theme }) => {
11
11
  const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);
@@ -37,10 +37,19 @@ const Tooltip = forwardRef(function Tooltip({ testId, children, target, showDela
37
37
  if (!target)
38
38
  return;
39
39
  const showTooltip = () => {
40
- setShow(
41
40
  // This approach may result in a tooltip NOT appearing 1px before it should due to browser specifics. Enhance as needed.
42
41
  // https://stackoverflow.com/a/64747288
43
- smart ? target.scrollWidth > target.clientWidth : true);
42
+ const checkTruncation = (element) => {
43
+ if (testElForOverflow(element).some(Boolean) &&
44
+ !['absolute', 'fixed'].includes(window.getComputedStyle(element).position))
45
+ return true;
46
+ for (const child of element.children) {
47
+ if (checkTruncation(child))
48
+ return true;
49
+ }
50
+ return false;
51
+ };
52
+ setShow(smart ? checkTruncation(target) : true);
44
53
  };
45
54
  const onFocusIn = () => {
46
55
  showTooltip();
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAyCvD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC;aACvD,KAAK,CAAC,UAAU,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CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEnC,OAAO,CACL,KAAC,OAAO,mBACO,OAAO,CAAC,IAAI,EACzB,EAAE,EAAE,EAAE,KACF,SAAS,EACb,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAC,OAAO,EAChB,EAAE,EAAE,aAAa,EACjB,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,MAAM,EACd,KAAK,QACL,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,kBAAkB,QAClB,GAAG,EAAE,UAAU,YAEd,QAAQ,GACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, MutableRefObject, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { BaseProps, ForwardProps, TestIdProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Popover from '../Popover';\nimport type { Delay, PopoverProps } from '../Popover';\nimport { useConsolidatedRef, useTestIds, useUID } from '../../hooks';\nimport { calculateFontSize } from '../../styles';\nimport { getActiveElement, mouseState, withTestIds } from '../../utils';\n\nimport { getTooltipTestIds } from './Tooltip.test-ids';\n\nexport interface TooltipProps extends BaseProps, TestIdProp {\n /** Text content for the tooltip. */\n children: string | string[];\n /** Element to serve as the tooltip's target. */\n target: Element | null;\n /**\n * Delay showing the tooltip on mouseenter.\n * @default 'short'\n */\n showDelay?: Delay;\n /**\n * Delay hiding the tooltip on mouseleave.\n * @default 'long'\n */\n hideDelay?: Delay;\n /**\n * If true, the Tooltip will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default true\n */\n portal?: PopoverProps['portal'];\n /**\n * If true, the Tooltip will automatically apply an aria-describedby attribute to its target.\n * @default true\n */\n describeTarget?: boolean;\n /**\n * Sets the placement of the tooltip relative to the target.\n * @default 'bottom'\n */\n placement?: PopoverProps['placement'];\n /**\n * Conditionally renders a tooltip only if the associated element's text content is truncated.\n * To work, the associated element must be be displayed as a CSS \"block box\" i.e. block, inline-block, etc...\n * @default false\n */\n smart?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTooltip = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n background-color: ${theme.components.tooltip['background-color']};\n color: ${theme.components.tooltip['foreground-color']};\n font-size: ${fontSize.xxs};\n max-width: 40ch;\n padding: ${theme.base.spacing};\n white-space: pre-line;\n word-break: break-word;\n pointer-events: none;\n `;\n});\n\nStyledTooltip.defaultProps = defaultThemeProp;\n\nconst Tooltip: FunctionComponent<TooltipProps & ForwardProps> = forwardRef(function Tooltip(\n {\n testId,\n children,\n target,\n showDelay = 'short',\n hideDelay = 'long',\n placement = 'bottom',\n describeTarget = true,\n smart,\n ...restProps\n }: PropsWithoutRef<TooltipProps>,\n ref: Ref<HTMLDivElement>\n) {\n const id = useUID();\n const [show, setShow] = useState(false);\n const tooltipRef = useConsolidatedRef(ref);\n const lastClickedRef: MutableRefObject<EventTarget | null> = useRef(null);\n const testIds = useTestIds(testId, getTooltipTestIds);\n\n const onMouseDown = useCallback(\n ({ target: eTarget }: MouseEvent) => {\n lastClickedRef.current = eTarget;\n if (eTarget === tooltipRef.current || eTarget === target) return;\n setShow(false);\n },\n [target]\n );\n\n useEffect(() => {\n if (!target) return;\n\n const showTooltip = () => {\n setShow(\n // This approach may result in a tooltip NOT appearing 1px before it should due to browser specifics. Enhance as needed.\n // https://stackoverflow.com/a/64747288\n smart ? target.scrollWidth > target.clientWidth : true\n );\n };\n\n const onFocusIn = () => {\n showTooltip();\n };\n\n const onFocusOut = () => {\n if (!lastClickedRef.current || lastClickedRef.current !== tooltipRef.current) {\n setShow(false);\n }\n lastClickedRef.current = null;\n };\n\n const onMouseEnter = () => {\n if (mouseState.primary) {\n return;\n }\n\n showTooltip();\n };\n\n const onMouseLeave = () => {\n if (getActiveElement() !== target) {\n setShow(false);\n }\n };\n\n const onKeyDown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape' && getActiveElement() === target) {\n setShow(false);\n }\n };\n\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onMouseDown);\n\n target.addEventListener('focusin', onFocusIn);\n target.addEventListener('focusout', onFocusOut);\n target.addEventListener('mouseenter', onMouseEnter);\n target.addEventListener('mouseleave', onMouseLeave);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onMouseDown);\n\n target.removeEventListener('focusin', onFocusIn);\n target.removeEventListener('focusout', onFocusOut);\n target.removeEventListener('mouseenter', onMouseEnter);\n target.removeEventListener('mouseleave', onMouseLeave);\n };\n }, [target, onMouseDown, smart]);\n\n useEffect(() => {\n if (target && describeTarget && show) {\n const describedBy = target.getAttribute('aria-describedby');\n // Set the attribute to the old attribute plus the id\n target.setAttribute('aria-describedby', describedBy ? `${describedBy} ${id}` : id);\n } else if (target) {\n // Get the old attribute\n const describedBy = target.getAttribute('aria-describedby');\n if (describedBy) {\n // If the old attribute matches the id just remove it entirely\n if (describedBy === id) {\n target.removeAttribute('aria-describedby');\n } else {\n // Otherwise we want to just remove the id that was added and reset the attribute to what it was before\n const oldDescribedBy = describedBy.replace(new RegExp(`(?:^|\\\\s+)${id}`), '');\n target.setAttribute('aria-describedby', oldDescribedBy);\n }\n }\n }\n }, [describeTarget, target, show]);\n\n return (\n <Popover\n data-testid={testIds.root}\n id={id}\n {...restProps}\n show={show}\n showDelay={showDelay}\n hideDelay={hideDelay}\n groupId='tooltip'\n strategy='fixed'\n as={StyledTooltip}\n role='tooltip'\n target={target}\n arrow\n placement={placement}\n onMouseDown={onMouseDown}\n hideOnTargetHidden\n ref={tooltipRef}\n >\n {children}\n </Popover>\n );\n});\n\nexport default withTestIds(Tooltip, getTooltipTestIds);\n"]}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAyCvD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC;aACvD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC;iBACxC,QAAQ,CAAC,GAAG;;eAEd,KAAK,CAAC,IAAI,CAAC,OAAO;;;;GAI9B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE9C,MAAM,OAAO,GAAmD,UAAU,CAAC,SAAS,O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cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC9E,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;iBACzD;aACF;SACF;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEnC,OAAO,CACL,KAAC,OAAO,mBACO,OAAO,CAAC,IAAI,EACzB,EAAE,EAAE,EAAE,KACF,SAAS,EACb,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAC,OAAO,EAChB,EAAE,EAAE,aAAa,EACjB,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,MAAM,EACd,KAAK,QACL,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,kBAAkB,QAClB,GAAG,EAAE,UAAU,YAEd,QAAQ,GACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, MutableRefObject, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { BaseProps, ForwardProps, TestIdProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Popover from '../Popover';\nimport type { Delay, PopoverProps } from '../Popover';\nimport { useConsolidatedRef, useTestIds, useUID } from '../../hooks';\nimport { calculateFontSize } from '../../styles';\nimport { getActiveElement, mouseState, testElForOverflow, withTestIds } from '../../utils';\n\nimport { getTooltipTestIds } from './Tooltip.test-ids';\n\nexport interface TooltipProps extends BaseProps, TestIdProp {\n /** Text content for the tooltip. */\n children: string | string[];\n /** Element to serve as the tooltip's target. */\n target: Element | null;\n /**\n * Delay showing the tooltip on mouseenter.\n * @default 'short'\n */\n showDelay?: Delay;\n /**\n * Delay hiding the tooltip on mouseleave.\n * @default 'long'\n */\n hideDelay?: Delay;\n /**\n * If true, the Tooltip will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default true\n */\n portal?: PopoverProps['portal'];\n /**\n * If true, the Tooltip will automatically apply an aria-describedby attribute to its target.\n * @default true\n */\n describeTarget?: boolean;\n /**\n * Sets the placement of the tooltip relative to the target.\n * @default 'bottom'\n */\n placement?: PopoverProps['placement'];\n /**\n * Conditionally renders a tooltip only if the associated element's (or its descendants) text content is truncated.\n * To work, the associated element must be be displayed as a CSS \"block box\" i.e. block, inline-block, etc...\n * @default false\n */\n smart?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTooltip = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n background-color: ${theme.components.tooltip['background-color']};\n color: ${theme.components.tooltip['foreground-color']};\n font-size: ${fontSize.xxs};\n max-width: 40ch;\n padding: ${theme.base.spacing};\n white-space: pre-line;\n word-break: break-word;\n pointer-events: none;\n `;\n});\n\nStyledTooltip.defaultProps = defaultThemeProp;\n\nconst Tooltip: FunctionComponent<TooltipProps & ForwardProps> = forwardRef(function Tooltip(\n {\n testId,\n children,\n target,\n showDelay = 'short',\n hideDelay = 'long',\n placement = 'bottom',\n describeTarget = true,\n smart,\n ...restProps\n }: PropsWithoutRef<TooltipProps>,\n ref: Ref<HTMLDivElement>\n) {\n const id = useUID();\n const [show, setShow] = useState(false);\n const tooltipRef = useConsolidatedRef(ref);\n const lastClickedRef: MutableRefObject<EventTarget | null> = useRef(null);\n const testIds = useTestIds(testId, getTooltipTestIds);\n\n const onMouseDown = useCallback(\n ({ target: eTarget }: MouseEvent) => {\n lastClickedRef.current = eTarget;\n if (eTarget === tooltipRef.current || eTarget === target) return;\n setShow(false);\n },\n [target]\n );\n\n useEffect(() => {\n if (!target) return;\n\n const showTooltip = () => {\n // This approach may result in a tooltip NOT appearing 1px before it should due to browser specifics. Enhance as needed.\n // https://stackoverflow.com/a/64747288\n\n const checkTruncation = (element: Element): boolean => {\n if (\n testElForOverflow(element).some(Boolean) &&\n !['absolute', 'fixed'].includes(window.getComputedStyle(element).position)\n )\n return true;\n\n for (const child of element.children) {\n if (checkTruncation(child)) return true;\n }\n\n return false;\n };\n\n setShow(smart ? checkTruncation(target) : true);\n };\n\n const onFocusIn = () => {\n showTooltip();\n };\n\n const onFocusOut = () => {\n if (!lastClickedRef.current || lastClickedRef.current !== tooltipRef.current) {\n setShow(false);\n }\n lastClickedRef.current = null;\n };\n\n const onMouseEnter = () => {\n if (mouseState.primary) {\n return;\n }\n\n showTooltip();\n };\n\n const onMouseLeave = () => {\n if (getActiveElement() !== target) {\n setShow(false);\n }\n };\n\n const onKeyDown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape' && getActiveElement() === target) {\n setShow(false);\n }\n };\n\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onMouseDown);\n\n target.addEventListener('focusin', onFocusIn);\n target.addEventListener('focusout', onFocusOut);\n target.addEventListener('mouseenter', onMouseEnter);\n target.addEventListener('mouseleave', onMouseLeave);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onMouseDown);\n\n target.removeEventListener('focusin', onFocusIn);\n target.removeEventListener('focusout', onFocusOut);\n target.removeEventListener('mouseenter', onMouseEnter);\n target.removeEventListener('mouseleave', onMouseLeave);\n };\n }, [target, onMouseDown, smart]);\n\n useEffect(() => {\n if (target && describeTarget && show) {\n const describedBy = target.getAttribute('aria-describedby');\n // Set the attribute to the old attribute plus the id\n target.setAttribute('aria-describedby', describedBy ? `${describedBy} ${id}` : id);\n } else if (target) {\n // Get the old attribute\n const describedBy = target.getAttribute('aria-describedby');\n if (describedBy) {\n // If the old attribute matches the id just remove it entirely\n if (describedBy === id) {\n target.removeAttribute('aria-describedby');\n } else {\n // Otherwise we want to just remove the id that was added and reset the attribute to what it was before\n const oldDescribedBy = describedBy.replace(new RegExp(`(?:^|\\\\s+)${id}`), '');\n target.setAttribute('aria-describedby', oldDescribedBy);\n }\n }\n }\n }, [describeTarget, target, show]);\n\n return (\n <Popover\n data-testid={testIds.root}\n id={id}\n {...restProps}\n show={show}\n showDelay={showDelay}\n hideDelay={hideDelay}\n groupId='tooltip'\n strategy='fixed'\n as={StyledTooltip}\n role='tooltip'\n target={target}\n arrow\n placement={placement}\n onMouseDown={onMouseDown}\n hideOnTargetHidden\n ref={tooltipRef}\n >\n {children}\n </Popover>\n );\n});\n\nexport default withTestIds(Tooltip, getTooltipTestIds);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "6.1.2",
3
+ "version": "6.2.0",
4
4
  "description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
5
5
  "repository": {
6
6
  "type": "git",