@pega/cosmos-react-core 8.17.2 → 8.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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' | 'medium' | 'long' | 'numeric';
61
+ export type DateTimeFormat = 'short' | 'medium' | 'long' | 'numeric' | '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,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,WAAW,kBAAmB,SAAQ,UAAU,EAAE,SAAS;IAC/D,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,w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,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DateTime.types.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BaseProps, NoChildrenProp, TestIdProp } from '../../types';\nimport type { FormControlProps } from '../FormControl';\n\nexport interface DateTimeProperties extends TestIdProp, BaseProps {\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"]}
1
+ {"version":3,"file":"DateTime.types.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BaseProps, NoChildrenProp, TestIdProp } from '../../types';\nimport type { FormControlProps } from '../FormControl';\n\nexport interface DateTimeProperties extends TestIdProp, BaseProps {\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' | 'long-numeric';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAEA,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;AASzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAqBjD,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,MAAM,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ACH,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAC;CACrE;AAgBD,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,EACE,MAAM,EACN,gBAAgB,EAChB,WAAsB,EACtB,YAAuB,EACxB,EAAE,qBAAqB,UAgCzB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAO,IAIzC,CAAC"}
@@ -61,78 +61,98 @@ const dateTimeNumeric = {
61
61
  ...dateNumeric,
62
62
  ...timeNumeric
63
63
  };
64
+ const timeLongNumeric = {
65
+ ...timeNumeric,
66
+ second: 'numeric'
67
+ };
68
+ const dateTimeLongNumeric = {
69
+ ...dateNumeric,
70
+ ...timeLongNumeric
71
+ };
64
72
  const formatMapping = {
65
73
  date: {
66
74
  short: dateShort,
67
75
  medium: dateMedium,
68
76
  long: dateLong,
69
- numeric: dateNumeric
77
+ numeric: dateNumeric,
78
+ 'long-numeric': dateNumeric
70
79
  },
71
80
  datetime: {
72
81
  short: dateTimeShort,
73
82
  medium: dateTimeMedium,
74
83
  long: dateTimeLong,
75
- numeric: dateTimeNumeric
84
+ numeric: dateTimeNumeric,
85
+ 'long-numeric': dateTimeLongNumeric
76
86
  },
77
87
  datetime12: {
78
88
  short: { ...dateTimeShort, hour12: true },
79
89
  medium: { ...dateTimeMedium, hour12: true },
80
90
  long: { ...dateTimeLong, hour12: true },
81
- numeric: { ...dateTimeNumeric, hour12: true }
91
+ numeric: { ...dateTimeNumeric, hour12: true },
92
+ 'long-numeric': { ...dateTimeLongNumeric, hour12: true }
82
93
  },
83
94
  datetime24: {
84
95
  short: { ...dateTimeShort, hour12: false },
85
96
  medium: { ...dateTimeMedium, hour12: false },
86
97
  long: { ...dateTimeLong, hour12: false },
87
- numeric: { ...dateTimeNumeric, hour12: false }
98
+ numeric: { ...dateTimeNumeric, hour12: false },
99
+ 'long-numeric': { ...dateTimeLongNumeric, hour12: false }
88
100
  },
89
101
  time: {
90
102
  short: timeShort,
91
103
  medium: timeMedium,
92
104
  long: timeLong,
93
- numeric: timeNumeric
105
+ numeric: timeNumeric,
106
+ 'long-numeric': timeLongNumeric
94
107
  },
95
108
  time12: {
96
109
  short: { ...timeShort, hour12: true },
97
110
  medium: { ...timeMedium, hour12: true },
98
111
  long: { ...timeLong, hour12: true },
99
- numeric: { ...timeNumeric, hour12: true }
112
+ numeric: { ...timeNumeric, hour12: true },
113
+ 'long-numeric': { ...timeLongNumeric, hour12: true }
100
114
  },
101
115
  time24: {
102
116
  short: { ...timeShort, hour12: false },
103
117
  medium: { ...timeMedium, hour12: false },
104
118
  long: { ...timeLong, hour12: false },
105
- numeric: { ...timeNumeric, hour12: false }
119
+ numeric: { ...timeNumeric, hour12: false },
120
+ 'long-numeric': { ...timeLongNumeric, hour12: false }
106
121
  },
107
122
  month: {
108
123
  short: { month: 'short' },
109
124
  medium: { month: 'short' },
110
125
  long: { month: 'long' },
111
- numeric: { month: 'numeric' }
126
+ numeric: { month: 'numeric' },
127
+ 'long-numeric': { month: 'numeric' }
112
128
  },
113
129
  monthyear: {
114
130
  short: { year: 'numeric', month: 'short' },
115
131
  medium: { year: 'numeric', month: 'short' },
116
132
  long: { year: 'numeric', month: 'long' },
117
- numeric: { year: 'numeric', month: 'numeric' }
133
+ numeric: { year: 'numeric', month: 'numeric' },
134
+ 'long-numeric': { year: 'numeric', month: 'numeric' }
118
135
  },
119
136
  week: {
120
137
  short: { month: 'short', day: 'numeric' },
121
138
  medium: { month: 'short', day: 'numeric' },
122
139
  long: { month: 'long', day: 'numeric' },
123
- numeric: { month: 'numeric', day: 'numeric' }
140
+ numeric: { month: 'numeric', day: 'numeric' },
141
+ 'long-numeric': { month: 'numeric', day: 'numeric' }
124
142
  },
125
143
  year: {
126
144
  short: { year: 'numeric' },
127
145
  medium: { year: 'numeric' },
128
146
  long: { year: 'numeric' },
129
- numeric: { year: '2-digit' }
147
+ numeric: { year: '2-digit' },
148
+ 'long-numeric': { year: '2-digit' }
130
149
  },
131
150
  relative: {
132
151
  short: { style: 'long', numeric: 'auto' },
133
152
  medium: { style: 'long', numeric: 'auto' },
134
153
  long: { style: 'long', numeric: 'auto' },
135
- numeric: { style: 'short', numeric: 'auto' }
154
+ numeric: { style: 'short', numeric: 'auto' },
155
+ 'long-numeric': { style: 'short', numeric: 'auto' }
136
156
  }
137
157
  };
