baseui 0.0.0-next-84297ea → 0.0.0-next-aadc4ef

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.
@@ -11,10 +11,11 @@ type DatepickerState = {
11
11
  isPseudoFocused: boolean;
12
12
  lastActiveElm: HTMLElement | undefined | null;
13
13
  inputValue?: string;
14
+ ariaDescribedby: string | null;
14
15
  };
15
16
  export default class Datepicker<T = Date> extends React.Component<DatepickerProps<T>, DatepickerState> {
16
17
  static defaultProps: {
17
- 'aria-describedby': string;
18
+ 'aria-describedby': any;
18
19
  value: any;
19
20
  formatString: string;
20
21
  adapter: import("./utils/types").DateIOAdapter<Date>;
@@ -22,6 +23,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
22
23
  calendar: HTMLElement | undefined | null;
23
24
  dateHelpers: DateHelpers<T>;
24
25
  constructor(props: DatepickerProps<T>);
26
+ componentDidMount(): void;
25
27
  handleChange: (a: T | undefined | null | Array<T | undefined | null>) => void;
26
28
  onCalendarSelect: (a: {
27
29
  readonly date: T | undefined | null | Array<T | undefined | null>;
@@ -38,6 +40,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
38
40
  handleKeyDown: (event: KeyboardEvent) => void;
39
41
  focusCalendar: () => void;
40
42
  normalizeDashes: (inputValue: string) => string;
43
+ generateAriaDescribedByIds: () => string;
41
44
  hasLockedBehavior: () => boolean;
42
45
  componentDidUpdate(prevProps: DatepickerProps<T>): void;
43
46
  getPlaceholder: () => string;
@@ -9,6 +9,8 @@ exports.default = exports.DEFAULT_DATE_FORMAT = void 0;
9
9
 
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
 
12
+ var _reactUid = require("react-uid");
13
+
12
14
  var _input = require("../input");
13
15
 
14
16
  var _popover = require("../popover");
@@ -483,6 +485,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
483
485
  return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
484
486
  });
485
487
 
488
+ _defineProperty(_assertThisInitialized(_this), "generateAriaDescribedByIds", function () {
489
+ var idList = _this.state.ariaDescribedby;
490
+
491
+ if (_this.props['aria-describedby']) {
492
+ idList = "".concat(_this.props['aria-describedby'], " ").concat(idList);
493
+ }
494
+
495
+ return idList;
496
+ });
497
+
486
498
  _defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
487
499
  return _this.props.rangedCalendarBehavior === _constants.RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
488
500
  });
@@ -498,12 +510,21 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
498
510
  selectedInput: null,
499
511
  isPseudoFocused: false,
500
512
  lastActiveElm: null,
501
- inputValue: _this.formatDisplayValue(props.value) || ''
513
+ inputValue: _this.formatDisplayValue(props.value) || '',
514
+ ariaDescribedby: null // we initialize this post-mount to prevent SSR hydration issue
515
+
502
516
  };
503
517
  return _this;
504
518
  }
505
519
 
