@digitransit-component/digitransit-component-datetimepicker 7.0.1 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -142,6 +142,10 @@ var css_248z = ".styles_sr-only__D6MJ6:not(:focus, :active) {\n clip: rect(0 0
142
142
  var styles = {"sr-only":"styles_sr-only__D6MJ6","dt-datetimepicker":"styles_dt-datetimepicker__DSYbh","hidden":"styles_hidden__TjnWH","datetimepicker-open-container":"styles_datetimepicker-open-container__zWBiT","top-row-container":"styles_top-row-container__rGdmj","closed":"styles_closed__QYbCF","time-icon":"styles_time-icon__ES47Y","dropdown-icon":"styles_dropdown-icon__O0GrI","close-icon":"styles_close-icon__B5-I5","label-open":"styles_label-open__dVDlF","textbutton":"styles_textbutton__sVckw","active":"styles_active__9LaDz","combobox-left":"styles_combobox-left__nwwOo","combobox-right":"styles_combobox-right__qlPKD","departure-or-arrival-container":"styles_departure-or-arrival-container__Rj3b9","radio-textbutton-label":"styles_radio-textbutton-label__LeV2o","first-radio":"styles_first-radio__F8N7J","radio-textbutton":"styles_radio-textbutton__Ad81W","departure-now-button":"styles_departure-now-button__8ZlDU","open-button":"styles_open-button__yl4be","close-button":"styles_close-button__mdfIU","right-edge":"styles_right-edge__XbqgK","combobox-container":"styles_combobox-container__sR9aU","combobox-icon":"styles_combobox-icon__wsdX4","date-input-icon":"styles_date-input-icon__SFXGx","time-input-icon":"styles_time-input-icon__J1qei","datetimepicker-select-container":"styles_datetimepicker-select-container__Y8wgE","picker-container":"styles_picker-container__wz2Zj","combobox-mobile-container":"styles_combobox-mobile-container__ZzG8g","mobile-modal-overlay":"styles_mobile-modal-overlay__wq8cS","mobile-modal-content":"styles_mobile-modal-content__Gla3M","top-row":"styles_top-row__hzke9","modal-title":"styles_modal-title__CztKf","tab-row":"styles_tab-row__6WYwM","radio-tab-label":"styles_radio-tab-label__-7Fx-","input-row":"styles_input-row__r-26j","input-container":"styles_input-container__US3eW","time-input-mobile":"styles_time-input-mobile__QGutf","mobile-input-display":"styles_mobile-input-display__Xnjg1","mobile-input-hidden":"styles_mobile-input-hidden__tkKxe","container":"styles_container__YXGq1","suggestion":"styles_suggestion__3Hx-R","suggestionHighlighted":"styles_suggestionHighlighted__lexDG","suggestionsContainerOpen":"styles_suggestionsContainerOpen__pzu14","input":"styles_input__Yk2Tv","buttons-row":"styles_buttons-row__zrM35","ready-button":"styles_ready-button__e23mO"};
143
143
  styleInject(css_248z);
144
144
 
145
+ const DEFAULT_TRANSLATION_SETTINGS = {
146
+ lng: 'fi'
147
+ };
148
+
145
149
  /**
146
150
  * Component to display a date or time input on desktop.
147
151
  *
@@ -175,10 +179,10 @@ function DesktopDatetimepicker({
175
179
  id,
176
180
  label,
177
181
  icon,
178
- disableTyping,
179
- timeZone,
180
- datePicker,
181
- translationSettings
182
+ disableTyping = false,
183
+ timeZone = 'Europe/Helsinki',
184
+ datePicker = false,
185
+ translationSettings = DEFAULT_TRANSLATION_SETTINGS
182
186
  }) {
183
187
  Settings.defaultZone = timeZone;
184
188
  const [t] = useTranslation();
@@ -410,14 +414,6 @@ process.env.NODE_ENV !== "production" ? DesktopDatetimepicker.propTypes = {
410
414
  lng: PropTypes.string.isRequired
411
415
  })
412
416
  } : void 0;
413
- DesktopDatetimepicker.defaultProps = {
414
- disableTyping: false,
415
- timeZone: 'Europe/Helsinki',
416
- datePicker: false,
417
- translationSettings: {
418
- lng: 'fi'
419
- }
420
- };
421
417
 
422
418
  /**
423
419
  * Detect if user is on a mobile device by parsing userAgent. This is not 100% reliable but close enough.
@@ -530,7 +526,7 @@ function MobileDatepicker({
530
526
  id,
531
527
  label,
532
528
  icon,
533
- timeZone
529
+ timeZone = 'Europe/Helsinki'
534
530
  }) {
535
531
  Settings.defaultZone = timeZone;
536
532
  const dateChoices = Array(itemCount).fill().map((_, i) => DateTime.fromMillis(startTime).plus({
@@ -576,10 +572,6 @@ process.env.NODE_ENV !== "production" ? MobileDatepicker.propTypes = {
576
572
  icon: PropTypes.node,
577
573
  timeZone: PropTypes.string
578
574
  } : void 0;
579
- MobileDatepicker.defaultProps = {
580
- icon: null,
581
- timeZone: 'Europe/Helsinki'
582
- };
583
575
 
584
576
  /**
585
577
  * Component to display a time input on mobile
@@ -591,7 +583,7 @@ function MobileTimepicker({
591
583
  id,
592
584
  label,
593
585
  icon,
594
- timeZone
586
+ timeZone = 'Europe/Helsinki'
595
587
  }) {
596
588
  const [inputValue, changeInputValue] = useState(getDisplay(value));
597
589
  const [isValidInput, setValidInput] = useState(true);
@@ -645,10 +637,6 @@ process.env.NODE_ENV !== "production" ? MobileTimepicker.propTypes = {
645
637
  icon: PropTypes.node,
646
638
  timeZone: PropTypes.string
647
639
  } : void 0;
648
- MobileTimepicker.defaultProps = {
649
- icon: null,
650
- timeZone: 'Europe/Helsinki'
651
- };
652
640
 
653
641
  Settings.defaultLocale = 'en';
654
642
 
@@ -672,8 +660,8 @@ function MobilePickerModal({
672
660
  departureOrArrival,
673
661
  onNowClick,
674
662
  lang,
675
- color,
676
- timeZone,
663
+ color = '#007ac9',
664
+ timeZone = 'Europe/Helsinki',
677
665
  onSubmit,
678
666
  onCancel,
679
667
  timestamp,
@@ -812,10 +800,6 @@ process.env.NODE_ENV !== "production" ? MobilePickerModal.propTypes = {
812
800
  medium: PropTypes.number.isRequired
813
801
  }).isRequired
814
802
  } : void 0;
815
- MobilePickerModal.defaultProps = {
816
- color: '#007ac9',
817
- timeZone: 'Europe/Helsinki'
818
- };
819
803
 
820
804
  Settings.defaultLocale = 'en';
821
805
 
@@ -854,7 +838,7 @@ Settings.defaultLocale = 'en';
854
838
  * />
855
839
  */
