@cloudscape-design/components 3.0.882 → 3.0.884

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.
Files changed (158) hide show
  1. package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.d.ts.map +1 -1
  2. package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js +1 -1
  3. package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js.map +1 -1
  4. package/breadcrumb-group/item/item.d.ts.map +1 -1
  5. package/breadcrumb-group/item/item.js +1 -1
  6. package/breadcrumb-group/item/item.js.map +1 -1
  7. package/button/internal.d.ts.map +1 -1
  8. package/button/internal.js +1 -1
  9. package/button/internal.js.map +1 -1
  10. package/button-group/file-input-item.d.ts +5 -3
  11. package/button-group/file-input-item.d.ts.map +1 -1
  12. package/button-group/file-input-item.js +2 -2
  13. package/button-group/file-input-item.js.map +1 -1
  14. package/button-group/icon-button-item.d.ts +5 -3
  15. package/button-group/icon-button-item.d.ts.map +1 -1
  16. package/button-group/icon-button-item.js +2 -2
  17. package/button-group/icon-button-item.js.map +1 -1
  18. package/button-group/icon-toggle-button-item.d.ts +5 -3
  19. package/button-group/icon-toggle-button-item.d.ts.map +1 -1
  20. package/button-group/icon-toggle-button-item.js +2 -2
  21. package/button-group/icon-toggle-button-item.js.map +1 -1
  22. package/button-group/item-element.d.ts.map +1 -1
  23. package/button-group/item-element.js +4 -4
  24. package/button-group/item-element.js.map +1 -1
  25. package/button-group/menu-dropdown-item.d.ts +1 -0
  26. package/button-group/menu-dropdown-item.d.ts.map +1 -1
  27. package/button-group/menu-dropdown-item.js +2 -2
  28. package/button-group/menu-dropdown-item.js.map +1 -1
  29. package/calendar/grid/index.d.ts.map +1 -1
  30. package/calendar/grid/index.js +1 -1
  31. package/calendar/grid/index.js.map +1 -1
  32. package/date-range-picker/calendar/grids/grid-cell.d.ts.map +1 -1
  33. package/date-range-picker/calendar/grids/grid-cell.js +2 -2
  34. package/date-range-picker/calendar/grids/grid-cell.js.map +1 -1
  35. package/date-range-picker/calendar/grids/grid.d.ts +18 -0
  36. package/date-range-picker/calendar/grids/grid.d.ts.map +1 -0
  37. package/date-range-picker/calendar/grids/grid.js +174 -0
  38. package/date-range-picker/calendar/grids/grid.js.map +1 -0
  39. package/date-range-picker/calendar/grids/index.d.ts +3 -20
  40. package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
  41. package/date-range-picker/calendar/grids/index.js +51 -22
  42. package/date-range-picker/calendar/grids/index.js.map +1 -1
  43. package/date-range-picker/calendar/grids/interfaces.d.ts +47 -0
  44. package/date-range-picker/calendar/grids/interfaces.d.ts.map +1 -0
  45. package/date-range-picker/calendar/grids/interfaces.js +2 -0
  46. package/date-range-picker/calendar/grids/interfaces.js.map +1 -0
  47. package/date-range-picker/calendar/grids/intl.d.ts +17 -0
  48. package/date-range-picker/calendar/grids/intl.d.ts.map +1 -0
  49. package/date-range-picker/calendar/grids/intl.js +56 -0
  50. package/date-range-picker/calendar/grids/intl.js.map +1 -0
  51. package/date-range-picker/calendar/grids/styles.css.js +30 -24
  52. package/date-range-picker/calendar/grids/styles.scoped.css +62 -46
  53. package/date-range-picker/calendar/grids/styles.selectors.js +30 -24
  54. package/date-range-picker/calendar/header/header-button.d.ts +5 -4
  55. package/date-range-picker/calendar/header/header-button.d.ts.map +1 -1
  56. package/date-range-picker/calendar/header/header-button.js +6 -6
  57. package/date-range-picker/calendar/header/header-button.js.map +1 -1
  58. package/date-range-picker/calendar/header/index.d.ts +6 -4
  59. package/date-range-picker/calendar/header/index.d.ts.map +1 -1
  60. package/date-range-picker/calendar/header/index.js +18 -13
  61. package/date-range-picker/calendar/header/index.js.map +1 -1
  62. package/date-range-picker/calendar/index.d.ts +2 -1
  63. package/date-range-picker/calendar/index.d.ts.map +1 -1
  64. package/date-range-picker/calendar/index.js +49 -41
  65. package/date-range-picker/calendar/index.js.map +1 -1
  66. package/date-range-picker/calendar/range-inputs.d.ts +4 -3
  67. package/date-range-picker/calendar/range-inputs.d.ts.map +1 -1
  68. package/date-range-picker/calendar/range-inputs.js +23 -10
  69. package/date-range-picker/calendar/range-inputs.js.map +1 -1
  70. package/date-range-picker/calendar/utils.d.ts +2 -0
  71. package/date-range-picker/calendar/utils.d.ts.map +1 -1
  72. package/date-range-picker/calendar/utils.js +27 -1
  73. package/date-range-picker/calendar/utils.js.map +1 -1
  74. package/date-range-picker/dropdown.d.ts +3 -2
  75. package/date-range-picker/dropdown.d.ts.map +1 -1
  76. package/date-range-picker/dropdown.js +17 -12
  77. package/date-range-picker/dropdown.js.map +1 -1
  78. package/date-range-picker/index.d.ts.map +1 -1
  79. package/date-range-picker/index.js +17 -8
  80. package/date-range-picker/index.js.map +1 -1
  81. package/date-range-picker/interfaces.d.ts +89 -14
  82. package/date-range-picker/interfaces.d.ts.map +1 -1
  83. package/date-range-picker/interfaces.js.map +1 -1
  84. package/date-range-picker/mode-switcher.js +2 -2
  85. package/date-range-picker/mode-switcher.js.map +1 -1
  86. package/date-range-picker/relative-range/index.d.ts +2 -1
  87. package/date-range-picker/relative-range/index.d.ts.map +1 -1
  88. package/date-range-picker/relative-range/index.js +14 -8
  89. package/date-range-picker/relative-range/index.js.map +1 -1
  90. package/date-range-picker/relative-range/styles.css.js +6 -9
  91. package/date-range-picker/relative-range/styles.scoped.css +10 -19
  92. package/date-range-picker/relative-range/styles.selectors.js +6 -9
  93. package/date-range-picker/styles.css.js +23 -38
  94. package/date-range-picker/styles.scoped.css +32 -78
  95. package/date-range-picker/styles.selectors.js +23 -38
  96. package/date-range-picker/test-classes/styles.css.js +36 -2
  97. package/date-range-picker/test-classes/styles.scoped.css +36 -2
  98. package/date-range-picker/test-classes/styles.selectors.js +36 -2
  99. package/date-range-picker/utils.d.ts +9 -11
  100. package/date-range-picker/utils.d.ts.map +1 -1
  101. package/date-range-picker/utils.js +43 -32
  102. package/date-range-picker/utils.js.map +1 -1
  103. package/file-token-group/file-token.d.ts.map +1 -1
  104. package/file-token-group/file-token.js +1 -1
  105. package/file-token-group/file-token.js.map +1 -1
  106. package/i18n/messages/all.all.js +1 -1
  107. package/i18n/messages/all.all.json +1 -1
  108. package/i18n/messages/all.en.js +1 -1
  109. package/i18n/messages/all.en.json +1 -1
  110. package/i18n/messages-types.d.ts +9 -0
  111. package/i18n/messages-types.d.ts.map +1 -1
  112. package/i18n/messages-types.js.map +1 -1
  113. package/internal/components/tooltip/index.d.ts +2 -1
  114. package/internal/components/tooltip/index.d.ts.map +1 -1
  115. package/internal/components/tooltip/index.js +21 -2
  116. package/internal/components/tooltip/index.js.map +1 -1
  117. package/internal/environment.js +1 -1
  118. package/internal/environment.json +1 -1
  119. package/internal/manifest.json +1 -1
  120. package/internal/utils/date-time/calendar.d.ts +22 -6
  121. package/internal/utils/date-time/calendar.d.ts.map +1 -1
  122. package/internal/utils/date-time/calendar.js +62 -11
  123. package/internal/utils/date-time/calendar.js.map +1 -1
  124. package/multiselect/index.d.ts.map +1 -1
  125. package/multiselect/index.js +2 -3
  126. package/multiselect/index.js.map +1 -1
  127. package/package.json +1 -1
  128. package/progress-bar/index.d.ts.map +1 -1
  129. package/progress-bar/index.js +4 -3
  130. package/progress-bar/index.js.map +1 -1
  131. package/progress-bar/internal.js +2 -2
  132. package/progress-bar/internal.js.map +1 -1
  133. package/segmented-control/segment.d.ts.map +1 -1
  134. package/segmented-control/segment.js +1 -1
  135. package/segmented-control/segment.js.map +1 -1
  136. package/select/parts/item.d.ts.map +1 -1
  137. package/select/parts/item.js +4 -2
  138. package/select/parts/item.js.map +1 -1
  139. package/select/parts/multiselect-item.d.ts.map +1 -1
  140. package/select/parts/multiselect-item.js +4 -2
  141. package/select/parts/multiselect-item.js.map +1 -1
  142. package/slider/internal.d.ts.map +1 -1
  143. package/slider/internal.js +1 -1
  144. package/slider/internal.js.map +1 -1
  145. package/tabs/tab-header-bar.d.ts.map +1 -1
  146. package/tabs/tab-header-bar.js +1 -1
  147. package/tabs/tab-header-bar.js.map +1 -1
  148. package/test-utils/dom/date-range-picker/index.d.ts +26 -0
  149. package/test-utils/dom/date-range-picker/index.js +58 -24
  150. package/test-utils/dom/date-range-picker/index.js.map +1 -1
  151. package/test-utils/selectors/date-range-picker/index.d.ts +26 -0
  152. package/test-utils/selectors/date-range-picker/index.js +58 -24
  153. package/test-utils/selectors/date-range-picker/index.js.map +1 -1
  154. package/test-utils/tsconfig.tsbuildinfo +1 -1
  155. package/date-range-picker/calendar/grids/monthly-grid.d.ts +0 -39
  156. package/date-range-picker/calendar/grids/monthly-grid.d.ts.map +0 -1
  157. package/date-range-picker/calendar/grids/monthly-grid.js +0 -97
  158. package/date-range-picker/calendar/grids/monthly-grid.js.map +0 -1
