@cloudscape-design/components 3.0.81 → 3.0.82

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.
@@ -3,5 +3,5 @@ export interface DateRangePickerEmbeddedProps extends DateRangePickerBaseProps {
3
3
  ariaLabelledby?: string;
4
4
  ariaDescribedby?: string;
5
5
  }
6
- export declare function DateRangePickerEmbedded({ value, locale, startOfWeek, isDateEnabled, relativeOptions, i18nStrings, dateOnly, timeInputFormat, rangeSelectorMode, onChange, timeOffset, }: DateRangePickerEmbeddedProps): JSX.Element;
6
+ export declare function DateRangePickerEmbedded({ value, locale, startOfWeek, isDateEnabled, relativeOptions, i18nStrings, dateOnly, timeInputFormat, rangeSelectorMode, onChange, timeOffset, getTimeOffset, }: DateRangePickerEmbeddedProps): JSX.Element;
7
7
  //# sourceMappingURL=embedded.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/embedded.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAMxD,MAAM,WAAW,4BAA6B,SAAQ,wBAAwB;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,eAAe,EACf,WAAW,EACX,QAAgB,EAChB,eAA4B,EAC5B,iBAA6B,EAC7B,QAAQ,EACR,UAAU,GACX,EAAE,4BAA4B,eAiF9B"}
