@pega/cosmos-react-core 10.0.0-build.10.2 → 10.0.0-build.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/DateTime/DateTimeDisplay.d.ts +6 -0
- package/lib/components/DateTime/DateTimeDisplay.d.ts.map +1 -1
- package/lib/components/DateTime/DateTimeDisplay.js +6 -2
- package/lib/components/DateTime/DateTimeDisplay.js.map +1 -1
- package/lib/components/DateTime/utils.d.ts +7 -1
- package/lib/components/DateTime/utils.d.ts.map +1 -1
- package/lib/components/DateTime/utils.js +21 -4
- package/lib/components/DateTime/utils.js.map +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapseButton.d.ts.map +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapseButton.js +3 -9
- package/lib/components/ExpandCollapse/ExpandCollapseButton.js.map +1 -1
- package/lib/components/LiveLog/LiveLog.d.ts.map +1 -1
- package/lib/components/LiveLog/LiveLog.js +1 -1
- package/lib/components/LiveLog/LiveLog.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,12 @@ export interface DateTimeDisplayProps extends BaseProps {
|
|
|
21
21
|
* preserve backwards compatibility with callers that pass pre-converted values.
|
|
22
22
|
*/
|
|
23
23
|
timeZone?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Appends the timezone abbreviation after the value for the `datetime` variant. Requires a valid
|
|
26
|
+
* `timeZone`; ignored otherwise.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
showTimeZone?: boolean;
|
|
24
30
|
/** Ref for the wrapping element. */
|
|
25
31
|
ref?: Ref<HTMLTimeElement>;
|
|
26
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/DateTimeDisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,K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ACxB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,mOAAgB,CAAC;AAEnD,QAAA,MAAM,eAAe,EAAE,+BAA+B,CAAC,oBAAoB,CA6E1E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -8,12 +8,14 @@ import { getValidTimeZone, parseToDate } from './Input/utils';
|
|
|
8
8
|
import { isValidDate } from './Picker/utils';
|
|
9
9
|
import { formatDateTime } from './utils';
|
|
10
10
|
export const StyledDateTimeDisplay = styled.time ``;
|
|
11
|
-
const DateTimeDisplay = forwardRef(function DateTimeDisplay({ value, variant, format = 'medium', clockFormat, timeZone, ...restProps }, ref) {
|
|
11
|
+
const DateTimeDisplay = forwardRef(function DateTimeDisplay({ value, variant, format = 'medium', clockFormat, timeZone, showTimeZone = false, ...restProps }, ref) {
|
|
12
12
|
const { locale } = useConfiguration();
|
|
13
13
|
const t = useI18n();
|
|
14
14
|
const parsedDate = value || value === 0 ? parseToDate(value) : undefined;
|
|
15
15
|
const hasValue = !!parsedDate && isValidDate(parsedDate);
|
|
16
16
|
const resolvedTimeZone = useMemo(() => getValidTimeZone(timeZone) ?? 'UTC', [timeZone]);
|
|
17
|
+
// The timezone is only shown when the caller supplied a valid one; the UTC fallback is not shown.
|
|
18
|
+
const shouldShowTimeZone = showTimeZone && !!getValidTimeZone(timeZone);
|
|
17
19
|
const displayText = hasValue
|
|
18
20
|
? cap(formatDateTime(parsedDate, {
|
|
19
21
|
t,
|
|
@@ -21,7 +23,8 @@ const DateTimeDisplay = forwardRef(function DateTimeDisplay({ value, variant, fo
|
|
|
21
23
|
format,
|
|
22
24
|
variant,
|
|
23
25
|
clockFormat,
|
|
24
|
-
timeZone: resolvedTimeZone
|
|
26
|
+
timeZone: resolvedTimeZone,
|
|
27
|
+
showTimeZone: shouldShowTimeZone
|
|
25
28
|
}))
|
|
26
29
|
: undefined;
|
|
27
30
|
// Abbreviated month names (e.g. "Oct") read phonetically to screen readers, so an
|
|
@@ -36,6 +39,7 @@ const DateTimeDisplay = forwardRef(function DateTimeDisplay({ value, variant, fo
|
|
|
36
39
|
variant,
|
|
37
40
|
clockFormat,
|
|
38
41
|
timeZone: resolvedTimeZone,
|
|
42
|
+
showTimeZone: shouldShowTimeZone,
|
|
39
43
|
abbreviated: false
|
|
40
44
|
}))
|
|
41
45
|
: displayText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeDisplay.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTimeDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"DateTimeDisplay.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTimeDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,OAAO,MAA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CACH;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,kFAAkF;IAClF,oFAAoF;IACpF,sFAAsF;IACtF,0EAA0E;IAC1E,MAAM,cAAc,GAClB,QAAQ,IAAI,MAAM,KAAK,QAAQ;QAC7B,CAAC,CAAC,GAAG,CACD,cAAc,CAAC,UAAU,EAAE;YACzB,CAAC;YACD,MAAM;YACN,MAAM;YACN,OAAO;YACP,WAAW;YACX,QAAQ,EAAE,gBAAgB;YAC1B,YAAY,EAAE,kBAAkB;YAChC,WAAW,EAAE,KAAK;SACnB,CAAC,CACH;QACH,CAAC,CAAC,WAAW,CAAC;IAElB,IAAI,OAAO,GAAG,KAAC,OAAO,KAAG,CAAC;IAC1B,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,WAAW,KAAK,cAAc,CAAC,CAAC,CAAC,CAC/B,6BAAkB,cAAc,YAAG,WAAW,GAAQ,CACvD,CAAC,CAAC,CAAC,CACF,4BAAG,WAAW,GAAI,CACnB,CAAC;IACN,CAAC;IAED,OAAO,CACL,KAAC,qBAAqB,IACpB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,KACrD,SAAS,YAEZ,OAAO,GACc,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, useMemo } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled from 'styled-components';\n\nimport type { BaseProps, ForwardRefForwardPropsComponent } from '../../types';\nimport { useConfiguration, useI18n } from '../../hooks';\nimport NoValue from '../NoValue/NoValue';\nimport cap from '../../utils/cap';\n\nimport type { DateTimeFormat, DateTimeVariant } from './DateTime.types';\nimport { getValidTimeZone, 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 /**\n * IANA timezone identifier (e.g. 'America/New_York', 'Europe/Paris').\n * When provided all screens will render the value in this timezone regardless\n * of the browser locale. When omitted the component defaults to UTC to\n * preserve backwards compatibility with callers that pass pre-converted values.\n */\n timeZone?: string;\n /**\n * Appends the timezone abbreviation after the value for the `datetime` variant. Requires a valid\n * `timeZone`; ignored otherwise.\n * @default false\n */\n showTimeZone?: boolean;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLTimeElement>;\n}\n\nexport const StyledDateTimeDisplay = styled.time``;\n\nconst DateTimeDisplay: ForwardRefForwardPropsComponent<DateTimeDisplayProps> = forwardRef(\n function DateTimeDisplay(\n {\n value,\n variant,\n format = 'medium',\n clockFormat,\n timeZone,\n showTimeZone = false,\n ...restProps\n }: PropsWithoutRef<DateTimeDisplayProps>,\n ref: DateTimeDisplayProps['ref']\n ) {\n const { locale } = useConfiguration();\n const t = useI18n();\n\n const parsedDate = value || value === 0 ? parseToDate(value) : undefined;\n const hasValue = !!parsedDate && isValidDate(parsedDate);\n\n const resolvedTimeZone = useMemo(() => getValidTimeZone(timeZone) ?? 'UTC', [timeZone]);\n // The timezone is only shown when the caller supplied a valid one; the UTC fallback is not shown.\n const shouldShowTimeZone = showTimeZone && !!getValidTimeZone(timeZone);\n\n const displayText = hasValue\n ? cap(\n formatDateTime(parsedDate, {\n t,\n locale,\n format,\n variant,\n clockFormat,\n timeZone: resolvedTimeZone,\n showTimeZone: shouldShowTimeZone\n })\n )\n : undefined;\n\n // Abbreviated month names (e.g. \"Oct\") read phonetically to screen readers, so an\n // accessible, fully expanded label (e.g. \"October\") is exposed via aria-label while\n // the visible, abbreviated text stays unchanged. Only 'medium' format ever renders an\n // abbreviated month name, so other formats simply reuse the display text.\n const accessibleText =\n hasValue && format === 'medium'\n ? cap(\n formatDateTime(parsedDate, {\n t,\n locale,\n format,\n variant,\n clockFormat,\n timeZone: resolvedTimeZone,\n showTimeZone: shouldShowTimeZone,\n abbreviated: false\n })\n )\n : displayText;\n\n let content = <NoValue />;\n if (hasValue) {\n content =\n displayText !== accessibleText ? (\n <abbr aria-label={accessibleText}>{displayText}</abbr>\n ) : (\n <>{displayText}</>\n );\n }\n\n return (\n <StyledDateTimeDisplay\n ref={ref}\n dateTime={hasValue ? parsedDate.toISOString() : undefined}\n {...restProps}\n >\n {content}\n </StyledDateTimeDisplay>\n );\n }\n);\n\nexport default DateTimeDisplay;\n"]}
|
|
@@ -7,6 +7,12 @@ type DateTimeFormatOptions<F extends DateTimeFormat = DateTimeFormat> = {
|
|
|
7
7
|
locale: string;
|
|
8
8
|
format: F;
|
|
9
9
|
timeZone?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Appends the timezone abbreviation after the formatted value. Only applies to the `datetime`
|
|
12
|
+
* variant when a valid `timeZone` is also supplied.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
showTimeZone?: boolean;
|
|
10
16
|
clockFormat?: ClockFormat;
|
|
11
17
|
calendarType?: CalendarType;
|
|
12
18
|
} & (F extends 'medium' ? {
|
|
@@ -28,7 +34,7 @@ type DateTimeFormatOptions<F extends DateTimeFormat = DateTimeFormat> = {
|
|
|
28
34
|
t: TranslationFunction<TranslationPack>;
|
|
29
35
|
});
|
|
30
36
|
export declare function getIntlDateTimeFormatFromCache(locale: string, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
31
|
-
export declare function formatDateTime<F extends DateTimeFormat>(value: Date, { t, locale, format, variant, clockFormat, calendarType, timeZone, abbreviated }: DateTimeFormatOptions<F>): string;
|
|
37
|
+
export declare function formatDateTime<F extends DateTimeFormat>(value: Date, { t, locale, format, variant, clockFormat, calendarType, timeZone, showTimeZone, abbreviated }: DateTimeFormatOptions<F>): string;
|
|
32
38
|
interface DurationFormatOptions {
|
|
33
39
|
/** Locale to be used - en_US, jp_JP, fr_FR etc */
|
|
34
40
|
locale: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAKA,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;AACzF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAKA,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;AACzF,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AASlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAwBjD,KAAK,qBAAqB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GAAG,CAAC,CAAC,SAAS,QAAQ,GACnB;IACE;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,G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
|
@@ -4,7 +4,7 @@ import tz from 'dayjs/plugin/timezone';
|
|
|
4
4
|
import utc from 'dayjs/plugin/utc';
|
|
5
5
|
import { cap } from '../../utils';
|
|
6
6
|
import { CALENDAR_TYPES } from './Input/local';
|
|
7
|
-
import { getEndOfWeek, getQuarterForDateTimeZone, getStartOfWeek, getWeek, getWeekYear } from './Input/utils';
|
|
7
|
+
import { getEndOfWeek, getQuarterForDateTimeZone, getStartOfWeek, getValidTimeZone, getWeek, getWeekYear } from './Input/utils';
|
|
8
8
|
dayjs.extend(utc);
|
|
9
9
|
dayjs.extend(tz);
|
|
10
10
|
const unitsInMs = {
|
|
@@ -186,7 +186,19 @@ function expandAbbreviatedMonthParts(date, parts, locale, timeZone) {
|
|
|
186
186
|
return part.value === longMonth ? part : { ...part, value: longMonth };
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
function getTimeZoneText(date, locale, timeZone) {
|
|
190
|
+
const validTimeZone = getValidTimeZone(timeZone);
|
|
191
|
+
if (!validTimeZone)
|
|
192
|
+
return undefined;
|
|
193
|
+
return getIntlDateTimeFormatFromCache(locale, {
|
|
194
|
+
timeZone: validTimeZone,
|
|
195
|
+
timeZoneName: 'short',
|
|
196
|
+
hour: 'numeric'
|
|
197
|
+
})
|
|
198
|
+
.formatToParts(date)
|
|
199
|
+
.find(part => part.type === 'timeZoneName')?.value;
|
|
200
|
+
}
|
|
201
|
+
export function formatDateTime(value, { t, locale, format, variant, clockFormat, calendarType = CALENDAR_TYPES.ISO_8601, timeZone, showTimeZone = false, abbreviated = true }) {
|
|
190
202
|
const getFormattedDate = (date, dateVariant) => {
|
|
191
203
|
const resolvedVariant = dateVariant === 'time' || dateVariant === 'datetime'
|
|
192
204
|
? `${dateVariant}${clockFormat ?? ''}`
|
|
@@ -258,8 +270,13 @@ export function formatDateTime(value, { t, locale, format, variant, clockFormat,
|
|
|
258
270
|
return getFormattedWeek(value);
|
|
259
271
|
case 'quarteryear':
|
|
260
272
|
return getFormattedQuarterYear(value);
|
|
261
|
-
default:
|
|
262
|
-
|
|
273
|
+
default: {
|
|
274
|
+
const formattedDate = getFormattedDate(value, variant);
|
|
275
|
+
if (!showTimeZone || variant !== 'datetime')
|
|
276
|
+
return formattedDate;
|
|
277
|
+
const timeZoneText = getTimeZoneText(value, locale, timeZone);
|
|
278
|
+
return timeZoneText ? `${formattedDate} ${timeZoneText}` : formattedDate;
|
|
279
|
+
}
|
|
263
280
|
}
|
|
264
281
|
}
|
|
265
282
|
const dayInMs = 24 * 60 * 60 * 1000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvC,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAInC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,cAAc,EACd,OAAO,EACP,WAAW,EACZ,MAAM,eAAe,CAAC;AAGvB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAClB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEjB,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,GAAG,IAAI;IACjB,MAAM,EAAE,IAAI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CAAC;IAAC,MAAM,CAAC;QACP,OAAO,sBAAsB,EAAE,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC,CAAC","sourcesContent":["// cspell:ignore DDTHH\nimport dayjs from 'dayjs';\nimport tz from 'dayjs/plugin/timezone';\nimport utc from 'dayjs/plugin/utc';\n\nimport 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, type CalendarType } from './Input/local';\nimport {\n getEndOfWeek,\n getQuarterForDateTimeZone,\n getStartOfWeek,\n getWeek,\n getWeekYear\n} from './Input/utils';\nimport type { ClockFormat } from './Input/utils';\n\ndayjs.extend(utc);\ndayjs.extend(tz);\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;\nconst timeUnitsOrdered = [\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second'\n] as const satisfies TimeUnit[];\n\ntype DateTimeFormatOptions<F extends DateTimeFormat = DateTimeFormat> = {\n locale: string;\n format: F;\n timeZone?: string;\n clockFormat?: ClockFormat;\n calendarType?: CalendarType;\n} & (F extends 'medium'\n ? {\n /**\n * When false, abbreviated month names (e.g. \"Oct\") are expanded to their full form\n * (e.g. \"October\") so the result is suitable for use as an accessible label read by\n * screen readers. Numeric months and locales without a distinct abbreviated form are\n * left untouched. Only has an effect when `format` is `'medium'`.\n * @default true\n */\n abbreviated?: boolean;\n }\n : { abbreviated?: never }) &\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\nconst timeLongNumeric = {\n ...timeNumeric,\n second: 'numeric'\n} satisfies TimeOptions;\n\nconst dateTimeLongNumeric = {\n ...dateNumeric,\n ...timeLongNumeric\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 'long-numeric': dateNumeric\n },\n datetime: {\n short: dateTimeShort,\n medium: dateTimeMedium,\n long: dateTimeLong,\n numeric: dateTimeNumeric,\n 'long-numeric': dateTimeLongNumeric\n },\n datetime12: {\n short: { ...dateTimeShort, hour12: true },\n medium: { ...dateTimeMedium, hour12: true },\n long: { ...dateTimeLong, hour12: true },\n numeric: { ...dateTimeNumeric, hour12: true },\n 'long-numeric': { ...dateTimeLongNumeric, 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 'long-numeric': { ...dateTimeLongNumeric, hour12: false }\n },\n time: {\n short: timeShort,\n medium: timeMedium,\n long: timeLong,\n numeric: timeNumeric,\n 'long-numeric': timeLongNumeric\n },\n time12: {\n short: { ...timeShort, hour12: true },\n medium: { ...timeMedium, hour12: true },\n long: { ...timeLong, hour12: true },\n numeric: { ...timeNumeric, hour12: true },\n 'long-numeric': { ...timeLongNumeric, 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 'long-numeric': { ...timeLongNumeric, hour12: false }\n },\n month: {\n short: { month: 'short' },\n medium: { month: 'short' },\n long: { month: 'long' },\n numeric: { month: 'numeric' },\n 'long-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 'long-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 'long-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 'long-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 'long-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: Map<\n // locale & stringified sorted Intl.DateTimeFormatOptions\n string,\n Intl.DateTimeFormat\n> = new Map();\n\nexport function getIntlDateTimeFormatFromCache(\n locale: string,\n options: Intl.DateTimeFormatOptions = {}\n) {\n const sortedOptions = JSON.stringify(options, Object.keys(options).sort());\n const key = `${locale}${sortedOptions}`;\n\n if (!dateTimeFormatCache.has(key)) {\n dateTimeFormatCache.set(key, new Intl.DateTimeFormat(locale, options));\n }\n\n return dateTimeFormatCache.get(key)!;\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\n// Expands any abbreviated 'month' part (e.g. \"Oct\") in the formatted parts of a date to\n// its full form (e.g. \"October\"), so the result can be exposed as an accessible label.\n// Numeric months and already-expanded month names are left untouched.\nfunction expandAbbreviatedMonthParts(\n date: Date,\n parts: Intl.DateTimeFormatPart[],\n locale: string,\n timeZone?: string\n): Intl.DateTimeFormatPart[] {\n return parts.map(part => {\n if (part.type !== 'month' || /^\\d+$/.test(part.value)) {\n return part;\n }\n\n const longMonth = getIntlDateTimeFormatFromCache(locale, {\n month: 'long',\n timeZone\n }).format(date);\n\n return part.value === longMonth ? part : { ...part, value: longMonth };\n });\n}\n\nexport function formatDateTime<F extends DateTimeFormat>(\n value: Date,\n {\n t,\n locale,\n format,\n variant,\n clockFormat,\n calendarType = CALENDAR_TYPES.ISO_8601,\n timeZone,\n abbreviated = true\n }: DateTimeFormatOptions<F>\n) {\n const getFormattedDate = (\n date: Date,\n dateVariant: ExcludeStrict<AbsoluteVariant, 'quarteryear'>\n ) => {\n const resolvedVariant: AddClockFormatToTimeKeys<typeof dateVariant> =\n dateVariant === 'time' || dateVariant === 'datetime'\n ? `${dateVariant}${clockFormat ?? ''}`\n : dateVariant;\n const resolvedOptions = formatMapping[resolvedVariant][format];\n\n const intlFormat = getIntlDateTimeFormatFromCache(locale, {\n ...resolvedOptions,\n timeZone\n });\n\n if (abbreviated) {\n return intlFormat.format(date);\n }\n\n return expandAbbreviatedMonthParts(date, intlFormat.formatToParts(date), locale, timeZone)\n .map(part => part.value)\n .join('');\n };\n\n const relativeTimeFormatter = (\n relativeValue: number,\n unit: TimeUnit,\n enforceNumeric?: boolean\n ) => {\n const resolvedOptions: Intl.RelativeTimeFormatOptions = {\n ...formatMapping.relative[format],\n numeric: enforceNumeric ? 'always' : 'auto'\n };\n\n relativeTimeFormatCache[locale] ??= new Map();\n const map = relativeTimeFormatCache[locale];\n\n if (!map.has(resolvedOptions)) {\n map.set(\n resolvedOptions,\n new Intl.RelativeTimeFormat(locale, {\n ...resolvedOptions\n })\n );\n }\n\n return map.get(resolvedOptions)!.format(relativeValue, unit);\n };\n\n const getRelativeTime = (date: Date) => {\n const now = dayjs();\n const targetDate = dayjs(date);\n\n // Deliberately reduce precision to 1 minute, handles \"now\" cases\n const isWithinMinute = Math.abs(targetDate.diff(now, 'millisecond')) < 60000;\n if (isWithinMinute) {\n return relativeTimeFormatter(0, 'second', false);\n }\n\n // Find the most appropriate unit by checking dayjs diff for each unit\n for (const unit of timeUnitsOrdered) {\n const diff = targetDate.diff(now, unit);\n if (Math.abs(diff) >= 1) {\n return relativeTimeFormatter(diff, unit, true);\n }\n }\n\n // Fallback to seconds if no unit has a difference >= 1\n const secondsDiff = targetDate.diff(now, 'second');\n return relativeTimeFormatter(secondsDiff, 'second', true);\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 startDate = getFormattedDate(getStartOfWeek(date, calendarType, timeZone), 'week');\n const endDate = getFormattedDate(getEndOfWeek(date, calendarType, timeZone), 'week');\n\n return `${cap(displayNames.of('weekOfYear'))} ${getWeek(\n date,\n calendarType,\n timeZone\n )}, ${getWeekYear(date, calendarType, timeZone)} (${startDate} - ${endDate})`;\n };\n\n const getFormattedQuarterYear = (date: Date) => {\n const formattedYear = getFormattedDate(date, 'year');\n const quarterNumber = getQuarterForDateTimeZone(date, timeZone);\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\n/**\n * @param timeZone - IANA timezone string (e.g. \"America/New_York\")\n * @returns Current date and time for the given timezone, with wall-clock time\n * encoded in UTC fields — matching the convention used by DateTime inputs.\n */\nexport const getAdjustedUTCDateTimeForTimezone = (timeZone: string): Date => {\n try {\n // eslint-disable-next-line no-new\n new Intl.DateTimeFormat('en-US', { timeZone });\n } catch {\n return getAdjustedUTCDateTime();\n }\n return new Date(`${dayjs().tz(timeZone).format('YYYY-MM-DDTHH:mm:ss.SSS')}Z`);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceR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AAC;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;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,QAAgB,EAAQ,EAAE;IAC1E,IAAI,CAAC;QACH,kCAAkC;QAClC,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,sBAAsB,EAAE,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC,CAAC","sourcesContent":["// cspell:ignore DDTHH\nimport dayjs from 'dayjs';\nimport tz from 'dayjs/plugin/timezone';\nimport utc from 'dayjs/plugin/utc';\n\nimport 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, type CalendarType } from './Input/local';\nimport {\n getEndOfWeek,\n getQuarterForDateTimeZone,\n getStartOfWeek,\n getValidTimeZone,\n getWeek,\n getWeekYear\n} from './Input/utils';\nimport type { ClockFormat } from './Input/utils';\n\ndayjs.extend(utc);\ndayjs.extend(tz);\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;\nconst timeUnitsOrdered = [\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second'\n] as const satisfies TimeUnit[];\n\ntype DateTimeFormatOptions<F extends DateTimeFormat = DateTimeFormat> = {\n locale: string;\n format: F;\n timeZone?: string;\n /**\n * Appends the timezone abbreviation after the formatted value. Only applies to the `datetime`\n * variant when a valid `timeZone` is also supplied.\n * @default false\n */\n showTimeZone?: boolean;\n clockFormat?: ClockFormat;\n calendarType?: CalendarType;\n} & (F extends 'medium'\n ? {\n /**\n * When false, abbreviated month names (e.g. \"Oct\") are expanded to their full form\n * (e.g. \"October\") so the result is suitable for use as an accessible label read by\n * screen readers. Numeric months and locales without a distinct abbreviated form are\n * left untouched. Only has an effect when `format` is `'medium'`.\n * @default true\n */\n abbreviated?: boolean;\n }\n : { abbreviated?: never }) &\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\nconst timeLongNumeric = {\n ...timeNumeric,\n second: 'numeric'\n} satisfies TimeOptions;\n\nconst dateTimeLongNumeric = {\n ...dateNumeric,\n ...timeLongNumeric\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 'long-numeric': dateNumeric\n },\n datetime: {\n short: dateTimeShort,\n medium: dateTimeMedium,\n long: dateTimeLong,\n numeric: dateTimeNumeric,\n 'long-numeric': dateTimeLongNumeric\n },\n datetime12: {\n short: { ...dateTimeShort, hour12: true },\n medium: { ...dateTimeMedium, hour12: true },\n long: { ...dateTimeLong, hour12: true },\n numeric: { ...dateTimeNumeric, hour12: true },\n 'long-numeric': { ...dateTimeLongNumeric, 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 'long-numeric': { ...dateTimeLongNumeric, hour12: false }\n },\n time: {\n short: timeShort,\n medium: timeMedium,\n long: timeLong,\n numeric: timeNumeric,\n 'long-numeric': timeLongNumeric\n },\n time12: {\n short: { ...timeShort, hour12: true },\n medium: { ...timeMedium, hour12: true },\n long: { ...timeLong, hour12: true },\n numeric: { ...timeNumeric, hour12: true },\n 'long-numeric': { ...timeLongNumeric, 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 'long-numeric': { ...timeLongNumeric, hour12: false }\n },\n month: {\n short: { month: 'short' },\n medium: { month: 'short' },\n long: { month: 'long' },\n numeric: { month: 'numeric' },\n 'long-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 'long-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 'long-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 'long-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 'long-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: Map<\n // locale & stringified sorted Intl.DateTimeFormatOptions\n string,\n Intl.DateTimeFormat\n> = new Map();\n\nexport function getIntlDateTimeFormatFromCache(\n locale: string,\n options: Intl.DateTimeFormatOptions = {}\n) {\n const sortedOptions = JSON.stringify(options, Object.keys(options).sort());\n const key = `${locale}${sortedOptions}`;\n\n if (!dateTimeFormatCache.has(key)) {\n dateTimeFormatCache.set(key, new Intl.DateTimeFormat(locale, options));\n }\n\n return dateTimeFormatCache.get(key)!;\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\n// Expands any abbreviated 'month' part (e.g. \"Oct\") in the formatted parts of a date to\n// its full form (e.g. \"October\"), so the result can be exposed as an accessible label.\n// Numeric months and already-expanded month names are left untouched.\nfunction expandAbbreviatedMonthParts(\n date: Date,\n parts: Intl.DateTimeFormatPart[],\n locale: string,\n timeZone?: string\n): Intl.DateTimeFormatPart[] {\n return parts.map(part => {\n if (part.type !== 'month' || /^\\d+$/.test(part.value)) {\n return part;\n }\n\n const longMonth = getIntlDateTimeFormatFromCache(locale, {\n month: 'long',\n timeZone\n }).format(date);\n\n return part.value === longMonth ? part : { ...part, value: longMonth };\n });\n}\n\nfunction getTimeZoneText(date: Date, locale: string, timeZone?: string): string | undefined {\n const validTimeZone = getValidTimeZone(timeZone);\n if (!validTimeZone) return undefined;\n\n return getIntlDateTimeFormatFromCache(locale, {\n timeZone: validTimeZone,\n timeZoneName: 'short',\n hour: 'numeric'\n })\n .formatToParts(date)\n .find(part => part.type === 'timeZoneName')?.value;\n}\n\nexport function formatDateTime<F extends DateTimeFormat>(\n value: Date,\n {\n t,\n locale,\n format,\n variant,\n clockFormat,\n calendarType = CALENDAR_TYPES.ISO_8601,\n timeZone,\n showTimeZone = false,\n abbreviated = true\n }: DateTimeFormatOptions<F>\n) {\n const getFormattedDate = (\n date: Date,\n dateVariant: ExcludeStrict<AbsoluteVariant, 'quarteryear'>\n ) => {\n const resolvedVariant: AddClockFormatToTimeKeys<typeof dateVariant> =\n dateVariant === 'time' || dateVariant === 'datetime'\n ? `${dateVariant}${clockFormat ?? ''}`\n : dateVariant;\n const resolvedOptions = formatMapping[resolvedVariant][format];\n\n const intlFormat = getIntlDateTimeFormatFromCache(locale, {\n ...resolvedOptions,\n timeZone\n });\n\n if (abbreviated) {\n return intlFormat.format(date);\n }\n\n return expandAbbreviatedMonthParts(date, intlFormat.formatToParts(date), locale, timeZone)\n .map(part => part.value)\n .join('');\n };\n\n const relativeTimeFormatter = (\n relativeValue: number,\n unit: TimeUnit,\n enforceNumeric?: boolean\n ) => {\n const resolvedOptions: Intl.RelativeTimeFormatOptions = {\n ...formatMapping.relative[format],\n numeric: enforceNumeric ? 'always' : 'auto'\n };\n\n relativeTimeFormatCache[locale] ??= new Map();\n const map = relativeTimeFormatCache[locale];\n\n if (!map.has(resolvedOptions)) {\n map.set(\n resolvedOptions,\n new Intl.RelativeTimeFormat(locale, {\n ...resolvedOptions\n })\n );\n }\n\n return map.get(resolvedOptions)!.format(relativeValue, unit);\n };\n\n const getRelativeTime = (date: Date) => {\n const now = dayjs();\n const targetDate = dayjs(date);\n\n // Deliberately reduce precision to 1 minute, handles \"now\" cases\n const isWithinMinute = Math.abs(targetDate.diff(now, 'millisecond')) < 60000;\n if (isWithinMinute) {\n return relativeTimeFormatter(0, 'second', false);\n }\n\n // Find the most appropriate unit by checking dayjs diff for each unit\n for (const unit of timeUnitsOrdered) {\n const diff = targetDate.diff(now, unit);\n if (Math.abs(diff) >= 1) {\n return relativeTimeFormatter(diff, unit, true);\n }\n }\n\n // Fallback to seconds if no unit has a difference >= 1\n const secondsDiff = targetDate.diff(now, 'second');\n return relativeTimeFormatter(secondsDiff, 'second', true);\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 startDate = getFormattedDate(getStartOfWeek(date, calendarType, timeZone), 'week');\n const endDate = getFormattedDate(getEndOfWeek(date, calendarType, timeZone), 'week');\n\n return `${cap(displayNames.of('weekOfYear'))} ${getWeek(\n date,\n calendarType,\n timeZone\n )}, ${getWeekYear(date, calendarType, timeZone)} (${startDate} - ${endDate})`;\n };\n\n const getFormattedQuarterYear = (date: Date) => {\n const formattedYear = getFormattedDate(date, 'year');\n const quarterNumber = getQuarterForDateTimeZone(date, timeZone);\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 const formattedDate = getFormattedDate(value, variant);\n if (!showTimeZone || variant !== 'datetime') return formattedDate;\n\n const timeZoneText = getTimeZoneText(value, locale, timeZone);\n return timeZoneText ? `${formattedDate} ${timeZoneText}` : formattedDate;\n }\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\n/**\n * @param timeZone - IANA timezone string (e.g. \"America/New_York\")\n * @returns Current date and time for the given timezone, with wall-clock time\n * encoded in UTC fields — matching the convention used by DateTime inputs.\n */\nexport const getAdjustedUTCDateTimeForTimezone = (timeZone: string): Date => {\n try {\n // eslint-disable-next-line no-new\n new Intl.DateTimeFormat('en-US', { timeZone });\n } catch {\n return getAdjustedUTCDateTime();\n }\n return new Date(`${dayjs().tz(timeZone).format('YYYY-MM-DDTHH:mm:ss.SSS')}Z`);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandCollapseButton.d.ts","sourceRoot":"","sources":["../../../src/components/ExpandCollapse/ExpandCollapseButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpandCollapseButton.d.ts","sourceRoot":"","sources":["../../../src/components/ExpandCollapse/ExpandCollapseButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK1F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,MAAM,yBAAyB,GAAG,cAAc,CACpD,QAAQ,EACR,cAAc,GACZ,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAC7B,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;IAElB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,IAAI,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,CAAA;KAAE,CAAC;IAE1D;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;CAC7C,CACJ,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;gBACzB,OAAO;kBACL,UAAU;gIAyBxB,CAAC;;AAIH,wBA0EG"}
|
|
@@ -2,8 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { defaultThemeProp } from '../../theme';
|
|
5
|
-
import { useDirection, useI18n
|
|
6
|
-
import HiddenText from '../HiddenText';
|
|
5
|
+
import { useDirection, useI18n } from '../../hooks';
|
|
7
6
|
import { calculateFontSize } from '../../styles';
|
|
8
7
|
import Button from '../Button';
|
|
9
8
|
import Flex from '../Flex';
|
|
@@ -37,14 +36,9 @@ export const StyledExpandCollapseButton = styled(Button)(({ $iconOnly, $headingT
|
|
|
37
36
|
StyledExpandCollapseButton.defaultProps = defaultThemeProp;
|
|
38
37
|
export default forwardRef(function ExpandCollapseButton({ expanded, onToggle, label, iconOnly = false, count, compact, 'aria-labelledby': labelledBy, ...restProps }, ref) {
|
|
39
38
|
const t = useI18n();
|
|
40
|
-
const hiddenTextId = useUID();
|
|
41
39
|
const toggleText = expanded ? t('collapse') : t('expand');
|
|
42
40
|
let ariaLabel;
|
|
43
|
-
|
|
44
|
-
if (labelledBy && !label) {
|
|
45
|
-
ariaLabelledBy = `${hiddenTextId} ${labelledBy}`;
|
|
46
|
-
}
|
|
47
|
-
else if (iconOnly) {
|
|
41
|
+
if (iconOnly && (!labelledBy || label)) {
|
|
48
42
|
if (label) {
|
|
49
43
|
const labelText = typeof label === 'string' ? label : label.text;
|
|
50
44
|
ariaLabel = `${toggleText} - ${labelText}`;
|
|
@@ -76,6 +70,6 @@ export default forwardRef(function ExpandCollapseButton({ expanded, onToggle, la
|
|
|
76
70
|
else {
|
|
77
71
|
renderedCount = _jsx(Count, { ...count });
|
|
78
72
|
}
|
|
79
|
-
return (
|
|
73
|
+
return (_jsx(StyledExpandCollapseButton, { ...restProps, ref: ref, onClick: onToggle, "aria-expanded": expanded, "aria-label": ariaLabel, "aria-labelledby": labelledBy, label: tooltipText, icon: iconOnly, compact: compact, variant: iconOnly ? 'simple' : 'text', "$iconOnly": iconOnly, "$headingTag": headingTag, children: _jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, as: 'span', children: [_jsx(Icon, { name: 'caret-right', size: !iconOnly ? 'font-size' : undefined }), renderedLabel, renderedCount] }) }));
|
|
80
74
|
});
|
|
81
75
|
//# sourceMappingURL=ExpandCollapseButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandCollapseButton.js","sourceRoot":"","sources":["../../../src/components/ExpandCollapse/ExpandCollapseButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
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utRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { NoChildrenProp, RefElement, WithAttributes, HeadingTag } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useDirection, useI18n } from '../../hooks';\nimport { calculateFontSize, type FontSize } from '../../styles';\nimport Button from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Flex from '../Flex';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Text from '../Text';\nimport Count from '../Badges/Count';\nimport type { CountProps } from '../Badges/Count';\n\nregisterIcon(caretRightIcon);\n\nexport type ExpandCollapseButtonProps = WithAttributes<\n 'button',\n NoChildrenProp &\n Pick<ButtonProps, 'compact'> & {\n /** Indicates whether the content is expanded. */\n expanded: boolean;\n\n /** Callback function triggered when the button is toggled. */\n onToggle: () => void;\n\n /**\n * Label for the button. Can be a string or an object containing text and a heading tag.\n */\n label?: string | { text: string; headingTag: HeadingTag };\n\n /**\n * If true, only the icon is displayed. Tooltip will always show \"Expand\" or \"Collapse\".\n * @default false\n */\n iconOnly?: boolean;\n\n /** Optional count to display next to the label. Only available when iconOnly is false. */\n count?: CountProps['children'] | CountProps;\n }\n>;\n\nexport const StyledExpandCollapseButton = styled(Button)<{\n $iconOnly?: boolean;\n $headingTag?: HeadingTag;\n}>(({ $iconOnly, $headingTag, theme }) => {\n const { rtl } = useDirection();\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n ${!$iconOnly &&\n css`\n font-size: ${fontSize[\n theme.components.text[$headingTag ?? 'primary']['font-size'] as FontSize\n ]};\n `}\n\n ${StyledIcon} {\n transition: transform ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n }\n\n &[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n `;\n});\n\nStyledExpandCollapseButton.defaultProps = defaultThemeProp;\n\nexport default forwardRef<\n RefElement<ExpandCollapseButtonProps>,\n PropsWithoutRef<ExpandCollapseButtonProps>\n>(function ExpandCollapseButton(\n {\n expanded,\n onToggle,\n label,\n iconOnly = false,\n count,\n compact,\n 'aria-labelledby': labelledBy,\n ...restProps\n },\n ref\n) {\n const t = useI18n();\n const toggleText = expanded ? t('collapse') : t('expand');\n\n let ariaLabel: string | undefined;\n\n if (iconOnly && (!labelledBy || label)) {\n if (label) {\n const labelText = typeof label === 'string' ? label : label.text;\n ariaLabel = `${toggleText} - ${labelText}`;\n } else {\n ariaLabel = toggleText;\n }\n }\n\n const tooltipText = iconOnly ? toggleText : undefined;\n\n let renderedLabel: ReactNode;\n let headingTag: HeadingTag | undefined;\n if (iconOnly || !label) {\n renderedLabel = null;\n } else if (typeof label === 'string') {\n renderedLabel = <span>{label}</span>;\n } else {\n renderedLabel = <Text variant={label.headingTag}>{label.text}</Text>;\n headingTag = label.headingTag;\n }\n\n let renderedCount: ReactNode;\n if (iconOnly || count === undefined) {\n renderedCount = null;\n } else if (typeof count === 'number' || count === null) {\n renderedCount = <Count>{count}</Count>;\n } else {\n renderedCount = <Count {...count} />;\n }\n\n return (\n <StyledExpandCollapseButton\n {...restProps}\n ref={ref}\n onClick={onToggle}\n aria-expanded={expanded}\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n label={tooltipText}\n icon={iconOnly}\n compact={compact}\n variant={iconOnly ? 'simple' : 'text'}\n $iconOnly={iconOnly}\n $headingTag={headingTag}\n >\n <Flex container={{ alignItems: 'center', gap: 1 }} as='span'>\n <Icon name='caret-right' size={!iconOnly ? 'font-size' : undefined} />\n {renderedLabel}\n {renderedCount}\n </Flex>\n </StyledExpandCollapseButton>\n );\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveLog.d.ts","sourceRoot":"","sources":["../../../src/components/LiveLog/LiveLog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAW,OAAO,EAAE,MAAM,OAAO,CAAC;AAMjE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAGb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;KAC/C;CACF;AAwDD,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"LiveLog.d.ts","sourceRoot":"","sources":["../../../src/components/LiveLog/LiveLog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAW,OAAO,EAAE,MAAM,OAAO,CAAC;AAMjE,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAGb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;KAC/C;CACF;AAwDD,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,CA4E5C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -94,7 +94,7 @@ const LiveLog = ({ children, maxLength = 15 }) => {
|
|
|
94
94
|
if (priorCtx.initialized) {
|
|
95
95
|
return _jsx(context.Provider, { value: priorCtx, children: children });
|
|
96
96
|
}
|
|
97
|
-
return (_jsxs(context.Provider, { value: providerValue, children: [children,
|
|
97
|
+
return (_jsxs(context.Provider, { value: providerValue, children: [children, _jsx(StyledLog, { role: 'log', "aria-label": t('polite_announcements'), "aria-relevant": 'additions', children: state.politeMessages.map(({ message, id }) => (_jsx("p", { children: message }, id))) }), _jsx(StyledLog, { role: 'log', "aria-label": t('assertive_announcements'), "aria-live": 'assertive', "aria-relevant": 'additions', children: state.assertiveMessages.map(({ message, id }) => (_jsx("p", { children: message }, id))) })] }));
|
|
98
98
|
};
|
|
99
99
|
export default LiveLog;
|
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Q,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAoB,CAAC;IAC1E,CAAC;IAED,OAAO,CACL,MAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,aACnC,QAAQ,EAET,KAAC,SAAS,IAAC,IAAI,EAAC,KAAK,gBAAa,CAAC,CAAC,sBAAsB,CAAC,mBAAgB,WAAW,YACnF,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAC7C,sBAAa,OAAO,IAAZ,EAAE,CAAe,CAC1B,CAAC,GACQ,EAEZ,KAAC,SAAS,IACR,IAAI,EAAC,KAAK,gBACE,CAAC,CAAC,yBAAyB,CAAC,eAC9B,WAAW,mBACP,WAAW,YAExB,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAChD,sBAAa,OAAO,IAAZ,EAAE,CAAe,CAC1B,CAAC,GACQ,IACK,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { useEffect, useContext, useReducer, useMemo } from 'react';\nimport type { FunctionComponent, Reducer, Context } from 'react';\n\nimport { createUID, windowIsAvailable } from '../../utils';\nimport { useI18n } from '../../hooks';\n\nimport { StyledLog } from './LiveLog.styles';\nimport type {\n LiveLogContextValue,\n LiveLogProps,\n LiveLogState,\n ReducerAction\n} from './LiveLog.types';\nimport { LiveLogContext } from './Context';\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n liveLogContext?: Context<LiveLogContextValue>;\n }\n}\n\nconst reducer = (state: LiveLogState, action: ReducerAction) => {\n const type = action.type;\n\n switch (type) {\n case 'announce': {\n const message = action.payload.message;\n const messageType = action.payload.type;\n const announceMessage =\n ['alert', 'error', 'exception'].includes(messageType) ||\n !state.suppressedTypes.includes(messageType);\n\n if (announceMessage) {\n const id = createUID();\n\n if (action.payload.level === 'assertive') {\n return {\n ...state,\n assertiveMessages: [...state.assertiveMessages, { message, id }]\n };\n }\n\n return {\n ...state,\n politeMessages: [...state.politeMessages, { message, id }]\n };\n }\n\n return state;\n }\n case 'setMaxLength': {\n return {\n ...state,\n maxLength: action.payload > 0 ? action.payload : 15\n };\n }\n case 'trimLength': {\n const trimPolite = state.politeMessages.length > state.maxLength;\n const trimAssertive = state.assertiveMessages.length > state.maxLength;\n\n return {\n ...state,\n politeMessages: trimPolite\n ? [...state.politeMessages.slice(-state.maxLength)]\n : state.politeMessages,\n assertiveMessages: trimAssertive\n ? [...state.assertiveMessages.slice(-state.maxLength)]\n : state.assertiveMessages\n };\n }\n default:\n return state;\n }\n};\n\nconst LiveLog: FunctionComponent<LiveLogProps> = ({ children, maxLength = 15 }: LiveLogProps) => {\n const t = useI18n();\n\n const [state, dispatch] = useReducer<Reducer<LiveLogState, ReducerAction>>(reducer, {\n maxLength,\n politeMessages: [],\n assertiveMessages: [],\n suppressedTypes: [] // initialize via a11y settings once available.\n });\n\n // Manage log length.\n useEffect(() => {\n const timeout = setTimeout(() => {\n dispatch({ type: 'trimLength' });\n }, 1000);\n\n return () => {\n clearTimeout(timeout);\n };\n }, [state.assertiveMessages, state.politeMessages, state.maxLength]);\n\n // Update max length\n useEffect(() => {\n dispatch({ type: 'setMaxLength', payload: maxLength });\n }, [maxLength]);\n\n const providerValue = useMemo<LiveLogContextValue>(\n () => ({\n announce: ({ message, type = 'info', assertive = false }) => {\n dispatch({\n type: 'announce',\n payload: { message, type, level: assertive ? 'assertive' : 'polite' }\n });\n },\n announcePolite: ({ message, type = 'info' }) => {\n dispatch({ type: 'announce', payload: { message, type, level: 'polite' } });\n },\n announceAssertive: ({ message, type = 'info' }) => {\n dispatch({ type: 'announce', payload: { message, type, level: 'assertive' } });\n },\n initialized: true\n }),\n []\n );\n\n // Don't create additional LiveLogContext.Providers.\n const context = windowIsAvailable\n ? window.cosmos.liveLogContext ?? LiveLogContext\n : LiveLogContext;\n const priorCtx = useContext(context);\n if (priorCtx.initialized) {\n return <context.Provider value={priorCtx}>{children}</context.Provider>;\n }\n\n return (\n <context.Provider value={providerValue}>\n {children}\n\n <StyledLog role='log' aria-label={t('polite_announcements')} aria-relevant='additions'>\n {state.politeMessages.map(({ message, id }) => (\n <p key={id}>{message}</p>\n ))}\n </StyledLog>\n\n <StyledLog\n role='log'\n aria-label={t('assertive_announcements')}\n aria-live='assertive'\n aria-relevant='additions'\n >\n {state.assertiveMessages.map(({ message, id }) => (\n <p key={id}>{message}</p>\n ))}\n </StyledLog>\n </context.Provider>\n );\n};\n\nexport default LiveLog;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-core",
|
|
3
|
-
"version": "10.0.0-build.10.
|
|
3
|
+
"version": "10.0.0-build.10.3",
|
|
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
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Pegasystems",
|