@@ -4,7 +4,7 @@ import { ExpandToViewport } from '../internal/components/dropdown/interfaces';
4
4
  import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
5
5
  import { NonCancelableEventHandler } from '../internal/events';
6
6
  import { TimeInputProps } from '../time-input/interfaces';
7
- interface DateRangePickerBaseProps {
7
+ export interface DateRangePickerBaseProps {
8
8
  /**
9
9
  * The current date range value. Can be either an absolute time range
10
10
  * or a relative time range.
@@ -52,6 +52,8 @@ interface DateRangePickerBaseProps {
52
52
  * Do not use `dateOnly` flag conditionally. The component does not trigger the value update
53
53
  * when the flag changes which means the value format can become inconsistent.
54
54
  *
55
+ * This does not apply when the 'granularity' is set to 'month'
56
+ *
55
57
  * Default: `false`.
56
58
  */
57
59
  dateOnly?: boolean;
@@ -70,7 +72,7 @@ interface DateRangePickerBaseProps {
70
72
  *
71
73
  * Use to restrict the granularity of time that the user can enter.
72
74
  *
73
- * Has no effect when `dateOnly` is true.
75
+ * Has no effect when `dateOnly` is true or `granularity` is set to 'month'.
74
76
  */
75
77
  timeInputFormat?: TimeInputProps.Format;
76
78
  /**
@@ -101,6 +103,11 @@ interface DateRangePickerBaseProps {
101
103
  * Default: the user's current time offset as provided by the browser.
102
104
  */
103
105
  getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction;
106
+ /**
107
+ * Specifies the granularity at which users will be able to select a date range.
108
+ * Defaults to `day`.
109
+ */
110
+ granularity?: DateRangePickerProps.Granularity;
104
111
  }
105
112
  export interface DateRangePickerProps extends BaseComponentProps, FormFieldValidationControlProps, ExpandToViewport, DateRangePickerBaseProps {
106
113
  /**
@@ -249,117 +256,185 @@ export declare namespace DateRangePickerProps {
249
256
  /**
250
257
  * Label of the mode selection group. In the standard view, it adds 'aria-label' to the group of segments.
251
258
  * In a narrow container the label is visible and attached to the select component.
259
+ * @i18n
252
260
  */
253
261
  modeSelectionLabel?: string;
254
262
  /**
255
263
  * Segment title of the relative range selection mode
264
+ * @i18n
256
265
  */
257
266
  relativeModeTitle?: string;
258
267
  /**
259
268
  * Segment title of the absolute range selection mode
269
+ * @i18n
260
270
  */
261
271
  absoluteModeTitle?: string;
262
272
  /**
263
273
  * Heading for the relative range selection area
274
+ * @i18n
264
275
  */
265
276
  relativeRangeSelectionHeading?: string;
277
+ /**
278
+ * Description for the relative range selection area
279
+ * @i18n
280
+ */
281
+ relativeRangeSelectionMonthlyDescription?: string;
266
282
  /**
267
283
  * Visible label of the Cancel button
284
+ * @i18n
268
285
  */
269
286
  cancelButtonLabel?: string;
270
287
  /**
271
288
  * Visible label of the Clear and dismiss button
289
+ * @i18n
272
290
  */
273
291
  clearButtonLabel?: string;
274
292
  /**
275
293
  * Visible label of the Apply button
294
+ * @i18n
276
295
  */
277
296
  applyButtonLabel?: string;
278
297
  /**
279
298
  * Formatting function for relative ranges.
280
299
  * This function must convert a relative range to a human-readable string.
300
+ * @i18n
281
301
  */
282
302
  formatRelativeRange?: (value: RelativeValue) => string;
283
303
  /**
284
304
  * Formatting function for time units.
285
305
  *
286
306
  * This function must return a localized form of the unit that fits the provided time value.
307
+ * @i18n
287
308
  */
288
309
  formatUnit?: (unit: TimeUnit, value: number) => string;
289
310
  /**
290
311
  * Visible label for the option for selecting
291
312
  * a custom relative range.
313
+ * @i18n
292
314
  */
293
315
  customRelativeRangeOptionLabel?: string;
294
316
  /**
295
317
  * Visible description for the option for selecting
296
318
  * a custom relative range.
319
+ * @i18n
297
320
  */
298
321
  customRelativeRangeOptionDescription?: string;
299
322
  /**
300
323
  * Visible label for the duration selector for
301
324
  * the custom relative range.
325
+ * @i18n
302
326
  */
303
327
  customRelativeRangeDurationLabel?: string;
304
328
  /**
305
329
  * Placeholder for the duration selector for
306
330
  * the custom relative range.
331
+ * @i18n
307
332
  */
308
333
  customRelativeRangeDurationPlaceholder?: string;
309
334
  /**
310
335
  * Visible label for the unit selector for the
311
336
  * custom relative range.
337
+ * @i18n
312
338
  */
313
339
  customRelativeRangeUnitLabel?: string;
314
340
  /**
315
- * Used as part of the aria label for today's date in the calendar.
316
- */
317
- todayAriaLabel?: string;
318
- /**
319
- * An aria label for the 'next month' button.
320
- */
321
- nextMonthAriaLabel?: string;
322
- /**
323
- * An aria label for the 'previous month' button.
341
+ * Visible label for the Start Month input for the
342
+ * absolute range.
343
+ * @i18n
324
344
  */
325
- previousMonthAriaLabel?: string;
345
+ startMonthLabel?: string;
326
346
  /**
327
347
  * Visible label for the Start Date input for the
328
348
  * absolute range.
349
+ * @i18n
329
350
  */
330
351
  startDateLabel?: string;
331
352
  /**
332
353
  * Visible label for the Start Time input for the
333
354
  * absolute range.
355
+ * @i18n
334
356
  */
335
357
  startTimeLabel?: string;
358
+ /**
359
+ * Visible label for the End Month input for the
360
+ * absolute range.
361
+ * @i18n
362
+ */
363
+ endMonthLabel?: string;
336
364
  /**
337
365
  * Visible label for the End Date input for the
338
366
  * absolute range.
367
+ * @i18n
339
368
  */
340
369
  endDateLabel?: string;
341
370
  /**
342
371
  * Visible label for the End Time input for the
343
372
  * absolute range.
373
+ * @i18n
344
374
  */
345
375
  endTimeLabel?: string;
376
+ /**
377
+ * Constraint text for the date input field for the
378
+ * absolute range with no time option.
379
+ * @i18n
380
+ */
381
+ dateConstraintText?: string;
346
382
  /**
347
383
  * Constraint text for the input fields for the
348
384
  * absolute range.
385
+ * @i18n
349
386
  */
350
387
  dateTimeConstraintText?: string;
388
+ /**
389
+ * Constraint text for the month input fields for the
390
+ * absolute range.
391
+ * @i18n
392
+ */
393
+ monthConstraintText?: string;
351
394
  /**
352
395
  * Provides a text alternative for the error icon in the error alert.
396
+ * @i18n
353
397
  */
354
398
  errorIconAriaLabel?: string;
355
399
  /**
356
400
  * When the property is set, screen readers announce the selected range when the absolute range gets selected.
357
401
  */
358
402
  renderSelectedAbsoluteRangeAriaLive?: (startDate: string, endDate: string) => string;
403
+ /**
404
+ * Used as part of the `aria-label` for today's date in the calendar.
405
+ * @i18n
406
+ */
407
+ todayAriaLabel?: string;
408
+ /**
409
+ * Specifies an `aria-label` for the 'next month' button.
410
+ * @i18n
411
+ */
412
+ nextMonthAriaLabel?: string;
413
+ /**
414
+ * Specifies an `aria-label` for the 'previous month' button.
415
+ * @i18n
416
+ */
417
+ previousMonthAriaLabel?: string;
418
+ /**
419
+ * Used as part of the `aria-label` for the current month in the calendar.
420
+ * @i18n
421
+ */
422
+ currentMonthAriaLabel?: string;
423
+ /**
424
+ * Specifies an `aria-label` for the 'next year' button.
425
+ * @i18n
426
+ */
427
+ nextYearAriaLabel?: string;
428
+ /**
429
+ * Specifies an `aria-label` for the 'previous year' button.
430
+ * @i18n
431
+ */
432
+ previousYearAriaLabel?: string;
359
433
  }
360
434
  type AbsoluteFormat = 'iso' | 'long-localized';
435
+ type Granularity = 'day' | 'month';
361
436
  }
362
437
  export type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;
363
- export type RangeCalendarI18nStrings = Pick<DateRangePickerProps.I18nStrings, 'todayAriaLabel' | 'nextMonthAriaLabel' | 'previousMonthAriaLabel' | 'startDateLabel' | 'startTimeLabel' | 'endDateLabel' | 'endTimeLabel' | 'dateTimeConstraintText' | 'renderSelectedAbsoluteRangeAriaLive'>;
364
- export {};
438
+ export type QuarterIndex = 0 | 1 | 2;
439
+ export type RangeCalendarI18nStrings = Pick<DateRangePickerProps.I18nStrings, 'todayAriaLabel' | 'nextMonthAriaLabel' | 'previousMonthAriaLabel' | 'currentMonthAriaLabel' | 'nextYearAriaLabel' | 'previousYearAriaLabel' | 'startMonthLabel' | 'startDateLabel' | 'startTimeLabel' | 'endMonthLabel' | 'endDateLabel' | 'endTimeLabel' | 'dateConstraintText' | 'dateTimeConstraintText' | 'monthConstraintText' | 'renderSelectedAbsoluteRangeAriaLive'>;
365
440
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,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;AAE1D,UAAU,wBAAwB;IAChC;;;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;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,oBAAoB,CAAC,0BAA0B,CAAC;IAErE;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAE/C;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;OAQG;IACH,iBAAi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GACrB,qCAAqC,CACxC,CAAC"}
@@ -1 +1 @@
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 React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { TimeInputProps } from '../time-input/interfaces';\n\ninterface 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 * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: DateRangePickerProps.DateDisabledReasonFunction;\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 *\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 which time units to allow in the custom relative range control.\n */\n customRelativeRangeUnits?: DateRangePickerProps.TimeUnit[];\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 DateDisabledReasonFunction {\n (date: Date): string;\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"]}
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 React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { TimeInputProps } from '../time-input/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 * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: DateRangePickerProps.DateDisabledReasonFunction;\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 * This does not apply when the 'granularity' is set to 'month'\n *\n * Default: `false`.\n */\n dateOnly?: boolean;\n\n /**\n * Determines the range selector mode as follows:\n *\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 or `granularity` is set to 'month'.\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 /**\n * Specifies the granularity at which users will be able to select a date range.\n * Defaults to `day`.\n */\n granularity?: DateRangePickerProps.Granularity;\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 which time units to allow in the custom relative range control.\n */\n customRelativeRangeUnits?: DateRangePickerProps.TimeUnit[];\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 DateDisabledReasonFunction {\n (date: Date): string;\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 * @i18n\n */\n modeSelectionLabel?: string;\n\n /**\n * Segment title of the relative range selection mode\n * @i18n\n */\n relativeModeTitle?: string;\n\n /**\n * Segment title of the absolute range selection mode\n * @i18n\n */\n absoluteModeTitle?: string;\n\n /**\n * Heading for the relative range selection area\n * @i18n\n */\n relativeRangeSelectionHeading?: string;\n\n /**\n * Description for the relative range selection area\n * @i18n\n */\n relativeRangeSelectionMonthlyDescription?: string;\n\n /**\n * Visible label of the Cancel button\n * @i18n\n */\n cancelButtonLabel?: string;\n\n /**\n * Visible label of the Clear and dismiss button\n * @i18n\n */\n clearButtonLabel?: string;\n\n /**\n * Visible label of the Apply button\n * @i18n\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 * @i18n\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 * @i18n\n */\n formatUnit?: (unit: TimeUnit, value: number) => string;\n\n /**\n * Visible label for the option for selecting\n * a custom relative range.\n * @i18n\n */\n customRelativeRangeOptionLabel?: string;\n\n /**\n * Visible description for the option for selecting\n * a custom relative range.\n * @i18n\n */\n customRelativeRangeOptionDescription?: string;\n\n /**\n * Visible label for the duration selector for\n * the custom relative range.\n * @i18n\n */\n customRelativeRangeDurationLabel?: string;\n\n /**\n * Placeholder for the duration selector for\n * the custom relative range.\n * @i18n\n */\n customRelativeRangeDurationPlaceholder?: string;\n\n /**\n * Visible label for the unit selector for the\n * custom relative range.\n * @i18n\n */\n customRelativeRangeUnitLabel?: string;\n\n /**\n * Visible label for the Start Month input for the\n * absolute range.\n * @i18n\n */\n startMonthLabel?: string;\n\n /**\n * Visible label for the Start Date input for the\n * absolute range.\n * @i18n\n */\n startDateLabel?: string;\n\n /**\n * Visible label for the Start Time input for the\n * absolute range.\n * @i18n\n */\n startTimeLabel?: string;\n\n /**\n * Visible label for the End Month input for the\n * absolute range.\n * @i18n\n */\n endMonthLabel?: string;\n\n /**\n * Visible label for the End Date input for the\n * absolute range.\n * @i18n\n */\n endDateLabel?: string;\n\n /**\n * Visible label for the End Time input for the\n * absolute range.\n * @i18n\n */\n endTimeLabel?: string;\n\n /**\n * Constraint text for the date input field for the\n * absolute range with no time option.\n * @i18n\n */\n dateConstraintText?: string;\n\n /**\n * Constraint text for the input fields for the\n * absolute range.\n * @i18n\n */\n dateTimeConstraintText?: string;\n\n /**\n * Constraint text for the month input fields for the\n * absolute range.\n * @i18n\n */\n monthConstraintText?: string;\n\n /**\n * Provides a text alternative for the error icon in the error alert.\n * @i18n\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 * Used as part of the `aria-label` for today's date in the calendar.\n * @i18n\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n * @i18n\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n * @i18n\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Used as part of the `aria-label` for the current month in the calendar.\n * @i18n\n */\n currentMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next year' button.\n * @i18n\n */\n nextYearAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous year' button.\n * @i18n\n */\n previousYearAriaLabel?: string;\n }\n\n export type AbsoluteFormat = 'iso' | 'long-localized';\n\n export type Granularity = 'day' | 'month';\n}\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type QuarterIndex = 0 | 1 | 2;\n\nexport type RangeCalendarI18nStrings = Pick<\n DateRangePickerProps.I18nStrings,\n | 'todayAriaLabel'\n | 'nextMonthAriaLabel'\n | 'previousMonthAriaLabel'\n | 'currentMonthAriaLabel'\n | 'nextYearAriaLabel'\n | 'previousYearAriaLabel'\n | 'startMonthLabel'\n | 'startDateLabel'\n | 'startTimeLabel'\n | 'endMonthLabel'\n | 'endDateLabel'\n | 'endTimeLabel'\n | 'dateConstraintText'\n | 'dateTimeConstraintText'\n | 'monthConstraintText'\n | 'renderSelectedAbsoluteRangeAriaLive'\n>;\n"]}
@@ -3,10 +3,10 @@
3
3
  import React from 'react';