1
+ {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/embedded.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAOxD,MAAM,WAAW,4BAA6B,SAAQ,wBAAwB;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,eAAe,EACf,WAAW,EACX,QAAgB,EAChB,eAA4B,EAC5B,iBAA6B,EAC7B,QAAQ,EACR,UAAU,EACV,aAAa,GACd,EAAE,4BAA4B,eAiF9B"}
@@ -10,8 +10,9 @@ import { useDateRangePicker } from './use-date-range-picker';
10
10
  import { fireNonCancelableEvent } from '../internal/events/index.js';
11
11
  import { formatValue } from './use-date-range-picker.js';
12
12
  import { useMobile } from '../internal/hooks/use-mobile';
13
+ import { normalizeTimeOffset } from './time-offset';
13
14
  export function DateRangePickerEmbedded(_a) {
14
- var value = _a.value, _b = _a.locale, locale = _b === void 0 ? '' : _b, startOfWeek = _a.startOfWeek, _c = _a.isDateEnabled, isDateEnabled = _c === void 0 ? function () { return true; } : _c, relativeOptions = _a.relativeOptions, i18nStrings = _a.i18nStrings, _d = _a.dateOnly, dateOnly = _d === void 0 ? false : _d, _e = _a.timeInputFormat, timeInputFormat = _e === void 0 ? 'hh:mm:ss' : _e, _f = _a.rangeSelectorMode, rangeSelectorMode = _f === void 0 ? 'default' : _f, onChange = _a.onChange, timeOffset = _a.timeOffset;
15
+ var value = _a.value, _b = _a.locale, locale = _b === void 0 ? '' : _b, startOfWeek = _a.startOfWeek, _c = _a.isDateEnabled, isDateEnabled = _c === void 0 ? function () { return true; } : _c, relativeOptions = _a.relativeOptions, i18nStrings = _a.i18nStrings, _d = _a.dateOnly, dateOnly = _d === void 0 ? false : _d, _e = _a.timeInputFormat, timeInputFormat = _e === void 0 ? 'hh:mm:ss' : _e, _f = _a.rangeSelectorMode, rangeSelectorMode = _f === void 0 ? 'default' : _f, onChange = _a.onChange, timeOffset = _a.timeOffset, getTimeOffset = _a.getTimeOffset;
15
16
  var _g = useDateRangePicker({
16
17
  value: value,
17
18
  relativeOptions: relativeOptions,
@@ -20,7 +21,8 @@ export function DateRangePickerEmbedded(_a) {
20
21
  var isSingleGrid = useMobile();
21
22
  function updateRange(value) {
22
23
  var newValue = value.type === 'relative' ? value : fillMissingTime(value);
23
- fireNonCancelableEvent(onChange, { value: formatValue(newValue, { dateOnly: dateOnly, timeOffset: timeOffset }) });
24
+ var normalizedTimeOffset = normalizeTimeOffset(newValue, getTimeOffset, timeOffset);
25
+ fireNonCancelableEvent(onChange, { value: formatValue(newValue, { dateOnly: dateOnly, timeOffset: normalizedTimeOffset }) });
24
26
  }
25
27
  var focusRefs = {
26
28
  "default": useRef(null),
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.js","sourceRoot":"","sources":["../../../src/date-range-picker/embedded.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AACnD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAOzD,MAAM,UAAU,uBAAuB,CAAC,EAYT;QAX7B,KAAK,WAAA,EACL,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,WAAW,iBAAA,EACX,qBAA0B,EAA1B,aAAa,mBAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,KAAA,EAC1B,eAAe,qBAAA,EACf,WAAW,iBAAA,EACX,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,uBAA4B,EAA5B,eAAe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Q,EAAE,UAAC,IAA6B;wBACtC,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBAC9B,CAAC,EACD,WAAW,EAAE,WAAW,GACxB,CACH;gBAEA,kBAAkB,KAAK,UAAU,IAAI,CACpC,oBAAC,QAAQ,IACP,GAAG,EAAE,SAAS,CAAC,eAAe,CAAC,EAC/B,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,OAAO,EAC9C,gBAAgB,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,SAAS,EAClD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,UAAA,KAAK;wBACtB,wBAAwB,CAAC,KAAK,CAAC,CAAC;wBAChC,WAAW,CAAC,KAAK,CAAC,CAAC;oBACrB,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAChC,CACH;gBAEA,kBAAkB,KAAK,UAAU,IAAI,CACpC,oBAAC,mBAAmB,IAClB,GAAG,EAAE,SAAS,CAAC,eAAe,CAAC,EAC/B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,qBAAqB,EACvC,QAAQ,EAAE,UAAA,KAAK;wBACb,wBAAwB,CAAC,KAAK,CAAC,CAAC;wBAChC,WAAW,CAAC,KAAK,CAAC,CAAC;oBACrB,CAAC,EACD,WAAW,EAAE,WAAW,GACxB,CACH,CACY,CACH,CACD,CAChB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport Calendar from './calendar';\nimport InternalBox from '../box/internal';\nimport SpaceBetween from '../space-between/index.js';\n\nimport RelativeRangePicker from './relative-range';\nimport ModeSwitcher from './mode-switcher';\nimport { useDateRangePicker } from './use-date-range-picker';\nimport { DateRangePickerBaseProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport { DateRangePickerProps, Focusable } from './interfaces';\nimport { formatValue } from './use-date-range-picker.js';\nimport { useMobile } from '../internal/hooks/use-mobile';\n\nexport interface DateRangePickerEmbeddedProps extends DateRangePickerBaseProps {\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nexport function DateRangePickerEmbedded({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n relativeOptions,\n i18nStrings,\n dateOnly = false,\n timeInputFormat = 'hh:mm:ss',\n rangeSelectorMode = 'default',\n onChange,\n timeOffset,\n}: DateRangePickerEmbeddedProps) {\n const {\n fillMissingTime,\n rangeSelectionMode,\n setRangeSelectionMode,\n selectedAbsoluteRange,\n setSelectedAbsoluteRange,\n selectedRelativeRange,\n setSelectedRelativeRange,\n } = useDateRangePicker({\n value,\n relativeOptions,\n rangeSelectorMode,\n });\n\n const isSingleGrid = useMobile();\n\n function updateRange(value: DateRangePickerProps.AbsoluteValue | DateRangePickerProps.RelativeValue) {\n const newValue = value.type === 'relative' ? value : fillMissingTime(value);\n\n fireNonCancelableEvent(onChange, { value: formatValue(newValue, { dateOnly, timeOffset }) });\n }\n\n const focusRefs = {\n default: useRef<Focusable>(null),\n 'absolute-only': useRef<Focusable>(null),\n 'relative-only': useRef<Focusable>(null),\n };\n\n return (\n <SpaceBetween size=\"l\">\n <InternalBox padding={{ top: 'm', horizontal: 'l' }}>\n <SpaceBetween direction=\"vertical\" size=\"s\">\n {rangeSelectorMode === 'default' && (\n <ModeSwitcher\n ref={focusRefs.default}\n mode={rangeSelectionMode}\n onChange={(mode: 'absolute' | 'relative') => {\n setRangeSelectionMode(mode);\n }}\n i18nStrings={i18nStrings}\n />\n )}\n\n {rangeSelectionMode === 'absolute' && (\n <Calendar\n ref={focusRefs['absolute-only']}\n isSingleGrid={isSingleGrid}\n initialEndDate={selectedAbsoluteRange?.endDate}\n initialStartDate={selectedAbsoluteRange?.startDate}\n locale={locale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n i18nStrings={i18nStrings}\n onSelectDateRange={range => {\n setSelectedAbsoluteRange(range);\n updateRange(range);\n }}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n />\n )}\n\n {rangeSelectionMode === 'relative' && (\n <RelativeRangePicker\n ref={focusRefs['relative-only']}\n isSingleGrid={isSingleGrid}\n options={relativeOptions}\n dateOnly={dateOnly}\n initialSelection={selectedRelativeRange}\n onChange={range => {\n setSelectedRelativeRange(range);\n updateRange(range);\n }}\n i18nStrings={i18nStrings}\n />\n )}\n </SpaceBetween>\n </InternalBox>\n </SpaceBetween>\n );\n}\n"]}
1
+ {"version":3,"file":"embedded.js","sourceRoot":"","sources":["../../../src/date-range-picker/embedded.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AACnD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAOpD,MAAM,UAAU,uBAAuB,CAAC,EAaT;QAZ7B,KAAK,WAAA,EACL,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,WAAW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WAAW,CAAC,KAAK,CAAC,CAAC;oBACrB,CAAC,EACD,WAAW,EAAE,WAAW,GACxB,CACH,CACY,CACH,CACD,CAChB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport Calendar from './calendar';\nimport InternalBox from '../box/internal';\nimport SpaceBetween from '../space-between/index.js';\n\nimport RelativeRangePicker from './relative-range';\nimport ModeSwitcher from './mode-switcher';\nimport { useDateRangePicker } from './use-date-range-picker';\nimport { DateRangePickerBaseProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport { DateRangePickerProps, Focusable } from './interfaces';\nimport { formatValue } from './use-date-range-picker.js';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport { normalizeTimeOffset } from './time-offset';\n\nexport interface DateRangePickerEmbeddedProps extends DateRangePickerBaseProps {\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nexport function DateRangePickerEmbedded({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n relativeOptions,\n i18nStrings,\n dateOnly = false,\n timeInputFormat = 'hh:mm:ss',\n rangeSelectorMode = 'default',\n onChange,\n timeOffset,\n getTimeOffset,\n}: DateRangePickerEmbeddedProps) {\n const {\n fillMissingTime,\n rangeSelectionMode,\n setRangeSelectionMode,\n selectedAbsoluteRange,\n setSelectedAbsoluteRange,\n selectedRelativeRange,\n setSelectedRelativeRange,\n } = useDateRangePicker({\n value,\n relativeOptions,\n rangeSelectorMode,\n });\n\n const isSingleGrid = useMobile();\n\n function updateRange(value: DateRangePickerProps.AbsoluteValue | DateRangePickerProps.RelativeValue) {\n const newValue = value.type === 'relative' ? value : fillMissingTime(value);\n const normalizedTimeOffset = normalizeTimeOffset(newValue, getTimeOffset, timeOffset);\n fireNonCancelableEvent(onChange, { value: formatValue(newValue, { dateOnly, timeOffset: normalizedTimeOffset }) });\n }\n\n const focusRefs = {\n default: useRef<Focusable>(null),\n 'absolute-only': useRef<Focusable>(null),\n 'relative-only': useRef<Focusable>(null),\n };\n\n return (\n <SpaceBetween size=\"l\">\n <InternalBox padding={{ top: 'm', horizontal: 'l' }}>\n <SpaceBetween direction=\"vertical\" size=\"s\">\n {rangeSelectorMode === 'default' && (\n <ModeSwitcher\n ref={focusRefs.default}\n mode={rangeSelectionMode}\n onChange={(mode: 'absolute' | 'relative') => {\n setRangeSelectionMode(mode);\n }}\n i18nStrings={i18nStrings}\n />\n )}\n\n {rangeSelectionMode === 'absolute' && (\n <Calendar\n ref={focusRefs['absolute-only']}\n isSingleGrid={isSingleGrid}\n initialEndDate={selectedAbsoluteRange?.endDate}\n initialStartDate={selectedAbsoluteRange?.startDate}\n locale={locale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n i18nStrings={i18nStrings}\n onSelectDateRange={range => {\n setSelectedAbsoluteRange(range);\n updateRange(range);\n }}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n />\n )}\n\n {rangeSelectionMode === 'relative' && (\n <RelativeRangePicker\n ref={focusRefs['relative-only']}\n isSingleGrid={isSingleGrid}\n options={relativeOptions}\n dateOnly={dateOnly}\n initialSelection={selectedRelativeRange}\n onChange={range => {\n setSelectedRelativeRange(range);\n updateRange(range);\n }}\n i18nStrings={i18nStrings}\n />\n )}\n </SpaceBetween>\n </InternalBox>\n </SpaceBetween>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA2BpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAmDhC,QAAA,MAAM,eAAe,uGAgMpB,CAAC;AAGF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA2BpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAmDhC,QAAA,MAAM,eAAe,uGAuMpB,CAAC;AAGF,eAAe,eAAe,CAAC"}
@@ -18,7 +18,7 @@ import { useMobile } from '../internal/hooks/use-mobile';
18
18
  import ButtonTrigger from '../internal/components/button-trigger';
19
19
  import { useFormFieldContext } from '../internal/context/form-field-context';
20
20
  import InternalIcon from '../icon/internal';
21
- import { shiftTimeOffset } from './time-offset';
21
+ import { normalizeTimeOffset, shiftTimeOffset } from './time-offset';
22
22
  import useBaseComponent from '../internal/hooks/use-base-component';
23
23
  import { useMergeRefs } from '../internal/hooks/use-merge-refs';
24
24
  import { fireNonCancelableEvent } from '../internal/events/index.js';
@@ -51,10 +51,11 @@ function isDateOnly(value) {
51
51
  var DateRangePicker = React.forwardRef(function (_a, ref) {
52
52
  var _b;
53
53
  var _c, _d;
54
- var _e = _a.locale, locale = _e === void 0 ? '' : _e, startOfWeek = _a.startOfWeek, _f = _a.isDateEnabled, isDateEnabled = _f === void 0 ? function () { return true; } : _f, value = _a.value, placeholder = _a.placeholder, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.disabled, disabled = _h === void 0 ? false : _h, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, _j = _a.relativeOptions, relativeOptions = _j === void 0 ? [] : _j, i18nStrings = _a.i18nStrings, _k = _a.isValidRange, isValidRange = _k === void 0 ? function () { return ({ valid: true }); } : _k, _l = _a.showClearButton, showClearButton = _l === void 0 ? true : _l, _m = _a.dateOnly, dateOnly = _m === void 0 ? false : _m, timeOffset = _a.timeOffset, _o = _a.timeInputFormat, timeInputFormat = _o === void 0 ? 'hh:mm:ss' : _o, _p = _a.expandToViewport, expandToViewport = _p === void 0 ? false : _p, _q = _a.rangeSelectorMode, rangeSelectorMode = _q === void 0 ? 'default' : _q, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "value", "placeholder", "readOnly", "disabled", "onChange", "onBlur", "onFocus", "relativeOptions", "i18nStrings", "isValidRange", "showClearButton", "dateOnly", "timeOffset", "timeInputFormat", "expandToViewport", "rangeSelectorMode"]);
54
+ var _e = _a.locale, locale = _e === void 0 ? '' : _e, startOfWeek = _a.startOfWeek, _f = _a.isDateEnabled, isDateEnabled = _f === void 0 ? function () { return true; } : _f, value = _a.value, placeholder = _a.placeholder, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.disabled, disabled = _h === void 0 ? false : _h, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, _j = _a.relativeOptions, relativeOptions = _j === void 0 ? [] : _j, i18nStrings = _a.i18nStrings, _k = _a.isValidRange, isValidRange = _k === void 0 ? function () { return ({ valid: true }); } : _k, _l = _a.showClearButton, showClearButton = _l === void 0 ? true : _l, _m = _a.dateOnly, dateOnly = _m === void 0 ? false : _m, timeOffset = _a.timeOffset, getTimeOffset = _a.getTimeOffset, _o = _a.timeInputFormat, timeInputFormat = _o === void 0 ? 'hh:mm:ss' : _o, _p = _a.expandToViewport, expandToViewport = _p === void 0 ? false : _p, _q = _a.rangeSelectorMode, rangeSelectorMode = _q === void 0 ? 'default' : _q, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "value", "placeholder", "readOnly", "disabled", "onChange", "onBlur", "onFocus", "relativeOptions", "i18nStrings", "isValidRange", "showClearButton", "dateOnly", "timeOffset", "getTimeOffset", "timeInputFormat", "expandToViewport", "rangeSelectorMode"]);
55
55
  var __internalRootRef = useBaseComponent('DateRangePicker').__internalRootRef;
56
56
  checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);
57
- value = isDateOnly(value) ? value : shiftTimeOffset(value, timeOffset);
57
+ var normalizedTimeOffset = normalizeTimeOffset(value, getTimeOffset, timeOffset);
58
+ value = isDateOnly(value) ? value : shiftTimeOffset(value, normalizedTimeOffset);
58
59
  var baseProps = getBaseProps(rest);
59
60
  var _r = useFormFieldContext(__assign({ ariaLabelledby: (_c = rest.ariaLabelledby) !== null && _c !== void 0 ? _c : i18nStrings.ariaLabelledby, ariaDescribedby: (_d = rest.ariaDescribedby) !== null && _d !== void 0 ? _d : i18nStrings.ariaDescribedby }, rest)), invalid = _r.invalid, controlId = _r.controlId, ariaDescribedby = _r.ariaDescribedby, ariaLabelledby = _r.ariaLabelledby;
60
61
  var isSingleGrid = useMobile();
@@ -95,7 +96,12 @@ var DateRangePicker = React.forwardRef(function (_a, ref) {
95
96
  }
96
97
  }
97
98
  }
98
- fireNonCancelableEvent(onChange, { value: formatValue(newValue, { dateOnly: dateOnly, timeOffset: timeOffset }) });
99
+ fireNonCancelableEvent(onChange, {
100
+ value: formatValue(newValue, {
101
+ dateOnly: dateOnly,
102
+ timeOffset: normalizeTimeOffset(newValue, getTimeOffset, timeOffset)
103
+ })
104
+ });
99
105
  return validationResult || { valid: true };
100
106
  };
101
107
  var prevDateOnly = usePrevious(dateOnly);
@@ -124,7 +130,7 @@ var DateRangePicker = React.forwardRef(function (_a, ref) {
124
130
  React.createElement("span", { className: styles['trigger-flexbox'] },
125
131
  React.createElement("span", { className: styles['icon-wrapper'] },
126
132
  React.createElement(InternalIcon, { name: "calendar", variant: disabled || readOnly ? 'disabled' : 'normal' })),
127
- renderDateRange(value, placeholder !== null && placeholder !== void 0 ? placeholder : '', i18nStrings.formatRelativeRange, timeOffset)))));
133
+ renderDateRange(value, placeholder !== null && placeholder !== void 0 ? placeholder : '', i18nStrings.formatRelativeRange, normalizedTimeOffset)))));
128
134
  var mergedRef = useMergeRefs(rootRef, __internalRootRef);