138
158
  const dateTimeFormatCache = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/DateTime/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,cAAc,EACd,OAAO,EACP,WAAW,EACZ,MAAM,eAAe,CAAC;AAGvB,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;CACkD,CAAC;AAGjE,MAAM,gBAAgB,GAAG;IACvB,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;CACqB,CAAC;AAqBhC,MAAM,SAAS,GAAG;IAChB,SAAS,EAAE,OAAO;CACC,CAAC;AAEtB,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,QAAQ;CACA,CAAC;AAEtB,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,M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CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY;YAAE,MAAM;IACpD,CAAC;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 dayjs from 'dayjs';\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 } 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\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 = {\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: 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 let formatter = dateTimeFormatCache.get(key);\n\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, options);\n dateTimeFormatCache.set(key, formatter);\n }\n\n return formatter;\n}\n\nconst relativeTimeFormatCache: Map<\n // locale & stringified sorted Intl.RelativeTimeFormatOptions\n string,\n Intl.RelativeTimeFormat\n> = new Map();\n\nconst getIntlRelativeTimeFormatFromCache = (\n locale: string,\n options: Intl.RelativeTimeFormatOptions = {}\n) => {\n const sortedOptions = JSON.stringify(options, Object.keys(options).sort());\n const key = `${locale}${sortedOptions}`;\n let formatter = relativeTimeFormatCache.get(key);\n\n if (!formatter) {\n formatter = new Intl.RelativeTimeFormat(locale, options);\n relativeTimeFormatCache.set(key, formatter);\n }\n\n return formatter;\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 ) => {\n const resolvedVariant: AddClockFormatToTimeKeys<typeof dateVariant> =\n dateVariant === 'time' || dateVariant === 'datetime'\n ? `${dateVariant}${clockFormat ?? ''}`\n : dateVariant;\n const resolvedOptions = formatMapping[resolvedVariant][format];\n\n return getIntlDateTimeFormatFromCache(locale, {\n ...resolvedOptions,\n timeZone\n }).format(date);\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 return getIntlRelativeTimeFormatFromCache(locale, 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"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":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rF,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,CAAC;YAChE,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;QAC1E,CAAC;QACD,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY;YAAE,MAAM;IACpD,CAAC;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 dayjs from 'dayjs';\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 } 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\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 = {\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\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 let formatter = dateTimeFormatCache.get(key);\n\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, options);\n dateTimeFormatCache.set(key, formatter);\n }\n\n return formatter;\n}\n\nconst relativeTimeFormatCache: Map<\n // locale & stringified sorted Intl.RelativeTimeFormatOptions\n string,\n Intl.RelativeTimeFormat\n> = new Map();\n\nconst getIntlRelativeTimeFormatFromCache = (\n locale: string,\n options: Intl.RelativeTimeFormatOptions = {}\n) => {\n const sortedOptions = JSON.stringify(options, Object.keys(options).sort());\n const key = `${locale}${sortedOptions}`;\n let formatter = relativeTimeFormatCache.get(key);\n\n if (!formatter) {\n formatter = new Intl.RelativeTimeFormat(locale, options);\n relativeTimeFormatCache.set(key, formatter);\n }\n\n return formatter;\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 ) => {\n const resolvedVariant: AddClockFormatToTimeKeys<typeof dateVariant> =\n dateVariant === 'time' || dateVariant === 'datetime'\n ? `${dateVariant}${clockFormat ?? ''}`\n : dateVariant;\n const resolvedOptions = formatMapping[resolvedVariant][format];\n\n return getIntlDateTimeFormatFromCache(locale, {\n ...resolvedOptions,\n timeZone\n }).format(date);\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 return getIntlRelativeTimeFormatFromCache(locale, 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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.d.ts","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,iBAAiB,EAGjB,OAAO,EAIR,MAAM,OAAO,CAAC;AA6Bf,OAAO,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAgB,YAAY,EAAoC,MAAM,iBAAiB,CAAC;AAEpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AA8BrD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;KAC/C;CACF;;;;AAwWD,wBAAuD"}