4
4
  import { useInternalI18n } from '../i18n/context';
5
5
  import InternalSegmentedControl from '../segmented-control/internal';
6
- import styles from './styles.css.js';
6
+ import testutilStyles from './test-classes/styles.css.js';
7
7
  export default function ModeSwitcher({ i18nStrings, mode, onChange }) {
8
8
  const i18n = useInternalI18n('date-range-picker');
9
- return (React.createElement(InternalSegmentedControl, { className: styles['mode-switch'], selectedId: mode, label: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modeSelectionLabel, options: [
9
+ return (React.createElement(InternalSegmentedControl, { className: testutilStyles['mode-switch'], selectedId: mode, label: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modeSelectionLabel, options: [
10
10
  { id: 'relative', text: i18n('i18nStrings.relativeModeTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.relativeModeTitle) },
11
11
  { id: 'absolute', text: i18n('i18nStrings.absoluteModeTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.absoluteModeTitle) },
12
12
  ], onChange: e => onChange(e.detail.selectedId) }));
@@ -1 +1 @@
1
- {"version":3,"file":"mode-switcher.js","sourceRoot":"","sources":["../../../src/date-range-picker/mode-switcher.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AAGrE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAqB;IACrF,MAAM,IAAI,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAElD,OAAO,CACL,oBAAC,wBAAwB,IACvB,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,EAChC,UAAU,EAAE,IAAI,EAChB,KAAK,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,EACtC,OAAO,EAAE;YACP,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,EAAE;YAC/F,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,EAAE;SAChG,EACD,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAqC,CAAC,GACvE,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { useInternalI18n } from '../i18n/context';\nimport InternalSegmentedControl from '../segmented-control/internal';\nimport { DateRangePickerProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface ModeSwitcherProps extends Pick<DateRangePickerProps, 'i18nStrings'> {\n mode: 'absolute' | 'relative';\n onChange: (mode: 'absolute' | 'relative') => void;\n}\n\nexport default function ModeSwitcher({ i18nStrings, mode, onChange }: ModeSwitcherProps) {\n const i18n = useInternalI18n('date-range-picker');\n\n return (\n <InternalSegmentedControl\n className={styles['mode-switch']}\n selectedId={mode}\n label={i18nStrings?.modeSelectionLabel}\n options={[\n { id: 'relative', text: i18n('i18nStrings.relativeModeTitle', i18nStrings?.relativeModeTitle) },\n { id: 'absolute', text: i18n('i18nStrings.absoluteModeTitle', i18nStrings?.absoluteModeTitle) },\n ]}\n onChange={e => onChange(e.detail.selectedId as 'absolute' | 'relative')}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"mode-switcher.js","sourceRoot":"","sources":["../../../src/date-range-picker/mode-switcher.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AAGrE,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAO1D,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAqB;IACrF,MAAM,IAAI,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAElD,OAAO,CACL,oBAAC,wBAAwB,IACvB,SAAS,EAAE,cAAc,CAAC,aAAa,CAAC,EACxC,UAAU,EAAE,IAAI,EAChB,KAAK,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,EACtC,OAAO,EAAE;YACP,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,EAAE;YAC/F,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,EAAE;SAChG,EACD,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAqC,CAAC,GACvE,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { useInternalI18n } from '../i18n/context';\nimport InternalSegmentedControl from '../segmented-control/internal';\nimport { DateRangePickerProps } from './interfaces';\n\nimport testutilStyles from './test-classes/styles.css.js';\n\ninterface ModeSwitcherProps extends Pick<DateRangePickerProps, 'i18nStrings'> {\n mode: 'absolute' | 'relative';\n onChange: (mode: 'absolute' | 'relative') => void;\n}\n\nexport default function ModeSwitcher({ i18nStrings, mode, onChange }: ModeSwitcherProps) {\n const i18n = useInternalI18n('date-range-picker');\n\n return (\n <InternalSegmentedControl\n className={testutilStyles['mode-switch']}\n selectedId={mode}\n label={i18nStrings?.modeSelectionLabel}\n options={[\n { id: 'relative', text: i18n('i18nStrings.relativeModeTitle', i18nStrings?.relativeModeTitle) },\n { id: 'absolute', text: i18n('i18nStrings.absoluteModeTitle', i18nStrings?.absoluteModeTitle) },\n ]}\n onChange={e => onChange(e.detail.selectedId as 'absolute' | 'relative')}\n />\n );\n}\n"]}
@@ -8,7 +8,8 @@ interface RelativeRangePickerProps {
8
8
  i18nStrings?: DateRangePickerProps.I18nStrings;
9
9
  isSingleGrid: boolean;
10
10
  customUnits?: DateRangePickerProps.TimeUnit[];
11
+ granularity?: DateRangePickerProps.Granularity;
11
12
  }
12
- export default function RelativeRangePicker({ dateOnly, options: clientOptions, initialSelection: initialRange, onChange: onChangeRangeSize, i18nStrings, isSingleGrid, customUnits, }: RelativeRangePickerProps): JSX.Element;
13
+ export default function RelativeRangePicker({ dateOnly, options: clientOptions, initialSelection: initialRange, onChange: onChangeRangeSize, i18nStrings, isSingleGrid, customUnits, granularity, }: RelativeRangePickerProps): JSX.Element;
13
14
  export {};
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-range-picker/relative-range/index.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAIrD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAC5D,gBAAgB,EAAE,oBAAoB,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5D,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,aAAa,KAAK,IAAI,CAAC;IAC9D,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAC/C,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC;CAC/C;AAYD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,QAAQ,EACR,OAAO,EAAE,aAAkB,EAC3B,gBAAgB,EAAE,YAAY,EAC9B,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,EAAE,wBAAwB,eAmL1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-range-picker/relative-range/index.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAKrD,UAAU,wBAAwB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAC5D,gBAAgB,EAAE,oBAAoB,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5D,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,aAAa,KAAK,IAAI,CAAC;IAC9D,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAC/C,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;CAChD;AAaD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,QAAQ,EACR,OAAO,EAAE,aAAkB,EAC3B,gBAAgB,EAAE,YAAY,EAC9B,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAmB,GACpB,EAAE,wBAAwB,eA4L1B"}
@@ -10,11 +10,13 @@ import InternalInput from '../../input/internal';
10
10
  import InternalRadioGroup from '../../radio-group/internal';
11
11
  import InternalSelect from '../../select/internal';
12
12
  import InternalSpaceBetween from '../../space-between/internal';
13
+ import testutilStyles from '../test-classes/styles.css.js';
13
14
  import styles from './styles.css.js';
14
- const dayUnits = ['day', 'week', 'month', 'year'];
15
+ const monthUnits = ['month', 'year'];
16
+ const dayUnits = ['day', 'week', ...monthUnits];
15
17
  const units = ['second', 'minute', 'hour', ...dayUnits];
16
18
  const CUSTOM_OPTION_SELECT_KEY = 'awsui-internal-custom-duration-key';
17
- export default function RelativeRangePicker({ dateOnly, options: clientOptions = [], initialSelection: initialRange, onChange: onChangeRangeSize, i18nStrings, isSingleGrid, customUnits, }) {
19
+ export default function RelativeRangePicker({ dateOnly, options: clientOptions = [], initialSelection: initialRange, onChange: onChangeRangeSize, i18nStrings, isSingleGrid, customUnits, granularity = 'day', }) {
18
20
  var _a;
19
21
  const i18n = useInternalI18n('date-range-picker');
20
22
  const formatRelativeRange = i18n('i18nStrings.formatRelativeRange', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.formatRelativeRange, format => ({ amount, unit }) => format({ amount, unit }));
@@ -42,7 +44,7 @@ export default function RelativeRangePicker({ dateOnly, options: clientOptions =
42
44
  // NaN represents an empty duration
43
45
  return NaN;
44
46
  });
45
- let finalUnits = dateOnly ? dayUnits : units;
47
+ let finalUnits = granularity === 'month' ? monthUnits : dateOnly ? dayUnits : units;
46
48
  if (customUnits) {
47
49
  finalUnits = customUnits.filter(unit => {
48
50
  if (units.includes(unit)) {
@@ -52,7 +54,7 @@ export default function RelativeRangePicker({ dateOnly, options: clientOptions =
52
54
  return false;
53
55
  });
54
56
  }
55
- let initialCustomTimeUnit = dateOnly ? 'day' : 'minute';
57
+ let initialCustomTimeUnit = granularity === 'month' ? 'month' : dateOnly ? 'day' : 'minute';
56
58
  if (!finalUnits.includes(initialCustomTimeUnit)) {
57
59
  initialCustomTimeUnit = finalUnits[0];
58
60
  }
@@ -61,8 +63,12 @@ export default function RelativeRangePicker({ dateOnly, options: clientOptions =
61
63
  const showCustomControls = clientOptions.length === 0 || selectedRadio === CUSTOM_OPTION_SELECT_KEY;
62
64
  return (React.createElement("div", null,
63
65
  React.createElement(InternalSpaceBetween, { size: "xs", direction: "vertical" },
64
- showRadioControl && (React.createElement(InternalFormField, { label: i18n('i18nStrings.relativeRangeSelectionHeading', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.relativeRangeSelectionHeading) },
65
- React.createElement(InternalRadioGroup, { className: styles['relative-range-radio-group'], onChange: ({ detail }) => {
66
+ showRadioControl && (React.createElement(InternalFormField, Object.assign({}, {
67
+ label: i18n('i18nStrings.relativeRangeSelectionHeading', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.relativeRangeSelectionHeading),
68
+ description: granularity === 'month' &&
69
+ i18n('i18nStrings.relativeRangeSelectionMonthlyDescription', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.relativeRangeSelectionMonthlyDescription),
70
+ }),
71
+ React.createElement(InternalRadioGroup, { className: testutilStyles['relative-range-radio-group'], onChange: ({ detail }) => {
66
72
  setSelectedRadio(detail.value);
67
73
  if (detail.value === CUSTOM_OPTION_SELECT_KEY) {
68
74
  setCustomDuration(NaN);
@@ -88,14 +94,14 @@ export default function RelativeRangePicker({ dateOnly, options: clientOptions =
88
94
  }) },
89
95
  React.createElement("div", { className: styles['custom-range-duration'] },
90
96
  React.createElement(InternalFormField, { label: i18n('i18nStrings.customRelativeRangeDurationLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.customRelativeRangeDurationLabel) },
91
- React.createElement(InternalInput, { type: "number", className: styles['custom-range-duration-input'], value: isNaN(customDuration) || customDuration === 0 ? '' : customDuration === null || customDuration === void 0 ? void 0 : customDuration.toString(), onChange: e => {
97
+ React.createElement(InternalInput, { type: "number", className: testutilStyles['custom-range-duration-input'], value: isNaN(customDuration) || customDuration === 0 ? '' : customDuration === null || customDuration === void 0 ? void 0 : customDuration.toString(), onChange: e => {
92
98
  const amount = Number(e.detail.value);
93
99
  setCustomDuration(amount);
94
100
  onChangeRangeSize({ amount, unit: customUnitOfTime, type: 'relative' });
95
101
  }, placeholder: i18n('i18nStrings.customRelativeRangeDurationPlaceholder', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.customRelativeRangeDurationPlaceholder), __inheritFormFieldProps: true }))),
96
102
  React.createElement("div", { className: styles['custom-range-unit'] },
97
103
  React.createElement(InternalFormField, { label: i18n('i18nStrings.customRelativeRangeUnitLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.customRelativeRangeUnitLabel) },
98
- React.createElement(InternalSelect, { className: styles['custom-range-unit-select'], selectedOption: {
104
+ React.createElement(InternalSelect, { className: testutilStyles['custom-range-unit-select'], selectedOption: {
99
105
  value: customUnitOfTime,
100
106
  label: formatUnit === null || formatUnit === void 0 ? void 0 : formatUnit(customUnitOfTime, customDuration),
101
107
  }, onChange: e => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/date-range-picker/relative-range/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAGhE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAiBrC,MAAM,QAAQ,GAAiD,CAAC,KAAK,EAAE,MAAM,EAAE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nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../../box/internal';\nimport InternalFormField from '../../form-field/internal';\nimport { useInternalI18n } from '../../i18n/context';\nimport InternalInput from '../../input/internal';\nimport { RadioGroupProps } from '../../radio-group/interfaces';\nimport InternalRadioGroup from '../../radio-group/internal';\nimport InternalSelect from '../../select/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport { DateRangePickerProps } from '../interfaces';\n\nimport styles from './styles.css.js';\n\ninterface RelativeRangePickerProps {\n dateOnly: boolean;\n options: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n initialSelection: DateRangePickerProps.RelativeValue | null;\n onChange: (range: DateRangePickerProps.RelativeValue) => void;\n i18nStrings?: DateRangePickerProps.I18nStrings;\n isSingleGrid: boolean;\n customUnits?: DateRangePickerProps.TimeUnit[];\n}\n\ninterface UnitSelectOption {\n value: DateRangePickerProps.TimeUnit;\n label: string;\n}\n\nconst dayUnits: ReadonlyArray<DateRangePickerProps.TimeUnit> = ['day', 'week', 'month', 'year'];\nconst units: ReadonlyArray<DateRangePickerProps.TimeUnit> = ['second', 'minute', 'hour', ...dayUnits];\n\nconst CUSTOM_OPTION_SELECT_KEY = 'awsui-internal-custom-duration-key';\n\nexport default function RelativeRangePicker({\n dateOnly,\n options: clientOptions = [],\n initialSelection: initialRange,\n onChange: onChangeRangeSize,\n i18nStrings,\n isSingleGrid,\n customUnits,\n}: RelativeRangePickerProps) {\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 const formatUnit = i18n(\n 'i18nStrings.formatUnit',\n i18nStrings?.formatUnit,\n format => (unit, amount) => format({ amount, unit })\n );\n\n const radioOptions: RadioGroupProps.RadioButtonDefinition[] = clientOptions.map(option => ({\n value: option.key,\n label: formatRelativeRange?.(option),\n }));\n radioOptions.push({\n value: CUSTOM_OPTION_SELECT_KEY,\n label: i18n('i18nStrings.customRelativeRangeOptionLabel', i18nStrings?.customRelativeRangeOptionLabel),\n description: i18n(\n 'i18nStrings.customRelativeRangeOptionDescription',\n i18nStrings?.customRelativeRangeOptionDescription\n ),\n });\n\n const [selectedRadio, setSelectedRadio] = useState(() => {\n if (initialRange && !initialRange.key) {\n return CUSTOM_OPTION_SELECT_KEY;\n }\n return initialRange?.key ?? null;\n });\n\n const [customDuration, setCustomDuration] = useState(() => {\n if (initialRange) {\n return initialRange.amount;\n }\n // NaN represents an empty duration\n return NaN;\n });\n\n let finalUnits = dateOnly ? dayUnits : units;\n if (customUnits) {\n finalUnits = customUnits.filter(unit => {\n if (units.includes(unit)) {\n return true;\n }\n warnOnce(\n 'DateRangePicker',\n `Invalid unit found in customRelativeRangeUnits: ${unit}. This entry will be ignored.`\n );\n return false;\n });\n }\n\n let initialCustomTimeUnit: DateRangePickerProps.TimeUnit = dateOnly ? 'day' : 'minute';\n if (!finalUnits.includes(initialCustomTimeUnit)) {\n initialCustomTimeUnit = finalUnits[0];\n }\n const [customUnitOfTime, setCustomUnitOfTime] = useState<DateRangePickerProps.TimeUnit>(\n initialRange?.unit ?? initialCustomTimeUnit\n );\n\n const showRadioControl = clientOptions.length > 0;\n const showCustomControls = clientOptions.length === 0 || selectedRadio === CUSTOM_OPTION_SELECT_KEY;\n\n return (\n <div>\n <InternalSpaceBetween size=\"xs\" direction=\"vertical\">\n {showRadioControl && (\n <InternalFormField\n label={i18n('i18nStrings.relativeRangeSelectionHeading', i18nStrings?.relativeRangeSelectionHeading)}\n >\n <InternalRadioGroup\n className={styles['relative-range-radio-group']}\n onChange={({ detail }) => {\n setSelectedRadio(detail.value);\n\n if (detail.value === CUSTOM_OPTION_SELECT_KEY) {\n setCustomDuration(NaN);\n setCustomUnitOfTime(initialCustomTimeUnit);\n onChangeRangeSize({\n amount: NaN,\n unit: initialCustomTimeUnit,\n type: 'relative',\n });\n } else {\n const option = clientOptions.filter(o => o.key === detail.value)[0];\n onChangeRangeSize(option);\n }\n }}\n value={selectedRadio}\n items={radioOptions}\n />\n </InternalFormField>\n )}\n\n {showCustomControls && (\n <InternalSpaceBetween direction=\"vertical\" size=\"xs\">\n {!showRadioControl && (\n <InternalBox fontSize=\"body-m\" color=\"text-body-secondary\">\n {i18n(\n 'i18nStrings.customRelativeRangeOptionDescription',\n i18nStrings?.customRelativeRangeOptionDescription\n )}\n </InternalBox>\n )}\n\n <div\n className={clsx(styles['custom-range'], {\n [styles['custom-range--no-padding']]: !showRadioControl,\n })}\n >\n <div\n className={clsx(styles['custom-range-form-controls'], {\n [styles.vertical]: isSingleGrid,\n })}\n >\n <div className={styles['custom-range-duration']}>\n <InternalFormField\n label={i18n(\n 'i18nStrings.customRelativeRangeDurationLabel',\n i18nStrings?.customRelativeRangeDurationLabel\n )}\n >\n <InternalInput\n type=\"number\"\n className={styles['custom-range-duration-input']}\n value={isNaN(customDuration) || customDuration === 0 ? '' : customDuration?.toString()}\n onChange={e => {\n const amount = Number(e.detail.value);\n\n setCustomDuration(amount);\n onChangeRangeSize({ amount, unit: customUnitOfTime, type: 'relative' });\n }}\n placeholder={i18n(\n 'i18nStrings.customRelativeRangeDurationPlaceholder',\n i18nStrings?.customRelativeRangeDurationPlaceholder\n )}\n __inheritFormFieldProps={true}\n />\n </InternalFormField>\n </div>\n\n <div className={styles['custom-range-unit']}>\n <InternalFormField\n label={i18n('i18nStrings.customRelativeRangeUnitLabel', i18nStrings?.customRelativeRangeUnitLabel)}\n >\n <InternalSelect\n className={styles['custom-range-unit-select']}\n selectedOption={\n {\n value: customUnitOfTime,\n label: formatUnit?.(customUnitOfTime, customDuration),\n } as UnitSelectOption\n }\n onChange={e => {\n const { value: unit } = e.detail.selectedOption as UnitSelectOption;\n\n setCustomUnitOfTime(unit);\n onChangeRangeSize({ amount: customDuration, unit, type: 'relative' });\n }}\n options={finalUnits.map(unit => ({\n value: unit,\n label: formatUnit?.(unit, customDuration),\n }))}\n renderHighlightedAriaLive={option => option.label || option.value || ''}\n />\n </InternalFormField>\n </div>\n </div>\n </div>\n </InternalSpaceBetween>\n )}\n </InternalSpaceBetween>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/date-range-picker/relative-range/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAGhE,OAAO,cAAc,MAAM,+BAA+B,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAkBrC,MAAM,UAAU,GAAiD,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACnF,MAAM,QAAQ,GAAiD,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC;AAC9F,MAAM,KAAK,GAAiD,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC;AAEtG,MAAM,wBAAwB,GAAG,oCAAoC,CAAC;AAEtE,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,QAAQ,EACR,OAAO,EAAE,aAAa,GAAG,EAAE,EAC3B,gBAAgB,EAAE,YAAY,EAC9B,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,E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,WAAW,CAAE,sCAAsC,CACpD,EACD,uBAAuB,EAAE,IAAI,GAC7B,CACgB,CAChB;wBAEN,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC;4BACzC,oBAAC,iBAAiB,IAChB,KAAK,EAAE,IAAI,CAAC,0CAA0C,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,4BAA4B,CAAC;gCAElG,oBAAC,cAAc,IACb,SAAS,EAAE,cAAc,CAAC,0BAA0B,CAAC,EACrD,cAAc,EACZ;wCACE,KAAK,EAAE,gBAAgB;wCACvB,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,gBAAgB,EAAE,cAAc,CAAC;qCAClC,EAEvB,QAAQ,EAAE,CAAC,CAAC,EAAE;wCACZ,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,cAAkC,CAAC;wCAEpE,mBAAmB,CAAC,IAAI,CAAC,CAAC;wCAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;oCACxE,CAAC,EACD,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wCAC/B,KAAK,EAAE,IAAI;wCACX,KAAK,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,IAAI,EAAE,cAAc,CAAC;qCAC1C,CAAC,CAAC,EACH,yBAAyB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,GACvE,CACgB,CAChB,CACF,CACF,CACe,CACxB,CACoB,CACnB,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../../box/internal';\nimport InternalFormField from '../../form-field/internal';\nimport { useInternalI18n } from '../../i18n/context';\nimport InternalInput from '../../input/internal';\nimport { RadioGroupProps } from '../../radio-group/interfaces';\nimport InternalRadioGroup from '../../radio-group/internal';\nimport InternalSelect from '../../select/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport { DateRangePickerProps } from '../interfaces';\n\nimport testutilStyles from '../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface RelativeRangePickerProps {\n dateOnly: boolean;\n options: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n initialSelection: DateRangePickerProps.RelativeValue | null;\n onChange: (range: DateRangePickerProps.RelativeValue) => void;\n i18nStrings?: DateRangePickerProps.I18nStrings;\n isSingleGrid: boolean;\n customUnits?: DateRangePickerProps.TimeUnit[];\n granularity?: DateRangePickerProps.Granularity;\n}\n\ninterface UnitSelectOption {\n value: DateRangePickerProps.TimeUnit;\n label: string;\n}\n\nconst monthUnits: ReadonlyArray<DateRangePickerProps.TimeUnit> = ['month', 'year'];\nconst dayUnits: ReadonlyArray<DateRangePickerProps.TimeUnit> = ['day', 'week', ...monthUnits];\nconst units: ReadonlyArray<DateRangePickerProps.TimeUnit> = ['second', 'minute', 'hour', ...dayUnits];\n\nconst CUSTOM_OPTION_SELECT_KEY = 'awsui-internal-custom-duration-key';\n\nexport default function RelativeRangePicker({\n dateOnly,\n options: clientOptions = [],\n initialSelection: initialRange,\n onChange: onChangeRangeSize,\n i18nStrings,\n isSingleGrid,\n customUnits,\n granularity = 'day',\n}: RelativeRangePickerProps) {\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 const formatUnit = i18n(\n 'i18nStrings.formatUnit',\n i18nStrings?.formatUnit,\n format => (unit, amount) => format({ amount, unit })\n );\n\n const radioOptions: RadioGroupProps.RadioButtonDefinition[] = clientOptions.map(option => ({\n value: option.key,\n label: formatRelativeRange?.(option),\n }));\n radioOptions.push({\n value: CUSTOM_OPTION_SELECT_KEY,\n label: i18n('i18nStrings.customRelativeRangeOptionLabel', i18nStrings?.customRelativeRangeOptionLabel),\n description: i18n(\n 'i18nStrings.customRelativeRangeOptionDescription',\n i18nStrings?.customRelativeRangeOptionDescription\n ),\n });\n\n const [selectedRadio, setSelectedRadio] = useState(() => {\n if (initialRange && !initialRange.key) {\n return CUSTOM_OPTION_SELECT_KEY;\n }\n return initialRange?.key ?? null;\n });\n\n const [customDuration, setCustomDuration] = useState(() => {\n if (initialRange) {\n return initialRange.amount;\n }\n // NaN represents an empty duration\n return NaN;\n });\n\n let finalUnits = granularity === 'month' ? monthUnits : dateOnly ? dayUnits : units;\n if (customUnits) {\n finalUnits = customUnits.filter(unit => {\n if (units.includes(unit)) {\n return true;\n }\n warnOnce(\n 'DateRangePicker',\n `Invalid unit found in customRelativeRangeUnits: ${unit}. This entry will be ignored.`\n );\n return false;\n });\n }\n\n let initialCustomTimeUnit: DateRangePickerProps.TimeUnit =\n granularity === 'month' ? 'month' : dateOnly ? 'day' : 'minute';\n if (!finalUnits.includes(initialCustomTimeUnit)) {\n initialCustomTimeUnit = finalUnits[0];\n }\n const [customUnitOfTime, setCustomUnitOfTime] = useState<DateRangePickerProps.TimeUnit>(\n initialRange?.unit ?? initialCustomTimeUnit\n );\n\n const showRadioControl = clientOptions.length > 0;\n const showCustomControls = clientOptions.length === 0 || selectedRadio === CUSTOM_OPTION_SELECT_KEY;\n\n return (\n <div>\n <InternalSpaceBetween size=\"xs\" direction=\"vertical\">\n {showRadioControl && (\n <InternalFormField\n {...{\n label: i18n('i18nStrings.relativeRangeSelectionHeading', i18nStrings?.relativeRangeSelectionHeading),\n description:\n granularity === 'month' &&\n i18n(\n 'i18nStrings.relativeRangeSelectionMonthlyDescription',\n i18nStrings?.relativeRangeSelectionMonthlyDescription\n ),\n }}\n >\n <InternalRadioGroup\n className={testutilStyles['relative-range-radio-group']}\n onChange={({ detail }) => {\n setSelectedRadio(detail.value);\n\n if (detail.value === CUSTOM_OPTION_SELECT_KEY) {\n setCustomDuration(NaN);\n setCustomUnitOfTime(initialCustomTimeUnit);\n onChangeRangeSize({\n amount: NaN,\n unit: initialCustomTimeUnit,\n type: 'relative',\n });\n } else {\n const option = clientOptions.filter(o => o.key === detail.value)[0];\n onChangeRangeSize(option);\n }\n }}\n value={selectedRadio}\n items={radioOptions}\n />\n </InternalFormField>\n )}\n\n {showCustomControls && (\n <InternalSpaceBetween direction=\"vertical\" size=\"xs\">\n {!showRadioControl && (\n <InternalBox fontSize=\"body-m\" color=\"text-body-secondary\">\n {i18n(\n 'i18nStrings.customRelativeRangeOptionDescription',\n i18nStrings?.customRelativeRangeOptionDescription\n )}\n </InternalBox>\n )}\n\n <div\n className={clsx(styles['custom-range'], {\n [styles['custom-range--no-padding']]: !showRadioControl,\n })}\n >\n <div\n className={clsx(styles['custom-range-form-controls'], {\n [styles.vertical]: isSingleGrid,\n })}\n >\n <div className={styles['custom-range-duration']}>\n <InternalFormField\n label={i18n(\n 'i18nStrings.customRelativeRangeDurationLabel',\n i18nStrings?.customRelativeRangeDurationLabel\n )}\n >\n <InternalInput\n type=\"number\"\n className={testutilStyles['custom-range-duration-input']}\n value={isNaN(customDuration) || customDuration === 0 ? '' : customDuration?.toString()}\n onChange={e => {\n const amount = Number(e.detail.value);\n\n setCustomDuration(amount);\n onChangeRangeSize({ amount, unit: customUnitOfTime, type: 'relative' });\n }}\n placeholder={i18n(\n 'i18nStrings.customRelativeRangeDurationPlaceholder',\n i18nStrings?.customRelativeRangeDurationPlaceholder\n )}\n __inheritFormFieldProps={true}\n />\n </InternalFormField>\n </div>\n\n <div className={styles['custom-range-unit']}>\n <InternalFormField\n label={i18n('i18nStrings.customRelativeRangeUnitLabel', i18nStrings?.customRelativeRangeUnitLabel)}\n >\n <InternalSelect\n className={testutilStyles['custom-range-unit-select']}\n selectedOption={\n {\n value: customUnitOfTime,\n label: formatUnit?.(customUnitOfTime, customDuration),\n } as UnitSelectOption\n }\n onChange={e => {\n const { value: unit } = e.detail.selectedOption as UnitSelectOption;\n\n setCustomUnitOfTime(unit);\n onChangeRangeSize({ amount: customDuration, unit, type: 'relative' });\n }}\n options={finalUnits.map(unit => ({\n value: unit,\n label: formatUnit?.(unit, customDuration),\n }))}\n renderHighlightedAriaLive={option => option.label || option.value || ''}\n />\n </InternalFormField>\n </div>\n </div>\n </div>\n </InternalSpaceBetween>\n )}\n </InternalSpaceBetween>\n </div>\n );\n}\n"]}
@@ -1,14 +1,11 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "custom-range": "awsui_custom-range_16zmw_k2gxg_145",
5
- "custom-range--no-padding": "awsui_custom-range--no-padding_16zmw_k2gxg_151",
6
- "custom-range-form-controls": "awsui_custom-range-form-controls_16zmw_k2gxg_155",
7
- "custom-range-duration": "awsui_custom-range-duration_16zmw_k2gxg_159",
8
- "custom-range-unit": "awsui_custom-range-unit_16zmw_k2gxg_160",
9
- "vertical": "awsui_vertical_16zmw_k2gxg_166",
10
- "custom-range-duration-input": "awsui_custom-range-duration-input_16zmw_k2gxg_177",
11
- "custom-range-unit-select": "awsui_custom-range-unit-select_16zmw_k2gxg_178",
12
- "relative-range-radio-group": "awsui_relative-range-radio-group_16zmw_k2gxg_182"
4
+ "custom-range": "awsui_custom-range_16zmw_12l7m_145",
5
+ "custom-range--no-padding": "awsui_custom-range--no-padding_16zmw_12l7m_151",
6
+ "custom-range-form-controls": "awsui_custom-range-form-controls_16zmw_12l7m_155",
7
+ "custom-range-duration": "awsui_custom-range-duration_16zmw_12l7m_159",
8
+ "custom-range-unit": "awsui_custom-range-unit_16zmw_12l7m_160",
9
+ "vertical": "awsui_vertical_16zmw_12l7m_166"
13
10
  };
14
11
 
@@ -142,43 +142,34 @@
142
142
  */
143
143
  /* Style used for links in slots/components that are text heavy, to help links stand out among
144
144
  surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
145
- .awsui_custom-range_16zmw_k2gxg_145:not(#\9) {
145
+ .awsui_custom-range_16zmw_12l7m_145:not(#\9) {
146
146
  padding-inline-start: calc(14px + var(--space-xs-zb16t3, 8px));
147
147
  display: flex;
148
148
  inline-size: 80%;
149
149
  }
150
150
 
151
- .awsui_custom-range--no-padding_16zmw_k2gxg_151:not(#\9) {
151
+ .awsui_custom-range--no-padding_16zmw_12l7m_151:not(#\9) {
152
152
  padding-inline-start: 0;
153
153
  }
154
154
 
155
- .awsui_custom-range-form-controls_16zmw_k2gxg_155:not(#\9) {
155
+ .awsui_custom-range-form-controls_16zmw_12l7m_155:not(#\9) {
156
156
  display: flex;
157
157
  inline-size: 100%;
158
158
  }
159
- .awsui_custom-range-form-controls_16zmw_k2gxg_155 > .awsui_custom-range-duration_16zmw_k2gxg_159:not(#\9),
160
- .awsui_custom-range-form-controls_16zmw_k2gxg_155 > .awsui_custom-range-unit_16zmw_k2gxg_160:not(#\9) {
159
+ .awsui_custom-range-form-controls_16zmw_12l7m_155 > .awsui_custom-range-duration_16zmw_12l7m_159:not(#\9),
160
+ .awsui_custom-range-form-controls_16zmw_12l7m_155 > .awsui_custom-range-unit_16zmw_12l7m_160:not(#\9) {
161
161
  inline-size: 50%;
162
162
  }
163
- .awsui_custom-range-form-controls_16zmw_k2gxg_155 > .awsui_custom-range-duration_16zmw_k2gxg_159:not(#\9) {
163
+ .awsui_custom-range-form-controls_16zmw_12l7m_155 > .awsui_custom-range-duration_16zmw_12l7m_159:not(#\9) {
164
164
  margin-inline-end: var(--space-xs-zb16t3, 8px);
165
165
  }
166
- .awsui_custom-range-form-controls_16zmw_k2gxg_155.awsui_vertical_16zmw_k2gxg_166:not(#\9) {
166
+ .awsui_custom-range-form-controls_16zmw_12l7m_155.awsui_vertical_16zmw_12l7m_166:not(#\9) {
167
167
  flex-direction: column;
168
168
  }
169
- .awsui_custom-range-form-controls_16zmw_k2gxg_155.awsui_vertical_16zmw_k2gxg_166 > .awsui_custom-range-duration_16zmw_k2gxg_159:not(#\9),
170
- .awsui_custom-range-form-controls_16zmw_k2gxg_155.awsui_vertical_16zmw_k2gxg_166 > .awsui_custom-range-unit_16zmw_k2gxg_160:not(#\9) {
169
+ .awsui_custom-range-form-controls_16zmw_12l7m_155.awsui_vertical_16zmw_12l7m_166 > .awsui_custom-range-duration_16zmw_12l7m_159:not(#\9),
170
+ .awsui_custom-range-form-controls_16zmw_12l7m_155.awsui_vertical_16zmw_12l7m_166 > .awsui_custom-range-unit_16zmw_12l7m_160:not(#\9) {
171
171
  inline-size: 100%;
172
172
  }
173
- .awsui_custom-range-form-controls_16zmw_k2gxg_155.awsui_vertical_16zmw_k2gxg_166 > .awsui_custom-range-unit_16zmw_k2gxg_160:not(#\9) {
173
+ .awsui_custom-range-form-controls_16zmw_12l7m_155.awsui_vertical_16zmw_12l7m_166 > .awsui_custom-range-unit_16zmw_12l7m_160:not(#\9) {
174
174
  margin-block-start: var(--space-s-34lx8l, 12px);
175
- }
176
-
177
- .awsui_custom-range-duration-input_16zmw_k2gxg_177:not(#\9),
178
- .awsui_custom-range-unit-select_16zmw_k2gxg_178:not(#\9) {
179
- /* used in test-utils */
180
- }
181
-
182
- .awsui_relative-range-radio-group_16zmw_k2gxg_182:not(#\9) {
183
- /* used in test-utils */
184
175
  }