@happeouikit/form-elements 2.3.1 → 2.3.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.4
4
+
5
+ - [Fixed] DatePicker. Added htmlFor to the label and input ID autogeneration. Accessibility issue.
6
+
3
7
  ## 2.3.1
4
8
 
5
9
  - [Fixed] remove role from span, keep role on input only
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
 
7
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
8
 
9
- import React, { useState } from "react";
9
+ import React, { useState, useRef } from "react";
10
10
  import PropTypes from "prop-types";
11
11
  import styled, { css } from "styled-components";
12
12
  import DayPickerInput from "react-day-picker/DayPickerInput";
@@ -26,7 +26,7 @@ import Dropdown from "./Dropdown"; // CSS
26
26
 
27
27
  import "react-day-picker/lib/style.css";
28
28
  import messages from "./messages";
29
- import { useDevWarningOnce } from "./utils";
29
+ import { useDevWarningOnce, uuidv4 } from "./utils";
30
30
  import { jsx as _jsx } from "react/jsx-runtime";
31
31
  import { jsxs as _jsxs } from "react/jsx-runtime";
32
32
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -68,7 +68,14 @@ var DatePicker = function DatePicker(_ref) {
68
68
  disabledDays = _ref.disabledDays,
69
69
  value = _ref.value,
70
70
  pickerRef = _ref.pickerRef,
71
- props = _objectWithoutProperties(_ref, ["label", "locale", "width", "date", "type", "fromMonth", "disabledDays", "value", "pickerRef"]);
71
+ _ref$inputProps = _ref.inputProps,
72
+ inputProps = _ref$inputProps === void 0 ? {} : _ref$inputProps,
73
+ props = _objectWithoutProperties(_ref, ["label", "locale", "width", "date", "type", "fromMonth", "disabledDays", "value", "pickerRef", "inputProps"]);
74
+
75
+ // Stores the ID of the input field. If "id" isn't provided, it will be generated
76
+ // to improve accessibility by linking label to the input field.
77
+ var _useRef = useRef(inputProps.id || uuidv4()),
78
+ datePickerId = _useRef.current;
72
79
 
73
80
  var _useState = useState(fromMonth),
74
81
  _useState2 = _slicedToArray(_useState, 2),
@@ -90,11 +97,14 @@ var DatePicker = function DatePicker(_ref) {
90
97
  return /*#__PURE__*/_jsxs(Wrapper, {
91
98
  width: width,
92
99
  hasRange: isRangeMode,
93
- children: [label && /*#__PURE__*/_jsx("div", {
100
+ children: [label && /*#__PURE__*/_jsx("label", {
101
+ htmlFor: datePickerId,
102
+ "aria-label": label,
94
103
  style: {
95
104
  margin: "4px 0"
96
105
  },
97
106
  children: /*#__PURE__*/_jsx(BodyUI, {
107
+ as: "span",
98
108
  color: gray01,
99
109
  children: label
100
110
  })
@@ -126,7 +136,10 @@ var DatePicker = function DatePicker(_ref) {
126
136
  showOutsideDays: true,
127
137
  month: month
128
138
  },
129
- ref: pickerRef
139
+ ref: pickerRef,
140
+ inputProps: _objectSpread({
141
+ id: datePickerId
142
+ }, inputProps)
130
143
  }, props), date[type])]
131
144
  });
132
145
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happeouikit/form-elements",
3
- "version": "2.3.1",
3
+ "version": "2.3.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",