129
135
  return (React.createElement("div", __assign({}, baseProps, { ref: mergedRef, className: clsx(baseProps.className, styles.root), onKeyDown: onWrapperKeyDownHandler }),
130
136
  React.createElement(Dropdown, { stretchWidth: true, stretchHeight: true, open: isDropDownOpen, onDropdownClose: function () { return closeDropdown(); }, trigger: trigger, stretchToTriggerWidth: false, expandToViewport: expandToViewport, dropdownId: dropdownId }, isDropDownOpen && (React.createElement(DateRangePickerDropdown, { startOfWeek: startOfWeek, locale: normalizedLocale, isSingleGrid: isSingleGrid, onDropdownClose: function () { return 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 })))));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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,2BAA2B,CAAC;AAC5D,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,O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AE,uBAAuB;QAElC,oBAAC,QAAQ,IACP,YAAY,EAAE,IAAI,EAClB,aAAa,EAAE,IAAI,EACnB,IAAI,EAAE,cAAc,EACpB,eAAe,EAAE,cAAM,OAAA,aAAa,EAAE,EAAf,CAAe,EACtC,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,KAAK,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,IAErB,cAAc,IAAI,CACjB,oBAAC,uBAAuB,IACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,cAAM,OAAA,aAAa,CAAC,IAAI,CAAC,EAAnB,CAAmB,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,GAChC,CACH,CACQ,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 '../calendar/utils/locales';\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 { 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/index.js';\nimport { isDevelopment } from '../internal/is-development.js';\nimport { warnOnce } from '../internal/logging.js';\nimport { usePrevious } from '../internal/hooks/use-previous/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';\nimport { formatValue } from './use-date-range-picker.js';\n\nexport { DateRangePickerProps };\n\nfunction renderDateRange(\n range: null | DateRangePickerProps.Value,\n placeholder: string,\n formatRelativeRange: DateRangePickerProps.I18nStrings['formatRelativeRange'],\n timeOffset?: 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 timeInputFormat = 'hh:mm:ss',\n expandToViewport = false,\n rangeSelectorMode = 'default',\n ...rest\n }: DateRangePickerProps,\n ref: Ref<DateRangePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DateRangePicker');\n checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);\n\n value = isDateOnly(value) ? value : shiftTimeOffset(value, timeOffset);\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\n useFocusTracker({ rootRef, onBlur, onFocus, viewportId: expandToViewport ? dropdownId : '' });\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 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, { value: formatValue(newValue, { dateOnly, timeOffset }) });\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 trigger = (\n <div className={styles['trigger-wrapper']}>\n <ButtonTrigger\n ref={triggerRef}\n id={controlId}\n invalid={invalid}\n ariaLabel={i18nStrings.ariaLabel}\n ariaDescribedby={ariaDescribedby}\n ariaLabelledby={ariaLabelledby}\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=\"true\"\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 {renderDateRange(value, placeholder ?? '', i18nStrings.formatRelativeRange, timeOffset)}\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 {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 />\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DateRangePicker, 'DateRangePicker');\nexport default DateRangePicker;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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,2BAA2B,CAAC;AAC5D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C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AAE,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,GAChC,CACH,CACQ,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 '../calendar/utils/locales';\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/index.js';\nimport { isDevelopment } from '../internal/is-development.js';\nimport { warnOnce } from '../internal/logging.js';\nimport { usePrevious } from '../internal/hooks/use-previous/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';\nimport { formatValue } from './use-date-range-picker.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 ...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\n useFocusTracker({ rootRef, onBlur, onFocus, viewportId: expandToViewport ? dropdownId : '' });\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 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 trigger = (\n <div className={styles['trigger-wrapper']}>\n <ButtonTrigger\n ref={triggerRef}\n id={controlId}\n invalid={invalid}\n ariaLabel={i18nStrings.ariaLabel}\n ariaDescribedby={ariaDescribedby}\n ariaLabelledby={ariaLabelledby}\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=\"true\"\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 {renderDateRange(value, placeholder ?? '', i18nStrings.formatRelativeRange, normalizedTimeOffset)}\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 {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 />\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DateRangePicker, 'DateRangePicker');\nexport default DateRangePicker;\n"]}