506
520
  _createClass(Datepicker, [{
521
+ key: "componentDidMount",
522
+ value: function componentDidMount() {
523
+ this.setState({
524
+ ariaDescribedby: (0, _reactUid.uid)(this)
525
+ });
526
+ }
527
+ }, {
507
528
  key: "getNullDatePlaceholder",
508
529
  value: function getNullDatePlaceholder(formatString) {
509
530
  return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
@@ -574,7 +595,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
574
595
  "aria-label": inputLabel,
575
596
  error: this.props.error,
576
597
  positive: this.props.positive,
577
- "aria-describedby": this.props['aria-describedby'],
598
+ "aria-describedby": this.generateAriaDescribedByIds(),
578
599
  "aria-labelledby": this.props['aria-labelledby'],
579
600
  "aria-required": this.props.required || null,
580
601
  disabled: this.props.disabled,
@@ -659,7 +680,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
659
680
  $separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
660
681
  }), _this4.props.range && _this4.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), _this4.renderInputComponent(locale, _constants.INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, _constants.INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
661
682
  // @ts-ignore
662
- id: _this4.props['aria-describedby'],
683
+ id: _this4.state.ariaDescribedby,
663
684
  style: {
664
685
  position: 'fixed',
665
686
  width: '0px',
@@ -712,7 +733,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
712
733
  exports.default = Datepicker;
713
734
 
714
735
  _defineProperty(Datepicker, "defaultProps", {
715
- 'aria-describedby': 'datepicker--screenreader--message--input',
736
+ 'aria-describedby': null,
716
737
  // @ts-ignore
717
738
  value: null,
718
739
  formatString: DEFAULT_DATE_FORMAT,
@@ -9,6 +9,7 @@ This source code is licensed under the MIT license found in the
9
9
  LICENSE file in the root directory of this source tree.
10
10
  */
11
11
  import * as React from 'react';
12
+ import { uid } from 'react-uid';
12
13
  import { MaskedInput } from '../input';
13
14
  import { Popover, PLACEMENT, ACCESSIBILITY_TYPE } from '../popover';
14
15
  import Calendar from './calendar';
@@ -381,6 +382,16 @@ export default class Datepicker extends React.Component {
381
382
  return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
382
383
  });
383
384
 
385
+ _defineProperty(this, "generateAriaDescribedByIds", () => {
386
+ let idList = this.state.ariaDescribedby;
387
+
388
+ if (this.props['aria-describedby']) {
389
+ idList = `${this.props['aria-describedby']} ${idList}`;
390
+ }
391
+
392
+ return idList;
393
+ });
394
+
384
395
  _defineProperty(this, "hasLockedBehavior", () => {
385
396
  return this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked && this.props.range && this.props.separateRangeInputs;
386
397
  });
@@ -394,10 +405,18 @@ export default class Datepicker extends React.Component {
394
405
  selectedInput: null,
395
406
  isPseudoFocused: false,
396
407
  lastActiveElm: null,
397
- inputValue: this.formatDisplayValue(props.value) || ''
408
+ inputValue: this.formatDisplayValue(props.value) || '',
409
+ ariaDescribedby: null // we initialize this post-mount to prevent SSR hydration issue
410
+
398
411
  };
399
412
  }
400
413
 
414
+ componentDidMount() {
415
+ this.setState({
416
+ ariaDescribedby: uid(this)
417
+ });
418
+ }
419
+
401
420
  getNullDatePlaceholder(formatString) {
402
421
  return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
403
422
  }
@@ -447,7 +466,7 @@ export default class Datepicker extends React.Component {
447
466
  "aria-label": inputLabel,
448
467
  error: this.props.error,
449
468
  positive: this.props.positive,
450
- "aria-describedby": this.props['aria-describedby'],
469
+ "aria-describedby": this.generateAriaDescribedByIds(),
451
470
  "aria-labelledby": this.props['aria-labelledby'],
452
471
  "aria-required": this.props.required || null,
453
472
  disabled: this.props.disabled,
@@ -501,7 +520,7 @@ export default class Datepicker extends React.Component {
501
520
  $separateRangeInputs: this.props.range && this.props.separateRangeInputs
502
521
  }), this.props.range && this.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), this.renderInputComponent(locale, INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), this.renderInputComponent(locale, INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, this.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
503
522
  // @ts-ignore
504
- id: this.props['aria-describedby'],
523
+ id: this.state.ariaDescribedby,
505
524
  style: {
506
525
  position: 'fixed',
507
526
  width: '0px',
@@ -549,7 +568,7 @@ export default class Datepicker extends React.Component {
549
568
  }
550
569
 
551
570
  _defineProperty(Datepicker, "defaultProps", {
552
- 'aria-describedby': 'datepicker--screenreader--message--input',
571
+ 'aria-describedby': null,
553
572
  // @ts-ignore
554
573
  value: null,
555
574
  formatString: DEFAULT_DATE_FORMAT,
@@ -55,6 +55,7 @@ This source code is licensed under the MIT license found in the
55
55
  LICENSE file in the root directory of this source tree.
56
56
  */
57
57
  import * as React from 'react';
58
+ import { uid } from 'react-uid';
58
59
  import { MaskedInput } from '../input';
59
60
  import { Popover, PLACEMENT, ACCESSIBILITY_TYPE } from '../popover';
60
61
  import Calendar from './calendar';
@@ -464,6 +465,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
464
465
  return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
465
466
  });
466
467
 
468
+ _defineProperty(_assertThisInitialized(_this), "generateAriaDescribedByIds", function () {
469
+ var idList = _this.state.ariaDescribedby;
470
+
471
+ if (_this.props['aria-describedby']) {
472
+ idList = "".concat(_this.props['aria-describedby'], " ").concat(idList);
473
+ }
474
+
475
+ return idList;
476
+ });
477
+
467
478
  _defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
468
479
  return _this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
469
480
  });
@@ -479,12 +490,21 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
479
490
  selectedInput: null,
480
491
  isPseudoFocused: false,
481
492
  lastActiveElm: null,
482
- inputValue: _this.formatDisplayValue(props.value) || ''
493
+ inputValue: _this.formatDisplayValue(props.value) || '',
494
+ ariaDescribedby: null // we initialize this post-mount to prevent SSR hydration issue
495
+
483
496
  };
484
497
  return _this;
485
498
  }
486
499
 
487
500
  _createClass(Datepicker, [{
501
+ key: "componentDidMount",
502
+ value: function componentDidMount() {
503
+ this.setState({
504
+ ariaDescribedby: uid(this)
505
+ });
506
+ }
507
+ }, {
488
508
  key: "getNullDatePlaceholder",
489
509
  value: function getNullDatePlaceholder(formatString) {
490
510
  return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
@@ -555,7 +575,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
555
575
  "aria-label": inputLabel,
556
576
  error: this.props.error,
557
577
  positive: this.props.positive,
558
- "aria-describedby": this.props['aria-describedby'],
578
+ "aria-describedby": this.generateAriaDescribedByIds(),
559
579
  "aria-labelledby": this.props['aria-labelledby'],
560
580
  "aria-required": this.props.required || null,
561
581
  disabled: this.props.disabled,
@@ -640,7 +660,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
640
660
  $separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
641
661
  }), _this4.props.range && _this4.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), _this4.renderInputComponent(locale, INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
642
662
  // @ts-ignore
643
- id: _this4.props['aria-describedby'],
663
+ id: _this4.state.ariaDescribedby,
644
664
  style: {
645
665
  position: 'fixed',
646
666
  width: '0px',
@@ -691,7 +711,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
691
711
  }(React.Component);
692
712
 
693
713
  _defineProperty(Datepicker, "defaultProps", {
694
- 'aria-describedby': 'datepicker--screenreader--message--input',
714
+ 'aria-describedby': null,
695
715
  // @ts-ignore
696
716
  value: null,
697
717
  formatString: DEFAULT_DATE_FORMAT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "0.0.0-next-84297ea",
3
+ "version": "0.0.0-next-aadc4ef",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",