1
+ {"version":3,"file":"Toaster.d.ts","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,iBAAiB,EAGjB,OAAO,EAIR,MAAM,OAAO,CAAC;AA6Bf,OAAO,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAgB,YAAY,EAAoC,MAAM,iBAAiB,CAAC;AAEpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AA8BrD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;KAC/C;CACF;;;;AA0WD,wBAAuD"}
@@ -199,7 +199,7 @@ const Toast = forwardRef(function Toast({ id, firstToast, dispatch, topLevelDism
199
199
  '--scale': dismissed ? '0' : '1'
200
200
  }, onTransitionEnd: onTransitionEnd, children: [_jsxs(Flex, { item: { grow: 1 }, as: StyledToastContent, children: [content, hasProp(restProps, 'href') ? (_jsxs(_Fragment, { children: [' ', _jsxs(Link, { href: restProps.href, children: ["(", id, "): ", restProps.label] })] })) : undefined] }), _jsxs(Flex, { container: { inline: true, justify: 'end', gap: 0.5 }, children: [_jsx(Keyboard, { keyName: 'Alt' }), _jsx(Keyboard, { keyName: 'Enter' })] }), _jsx(Button, { as: StyledToastButton, variant: 'simple', onClick: dismiss(false), icon: true, "aria-label": t('dismiss_label'), children: _jsx(Icon, { name: 'times' }) })] }));
201
201
  });
202
- const Toaster = ({ testId, children, dismissAfter = Infinity, onDismiss }) => {
202
+ const Toaster = ({ testId, children, dismissAfter = 7_500, onDismiss }) => {
203
203
  const { portalTarget } = useConfiguration();
204
204
  const [messages, dispatch] = useReducer(reducer, []);
205
205
  const [yOffsets, setYOffsets] = useState([]);
@@ -217,7 +217,9 @@ const Toaster = ({ testId, children, dismissAfter = Infinity, onDismiss }) => {
217
217
  const message = {
218
218
  ...incoming,
219
219
  id: incoming.id ?? createUID(),
220
- dismissAfter: hasProp(incoming, 'href') ? 10_000 : incoming.dismissAfter
220
+ dismissAfter: hasProp(incoming, 'href')
221
+ ? 15_000
222
+ : Math.max(incoming.dismissAfter ?? 7_500, 7_500)
221
223
  };
222
224
  dispatch({
223
225
  type: 'push',
@@ -258,7 +260,7 @@ const Toaster = ({ testId, children, dismissAfter = Infinity, onDismiss }) => {
258
260
  }
259
261
  return (
260
262
  // Base Toast
261
- _createElement(Toast, { "data-testid": testIds.toast, ...message, ...sharedProps, dismissAfter: message.dismissAfter ?? dismissAfter, key: message.id }));
263
+ _createElement(Toast, { "data-testid": testIds.toast, ...message, ...sharedProps, dismissAfter: Math.max(message.dismissAfter, dismissAfter), key: message.id }));
262
264
  }) }), portalTarget)] }));
263
265
  };
