@happeouikit/form-elements 2.3.15 → 2.3.17
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 +12 -0
- package/dist/DatePicker.js +3 -3
- package/dist/Textarea.js +40 -4
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.17
|
|
4
|
+
|
|
5
|
+
- [Added] Add `autoHeight` and `maxHeight` properties to textarea.
|
|
6
|
+
|
|
7
|
+
## 2.3.16
|
|
8
|
+
|
|
9
|
+
- [Added] Only disable a day or month if the disabledDays prop is present. Otherwise, treat as enabled
|
|
10
|
+
|
|
11
|
+
## 2.3.15
|
|
12
|
+
|
|
13
|
+
- Version update
|
|
14
|
+
|
|
3
15
|
## 2.3.14
|
|
4
16
|
|
|
5
17
|
- [Added] Changed DatePicker placeholder
|
package/dist/DatePicker.js
CHANGED
|
@@ -235,10 +235,10 @@ var CustomNavbar = function CustomNavbar(_ref3) {
|
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
var enabledPreviousArrow = useMemo(function () {
|
|
238
|
-
return new Date(previousMonth.toDateString()) >= moment(disabledDays.before).startOf("month");
|
|
238
|
+
return !(disabledDays !== null && disabledDays !== void 0 && disabledDays.before) || new Date(previousMonth.toDateString()) >= moment(disabledDays.before).startOf("month");
|
|
239
239
|
}, [previousMonth, disabledDays]);
|
|
240
240
|
var enabledNextArrow = useMemo(function () {
|
|
241
|
-
return new Date(nextMonth.toDateString()) <= moment(disabledDays.after).startOf("month");
|
|
241
|
+
return !(disabledDays !== null && disabledDays !== void 0 && disabledDays.after) || new Date(nextMonth.toDateString()) <= moment(disabledDays.after).startOf("month");
|
|
242
242
|
}, [nextMonth, disabledDays]);
|
|
243
243
|
var disabledStyle = {
|
|
244
244
|
fill: gray06,
|
|
@@ -344,7 +344,7 @@ var MonthPicker = function MonthPicker(_ref4) {
|
|
|
344
344
|
year: selectedYear,
|
|
345
345
|
month: month
|
|
346
346
|
}).startOf("month");
|
|
347
|
-
return monthDate < moment(before).startOf("month") || monthDate > moment(after).startOf("month");
|
|
347
|
+
return before && monthDate < moment(before).startOf("month") || after && monthDate > moment(after).startOf("month");
|
|
348
348
|
};
|
|
349
349
|
|
|
350
350
|
var months = moment.monthsShort();
|
package/dist/Textarea.js
CHANGED
|
@@ -6,7 +6,8 @@ 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/* eslint-disable react/require-default-props */
|
|
10
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
10
11
|
import styled from "styled-components";
|
|
11
12
|
import { active, gray01, gray04, gray06 } from "@happeouikit/colors";
|
|
12
13
|
import PropTypes from "prop-types";
|
|
@@ -26,6 +27,30 @@ var Textarea = function Textarea(_ref) {
|
|
|
26
27
|
var accessibility = label ? {
|
|
27
28
|
"aria-labelledby": id
|
|
28
29
|
} : {};
|
|
30
|
+
var textareaRef = useRef(null);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
var textarea = textareaRef.current;
|
|
33
|
+
|
|
34
|
+
if (textarea) {
|
|
35
|
+
textarea.style.height = "".concat(Math.min(textarea.scrollHeight, props.maxHeight), "px");
|
|
36
|
+
}
|
|
37
|
+
}, [props.maxHeight]);
|
|
38
|
+
|
|
39
|
+
var onChange = function onChange(event) {
|
|
40
|
+
// Handle auto height
|
|
41
|
+
if (props.autoHeight) {
|
|
42
|
+
var target = event.target; // First set height to inherit to allow textarea to contract
|
|
43
|
+
|
|
44
|
+
target.style.height = "inherit";
|
|
45
|
+
target.style.height = "".concat(target.scrollHeight, "px");
|
|
46
|
+
} // call props.onChange if exists
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if (typeof props.onChange === "function") {
|
|
50
|
+
props.onChange(event);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
29
54
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
30
55
|
children: [!!label && /*#__PURE__*/_jsx(Label, {
|
|
31
56
|
id: id,
|
|
@@ -33,16 +58,27 @@ var Textarea = function Textarea(_ref) {
|
|
|
33
58
|
color: gray01,
|
|
34
59
|
children: label
|
|
35
60
|
})
|
|
36
|
-
}), /*#__PURE__*/_jsx(StyledTextarea, _objectSpread(_objectSpread({
|
|
61
|
+
}), /*#__PURE__*/_jsx(StyledTextarea, _objectSpread(_objectSpread(_objectSpread({
|
|
62
|
+
ref: textareaRef,
|
|
37
63
|
cols: cols,
|
|
38
64
|
rows: rows
|
|
39
|
-
}, accessibility), props)
|
|
65
|
+
}, accessibility), props), {}, {
|
|
66
|
+
style: _objectSpread(_objectSpread({}, props.style), {}, {
|
|
67
|
+
maxHeight: props.maxHeight
|
|
68
|
+
}),
|
|
69
|
+
onChange: onChange
|
|
70
|
+
}))]
|
|
40
71
|
});
|
|
41
72
|
};
|
|
42
73
|
|
|
43
74
|
Textarea.propTypes = {
|
|
44
75
|
rows: PropTypes.number,
|
|
45
|
-
cols: PropTypes.number
|
|
76
|
+
cols: PropTypes.number,
|
|
77
|
+
autoHeight: PropTypes.bool,
|
|
78
|
+
maxHeight: PropTypes.number
|
|
79
|
+
};
|
|
80
|
+
Textarea.defaultProps = {
|
|
81
|
+
maxHeight: 9999
|
|
46
82
|
};
|
|
47
83
|
var StyledTextarea = styled.textarea.withConfig({
|
|
48
84
|
displayName: "Textarea__StyledTextarea",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happeouikit/form-elements",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -44,5 +44,6 @@
|
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"gitHead": "f2782af0f34d915128c836831456ed9cf9c7b090"
|
|
48
49
|
}
|