@@ -76,8 +76,23 @@ export interface DateRangePickerBaseProps {
76
76
  * Has no effect when `dateOnly` is true.
77
77
  *
78
78
  * Default: the user's current time offset as provided by the browser.
79
+ *
80
+ * This property is deprecated. Use getTimeOffset instead.
81
+ * @deprecated
79
82
  */
80
83
  timeOffset?: number;
84
+ /**
85
+ * A function that defines timezone offset from UTC in minutes for selected dates.
86
+ * Use it to define time relative to the desired timezone.
87
+ *
88
+ * The function is called for the start date and the end date and takes a UTC date
89
+ * corresponding the selected value as an argument.
90
+ *
91
+ * Has no effect when `dateOnly` is true.
92
+ *
93
+ * Default: the user's current time offset as provided by the browser.
94
+ */
95
+ getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction;
81
96
  }
82
97
  export interface DateRangePickerProps extends BaseComponentProps, FormFieldValidationControlProps, ExpandToViewport, DateRangePickerBaseProps {
83
98
  /**
@@ -165,6 +180,9 @@ export declare namespace DateRangePickerProps {
165
180
  interface IsDateEnabledFunction {
166
181
  (date: Date): boolean;
167
182
  }
183
+ interface GetTimeOffsetFunction {
184
+ (date: Date): number;
185
+ }
168
186
  type RangeSelectorMode = 'default' | 'absolute-only' | 'relative-only';
169
187
  interface Ref {
170
188
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/interfaces.ts"],"names":[],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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';\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 */\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 timeOffset?: number;\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\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 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 * 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 interface Focusable {\n focus(): void;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/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';\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 */\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 * This property is deprecated. Use getTimeOffset instead.\n * @deprecated\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\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 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 * 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 interface Focusable {\n focus(): void;\n}\n"]}
@@ -2,11 +2,24 @@ import { DateRangePickerProps } from './interfaces';
2
2
  /**
3
3
  * Appends a time zone offset to an offset-less date string.
4
4
  */
5
- export declare function setTimeOffset(value: DateRangePickerProps.Value | null, timeOffsetInMinutes?: number): DateRangePickerProps.Value | null;
5
+ export declare function setTimeOffset(value: DateRangePickerProps.Value | null, timeOffset: {
6
+ startDate?: number;
7
+ endDate?: number;
8
+ }): DateRangePickerProps.Value | null;
6
9
  /**
7
10
  * Re-formats an absolute date range so that it is expressed using the
8
11
  * target time offset. The returned value still represents the same range
9
12
  * in time, but contains no visible offset.
10
13
  */
11
- export declare function shiftTimeOffset(value: null | DateRangePickerProps.Value, timeOffsetInMinutes?: number): DateRangePickerProps.Value | null;
14
+ export declare function shiftTimeOffset(value: null | DateRangePickerProps.Value, timeOffset: {
15
+ startDate?: number;
16
+ endDate?: number;
17
+ }): DateRangePickerProps.Value | null;
18
+ export declare function normalizeTimeOffset(value: null | DateRangePickerProps.Value, getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction, timeOffset?: number): {
19
+ startDate: number;
20
+ endDate: number;
21
+ } | {
22
+ startDate: undefined;
23
+ endDate: undefined;
24
+ };
12
25
  //# sourceMappingURL=time-offset.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-offset.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/time-offset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAIpD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,oBAAoB,CAAC,KAAK,GAAG,IAAI,EACxC,mBAAmB,CAAC,EAAE,MAAM,GAC3B,oBAAoB,CAAC,KAAK,GAAG,IAAI,CAYnC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,EACxC,mBAAmB,CAAC,EAAE,MAAM,GAC3B,oBAAoB,CAAC,KAAK,GAAG,IAAI,CA2BnC"}
1
+ {"version":3,"file":"time-offset.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/time-offset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAKpD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,oBAAoB,CAAC,KAAK,GAAG,IAAI,EACxC,UAAU,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,oBAAoB,CAAC,KAAK,GAAG,IAAI,CASnC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,EACxC,UAAU,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,oBAAoB,CAAC,KAAK,GAAG,IAAI,CA2BnC;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,EACxC,aAAa,CAAC,EAAE,oBAAoB,CAAC,qBAAqB,EAC1D,UAAU,CAAC,EAAE,MAAM;;;;;;EAapB"}
@@ -1,17 +1,17 @@
1
1
  import { warnOnce } from '../internal/logging';
2
- import { formatTimezoneOffset, shiftTimezoneOffset } from '../internal/utils/date-time';
2
+ import { formatTimezoneOffset, parseTimezoneOffset, shiftTimezoneOffset } from '../internal/utils/date-time';
3
+ import { addMinutes } from 'date-fns';
3
4
  /**
4
5
  * Appends a time zone offset to an offset-less date string.
5
6
  */
6
- export function setTimeOffset(value, timeOffsetInMinutes) {
7
+ export function setTimeOffset(value, timeOffset) {
7
8
  if (!((value === null || value === void 0 ? void 0 : value.type) === 'absolute')) {
8
9
  return value;
9
10
  }
10
- var startDate = value.startDate, endDate = value.endDate;
11
11
  return {
12
12
  type: 'absolute',
13
- startDate: startDate + formatTimezoneOffset(startDate, timeOffsetInMinutes),
14
- endDate: endDate + formatTimezoneOffset(endDate, timeOffsetInMinutes)
13
+ startDate: value.startDate + formatTimezoneOffset(value.startDate, timeOffset.startDate),
14
+ endDate: value.endDate + formatTimezoneOffset(value.endDate, timeOffset.endDate)
15
15
  };
16
16
  }
17
17
  /**
@@ -19,7 +19,7 @@ export function setTimeOffset(value, timeOffsetInMinutes) {
19
19
  * target time offset. The returned value still represents the same range
20
20
  * in time, but contains no visible offset.
21
21
  */
22
- export function shiftTimeOffset(value, timeOffsetInMinutes) {
22
+ export function shiftTimeOffset(value, timeOffset) {
23
23
  if (!value || value.type !== 'absolute') {
24
24
  return value;
25
25
  }
@@ -37,8 +37,42 @@ export function shiftTimeOffset(value, timeOffsetInMinutes) {
37
37
  }
38
38
  return {
39
39
  type: 'absolute',
40
- startDate: shiftTimezoneOffset(value.startDate, timeOffsetInMinutes),
41
- endDate: shiftTimezoneOffset(value.endDate, timeOffsetInMinutes)
40
+ startDate: shiftTimezoneOffset(value.startDate, timeOffset.startDate),
41
+ endDate: shiftTimezoneOffset(value.endDate, timeOffset.endDate)
42
42
  };
43
43
  }
44
+ export function normalizeTimeOffset(value, getTimeOffset, timeOffset) {
45
+ if (value && value.type === 'absolute') {
46
+ if (getTimeOffset) {
47
+ return {
48
+ startDate: getTimeOffset(parseDateUTC(value.startDate)),
49
+ endDate: getTimeOffset(parseDateUTC(value.endDate))
50
+ };
51
+ }
52
+ else if (timeOffset !== undefined) {
53
+ return { startDate: timeOffset, endDate: timeOffset };
54
+ }
55
+ }
56
+ return { startDate: undefined, endDate: undefined };
57
+ }
58
+ /*
59
+ Before the getTimeOffset function is used there is no information on the preferred time offset.
60
+
61
+ Besides, the ISO date string might or might not contain the offset:
62
+ - 2021-02-03T01:02:03
63
+ - 2021-02-03T01:02:03Z
64
+ - 2021-02-03T01:02:03+01:00
65
+
66
+ For every value above the date is converted to UTC and the following is true:
67
+ date.getUTCFullYear() === 2021
68
+ date.getUTCMonth() === 1
69
+ date.getUTCDate() === 3
70
+ date.getUTCHours() === 1
71
+ date.getUTCMinutes() === 2
72
+ date.getUTCSeconds() === 3
73
+ */
74
+ function parseDateUTC(isoDateString) {
75
+ var date = new Date(isoDateString);
76
+ return addMinutes(date, parseTimezoneOffset(isoDateString));
77
+ }
44
78
  //# sourceMappingURL=time-offset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-offset.js","sourceRoot":"","sources":["../../../src/date-range-picker/time-offset.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,q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All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { DateRangePickerProps } from './interfaces';\nimport { warnOnce } from '../internal/logging';\nimport { formatTimezoneOffset, shiftTimezoneOffset } from '../internal/utils/date-time';\n\n/**\n * Appends a time zone offset to an offset-less date string.\n */\nexport function setTimeOffset(\n value: DateRangePickerProps.Value | null,\n timeOffsetInMinutes?: number\n): DateRangePickerProps.Value | null {\n if (!(value?.type === 'absolute')) {\n return value;\n }\n\n const { startDate, endDate } = value;\n\n return {\n type: 'absolute',\n startDate: startDate + formatTimezoneOffset(startDate, timeOffsetInMinutes),\n endDate: endDate + formatTimezoneOffset(endDate, timeOffsetInMinutes),\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 timeOffsetInMinutes?: 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, timeOffsetInMinutes),\n endDate: shiftTimezoneOffset(value.endDate, timeOffsetInMinutes),\n };\n}\n"]}
1
+ {"version":3,"file":"time-offset.js","sourceRoot":"","sources":["../../../src/date-range-picker/time-offset.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C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AAC;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,IAAM,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 '../internal/logging';\nimport { formatTimezoneOffset, 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 + formatTimezoneOffset(value.startDate, timeOffset.startDate),\n endDate: value.endDate + formatTimezoneOffset(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"]}
@@ -8,7 +8,10 @@ declare function fillMissingTime(value: DateRangePickerProps.AbsoluteValue | nul
8
8
  type: "absolute";
9
9
  } | null;
10
10
  export declare function formatValue(value: null | DateRangePickerProps.Value, { timeOffset, dateOnly }: {
11
- timeOffset?: number;
11
+ timeOffset: {
12
+ startDate?: number;
13
+ endDate?: number;
14
+ };
12
15
  dateOnly: boolean;
13
16
  }): null | DateRangePickerProps.Value;
14
17
  export declare function useDateRangePicker({ value, relativeOptions, rangeSelectorMode }: UseDateRangePickerProps): {
@@ -1 +1 @@
1
- {"version":3,"file":"use-date-range-picker.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/use-date-range-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,iBAAS,eAAe,CAAC,KAAK,EAAE,oBAAoB,CAAC,aAAa,GAAG,IAAI;;;;SAWxE;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,EACxC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACnE,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAYnC;AAmBD,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,EAAE,uBAAuB;;;;;;;;EAsBxG;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC;IACzC,eAAe,EAAE,aAAa,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACpE,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;CAC3D"}
1
+ {"version":3,"file":"use-date-range-picker.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/use-date-range-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD;;GAEG;AACH,iBAAS,eAAe,CAAC,KAAK,EAAE,oBAAoB,CAAC,aAAa,GAAG,IAAI;;;;SAWxE;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,EACxC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;IAAE,UAAU,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACpG,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAYnC;AAmBD,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,EAAE,uBAAuB;;;;;;;;EAsBxG;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC;IACzC,eAAe,EAAE,aAAa,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACpE,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;CAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-date-range-picker.js","sourceRoot":"","sources":["../../../src/date-range-picker/use-date-range-picker.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C;;GAEG;AACH,SAAS,eAAe,CAAC,KAAgD;IACvE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IACK,IAAA,KAAyB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GA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,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAsE;QAApE,KAAK,WAAA,EAAE,eAAe,qBAAA,EAAE,iBAAiB,uBAAA;IACtE,IAAA,KAA8C,QAAQ,CAC1D,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAC1D,EAFM,kBAAkB,QAAA,EAAE,qBAAqB,QAE/C,CAAC;IAEI,IAAA,KAAoD,QAAQ,CAChE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC1C,EAFM,qBAAqB,QAAA,EAAE,wBAAwB,QAErD,CAAC;IAEI,IAAA,KAAoD,QAAQ,CAChE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC1C,EAFM,qBAAqB,QAAA,EAAE,wBAAwB,QAErD,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;QACf,kBAAkB,oBAAA;QAClB,qBAAqB,uBAAA;QACrB,qBAAqB,uBAAA;QACrB,wBAAwB,0BAAA;QACxB,qBAAqB,uBAAA;QACrB,wBAAwB,0BAAA;KACzB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useState } from 'react';\nimport { DateRangePickerProps } from './interfaces';\nimport { setTimeOffset } from './time-offset';\n/**\n * This function fills in a start and end time if they are missing.\n */\nfunction fillMissingTime(value: DateRangePickerProps.AbsoluteValue | null) {\n if (!value) {\n return value;\n }\n const [startDate, startTime] = value.startDate.split('T');\n const [endDate, endTime] = value.endDate.split('T');\n return {\n ...value,\n startDate: startTime ? value.startDate : `${startDate}T00:00:00`,\n endDate: endTime ? value.endDate : `${endDate}T23:59:59`,\n };\n}\n\nexport function formatValue(\n value: null | DateRangePickerProps.Value,\n { timeOffset, dateOnly }: { timeOffset?: number; dateOnly: boolean }\n): null | DateRangePickerProps.Value {\n if (!value || value.type === 'relative') {\n return value;\n }\n if (dateOnly) {\n return {\n type: 'absolute',\n startDate: value.startDate.split('T')[0],\n endDate: value.endDate.split('T')[0],\n };\n }\n return setTimeOffset(value, timeOffset);\n}\n\nfunction getDefaultMode(\n value: null | DateRangePickerProps.Value,\n relativeOptions: readonly DateRangePickerProps.RelativeOption[],\n rangeSelectorMode: DateRangePickerProps.RangeSelectorMode\n) {\n if (value && value.type) {\n return value.type;\n }\n if (rangeSelectorMode === 'relative-only') {\n return 'relative';\n }\n if (rangeSelectorMode === 'absolute-only') {\n return 'absolute';\n }\n return relativeOptions.length > 0 ? 'relative' : 'absolute';\n}\n\nexport function useDateRangePicker({ value, relativeOptions, rangeSelectorMode }: UseDateRangePickerProps) {\n const [rangeSelectionMode, setRangeSelectionMode] = useState<'absolute' | 'relative'>(\n getDefaultMode(value, relativeOptions, rangeSelectorMode)\n );\n\n const [selectedAbsoluteRange, setSelectedAbsoluteRange] = useState<DateRangePickerProps.AbsoluteValue | null>(\n value?.type === 'absolute' ? value : null\n );\n\n const [selectedRelativeRange, setSelectedRelativeRange] = useState<DateRangePickerProps.RelativeValue | null>(\n value?.type === 'relative' ? value : null\n );\n\n return {\n fillMissingTime,\n rangeSelectionMode,\n setRangeSelectionMode,\n selectedAbsoluteRange,\n setSelectedAbsoluteRange,\n selectedRelativeRange,\n setSelectedRelativeRange,\n };\n}\n\nexport interface UseDateRangePickerProps {\n value: null | DateRangePickerProps.Value;\n relativeOptions: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n rangeSelectorMode: DateRangePickerProps.RangeSelectorMode;\n}\n"]}
1
+ {"version":3,"file":"use-date-range-picker.js","sourceRoot":"","sources":["../../../src/date-range-picker/use-date-range-picker.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAA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I,KAAK,CAAC,IAAI,EAAE;QACvB,OAAO,KAAK,CAAC,IAAI,CAAC;KACnB;IACD,IAAI,iBAAiB,KAAK,eAAe,EAAE;QACzC,OAAO,UAAU,CAAC;KACnB;IACD,IAAI,iBAAiB,KAAK,eAAe,EAAE;QACzC,OAAO,UAAU,CAAC;KACnB;IACD,OAAO,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAsE;QAApE,KAAK,WAAA,EAAE,eAAe,qBAAA,EAAE,iBAAiB,uBAAA;IACtE,IAAA,KAA8C,QAAQ,CAC1D,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAC1D,EAFM,kBAAkB,QAAA,EAAE,qBAAqB,QAE/C,CAAC;IAEI,IAAA,KAAoD,QAAQ,CAChE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC1C,EAFM,qBAAqB,QAAA,EAAE,wBAAwB,QAErD,CAAC;IAEI,IAAA,KAAoD,QAAQ,CAChE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAC1C,EAFM,qBAAqB,QAAA,EAAE,wBAAwB,QAErD,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;QACf,kBAAkB,oBAAA;QAClB,qBAAqB,uBAAA;QACrB,qBAAqB,uBAAA;QACrB,wBAAwB,0BAAA;QACxB,qBAAqB,uBAAA;QACrB,wBAAwB,0BAAA;KACzB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useState } from 'react';\nimport { DateRangePickerProps } from './interfaces';\nimport { setTimeOffset } from './time-offset';\n\n/**\n * This function fills in a start and end time if they are missing.\n */\nfunction fillMissingTime(value: DateRangePickerProps.AbsoluteValue | null) {\n if (!value) {\n return value;\n }\n const [startDate, startTime] = value.startDate.split('T');\n const [endDate, endTime] = value.endDate.split('T');\n return {\n ...value,\n startDate: startTime ? value.startDate : `${startDate}T00:00:00`,\n endDate: endTime ? value.endDate : `${endDate}T23:59:59`,\n };\n}\n\nexport function formatValue(\n value: null | DateRangePickerProps.Value,\n { timeOffset, dateOnly }: { timeOffset: { startDate?: number; endDate?: number }; dateOnly: boolean }\n): null | DateRangePickerProps.Value {\n if (!value || value.type === 'relative') {\n return value;\n }\n if (dateOnly) {\n return {\n type: 'absolute',\n startDate: value.startDate.split('T')[0],\n endDate: value.endDate.split('T')[0],\n };\n }\n return setTimeOffset(value, timeOffset);\n}\n\nfunction getDefaultMode(\n value: null | DateRangePickerProps.Value,\n relativeOptions: readonly DateRangePickerProps.RelativeOption[],\n rangeSelectorMode: DateRangePickerProps.RangeSelectorMode\n) {\n if (value && value.type) {\n return value.type;\n }\n if (rangeSelectorMode === 'relative-only') {\n return 'relative';\n }\n if (rangeSelectorMode === 'absolute-only') {\n return 'absolute';\n }\n return relativeOptions.length > 0 ? 'relative' : 'absolute';\n}\n\nexport function useDateRangePicker({ value, relativeOptions, rangeSelectorMode }: UseDateRangePickerProps) {\n const [rangeSelectionMode, setRangeSelectionMode] = useState<'absolute' | 'relative'>(\n getDefaultMode(value, relativeOptions, rangeSelectorMode)\n );\n\n const [selectedAbsoluteRange, setSelectedAbsoluteRange] = useState<DateRangePickerProps.AbsoluteValue | null>(\n value?.type === 'absolute' ? value : null\n );\n\n const [selectedRelativeRange, setSelectedRelativeRange] = useState<DateRangePickerProps.RelativeValue | null>(\n value?.type === 'relative' ? value : null\n );\n\n return {\n fillMissingTime,\n rangeSelectionMode,\n setRangeSelectionMode,\n selectedAbsoluteRange,\n setSelectedAbsoluteRange,\n selectedRelativeRange,\n setSelectedRelativeRange,\n };\n}\n\nexport interface UseDateRangePickerProps {\n value: null | DateRangePickerProps.Value;\n relativeOptions: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n rangeSelectorMode: DateRangePickerProps.RangeSelectorMode;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
 
2
- export var PACKAGE_VERSION = '3.0.0 (11b4eac)';
2
+ export var PACKAGE_VERSION = '3.0.0 (280c63e)';
3
3
  export var THEME = 'open-source-visual-refresh';
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
5
5
 
@@ -1,2 +1,5 @@
1
- export declare function formatDateRange(startDate: string, endDate: string, timeOffset?: number): string;
1
+ export declare function formatDateRange(startDate: string, endDate: string, timeOffset: {
2
+ startDate?: number;
3
+ endDate?: number;
4
+ }): string;
2
5
  //# sourceMappingURL=format-date-range.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-date-range.d.ts","sourceRoot":"","sources":["../../../../../src/internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/F"}
1
+ {"version":3,"file":"format-date-range.d.ts","sourceRoot":"","sources":["../../../../../src/internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,MAAM,CAKR"}
@@ -4,8 +4,8 @@ import { formatTimezoneOffset } from './format-timezone-offset';
4
4
  import { isIsoDateOnly } from './is-iso-date-only';
5
5
  export function formatDateRange(startDate, endDate, timeOffset) {
6
6
  var isDateOnly = isIsoDateOnly(startDate) && isIsoDateOnly(endDate);
7
- var formattedStartOffset = isDateOnly ? '' : formatTimezoneOffset(startDate, timeOffset);
8
- var formattedEndOffset = isDateOnly ? '' : formatTimezoneOffset(endDate, timeOffset);
7
+ var formattedStartOffset = isDateOnly ? '' : formatTimezoneOffset(startDate, timeOffset.startDate);
8
+ var formattedEndOffset = isDateOnly ? '' : formatTimezoneOffset(endDate, timeOffset.endDate);
9
9
  return startDate + formattedStartOffset + ' ' + '—' + ' ' + endDate + formattedEndOffset;
10
10
  }
11
11
  //# sourceMappingURL=format-date-range.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-date-range.js","sourceRoot":"","sources":["../../../../../src/internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,OAAe,EAAE,UAAmB;IACrF,IAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IACtE,IAAM,oBAAoB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC3F,IAAM,kBAAkB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACvF,OAAO,SAAS,GAAG,oBAAoB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,kBAAkB,CAAC;AAC3F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { formatTimezoneOffset } from './format-timezone-offset';\nimport { isIsoDateOnly } from './is-iso-date-only';\n\nexport function formatDateRange(startDate: string, endDate: string, timeOffset?: number): string {\n const isDateOnly = isIsoDateOnly(startDate) && isIsoDateOnly(endDate);\n const formattedStartOffset = isDateOnly ? '' : formatTimezoneOffset(startDate, timeOffset);\n const formattedEndOffset = isDateOnly ? '' : formatTimezoneOffset(endDate, timeOffset);\n return startDate + formattedStartOffset + ' ' + '—' + ' ' + endDate + formattedEndOffset;\n}\n"]}
1
+ {"version":3,"file":"format-date-range.js","sourceRoot":"","sources":["../../../../../src/internal/utils/date-time/format-date-range.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,UAAU,eAAe,CAC7B,SAAiB,EACjB,OAAe,EACf,UAAoD;IAEpD,IAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IACtE,IAAM,oBAAoB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IACrG,IAAM,kBAAkB,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/F,OAAO,SAAS,GAAG,oBAAoB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,kBAAkB,CAAC;AAC3F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { formatTimezoneOffset } from './format-timezone-offset';\nimport { isIsoDateOnly } from './is-iso-date-only';\n\nexport function formatDateRange(\n startDate: string,\n endDate: string,\n timeOffset: { startDate?: number; endDate?: number }\n): string {\n const isDateOnly = isIsoDateOnly(startDate) && isIsoDateOnly(endDate);\n const formattedStartOffset = isDateOnly ? '' : formatTimezoneOffset(startDate, timeOffset.startDate);\n const formattedEndOffset = isDateOnly ? '' : formatTimezoneOffset(endDate, timeOffset.endDate);\n return startDate + formattedStartOffset + ' ' + '—' + ' ' + endDate + formattedEndOffset;\n}\n"]}
package/package.json CHANGED
@@ -113,6 +113,6 @@
113
113
  "./internal/base-component/index.js",
114
114
  "./internal/base-component/styles.css.js"
115
115
  ],
116
- "version": "3.0.81",
116
+ "version": "3.0.82",
117
117
  "license": "Apache-2.0"
118
118
  }