264
266
  export default withTestIds(Toaster, getToasterTestIds);
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,OAAO,EACP,eAAe,EACf,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACV,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AAC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,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;4BAC5B,UAAU,EAAE,CAAC,KAAK,CAAC;4BACnB,eAAe,EAAE,SAAS;4BAC1B,QAAQ;4BACR,GAAG,EAAE,EAAE,CAAC,EAAE;gCACR,IAAI,EAAE,EAAE,CAAC;oCACP,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;gCACtD,CAAC;qCAAM,CAAC;oCACN,OAAO,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gCAC3C,CAAC;4BACH,CAAC;yBAC4B,CAAC;wBAEhC,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;4BAC7B,OAAO;4BACL,kBAAkB;4BAClB,eAAC,KAAK,mBACS,OAAO,CAAC,KAAK,KACtB,OAAO,KACP,WAAW,EACf,GAAG,EAAE,OAAO,CAAC,EAAE,GACf,CACH,CAAC;wBACJ,CAAC;wBAED,OAAO;wBACL,aAAa;wBACb,eAAC,KAAK,mBACS,OAAO,CAAC,KAAK,KACtB,OAAO,KACP,WAAW,EACf,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,YAAY,EAClD,GAAG,EAAE,OAAO,CAAC,EAAE,GACf,CACH,CAAC;oBACJ,CAAC,CAAC,GACY,EAChB,YAAY,CACb,IACF,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import {\n useContext,\n useReducer,\n useMemo,\n useLayoutEffect,\n useRef,\n useState,\n forwardRef,\n useEffect\n} from 'react';\nimport type {\n FunctionComponent,\n CSSProperties,\n TransitionEvent,\n Context,\n PropsWithoutRef,\n Ref,\n Dispatch\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport Link, { StyledLink } from '../Link';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport {\n createUID,\n windowIsAvailable,\n withTestIds,\n hasProp,\n getActiveElement,\n getFocusables\n} from '../../utils';\nimport {\n useConfiguration,\n useI18n,\n useLiveLog,\n useOS,\n useShortcut,\n useTestIds,\n useConsolidatedRef,\n useEscape,\n useFocusWithin\n} from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport '../../init';\nimport { registerAction } from '../ShortcutManager';\nimport type { OmitStrict } from '../../types';\nimport { Keyboard } from '../Badges';\nimport { StyledKeyboard } from '../Badges/Keyboard';\n\nimport type { ToastMessage, ToasterProps, BaseToastMessage, CreatedMessage } from './Toaster.types';\nimport { ToasterContext } from './Context';\nimport type { ToasterContextValue } from './Context';\nimport { getToasterTestIds } from './Toaster.test-ids';\n\nregisterIcon(timesIcon);\nregisterAction(\n { id: 'JumpToToast', defaultKeyBinding: 'Alt+Enter' },\n { id: 'DismissToast', defaultKeyBinding: 'Alt+Q' }\n);\n\ntype ToastState = (\n | OmitStrict<BaseToastMessage, 'dismissAfter'>\n | OmitStrict<CreatedMessage, 'dismissAfter'>\n) & {\n id: NonNullable<ToastMessage['id']>;\n dismissAfter?: number;\n};\n\ntype ToastReducerAction =\n | { type: 'push'; payload: ToastState }\n | { type: 'unmount'; payload: ToastState['id'] };\n\ntype ToastProps = ToastState & {\n // determines if this is the first toast in the list, used to dismiss the first toast with a shortcut, not exposed outside\n firstToast: boolean;\n topLevelDismiss: ToasterProps['onDismiss'];\n translateY: number;\n dispatch: Dispatch<ToastReducerAction>;\n ref: Ref<HTMLDivElement>;\n};\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n toasterContext?: Context<ToasterContextValue>;\n }\n}\n\nconst StyledToastButton = styled.button(\n ({ theme }) => css`\n border: none;\n color: inherit;\n padding: 0;\n font-size: 1rem;\n margin-block: calc(${theme.base.spacing} / 2);\n margin-inline-end: calc(${theme.base.spacing} / 2);\n\n &:enabled:hover {\n background: #ffffff19;\n }\n\n &:enabled:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n `\n);\n\nStyledToastButton.defaultProps = defaultThemeProp;\n\nconst StyledToastContent = styled.div(({ theme }) => {\n return css`\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: clip;\n text-overflow: ellipsis;\n font-size: ${theme.base['font-size']};\n margin-inline-start: calc(${theme.base['border-radius']} / 2);\n padding-inline-start: calc(${theme.base.spacing} / 2);\n\n ${StyledLink} {\n color: ${theme.base.colors.blue.light};\n }\n `;\n});\n\nStyledToastContent.defaultProps = defaultThemeProp;\n\nconst StyledToast = styled.div(({ theme }) => {\n return css`\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 100%;\n background: ${theme.base.colors.slate['extra-dark']};\n color: ${theme.base.colors.white};\n border-radius: calc(${theme.base['border-radius']} / 2);\n opacity: var(--opacity);\n transform: translateY(var(--translateY)) scale(var(--scale));\n transition-property: transform, opacity;\n transition-duration: ${theme.base.animation.speed};\n transition-timing-function: ${theme.base.animation.timing.ease};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n\n :focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n\n ${StyledKeyboard} {\n color: ${theme.base.palette.light};\n background-color: ${theme.base.colors.gray.dark};\n border-color: ${theme.base.colors.gray.medium};\n inset-block-start: unset;\n }\n `;\n});\n\nStyledToast.defaultProps = defaultThemeProp;\n\nconst StyledToaster = styled.div(({ theme }) => {\n return css`\n position: fixed;\n z-index: ${theme.base['z-index'].toast};\n width: min(40ch, calc(100% - 1rem));\n inset-inline-start: 50%;\n transform: translateX(-50%);\n top: 100%;\n `;\n});\n\nStyledToaster.defaultProps = defaultThemeProp;\n\nfunction reducer(current: ToastState[], action: ToastReducerAction) {\n switch (action.type) {\n case 'push':\n return [\n ...current,\n {\n ...action.payload\n }\n ];\n\n case 'unmount':\n return current.filter(m => m.id !== action.payload);\n\n default:\n return current;\n }\n}\n\nconst Toast = forwardRef(function Toast(\n {\n id,\n firstToast,\n dispatch,\n topLevelDismiss,\n translateY,\n onDismiss,\n dismissAfter,\n ...restProps\n }: PropsWithoutRef<ToastProps>,\n ref: ToastProps['ref']\n) {\n const [dismissed, setDismissed] = useState(false);\n const timeoutRef = useRef(NaN);\n const t = useI18n();\n const { macintosh } = useOS();\n const { announcePolite } = useLiveLog();\n const content = hasProp(restProps, 'href') ? t('created') : restProps.content;\n const initiatorRef = useRef<HTMLElement | null>(null);\n const containerRef = useConsolidatedRef(ref);\n\n useEffect(() => {\n const fullMessage = hasProp(restProps, 'href')\n ? `${content} ${id} ${restProps.label}`\n : content;\n\n const shortcutJumpMessage = t('keypress_instruction', [\n macintosh ? 'Option + Enter' : 'Alt + Enter',\n t('shortcut_JumpToToast')\n ]);\n\n const shortcutDismissMessage = t('keypress_instruction', [\n macintosh ? 'Option + Q' : 'Alt + Q',\n t('shortcut_DismissToast')\n ]);\n\n announcePolite({\n message: `${fullMessage}. ${shortcutJumpMessage}. ${shortcutDismissMessage}.`,\n type: 'acknowledgement'\n });\n }, []);\n\n const onTransitionEnd = (e: TransitionEvent<HTMLDivElement>) => {\n if (dismissed && e.propertyName === 'opacity' && e.target === e.currentTarget) {\n dispatch({ type: 'unmount', payload: id });\n }\n };\n\n const dismiss = (timeout: boolean) => () => {\n if (initiatorRef.current) {\n initiatorRef.current?.focus?.();\n initiatorRef.current = null;\n }\n clearTimeout(timeoutRef.current);\n if (dismissed) return;\n setDismissed(true);\n onDismiss?.({ id, timeout });\n topLevelDismiss?.({ id, timeout });\n };\n\n const startTimer = () => {\n if (Number.isFinite(dismissAfter)) {\n timeoutRef.current = window.setTimeout(dismiss(true), dismissAfter);\n }\n };\n\n useEffect(() => {\n startTimer();\n return () => {\n window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n // Alt+Enter focuses on the first focusable element in the first toast.\n // Tab to the next toast if there are multiple.\n useShortcut('JumpToToast', () => {\n const activeElement = getActiveElement();\n if (activeElement && activeElement !== document.body) {\n initiatorRef.current = activeElement as HTMLElement;\n }\n if (firstToast && containerRef.current) {\n getFocusables(containerRef.current)[0]?.focus();\n }\n });\n\n // Alt+Q dismisses the first toast.\n useShortcut('DismissToast', () => {\n if (firstToast) dismiss(false)();\n });\n\n // Escape dismisses the toast and focuses the initiator.\n useEscape(() => {\n const currentFocus = getActiveElement();\n if (containerRef.current?.contains(currentFocus)) {\n dismiss(false)();\n }\n });\n\n useFocusWithin([containerRef], (focused: boolean) => {\n if (focused) {\n window.clearTimeout(timeoutRef.current);\n } else {\n startTimer();\n }\n });\n\n return (\n <Flex\n {...restProps}\n data-app-region\n container={{ alignItems: 'center', gap: 0.25 }}\n as={StyledToast}\n ref={containerRef}\n style={\n {\n '--translateY': `${-translateY}px`,\n '--opacity': dismissed ? '0' : '1',\n '--scale': dismissed ? '0' : '1'\n } as CSSProperties\n }\n onTransitionEnd={onTransitionEnd}\n >\n <Flex item={{ grow: 1 }} as={StyledToastContent}>\n {content}\n {hasProp(restProps, 'href') ? (\n <>\n {' '}\n <Link href={restProps.href}>\n ({id}): {restProps.label}\n </Link>\n </>\n ) : undefined}\n </Flex>\n <Flex container={{ inline: true, justify: 'end', gap: 0.5 }}>\n <Keyboard keyName='Alt' />\n <Keyboard keyName='Enter' />\n </Flex>\n <Button\n as={StyledToastButton}\n variant='simple'\n onClick={dismiss(false)}\n icon\n aria-label={t('dismiss_label')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n );\n});\n\nconst Toaster: FunctionComponent<ToasterProps> = ({\n testId,\n children,\n dismissAfter = Infinity,\n onDismiss\n}: ToasterProps) => {\n const { portalTarget } = useConfiguration();\n const [messages, dispatch] = useReducer(reducer, []);\n const [yOffsets, setYOffsets] = useState<number[]>([]);\n const heightHashRef = useRef<{\n [id: string]: number;\n }>({});\n const testIds = useTestIds(testId, getToasterTestIds);\n\n // This effect will cause a re-render with a translateY value set for each toast.\n useLayoutEffect(() => {\n const heights = [...messages].reverse().map(({ id }) => heightHashRef.current[id]);\n\n setYOffsets(\n heights\n .map((_, i) => heights.slice(0, i + 1).reduce((sum, cur) => sum + cur + 4, 0))\n .reverse()\n );\n }, [messages.length]);\n\n const providerValue = useMemo(\n () => ({\n push(incoming: ToastMessage) {\n const message: ToastState = {\n ...incoming,\n id: incoming.id ?? createUID(),\n dismissAfter: hasProp(incoming, 'href') ? 10_000 : incoming.dismissAfter\n };\n\n dispatch({\n type: 'push',\n payload: message\n });\n },\n initialized: true\n }),\n []\n );\n\n // Don't create additional ToasterContext.Providers.\n const context = windowIsAvailable\n ? window.cosmos.toasterContext ?? ToasterContext\n : ToasterContext;\n const priorCtx = useContext(context);\n if (priorCtx.initialized) {\n return <context.Provider value={priorCtx}>{children}</context.Provider>;\n }\n\n return (\n <>\n <context.Provider value={providerValue}>{children}</context.Provider>\n {!!messages.length &&\n portalTarget &&\n createPortal(\n <StyledToaster data-testid={testIds.root}>\n {messages.map((message, i) => {\n const sharedProps = {\n translateY: yOffsets[i] ?? 0,\n firstToast: i === 0,\n topLevelDismiss: onDismiss,\n dispatch,\n ref: el => {\n if (el) {\n heightHashRef.current[message.id] = el.offsetHeight;\n } else {\n delete heightHashRef.current[message.id];\n }\n }\n } satisfies Partial<ToastProps>;\n\n if (hasProp(message, 'href')) {\n return (\n // Toast with Link\n <Toast\n data-testid={testIds.toast}\n {...message}\n {...sharedProps}\n key={message.id}\n />\n );\n }\n\n return (\n // Base Toast\n <Toast\n data-testid={testIds.toast}\n {...message}\n {...sharedProps}\n dismissAfter={message.dismissAfter ?? dismissAfter}\n key={message.id}\n />\n );\n })}\n </StyledToaster>,\n portalTarget\n )}\n </>\n );\n};\n\nexport default withTestIds(Toaster, getToasterTestIds);\n"]}
1
+ {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,OAAO,EACP,eAAe,EACf,MAAM,EACN,QAAQ,EACR,UAAU,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,CAAC,EAAE,GACf,CACH,CAAC;oBACJ,CAAC,CAAC,GACY,EAChB,YAAY,CACb,IACF,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import {\n useContext,\n useReducer,\n useMemo,\n useLayoutEffect,\n useRef,\n useState,\n forwardRef,\n useEffect\n} from 'react';\nimport type {\n FunctionComponent,\n CSSProperties,\n TransitionEvent,\n Context,\n PropsWithoutRef,\n Ref,\n Dispatch\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport Link, { StyledLink } from '../Link';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport {\n createUID,\n windowIsAvailable,\n withTestIds,\n hasProp,\n getActiveElement,\n getFocusables\n} from '../../utils';\nimport {\n useConfiguration,\n useI18n,\n useLiveLog,\n useOS,\n useShortcut,\n useTestIds,\n useConsolidatedRef,\n useEscape,\n useFocusWithin\n} from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport '../../init';\nimport { registerAction } from '../ShortcutManager';\nimport type { OmitStrict } from '../../types';\nimport { Keyboard } from '../Badges';\nimport { StyledKeyboard } from '../Badges/Keyboard';\n\nimport type { ToastMessage, ToasterProps, BaseToastMessage, CreatedMessage } from './Toaster.types';\nimport { ToasterContext } from './Context';\nimport type { ToasterContextValue } from './Context';\nimport { getToasterTestIds } from './Toaster.test-ids';\n\nregisterIcon(timesIcon);\nregisterAction(\n { id: 'JumpToToast', defaultKeyBinding: 'Alt+Enter' },\n { id: 'DismissToast', defaultKeyBinding: 'Alt+Q' }\n);\n\ntype ToastState = (\n | OmitStrict<BaseToastMessage, 'dismissAfter'>\n | OmitStrict<CreatedMessage, 'dismissAfter'>\n) & {\n id: NonNullable<ToastMessage['id']>;\n dismissAfter: number;\n};\n\ntype ToastReducerAction =\n | { type: 'push'; payload: ToastState }\n | { type: 'unmount'; payload: ToastState['id'] };\n\ntype ToastProps = ToastState & {\n // determines if this is the first toast in the list, used to dismiss the first toast with a shortcut, not exposed outside\n firstToast: boolean;\n topLevelDismiss: ToasterProps['onDismiss'];\n translateY: number;\n dispatch: Dispatch<ToastReducerAction>;\n ref: Ref<HTMLDivElement>;\n};\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n toasterContext?: Context<ToasterContextValue>;\n }\n}\n\nconst StyledToastButton = styled.button(\n ({ theme }) => css`\n border: none;\n color: inherit;\n padding: 0;\n font-size: 1rem;\n margin-block: calc(${theme.base.spacing} / 2);\n margin-inline-end: calc(${theme.base.spacing} / 2);\n\n &:enabled:hover {\n background: #ffffff19;\n }\n\n &:enabled:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n `\n);\n\nStyledToastButton.defaultProps = defaultThemeProp;\n\nconst StyledToastContent = styled.div(({ theme }) => {\n return css`\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: clip;\n text-overflow: ellipsis;\n font-size: ${theme.base['font-size']};\n margin-inline-start: calc(${theme.base['border-radius']} / 2);\n padding-inline-start: calc(${theme.base.spacing} / 2);\n\n ${StyledLink} {\n color: ${theme.base.colors.blue.light};\n }\n `;\n});\n\nStyledToastContent.defaultProps = defaultThemeProp;\n\nconst StyledToast = styled.div(({ theme }) => {\n return css`\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 100%;\n background: ${theme.base.colors.slate['extra-dark']};\n color: ${theme.base.colors.white};\n border-radius: calc(${theme.base['border-radius']} / 2);\n opacity: var(--opacity);\n transform: translateY(var(--translateY)) scale(var(--scale));\n transition-property: transform, opacity;\n transition-duration: ${theme.base.animation.speed};\n transition-timing-function: ${theme.base.animation.timing.ease};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n\n :focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n\n ${StyledKeyboard} {\n color: ${theme.base.palette.light};\n background-color: ${theme.base.colors.gray.dark};\n border-color: ${theme.base.colors.gray.medium};\n inset-block-start: unset;\n }\n `;\n});\n\nStyledToast.defaultProps = defaultThemeProp;\n\nconst StyledToaster = styled.div(({ theme }) => {\n return css`\n position: fixed;\n z-index: ${theme.base['z-index'].toast};\n width: min(40ch, calc(100% - 1rem));\n inset-inline-start: 50%;\n transform: translateX(-50%);\n top: 100%;\n `;\n});\n\nStyledToaster.defaultProps = defaultThemeProp;\n\nfunction reducer(current: ToastState[], action: ToastReducerAction) {\n switch (action.type) {\n case 'push':\n return [\n ...current,\n {\n ...action.payload\n }\n ];\n\n case 'unmount':\n return current.filter(m => m.id !== action.payload);\n\n default:\n return current;\n }\n}\n\nconst Toast = forwardRef(function Toast(\n {\n id,\n firstToast,\n dispatch,\n topLevelDismiss,\n translateY,\n onDismiss,\n dismissAfter,\n ...restProps\n }: PropsWithoutRef<ToastProps>,\n ref: ToastProps['ref']\n) {\n const [dismissed, setDismissed] = useState(false);\n const timeoutRef = useRef(NaN);\n const t = useI18n();\n const { macintosh } = useOS();\n const { announcePolite } = useLiveLog();\n const content = hasProp(restProps, 'href') ? t('created') : restProps.content;\n const initiatorRef = useRef<HTMLElement | null>(null);\n const containerRef = useConsolidatedRef(ref);\n\n useEffect(() => {\n const fullMessage = hasProp(restProps, 'href')\n ? `${content} ${id} ${restProps.label}`\n : content;\n\n const shortcutJumpMessage = t('keypress_instruction', [\n macintosh ? 'Option + Enter' : 'Alt + Enter',\n t('shortcut_JumpToToast')\n ]);\n\n const shortcutDismissMessage = t('keypress_instruction', [\n macintosh ? 'Option + Q' : 'Alt + Q',\n t('shortcut_DismissToast')\n ]);\n\n announcePolite({\n message: `${fullMessage}. ${shortcutJumpMessage}. ${shortcutDismissMessage}.`,\n type: 'acknowledgement'\n });\n }, []);\n\n const onTransitionEnd = (e: TransitionEvent<HTMLDivElement>) => {\n if (dismissed && e.propertyName === 'opacity' && e.target === e.currentTarget) {\n dispatch({ type: 'unmount', payload: id });\n }\n };\n\n const dismiss = (timeout: boolean) => () => {\n if (initiatorRef.current) {\n initiatorRef.current?.focus?.();\n initiatorRef.current = null;\n }\n clearTimeout(timeoutRef.current);\n if (dismissed) return;\n setDismissed(true);\n onDismiss?.({ id, timeout });\n topLevelDismiss?.({ id, timeout });\n };\n\n const startTimer = () => {\n if (Number.isFinite(dismissAfter)) {\n timeoutRef.current = window.setTimeout(dismiss(true), dismissAfter);\n }\n };\n\n useEffect(() => {\n startTimer();\n return () => {\n window.clearTimeout(timeoutRef.current);\n };\n }, []);\n\n // Alt+Enter focuses on the first focusable element in the first toast.\n // Tab to the next toast if there are multiple.\n useShortcut('JumpToToast', () => {\n const activeElement = getActiveElement();\n if (activeElement && activeElement !== document.body) {\n initiatorRef.current = activeElement as HTMLElement;\n }\n if (firstToast && containerRef.current) {\n getFocusables(containerRef.current)[0]?.focus();\n }\n });\n\n // Alt+Q dismisses the first toast.\n useShortcut('DismissToast', () => {\n if (firstToast) dismiss(false)();\n });\n\n // Escape dismisses the toast and focuses the initiator.\n useEscape(() => {\n const currentFocus = getActiveElement();\n if (containerRef.current?.contains(currentFocus)) {\n dismiss(false)();\n }\n });\n\n useFocusWithin([containerRef], (focused: boolean) => {\n if (focused) {\n window.clearTimeout(timeoutRef.current);\n } else {\n startTimer();\n }\n });\n\n return (\n <Flex\n {...restProps}\n data-app-region\n container={{ alignItems: 'center', gap: 0.25 }}\n as={StyledToast}\n ref={containerRef}\n style={\n {\n '--translateY': `${-translateY}px`,\n '--opacity': dismissed ? '0' : '1',\n '--scale': dismissed ? '0' : '1'\n } as CSSProperties\n }\n onTransitionEnd={onTransitionEnd}\n >\n <Flex item={{ grow: 1 }} as={StyledToastContent}>\n {content}\n {hasProp(restProps, 'href') ? (\n <>\n {' '}\n <Link href={restProps.href}>\n ({id}): {restProps.label}\n </Link>\n </>\n ) : undefined}\n </Flex>\n <Flex container={{ inline: true, justify: 'end', gap: 0.5 }}>\n <Keyboard keyName='Alt' />\n <Keyboard keyName='Enter' />\n </Flex>\n <Button\n as={StyledToastButton}\n variant='simple'\n onClick={dismiss(false)}\n icon\n aria-label={t('dismiss_label')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n );\n});\n\nconst Toaster: FunctionComponent<ToasterProps> = ({\n testId,\n children,\n dismissAfter = 7_500,\n onDismiss\n}: ToasterProps) => {\n const { portalTarget } = useConfiguration();\n const [messages, dispatch] = useReducer(reducer, []);\n const [yOffsets, setYOffsets] = useState<number[]>([]);\n const heightHashRef = useRef<{\n [id: string]: number;\n }>({});\n const testIds = useTestIds(testId, getToasterTestIds);\n\n // This effect will cause a re-render with a translateY value set for each toast.\n useLayoutEffect(() => {\n const heights = [...messages].reverse().map(({ id }) => heightHashRef.current[id]);\n\n setYOffsets(\n heights\n .map((_, i) => heights.slice(0, i + 1).reduce((sum, cur) => sum + cur + 4, 0))\n .reverse()\n );\n }, [messages.length]);\n\n const providerValue = useMemo(\n () => ({\n push(incoming: ToastMessage) {\n const message: ToastState = {\n ...incoming,\n id: incoming.id ?? createUID(),\n dismissAfter: hasProp(incoming, 'href')\n ? 15_000\n : Math.max(incoming.dismissAfter ?? 7_500, 7_500)\n };\n\n dispatch({\n type: 'push',\n payload: message\n });\n },\n initialized: true\n }),\n []\n );\n\n // Don't create additional ToasterContext.Providers.\n const context = windowIsAvailable\n ? window.cosmos.toasterContext ?? ToasterContext\n : ToasterContext;\n const priorCtx = useContext(context);\n if (priorCtx.initialized) {\n return <context.Provider value={priorCtx}>{children}</context.Provider>;\n }\n\n return (\n <>\n <context.Provider value={providerValue}>{children}</context.Provider>\n {!!messages.length &&\n portalTarget &&\n createPortal(\n <StyledToaster data-testid={testIds.root}>\n {messages.map((message, i) => {\n const sharedProps = {\n translateY: yOffsets[i] ?? 0,\n firstToast: i === 0,\n topLevelDismiss: onDismiss,\n dispatch,\n ref: el => {\n if (el) {\n heightHashRef.current[message.id] = el.offsetHeight;\n } else {\n delete heightHashRef.current[message.id];\n }\n }\n } satisfies Partial<ToastProps>;\n\n if (hasProp(message, 'href')) {\n return (\n // Toast with Link\n <Toast\n data-testid={testIds.toast}\n {...message}\n {...sharedProps}\n key={message.id}\n />\n );\n }\n\n return (\n // Base Toast\n <Toast\n data-testid={testIds.toast}\n {...message}\n {...sharedProps}\n dismissAfter={Math.max(message.dismissAfter, dismissAfter)}\n key={message.id}\n />\n );\n })}\n </StyledToaster>,\n portalTarget\n )}\n </>\n );\n};\n\nexport default withTestIds(Toaster, getToasterTestIds);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "8.17.2",
3
+ "version": "8.18.1",
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",