@cloudscape-design/components 3.0.532 → 3.0.533
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/date-range-picker/index.d.ts.map +1 -1
- package/date-range-picker/index.js +21 -5
- package/date-range-picker/index.js.map +1 -1
- package/date-range-picker/interfaces.d.ts +16 -0
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/date-range-picker/interfaces.js.map +1 -1
- package/date-range-picker/styles.css.js +39 -38
- package/date-range-picker/styles.scoped.css +51 -46
- package/date-range-picker/styles.selectors.js +39 -38
- package/date-range-picker/time-offset.js +3 -3
- package/date-range-picker/time-offset.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/internal/utils/date-time/format-date-iso.d.ts +7 -0
- package/internal/utils/date-time/format-date-iso.d.ts.map +1 -0
- package/internal/utils/date-time/format-date-iso.js +8 -0
- package/internal/utils/date-time/format-date-iso.js.map +1 -0
- package/internal/utils/date-time/format-date-localized.d.ts +8 -0
- package/internal/utils/date-time/format-date-localized.d.ts.map +1 -0
- package/internal/utils/date-time/format-date-localized.js +32 -0
- package/internal/utils/date-time/format-date-localized.js.map +1 -0
- package/internal/utils/date-time/format-date-range.d.ts +11 -3
- package/internal/utils/date-time/format-date-range.d.ts.map +1 -1
- package/internal/utils/date-time/format-date-range.js +30 -5
- package/internal/utils/date-time/format-date-range.js.map +1 -1
- package/internal/utils/date-time/format-time-offset.d.ts +3 -0
- package/internal/utils/date-time/format-time-offset.d.ts.map +1 -0
- package/internal/utils/date-time/format-time-offset.js +31 -0
- package/internal/utils/date-time/format-time-offset.js.map +1 -0
- package/internal/utils/date-time/index.d.ts +1 -1
- package/internal/utils/date-time/index.d.ts.map +1 -1
- package/internal/utils/date-time/index.js +1 -1
- package/internal/utils/date-time/index.js.map +1 -1
- package/package.json +1 -1
- package/internal/utils/date-time/format-timezone-offset.d.ts +0 -2
- package/internal/utils/date-time/format-timezone-offset.d.ts.map +0 -1
- package/internal/utils/date-time/format-timezone-offset.js +0 -12
- package/internal/utils/date-time/format-timezone-offset.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["date-range-picker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA8BpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["date-range-picker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA8BpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAuEhC,QAAA,MAAM,eAAe,uGAkPpB,CAAC;AAGF,eAAe,eAAe,CAAC"}
|
|
@@ -31,12 +31,19 @@ import { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';
|
|
|
31
31
|
import { useInternalI18n } from '../i18n/context';
|
|
32
32
|
import { formatValue } from './utils';
|
|
33
33
|
import ResetContextsForModal from '../internal/context/reset-contexts-for-modal.js';
|
|
34
|
-
function renderDateRange(range, placeholder, formatRelativeRange, timeOffset) {
|
|
34
|
+
function renderDateRange({ locale, range, placeholder = '', formatRelativeRange, absoluteFormat, hideTimeOffset, timeOffset, }) {
|
|
35
35
|
var _a;
|
|
36
36
|
if (!range) {
|
|
37
37
|
return (React.createElement("span", { className: styles['label-text'], "aria-disabled": true }, placeholder));
|
|
38
38
|
}
|
|
39
|
-
const formatted = range.type === 'relative' ? ((_a = formatRelativeRange === null || formatRelativeRange === void 0 ? void 0 : formatRelativeRange(range)) !== null && _a !== void 0 ? _a : '') : (React.createElement(BreakSpaces, { text: formatDateRange(
|
|
39
|
+
const formatted = range.type === 'relative' ? ((_a = formatRelativeRange === null || formatRelativeRange === void 0 ? void 0 : formatRelativeRange(range)) !== null && _a !== void 0 ? _a : '') : (React.createElement(BreakSpaces, { text: formatDateRange({
|
|
40
|
+
startDate: range.startDate,
|
|
41
|
+
endDate: range.endDate,
|
|
42
|
+
timeOffset,
|
|
43
|
+
hideTimeOffset,
|
|
44
|
+
format: absoluteFormat,
|
|
45
|
+
locale,
|
|
46
|
+
}) }));
|
|
40
47
|
return (React.createElement(InternalBox, { fontWeight: "normal", display: "inline", color: "inherit", variant: "span" }, formatted));
|
|
41
48
|
}
|
|
42
49
|
function BreakSpaces({ text }) {
|
|
@@ -53,7 +60,7 @@ function isDateOnly(value) {
|
|
|
53
60
|
}
|
|
54
61
|
const DateRangePicker = React.forwardRef((_a, ref) => {
|
|
55
62
|
var _b, _c;
|
|
56
|
-
var { locale = '', startOfWeek, isDateEnabled = () => true, value, placeholder, readOnly = false, disabled = false, onChange, onBlur, onFocus, relativeOptions = [], i18nStrings, isValidRange = () => ({ valid: true }), showClearButton = true, dateOnly = false, timeOffset, getTimeOffset, timeInputFormat = 'hh:mm:ss', expandToViewport = false, rangeSelectorMode = 'default', customAbsoluteRangeControl } = _a, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "value", "placeholder", "readOnly", "disabled", "onChange", "onBlur", "onFocus", "relativeOptions", "i18nStrings", "isValidRange", "showClearButton", "dateOnly", "timeOffset", "getTimeOffset", "timeInputFormat", "expandToViewport", "rangeSelectorMode", "customAbsoluteRangeControl"]);
|
|
63
|
+
var { locale = '', startOfWeek, isDateEnabled = () => true, value, placeholder, readOnly = false, disabled = false, onChange, onBlur, onFocus, relativeOptions = [], i18nStrings, isValidRange = () => ({ valid: true }), showClearButton = true, dateOnly = false, timeOffset, getTimeOffset, timeInputFormat = 'hh:mm:ss', expandToViewport = false, rangeSelectorMode = 'default', customAbsoluteRangeControl, absoluteFormat = 'iso', hideTimeOffset } = _a, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "value", "placeholder", "readOnly", "disabled", "onChange", "onBlur", "onFocus", "relativeOptions", "i18nStrings", "isValidRange", "showClearButton", "dateOnly", "timeOffset", "getTimeOffset", "timeInputFormat", "expandToViewport", "rangeSelectorMode", "customAbsoluteRangeControl", "absoluteFormat", "hideTimeOffset"]);
|
|
57
64
|
const { __internalRootRef } = useBaseComponent('DateRangePicker');
|
|
58
65
|
checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);
|
|
59
66
|
const normalizedTimeOffset = normalizeTimeOffset(value, getTimeOffset, timeOffset);
|
|
@@ -131,6 +138,15 @@ const DateRangePicker = React.forwardRef((_a, ref) => {
|
|
|
131
138
|
warnOnce('DateRangePicker', 'A function for i18nStrings.formatRelativeRange was not provided. Relative ranges will not be correctly rendered.');
|
|
132
139
|
}
|
|
133
140
|
}
|
|
141
|
+
const formattedDate = renderDateRange({
|
|
142
|
+
locale: normalizedLocale,
|
|
143
|
+
range: value,
|
|
144
|
+
placeholder,
|
|
145
|
+
formatRelativeRange,
|
|
146
|
+
absoluteFormat,
|
|
147
|
+
hideTimeOffset,
|
|
148
|
+
timeOffset: normalizedTimeOffset,
|
|
149
|
+
});
|
|
134
150
|
const trigger = (React.createElement("div", { className: styles['trigger-wrapper'] },
|
|
135
151
|
React.createElement(ButtonTrigger, { ref: triggerRef, id: controlId, invalid: invalid, ariaLabelledby: joinStrings(ariaLabelledby, triggerContentId), ariaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.ariaLabel, ariaDescribedby: ariaDescribedby, className: clsx(styles.label, {
|
|
136
152
|
[styles['label-enabled']]: !readOnly && !disabled,
|
|
@@ -142,9 +158,9 @@ const DateRangePicker = React.forwardRef((_a, ref) => {
|
|
|
142
158
|
React.createElement("span", { className: styles['trigger-flexbox'] },
|
|
143
159
|
React.createElement("span", { className: styles['icon-wrapper'] },
|
|
144
160
|
React.createElement(InternalIcon, { name: "calendar", variant: disabled || readOnly ? 'disabled' : 'normal' })),
|
|
145
|
-
React.createElement("span", { id: triggerContentId },
|
|
161
|
+
React.createElement("span", { id: triggerContentId }, formattedDate)))));
|
|
146
162
|
const mergedRef = useMergeRefs(rootRef, __internalRootRef);
|
|
147
|
-
return (React.createElement("div", Object.assign({}, baseProps, { ref: mergedRef, className: clsx(baseProps.className, styles.root), onKeyDown: onWrapperKeyDownHandler }),
|
|
163
|
+
return (React.createElement("div", Object.assign({}, baseProps, { ref: mergedRef, className: clsx(baseProps.className, styles.root, absoluteFormat === 'long-localized' && !dateOnly && styles.wide), onKeyDown: onWrapperKeyDownHandler }),
|
|
148
164
|
React.createElement(Dropdown, { stretchWidth: true, stretchHeight: true, open: isDropDownOpen, onDropdownClose: () => closeDropdown(), trigger: trigger, stretchToTriggerWidth: false, expandToViewport: expandToViewport, dropdownId: dropdownId },
|
|
149
165
|
React.createElement(ResetContextsForModal, null, isDropDownOpen && (React.createElement(DateRangePickerDropdown, { startOfWeek: startOfWeek, locale: normalizedLocale, isSingleGrid: isSingleGrid, onDropdownClose: () => closeDropdown(true), value: value, showClearButton: showClearButton, isDateEnabled: isDateEnabled, i18nStrings: i18nStrings, onClear: onClear, onApply: onApply, relativeOptions: relativeOptions, isValidRange: isValidRange, dateOnly: dateOnly, timeInputFormat: timeInputFormat, rangeSelectorMode: rangeSelectorMode, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, customAbsoluteRangeControl: customAbsoluteRangeControl }))))));
|
|
150
166
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-range-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,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AAI,EAClB,aAAa,EAAE,IAAI,EACnB,IAAI,EAAE,cAAc,EACpB,eAAe,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,EACtC,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,KAAK,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU;YAGtB,oBAAC,qBAAqB,QACnB,cAAc,IAAI,CACjB,oBAAC,uBAAuB,IACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAC1C,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,0BAA0B,EAAE,0BAA0B,GACtD,CACH,CACqB,CACf,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AACrD,eAAe,eAAe,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useEffect, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DateRangePickerProps } from './interfaces';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { KeyCode } from '../internal/keycode';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport InternalBox from '../box/internal';\nimport { DateRangePickerDropdown } from './dropdown';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport Dropdown from '../internal/components/dropdown';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport ButtonTrigger from '../internal/components/button-trigger';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport InternalIcon from '../icon/internal';\nimport { normalizeTimeOffset, shiftTimeOffset } from './time-offset';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { isDevelopment } from '../internal/is-development.js';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings/join-strings';\nimport { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';\nimport { useInternalI18n } from '../i18n/context';\nimport { formatValue } from './utils';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal.js';\n\nexport { DateRangePickerProps };\n\nfunction renderDateRange(\n range: null | DateRangePickerProps.Value,\n placeholder: string,\n formatRelativeRange: DateRangePickerProps.I18nStrings['formatRelativeRange'],\n timeOffset: { startDate?: number; endDate?: number }\n) {\n if (!range) {\n return (\n <span className={styles['label-text']} aria-disabled={true}>\n {placeholder}\n </span>\n );\n }\n\n const formatted =\n range.type === 'relative' ? (\n formatRelativeRange?.(range) ?? ''\n ) : (\n <BreakSpaces text={formatDateRange(range.startDate, range.endDate, timeOffset)} />\n );\n\n return (\n <InternalBox fontWeight=\"normal\" display=\"inline\" color=\"inherit\" variant=\"span\">\n {formatted}\n </InternalBox>\n );\n}\n\nfunction BreakSpaces({ text }: { text: string }) {\n const tokens = text.split(/( )/);\n return (\n <>\n {tokens.map((token, index) => (\n <React.Fragment key={index}>\n {token.length > 1 ? <span className={styles['label-token-nowrap']}>{token}</span> : token}\n {token === ' ' && <wbr />}\n </React.Fragment>\n ))}\n </>\n );\n}\n\nfunction isDateOnly(value: null | DateRangePickerProps.Value) {\n if (!value || value.type !== 'absolute') {\n return false;\n }\n return isIsoDateOnly(value.startDate) && isIsoDateOnly(value.endDate);\n}\n\nconst DateRangePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n value,\n placeholder,\n readOnly = false,\n disabled = false,\n onChange,\n onBlur,\n onFocus,\n relativeOptions = [],\n i18nStrings,\n isValidRange = () => ({ valid: true }),\n showClearButton = true,\n dateOnly = false,\n timeOffset,\n getTimeOffset,\n timeInputFormat = 'hh:mm:ss',\n expandToViewport = false,\n rangeSelectorMode = 'default',\n customAbsoluteRangeControl,\n ...rest\n }: DateRangePickerProps,\n ref: Ref<DateRangePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DateRangePicker');\n checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);\n\n const normalizedTimeOffset = normalizeTimeOffset(value, getTimeOffset, timeOffset);\n value = isDateOnly(value) ? value : shiftTimeOffset(value, normalizedTimeOffset);\n\n const baseProps = getBaseProps(rest);\n const { invalid, controlId, ariaDescribedby, ariaLabelledby } = useFormFieldContext({\n ariaLabelledby: rest.ariaLabelledby ?? i18nStrings?.ariaLabelledby,\n ariaDescribedby: rest.ariaDescribedby ?? i18nStrings?.ariaDescribedby,\n ...rest,\n });\n const isSingleGrid = useMobile();\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n useForwardFocus(ref, triggerRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('date-range-picker-dropdown');\n const triggerContentId = useUniqueId('date-range-picker-trigger');\n\n useFocusTracker({ rootRef, onBlur, onFocus });\n\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n\n const closeDropdown = (focusTrigger = false) => {\n setIsDropDownOpen(false);\n if (focusTrigger) {\n triggerRef.current?.focus();\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape) {\n if (isDropDownOpen) {\n event.stopPropagation();\n }\n closeDropdown(true);\n }\n };\n\n const onClear = () => {\n fireNonCancelableEvent(onChange, { value: null });\n };\n\n const onApply = (newValue: null | DateRangePickerProps.Value): DateRangePickerProps.ValidationResult => {\n const validationResult = isValidRange(newValue);\n if (validationResult?.valid === false) {\n return validationResult;\n }\n\n if (isDevelopment) {\n if (newValue?.type === 'absolute') {\n const [startDateWithoutTime] = newValue.startDate.split('T');\n const [endDateWithoutTime] = newValue.endDate.split('T');\n if (!startDateWithoutTime || !endDateWithoutTime) {\n warnOnce(\n 'DateRangePicker',\n 'You have provided an `isValidRange` prop that did not catch a missing start or end date.'\n );\n }\n }\n }\n fireNonCancelableEvent(onChange, {\n value: formatValue(newValue, {\n dateOnly,\n timeOffset: normalizeTimeOffset(newValue, getTimeOffset, timeOffset),\n }),\n });\n return validationResult || { valid: true };\n };\n\n const prevDateOnly = usePrevious(dateOnly);\n useEffect(() => {\n if (prevDateOnly !== undefined && prevDateOnly !== dateOnly) {\n warnOnce(\n 'DateRangePicker',\n `The provided \\`dateOnly\\` flag has been changed from \"${prevDateOnly}\" to \"${dateOnly}\" which can lead to unexpected value format. Consider using separate components.`\n );\n }\n }, [prevDateOnly, dateOnly]);\n\n if (value && value.type !== 'absolute' && value.type !== 'relative') {\n warnOnce('DateRangePicker', 'You provided an invalid value. Reverting back to default.');\n value = null;\n }\n\n if (\n (value?.type === 'absolute' && rangeSelectorMode === 'relative-only') ||\n (value?.type === 'relative' && rangeSelectorMode === 'absolute-only')\n ) {\n warnOnce(\n 'DateRangePicker',\n 'The provided value does not correspond to the current range selector mode. Reverting back to default.'\n );\n value = null;\n }\n\n const i18n = useInternalI18n('date-range-picker');\n const formatRelativeRange = i18n(\n 'i18nStrings.formatRelativeRange',\n i18nStrings?.formatRelativeRange,\n format =>\n ({ amount, unit }) =>\n format({ amount, unit })\n );\n\n if (isDevelopment) {\n if (!formatRelativeRange && rangeSelectorMode !== 'absolute-only') {\n warnOnce(\n 'DateRangePicker',\n 'A function for i18nStrings.formatRelativeRange was not provided. Relative ranges will not be correctly rendered.'\n );\n }\n }\n\n const trigger = (\n <div className={styles['trigger-wrapper']}>\n <ButtonTrigger\n ref={triggerRef}\n id={controlId}\n invalid={invalid}\n ariaLabelledby={joinStrings(ariaLabelledby, triggerContentId)}\n ariaLabel={i18nStrings?.ariaLabel}\n ariaDescribedby={ariaDescribedby}\n className={clsx(styles.label, {\n [styles['label-enabled']]: !readOnly && !disabled,\n })}\n hideCaret={true}\n onClick={() => {\n if (!readOnly && !disabled) {\n setIsDropDownOpen(true);\n }\n }}\n disabled={disabled}\n readOnly={readOnly}\n ariaHasPopup=\"dialog\"\n >\n <span className={styles['trigger-flexbox']}>\n <span className={styles['icon-wrapper']}>\n <InternalIcon name=\"calendar\" variant={disabled || readOnly ? 'disabled' : 'normal'} />\n </span>\n <span id={triggerContentId}>\n {renderDateRange(value, placeholder ?? '', formatRelativeRange, normalizedTimeOffset)}\n </span>\n </span>\n </ButtonTrigger>\n </div>\n );\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n return (\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(baseProps.className, styles.root)}\n onKeyDown={onWrapperKeyDownHandler}\n >\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={() => closeDropdown()}\n trigger={trigger}\n stretchToTriggerWidth={false}\n expandToViewport={expandToViewport}\n dropdownId={dropdownId}\n >\n {/* Reset form field context to prevent a wrapper form field from labelling all inputs inside the dropdown. */}\n <ResetContextsForModal>\n {isDropDownOpen && (\n <DateRangePickerDropdown\n startOfWeek={startOfWeek}\n locale={normalizedLocale}\n isSingleGrid={isSingleGrid}\n onDropdownClose={() => closeDropdown(true)}\n value={value}\n showClearButton={showClearButton}\n isDateEnabled={isDateEnabled}\n i18nStrings={i18nStrings}\n onClear={onClear}\n onApply={onApply}\n relativeOptions={relativeOptions}\n isValidRange={isValidRange}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n rangeSelectorMode={rangeSelectorMode}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n customAbsoluteRangeControl={customAbsoluteRangeControl}\n />\n )}\n </ResetContextsForModal>\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DateRangePicker, 'DateRangePicker');\nexport default DateRangePicker;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-range-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC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AAqB,QACnB,cAAc,IAAI,CACjB,oBAAC,uBAAuB,IACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAC1C,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,0BAA0B,EAAE,0BAA0B,GACtD,CACH,CACqB,CACf,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AACrD,eAAe,eAAe,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useEffect, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DateRangePickerProps } from './interfaces';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { KeyCode } from '../internal/keycode';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport InternalBox from '../box/internal';\nimport { DateRangePickerDropdown } from './dropdown';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport Dropdown from '../internal/components/dropdown';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport ButtonTrigger from '../internal/components/button-trigger';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport InternalIcon from '../icon/internal';\nimport { normalizeTimeOffset, shiftTimeOffset } from './time-offset';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { isDevelopment } from '../internal/is-development.js';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings/join-strings';\nimport { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';\nimport { useInternalI18n } from '../i18n/context';\nimport { formatValue } from './utils';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal.js';\n\nexport { DateRangePickerProps };\n\nfunction renderDateRange({\n locale,\n range,\n placeholder = '',\n formatRelativeRange,\n absoluteFormat,\n hideTimeOffset,\n timeOffset,\n}: {\n locale?: string;\n range: null | DateRangePickerProps.Value;\n placeholder?: string;\n formatRelativeRange: DateRangePickerProps.I18nStrings['formatRelativeRange'];\n absoluteFormat: DateRangePickerProps.AbsoluteFormat;\n hideTimeOffset?: boolean;\n timeOffset: { startDate?: number; endDate?: number };\n}) {\n if (!range) {\n return (\n <span className={styles['label-text']} aria-disabled={true}>\n {placeholder}\n </span>\n );\n }\n\n const formatted =\n range.type === 'relative' ? (\n formatRelativeRange?.(range) ?? ''\n ) : (\n <BreakSpaces\n text={formatDateRange({\n startDate: range.startDate,\n endDate: range.endDate,\n timeOffset,\n hideTimeOffset,\n format: absoluteFormat,\n locale,\n })}\n />\n );\n\n return (\n <InternalBox fontWeight=\"normal\" display=\"inline\" color=\"inherit\" variant=\"span\">\n {formatted}\n </InternalBox>\n );\n}\n\nfunction BreakSpaces({ text }: { text: string }) {\n const tokens = text.split(/( )/);\n return (\n <>\n {tokens.map((token, index) => (\n <React.Fragment key={index}>\n {token.length > 1 ? <span className={styles['label-token-nowrap']}>{token}</span> : token}\n {token === ' ' && <wbr />}\n </React.Fragment>\n ))}\n </>\n );\n}\n\nfunction isDateOnly(value: null | DateRangePickerProps.Value) {\n if (!value || value.type !== 'absolute') {\n return false;\n }\n return isIsoDateOnly(value.startDate) && isIsoDateOnly(value.endDate);\n}\n\nconst DateRangePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n value,\n placeholder,\n readOnly = false,\n disabled = false,\n onChange,\n onBlur,\n onFocus,\n relativeOptions = [],\n i18nStrings,\n isValidRange = () => ({ valid: true }),\n showClearButton = true,\n dateOnly = false,\n timeOffset,\n getTimeOffset,\n timeInputFormat = 'hh:mm:ss',\n expandToViewport = false,\n rangeSelectorMode = 'default',\n customAbsoluteRangeControl,\n absoluteFormat = 'iso',\n hideTimeOffset,\n ...rest\n }: DateRangePickerProps,\n ref: Ref<DateRangePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DateRangePicker');\n checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);\n\n const normalizedTimeOffset = normalizeTimeOffset(value, getTimeOffset, timeOffset);\n value = isDateOnly(value) ? value : shiftTimeOffset(value, normalizedTimeOffset);\n\n const baseProps = getBaseProps(rest);\n const { invalid, controlId, ariaDescribedby, ariaLabelledby } = useFormFieldContext({\n ariaLabelledby: rest.ariaLabelledby ?? i18nStrings?.ariaLabelledby,\n ariaDescribedby: rest.ariaDescribedby ?? i18nStrings?.ariaDescribedby,\n ...rest,\n });\n const isSingleGrid = useMobile();\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n useForwardFocus(ref, triggerRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('date-range-picker-dropdown');\n const triggerContentId = useUniqueId('date-range-picker-trigger');\n\n useFocusTracker({ rootRef, onBlur, onFocus });\n\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n\n const closeDropdown = (focusTrigger = false) => {\n setIsDropDownOpen(false);\n if (focusTrigger) {\n triggerRef.current?.focus();\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape) {\n if (isDropDownOpen) {\n event.stopPropagation();\n }\n closeDropdown(true);\n }\n };\n\n const onClear = () => {\n fireNonCancelableEvent(onChange, { value: null });\n };\n\n const onApply = (newValue: null | DateRangePickerProps.Value): DateRangePickerProps.ValidationResult => {\n const validationResult = isValidRange(newValue);\n if (validationResult?.valid === false) {\n return validationResult;\n }\n\n if (isDevelopment) {\n if (newValue?.type === 'absolute') {\n const [startDateWithoutTime] = newValue.startDate.split('T');\n const [endDateWithoutTime] = newValue.endDate.split('T');\n if (!startDateWithoutTime || !endDateWithoutTime) {\n warnOnce(\n 'DateRangePicker',\n 'You have provided an `isValidRange` prop that did not catch a missing start or end date.'\n );\n }\n }\n }\n fireNonCancelableEvent(onChange, {\n value: formatValue(newValue, {\n dateOnly,\n timeOffset: normalizeTimeOffset(newValue, getTimeOffset, timeOffset),\n }),\n });\n return validationResult || { valid: true };\n };\n\n const prevDateOnly = usePrevious(dateOnly);\n useEffect(() => {\n if (prevDateOnly !== undefined && prevDateOnly !== dateOnly) {\n warnOnce(\n 'DateRangePicker',\n `The provided \\`dateOnly\\` flag has been changed from \"${prevDateOnly}\" to \"${dateOnly}\" which can lead to unexpected value format. Consider using separate components.`\n );\n }\n }, [prevDateOnly, dateOnly]);\n\n if (value && value.type !== 'absolute' && value.type !== 'relative') {\n warnOnce('DateRangePicker', 'You provided an invalid value. Reverting back to default.');\n value = null;\n }\n\n if (\n (value?.type === 'absolute' && rangeSelectorMode === 'relative-only') ||\n (value?.type === 'relative' && rangeSelectorMode === 'absolute-only')\n ) {\n warnOnce(\n 'DateRangePicker',\n 'The provided value does not correspond to the current range selector mode. Reverting back to default.'\n );\n value = null;\n }\n\n const i18n = useInternalI18n('date-range-picker');\n const formatRelativeRange = i18n(\n 'i18nStrings.formatRelativeRange',\n i18nStrings?.formatRelativeRange,\n format =>\n ({ amount, unit }) =>\n format({ amount, unit })\n );\n\n if (isDevelopment) {\n if (!formatRelativeRange && rangeSelectorMode !== 'absolute-only') {\n warnOnce(\n 'DateRangePicker',\n 'A function for i18nStrings.formatRelativeRange was not provided. Relative ranges will not be correctly rendered.'\n );\n }\n }\n\n const formattedDate: string | JSX.Element = renderDateRange({\n locale: normalizedLocale,\n range: value,\n placeholder,\n formatRelativeRange,\n absoluteFormat,\n hideTimeOffset,\n timeOffset: normalizedTimeOffset,\n });\n\n const trigger = (\n <div className={styles['trigger-wrapper']}>\n <ButtonTrigger\n ref={triggerRef}\n id={controlId}\n invalid={invalid}\n ariaLabelledby={joinStrings(ariaLabelledby, triggerContentId)}\n ariaLabel={i18nStrings?.ariaLabel}\n ariaDescribedby={ariaDescribedby}\n className={clsx(styles.label, {\n [styles['label-enabled']]: !readOnly && !disabled,\n })}\n hideCaret={true}\n onClick={() => {\n if (!readOnly && !disabled) {\n setIsDropDownOpen(true);\n }\n }}\n disabled={disabled}\n readOnly={readOnly}\n ariaHasPopup=\"dialog\"\n >\n <span className={styles['trigger-flexbox']}>\n <span className={styles['icon-wrapper']}>\n <InternalIcon name=\"calendar\" variant={disabled || readOnly ? 'disabled' : 'normal'} />\n </span>\n <span id={triggerContentId}>{formattedDate}</span>\n </span>\n </ButtonTrigger>\n </div>\n );\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n return (\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(\n baseProps.className,\n styles.root,\n absoluteFormat === 'long-localized' && !dateOnly && styles.wide\n )}\n onKeyDown={onWrapperKeyDownHandler}\n >\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={() => closeDropdown()}\n trigger={trigger}\n stretchToTriggerWidth={false}\n expandToViewport={expandToViewport}\n dropdownId={dropdownId}\n >\n {/* Reset form field context to prevent a wrapper form field from labelling all inputs inside the dropdown. */}\n <ResetContextsForModal>\n {isDropDownOpen && (\n <DateRangePickerDropdown\n startOfWeek={startOfWeek}\n locale={normalizedLocale}\n isSingleGrid={isSingleGrid}\n onDropdownClose={() => closeDropdown(true)}\n value={value}\n showClearButton={showClearButton}\n isDateEnabled={isDateEnabled}\n i18nStrings={i18nStrings}\n onClear={onClear}\n onApply={onApply}\n relativeOptions={relativeOptions}\n isValidRange={isValidRange}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n rangeSelectorMode={rangeSelectorMode}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n customAbsoluteRangeControl={customAbsoluteRangeControl}\n />\n )}\n </ResetContextsForModal>\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DateRangePicker, 'DateRangePicker');\nexport default DateRangePicker;\n"]}
|
|
@@ -133,6 +133,21 @@ export interface DateRangePickerProps extends BaseComponentProps, FormFieldValid
|
|
|
133
133
|
* Specifies an additional control displayed in the dropdown, located below the range calendar.
|
|
134
134
|
*/
|
|
135
135
|
customAbsoluteRangeControl?: DateRangePickerProps.AbsoluteRangeControl;
|
|
136
|
+
/**
|
|
137
|
+
* Specifies the time format to use for displaying the absolute time range.
|
|
138
|
+
*
|
|
139
|
+
* It can take the following values:
|
|
140
|
+
* * `iso`: ISO 8601 format, e.g.: 2024-01-30T13:32:32+01:00 (or 2024-01-30 when `dateOnly` is true)
|
|
141
|
+
* * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024, 13:32:32 (UTC+1) (or January 30, 2024 when `dateOnly` is true)
|
|
142
|
+
*
|
|
143
|
+
* Defaults to `iso`.
|
|
144
|
+
*/
|
|
145
|
+
absoluteFormat?: DateRangePickerProps.AbsoluteFormat;
|
|
146
|
+
/**
|
|
147
|
+
* Specifies whether to hide the time offset in the displayed absolute time range.
|
|
148
|
+
* Defaults to `false`.
|
|
149
|
+
*/
|
|
150
|
+
hideTimeOffset?: boolean;
|
|
136
151
|
}
|
|
137
152
|
export declare namespace DateRangePickerProps {
|
|
138
153
|
type Value = AbsoluteValue | RelativeValue;
|
|
@@ -328,6 +343,7 @@ export declare namespace DateRangePickerProps {
|
|
|
328
343
|
*/
|
|
329
344
|
renderSelectedAbsoluteRangeAriaLive?: (startDate: string, endDate: string) => string;
|
|
330
345
|
}
|
|
346
|
+
type AbsoluteFormat = 'iso' | 'long-localized';
|
|
331
347
|
}
|
|
332
348
|
export type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
333
349
|
export type RangeCalendarI18nStrings = Pick<DateRangePickerProps.I18nStrings, 'todayAriaLabel' | 'nextMonthAriaLabel' | 'previousMonthAriaLabel' | 'startDateLabel' | 'startTimeLabel' | 'endDateLabel' | 'endTimeLabel' | 'dateTimeConstraintText' | 'renderSelectedAbsoluteRangeAriaLive'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["date-range-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC;IAEzC;;OAEG;IACH,eAAe,EAAE,aAAa,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAEpE;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;IAE3D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,WAAW,CAAC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Ac,GAAG,KAAK,GAAG,gBAAgB,CAAC;CACvD;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,oBAAoB,CAAC,WAAW,EAC9B,gBAAgB,GAChB,oBAAoB,GACpB,wBAAwB,GACxB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,wBAAwB,GACxB,qCAAqC,CACxC,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["date-range-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { TimeInputProps } from '../time-input/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport React from 'react';\n\nexport interface DateRangePickerBaseProps {\n /**\n * The current date range value. Can be either an absolute time range\n * or a relative time range.\n */\n value: null | DateRangePickerProps.Value;\n\n /**\n * A list of relative time ranges that are shown as suggestions.\n */\n relativeOptions: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n\n /**\n * A function that defines whether a particular date should be enabled\n * in the calendar or not. Note that disabling a date in the calendar\n * still allows users to enter this date via keyboard. We therefore\n * recommend that you also validate these constraints client- and\n * server-side, in the same way as for other form elements.\n */\n isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;\n\n /**\n * The locale to be used for rendering month names and defining the\n * starting date of the week. If not provided, it will be determined\n * from the page and browser locales. Supported values and formats\n * are as-per the [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Starting day of the week. [0-6] maps to [Sunday-Saturday].\n * By default the starting day of the week is defined by the locale,\n * but you can override it using this property.\n */\n startOfWeek?: number;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: DateRangePickerProps.I18nStrings;\n\n /**\n * Hides time inputs and changes the input format to date-only, e.g. 2021-04-06.\n *\n * Do not use `dateOnly` flag conditionally. The component does not trigger the value update\n * when the flag changes which means the value format can become inconsistent.\n *\n * Default: `false`.\n */\n dateOnly?: boolean;\n\n /**\n * Determines the range selector mode as follows:\n * * `default` for combined absolute/relative range selector.\n * * `absolute-only` for absolute-only range selector.\n * * `relative-only` for relative-only range selector.\n *\n * By default, the range selector mode is `default`.\n */\n rangeSelectorMode?: DateRangePickerProps.RangeSelectorMode;\n\n /**\n * Specifies the format of the time input for absolute ranges.\n *\n * Use to restrict the granularity of time that the user can enter.\n *\n * Has no effect when `dateOnly` is true.\n */\n timeInputFormat?: TimeInputProps.Format;\n\n /**\n * Fired whenever a user changes the component's value.\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<DateRangePickerProps.ChangeDetail>;\n\n /**\n * The time offset from UTC in minutes that should be used to\n * display and produce values.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n *\n * @deprecated Use `getTimeOffset` instead.\n */\n timeOffset?: number;\n\n /**\n * A function that defines timezone offset from UTC in minutes for selected dates.\n * Use it to define time relative to the desired timezone.\n *\n * The function is called for the start date and the end date and takes a UTC date\n * corresponding the selected value as an argument.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n */\n getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction;\n}\nexport interface DateRangePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n DateRangePickerBaseProps {\n /**\n * Specifies the placeholder text that is rendered when the value is empty.\n */\n placeholder?: string;\n\n /**\n * Specifies that the component is disabled, preventing the user from\n * modifying the value. A disabled component cannot receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies that the component is read-only, preventing the user from\n * modifying the value. A read-only component can receive focus.\n */\n readOnly?: boolean;\n\n /**\n * Fired when keyboard focus is set onto the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Fired when keyboard focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * A function that defines whether a particular range is valid or not.\n *\n * Ensure that your function checks for missing fields in the value.\n */\n isValidRange: DateRangePickerProps.ValidationFunction;\n\n /**\n * Specifies whether the component should show a button that\n * allows the user to clear the selected value.\n */\n showClearButton?: boolean;\n\n /**\n * Specifies an additional control displayed in the dropdown, located below the range calendar.\n */\n customAbsoluteRangeControl?: DateRangePickerProps.AbsoluteRangeControl;\n}\n\nexport namespace DateRangePickerProps {\n export type Value = AbsoluteValue | RelativeValue;\n export interface AbsoluteValue {\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n startDate: string;\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n endDate: string;\n type: 'absolute';\n }\n\n export interface RelativeValue {\n /**\n * If provided, used to match this value\n * to a provided relative option.\n */\n key?: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n export interface RelativeOption {\n /**\n * Used to uniquely identify this relative option.\n */\n key: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n\n export type TimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n\n export type ValidationFunction = (value: Value | null) => ValidationResult;\n\n export type ValidationResult = ValidRangeResult | InvalidRangeResult;\n\n export interface ValidRangeResult {\n valid: true;\n }\n\n export interface InvalidRangeResult {\n valid: false;\n errorMessage: string;\n }\n\n export interface ChangeDetail {\n /**\n * The newly selected range of this date range picker.\n */\n value: null | Value;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface GetTimeOffsetFunction {\n (date: Date): number;\n }\n\n export interface DateTimeStrings {\n date: string;\n time: string;\n }\n\n export interface PendingAbsoluteValue {\n start: DateTimeStrings;\n end: DateTimeStrings;\n }\n\n export type AbsoluteRangeControl = (\n selectedRange: PendingAbsoluteValue,\n setSelectedRange: React.Dispatch<React.SetStateAction<PendingAbsoluteValue>>\n ) => React.ReactNode;\n\n export type RangeSelectorMode = 'default' | 'absolute-only' | 'relative-only';\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n\n export interface I18nStrings {\n /**\n * Adds `aria-label` to the trigger and dropdown.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the trigger and dropdown.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the trigger and dropdown.\n */\n ariaDescribedby?: string;\n\n /**\n * Label of the mode selection group. In the standard view, it adds 'aria-label' to the group of segments.\n * In a narrow container the label is visible and attached to the select component.\n */\n modeSelectionLabel?: string;\n\n /**\n * Segment title of the relative range selection mode\n */\n relativeModeTitle?: string;\n\n /**\n * Segment title of the absolute range selection mode\n */\n absoluteModeTitle?: string;\n\n /**\n * Heading for the relative range selection area\n */\n relativeRangeSelectionHeading?: string;\n\n /**\n * Visible label of the Cancel button\n */\n cancelButtonLabel?: string;\n /**\n * Visible label of the Clear and dismiss button\n */\n clearButtonLabel?: string;\n /**\n * Visible label of the Apply button\n */\n applyButtonLabel?: string;\n\n /**\n * Formatting function for relative ranges.\n * This function must convert a relative range to a human-readable string.\n */\n formatRelativeRange?: (value: RelativeValue) => string;\n\n /**\n * Formatting function for time units.\n *\n * This function must return a localized form of the unit that fits the provided time value.\n */\n formatUnit?: (unit: TimeUnit, value: number) => string;\n\n /**\n * Visible label for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionLabel?: string;\n\n /**\n * Visible description for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionDescription?: string;\n\n /**\n * Visible label for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationLabel?: string;\n /**\n * Placeholder for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationPlaceholder?: string;\n /**\n * Visible label for the unit selector for the\n * custom relative range.\n */\n customRelativeRangeUnitLabel?: string;\n\n /**\n * Used as part of the aria label for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * An aria label for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * An aria label for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Visible label for the Start Date input for the\n * absolute range.\n */\n startDateLabel?: string;\n /**\n * Visible label for the Start Time input for the\n * absolute range.\n */\n startTimeLabel?: string;\n /**\n * Visible label for the End Date input for the\n * absolute range.\n */\n endDateLabel?: string;\n /**\n * Visible label for the End Time input for the\n * absolute range.\n */\n endTimeLabel?: string;\n\n /**\n * Constraint text for the input fields for the\n * absolute range.\n */\n dateTimeConstraintText?: string;\n\n /**\n * Provides a text alternative for the error icon in the error alert.\n */\n errorIconAriaLabel?: string;\n\n /**\n * When the property is set, screen readers announce the selected range when the absolute range gets selected.\n */\n renderSelectedAbsoluteRangeAriaLive?: (startDate: string, endDate: string) => string;\n }\n}\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type RangeCalendarI18nStrings = Pick<\n DateRangePickerProps.I18nStrings,\n | 'todayAriaLabel'\n | 'nextMonthAriaLabel'\n | 'previousMonthAriaLabel'\n | 'startDateLabel'\n | 'startTimeLabel'\n | 'endDateLabel'\n | 'endTimeLabel'\n | 'dateTimeConstraintText'\n | 'renderSelectedAbsoluteRangeAriaLive'\n>;\n\nexport interface Focusable {\n focus(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["date-range-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { TimeInputProps } from '../time-input/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport React from 'react';\n\nexport interface DateRangePickerBaseProps {\n /**\n * The current date range value. Can be either an absolute time range\n * or a relative time range.\n */\n value: null | DateRangePickerProps.Value;\n\n /**\n * A list of relative time ranges that are shown as suggestions.\n */\n relativeOptions: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n\n /**\n * A function that defines whether a particular date should be enabled\n * in the calendar or not. Note that disabling a date in the calendar\n * still allows users to enter this date via keyboard. We therefore\n * recommend that you also validate these constraints client- and\n * server-side, in the same way as for other form elements.\n */\n isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;\n\n /**\n * The locale to be used for rendering month names and defining the\n * starting date of the week. If not provided, it will be determined\n * from the page and browser locales. Supported values and formats\n * are as-per the [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Starting day of the week. [0-6] maps to [Sunday-Saturday].\n * By default the starting day of the week is defined by the locale,\n * but you can override it using this property.\n */\n startOfWeek?: number;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: DateRangePickerProps.I18nStrings;\n\n /**\n * Hides time inputs and changes the input format to date-only, e.g. 2021-04-06.\n *\n * Do not use `dateOnly` flag conditionally. The component does not trigger the value update\n * when the flag changes which means the value format can become inconsistent.\n *\n * Default: `false`.\n */\n dateOnly?: boolean;\n\n /**\n * Determines the range selector mode as follows:\n * * `default` for combined absolute/relative range selector.\n * * `absolute-only` for absolute-only range selector.\n * * `relative-only` for relative-only range selector.\n *\n * By default, the range selector mode is `default`.\n */\n rangeSelectorMode?: DateRangePickerProps.RangeSelectorMode;\n\n /**\n * Specifies the format of the time input for absolute ranges.\n *\n * Use to restrict the granularity of time that the user can enter.\n *\n * Has no effect when `dateOnly` is true.\n */\n timeInputFormat?: TimeInputProps.Format;\n\n /**\n * Fired whenever a user changes the component's value.\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<DateRangePickerProps.ChangeDetail>;\n\n /**\n * The time offset from UTC in minutes that should be used to\n * display and produce values.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n *\n * @deprecated Use `getTimeOffset` instead.\n */\n timeOffset?: number;\n\n /**\n * A function that defines timezone offset from UTC in minutes for selected dates.\n * Use it to define time relative to the desired timezone.\n *\n * The function is called for the start date and the end date and takes a UTC date\n * corresponding the selected value as an argument.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n */\n getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction;\n}\nexport interface DateRangePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n DateRangePickerBaseProps {\n /**\n * Specifies the placeholder text that is rendered when the value is empty.\n */\n placeholder?: string;\n\n /**\n * Specifies that the component is disabled, preventing the user from\n * modifying the value. A disabled component cannot receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies that the component is read-only, preventing the user from\n * modifying the value. A read-only component can receive focus.\n */\n readOnly?: boolean;\n\n /**\n * Fired when keyboard focus is set onto the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Fired when keyboard focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * A function that defines whether a particular range is valid or not.\n *\n * Ensure that your function checks for missing fields in the value.\n */\n isValidRange: DateRangePickerProps.ValidationFunction;\n\n /**\n * Specifies whether the component should show a button that\n * allows the user to clear the selected value.\n */\n showClearButton?: boolean;\n\n /**\n * Specifies an additional control displayed in the dropdown, located below the range calendar.\n */\n customAbsoluteRangeControl?: DateRangePickerProps.AbsoluteRangeControl;\n\n /**\n * Specifies the time format to use for displaying the absolute time range.\n *\n * It can take the following values:\n * * `iso`: ISO 8601 format, e.g.: 2024-01-30T13:32:32+01:00 (or 2024-01-30 when `dateOnly` is true)\n * * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024, 13:32:32 (UTC+1) (or January 30, 2024 when `dateOnly` is true)\n *\n * Defaults to `iso`.\n */\n absoluteFormat?: DateRangePickerProps.AbsoluteFormat;\n\n /**\n * Specifies whether to hide the time offset in the displayed absolute time range.\n * Defaults to `false`.\n */\n hideTimeOffset?: boolean;\n}\n\nexport namespace DateRangePickerProps {\n export type Value = AbsoluteValue | RelativeValue;\n export interface AbsoluteValue {\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n startDate: string;\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n endDate: string;\n type: 'absolute';\n }\n\n export interface RelativeValue {\n /**\n * If provided, used to match this value\n * to a provided relative option.\n */\n key?: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n export interface RelativeOption {\n /**\n * Used to uniquely identify this relative option.\n */\n key: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n\n export type TimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n\n export type ValidationFunction = (value: Value | null) => ValidationResult;\n\n export type ValidationResult = ValidRangeResult | InvalidRangeResult;\n\n export interface ValidRangeResult {\n valid: true;\n }\n\n export interface InvalidRangeResult {\n valid: false;\n errorMessage: string;\n }\n\n export interface ChangeDetail {\n /**\n * The newly selected range of this date range picker.\n */\n value: null | Value;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface GetTimeOffsetFunction {\n (date: Date): number;\n }\n\n export interface DateTimeStrings {\n date: string;\n time: string;\n }\n\n export interface PendingAbsoluteValue {\n start: DateTimeStrings;\n end: DateTimeStrings;\n }\n\n export type AbsoluteRangeControl = (\n selectedRange: PendingAbsoluteValue,\n setSelectedRange: React.Dispatch<React.SetStateAction<PendingAbsoluteValue>>\n ) => React.ReactNode;\n\n export type RangeSelectorMode = 'default' | 'absolute-only' | 'relative-only';\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n\n export interface I18nStrings {\n /**\n * Adds `aria-label` to the trigger and dropdown.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the trigger and dropdown.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the trigger and dropdown.\n */\n ariaDescribedby?: string;\n\n /**\n * Label of the mode selection group. In the standard view, it adds 'aria-label' to the group of segments.\n * In a narrow container the label is visible and attached to the select component.\n */\n modeSelectionLabel?: string;\n\n /**\n * Segment title of the relative range selection mode\n */\n relativeModeTitle?: string;\n\n /**\n * Segment title of the absolute range selection mode\n */\n absoluteModeTitle?: string;\n\n /**\n * Heading for the relative range selection area\n */\n relativeRangeSelectionHeading?: string;\n\n /**\n * Visible label of the Cancel button\n */\n cancelButtonLabel?: string;\n /**\n * Visible label of the Clear and dismiss button\n */\n clearButtonLabel?: string;\n /**\n * Visible label of the Apply button\n */\n applyButtonLabel?: string;\n\n /**\n * Formatting function for relative ranges.\n * This function must convert a relative range to a human-readable string.\n */\n formatRelativeRange?: (value: RelativeValue) => string;\n\n /**\n * Formatting function for time units.\n *\n * This function must return a localized form of the unit that fits the provided time value.\n */\n formatUnit?: (unit: TimeUnit, value: number) => string;\n\n /**\n * Visible label for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionLabel?: string;\n\n /**\n * Visible description for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionDescription?: string;\n\n /**\n * Visible label for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationLabel?: string;\n /**\n * Placeholder for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationPlaceholder?: string;\n /**\n * Visible label for the unit selector for the\n * custom relative range.\n */\n customRelativeRangeUnitLabel?: string;\n\n /**\n * Used as part of the aria label for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * An aria label for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * An aria label for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Visible label for the Start Date input for the\n * absolute range.\n */\n startDateLabel?: string;\n /**\n * Visible label for the Start Time input for the\n * absolute range.\n */\n startTimeLabel?: string;\n /**\n * Visible label for the End Date input for the\n * absolute range.\n */\n endDateLabel?: string;\n /**\n * Visible label for the End Time input for the\n * absolute range.\n */\n endTimeLabel?: string;\n\n /**\n * Constraint text for the input fields for the\n * absolute range.\n */\n dateTimeConstraintText?: string;\n\n /**\n * Provides a text alternative for the error icon in the error alert.\n */\n errorIconAriaLabel?: string;\n\n /**\n * When the property is set, screen readers announce the selected range when the absolute range gets selected.\n */\n renderSelectedAbsoluteRangeAriaLive?: (startDate: string, endDate: string) => string;\n }\n\n export type AbsoluteFormat = 'iso' | 'long-localized';\n}\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type RangeCalendarI18nStrings = Pick<\n DateRangePickerProps.I18nStrings,\n | 'todayAriaLabel'\n | 'nextMonthAriaLabel'\n | 'previousMonthAriaLabel'\n | 'startDateLabel'\n | 'startTimeLabel'\n | 'endDateLabel'\n | 'endTimeLabel'\n | 'dateTimeConstraintText'\n | 'renderSelectedAbsoluteRangeAriaLive'\n>;\n\nexport interface Focusable {\n focus(): void;\n}\n"]}
|
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"calendar": "
|
|
5
|
-
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-
|
|
6
|
-
"root": "
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"trigger-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"calendar-header
|
|
14
|
-
"calendar-header-
|
|
15
|
-
"calendar-
|
|
16
|
-
"calendar-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"date-and-time-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"label
|
|
27
|
-
"label-
|
|
28
|
-
"label-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"dropdown
|
|
32
|
-
"
|
|
33
|
-
"start-
|
|
34
|
-
"
|
|
35
|
-
"end-
|
|
36
|
-
"
|
|
37
|
-
"validation-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
4
|
+
"calendar": "awsui_calendar_mgja0_15dh9_93",
|
|
5
|
+
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_mgja0_15dh9_1",
|
|
6
|
+
"root": "awsui_root_mgja0_15dh9_120",
|
|
7
|
+
"wide": "awsui_wide_mgja0_15dh9_154",
|
|
8
|
+
"focus-lock": "awsui_focus-lock_mgja0_15dh9_161",
|
|
9
|
+
"trigger-wrapper": "awsui_trigger-wrapper_mgja0_15dh9_165",
|
|
10
|
+
"trigger-flexbox": "awsui_trigger-flexbox_mgja0_15dh9_169",
|
|
11
|
+
"calendar-container": "awsui_calendar-container_mgja0_15dh9_173",
|
|
12
|
+
"one-grid": "awsui_one-grid_mgja0_15dh9_176",
|
|
13
|
+
"calendar-header": "awsui_calendar-header_mgja0_15dh9_180",
|
|
14
|
+
"calendar-header-months-wrapper": "awsui_calendar-header-months-wrapper_mgja0_15dh9_186",
|
|
15
|
+
"calendar-header-month": "awsui_calendar-header-month_mgja0_15dh9_186",
|
|
16
|
+
"calendar-next-month-btn": "awsui_calendar-next-month-btn_mgja0_15dh9_205",
|
|
17
|
+
"calendar-prev-month-btn": "awsui_calendar-prev-month-btn_mgja0_15dh9_208",
|
|
18
|
+
"first-grid": "awsui_first-grid_mgja0_15dh9_212",
|
|
19
|
+
"second-grid": "awsui_second-grid_mgja0_15dh9_213",
|
|
20
|
+
"date-and-time-container": "awsui_date-and-time-container_mgja0_15dh9_217",
|
|
21
|
+
"date-and-time-wrapper": "awsui_date-and-time-wrapper_mgja0_15dh9_223",
|
|
22
|
+
"footer": "awsui_footer_mgja0_15dh9_230",
|
|
23
|
+
"has-clear-button": "awsui_has-clear-button_mgja0_15dh9_239",
|
|
24
|
+
"footer-button-wrapper": "awsui_footer-button-wrapper_mgja0_15dh9_248",
|
|
25
|
+
"icon-wrapper": "awsui_icon-wrapper_mgja0_15dh9_255",
|
|
26
|
+
"label": "awsui_label_mgja0_15dh9_260",
|
|
27
|
+
"label-enabled": "awsui_label-enabled_mgja0_15dh9_265",
|
|
28
|
+
"label-text": "awsui_label-text_mgja0_15dh9_269",
|
|
29
|
+
"label-token-nowrap": "awsui_label-token-nowrap_mgja0_15dh9_274",
|
|
30
|
+
"mode-switch": "awsui_mode-switch_mgja0_15dh9_278",
|
|
31
|
+
"dropdown": "awsui_dropdown_mgja0_15dh9_282",
|
|
32
|
+
"dropdown-content": "awsui_dropdown-content_mgja0_15dh9_304",
|
|
33
|
+
"start-date-input": "awsui_start-date-input_mgja0_15dh9_313",
|
|
34
|
+
"start-time-input": "awsui_start-time-input_mgja0_15dh9_314",
|
|
35
|
+
"end-date-input": "awsui_end-date-input_mgja0_15dh9_315",
|
|
36
|
+
"end-time-input": "awsui_end-time-input_mgja0_15dh9_316",
|
|
37
|
+
"validation-section": "awsui_validation-section_mgja0_15dh9_320",
|
|
38
|
+
"validation-error": "awsui_validation-error_mgja0_15dh9_324",
|
|
39
|
+
"clear-button": "awsui_clear-button_mgja0_15dh9_328",
|
|
40
|
+
"apply-button": "awsui_apply-button_mgja0_15dh9_332",
|
|
41
|
+
"cancel-button": "awsui_cancel-button_mgja0_15dh9_336",
|
|
42
|
+
"calendar-aria-live": "awsui_calendar-aria-live_mgja0_15dh9_340"
|
|
42
43
|
};
|
|
43
44
|
|
|
@@ -90,11 +90,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
90
90
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
91
|
SPDX-License-Identifier: Apache-2.0
|
|
92
92
|
*/
|
|
93
|
-
.
|
|
94
|
-
animation: awsui_awsui-motion-fade-in-
|
|
93
|
+
.awsui_calendar_mgja0_15dh9_93:not(#\9) {
|
|
94
|
+
animation: awsui_awsui-motion-fade-in-0_mgja0_15dh9_1 var(--motion-duration-show-quick-aq3ump, 135ms) var(--motion-easing-show-quick-vc5zgd, ease-out);
|
|
95
95
|
animation-fill-mode: both;
|
|
96
96
|
}
|
|
97
|
-
@keyframes awsui_awsui-motion-fade-in-
|
|
97
|
+
@keyframes awsui_awsui-motion-fade-in-0_mgja0_15dh9_1 {
|
|
98
98
|
from {
|
|
99
99
|
opacity: 0;
|
|
100
100
|
}
|
|
@@ -103,12 +103,12 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
@media (prefers-reduced-motion: reduce) {
|
|
106
|
-
.
|
|
106
|
+
.awsui_calendar_mgja0_15dh9_93:not(#\9) {
|
|
107
107
|
animation: none;
|
|
108
108
|
transition: none;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
.awsui-motion-disabled .
|
|
111
|
+
.awsui-motion-disabled .awsui_calendar_mgja0_15dh9_93:not(#\9), .awsui-mode-entering .awsui_calendar_mgja0_15dh9_93:not(#\9) {
|
|
112
112
|
animation: none;
|
|
113
113
|
transition: none;
|
|
114
114
|
}
|
|
@@ -117,7 +117,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
117
117
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
118
118
|
SPDX-License-Identifier: Apache-2.0
|
|
119
119
|
*/
|
|
120
|
-
.
|
|
120
|
+
.awsui_root_mgja0_15dh9_120:not(#\9) {
|
|
121
121
|
border-collapse: separate;
|
|
122
122
|
border-spacing: 0;
|
|
123
123
|
box-sizing: border-box;
|
|
@@ -151,35 +151,40 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
151
151
|
font-family: var(--font-family-base-dnvic8, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
152
152
|
-webkit-font-smoothing: auto;
|
|
153
153
|
-moz-osx-font-smoothing: auto;
|
|
154
|
+
}
|
|
155
|
+
.awsui_root_mgja0_15dh9_120:not(#\9):not(.awsui_wide_mgja0_15dh9_154) {
|
|
154
156
|
max-inline-size: 32em;
|
|
155
157
|
}
|
|
158
|
+
.awsui_root_mgja0_15dh9_120.awsui_wide_mgja0_15dh9_154:not(#\9) {
|
|
159
|
+
max-inline-size: 39em;
|
|
160
|
+
}
|
|
156
161
|
|
|
157
|
-
.awsui_focus-
|
|
162
|
+
.awsui_focus-lock_mgja0_15dh9_161:not(#\9) {
|
|
158
163
|
display: contents;
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
.awsui_trigger-
|
|
166
|
+
.awsui_trigger-wrapper_mgja0_15dh9_165:not(#\9) {
|
|
162
167
|
min-inline-size: calc(var(--size-calendar-grid-width-lrunz7, 238px) + 2 * var(--space-l-t419sm, 20px));
|
|
163
168
|
}
|
|
164
169
|
|
|
165
|
-
.awsui_trigger-
|
|
170
|
+
.awsui_trigger-flexbox_mgja0_15dh9_169:not(#\9) {
|
|
166
171
|
display: flex;
|
|
167
172
|
}
|
|
168
173
|
|
|
169
|
-
.awsui_calendar-
|
|
174
|
+
.awsui_calendar-container_mgja0_15dh9_173:not(#\9) {
|
|
170
175
|
inline-size: calc(2 * var(--size-calendar-grid-width-lrunz7, 238px) + var(--space-xs-zb16t3, 8px));
|
|
171
176
|
}
|
|
172
|
-
.awsui_calendar-
|
|
177
|
+
.awsui_calendar-container_mgja0_15dh9_173.awsui_one-grid_mgja0_15dh9_176:not(#\9) {
|
|
173
178
|
inline-size: var(--size-calendar-grid-width-lrunz7, 238px);
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
.awsui_calendar-
|
|
181
|
+
.awsui_calendar-header_mgja0_15dh9_180:not(#\9) {
|
|
177
182
|
display: flex;
|
|
178
183
|
justify-content: space-between;
|
|
179
184
|
align-items: center;
|
|
180
185
|
position: relative;
|
|
181
186
|
}
|
|
182
|
-
.awsui_calendar-header-months-
|
|
187
|
+
.awsui_calendar-header-months-wrapper_mgja0_15dh9_186:not(#\9) {
|
|
183
188
|
position: absolute;
|
|
184
189
|
inset: 0;
|
|
185
190
|
margin-block: 0;
|
|
@@ -190,7 +195,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
190
195
|
flex: 1;
|
|
191
196
|
pointer-events: none;
|
|
192
197
|
}
|
|
193
|
-
.awsui_calendar-header-
|
|
198
|
+
.awsui_calendar-header-month_mgja0_15dh9_186:not(#\9) {
|
|
194
199
|
font-size: var(--font-size-body-m-x4okxb, 14px);
|
|
195
200
|
line-height: var(--line-height-body-m-30ar75, 20px);
|
|
196
201
|
font-weight: 700;
|
|
@@ -198,32 +203,32 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
198
203
|
display: flex;
|
|
199
204
|
pointer-events: auto;
|
|
200
205
|
}
|
|
201
|
-
.awsui_calendar-next-month-
|
|
206
|
+
.awsui_calendar-next-month-btn_mgja0_15dh9_205:not(#\9) {
|
|
202
207
|
/* used for identifying element */
|
|
203
208
|
}
|
|
204
|
-
.awsui_calendar-prev-month-
|
|
209
|
+
.awsui_calendar-prev-month-btn_mgja0_15dh9_208:not(#\9) {
|
|
205
210
|
/* used for identifying element */
|
|
206
211
|
}
|
|
207
212
|
|
|
208
|
-
.awsui_first-
|
|
209
|
-
.awsui_second-
|
|
213
|
+
.awsui_first-grid_mgja0_15dh9_212:not(#\9),
|
|
214
|
+
.awsui_second-grid_mgja0_15dh9_213:not(#\9) {
|
|
210
215
|
/* used in test-utils */
|
|
211
216
|
}
|
|
212
217
|
|
|
213
|
-
.awsui_date-and-time-
|
|
218
|
+
.awsui_date-and-time-container_mgja0_15dh9_217:not(#\9) {
|
|
214
219
|
display: grid;
|
|
215
220
|
grid-template-columns: repeat(auto-fit, minmax(var(--size-calendar-grid-width-lrunz7, 238px), 1fr));
|
|
216
221
|
gap: var(--space-xs-zb16t3, 8px);
|
|
217
222
|
}
|
|
218
223
|
|
|
219
|
-
.awsui_date-and-time-
|
|
224
|
+
.awsui_date-and-time-wrapper_mgja0_15dh9_223:not(#\9) {
|
|
220
225
|
inline-size: var(--size-calendar-grid-width-lrunz7, 238px);
|
|
221
226
|
display: grid;
|
|
222
227
|
gap: var(--space-xs-zb16t3, 8px);
|
|
223
228
|
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
|
|
224
229
|
}
|
|
225
230
|
|
|
226
|
-
.
|
|
231
|
+
.awsui_footer_mgja0_15dh9_230:not(#\9) {
|
|
227
232
|
display: flex;
|
|
228
233
|
flex-wrap: wrap;
|
|
229
234
|
justify-content: flex-end;
|
|
@@ -232,51 +237,51 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
232
237
|
padding-block-end: var(--space-s-34lx8l, 12px);
|
|
233
238
|
padding-inline: var(--space-l-t419sm, 20px);
|
|
234
239
|
}
|
|
235
|
-
.
|
|
240
|
+
.awsui_footer_mgja0_15dh9_230.awsui_has-clear-button_mgja0_15dh9_239:not(#\9) {
|
|
236
241
|
justify-content: space-between;
|
|
237
242
|
}
|
|
238
|
-
.
|
|
243
|
+
.awsui_footer_mgja0_15dh9_230.awsui_one-grid_mgja0_15dh9_176:not(#\9) {
|
|
239
244
|
padding-block-start: 0;
|
|
240
245
|
padding-block-end: var(--space-s-34lx8l, 12px);
|
|
241
246
|
padding-inline: var(--space-xs-zb16t3, 8px);
|
|
242
247
|
}
|
|
243
248
|
|
|
244
|
-
.awsui_footer-button-
|
|
249
|
+
.awsui_footer-button-wrapper_mgja0_15dh9_248:not(#\9) {
|
|
245
250
|
padding-block-start: var(--space-s-34lx8l, 12px);
|
|
246
251
|
}
|
|
247
|
-
.awsui_footer-button-
|
|
252
|
+
.awsui_footer-button-wrapper_mgja0_15dh9_248:not(#\9):last-child {
|
|
248
253
|
margin-inline-start: auto;
|
|
249
254
|
}
|
|
250
255
|
|
|
251
|
-
.awsui_icon-
|
|
256
|
+
.awsui_icon-wrapper_mgja0_15dh9_255:not(#\9) {
|
|
252
257
|
color: var(--color-text-interactive-default-lnx6lk, #414d5c);
|
|
253
258
|
margin-inline-end: var(--space-xs-zb16t3, 8px);
|
|
254
259
|
}
|
|
255
260
|
|
|
256
|
-
.
|
|
261
|
+
.awsui_label_mgja0_15dh9_260:not(#\9) {
|
|
257
262
|
-webkit-user-select: text;
|
|
258
263
|
user-select: text;
|
|
259
264
|
cursor: default;
|
|
260
265
|
}
|
|
261
266
|
|
|
262
|
-
.
|
|
267
|
+
.awsui_label_mgja0_15dh9_260.awsui_label-enabled_mgja0_15dh9_265:not(#\9):hover > .awsui_trigger-flexbox_mgja0_15dh9_169 > .awsui_icon-wrapper_mgja0_15dh9_255 {
|
|
263
268
|
color: var(--color-text-interactive-hover-mj8add, #000716);
|
|
264
269
|
}
|
|
265
270
|
|
|
266
|
-
.awsui_label-
|
|
271
|
+
.awsui_label-text_mgja0_15dh9_269:not(#\9) {
|
|
267
272
|
color: var(--color-text-input-placeholder-mx1ygd, #5f6b7a);
|
|
268
273
|
font-style: italic;
|
|
269
274
|
}
|
|
270
275
|
|
|
271
|
-
.awsui_label-token-
|
|
276
|
+
.awsui_label-token-nowrap_mgja0_15dh9_274:not(#\9) {
|
|
272
277
|
white-space: nowrap;
|
|
273
278
|
}
|
|
274
279
|
|
|
275
|
-
.awsui_mode-
|
|
280
|
+
.awsui_mode-switch_mgja0_15dh9_278:not(#\9) {
|
|
276
281
|
/* used in test-utils */
|
|
277
282
|
}
|
|
278
283
|
|
|
279
|
-
.
|
|
284
|
+
.awsui_dropdown_mgja0_15dh9_282:not(#\9) {
|
|
280
285
|
overflow: auto;
|
|
281
286
|
border-block-start: 1px solid var(--color-border-container-top-736buh, transparent);
|
|
282
287
|
border-block-end: 1px solid var(--color-border-container-top-736buh, transparent);
|
|
@@ -285,10 +290,10 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
285
290
|
border-end-start-radius: var(--border-radius-dropdown-0dhh79, 8px);
|
|
286
291
|
border-end-end-radius: var(--border-radius-dropdown-0dhh79, 8px);
|
|
287
292
|
}
|
|
288
|
-
.
|
|
293
|
+
.awsui_dropdown_mgja0_15dh9_282:not(#\9):focus {
|
|
289
294
|
outline: none;
|
|
290
295
|
}
|
|
291
|
-
body[data-awsui-focus-visible=true] .
|
|
296
|
+
body[data-awsui-focus-visible=true] .awsui_dropdown_mgja0_15dh9_282:not(#\9):focus {
|
|
292
297
|
outline: 2px dotted transparent;
|
|
293
298
|
outline-offset: 2px;
|
|
294
299
|
border-start-start-radius: var(--border-radius-dropdown-0dhh79, 8px);
|
|
@@ -298,43 +303,43 @@ body[data-awsui-focus-visible=true] .awsui_dropdown_mgja0_1nkdu_277:not(#\9):foc
|
|
|
298
303
|
box-shadow: 0 0 0 2px var(--color-border-item-focused-b2ntyl, #0972d3);
|
|
299
304
|
}
|
|
300
305
|
|
|
301
|
-
.awsui_dropdown-
|
|
306
|
+
.awsui_dropdown-content_mgja0_15dh9_304:not(#\9) {
|
|
302
307
|
-webkit-user-select: text;
|
|
303
308
|
user-select: text;
|
|
304
309
|
background-color: var(--color-background-container-content-4un1ap, #ffffff);
|
|
305
310
|
inline-size: calc(2 * var(--size-calendar-grid-width-lrunz7, 238px) + var(--space-xs-zb16t3, 8px) + 2 * var(--space-l-t419sm, 20px));
|
|
306
311
|
}
|
|
307
|
-
.awsui_dropdown-
|
|
312
|
+
.awsui_dropdown-content_mgja0_15dh9_304.awsui_one-grid_mgja0_15dh9_176:not(#\9) {
|
|
308
313
|
inline-size: calc(var(--size-calendar-grid-width-lrunz7, 238px) + 2 * var(--space-l-t419sm, 20px));
|
|
309
314
|
}
|
|
310
315
|
|
|
311
|
-
.awsui_start-date-
|
|
312
|
-
.awsui_start-time-
|
|
313
|
-
.awsui_end-date-
|
|
314
|
-
.awsui_end-time-
|
|
316
|
+
.awsui_start-date-input_mgja0_15dh9_313:not(#\9),
|
|
317
|
+
.awsui_start-time-input_mgja0_15dh9_314:not(#\9),
|
|
318
|
+
.awsui_end-date-input_mgja0_15dh9_315:not(#\9),
|
|
319
|
+
.awsui_end-time-input_mgja0_15dh9_316:not(#\9) {
|
|
315
320
|
/* used in test-utils */
|
|
316
321
|
}
|
|
317
322
|
|
|
318
|
-
.awsui_validation-
|
|
323
|
+
.awsui_validation-section_mgja0_15dh9_320:not(#\9) {
|
|
319
324
|
/* used in test-utils */
|
|
320
325
|
}
|
|
321
326
|
|
|
322
|
-
.awsui_validation-
|
|
327
|
+
.awsui_validation-error_mgja0_15dh9_324:not(#\9) {
|
|
323
328
|
/* used in test-utils */
|
|
324
329
|
}
|
|
325
330
|
|
|
326
|
-
.awsui_clear-
|
|
331
|
+
.awsui_clear-button_mgja0_15dh9_328:not(#\9) {
|
|
327
332
|
/* used in test-utils */
|
|
328
333
|
}
|
|
329
334
|
|
|
330
|
-
.awsui_apply-
|
|
335
|
+
.awsui_apply-button_mgja0_15dh9_332:not(#\9) {
|
|
331
336
|
/* used in test-utils */
|
|
332
337
|
}
|
|
333
338
|
|
|
334
|
-
.awsui_cancel-
|
|
339
|
+
.awsui_cancel-button_mgja0_15dh9_336:not(#\9) {
|
|
335
340
|
/* used in test-utils */
|
|
336
341
|
}
|
|
337
342
|
|
|
338
|
-
.awsui_calendar-aria-
|
|
343
|
+
.awsui_calendar-aria-live_mgja0_15dh9_340:not(#\9) {
|
|
339
344
|
/* used in test-utils */
|
|
340
345
|
}
|
|
@@ -2,43 +2,44 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"calendar": "
|
|
6
|
-
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-
|
|
7
|
-
"root": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"trigger-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"calendar-header
|
|
15
|
-
"calendar-header-
|
|
16
|
-
"calendar-
|
|
17
|
-
"calendar-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"date-and-time-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"label
|
|
28
|
-
"label-
|
|
29
|
-
"label-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"dropdown
|
|
33
|
-
"
|
|
34
|
-
"start-
|
|
35
|
-
"
|
|
36
|
-
"end-
|
|
37
|
-
"
|
|
38
|
-
"validation-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
5
|
+
"calendar": "awsui_calendar_mgja0_15dh9_93",
|
|
6
|
+
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_mgja0_15dh9_1",
|
|
7
|
+
"root": "awsui_root_mgja0_15dh9_120",
|
|
8
|
+
"wide": "awsui_wide_mgja0_15dh9_154",
|
|
9
|
+
"focus-lock": "awsui_focus-lock_mgja0_15dh9_161",
|
|
10
|
+
"trigger-wrapper": "awsui_trigger-wrapper_mgja0_15dh9_165",
|
|
11
|
+
"trigger-flexbox": "awsui_trigger-flexbox_mgja0_15dh9_169",
|
|
12
|
+
"calendar-container": "awsui_calendar-container_mgja0_15dh9_173",
|
|
13
|
+
"one-grid": "awsui_one-grid_mgja0_15dh9_176",
|
|
14
|
+
"calendar-header": "awsui_calendar-header_mgja0_15dh9_180",
|
|
15
|
+
"calendar-header-months-wrapper": "awsui_calendar-header-months-wrapper_mgja0_15dh9_186",
|
|
16
|
+
"calendar-header-month": "awsui_calendar-header-month_mgja0_15dh9_186",
|
|
17
|
+
"calendar-next-month-btn": "awsui_calendar-next-month-btn_mgja0_15dh9_205",
|
|
18
|
+
"calendar-prev-month-btn": "awsui_calendar-prev-month-btn_mgja0_15dh9_208",
|
|
19
|
+
"first-grid": "awsui_first-grid_mgja0_15dh9_212",
|
|
20
|
+
"second-grid": "awsui_second-grid_mgja0_15dh9_213",
|
|
21
|
+
"date-and-time-container": "awsui_date-and-time-container_mgja0_15dh9_217",
|
|
22
|
+
"date-and-time-wrapper": "awsui_date-and-time-wrapper_mgja0_15dh9_223",
|
|
23
|
+
"footer": "awsui_footer_mgja0_15dh9_230",
|
|
24
|
+
"has-clear-button": "awsui_has-clear-button_mgja0_15dh9_239",
|
|
25
|
+
"footer-button-wrapper": "awsui_footer-button-wrapper_mgja0_15dh9_248",
|
|
26
|
+
"icon-wrapper": "awsui_icon-wrapper_mgja0_15dh9_255",
|
|
27
|
+
"label": "awsui_label_mgja0_15dh9_260",
|
|
28
|
+
"label-enabled": "awsui_label-enabled_mgja0_15dh9_265",
|
|
29
|
+
"label-text": "awsui_label-text_mgja0_15dh9_269",
|
|
30
|
+
"label-token-nowrap": "awsui_label-token-nowrap_mgja0_15dh9_274",
|
|
31
|
+
"mode-switch": "awsui_mode-switch_mgja0_15dh9_278",
|
|
32
|
+
"dropdown": "awsui_dropdown_mgja0_15dh9_282",
|
|
33
|
+
"dropdown-content": "awsui_dropdown-content_mgja0_15dh9_304",
|
|
34
|
+
"start-date-input": "awsui_start-date-input_mgja0_15dh9_313",
|
|
35
|
+
"start-time-input": "awsui_start-time-input_mgja0_15dh9_314",
|
|
36
|
+
"end-date-input": "awsui_end-date-input_mgja0_15dh9_315",
|
|
37
|
+
"end-time-input": "awsui_end-time-input_mgja0_15dh9_316",
|
|
38
|
+
"validation-section": "awsui_validation-section_mgja0_15dh9_320",
|
|
39
|
+
"validation-error": "awsui_validation-error_mgja0_15dh9_324",
|
|
40
|
+
"clear-button": "awsui_clear-button_mgja0_15dh9_328",
|
|
41
|
+
"apply-button": "awsui_apply-button_mgja0_15dh9_332",
|
|
42
|
+
"cancel-button": "awsui_cancel-button_mgja0_15dh9_336",
|
|
43
|
+
"calendar-aria-live": "awsui_calendar-aria-live_mgja0_15dh9_340"
|
|
43
44
|
};
|
|
44
45
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
2
|
-
import {
|
|
2
|
+
import { formatTimeOffsetISO, parseTimezoneOffset, shiftTimezoneOffset } from '../internal/utils/date-time';
|
|
3
3
|
import { addMinutes } from 'date-fns';
|
|
4
4
|
/**
|
|
5
5
|
* Appends a time zone offset to an offset-less date string.
|
|
@@ -10,8 +10,8 @@ export function setTimeOffset(value, timeOffset) {
|
|
|
10
10
|
}
|
|
11
11
|
return {
|
|
12
12
|
type: 'absolute',
|
|
13
|
-
startDate: value.startDate +
|
|
14
|
-
endDate: value.endDate +
|
|
13
|
+
startDate: value.startDate + formatTimeOffsetISO(value.startDate, timeOffset.startDate),
|
|
14
|
+
endDate: value.endDate + formatTimeOffsetISO(value.endDate, timeOffset.endDate),
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-offset.js","sourceRoot":"lib/default/","sources":["date-range-picker/time-offset.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"time-offset.js","sourceRoot":"lib/default/","sources":["date-range-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E,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;KAChE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,KAAwC,EACxC,aAA0D,EAC1D,UAAmB;IAEnB,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;QACtC,IAAI,aAAa,EAAE;YACjB,OAAO;gBACL,SAAS,EAAE,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBACvD,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aACpD,CAAC;SACH;aAAM,IAAI,UAAU,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;SACvD;KACF;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;EAeE;AACF,SAAS,YAAY,CAAC,aAAqB;IACzC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC,IAAI,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { DateRangePickerProps } from './interfaces';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { formatTimeOffsetISO, parseTimezoneOffset, shiftTimezoneOffset } from '../internal/utils/date-time';\nimport { addMinutes } from 'date-fns';\n\n/**\n * Appends a time zone offset to an offset-less date string.\n */\nexport function setTimeOffset(\n value: DateRangePickerProps.Value | null,\n timeOffset: { startDate?: number; endDate?: number }\n): DateRangePickerProps.Value | null {\n if (!(value?.type === 'absolute')) {\n return value;\n }\n return {\n type: 'absolute',\n startDate: value.startDate + formatTimeOffsetISO(value.startDate, timeOffset.startDate),\n endDate: value.endDate + formatTimeOffsetISO(value.endDate, timeOffset.endDate),\n };\n}\n\n/**\n * Re-formats an absolute date range so that it is expressed using the\n * target time offset. The returned value still represents the same range\n * in time, but contains no visible offset.\n */\nexport function shiftTimeOffset(\n value: null | DateRangePickerProps.Value,\n timeOffset: { startDate?: number; endDate?: number }\n): DateRangePickerProps.Value | null {\n if (!value || value.type !== 'absolute') {\n return value;\n }\n\n /*\n This regex matches an ISO date-time with\n - optional seconds;\n - optional milliseconds;\n - optional time offset or 'Z'.\n */\n const dateTimeRegex = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2})?(\\.\\d{1,3})?(((\\+|-)\\d{2}(:\\d{2})?)|Z)?$/;\n\n if (!dateTimeRegex.test(value.startDate) || !dateTimeRegex.test(value.endDate)) {\n warnOnce(\n 'DateRangePicker',\n 'You have provided a misformatted start or end date. The component will fall back to an empty value. ' +\n 'Dates have to be ISO8601-formatted with an optional time zone offset.'\n );\n return null;\n }\n\n return {\n type: 'absolute',\n startDate: shiftTimezoneOffset(value.startDate, timeOffset.startDate),\n endDate: shiftTimezoneOffset(value.endDate, timeOffset.endDate),\n };\n}\n\nexport function normalizeTimeOffset(\n value: null | DateRangePickerProps.Value,\n getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction,\n timeOffset?: number\n) {\n if (value && value.type === 'absolute') {\n if (getTimeOffset) {\n return {\n startDate: getTimeOffset(parseDateUTC(value.startDate)),\n endDate: getTimeOffset(parseDateUTC(value.endDate)),\n };\n } else if (timeOffset !== undefined) {\n return { startDate: timeOffset, endDate: timeOffset };\n }\n }\n return { startDate: undefined, endDate: undefined };\n}\n\n/*\n Before the getTimeOffset function is used there is no information on the preferred time offset.\n \n Besides, the ISO date string might or might not contain the offset:\n - 2021-02-03T01:02:03\n - 2021-02-03T01:02:03Z\n - 2021-02-03T01:02:03+01:00\n \n For every value above the date is converted to UTC and the following is true:\n date.getUTCFullYear() === 2021\n date.getUTCMonth() === 1\n date.getUTCDate() === 3\n date.getUTCHours() === 1\n date.getUTCMinutes() === 2\n date.getUTCSeconds() === 3\n*/\nfunction parseDateUTC(isoDateString: string): Date {\n const date = new Date(isoDateString);\n return addMinutes(date, parseTimezoneOffset(isoDateString));\n}\n"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date-iso.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-iso.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,WAAW,EACvB,IAAI,EAAE,OAAO,EACb,cAAc,EACd,UAAU,EACV,UAAU,GACX,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,UAGA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { formatTimeOffsetISO } from './format-time-offset';
|
|
4
|
+
export default function ({ date: isoDate, hideTimeOffset, isDateOnly, timeOffset, }) {
|
|
5
|
+
const formattedOffset = hideTimeOffset || isDateOnly ? '' : formatTimeOffsetISO(isoDate, timeOffset);
|
|
6
|
+
return isoDate + formattedOffset;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=format-date-iso.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date-iso.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-iso.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,CAAC,OAAO,WAAW,EACvB,IAAI,EAAE,OAAO,EACb,cAAc,EACd,UAAU,EACV,UAAU,GAMX;IACC,MAAM,eAAe,GAAG,cAAc,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACrG,OAAO,OAAO,GAAG,eAAe,CAAC;AACnC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { formatTimeOffsetISO } from './format-time-offset';\n\nexport default function ({\n date: isoDate,\n hideTimeOffset,\n isDateOnly,\n timeOffset,\n}: {\n date: string;\n hideTimeOffset?: boolean;\n isDateOnly: boolean;\n timeOffset?: number;\n}) {\n const formattedOffset = hideTimeOffset || isDateOnly ? '' : formatTimeOffsetISO(isoDate, timeOffset);\n return isoDate + formattedOffset;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default function formatDateLocalized({ date: isoDate, hideTimeOffset, isDateOnly, timeOffset, locale, }: {
|
|
2
|
+
date: string;
|
|
3
|
+
hideTimeOffset?: boolean;
|
|
4
|
+
isDateOnly: boolean;
|
|
5
|
+
timeOffset?: number;
|
|
6
|
+
locale?: string;
|
|
7
|
+
}): string;
|
|
8
|
+
//# sourceMappingURL=format-date-localized.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date-localized.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-localized.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,IAAI,EAAE,OAAO,EACb,cAAc,EACd,UAAU,EACV,UAAU,EACV,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,UA4BA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { formatTimeOffsetLocalized } from './format-time-offset';
|
|
4
|
+
export default function formatDateLocalized({ date: isoDate, hideTimeOffset, isDateOnly, timeOffset, locale, }) {
|
|
5
|
+
const date = new Date(isoDate);
|
|
6
|
+
const formattedDate = new Intl.DateTimeFormat(locale, {
|
|
7
|
+
day: 'numeric',
|
|
8
|
+
month: 'long',
|
|
9
|
+
year: 'numeric',
|
|
10
|
+
}).format(date);
|
|
11
|
+
if (isDateOnly) {
|
|
12
|
+
return formattedDate;
|
|
13
|
+
}
|
|
14
|
+
const formattedTime = new Intl.DateTimeFormat(locale, {
|
|
15
|
+
hour: '2-digit',
|
|
16
|
+
hourCycle: 'h23',
|
|
17
|
+
minute: '2-digit',
|
|
18
|
+
second: '2-digit',
|
|
19
|
+
}).format(date);
|
|
20
|
+
const formattedDateTime = formattedDate + getDateTimeSeparator(locale) + formattedTime;
|
|
21
|
+
if (hideTimeOffset) {
|
|
22
|
+
return formattedDateTime;
|
|
23
|
+
}
|
|
24
|
+
const formattedTimeOffset = formatTimeOffsetLocalized(isoDate, timeOffset);
|
|
25
|
+
return formattedDateTime + ' ' + formattedTimeOffset;
|
|
26
|
+
}
|
|
27
|
+
// Languages in which date and time are separated just with a space, without comma
|
|
28
|
+
const languagesWithoutDateTimeSeparator = ['ja', 'zh-CN', 'zh-TW'];
|
|
29
|
+
function getDateTimeSeparator(locale) {
|
|
30
|
+
return locale && languagesWithoutDateTimeSeparator.includes(locale) ? ' ' : ', ';
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=format-date-localized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date-localized.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-localized.ts"],"names":[],"m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C;AACnF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { formatTimeOffsetLocalized } from './format-time-offset';\n\nexport default function formatDateLocalized({\n date: isoDate,\n hideTimeOffset,\n isDateOnly,\n timeOffset,\n locale,\n}: {\n date: string;\n hideTimeOffset?: boolean;\n isDateOnly: boolean;\n timeOffset?: number;\n locale?: string;\n}) {\n const date = new Date(isoDate);\n\n const formattedDate = new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n }).format(date);\n\n if (isDateOnly) {\n return formattedDate;\n }\n\n const formattedTime = new Intl.DateTimeFormat(locale, {\n hour: '2-digit',\n hourCycle: 'h23',\n minute: '2-digit',\n second: '2-digit',\n }).format(date);\n\n const formattedDateTime = formattedDate + getDateTimeSeparator(locale) + formattedTime;\n\n if (hideTimeOffset) {\n return formattedDateTime;\n }\n\n const formattedTimeOffset = formatTimeOffsetLocalized(isoDate, timeOffset);\n return formattedDateTime + ' ' + formattedTimeOffset;\n}\n\n// Languages in which date and time are separated just with a space, without comma\nconst languagesWithoutDateTimeSeparator = ['ja', 'zh-CN', 'zh-TW'];\n\nfunction getDateTimeSeparator(locale?: string) {\n return locale && languagesWithoutDateTimeSeparator.includes(locale) ? ' ' : ', ';\n}\n"]}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DateRangePickerProps } from '../../../date-range-picker/interfaces';
|
|
2
|
+
export declare function formatDateRange({ startDate, endDate, timeOffset, hideTimeOffset, format, locale, }: {
|
|
3
|
+
startDate: string;
|
|
4
|
+
endDate: string;
|
|
5
|
+
hideTimeOffset?: boolean;
|
|
6
|
+
timeOffset: {
|
|
7
|
+
startDate?: number;
|
|
8
|
+
endDate?: number;
|
|
9
|
+
};
|
|
10
|
+
format: DateRangePickerProps.AbsoluteFormat;
|
|
11
|
+
locale?: string;
|
|
4
12
|
}): string;
|
|
5
13
|
//# sourceMappingURL=format-date-range.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-date-range.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"format-date-range.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,MAAM,GACP,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,MAAM,EAAE,oBAAoB,CAAC,cAAc,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,CAqBT"}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { formatTimezoneOffset } from './format-timezone-offset';
|
|
4
3
|
import { isIsoDateOnly } from './is-iso-date-only';
|
|
5
|
-
|
|
4
|
+
import formatDateIso from './format-date-iso';
|
|
5
|
+
import formatDateLocalized from './format-date-localized';
|
|
6
|
+
export function formatDateRange({ startDate, endDate, timeOffset, hideTimeOffset, format, locale, }) {
|
|
6
7
|
const isDateOnly = isIsoDateOnly(startDate) && isIsoDateOnly(endDate);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
return (formatDate({
|
|
9
|
+
date: startDate,
|
|
10
|
+
format,
|
|
11
|
+
hideTimeOffset,
|
|
12
|
+
isDateOnly,
|
|
13
|
+
timeOffset: timeOffset.startDate,
|
|
14
|
+
locale,
|
|
15
|
+
}) +
|
|
16
|
+
' — ' +
|
|
17
|
+
formatDate({
|
|
18
|
+
date: endDate,
|
|
19
|
+
format,
|
|
20
|
+
hideTimeOffset,
|
|
21
|
+
isDateOnly,
|
|
22
|
+
timeOffset: timeOffset.endDate,
|
|
23
|
+
locale,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
function formatDate({ date, format, hideTimeOffset, isDateOnly, timeOffset, locale, }) {
|
|
27
|
+
switch (format) {
|
|
28
|
+
case 'long-localized': {
|
|
29
|
+
return formatDateLocalized({ date, hideTimeOffset, isDateOnly, locale, timeOffset });
|
|
30
|
+
}
|
|
31
|
+
default: {
|
|
32
|
+
return formatDateIso({ date, hideTimeOffset, isDateOnly, timeOffset });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
10
35
|
}
|
|
11
36
|
//# sourceMappingURL=format-date-range.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-date-range.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"format-date-range.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,mBAAmB,MAAM,yBAAyB,CAAC;AAG1D,MAAM,UAAU,eAAe,CAAC,EAC9B,SAAS,EACT,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,MAAM,GAQP;IACC,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IACtE,OAAO,CACL,UAAU,CAAC;QACT,IAAI,EAAE,SAAS;QACf,MAAM;QACN,cAAc;QACd,UAAU;QACV,UAAU,EAAE,UAAU,CAAC,SAAS;QAChC,MAAM;KACP,CAAC;QACF,KAAK;QACL,UAAU,CAAC;YACT,IAAI,EAAE,OAAO;YACb,MAAM;YACN,cAAc;YACd,UAAU;YACV,UAAU,EAAE,UAAU,CAAC,OAAO;YAC9B,MAAM;SACP,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAClB,IAAI,EACJ,MAAM,EACN,cAAc,EACd,UAAU,EACV,UAAU,EACV,MAAM,GAQP;IACC,QAAQ,MAAM,EAAE;QACd,KAAK,gBAAgB,CAAC,CAAC;YACrB,OAAO,mBAAmB,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;SACtF;QACD,OAAO,CAAC,CAAC;YACP,OAAO,aAAa,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;SACxE;KACF;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { isIsoDateOnly } from './is-iso-date-only';\nimport formatDateIso from './format-date-iso';\nimport formatDateLocalized from './format-date-localized';\nimport { DateRangePickerProps } from '../../../date-range-picker/interfaces';\n\nexport function formatDateRange({\n startDate,\n endDate,\n timeOffset,\n hideTimeOffset,\n format,\n locale,\n}: {\n startDate: string;\n endDate: string;\n hideTimeOffset?: boolean;\n timeOffset: { startDate?: number; endDate?: number };\n format: DateRangePickerProps.AbsoluteFormat;\n locale?: string;\n}): string {\n const isDateOnly = isIsoDateOnly(startDate) && isIsoDateOnly(endDate);\n return (\n formatDate({\n date: startDate,\n format,\n hideTimeOffset,\n isDateOnly,\n timeOffset: timeOffset.startDate,\n locale,\n }) +\n ' — ' +\n formatDate({\n date: endDate,\n format,\n hideTimeOffset,\n isDateOnly,\n timeOffset: timeOffset.endDate,\n locale,\n })\n );\n}\n\nfunction formatDate({\n date,\n format,\n hideTimeOffset,\n isDateOnly,\n timeOffset,\n locale,\n}: {\n date: string;\n format: DateRangePickerProps.AbsoluteFormat;\n hideTimeOffset?: boolean;\n isDateOnly: boolean;\n timeOffset?: number;\n locale?: string;\n}) {\n switch (format) {\n case 'long-localized': {\n return formatDateLocalized({ date, hideTimeOffset, isDateOnly, locale, timeOffset });\n }\n default: {\n return formatDateIso({ date, hideTimeOffset, isDateOnly, timeOffset });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-time-offset.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-time-offset.ts"],"names":[],"mappings":"AAKA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,UAQ5E;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,UAYlF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { padLeftZeros } from '../strings';
|
|
4
|
+
export function formatTimeOffsetISO(isoDate, offsetInMinutes) {
|
|
5
|
+
offsetInMinutes = defaultToLocal(isoDate, offsetInMinutes);
|
|
6
|
+
const { hours, minutes } = getMinutesAndHours(offsetInMinutes);
|
|
7
|
+
const sign = offsetInMinutes < 0 ? '-' : '+';
|
|
8
|
+
const formattedOffset = `${sign}${formatISO2Digits(hours)}:${formatISO2Digits(minutes)}`;
|
|
9
|
+
return formattedOffset;
|
|
10
|
+
}
|
|
11
|
+
export function formatTimeOffsetLocalized(isoDate, offsetInMinutes) {
|
|
12
|
+
offsetInMinutes = defaultToLocal(isoDate, offsetInMinutes);
|
|
13
|
+
if (offsetInMinutes === 0) {
|
|
14
|
+
return '(UTC)';
|
|
15
|
+
}
|
|
16
|
+
const { hours, minutes } = getMinutesAndHours(offsetInMinutes);
|
|
17
|
+
const sign = offsetInMinutes < 0 ? '-' : '+';
|
|
18
|
+
const formattedMinutes = minutes === 0 ? '' : `:${minutes}`;
|
|
19
|
+
const formattedOffset = `(UTC${sign}${hours}${formattedMinutes})`;
|
|
20
|
+
return formattedOffset;
|
|
21
|
+
}
|
|
22
|
+
function defaultToLocal(isoDate, offsetInMinutes) {
|
|
23
|
+
return offsetInMinutes !== null && offsetInMinutes !== void 0 ? offsetInMinutes : 0 - new Date(isoDate).getTimezoneOffset();
|
|
24
|
+
}
|
|
25
|
+
function getMinutesAndHours(minutes) {
|
|
26
|
+
return { hours: Math.floor(Math.abs(minutes) / 60), minutes: Math.abs(minutes % 60) };
|
|
27
|
+
}
|
|
28
|
+
function formatISO2Digits(n) {
|
|
29
|
+
return padLeftZeros(n.toFixed(0), 2);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=format-time-offset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-time-offset.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-time-offset.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,eAAwB;IAC3E,eAAe,GAAG,cAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAE/D,MAAM,IAAI,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7C,MAAM,eAAe,GAAG,GAAG,IAAI,GAAG,gBAAgB,C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inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { padLeftZeros } from '../strings';\n\nexport function formatTimeOffsetISO(isoDate: string, offsetInMinutes?: number) {\n offsetInMinutes = defaultToLocal(isoDate, offsetInMinutes);\n const { hours, minutes } = getMinutesAndHours(offsetInMinutes);\n\n const sign = offsetInMinutes < 0 ? '-' : '+';\n const formattedOffset = `${sign}${formatISO2Digits(hours)}:${formatISO2Digits(minutes)}`;\n\n return formattedOffset;\n}\n\nexport function formatTimeOffsetLocalized(isoDate: string, offsetInMinutes?: number) {\n offsetInMinutes = defaultToLocal(isoDate, offsetInMinutes);\n if (offsetInMinutes === 0) {\n return '(UTC)';\n }\n const { hours, minutes } = getMinutesAndHours(offsetInMinutes);\n\n const sign = offsetInMinutes < 0 ? '-' : '+';\n const formattedMinutes = minutes === 0 ? '' : `:${minutes}`;\n const formattedOffset = `(UTC${sign}${hours}${formattedMinutes})`;\n\n return formattedOffset;\n}\n\nfunction defaultToLocal(isoDate: string, offsetInMinutes?: number) {\n return offsetInMinutes ?? 0 - new Date(isoDate).getTimezoneOffset();\n}\n\nfunction getMinutesAndHours(minutes: number) {\n return { hours: Math.floor(Math.abs(minutes) / 60), minutes: Math.abs(minutes % 60) };\n}\n\nfunction formatISO2Digits(n: number) {\n return padLeftZeros(n.toFixed(0), 2);\n}\n"]}
|
|
@@ -3,7 +3,7 @@ export { formatDateRange } from './format-date-range';
|
|
|
3
3
|
export { formatDate } from './format-date';
|
|
4
4
|
export { formatTime } from './format-time';
|
|
5
5
|
export { formatDateTime } from './format-date-time';
|
|
6
|
-
export {
|
|
6
|
+
export { formatTimeOffsetISO } from './format-time-offset';
|
|
7
7
|
export { isIsoDateOnly } from './is-iso-date-only';
|
|
8
8
|
export { joinDateTime, splitDateTime } from './join-date-time';
|
|
9
9
|
export { parseDate } from './parse-date';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -5,7 +5,7 @@ export { formatDateRange } from './format-date-range';
|
|
|
5
5
|
export { formatDate } from './format-date';
|
|
6
6
|
export { formatTime } from './format-time';
|
|
7
7
|
export { formatDateTime } from './format-date-time';
|
|
8
|
-
export {
|
|
8
|
+
export { formatTimeOffsetISO } from './format-time-offset';
|
|
9
9
|
export { isIsoDateOnly } from './is-iso-date-only';
|
|
10
10
|
export { joinDateTime, splitDateTime } from './join-date-time';
|
|
11
11
|
export { parseDate } from './parse-date';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { isoToDisplay, displayToIso } from './display-format';\nexport { formatDateRange } from './format-date-range';\nexport { formatDate } from './format-date';\nexport { formatTime } from './format-time';\nexport { formatDateTime } from './format-date-time';\nexport { formatTimeOffsetISO } from './format-time-offset';\nexport { isIsoDateOnly } from './is-iso-date-only';\nexport { joinDateTime, splitDateTime } from './join-date-time';\nexport { parseDate } from './parse-date';\nexport { parseTimezoneOffset } from './parse-timezone-offset';\nexport { shiftTimezoneOffset } from './shift-timezone-offset';\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-timezone-offset.d.ts","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-timezone-offset.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,UAS7E"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { padLeftZeros } from '../strings';
|
|
4
|
-
export function formatTimezoneOffset(isoDate, offsetInMinutes) {
|
|
5
|
-
offsetInMinutes = offsetInMinutes !== null && offsetInMinutes !== void 0 ? offsetInMinutes : 0 - new Date(isoDate).getTimezoneOffset();
|
|
6
|
-
const hoursOffset = padLeftZeros(Math.floor(Math.abs(offsetInMinutes) / 60).toFixed(0), 2);
|
|
7
|
-
const minuteOffset = padLeftZeros(Math.abs(offsetInMinutes % 60).toFixed(0), 2);
|
|
8
|
-
const sign = offsetInMinutes < 0 ? '-' : '+';
|
|
9
|
-
const formattedOffset = `${sign}${hoursOffset}:${minuteOffset}`;
|
|
10
|
-
return formattedOffset;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=format-timezone-offset.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format-timezone-offset.js","sourceRoot":"lib/default/","sources":["internal/utils/date-time/format-timezone-offset.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,eAAwB;IAC5E,eAAe,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC/E,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3F,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhF,MAAM,IAAI,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7C,MAAM,eAAe,GAAG,GAAG,IAAI,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC;IAEhE,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { padLeftZeros } from '../strings';\n\nexport function formatTimezoneOffset(isoDate: string, offsetInMinutes?: number) {\n offsetInMinutes = offsetInMinutes ?? 0 - new Date(isoDate).getTimezoneOffset();\n const hoursOffset = padLeftZeros(Math.floor(Math.abs(offsetInMinutes) / 60).toFixed(0), 2);\n const minuteOffset = padLeftZeros(Math.abs(offsetInMinutes % 60).toFixed(0), 2);\n\n const sign = offsetInMinutes < 0 ? '-' : '+';\n const formattedOffset = `${sign}${hoursOffset}:${minuteOffset}`;\n\n return formattedOffset;\n}\n"]}
|