856
840
  function Datetimepicker({
857
- timestamp,
841
+ timestamp = null,
858
842
  onTimeChange,
859
843
  onDateChange,
860
844
  departureOrArrival,
@@ -864,8 +848,8 @@ function Datetimepicker({
864
848
  embedWhenClosed,
865
849
  embedWhenOpen,
866
850
  lang,
867
- color,
868
- timeZone,
851
+ color = '#007ac9',
852
+ timeZone = 'Europe/Helsinki',
869
853
  onModalSubmit,
870
854
  fontWeights,
871
855
  serviceTimeRange,
@@ -1247,16 +1231,6 @@ process.env.NODE_ENV !== "production" ? Datetimepicker.propTypes = {
1247
1231
  onClose: PropTypes.func,
1248
1232
  openPicker: PropTypes.bool
1249
1233
  } : void 0;
1250
- Datetimepicker.defaultProps = {
1251
- timestamp: null,
1252
- embedWhenClosed: null,
1253
- embedWhenOpen: null,
1254
- color: '#007ac9',
1255
- timeZone: 'Europe/Helsinki',
1256
- onOpen: null,
1257
- onClose: null,
1258
- openPicker: undefined
1259
- };
1260
1234
 
1261
1235
  /* eslint sort-keys: "error" */
1262
1236
  const translations = {
@@ -1376,6 +1350,10 @@ const i18n = createInstance({
1376
1350
  });
1377
1351
  i18n.init();
1378
1352
 
1353
+ const DEFAULT_FONT_WEIGHTS = {
1354
+ medium: 500
1355
+ };
1356
+
1379
1357
  /**
1380
1358
  * This component renders an input to choose a date and time. Renders separate input fields for date and time selection. Values for timestamp and arriveBy correspond to Digitransit query params time and arriveBy. This component will display a native date input on mobile and a custom one for desktop. Mobile detection is done by parsing user agent.
1381
1359
  *
@@ -1414,7 +1392,7 @@ i18n.init();
1414
1392
  * />
1415
1393
  */
1416
1394
  function DatetimepickerStateContainer({
1417
- realtime,
1395
+ realtime = false,
1418
1396
  initialArriveBy,
1419
1397
  initialTimestamp,
1420
1398
  onDepartureClick,
@@ -1424,11 +1402,11 @@ function DatetimepickerStateContainer({
1424
1402
  onNowClick,
1425
1403
  embedWhenClosed,
1426
1404
  embedWhenOpen,
1427
- lang,
1428
- color,
1429
- timeZone,
1430
- fontWeights,
1431
- serviceTimeRange,
1405
+ lang = 'en',
1406
+ color = '#007ac9',
1407
+ timeZone = 'Europe/Helsinki',
1408
+ fontWeights = DEFAULT_FONT_WEIGHTS,
1409
+ serviceTimeRange = 30,
1432
1410
  onOpen,
1433
1411
  onClose,
1434
1412
  openPicker
@@ -1564,23 +1542,6 @@ process.env.NODE_ENV !== "production" ? DatetimepickerStateContainer.propTypes =
1564
1542
  onClose: PropTypes.func,
1565
1543
  openPicker: PropTypes.bool
1566
1544
  } : void 0;
1567
- DatetimepickerStateContainer.defaultProps = {
1568
- realtime: false,
1569
- initialArriveBy: undefined,
1570
- initialTimestamp: undefined,
1571
- embedWhenClosed: null,
1572
- embedWhenOpen: null,
1573
- lang: 'en',
1574
- color: '#007ac9',
1575
- timeZone: 'Europe/Helsinki',
1576
- fontWeights: {
1577
- medium: 500
1578
- },
1579
- onOpen: null,
1580
- onClose: null,
1581
- openPicker: undefined,
1582
- serviceTimeRange: 30
1583
- };
1584
1545
 
1585
1546
  export { DatetimepickerStateContainer as default };
1586
1547
  //# sourceMappingURL=index.js.map